summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-02-03 17:44:38 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-02-09 14:45:19 +0100
commit0a50ed4fb20cc816a8999798339857862ec245b4 (patch)
treedef14bcf03b5e9b83ecbbeb5bd74b0be3ef6d46c
parent391f6cbf804f0a2bbd5e22cd3626d7af9a2e8cfa (diff)
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. (cherry picked from commit 5e6f79348c2df12c8793e3c5cb943a86f9e47cc5) Conflicts: sw/qa/extras/ww8export/ww8export3.cxx Change-Id: I6f2ede619a8ea47404c4c37480b0e6d886cf5fce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110628 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/ww8export/data/gutter-left.docbin0 -> 22528 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx13
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx8
-rw-r--r--sw/source/filter/ww8/ww8par.hxx3
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx16
5 files changed, 35 insertions, 5 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/gutter-left.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index e8d3aaec215f..eca50addbe46 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -57,6 +57,19 @@ DECLARE_WW8EXPORT_TEST(testTdf37778_readonlySection, "tdf37778_readonlySection.d
CPPUNIT_ASSERT_EQUAL_MESSAGE("Last printed date", sal_Int16(2009), xDPS->getDocumentProperties()->getPrintDate().Year);
}
+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 bea6090df892..eb5d42253024 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4074,6 +4074,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::sprmSDxaLeft );
@@ -4082,6 +4083,13 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
// sprmSDxaRight
m_rWW8Export.InsUInt16( NS_sprm::sprmSDxaRight );
m_rWW8Export.InsUInt16( m_pageMargins.nRight );
+
+ if (nGutter)
+ {
+ // sprmSDzaGutter
+ m_rWW8Export.InsUInt16(NS_sprm::sprmSDzaGutter);
+ m_rWW8Export.InsUInt16(nGutter);
+ }
}
else
{ // normal paragraphs
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index d178bbbeda9a..b2f4a12db1b9 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -794,6 +794,7 @@ public:
sal_uInt32 nPgWidth;
sal_uInt32 nPgLeft;
sal_uInt32 nPgRight;
+ sal_uInt32 nPgGutter;
css::drawing::TextVerticalAdjust mnVerticalAdjustment;
sal_uInt8 mnBorders;
@@ -810,7 +811,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 634ac5131b0c..4a8821f678f8 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -477,9 +477,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)
@@ -502,6 +507,7 @@ void wwSectionManager::SetLeftRight(wwSection &rSection)
rSection.nPgLeft = nWWLe;
rSection.nPgRight = nWWRi;
+ rSection.nPgGutter = nWWGu;
}
void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat,
@@ -516,8 +522,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());
@@ -810,6 +817,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)