Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

#54: Fix incorrect assertions for spine item references #107

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ePub3/ePub/cfi.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class CFI
/// Bitfield values identifying special status for a CFI component.
enum Flags : uint8_t
{
Qualifier = 1<<0, ///< The component contains an `id` or `idref` qualifier, i.e. `[bob]`
Qualifier = 1<<0, ///< The component contains an `id` qualifier, i.e. `[bob]`
CharacterOffset = 1<<1, ///< The component has a character offset value, i.e. `:12`
TemporalOffset = 1<<2, ///< The component has a temporal offset value, i.e. `~87.24`.
SpatialOffset = 1<<3, ///< The component has a spatial offset value, i.e. `@150:220`
Expand Down Expand Up @@ -239,7 +239,7 @@ class CFI

uint8_t flags; ///< The bitfield containing values from the Flags enumeration.
uint32_t nodeIndex; ///< The numeric index for the node identified by component.
string qualifier; ///< The value of any `id` or `idref` qualifier.
string qualifier; ///< The value of any `id` qualifier.
uint32_t characterOffset; ///< The value of any character offset.
float temporalOffset; ///< The value, in seconds, of any temporal offset.
Point spatialOffset; ///< The value of any spatial offset.
Expand Down
11 changes: 8 additions & 3 deletions ePub3/ePub/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ unique_ptr<ByteStream> PackageBase::ReadStreamForItemAtPath(const string &path)
}
shared_ptr<SpineItem> PackageBase::ConfirmOrCorrectSpineItemQualifier(shared_ptr<SpineItem> pItem, CFI::Component *pComponent) const
{
if ( pComponent->HasQualifier() && pItem->Idref() != pComponent->qualifier )
if ( pComponent->HasQualifier() && pItem->Identifier() != pComponent->qualifier )
{
// find the item with the qualifier
pItem = _spine;
uint32_t idx = 2;

while ( pItem != nullptr )
{
if ( pItem->Idref() == pComponent->qualifier )
if ( pItem->Identifier() == pComponent->qualifier )
{
// found it-- correct the CFI
pComponent->nodeIndex = idx;
Expand Down Expand Up @@ -1098,7 +1098,12 @@ const CFI Package::CFIForSpineItem(shared_ptr<SpineItem> item) const
{
CFI result;
result._components.emplace_back(_spineCFIIndex);
result._components.emplace_back(_Str((item->Index()+1)*2, "[", item->Idref(), "]!"));
if ( item->Identifier().empty() )
{
result._components.emplace_back(_Str((item->Index()+1)*2, "!"));
} else {
result._components.emplace_back(_Str((item->Index()+1)*2, "[", item->Identifier(), "]!"));
}
return result;
}
shared_ptr<ManifestItem> Package::ManifestItemForCFI(ePub3::CFI &cfi, CFI* pRemainingCFI) const
Expand Down