[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    libexport fixes
From:       Zack Rusin <zack () kde ! org>
Date:       2003-07-05 22:17:00
[Download RAW message or body]

Hi guys,

to make it short this is a patch adding:
1) Full FRAME element support to FrameAnchor. Some people have been 
saying that they're missing it so now they have it.
2) Since #1 correlates with this one - fixing parsing of tables. Before 
libexport depended on the fact that before any cells are present in the 
dtd there's a Frameset element with the name == grpMgr. Now a manager 
is created when the first cell is seen. 
I have also a fix for all the filters, switching them to the 
FrameAnchor.FrameData element and I tested it with HtmlFilter which now 
kind of exports tables (exports but the inline tables are inserted in 
wrong locations (always at the end of the document) ), but that's a 
problem in the filter itself.
Comments?

Zack

["libexport.diff" (text/x-diff)]

? Attributes.cpp
? Attributes.h
Index: KWEFKWordLeader.cc
===================================================================
RCS file: /home/kde/koffice/filters/kword/libexport/KWEFKWordLeader.cc,v
retrieving revision 1.39
diff -u -3 -p -b -B -r1.39 KWEFKWordLeader.cc
--- KWEFKWordLeader.cc	4 Jan 2003 10:08:37 -0000	1.39
+++ KWEFKWordLeader.cc	5 Jul 2003 22:12:02 -0000
@@ -77,6 +77,19 @@ static FrameAnchor *findAnchor ( const K
     return NULL;
 }
 
