diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-25 18:54:37 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-06-01 08:10:23 +0200 |
commit | 8d322275b0a4d482296b891a550e538e33986324 (patch) | |
tree | 7ef8f52a8b55020e968f78b9962586438bc7df76 | |
parent | 5bc597c49207be961454cc333425f6d2a9230347 (diff) |
Watermark: VML font-family import for textpath
Handle style attribute to get font-family:
<v:textpath style="font-family:"DejaVu Sans Light";font-size:1pt" .../>
Change-Id: I5fe530aecccc57e103b413ef494502f666f1005a
Reviewed-on: https://gerrit.libreoffice.org/38039
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | include/oox/vml/vmlformatting.hxx | 1 | ||||
-rw-r--r-- | oox/source/vml/vmlformatting.cxx | 22 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/watermark-font.docx | bin | 0 -> 10705 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 13 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 3 |
6 files changed, 38 insertions, 2 deletions
diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx index d7c3e92f0b9c..efb0e6606887 100644 --- a/include/oox/vml/vmlformatting.hxx +++ b/include/oox/vml/vmlformatting.hxx @@ -241,6 +241,7 @@ struct OOX_DLLPUBLIC ShadowModel struct OOX_DLLPUBLIC TextpathModel { OptValue<OUString> moString; ///< Specifies the string of the textpath. + OptValue<OUString> moStyle; ///< Specifies the style of the textpath. TextpathModel(); diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 36cc43dea07d..f37c15d181d6 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -882,6 +882,28 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen } rPropMap.setAnyProperty(PROP_CustomShapeGeometry, uno::makeAny(aGeomPropSeq)); } + if (moStyle.has()) + { + OUString aStyle = moStyle.get(OUString()); + + sal_Int32 nIndex = 0; + while( nIndex >= 0 ) + { + OUString aName, aValue; + if (ConversionHelper::separatePair(aName, aValue, aStyle.getToken(0, ';', nIndex), ':')) + { + if (aName == "font-family") + { + // remove " (first, and last character) + if (aValue.getLength() > 2) + aValue = aValue.copy(1, aValue.getLength() - 2); + + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + xPropertySet->setPropertyValue("CharFontName", uno::makeAny(aValue)); + } + } + } + } } } // namespace vml diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index ed369ae1c7d9..02cf06e51429 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -383,6 +383,7 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A break; case VML_TOKEN( textpath ): mrTypeModel.maTextpathModel.moString.assignIfUsed(rAttribs.getString(XML_string)); + mrTypeModel.maTextpathModel.moStyle.assignIfUsed(rAttribs.getString(XML_style)); break; } return nullptr; diff --git a/sw/qa/extras/ooxmlexport/data/watermark-font.docx b/sw/qa/extras/ooxmlexport/data/watermark-font.docx Binary files differnew file mode 100644 index 000000000000..82d7ec8a83fc --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/watermark-font.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 80b5bba9ad9f..636dd76643e6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -727,6 +727,19 @@ DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx") CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, "LineStyle")); } +DECLARE_OOXMLEXPORT_TEST(testWatermarkFont, "watermark-font.docx") +{ + uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("TestFont"), xShape->getString()); + + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + OUString aFont; + + // Check font family + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CharFontName") >>= aFont); + CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Serif"), aFont); +} + DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx") { // The problem was that the alignment are not exchange when the paragraph are RTL. diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index e8c81d6e575b..b3c0ff237025 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -835,8 +835,7 @@ void SwUiWriterTest::testWatermarkDOCX() const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>(pItem); CPPUNIT_ASSERT_EQUAL(OUString("CustomWatermark"), pWatermark->GetText()); - //TODO: VML import textpath style - //CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Sans Light"), pWatermark->GetFont()); + CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Sans Light"), pWatermark->GetFont()); CPPUNIT_ASSERT_EQUAL((sal_Int16)45, pWatermark->GetAngle()); CPPUNIT_ASSERT_EQUAL((sal_uInt32)0x548dd4, pWatermark->GetColor()); CPPUNIT_ASSERT_EQUAL((sal_Int16)50, pWatermark->GetTransparency()); |