[Libreoffice-commits] core.git: 2 commits - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jul 14 07:47:29 PDT 2014


 sw/qa/extras/ooxmlexport/data/footer-body-distance.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                |    7 ++
 writerfilter/source/dmapper/PropertyMap.cxx             |   53 +++++++---------
 3 files changed, 31 insertions(+), 29 deletions(-)

New commits:
commit f3145f74a2829526169a44696dbd3c16b2c5ae77
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 14 15:38:51 2014 +0200

    Clean up SectionPropertyMap::PrepareHeaderFooterProperties()
    
    If you copy the class members on the stack and tweak those (and not
    class members), then there is no need to manually restore the copy at
    the end of the method.
    
    Change-Id: I42b50cd6b99b6b277dd9809b40385ef6512ef141

diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index eb83a35..ff76c13 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -791,32 +791,32 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
     sal_Int32 nHeaderTop = m_nHeaderTop;
     if(HasHeader(bFirstPage))
     {
-        m_nTopMargin = m_nHeaderTop;
-        if( nTopMargin > 0 && nTopMargin > m_nHeaderTop )
-            m_nHeaderTop = nTopMargin - m_nHeaderTop;
+        nTopMargin = nHeaderTop;
+        if( m_nTopMargin > 0 && m_nTopMargin > nHeaderTop )
+            nHeaderTop = m_nTopMargin - nHeaderTop;
         else
-            m_nHeaderTop = 0;
+            nHeaderTop = 0;
 
         //minimum header height 1mm
-        if( m_nHeaderTop < MIN_HEAD_FOOT_HEIGHT )
-            m_nHeaderTop = MIN_HEAD_FOOT_HEIGHT;
+        if( nHeaderTop < MIN_HEAD_FOOT_HEIGHT )
+            nHeaderTop = MIN_HEAD_FOOT_HEIGHT;
     }
 
 
-    if( nTopMargin >= 0 ) //fixed height header -> see WW8Par6.hxx
+    if( m_nTopMargin >= 0 ) //fixed height header -> see WW8Par6.hxx
     {
         operator[](PROP_HEADER_IS_DYNAMIC_HEIGHT) = uno::makeAny( true );
         operator[](PROP_HEADER_DYNAMIC_SPACING) = uno::makeAny( true );
-        operator[](PROP_HEADER_BODY_DISTANCE) = uno::makeAny( m_nHeaderTop - MIN_HEAD_FOOT_HEIGHT );// ULSpace.Top()
-        operator[](PROP_HEADER_HEIGHT) = uno::makeAny( m_nHeaderTop );
+        operator[](PROP_HEADER_BODY_DISTANCE) = uno::makeAny( nHeaderTop - MIN_HEAD_FOOT_HEIGHT );// ULSpace.Top()
+        operator[](PROP_HEADER_HEIGHT) = uno::makeAny( nHeaderTop );
 
     }
     else
     {
         //todo: old filter fakes a frame into the header/footer to support overlapping
         //current setting is completely wrong!
-        operator[](PROP_HEADER_HEIGHT) = uno::makeAny( m_nHeaderTop );
-        operator[](PROP_HEADER_BODY_DISTANCE) = uno::makeAny( nTopMargin - m_nHeaderTop );
+        operator[](PROP_HEADER_HEIGHT) = uno::makeAny( nHeaderTop );
+        operator[](PROP_HEADER_BODY_DISTANCE) = uno::makeAny( m_nTopMargin - nHeaderTop );
         operator[](PROP_HEADER_IS_DYNAMIC_HEIGHT) = uno::makeAny( false );
         operator[](PROP_HEADER_DYNAMIC_SPACING) = uno::makeAny( false );
     }
@@ -825,21 +825,21 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
     sal_Int32 nHeaderBottom = m_nHeaderBottom;
     if( HasFooter( bFirstPage ) )
     {
-        m_nBottomMargin = m_nHeaderBottom;
-        if( nBottomMargin > 0 && nBottomMargin > m_nHeaderBottom )
-            m_nHeaderBottom = nBottomMargin - m_nHeaderBottom;
+        nBottomMargin = nHeaderBottom;
+        if( m_nBottomMargin > 0 && m_nBottomMargin > nHeaderBottom )
+            nHeaderBottom = m_nBottomMargin - nHeaderBottom;
         else
-            m_nHeaderBottom = 0;
-        if( m_nHeaderBottom < MIN_HEAD_FOOT_HEIGHT )
-            m_nHeaderBottom = MIN_HEAD_FOOT_HEIGHT;
+            nHeaderBottom = 0;
+        if( nHeaderBottom < MIN_HEAD_FOOT_HEIGHT )
+            nHeaderBottom = MIN_HEAD_FOOT_HEIGHT;
     }
 
-    if( nBottomMargin >= 0 ) //fixed height footer -> see WW8Par6.hxx
+    if( m_nBottomMargin >= 0 ) //fixed height footer -> see WW8Par6.hxx
     {
         operator[](PROP_FOOTER_IS_DYNAMIC_HEIGHT) = uno::makeAny( true );
         operator[](PROP_FOOTER_DYNAMIC_SPACING) = uno::makeAny( true );
-        operator[](PROP_FOOTER_BODY_DISTANCE) = uno::makeAny( m_nHeaderBottom - MIN_HEAD_FOOT_HEIGHT);
-        operator[](PROP_FOOTER_HEIGHT) = uno::makeAny( m_nHeaderBottom );
+        operator[](PROP_FOOTER_BODY_DISTANCE) = uno::makeAny( nHeaderBottom - MIN_HEAD_FOOT_HEIGHT);
+        operator[](PROP_FOOTER_HEIGHT) = uno::makeAny( nHeaderBottom );
     }
     else
     {
@@ -847,19 +847,13 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
         //current setting is completely wrong!
         operator[](PROP_FOOTER_IS_DYNAMIC_HEIGHT) = uno::makeAny( false );
         operator[](PROP_FOOTER_DYNAMIC_SPACING) = uno::makeAny( false );
-        operator[](PROP_FOOTER_HEIGHT) = uno::makeAny( nBottomMargin - m_nHeaderBottom );
-        operator[](PROP_FOOTER_BODY_DISTANCE) = uno::makeAny( m_nHeaderBottom );
+        operator[](PROP_FOOTER_HEIGHT) = uno::makeAny( m_nBottomMargin - nHeaderBottom );
+        operator[](PROP_FOOTER_BODY_DISTANCE) = uno::makeAny( nHeaderBottom );
     }
 
     //now set the top/bottom margin for the follow page style
-    operator[](PROP_TOP_MARGIN) = uno::makeAny( m_nTopMargin );
-    operator[](PROP_BOTTOM_MARGIN) = uno::makeAny( m_nBottomMargin );
-
-    // Restore original top margin, so we don't end up with a smaller margin in case we have to produce two page styles from one Word section.
-    m_nTopMargin = nTopMargin;
-    m_nHeaderTop = nHeaderTop;
-    m_nBottomMargin = nBottomMargin;
-    m_nHeaderBottom = nHeaderBottom;
+    operator[](PROP_TOP_MARGIN) = uno::makeAny( nTopMargin );
+    operator[](PROP_BOTTOM_MARGIN) = uno::makeAny( nBottomMargin );
 }
 
 uno::Reference<beans::XPropertySet> lcl_GetRangeProperties(bool bIsFirstSection, DomainMapper_Impl& rDM_Impl, uno::Reference<text::XTextRange> xStartingRange)
commit 8cf681c5049970573020d8b808c990441b9cf828
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 14 12:34:23 2014 +0200

    DOCX import: fix FooterBodyDistance for first pages
    
    The root cause was that code in
    SectionPropertyMap::PrepareHeaderFooterProperties() saved member
    variables on the stack, modified them, then restored them at the end of
    the method, but forgot to restore m_nBottomMargin there.
    
    The result of this was that First Page's FooterBodyDistance got set to
    zero, which is not the same as Default Style's FooterBodyDistance (150),
    so on export sw::util::IsPlausableSingleWordSection() returned false,
    which turned the page break into a section break.
    
    Change-Id: I1afa2603de1313ae1e2aaefd4b7c771fce27e21e

diff --git a/sw/qa/extras/ooxmlexport/data/footer-body-distance.docx b/sw/qa/extras/ooxmlexport/data/footer-body-distance.docx
new file mode 100644
index 0000000..0244d76
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/footer-body-distance.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 3ad8b6d..0c530fb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3776,6 +3776,13 @@ DECLARE_OOXMLEXPORT_TEST(testSdtDateCharformat, "sdt-date-charformat.docx")
         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:rPr/w:b", 1);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFooterBodyDistance, "footer-body-distance.docx")
+{
+    if (xmlDocPtr pXmlDoc = parseExport())
+        // Page break was exported as section break, this was 0
+        assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 13a7288..eb83a35 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -858,6 +858,7 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
     // Restore original top margin, so we don't end up with a smaller margin in case we have to produce two page styles from one Word section.
     m_nTopMargin = nTopMargin;
     m_nHeaderTop = nHeaderTop;
+    m_nBottomMargin = nBottomMargin;
     m_nHeaderBottom = nHeaderBottom;
 }
 


More information about the Libreoffice-commits mailing list