/src/libreoffice/svx/source/uitest/uiobject.cxx
Line | Count | Source |
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 | | #include <memory> |
11 | | #include <uiobject.hxx> |
12 | | #include <svx/charmap.hxx> |
13 | | #include <svx/numvset.hxx> |
14 | | #include <vcl/window.hxx> |
15 | | |
16 | | SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr<vcl::Window>& rCharSetWin) |
17 | 0 | : DrawingAreaUIObject(rCharSetWin) |
18 | 0 | , mpCharSet(static_cast<SvxShowCharSet*>(mpController)) |
19 | 0 | { |
20 | 0 | } |
21 | | |
22 | | void SvxShowCharSetUIObject::execute(const OUString& rAction, |
23 | | const StringMap& rParameters) |
24 | 0 | { |
25 | 0 | if (rAction == "SELECT") |
26 | 0 | { |
27 | 0 | auto itIndex = rParameters.find(u"INDEX"_ustr); |
28 | 0 | if (itIndex != rParameters.end()) |
29 | 0 | { |
30 | 0 | OUString aIndexStr = itIndex->second; |
31 | |
|
32 | 0 | sal_Int32 nIndex = aIndexStr.toInt32(); |
33 | 0 | mpCharSet->OutputIndex(nIndex); |
34 | 0 | } |
35 | 0 | else |
36 | 0 | { |
37 | 0 | auto itColumn = rParameters.find(u"COLUMN"_ustr); |
38 | 0 | auto itRow = rParameters.find(u"ROW"_ustr); |
39 | 0 | if (itColumn != rParameters.end() && itRow != rParameters.end()) |
40 | 0 | { |
41 | 0 | OUString aColStr = itColumn->second; |
42 | 0 | OUString aRowStr = itRow->second; |
43 | |
|
44 | 0 | sal_Int32 nColumn = aColStr.toInt32(); |
45 | 0 | sal_Int32 nRow = aRowStr.toInt32(); |
46 | |
|
47 | 0 | sal_Int32 nIndex = nColumn * COLUMN_COUNT + nRow; |
48 | 0 | mpCharSet->OutputIndex(nIndex); |
49 | 0 | } |
50 | 0 | } |
51 | 0 | } |
52 | 0 | else |
53 | 0 | WindowUIObject::execute(rAction, rParameters); |
54 | 0 | } |
55 | | |
56 | | std::unique_ptr<UIObject> SvxShowCharSetUIObject::create(vcl::Window* pWindow) |
57 | 0 | { |
58 | 0 | return std::unique_ptr<UIObject>(new SvxShowCharSetUIObject(pWindow)); |
59 | 0 | } |
60 | | |
61 | | OUString SvxShowCharSetUIObject::get_name() const |
62 | 0 | { |
63 | 0 | return u"SvxShowCharSetUIObject"_ustr; |
64 | 0 | } |
65 | | |
66 | | |
67 | | SvxNumValueSetUIObject::SvxNumValueSetUIObject(vcl::Window* pNumValueSetWin) |
68 | 0 | : DrawingAreaUIObject(pNumValueSetWin) |
69 | 0 | , mpNumValueSet(static_cast<SvxNumValueSet*>(mpController)) |
70 | 0 | { |
71 | 0 | } |
72 | | |
73 | | void SvxNumValueSetUIObject::execute(const OUString& rAction, |
74 | | const StringMap& rParameters) |
75 | 0 | { |
76 | 0 | if (rAction == "CHOOSE") |
77 | 0 | { |
78 | 0 | auto itPos = rParameters.find(u"POS"_ustr); |
79 | 0 | if (itPos != rParameters.end()) |
80 | 0 | { |
81 | 0 | OUString aIndexStr = itPos->second; |
82 | 0 | sal_Int32 nIndex = aIndexStr.toInt32(); |
83 | 0 | mpNumValueSet->SelectItem(nIndex); |
84 | 0 | mpNumValueSet->Select(); |
85 | 0 | } |
86 | 0 | } |
87 | 0 | else |
88 | 0 | DrawingAreaUIObject::execute(rAction, rParameters); |
89 | 0 | } |
90 | | |
91 | | std::unique_ptr<UIObject> SvxNumValueSetUIObject::create(vcl::Window* pWindow) |
92 | 0 | { |
93 | 0 | return std::unique_ptr<UIObject>(new SvxNumValueSetUIObject(pWindow)); |
94 | 0 | } |
95 | | |
96 | | OUString SvxNumValueSetUIObject::get_name() const |
97 | 0 | { |
98 | 0 | return u"SvxNumValueSetUIObject"_ustr; |
99 | 0 | } |
100 | | |
101 | | StringMap SvxNumValueSetUIObject::get_state() |
102 | 0 | { |
103 | 0 | StringMap aMap = WindowUIObject::get_state(); |
104 | 0 | aMap[u"SelectedItemId"_ustr] = OUString::number( mpNumValueSet->GetSelectedItemId() ); |
105 | 0 | aMap[u"SelectedItemPos"_ustr] = OUString::number( mpNumValueSet->GetSelectItemPos() ); |
106 | 0 | aMap[u"ItemsCount"_ustr] = OUString::number(mpNumValueSet->GetItemCount()); |
107 | 0 | aMap[u"ItemText"_ustr] = mpNumValueSet->GetItemText(mpNumValueSet->GetSelectedItemId()); |
108 | 0 | return aMap; |
109 | 0 | } |
110 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |