[Libreoffice-commits] .: 3 commits - sw/qa writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Tue Apr 3 06:25:45 PDT 2012


 sw/qa/extras/rtftok/data/fdo47107.rtf          |   21 ++++
 sw/qa/extras/rtftok/rtftok.cxx                 |   14 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |  122 +++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    5 -
 4 files changed, 161 insertions(+), 1 deletion(-)

New commits:
commit 63b78e6db15a76b9e928cb4a7d0d995bd12f9bf4
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Apr 3 15:07:06 2012 +0200

    testcase for fdo#47107

diff --git a/sw/qa/extras/rtftok/data/fdo47107.rtf b/sw/qa/extras/rtftok/data/fdo47107.rtf
new file mode 100644
index 0000000..74371cd
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo47107.rtf
@@ -0,0 +1,21 @@
+{\rtf1
+{\fonttbl
+{\f1 Symbol;}
+}
+\pard \fi-283\li283
+{\*\pn \pnlvlbody\pndec\pnstart1
+{\pntxta .}
+}
+{Alpha
+\par 
+Beta
+\par }
+\pard \fi-283\li283
+{\*\pn \pnlvlblt\pnf1\pnstart1
+{\pntxtb \'b7}
+}
+{Alpha
+\par 
+Beta
+\par }
+}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index ac7a2e4..45eabbf 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -76,6 +76,7 @@ public:
     void testFdo46955();
     void testFdo45394();
     void testFdo48104();
+    void testFdo47107();
 
     CPPUNIT_TEST_SUITE(RtfModelTest);
 #if !defined(MACOSX) && !defined(WNT)
@@ -95,6 +96,7 @@ public:
     CPPUNIT_TEST(testFdo46955);
     CPPUNIT_TEST(testFdo45394);
     CPPUNIT_TEST(testFdo48104);
+    CPPUNIT_TEST(testFdo47107);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -486,6 +488,18 @@ void RtfModelTest::testFdo48104()
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+void RtfModelTest::testFdo47107()
+{
+    load("fdo47107.rtf");
+
+    uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xStyles(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xNumberingStyles(xStyles->getByName(OUString(RTL_CONSTASCII_USTRINGPARAM("NumberingStyles"))), uno::UNO_QUERY);
+    // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException
+    xNumberingStyles->getByName("WWNum1");
+    xNumberingStyles->getByName("WWNum2");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit ea04bbd697ad984cc4e39ed42994a072f052ba36
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Apr 3 11:53:59 2012 +0200

    fdo#47107 rtftok: support bullet points in paragraph numberings

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 51f7b5e..5ceeaeb 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -893,6 +893,7 @@ void RTFDocumentImpl::text(OUString& rString)
         case DESTINATION_ANNOTATIONAUTHOR:
         case DESTINATION_FALT:
         case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
+        case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
             m_aStates.top().aDestinationText.append(rString);
             break;
         case DESTINATION_EQINSTRUCTION:
@@ -1321,6 +1322,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_PNTXTA:
             m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
             break;
+        case RTF_PNTXTB:
+            m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
+            break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
             // Make sure we skip destinations (even without \*) till we don't handle them
@@ -2083,6 +2087,12 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                     m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_NFC, pValue));
                 }
                 break;
+        case RTF_PNLVLBLT:
+                {
+                    m_aStates.top().aTableAttributes->push_back(make_pair(NS_rtf::LN_LSID, RTFValue::Pointer_t(new RTFValue(1))));
+                    m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_NFC, RTFValue::Pointer_t(new RTFValue(23)))); // bullets, same as \levelnfc23
+                }
+                break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
             aSkip.setParsed(false);
@@ -2735,6 +2745,13 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_PNSTART:
             m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_ISTARTAT, pIntValue));
             break;
+        case RTF_PNF:
+            {
+                int nFontIndex = getFontIndex(nParam);
+                RTFValue::Pointer_t pValue(new RTFValue(nFontIndex));
+                lcl_putNestedSprm(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_Lvl_rPr, NS_sprm::LN_CRgFtc0, pValue);
+            }
+            break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
             aSkip.setParsed(false);
