41#include <tdemessagebox.h>
46#include "KWEFStructures.h"
47#include "TagProcessing.h"
48#include "ProcessDocument.h"
49#include "KWEFBaseWorker.h"
50#include "KWEFKWordLeader.h"
52KWEFKWordLeader::KWEFKWordLeader(
void)
53 : m_syntaxVersion(-1), m_oldSyntax(false), m_worker(NULL), m_chain(NULL), m_hType(0), m_fType(0)
58 : m_syntaxVersion(-1), m_oldSyntax(false), m_worker(newWorker), m_chain(NULL)
60 if (newWorker) newWorker->registerKWordLeader(
this);
63KWEFKWordLeader::~KWEFKWordLeader(
void)
67static FrameAnchor *findAnchor (
const KoPictureKey& key,
68 TQValueList<ParaData>& paraList )
70 kdDebug(30508) <<
"findAnchor " << key.toString() << endl;
71 TQValueList<ParaData>::Iterator paraIt;
73 for ( paraIt = paraList.begin (); paraIt != paraList.end (); ++paraIt )
75 ValueListFormatData::Iterator formattingIt;
77 for ( formattingIt = (*paraIt).formattingList.begin ();
78 formattingIt != (*paraIt).formattingList.end ();
81 if ( (*formattingIt).id == 6 &&
82 (*formattingIt).frameAnchor.key == key )
84 kdDebug(30508) <<
"Found anchor " << (*formattingIt).frameAnchor.
key.toString() << endl;
85 return &(*formattingIt).frameAnchor;
90 kdWarning(30508) <<
"findAnchor returning NULL!" << endl;
94static void ProcessHardBrkTag ( TQDomNode myNode,
void* tagData, KWEFKWordLeader* )
97 bool* flag = (
bool*) tagData;
98 TQValueList<AttrProcessing> attrProcessingList;
100 ProcessAttributes (myNode, attrProcessingList);
102 kdDebug(30508) <<
"<HARDBRK frame=\"1\"> found" << endl;
105static void InsertBookmarkFormatData (
const int pos,
const TQString& name,
const bool start,
106 ValueListFormatData ¶FormatDataList)
108 ValueListFormatData::Iterator paraFormatDataIt;
110 FormatData book( start ? 1001 : 1002 , pos, 0 );
111 book.variable.m_text = name;
113 for (paraFormatDataIt = paraFormatDataList.begin ();
114 paraFormatDataIt != paraFormatDataList.end ();
117 if ( pos <= (*paraFormatDataIt).pos )
119 paraFormatDataList.insert ( paraFormatDataIt, book );
123 if ( ( pos > (*paraFormatDataIt).pos ) && ( pos < (*paraFormatDataIt).pos + (*paraFormatDataIt).len ) )
126 FormatData split ( *paraFormatDataIt );
128 split.len = pos - (*paraFormatDataIt).pos;
129 (*paraFormatDataIt).len -= split.len;
130 (*paraFormatDataIt).pos = pos;
131 paraFormatDataList.insert ( paraFormatDataIt, split );
132 paraFormatDataList.insert ( paraFormatDataIt, book );
138 paraFormatDataList.append ( book );
142void KWEFKWordLeader::createBookmarkFormatData( ParaData& paraData )
144 const int paraCount = m_paraCountMap[ m_currentFramesetName ];
146 TQValueList<Bookmark>::ConstIterator it;
147 for (it = m_bookmarkList.begin(); it != m_bookmarkList.end(); ++it )
149 if ( (*(it)).m_frameset != m_currentFramesetName )
154 if ( (*(it)).m_endparag == paraCount )
156 kdDebug(30508) <<
"Paragraph: " << paraCount <<
" end: " << (*(it)).m_name << endl;
157 InsertBookmarkFormatData( (*(it)).m_cursorIndexEnd, (*(it)).m_name,
false, paraData.formattingList);
160 if ( (*(it)).m_startparag == paraCount )
162 kdDebug(30508) <<
"Paragraph: " << paraCount <<
" begin: " << (*(it)).m_name << endl;
163 InsertBookmarkFormatData( (*(it)).m_cursorIndexStart, (*(it)).m_name,
true, paraData.formattingList);
168static void ProcessParagraphTag ( TQDomNode myNode,
170 KWEFKWordLeader *leader )
173 kdDebug (30508) <<
"ProcessParagraphTag () - Begin" << endl;
176 TQValueList<ParaData> *paraList = (TQValueList<ParaData> *) tagData;
178 AllowNoAttributes (myNode);
181 TQMap<TQString,int>::Iterator it = leader->m_paraCountMap.find( leader->m_currentFramesetName );
182 if ( it == leader->m_paraCountMap.end() )
183 leader->m_paraCountMap.insert( leader->m_currentFramesetName, 0 );
189 TQValueList<TagProcessing> tagProcessingList;
190 tagProcessingList <<
TagProcessing (
"TEXT", ProcessTextTag, ¶Data.text )
191 <<
TagProcessing (
"FORMATS", ProcessFormatsTag, ¶Data.formattingList )
192 <<
TagProcessing (
"LAYOUT", ProcessLayoutTag, ¶Data.layout );
194 if ( leader->m_oldSyntax )
196 tagProcessingList.append(
TagProcessing(
"HARDBRK", ProcessHardBrkTag, ¶Data.layout.pageBreakBefore ) );
198 ProcessSubtags (myNode, tagProcessingList, leader);
200 leader->createBookmarkFormatData( paraData );
201 CreateMissingFormatData (paraData.text, paraData.formattingList);
204 if ( paraData.formattingList.isEmpty () && !paraData.text.isEmpty () )
206 if ( paraData.layout.formatData.id == 1 )
208 paraData.formattingList << paraData.layout.formatData;
212 kdWarning (30508) <<
"No useful FORMAT tag found for text in PARAGRAPH" << endl;
217 *paraList << paraData;
220 kdDebug (30508) <<
"ProcessParagraphTag () - End " << paraText << endl;
225static void ProcessFrameTag ( TQDomNode myNode,
void *tagData,
226 KWEFKWordLeader *leader )
230 int lRed=0, lBlue=0, lGreen=0;
231 int rRed=0, rBlue=0, rGreen=0;
232 int tRed=0, tBlue=0, tGreen=0;
233 int bRed=0, bBlue=0, bGreen=0;
234 int bkRed=255, bkBlue=255, bkGreen=255;
236 frameAnchor->frame.lWidth=0.0;
237 frameAnchor->frame.rWidth=0.0;
238 frameAnchor->frame.tWidth=0.0;
239 frameAnchor->frame.bWidth=0.0;
241 TQValueList<AttrProcessing> attrProcessingList;
251 <<
AttrProcessing (
"runaroundSide", frameAnchor->frame.runaroundSide )
252 <<
AttrProcessing (
"runaroundGap", frameAnchor->frame.runaroundGap )
254 <<
AttrProcessing (
"autoCreateNewFrame", frameAnchor->frame.autoCreateNewFrame )
255 <<
AttrProcessing (
"newFrameBehavior", frameAnchor->frame.newFrameBehavior )
256 <<
AttrProcessing (
"newFrameBehaviour", frameAnchor->frame.newFrameBehavior )
299 if ( leader->m_oldSyntax )
313 ProcessAttributes (myNode, attrProcessingList);
315 frameAnchor->frame.lColor.setRgb( lRed, lGreen, lBlue );
316 frameAnchor->frame.rColor.setRgb( rRed, rGreen, rBlue );
317 frameAnchor->frame.tColor.setRgb( tRed, tGreen, tBlue );
318 frameAnchor->frame.bColor.setRgb( bRed, bGreen, bBlue );
319 frameAnchor->frame.bkColor.setRgb( bkRed, bkGreen, bkBlue );
321 AllowNoSubtags (myNode, leader);
324static void ProcessPictureAnchor( TQDomNode myNode, KWEFKWordLeader *leader,
FrameAnchor* frameAnchor,
const int frameType )
326 frameAnchor->type = frameType;
328 TQValueList<TagProcessing> tagProcessingList;
331 <<
TagProcessing (
"PICTURE", ProcessImageTag, &frameAnchor->picture.key )
332 <<
TagProcessing (
"IMAGE", ProcessImageTag, &frameAnchor->picture.key )
333 <<
TagProcessing (
"CLIPART", ProcessImageTag, &frameAnchor->picture.key )
335 ProcessSubtags (myNode, tagProcessingList, leader);
337 kdDebug (30508) <<
"FRAMESET PICTURE KEY " << frameAnchor->picture.key.toString() << endl;
339 frameAnchor->
key = frameAnchor->picture.key;
342static void ProcessTableAnchor( TQDomNode myNode, KWEFKWordLeader *leader,
FrameAnchor* frameAnchor,
343 const int col,
const int row,
const int cols,
const int rows )
345 frameAnchor->type = 6;
347 TQValueList<ParaData> cellParaList;
348 TQValueList<TagProcessing> tagProcessingList;
349 tagProcessingList <<
TagProcessing (
"FRAME", ProcessFrameTag, frameAnchor )
350 <<
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &cellParaList );
351 ProcessSubtags (myNode, tagProcessingList, leader);
353 frameAnchor->table.
addCell (col, row, cols, rows, cellParaList, frameAnchor->frame);
356static void ProcessFramesetTag ( TQDomNode myNode,
358 KWEFKWordLeader *leader )
361 kdDebug (30508) <<
"ProcessFramesetTag () - Begin" << endl;
364 TQValueList<ParaData> *paraList = (TQValueList<ParaData> *) tagData;
374 const TQString oldName ( leader->m_currentFramesetName );
376 TQValueList<AttrProcessing> attrProcessingList;
377 attrProcessingList <<
AttrProcessing (
"name", leader->m_currentFramesetName )
389 ProcessAttributes (myNode, attrProcessingList);
394 if ( grpMgr.isEmpty () )
401 kdDebug(30508) <<
"Processing Frameset: " << leader->m_currentFramesetName << endl;
402 TQValueList<TagProcessing> tagProcessingList;
404 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, paraList ));
405 ProcessSubtags (myNode, tagProcessingList, leader);
407 else if (frameInfo==1)
411 header.page = HeaderData::PAGE_FIRST;
412 TQValueList<TagProcessing> tagProcessingList;
414 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &header.para ));
416 ProcessSubtags (myNode, tagProcessingList, leader);
417 leader->doHeader( header );
419 else if (frameInfo==2)
423 header.page = HeaderData::PAGE_EVEN;
424 TQValueList<TagProcessing> tagProcessingList;
426 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &header.para ));
427 ProcessSubtags (myNode, tagProcessingList, leader);
428 leader->doHeader( header );
430 else if (frameInfo==3)
434 header.page = (leader->headerType() != 0 ) ? HeaderData::PAGE_ODD : HeaderData::PAGE_ALL;
435 TQValueList<TagProcessing> tagProcessingList;
437 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &header.para ));
438 ProcessSubtags (myNode, tagProcessingList, leader);
439 leader->doHeader( header );
441 else if (frameInfo==4)
445 footer.page = FooterData::PAGE_FIRST;
446 TQValueList<TagProcessing> tagProcessingList;
448 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &footer.para ));
449 ProcessSubtags (myNode, tagProcessingList, leader);
450 leader->doFooter( footer );
452 else if (frameInfo==5)
456 footer.page = FooterData::PAGE_EVEN;
457 TQValueList<TagProcessing> tagProcessingList;
459 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &footer.para ));
460 ProcessSubtags (myNode, tagProcessingList, leader);
461 leader->doFooter( footer );
463 else if (frameInfo==6)
467 footer.page = (leader->footerType() != 0) ? FooterData::PAGE_ODD : FooterData::PAGE_ALL;
468 TQValueList<TagProcessing> tagProcessingList;
470 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &footer.para ));
471 ProcessSubtags (myNode, tagProcessingList, leader);
472 leader->doFooter( footer );
477 if ( col != -1 && row != -1 )
479 if ( cols > 0 && rows > 0 )
482 kdDebug (30508) <<
"DEBUG - FRAMESET: table " << name <<
" col, row = "
483 << col <<
", " << row <<
", Mgr = "<< grpMgr << endl;
485 FrameAnchor *frameAnchor = findAnchor (grpMgr, *paraList);
488 ProcessTableAnchor( myNode, leader, frameAnchor, col, row, cols, rows );
493 KoPictureKey key( grpMgr );
494 TQValueList<FrameAnchor>::Iterator it;
495 for ( it = leader->m_nonInlinedTableAnchors.begin(); it != leader->m_nonInlinedTableAnchors.end(); ++it )
497 if ( (*it).key == key )
499 kdDebug(30508) <<
"Found pseudo-anchor for table: " << (*it).key.toString() << endl;
507 ProcessTableAnchor( myNode, leader, &(*it), col, row, cols, rows );
511 kdWarning(30508) <<
"Table anchor not found: " << grpMgr << endl;
513 ProcessTableAnchor( myNode, leader, &anchor, col, row, cols, rows );
515 leader->m_nonInlinedTableAnchors << anchor;
516 leader->m_unanchoredFramesets.append( grpMgr );
522 kdWarning (30508) <<
"Unexpected value for one of, or all FRAMESET attribute cols, rows: "
523 << cols <<
", " << rows <<
"!" << endl;
524 AllowNoSubtags (myNode, leader);
529 kdWarning (30508) <<
"Unset value for one of, or all FRAMESET attributes col, row: "
530 << col <<
", " << row <<
"!" << endl;
531 AllowNoSubtags (myNode, leader);
532 leader->m_unanchoredFramesets.append( leader->m_currentFramesetName );
541 kdDebug (30508) <<
"DEBUG: FRAMESET name of picture is " << name << endl;
544 FrameAnchor *frameAnchor = findAnchor ( leader->m_currentFramesetName, *paraList );
548 ProcessPictureAnchor( myNode, leader, frameAnchor, frameType );
554 kdDebug (30508) <<
"ProcessFramesetTag: Couldn't find anchor " << leader->m_currentFramesetName << endl;
556 ProcessPictureAnchor( myNode, leader, &anchor, frameType );
557 leader->m_nonInlinedPictureAnchors << anchor;
558 leader->m_unanchoredFramesets.append( leader->m_currentFramesetName );
566 kdWarning(30508) <<
"KFormula frameset not supported yet!" << endl;
570 kdWarning (30508) <<
"Unexpected frametype " << frameType <<
" (in ProcessFramesetTag)" << endl;
573 leader->m_currentFramesetName = oldName;
576 kdDebug (30508) <<
"ProcessFramesetTag () - End" << endl;
581static void ProcessFramesetsTag ( TQDomNode myNode,
583 KWEFKWordLeader *leader )
585 AllowNoAttributes (myNode);
586 TQValueList<TagProcessing> tagProcessingList;
587 tagProcessingList <<
TagProcessing (
"FRAMESET", ProcessFramesetTag, tagData );
588 ProcessSubtags (myNode, tagProcessingList, leader);
592static void ProcessStyleTag (TQDomNode myNode,
void *, KWEFKWordLeader *leader )
596 ProcessLayoutTag (myNode, &layout, leader);
598 leader->doFullDefineStyle (layout);
602static void ProcessStylesPluralTag (TQDomNode myNode,
void *, KWEFKWordLeader *leader )
604 AllowNoAttributes (myNode);
606 leader->doOpenStyles ();
608 TQValueList<TagProcessing> tagProcessingList;
609 tagProcessingList <<
TagProcessing (
"STYLE", ProcessStyleTag, leader );
610 ProcessSubtags (myNode, tagProcessingList, leader);
612 leader->doCloseStyles ();
616static void ProcessPaperBordersTag (TQDomNode myNode,
void*, KWEFKWordLeader* leader)
624 TQValueList<AttrProcessing> attrProcessingList;
625 if ( leader->m_oldSyntax )
651 ProcessAttributes (myNode, attrProcessingList);
653 leader->doFullPaperBorders(top, left, bottom, right);
655 AllowNoSubtags (myNode, leader);
658static void ProcessPaperTag (TQDomNode myNode,
void *, KWEFKWordLeader *leader)
662 int orientation = -1;
664 double height = -1.0;
668 double columnspacing = 36.0;
671 TQValueList<AttrProcessing> attrProcessingList;
689 if ( leader->m_oldSyntax )
705 ProcessAttributes (myNode, attrProcessingList);
707 leader->setHeaderType( hType );
708 leader->setFooterType( fType );
710 leader->doPageInfo ( hType, fType );
711 leader->doFullPaperFormat (format, width, height, orientation);
712 leader->doFullPaperFormatOther( columns, columnspacing, numPages );
714 TQValueList<TagProcessing> tagProcessingList;
716 <<
TagProcessing (
"PAPERBORDERS", ProcessPaperBordersTag, NULL )
719 ProcessSubtags (myNode, tagProcessingList, leader);
722static void ProcessVariableSettingsTag (TQDomNode myNode,
void *, KWEFKWordLeader *leader)
725 TQString print, creation, modification;
726 int creationYear = -1;
727 int creationMonth = -1;
728 int creationDay = -1;
729 int modificationYear = -1;
730 int modificationMonth = -1;
731 int modificationDay = -1;
733 TQValueList<AttrProcessing> attrProcessingList;
734 attrProcessingList <<
AttrProcessing (
"startingPageNumber", vs.startingPageNumber )
760 ProcessAttributes (myNode, attrProcessingList);
762 if ( creation.isEmpty() )
764 if ( ( creationYear >= 1970 ) && TQDate::isValid( creationYear, creationMonth, creationDay ) )
766 vs.creationTime = TQDateTime( TQDate( creationYear, creationMonth, creationDay ) );
770 vs.creationTime=TQDateTime::fromString(creation, TQt::ISODate);
773 if ( modification.isEmpty() )
775 if ( ( modificationYear >= 1970 ) && TQDate::isValid( modificationYear, modificationMonth, modificationDay ) )
777 vs.modificationTime = TQDateTime( TQDate( modificationYear, modificationMonth, modificationDay ) );
781 vs.modificationTime=TQDateTime::fromString(modification, TQt::ISODate);
784 if (!print.isEmpty())
785 vs.printTime=TQDateTime::fromString(print, TQt::ISODate);
788 leader->doVariableSettings (vs);
791static void ProcessSpellCheckIgnoreWordTag (TQDomNode myNode,
void *, KWEFKWordLeader *leader )
795 TQValueList<AttrProcessing> attrProcessingList;
799 ProcessAttributes (myNode, attrProcessingList);
801 leader->doFullSpellCheckIgnoreWord (ignoreword);
803 AllowNoSubtags (myNode, leader);
807static void ProcessSpellCheckIgnoreListTag (TQDomNode myNode,
void *, KWEFKWordLeader *leader )
809 AllowNoAttributes (myNode);
811 leader->doOpenSpellCheckIgnoreList ();
813 TQValueList<TagProcessing> tagProcessingList;
814 tagProcessingList <<
TagProcessing (
"SPELLCHECKIGNOREWORD", ProcessSpellCheckIgnoreWordTag, leader );
815 ProcessSubtags (myNode, tagProcessingList, leader);
817 leader->doCloseSpellCheckIgnoreList ();
821static void ProcessPixmapsKeyTag ( TQDomNode myNode,
823 KWEFKWordLeader *leader )
825 TQValueList<ParaData> *paraList = (TQValueList<ParaData> *) tagData;
830 key.loadAttributes(myNode.toElement());
831 const TQString name(myNode.toElement().attribute(
"name"));
833 kdDebug(30508) <<
"search anchors: " << key.toString() << endl;
839 TQValueList<ParaData>::Iterator paraIt;
841 for ( paraIt = paraList->begin(); paraIt != paraList->end(); ++paraIt )
843 ValueListFormatData::Iterator formattingIt;
844 for ( formattingIt = (*paraIt).formattingList.begin();
845 formattingIt != (*paraIt).formattingList.end();
848 if ( ( ( (*formattingIt).id == 6 ) || ( (*formattingIt).id == 2 ) )
849 && (*formattingIt).frameAnchor.key == key )
851 kdDebug(30508) <<
"Found anchor for inlined picture: " << (*formattingIt).frameAnchor.key.toString() << endl;
852 (*formattingIt).frameAnchor.picture.koStoreName = name;
858 TQValueList<FrameAnchor>::Iterator it;
859 for ( it = leader->m_nonInlinedPictureAnchors.begin(); it != leader->m_nonInlinedPictureAnchors.end(); ++it )
861 if ( (*it).key == key )
863 kdDebug(30508) <<
"Found pseudo-anchor for non-inlined picture: " << (*it).key.toString() << endl;
864 (*it).picture.koStoreName = name;
871 kdWarning (30508) <<
"Could not find any anchor for picture " << key.toString() << endl;
874 AllowNoSubtags (myNode, leader);
878static void ProcessPixmapsTag ( TQDomNode myNode,
880 KWEFKWordLeader *leader )
882 AllowNoAttributes (myNode);
884 TQValueList<TagProcessing> tagProcessingList;
885 tagProcessingList <<
TagProcessing (
"KEY", ProcessPixmapsKeyTag, tagData );
886 ProcessSubtags (myNode, tagProcessingList, leader);
890static void FreeCellParaLists ( TQValueList<ParaData> ¶List )
892 TQValueList<ParaData>::Iterator paraIt;
894 for ( paraIt = paraList.begin (); paraIt != paraList.end (); ++paraIt )
896 ValueListFormatData::Iterator formattingIt;
898 for ( formattingIt = (*paraIt).formattingList.begin ();
899 formattingIt != (*paraIt).formattingList.end ();
902 if ( (*formattingIt).id == 6 && (*formattingIt).frameAnchor.type == 6 )
904 TQValueList<TableCell>::Iterator cellIt;
906 for ( cellIt = (*formattingIt).frameAnchor.table.cellList.begin ();
907 cellIt != (*formattingIt).frameAnchor.table.cellList.end ();
910 FreeCellParaLists ( *(*cellIt).paraList );
911 delete (*cellIt).paraList;
919static void ProcessFootnoteFramesetTag ( TQDomNode myNode,
void *tagData, KWEFKWordLeader *leader )
922 int frameType = -1, frameInfo = -1;
923 bool visible =
false;
925 TQValueList<AttrProcessing> attrProcessingList;
939 ProcessAttributes (myNode, attrProcessingList);
942 if( ( frameType == 1 ) && ( frameInfo == 7 ) )
945 footnote.frameName = frameName;
946 TQValueList<TagProcessing> tagProcessingList;
948 tagProcessingList.append(
TagProcessing (
"PARAGRAPH", ProcessParagraphTag, &footnote.para ));
949 ProcessSubtags (myNode, tagProcessingList, leader);
950 leader->footnoteList.append( footnote );
955static void ProcessFootnoteFramesetsTag ( TQDomNode myNode,
void *tagData, KWEFKWordLeader *leader )
957 AllowNoAttributes (myNode);
959 TQValueList<TagProcessing> tagProcessingList;
960 tagProcessingList <<
TagProcessing (
"FRAMESET", ProcessFootnoteFramesetTag, tagData );
961 ProcessSubtags (myNode, tagProcessingList, leader);
964static void ProcessBookmarkItemTag ( TQDomNode myNode,
void* tag, KWEFKWordLeader *leader )
966 TQValueList<Bookmark> * bookmarkList =
static_cast< TQValueList<Bookmark> *
> ( tag );
970 TQValueList<AttrProcessing> attrProcessingList;
973 <<
AttrProcessing (
"cursorIndexStart", bookmark.m_cursorIndexStart )
980 ProcessAttributes (myNode, attrProcessingList);
982 AllowNoSubtags( myNode, leader );
986 kdDebug(30508) <<
"Bookmark: " << bookmark.m_name <<
" in frameset " << bookmark.m_frameset << endl;
988 bookmarkList->append( bookmark );
991static void ProcessBookmarksTag ( TQDomNode myNode,
void* tag, KWEFKWordLeader *leader )
993 AllowNoAttributes (myNode);
995 TQValueList<TagProcessing> tagProcessingList;
996 tagProcessingList <<
TagProcessing (
"BOOKMARKITEM", ProcessBookmarkItemTag, tag );
997 ProcessSubtags (myNode, tagProcessingList, leader);
1000void ProcessDocTag ( TQDomNode myNode,
1001 void* , KWEFKWordLeader* leader )
1005 TQString editor, author;
1007 TQValueList<AttrProcessing> attrProcessingList;
1018 ProcessAttributes( myNode, attrProcessingList );
1020 kdDebug(30508) <<
"Document written by " << editor << endl;
1021 kdDebug(30508) <<
"Document of syntax version " << leader->m_syntaxVersion << endl;
1023 if ( leader->m_syntaxVersion == 1 )
1025 leader->m_oldSyntax =
true;
1027 else if ( leader->m_syntaxVersion == -1 )
1031 if ( author ==
"Reginald Stadlbauer and Torben Weis" )
1033 kdDebug(30508) <<
"No syntax version but author attribute matches => assuming old syntax" << endl;
1034 leader->m_oldSyntax =
true;
1038 kdWarning(30508) <<
"No syntax version found, author attribute does not match => assuming new syntax" << endl;
1042 leader->doOpenHead();
1045 TQDomNode nodeIgnoreList=myNode.namedItem(
"SPELLCHECKIGNORELIST");
1046 if ( nodeIgnoreList.isNull () )
1047 kdDebug (30508) <<
"No <SPELLCHECKIGNORELIST>" << endl;
1049 ProcessSpellCheckIgnoreListTag (nodeIgnoreList, NULL, leader);
1052 TQDomNode nodePaper=myNode.namedItem(
"PAPER");
1053 if ( nodePaper.isNull () )
1054 kdWarning (30508) <<
"No <PAPER>" << endl;
1056 ProcessPaperTag (nodePaper, NULL, leader);
1059 TQDomNode nodeVariableSettings=myNode.namedItem(
"VARIABLESETTINGS");
1060 if ( nodeVariableSettings.isNull () )
1061 kdWarning (30508) <<
"No <VARIABLESETTINGS>" << endl;
1063 ProcessVariableSettingsTag (nodeVariableSettings, NULL, leader);
1066 TQDomNode nodeStyles=myNode.namedItem(
"STYLES");
1067 if ( nodeStyles.isNull () )
1068 kdWarning (30508) <<
"No <STYLES>" << endl;
1070 ProcessStylesPluralTag (nodeStyles, NULL, leader);
1073 TQValueList<FootnoteData> footnotes;
1074 TQDomNode nodeFramesets=myNode.namedItem(
"FRAMESETS");
1075 if ( !nodeFramesets.isNull() )
1076 ProcessFootnoteFramesetsTag(nodeFramesets, &footnotes, leader );
1079 TQValueList<TagProcessing> tagProcessingList;
1080 TQValueList<ParaData> paraList;
1085 <<
TagProcessing (
"FRAMESETS", ProcessFramesetsTag, ¶List )
1087 <<
TagProcessing (
"PICTURES", ProcessPixmapsTag, ¶List )
1088 <<
TagProcessing (
"PIXMAPS", ProcessPixmapsTag, ¶List )
1089 <<
TagProcessing (
"CLIPARTS", ProcessPixmapsTag, ¶List )
1091 <<
TagProcessing (
"BOOKMARKS", ProcessBookmarksTag, &leader->m_bookmarkList )
1098 ProcessSubtags (myNode, tagProcessingList, leader);
1100 leader->doCloseHead();
1101 leader->doDeclareNonInlinedFramesets( leader->m_nonInlinedPictureAnchors, leader->m_nonInlinedTableAnchors );
1102 leader->doOpenBody();
1104 leader->doFullDocument (paraList);
1106 kdDebug(30508) <<
"Unachored Framesets : START" << endl;
1107 TQStringList::ConstIterator it;
1108 for ( it = leader->m_unanchoredFramesets.begin(); it != leader->m_unanchoredFramesets.end(); ++it )
1110 kdDebug(30508) << (*it) << endl;
1112 kdDebug(30508) <<
"Unachored Framesets : END" << endl;
1114 FreeCellParaLists (paraList);
1116 leader->doCloseBody();
1124 m_worker = newWorker;
1127 newWorker->registerKWordLeader(
this);
1138#define DO_VOID_DEFINITION(string) \
1139 bool KWEFKWordLeader::string() \
1142 return m_worker->string(); \
1147bool KWEFKWordLeader::doOpenFile (
const TQString &filenameOut,
const TQString &to )
1150 return m_worker->doOpenFile (filenameOut, to);
1153 kdError (30508) <<
"No Worker! (in KWEFKWordLeader::doOpenFile)" << endl;
1159DO_VOID_DEFINITION (doCloseFile)
1160DO_VOID_DEFINITION (doAbortFile)
1161DO_VOID_DEFINITION (doOpenDocument)
1162DO_VOID_DEFINITION (doCloseDocument)
1163DO_VOID_DEFINITION (doOpenStyles)
1164DO_VOID_DEFINITION (doCloseStyles)
1165DO_VOID_DEFINITION (doOpenHead)
1166DO_VOID_DEFINITION (doCloseHead)
1167DO_VOID_DEFINITION (doOpenBody)
1168DO_VOID_DEFINITION (doCloseBody)
1169DO_VOID_DEFINITION (doOpenSpellCheckIgnoreList)
1170DO_VOID_DEFINITION (doCloseSpellCheckIgnoreList)
1172bool KWEFKWordLeader::doFullDocumentInfo (
const KWEFDocumentInfo &docInfo)
1175 return m_worker->doFullDocumentInfo (docInfo);
1184 return m_worker->doVariableSettings (varSettings);
1190bool KWEFKWordLeader::doFullDocument (
const TQValueList<ParaData> ¶List)
1193 return m_worker->doFullDocument (paraList);
1198bool KWEFKWordLeader::doPageInfo (
const int headerType,
const int footerType )
1201 return m_worker->doPageInfo ( headerType, footerType );
1206bool KWEFKWordLeader::doFullPaperFormat (
const int format,
const double width,
const double height,
const int orientation )
1209 return m_worker->doFullPaperFormat (format, width, height, orientation);
1214bool KWEFKWordLeader::doFullPaperBorders (
const double top,
const double left,
const double bottom,
const double right)
1217 return m_worker->doFullPaperBorders (top, left, bottom, right);
1222bool KWEFKWordLeader::doFullPaperFormatOther (
const int columns,
const double columnspacing,
const int numPages )
1225 return m_worker->doFullPaperFormatOther ( columns, columnspacing, numPages );
1230bool KWEFKWordLeader::doFullDefineStyle (
LayoutData &layout )
1233 return m_worker->doFullDefineStyle (layout);
1238bool KWEFKWordLeader::doFullSpellCheckIgnoreWord (
const TQString& ignoreword)
1241 return m_worker->doFullSpellCheckIgnoreWord (ignoreword);
1246bool KWEFKWordLeader::doHeader (
const HeaderData& header )
1249 return m_worker->doHeader (header);
1254bool KWEFKWordLeader::doFooter (
const FooterData& footer )
1257 return m_worker->doFooter (footer);
1262bool KWEFKWordLeader::doDeclareNonInlinedFramesets( TQValueList<FrameAnchor>& pictureAnchors, TQValueList<FrameAnchor>& tableAnchors )
1265 return m_worker->doDeclareNonInlinedFramesets( pictureAnchors, tableAnchors );
1270static bool ParseFile ( TQIODevice* subFile, TQDomDocument& doc)
1276 if ( !doc.setContent (subFile, &errorMsg, &errorLine, &errorColumn) )
1278 kdError (30508) <<
"Parsing Error! Aborting! (in ParseFile)" << endl
1279 <<
" Line: " << errorLine <<
" Column: " << errorColumn << endl
1280 <<
" Message: " << errorMsg << endl;
1282 KMessageBox::error( 0L, i18n(
"An error has occurred while parsing the KWord file.\nAt line: %1, column %2\nError message: %3")
1283 .arg( errorLine ).arg( errorColumn ).arg(i18n(
"TQXml", errorMsg.utf8() ) ),
1284 i18n(
"KWord Export Filter Library"), 0 );
1290static bool ProcessStoreFile ( TQIODevice* subFile,
1291 void (*processor) (TQDomNode,
void *, KWEFKWordLeader *),
1292 KWEFKWordLeader* leader)
1296 kdWarning(30508) <<
"Could not get a device for the document!" << endl;
1298 else if ( subFile->open ( IO_ReadOnly ) )
1300 kdDebug (30508) <<
"Processing Document..." << endl;
1302 if (!ParseFile(subFile, doc))
1312 TQDomNode docNode = doc.documentElement();
1313 processor (docNode, NULL, leader);
1319 kdWarning (30508) <<
"Unable to open document!" << endl;
1324TQIODevice* KWEFKWordLeader::getSubFileDevice(
const TQString& fileName)
1326 KoStoreDevice* subFile;
1328 subFile=m_chain->storageFile(fileName,KoStore::Read);
1332 kdError(30508) <<
"Could not get a device for sub-file: " << fileName << endl;
1339bool KWEFKWordLeader::loadSubFile(
const TQString& fileName, TQByteArray& array)
1341 KoStoreDevice* subFile;
1343 subFile=m_chain->storageFile(fileName,KoStore::Read);
1347 kdError(30508) <<
"Could not get a device for sub-file: " << fileName << endl;
1350 else if ( subFile->open ( IO_ReadOnly ) )
1352 array = subFile->readAll();
1357 kdError(30508) <<
"Unable to open " << fileName <<
" sub-file" << endl;
1364KoFilter::ConversionStatus KWEFKWordLeader::convert( KoFilterChain* chain,
1365 const TQCString& from,
const TQCString& to)
1367 if ( from !=
"application/x-kword" )
1369 return KoFilter::NotImplemented;
1374 kdError(30508) <<
"'Chain' is NULL! Internal error of the filter system?" << endl;
1375 return KoFilter::StupidError;
1380 if ( !doOpenFile (chain->outputFile(),to) )
1382 kdError (30508) <<
"Worker could not open export file! Aborting!" << endl;
1383 return KoFilter::StupidError;
1386 if ( !doOpenDocument () )
1388 kdError (30508) <<
"Worker could not open document! Aborting!" << endl;
1390 return KoFilter::StupidError;
1393 KoStoreDevice* subFile;
1395 subFile=chain->storageFile(
"documentinfo.xml",KoStore::Read);
1396 kdDebug (30508) <<
"Processing documentinfo.xml..." << endl;
1398 ProcessStoreFile (subFile, ProcessDocumentInfoTag,
this);
1400 subFile=chain->storageFile(
"root",KoStore::Read);
1401 kdDebug (30508) <<
"Processing root..." << endl;
1402 if (!ProcessStoreFile (subFile, ProcessDocTag,
this))
1404 kdWarning(30508) <<
"Opening root has failed. Trying raw XML file!" << endl;
1406 const TQString filename( chain->inputFile() );
1407 if (filename.isEmpty() )
1409 kdError(30508) <<
"Could not open document as raw XML! Aborting!" << endl;
1411 return KoFilter::StupidError;
1415 TQFile file( filename );
1416 if ( ! ProcessStoreFile( &file, ProcessDocTag,
this ) )
1418 kdError(30508) <<
"Could not process document! Aborting!" << endl;
1420 return KoFilter::StupidError;
1429 return KoFilter::OK;
The class AttrProcessing and the two functions ProcessAttributes () and AllowNoSubtags () allow for e...
This is basically <FRAMESET> tag.
KoPictureKey key
Picture key.
Base worker of the libexport system.
void addCell(int c, int r, int _cols, int _rows, TQValueList< ParaData > &p, FrameData &frameData)
The class TagProcessing and the two functions ProcessSubtags () and AllowNoSubtags () allow for easin...
see <VARIABLESETTINGS> in the KWord DTD