summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-01-30 14:33:44 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-30 14:58:23 +0100
commitda5b9bc95c32bd233595a28bd276f8ed1f4fc859 (patch)
tree2e9ea2038d242921ae35a1f6c733fba6ec211663
parente63923b0334ae381e0fcc576a6b6e08a62e657cf (diff)
DOCX import of wp14:sizeRelH/V relativeFrom="page"
Change-Id: Idd9dcc60f415081cb7a727b46a89d45af04465d0
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/pagerelsize.docxbin0 -> 17318 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx14
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx22
3 files changed, 35 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/pagerelsize.docx b/sw/qa/extras/ooxmlimport/data/pagerelsize.docx
new file mode 100755
index 000000000000..3b6c1ff448b4
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/pagerelsize.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index ab69ced00697..bfcaa267549d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1734,9 +1734,21 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
// The text in the groupshape was missing due to the w:sdt and w:sdtContent wrapper around it.
CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
}
-#endif
+DECLARE_OOXMLIMPORT_TEST(testPageRelSize, "pagerelsize.docx")
+{
+ // First textframe: width is relative from page, but not height.
+ uno::Reference<drawing::XShape> xTextFrame = getShape(1);
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
+ // Second textframe: height is relative from page, but not height.
+ xTextFrame = getShape(2);
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
+}
+
+#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 7f2079a2d83c..2f7cfd090157 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -739,6 +739,17 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
{
case NS_ooxml::LN_ST_SizeRelFromH_margin:
break;
+ case NS_ooxml::LN_ST_SizeRelFromH_page:
+ if (m_xShape.is())
+ {
+ uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW);
+ if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME));
+ }
+ }
+ break;
default:
SAL_WARN("writerfilter", "GraphicImport::lcl_attribute: unhandled NS_ooxml::LN_CT_SizeRelH_relativeFrom value: " << nIntValue);
break;
@@ -751,6 +762,17 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
{
case NS_ooxml::LN_ST_SizeRelFromV_margin:
break;
+ case NS_ooxml::LN_ST_SizeRelFromV_page:
+ if (m_xShape.is())
+ {
+ uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW);
+ if (xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue("RelativeHeightRelation", uno::makeAny(text::RelOrientation::PAGE_FRAME));
+ }
+ }
+ break;
default:
SAL_WARN("writerfilter", "GraphicImport::lcl_attribute: unhandled NS_ooxml::LN_CT_SizeRelV_relativeFrom value: " << nIntValue);
break;