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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 4 05:49:18 PST 2013


 sw/qa/extras/ooxmlimport/data/n793262.docx             |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx               |   18 +++++++++++++++
 writerfilter/source/dmapper/CellMarginHandler.cxx      |    6 ++++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx      |   17 ++++++++++++--
 writerfilter/source/dmapper/TablePropertiesHandler.cxx |   20 +++++++++++++++++
 5 files changed, 58 insertions(+), 3 deletions(-)

New commits:
commit 1cec392ef50699cc0f310823e4e5fdbb9b272f0f
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jan 4 14:37:10 2013 +0100

    n#793262 testcase

diff --git a/sw/qa/extras/ooxmlimport/data/n793262.docx b/sw/qa/extras/ooxmlimport/data/n793262.docx
new file mode 100755
index 0000000..7f2d2e0
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n793262.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3b7a658..813b653 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -111,6 +111,7 @@ public:
     void testN780645();
     void testFineTableDash();
     void testN792778();
+    void testN793262();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -174,6 +175,7 @@ void Test::run()
         {"n780645.docx", &Test::testN780645},
         {"tableborder-finedash.docx", &Test::testFineTableDash},
         {"n792778.docx", &Test::testN792778},
+        {"n793262.docx", &Test::testN793262},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1096,6 +1098,22 @@ void Test::testN792778()
     xInnerShape.set(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(11684), xInnerShape->getPosition().Y);
 }
+
+void Test::testN793262()
+{
+    uno::Reference<container::XEnumerationAccess> xHeaderText = getProperty< uno::Reference<container::XEnumerationAccess> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
+    uno::Reference<container::XEnumeration> xHeaderParagraphs(xHeaderText->createEnumeration());
+    xHeaderParagraphs->nextElement();
+    // Font size of the last empty paragraph in the header was ignored, this was 11.
+    CPPUNIT_ASSERT_EQUAL(16.f, getProperty<float>(xHeaderParagraphs->nextElement(), "CharHeight"));
+
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    // Cell margins as direct formatting were ignored, this was 0.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(76), getProperty<sal_Int32>(xTable->getCellByName("A1"), "TopBorderDistance"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 60ec497e0e91354a616978be531d15d3efa3f559
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jan 4 12:56:40 2013 +0100

    n#793262 DOCX: import w:tcMar inside w:tc
    
    These were ignored previously, and in case they contained some margins,
    the resulting table was potentially smaller than necessary.

diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx
index 6ee219e..6119831 100644
--- a/writerfilter/source/dmapper/CellMarginHandler.cxx
+++ b/writerfilter/source/dmapper/CellMarginHandler.cxx
@@ -75,6 +75,7 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
         switch( rSprm.getId() )
         {
             case NS_ooxml::LN_CT_TblCellMar_top:
+            case NS_ooxml::LN_CT_TcMar_top:
                 m_nTopMargin = m_nValue;
                 m_bTopMarginValid = true;
             break;
@@ -91,10 +92,12 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
                 }
             break;
             case NS_ooxml::LN_CT_TblCellMar_left:
+            case NS_ooxml::LN_CT_TcMar_left:
                 m_nLeftMargin = m_nValue;
                 m_bLeftMarginValid = true;
             break;
             case NS_ooxml::LN_CT_TblCellMar_bottom:
+            case NS_ooxml::LN_CT_TcMar_bottom:
                 m_nBottomMargin = m_nValue;
                 m_bBottomMarginValid = true;
             break;
@@ -111,11 +114,12 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
                 }
             break;
             case NS_ooxml::LN_CT_TblCellMar_right:
+            case NS_ooxml::LN_CT_TcMar_right:
                 m_nRightMargin = m_nValue;
                 m_bRightMarginValid = true;
             break;
             default:
-                OSL_FAIL( "unknown attribute");
+                OSL_FAIL( "unknown sprm");
         }
     }
     m_nValue = 0;
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 17e1a84..b1d560c 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -170,6 +170,26 @@ namespace dmapper {
                 }
             }
             break;
+            case NS_ooxml::LN_CT_TcPrBase_tcMar:
+                {
+                    writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+                    if (pProperties.get())
+                    {
+                        CellMarginHandlerPtr pCellMarginHandler(new CellMarginHandler);
+                        pProperties->resolve(*pCellMarginHandler);
+                        TablePropertyMapPtr pCellProperties(new TablePropertyMap);
+                        if (pCellMarginHandler->m_bTopMarginValid)
+                            pCellProperties->Insert(PROP_TOP_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nTopMargin));
+                        if (pCellMarginHandler->m_bLeftMarginValid)
+                            pCellProperties->Insert(PROP_LEFT_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nLeftMargin));
+                        if (pCellMarginHandler->m_bBottomMarginValid)
+                            pCellProperties->Insert(PROP_BOTTOM_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nBottomMargin));
+                        if (pCellMarginHandler->m_bRightMarginValid)
+                            pCellProperties->Insert(PROP_RIGHT_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nRightMargin));
+                        cellProps(pCellProperties);
+                    }
+                }
+            break;
             case NS_ooxml::LN_CT_TblPrBase_shd:
             {
                 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
commit e8b661dd0aed9b35104e910acbb814748a2c3af0
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jan 3 16:40:29 2013 +0100

    n#793262 fix DOCX import of last empty header/footer para char props
    
    At the end of the header/footer import, the last empty paragraph was
    removed. In case the last but one paragraph was empty, but had character
    properties (e.g. a custom font size), the removal changed these, and
    used the character properties of the last paragraph instead.
    
    Simply dispose the last paragraph, this way character properties are
    always kept.

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3b8e2d8..8716c0d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -278,8 +278,21 @@ void DomainMapper_Impl::RemoveLastParagraph( )
         }
         else
             xCursor.set(m_aTextAppendStack.top().xCursor, uno::UNO_QUERY);
-        xCursor->goLeft( 1, true );
-        xCursor->setString(OUString());
+        uno::Reference<container::XEnumerationAccess> xEnumerationAccess(xCursor, uno::UNO_QUERY);
+        // Keep the character properties of the last but one paragraph, even if
+        // it's empty. This works for headers/footers, and maybe in other cases
+        // as well, but surely not in textboxes.
+        if (m_bInHeaderFooterImport && xEnumerationAccess.is())
+        {
+            uno::Reference<container::XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
+            uno::Reference<lang::XComponent> xParagraph(xEnumeration->nextElement(), uno::UNO_QUERY);
+            xParagraph->dispose();
+        }
+        else
+        {
+            xCursor->goLeft( 1, true );
+            xCursor->setString(OUString());
+        }
     }
     catch( const uno::Exception& )
     {


More information about the Libreoffice-commits mailing list