@@ -3314,8 +3331,12 @@ int RTFDocumentImpl::popState()
         {
             // Abstract numbering
             RTFSprms aLeveltextAttributes;
-            OUString aTextValue("%1");
-            RTFValue::Pointer_t pTextAfter = aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
+            OUString aTextValue;
+            RTFValue::Pointer_t pTextBefore = aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
+            if (pTextBefore.get())
+                aTextValue += pTextBefore->getString();
+            aTextValue += "%1";
+            RTFValue::Pointer_t pTextAfter = aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelSuffix_val);
             if (pTextAfter.get())
                 aTextValue += pTextAfter->getString();
             RTFValue::Pointer_t pTextValue(new RTFValue(aTextValue));
@@ -3336,6 +3357,9 @@ int RTFDocumentImpl::popState()
 
             RTFValue::Pointer_t pLeveltextValue(new RTFValue(aLeveltextAttributes));
             aLevelSprms->push_back(make_pair(NS_ooxml::LN_CT_Lvl_lvlText, pLeveltextValue));
+            RTFValue::Pointer_t pRunProps = aState.aTableSprms.find(NS_ooxml::LN_CT_Lvl_rPr);
+            if (pRunProps.get())
+                aLevelSprms->push_back(make_pair(NS_ooxml::LN_CT_Lvl_rPr, pRunProps));
 
             RTFSprms aAbstractAttributes;
             RTFSprms aAbstractSprms;
@@ -3372,6 +3396,11 @@ int RTFDocumentImpl::popState()
     else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER)
     {
         RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
+        m_aStates.top().aTableAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelSuffix_val, pValue));
+    }
+    else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE)
+    {
+        RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
         m_aStates.top().aTableAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, pValue));
     }
     else if (aState.nDestinationState == DESTINATION_LISTLEVEL)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index ff2882b..1747958 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -111,6 +111,7 @@ namespace writerfilter {
             DESTINATION_FLYMAINCONTENT,
             DESTINATION_DRAWINGOBJECT,
             DESTINATION_PARAGRAPHNUMBERING,
+            DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE,
             DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER
         };
 
commit eeafdc5602e422d2cdf2026c135e5ea3e18e89af
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Apr 2 17:43:19 2012 +0200

    fdo#47107 rtftok: initial PN (legacy numbering syntax) support

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f75d8eb..51f7b5e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -892,6 +892,7 @@ void RTFDocumentImpl::text(OUString& rString)
         case DESTINATION_ANNOTATIONDATE:
         case DESTINATION_ANNOTATIONAUTHOR:
         case DESTINATION_FALT:
+        case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
             m_aStates.top().aDestinationText.append(rString);
             break;
         case DESTINATION_EQINSTRUCTION:
@@ -1310,6 +1311,16 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_DO:
             m_aStates.top().nDestinationState = DESTINATION_DRAWINGOBJECT;
             break;
+        case RTF_PN:
+            m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING;
+            break;
+        case RTF_PNTEXT:
+            // This destination should be ignored by readers that support paragraph numbering.
+            m_aStates.top().nDestinationState = DESTINATION_SKIP;
+            break;
+        case RTF_PNTXTA:
+            m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
+            break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
             // Make sure we skip destinations (even without \*) till we don't handle them
@@ -2060,6 +2071,18 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                     m_aSettingsTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Settings_linkStyles, pValue));
                 }
                 break;
+        case RTF_PNLVLBODY:
+                {
+                    RTFValue::Pointer_t pValue(new RTFValue(2));
+                    m_aStates.top().aTableAttributes->push_back(make_pair(NS_rtf::LN_LSID, pValue));
+                }
+                break;
+        case RTF_PNDEC:
+                {
+                    RTFValue::Pointer_t pValue(new RTFValue(0)); // decimal, same as \levelnfc0
+                    m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_NFC, pValue));
+                }
+                break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
             aSkip.setParsed(false);
@@ -2709,6 +2732,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_DPYSIZE:
             m_aStates.top().aDrawingObject.nBottom = TWIP_TO_MM100(nParam);
             break;
+        case RTF_PNSTART:
+            m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_ISTARTAT, pIntValue));
+            break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
             aSkip.setParsed(false);
@@ -3281,6 +3307,73 @@ int RTFDocumentImpl::popState()
         RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
         m_aListTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Numbering_abstractNum, pValue));
     }
