summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-06-07 09:36:06 +0200
committerAndras Timar <andras.timar@collabora.com>2017-06-15 11:00:05 +0200
commitdd0df1c8a213ab6f0959145396bc273bf885af39 (patch)
treef88f8768274ab4112c311ce9985fc44bf6dd3cc8 /sw
parentf11ae206bb368f643dbbaa6856c1d9809ad5c7b5 (diff)
Watermark: RTF font import and export
* font size * font family * rotation * TextPath geometry - working transparency & color * revert TextBox export removed by mistake Change-Id: I3f6df86809ae57dc40c275652a96b19d2a3d7eba Reviewed-on: https://gerrit.libreoffice.org/38494 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx10
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.cxx41
2 files changed, 48 insertions, 3 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 7386247ffd3d..0ab46d27f0ee 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1209,9 +1209,19 @@ DECLARE_RTFEXPORT_TEST(testWatermark, "watermark.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("WatermarkRTF"), xShape->getString());
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ OUString aFont;
+ float nFontSize;
// Check transparency
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, "FillTransparence"));
+
+ // Check font family
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CharFontName") >>= aFont);
+ CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Serif"), aFont);
+
+ // Check font size
+ CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CharHeight") >>= nFontSize);
+ CPPUNIT_ASSERT_EQUAL((float)66, nFontSize);
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 3a7b3397d0a2..beb8adc44cf6 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -21,14 +21,19 @@
#include <memory>
#include "rtfattributeoutput.hxx"
#include <svtools/rtfkeywd.hxx>
+#include <svtools/unitconv.hxx>
#include <filter/msfilter/rtfutil.hxx>
#include <editeng/editobj.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
#include <svx/svdotext.hxx>
#include <svx/unoapi.hxx>
#include <vcl/cvtgrf.hxx>
#include <textboxhelper.hxx>
#include <dcontact.hxx>
#include <algorithm>
+#include <filter/msfilter/rtfutil.hxx>
using namespace css;
@@ -554,9 +559,39 @@ sal_Int32 RtfSdrExport::StartShape()
if (pParaObj)
{
- const EditTextObject& rEditObj = pParaObj->GetTextObject();
- lcl_AppendSP(m_rAttrOutput.RunText(), "gtextUNICODE",
- msfilter::rtfutil::OutString(rEditObj.GetText(0), m_rExport.m_eCurrentEncoding));
+ // this is reached only in case some text is attached to the shape
+ // Watermark or TextBox?
+ if (pTextObj->TakeObjNameSingul().match("Text Frame"))
+ WriteOutliner(*pParaObj, TXT_HFTXTBOX);
+ else
+ {
+ const EditTextObject& rEditObj = pParaObj->GetTextObject();
+ const SfxItemSet& rItemSet = rEditObj.GetParaAttribs(0);
+
+ lcl_AppendSP(m_rAttrOutput.RunText(), "gtextUNICODE",
+ msfilter::rtfutil::OutString(rEditObj.GetText(0), m_rExport.m_eCurrentEncoding));
+
+ const SvxFontItem* pFontFamily = static_cast<const SvxFontItem*>(rItemSet.GetItem(SID_ATTR_CHAR_FONT));
+ if (pFontFamily)
+ {
+ lcl_AppendSP(m_rAttrOutput.RunText(), "gtextFont",
+ msfilter::rtfutil::OutString(pFontFamily->GetFamilyName(), m_rExport.m_eCurrentEncoding));
+ }
+
+ const SvxFontHeightItem* pFontHeight = static_cast<const SvxFontHeightItem*>(rItemSet.GetItem(SID_ATTR_CHAR_FONTHEIGHT));
+ if (pFontHeight)
+ {
+ long nFontHeight = TransformMetric(pFontHeight->GetHeight(), FUNIT_TWIP, FUNIT_POINT);
+ lcl_AppendSP(m_rAttrOutput.RunText(), "gtextSize",
+ msfilter::rtfutil::OutString(OUString::number(nFontHeight * RTF_MULTIPLIER), m_rExport.m_eCurrentEncoding));
+ }
+
+ // RTF angle: 0-360 * 2^16 clockwise
+ // LO angle: 0-360 * 100 counter-clockwise
+ sal_Int32 nRotation = -1 * pTextObj->GetGeoStat().nRotationAngle * RTF_MULTIPLIER / 100;
+ lcl_AppendSP(m_rAttrOutput.RunText(), "rotation",
+ msfilter::rtfutil::OutString(OUString::number(nRotation), m_rExport.m_eCurrentEncoding));
+ }
}
}