summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-10 14:19:26 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-10 17:12:26 +0100
commit1959431528686bd1b73b73c2664c8c161c2194f5 (patch)
tree473d2d2ffd434041245b15e4776d212250fafafb /oox/source
parentd665e63be3e4dfad44b178ee90ad83f9408fd43c (diff)
oox: handle all w14 text effects at groupshape import
When dealing with groupshapes, the responsibility to process the w14 text effects elements is in oox. This commit adds the code to handle all elements and its children elements and attributes and puts the values into a CharInteropGrabBag. Change-Id: Iafb8759bd60e0ee831296dc2d9159f4311ad5403
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/textcharacterproperties.cxx23
-rw-r--r--oox/source/drawingml/textcharacterpropertiescontext.cxx17
-rw-r--r--oox/source/drawingml/texteffectscontext.cxx303
-rw-r--r--oox/source/token/properties.txt1
4 files changed, 343 insertions, 1 deletions
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx
index 7f2e3a7fc964..bb7b227c91f0 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -63,6 +63,8 @@ void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSource
moItalic.assignIfUsed( rSourceProps.moItalic );
moUnderlineLineFollowText.assignIfUsed( rSourceProps.moUnderlineLineFollowText );
moUnderlineFillFollowText.assignIfUsed( rSourceProps.moUnderlineFillFollowText );
+
+ maTextEffectsProperties = rSourceProps.maTextEffectsProperties;
}
void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter, bool bUseOptional ) const
@@ -159,11 +161,30 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil
}
}
- void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter, bool bUseOptional ) const
+void pushToGrabBag( PropertySet& rPropSet, const std::vector<PropertyValue>& aVectorOfProperyValues )
+{
+ Sequence<PropertyValue> aGrabBag;
+ Any aAnyGrabBag = rPropSet.getAnyProperty(PROP_CharInteropGrabBag);
+ aAnyGrabBag >>= aGrabBag;
+
+ sal_Int32 nLength = aGrabBag.getLength();
+ aGrabBag.realloc(nLength + aVectorOfProperyValues.size());
+
+ for (size_t i = 0; i < aVectorOfProperyValues.size(); i++)
+ {
+ PropertyValue aPropertyValue = aVectorOfProperyValues[i];
+ aGrabBag[nLength + i] = aPropertyValue;
+ }
+
+ rPropSet.setAnyProperty(PROP_CharInteropGrabBag, makeAny(aGrabBag));
+}
+
+void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter, bool bUseOptional ) const
{
PropertyMap aPropMap;
pushToPropMap( aPropMap, rFilter, bUseOptional );
rPropSet.setProperties( aPropMap );
+ pushToGrabBag(rPropSet, maTextEffectsProperties);
}
float TextCharacterProperties::getCharHeightPoints( float fDefault ) const
diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index cde4a636282b..b432c80a6acf 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -22,6 +22,7 @@
#include "oox/helper/attributelist.hxx"
#include "oox/drawingml/drawingmltypes.hxx"
#include "oox/drawingml/colorchoicecontext.hxx"
+#include "oox/drawingml/texteffectscontext.hxx"
#include "oox/drawingml/lineproperties.hxx"
#include "oox/drawingml/textparagraphproperties.hxx"
#include "oox/core/relations.hxx"
@@ -194,6 +195,22 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
mrTextCharacterProperties.moCaseMap = XML_none;
}
break;
+ case OOX_TOKEN(w14, glow):
+ case OOX_TOKEN(w14, shadow):
+ case OOX_TOKEN(w14, reflection):
+ case OOX_TOKEN(w14, textOutline):
+ case OOX_TOKEN(w14, textFill):
+ case OOX_TOKEN(w14, scene3d):
+ case OOX_TOKEN(w14, props3d):
+ case OOX_TOKEN(w14, ligatures):
+ case OOX_TOKEN(w14, numForm):
+ case OOX_TOKEN(w14, numSpacing):
+ case OOX_TOKEN(w14, stylisticSets):
+ case OOX_TOKEN(w14, cntxtAlts):
+ {
+ return new TextEffectsContext( *this, aElementToken, mrTextCharacterProperties.maTextEffectsProperties );
+ }
+ break;
default:
SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
break;
diff --git a/oox/source/drawingml/texteffectscontext.cxx b/oox/source/drawingml/texteffectscontext.cxx
new file mode 100644
index 000000000000..ffe3283489a5
--- /dev/null
+++ b/oox/source/drawingml/texteffectscontext.cxx
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include "oox/drawingml/texteffectscontext.hxx"
+
+#include <map>
+
+namespace oox { namespace drawingml {
+
+namespace
+{
+
+OUString lclGetNameForElementId(sal_uInt32 aId)
+{
+ static std::map<sal_uInt32, OUString> aIdMap;
+ if(aIdMap.empty())
+ {
+ aIdMap[OOX_TOKEN(w14, srgbClr)] = "srgbClr";
+ aIdMap[OOX_TOKEN(w14, schemeClr)] = "schemeClr";
+ aIdMap[OOX_TOKEN(w14, tint)] = "tint";
+ aIdMap[OOX_TOKEN(w14, shade)] = "shade";
+ aIdMap[OOX_TOKEN(w14, alpha)] = "alpha";
+ aIdMap[OOX_TOKEN(w14, hueMod)] = "hueMod";
+ aIdMap[OOX_TOKEN(w14, sat)] = "sat";
+ aIdMap[OOX_TOKEN(w14, satOff)] = "satOff";
+ aIdMap[OOX_TOKEN(w14, satMod)] = "satMod";
+ aIdMap[OOX_TOKEN(w14, lum)] = "lum";
+ aIdMap[OOX_TOKEN(w14, lumOff)] = "lumOff";
+ aIdMap[OOX_TOKEN(w14, lumMod)] = "lumMod";
+ aIdMap[OOX_TOKEN(w14, noFill)] = "noFill";
+ aIdMap[OOX_TOKEN(w14, solidFill)] = "solidFill";
+ aIdMap[OOX_TOKEN(w14, gradFill)] = "gradFill";
+ aIdMap[OOX_TOKEN(w14, gsLst)] = "gsLst";
+ aIdMap[OOX_TOKEN(w14, gs)] = "gs";
+ aIdMap[OOX_TOKEN(w14, pos)] = "pos";
+ aIdMap[OOX_TOKEN(w14, lin)] = "lin";
+ aIdMap[OOX_TOKEN(w14, path)] = "path";
+ aIdMap[OOX_TOKEN(w14, fillToRect)] = "fillToRect";
+ aIdMap[OOX_TOKEN(w14, prstDash)] = "prstDash";
+ aIdMap[OOX_TOKEN(w14, round)] = "round";
+ aIdMap[OOX_TOKEN(w14, bevel)] = "bevel";
+ aIdMap[OOX_TOKEN(w14, miter)] = "miter";
+ aIdMap[OOX_TOKEN(w14, camera)] = "camera";
+ aIdMap[OOX_TOKEN(w14, lightRig)] = "lightRig";
+ aIdMap[OOX_TOKEN(w14, rot)] = "rot";
+ aIdMap[OOX_TOKEN(w14, bevelT)] = "bevelT";
+ aIdMap[OOX_TOKEN(w14, bevelB)] = "bevelB";
+ aIdMap[OOX_TOKEN(w14, extrusionClr)] = "extrusionClr";
+ aIdMap[OOX_TOKEN(w14, contourClr)] = "contourClr";
+ aIdMap[OOX_TOKEN(w14, styleSet)] = "styleSet";
+
+ aIdMap[OOX_TOKEN(w14, glow)] = "CharGlowTextEffect";
+ aIdMap[OOX_TOKEN(w14, shadow)] = "CharShadowTextEffect";
+ aIdMap[OOX_TOKEN(w14, reflection)] = "CharReflectionTextEffect";
+ aIdMap[OOX_TOKEN(w14, textOutline)] = "CharTextOutlineTextEffect";
+ aIdMap[OOX_TOKEN(w14, textFill)] = "CharTextFillTextEffect";
+ aIdMap[OOX_TOKEN(w14, scene3d)] = "CharScene3DTextEffect";
+ aIdMap[OOX_TOKEN(w14, props3d)] = "CharProps3DTextEffect";
+ aIdMap[OOX_TOKEN(w14, ligatures)] = "CharLigaturesTextEffect";
+ aIdMap[OOX_TOKEN(w14, numForm)] = "CharNumFormTextEffect";
+ aIdMap[OOX_TOKEN(w14, numSpacing)] = "CharNumSpacingTextEffect";
+ aIdMap[OOX_TOKEN(w14, stylisticSets)]= "CharStylisticSetsTextEffect";
+ aIdMap[OOX_TOKEN(w14, cntxtAlts)] = "CharCntxtAltsTextEffect";
+ }
+
+ return aIdMap[aId];
+}
+
+const char constAttributesSequenceName[] = "attributes";
+
+}
+
+using namespace oox::core;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+
+TextEffectsContext::TextEffectsContext(
+ ContextHandler2Helper& rParent,
+ sal_Int32 aElementToken,
+ std::vector<PropertyValue>& rTextEffectsProperties)
+ : ContextHandler2(rParent)
+ , mrTextEffectsProperties(rTextEffectsProperties)
+ , mpGrabBagStack(NULL)
+ , mnCurrentElement(aElementToken)
+{
+}
+
+TextEffectsContext::~TextEffectsContext()
+{
+}
+
+void TextEffectsContext::pushAttributeToGrabBag (const sal_Int32& aAttributeId, const OUString& rElementName, const AttributeList& rAttribs)
+{
+ if (!rAttribs.hasAttribute(aAttributeId))
+ return;
+ OUString aString = rAttribs.getString(aAttributeId).get();
+ mpGrabBagStack->addString(rElementName, aString);
+}
+
+void TextEffectsContext::processAttributes(const AttributeList& rAttribs)
+{
+ mpGrabBagStack->push(constAttributesSequenceName);
+ switch(mnCurrentElement)
+ {
+ case OOX_TOKEN(w14, glow):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, rad), "rad", rAttribs);
+ }
+ case OOX_TOKEN(w14, srgbClr):
+ case OOX_TOKEN(w14, schemeClr):
+ case OOX_TOKEN(w14, tint):
+ case OOX_TOKEN(w14, shade):
+ case OOX_TOKEN(w14, alpha):
+ case OOX_TOKEN(w14, hueMod):
+ case OOX_TOKEN(w14, sat):
+ case OOX_TOKEN(w14, satOff):
+ case OOX_TOKEN(w14, satMod):
+ case OOX_TOKEN(w14, lum):
+ case OOX_TOKEN(w14, lumOff):
+ case OOX_TOKEN(w14, lumMod):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, shadow):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, blurRad), "blurRad", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, dist), "dist", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, dir), "dir", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, sx), "sx", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, sy), "sy", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, kx), "kx", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, ky), "ky", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, algn), "algn", rAttribs);
+ }
+ case OOX_TOKEN(w14, reflection):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, blurRad), "blurRad", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, stA), "stA", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, stPos), "stPos", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, endA), "endA", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, endPos), "endPos", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, dist), "dist", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, dir), "dir", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, fadeDir), "fadeDir", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, sx), "sx", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, sy), "sy", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, kx), "kx", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, ky), "ky", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, algn), "algn", rAttribs);
+ }
+ case OOX_TOKEN(w14, textOutline):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, w), "w", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, cap), "cap", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, cmpd), "cmpd", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, algn), "algn", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, prstDash):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
+ }
+ case OOX_TOKEN(w14, gs):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, pos), "pos", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, lin):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, ang), "ang", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, scaled), "scaled", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, path):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, path), "path", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, fillToRect):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, l), "l", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, t), "t", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, r), "r", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, b), "b", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, miter):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, lim), "lim", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, camera):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, prst), "prst", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, lightRig):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, rig), "rig", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, dir), "dir", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, rot):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, lat), "lat", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, lon), "lon", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, rev), "rev", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, props3d):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, extrusionH), "extrusionH", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, contourW), "contourW", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, prstMaterial), "prstMaterial", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, bevelT):
+ case OOX_TOKEN(w14, bevelB):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, w), "w", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, h), "h", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, prst), "prst", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, ligatures):
+ case OOX_TOKEN(w14, numForm):
+ case OOX_TOKEN(w14, numSpacing):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, styleSet):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, id), "id", rAttribs);
+ pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
+ }
+ break;
+ case OOX_TOKEN(w14, cntxtAlts):
+ {
+ pushAttributeToGrabBag(OOX_TOKEN(w14, val), "val", rAttribs);
+ }
+ break;
+ default:
+ break;
+ }
+
+ mpGrabBagStack->pop();
+}
+
+void TextEffectsContext::onStartElement(const oox::AttributeList& rAttribs)
+{
+ OUString aElementName = lclGetNameForElementId(mnCurrentElement);
+ if(mpGrabBagStack.get() == NULL)
+ mpGrabBagStack.reset(new GrabBagStack(aElementName));
+ mpGrabBagStack->push(aElementName);
+ processAttributes(rAttribs);
+}
+
+void TextEffectsContext::onEndElement()
+{
+ mpGrabBagStack->pop();
+ OUString aCurrentElementName = mpGrabBagStack->getCurrentName();
+ OUString aPropertyName;
+
+ if (mpGrabBagStack->isStackEmpty())
+ {
+ if (aCurrentElementName == "CharGlowTextEffect" ||
+ aCurrentElementName == "CharShadowTextEffect" ||
+ aCurrentElementName == "CharReflectionTextEffect" ||
+ aCurrentElementName == "CharTextOutlineTextEffect" ||
+ aCurrentElementName == "CharTextFillTextEffect" ||
+ aCurrentElementName == "CharScene3DTextEffect" ||
+ aCurrentElementName == "CharProps3DTextEffect" ||
+ aCurrentElementName == "CharLigaturesTextEffect" ||
+ aCurrentElementName == "CharNumFormTextEffect" ||
+ aCurrentElementName == "CharNumSpacingTextEffect" ||
+ aCurrentElementName == "CharStylisticSetsTextEffect" ||
+ aCurrentElementName == "CharCntxtAltsTextEffect")
+ {
+ PropertyValue aValue = mpGrabBagStack->getRootProperty();
+ mrTextEffectsProperties.push_back(aValue);
+ }
+ }
+
+}
+
+ContextHandlerRef TextEffectsContext::onCreateContext(sal_Int32 aElementToken, const AttributeList& /*rAttribs*/)
+{
+ mnCurrentElement = aElementToken;
+ return this;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 7a41af2a5fdf..e6b824e648e1 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -71,6 +71,7 @@ CharFontPitchComplex
CharHeight
CharHeightAsian
CharHeightComplex
+CharInteropGrabBag
CharKerning
CharLocale
CharLocaleAsian