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

Attila Szűcs (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 15 09:56:18 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 |   13 ++++++++++++-
 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, 61 insertions(+), 2 deletions(-)

New commits:
commit c78221a5ad98939f3fb9ca6af4a2d2d2a63ff6ee
Author:     Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Mon Jun 29 15:55:28 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Jul 15 11:55:32 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)
    
    Change-Id: Iab8926b6219ac92ef1ab7488bdef1d3f2b47c396
    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>

diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 737e1f8d5902..8ff48ff467a7 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -107,6 +107,7 @@ enum class DocumentSettingId
     PROTECT_BOOKMARKS,
     PROTECT_FIELDS,
     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 aec3faac5665..e9d850bdcf2d 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -4182,6 +4182,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134548)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124423)
+{
+    createDoc("tdf124423.docx");
+    xmlDocUniquePtr 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 1f2f4aef7e85..5873f299493d 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -97,7 +97,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
     mbDisableOffPagePositioning ( false ),
     mbProtectBookmarks(false),
     mbProtectFields(false),
-    mbHeaderSpacingBelowLastPara(false)
+    mbHeaderSpacingBelowLastPara(false),
+    mbFrameAutowidthWithMorePara(false)
 
     // COMPATIBILITY FLAGS END
 {
@@ -226,6 +227,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
         case DocumentSettingId::PROTECT_BOOKMARKS: return mbProtectBookmarks;
         case DocumentSettingId::PROTECT_FIELDS: return mbProtectFields;
         case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA: return mbHeaderSpacingBelowLastPara;
+        case DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA: return mbFrameAutowidthWithMorePara;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -474,6 +476,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");
     }
@@ -646,6 +651,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
     // No mbProtectBookmarks: this is false by default everywhere
     // No mbProtectFields: this is false by default everywhere
     mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara;
+    mbFrameAutowidthWithMorePara = rSource.mbFrameAutowidthWithMorePara;
 }
 
 sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
@@ -946,6 +952,11 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 BAD_CAST(OString::boolean(mbHeaderSpacingBelowLastPara).getStr()));
     xmlTextWriterEndElement(pWriter);
 
+    xmlTextWriterStartElement(pWriter, BAD_CAST("mbFrameAutowidthWithMorePara"));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+        BAD_CAST(OString::boolean(mbFrameAutowidthWithMorePara).getStr()));
+    xmlTextWriterEndElement(pWriter);
+
     xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index ef404de0ba8b..8b409eb6be23 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -166,7 +166,7 @@ class DocumentSettingManager :
     bool mbProtectBookmarks;
     bool mbProtectFields;
     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 252101334374..95fd7d8947ec 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -72,6 +72,7 @@
 #include <bodyfrm.hxx>
 #include <FrameControlsManager.hxx>
 #include <ndtxt.hxx>
+#include <officecfg/Office/Compatibility.hxx>
 
 using namespace ::com::sun::star;
 
@@ -2516,6 +2517,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 adbd5f6c9e26..07f5502f0fea 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1848,6 +1848,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 7b94387500ac..9af674558e86 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -144,6 +144,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_PROTECT_BOOKMARKS,
     HANDLE_PROTECT_FIELDS,
     HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
+    HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA,
 };
 
 }
@@ -235,6 +236,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
         { OUString("ProtectBookmarks"), HANDLE_PROTECT_BOOKMARKS, cppu::UnoType<bool>::get(), 0 },
         { OUString("ProtectFields"), HANDLE_PROTECT_FIELDS, 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
@@ -980,6 +982,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));
     }
@@ -1465,6 +1477,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 65b0b4a86a83..1bec709d0f51 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("MsWordCompTrailingBlanks", uno::makeAny(true));
     m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
                                          uno::makeAny(true));
+    m_pImpl->SetDocumentSettingsProperty("FrameAutowidthWithMorePara", uno::makeAny(true));
 
     m_pImpl->SetDocumentSettingsProperty("TabAtLeftIndentForParagraphsInList", uno::makeAny(true));
 


More information about the Libreoffice-commits mailing list