diff --git a/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp b/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp index eea013b90..c99abe657 100644 --- a/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp +++ b/jni/NativeFormats/fbreader/src/formats/xhtml/XHTMLReader.cpp @@ -585,7 +585,7 @@ void XHTMLReader::beginParagraph() { myModelReader.addControl(**it); doBlockSpaceBefore = doBlockSpaceBefore || - (*it)->lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_BEFORE); + (*it)->isLengthSupported(ZLTextStyleEntry::LENGTH_SPACE_BEFORE); } if (doBlockSpaceBefore) { @@ -604,7 +604,7 @@ void XHTMLReader::endParagraph() { for (std::vector >::const_iterator it = myStyleEntryStack.begin(); it != myStyleEntryStack.end() - myStylesToRemove; ++it) { doBlockSpaceAfter = doBlockSpaceAfter || - (*it)->lengthSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER); + (*it)->isLengthSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER); } if (doBlockSpaceAfter) { ZLTextStyleEntry blockingEntry; diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp b/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp index 4c6efc29c..44789c393 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextModel.cpp @@ -285,19 +285,18 @@ void ZLTextModel::addControl(const ZLTextStyleEntry &entry) { *address++ = 0; ZLCachedMemoryAllocator::writeUInt32(address, entry.myMask); - address += 4;*/ + address += 4; - // Pack myLengths array so: + // Pack myLengths array in following manner: // - // 1) for every two elements there is a word with those Units (two Units + // 1) for each two elements there is a word with those Units (two Units // in two bytes) followed by two words with those Sizes; // - // 2) if there is one last element (without a pair) => then another one - // word is appended with only one Unit (in the first byte) followed by + // 2) if myLengths.size() is odd (that means the last element has no paired one) + // one more word is appended with only one Unit (in the first byte) followed by // a word containing corresponding Size. // - /*const int lengthMinusOne = ZLTextStyleEntry::NUMBER_OF_LENGTHS - 1; - for (int i = 0; i < lengthMinusOne; i += 2) { + for (int i = 0; i < ZLTextStyleEntry::NUMBER_OF_LENGTHS - 1; i += 2) { const ZLTextStyleEntry::LengthType &l0 = entry.myLengths[i]; const ZLTextStyleEntry::LengthType &l1 = entry.myLengths[i + 1]; *address++ = l0.Unit; @@ -307,8 +306,8 @@ void ZLTextModel::addControl(const ZLTextStyleEntry &entry) { ZLCachedMemoryAllocator::writeUInt16(address, l1.Size); address += 2; } - if (ZLTextStyleEntry::NUMBER_OF_LENGTHS % 2) { - const ZLTextStyleEntry::LengthType &l0 = entry.myLengths[lengthMinusOne]; + if (ZLTextStyleEntry::NUMBER_OF_LENGTHS % 2 == 1) { + const ZLTextStyleEntry::LengthType &l0 = entry.myLengths[ZLTextStyleEntry::NUMBER_OF_LENGTHS - 1]; *address++ = l0.Unit; *address++ = 0; ZLCachedMemoryAllocator::writeUInt16(address, l0.Size); @@ -323,7 +322,8 @@ void ZLTextModel::addControl(const ZLTextStyleEntry &entry) { memcpy(address + 2, &fontFamily.front(), fontFamilyLen); } myParagraphs.back()->addEntry(myLastEntryStart); - ++myParagraphLengths.back();*/ + ++myParagraphLengths.back(); + */ } void ZLTextModel::addHyperlinkControl(ZLTextKind textKind, ZLHyperlinkType hyperlinkType, const std::string &label) { diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.cpp b/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.cpp index 3b32bd302..7f0ed136f 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.cpp +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.cpp @@ -17,7 +17,7 @@ * 02110-1301, USA. */ -#include +#include #include @@ -27,7 +27,6 @@ #include "ZLCachedMemoryAllocator.h" #include "ZLTextParagraph.h" - const shared_ptr ResetBidiEntry::Instance = new ResetBidiEntry(); short ZLTextStyleEntry::length(Length name, const Metrics &metrics) const { @@ -79,7 +78,7 @@ ZLTextStyleEntry::ZLTextStyleEntry(char *address) { myFontModifier = *address++; myAlignmentType = (ZLTextAlignmentType)*address++; myFontSizeMag = *address++; - if (fontFamilySupported()) { + if (isFontFamilySupported()) { const size_t len = ZLCachedMemoryAllocator::readUInt16(address); ZLUnicodeUtil::Ucs2Char *ucs2data = (ZLUnicodeUtil::Ucs2Char *)(address + 2); ZLUnicodeUtil::Ucs2String ucs2str(ucs2data, ucs2data + len); @@ -182,7 +181,7 @@ void ZLTextParagraph::Iterator::next() { case ZLTextParagraphEntry::STYLE_ENTRY: { unsigned int mask = ZLCachedMemoryAllocator::readUInt32(myPointer + 2); - bool withFontFamily = (mask & ZLTextStyleEntry::SUPPORT_FONT_FAMILY) == ZLTextStyleEntry::SUPPORT_FONT_FAMILY; + bool withFontFamily = (mask & ZLTextStyleEntry::SUPPORTS_FONT_FAMILY) == ZLTextStyleEntry::SUPPORTS_FONT_FAMILY; myPointer += 10 + 2 * (ZLTextStyleEntry::NUMBER_OF_LENGTHS + (ZLTextStyleEntry::NUMBER_OF_LENGTHS + 1) / 2); diff --git a/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h b/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h index 6ddb4cff9..56d5ba180 100644 --- a/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h +++ b/jni/NativeFormats/zlibrary/text/src/model/ZLTextParagraph.h @@ -99,11 +99,11 @@ public: bool isEmpty() const; - bool lengthSupported(Length name) const; + bool isLengthSupported(Length name) const; short length(Length name, const Metrics &metrics) const; void setLength(Length name, short length, SizeUnit unit); - bool alignmentTypeSupported() const; + bool isAlignmentTypeSupported() const; ZLTextAlignmentType alignmentType() const; void setAlignmentType(ZLTextAlignmentType alignmentType); @@ -111,17 +111,17 @@ public: unsigned char fontModifier() const; void setFontModifier(ZLTextFontModifier style, bool set); - bool fontSizeSupported() const; + bool isFontSizeMagSupported() const; signed char fontSizeMag() const; void setFontSizeMag(signed char fontSizeMag); - bool fontFamilySupported() const; + bool isFontFamilySupported() const; const std::string &fontFamily() const; void setFontFamily(const std::string &fontFamily); - static const unsigned int SUPPORT_ALIGNMENT_TYPE = 1U << NUMBER_OF_LENGTHS; - static const unsigned int SUPPORT_FONT_SIZE = 1U << (NUMBER_OF_LENGTHS + 1); - static const unsigned int SUPPORT_FONT_FAMILY = 1U << (NUMBER_OF_LENGTHS + 2); + static const unsigned int SUPPORTS_ALIGNMENT_TYPE = 1U << NUMBER_OF_LENGTHS; + static const unsigned int SUPPORTS_FONT_SIZE_MAG = 1U << (NUMBER_OF_LENGTHS + 1); + static const unsigned int SUPPORTS_FONT_FAMILY = 1U << (NUMBER_OF_LENGTHS + 2); private: unsigned int myMask; @@ -337,16 +337,16 @@ inline ZLTextStyleEntry::Metrics::Metrics(int fontSize, int fontXHeight, int ful inline bool ZLTextStyleEntry::isEmpty() const { return myMask == 0; } -inline bool ZLTextStyleEntry::lengthSupported(Length name) const { return (myMask & (1U << name)) != 0; } +inline bool ZLTextStyleEntry::isLengthSupported(Length name) const { return (myMask & (1U << name)) != 0; } inline void ZLTextStyleEntry::setLength(Length name, short length, SizeUnit unit) { myLengths[name].Size = length; myLengths[name].Unit = unit; myMask |= 1U << name; } -inline bool ZLTextStyleEntry::alignmentTypeSupported() const { return (myMask & SUPPORT_ALIGNMENT_TYPE) == SUPPORT_ALIGNMENT_TYPE; } +inline bool ZLTextStyleEntry::isAlignmentTypeSupported() const { return (myMask & SUPPORTS_ALIGNMENT_TYPE) == SUPPORTS_ALIGNMENT_TYPE; } inline ZLTextAlignmentType ZLTextStyleEntry::alignmentType() const { return myAlignmentType; } -inline void ZLTextStyleEntry::setAlignmentType(ZLTextAlignmentType alignmentType) { myAlignmentType = alignmentType; myMask |= SUPPORT_ALIGNMENT_TYPE; } +inline void ZLTextStyleEntry::setAlignmentType(ZLTextAlignmentType alignmentType) { myAlignmentType = alignmentType; myMask |= SUPPORTS_ALIGNMENT_TYPE; } inline unsigned char ZLTextStyleEntry::supportedFontModifier() const { return mySupportedFontModifier; } inline unsigned char ZLTextStyleEntry::fontModifier() const { return myFontModifier; } @@ -359,13 +359,13 @@ inline void ZLTextStyleEntry::setFontModifier(ZLTextFontModifier style, bool set mySupportedFontModifier |= style; } -inline bool ZLTextStyleEntry::fontSizeSupported() const { return (myMask & SUPPORT_FONT_SIZE) == SUPPORT_FONT_SIZE; } +inline bool ZLTextStyleEntry::isFontSizeMagSupported() const { return (myMask & SUPPORTS_FONT_SIZE_MAG) == SUPPORTS_FONT_SIZE_MAG; } inline signed char ZLTextStyleEntry::fontSizeMag() const { return myFontSizeMag; } -inline void ZLTextStyleEntry::setFontSizeMag(signed char fontSizeMag) { myFontSizeMag = fontSizeMag; myMask |= SUPPORT_FONT_SIZE; } +inline void ZLTextStyleEntry::setFontSizeMag(signed char fontSizeMag) { myFontSizeMag = fontSizeMag; myMask |= SUPPORTS_FONT_SIZE_MAG; } -inline bool ZLTextStyleEntry::fontFamilySupported() const { return (myMask & SUPPORT_FONT_FAMILY) == SUPPORT_FONT_FAMILY; } +inline bool ZLTextStyleEntry::isFontFamilySupported() const { return (myMask & SUPPORTS_FONT_FAMILY) == SUPPORTS_FONT_FAMILY; } inline const std::string &ZLTextStyleEntry::fontFamily() const { return myFontFamily; } -inline void ZLTextStyleEntry::setFontFamily(const std::string &fontFamily) { myFontFamily = fontFamily; myMask |= SUPPORT_FONT_FAMILY; } +inline void ZLTextStyleEntry::setFontFamily(const std::string &fontFamily) { myFontFamily = fontFamily; myMask |= SUPPORTS_FONT_FAMILY; } inline ZLTextControlEntry::ZLTextControlEntry(ZLTextKind kind, bool isStart) : myKind(kind), myStart(isStart) {} inline ZLTextControlEntry::~ZLTextControlEntry() {}