[pt-PT] Added 20 words to autocorrect
[LibreOffice.git] / starmath / source / uiobject.cxx
blob5d7519816e52315a01b775c69fc0600db32572d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <memory>
11 #include "uiobject.hxx"
12 #include <ElementsDockingWindow.hxx>
14 ElementUIObject::ElementUIObject(SmElementsControl* pElementSelector,
15 const OUString& rID):
16 mpElementsSelector(pElementSelector),
17 maID(rID)
21 SmElement* ElementUIObject::get_element()
23 sal_uInt32 nID = maID.toUInt32();
24 size_t n = mpElementsSelector->maElementList.size();
25 if (nID >= n)
26 return nullptr;
28 return mpElementsSelector->maElementList[nID].get();
31 StringMap ElementUIObject::get_state()
33 StringMap aMap;
34 aMap["ID"] = maID;
36 SmElement* pElement = get_element();
37 if (pElement)
38 aMap["Text"] = pElement->getText();
40 return aMap;
43 void ElementUIObject::execute(const OUString& rAction,
44 const StringMap& /*rParameters*/)
46 if (rAction == "SELECT")
48 SmElement* pElement = get_element();
49 if (pElement)
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();
65 if (pElement)
66 aMap["CurrentEntry"] = pElement->getText();
68 aMap["CurrentSelection"] = OUString::fromUtf8(mpElementsSelector->msCurrentSetId);
70 return aMap;
73 std::unique_ptr<UIObject> ElementSelectorUIObject::get_child(const OUString& rID)
75 size_t nID = rID.toInt32();
76 size_t n = mpElementsSelector->maElementList.size();
77 if (nID >= n)
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));
93 return aChildren;
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: */