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

List:       kde-commits
Subject:    =?utf-8?q?=5Bcalligra=5D_filters/words/msword-odf=3A_DOC=3A_Impr?=
From:       Matus Uzak <matus.uzak () ixonos ! com>
Date:       2011-02-07 21:04:08
Message-ID: 20110207210408.71546A609B () git ! kde ! org
[Download RAW message or body]

Git commit d279e97d29f444d7fa15d94369334801b73ba081 by Matus Uzak.
Committed on 07/02/11 at 21:58.
Pushed by uzak into branch 'master'.

DOC: Improved the logic to identify headings.

The logic to identify a heading and its outline level changed a bit
according to [MS-DOC] - v20100926.  This helps us a lot to generate
the TOC.  We are still using a lot of hacks, like saving a heading
as a list-item to get the correct heading number in case it's not part
of the heading text.

M  +29   -26   filters/words/msword-odf/texthandler.cpp     
M  +11   -11   filters/words/msword-odf/texthandler.h     
M  +1    -0    filters/words/msword-odf/wv2/src/global.h     
M  +4    -1    filters/words/msword-odf/wv2/src/parser9x.cpp     

http://commits.kde.org/calligra/d279e97d29f444d7fa15d94369334801b73ba081

diff --git a/filters/words/msword-odf/texthandler.cpp \
b/filters/words/msword-odf/texthandler.cpp index 070207a..cd15b05 100644
--- a/filters/words/msword-odf/texthandler.cpp
+++ b/filters/words/msword-odf/texthandler.cpp
@@ -715,46 +715,50 @@ void KWordTextHandler::paragraphStart(wvWare::SharedPtr<const \
wvWare::ParagraphP  
     m_currentPPs = paragraphProperties;
 
-    // Check list information, because that's bigger than a paragraph,
-    // and we'll track that here in the TextHandler
+    // Check list information, because that's bigger than a paragraph, and
+    // we'll track that here in the TextHandler. NOT TRUE any more according to
+    // [MS-DOC] - v20100926
     //
-    // And heading information is here too, so track that for opening
-    // the Paragraph.
     bool isHeading = false;
     int outlineLevel = 0;
 
-    // ilfo = when non-zero, (1-based) index into the pllfo
-    // identifying the list to which the paragraph belongs.
+    //TODO: <text:numbered-paragraph>
+
+    //TODO: Put all the heading related logic here!
+    if (paragraphProperties) {
+        uint istd = paragraphProperties->pap().istd;
+
+        //Applying a heading style, paragraph is a heading.
+        if ( (istd >= 0x1) && (istd <= 0x9) ) {
+            isHeading = true;
+            //according to [MS-DOC] - v20100926
+            outlineLevel = istd - 1;
+            //MS-DOC outline level is ZERO based, whereas ODF has ONE based.
+            outlineLevel++;
+        }
+    }
+
+    // ilfo = when non-zero, (1-based) index into the pllfo identifying the
+    // list to which the paragraph belongs.
     if (!paragraphProperties) {
         // TODO: What to do here?
-    } else if (paragraphProperties->pap().ilfo == 0) {
+    } else if ( (paragraphProperties->pap().ilfo == 0)) {
 
-        // Not in a list at all in the word document, so check if we
-        // need to close one in the odt.
+        // Not in a list at all in the word document, so check if we need to
+        // close one in the odt.
 
         //kDebug(30513) << "Not in a list, so we may need to close a list.";
         if (listIsOpen()) {
             //kDebug(30513) << "closing list " << m_currentListID;
             closeList();
         }
-
-        //NOTE: Applying a heading style, paragraph is probably a heading.
-        //MSWord outline level is ZERO based, whereas ODF has ONE based.
-        uint istd = paragraphProperties->pap().istd;
-        if ( (istd >= 0x1) && (istd <= 0x9) ) {
-            outlineLevel = paragraphProperties->pap().lvl;
-            if ( (outlineLevel >= 0x0) && (outlineLevel <= 0x8) ) {
-                isHeading = true;
-                outlineLevel++;
-            } else {
-                outlineLevel = 0;
-            }
-
-        }
     } else if (paragraphProperties->pap().ilfo > 0) {
 
-        // We're in a list in the word document
-        kDebug(30513) << "we're in a list or heading";
+        // We're in a list in the word document.
+        //
+        // At the moment <text:numbered-paragraph> is not supported, we process
+        // the paragraph as an list-item instead.
+        kDebug(30513) << "we're in a list or numbered paragraph";
 
         // listInfo is our list properties object.
         const wvWare::ListInfo* listInfo = paragraphProperties->listInfo();
@@ -767,7 +771,6 @@ void KWordTextHandler::paragraphStart(wvWare::SharedPtr<const \
wvWare::ParagraphP  isHeading = true;
             outlineLevel = paragraphProperties->pap().ilvl + 1;
         } else if (listInfo->lsid() == 1 && listInfo->numberFormat() == 255) {
-            // Looks like a heading, so that'll be processed in Paragraph.
             kDebug(30513) << "found heading, pap().ilvl="
                     << paragraphProperties->pap().ilvl;
             isHeading = true;
diff --git a/filters/words/msword-odf/texthandler.h \
b/filters/words/msword-odf/texthandler.h index 0ef9011..baff80a 100644
--- a/filters/words/msword-odf/texthandler.h
+++ b/filters/words/msword-odf/texthandler.h
@@ -333,11 +333,11 @@ private:
             m_insideField(false),
             m_afterSeparator(false),
             m_hyperLinkActive(false),
+            m_tabLeader(QChar::Null),
             m_hyperLinkUrl(QString::null),
+            m_styleName(QString::null),
             m_instructions(QString::null),
 /*             m_result(QString::null), */
-            m_styleName(QString::null),
-            m_tabLeader(QChar::Null),
             m_writer(0),
             m_buffer(0)
         {
@@ -361,22 +361,22 @@ private:
         bool m_insideField;
         bool m_afterSeparator;
         bool m_hyperLinkActive;
-	
+
+        //the tab leader character for a TOC entry
+        QChar m_tabLeader;
+
         //stores the location (bookmark/URL) to jump to
         QString m_hyperLinkUrl;
+
+        //KoGenStyle name for the <text:span> element encapsulating content of the
+        //processed field (if applicable)
+        QString m_styleName;
         
         //stores field instructions
         QString m_instructions;
-        
+
         //stores the field result
 /*         QString m_result; */
-        
-        //KoGenStyle name for the <text:span> element encapsulating content of the
-        //processed field (if applicable)
-        QString m_styleName;
-
-        //the tab leader character for a TOC entry
-        QChar m_tabLeader;
 
         //writer and buffer used to place bookmark elements into the field result,
         //if bookmarks are not to be supported by your field type, use m_result
diff --git a/filters/words/msword-odf/wv2/src/global.h \
b/filters/words/msword-odf/wv2/src/global.h index 15770b1..a315361 100644
--- a/filters/words/msword-odf/wv2/src/global.h
+++ b/filters/words/msword-odf/wv2/src/global.h
@@ -39,6 +39,7 @@
 //#define WV2_DEBUG_FOOTNOTES 1
 //#define WV2_DEBUG_HEADERS 1
 //#define WV2_DEBUG_TABLES 1
+//#define WV2_DEBUG_PARAGRAPHS 1
 //#define WV2_DEBUG_PICTURES 1
 //#define WV2_DEBUG_ANNOTATIONS 1
 //#define WV2_DEBUG_BOOKMARK 1
diff --git a/filters/words/msword-odf/wv2/src/parser9x.cpp \
b/filters/words/msword-odf/wv2/src/parser9x.cpp index 367b0fe..0f48b5d 100644
--- a/filters/words/msword-odf/wv2/src/parser9x.cpp
+++ b/filters/words/msword-odf/wv2/src/parser9x.cpp
@@ -699,6 +699,10 @@ void Parser9x::processParagraph( U32 fc )
         delete props;
     }
     else {
+#ifdef WV2_DEBUG_PARAGRAPHS
+        props->pap().dump();
+#endif
+
         //Check if table skimming was active lately.  If yes, then this is the
         //paragraph behind the table (either a PARAGRAPH_MARK or a SECTION_MARK
         //follows a table)!
@@ -708,7 +712,6 @@ void Parser9x::processParagraph( U32 fc )
             m_textHandler->tableEndFound();
         }
 
-
         // Now that we have the complete PAP, let's see if this paragraph belongs to \
a list  props->createListInfo( *m_lists );
 


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

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