+static ParaData createTableMgr( const QString& grpMgr )
+{
+    ParaData  pData;
+    LayoutData lData;
+    FormatData fData;
+    fData.id = 6;
+    fData.frameAnchor.key  = KoPictureKey( grpMgr );
+    fData.frameAnchor.type = 6;
+    lData.formatData = fData;
+    pData.layout = lData;
+    pData.formattingList << fData;
+    return pData;
+}
 
 static void ProcessParagraphTag ( QDomNode         myNode,
                                   void            *tagData,
@@ -138,16 +151,76 @@ static void ProcessFrameTag ( QDomNode m
 {
     FrameAnchor* frameAnchor= (FrameAnchor*) tagData;
 
+    int lRed, lBlue, lGreen;
+    int rRed, rBlue, rGreen;
+    int tRed, tBlue, tGreen;
+    int bRed, bBlue, bGreen;
+    int bkRed, bkBlue, bkGreen;
+
     QValueList<AttrProcessing> attrProcessingList;
     attrProcessingList
-        << AttrProcessing ( "runaround", NULL,      NULL                 )
-        << AttrProcessing ( "top",       "double",  &frameAnchor->top    )
-        << AttrProcessing ( "bottom",    "double",  &frameAnchor->bottom )
-        << AttrProcessing ( "left",      "double",  &frameAnchor->left   )
-        << AttrProcessing ( "right",     "double",  &frameAnchor->right  )
+        << AttrProcessing ( "right",        "double",  &frameAnchor->frame.right  )
+        << AttrProcessing ( "left",         "double",  &frameAnchor->frame.left   )
+        << AttrProcessing ( "top",          "double",  &frameAnchor->frame.top    )
+        << AttrProcessing ( "bottom",       "double",  &frameAnchor->frame.bottom )
+
+        << AttrProcessing ( "min-height",   "double",  &frameAnchor->frame.minHeight )
+
+        << AttrProcessing ( "runaround",      "int",  &frameAnchor->frame.runaround         )
+        << AttrProcessing ( "runaroundSide",  "QString",  &frameAnchor->frame.runaroundSide )
+        << AttrProcessing ( "runaroundGap",   "double",  &frameAnchor->frame.runaroundGap   )
+
+        << AttrProcessing ( "autoCreateNewFrame",  "int",  &frameAnchor->frame.autoCreateNewFrame )
+        << AttrProcessing ( "newFrameBehavior",    "int",  &frameAnchor->frame.newFrameBehavior   )
+
+        << AttrProcessing ( "copy",       "int",  &frameAnchor->frame.copy      )
+        << AttrProcessing ( "sheetSide",  "int",  &frameAnchor->frame.sheetSide )
+
+        << AttrProcessing ( "lWidth",   "double",  &frameAnchor->frame.lWidth )
+        << AttrProcessing ( "rWidth",   "double",  &frameAnchor->frame.rWidth )
+        << AttrProcessing ( "tWidth",   "double",  &frameAnchor->frame.tWidth )
+        << AttrProcessing ( "bWidth",   "double",  &frameAnchor->frame.bWidth )
+
+        << AttrProcessing ( "lRed",     "int",  &lRed   )
+        << AttrProcessing ( "lGreen",   "int",  &lGreen )
+        << AttrProcessing ( "lBlue",    "int",  &lBlue  )
+
+        << AttrProcessing ( "rRed",     "int",  &rRed   )
+        << AttrProcessing ( "rGreen",   "int",  &rGreen )
+        << AttrProcessing ( "rBlue",    "int",  &rBlue  )
+
+        << AttrProcessing ( "tRed",     "int",  &tRed   )
+        << AttrProcessing ( "tGreen",   "int",  &tGreen )
+        << AttrProcessing ( "tBlue",    "int",  &tBlue  )
+
+        << AttrProcessing ( "bRed",     "int",  &bRed   )
+        << AttrProcessing ( "bGreen",   "int",  &bGreen )
+        << AttrProcessing ( "bBlue",    "int",  &bBlue  )
+
+        << AttrProcessing ( "lStyle",    "int",  &frameAnchor->frame.lStyle )
+        << AttrProcessing ( "rStyle",    "int",  &frameAnchor->frame.rStyle )
+        << AttrProcessing ( "tStyle",    "int",  &frameAnchor->frame.tStyle )
+        << AttrProcessing ( "bStyle",    "int",  &frameAnchor->frame.bStyle )
+
+        << AttrProcessing ( "bkRed",     "int",  &bkRed   )
+        << AttrProcessing ( "bkGreen",   "int",  &bkGreen )
+        << AttrProcessing ( "bkBlue",    "int",  &bkBlue  )
+
+        << AttrProcessing ( "bkStyle",    "int",  &frameAnchor->frame.bkStyle )
+
+        << AttrProcessing ( "bleftpt",     "double",  &frameAnchor->frame.bleftpt   )
+        << AttrProcessing ( "brightpt",    "double",  &frameAnchor->frame.brightpt  )
+        << AttrProcessing ( "btoppt",      "double",  &frameAnchor->frame.btoppt    )
+        << AttrProcessing ( "bbottompt",   "double",  &frameAnchor->frame.bbottompt )
         ;
     ProcessAttributes (myNode, attrProcessingList);
 
+    frameAnchor->frame.lColor  = QColor( lRed, lGreen, lBlue );
+    frameAnchor->frame.rColor  = QColor( rRed, rGreen, rBlue );
+    frameAnchor->frame.tColor  = QColor( tRed, tGreen, tBlue );
+    frameAnchor->frame.bColor  = QColor( bRed, bGreen, bBlue );
+    frameAnchor->frame.bkColor = QColor( bkRed, bkGreen, bkBlue );
+
     AllowNoSubtags (myNode, leader);
 }
 
@@ -196,7 +269,7 @@ static void ProcessFramesetTag ( QDomNod
                        << AttrProcessing ( "col",       "int",     (void *) &col       )
                        << AttrProcessing ( "rows",      "int",     (void *) &rows      )
                        << AttrProcessing ( "cols",      "int",     (void *) &cols      )
-                       << AttrProcessing ( "protectSize","",       NULL                )
+                       << AttrProcessing ( "protectSize", "",        NULL                )
                         ;
     ProcessAttributes (myNode, attrProcessingList);
 
@@ -291,13 +364,14 @@ static void ProcessFramesetTag ( QDomNod
                     {
 #if 0
                         kdDebug (30508) << "DEBUG - FRAMESET: table " << name << " col, row = "
-                                        << col << ", " << row << endl;
+                                        << col << ", " << row << ", Mgr = "<< grpMgr << endl;
 #endif
-
                         FrameAnchor *frameAnchor = findAnchor (grpMgr, *paraList);
+                        if ( !frameAnchor ) {
+                            *paraList << createTableMgr( grpMgr );
+                            frameAnchor = &paraList->last().formattingList.first().frameAnchor;
+                        }
 
-                        if ( frameAnchor )
-                        {
                             frameAnchor->type = 6;
 
                             QValueList<ParaData> cellParaList;
@@ -311,11 +384,6 @@ static void ProcessFramesetTag ( QDomNod
                         }
                         else
                         {
-                            kdWarning (30508) << "ProcessFramesetTag (): Couldn't find anchor " << name << endl;
-                        }
-                    }
-                    else
-                    {
                         kdWarning (30508) << "Unexpected value for one of, or all FRAMESET attribute cols, rows: "
                                         << cols << ", " << rows << "!" << endl;
                         AllowNoSubtags (myNode, leader);
@@ -390,7 +457,10 @@ static void ProcessFramesetsTag ( QDomNo
 
 static void ProcessStyleTag (QDomNode myNode, void *, KWEFKWordLeader *leader )
 {
-    AllowNoAttributes (myNode);
+    QValueList<AttrProcessing> attrProcessingList;
+    attrProcessingList
+        << AttrProcessing ( "outline",   "", NULL );
+    ProcessAttributes (myNode, attrProcessingList);
 
     LayoutData layout;
 
@@ -453,10 +523,16 @@ static void ProcessPaperTag (QDomNode my
                        << AttrProcessing ( "orientation",     "int",    (void *) &orientation )
                        << AttrProcessing ( "columns",         "",       NULL                  )
                        << AttrProcessing ( "columnspacing",   "",       NULL                  )
+                       << AttrProcessing ( "pages",               "",       NULL                  )
                        << AttrProcessing ( "hType",           "int",    (void*) &hType        )
                        << AttrProcessing ( "fType",           "int",    (void*) &fType        )
                        << AttrProcessing ( "spHeadBody",      "",       NULL                  )
-                       << AttrProcessing ( "spFootBody",      "",       NULL                  );
+                       << AttrProcessing ( "spFootBody",          "",       NULL                  )
+                       << AttrProcessing ( "spFootNoteBody",      "",       NULL                  )
+                       << AttrProcessing ( "slFootNotePosition",  "",       NULL                  )
+                       << AttrProcessing ( "slFootNoteLength",    "",       NULL                  )
+                       << AttrProcessing ( "slFootNoteWidth",     "",       NULL                  )
+                       << AttrProcessing ( "slFootNoteType",      "",       NULL                  );
     ProcessAttributes (myNode, attrProcessingList);
 
     leader->setHeaderType( hType );
@@ -492,7 +568,16 @@ static void ProcessVariableSettingsTag (
                                            (void *) &vs.displaycomment )
                        << AttrProcessing ( "displayfieldcode",
                                            "bool",
-                                           (void *) &vs.displayfieldcode );
+                                           (void *) &vs.displayfieldcode )
+                       << AttrProcessing ( "lastPrintingDate",
+                                           "",
+                                           NULL )
+                       << AttrProcessing ( "creationDate",
+                                           "",
+                                           NULL )
+                       << AttrProcessing ( "modificationDate",
+                                           "",
+                                           NULL );
     ProcessAttributes (myNode, attrProcessingList);
 
     leader->doVariableSettings (vs);
@@ -607,12 +692,21 @@ static void ProcessFootnoteFramesetTag (
 {
     QString frameName;
     int frameType = -1, frameInfo = -1;
+    bool visible = false;
 
     QValueList<AttrProcessing> attrProcessingList;
     attrProcessingList 
         << AttrProcessing ( "name",      "QString", (void *) &frameName      )
         << AttrProcessing ( "frameType", "int",     (void *) &frameType )
         << AttrProcessing ( "frameInfo", "int",     (void *) &frameInfo )
+        << AttrProcessing ( "removable",   "",        NULL                )
+        << AttrProcessing ( "visible",     "bool",    (void *) &visible )
+        << AttrProcessing ( "grpMgr",      "QString", NULL    )
+        << AttrProcessing ( "row",         "int",     NULL    )
+        << AttrProcessing ( "col",         "int",     NULL    )
+        << AttrProcessing ( "rows",        "int",     NULL    )
+        << AttrProcessing ( "cols",        "int",     NULL    )
+        << AttrProcessing ( "protectSize",  "",        NULL    )
         ;
     ProcessAttributes (myNode, attrProcessingList);
 
@@ -645,11 +739,13 @@ static void ProcessFootnoteFramesetsTag 
     //kdDebug (30508) << "Entering ProcessDocTag" << endl;
 
     QValueList<AttrProcessing> attrProcessingList;
-    attrProcessingList << AttrProcessing ( "editor",        "", NULL )
-                       << AttrProcessing ( "mime",          "", NULL )
-                       << AttrProcessing ( "syntaxVersion", "", NULL );
-    ProcessAttributes (myNode, attrProcessingList);
 
+    attrProcessingList << AttrProcessing ( "xmlns",         "QString", 0  )
+                       << AttrProcessing ( "editor",        "QString", 0  )
+                       << AttrProcessing ( "mime",          "QString", 0  )
+                       << AttrProcessing ( "syntaxVersion", "int",     0  );
+
+    ProcessAttributes( myNode, attrProcessingList );
     // TODO: verify syntax version and perhaps mime
 
     leader->doOpenHead();
Index: KWEFStructures.h
===================================================================
RCS file: /home/kde/koffice/filters/kword/libexport/KWEFStructures.h,v
retrieving revision 1.43
diff -u -3 -p -b -B -r1.43 KWEFStructures.h
--- KWEFStructures.h	30 Jun 2003 22:13:04 -0000	1.43
+++ KWEFStructures.h	5 Jul 2003 22:12:02 -0000
@@ -151,21 +151,53 @@ class Picture
         QString koStoreName;   // Picture store name: filename within kwd archive
 };
 
+/**
+ * For FRAME Tag.
+ * Look at kword.dtd for a complete description
+ * of individuals class members
+ */
+class FrameData
+{
+public:
+    double right;
+    double left;
+    double top;
+    double bottom;
+    double minHeight;
+    int runaround;
+    QString runaroundSide;
+    double runaroundGap;
+    int autoCreateNewFrame;
+    int newFrameBehavior;
+    int copy;
+    int sheetSide;
+
+    double lWidth, rWidth, tWidth, bWidth;
+
+    QColor lColor;
+    QColor rColor;
+    QColor tColor;
+    QColor bColor;
+
+    int lStyle, rStyle, tStyle, bStyle;
+
+    QColor bkColor;
+    int    bkStyle;
+    double bleftpt, brightpt, btoppt, bbottompt;
+};
 
+//This is basically FRAMESET tag
 class FrameAnchor
 {
    public:
       FrameAnchor ():
-       type(-1), top( 0.0 ), bottom( 0.0 ), left( 0.0 ), right( 0.0 ) {}
+       type(-1) {}
 
       FrameAnchor ( const KoPictureKey& n  ) : key (n), type (-1) {}
 
       KoPictureKey key; // KoPictureKey
       int     type;
-      double  top;      // Frame top
-      double  bottom;   // frame bottom
-      double  left;     // frame left
-      double  right;    // frame right
+      FrameData   frame;
 
       Picture picture;
       Table   table;
Index: ProcessDocument.cc
===================================================================
RCS file: /home/kde/koffice/filters/kword/libexport/ProcessDocument.cc,v
retrieving revision 1.44
diff -u -3 -p -b -B -r1.44 ProcessDocument.cc
--- ProcessDocument.cc	30 Jun 2003 22:13:04 -0000	1.44
+++ ProcessDocument.cc	5 Jul 2003 22:12:03 -0000
@@ -442,11 +442,16 @@ static void AppendTagProcessingFormatOne
         << TagProcessing ( "ITALIC",              ProcessBoolIntValueTag, &formatData.text.italic            )
         << TagProcessing ( "UNDERLINE",           ProcessUnderlineTag,    &formatData.text                   )
         << TagProcessing ( "STRIKEOUT",           ProcessStrikeoutTag,    &formatData.text                   )
-        << TagProcessing ( "CHARSET",             NULL,                   NULL                               )
         << TagProcessing ( "VERTALIGN",           ProcessIntValueTag,     &formatData.text.verticalAlignment )
-        << TagProcessing ( "TEXTBACKGROUNDCOLOR", ProcessColorAttrTag,    &formatData.text.bgColor           )
+        << TagProcessing ( "SHADOW",              NULL,                   NULL                               )
         << TagProcessing ( "FONTATTRIBUTE",       ProcessStringValueTag,  &formatData.text.fontAttribute     )
         << TagProcessing ( "LANGUAGE",            NULL,                   NULL                               )
+        << TagProcessing ( "ANCHOR",              NULL,                   NULL                               )
+        << TagProcessing ( "IMAGE",               NULL,                   NULL                               )
+        << TagProcessing ( "PICTURE",             NULL,                   NULL                               )
+        << TagProcessing ( "VARIABLE",            NULL,                   NULL                               )
+        << TagProcessing ( "TEXTBACKGROUNDCOLOR", ProcessColorAttrTag,    &formatData.text.bgColor           )
+        << TagProcessing ( "OFFSETFROMBASELINE",  NULL,                   NULL                               )
         ;
 }
 
@@ -461,7 +466,10 @@ static void SubProcessFormatOneTag(QDomN
         // It can happen in a child of <STYLE>, just put secure values
         formatPos=0;
         formatLen=0;
-        kdDebug (30508) << "Missing formatting! Style?" << endl;
+        kdDebug (30508) << "Missing formatting! Style? "
+                        << myNode.nodeName()
+                        << " = " << myNode.nodeValue()
+                        << endl;
     }
 
     FormatData formatData(1, formatPos, formatLen);
@@ -596,6 +604,8 @@ static void ProcessCounterTag ( QDomNode
     attrProcessingList << AttrProcessing ( "bulletfont",    "QString", (void *) &counter->customFont      );
     attrProcessingList << AttrProcessing ( "customdef",     "",        (void *) NULL                      );
     attrProcessingList << AttrProcessing ( "text",          "QString", (void *) &counter->text            );
+    attrProcessingList << AttrProcessing ( "display-levels",  "",                 NULL                      );
+    attrProcessingList << AttrProcessing ( "align",           "",                 NULL                      );
     ProcessAttributes (myNode, attrProcessingList);
 
     AllowNoSubtags (myNode, leader);
Index: TagProcessing.cc
===================================================================
RCS file: /home/kde/koffice/filters/kword/libexport/TagProcessing.cc,v
retrieving revision 1.12
diff -u -3 -p -b -B -r1.12 TagProcessing.cc
--- TagProcessing.cc	30 Jun 2003 22:13:04 -0000	1.12
+++ TagProcessing.cc	5 Jul 2003 22:12:03 -0000
@@ -129,7 +129,7 @@ void ProcessAttributes ( QDomNode       
     //kdDebug(30508) << "Starting ProcessAttributes for node: " << myNode.nodeName() << endl;
 
     QDomNamedNodeMap myAttribs ( myNode.attributes () );
-
+    //kdDebug(30508) << "Attributes = " << myAttribs.length () <<endl;
     for ( uint i = 0; i <  myAttribs.length (); i++ )
     {
         QDomAttr myAttrib ( myAttribs.item (i).toAttr () );
@@ -144,6 +144,7 @@ void ProcessAttributes ( QDomNode       
                   attrProcessingIt != attrProcessingList.end ();
                   attrProcessingIt++ )
             {
+              //kdDebug(30508) << "NAME: " << myAttrib.name () << " == " << (*attrProcessingIt).name <<endl;
                 if ( myAttrib.name () == (*attrProcessingIt).name )
                 {
                     found = true;


_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic