[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 26 12:26:07 UTC 2021


 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx        |    4 ++++
 writerfilter/source/dmapper/DomainMapper.cxx      |    9 ++++++++-
 writerfilter/source/dmapper/DomainMapper.hxx      |    1 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    1 +
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    3 +++
 writerfilter/source/dmapper/StyleSheetTable.cxx   |   10 ++++++++++
 6 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 633e72f078f99eb9f27e4ff623111ab634ff6fe1
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Wed Feb 24 10:07:08 2021 +0200
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Fri Feb 26 13:25:29 2021 +0100

    tdf#140572 writerfilter: ignore position in docDefaults
    
    Despite the documentation saying that anything in docDefaults
    should apply everywhere unless it is overridden in a higher
    priority style, the subscript/superscript setting in
    docDefaults seems to be ignored. Makes sense in a way,
    but perhaps document those exceptions?
    I looked for documentation in both "docDefaults" and "position"
    and didn't see anything suggesting why it is ignored.
    
    Change-Id: If676415b112921e4cb8f7306b8c8ad93a6fd8cde
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111442
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    (cherry picked from commit 861ca1f5030f2f6b7fbdc3bb3ded3d11130673ed)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111463

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 04c4975056e4..2b1b75c02b59 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -13,6 +13,7 @@
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <editeng/escapementitem.hxx>
 
 char const DATA_DIRECTORY[] = "/sw/qa/extras/ooxmlexport/data/";
 
@@ -65,6 +66,9 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFooterMarginLost, "footer-margin-lost.do
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf140572_docDefault_superscript, "tdf140572_docDefault_superscript.docx")
 {
     // A round-trip was crashing.
+
+    // Without the fix, everything was DFLT_ESC_AUTO_SUPER (default superscript)
+    CPPUNIT_ASSERT_EQUAL( sal_Int16(0), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharEscapement") );
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf138953, "croppedAndRotated.odt")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index ea64b4aa5f52..f229b200d1ef 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1804,8 +1804,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
         {
             if ( !IsStyleSheetImport() )
                 m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue ));
-            else
+            else if (!m_pImpl->IsDocDefaultsImport())
             {
+                // For some undocumented reason, MS Word seems to ignore this in docDefaults
+
                 // DON'T FIXME: Truly calculating this for Character Styles will be tricky,
                 // because it depends on the final fontsize - regardless of
                 // where it is set. So at the style level,
@@ -3989,6 +3991,11 @@ OUString DomainMapper::GetListStyleName(sal_Int32 nListId) const
     return m_pImpl->GetListStyleName( nListId );
 }
 
+void DomainMapper::SetDocDefaultsImport(bool bSet)
+{
+    m_pImpl->SetDocDefaultsImport(bSet);
+}
+
 bool DomainMapper::IsStyleSheetImport() const
 {
     return m_pImpl->IsStyleSheetImport();
diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx
index d2e08a0041aa..46bbd2b39018 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -112,6 +112,7 @@ public:
 
     bool IsInHeaderFooter() const;
     bool IsInTable() const;
+    void SetDocDefaultsImport(bool bSet);
     bool IsStyleSheetImport() const;
     bool IsInShape() const;
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0aee6c1d6598..2d79c618b8a1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -297,6 +297,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_pLastCharacterContext(),
         m_sCurrentParaStyleName(),
         m_sDefaultParaStyleName(),
+        m_bInDocDefaultsImport(false),
         m_bInStyleSheetImport( false ),
         m_bInAnyTableImport( false ),
         m_eInHeaderFooterImport( HeaderFooterImportState::none ),
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index b6c1cc1a8a7f..afd55fe28a26 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -508,6 +508,7 @@ private:
     ::std::vector<DeletableTabStop> m_aCurrentTabStops;
     OUString                        m_sCurrentParaStyleName; //highly inaccurate. Overwritten by "overlapping" paragraphs like comments, flys.
     OUString                        m_sDefaultParaStyleName; //caches the ConvertedStyleName of the default paragraph style
+    bool                            m_bInDocDefaultsImport;
     bool                            m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
     bool                            m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
     enum class HeaderFooterImportState
@@ -765,6 +766,8 @@ public:
     css::uno::Any GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext);
     // get property first from the given context, or secondly via inheritance from styles/docDefaults
     css::uno::Any GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext);
+    void        SetDocDefaultsImport( bool bSet ) { m_bInDocDefaultsImport = bSet;}
+    bool        IsDocDefaultsImport()const { return m_bInDocDefaultsImport;}
     void        SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}
     bool        IsStyleSheetImport()const { return m_bInStyleSheetImport;}
     void        SetAnyTableImport( bool bSet ) { m_bInAnyTableImport = bSet;}
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index ec258b7377c3..58a30c1825ea 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -689,6 +689,9 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
         }
         case NS_ooxml::LN_CT_PPrDefault_pPr:
         case NS_ooxml::LN_CT_DocDefaults_pPrDefault:
+            if (nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault)
+                m_pImpl->m_rDMapper.SetDocDefaultsImport(true);
+
             m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pDefaultParaProps );
             resolveSprmProps( m_pImpl->m_rDMapper, rSprm );
             if ( nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault && m_pImpl->m_pDefaultParaProps &&
@@ -699,13 +702,20 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
             m_pImpl->m_rDMapper.PopStyleSheetProperties();
             applyDefaults( true );
             m_pImpl->m_bHasImportedDefaultParaProps = true;
+            if (nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault)
+                m_pImpl->m_rDMapper.SetDocDefaultsImport(false);
         break;
         case NS_ooxml::LN_CT_RPrDefault_rPr:
         case NS_ooxml::LN_CT_DocDefaults_rPrDefault:
+            if (nSprmId == NS_ooxml::LN_CT_DocDefaults_rPrDefault)
+                m_pImpl->m_rDMapper.SetDocDefaultsImport(true);
+
             m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pDefaultCharProps );
             resolveSprmProps( m_pImpl->m_rDMapper, rSprm );
             m_pImpl->m_rDMapper.PopStyleSheetProperties();
             applyDefaults( false );
+            if (nSprmId == NS_ooxml::LN_CT_DocDefaults_rPrDefault)
+                m_pImpl->m_rDMapper.SetDocDefaultsImport(false);
         break;
         case NS_ooxml::LN_CT_TblPrBase_jc:     //table alignment - row properties!
              m_pImpl->m_pCurrentEntry->pProperties->Insert( PROP_HORI_ORIENT,


More information about the Libreoffice-commits mailing list