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

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 15 12:43:37 UTC 2020


 sw/inc/IDocumentSettingAccess.hxx             |    1 +
 sw/qa/core/layout/data/tdf128195.docx         |binary
 sw/qa/core/layout/layout.cxx                  |   11 +++++++++++
 sw/source/core/doc/DocumentSettingManager.cxx |   13 ++++++++++++-
 sw/source/core/inc/DocumentSettingManager.hxx |    1 +
 sw/source/core/layout/flowfrm.cxx             |    5 ++++-
 sw/source/filter/ww8/ww8par.cxx               |    3 +++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   19 +++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx  |    2 ++
 9 files changed, 53 insertions(+), 2 deletions(-)

New commits:
commit 9b5805d1ef2b9e9c4e8f389c069807bf4489ea95
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Wed May 20 08:41:46 2020 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jun 15 14:42:59 2020 +0200

    tdf#128195 Keep spacing below last paragraph in header (docx)
    
    Add a layout compat option to keep the spacing below the last paragraph
    in the header in doc/docx files
    
    Change-Id: I259511183a8252e04d9951357dbdd4f4832523ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94577
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 5c7d3fe54253..00176843b32f 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -105,6 +105,7 @@ enum class DocumentSettingId
     CONTINUOUS_ENDNOTES,
     PROTECT_BOOKMARKS,
     PROTECT_FIELDS,
+    HEADER_SPACING_BELOW_LAST_PARA,
 };
 
  /** Provides access to settings of a document
diff --git a/sw/qa/core/layout/data/tdf128195.docx b/sw/qa/core/layout/data/tdf128195.docx
new file mode 100644
index 000000000000..16180654ce8d
Binary files /dev/null and b/sw/qa/core/layout/data/tdf128195.docx differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index 8a3a3b5369e6..cfc13640c471 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -39,6 +39,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTableFlyOverlap)
     CPPUNIT_ASSERT_GREATEREQUAL(nFlyBottom, nTableTop);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTdf128195)
+{
+    // Load a document that has two paragraphs in the header.
+    // The second paragraph should have its bottom spacing applied.
+    load(DATA_DIRECTORY, "tdf128195.docx");
+    sal_Int32 nTxtHeight = parseDump("//header/txt[2]/infos/bounds", "height").toInt32();
+    sal_Int32 nTxtBottom = parseDump("//header/txt[2]/infos/bounds", "bottom").toInt32();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2269), nTxtHeight);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3529), nTxtBottom);
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testBorderCollapseCompat)
 {
     // Load a document with a border conflict: top cell has a dotted bottom border, bottom cell has
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 279e4850b944..797e9024abb2 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -95,7 +95,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
     mbLastBrowseMode( false ),
     mbDisableOffPagePositioning ( false ),
     mbProtectBookmarks(false),
-    mbProtectFields(false)
+    mbProtectFields(false),
+    mbHeaderSpacingBelowLastPara(false)
 
     // COMPATIBILITY FLAGS END
 {
@@ -222,6 +223,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
         case DocumentSettingId::CONTINUOUS_ENDNOTES: return mbContinuousEndnotes;
         case DocumentSettingId::PROTECT_BOOKMARKS: return mbProtectBookmarks;
         case DocumentSettingId::PROTECT_FIELDS: return mbProtectFields;
+        case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA: return mbHeaderSpacingBelowLastPara;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -463,6 +465,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
         case DocumentSettingId::PROTECT_FIELDS:
             mbProtectFields = value;
             break;
+        case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA:
+            mbHeaderSpacingBelowLastPara = value;
+            break;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -633,6 +638,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
     mbContinuousEndnotes = rSource.mbContinuousEndnotes;
     // No mbProtectBookmarks: this is false by default everywhere
     // No mbProtectFields: this is false by default everywhere
+    mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara;
 }
 
 sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
@@ -923,6 +929,11 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 BAD_CAST(OString::boolean(mbContinuousEndnotes).getStr()));
     xmlTextWriterEndElement(pWriter);
 
+    xmlTextWriterStartElement(pWriter, BAD_CAST("mbHeaderSpacingBelowLastPara"));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+                                BAD_CAST(OString::boolean(mbHeaderSpacingBelowLastPara).getStr()));
+    xmlTextWriterEndElement(pWriter);
+
     xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 2ea1a2583e54..f2d8f34c8c50 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -164,6 +164,7 @@ class DocumentSettingManager :
     bool mbContinuousEndnotes = false;
     bool mbProtectBookmarks;
     bool mbProtectFields;
+    bool mbHeaderSpacingBelowLastPara;
 
 public:
 
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index b67fdc5a07bd..967fdb1662fc 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1390,7 +1390,6 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs *pAttrs,
                                    const SwFrame* pPr,
                                    const bool _bConsiderGrid ) const
 {
-
     const SwFrame* pPrevFrame = GetPrevFrameForUpperSpaceCalc_( pPr );
 
     std::unique_ptr<SwBorderAttrAccess> pAccess;
@@ -1694,6 +1693,10 @@ SwTwips SwFlowFrame::CalcLowerSpace( const SwBorderAttrs* _pAttrs ) const
         nLowerSpace += CalcAddLowerSpaceAsLastInTableCell( _pAttrs );
     }
 
+    // tdf#128195 Consider para spacing below last paragraph in header
+    if (!m_rThis.IsInFly() && m_rThis.FindFooterOrHeader() && !GetFollow() && !m_rThis.GetIndNext())
+        nLowerSpace += _pAttrs->GetULSpace().GetLower() + _pAttrs->CalcLineSpacing();
+
     return nLowerSpace;
 }
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 68f834514762..546689fc065a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1845,6 +1845,9 @@ void SwWW8ImplReader::ImportDop()
         DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, true);
     m_rDoc.getIDocumentSettingAccess().set(
         DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, true);
+    // tdf#128195
+    m_rDoc.getIDocumentSettingAccess().set(
+        DocumentSettingId::HEADER_SPACING_BELOW_LAST_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 0cb9eaaa1d16..1e6de063f472 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -142,6 +142,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_CONTINUOUS_ENDNOTES,
     HANDLE_PROTECT_BOOKMARKS,
     HANDLE_PROTECT_FIELDS,
+    HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
 };
 
 }
@@ -231,6 +232,8 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
         { OUString("ContinuousEndnotes"), HANDLE_CONTINUOUS_ENDNOTES, cppu::UnoType<bool>::get(), 0 },
         { 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 },
+
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
  * find another solution before adding them to this property set - MTG
@@ -959,6 +962,16 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
             }
         }
         break;
+        case HANDLE_HEADER_SPACING_BELOW_LAST_PARA:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+            {
+                mpDoc->getIDocumentSettingAccess().set(
+                    DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, bTmp);
+            }
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1433,6 +1446,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
                 DocumentSettingId::PROTECT_FIELDS);
         }
         break;
+        case HANDLE_HEADER_SPACING_BELOW_LAST_PARA:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 0511b6677ba2..d07f045de806 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -125,6 +125,8 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon
     // Don't load the default style definitions to avoid weird mix
     m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(true));
     m_pImpl->SetDocumentSettingsProperty("MsWordCompTrailingBlanks", uno::makeAny(true));
+    m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
+                                         uno::makeAny(true));
 
     m_pImpl->SetDocumentSettingsProperty("TabAtLeftIndentForParagraphsInList", uno::makeAny(true));
 


More information about the Libreoffice-commits mailing list