Ejemplo n.º 1
0
bool OleMainStream::open(bool doReadFormattingData) {
	if (OleStream::open() == false) {
		return false;
	}

	static const std::size_t HEADER_SIZE = 768; //size of data in header of main stream
	char headerBuffer[HEADER_SIZE];
	seek(0, true);

	if (read(headerBuffer, HEADER_SIZE) != HEADER_SIZE) {
		return false;
	}

	bool result = readFIB(headerBuffer);
	if (!result) {
		return false;
	}

	// determining table stream number
	unsigned int tableNumber = (OleUtil::getU2Bytes(headerBuffer, 0xA) & 0x0200) ? 1 : 0;
	std::string tableName = tableNumber == 0 ? "0" : "1";
	tableName += "Table";
	OleEntry tableEntry;
	result = myStorage->getEntryByName(tableName, tableEntry);

	if (!result) {
		// cant't find table stream (that can be only in case if file format is below Word 7/8), so building simple table stream
		// TODO: CHECK may be not all old documents have ANSI
		ZLLogger::Instance().println("DocPlugin", "cant't find table stream, building own simple piece table, that includes all charachters");
		Piece piece = {myStartOfText, myEndOfText - myStartOfText, true, Piece::PIECE_TEXT, 0};
		myPieces.push_back(piece);
		return true;
	}

	result = readPieceTable(headerBuffer, tableEntry);

	if (!result) {
		ZLLogger::Instance().println("DocPlugin", "error during reading piece table");
		return false;
	}

	if (!doReadFormattingData) {
		return true;
	}

	OleEntry dataEntry;
	if (myStorage->getEntryByName("Data", dataEntry)) {
		myDataStream = new OleStream(myStorage, dataEntry, myBaseStream);
	}

	//result of reading following structures doesn't check, because all these
	//problems can be ignored, and document can be showed anyway, maybe with wrong formatting
	readBookmarks(headerBuffer, tableEntry);
	readStylesheet(headerBuffer, tableEntry);
	//readSectionsInfoTable(headerBuffer, tableEntry); //it isn't used now
	readParagraphStyleTable(headerBuffer, tableEntry);
	readCharInfoTable(headerBuffer, tableEntry);
	readFloatingImages(headerBuffer, tableEntry);
	return true;
}
Ejemplo n.º 2
0
void Themes::setTheme(QString &themeQss, QStringList &skinPaths) {
	QDir::setSearchPaths(QLatin1String("skin"), skinPaths);
	
	QString userStylesheetFn = userStylesheetPath();
	QString userStylesheetContent;
	if (readStylesheet(userStylesheetFn, userStylesheetContent)) {
		qWarning("Themes: allowing user stylesheet at '%s' to override the stylesheet", qPrintable(userStylesheetFn));
	}
	
	qApp->setStyleSheet(
		themeQss +
		QLatin1String("\n") +
		userStylesheetContent
	);

}