+    else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING)
+    {
+        RTFValue::Pointer_t pIdValue = aState.aTableAttributes.find(NS_rtf::LN_LSID);
+        if (pIdValue.get())
+        {
+            // Abstract numbering
+            RTFSprms aLeveltextAttributes;
+            OUString aTextValue("%1");
+            RTFValue::Pointer_t pTextAfter = aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
+            if (pTextAfter.get())
+                aTextValue += pTextAfter->getString();
+            RTFValue::Pointer_t pTextValue(new RTFValue(aTextValue));
+            aLeveltextAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, pTextValue));
+
+            RTFSprms aLevelAttributes;
+            RTFSprms aLevelSprms;
+            RTFValue::Pointer_t pIlvlValue(new RTFValue(0));
+            aLevelAttributes->push_back(make_pair(NS_ooxml::LN_CT_Lvl_ilvl, pIlvlValue));
+
+            RTFValue::Pointer_t pNfcValue = aState.aTableSprms.find(NS_rtf::LN_NFC);
+            if (pNfcValue.get())
+                aLevelSprms->push_back(make_pair(NS_rtf::LN_NFC, pNfcValue));
+
+            RTFValue::Pointer_t pStartatValue = aState.aTableSprms.find(NS_rtf::LN_ISTARTAT);
+            if (pStartatValue.get())
+                aLevelSprms->push_back(make_pair(NS_rtf::LN_ISTARTAT, pStartatValue));
+
+            RTFValue::Pointer_t pLeveltextValue(new RTFValue(aLeveltextAttributes));
+            aLevelSprms->push_back(make_pair(NS_ooxml::LN_CT_Lvl_lvlText, pLeveltextValue));
+
+            RTFSprms aAbstractAttributes;
+            RTFSprms aAbstractSprms;
+            aAbstractAttributes->push_back(make_pair(NS_ooxml::LN_CT_AbstractNum_abstractNumId, pIdValue));
+            RTFValue::Pointer_t pLevelValue(new RTFValue(aLevelAttributes, aLevelSprms));
+            aAbstractSprms->push_back(make_pair(NS_ooxml::LN_CT_AbstractNum_lvl, pLevelValue));
+
+            RTFSprms aListTableSprms;
+            RTFValue::Pointer_t pAbstractValue(new RTFValue(aAbstractAttributes, aAbstractSprms));
+            aListTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Numbering_abstractNum, pAbstractValue));
+
+            // Numbering
+            RTFSprms aNumberingAttributes;
+            RTFSprms aNumberingSprms;
+            aNumberingAttributes->push_back(make_pair(NS_rtf::LN_LSID, pIdValue));
+            aNumberingSprms->push_back(make_pair(NS_ooxml::LN_CT_Num_abstractNumId, pIdValue));
+            RTFValue::Pointer_t pNumberingValue(new RTFValue(aNumberingAttributes, aNumberingSprms));
+            aListTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Numbering_num, pNumberingValue));
+
+            // Table
+            RTFSprms aListTableAttributes;
+            writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aListTableAttributes, aListTableSprms));
+
+            RTFReferenceTable::Entries_t aListTableEntries;
+            aListTableEntries.insert(make_pair(0, pProp));
+            writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(aListTableEntries));
+            Mapper().table(NS_rtf::LN_LISTTABLE, pTable);
+
+            // Use it
+            lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_numPr, NS_sprm::LN_PIlvl, pIlvlValue);
+            lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_tabs, NS_sprm::LN_PIlfo, pIdValue);
+        }
+    }
+    else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER)
+    {
+        RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
+        m_aStates.top().aTableAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, pValue));
+    }
     else if (aState.nDestinationState == DESTINATION_LISTLEVEL)
     {
         RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 461b88e..ff2882b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -109,7 +109,9 @@ namespace writerfilter {
             DESTINATION_ANNOTATIONAUTHOR,
             DESTINATION_FALT,
             DESTINATION_FLYMAINCONTENT,
-            DESTINATION_DRAWINGOBJECT
+            DESTINATION_DRAWINGOBJECT,
+            DESTINATION_PARAGRAPHNUMBERING,
+            DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER
         };
 
         enum RTFBorderState


More information about the Libreoffice-commits mailing list