sw/qa/extras/ooxmlexport/data/tdf149089.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   10 ++++++++++
 writerfilter/source/dmapper/PropertyMap.cxx  |   13 ++++++++++---
 3 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 23f80b26098bcf9a8ae870e8ded878cca6e0c541
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Wed Jun 29 21:03:35 2022 +0800
Commit:     Mark Hung <mark...@gmail.com>
CommitDate: Thu Jul 7 15:18:19 2022 +0200

    tdf#149089 fallback GridMode.
    
    If line pitch is not defined -> fallback to none.
    Otherwise if charSpace is not defined -> fallback to lines.
    
    Change-Id: I1df027f2e74baf0215567fb9a70c879522558346
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136622
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <mark...@gmail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf149089.docx 
b/sw/qa/extras/ooxmlexport/data/tdf149089.docx
new file mode 100644
index 000000000000..2390476841e3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149089.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 75d7b8feb4ba..c264342fdb77 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -16,6 +16,7 @@
 #include <com/sun/star/text/XFootnotesSupplier.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
 #include <com/sun/star/text/XTextField.hpp>
+#include <com/sun/star/text/TextGridMode.hpp>
 #include <com/sun/star/drawing/XShapes.hpp>
 #include <com/sun/star/util/XRefreshable.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
@@ -1021,6 +1022,15 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, "tdf148273_secti
     CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf149089, "tdf149089.docx")
+{
+    uno::Reference<container::XNameAccess> xPageStyles = 
getStyles("PageStyles");
+    uno::Reference<beans::XPropertySet> 
xPageStyle(xPageStyles->getByName("Standard"), uno::UNO_QUERY);
+    sal_Int16 nGridMode;
+    xPageStyle->getPropertyValue("GridMode") >>= nGridMode;
+    CPPUNIT_ASSERT_EQUAL( sal_Int16(text::TextGridMode::LINES), nGridMode);   
// was LINES_AND_CHARS
+}
+
 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 e1814a8ce1d5..1ae28759db33 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1759,16 +1759,23 @@ void SectionPropertyMap::CloseSectionGroup( 
DomainMapper_Impl& rDM_Impl )
         }
 
         const sal_Int32 nGridLines = nTextAreaHeight / nGridLinePitch;
+        sal_Int16 nGridType = m_nGridType;
         if ( nGridLines >= 0 && nGridLines <= SAL_MAX_INT16 )
             Insert( PROP_GRID_LINES, uno::Any( sal_Int16(nGridLines) ) );
+        else
+            nGridType = text::TextGridMode::NONE;
 
         // PROP_GRID_MODE
-        Insert( PROP_GRID_MODE, uno::Any( static_cast<sal_Int16> (m_nGridType) 
) );
-        if ( m_nGridType == text::TextGridMode::LINES_AND_CHARS )
+        if ( nGridType == text::TextGridMode::LINES_AND_CHARS )
         {
-            Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars ) );
+            if (!m_nDxtCharSpace)
+                nGridType = text::TextGridMode::LINES;
+            else
+                Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars 
) );
         }
 
+        Insert( PROP_GRID_MODE, uno::Any( nGridType ) );
+
         sal_Int32 nCharWidth = 423; //240 twip/ 12 pt
         const StyleSheetEntryPtr pEntry = 
rDM_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( u"Standard" 
);
         if ( pEntry )

Reply via email to