summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-02-06 17:54:01 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-06 18:38:07 +0100
commit62b63d9f4b99713d10021c068005f74694299302 (patch)
treec51207624d2409e6878082ac59ec892b0648b63c /sw
parentFix spelling errror (diff)
downloadcore-62b63d9f4b99713d10021c068005f74694299302.tar.gz
core-62b63d9f4b99713d10021c068005f74694299302.zip
DOCX export: write wp14:sizeRelH and wp14:sizeRelV for Writer TextFrames
Change-Id: I16ee2682b6fa8c7b194e442d6dbe1437e7743c60
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx9
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/pagerelsize.docx (renamed from sw/qa/extras/ooxmlimport/data/pagerelsize.docx)bin17318 -> 17318 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/rel-size-round.docx (renamed from sw/qa/extras/ooxmlimport/data/rel-size-round.docx)bin15098 -> 15098 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx20
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx19
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx23
6 files changed, 52 insertions, 19 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index d6f7134aaf0d..7a6f9512bf73 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -408,6 +408,15 @@ protected:
return xShape;
}
+ /// Get TextFrame by name
+ uno::Reference<drawing::XShape> getTextFrameByName(OUString aName)
+ {
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xNameAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(xNameAccess->getByName(aName), uno::UNO_QUERY);
+ return xShape;
+ }
+
void header()
{
std::cout << "File tested,Execution Time (ms)" << std::endl;
diff --git a/sw/qa/extras/ooxmlimport/data/pagerelsize.docx b/sw/qa/extras/ooxmlexport/data/pagerelsize.docx
index 3b6c1ff448b4..3b6c1ff448b4 100755
--- a/sw/qa/extras/ooxmlimport/data/pagerelsize.docx
+++ b/sw/qa/extras/ooxmlexport/data/pagerelsize.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/rel-size-round.docx b/sw/qa/extras/ooxmlexport/data/rel-size-round.docx
index ccd076a15e48..ccd076a15e48 100755
--- a/sw/qa/extras/ooxmlimport/data/rel-size-round.docx
+++ b/sw/qa/extras/ooxmlexport/data/rel-size-round.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index a1cfd4c40b8f..3c1d9d81383c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2524,6 +2524,26 @@ DECLARE_OOXMLEXPORT_TEST(testDrawinglayerPicPos, "drawinglayer-pic-pos.docx")
// This was 1828800.
assertXPath(pXmlDocument, aXPath, "y", "0");
}
+
+DECLARE_OOXMLEXPORT_TEST(testPageRelSize, "pagerelsize.docx")
+{
+ // First textframe: width is relative from page, but not height.
+ uno::Reference<drawing::XShape> xTextFrame = getTextFrameByName("Frame1");
+ 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 = getTextFrameByName("Text Box 2");
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
+ CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx")
+{
+ // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.docx")
{
xmlDocPtr pXmlDocument = parseExport("word/document.xml");
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3fbf9ee32a22..91c5ede584c0 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1756,25 +1756,6 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
}
-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"));
-}
-
-DECLARE_OOXMLIMPORT_TEST(testRelSizeRound, "rel-size-round.docx")
-{
- // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
- CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight"));
-}
-
DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capitalization.docx")
{
// Capitalization inside a group shape was not imported
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index d0deeb5ce615..cd2bd55e4563 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -907,6 +907,29 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
pFS->endElementNS(XML_wps, XML_wsp);
pFS->endElementNS(XML_a, XML_graphicData);
pFS->endElementNS(XML_a, XML_graphic);
+
+ // Relative size of the Text Frame.
+ if (rSize.GetWidthPercent())
+ {
+ pFS->startElementNS(XML_wp14, XML_sizeRelH,
+ XML_relativeFrom, (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
+ FSEND);
+ pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
+ pFS->writeEscaped(OUString::number(rSize.GetWidthPercent() * oox::drawingml::PER_PERCENT));
+ pFS->endElementNS(XML_wp14, XML_pctWidth);
+ pFS->endElementNS(XML_wp14, XML_sizeRelH);
+ }
+ if (rSize.GetHeightPercent())
+ {
+ pFS->startElementNS(XML_wp14, XML_sizeRelV,
+ XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
+ FSEND);
+ pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
+ pFS->writeEscaped(OUString::number(rSize.GetHeightPercent() * oox::drawingml::PER_PERCENT));
+ pFS->endElementNS(XML_wp14, XML_pctHeight);
+ pFS->endElementNS(XML_wp14, XML_sizeRelV);
+ }
+
endDMLAnchorInline(&rFrmFmt);
}