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"
13 #include <ElementsDockingWindow.hxx>
15 ElementUIObject::ElementUIObject(const VclPtr
<SmElementsControl
>& xElementSelector
,
17 mxElementsSelector(xElementSelector
),
22 SmElement
* ElementUIObject::get_element()
24 sal_uInt32 nID
= maID
.toUInt32();
25 size_t n
= mxElementsSelector
->maElementList
.size();
29 return mxElementsSelector
->maElementList
[nID
].get();
32 StringMap
ElementUIObject::get_state()
37 SmElement
* pElement
= get_element();
39 aMap
["Text"] = pElement
->getText();
44 void ElementUIObject::execute(const OUString
& rAction
,
45 const StringMap
& /*rParameters*/)
47 if (rAction
== "SELECT")
49 SmElement
* pElement
= get_element();
51 mxElementsSelector
->maSelectHdlLink
.Call(*pElement
);
55 ElementSelectorUIObject::ElementSelectorUIObject(const VclPtr
<SmElementsControl
>& xElementSelector
):
56 WindowUIObject(xElementSelector
),
57 mxElementsSelector(xElementSelector
)
61 StringMap
ElementSelectorUIObject::get_state()
63 StringMap aMap
= WindowUIObject::get_state();
65 SmElement
* pElement
= mxElementsSelector
->mpCurrentElement
;
67 aMap
["CurrentEntry"] = pElement
->getText();
69 aMap
["CurrentSelection"] = OUString::fromUtf8(mxElementsSelector
->msCurrentSetId
);
74 std::unique_ptr
<UIObject
> ElementSelectorUIObject::get_child(const OUString
& rID
)
76 size_t nID
= rID
.toInt32();
77 size_t n
= mxElementsSelector
->maElementList
.size();
79 throw css::uno::RuntimeException("invalid id");
81 return std::unique_ptr
<UIObject
>(new ElementUIObject(mxElementsSelector
, rID
));
84 std::set
<OUString
> ElementSelectorUIObject::get_children() const
86 std::set
<OUString
> aChildren
;
88 size_t n
= mxElementsSelector
->maElementList
.size();
89 for (size_t i
= 0; i
< n
; ++i
)
91 aChildren
.insert(OUString::number(i
));
97 std::unique_ptr
<UIObject
> ElementSelectorUIObject::create(vcl::Window
* pWindow
)
99 SmElementsControl
* pElementsControl
= dynamic_cast<SmElementsControl
*>(pWindow
);
100 assert(pElementsControl
);
102 return std::unique_ptr
<UIObject
>(new ElementSelectorUIObject(pElementsControl
));
105 OUString
ElementSelectorUIObject::get_name() const
107 return OUString("SmElementSelector");
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */