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>
16 #include <sfx2/sidebar/Sidebar.hxx>
18 SwEditWinUIObject::SwEditWinUIObject(const VclPtr
<SwEditWin
>& xEditWin
):
19 WindowUIObject(xEditWin
),
26 SwWrtShell
& getWrtShell(VclPtr
<SwEditWin
> const & xEditWin
)
28 return xEditWin
->GetView().GetWrtShell();
33 StringMap
SwEditWinUIObject::get_state()
35 StringMap aMap
= WindowUIObject::get_state();
37 aMap
["SelectedText"] = mxEditWin
->GetView().GetSelectionText();
39 sal_uInt16 nPageNum
= 0;
40 sal_uInt16 nVirtPageNum
= 0;
41 SwWrtShell
& rWrtShell
= getWrtShell(mxEditWin
);
42 rWrtShell
.GetPageNum(nPageNum
, nVirtPageNum
);
43 aMap
["CurrentPage"] = OUString::number(nPageNum
);
44 rWrtShell
.GetPageNum(nPageNum
, nVirtPageNum
, false);
45 aMap
["TopVisiblePage"] = OUString::number(nPageNum
);
47 sal_uInt16 nPages
= rWrtShell
.GetPageCnt();
48 aMap
["Pages"] = OUString::number(nPages
);
50 aMap
["StartWord"] = OUString::boolean(rWrtShell
.IsStartWord());
51 aMap
["EndWord"] = OUString::boolean(rWrtShell
.IsEndWord());
52 aMap
["StartSentence"] = OUString::boolean(rWrtShell
.IsStartSentence());
53 aMap
["EndSentence"] = OUString::boolean(rWrtShell
.IsEndSentence());
54 aMap
["StartPara"] = OUString::boolean(rWrtShell
.IsSttPara());
55 aMap
["EndPara"] = OUString::boolean(rWrtShell
.IsEndPara());
56 aMap
["StartDoc"] = OUString::boolean(rWrtShell
.IsStartOfDoc());
57 aMap
["EndDoc"] = OUString::boolean(rWrtShell
.IsEndOfDoc());
62 void SwEditWinUIObject::execute(const OUString
& rAction
,
63 const StringMap
& rParameters
)
67 if (rParameters
.find("ZOOM") != rParameters
.end())
69 auto itr
= rParameters
.find("ZOOM");
70 OUString aVal
= itr
->second
;
71 sal_Int32 nVal
= aVal
.toInt32();
72 mxEditWin
->GetView().SetZoom(SvxZoomType::PERCENT
, nVal
);
75 else if (rAction
== "GOTO")
77 if (rParameters
.find("PAGE") != rParameters
.end())
79 auto itr
= rParameters
.find("PAGE");
80 OUString aVal
= itr
->second
;
81 sal_Int32 nVal
= aVal
.toInt32();
82 getWrtShell(mxEditWin
).GotoPage(nVal
, false);
85 else if (rAction
== "SELECT")
87 if (rParameters
.find("START_POS") != rParameters
.end())
89 auto itr
= rParameters
.find("START_POS");
90 OUString aStartPos
= itr
->second
;
91 sal_Int32 nStartPos
= aStartPos
.toInt32();
93 itr
= rParameters
.find("END_POS");
94 assert(itr
!= rParameters
.end());
95 OUString aEndPos
= itr
->second
;
96 sal_Int32 nEndPos
= aEndPos
.toInt32();
98 getWrtShell(mxEditWin
).SelectText(nStartPos
, nEndPos
);
101 else if (rAction
== "SIDEBAR")
103 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
104 DBG_ASSERT(pViewFrm
, "SwEditWinUIObject::execute: no viewframe");
105 pViewFrm
->ShowChildWindow(SID_SIDEBAR
);
107 if (rParameters
.find("PANEL") != rParameters
.end())
109 auto itr
= rParameters
.find("PANEL");
110 OUString aVal
= itr
->second
;
111 ::sfx2::sidebar::Sidebar::ShowPanel(aVal
, pViewFrm
->GetFrame().GetFrameInterface());
115 WindowUIObject::execute(rAction
, rParameters
);
118 OUString
SwEditWinUIObject::get_name() const
120 return OUString("SwEditWinUIObject");
123 std::unique_ptr
<UIObject
> SwEditWinUIObject::create(vcl::Window
* pWindow
)
125 SwEditWin
* pEditWin
= dynamic_cast<SwEditWin
*>(pWindow
);
127 return std::unique_ptr
<UIObject
>(new SwEditWinUIObject(pEditWin
));
130 SwNavigationPIUIObject::SwNavigationPIUIObject(const VclPtr
<SwNavigationPI
>& xSwNavigationPI
):
131 WindowUIObject(xSwNavigationPI
),
132 mxSwNavigationPI(xSwNavigationPI
)
136 StringMap
SwNavigationPIUIObject::get_state()
138 StringMap aMap
= WindowUIObject::get_state();
140 aMap
["selectioncount"] = OUString::number(mxSwNavigationPI
->m_aContentTree
->GetSelectionCount());
145 void SwNavigationPIUIObject::execute(const OUString
& rAction
,
146 const StringMap
& rParameters
)
148 if (rAction
== "ROOT")
150 mxSwNavigationPI
->m_aContentToolBox
->TriggerItem(mxSwNavigationPI
->m_aContentToolBox
->GetItemId("root"));
153 WindowUIObject::execute(rAction
, rParameters
);
156 std::unique_ptr
<UIObject
> SwNavigationPIUIObject::create(vcl::Window
* pWindow
)
158 SwNavigationPI
* pSwNavigationPI
= dynamic_cast<SwNavigationPI
*>(pWindow
);
159 assert(pSwNavigationPI
);
160 return std::unique_ptr
<UIObject
>(new SwNavigationPIUIObject(pSwNavigationPI
));
163 OUString
SwNavigationPIUIObject::get_name() const
165 return OUString("SwNavigationPIUIObject");
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */