[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - 2 commits - sw/qa writerfilter/source

Luboš Luňák l.lunak at suse.cz
Wed Aug 7 05:48:04 PDT 2013


 sw/qa/extras/rtfimport/data/fdo67498.rtf                 |    5 +
 sw/qa/extras/rtfimport/rtfimport.cxx                     |    8 ++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |    4 +
 writerfilter/source/dmapper/PropertyMap.cxx              |   47 ++++++++-------
 writerfilter/source/dmapper/PropertyMap.hxx              |    2 
 5 files changed, 47 insertions(+), 19 deletions(-)

New commits:
commit d4d1d426d5cfe755ed82d8b8b5d6061883890453
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Apr 22 18:06:26 2013 +0200

    avoid crash when no table grid is given
    
    The document may contain just <w:tblGrid/> and <w:tblW w:w="0" w:type="auto"/> .
    It appears we do not handle the auto width properly at all, but at least don't crash.
    
    Change-Id: Ibdc9d1ad69c13456acd347a151ec8739bcb98855

diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 527793e..59ce1ea 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -622,6 +622,10 @@ void DomainMapperTableManager::endOfRowAction()
         text::TableColumnSeparator* pSeparators = aSeparators.getArray();
         sal_Int16 nSum = 0;
         sal_uInt32 nPos = 0;
+        // Avoid divide by zero (if there's no grid, position using cell widths).
+        if( nFullWidthRelative == 0 )
+            for (sal_uInt32 i = 0; i < pCellWidths->size(); ++i)
+                nFullWidthRelative += (*pCellWidths.get())[i];
 
         for (sal_uInt32 i = 0; i < pCellWidths->size() - 1; ++i)
         {
commit b7d791f358332f0fe36d31b3842067e7de068dcf
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Aug 5 17:08:20 2013 +0200

    fdo#67498 RTF import: fix missing margins vs continuous section breaks
    
    The document had 3 sections, separated by continuous section breaks.
    Previously only margins from the last section were imported, this way
    the first page had default margins.
    
    Now margins are also applied when we hit continuous section breaks. This
    way margin values from the last section break affecting the page wins. A
    later commit could improve this further by setting the minimum of these
    and setting a section margin for each non-minimal sections.
    
    Change-Id: I4d9a4585e795220533909bd1d467d933caaa0d71
    Signed-off-by: Luboš Luňák <l.lunak at suse.cz>

diff --git a/sw/qa/extras/rtfimport/data/fdo67498.rtf b/sw/qa/extras/rtfimport/data/fdo67498.rtf
new file mode 100644
index 0000000..f1058c0
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo67498.rtf
@@ -0,0 +1,5 @@
+{\rtf1\paperw11906\paperh16838\margl5954\margr454\margt567\margb8505\sectd\sbknone
+a\sect\sectd\sbknone
+b\sect\sectd
+c\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 9dfb1b6..790f0f2 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -155,6 +155,7 @@ public:
     void testParaBottomMargin();
     void testN823655();
     void testN823675();
+    void testFdo67498();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -278,6 +279,7 @@ void Test::run()
         {"para-bottom-margin.rtf", &Test::testParaBottomMargin},
         {"n823655.rtf", &Test::testN823655},
         {"n823675.rtf", &Test::testN823675},
+        {"fdo67498.rtf", &Test::testFdo67498},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1300,6 +1302,12 @@ void Test::testN823675()
     CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name);
 }
 
+void Test::testFdo67498()
+{
+    // Left margin of the default page style wasn't set (was 2000).
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(5954)), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 5fe50f2..1b79667 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -820,6 +820,29 @@ uno::Reference<beans::XPropertySet> lcl_GetRangeProperties(bool bIsFirstSection,
     return xRangeProperties;
 }
 
+void SectionPropertyMap::HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl)
+{
+    if( m_nDzaGutter > 0 )
+    {
+        //todo: iGutterPos from DocProperties are missing
+        if( m_bGutterRTL )
+            m_nRightMargin += m_nDzaGutter;
+        else
+            m_nLeftMargin += m_nDzaGutter;
+    }
+    operator[]( PropertyDefinition( PROP_LEFT_MARGIN, false )) =  uno::makeAny( m_nLeftMargin  );
+    operator[]( PropertyDefinition( PROP_RIGHT_MARGIN, false )) = uno::makeAny( m_nRightMargin );
+
+    if (rDM_Impl.m_oBackgroundColor)
+        operator[](PropertyDefinition(PROP_BACK_COLOR,false )) = uno::makeAny(*rDM_Impl.m_oBackgroundColor);
+
+    /*** if headers/footers are available then the top/bottom margins of the
+      header/footer are copied to the top/bottom margin of the page
+      */
+    CopyLastHeaderFooter( false, rDM_Impl );
+    PrepareHeaderFooterProperties( false );
+}
+
 void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
 {
     PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
@@ -868,6 +891,10 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
                 try
                 {
                     xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(aName));
+                    uno::Reference<beans::XPropertySet> xPageStyle (rDM_Impl.GetPageStyles()->getByName(aName), uno::UNO_QUERY_THROW);
+                    HandleMarginsHeaderFooter(rDM_Impl);
+                    if (rDM_Impl.IsNewDoc())
+                        _ApplyProperties(xPageStyle);
                 }
                 catch( const uno::Exception& )
                 {
@@ -899,25 +926,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
         //get the properties and create appropriate page styles
         uno::Reference< beans::XPropertySet > xFollowPageStyle = GetPageStyle( rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), false );
 
-        if( m_nDzaGutter > 0 )
-        {
-            //todo: iGutterPos from DocProperties are missing
-            if( m_bGutterRTL )
-                m_nRightMargin += m_nDzaGutter;
-            else
-                m_nLeftMargin += m_nDzaGutter;
-        }
-        operator[]( PropertyDefinition( PROP_LEFT_MARGIN, false )) =  uno::makeAny( m_nLeftMargin  );
-        operator[]( PropertyDefinition( PROP_RIGHT_MARGIN, false )) = uno::makeAny( m_nRightMargin );
-
-        if (rDM_Impl.m_oBackgroundColor)
-            operator[](PropertyDefinition(PROP_BACK_COLOR, false)) = uno::makeAny(*rDM_Impl.m_oBackgroundColor);
-
-        /*** if headers/footers are available then the top/bottom margins of the
-            header/footer are copied to the top/bottom margin of the page
-          */
-        CopyLastHeaderFooter( false, rDM_Impl );
-        PrepareHeaderFooterProperties( false );
+        HandleMarginsHeaderFooter(rDM_Impl);
 
         const OUString sTrayIndex = rPropNameSupplier.GetName( PROP_PRINTER_PAPER_TRAY_INDEX );
         if( m_nPaperBin >= 0 )
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 595ebb2..8389859 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -266,6 +266,8 @@ public:
             sal_Int32 nValue );
 
     void CloseSectionGroup( DomainMapper_Impl& rDM_Impl );
+    /// Handling of margins, header and footer for any kind of sections breaks.
+    void HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl);
 };
 typedef boost::shared_ptr<SectionPropertyMap> SectionPropertyMapPtr;
 


More information about the Libreoffice-commits mailing list