summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-02-22 20:42:37 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-02-23 17:40:09 +0100
commitab2b20b66394c1d219caafc380488f5296c1c12c (patch)
tree0cd8abbd1b80e75b25fe7836151ed2c8f7c828d6 /writerfilter
parent7f93b4001f3b7266695b46b3a5c95d0b9c66af35 (diff)
ooxml: handle w14:shadow in import/export
Refactor the code to support an additional main element at processing of w14 elements for rPr. Change-Id: Iaf18a11bbda245b0b5b629e5f2e9f1f9682e6d41
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx27
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx2
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
-rw-r--r--writerfilter/source/dmapper/TextEffectsHandler.cxx104
-rw-r--r--writerfilter/source/dmapper/TextEffectsHandler.hxx19
5 files changed, 118 insertions, 35 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 80f1ed8fc9d9..8e43ede9eb15 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2336,20 +2336,29 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
m_pImpl->m_nTableDepth--;
break;
case NS_ooxml::LN_glow_glow:
+ case NS_ooxml::LN_shadow_shadow:
+ case NS_ooxml::LN_reflection_reflection:
+ case NS_ooxml::LN_textOutline_textOutline:
+ case NS_ooxml::LN_textFill_textFill:
+ case NS_ooxml::LN_scene3d_scene3d:
+ case NS_ooxml::LN_props3d_props3d:
+ case NS_ooxml::LN_ligatures_ligatures:
+ case NS_ooxml::LN_numForm_numForm:
+ case NS_ooxml::LN_numSpacing_numSpacing:
+ case NS_ooxml::LN_stylisticSets_stylisticSets:
+ case NS_ooxml::LN_cntxtAlts_cntxtAlts:
{
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if( pProperties.get())
{
- TextEffectsHandlerPtr pTextEffectsHandlerPtr( new TextEffectsHandler );
- sal_Bool bEnableTempGrabBag = !pTextEffectsHandlerPtr->isInteropGrabBagEnabled();
- if( bEnableTempGrabBag )
- pTextEffectsHandlerPtr->enableInteropGrabBag( "glow" );
-
- pProperties->resolve(*pTextEffectsHandlerPtr);
+ TextEffectsHandlerPtr pTextEffectsHandlerPtr( new TextEffectsHandler(nSprmId) );
+ boost::optional<PropertyIds> aPropertyId = pTextEffectsHandlerPtr->getGrabBagPropertyId();
- rContext->Insert(PROP_CHAR_GLOW_TEXT_EFFECT, pTextEffectsHandlerPtr->getInteropGrabBag().Value, true, CHAR_GRAB_BAG);
- if(bEnableTempGrabBag)
- pTextEffectsHandlerPtr->disableInteropGrabBag();
+ if(aPropertyId)
+ {
+ pProperties->resolve(*pTextEffectsHandlerPtr);
+ rContext->Insert(*aPropertyId, uno::makeAny(pTextEffectsHandlerPtr->getInteropGrabBag()), true, CHAR_GRAB_BAG);
+ }
}
}
break;
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index ce007e230e0f..c3792cc89221 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -115,7 +115,6 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_CHAR_BOTTOM_BORDER_DISTANCE: sName = "CharBottomBorderDistance"; break;
case PROP_CHAR_SHADOW_FORMAT: sName = "CharShadowFormat"; break;
case PROP_CHAR_HIGHLIGHT: sName = "CharHighlight"; break;
-
case PROP_PARA_STYLE_NAME: sName = "ParaStyleName"; break;
case PROP_PARA_ADJUST: sName = "ParaAdjust"; break;
case PROP_PARA_VERT_ALIGNMENT: sName = "ParaVertAlignment"; break;
@@ -377,6 +376,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_TOC_PARAGRAPH_OUTLINE_LEVEL : sName = "TOCParagraphOutlineLevel"; break;
case PROP_CHAR_THEME_COLOR_TINT : sName = "CharThemeColorTint"; break;
case PROP_CHAR_GLOW_TEXT_EFFECT : sName = "CharGlowTextEffect"; break;
+ case PROP_CHAR_SHADOW_TEXT_EFFECT : sName = "CharShadowTextEffect"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index c8155b1be18d..18ba148e10c2 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -348,6 +348,7 @@ enum PropertyIds
,PROP_TOC_PARAGRAPH_OUTLINE_LEVEL
,PROP_CHAR_THEME_COLOR_TINT
,PROP_CHAR_GLOW_TEXT_EFFECT
+ ,PROP_CHAR_SHADOW_TEXT_EFFECT
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
diff --git a/writerfilter/source/dmapper/TextEffectsHandler.cxx b/writerfilter/source/dmapper/TextEffectsHandler.cxx
index 060a389ae82c..edb219ea6548 100644
--- a/writerfilter/source/dmapper/TextEffectsHandler.cxx
+++ b/writerfilter/source/dmapper/TextEffectsHandler.cxx
@@ -98,7 +98,7 @@ public:
}
};
-OUString TextEffectsHandler::getSchemeColorTypeString(sal_Int32 nType)
+OUString TextEffectsHandler::getSchemeColorValTypeString(sal_Int32 nType)
{
switch (nType)
{
@@ -118,17 +118,70 @@ OUString TextEffectsHandler::getSchemeColorTypeString(sal_Int32 nType)
return OUString();
}
+OUString TextEffectsHandler::getRectAlignmentString(sal_Int32 nType)
+{
+ switch (nType)
+ {
+ case NS_ooxml::LN_ST_RectAlignment_none: return OUString("none");
+ case NS_ooxml::LN_ST_RectAlignment_tl: return OUString("tl");
+ case NS_ooxml::LN_ST_RectAlignment_t: return OUString("t");
+ case NS_ooxml::LN_ST_RectAlignment_tr: return OUString("tr");
+ case NS_ooxml::LN_ST_RectAlignment_l: return OUString("l");
+ case NS_ooxml::LN_ST_RectAlignment_ctr: return OUString("ctr");
+ case NS_ooxml::LN_ST_RectAlignment_r: return OUString("r");
+ case NS_ooxml::LN_ST_RectAlignment_bl: return OUString("bl");
+ case NS_ooxml::LN_ST_RectAlignment_b: return OUString("b");
+ case NS_ooxml::LN_ST_RectAlignment_br: return OUString("br");
-TextEffectsHandler::TextEffectsHandler() :
+ default: break;
+ }
+ return OUString();
+}
+
+void TextEffectsHandler::convertElementIdToPropertyId(sal_Int32 aElementId)
+{
+ switch(aElementId)
+ {
+ case NS_ooxml::LN_glow_glow:
+ maPropertyId = PROP_CHAR_GLOW_TEXT_EFFECT;
+ maElementName = "glow";
+ break;
+ case NS_ooxml::LN_shadow_shadow:
+ maPropertyId = PROP_CHAR_SHADOW_TEXT_EFFECT;
+ maElementName = "shadow";
+ break;
+ case NS_ooxml::LN_reflection_reflection:
+ case NS_ooxml::LN_textOutline_textOutline:
+ case NS_ooxml::LN_textFill_textFill:
+ case NS_ooxml::LN_scene3d_scene3d:
+ case NS_ooxml::LN_props3d_props3d:
+ case NS_ooxml::LN_ligatures_ligatures:
+ case NS_ooxml::LN_numForm_numForm:
+ case NS_ooxml::LN_numSpacing_numSpacing:
+ case NS_ooxml::LN_stylisticSets_stylisticSets:
+ case NS_ooxml::LN_cntxtAlts_cntxtAlts:
+ default:
+ break;
+ }
+}
+
+TextEffectsHandler::TextEffectsHandler(sal_uInt32 aElementId) :
LoggedProperties(dmapper_logger, "TextEffectsHandler"),
mpGrabBagStack(NULL)
{
+ convertElementIdToPropertyId(aElementId);
+ mpGrabBagStack.reset(new GrabBagStack(maElementName));
}
TextEffectsHandler::~TextEffectsHandler()
{
}
+boost::optional<PropertyIds> TextEffectsHandler::getGrabBagPropertyId()
+{
+ return maPropertyId;
+}
+
void TextEffectsHandler::lcl_attribute(Id aName, Value& aValue)
{
@@ -147,7 +200,7 @@ void TextEffectsHandler::lcl_attribute(Id aName, Value& aValue)
mpGrabBagStack->appendElement("val", makeAny(sal_Int32(aValue.getInt())));
break;
case NS_ooxml::LN_CT_SchemeColor_val:
- mpGrabBagStack->appendElement("val", makeAny(getSchemeColorTypeString(sal_Int32(aValue.getInt()))));
+ mpGrabBagStack->appendElement("val", makeAny(getSchemeColorValTypeString(sal_Int32(aValue.getInt()))));
break;
case NS_ooxml::LN_CT_SRgbColor_val:
{
@@ -155,12 +208,39 @@ void TextEffectsHandler::lcl_attribute(Id aName, Value& aValue)
OUStringBuffer aStr;
comphelper::string::padToLength(aStr, 6 - aBuf.getLength(), '0');
aStr.append(aBuf.getStr());
- mpGrabBagStack->appendElement("val", makeAny(aStr.makeStringAndClear()));
+ mpGrabBagStack->appendElement("val", makeAny(aStr.makeStringAndClear().toAsciiUpperCase()));
}
break;
case NS_ooxml::LN_CT_Glow_rad:
mpGrabBagStack->appendElement("rad", makeAny(sal_Int32(aValue.getInt())));
break;
+ case NS_ooxml::LN_CT_Shadow_blurRad:
+ mpGrabBagStack->appendElement("blurRad", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_dist:
+ mpGrabBagStack->appendElement("dist", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_dir:
+ mpGrabBagStack->appendElement("dir", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_sx:
+ mpGrabBagStack->appendElement("sx", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_sy:
+ mpGrabBagStack->appendElement("sy", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_kx:
+ mpGrabBagStack->appendElement("kx", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_ky:
+ mpGrabBagStack->appendElement("ky", makeAny(sal_Int32(aValue.getInt())));
+ break;
+ case NS_ooxml::LN_CT_Shadow_algn:
+ {
+ uno::Any aAny = makeAny(getRectAlignmentString(sal_Int32(aValue.getInt())));
+ mpGrabBagStack->appendElement("algn", aAny);
+ }
+ break;
default:
break;
}
@@ -251,22 +331,6 @@ beans::PropertyValue TextEffectsHandler::getInteropGrabBag()
return aReturn;
}
-void TextEffectsHandler::enableInteropGrabBag(OUString aName)
-{
- mpGrabBagStack.reset(new GrabBagStack(aName));
-}
-
-void TextEffectsHandler::disableInteropGrabBag()
-{
- mpGrabBagStack.reset();
-}
-
-bool TextEffectsHandler::isInteropGrabBagEnabled()
-{
- return mpGrabBagStack.get() != NULL;
-}
-
-
}//namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/TextEffectsHandler.hxx b/writerfilter/source/dmapper/TextEffectsHandler.hxx
index f224c63fc9dc..a2d2ca99de3f 100644
--- a/writerfilter/source/dmapper/TextEffectsHandler.hxx
+++ b/writerfilter/source/dmapper/TextEffectsHandler.hxx
@@ -13,10 +13,15 @@
#include <WriterFilterDllApi.hxx>
#include <resourcemodel/LoggedResources.hxx>
+
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <i18nlangtag/languagetag.hxx>
+
+#include <PropertyIds.hxx>
+
#include <boost/scoped_ptr.hpp>
+#include <boost/optional.hpp>
namespace writerfilter {
namespace dmapper
@@ -28,22 +33,26 @@ class GrabBagStack;
class TextEffectsHandler : public LoggedProperties
{
private:
+ boost::optional<PropertyIds> maPropertyId;
+ OUString maElementName;
boost::scoped_ptr<GrabBagStack> mpGrabBagStack;
+ void convertElementIdToPropertyId(sal_Int32 aElementId);
+
// LoggedProperties
virtual void lcl_attribute(Id aName, Value& aValue);
virtual void lcl_sprm(Sprm& sprm);
public:
- TextEffectsHandler();
+ TextEffectsHandler(sal_uInt32 aElementId);
virtual ~TextEffectsHandler();
+ boost::optional<PropertyIds> getGrabBagPropertyId();
+
css::beans::PropertyValue getInteropGrabBag();
- void enableInteropGrabBag(OUString aName);
- void disableInteropGrabBag();
- bool isInteropGrabBagEnabled();
- static OUString getSchemeColorTypeString(sal_Int32 nType);
+ static OUString getSchemeColorValTypeString(sal_Int32 nType);
+ static OUString getRectAlignmentString(sal_Int32 nType);
};
typedef boost::shared_ptr<TextEffectsHandler> TextEffectsHandlerPtr;