1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "uiobject.hxx"
12 #include "ElementsDockingWindow.hxx"
14 ElementUIObject::ElementUIObject(VclPtr
<SmElementsControl
> xElementSelector
,
16 mxElementsSelector(xElementSelector
),
21 SmElement
* ElementUIObject::get_element()
23 sal_uInt32 nID
= maID
.toUInt32();
24 size_t n
= mxElementsSelector
->maElementList
.size();
28 return mxElementsSelector
->maElementList
[nID
].get();
31 StringMap
ElementUIObject::get_state()
36 SmElement
* pElement
= get_element();
38 aMap
["Text"] = pElement
->getText();
43 void ElementUIObject::execute(const OUString
& rAction
,
44 const StringMap
& /*rParameters*/)
46 if (rAction
== "SELECT")
48 SmElement
* pElement
= get_element();
50 mxElementsSelector
->maSelectHdlLink
.Call(*pElement
);
54 ElementSelectorUIObject::ElementSelectorUIObject(VclPtr
<SmElementsControl
> xElementSelector
):
55 WindowUIObject(xElementSelector
),
56 mxElementsSelector(xElementSelector
)
60 StringMap
ElementSelectorUIObject::get_state()
62 StringMap aMap
= WindowUIObject::get_state();
64 SmElement
* pElement
= mxElementsSelector
->mpCurrentElement
;
66 aMap
["CurrentEntry"] = pElement
->getText();
68 aMap
["CurrentSelection"] = OUString::number(mxElementsSelector
->maCurrentSetId
);
73 std::unique_ptr
<UIObject
> ElementSelectorUIObject::get_child(const OUString
& rID
)
75 size_t nID
= rID
.toInt32();
76 size_t n
= mxElementsSelector
->maElementList
.size();
78 throw css::uno::RuntimeException("invalid id");
80 return std::unique_ptr
<UIObject
>(new ElementUIObject(mxElementsSelector
, rID
));
83 std::set
<OUString
> ElementSelectorUIObject::get_children() const
85 std::set
<OUString
> aChildren
;
87 size_t n
= mxElementsSelector
->maElementList
.size();
88 for (size_t i
= 0; i
< n
; ++i
)
90 aChildren
.insert(OUString::number(i
));
96 std::unique_ptr
<UIObject
> ElementSelectorUIObject::create(vcl::Window
* pWindow
)
98 SmElementsControl
* pElementsControl
= dynamic_cast<SmElementsControl
*>(pWindow
);
99 assert(pElementsControl
);
101 return std::unique_ptr
<UIObject
>(new ElementSelectorUIObject(pElementsControl
));
104 OUString
ElementSelectorUIObject::get_name() const
106 return OUString("SmElementSelector");
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */