void LatexDocVisitor::visitPre(DocImage *img) { if (img->type()==DocImage::Latex) { if (m_hide) return; QCString gfxName = img->name(); if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf") { gfxName=gfxName.left(gfxName.length()-4); } visitPreStart(m_t,img->hasCaption(), gfxName, img->width(), img->height()); } else // other format -> skip { pushEnabled(); m_hide=TRUE; } }
void DocSets::writeToken(FTextStream &t, const Definition *d, const QCString &type, const QCString &lang, const char *scope, const char *anchor, const char *decl) { t << " <Token>" << endl; t << " <TokenIdentifier>" << endl; QCString name = d->name(); if (name.right(2)=="-p") name=name.left(name.length()-2); t << " <Name>" << convertToXML(name) << "</Name>" << endl; if (!lang.isEmpty()) { t << " <APILanguage>" << lang << "</APILanguage>" << endl; } if (!type.isEmpty()) { t << " <Type>" << type << "</Type>" << endl; } if (scope) { t << " <Scope>" << convertToXML(scope) << "</Scope>" << endl; } t << " </TokenIdentifier>" << endl; t << " <Path>" << d->getOutputFileBase() << Doxygen::htmlFileExtension << "</Path>" << endl; if (anchor) { t << " <Anchor>" << anchor << "</Anchor>" << endl; } QCString tooltip = d->briefDescriptionAsTooltip(); if (!tooltip.isEmpty()) { t << " <Abstract>" << convertToXML(tooltip) << "</Abstract>" << endl; } if (decl) { t << " <DeclaredIn>" << convertToXML(decl) << "</DeclaredIn>" << endl; } t << " </Token>" << endl; }
QCString MIMECodec::decodeEndLine(const QCString &str) { int size = str.length(); const char *data = str.data(); QCString buffer(size); char *buf = buffer.data(); int index = 0; for (int i = 0; i < size; i++) { char c = data[i]; if (c != '\r') { buf[index++] = c; } } buffer.truncate(index); return buffer; }
void OutputList::parseDoc(const char *fileName,int startLine, Definition *ctx,MemberDef * md, const QCString &docStr,bool indexWords, bool isExample,const char *exampleName, bool singleLine,bool linkFromIndex) { int count=0; if (docStr.isEmpty()) return; OutputGenerator *og=outputs->first(); while (og) { if (og->isEnabled()) count++; og=outputs->next(); } if (count==0) return; // no output formats enabled. DocNode *root=0; if (docStr.at(docStr.length()-1)=='\n') { root = validatingParseDoc(fileName,startLine, ctx,md,docStr,indexWords,isExample,exampleName, singleLine,linkFromIndex); } else { root = validatingParseDoc(fileName,startLine, ctx,md,docStr+"\n",indexWords,isExample,exampleName, singleLine,linkFromIndex); } og=outputs->first(); while (og) { //printf("og->printDoc(extension=%s)\n", // ctx?ctx->getDefFileExtension().data():"<null>"); if (og->isEnabled()) og->printDoc(root,ctx?ctx->getDefFileExtension():QCString("")); og=outputs->next(); } delete root; }
/*! convert path name into the url in the hypertext generated by htags. * \param path path name * \returns URL NULL: not found. */ QCString Htags::path2URL(const QCString &path) { QCString url,symName=path; QCString dir = g_inputDir.absPath().utf8(); int dl=dir.length(); if ((int)symName.length()>dl+1) { symName = symName.mid(dl+1); } if (!symName.isEmpty()) { QCString *result = g_symbolDict[symName]; //printf("path2URL=%s symName=%s result=%p\n",path.data(),symName.data(),result); if (result) { url = "HTML/" + *result; } } return url; }
void MonitorWindow::save() { QString s = QFileDialog::getSaveFileName ("sim.log", QString::null, this); if (s.isEmpty()) return; QFile f(s); if (!f.open(IO_WriteOnly)){ QMessageBox::warning(this, i18n("Error"), i18n("Can't create file %1") .arg(s)); return; } QCString t; if (edit->hasSelectedText()){ t = unquoteText(edit->selectedText()).local8Bit(); }else{ t = unquoteText(edit->text()).local8Bit(); } #if defined(WIN32) || defined(__OS2__) t.replace(QRegExp("\n"),"\r\n"); #endif f.writeBlock(t, t.length()); }
QCString value_of(QCString s, QCString k, int & index, QCString & next, int & index2) { QCString result; index = s.find(k, index); if (index != -1) { index += k.length(); result = get_next_word(s, index, index2); if (! result.isEmpty()) { int index3; next = get_next_word(s, index2, index3); } } return result; }
void KRFBDecoder::sendCutEvent( const QString &unicode ) { // // Warning: There is a bug in the RFB protocol because there is no way to find // out the codepage in use on the remote machine. This could be fixed by requiring // the remote server to use utf8 etc. but for now we have to assume they're the // same. I've reported this problem to the ORL guys, but they apparantly have no // immediate plans to fix the issue. :-( (rich) // CARD8 padding[3]; QCString text = unicode.local8Bit(); CARD32 length = text.length(); length = Swap32IfLE( length ); con->write( &ClientCutTextId, 1 ); con->write( &padding, 3 ); con->write( &length, 4 ); con->write( text.data(), length ); }
void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) { VCardEntity vcards; VCardList vcardlist; vcardlist.setAutoDelete( true ); AddressBook::Iterator it; for ( it = ab->begin(); it != ab->end(); ++it ) { if ( (*it).resource() == resource ) { VCARD::VCard *v = new VCARD::VCard; saveAddressee( (*it), v, false ); (*it).setChanged( false ); vcardlist.append( v ); } } vcards.setCardList( vcardlist ); QCString vcardData = vcards.asString(); file->writeBlock( (const char*)vcardData, vcardData.length() ); }
void TooltipManager::addTooltip(Definition *d) { static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS); if (!sourceTooltips) return; QCString id = d->getOutputFileBase(); int i=id.findRev('/'); if (i!=-1) { id = id.right(id.length()-i-1); // strip path (for CREATE_SUBDIRS=YES) } id+=escapeId(Doxygen::htmlFileExtension); QCString anc = d->anchor(); if (!anc.isEmpty()) { id+="_"+anc; } if (p->tooltipInfo.find(id)==0) { p->tooltipInfo.insert(id,d); } }
static QString evilBytes( const QCString& str, bool utf8 ) { if ( utf8 ) { return protect( str ); } else { QString result; QCString t = protect( str ).latin1(); int len = ( int ) t.length(); for ( int k = 0; k < len; k++ ) { if ( ( uchar ) t[k] >= 0x7f ) result += numericEntity( ( uchar ) t[k] ); else result += QChar( t[k] ); } return result; } }
QCString HtmlHelp::recode(const QCString &s) { int iSize = s.length(); int oSize = iSize*4+1; QCString output(oSize); size_t iLeft = iSize; size_t oLeft = oSize; const char *iPtr = s.data(); char *oPtr = output.data(); if (!portable_iconv(m_fromUtf8,&iPtr,&iLeft,&oPtr,&oLeft)) { oSize -= oLeft; output.resize(oSize+1); output.at(oSize)='\0'; return output; } else { return s; } }
void cTextField::replaceSelection(const QCString &replacement) { // Delete the selection, reposition caret_, then reinsert if (selection_ != 0) { if (selection_ < 0) { setCaret(caret_ + selection_); // Place the caret at the start of the selection selection_ = - selection_; } for (int i = 0; i < selection_ && caret_ < text_.length(); ++i) { text_.remove(caret_, 1); } selection_ = 0; invalidateText(); } // Insert text at the caret int i; for (i = 0; i < (int)replacement.length() && text_.length() + 1 <= maxLength_; ++i) { text_.insert(caret_ + i, replacement.at(i)); } setCaret(caret_ + i); }
bool Definition::_docsAlreadyAdded(const QCString &doc,QCString &sigList) { uchar md5_sig[16]; QCString sigStr(33); // to avoid mismatches due to differences in indenting, we first remove // double whitespaces... QCString docStr = doc.simplifyWhiteSpace(); MD5Buffer((const unsigned char *)docStr.data(),docStr.length(),md5_sig); MD5SigToString(md5_sig,sigStr.rawData(),33); //printf("%s:_docsAlreadyAdded doc='%s' sig='%s' docSigs='%s'\n", // name().data(),doc.data(),sigStr.data(),sigList.data()); if (sigList.find(sigStr)==-1) // new docs, add signature to prevent re-adding it { sigList+=":"+sigStr; return FALSE; } else { return TRUE; } }
QCString DiagramItem::label() const { QCString result; if (!templSpec.isEmpty()) { // we use classDef->name() here and not diplayName() in order // to get the name used in the inheritance relation. QCString n = classDef->name(); if (/*n.right(2)=="-g" ||*/ n.right(2)=="-p") { n = n.left(n.length()-2); } result=insertTemplateSpecifierInScope(n,templSpec); } else { result=classDef->displayName(); } if (Config_getBool("HIDE_SCOPE_NAMES")) result=stripScope(result); return result; }
static QCString buildFileName(const char *name) { QCString fileName; if (name==0) return "noname"; const char *p=name; char c; while ((c=*p++)) { switch (c) { case ':': fileName+="_"; if (*p==':') p++; break; case '<': case '>': case '&': case '*': case '!': case '^': case '~': case '%': case '+': case '/': fileName+="_"; break; default: fileName+=c; } } QCString manExtension = "." + getExtension(); if (fileName.right(manExtension.length())!=manExtension) { fileName+=manExtension; } return fileName; }
static QCString getListOfBibFiles(const QCString &sep,bool namesOnly) { QCString result; QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); const char *bibdata = citeDataList.first(); while (bibdata) { int i; QCString bibFile = bibdata; if (namesOnly && bibFile.right(4)==".bib") // strip extension { bibFile = bibFile.left(bibFile.length()-4); } if ((i=bibFile.findRev('/'))!=-1) // strip path { bibFile = bibFile.mid(i+1); } if (!bibFile.isEmpty()) { if (namesOnly) // bare names { result+=bibFile; } else // add quotes for paths with spaces { result+="\""+bibFile+"\""; } bibdata = citeDataList.next(); if (bibdata) { result+=sep; } } else { bibdata = citeDataList.next(); } } return result; }
void LatexDocVisitor::visitPre(DocImage *img) { if (img->type()==DocImage::Latex) { if (m_hide) return; if (img->hasCaption()) { m_t << "\n\\begin{DoxyImage}\n"; } else { m_t << "\n\\begin{DoxyImageNoCaption}\n" " \\mbox{"; } QCString gfxName = img->name(); if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf") { gfxName=gfxName.left(gfxName.length()-4); } m_t << "\\includegraphics"; if (!img->width().isEmpty()) { m_t << "[width=" << img->width() << "]"; } else if (!img->height().isEmpty()) { m_t << "[height=" << img->height() << "]"; } m_t << "{" << gfxName << "}"; if (img->hasCaption()) { m_t << "\n\\caption{"; } } else // other format -> skip { pushEnabled(); m_hide=TRUE; } }
void Definition::writePathFragment(OutputList &ol) const { makeResident(); if (m_impl->outerScope && m_impl->outerScope!=Doxygen::globalScope) { m_impl->outerScope->writePathFragment(ol); } ol.writeString(" <li class=\"navelem\">"); if (isLinkable()) { if (definitionType()==Definition::TypeGroup && ((const GroupDef*)this)->groupTitle()) { ol.writeObjectLink(getReference(),getOutputFileBase(),0,((const GroupDef*)this)->groupTitle()); } else if (definitionType()==Definition::TypePage && !((const PageDef*)this)->title().isEmpty()) { ol.writeObjectLink(getReference(),getOutputFileBase(),0,((const PageDef*)this)->title()); } else if (definitionType()==Definition::TypeClass) { QCString name = m_impl->localName; if (name.right(2)=="-p" || name.right(2)=="-g") { name = name.left(name.length()-2); } ol.writeObjectLink(getReference(),getOutputFileBase(),0,name); } else { ol.writeObjectLink(getReference(),getOutputFileBase(),0,m_impl->localName); } } else { ol.startBold(); ol.docify(m_impl->localName); ol.endBold(); } ol.writeString(" </li>\n"); }
static int findMatchingPart(const QCString &path,const QCString dir) { int si1; int pos1=0,pos2=0; while ((si1=path.find('/',pos1))!=-1) { int si2=dir.find('/',pos2); //printf(" found slash at pos %d in path %d: %s<->%s\n",si1,si2, // path.mid(pos1,si1-pos2).data(),dir.mid(pos2).data()); if (si2==-1 && path.mid(pos1,si1-pos2)==dir.mid(pos2)) // match at end { return dir.length(); } if (si1!=si2 || path.mid(pos1,si1-pos2)!=dir.mid(pos2,si2-pos2)) // no match in middle { return QMAX(pos1-1,0); } pos1=si1+1; pos2=si2+1; } return 0; }
void ChatWindow::sendLine() { if (!bConnected){ qApp->beep(); return; } QColor oldColor = edtChat->color(); QString s = edtChat->text(); s.replace(QRegExp("<br>"), ""); s.replace(QRegExp("</?p>"), ""); QCString sLineSend = s.local8Bit(); chat->chat->sendLine(sLineSend); QString clientString; QString br; if (bClientMode){ int n = txtChat->paragraphs(); clientString = txtChat->text(n-1); txtChat->removeParagraph(n-1); br = "<br>"; int pos = clientString.find(">"); clientString = chatHeader(chat->getUin()) + clientString.mid(pos+4); } QString line = chatHeader(0) + MainWindow::ParseText(sLineSend, false) + "<br>\n"; txtChat->insertParagraph(br + line, -1); if (bClientMode) txtChat->insertParagraph(clientString, -1); txtChat->scrollToBottom(); txtChat->moveCursor(QTextEdit::MoveEnd, false); edtChat->setText(""); edtChat->setBold(btnBold->isOn()); edtChat->setItalic(btnItalic->isOn()); edtChat->setUnderline(btnUnderline->isOn()); if (logFile){ QCString s = line.local8Bit(); logFile->writeBlock(s, s.length()); logFile->flush(); } edtChat->setColor(oldColor); }
bool HttpClientHandler::sendFile(HttpResponseHeader & hdr,const QString & full_path) { // Out(SYS_WEB|LOG_DEBUG) << "Sending file " << full_path << endl; // first look in cache MMapFile* c = srv->cacheLookup(full_path); if (!c) { // not in cache so load it c = new MMapFile(); if (!c->open(full_path,MMapFile::READ)) { delete c; Out(SYS_WEB|LOG_DEBUG) << "Failed to open file " << full_path << endl; return false; } srv->insertIntoCache(full_path,c); } hdr.setValue("Content-Length",QString::number(c->getSize())); // Out(SYS_WEB|LOG_DEBUG) << "HTTP header : " << endl; // Out(SYS_WEB|LOG_DEBUG) << hdr.toString() << endl; QCString d = hdr.toString().utf8(); client->writeBlock(d.data(),d.length()); Uint32 written = 0; Uint32 total = c->getSize(); const char* data = (const char*)c->getDataPointer(); while (written < total) { Uint32 w = client->writeBlock(data + written,total - written); written += w; } client->flush(); // Out(SYS_WEB|LOG_DEBUG) << "Finished sending " << full_path << " (" << written << " bytes)" << endl; return true; }
static void continueInWindow(QString _wname) { QCString wname = _wname.latin1(); int id = -1; QCStringList apps = kapp->dcopClient()->registeredApplications(); for (QCStringList::Iterator it = apps.begin(); it != apps.end(); ++it) { QCString &clientId = *it; if (qstrncmp(clientId, wname, wname.length()) != 0) continue; DCOPRef client(clientId.data(), wname + "-mainwindow#1"); DCOPReply result = client.call("getWinID()"); if (result.isValid()) { id = (int)result; break; } } KWin::activateWindow(id); }
bool PasswdProcess::isPrompt(QCString line, const char *word) { unsigned i, j, colon; unsigned int lineLength(line.length()); for(i = 0, j = 0, colon = 0; i < lineLength; i++) { if(line[i] == ':') { j = i; colon++; continue; } if(!isspace(line[i])) j++; } if((colon != 1) || (line[j] != ':')) return false; if(word == 0L) return true; return line.contains(word, false); }
bool KNGroupListData::writeOut() { QFile f(path + "groups"); QCString temp; if(f.open(IO_WriteOnly)) { for(KNGroupInfo *i = groups->first(); i; i = groups->next()) { temp = i->name.utf8(); switch(i->status) { case KNGroup::unknown: temp += " u "; break; case KNGroup::readOnly: temp += " n "; break; case KNGroup::postingAllowed: temp += " y "; break; case KNGroup::moderated: temp += " m "; break; } temp += i->description.utf8() + "\n"; f.writeBlock(temp.data(), temp.length()); } f.close(); return true; } else { kdWarning(5003) << "unable to open " << f.name() << " reason " << f.status() << endl; return false; } }
void LoggerWidget::save() { QString file = KFileDialog::getSaveFileName( QString::null, QString::null, this ); if ( !file.isNull() ) { QFile f( file ); if ( f.exists() ) { int result = KMessageBox::warningContinueCancel( this, i18n( "Log file exists, overwrite?" ), i18n( "KDat: Save Log" ), i18n("&Overwrite")); if (result != KMessageBox::Continue) return; } if ( f.open( IO_WriteOnly ) ) { QCString line; for ( int i = 0; i < _mle->numLines(); i++ ) { line = _mle->textLine( i ).utf8(); f.writeBlock( line, line.length() ); f.writeBlock( "\n", 1 ); } f.close(); } } }
static QCString wc2rx( const QCString &pattern ) { int patlen = (int)pattern.length(); QCString wcpattern("^"); char c; for( int i = 0; i < patlen; i++ ) { c = pattern[i]; switch ( (char)c ) { case '*': // '*' ==> '.*' wcpattern += '.'; break; case '?': // '?' ==> '.' c = '.'; break; case '.': // quote special regexp chars case '+': case '\\': case '$': case '^': wcpattern += '\\'; break; case '[': if ( (char)pattern[i+1] == '^' ) { // don't quote '^' after '[' wcpattern += '['; c = pattern[i+1]; i++; } break; } wcpattern += c; } wcpattern += '$'; return wcpattern; // return new regexp pattern }
void QUrl::decode( QString& url ) { if ( url.isEmpty() ) return; int newlen = 0; QCString curl = url.utf8(); int oldlen = curl.length(); QCString newUrl(oldlen); int i = 0; while ( i < oldlen ) { uchar c = (uchar)curl[ i++ ]; if ( c == '%' && i <= oldlen - 2 ) { c = hex_to_int( (uchar)curl[ i ] ) * 16 + hex_to_int( (uchar)curl[ i + 1 ] ); i += 2; } newUrl [ newlen++ ] = c; } newUrl.truncate( newlen ); url = QString::fromUtf8(newUrl.data()); }
QString KXFace::fromImage(const QImage &image) { if(image.isNull()) return QString::null; QImage scaledImg = image.smoothScale(48, 48); QByteArray ba; QBuffer buffer(ba); buffer.open(IO_WriteOnly); scaledImg.save(&buffer, "XBM"); QString xbm(ba); xbm.remove(0, xbm.find("{") + 1); xbm.truncate(xbm.find("}")); xbm.remove(" "); xbm.remove(","); xbm.remove("0x"); xbm.remove("\n"); xbm.truncate(576); QCString tmp = QCString(xbm.latin1()); uint len = tmp.length(); for(uint i = 0; i < len; ++i) { switch(tmp[i]) { case '1': tmp[i] = '8'; break; case '2': tmp[i] = '4'; break; case '3': tmp[i] = 'c'; break; case '4': tmp[i] = '2'; break; case '5': tmp[i] = 'a'; break; case '7': tmp[i] = 'e'; break; case '8': tmp[i] = '1'; break; case 'A': case 'a': tmp[i] = '5'; break; case 'B': case 'b': tmp[i] = 'd'; break; case 'C': case 'c': tmp[i] = '3'; break; case 'D': case 'd': tmp[i] = 'b'; break; case 'E': case 'e': tmp[i] = '7'; break; } if(i % 2) { char t = tmp[i]; tmp[i] = tmp[i - 1]; tmp[i - 1] = t; } } tmp.replace(QRegExp("(\\w{12})"), "\\1\n"); tmp.replace(QRegExp("(\\w{4})"), "0x\\1,"); len = tmp.length(); char *fbuf = (char *)malloc(len + 1); strncpy(fbuf, (const char *)tmp, len); fbuf[len] = '\0'; if(!(status = setjmp(comp_env))) { ReadFace(fbuf); GenFace(); CompAll(fbuf); } QString ret(fbuf); free(fbuf); return ret; }
void writeCString(QDataStream &stream, QCString &str) { stream.writeRawBytes(str.data(), str.length()); stream << (Q_UINT8)0; }