[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 3 18:10:15 UTC 2021
sw/qa/extras/ww8export/data/gutter-left.doc |binary
sw/qa/extras/ww8export/ww8export3.cxx | 13 +++++++++++++
sw/source/filter/ww8/ww8atr.cxx | 8 ++++++++
sw/source/filter/ww8/ww8par.hxx | 3 ++-
sw/source/filter/ww8/ww8par6.cxx | 16 ++++++++++++----
5 files changed, 35 insertions(+), 5 deletions(-)
New commits:
commit 5e6f79348c2df12c8793e3c5cb943a86f9e47cc5
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Feb 3 17:44:38 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Feb 3 19:09:26 2021 +0100
tdf#91920 sw page gutter margin: add DOC filter
Map between sprmSDzaGutter and SvxLRSpaceItem::m_nGutterMargin, but
leave the fRTLGutter and iGutterPos cases alone for now.
Change-Id: I6f2ede619a8ea47404c4c37480b0e6d886cf5fce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110382
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/ww8export/data/gutter-left.doc b/sw/qa/extras/ww8export/data/gutter-left.doc
new file mode 100644
index 000000000000..0d76e8748699
Binary files /dev/null and b/sw/qa/extras/ww8export/data/gutter-left.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index b8e2117d4d6e..2eb5c361f8ac 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -93,6 +93,19 @@ DECLARE_WW8EXPORT_TEST(testTdf104596_wrapInHeaderTable, "tdf104596_wrapInHeaderT
CPPUNIT_ASSERT_MESSAGE("Text must wrap under green box", nRowHeight > 1000);
}
+DECLARE_WW8EXPORT_TEST(testGutterLeft, "gutter-left.doc")
+{
+ uno::Reference<beans::XPropertySet> xPageStyle;
+ getStyles("PageStyles")->getByName("Standard") >>= xPageStyle;
+ sal_Int32 nGutterMargin{};
+ xPageStyle->getPropertyValue("GutterMargin") >>= nGutterMargin;
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1270
+ // - Actual : 0
+ // i.e. gutter margin was lost.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin);
+}
+
DECLARE_WW8EXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc")
{
auto xNumberingRules
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 5b7e0a3b9a45..e7c2b0e71c63 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4042,6 +4042,7 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
m_pageMargins.nLeft += sal::static_int_cast<sal_uInt16>(rLR.GetLeft());
m_pageMargins.nRight += sal::static_int_cast<sal_uInt16>(rLR.GetRight());
+ sal_uInt16 nGutter = rLR.GetGutterMargin();
// sprmSDxaLeft
m_rWW8Export.InsUInt16( NS_sprm::SDxaLeft::val );
@@ -4050,6 +4051,13 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
// sprmSDxaRight
m_rWW8Export.InsUInt16( NS_sprm::SDxaRight::val );
m_rWW8Export.InsUInt16( m_pageMargins.nRight );
+
+ if (nGutter)
+ {
+ // sprmSDzaGutter
+ m_rWW8Export.InsUInt16(NS_sprm::SDzaGutter::val);
+ m_rWW8Export.InsUInt16(nGutter);
+ }
}
else
{ // normal paragraphs
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 57b53e05589c..a8370dd84f41 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -798,6 +798,7 @@ public:
sal_uInt32 nPgWidth;
sal_uInt32 nPgLeft;
sal_uInt32 nPgRight;
+ sal_uInt32 nPgGutter;
css::drawing::TextVerticalAdjust mnVerticalAdjustment;
sal_uInt8 mnBorders;
@@ -814,7 +815,7 @@ public:
bool IsBiDi() const { return maSep.fBiDi != 0; }
sal_uInt32 GetPageWidth() const { return nPgWidth; }
sal_uInt32 GetTextAreaWidth() const
- { return GetPageWidth() - GetPageLeft() - GetPageRight(); }
+ { return GetPageWidth() - GetPageLeft() - nPgGutter - GetPageRight(); }
sal_uInt32 GetPageHeight() const { return maSep.yaPage; }
sal_uInt32 GetPageLeft() const { return nPgLeft; }
sal_uInt32 GetPageRight() const { return nPgRight; }
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 815c3ef97bef..e7b2ba75d8b2 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -482,9 +482,14 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
case is handled in GetPageULData.
*/
if (rSection.maSep.fRTLGutter)
+ {
nWWRi += nWWGu;
- else if (!mrReader.m_xWDop->iGutterPos)
- nWWLe += nWWGu;
+ nWWGu = 0;
+ }
+ else if (mrReader.m_xWDop->iGutterPos)
+ {
+ nWWGu = 0;
+ }
// Left / Right
if ((rSection.nPgWidth - nWWLe - nWWRi) < MINLAY)
@@ -507,6 +512,7 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
rSection.nPgLeft = nWWLe;
rSection.nPgRight = nWWRi;
+ rSection.nPgGutter = nWWGu;
}
void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
@@ -521,8 +527,9 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight()));
rFormat.SetFormatAttr(aSz);
- rFormat.SetFormatAttr(
- SvxLRSpaceItem(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, RES_LR_SPACE));
+ SvxLRSpaceItem aLR(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, RES_LR_SPACE);
+ aLR.SetGutterMargin(rSection.nPgGutter);
+ rFormat.SetFormatAttr(aLR);
if (!bIgnoreCols)
SetCols(rFormat, rSection, rSection.GetTextAreaWidth());
@@ -817,6 +824,7 @@ wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.nNode)
, nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width())
, nPgLeft(MM_250)
, nPgRight(MM_250)
+ , nPgGutter(0)
, mnVerticalAdjustment(drawing::TextVerticalAdjust_TOP)
, mnBorders(0)
, mbHasFootnote(false)
More information about the Libreoffice-commits
mailing list