diff --git a/src/org/geometerplus/fbreader/fbreader/BookTextView.java b/src/org/geometerplus/fbreader/fbreader/BookTextView.java index e6e4cdca2..947f0d37f 100644 --- a/src/org/geometerplus/fbreader/fbreader/BookTextView.java +++ b/src/org/geometerplus/fbreader/fbreader/BookTextView.java @@ -214,9 +214,12 @@ public class BookTextView extends FBView { new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, BUFFER_SIZE, 0).setValue(myPositionStack.size()); new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, POSITION_IN_BUFFER, 0).setValue(myCurrentPointInStack); + final ZLIntegerOption option = new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, "", 0); for (int i = 0; i < myPositionStack.size(); ++i) { Position position = (Position)myPositionStack.get(i); - new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, PARAGRAPH_PREFIX + i, 0).setValue(position.ParagraphIndex); + option.changeName(PARAGRAPH_PREFIX + i); + option.setValue(position.ParagraphIndex); + //new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, PARAGRAPH_PREFIX + i, 0).setValue(position.ParagraphIndex); new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, WORD_PREFIX + i, 0).setValue(position.WordIndex); new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, CHAR_PREFIX + i, 0).setValue(position.CharIndex); new ZLIntegerOption(ZLOption.STATE_CATEGORY, group, MODEL_PREFIX + i, 0).setValue(position.ModelIndex); diff --git a/src/org/geometerplus/fbreader/formats/plucker/PluckerBookReader.java b/src/org/geometerplus/fbreader/formats/plucker/PluckerBookReader.java index e6ef06186..31c26c4f4 100644 --- a/src/org/geometerplus/fbreader/formats/plucker/PluckerBookReader.java +++ b/src/org/geometerplus/fbreader/formats/plucker/PluckerBookReader.java @@ -156,6 +156,8 @@ public class PluckerBookReader extends BookReader { byte[] buf = new byte[size]; doProcess = myStream.read(buf, 0, (int)size) == size; if (doProcess) { + // TODO: use encoding!!!! + // TODO: don't create any new objects!!!! myCharBuffer = new String(buf).toCharArray(); } } else if (myCompressionVersion == 1) { diff --git a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java index 453102f06..da9089baf 100644 --- a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java +++ b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java @@ -34,12 +34,13 @@ public abstract class ZLTextViewImpl extends ZLTextView { private ArrayList/**/ myModels; private final ZLTextSelectionModel mySelectionModel; - protected class Position { + protected static class Position { public int ParagraphIndex; public int WordIndex; public int CharIndex; public int ModelIndex; + // TODO: move model index to the start of argument list public Position(int paragraphIndex, int wordIndex, int charIndex, int modelIndex) { ParagraphIndex = paragraphIndex; WordIndex = wordIndex; @@ -47,7 +48,13 @@ public abstract class ZLTextViewImpl extends ZLTextView { ModelIndex = modelIndex; } + // TODO: remove public Position(ZLTextWordCursor cursor) { + this(0, cursor); + } + + public Position(int modelIndex, ZLTextWordCursor cursor) { + ModelIndex = modelIndex; set(cursor); } @@ -57,8 +64,6 @@ public abstract class ZLTextViewImpl extends ZLTextView { WordIndex = cursor.getWordIndex(); CharIndex = cursor.getCharIndex(); } - ModelIndex = myCurrentModelIndex; - // System.out.println("creating position " + myCurrentModelIndex); } public boolean equalsToCursor(ZLTextWordCursor cursor) { @@ -68,7 +73,6 @@ public abstract class ZLTextViewImpl extends ZLTextView { (CharIndex == cursor.getCharIndex()); // (ModelIndex == cursor.getModelIndex()); } - } private interface SizeUnit { @@ -141,6 +145,7 @@ public abstract class ZLTextViewImpl extends ZLTextView { } } + // TODO => setModelIndex(int modelIndex) public void setModel(int modelNumber) { if ((modelNumber != myCurrentModelIndex) && (modelNumber >= 0) && (modelNumber < myModels.size())) { @@ -352,10 +357,15 @@ public abstract class ZLTextViewImpl extends ZLTextView { protected void savePosition(Position position) { } - protected final void savePosition(Position position, ZLTextWordCursor cursor) { + // TODO: remove + protected final void savePosition(Position position, ZLTextWordCursor cursorToCheck) { + savePosition(position, 0, cursorToCheck); + } + + protected final void savePosition(Position position, int modelIndexToCheck, ZLTextWordCursor cursorToCheck) { //TODO: придумать какое-то разумное условие, чтобы позиции сохранились // при переходе к другой модели, или как-то запихать в курсор номер модели - if (!position.equalsToCursor(cursor)) { + if ((position.ModelIndex != modelIndexToCheck) || !position.equalsToCursor(cursorToCheck)) { savePosition(position); } }