diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-27 08:23:18 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-27 08:31:44 +0100 |
commit | ddecc215614de485ab1b64812cb1b51644cad280 (patch) | |
tree | bafce7a1b3404c04cb03f42373452541f90926ba | |
parent | d87240c0b2fba39b437f87be2b3c9cf54ad0ee5f (diff) |
RTF export: handle Relative{Height,Width}{,Relation}
Change-Id: I16bef12840f45b269de18fdac4c3718ed904e1be
-rw-r--r-- | sw/qa/extras/rtfexport/data/relsize.rtf (renamed from sw/qa/extras/rtfimport/data/relsize.rtf) | 0 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 40 |
4 files changed, 49 insertions, 9 deletions
diff --git a/sw/qa/extras/rtfimport/data/relsize.rtf b/sw/qa/extras/rtfexport/data/relsize.rtf index b32186af1849..b32186af1849 100644 --- a/sw/qa/extras/rtfimport/data/relsize.rtf +++ b/sw/qa/extras/rtfexport/data/relsize.rtf diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 02b2ebb35913..9251a891dbbd 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -602,6 +602,15 @@ DECLARE_RTFEXPORT_TEST(testFdo74709, "fdo74709.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(360)), getProperty<sal_Int32>(xCell, "RightBorderDistance")); } +DECLARE_RTFEXPORT_TEST(testRelsize, "relsize.rtf") +{ + uno::Reference<drawing::XShape> xShape = getShape(1); + CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 738d1e2558c6..cb19476e9d64 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1619,15 +1619,6 @@ DECLARE_RTFIMPORT_TEST(testDprectAnchor, "dprect-anchor.rtf") CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType")); } -DECLARE_RTFIMPORT_TEST(testRelsize, "relsize.rtf") -{ - uno::Reference<drawing::XShape> xShape = getShape(1); - CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); -} - CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index f9b8e71d841e..2074a06dc0da 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -1576,6 +1576,45 @@ void lcl_TextFrameShadow(std::vector< std::pair<OString, OString> >& rFlyPropert rFlyProperties.push_back(std::make_pair<OString, OString>("shadowOffsetY", OString(aOffsetY))); } +void lcl_TextFrameRelativeSize(std::vector< std::pair<OString, OString> >& rFlyProperties, const SwFrmFmt& rFrmFmt) +{ + const SwFmtFrmSize& rSize = rFrmFmt.GetFrmSize(); + + // Relative size of the Text Frame. + if (rSize.GetWidthPercent()) + { + rFlyProperties.push_back(std::make_pair<OString, OString>("pctHoriz", OString::number(rSize.GetWidthPercent() * 10))); + + OString aRelation; + switch (rSize.GetWidthPercentRelation()) + { + case text::RelOrientation::PAGE_FRAME: + aRelation = "1"; // page + break; + default: + aRelation = "0"; // margin + break; + } + rFlyProperties.push_back(std::make_pair("sizerelh", aRelation)); + } + if (rSize.GetHeightPercent()) + { + rFlyProperties.push_back(std::make_pair<OString, OString>("pctVert", OString::number(rSize.GetHeightPercent() * 10))); + + OString aRelation; + switch (rSize.GetHeightPercentRelation()) + { + case text::RelOrientation::PAGE_FRAME: + aRelation = "1"; // page + break; + default: + aRelation = "0"; // margin + break; + } + rFlyProperties.push_back(std::make_pair("sizerelv", aRelation)); + } +} + void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& /*rNdTopLeft*/ ) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); @@ -1610,6 +1649,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt(); lcl_TextFrameShadow(m_aFlyProperties, rFrmFmt); + lcl_TextFrameRelativeSize(m_aFlyProperties, rFrmFmt); for (size_t i = 0; i < m_aFlyProperties.size(); ++i) { |