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 <svx/charmap.hxx>
13 #include <svx/numvset.hxx>
14 #include <vcl/window.hxx>
16 SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr
<vcl::Window
>& rCharSetWin
)
17 : DrawingAreaUIObject(rCharSetWin
)
18 , mpCharSet(static_cast<SvxShowCharSet
*>(mpController
))
22 void SvxShowCharSetUIObject::execute(const OUString
& rAction
,
23 const StringMap
& rParameters
)
25 if (rAction
== "SELECT")
27 auto itIndex
= rParameters
.find(u
"INDEX"_ustr
);
28 if (itIndex
!= rParameters
.end())
30 OUString aIndexStr
= itIndex
->second
;
32 sal_Int32 nIndex
= aIndexStr
.toInt32();
33 mpCharSet
->OutputIndex(nIndex
);
37 auto itColumn
= rParameters
.find(u
"COLUMN"_ustr
);
38 auto itRow
= rParameters
.find(u
"ROW"_ustr
);
39 if (itColumn
!= rParameters
.end() && itRow
!= rParameters
.end())
41 OUString aColStr
= itColumn
->second
;
42 OUString aRowStr
= itRow
->second
;
44 sal_Int32 nColumn
= aColStr
.toInt32();
45 sal_Int32 nRow
= aRowStr
.toInt32();
47 sal_Int32 nIndex
= nColumn
* COLUMN_COUNT
+ nRow
;
48 mpCharSet
->OutputIndex(nIndex
);
53 WindowUIObject::execute(rAction
, rParameters
);
56 std::unique_ptr
<UIObject
> SvxShowCharSetUIObject::create(vcl::Window
* pWindow
)
58 return std::unique_ptr
<UIObject
>(new SvxShowCharSetUIObject(pWindow
));
61 OUString
SvxShowCharSetUIObject::get_name() const
63 return u
"SvxShowCharSetUIObject"_ustr
;
67 SvxNumValueSetUIObject::SvxNumValueSetUIObject(vcl::Window
* pNumValueSetWin
)
68 : DrawingAreaUIObject(pNumValueSetWin
)
69 , mpNumValueSet(static_cast<SvxNumValueSet
*>(mpController
))
73 void SvxNumValueSetUIObject::execute(const OUString
& rAction
,
74 const StringMap
& rParameters
)
76 if (rAction
== "CHOOSE")
78 auto itPos
= rParameters
.find(u
"POS"_ustr
);
79 if (itPos
!= rParameters
.end())
81 OUString aIndexStr
= itPos
->second
;
82 sal_Int32 nIndex
= aIndexStr
.toInt32();
83 mpNumValueSet
->SelectItem(nIndex
);
84 mpNumValueSet
->Select();
88 DrawingAreaUIObject::execute(rAction
, rParameters
);
91 std::unique_ptr
<UIObject
> SvxNumValueSetUIObject::create(vcl::Window
* pWindow
)
93 return std::unique_ptr
<UIObject
>(new SvxNumValueSetUIObject(pWindow
));
96 OUString
SvxNumValueSetUIObject::get_name() const
98 return u
"SvxNumValueSetUIObject"_ustr
;
101 StringMap
SvxNumValueSetUIObject::get_state()
103 StringMap aMap
= WindowUIObject::get_state();
104 aMap
[u
"SelectedItemId"_ustr
] = OUString::number( mpNumValueSet
->GetSelectedItemId() );
105 aMap
[u
"SelectedItemPos"_ustr
] = OUString::number( mpNumValueSet
->GetSelectItemPos() );
106 aMap
[u
"ItemsCount"_ustr
] = OUString::number(mpNumValueSet
->GetItemCount());
107 aMap
[u
"ItemText"_ustr
] = mpNumValueSet
->GetItemText(mpNumValueSet
->GetSelectedItemId());
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */