diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-06-07 08:03:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-06-07 08:45:46 +0200 |
commit | 1f127a2b9e1c1daab0972f98fc8708ecb7afa299 (patch) | |
tree | b81fbf9af5bb65d09dc9538f1daa467f90d5e167 /include/editeng | |
parent | f4b6cee77e1725837f9a6044fec0b561c7049c3b (diff) |
sw layout: allow negative page border distances
Writer follows the CSS box model when it comes to page borders: there
can be a positive distance between the edge of the page and the border,
and again a positive distance between the border and the body frame.
This ensures that the page border never intersect with the body frame,
which is usually what users expect. Word, however, can work with 2
distances for border and text, both measured from the edge of the page,
leading to a page border, which is inside the body text. This is
described at great detail at
<https://wiki.openoffice.org/wiki/Writer/MSInteroperability/PageBorder#Importing_case_3:>.
Fix the problem by allowing negative border distances: this doesn't
influence the position or the size of the body frame, but it gives us a
way to position the border more towards the center of the page, leading
the matching layout between Writer and Word.
The doc model (to allow negative border distances), UNO API and DOCX
filter is updated in this commit. The ODT filter works without explicit
effort. Other filters are not yet updated in this commit.
Change-Id: I723e1bdb8dc6391129f1686f88826cc089f6fd67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135462
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'include/editeng')
-rw-r--r-- | include/editeng/boxitem.hxx | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx index 6e0fc53d080c..750993c91f7d 100644 --- a/include/editeng/boxitem.hxx +++ b/include/editeng/boxitem.hxx @@ -59,7 +59,7 @@ class EDITENG_DLLPUBLIC SvxBoxItem final : public SfxPoolItem pBottom, pLeft, pRight; - sal_uInt16 nTopDist, + sal_Int16 nTopDist, nBottomDist, nLeftDist, nRightDist; @@ -97,29 +97,30 @@ public: //The Pointers are being copied! void SetLine( const editeng::SvxBorderLine* pNew, SvxBoxItemLine nLine ); - sal_uInt16 GetDistance( SvxBoxItemLine nLine ) const; + sal_Int16 GetDistance( SvxBoxItemLine nLine, bool bAllowNegative = false ) const; sal_uInt16 GetSmallestDistance() const; bool IsRemoveAdjacentCellBorder() const { return bRemoveAdjCellBorder; } - void SetDistance( sal_uInt16 nNew, SvxBoxItemLine nLine ); - inline void SetAllDistances( sal_uInt16 nNew ); + void SetDistance( sal_Int16 nNew, SvxBoxItemLine nLine ); + inline void SetAllDistances( sal_Int16 nNew ); void SetRemoveAdjacentCellBorder( bool bSet ) { bRemoveAdjCellBorder = bSet; } // Line width plus Space plus inward distance // bEvenIfNoLine = TRUE -> Also return distance, when no Line is set sal_uInt16 CalcLineWidth( SvxBoxItemLine nLine ) const; - sal_uInt16 CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine = false ) const; + sal_Int16 CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine = false, bool bAllowNegative = false ) const; bool HasBorder( bool bTreatPaddingAsBorder ) const; static css::table::BorderLine2 SvxLineToLine( const editeng::SvxBorderLine* pLine, bool bConvert ); static bool LineToSvxLine(const css::table::BorderLine& rLine, editeng::SvxBorderLine& rSvxLine, bool bConvert); static bool LineToSvxLine(const css::table::BorderLine2& rLine, editeng::SvxBorderLine& rSvxLine, bool bConvert); virtual boost::property_tree::ptree dumpAsJSON() const override; + void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; -inline void SvxBoxItem::SetAllDistances(sal_uInt16 const nNew) +inline void SvxBoxItem::SetAllDistances(sal_Int16 const nNew) { nTopDist = nBottomDist = nLeftDist = nRightDist = nNew; } @@ -240,7 +241,7 @@ namespace editeng { void EDITENG_DLLPUBLIC BorderDistanceFromWord(bool bFromEdge, sal_Int32& nMargin, - sal_Int32& nBorderDistance, sal_Int32 nBorderWidth); + sal_Int32& nBorderDistance, sal_Int32 nBorderWidth, bool bAllowNegativeBorderDistance = false); struct EDITENG_DLLPUBLIC WordPageMargins final { |