LibreOffice Module oox (master)  1
grabbagstack.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  */
10 
12 #include <com/sun/star/uno/Sequence.hxx>
13 #include <comphelper/sequence.hxx>
14 
15 namespace oox
16 {
17 
18 using namespace css::beans;
19 using namespace css::uno;
20 
21 GrabBagStack::GrabBagStack(const OUString& aElementName)
22 {
23  mCurrentElement.maElementName = aElementName;
24 }
25 
27 {}
28 
30 {
31  return mStack.empty();
32 }
33 
35 {
36  while(!mStack.empty())
37  pop();
38 
39  PropertyValue aProperty;
40  aProperty.Name = mCurrentElement.maElementName;
41  aProperty.Value <<= comphelper::containerToSequence(mCurrentElement.maPropertyList);
42 
43  return aProperty;
44 }
45 
46 void GrabBagStack::appendElement(const OUString& aName, const Any& aAny)
47 {
48  PropertyValue aValue;
49  aValue.Name = aName;
50  aValue.Value = aAny;
51  mCurrentElement.maPropertyList.push_back(aValue);
52 }
53 
54 void GrabBagStack::push(const OUString& aKey)
55 {
56  mStack.push(mCurrentElement);
57  mCurrentElement.maElementName = aKey;
58  mCurrentElement.maPropertyList.clear();
59 }
60 
62 {
63  OUString aName = mCurrentElement.maElementName;
64  Sequence<PropertyValue> aSequence(comphelper::containerToSequence(mCurrentElement.maPropertyList));
65  mCurrentElement = mStack.top();
66  mStack.pop();
67  appendElement(aName, makeAny(aSequence));
68 }
69 
70 void GrabBagStack::addInt32(const OUString& aElementName, sal_Int32 aIntValue)
71 {
72  appendElement(aElementName, makeAny(aIntValue));
73 }
74 
75 void GrabBagStack::addString(const OUString& aElementName, const OUString& aStringValue)
76 {
77  appendElement(aElementName, makeAny(aStringValue));
78 }
79 
80 } // namespace oox
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::beans::PropertyValue getRootProperty()
void addInt32(const OUString &aElementName, sal_Int32 aIntValue)
bool isStackEmpty() const
void addString(const OUString &aElementName, const OUString &aStringValue)
void appendElement(const OUString &aName, const css::uno::Any &aAny)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
OUString aName
void push(const OUString &aKey)
GrabBagStack(const OUString &aElementName)
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)