1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

formatting

This commit is contained in:
Nikolay Pultsin 2014-06-30 00:06:05 +01:00
parent dde4be579e
commit a7fa712e03
28 changed files with 92 additions and 92 deletions

View file

@ -48,7 +48,7 @@ BookModel::~BookModel() {
void BookModel::setHyperlinkMatcher(shared_ptr<HyperlinkMatcher> matcher) {
myHyperlinkMatcher = matcher;
}
BookModel::Label BookModel::label(const std::string &id) const {
if (!myHyperlinkMatcher.isNull()) {
return myHyperlinkMatcher->match(myInternalHyperlinks, id);

View file

@ -297,7 +297,7 @@ void StyleSheetMultiStyleParser::processAtRule(const std::string &name, const St
for (std::vector<std::string>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
if (ZLStringUtil::stringStartsWith(*jt, "url(") &&
ZLStringUtil::stringEndsWith(*jt, ")")) {
path = ZLFile(url2FullPath(*jt)).path();
path = ZLFile(url2FullPath(*jt)).path();
break;
}
}
@ -349,7 +349,7 @@ void StyleSheetParserWithCache::importCSS(const std::string &path) {
StyleSheetParserWithCache importParser(fileToImport, myPathPrefix, myFontMap, myEncryptionMap);
importParser.myProcessedFiles.insert(myProcessedFiles.begin(), myProcessedFiles.end());
importParser.parseStream(stream);
myEntries.insert(myEntries.end(), importParser.myEntries.begin(), importParser.myEntries.end());
myEntries.insert(myEntries.end(), importParser.myEntries.begin(), importParser.myEntries.end());
}
myProcessedFiles.insert(fileToImport.path());
}

View file

@ -199,7 +199,7 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
const std::string &fontSize = value(styles, "font-size");
if (!fontSize.empty()) {
bool doSetFontSize = true;
bool doSetFontSize = true;
short size = 100;
ZLTextStyleEntry::SizeUnit unit = ZLTextStyleEntry::SIZE_UNIT_PERCENT;
if (fontSize == "xx-small") {

View file

@ -123,7 +123,7 @@ void HtmlReader::readDocument(ZLInputStream &stream) {
int quotationCounter = 0;
HtmlTag currentTag;
char endOfComment[2] = "\0";
const std::size_t BUFSIZE = 2048;
char *buffer = new char[BUFSIZE];
std::size_t length;
@ -362,7 +362,7 @@ void HtmlReader::readDocument(ZLInputStream &stream) {
break;
}
}
offset += length;
offset += length;
} while (length == BUFSIZE);
endOfProcessing:
delete[] buffer;

View file

@ -134,7 +134,7 @@ void OEBBookReader::startElementHandler(const char *tag, const char **xmlattribu
}
bool OEBBookReader::coverIsSingleImage() const {
return
return
COVER_IMAGE == myCoverFileType ||
(COVER == myCoverFileType &&
ZLStringUtil::stringStartsWith(myCoverMimeType, "image/"));

View file

@ -67,7 +67,7 @@ protected:
FONT_ITALIC,
FONT_UNDERLINED
};
virtual void addCharData(const char *data, std::size_t len, bool convert) = 0;
virtual void insertImage(const std::string &mimeType, const std::string &fileName, std::size_t startOffset, std::size_t size) = 0;
virtual void setEncoding(int code) = 0;
@ -91,7 +91,7 @@ protected:
bool Underlined;
ZLTextAlignmentType Alignment;
DestinationType Destination;
bool ReadDataAsHex;
};
@ -109,7 +109,7 @@ private:
int myBinaryDataSize;
std::string myNextImageMimeType;
int myIsInterrupted;
int myIsInterrupted;
friend class RtfNewParagraphCommand;
friend class RtfFontPropertyCommand;

View file

@ -97,7 +97,7 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
unsigned int currentLineLength = 0;
unsigned int currentLineIndent = 0;
int currentNumberOfEmptyLines = -1;
char *buffer = new char[BUFFER_SIZE];
int length;
char previous = 0;
@ -127,7 +127,7 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
if (!currentLineIsEmpty) {
stringIndentTable[std::min(currentLineIndent, tableSize - 1)]++;
}
currentLineIsEmpty = true;
currentLineLength = 0;
currentLineIndent = 0;
@ -182,8 +182,8 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
}
if (emptyLinesBeforeNewSection > 0) {
for (index = tableSize - 1; index > 0; --index) {
emptyLinesTable[index - 1] += emptyLinesTable[index];
emptyLinesBeforeShortStringTable[index - 1] += emptyLinesBeforeShortStringTable[index];
emptyLinesTable[index - 1] += emptyLinesTable[index];
emptyLinesBeforeShortStringTable[index - 1] += emptyLinesBeforeShortStringTable[index];
}
for (index = emptyLinesBeforeNewSection; index < tableSize; ++index) {
if ((emptyLinesBeforeShortStringTable[index] > 2) &&

View file

@ -24,5 +24,5 @@ const std::vector<std::string> &EntityFilesCollector::xhtmlDTDs() {
if (DTDs.empty()) {
DTDs.push_back("formats/xhtml/xhtml-merged.ent");
}
return DTDs;
return DTDs;
}

View file

@ -50,14 +50,14 @@ class XHTMLTagAction {
public:
virtual ~XHTMLTagAction();
virtual void doAtStart(XHTMLReader &reader, const char **xmlattributes) = 0;
virtual void doAtEnd(XHTMLReader &reader) = 0;
virtual bool isEnabled(XHTMLReadingState state) = 0;
protected:
static BookReader &bookReader(XHTMLReader &reader);
static const std::string &pathPrefix(XHTMLReader &reader);
static BookReader &bookReader(XHTMLReader &reader);
static const std::string &pathPrefix(XHTMLReader &reader);
static void beginParagraph(XHTMLReader &reader);
static void endParagraph(XHTMLReader &reader);
};

View file

@ -66,7 +66,7 @@ shared_ptr<Book> Book::loadFromFile(const ZLFile &file) {
shared_ptr<Book> book = new Book(file, 0);
if (!plugin->readMetainfo(*book)) {
return 0;
return 0;
}
if (book->title().empty()) {

View file

@ -80,7 +80,7 @@ shared_ptr<Tag> Tag::cloneSubTag(shared_ptr<Tag> tag, shared_ptr<Tag> oldparent,
}
if (levels.empty()) {
return 0;
return 0;
}
shared_ptr<Tag> res = newparent;

View file

@ -43,7 +43,7 @@ public:
static void setTagId(shared_ptr<Tag>, int tagId);
static shared_ptr<Tag> cloneSubTag(shared_ptr<Tag> tag, shared_ptr<Tag> oldparent, shared_ptr<Tag> newparent);
static void collectAncestors(shared_ptr<Tag> tag, TagList &parents);
static void collectTagNames(std::vector<std::string> &tags);
@ -70,7 +70,7 @@ public:
int tagId() const;
std::size_t level() const;
private:
const std::string myName;
mutable std::string myFullName;
@ -78,7 +78,7 @@ private:
shared_ptr<Tag> myParent;
TagList myChildren;
const std::size_t myLevel;
int myTagId;
mutable jobject myJavaTag;

View file

@ -46,7 +46,7 @@ public:
protected:
virtual std::string delimiter() const = 0;
private:
std::string myPath;

View file

@ -23,7 +23,7 @@
#include "ZLDir.h"
class ZLFSDir : public ZLDir {
protected:
ZLFSDir(const std::string &path);

View file

@ -39,11 +39,11 @@ public:
protected:
static ZLFSManager *ourInstance;
protected:
ZLFSManager();
virtual ~ZLFSManager();
public:
void normalize(std::string &path) const;
virtual std::string resolveSymlink(const std::string &path) const = 0;

View file

@ -29,7 +29,7 @@ ZLCharSequence::ZLCharSequence(const char *ptr, std::size_t size) : mySize(size)
myHead = new char[mySize];
for (std::size_t count = 0; count < mySize; ++count){
myHead[count] = ptr[count];
}
}
}
ZLCharSequence::ZLCharSequence(const ZLCharSequence& other) : mySize(other.mySize) {
@ -48,11 +48,11 @@ ZLCharSequence::ZLCharSequence(const std::string &hexSequence) {
myHead = new char[mySize];
for (std::size_t count = 0; count < mySize; ++count){
char a = hexSequence[count * 5 + 2];
char b = hexSequence[count * 5 + 3];
a -= (a >= 97) ? 87 : 48;
char b = hexSequence[count * 5 + 3];
a -= (a >= 97) ? 87 : 48;
b -= (b >= 97) ? 87 : 48;
myHead[count] = a*16 + b;
}
}
}
ZLCharSequence& ZLCharSequence::operator= (const ZLCharSequence& other) {
@ -72,20 +72,20 @@ ZLCharSequence& ZLCharSequence::operator= (const ZLCharSequence& other) {
}
}
return *this;
}
}
std::string ZLCharSequence::toHexSequence() const {
std::string ZLCharSequence::toHexSequence() const {
std::string result;
static const char table[] = "0123456789abcdef";
for (std::size_t count = 0;; ++count) {
result += "0x";
result += table[(myHead[count] >> 4) & 0x0F];
result += table[myHead[count] & 0x0F];
if (count == mySize-1) {
if (count == mySize-1) {
return result;
}
result += " ";
}
}
return result;
}

View file

@ -25,17 +25,17 @@
class ZLCharSequence {
public:
ZLCharSequence();
ZLCharSequence(const char *ptr, std::size_t size);
ZLCharSequence();
ZLCharSequence(const char *ptr, std::size_t size);
ZLCharSequence(const std::string &hexSequence);
ZLCharSequence(const ZLCharSequence &other);
~ZLCharSequence();
~ZLCharSequence();
std::size_t getSize() const;
const char &operator [] (std::size_t index) const;
ZLCharSequence &operator = (const ZLCharSequence& other);
std::string toHexSequence() const;
std::string toHexSequence() const;
// returns
// an integer < 0 if the sequence is less than other
@ -43,7 +43,7 @@ public:
// 0 if the sequence is equal to other
int compareTo(const ZLCharSequence &other) const;
private:
private:
std::size_t mySize;
char *myHead;
};

View file

@ -80,15 +80,15 @@ int ZLStatistics::correlation(const ZLStatistics& candidate, const ZLStatistics&
const unsigned long long patternSum = pattern.getVolume();
const unsigned long long candidateSum2 = candidate.getSquaresVolume();
const unsigned long long patternSum2 = pattern.getSquaresVolume();
shared_ptr<ZLStatisticsItem> ptrA = candidate.begin();
shared_ptr<ZLStatisticsItem> ptrB = pattern.begin();
const shared_ptr<ZLStatisticsItem> endA = candidate.end();
const shared_ptr<ZLStatisticsItem> endB = pattern.end();
std::size_t count = 0;
long long correlationSum = 0;
while ((*ptrA != *endA) && (*ptrB != *endB)) {
while ((*ptrA != *endA) && (*ptrB != *endB)) {
++count;
const int comparison = ptrA->sequence().compareTo(ptrB->sequence());
if (comparison < 0) {
@ -141,10 +141,10 @@ int ZLStatistics::correlation(const ZLStatistics& candidate, const ZLStatistics&
}
int candidateMult = 1000000 / patternMult;
const long long quotient1 = (patternMult * numerator / patternDispersion);
const long long quotient1 = (patternMult * numerator / patternDispersion);
const long long quotient2 = (candidateMult * numerator / candidateDispersion);
const int sign = (numerator >= 0) ? 1 : -1;
return sign * quotient1 * quotient2;
}
@ -155,7 +155,7 @@ ZLMapBasedStatistics::ZLMapBasedStatistics() : ZLStatistics() {
ZLMapBasedStatistics::ZLMapBasedStatistics(const Dictionary &dictionary) {
if (!dictionary.empty()) {
myCharSequenceSize = dictionary.begin()->first.getSize();
myVolumesAreUpToDate = false;
myVolumesAreUpToDate = false;
myDictionary = dictionary;
} else {
myCharSequenceSize = 0;
@ -191,7 +191,7 @@ ZLMapBasedStatistics ZLMapBasedStatistics::top(std::size_t amount) const {
tempVector.resize(myDictionary.size());
std::copy(myDictionary.begin(), myDictionary.end(), tempVector.begin());
std::sort(tempVector.rbegin(), tempVector.rend(), LessFrequency());
Vector::const_iterator it = tempVector.begin();
Vector::const_iterator it = tempVector.begin();
while (amount != 0) {
dictionary[it->first] = it->second;
++it;
@ -213,7 +213,7 @@ void ZLMapBasedStatistics::retain(const ZLMapBasedStatistics &other) {
const Dictionary::iterator endA = myDictionary.end();
const Dictionary::const_iterator endB = other.myDictionary.end();
while ((itA != endA) && (itB != endB)) {
while ((itA != endA) && (itB != endB)) {
const int comparison = itA->first.compareTo(itB->first);
if (comparison < 0) {
myDictionary.erase(itA++);
@ -230,7 +230,7 @@ void ZLMapBasedStatistics::retain(const ZLMapBasedStatistics &other) {
if (itA != endA) {
myDictionary.erase(itA, endA);
}
myVolumesAreUpToDate = true;
myVolumesAreUpToDate = true;
} else {
*this = ZLMapBasedStatistics();
}
@ -241,7 +241,7 @@ void ZLMapBasedStatistics::scaleToShort() {
const std::size_t maxShort = 65535;
if (maxFrequency > maxShort) {
const std::size_t devider = maxFrequency / maxShort + 1;
Dictionary::iterator it = myDictionary.begin();
Dictionary::iterator it = myDictionary.begin();
const Dictionary::iterator end = myDictionary.end();
while (it != end) {
if (it->second < devider) {
@ -272,7 +272,7 @@ ZLArrayBasedStatistics::ZLArrayBasedStatistics(std::size_t charSequenceSize, std
mySequences = new char[myCharSequenceSize * size];
myFrequencies = new unsigned short[size];
}
ZLArrayBasedStatistics::~ZLArrayBasedStatistics() {
if (mySequences != 0) {
delete[] mySequences;
@ -285,7 +285,7 @@ void ZLArrayBasedStatistics::insert(const ZLCharSequence &charSequence, std::siz
return;
}
for (std::size_t i = 0; i < myCharSequenceSize; ++i) {
mySequences[myBack * myCharSequenceSize + i] = charSequence[i];
mySequences[myBack * myCharSequenceSize + i] = charSequence[i];
}
myFrequencies[myBack] = (unsigned short) frequency;
++myBack;
@ -334,6 +334,6 @@ ZLArrayBasedStatistics& ZLArrayBasedStatistics::operator= (const ZLArrayBasedSta
} else {
mySequences = 0;
myFrequencies = 0;
}
}
return *this;
}

View file

@ -39,7 +39,7 @@ public:
std::size_t getVolume() const;
unsigned long long getSquaresVolume() const;
std::size_t getCharSequenceSize() const;
public:
virtual shared_ptr<ZLStatisticsItem> begin() const = 0;
virtual shared_ptr<ZLStatisticsItem> end() const = 0;
@ -60,27 +60,27 @@ protected:
class ZLMapBasedStatistics : public ZLStatistics {
private:
typedef std::vector<std::pair<ZLCharSequence, std::size_t> > Vector;
typedef std::vector<std::pair<ZLCharSequence, std::size_t> > Vector;
typedef std::map<ZLCharSequence, std::size_t> Dictionary;
public:
ZLMapBasedStatistics();
ZLMapBasedStatistics(const Dictionary &dictionary);
~ZLMapBasedStatistics();
~ZLMapBasedStatistics();
std::size_t getSize() const;
ZLMapBasedStatistics top(std::size_t amount) const;
void scaleToShort();
void retain(const ZLMapBasedStatistics &other);
void retain(const ZLMapBasedStatistics &other);
bool empty() const;
virtual shared_ptr<ZLStatisticsItem> begin() const;
virtual shared_ptr<ZLStatisticsItem> end() const;
protected:
protected:
void calculateVolumes() const;
private:
@ -97,12 +97,12 @@ private:
class ZLArrayBasedStatistics : public ZLStatistics {
public:
ZLArrayBasedStatistics();
ZLArrayBasedStatistics(std::size_t charSequenceSize, std::size_t size, std::size_t volume, unsigned long long squaresVolume);
ZLArrayBasedStatistics(std::size_t charSequenceSize, std::size_t size, std::size_t volume, unsigned long long squaresVolume);
~ZLArrayBasedStatistics();
ZLArrayBasedStatistics &operator = (const ZLArrayBasedStatistics &other);
void insert(const ZLCharSequence &charSequence, std::size_t frequency);
bool empty() const;
virtual shared_ptr<ZLStatisticsItem> begin() const;
@ -113,7 +113,7 @@ protected:
private:
std::size_t myCapacity;
std::size_t myBack;
std::size_t myBack;
char* mySequences;
unsigned short* myFrequencies;
};

View file

@ -19,7 +19,7 @@
#include "ZLStatisticsItem.h"
ZLMapBasedStatisticsItem::ZLMapBasedStatisticsItem(const std::map<ZLCharSequence, std::size_t>::const_iterator it, std::size_t index) : ZLStatisticsItem(index),
ZLMapBasedStatisticsItem::ZLMapBasedStatisticsItem(const std::map<ZLCharSequence, std::size_t>::const_iterator it, std::size_t index) : ZLStatisticsItem(index),
myIterator(it) {
}

View file

@ -21,8 +21,8 @@
#include <string>
#include <map>
#include <ZLFile.h>
#include <ZLInputStream.h>
#include <ZLFile.h>
#include <ZLInputStream.h>
#include "ZLCharSequence.h"
#include "ZLStatistics.h"
@ -64,5 +64,5 @@ shared_ptr<ZLArrayBasedStatistics> ZLStatisticsXMLReader::readStatistics(const s
statisticsMap.insert(std::make_pair(fileName, myStatisticsPtr));
return myStatisticsPtr;
return myStatisticsPtr;
}

View file

@ -36,7 +36,7 @@ public:
private:
shared_ptr<ZLArrayBasedStatistics> myStatisticsPtr;
private:
static const std::string ITEM_TAG;
static const std::string STATISTICS_TAG;

View file

@ -35,7 +35,7 @@ const std::string ZLibrary::PathDelimiter(":");
const std::string ZLibrary::EndOfLine("\n");
/*void ZLibrary::initLocale() {
const char *locale = setlocale(LC_MESSAGES, "");
const char *locale = setlocale(LC_MESSAGES, "");
if (locale != 0) {
std::string sLocale = locale;
const int dotIndex = sLocale.find('.');

View file

@ -436,23 +436,23 @@ ZLUnicodeUtil::Breakable ZLUnicodeUtil::isBreakable(Ucs4Char c) {
}
if (((c >= 0x201A) && (c <= 0x201C)) ||
((c >= 0x201E) && (c <= 0x201F))) {
return BREAKABLE_BEFORE;
((c >= 0x201E) && (c <= 0x201F))) {
return BREAKABLE_BEFORE;
}
switch (c) {
case 0x2018: case 0x2039: case 0x2045:
case 0x207D: case 0x208D: case 0x2329:
case 0x3008: case 0x300A: case 0x300C:
case 0x300E: case 0x3010: case 0x3014:
case 0x3016: case 0x3018: case 0x301A:
case 0x301D: case 0xFD3E: case 0xFE35:
case 0xFE37: case 0xFE39: case 0xFE3B:
case 0xFE3D: case 0xFE3F: case 0xFE41:
case 0xFE43: case 0xFE59: case 0xFE5B:
case 0xFE5D: case 0xFF08: case 0xFF3B:
case 0xFF5B: case 0xFF62:
return BREAKABLE_BEFORE;
}
switch (c) {
case 0x2018: case 0x2039: case 0x2045:
case 0x207D: case 0x208D: case 0x2329:
case 0x3008: case 0x300A: case 0x300C:
case 0x300E: case 0x3010: case 0x3014:
case 0x3016: case 0x3018: case 0x301A:
case 0x301D: case 0xFD3E: case 0xFE35:
case 0xFE37: case 0xFE39: case 0xFE3B:
case 0xFE3D: case 0xFE3F: case 0xFE41:
case 0xFE43: case 0xFE59: case 0xFE5B:
case 0xFE5D: case 0xFF08: case 0xFF3B:
case 0xFF5B: case 0xFF62:
return BREAKABLE_BEFORE;
}
return BREAKABLE_AFTER;
}

View file

@ -40,7 +40,7 @@ public:
BREAKABLE_BEFORE,
BREAKABLE_AFTER
};
static bool isUtf8String(const char *str, int len);
static bool isUtf8String(const std::string &str);
static void cleanUtf8String(std::string &str);

View file

@ -58,7 +58,7 @@ private:
bool myInitialized;
bool myEof;
private:
private:
// disable copying
ZLAsynchronousInputStream(const ZLAsynchronousInputStream &);
const ZLAsynchronousInputStream &operator = (const ZLAsynchronousInputStream &);

View file

@ -31,7 +31,7 @@ public:
private:
bool processInputInternal(Handler &handler);
private:
private:
// disable copying
ZLPlainAsynchronousInputStream(const ZLPlainAsynchronousInputStream &);
const ZLPlainAsynchronousInputStream &operator = (const ZLPlainAsynchronousInputStream &);

View file

@ -363,7 +363,7 @@ void ZLTextModel::addVideoEntry(const ZLVideoEntry &entry) {
std::size_t len = 4;
for (std::map<std::string,std::string>::const_iterator it = sources.begin(); it != sources.end(); ++it) {
len += 2 * (ZLUnicodeUtil::utf8Length(it->first) + ZLUnicodeUtil::utf8Length(it->second)) + 4;
len += 2 * (ZLUnicodeUtil::utf8Length(it->first) + ZLUnicodeUtil::utf8Length(it->second)) + 4;
}
myLastEntryStart = myAllocator->allocate(len);