summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-07 16:40:33 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-07 16:48:23 +0100
commit5797d7633419bb1775056d513e89d1fc0ce461e0 (patch)
treedbb5f47b493fae870a236c10a132e4e3f7eecbc6
parent25d154bbf94157f0bdf71a71964409857634c570 (diff)
ooxml: make GrabBagStack ready for reuse and move it to oox
Change-Id: Ia7d52a003138a275860d3462382e636747343488
-rw-r--r--include/oox/helper/grabbagstack.hxx56
-rw-r--r--oox/Library_oox.mk1
-rw-r--r--oox/source/helper/grabbagstack.cxx93
-rw-r--r--writerfilter/source/dmapper/TextEffectsHandler.cxx90
-rw-r--r--writerfilter/source/dmapper/TextEffectsHandler.hxx10
5 files changed, 157 insertions, 93 deletions
diff --git a/include/oox/helper/grabbagstack.hxx b/include/oox/helper/grabbagstack.hxx
new file mode 100644
index 000000000000..b438ac8dc66e
--- /dev/null
+++ b/include/oox/helper/grabbagstack.hxx
@@ -0,0 +1,56 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_OOX_HELPER_GRABBAGSTACK_HXX
+#define INCLUDED_OOX_HELPER_GRABBAGSTACK_HXX
+
+#include <oox/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <vector>
+#include <stack>
+
+namespace oox {
+
+struct GrabBagStackElement
+{
+ OUString maName;
+ std::vector<css::beans::PropertyValue> maPropertyList;
+};
+
+/// Tool that is useful for construction of a nested Sequence/PropertyValue hierarchy
+class OOX_DLLPUBLIC GrabBagStack
+{
+private:
+ std::stack<GrabBagStackElement> mStack;
+ GrabBagStackElement mCurrentElement;
+
+public:
+ GrabBagStack(OUString aName);
+
+ virtual ~GrabBagStack();
+
+ OUString getCurrentName();
+
+ css::beans::PropertyValue getRootProperty();
+
+ void appendElement(OUString aName, css::uno::Any aAny);
+ void push(OUString aKey);
+ void pop();
+ void addInt32(OUString aElementName, sal_Int32 aIntValue);
+ void addString(OUString aElementName, OUString aStringValue);
+};
+
+} // namespace oox
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index d17626750b49..cdda38a17929 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -217,6 +217,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
oox/source/helper/binarystreambase \
oox/source/helper/containerhelper \
oox/source/helper/graphichelper \
+ oox/source/helper/grabbagstack \
oox/source/helper/modelobjecthelper \
oox/source/helper/progressbar \
oox/source/helper/propertymap \
diff --git a/oox/source/helper/grabbagstack.cxx b/oox/source/helper/grabbagstack.cxx
new file mode 100644
index 000000000000..ee7ec7079ec0
--- /dev/null
+++ b/oox/source/helper/grabbagstack.cxx
@@ -0,0 +1,93 @@
+/* -*- 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/helper/grabbagstack.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace oox
+{
+
+using namespace css::beans;
+using namespace css::uno;
+
+GrabBagStack::GrabBagStack(OUString aName)
+{
+ mCurrentElement.maName = aName;
+}
+
+GrabBagStack::~GrabBagStack()
+{}
+
+OUString GrabBagStack::getCurrentName()
+{
+ return mCurrentElement.maName;
+}
+
+PropertyValue GrabBagStack::getRootProperty()
+{
+ while(!mStack.empty())
+ pop();
+
+ PropertyValue aProperty;
+ aProperty.Name = mCurrentElement.maName;
+
+ Sequence<PropertyValue> aSequence(mCurrentElement.maPropertyList.size());
+ PropertyValue* pSequence = aSequence.getArray();
+ std::vector<PropertyValue>::iterator i;
+ for (i = mCurrentElement.maPropertyList.begin(); i != mCurrentElement.maPropertyList.end(); ++i)
+ *pSequence++ = *i;
+
+ aProperty.Value = makeAny(aSequence);
+
+ return aProperty;
+}
+
+void GrabBagStack::appendElement(OUString aName, Any aAny)
+{
+ PropertyValue aValue;
+ aValue.Name = aName;
+ aValue.Value = aAny;
+ mCurrentElement.maPropertyList.push_back(aValue);
+}
+
+void GrabBagStack::push(OUString aKey)
+{
+ mStack.push(mCurrentElement);
+ mCurrentElement.maName = aKey;
+ mCurrentElement.maPropertyList.clear();
+}
+
+void GrabBagStack::pop()
+{
+ OUString aName = mCurrentElement.maName;
+ Sequence<PropertyValue> aSequence(mCurrentElement.maPropertyList.size());
+ PropertyValue* pSequence = aSequence.getArray();
+ std::vector<PropertyValue>::iterator i;
+ for (i = mCurrentElement.maPropertyList.begin(); i != mCurrentElement.maPropertyList.end(); ++i)
+ *pSequence++ = *i;
+
+ mCurrentElement = mStack.top();
+ mStack.pop();
+ appendElement(aName, makeAny(aSequence));
+}
+
+void GrabBagStack::addInt32(OUString aElementName, sal_Int32 aIntValue)
+{
+ appendElement(aElementName, makeAny(aIntValue));
+}
+
+void GrabBagStack::addString(OUString aElementName, OUString aStringValue)
+{
+ appendElement(aElementName, makeAny(aStringValue));
+}
+
+} // namespace oox
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/TextEffectsHandler.cxx b/writerfilter/source/dmapper/TextEffectsHandler.cxx
index 2d4c32b936b6..ef8efc8b4b94 100644
--- a/writerfilter/source/dmapper/TextEffectsHandler.cxx
+++ b/writerfilter/source/dmapper/TextEffectsHandler.cxx
@@ -9,107 +9,21 @@
*/
#include <TextEffectsHandler.hxx>
+
#include <rtl/ustrbuf.hxx>
#include <comphelper/string.hxx>
#include <ooxml/resourceids.hxx>
#include "dmapperLoggers.hxx"
-#include <map>
-#include <stack>
-#include <vector>
namespace writerfilter {
namespace dmapper
{
using namespace std;
+using namespace oox;
using namespace css::uno;
using namespace css::beans;
-struct GrabBagStackElement
-{
- OUString maName;
- std::vector<beans::PropertyValue> maPropertyList;
-};
-
-/// Tool that is useful for construction of a nested Sequence/PropertyValue hierarchy
-class GrabBagStack
-{
-public:
- GrabBagStack(OUString aName)
- {
- mCurrentElement.maName = aName;
- }
-
- virtual ~GrabBagStack()
- {}
-
- std::stack<GrabBagStackElement> mStack;
- GrabBagStackElement mCurrentElement;
-
- OUString getCurrentName()
- {
- return mCurrentElement.maName;
- }
-
- PropertyValue getRootProperty()
- {
- while(!mStack.empty())
- pop();
-
- PropertyValue aProperty;
- aProperty.Name = mCurrentElement.maName;
-
- Sequence<PropertyValue> aSequence(mCurrentElement.maPropertyList.size());
- PropertyValue* pSequence = aSequence.getArray();
- std::vector<PropertyValue>::iterator i;
- for (i = mCurrentElement.maPropertyList.begin(); i != mCurrentElement.maPropertyList.end(); ++i)
- *pSequence++ = *i;
-
- aProperty.Value = makeAny(aSequence);
-
- return aProperty;
- }
-
- void appendElement(OUString aName, Any aAny)
- {
- PropertyValue aValue;
- aValue.Name = aName;
- aValue.Value = aAny;
- mCurrentElement.maPropertyList.push_back(aValue);
- }
-
- void push(OUString aKey)
- {
- mStack.push(mCurrentElement);
- mCurrentElement.maName = aKey;
- mCurrentElement.maPropertyList.clear();
- }
-
- void pop()
- {
- OUString aName = mCurrentElement.maName;
- Sequence<PropertyValue> aSequence(mCurrentElement.maPropertyList.size());
- PropertyValue* pSequence = aSequence.getArray();
- std::vector<PropertyValue>::iterator i;
- for (i = mCurrentElement.maPropertyList.begin(); i != mCurrentElement.maPropertyList.end(); ++i)
- *pSequence++ = *i;
-
- mCurrentElement = mStack.top();
- mStack.pop();
- appendElement(aName, makeAny(aSequence));
- }
-
- void addInt32(OUString aElementName, sal_Int32 aIntValue)
- {
- appendElement(aElementName, makeAny(aIntValue));
- }
-
- void addString(OUString aElementName, OUString aStringValue)
- {
- appendElement(aElementName, makeAny(aStringValue));
- }
-};
-
namespace
{
diff --git a/writerfilter/source/dmapper/TextEffectsHandler.hxx b/writerfilter/source/dmapper/TextEffectsHandler.hxx
index 14063598683d..4d402b4562a0 100644
--- a/writerfilter/source/dmapper/TextEffectsHandler.hxx
+++ b/writerfilter/source/dmapper/TextEffectsHandler.hxx
@@ -20,6 +20,8 @@
#include <PropertyIds.hxx>
+#include <oox/helper/grabbagstack.hxx>
+
#include <boost/scoped_ptr.hpp>
#include <boost/optional.hpp>
@@ -27,15 +29,13 @@ namespace writerfilter {
namespace dmapper
{
-class GrabBagStack;
-
/// Class to process all text effects like glow, textOutline, ...
class TextEffectsHandler : public LoggedProperties
{
private:
- boost::optional<PropertyIds> maPropertyId;
- OUString maElementName;
- boost::scoped_ptr<GrabBagStack> mpGrabBagStack;
+ boost::optional<PropertyIds> maPropertyId;
+ OUString maElementName;
+ boost::scoped_ptr<oox::GrabBagStack> mpGrabBagStack;
void convertElementIdToPropertyId(sal_Int32 aElementId);