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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 23 06:38:05 UTC 2018


 sw/qa/extras/ooxmlexport/data/fdo72560b.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx        |    8 ++++++
 writerfilter/source/dmapper/DomainMapper.cxx      |   26 +++-------------------
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   10 ++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    2 +
 5 files changed, 24 insertions(+), 22 deletions(-)

New commits:
commit 150c12fc0fba2c2f4b08b4298678ee49676ebae0
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Tue Jul 17 16:27:15 2018 +0300
Commit:     Justin Luth <justin_luth at sil.org>
CommitDate: Mon Jul 23 08:37:44 2018 +0200

    tdf#72560 writerfilter: check my style, not default style
    
    The default style is only relevant if no style is defined
    for the paragraph, so it should not be hard-coded into
    any general operation.
    
    The intention of that code was to look for an inherited value,
    which can properly be found with GetPropertyFromStyleSheet().
    
    Change-Id: Ie2805d2516b43b45e702ee860deabe89d50ec031
    Reviewed-on: https://gerrit.libreoffice.org/57804
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ooxmlexport/data/fdo72560b.docx b/sw/qa/extras/ooxmlexport/data/fdo72560b.docx
new file mode 100644
index 000000000000..dfe5176f3ae3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo72560b.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index bc4e289647c4..381262a85d33 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -290,6 +290,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo72560, "fdo72560.docx")
     CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), getProperty< sal_Int32 >( xParaRightLTR, "ParaAdjust" ));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFdo72560b, "fdo72560b.docx")
+{
+    // The problem was libreoffice confuse when RTL was specified in non-default style
+    uno::Reference<uno::XInterface> xParaEndRTL(getParagraph( 2, "RTL END"));
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>( xParaEndRTL, "WritingMode" ));
+    CPPUNIT_ASSERT_EQUAL( sal_Int32(style::ParagraphAdjust_LEFT), getProperty< sal_Int32 >( xParaEndRTL, "ParaAdjust" ));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testRPrChangeClosed, "rprchange_closed.docx")
 {
     // Redline defined by rPrChanged wasn't removed.
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 5e6f2b0c0a1a..c1e3141ed9f5 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1183,28 +1183,10 @@ void DomainMapper::lcl_sprm(Sprm & rSprm)
 static bool ExchangeLeftRight(const PropertyMapPtr& rContext, DomainMapper_Impl& rImpl)
 {
     bool bExchangeLeftRight = false;
-    boost::optional<PropertyMap::Property> aPropPara = rContext->getProperty(PROP_WRITING_MODE);
-    if( aPropPara )
-    {
-        sal_Int32 aAdjust ;
-        if( (aPropPara->second >>= aAdjust) && aAdjust == text::WritingMode2::RL_TB )
-            bExchangeLeftRight = true;
-    }
-    else
-    {
-        // check if there RTL <bidi> in default style for the paragraph
-        StyleSheetEntryPtr pTable = rImpl.GetStyleSheetTable()->FindDefaultParaStyle();
-        if ( pTable )
-        {
-            boost::optional<PropertyMap::Property> aPropStyle = pTable->pProperties->getProperty(PROP_WRITING_MODE);
-            if( aPropStyle )
-            {
-                sal_Int32 aDirect;
-                if( (aPropStyle->second >>= aDirect) && aDirect == text::WritingMode2::RL_TB )
-                    bExchangeLeftRight = true;
-            }
-        }
-    }
+    sal_Int32 aAdjust;
+    uno::Any aPropPara = rImpl.GetAnyProperty(PROP_WRITING_MODE, rContext);
+    if( (aPropPara >>= aAdjust) && aAdjust == text::WritingMode2::RL_TB )
+        bExchangeLeftRight = true;
     return bExchangeLeftRight;
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8c3c59243aa0..7f0bbedfe4e0 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -718,6 +718,16 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId)
     return uno::Any();
 }
 
+uno::Any DomainMapper_Impl::GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext)
+{
+    if ( rContext )
+    {
+        boost::optional<PropertyMap::Property> aProperty = rContext->getProperty(eId);
+        if ( aProperty )
+            return aProperty->second;
+    }
+    return GetPropertyFromStyleSheet(eId);
+}
 
 ListsManager::Pointer const & DomainMapper_Impl::GetListTable()
 {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 013f8aaa5799..6b6755c6fbfd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -698,6 +698,8 @@ public:
     const OUString  GetDefaultParaStyleName();
 
     css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId);
+    // get property first from the given context, or secondly from its stylesheet
+    css::uno::Any GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext);
     void        SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}
     bool        IsStyleSheetImport()const { return m_bInStyleSheetImport;}
     void        SetAnyTableImport( bool bSet ) { m_bInAnyTableImport = bSet;}


More information about the Libreoffice-commits mailing list