[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Mar 27 00:32:10 PDT 2014


 sw/qa/extras/rtfexport/data/relsize.rtf     |   42 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx        |    9 ++++++
 sw/qa/extras/rtfimport/data/relsize.rtf     |   42 ----------------------------
 sw/qa/extras/rtfimport/rtfimport.cxx        |    9 ------
 sw/source/filter/ww8/rtfattributeoutput.cxx |   40 ++++++++++++++++++++++++++
 5 files changed, 91 insertions(+), 51 deletions(-)

New commits:
commit ddecc215614de485ab1b64812cb1b51644cad280
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 27 08:23:18 2014 +0100

    RTF export: handle Relative{Height,Width}{,Relation}
    
    Change-Id: I16bef12840f45b269de18fdac4c3718ed904e1be

diff --git a/sw/qa/extras/rtfimport/data/relsize.rtf b/sw/qa/extras/rtfexport/data/relsize.rtf
similarity index 100%
rename from sw/qa/extras/rtfimport/data/relsize.rtf
rename to sw/qa/extras/rtfexport/data/relsize.rtf
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 02b2ebb..9251a89 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 738d1e2..cb19476 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 f9b8e71..2074a06 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)
             {


More information about the Libreoffice-commits mailing list