コード例 #1
0
void StylesPlugin::setStyles()
{
    QStyle *style = NULL;
#if QT_VERSION >= 300
    if (*getStyle())
        style = QStyleFactory::create(getStyle());
#else
if (*getStyle()){
    string s = getStyle();
    if (s == "windows"){
        style = new QWindowsStyle;
    }else if (s == "motif"){
        style = new QMotifStyle;
    }else if (s == "cde"){
        style = new QCDEStyle;
    }else if (s == "motifplus"){
        style = new QMotifPlusStyle;
    }else if (s == "platinum"){
        style = new QPlatinumStyle;
    }else if (s == "sgi"){
        style = new QSGIStyle;
#ifdef WIN32
    }else{
        bool bOK = true;
        if (s == "xpstyle"){
            HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
            if (hLib){
                FreeLibrary(hLib);
            }else{
                bOK = false;
            }
        }
        if (bOK){
            string dll = "plugins\\styles\\";
            dll += s;
            dll += ".dll";
            HINSTANCE hLib = LoadLibraryA(app_file(dll.c_str()).c_str());
            if (hLib){
                StyleInfo*  (*getStyleInfo)() = NULL;
                (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
                if (getStyleInfo){
                    StyleInfo *info = getStyleInfo();
                    if (info && info->create)
                        style = info->create();
                }
            }
        }
#endif
    }
}
#endif
    if (style){
        QApplication::setStyle(style);
        if (!getSystemColors())
            setColors();
    }else{
        setStyle(NULL);
    }
}
コード例 #2
0
bool OleMainStream::readParagraphStyleTable(const char *headerBuffer, const OleEntry &tableEntry) {
	//PlcBtePapx structure is table with formatting for all paragraphs
	unsigned int beginParagraphInfo = OleUtil::getU4Bytes(headerBuffer, 0x102); // address of PlcBtePapx structure
	std::size_t paragraphInfoLength = (std::size_t)OleUtil::getU4Bytes(headerBuffer, 0x106); // length of PlcBtePapx structure
	if (paragraphInfoLength < 4) {
		return false;
	}

	OleStream tableStream(myStorage, tableEntry, myBaseStream);
	std::string buffer;
	if (!readToBuffer(buffer, beginParagraphInfo, paragraphInfoLength, tableStream)) {
		return false;
	}

	static const unsigned int PAPX_SIZE = 4;
	std::size_t size = calcCountOfPLC(paragraphInfoLength, PAPX_SIZE);

	std::vector<unsigned int> paragraphBlocks;
	for (std::size_t index = 0, tOffset = (size + 1) * 4; index < size; ++index, tOffset += PAPX_SIZE) {
		paragraphBlocks.push_back(OleUtil::getU4Bytes(buffer.c_str(), tOffset));
	}

	char *formatPageBuffer = new char[OleStorage::BBD_BLOCK_SIZE];
	for (std::size_t index = 0; index < paragraphBlocks.size(); ++index) {
		seek(paragraphBlocks.at(index) * OleStorage::BBD_BLOCK_SIZE, true);
		if (read(formatPageBuffer, OleStorage::BBD_BLOCK_SIZE) != OleStorage::BBD_BLOCK_SIZE) {
			return false;
		}
		const unsigned int paragraphsCount = OleUtil::getU1Byte(formatPageBuffer, 0x1ff); //offset with 'cpara' value (count of paragraphs)
		for (unsigned int index2 = 0; index2 < paragraphsCount; ++index2) {
			const unsigned int offset = OleUtil::getU4Bytes(formatPageBuffer, index2 * 4);
			unsigned int papxOffset = OleUtil::getU1Byte(formatPageBuffer, (paragraphsCount + 1) * 4 + index2 * 13) * 2;
			if (papxOffset <= 0) {
				continue;
			}
			unsigned int len = OleUtil::getU1Byte(formatPageBuffer, papxOffset) * 2;
			if (len == 0) {
				++papxOffset;
				len = OleUtil::getU1Byte(formatPageBuffer, papxOffset) * 2;
			}

			const unsigned int styleId = OleUtil::getU2Bytes(formatPageBuffer, papxOffset + 1);
			Style styleInfo = getStyleFromStylesheet(styleId, myStyleSheet);

			if (len >= 3) {
				getStyleInfo(papxOffset, formatPageBuffer + 3, len - 3, styleInfo);
			}

			unsigned int charPos = 0;
			if (!offsetToCharPos(offset, charPos, myPieces)) {
				continue;
			}
			myStyleInfoList.push_back(CharPosToStyle(charPos, styleInfo));
		}
	}
	delete[] formatPageBuffer;
	return true;
}
コード例 #3
0
int main(int argc, char *argv[])
{
    int res = 1;
#ifdef WIN32
    HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex");
#endif
    QApplication::setColorSpec( QApplication::ManyColor );
    qInstallMsgHandler(simMessageOutput);
    KAboutData aboutData(PACKAGE,
                         I18N_NOOP("SIM"),
                         _VERSION,
                         I18N_NOOP("Multiprotcol instant messenger"),
                         KAboutData::License_GPL,
                         "Copyright (C) 2002-2004, Vladimir Shutoff",
                         0,
                         "http://sim-icq.sourceforge.net/",
                         "*****@*****.**");
    aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**");
    aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**");
    setAboutData(&aboutData);
#ifndef WIN32
    int _argc = 0;
    char **_argv = new char*[argc + 1];
    _argv[_argc++] = argv[0];
    char **to = argv + 1;
    // check all parameters and sort them
    // _argc/v: parameter for KUnqiueApplication
    //  argc/v: plugin parameter
    for (char **p = argv + 1; *p; ++p){
        char *arg = *p;
        // check if "-" or "--"
        if (arg[0] != '-') {
            *(to++) = *p;
            continue;
        }
        arg++;
        if (arg[0] == '-')
            arg++;
        // if they are parameters with variable params we need
        // to skip the next param
        bool bSkip = false;
        const char **q;
        // check for qt or kde - parameters
        for (q = qt_args; *q; ++q){
            unsigned len = strlen(*q);
            bSkip = false;
            // variable parameter?
            if ((*q)[len-1] == ':'){
                len--;
                bSkip = true;
            }
            // copy them for KUnqiueApplication-args
            if ((strlen(arg) == len) && !memcmp(arg, *q, len))
                break;
        }
        // dunno know what to do here
        if (*q){
            _argv[_argc++] = *p;
            argc--;
            if (bSkip){
                ++p;
                if (*p == NULL) break;
                _argv[_argc++] = *p;
                argc--;
            }
        }else{
            *(to++) = *p;
        }
    }
    *to = NULL;
    _argv[_argc] = NULL;
#ifdef USE_KDE
    KCmdLineArgs::init( _argc, _argv, &aboutData );
    KCmdLineOptions options[] =
        {
            { 0, 0, 0 }
        };
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();
    if (!KUniqueApplication::start())
        exit(-1);
    SimApp app;
#else
    SimApp app(_argc, _argv);
#endif
#ifndef QT_MACOSX_VERSION
    old_errhandler = XSetErrorHandler(x_errhandler);
#endif
#else
	for (int i = 0; i < argc; i++){
		string arg = argv[i];
		if ((arg[0] == '/') || (arg[0] == '-'))
			arg = arg.substr(1);
		if ((arg == "reinstall") || (arg == "showicons") || (arg == "hideicons"))
			return 0;
	}
    SimApp app(argc, argv);
    StyleInfo*  (*getStyleInfo)() = NULL;
    HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
    if (hLib != NULL)
        hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str());
    if (hLib != NULL)
        (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
    if (getStyleInfo){
        StyleInfo *info = getStyleInfo();
        if (info)
            qApp->setStyle(info->create());
    }
#endif
    PluginManager p(argc, argv);
    if (p.isLoaded())
        res = app.exec();
#ifdef WIN32
    CloseHandle(hMutex);
#endif
    return res;
};
コード例 #4
0
bool OleMainStream::readStylesheet(const char *headerBuffer, const OleEntry &tableEntry) {
	//STSH structure is a stylesheet
	unsigned int beginStshInfo = OleUtil::getU4Bytes(headerBuffer, 0xa2); // address of STSH structure
	std::size_t stshInfoLength = (std::size_t)OleUtil::getU4Bytes(headerBuffer, 0xa6); // length of STSH structure

	OleStream tableStream(myStorage, tableEntry, myBaseStream);
	char *buffer = new char[stshInfoLength];
	if (!tableStream.seek(beginStshInfo, true)) {
		ZLLogger::Instance().println("DocPlugin", "problems with reading STSH structure");
		return false;
	}
	if (tableStream.read(buffer, stshInfoLength) != stshInfoLength) {
		ZLLogger::Instance().println("DocPlugin", "problems with reading STSH structure, invalid length");
		return false;
	}

	std::size_t stdCount = (std::size_t)OleUtil::getU2Bytes(buffer, 2);
	std::size_t stdBaseInFile = (std::size_t)OleUtil::getU2Bytes(buffer, 4);
	myStyleSheet.resize(stdCount);

	std::vector<bool> isFilled;
	isFilled.resize(stdCount, false);

	std::size_t stdLen = 0;
	bool styleSheetWasChanged = false;
	do { //make it in while loop, because some base style can be after their successors
		styleSheetWasChanged = false;
		for (std::size_t index = 0, offset = 2 + (std::size_t)OleUtil::getU2Bytes(buffer, 0); index < stdCount; index++, offset += 2 + stdLen) {
			stdLen = (std::size_t)OleUtil::getU2Bytes(buffer, offset);
			if (isFilled.at(index)) {
				continue;
			}

			if (stdLen == 0) {
				//if record is empty, left it default
				isFilled[index] = true;
				continue;
			}

			Style styleInfo = myStyleSheet.at(index);

			const unsigned int styleAndBaseType = OleUtil::getU2Bytes(buffer, offset + 4);
			const unsigned int styleType = styleAndBaseType % 16;
			const unsigned int baseStyleId = styleAndBaseType / 16;
			if (baseStyleId == Style::STYLE_NIL || baseStyleId == Style::STYLE_USER) {
				//if based on nil or user style, left default
			} else {
				int baseStyleIndex = getStyleIndex(baseStyleId, isFilled, myStyleSheet);
				if (baseStyleIndex < 0) {
					//this base style is not filled yet, so pass it at some time
					continue;
				}
				styleInfo = myStyleSheet.at(baseStyleIndex);
				styleInfo.StyleIdCurrent = Style::STYLE_INVALID;
			}

			// parse STD structure
			unsigned int tmp = OleUtil::getU2Bytes(buffer, offset + 6);
			unsigned int upxCount = tmp % 16;
			styleInfo.StyleIdNext = tmp / 16;

			//adding current style
			myStyleSheet[index] = styleInfo;
			isFilled[index] = true;
			styleSheetWasChanged = true;

			std::size_t pos = 2 + stdBaseInFile;
			std::size_t nameLen = (std::size_t)OleUtil::getU2Bytes(buffer, offset + pos);
			nameLen = nameLen * 2 + 2; //from Unicode characters to bytes + Unicode null charachter length
			pos += 2 + nameLen;
			if (pos % 2 != 0) {
				++pos;
			}
			if (pos >= stdLen) {
				continue;
			}
			std::size_t upxLen = (std::size_t)OleUtil::getU2Bytes(buffer, offset + pos);
			if (pos + upxLen > stdLen) {
				//UPX length too large
				continue;
			}
			//for style info styleType must be equal 1
			if (styleType == 1 && upxCount >= 1) {
				if (upxLen >= 2) {
					styleInfo.StyleIdCurrent = OleUtil::getU2Bytes(buffer, offset + pos + 2);
					getStyleInfo(0, buffer + offset + pos + 4, upxLen - 2, styleInfo);
					myStyleSheet[index] = styleInfo;
				}
				pos += 2 + upxLen;
				if (pos % 2 != 0) {
					++pos;
				}
				upxLen = (std::size_t)OleUtil::getU2Bytes(buffer, offset + pos);
			}
			if (upxLen == 0 || pos + upxLen > stdLen) {
				//too small/too large
				continue;
			}
			//for char info styleType can be equal 1 or 2
			if ((styleType == 1 && upxCount >= 2) || (styleType == 2 && upxCount >= 1)) {
				CharInfo charInfo;
				getCharInfo(0, Style::STYLE_INVALID, buffer + offset + pos + 2, upxLen, charInfo);
				styleInfo.CurrentCharInfo = charInfo;
				myStyleSheet[index] = styleInfo;
			}
		}
	} while (styleSheetWasChanged);
	delete[] buffer;
	return true;
}