Branch libreoffice-5-0-4
[LibreOffice.git] / oox / source / helper / grabbagstack.cxx
blob1505bb28686414f020b344d757c9ef08e0d246b1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include "oox/helper/grabbagstack.hxx"
12 #include <com/sun/star/uno/Sequence.hxx>
14 namespace oox
17 using namespace css::beans;
18 using namespace css::uno;
20 GrabBagStack::GrabBagStack(const OUString& aName)
22 mCurrentElement.maName = aName;
25 GrabBagStack::~GrabBagStack()
28 bool GrabBagStack::isStackEmpty()
30 return mStack.empty();
33 PropertyValue GrabBagStack::getRootProperty()
35 while(!mStack.empty())
36 pop();
38 PropertyValue aProperty;
39 aProperty.Name = mCurrentElement.maName;
41 Sequence<PropertyValue> aSequence(mCurrentElement.maPropertyList.size());
42 PropertyValue* pSequence = aSequence.getArray();
43 std::vector<PropertyValue>::iterator i;
44 for (i = mCurrentElement.maPropertyList.begin(); i != mCurrentElement.maPropertyList.end(); ++i)
45 *pSequence++ = *i;
47 aProperty.Value = makeAny(aSequence);
49 return aProperty;
52 void GrabBagStack::appendElement(const OUString& aName, Any aAny)
54 PropertyValue aValue;
55 aValue.Name = aName;
56 aValue.Value = aAny;
57 mCurrentElement.maPropertyList.push_back(aValue);
60 void GrabBagStack::push(const OUString& aKey)
62 mStack.push(mCurrentElement);
63 mCurrentElement.maName = aKey;
64 mCurrentElement.maPropertyList.clear();
67 void GrabBagStack::pop()
69 OUString aName = mCurrentElement.maName;
70 Sequence<PropertyValue> aSequence(mCurrentElement.maPropertyList.size());
71 PropertyValue* pSequence = aSequence.getArray();
72 std::vector<PropertyValue>::iterator i;
73 for (i = mCurrentElement.maPropertyList.begin(); i != mCurrentElement.maPropertyList.end(); ++i)
74 *pSequence++ = *i;
76 mCurrentElement = mStack.top();
77 mStack.pop();
78 appendElement(aName, makeAny(aSequence));
81 void GrabBagStack::addInt32(const OUString& aElementName, sal_Int32 aIntValue)
83 appendElement(aElementName, makeAny(aIntValue));
86 void GrabBagStack::addString(const OUString& aElementName, const OUString& aStringValue)
88 appendElement(aElementName, makeAny(aStringValue));
91 } // namespace oox
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */