--Boundary-00=_rv0L9VvCSYWbRkI Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8bit Content-Disposition: inline Here is the patch which adds support for more fields to RTF Import filter. It also fixes a little problem with importing document title. Please test and apply if correct. Tomek PS One more question: abstract==comments or abstract==subject I think that the second one is correct, but I'm not sure. --Boundary-00=_rv0L9VvCSYWbRkI Content-Type: text/x-diff; charset="iso-8859-2"; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch" Common subdirectories: import/CVS and import.my/CVS diff -u -3 -p -d -b import/rtfimport.cpp import.my/rtfimport.cpp --- import/rtfimport.cpp Sat Jul 6 19:54:34 2002 +++ import.my/rtfimport.cpp Fri Jul 12 23:15:40 2002 @@ -22,6 +22,8 @@ #include #include #include +#include +#include typedef KGenericFactory RTFImportFactory; K_EXPORT_COMPONENT_FACTORY( librtfimport, RTFImportFactory( "rtfimport" ) ); @@ -579,10 +581,10 @@ KoFilter::ConversionStatus RTFImport::co docInfo.addNode( "abstract" ); docInfo.appendNode( doccomm ); docInfo.closeNode( "abstract" ); - docInfo.closeNode( "about" ); docInfo.addNode( "title" ); docInfo.appendNode( title ); docInfo.closeNode( "title" ); + docInfo.closeNode( "about" ); docInfo.closeNode( "document-info" ); // Write out main document and document info @@ -1239,6 +1241,7 @@ void RTFImport::parseFldinst( RTFPropert { static QCString str; static bool formatInserted; + static RTFFormat fmt; if (token.type == RTFTokenizer::OpenGroup) { str=""; @@ -1247,15 +1250,7 @@ void RTFImport::parseFldinst( RTFPropert else if (token.type == RTFTokenizer::PlainText) { str+=token.text; - if(!formatInserted) - { - kwFormat.fmt = state.format; - kwFormat.id = 1; - kwFormat.pos = textState->length; - kwFormat.len = 1; - textState->formats << kwFormat; - formatInserted=true; - } + fmt=state.format; } else if (token.type == RTFTokenizer::CloseGroup) { @@ -1263,8 +1258,10 @@ void RTFImport::parseFldinst( RTFPropert node.clear(7); QCString key; int type=-1; - str=str.upper(); - if(str.find("AUTHOR")!=-1) + QStringList list; + list=QStringList::split('\\', str); + list[0]=list[0].upper().stripWhiteSpace(); + if(list[0]=="AUTHOR") { key="STRING"; type=8; @@ -1273,9 +1270,130 @@ void RTFImport::parseFldinst( RTFPropert node.setAttribute("value", "NO AUTHOR"); node.closeNode("FIELD"); } + if(list[0]=="FILENAME") + { + key="STRING"; + type=8; + node.addNode("FIELD"); + node.setAttribute("subtype", 0); + node.setAttribute("value", "NO FILENAME"); + node.closeNode("FIELD"); + } + if(list[0]=="TITLE") + { + key="STRING"; + type=8; + node.addNode("FIELD"); + node.setAttribute("subtype", 10); + node.setAttribute("value", "NO TITLE"); + node.closeNode("FIELD"); + } + if(list[0]=="NUMPAGES") + { + key="NUMBER"; + type=4; + node.addNode("PGNUM"); + node.setAttribute("subtype", 1); + node.setAttribute("value", 0); + node.closeNode("PGNUM"); + } + if(list[0]=="PAGE") + { + key="NUMBER"; + type=4; + node.addNode("PGNUM"); + node.setAttribute("subtype", 0); + node.setAttribute("value", 0); + node.closeNode("PGNUM"); + } + if((list[0]=="TIME")||(list[0]=="DATE")) + { + unsigned int j; + for(j=1;jonlyValidIn=0L; @@ -1298,7 +1416,7 @@ void RTFImport::parseFldinst( RTFPropert } } -void RTFImport::addVariable(DomNode& spec, int type, QCString key) +void RTFImport::addVariable(DomNode& spec, int type, QCString key, RTFFormat* fmt) { DomNode node; @@ -1317,6 +1435,8 @@ void RTFImport::addVariable(DomNode& spe kwFormat.id = 4; kwFormat.pos = textState->length++; kwFormat.len = 1; + if(fmt) + kwFormat.fmt = *fmt; textState->text.putch( '#' ); textState->formats << kwFormat; } @@ -1540,7 +1660,7 @@ void RTFImport::addFormat( DomNode &node else node.setAttribute( "len", 1); } - if (format.id == 1) + if ((format.id == 1)||(format.id == 4)) { // Normal text, store changes between format and base format if (!baseFormat || format.fmt.color != baseFormat->color) @@ -1618,7 +1738,7 @@ void RTFImport::addFormat( DomNode &node node.closeNode( "CHARSET" ); } } - else if (format.id == 4 || format.id == 6) + if (format.id == 4 || format.id == 6) { // Variable or anchor node.closeTag( true ); diff -u -3 -p -d -b import/rtfimport.h import.my/rtfimport.h --- import/rtfimport.h Sat Jul 6 19:54:34 2002 +++ import.my/rtfimport.h Fri Jul 12 22:06:15 2002 @@ -240,7 +240,7 @@ public: void addFormat( DomNode &node, KWFormat &format, RTFFormat *baseFormat ); void addLayout( DomNode &node, QCString &name, RTFLayout &layout, bool frameBreak ); void addParagraph( DomNode &node, bool frameBreak ); - void addVariable(DomNode& spec, int type, QCString key); + void addVariable(DomNode& spec, int type, QCString key, RTFFormat* fmt=0); void finishTable(); void writeOutPart( const char *name, QByteArray &array ); void writeOutMetafile( const char *name, QByteArray &array ); --Boundary-00=_rv0L9VvCSYWbRkI-- _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel