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

Lubos Lunak llunak at kemper.freedesktop.org
Wed Jul 11 06:19:04 PDT 2012


 sw/qa/extras/ooxmltok/data/numbering1.docx   |binary
 sw/qa/extras/ooxmltok/ooxmltok.cxx           |   58 +++++++++++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx |   29 +++++++------
 3 files changed, 74 insertions(+), 13 deletions(-)

New commits:
commit 794caa58a7208921ad8f911d586088213e390fba
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Jul 11 15:17:02 2012 +0200

    add a testcase for the recent writerfilter numbering fix
    
    Change-Id: I41300ec0bf4b7db93912236e0d15fcab97cabd2d

diff --git a/sw/qa/extras/ooxmltok/data/numbering1.docx b/sw/qa/extras/ooxmltok/data/numbering1.docx
new file mode 100644
index 0000000..55b4af3
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/numbering1.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index a3fd38a..28f8dfb 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -76,6 +76,7 @@ public:
     void testN766481();
     void testN766487();
     void testN693238();
+    void testNumbering1();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -100,6 +101,7 @@ public:
     CPPUNIT_TEST(testN766481);
     CPPUNIT_TEST(testN766487);
     CPPUNIT_TEST(testN693238);
+    CPPUNIT_TEST(testNumbering1);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -678,6 +680,62 @@ void Test::testN693238()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nValue);
 }
 
+void Test::testNumbering1()
+{
+    load( "numbering1.docx" );
+/* <w:numPr> in the paragraph itself was overriden by <w:numpr> introduced by the paragraph's <w:pStyle>
+enum = ThisComponent.Text.createEnumeration
+para = enum.NextElement
+xray para.NumberingStyleName
+numberingstyle = ThisComponent.NumberingRules.getByIndex(6)
+xray numberingstyle.name   - should match name above
+numbering = numberingstyle.getByIndex(0)
+xray numbering(11)  - should be 4, arabic
+note that the indexes may get off as the implementation evolves, C++ code seaches in loops
+*/
+    uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
+    // list of paragraphs
+    uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+    uno::Reference<uno::XInterface> paragraph(paraEnum->nextElement(), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> text(paragraph, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL( OUString( "Text1." ), text->getString());
+    uno::Reference<beans::XPropertySet> xPropertySet( paragraph, uno::UNO_QUERY );
+    OUString numberingStyleName;
+    xPropertySet->getPropertyValue( "NumberingStyleName" ) >>= numberingStyleName;
+    uno::Reference<text::XNumberingRulesSupplier> xNumberingRulesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> numberingRules(xNumberingRulesSupplier->getNumberingRules(), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> numberingRule;
+    for( int i = 0;
+         i < numberingRules->getCount();
+         ++i )
+    {
+        xPropertySet.set( numberingRules->getByIndex( i ), uno::UNO_QUERY );
+        OUString name;
+        xPropertySet->getPropertyValue( "Name" ) >>= name;
+        if( name == numberingStyleName )
+        {
+            numberingRule.set( numberingRules->getByIndex( i ), uno::UNO_QUERY );
+            break;
+        }
+    }
+    CPPUNIT_ASSERT( numberingRule.is());
+    uno::Sequence< beans::PropertyValue > numbering;
+    numberingRule->getByIndex( 0 ) >>= numbering;
+    sal_Int16 numberingType = style::NumberingType::NUMBER_NONE;
+    for( int i = 0;
+         i < numbering.getLength();
+         ++i )
+        {
+        if( numbering[ i ].Name == "NumberingType" )
+            {
+            numbering[ i ].Value >>= numberingType;
+            break;
+            }
+        }
+    CPPUNIT_ASSERT_EQUAL( style::NumberingType::ARABIC, numberingType );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 7039abde34942812c44a2e265ddcb79cc5c62be2
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Jul 11 12:17:30 2012 +0200

    remove pointless named temporary
    
    Change-Id: I6d0b45451c8fe232afc05041d3c70a98e8bd8cc8

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 0d9ffd0..9d2bc18 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1529,10 +1529,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
                 }
             }
             else if ( !m_pImpl->IsStyleSheetImport( ) )
-            {
-                rtl::OUString sNone;
-                rContext->Insert( PROP_NUMBERING_STYLE_NAME, true, uno::makeAny( sNone ) );
-            }
+                rContext->Insert( PROP_NUMBERING_STYLE_NAME, true, uno::makeAny( OUString() ) );
         }
         break;
     case NS_sprm::LN_PFNoLineNumb:   // sprmPFNoLineNumb
commit e7ab4bb6b0e83f01148ffff41e8c5eaa0c5ba0a4
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Jul 11 12:15:40 2012 +0200

    do not let a style override paragraph's numbering
    
    If a paragraph has its own <w:numPr>, do not let <w:pStyle> override that.
    
    Change-Id: I7cea0d1c8bf59804f8c56382ee68c7fad5ed3ef6

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 03ef24d..0d9ffd0 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1524,6 +1524,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
                 {
                     uno::Any aRules = uno::makeAny( pList->GetNumberingRules( ) );
                     rContext->Insert( PROP_NUMBERING_RULES, true, aRules );
+                    // erase numbering from pStyle if already set
+                    rContext->erase( PropertyDefinition( PROP_NUMBERING_STYLE_NAME, true ));
                 }
             }
             else if ( !m_pImpl->IsStyleSheetImport( ) )
@@ -2981,17 +2983,21 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
         const ::rtl::OUString sConvertedStyleName = pStyleTable->ConvertStyleName( sStringValue, true );
         if (m_pImpl->GetTopContext() && m_pImpl->GetTopContextType() != CONTEXT_SECTION)
             m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, true, uno::makeAny( sConvertedStyleName ));
-        const StyleSheetEntryPtr pEntry = pStyleTable->FindStyleSheetByISTD(sStringValue);
-        //apply numbering to paragraph if it was set at the style
-        OSL_ENSURE( pEntry.get(), "no style sheet found" );
-        const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
+        //apply numbering to paragraph if it was set at the style, but only if the paragraph itself
+        //does not specify the numbering
+        if( rContext->find( PropertyDefinition( PROP_NUMBERING_RULES, true )) == rContext->end()) // !contains
+        {
+            const StyleSheetEntryPtr pEntry = pStyleTable->FindStyleSheetByISTD(sStringValue);
+            OSL_ENSURE( pEntry.get(), "no style sheet found" );
+            const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
 
-        if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
-            rContext->Insert( PROP_NUMBERING_STYLE_NAME, true, uno::makeAny(
-                        ListDef::GetStyleName( pStyleSheetProperties->GetListId( ) ) ), false);
+            if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
+                rContext->Insert( PROP_NUMBERING_STYLE_NAME, true, uno::makeAny(
+                            ListDef::GetStyleName( pStyleSheetProperties->GetListId( ) ) ), false);
 
-        if( pStyleSheetProperties && pStyleSheetProperties->GetListLevel() >= 0 )
-            rContext->Insert( PROP_NUMBERING_LEVEL, true, uno::makeAny(pStyleSheetProperties->GetListLevel()), false);
+            if( pStyleSheetProperties && pStyleSheetProperties->GetListLevel() >= 0 )
+                rContext->Insert( PROP_NUMBERING_LEVEL, true, uno::makeAny(pStyleSheetProperties->GetListLevel()), false);
+        }
     }
     break;
     case NS_ooxml::LN_EG_RPrBase_rStyle:


More information about the Libreoffice-commits mailing list