sw/qa/extras/ooxmlexport/data/TextEffects.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 ++ sw/source/filter/ww8/docxattributeoutput.cxx | 103 ++++++++++++++++++++- sw/source/filter/ww8/docxattributeoutput.hxx | 3 sw/source/filter/ww8/docxexport.cxx | 1 writerfilter/source/dmapper/TextEffectsHandler.cxx | 62 +++++++++++- writerfilter/source/dmapper/TextEffectsHandler.hxx | 3 writerfilter/source/ooxml/model.xml | 25 +++-- 8 files changed, 193 insertions(+), 16 deletions(-)
New commits: commit 0d2c1e6423b32dc933b08a821a98c0f175987222 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Feb 21 20:10:46 2014 +0100 OOXML roundtrip test for w14:glow Change-Id: I80dd71bad02be980229899845c1451df6f34dca5 diff --git a/sw/qa/extras/ooxmlexport/data/TextEffects.docx b/sw/qa/extras/ooxmlexport/data/TextEffects.docx new file mode 100644 index 0000000..d164cd9 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/TextEffects.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 4793249..288c397 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -156,6 +156,7 @@ xmlNodeSetPtr Test::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath) xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("pic"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/picture")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml")); xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx); return pXmlXpathObj->nodesetval; } @@ -3419,6 +3420,17 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeParaSpacing, "dml-groupshape-paraspaci CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin")); } + +DECLARE_OOXMLEXPORT_TEST(testW14TextEffects, "TextEffects.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:rPr/w14:glow", "rad").match("63500")); + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:rPr/w14:glow", "rad").match("228600")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); commit 3554f377eac7446c3d91b70c740c22bb060b9313 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Feb 21 20:07:56 2014 +0100 ooxml: export w14:glow with subelements from a CharGrabGab Change-Id: I3e60f0532a18eba12f7a63c3e745668f54b8806e diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b1e4a01..b81fcc6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1121,7 +1121,8 @@ void DocxAttributeOutput::InitCollectedRunProperties() FSNS( XML_w, XML_eastAsianLayout ), FSNS( XML_w, XML_specVanish ), FSNS( XML_w, XML_oMath ), - FSNS( XML_w, XML_rPrChange ) + FSNS( XML_w, XML_rPrChange ), + FSNS( XML_w14, XML_glow ), }; // postpone the output so that we can later [in EndParagraphProperties()] @@ -1135,6 +1136,94 @@ void DocxAttributeOutput::InitCollectedRunProperties() } +namespace +{ + +struct NameToId +{ + const OUString maName; + const sal_Int32 maId; +}; + +const NameToId aNameToIdMapping[] = +{ + { OUString("val"), FSNS( XML_w14, XML_val ) }, + { OUString("rad"), FSNS( XML_w14, XML_rad ) }, + { OUString("schemeClr"), FSNS( XML_w14, XML_schemeClr ) }, + { OUString("srgbClr"), FSNS( XML_w14, XML_srgbClr ) }, + { OUString("tint"), FSNS( XML_w14, XML_tint ) }, + { OUString("shade"), FSNS( XML_w14, XML_shade ) }, + { OUString("alpha"), FSNS( XML_w14, XML_alpha ) }, + { OUString("hueMod"), FSNS( XML_w14, XML_hueMod ) }, + { OUString("sat"), FSNS( XML_w14, XML_sat ) }, + { OUString("satOff"), FSNS( XML_w14, XML_satOff ) }, + { OUString("satMod"), FSNS( XML_w14, XML_satMod ) }, + { OUString("lum"), FSNS( XML_w14, XML_lum ) }, + { OUString("lumOff"), FSNS( XML_w14, XML_lumOff ) }, + { OUString("lumMod"), FSNS( XML_w14, XML_lumMod ) }, +}; + +void lclProcessRecursiveGrabBag(sal_Int32 aElementId, css::uno::Sequence<css::beans::PropertyValue> aElements, sax_fastparser::FSHelperPtr pSerializer) +{ + css::uno::Sequence<css::beans::PropertyValue> aAttributes; + FastAttributeList* pAttributes = pSerializer->createAttrList(); + + for (sal_Int32 j=0; j < aElements.getLength(); ++j) + { + if( aElements[j].Name == "attributes") + { + aElements[j].Value >>= aAttributes; + } + } + + for (sal_Int32 j=0; j < aAttributes.getLength(); ++j) + { + uno::Any aAny = aAttributes[j].Value; + OString aValue; + + if(aAny.getValueType() == getCppuType<sal_Int32>()) + { + aValue = OString::number(aAny.get<sal_Int32>()); + } + else if(aAny.getValueType() == getCppuType<OUString>()) + { + aValue = OUStringToOString(aAny.get<OUString>(), RTL_TEXTENCODING_ASCII_US); + } + + sal_Int32 aLength = sizeof (aNameToIdMapping) / sizeof(NameToId); + for (sal_Int32 i=0; i < aLength; ++i) + { + if(aAttributes[j].Name == aNameToIdMapping[i].maName) + { + pAttributes->add( aNameToIdMapping[i].maId, aValue.getStr()); + } + } + } + + XFastAttributeListRef xAttributesList( pAttributes ); + + pSerializer->startElement(aElementId, xAttributesList); + + for (sal_Int32 j=0; j < aElements.getLength(); ++j) + { + css::uno::Sequence<css::beans::PropertyValue> aSumElements; + + sal_Int32 aLength = sizeof (aNameToIdMapping) / sizeof(NameToId); + for (sal_Int32 i=0; i < aLength; ++i) + { + if( aElements[j].Name == aNameToIdMapping[i].maName) + { + aElements[j].Value >>= aSumElements; + lclProcessRecursiveGrabBag(aNameToIdMapping[i].maId, aSumElements, pSerializer); + } + } + } + + pSerializer->endElement(aElementId); +} + +} + void DocxAttributeOutput::WriteCollectedRunProperties() { // Write all differed properties @@ -1169,6 +1258,12 @@ void DocxAttributeOutput::WriteCollectedRunProperties() m_pSerializer->singleElementNS( XML_w, XML_lang, xAttrList ); } + + if (m_aTextEffectsGrabBag.getLength() > 0) + { + lclProcessRecursiveGrabBag(FSNS( XML_w14, XML_glow ), m_aTextEffectsGrabBag, m_pSerializer); + m_aTextEffectsGrabBag.realloc(0); + } } void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData ) @@ -6342,6 +6437,12 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem ) { // just skip these, they were processed before } + else if (i->first == "CharGlowTextEffect") + { + uno::Sequence<beans::PropertyValue> aGrabBagSeq; + i->second >>= aGrabBagSeq; + m_aTextEffectsGrabBag = aGrabBagSeq; + } else SAL_INFO("sw.ww8", "DocxAttributeOutput::CharGrabBag: unhandled grab bag property " << i->first); } diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 660776c..8463d39 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -736,6 +736,9 @@ private: /// names of these bookmarks for each sequence. std::map<OUString, std::vector<OString> > m_aSeqBookmarksNames; + /// GrabBag for text effexts like glow + css::uno::Sequence<css::beans::PropertyValue> m_aTextEffectsGrabBag; + /// The current table helper SwWriteTable *m_pTableWrt; diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 2f416e5..321e01e 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1255,6 +1255,7 @@ XFastAttributeListRef DocxExport::MainXmlNamespaces( FSHelperPtr serializer ) pAttr->add( FSNS( XML_xmlns, XML_wpg ), "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" ); pAttr->add( FSNS( XML_xmlns, XML_mc ), "http://schemas.openxmlformats.org/markup-compatibility/2006" ); pAttr->add( FSNS( XML_xmlns, XML_wp14 ), "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" ); + pAttr->add( FSNS( XML_xmlns, XML_w14 ), "http://schemas.microsoft.com/office/word/2010/wordml" ); return XFastAttributeListRef( pAttr ); } commit 02d8db735bd2166cda4e997775d3e41ecee65c6f Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Feb 21 19:53:40 2014 +0100 writerfilter: add more w14:glow attributes into GrabBag Fix and add more attributes into the GrabBag, add attributes for an element into its own collection. Change-Id: I8d2e2fa35f4bc447c7e913e5c39223fc01f39d5a diff --git a/writerfilter/source/dmapper/TextEffectsHandler.cxx b/writerfilter/source/dmapper/TextEffectsHandler.cxx index ad3fb75..6e00b20 100644 --- a/writerfilter/source/dmapper/TextEffectsHandler.cxx +++ b/writerfilter/source/dmapper/TextEffectsHandler.cxx @@ -9,12 +9,12 @@ */ #include <TextEffectsHandler.hxx> +#include <rtl/ustrbuf.hxx> +#include <comphelper/string.hxx> #include <ooxml/resourceids.hxx> #include "dmapperLoggers.hxx" - #include <stack> - namespace writerfilter { namespace dmapper { @@ -29,6 +29,7 @@ struct GrabBagStackElement std::vector<beans::PropertyValue> maPropertyList; }; +/// Tool that is useful for construction of a nested Sequence/PropertyValue hierarchy class GrabBagStack { public: @@ -43,6 +44,11 @@ public: std::stack<GrabBagStackElement> mStack; GrabBagStackElement mCurrentElement; + OUString getCurrentName() + { + return mCurrentElement.maName; + } + PropertyValue getRootProperty() { while(!mStack.empty()) @@ -92,6 +98,27 @@ public: } }; +OUString TextEffectsHandler::getSchemeColorTypeString(sal_Int32 nType) +{ + switch (nType) + { + case NS_ooxml::LN_ST_SchemeColorVal_bg1: return OUString("bg1"); + case NS_ooxml::LN_ST_SchemeColorVal_tx1: return OUString("tx1"); + case NS_ooxml::LN_ST_SchemeColorVal_bg2: return OUString("bg2"); + case NS_ooxml::LN_ST_SchemeColorVal_tx2: return OUString("tx2"); + case NS_ooxml::LN_ST_SchemeColorVal_accent1: return OUString("accent1"); + case NS_ooxml::LN_ST_SchemeColorVal_accent2: return OUString("accent2"); + case NS_ooxml::LN_ST_SchemeColorVal_accent3: return OUString("accent3"); + case NS_ooxml::LN_ST_SchemeColorVal_accent4: return OUString("accent4"); + case NS_ooxml::LN_ST_SchemeColorVal_accent5: return OUString("accent5"); + case NS_ooxml::LN_ST_SchemeColorVal_accent6: return OUString("accent6"); + + default: break; + } + return OUString(); +} + + TextEffectsHandler::TextEffectsHandler() : LoggedProperties(dmapper_logger, "TextEffectsHandler"), mpGrabBagStack(NULL) @@ -104,20 +131,35 @@ TextEffectsHandler::~TextEffectsHandler() void TextEffectsHandler::lcl_attribute(Id aName, Value& aValue) { - sal_Int32 nValue = aValue.getInt(); + + if (mpGrabBagStack->getCurrentName() != "attributes") + mpGrabBagStack->push("attributes"); + switch(aName) { case NS_ooxml::LN_CT_Percentage_val: - mpGrabBagStack->appendElement("val", makeAny(nValue)); + mpGrabBagStack->appendElement("val", makeAny(aValue.getInt())); break; case NS_ooxml::LN_CT_PositiveFixedPercentage_val: - mpGrabBagStack->appendElement("val", makeAny(nValue)); + mpGrabBagStack->appendElement("val", makeAny(aValue.getInt())); + break; + case NS_ooxml::LN_CT_PositivePercentage_val: + mpGrabBagStack->appendElement("val", makeAny(aValue.getInt())); break; case NS_ooxml::LN_CT_SchemeColor_val: - mpGrabBagStack->appendElement("val", makeAny(nValue)); + mpGrabBagStack->appendElement("val", makeAny(getSchemeColorTypeString(aValue.getInt()))); + break; + case NS_ooxml::LN_CT_SRgbColor_val: + { + OUStringBuffer aBuf = OUString::number(aValue.getInt(), 16); + OUStringBuffer aStr; + comphelper::string::padToLength(aStr, 6 - aBuf.getLength(), '0'); + aStr.append(aBuf.getStr()); + mpGrabBagStack->appendElement("val", makeAny(aStr.makeStringAndClear())); + } break; case NS_ooxml::LN_CT_Glow_rad: - mpGrabBagStack->appendElement("rad", makeAny(nValue)); + mpGrabBagStack->appendElement("rad", makeAny(aValue.getInt())); break; default: break; @@ -126,6 +168,9 @@ void TextEffectsHandler::lcl_attribute(Id aName, Value& aValue) void TextEffectsHandler::lcl_sprm(Sprm& rSprm) { + if (mpGrabBagStack->getCurrentName() == "attributes") + mpGrabBagStack->pop(); + sal_uInt32 nSprmId = rSprm.getId(); switch(nSprmId) @@ -177,6 +222,9 @@ void TextEffectsHandler::lcl_sprm(Sprm& rSprm) pProperties.get()->resolve( *this ); + if (mpGrabBagStack->getCurrentName() == "attributes") + mpGrabBagStack->pop(); + switch(nSprmId) { case NS_ooxml::LN_EG_ColorChoice_srgbClr: diff --git a/writerfilter/source/dmapper/TextEffectsHandler.hxx b/writerfilter/source/dmapper/TextEffectsHandler.hxx index 89c5626..f224c63 100644 --- a/writerfilter/source/dmapper/TextEffectsHandler.hxx +++ b/writerfilter/source/dmapper/TextEffectsHandler.hxx @@ -24,6 +24,7 @@ namespace dmapper class GrabBagStack; +/// Class to process all text effects like glow, textOutline, ... class TextEffectsHandler : public LoggedProperties { private: @@ -41,6 +42,8 @@ public: void enableInteropGrabBag(OUString aName); void disableInteropGrabBag(); bool isInteropGrabBagEnabled(); + + static OUString getSchemeColorTypeString(sal_Int32 nType); }; typedef boost::shared_ptr<TextEffectsHandler> TextEffectsHandlerPtr; commit 22a5e4db00a1372270b80f6f121fec91de1f20dd Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Feb 21 19:51:06 2014 +0100 writerfilter: fix w14 simple types Change-Id: I5693b7570227e1a337f03febc28f5ea336b4af7f diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 0a00ea2..d8a9192 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -5335,16 +5335,26 @@ </define> <define name="ST_PositiveFixedPercentage"> - <empty/> + <data type="long"> + <xs:documentation>Positive fixed precentage</xs:documentation> + <param name="minInclusive">0</param> + <param name="maxInclusive">27273042316900</param> + </data> </define> <define name="ST_PositivePercentage"> - <empty/> + <data type="long"> + <xs:documentation>Positive precentage</xs:documentation> + <param name="minInclusive">0</param> + <param name="maxInclusive">27273042316900</param> + </data> </define> <define name="ST_Percentage"> - <data type="int"> - <xs:documentation>Percentage</xs:documentation> + <data type="long"> + <xs:documentation>Precentage</xs:documentation> + <param name="minInclusive">0</param> + <param name="maxInclusive">27273042316900</param> </data> </define> @@ -5483,7 +5493,7 @@ <value name="bg1" tokenid="ooxml:ST_SchemeColorVal_bg1">bg1</value> <value name="tx1" tokenid="ooxml:ST_SchemeColorVal_tx1">tx1</value> <value name="bg2" tokenid="ooxml:ST_SchemeColorVal_bg2">bg2</value> - <value name="tx2" tokenid="ooxml:ST_SchemeColorVal">tx2</value> + <value name="tx2" tokenid="ooxml:ST_SchemeColorVal_tx2">tx2</value> <value name="accent1" tokenid="ooxml:ST_SchemeColorVal_accent1">accent1</value> <value name="accent2" tokenid="ooxml:ST_SchemeColorVal_accent2">accent2</value> <value name="accent3" tokenid="ooxml:ST_SchemeColorVal_accent3">accent3</value> @@ -5493,9 +5503,8 @@ </resource> <resource name="ST_PositiveCoordinate" resource="Integer" generated="yes"/> <resource name="ST_HexColorRGB" resource="Hex"/> - <resource name="ST_PositivePercentage" resource="Value"> - <action name="characters" action="positivePercentage"/> - </resource> + <resource name="ST_PositivePercentage" resource="Integer" generated="yes"/> + <resource name="ST_PositiveFixedPercentage" resource="Integer" generated="yes"/> <resource name="ST_Percentage" resource="Integer" generated="yes"/> <resource name="EG_ColorTransform" resource="Properties" tag="character">
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits