[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sw/qa writerfilter/source

Miklos Vajna vmiklos at suse.cz
Thu Mar 7 00:30:15 PST 2013


 sw/qa/extras/ooxmlimport/data/fdo59638.docx      |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx         |   25 ++++++++++++++++
 sw/qa/extras/rtfimport/data/fdo59638.rtf         |   35 +++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx             |   25 ++++++++++++++++
 writerfilter/source/dmapper/NumberingManager.cxx |    9 +++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx   |   25 +++++++++++++++-
 writerfilter/source/rtftok/rtfdocumentimpl.hxx   |    1 
 7 files changed, 118 insertions(+), 2 deletions(-)

New commits:
commit 202d4d32d481ce7e2d1f9933186b30f9ae77497a
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Feb 28 14:20:00 2013 +0100

    fdo#59638 import of DOCX w:lvlOverride / RTF_LFOLEVEL
    
    Also handle RTF_F inside RTF_LISTLEVEL. Word typically uses the Symbol
    font to describe bullet characters instead of using a sane Unicode
    value, the previous can only be handled if we parse the custom font set
    for the list.
    
    (cherry picked from commits 521586b328305c4466603438a9931993b92873c6,
    2f82a08d3565239c2bfe8d21fbebd89bd4657708 and
    58c30a3545a5725d704eabd79071db02f1f2cb23)
    
    Change-Id: I1491f07c40953949e381a035c1596c207cdc4c35
    Reviewed-on: https://gerrit.libreoffice.org/2503
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/sw/qa/extras/ooxmlimport/data/fdo59638.docx b/sw/qa/extras/ooxmlimport/data/fdo59638.docx
new file mode 100755
index 0000000..d33e7cc
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/fdo59638.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 2c32f13..1ade3ed 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -112,6 +112,7 @@ public:
     void testFineTableDash();
     void testN779642();
     void testFdo53985();
+    void testFdo59638();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -176,6 +177,7 @@ void Test::run()
         {"tableborder-finedash.docx", &Test::testFineTableDash},
         {"n779642.docx", &Test::testN779642},
         {"fdo53985.docx", &Test::testFdo53985},
+        {"fdo59638.docx", &Test::testFdo59638},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1096,6 +1098,29 @@ void Test::testFdo53985()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTables->getCount()); // Only 4 tables were imported.
 }
 
+void Test::testFdo59638()
+{
+    // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
+
+    uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProps;
+    xLevels->getByIndex(0) >>= aProps; // 1st level
+
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+
+        if (rProp.Name == "BulletChar")
+        {
+            // Was '*', should be 'o'.
+            CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
+            return;
+        }
+    }
+    CPPUNIT_FAIL("no BulletChar property");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/rtfimport/data/fdo59638.rtf b/sw/qa/extras/rtfimport/data/fdo59638.rtf
new file mode 100644
index 0000000..e2572bf
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo59638.rtf
@@ -0,0 +1,35 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\fonttbl
+{\f0\fbidi \froman\fcharset238\fprq2
+Times New Roman;}
+{\f2\fbidi \fmodern\fcharset238\fprq1
+Courier New;}
+{\f3\fbidi \froman\fcharset2\fprq2
+Symbol;}
+}
+{\*\listtable
+{\list\listtemplateid-1784933330\listsimple
+{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat0\levelspace0\levelindent0
+{\leveltext\'01*;}
+{\levelnumbers;}
+\hres0\chhres0 }
+{\listname ;}
+\listid-2}
+}
+{\*\listoverridetable
+{\listoverride\listid-2\listoverridecount1
+{\lfolevel\listoverrideformat
+{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat0\levelold\levelspace0
+\levelindent0
+{\leveltext\'01\u-3913 ?;}
+{\levelnumbers;}
+\f3\fbias0 }
+}
+\ls1}
+}
+\pard\plain \ltrpar\ql \fi-360\li720\ri0\nowidctlpar\wrapdefault
+\faauto\ls1\rin0\lin720\itap0\pararsid7241016 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1031\langfe1031\loch\af31506\hich\af31506\dbch\af31505\cgrid\langnp1031\langfenp1031 
+{\rtlch\fcs1 \af37 \ltrch\fcs0 
+\f37\insrsid15285686 \hich\af37\dbch\af31505\loch\f37 3
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 18ae927..b55aad9 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -139,6 +139,7 @@ public:
     void testFdo44053();
     void testFdo58646line();
     void testFdo59953();
+    void testFdo59638();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -228,6 +229,7 @@ void Test::run()
         {"fdo44053.rtf", &Test::testFdo44053},
         {"fdo58646line.rtf", &Test::testFdo58646line},
         {"fdo59953.rtf", &Test::testFdo59953},
+        {"fdo59638.rtf", &Test::testFdo59638},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1085,6 +1087,29 @@ void Test::testFdo59953()
     CPPUNIT_ASSERT_EQUAL(sal_Int16(7650), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
 }
 
+void Test::testFdo59638()
+{
+    // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
+
+    uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProps;
+    xLevels->getByIndex(0) >>= aProps; // 1st level
+
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+
+        if (rProp.Name == "BulletChar")
+        {
+            // Was '*', should be 'o'.
+            CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
+            return;
+        }
+    }
+    CPPUNIT_FAIL("no BulletChar property");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 529a794..470cb0c 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -495,7 +495,7 @@ uno::Sequence< uno::Sequence< beans::PropertyValue > > ListDef::GetPropertyValue
     for ( sal_Int32 i = 0; i < nThisCount; i++ )
     {
         uno::Sequence< beans::PropertyValue > level = aThis[i];
-        if ( level.getLength( ) == 0 )
+        if ( level.hasElements() )
         {
             // If the the element contains something, merge it
             lcl_mergeProperties( level, aAbstract[i] );
@@ -953,6 +953,13 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
                 pLevel->SetParaStyle( pStyle );
             }
             break;
+            case NS_ooxml::LN_CT_Num_lvlOverride:
+            {
+                writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+                if (pProperties.get())
+                    pProperties->resolve(*this);
+            }
+            break;
             case NS_ooxml::LN_EG_RPrBase_rFonts: //contains font properties
             case NS_ooxml::LN_EG_RPrBase_color:
             case NS_ooxml::LN_EG_RPrBase_u:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d966275..c35b0d9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1238,6 +1238,10 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_LIST:
             m_aStates.top().nDestinationState = DESTINATION_LISTENTRY;
             break;
+        case RTF_LFOLEVEL:
+            m_aStates.top().nDestinationState = DESTINATION_LFOLEVEL;
+            m_aStates.top().aTableSprms.clear();
+            break;
         case RTF_LISTOVERRIDETABLE:
             m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDETABLE;
             break;
@@ -2716,6 +2720,14 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                 m_aFontIndexes.push_back(nParam);
                 m_nCurrentFontIndex = getFontIndex(nParam);
             }
+            else if (m_aStates.top().nDestinationState == DESTINATION_LISTLEVEL)
+            {
+                RTFSprms aFontSprms;
+                aFontSprms.set(NS_sprm::LN_CRgFtc0, RTFValue::Pointer_t(new RTFValue(getFontIndex(nParam))));
+                RTFSprms aRunPropsSprms;
+                aRunPropsSprms.set(NS_ooxml::LN_EG_RPrBase_rFonts, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aFontSprms)));
+                m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_rPr, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aRunPropsSprms)));
+            }
             else
             {
                 int nFontIndex = getFontIndex(nParam);
@@ -4195,7 +4207,18 @@ int RTFDocumentImpl::popState()
         aState.aTableAttributes.set(NS_ooxml::LN_CT_Lvl_ilvl, pInnerValue);
 
         RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
-        m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, false);
+        if (m_aStates.top().nDestinationState != DESTINATION_LFOLEVEL)
+            m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, false);
+        else
+            m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_NumLvl_lvl, pValue);
+    }
+    else if (aState.nDestinationState == DESTINATION_LFOLEVEL)
+    {
+        RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
+        aState.aTableAttributes.set(NS_ooxml::LN_CT_NumLvl_ilvl, pInnerValue);
+
+        RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
+        m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_lvlOverride, pValue);
     }
     // list override table
     else if (aState.nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a26d3ff..c7affd7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -179,6 +179,7 @@ namespace writerfilter {
             DESTINATION_MBOX,
             DESTINATION_MEQARR,
             DESTINATION_UPR,
+            DESTINATION_LFOLEVEL,
         };
 
         enum RTFBorderState


More information about the Libreoffice-commits mailing list