mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
style entry writing to the model cache
This commit is contained in:
parent
2422f080a8
commit
74cb4cf7be
11 changed files with 234 additions and 180 deletions
|
@ -70,7 +70,7 @@ static void parseLength(const std::string &toParse, short &size, ZLTextStyleEntr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const AttributeMap &map, const std::string &attributeName) {
|
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Feature fetureId, const AttributeMap &map, const std::string &attributeName) {
|
||||||
StyleSheetTable::AttributeMap::const_iterator it = map.find(attributeName);
|
StyleSheetTable::AttributeMap::const_iterator it = map.find(attributeName);
|
||||||
if (it == map.end()) {
|
if (it == map.end()) {
|
||||||
return;
|
return;
|
||||||
|
@ -80,7 +80,7 @@ void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Lengt
|
||||||
short size;
|
short size;
|
||||||
ZLTextStyleEntry::SizeUnit unit;
|
ZLTextStyleEntry::SizeUnit unit;
|
||||||
parseLength(values[0], size, unit);
|
parseLength(values[0], size, unit);
|
||||||
entry.setLength(name, size, unit);
|
entry.setLength(fetureId, size, unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,19 +190,19 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
||||||
const std::vector<std::string> &fontSize = values(styles, "font-size");
|
const std::vector<std::string> &fontSize = values(styles, "font-size");
|
||||||
if (!fontSize.empty()) {
|
if (!fontSize.empty()) {
|
||||||
if (fontSize[0] == "xx-small") {
|
if (fontSize[0] == "xx-small") {
|
||||||
entry->setFontSizeMag(-3);
|
entry->setFontSizeMagnification(-3);
|
||||||
} else if (fontSize[0] == "x-small") {
|
} else if (fontSize[0] == "x-small") {
|
||||||
entry->setFontSizeMag(-2);
|
entry->setFontSizeMagnification(-2);
|
||||||
} else if (fontSize[0] == "small") {
|
} else if (fontSize[0] == "small") {
|
||||||
entry->setFontSizeMag(-1);
|
entry->setFontSizeMagnification(-1);
|
||||||
} else if (fontSize[0] == "medium") {
|
} else if (fontSize[0] == "medium") {
|
||||||
entry->setFontSizeMag(0);
|
entry->setFontSizeMagnification(0);
|
||||||
} else if (fontSize[0] == "large") {
|
} else if (fontSize[0] == "large") {
|
||||||
entry->setFontSizeMag(1);
|
entry->setFontSizeMagnification(1);
|
||||||
} else if (fontSize[0] == "x-large") {
|
} else if (fontSize[0] == "x-large") {
|
||||||
entry->setFontSizeMag(2);
|
entry->setFontSizeMagnification(2);
|
||||||
} else if (fontSize[0] == "xx-large") {
|
} else if (fontSize[0] == "xx-large") {
|
||||||
entry->setFontSizeMag(3);
|
entry->setFontSizeMagnification(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map);
|
void addMap(const std::string &tag, const std::string &aClass, const AttributeMap &map);
|
||||||
|
|
||||||
static void setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const AttributeMap &map, const std::string &attributeName);
|
static void setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Feature featureId, const AttributeMap &map, const std::string &attributeName);
|
||||||
static const std::vector<std::string> &values(const AttributeMap &map, const std::string &name);
|
static const std::vector<std::string> &values(const AttributeMap &map, const std::string &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -585,7 +585,7 @@ void XHTMLReader::beginParagraph() {
|
||||||
myModelReader.addControl(**it);
|
myModelReader.addControl(**it);
|
||||||
doBlockSpaceBefore =
|
doBlockSpaceBefore =
|
||||||
doBlockSpaceBefore ||
|
doBlockSpaceBefore ||
|
||||||
(*it)->isLengthSupported(ZLTextStyleEntry::LENGTH_SPACE_BEFORE);
|
(*it)->isFeatureSupported(ZLTextStyleEntry::LENGTH_SPACE_BEFORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doBlockSpaceBefore) {
|
if (doBlockSpaceBefore) {
|
||||||
|
@ -604,7 +604,7 @@ void XHTMLReader::endParagraph() {
|
||||||
for (std::vector<shared_ptr<ZLTextStyleEntry> >::const_iterator it = myStyleEntryStack.begin(); it != myStyleEntryStack.end() - myStylesToRemove; ++it) {
|
for (std::vector<shared_ptr<ZLTextStyleEntry> >::const_iterator it = myStyleEntryStack.begin(); it != myStyleEntryStack.end() - myStylesToRemove; ++it) {
|
||||||
doBlockSpaceAfter =
|
doBlockSpaceAfter =
|
||||||
doBlockSpaceAfter ||
|
doBlockSpaceAfter ||
|
||||||
(*it)->isLengthSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER);
|
(*it)->isFeatureSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER);
|
||||||
}
|
}
|
||||||
if (doBlockSpaceAfter) {
|
if (doBlockSpaceAfter) {
|
||||||
ZLTextStyleEntry blockingEntry;
|
ZLTextStyleEntry blockingEntry;
|
||||||
|
|
29
jni/NativeFormats/zlibrary/core/src/util/ZLBoolean3.h
Normal file
29
jni/NativeFormats/zlibrary/core/src/util/ZLBoolean3.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ZLBOOLEAN3_H__
|
||||||
|
#define __ZLBOOLEAN3_H__
|
||||||
|
|
||||||
|
enum ZLBoolean3 {
|
||||||
|
B3_FALSE = 0,
|
||||||
|
B3_TRUE = 1,
|
||||||
|
B3_UNDEFINED = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __ZLBOOLEAN3_H__ */
|
|
@ -25,9 +25,12 @@
|
||||||
//#include <ZLSearchUtil.h>
|
//#include <ZLSearchUtil.h>
|
||||||
//#include <ZLLanguageUtil.h>
|
//#include <ZLLanguageUtil.h>
|
||||||
#include <ZLUnicodeUtil.h>
|
#include <ZLUnicodeUtil.h>
|
||||||
|
//#include <ZLStringUtil.h>
|
||||||
|
//#include <ZLLogger.h>
|
||||||
|
|
||||||
#include "ZLTextModel.h"
|
#include "ZLTextModel.h"
|
||||||
#include "ZLTextParagraph.h"
|
#include "ZLTextParagraph.h"
|
||||||
|
#include "ZLTextStyleEntry.h"
|
||||||
|
|
||||||
ZLTextModel::ZLTextModel(const std::string &id, const std::string &language, const size_t rowSize,
|
ZLTextModel::ZLTextModel(const std::string &id, const std::string &language, const size_t rowSize,
|
||||||
const std::string &directoryName, const std::string &fileExtension) :
|
const std::string &directoryName, const std::string &fileExtension) :
|
||||||
|
@ -265,65 +268,73 @@ void ZLTextModel::addControl(ZLTextKind textKind, bool isStart) {
|
||||||
++myParagraphLengths.back();
|
++myParagraphLengths.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//static int EntryCount = 0;
|
||||||
|
//static int EntryLen = 0;
|
||||||
|
|
||||||
void ZLTextModel::addControl(const ZLTextStyleEntry &entry) {
|
void ZLTextModel::addControl(const ZLTextStyleEntry &entry) {
|
||||||
/*
|
// +++ calculating entry size
|
||||||
size_t len = 10 + 2 * (ZLTextStyleEntry::NUMBER_OF_LENGTHS +
|
size_t len = 4; // entry type + feature mask
|
||||||
(ZLTextStyleEntry::NUMBER_OF_LENGTHS + 1) / 2);
|
for (int i = 0; i < ZLTextStyleEntry::NUMBER_OF_LENGTHS; ++i) {
|
||||||
|
if (entry.isFeatureSupported((ZLTextStyleEntry::Feature)i)) {
|
||||||
ZLUnicodeUtil::Ucs2String fontFamily;
|
len += 4; // each supported length
|
||||||
size_t fontFamilyLen = 0;
|
}
|
||||||
if (entry.fontFamilySupported()) {
|
|
||||||
ZLUnicodeUtil::utf8ToUcs2(fontFamily, entry.fontFamily());
|
|
||||||
fontFamilyLen = fontFamily.size() * 2;
|
|
||||||
len += 2 + fontFamilyLen;
|
|
||||||
}
|
}
|
||||||
|
if (entry.isFeatureSupported(ZLTextStyleEntry::ALIGNMENT_TYPE) ||
|
||||||
|
entry.isFeatureSupported(ZLTextStyleEntry::FONT_SIZE_MAGNIFICATION)) {
|
||||||
|
len += 2;
|
||||||
|
}
|
||||||
|
ZLUnicodeUtil::Ucs2String fontFamily;
|
||||||
|
if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_FAMILY)) {
|
||||||
|
ZLUnicodeUtil::utf8ToUcs2(fontFamily, entry.fontFamily());
|
||||||
|
len += 2 + fontFamily.size() * 2;
|
||||||
|
}
|
||||||
|
if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_STYLE_MODIFIER)) {
|
||||||
|
len += 2;
|
||||||
|
}
|
||||||
|
// --- calculating entry size
|
||||||
|
|
||||||
|
/*
|
||||||
|
EntryCount += 1;
|
||||||
|
EntryLen += len;
|
||||||
|
std::string debug = "style entry counter: ";
|
||||||
|
ZLStringUtil::appendNumber(debug, EntryCount);
|
||||||
|
debug += "/";
|
||||||
|
ZLStringUtil::appendNumber(debug, EntryLen);
|
||||||
|
ZLLogger::Instance().println(ZLLogger::DEFAULT_CLASS, debug);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +++ writing entry
|
||||||
myLastEntryStart = myAllocator->allocate(len);
|
myLastEntryStart = myAllocator->allocate(len);
|
||||||
char *address = myLastEntryStart;
|
char *address = myLastEntryStart;
|
||||||
|
|
||||||
*address++ = ZLTextParagraphEntry::STYLE_ENTRY;
|
*address++ = ZLTextParagraphEntry::STYLE_ENTRY;
|
||||||
*address++ = 0;
|
*address++ = 0;
|
||||||
|
address = ZLCachedMemoryAllocator::writeUInt16(address, entry.myFeatureMask);
|
||||||
|
|
||||||
ZLCachedMemoryAllocator::writeUInt32(address, entry.myMask);
|
for (int i = 0; i < ZLTextStyleEntry::NUMBER_OF_LENGTHS; ++i) {
|
||||||
address += 4;
|
if (entry.isFeatureSupported((ZLTextStyleEntry::Feature)i)) {
|
||||||
|
const ZLTextStyleEntry::LengthType &len = entry.myLengths[i];
|
||||||
|
address = ZLCachedMemoryAllocator::writeUInt16(address, len.Size);
|
||||||
|
*address++ = len.Unit;
|
||||||
|
*address++ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.isFeatureSupported(ZLTextStyleEntry::ALIGNMENT_TYPE) ||
|
||||||
|
entry.isFeatureSupported(ZLTextStyleEntry::FONT_SIZE_MAGNIFICATION)) {
|
||||||
|
*address++ = entry.myAlignmentType;
|
||||||
|
*address++ = entry.myFontSizeMagnification;
|
||||||
|
}
|
||||||
|
if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_FAMILY)) {
|
||||||
|
address = ZLCachedMemoryAllocator::writeString(address, fontFamily);
|
||||||
|
}
|
||||||
|
if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_STYLE_MODIFIER)) {
|
||||||
|
*address++ = entry.mySupportedFontModifier;
|
||||||
|
*address++ = entry.myFontModifier;
|
||||||
|
}
|
||||||
|
// --- writing entry
|
||||||
|
|
||||||
// Pack myLengths array in following manner:
|
|
||||||
//
|
|
||||||
// 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 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.
|
|
||||||
//
|
|
||||||
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;
|
|
||||||
*address++ = l1.Unit;
|
|
||||||
ZLCachedMemoryAllocator::writeUInt16(address, l0.Size);
|
|
||||||
address += 2;
|
|
||||||
ZLCachedMemoryAllocator::writeUInt16(address, l1.Size);
|
|
||||||
address += 2;
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
address += 2;
|
|
||||||
}
|
|
||||||
*address++ = entry.mySupportedFontModifier;
|
|
||||||
*address++ = entry.myFontModifier;
|
|
||||||
*address++ = entry.myAlignmentType;
|
|
||||||
*address++ = entry.myFontSizeMag;
|
|
||||||
if (entry.fontFamilySupported()) {
|
|
||||||
ZLCachedMemoryAllocator::writeUInt16(address, fontFamily.size());
|
|
||||||
memcpy(address + 2, &fontFamily.front(), fontFamilyLen);
|
|
||||||
}
|
|
||||||
myParagraphs.back()->addEntry(myLastEntryStart);
|
myParagraphs.back()->addEntry(myLastEntryStart);
|
||||||
++myParagraphLengths.back();
|
++myParagraphLengths.back();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLTextModel::addHyperlinkControl(ZLTextKind textKind, ZLHyperlinkType hyperlinkType, const std::string &label) {
|
void ZLTextModel::addHyperlinkControl(ZLTextKind textKind, ZLHyperlinkType hyperlinkType, const std::string &label) {
|
||||||
|
|
|
@ -30,32 +30,33 @@
|
||||||
|
|
||||||
const shared_ptr<ZLTextParagraphEntry> ResetBidiEntry::Instance = new ResetBidiEntry();
|
const shared_ptr<ZLTextParagraphEntry> ResetBidiEntry::Instance = new ResetBidiEntry();
|
||||||
|
|
||||||
short ZLTextStyleEntry::length(Length name, const Metrics &metrics) const {
|
short ZLTextStyleEntry::length(Feature featureId, const Metrics &metrics) const {
|
||||||
switch (myLengths[name].Unit) {
|
switch (myLengths[featureId].Unit) {
|
||||||
default:
|
default:
|
||||||
case SIZE_UNIT_PIXEL:
|
case SIZE_UNIT_PIXEL:
|
||||||
return myLengths[name].Size;
|
return myLengths[featureId].Size;
|
||||||
case SIZE_UNIT_EM_100:
|
case SIZE_UNIT_EM_100:
|
||||||
return (myLengths[name].Size * metrics.FontSize + 50) / 100;
|
return (myLengths[featureId].Size * metrics.FontSize + 50) / 100;
|
||||||
case SIZE_UNIT_EX_100:
|
case SIZE_UNIT_EX_100:
|
||||||
return (myLengths[name].Size * metrics.FontXHeight + 50) / 100;
|
return (myLengths[featureId].Size * metrics.FontXHeight + 50) / 100;
|
||||||
case SIZE_UNIT_PERCENT:
|
case SIZE_UNIT_PERCENT:
|
||||||
switch (name) {
|
switch (featureId) {
|
||||||
default:
|
default:
|
||||||
case LENGTH_LEFT_INDENT:
|
case LENGTH_LEFT_INDENT:
|
||||||
case LENGTH_RIGHT_INDENT:
|
case LENGTH_RIGHT_INDENT:
|
||||||
case LENGTH_FIRST_LINE_INDENT_DELTA:
|
case LENGTH_FIRST_LINE_INDENT_DELTA:
|
||||||
return (myLengths[name].Size * metrics.FullWidth + 50) / 100;
|
return (myLengths[featureId].Size * metrics.FullWidth + 50) / 100;
|
||||||
case LENGTH_SPACE_BEFORE:
|
case LENGTH_SPACE_BEFORE:
|
||||||
case LENGTH_SPACE_AFTER:
|
case LENGTH_SPACE_AFTER:
|
||||||
return (myLengths[name].Size * metrics.FullHeight + 50) / 100;
|
return (myLengths[featureId].Size * metrics.FullHeight + 50) / 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
ZLTextStyleEntry::ZLTextStyleEntry(char *address) {
|
ZLTextStyleEntry::ZLTextStyleEntry(char *address) {
|
||||||
myMask = ZLCachedMemoryAllocator::readUInt32(address);
|
myFeatureMask = ZLCachedMemoryAllocator::readUInt16(address);
|
||||||
address += 4;
|
address += 2;
|
||||||
|
|
||||||
const int lengthMinusOne = ZLTextStyleEntry::NUMBER_OF_LENGTHS - 1;
|
const int lengthMinusOne = ZLTextStyleEntry::NUMBER_OF_LENGTHS - 1;
|
||||||
for (int i = 0; i < lengthMinusOne; i += 2) {
|
for (int i = 0; i < lengthMinusOne; i += 2) {
|
||||||
|
@ -78,14 +79,15 @@ ZLTextStyleEntry::ZLTextStyleEntry(char *address) {
|
||||||
mySupportedFontModifier = *address++;
|
mySupportedFontModifier = *address++;
|
||||||
myFontModifier = *address++;
|
myFontModifier = *address++;
|
||||||
myAlignmentType = (ZLTextAlignmentType)*address++;
|
myAlignmentType = (ZLTextAlignmentType)*address++;
|
||||||
myFontSizeMag = *address++;
|
myFontSizeMagnification = *address++;
|
||||||
if (isFontFamilySupported()) {
|
if (isFeatureSupported(FONT_FAMILY)) {
|
||||||
const size_t len = ZLCachedMemoryAllocator::readUInt16(address);
|
const size_t len = ZLCachedMemoryAllocator::readUInt16(address);
|
||||||
ZLUnicodeUtil::Ucs2Char *ucs2data = (ZLUnicodeUtil::Ucs2Char *)(address + 2);
|
ZLUnicodeUtil::Ucs2Char *ucs2data = (ZLUnicodeUtil::Ucs2Char *)(address + 2);
|
||||||
ZLUnicodeUtil::Ucs2String ucs2str(ucs2data, ucs2data + len);
|
ZLUnicodeUtil::Ucs2String ucs2str(ucs2data, ucs2data + len);
|
||||||
ZLUnicodeUtil::ucs2ToUtf8(myFontFamily, ucs2str);
|
ZLUnicodeUtil::ucs2ToUtf8(myFontFamily, ucs2str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ZLTextControlEntryPool ZLTextControlEntryPool::Pool;
|
ZLTextControlEntryPool ZLTextControlEntryPool::Pool;
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ shared_ptr<ZLTextParagraphEntry> ZLTextControlEntryPool::controlEntry(ZLTextKind
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
ZLTextHyperlinkControlEntry::ZLTextHyperlinkControlEntry(const char *address) : ZLTextControlEntry((ZLTextKind)*address, true), myHyperlinkType((ZLHyperlinkType)*(address + 1)) {
|
ZLTextHyperlinkControlEntry::ZLTextHyperlinkControlEntry(const char *address) : ZLTextControlEntry((ZLTextKind)*address, true), myHyperlinkType((ZLHyperlinkType)*(address + 1)) {
|
||||||
const size_t len = ZLCachedMemoryAllocator::readUInt16(address + 2);
|
const size_t len = ZLCachedMemoryAllocator::readUInt16(address + 2);
|
||||||
ZLUnicodeUtil::Ucs2Char *ucs2data = (ZLUnicodeUtil::Ucs2Char *)(address + 4);
|
ZLUnicodeUtil::Ucs2Char *ucs2data = (ZLUnicodeUtil::Ucs2Char *)(address + 4);
|
||||||
|
@ -122,7 +125,6 @@ ImageEntry::ImageEntry(const char *address) {
|
||||||
ZLUnicodeUtil::ucs2ToUtf8(myId, ucs2str);
|
ZLUnicodeUtil::ucs2ToUtf8(myId, ucs2str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const shared_ptr<ZLTextParagraphEntry> ZLTextParagraph::Iterator::entry() const {
|
const shared_ptr<ZLTextParagraphEntry> ZLTextParagraph::Iterator::entry() const {
|
||||||
if (myEntry.isNull()) {
|
if (myEntry.isNull()) {
|
||||||
switch (*myPointer) {
|
switch (*myPointer) {
|
||||||
|
@ -182,7 +184,7 @@ void ZLTextParagraph::Iterator::next() {
|
||||||
case ZLTextParagraphEntry::STYLE_ENTRY:
|
case ZLTextParagraphEntry::STYLE_ENTRY:
|
||||||
{
|
{
|
||||||
unsigned int mask = ZLCachedMemoryAllocator::readUInt32(myPointer + 2);
|
unsigned int mask = ZLCachedMemoryAllocator::readUInt32(myPointer + 2);
|
||||||
bool withFontFamily = (mask & ZLTextStyleEntry::SUPPORTS_FONT_FAMILY) == ZLTextStyleEntry::SUPPORTS_FONT_FAMILY;
|
bool withFontFamily = (mask & (1 << ZLTextStyleEntry::FONT_FAMILY)) != 0;
|
||||||
|
|
||||||
myPointer += 10 + 2 * (ZLTextStyleEntry::NUMBER_OF_LENGTHS +
|
myPointer += 10 + 2 * (ZLTextStyleEntry::NUMBER_OF_LENGTHS +
|
||||||
(ZLTextStyleEntry::NUMBER_OF_LENGTHS + 1) / 2);
|
(ZLTextStyleEntry::NUMBER_OF_LENGTHS + 1) / 2);
|
||||||
|
@ -234,7 +236,7 @@ size_t ZLTextParagraph::characterNumber() const {
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ZLTextTreeParagraph::ZLTextTreeParagraph(ZLTextTreeParagraph *parent) : myIsOpen(false), myParent(parent) {
|
ZLTextTreeParagraph::ZLTextTreeParagraph(ZLTextTreeParagraph *parent) : myIsOpen(false), myParent(parent) {
|
||||||
if (parent != 0) {
|
if (parent != 0) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ private:
|
||||||
class ZLTextHyperlinkControlEntry : public ZLTextControlEntry {
|
class ZLTextHyperlinkControlEntry : public ZLTextControlEntry {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZLTextHyperlinkControlEntry(const char *address);
|
//ZLTextHyperlinkControlEntry(const char *address);
|
||||||
~ZLTextHyperlinkControlEntry();
|
~ZLTextHyperlinkControlEntry();
|
||||||
const std::string &label() const;
|
const std::string &label() const;
|
||||||
ZLHyperlinkType hyperlinkType() const;
|
ZLHyperlinkType hyperlinkType() const;
|
||||||
|
@ -117,7 +117,7 @@ private:
|
||||||
class ZLTextEntry : public ZLTextParagraphEntry {
|
class ZLTextEntry : public ZLTextParagraphEntry {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZLTextEntry(const char *address);
|
//ZLTextEntry(const char *address);
|
||||||
~ZLTextEntry();
|
~ZLTextEntry();
|
||||||
|
|
||||||
size_t dataLength() const;
|
size_t dataLength() const;
|
||||||
|
@ -130,7 +130,7 @@ private:
|
||||||
class ImageEntry : public ZLTextParagraphEntry {
|
class ImageEntry : public ZLTextParagraphEntry {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageEntry(const char *address);
|
//ImageEntry(const char *address);
|
||||||
~ImageEntry();
|
~ImageEntry();
|
||||||
const std::string &id() const;
|
const std::string &id() const;
|
||||||
short vOffset() const;
|
short vOffset() const;
|
||||||
|
@ -152,6 +152,7 @@ private:
|
||||||
class ZLTextParagraph {
|
class ZLTextParagraph {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/*
|
||||||
class Iterator {
|
class Iterator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -169,6 +170,7 @@ public:
|
||||||
size_t myEndIndex;
|
size_t myEndIndex;
|
||||||
mutable shared_ptr<ZLTextParagraphEntry> myEntry;
|
mutable shared_ptr<ZLTextParagraphEntry> myEntry;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
enum Kind {
|
enum Kind {
|
||||||
TEXT_PARAGRAPH,
|
TEXT_PARAGRAPH,
|
||||||
|
@ -189,8 +191,8 @@ public:
|
||||||
|
|
||||||
size_t entryNumber() const;
|
size_t entryNumber() const;
|
||||||
|
|
||||||
size_t textDataLength() const;
|
//size_t textDataLength() const;
|
||||||
size_t characterNumber() const;
|
//size_t characterNumber() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addEntry(char *address);
|
void addEntry(char *address);
|
||||||
|
@ -283,10 +285,10 @@ inline ZLTextParagraph::Kind ZLTextParagraph::kind() const { return TEXT_PARAGRA
|
||||||
inline size_t ZLTextParagraph::entryNumber() const { return myEntryNumber; }
|
inline size_t ZLTextParagraph::entryNumber() const { return myEntryNumber; }
|
||||||
inline void ZLTextParagraph::addEntry(char *address) { if (myEntryNumber == 0) myFirstEntryAddress = address; ++myEntryNumber; }
|
inline void ZLTextParagraph::addEntry(char *address) { if (myEntryNumber == 0) myFirstEntryAddress = address; ++myEntryNumber; }
|
||||||
|
|
||||||
inline ZLTextParagraph::Iterator::Iterator(const ZLTextParagraph ¶graph) : myPointer(paragraph.myFirstEntryAddress), myIndex(0), myEndIndex(paragraph.entryNumber()) {}
|
//inline ZLTextParagraph::Iterator::Iterator(const ZLTextParagraph ¶graph) : myPointer(paragraph.myFirstEntryAddress), myIndex(0), myEndIndex(paragraph.entryNumber()) {}
|
||||||
inline ZLTextParagraph::Iterator::~Iterator() {}
|
//inline ZLTextParagraph::Iterator::~Iterator() {}
|
||||||
inline bool ZLTextParagraph::Iterator::isEnd() const { return myIndex == myEndIndex; }
|
//inline bool ZLTextParagraph::Iterator::isEnd() const { return myIndex == myEndIndex; }
|
||||||
inline ZLTextParagraphEntry::Kind ZLTextParagraph::Iterator::entryKind() const { return (ZLTextParagraphEntry::Kind)*myPointer; }
|
//inline ZLTextParagraphEntry::Kind ZLTextParagraph::Iterator::entryKind() const { return (ZLTextParagraphEntry::Kind)*myPointer; }
|
||||||
|
|
||||||
inline ZLTextSpecialParagraph::ZLTextSpecialParagraph(Kind kind) : myKind(kind) {}
|
inline ZLTextSpecialParagraph::ZLTextSpecialParagraph(Kind kind) : myKind(kind) {}
|
||||||
inline ZLTextSpecialParagraph::~ZLTextSpecialParagraph() {}
|
inline ZLTextSpecialParagraph::~ZLTextSpecialParagraph() {}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <ZLTextParagraph.h>
|
#include <ZLTextParagraph.h>
|
||||||
#include <ZLTextAlignmentType.h>
|
#include <ZLTextAlignmentType.h>
|
||||||
|
#include <ZLBoolean3.h>
|
||||||
|
|
||||||
class ZLTextStyleEntry : public ZLTextParagraphEntry {
|
class ZLTextStyleEntry : public ZLTextParagraphEntry {
|
||||||
|
|
||||||
|
@ -45,7 +46,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FontModifier {
|
enum FontModifier {
|
||||||
FONT_MODIFIER_DEFAULT = 0,
|
|
||||||
FONT_MODIFIER_BOLD = 1 << 0,
|
FONT_MODIFIER_BOLD = 1 << 0,
|
||||||
FONT_MODIFIER_ITALIC = 1 << 1,
|
FONT_MODIFIER_ITALIC = 1 << 1,
|
||||||
FONT_MODIFIER_UNDERLINED = 1 << 2,
|
FONT_MODIFIER_UNDERLINED = 1 << 2,
|
||||||
|
@ -53,19 +53,19 @@ public:
|
||||||
FONT_MODIFIER_SMALLCAPS = 1 << 4,
|
FONT_MODIFIER_SMALLCAPS = 1 << 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Length {
|
enum Feature {
|
||||||
LENGTH_LEFT_INDENT = 0,
|
LENGTH_LEFT_INDENT = 0,
|
||||||
LENGTH_RIGHT_INDENT = 1,
|
LENGTH_RIGHT_INDENT = 1,
|
||||||
LENGTH_FIRST_LINE_INDENT_DELTA = 2,
|
LENGTH_FIRST_LINE_INDENT_DELTA = 2,
|
||||||
LENGTH_SPACE_BEFORE = 3,
|
LENGTH_SPACE_BEFORE = 3,
|
||||||
LENGTH_SPACE_AFTER = 4,
|
LENGTH_SPACE_AFTER = 4,
|
||||||
NUMBER_OF_LENGTHS = 5,
|
NUMBER_OF_LENGTHS = 5,
|
||||||
|
ALIGNMENT_TYPE = NUMBER_OF_LENGTHS,
|
||||||
|
FONT_SIZE_MAGNIFICATION = NUMBER_OF_LENGTHS + 1,
|
||||||
|
FONT_FAMILY = NUMBER_OF_LENGTHS + 2,
|
||||||
|
FONT_STYLE_MODIFIER = NUMBER_OF_LENGTHS + 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
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:
|
private:
|
||||||
struct LengthType {
|
struct LengthType {
|
||||||
SizeUnit Unit;
|
SizeUnit Unit;
|
||||||
|
@ -74,80 +74,88 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ZLTextStyleEntry();
|
ZLTextStyleEntry();
|
||||||
ZLTextStyleEntry(char *address);
|
//ZLTextStyleEntry(char *address);
|
||||||
~ZLTextStyleEntry();
|
~ZLTextStyleEntry();
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
bool isFeatureSupported(Feature featureId) const;
|
||||||
|
|
||||||
bool isLengthSupported(Length name) const;
|
short length(Feature featureId, const Metrics &metrics) const;
|
||||||
short length(Length name, const Metrics &metrics) const;
|
void setLength(Feature featureId, short length, SizeUnit unit);
|
||||||
void setLength(Length name, short length, SizeUnit unit);
|
|
||||||
|
|
||||||
bool isAlignmentTypeSupported() const;
|
|
||||||
ZLTextAlignmentType alignmentType() const;
|
ZLTextAlignmentType alignmentType() const;
|
||||||
void setAlignmentType(ZLTextAlignmentType alignmentType);
|
void setAlignmentType(ZLTextAlignmentType alignmentType);
|
||||||
|
|
||||||
unsigned char supportedFontModifier() const;
|
ZLBoolean3 fontModifier(FontModifier modifier) const;
|
||||||
unsigned char fontModifier() const;
|
void setFontModifier(FontModifier modifier, bool on);
|
||||||
void setFontModifier(FontModifier style, bool set);
|
|
||||||
|
|
||||||
bool isFontSizeMagSupported() const;
|
signed char fontSizeMagnification() const;
|
||||||
signed char fontSizeMag() const;
|
void setFontSizeMagnification(signed char fontSizeMagnification);
|
||||||
void setFontSizeMag(signed char fontSizeMag);
|
|
||||||
|
|
||||||
bool isFontFamilySupported() const;
|
|
||||||
const std::string &fontFamily() const;
|
const std::string &fontFamily() const;
|
||||||
void setFontFamily(const std::string &fontFamily);
|
void setFontFamily(const std::string &fontFamily);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int myMask;
|
unsigned short myFeatureMask;
|
||||||
|
|
||||||
LengthType myLengths[NUMBER_OF_LENGTHS];
|
LengthType myLengths[NUMBER_OF_LENGTHS];
|
||||||
|
|
||||||
ZLTextAlignmentType myAlignmentType;
|
ZLTextAlignmentType myAlignmentType;
|
||||||
unsigned char mySupportedFontModifier;
|
unsigned char mySupportedFontModifier;
|
||||||
unsigned char myFontModifier;
|
unsigned char myFontModifier;
|
||||||
signed char myFontSizeMag;
|
signed char myFontSizeMagnification;
|
||||||
std::string myFontFamily;
|
std::string myFontFamily;
|
||||||
|
|
||||||
friend class ZLTextModel;
|
friend class ZLTextModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ZLTextStyleEntry::ZLTextStyleEntry() : myMask(0), myAlignmentType(ALIGN_UNDEFINED), mySupportedFontModifier(0), myFontModifier(0), myFontSizeMag(0) {}
|
inline ZLTextStyleEntry::ZLTextStyleEntry() : myFeatureMask(0), myAlignmentType(ALIGN_UNDEFINED), mySupportedFontModifier(0), myFontModifier(0), myFontSizeMagnification(0) {}
|
||||||
inline ZLTextStyleEntry::~ZLTextStyleEntry() {}
|
inline ZLTextStyleEntry::~ZLTextStyleEntry() {}
|
||||||
|
|
||||||
inline ZLTextStyleEntry::Metrics::Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight) : FontSize(fontSize), FontXHeight(fontXHeight), FullWidth(fullWidth), FullHeight(fullHeight) {}
|
inline ZLTextStyleEntry::Metrics::Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight) : FontSize(fontSize), FontXHeight(fontXHeight), FullWidth(fullWidth), FullHeight(fullHeight) {}
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isEmpty() const { return myMask == 0; }
|
inline bool ZLTextStyleEntry::isEmpty() const { return myFeatureMask == 0; }
|
||||||
|
inline bool ZLTextStyleEntry::isFeatureSupported(Feature featureId) const {
|
||||||
inline bool ZLTextStyleEntry::isLengthSupported(Length name) const { return (myMask & (1U << name)) != 0; }
|
return (myFeatureMask & (1 << featureId)) != 0;
|
||||||
inline void ZLTextStyleEntry::setLength(Length name, short length, SizeUnit unit) {
|
}
|
||||||
myLengths[name].Size = length;
|
|
||||||
myLengths[name].Unit = unit;
|
inline void ZLTextStyleEntry::setLength(Feature featureId, short length, SizeUnit unit) {
|
||||||
myMask |= 1U << name;
|
myFeatureMask |= 1 << featureId;
|
||||||
|
myLengths[featureId].Size = length;
|
||||||
|
myLengths[featureId].Unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isAlignmentTypeSupported() const { return (myMask & SUPPORTS_ALIGNMENT_TYPE) == SUPPORTS_ALIGNMENT_TYPE; }
|
|
||||||
inline ZLTextAlignmentType ZLTextStyleEntry::alignmentType() const { return myAlignmentType; }
|
inline ZLTextAlignmentType ZLTextStyleEntry::alignmentType() const { return myAlignmentType; }
|
||||||
inline void ZLTextStyleEntry::setAlignmentType(ZLTextAlignmentType alignmentType) { myAlignmentType = alignmentType; myMask |= SUPPORTS_ALIGNMENT_TYPE; }
|
inline void ZLTextStyleEntry::setAlignmentType(ZLTextAlignmentType alignmentType) {
|
||||||
|
myFeatureMask |= 1 << ALIGNMENT_TYPE;
|
||||||
inline unsigned char ZLTextStyleEntry::supportedFontModifier() const { return mySupportedFontModifier; }
|
myAlignmentType = alignmentType;
|
||||||
inline unsigned char ZLTextStyleEntry::fontModifier() const { return myFontModifier; }
|
|
||||||
inline void ZLTextStyleEntry::setFontModifier(FontModifier style, bool set) {
|
|
||||||
if (set) {
|
|
||||||
myFontModifier |= style;
|
|
||||||
} else {
|
|
||||||
myFontModifier &= ~style;
|
|
||||||
}
|
|
||||||
mySupportedFontModifier |= style;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isFontSizeMagSupported() const { return (myMask & SUPPORTS_FONT_SIZE_MAG) == SUPPORTS_FONT_SIZE_MAG; }
|
inline ZLBoolean3 ZLTextStyleEntry::fontModifier(FontModifier modifier) const {
|
||||||
inline signed char ZLTextStyleEntry::fontSizeMag() const { return myFontSizeMag; }
|
if ((mySupportedFontModifier & modifier) == 0) {
|
||||||
inline void ZLTextStyleEntry::setFontSizeMag(signed char fontSizeMag) { myFontSizeMag = fontSizeMag; myMask |= SUPPORTS_FONT_SIZE_MAG; }
|
return B3_UNDEFINED;
|
||||||
|
}
|
||||||
|
return (myFontModifier & modifier) == 0 ? B3_FALSE : B3_TRUE;
|
||||||
|
}
|
||||||
|
inline void ZLTextStyleEntry::setFontModifier(FontModifier modifier, bool on) {
|
||||||
|
myFeatureMask |= FONT_STYLE_MODIFIER;
|
||||||
|
mySupportedFontModifier |= modifier;
|
||||||
|
if (on) {
|
||||||
|
myFontModifier |= modifier;
|
||||||
|
} else {
|
||||||
|
myFontModifier &= ~modifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline signed char ZLTextStyleEntry::fontSizeMagnification() const { return myFontSizeMagnification; }
|
||||||
|
inline void ZLTextStyleEntry::setFontSizeMagnification(signed char fontSizeMagnification) {
|
||||||
|
myFeatureMask |= FONT_SIZE_MAGNIFICATION;
|
||||||
|
myFontSizeMagnification = fontSizeMagnification;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isFontFamilySupported() const { return (myMask & SUPPORTS_FONT_FAMILY) == SUPPORTS_FONT_FAMILY; }
|
|
||||||
inline const std::string &ZLTextStyleEntry::fontFamily() const { return myFontFamily; }
|
inline const std::string &ZLTextStyleEntry::fontFamily() const { return myFontFamily; }
|
||||||
inline void ZLTextStyleEntry::setFontFamily(const std::string &fontFamily) { myFontFamily = fontFamily; myMask |= SUPPORTS_FONT_FAMILY; }
|
inline void ZLTextStyleEntry::setFontFamily(const std::string &fontFamily) {
|
||||||
|
myFeatureMask |= FONT_FAMILY;
|
||||||
|
myFontFamily = fontFamily;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __ZLTEXTSTYLEENTRY_H__ */
|
#endif /* __ZLTEXTSTYLEENTRY_H__ */
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.*;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
import org.geometerplus.zlibrary.core.util.*;
|
import org.geometerplus.zlibrary.core.util.*;
|
||||||
|
|
||||||
public class ZLTextPlainModel implements ZLTextModel {
|
public class ZLTextPlainModel implements ZLTextModel, ZLTextStyleEntry.Feature {
|
||||||
private final String myId;
|
private final String myId;
|
||||||
private final String myLanguage;
|
private final String myLanguage;
|
||||||
|
|
||||||
|
@ -184,20 +184,30 @@ public class ZLTextPlainModel implements ZLTextModel {
|
||||||
break;
|
break;
|
||||||
case ZLTextParagraph.Entry.STYLE:
|
case ZLTextParagraph.Entry.STYLE:
|
||||||
{
|
{
|
||||||
final int mask = (int)data[dataOffset++];
|
|
||||||
final ZLTextStyleEntry entry = new ZLTextStyleEntry();
|
final ZLTextStyleEntry entry = new ZLTextStyleEntry();
|
||||||
if ((mask & ZLTextStyleEntry.SUPPORTS_LEFT_INDENT) ==
|
|
||||||
ZLTextStyleEntry.SUPPORTS_LEFT_INDENT) {
|
final short mask = (short)data[dataOffset++];
|
||||||
entry.setLeftIndent((short)data[dataOffset++]);
|
for (int i = 0; i < NUMBER_OF_LENGTHS; ++i) {
|
||||||
|
if (ZLTextStyleEntry.isFeatureSupported(mask, i)) {
|
||||||
|
// TODO: read length
|
||||||
|
dataOffset += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((mask & ZLTextStyleEntry.SUPPORTS_RIGHT_INDENT) ==
|
if (ZLTextStyleEntry.isFeatureSupported(mask, ALIGNMENT_TYPE) ||
|
||||||
ZLTextStyleEntry.SUPPORTS_RIGHT_INDENT) {
|
ZLTextStyleEntry.isFeatureSupported(mask, FONT_SIZE_MAGNIFICATION)) {
|
||||||
entry.setRightIndent((short)data[dataOffset++]);
|
// TODO: read alignment type and/or font size magnification
|
||||||
|
dataOffset += 1;
|
||||||
}
|
}
|
||||||
if ((mask & ZLTextStyleEntry.SUPPORTS_ALIGNMENT_TYPE) ==
|
if (ZLTextStyleEntry.isFeatureSupported(mask, FONT_FAMILY)) {
|
||||||
ZLTextStyleEntry.SUPPORTS_ALIGNMENT_TYPE) {
|
final short familyLength = (short)data[dataOffset++];
|
||||||
entry.setAlignmentType((byte)data[dataOffset++]);
|
// TODO: read font family
|
||||||
|
dataOffset += familyLength;
|
||||||
}
|
}
|
||||||
|
if (ZLTextStyleEntry.isFeatureSupported(mask, FONT_STYLE_MODIFIER)) {
|
||||||
|
// TODO: read font modifiers
|
||||||
|
dataOffset += 1;
|
||||||
|
}
|
||||||
|
|
||||||
myStyleEntry = entry;
|
myStyleEntry = entry;
|
||||||
}
|
}
|
||||||
case ZLTextParagraph.Entry.RESET_BIDI:
|
case ZLTextParagraph.Entry.RESET_BIDI:
|
||||||
|
|
|
@ -20,58 +20,47 @@
|
||||||
package org.geometerplus.zlibrary.text.model;
|
package org.geometerplus.zlibrary.text.model;
|
||||||
|
|
||||||
public final class ZLTextStyleEntry {
|
public final class ZLTextStyleEntry {
|
||||||
final static short SUPPORTS_LEFT_INDENT = 1 << 0;
|
interface Feature {
|
||||||
final static short SUPPORTS_RIGHT_INDENT = 1 << 1;
|
int LENGTH_LEFT_INDENT = 0;
|
||||||
final static short SUPPORTS_ALIGNMENT_TYPE = 1 << 2;
|
int LENGTH_RIGHT_INDENT = 1;
|
||||||
|
int LENGTH_FIRST_LINE_INDENT_DELTA = 2;
|
||||||
|
int LENGTH_SPACE_BEFORE = 3;
|
||||||
|
int LENGTH_SPACE_AFTER = 4;
|
||||||
|
int NUMBER_OF_LENGTHS = 5;
|
||||||
|
int ALIGNMENT_TYPE = NUMBER_OF_LENGTHS;
|
||||||
|
int FONT_SIZE_MAGNIFICATION = NUMBER_OF_LENGTHS + 1;
|
||||||
|
int FONT_FAMILY = NUMBER_OF_LENGTHS + 2;
|
||||||
|
int FONT_STYLE_MODIFIER = NUMBER_OF_LENGTHS + 3;
|
||||||
|
}
|
||||||
|
|
||||||
private short myMask;
|
private short myFeatureMask;
|
||||||
private short myLeftIndent;
|
|
||||||
private short myRightIndent;
|
static boolean isFeatureSupported(short mask, int featureId) {
|
||||||
private byte myAlignmentType;
|
return (mask & (1 << featureId)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFeatureSupported(int featureId) {
|
||||||
|
return isFeatureSupported(myFeatureMask, featureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//private short myLeftIndent;
|
||||||
|
//private short myRightIndent;
|
||||||
|
//private byte myAlignmentType;
|
||||||
|
|
||||||
public ZLTextStyleEntry() {
|
public ZLTextStyleEntry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
short getMask() {
|
/*
|
||||||
return myMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLeftIndentSupported() {
|
|
||||||
return (myMask & SUPPORTS_LEFT_INDENT) == SUPPORTS_LEFT_INDENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getLeftIndent() {
|
public short getLeftIndent() {
|
||||||
return myLeftIndent;
|
return myLeftIndent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftIndent(short leftIndent) {
|
|
||||||
myMask |= SUPPORTS_LEFT_INDENT;
|
|
||||||
myLeftIndent = leftIndent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRightIndentSupported() {
|
|
||||||
return (myMask & SUPPORTS_RIGHT_INDENT) == SUPPORTS_RIGHT_INDENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getRightIndent() {
|
public short getRightIndent() {
|
||||||
return myRightIndent;
|
return myRightIndent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightIndent(short rightIndent) {
|
|
||||||
myMask |= SUPPORTS_RIGHT_INDENT;
|
|
||||||
myRightIndent = rightIndent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlignmentTypeSupported() {
|
|
||||||
return (myMask & SUPPORTS_ALIGNMENT_TYPE) == SUPPORTS_ALIGNMENT_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getAlignmentType() {
|
public byte getAlignmentType() {
|
||||||
return myAlignmentType;
|
return myAlignmentType;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public void setAlignmentType(byte alignmentType) {
|
|
||||||
myMask |= SUPPORTS_ALIGNMENT_TYPE;
|
|
||||||
myAlignmentType = alignmentType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,8 @@ public final class ZLTextWritablePlainModel extends ZLTextPlainModel implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStyleEntry(ZLTextStyleEntry entry) {
|
public void addStyleEntry(ZLTextStyleEntry entry) {
|
||||||
|
// TODO: implement
|
||||||
|
/*
|
||||||
int len = 2;
|
int len = 2;
|
||||||
for (int mask = entry.getMask(); mask != 0; mask >>= 1) {
|
for (int mask = entry.getMask(); mask != 0; mask >>= 1) {
|
||||||
len += mask & 1;
|
len += mask & 1;
|
||||||
|
@ -149,6 +151,7 @@ public final class ZLTextWritablePlainModel extends ZLTextPlainModel implements
|
||||||
if (entry.isAlignmentTypeSupported()) {
|
if (entry.isAlignmentTypeSupported()) {
|
||||||
block[myBlockOffset++] = (char)entry.getAlignmentType();
|
block[myBlockOffset++] = (char)entry.getAlignmentType();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFixedHSpace(short length) {
|
public void addFixedHSpace(short length) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue