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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 3 13:39:47 UTC 2021


 sw/qa/extras/ooxmlexport/data/gutter-left.docx    |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx        |   13 +++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx      |   12 ++++++------
 writerfilter/source/dmapper/DomainMapper.cxx      |    1 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    5 ++++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    1 +
 writerfilter/source/dmapper/PropertyIds.cxx       |    3 +++
 writerfilter/source/dmapper/PropertyIds.hxx       |    1 +
 writerfilter/source/dmapper/PropertyMap.cxx       |    2 ++
 writerfilter/source/dmapper/PropertyMap.hxx       |    2 ++
 10 files changed, 33 insertions(+), 7 deletions(-)

New commits:
commit b07f6c14a49aea23457b41b0d75390e68fe550b3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Feb 3 11:58:10 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Feb 3 14:38:55 2021 +0100

    tdf#91920 sw page gutter margin: add DOCX filter
    
    - import: convert the gutter twips value to mm100, then map it to the
    GutterMargin property of the page style
    
    - export: map SvxLRSpaceItem::m_nGutterMargin to <w:pgMar ... w:gutter="..."/>
    
    Change-Id: I971d32ffe4e67c2c5a5518b5aa63cb8514e04e2a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110345
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/gutter-left.docx b/sw/qa/extras/ooxmlexport/data/gutter-left.docx
new file mode 100644
index 000000000000..4dc1cbf615f7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/gutter-left.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 3d89e01501c7..c35db2c88cd1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -38,6 +38,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf138892_noNumbering, "tdf138892_noNumbering.docx"
     CPPUNIT_ASSERT_MESSAGE("Para3: <blank line>", getProperty<OUString>(getParagraph(3), "NumberingStyleName").isEmpty());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testGutterLeft, "gutter-left.docx")
+{
+    uno::Reference<beans::XPropertySet> xPageStyle;
+    getStyles("PageStyles")->getByName("Standard") >>= xPageStyle;
+    sal_Int32 nGutterMargin{};
+    xPageStyle->getPropertyValue("GutterMargin") >>= nGutterMargin;
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 1270
+    // - Actual  : 0
+    // i.e. gutter margin was lost.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf134619_numberingProps, "tdf134619_numberingProps.doc")
 {
     // Get the third paragraph's numbering style's 1st level's bullet size
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 04bf7b36c068..653e72b64b69 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8765,10 +8765,12 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
 
         m_pageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLRSpace.GetLeft());
         m_pageMargins.nRight += sal::static_int_cast<sal_uInt16>(rLRSpace.GetRight());
+        sal_uInt16 nGutter = rLRSpace.GetGutterMargin();
 
-        AddToAttrList( m_pSectionSpacingAttrList, 2,
+        AddToAttrList( m_pSectionSpacingAttrList, 3,
                 FSNS( XML_w, XML_left ), OString::number( m_pageMargins.nLeft ).getStr(),
-                FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nRight ).getStr() );
+                FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nRight ).getStr(),
+                FSNS( XML_w, XML_gutter ), OString::number( nGutter ).getStr() );
     }
     else
     {
@@ -8851,13 +8853,11 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
         // Page Bottom
         m_pageMargins.nBottom = aDistances.dyaBottom;
 
-        AddToAttrList( m_pSectionSpacingAttrList, 5,
+        AddToAttrList( m_pSectionSpacingAttrList, 4,
                 FSNS( XML_w, XML_header ), OString::number( nHeader ).getStr(),
                 FSNS( XML_w, XML_top ), OString::number( m_pageMargins.nTop ).getStr(),
                 FSNS( XML_w, XML_footer ), OString::number( nFooter ).getStr(),
-                FSNS( XML_w, XML_bottom ), OString::number( m_pageMargins.nBottom ).getStr(),
-                // FIXME Page Gutter is not handled ATM, setting to 0 as it's mandatory for OOXML
-                FSNS( XML_w, XML_gutter ), "0" );
+                FSNS( XML_w, XML_bottom ), OString::number( m_pageMargins.nBottom ).getStr() );
     }
     else
     {
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 13da5508b236..0aee54ae125e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2174,6 +2174,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
             pSectionContext->SetLeftMargin( rPageMar.left );
             pSectionContext->SetHeaderTop( rPageMar.header );
             pSectionContext->SetHeaderBottom( rPageMar.footer );
+            pSectionContext->SetGutterMargin(rPageMar.gutter);
         }
         break;
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d0ed6bcb10b2..c2b60fc48f5c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6909,7 +6909,9 @@ void DomainMapper_Impl::SetPageMarginTwip( PageMarElement eElement, sal_Int32 nV
         case PAGE_MAR_LEFT   : m_aPageMargins.left    = nValue; break;
         case PAGE_MAR_HEADER : m_aPageMargins.header  = nValue; break;
         case PAGE_MAR_FOOTER : m_aPageMargins.footer  = nValue; break;
-        case PAGE_MAR_GUTTER : break;
+        case PAGE_MAR_GUTTER:
+            m_aPageMargins.gutter = nValue;
+            break;
     }
 }
 
@@ -6923,6 +6925,7 @@ PageMar::PageMar()
     , left(right)
     , header(ConversionHelper::convertTwipToMM100(sal_Int32(720)))
     , footer(header)
+    , gutter(0)
 {
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index b4b111e787ec..ab29d0a3a185 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -77,6 +77,7 @@ struct PageMar
     sal_Int32 left;
     sal_Int32 header;
     sal_Int32 footer;
+    sal_Int32 gutter;
     public:
         PageMar();
 };
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 3aafab2c9354..5450c0c0dfc6 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -357,6 +357,9 @@ OUString getPropertyName( PropertyIds eId )
         case PROP_CHAR_TRANSPARENCE: sName = "CharTransparence"; break;
         case PROP_CELL_FORMULA: sName = "CellFormula"; break;
         case PROP_CELL_FORMULA_CONVERTED: sName = "CellFormulaConverted"; break;
+        case PROP_GUTTER_MARGIN:
+            sName = "GutterMargin";
+            break;
     }
     assert(sName.getLength()>0);
     return sName;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 5eed2297ff0d..766748116a70 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -359,6 +359,7 @@ enum PropertyIds
         ,PROP_CHAR_TRANSPARENCE
         ,PROP_CELL_FORMULA
         ,PROP_CELL_FORMULA_CONVERTED
+        ,PROP_GUTTER_MARGIN
     };
 
 //Returns the UNO string equivalent to eId.
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 4cdd76e91a2c..6f8f8d5a9b1e 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -412,6 +412,7 @@ SectionPropertyMap::SectionPropertyMap( bool bIsFirstSection )
     , m_nBreakType( -1 )
     , m_nLeftMargin( 2540 )  // page left margin,  default 1 inch = 1440 twip -> 2540 1/100 mm
     , m_nRightMargin( 2540 ) // page right margin,  default 1 inch = 1440 twip -> 2540 1/100 mm
+    , m_nGutterMargin(0)
     , m_nTopMargin( 2540 )
     , m_nBottomMargin( 2540 )
     , m_nHeaderTop( 1270 )    // 720 twip
@@ -1066,6 +1067,7 @@ void SectionPropertyMap::HandleMarginsHeaderFooter( bool bFirstPage, DomainMappe
 {
     Insert( PROP_LEFT_MARGIN, uno::makeAny( m_nLeftMargin ) );
     Insert( PROP_RIGHT_MARGIN, uno::makeAny( m_nRightMargin ) );
+    Insert(PROP_GUTTER_MARGIN, uno::makeAny(m_nGutterMargin));
 
     if ( rDM_Impl.m_oBackgroundColor )
         Insert( PROP_BACK_COLOR, uno::makeAny( *rDM_Impl.m_oBackgroundColor ) );
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index c48d52803ee1..f8c976abd388 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -254,6 +254,7 @@ private:
 
     sal_Int32                                       m_nLeftMargin;
     sal_Int32                                       m_nRightMargin;
+    sal_Int32                                       m_nGutterMargin;
     sal_Int32                                       m_nTopMargin;
     sal_Int32                                       m_nBottomMargin;
     sal_Int32                                       m_nHeaderTop;
@@ -381,6 +382,7 @@ public:
     void SetBottomMargin( sal_Int32 nSet ) { m_nBottomMargin = nSet; }
     void SetHeaderTop( sal_Int32 nSet )    { m_nHeaderTop = nSet; }
     void SetHeaderBottom( sal_Int32 nSet ) { m_nHeaderBottom = nSet; }
+    void SetGutterMargin( sal_Int32 nGutterMargin ) { m_nGutterMargin = nGutterMargin; }
     sal_Int32 GetPageWidth() const;
 
     void SetGridType( sal_Int32 nSet )      { m_nGridType = nSet; }


More information about the Libreoffice-commits mailing list