Beispiel #1
0
void PmlReader::processTag(std::string &tagName, const std::string &parameter) {
	const char tagDeterminant = *tagName.data();
	switch (tagDeterminant) {
		case 'p':
			newPage();
			break;
		case 'x':
			//TODO add close tag processing
			newPage();
			break;
		case 'B':
			if (!myState.BoldBlockOn) {
				processFontProperty(FONT_BOLD);
			}
			break;
		case 'i': 
			processFontProperty(FONT_ITALIC);
			break;
		case 'u': 
			processFontProperty(FONT_UNDERLINED);
			break;
		case 'v': 
			myState.InvisibleText = !myState.InvisibleText;;
			break;
		case 'c':
			processAlignment(ALIGN_CENTER);
			break;
		case 'r':
			processAlignment(ALIGN_RIGHT);
			break;
		case 'n':
			processFontSize(NORMAL);
			break;
		case 'b':
			myState.BoldBlockOn = !myState.BoldBlockOn;
			processFontProperty(FONT_BOLD);
			break;
		case 's':
			processFontSize(SMALLER);
			break;
		case 'l':
			processFontSize(LARGER);
			break;
		case 'k':
			myState.SmallCaps = !myState.SmallCaps;
			processFontSize(SMALLER);
			break;
		case 'S':
			if (tagName == "Sb") {
				processFontProperty(FONT_SUBSCRIPT);
			} else if (tagName == "Sp") {
				processFontProperty(FONT_SUPERSCRIPT);
			} else if (tagName == "Sd") {
				//processSidebarLink();
			}
			break;
		case 't':
			processIndent();
			break;
		case 'T':
			processIndent(parameter);
			myState.IndentBlockOn = false;
			break;
		case 'w':
			//addHorizontalRule(parameter);
			break;	
		case 'F':
			processLink(FOOTNOTE, parameter);
			break;
		case 'q':
			processLink(INTERNAL_HYPERLINK, parameter);
			break;
		case 'Q':
			addLinkLabel(parameter);
			break;
		case 'm':
			addImageReference(parameter);
			break;
		default:
			//std::cerr << "PmlReader: unsupported tag: name: " << tagName << "	parameter: " << parameter << "\n"; 
			break;
	}
}
void PluckerBookReader::processTextFunction(char *ptr) {
	switch ((unsigned char)*ptr) {
		case 0x08:
			safeAddControl(INTERNAL_HYPERLINK, false);
			break;
		case 0x0A:
			safeAddHyperlinkControl(fromNumber(twoBytes(ptr + 1)));
			break;
		case 0x0C:
		{
			int sectionNum = twoBytes(ptr + 1);
			int paragraphNum = twoBytes(ptr + 3);
			safeAddHyperlinkControl(fromNumber(sectionNum) + '#' + fromNumber(paragraphNum));
			myReferencedParagraphs.insert(std::pair<int,int>(sectionNum, paragraphNum));
			break;
		}
		case 0x11:
			changeFont((FontType)*(ptr + 1));
			break;
		case 0x1A:
			safeBeginParagraph();
			addImageReference(fromNumber(twoBytes(ptr + 1)));
			break;
		case 0x22:
			if (!myParagraphStarted) {
				if (myForcedEntry == 0) {
					myForcedEntry = new ZLTextForcedControlEntry();
				}
				myForcedEntry->setLeftIndent(*(ptr + 1));
				myForcedEntry->setRightIndent(*(ptr + 2));
			}
			break;
		case 0x29:
			if (!myParagraphStarted) {
				if (myForcedEntry == 0) {
					myForcedEntry = new ZLTextForcedControlEntry();
				}
				switch (*(ptr + 1)) {
					case 0: myForcedEntry->setAlignmentType(ALIGN_LEFT); break;
					case 1: myForcedEntry->setAlignmentType(ALIGN_RIGHT); break;
					case 2: myForcedEntry->setAlignmentType(ALIGN_CENTER); break;
					case 3: myForcedEntry->setAlignmentType(ALIGN_JUSTIFY); break;
				}
			}
			break;
		case 0x33: // just break line instead of horizontal rule (TODO: draw horizontal rule?)
			safeEndParagraph();
			break;
		case 0x38:
			safeEndParagraph();
			break;
		case 0x40: 
			safeAddControl(EMPHASIS, true);
			break;
		case 0x48:
			safeAddControl(EMPHASIS, false);
			break;
		case 0x53: // color setting is ignored
			break;
		case 0x5C:
			addImageReference(fromNumber(twoBytes(ptr + 3)));
			break;
		case 0x60: // underlined text is ignored
			break;
		case 0x68: // underlined text is ignored
			break;
		case 0x70: // strike-through text is ignored
			break;
		case 0x78: // strike-through text is ignored
			break;
		case 0x83: 
		{
			char utf8[4];
			int len = ZLUnicodeUtil::ucs2ToUtf8(utf8, twoBytes(ptr + 2));
			safeBeginParagraph();
			addData(std::string(utf8, len));
			myBufferIsEmpty = false;
			myBytesToSkip = *(ptr + 1);
			break;
		}
		case 0x85: // TODO: process 4-byte unicode character
			break;
		case 0x8E: // custom font operations are ignored
		case 0x8C:
		case 0x8A:
		case 0x88:
			break;
		case 0x90: // TODO: add table processing
		case 0x92: // TODO: process table
		case 0x97: // TODO: process table
			break;
		default: // this should be impossible
			//std::cerr << "Oops... function #" << (int)(unsigned char)*ptr << "\n";
			break;
	}
}