[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/inc sw/qa sw/source writerfilter/source

Attila Szűcs (via logerrit) logerrit at kemper.freedesktop.org
Sun Sep 13 21:33:35 UTC 2020


 sw/inc/IDocumentSettingAccess.hxx             |    1 +
 sw/qa/extras/layout/data/tdf124423.docx       |binary
 sw/qa/extras/layout/data/tdf124423.odt        |binary
 sw/qa/extras/layout/layout.cxx                |   19 +++++++++++++++++++
 sw/source/core/doc/DocumentSettingManager.cxx |    8 +++++++-
 sw/source/core/inc/DocumentSettingManager.hxx |    2 +-
 sw/source/core/layout/fly.cxx                 |    7 +++++++
 sw/source/filter/ww8/ww8par.cxx               |    2 ++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 ++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx  |    1 +
 10 files changed, 56 insertions(+), 2 deletions(-)

New commits:
commit 4a00fa7032acc6e1c9780a28ab808cc690190647
Author:     Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Mon Jun 29 15:55:28 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Sun Sep 13 23:33:01 2020 +0200

    tdf#124423 sw: fix AutoSize width frames of DOCX
    
    Add layout compatibility option FRAME_AUTOWIDTH_WITH_MORE_PARA
    to keep paragraph area width of AutoSize width frames with
    more than one paragraph.
    
    Co-authored-by: Tibor Nagy (NISZ)
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97425
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit c78221a5ad98939f3fb9ca6af4a2d2d2a63ff6ee)
    
    Change-Id: Iab8926b6219ac92ef1ab7488bdef1d3f2b47c396
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102570
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index f182027ded95..32752b63f7c5 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -104,6 +104,7 @@ enum class DocumentSettingId
     APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
     CONTINUOUS_ENDNOTES,
     HEADER_SPACING_BELOW_LAST_PARA,
+    FRAME_AUTOWIDTH_WITH_MORE_PARA,
 };
 
  /** Provides access to settings of a document
diff --git a/sw/qa/extras/layout/data/tdf124423.docx b/sw/qa/extras/layout/data/tdf124423.docx
new file mode 100644
index 000000000000..d48cc60b2923
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf124423.docx differ
diff --git a/sw/qa/extras/layout/data/tdf124423.odt b/sw/qa/extras/layout/data/tdf124423.odt
new file mode 100644
index 000000000000..2202c93c5c46
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf124423.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index fae3e8f7dfd6..adb19aee2646 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -4091,6 +4091,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrTableRowSpan)
     assertXPathContent(pXmlDoc, "//textarray[1]/text", "USA");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124423)
+{
+    createDoc("tdf124423.docx");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    sal_Int32 nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32();
+    sal_Int32 nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32();
+    sal_Int32 nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32();
+    CPPUNIT_ASSERT_EQUAL(nPageWidth, nFly2Width);
+    CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
+
+    createDoc("tdf124423.odt");
+    pXmlDoc = parseLayoutDump();
+    nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32();
+    nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32();
+    nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32();
+    CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly2Width);
+    CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index c6293837d1f3..466b669723e9 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -92,7 +92,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
     mApplyParagraphMarkFormatToNumbering(false),
     mbLastBrowseMode( false ),
     mbDisableOffPagePositioning ( false ),
-    mbHeaderSpacingBelowLastPara(false)
+    mbHeaderSpacingBelowLastPara(false),
+    mbFrameAutowidthWithMorePara(false)
 
     // COMPATIBILITY FLAGS END
 {
@@ -220,6 +221,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
             return mbContinuousEndnotes;
         case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA:
             return mbHeaderSpacingBelowLastPara;
+        case DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA: return mbFrameAutowidthWithMorePara;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -458,6 +460,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
         case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA:
             mbHeaderSpacingBelowLastPara = value;
             break;
+        case DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA:
+            mbFrameAutowidthWithMorePara = value;
+            break;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -601,6 +606,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
     mbMsWordCompTrailingBlanks = rSource.mbMsWordCompTrailingBlanks;
     mbEmptyDbFieldHidesPara = rSource.mbEmptyDbFieldHidesPara;
     mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara;
+    mbFrameAutowidthWithMorePara = rSource.mbFrameAutowidthWithMorePara;
 }
 
 sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index fe87b339307c..e4563ddb4068 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -162,7 +162,7 @@ class DocumentSettingManager :
     bool mbEmptyDbFieldHidesPara;
     bool mbContinuousEndnotes = false;
     bool mbHeaderSpacingBelowLastPara;
-
+    bool mbFrameAutowidthWithMorePara; //tdf#124423
 public:
 
     DocumentSettingManager(SwDoc &rDoc);
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index b5f364511f6e..215e53b59dde 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -76,6 +76,7 @@
 #include <bodyfrm.hxx>
 #include <FrameControlsManager.hxx>
 #include <ndtxt.hxx>
+#include <officecfg/Office/Compatibility.hxx>
 
 using namespace ::com::sun::star;
 
@@ -2530,6 +2531,12 @@ static SwTwips lcl_CalcAutoWidth( const SwLayoutFrame& rFrame )
     // No autowidth defined for columned frames
     if ( !pFrame || pFrame->IsColumnFrame() )
         return nRet;
+    // tdf#124423 In Microsoft compatibility mode: widen the frame to max (PagePrintArea) if it contains at least 2 paragraphs.
+    if (rFrame.GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA) && pFrame && pFrame->GetNext())
+    {
+        const SwPageFrame* pPage = pFrame->FindPageFrame();
+        return pFrame->GetUpper()->IsVertical() ? pPage->getFramePrintArea().Height() : pPage->getFramePrintArea().Width();
+    }
 
     while ( pFrame )
     {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index f476d156a323..122e7c0fe72a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1840,6 +1840,8 @@ void SwWW8ImplReader::ImportDop()
     // tdf#128195
     m_rDoc.getIDocumentSettingAccess().set(
         DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, true);
+    m_rDoc.getIDocumentSettingAccess().set(
+        DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA, true);
 
     // Import Default Tabs
     long nDefTabSiz = m_xWDop->dxaTab;
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 9887cdc11dc8..a40fe330e709 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -145,6 +145,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_EMPTY_DB_FIELD_HIDES_PARA,
     HANDLE_CONTINUOUS_ENDNOTES,
     HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
+    HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA,
 };
 
 static MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -231,6 +232,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
         { OUString("EmptyDbFieldHidesPara"), HANDLE_EMPTY_DB_FIELD_HIDES_PARA, cppu::UnoType<bool>::get(), 0 },
         { OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType<bool>::get(), 0 },
         { OUString("HeaderSpacingBelowLastPara"), HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType<bool>::get(), 0 },
+        { OUString("FrameAutowidthWithMorePara"), HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA, cppu::UnoType<bool>::get(), 0 },
 
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
@@ -950,6 +952,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
             }
         }
         break;
+        case HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+            {
+                mpDoc->getIDocumentSettingAccess().set(
+                    DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA, bTmp);
+            }
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1418,6 +1430,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
                 DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA);
         }
         break;
+        case HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 91d69d40cc33..ec3809cd291a 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -127,6 +127,7 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon
     m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(true));
     m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
                                          uno::makeAny(true));
+    m_pImpl->SetDocumentSettingsProperty("FrameAutowidthWithMorePara", uno::makeAny(true));
 
     // Initialize RDF metadata, to be able to add statements during the import.
     try


More information about the Libreoffice-commits mailing list