Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/oox/source/helper/grabbagstack.cxx
Line
Count
Source (jump to first uncovered line)
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
11
#include <oox/helper/grabbagstack.hxx>
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
648
{
23
648
    mCurrentElement.maElementName = aElementName;
24
648
}
25
26
GrabBagStack::~GrabBagStack()
27
648
{}
28
29
bool GrabBagStack::isStackEmpty() const
30
0
{
31
0
    return mStack.empty();
32
0
}
33
34
PropertyValue GrabBagStack::getRootProperty()
35
648
{
36
648
    while(!mStack.empty())
37
0
        pop();
38
39
648
    PropertyValue aProperty;
40
648
    aProperty.Name = mCurrentElement.maElementName;
41
648
    aProperty.Value <<= comphelper::containerToSequence(mCurrentElement.maPropertyList);
42
43
648
    return aProperty;
44
648
}
45
46
void GrabBagStack::appendElement(const OUString& aName, const Any& aAny)
47
9.07k
{
48
9.07k
    PropertyValue aValue;
49
9.07k
    aValue.Name = aName;
50
9.07k
    aValue.Value = aAny;
51
9.07k
    mCurrentElement.maPropertyList.push_back(aValue);
52
9.07k
}
53
54
void GrabBagStack::push(const OUString& aKey)
55
4.10k
{
56
4.10k
    mStack.push(mCurrentElement);
57
4.10k
    mCurrentElement.maElementName = aKey;
58
4.10k
    mCurrentElement.maPropertyList.clear();
59
4.10k
}
60
61
void GrabBagStack::pop()
62
4.10k
{
63
4.10k
    OUString aName = mCurrentElement.maElementName;
64
4.10k
    Sequence<PropertyValue> aSequence(comphelper::containerToSequence(mCurrentElement.maPropertyList));
65
4.10k
    mCurrentElement = mStack.top();
66
4.10k
    mStack.pop();
67
4.10k
    appendElement(aName, Any(aSequence));
68
4.10k
}
69
70
void GrabBagStack::addInt32(const OUString& aElementName, sal_Int32 aIntValue)
71
2.80k
{
72
2.80k
    appendElement(aElementName, Any(aIntValue));
73
2.80k
}
74
75
void GrabBagStack::addString(const OUString& aElementName, const OUString& aStringValue)
76
648
{
77
648
    appendElement(aElementName, Any(aStringValue));
78
648
}
79
80
} // namespace oox
81
82
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */