summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginHasHeader.docxbin0 -> 20882 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginNoHeader.docxbin0 -> 14683 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx36
-rw-r--r--sw/source/core/inc/pagefrm.hxx1
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx9
-rw-r--r--sw/source/core/layout/pagechg.cxx12
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx7
7 files changed, 65 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginHasHeader.docx b/sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginHasHeader.docx
new file mode 100644
index 000000000000..b978eec993c7
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginHasHeader.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginNoHeader.docx b/sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginNoHeader.docx
new file mode 100644
index 000000000000..70c2793cbf96
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123324_testRelativeAnchorHeightFromTopMarginNoHeader.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 167c05111a51..3ca1a456182f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1163,6 +1163,42 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf108505, "tdf108505.docx")
getProperty<OUString>(xText, "CharFontName"));
}
+DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorHeightFromTopMarginHasHeader,
+ "tdf123324_testRelativeAnchorHeightFromTopMarginHasHeader.docx")
+{
+ // TODO: fix export too
+ if (mbExported)
+ return;
+ // tdf#123324 The height was set relative to page print area top,
+ // but this was handled relative to page height.
+ // Note: page print area top = margin + header height.
+ // In this case the header exists.
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ const sal_Int32 nAnchoredHeight
+ = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "height").toInt32();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2551), nAnchoredHeight);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorHeightFromTopMarginNoHeader,
+ "tdf123324_testRelativeAnchorHeightFromTopMarginNoHeader.docx")
+{
+ // TODO: fix export too
+ if (mbExported)
+ return;
+ // tdf#123324 The height was set relative from top margin, but this was handled relative from page height.
+ // Note: the MSO Word margin = LO margin + LO header height.
+ // In this case the header does not exist, so MSO Word margin and LO Writer margin are the same.
+
+ // tdf#123324 The height was set relative to page print area top,
+ // but this was handled relative to page height.
+ // Note: page print area top = margin + header height.
+ // In this case the header does not exist, so OpenDocument and OOXML margins are the same.
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ const sal_Int32 nAnchoredHeight
+ = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "height").toInt32();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2551), nAnchoredHeight);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 3c7f29f52ad0..a9f642c1f03e 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -330,6 +330,7 @@ public:
/// If false is returned, then the caller should handle negative difference as (at least) zero difference instead.
bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff);
+ const SwHeaderFrame* GetHeaderFrame() const;
const SwFooterFrame* GetFooterFrame() const;
};
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 1af32ed2fa80..1ea69271f202 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -688,6 +688,15 @@ SwRect SwAnchoredDrawObject::GetObjBoundRect() const
if (GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::FRAME)
// Exclude margins.
nHeight = GetPageFrame()->getFramePrintArea().SVRect().GetHeight();
+ else if (GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::PAGE_PRINT_AREA)
+ {
+ // count required height: print area top = top margin + header
+ SwRect aHeaderRect;
+ const SwHeaderFrame* pHeaderFrame = GetPageFrame()->GetHeaderFrame();
+ if (pHeaderFrame)
+ aHeaderRect = pHeaderFrame->GetPaintArea();
+ nHeight = GetPageFrame()->GetTopMargin() + aHeaderRect.Height();
+ }
else if (GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
{
// count required height: print area bottom = bottom margin + footer
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index a3188eb2a5ca..ebcf239ef580 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -2512,6 +2512,18 @@ bool SwPageFrame::CheckPageHeightValidForHideWhitespace(SwTwips nDiff)
return true;
}
+const SwHeaderFrame* SwPageFrame::GetHeaderFrame() const
+{
+ const SwFrame* pLowerFrame = Lower();
+ while (pLowerFrame)
+ {
+ if (pLowerFrame->IsHeaderFrame())
+ return dynamic_cast<const SwHeaderFrame*>(pLowerFrame);
+ pLowerFrame = pLowerFrame->GetNext();
+ }
+ return nullptr;
+}
+
const SwFooterFrame* SwPageFrame::GetFooterFrame() const
{
const SwFrame* pLowerFrame = Lower();
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 8286503ca114..6c8523ab9bff 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -996,6 +996,13 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
xPropertySet->setPropertyValue("RelativeHeightRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME));
}
break;
+ case NS_ooxml::LN_ST_SizeRelFromV_topMargin:
+ if (m_xShape.is())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RelativeHeightRelation", uno::makeAny(text::RelOrientation::PAGE_PRINT_AREA));
+ }
+ break;
case NS_ooxml::LN_ST_SizeRelFromV_bottomMargin:
if (m_xShape.is())
{