private void safeBeginParagraph() { if (!myParagraphStarted) { myParagraphStarted = true; myBufferIsEmpty = true; beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH); if (!myParagraphStored) { // final ArrayList models = Model.getBookTextModels(); // myParagraphVector.add(new Pair(((ZLTextPlainModel) // models.get(models.size()-1)/*BookTextModel*/).getParagraphsNumber() - 1, models.size() - // 1)); myParagraphStored = true; } for (Iterator it = myDelayedControls.iterator(); it.hasNext(); ) { Pair pit = (Pair) it.next(); addControl((Byte) pit.myFirst, (Boolean) pit.mySecond); } // if (myForcedEntry != null) { // addControl(myForcedEntry); // } else { addControl(FBTextKind.REGULAR, true); // } for (Iterator it = myDelayedHyperlinks.iterator(); it.hasNext(); ) { addHyperlinkControl(FBTextKind.INTERNAL_HYPERLINK, (String) it.next()); } myDelayedHyperlinks.clear(); } }
private void processTextParagraph(char[] data, int start, int end) { changeFont(FontType.FT_REGULAR); while (popKind()) {} myParagraphStarted = false; myBytesToSkip = 0; int textStart = start; boolean functionFlag = false; for (int ptr = start; ptr < end; ++ptr) { if (data[ptr] == 0) { functionFlag = true; if (ptr > textStart) { safeBeginParagraph(); // myConvertedTextBuffer = "";//.erase(); myConvertedTextBuffer = ""; // myConverter.convert(data, textStart, ptr); addData(myConvertedTextBuffer.toCharArray()); myBufferIsEmpty = false; } } else if (functionFlag) { int paramCounter = (data[ptr]) % 8; if (end - ptr > paramCounter) { processTextFunction(data, ptr); ptr += paramCounter; } else { ptr = end - 1; } functionFlag = false; if (myBytesToSkip > 0) { ptr += myBytesToSkip; myBytesToSkip = 0; } textStart = ptr + 1; } else { if (data[ptr] == 0xA0) { data[ptr] = 0x20; } if (!myParagraphStarted && (textStart == ptr) && (data[ptr] == ' ')) { ++textStart; } } } if (end > textStart) { safeBeginParagraph(); // myConvertedTextBuffer = "";//erase(); myConvertedTextBuffer = ""; // myConverter.convert(data, textStart, end); addData(myConvertedTextBuffer.toCharArray()); myBufferIsEmpty = false; } safeEndParagraph(); // if (myForcedEntry != null) { // myForcedEntry = null; // } myDelayedControls.clear(); }
public boolean readDocument() { try { myStream = new ZLInputStreamWithOffset(myFile.getInputStream()); PdbHeader header = new PdbHeader(myStream); setMainTextModel(); myFont = FontType.FT_REGULAR; for (int index = 0; index < header.Offsets.length; ++index) { int currentOffset = myStream.offset(); int pit = header.Offsets[index]; if (currentOffset > pit) { break; } // myStream.seek(pit - currentOffset, false); myStream.skip(pit - currentOffset); if (myStream.offset() != pit) { break; } int recordSize = ((index != header.Offsets.length - 1) ? header.Offsets[index + 1] : myFileSize) - pit; readRecord(recordSize); } myStream.close(); } catch (IOException e) { return false; } for (Iterator it = myReferencedParagraphs.iterator(); it.hasNext(); ) { Pair pair = (Pair) it.next(); int first = (Integer) pair.myFirst; int second = (Integer) pair.mySecond; ArrayList /*<Integer>*/ list = (ArrayList) myParagraphMap.get(first); if (list != null) { for (int k = second; k < list.size(); ++k) { if (((Integer) ((Pair) list.get(k)).myFirst) != -1) { // addHyperlinkLabel(fromNumber(first) + '#' + fromNumber(second), // (Integer)list.get(k)); final Pair p = (Pair) list.get(k); // addHyperlinkLabel(fromNumber(first) + '#' + fromNumber(second), (Integer) p.mySecond, // (Integer) p.myFirst); break; } } } } myReferencedParagraphs.clear(); myParagraphMap.clear(); return true; }