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/.
11 #include "uiobject.hxx"
12 #include <ElementsDockingWindow.hxx>
14 ElementUIObject::ElementUIObject(SmElementsControl
* pElementSelector
,
16 mpElementsSelector(pElementSelector
),
21 SmElement
* ElementUIObject::get_element()
23 sal_uInt32 nID
= maID
.toUInt32();
24 size_t n
= mpElementsSelector
->maElementList
.size();
28 return mpElementsSelector
->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 mpElementsSelector
->maSelectHdlLink
.Call(*pElement
);
54 ElementSelectorUIObject::ElementSelectorUIObject(vcl::Window
* pElementSelectorWindow
)
55 : DrawingAreaUIObject(pElementSelectorWindow
)
56 , mpElementsSelector(static_cast<SmElementsControl
*>(mpController
))
60 StringMap
ElementSelectorUIObject::get_state()
62 StringMap aMap
= DrawingAreaUIObject::get_state();
64 SmElement
* pElement
= mpElementsSelector
->current();
66 aMap
["CurrentEntry"] = pElement
->getText();
68 aMap
["CurrentSelection"] = OUString::fromUtf8(mpElementsSelector
->msCurrentSetId
);
73 std::unique_ptr
<UIObject
> ElementSelectorUIObject::get_child(const OUString
& rID
)
75 size_t nID
= rID
.toInt32();
76 size_t n
= mpElementsSelector
->maElementList
.size();
78 throw css::uno::RuntimeException("invalid id");
80 return std::unique_ptr
<UIObject
>(new ElementUIObject(mpElementsSelector
, rID
));
83 std::set
<OUString
> ElementSelectorUIObject::get_children() const
85 std::set
<OUString
> aChildren
;
87 size_t n
= mpElementsSelector
->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 return std::unique_ptr
<UIObject
>(new ElementSelectorUIObject(pWindow
));
101 OUString
ElementSelectorUIObject::get_name() const
103 return "SmElementSelector";
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */