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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <i18nutil/unicode.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <swmodule.hxx>
30 #include <gloshdl.hxx>
31 #include <gloslst.hxx>
32 #include <workctrl.hxx>
33 #include <strings.hrc>
37 #include <cppuhelper/queryinterface.hxx>
38 #include <cppuhelper/supportsservice.hxx>
39 #include <vcl/event.hxx>
40 #include <vcl/menu.hxx>
41 #include <vcl/settings.hxx>
42 #include <rtl/ustring.hxx>
43 #include <swabstdlg.hxx>
44 #include <sfx2/zoomitem.hxx>
45 #include <vcl/svapp.hxx>
46 #include <vcl/weldutils.hxx>
47 #include <svx/dialmgr.hxx>
48 #include <svx/strings.hrc>
49 #include <bitmaps.hlst>
50 #include <toolkit/helper/vclunohelper.hxx>
51 #include <com/sun/star/frame/XFrame.hpp>
53 #include <sfx2/viewfrm.hxx>
56 #define NAVI_ENTRIES 21
58 using namespace ::com::sun::star
;
59 using namespace ::com::sun::star::uno
;
60 using namespace ::com::sun::star::beans
;
61 using namespace ::com::sun::star::frame
;
63 SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl
, SfxVoidItem
);
65 SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
69 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
71 rTbx
.SetItemBits( nId
, ToolBoxItemBits::DROPDOWN
| rTbx
.GetItemBits( nId
) );
74 SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl()
78 void SwTbxAutoTextCtrl::CreatePopupWindow()
80 SwView
* pView
= ::GetActiveView();
81 if(pView
&& !pView
->GetDocShell()->IsReadOnly() &&
82 !pView
->GetWrtShell().HasReadonlySel() )
84 Link
<Menu
*,bool> aLnk
= LINK(this, SwTbxAutoTextCtrl
, PopupHdl
);
86 ScopedVclPtrInstance
<PopupMenu
> pPopup
;
87 SwGlossaryList
* pGlossaryList
= ::GetGlossaryList();
88 const size_t nGroupCount
= pGlossaryList
->GetGroupCount();
89 for(size_t i
= 1; i
<= nGroupCount
; ++i
)
91 OUString sTitle
= pGlossaryList
->GetGroupTitle(i
- 1);
92 const sal_uInt16 nBlockCount
= pGlossaryList
->GetBlockCount(i
-1);
95 sal_uInt16 nIndex
= o3tl::narrowing
<sal_uInt16
>(100*i
);
96 // but insert without extension
97 pPopup
->InsertItem( i
, sTitle
);
98 VclPtrInstance
<PopupMenu
> pSub
;
99 pSub
->SetSelectHdl(aLnk
);
100 pPopup
->SetPopupMenu(i
, pSub
);
101 for(sal_uInt16 j
= 0; j
< nBlockCount
; j
++)
103 OUString
sLongName(pGlossaryList
->GetBlockLongName(i
- 1, j
));
104 OUString
sShortName(pGlossaryList
->GetBlockShortName(i
- 1, j
));
106 OUString sEntry
= sShortName
+ " - " + sLongName
;
107 pSub
->InsertItem(++nIndex
, sEntry
);
112 ToolBox
* pToolBox
= &GetToolBox();
113 ToolBoxItemId nId
= GetId();
114 pToolBox
->SetItemDown( nId
, true );
116 pPopup
->Execute( pToolBox
, pToolBox
->GetItemRect( nId
),
117 (pToolBox
->GetAlign() == WindowAlign::Top
|| pToolBox
->GetAlign() == WindowAlign::Bottom
) ?
118 PopupMenuFlags::ExecuteDown
: PopupMenuFlags::ExecuteRight
);
120 pToolBox
->SetItemDown( nId
, false );
122 GetToolBox().EndSelection();
125 void SwTbxAutoTextCtrl::StateChangedAtToolBoxControl( sal_uInt16
,
127 const SfxPoolItem
* pState
)
129 GetToolBox().EnableItem( GetId(), (GetItemState(pState
) != SfxItemState::DISABLED
) );
132 IMPL_STATIC_LINK(SwTbxAutoTextCtrl
, PopupHdl
, Menu
*, pMenu
, bool)
134 sal_uInt16 nId
= pMenu
->GetCurItemId();
136 sal_uInt16 nBlock
= nId
/ 100;
138 SwGlossaryList
* pGlossaryList
= ::GetGlossaryList();
139 OUString sGroup
= pGlossaryList
->GetGroupName(nBlock
- 1);
140 OUString sShortName
=
141 pGlossaryList
->GetBlockShortName(nBlock
- 1, nId
- (100 * nBlock
) - 1);
143 if (SwView
* pView
= GetActiveView())
145 SwGlossaryHdl
* pGlosHdl
= pView
->GetGlosHdl();
146 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
147 ::GlossarySetActGroup fnSetActGroup
= pFact
->SetGlossaryActGroupFunc();
149 (*fnSetActGroup
)( sGroup
);
150 pGlosHdl
->SetCurGroup(sGroup
, true);
151 pGlosHdl
->InsertGlossary(sShortName
);
158 // determine the order of the toolbox items
159 static sal_uInt16 aNavigationInsertIds
[ NAVI_ENTRIES
] =
178 NID_TABLE_FORMULA_ERROR
,
184 rtl::OUStringConstExpr
constexpr aNavigationImgIds
[ NAVI_ENTRIES
] =
199 RID_BMP_RIBBAR_POSTIT
,
201 RID_BMP_RIBBAR_ENTRY
,
202 RID_BMP_RIBBAR_FORMULA
,
203 RID_BMP_RIBBAR_ERROR
,
204 RID_BMP_RIBBAR_RECENCY
,
205 RID_BMP_RIBBAR_FIELD
,
206 RID_BMP_RIBBAR_FIELD_BYTYPE
209 const TranslateId aNavigationStrIds
[ NAVI_ENTRIES
] =
211 STR_CONTENT_TYPE_TABLE
,
212 STR_CONTENT_TYPE_FRAME
,
213 STR_CONTENT_TYPE_GRAPHIC
,
214 STR_CONTENT_TYPE_OLE
,
216 STR_CONTENT_TYPE_OUTLINE
,
218 STR_CONTENT_TYPE_DRAWOBJECT
,
220 STR_CONTENT_TYPE_REGION
,
221 STR_CONTENT_TYPE_BOOKMARK
,
223 STR_CONTENT_TYPE_FOOTNOTE
,
224 STR_CONTENT_TYPE_POSTIT
,
226 STR_CONTENT_TYPE_INDEX
,
228 ST_TABLE_FORMULA_ERROR
,
230 STR_CONTENT_TYPE_TEXTFIELD
,
234 // these are global strings
235 const TranslateId STR_IMGBTN_ARY
[] =
241 STR_IMGBTN_CTRL_DOWN
,
246 STR_IMGBTN_OUTL_DOWN
,
249 STR_IMGBTN_MARK_DOWN
,
250 STR_IMGBTN_POSTIT_DOWN
,
251 STR_IMGBTN_SRCH_REP_DOWN
,
252 STR_IMGBTN_INDEX_ENTRY_DOWN
,
253 STR_IMGBTN_TBLFML_DOWN
,
254 STR_IMGBTN_TBLFML_ERR_DOWN
,
255 STR_IMGBTN_RECENCY_DOWN
,
256 STR_IMGBTN_FIELD_DOWN
,
257 STR_IMGBTN_FIELD_BYTYPE_DOWN
,
271 STR_IMGBTN_POSTIT_UP
,
272 STR_IMGBTN_SRCH_REP_UP
,
273 STR_IMGBTN_INDEX_ENTRY_UP
,
274 STR_IMGBTN_TBLFML_UP
,
275 STR_IMGBTN_TBLFML_ERR_UP
,
276 STR_IMGBTN_RECENCY_UP
,
278 STR_IMGBTN_FIELD_BYTYPE_UP
,
281 static OUString
lcl_GetScrollToolTip(bool bNext
)
283 sal_uInt16 nResId
= SwView::GetMoveType();
284 OUString sToolTip
= SwResId(STR_IMGBTN_ARY
[(!bNext
? NID_COUNT
: 0) + nResId
- NID_START
]);
285 if (nResId
== NID_FIELD_BYTYPE
)
288 SwWrtShell
* pWrtSh
= GetActiveWrtShell();
291 SwField
* pCurField
= pWrtSh
->GetCurField(true);
293 sFieldType
= SwFieldType::GetTypeStr(pCurField
->GetTypeId());
295 if (!sFieldType
.isEmpty())
296 sToolTip
= sToolTip
.replaceFirst(u
"%FIELDTYPE", sFieldType
);
298 sToolTip
= SwResId(SW_STR_NONE
);
305 class SwZoomBox_Impl final
: public InterimItemWindow
307 std::unique_ptr
<weld::ComboBox
> m_xWidget
;
308 sal_uInt16 m_nSlotId
;
311 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
312 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
313 DECL_LINK(ActivateHdl
, weld::ComboBox
&, bool);
314 DECL_LINK(FocusOutHdl
, weld::Widget
&, void);
321 SwZoomBox_Impl(vcl::Window
* pParent
, sal_uInt16 nSlot
);
323 virtual void dispose() override
326 InterimItemWindow::dispose();
331 m_xWidget
->save_value();
334 void set_entry_text(const OUString
& rText
)
336 m_xWidget
->set_entry_text(rText
);
339 virtual ~SwZoomBox_Impl() override
347 SwZoomBox_Impl::SwZoomBox_Impl(vcl::Window
* pParent
, sal_uInt16 nSlot
)
348 : InterimItemWindow(pParent
, "modules/swriter/ui/zoombox.ui", "ZoomBox")
349 , m_xWidget(m_xBuilder
->weld_combo_box("zoom"))
353 InitControlBase(m_xWidget
.get());
355 m_xWidget
->set_help_id(HID_PVIEW_ZOOM_LB
);
356 m_xWidget
->set_entry_completion(false);
357 m_xWidget
->connect_changed(LINK(this, SwZoomBox_Impl
, SelectHdl
));
358 m_xWidget
->connect_key_press(LINK(this, SwZoomBox_Impl
, KeyInputHdl
));
359 m_xWidget
->connect_entry_activate(LINK(this, SwZoomBox_Impl
, ActivateHdl
));
360 m_xWidget
->connect_focus_out(LINK(this, SwZoomBox_Impl
, FocusOutHdl
));
362 const TranslateId aZoomValues
[] =
363 { RID_SVXSTR_ZOOM_25
, RID_SVXSTR_ZOOM_50
,
364 RID_SVXSTR_ZOOM_75
, RID_SVXSTR_ZOOM_100
,
365 RID_SVXSTR_ZOOM_150
, RID_SVXSTR_ZOOM_200
,
366 RID_SVXSTR_ZOOM_WHOLE_PAGE
, RID_SVXSTR_ZOOM_PAGE_WIDTH
,
367 RID_SVXSTR_ZOOM_OPTIMAL_VIEW
};
368 for(const TranslateId
& pZoomValue
: aZoomValues
)
370 OUString sEntry
= SvxResId(pZoomValue
);
371 m_xWidget
->append_text(sEntry
);
374 int nWidth
= m_xWidget
->get_pixel_size(SvxResId(RID_SVXSTR_ZOOM_200
)).Width();
375 m_xWidget
->set_entry_width_chars(std::ceil(nWidth
/ m_xWidget
->get_approximate_digit_width()));
377 SetSizePixel(m_xWidget
->get_preferred_size());
380 IMPL_LINK(SwZoomBox_Impl
, SelectHdl
, weld::ComboBox
&, rComboBox
, void)
382 if (rComboBox
.changed_by_direct_pick()) // only when picked from the list
386 IMPL_LINK_NOARG(SwZoomBox_Impl
, ActivateHdl
, weld::ComboBox
&, bool)
392 void SwZoomBox_Impl::Select()
394 if( FN_PREVIEW_ZOOM
== m_nSlotId
)
396 bool bNonNumeric
= true;
398 OUString sEntry
= m_xWidget
->get_active_text().replaceAll("%", "");
399 SvxZoomItem
aZoom(SvxZoomType::PERCENT
,100);
400 if(sEntry
== SvxResId( RID_SVXSTR_ZOOM_PAGE_WIDTH
) )
401 aZoom
.SetType(SvxZoomType::PAGEWIDTH
);
402 else if(sEntry
== SvxResId( RID_SVXSTR_ZOOM_OPTIMAL_VIEW
) )
403 aZoom
.SetType(SvxZoomType::OPTIMAL
);
404 else if(sEntry
== SvxResId( RID_SVXSTR_ZOOM_WHOLE_PAGE
) )
405 aZoom
.SetType(SvxZoomType::WHOLEPAGE
);
410 sal_uInt16 nZoom
= o3tl::narrowing
<sal_uInt16
>(sEntry
.toInt32());
415 aZoom
.SetValue(nZoom
);
420 // put old value back, in case its effectively the same
421 // as the picked option and no update to number comes
423 m_xWidget
->set_entry_text(m_xWidget
->get_saved_value());
426 if (SfxObjectShell
* pCurrentShell
= SfxObjectShell::Current())
428 pCurrentShell
->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM
,
429 SfxCallMode::ASYNCHRON
, { &aZoom
});
435 IMPL_LINK(SwZoomBox_Impl
, KeyInputHdl
, const KeyEvent
&, rKEvt
, bool)
437 bool bHandled
= false;
439 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
449 m_xWidget
->set_entry_text(m_xWidget
->get_saved_value());
455 return bHandled
|| ChildKeyInput(rKEvt
);
458 IMPL_LINK_NOARG(SwZoomBox_Impl
, FocusOutHdl
, weld::Widget
&, void)
460 if (!m_xWidget
->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus
461 m_xWidget
->set_entry_text(m_xWidget
->get_saved_value());
464 void SwZoomBox_Impl::ReleaseFocus()
471 SfxViewShell
* pCurSh
= SfxViewShell::Current();
475 vcl::Window
* pShellWnd
= pCurSh
->GetWindow();
478 pShellWnd
->GrabFocus();
482 SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl
, SfxUInt16Item
);
484 SwPreviewZoomControl::SwPreviewZoomControl(
488 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
492 SwPreviewZoomControl::~SwPreviewZoomControl()
496 void SwPreviewZoomControl::StateChangedAtToolBoxControl( sal_uInt16
/*nSID*/,
498 const SfxPoolItem
* pState
)
500 ToolBoxItemId nId
= GetId();
501 GetToolBox().EnableItem( nId
, (GetItemState(pState
) != SfxItemState::DISABLED
) );
502 SwZoomBox_Impl
* pBox
= static_cast<SwZoomBox_Impl
*>(GetToolBox().GetItemWindow( GetId() ));
503 if(SfxItemState::DEFAULT
<= eState
)
505 OUString
sZoom(unicode::formatPercent(static_cast<const SfxUInt16Item
*>(pState
)->GetValue(),
506 Application::GetSettings().GetUILanguageTag()));
507 pBox
->set_entry_text(sZoom
);
512 VclPtr
<InterimItemWindow
> SwPreviewZoomControl::CreateItemWindow( vcl::Window
*pParent
)
514 VclPtrInstance
<SwZoomBox_Impl
> pRet( pParent
, GetSlotId() );
520 class SwJumpToSpecificBox_Impl final
: public InterimItemWindow
522 std::unique_ptr
<weld::Entry
> m_xWidget
;
524 sal_uInt16 m_nSlotId
;
526 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
527 DECL_LINK(SelectHdl
, weld::Entry
&, bool);
529 SwJumpToSpecificBox_Impl(vcl::Window
* pParent
, sal_uInt16 nSlot
);
530 virtual void dispose() override
533 InterimItemWindow::dispose();
535 virtual ~SwJumpToSpecificBox_Impl() override
543 IMPL_LINK(SwJumpToSpecificBox_Impl
, KeyInputHdl
, const KeyEvent
&, rKEvt
, bool)
545 return ChildKeyInput(rKEvt
);
548 SwJumpToSpecificBox_Impl::SwJumpToSpecificBox_Impl(vcl::Window
* pParent
, sal_uInt16 nSlot
)
549 : InterimItemWindow(pParent
, "modules/swriter/ui/jumpposbox.ui", "JumpPosBox")
550 , m_xWidget(m_xBuilder
->weld_entry("jumppos"))
553 InitControlBase(m_xWidget
.get());
555 m_xWidget
->connect_key_press(LINK(this, SwJumpToSpecificBox_Impl
, KeyInputHdl
));
556 m_xWidget
->connect_activate(LINK(this, SwJumpToSpecificBox_Impl
, SelectHdl
));
558 SetSizePixel(m_xWidget
->get_preferred_size());
561 IMPL_LINK_NOARG(SwJumpToSpecificBox_Impl
, SelectHdl
, weld::Entry
&, bool)
563 OUString
sEntry(m_xWidget
->get_text());
564 SfxUInt16Item
aPageNum(m_nSlotId
);
565 aPageNum
.SetValue(o3tl::narrowing
<sal_uInt16
>(sEntry
.toInt32()));
566 if (SfxObjectShell
* pCurrentShell
= SfxObjectShell::Current())
568 pCurrentShell
->GetDispatcher()->ExecuteList(m_nSlotId
, SfxCallMode::ASYNCHRON
,
574 SFX_IMPL_TOOLBOX_CONTROL( SwJumpToSpecificPageControl
, SfxUInt16Item
);
576 SwJumpToSpecificPageControl::SwJumpToSpecificPageControl(
580 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
583 SwJumpToSpecificPageControl::~SwJumpToSpecificPageControl()
586 VclPtr
<InterimItemWindow
> SwJumpToSpecificPageControl::CreateItemWindow( vcl::Window
*pParent
)
588 VclPtrInstance
<SwJumpToSpecificBox_Impl
> pRet( pParent
, GetSlotId() );
592 NavElementBox_Base::NavElementBox_Base(std::unique_ptr
<weld::ComboBox
> xComboBox
,
593 uno::Reference
<frame::XFrame
> xFrame
)
594 : m_xComboBox(std::move(xComboBox
))
595 ,m_xFrame(std::move(xFrame
))
597 m_xComboBox
->set_size_request(150, -1);
599 m_xComboBox
->make_sorted();
600 m_xComboBox
->freeze();
601 for (sal_uInt16 i
= 0; i
< NID_COUNT
; i
++)
602 m_xComboBox
->append(OUString::number(aNavigationInsertIds
[i
]),
603 SwResId(aNavigationStrIds
[i
]), OUString(aNavigationImgIds
[i
]));
606 m_xComboBox
->connect_changed(LINK(this, NavElementBox_Base
, SelectHdl
));
607 m_xComboBox
->connect_key_press(LINK(this, NavElementBox_Base
, KeyInputHdl
));
610 NavElementBox_Impl::NavElementBox_Impl(vcl::Window
* pParent
,
611 const uno::Reference
<frame::XFrame
>& xFrame
)
612 : InterimItemWindow(pParent
, "modules/swriter/ui/combobox.ui", "ComboBox")
613 ,NavElementBox_Base(m_xBuilder
->weld_combo_box("combobox"), xFrame
)
615 SetSizePixel(m_xContainer
->get_preferred_size());
618 void NavElementBox_Base::ReleaseFocus_Impl()
620 if ( m_xFrame
.is() && m_xFrame
->getContainerWindow().is() )
621 m_xFrame
->getContainerWindow()->setFocus();
624 IMPL_STATIC_LINK(NavElementBox_Base
, SelectHdl
, weld::ComboBox
&, rComboBox
, void)
626 if (!rComboBox
.changed_by_direct_pick()) // only when picked from the list
628 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
631 SfxUInt32Item
aParam(FN_NAV_ELEMENT
, rComboBox
.get_active_id().toUInt32());
632 const SfxPoolItem
* aArgs
[2];
635 SfxDispatcher
* pDispatch
= pViewFrm
->GetBindings().GetDispatcher();
636 pDispatch
->Execute(FN_NAV_ELEMENT
, SfxCallMode::SYNCHRON
, aArgs
);
639 void NavElementBox_Base::UpdateBox()
641 sal_uInt16 nMoveType
= SwView::GetMoveType();
642 for (size_t i
= 0; i
< SAL_N_ELEMENTS(aNavigationInsertIds
); ++i
)
644 if (nMoveType
== aNavigationInsertIds
[i
])
646 m_xComboBox
->set_active_text(SwResId(aNavigationStrIds
[i
]));
652 IMPL_LINK(NavElementBox_Base
, KeyInputHdl
, const KeyEvent
&, rKEvt
, bool)
654 return DoKeyInput(rKEvt
);
657 bool NavElementBox_Base::DoKeyInput(const KeyEvent
& /*rKEvt*/)
662 bool NavElementBox_Impl::DoKeyInput(const KeyEvent
& rKEvt
)
664 if (KEY_ESCAPE
== rKEvt
.GetKeyCode().GetCode())
669 return ChildKeyInput(rKEvt
);
672 NavElementToolBoxControl::NavElementToolBoxControl( const uno::Reference
< uno::XComponentContext
>& rxContext
)
673 : NavElementToolBoxControl_Base( rxContext
,
674 uno::Reference
< frame::XFrame
>(),
681 sal_Bool SAL_CALL
NavElementToolBoxControl::supportsService( const OUString
& ServiceName
)
683 return cppu::supportsService( this, ServiceName
);
686 OUString SAL_CALL
NavElementToolBoxControl::getImplementationName()
688 return "lo.writer.NavElementToolBoxController";
691 uno::Sequence
< OUString
> SAL_CALL
NavElementToolBoxControl::getSupportedServiceNames()
693 return { "com.sun.star.frame.ToolbarController" };
697 void SAL_CALL
NavElementToolBoxControl::dispose()
699 svt::ToolboxController::dispose();
701 SolarMutexGuard aSolarMutexGuard
;
702 m_xVclBox
.disposeAndClear();
708 void SAL_CALL
NavElementToolBoxControl::statusChanged( const frame::FeatureStateEvent
& rEvent
)
713 SolarMutexGuard aSolarMutexGuard
;
714 if ( rEvent
.FeatureURL
.Path
!= "NavElement" )
717 if ( rEvent
.IsEnabled
)
719 m_pBox
->set_sensitive(true);
723 m_pBox
->set_sensitive(true);
725 if (SwView
* pView
= GetActiveView())
727 pView
->GetViewFrame().GetBindings().Invalidate(FN_SCROLL_NEXT
);
728 pView
->GetViewFrame().GetBindings().Invalidate(FN_SCROLL_PREV
);
732 // XToolbarController
733 void SAL_CALL
NavElementToolBoxControl::execute( sal_Int16
/*KeyModifier*/ )
737 void SAL_CALL
NavElementToolBoxControl::click()
741 void SAL_CALL
NavElementToolBoxControl::doubleClick()
745 uno::Reference
< awt::XWindow
> SAL_CALL
NavElementToolBoxControl::createPopupWindow()
747 return uno::Reference
< awt::XWindow
>();
750 uno::Reference
< awt::XWindow
> SAL_CALL
NavElementToolBoxControl::createItemWindow(
751 const uno::Reference
< awt::XWindow
>& xParent
)
753 uno::Reference
< awt::XWindow
> xItemWindow
;
757 SolarMutexGuard aSolarMutexGuard
;
759 std::unique_ptr
<weld::ComboBox
> xWidget(m_pBuilder
->weld_combo_box("NavElementWidget"));
761 xItemWindow
= css::uno::Reference
<css::awt::XWindow
>(new weld::TransportAsXWindow(xWidget
.get()));
763 m_xWeldBox
.reset(new NavElementBox_Base(std::move(xWidget
), m_xFrame
));
764 m_pBox
= m_xWeldBox
.get();
768 VclPtr
<vcl::Window
> pParent
= VCLUnoHelper::GetWindow( xParent
);
771 SolarMutexGuard aSolarMutexGuard
;
772 m_xVclBox
= VclPtr
<NavElementBox_Impl
>::Create( pParent
, m_xFrame
);
773 m_pBox
= m_xVclBox
.get();
774 xItemWindow
= VCLUnoHelper::GetInterface(m_xVclBox
);
781 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
782 lo_writer_NavElementToolBoxController_get_implementation(
783 css::uno::XComponentContext
*rxContext
,
784 css::uno::Sequence
<css::uno::Any
> const &)
786 return cppu::acquire( new NavElementToolBoxControl( rxContext
) );
791 typedef cppu::ImplInheritanceHelper
< ::svt::ToolboxController
, css::lang::XServiceInfo
> PrevNextScrollToolboxController_Base
;
792 class PrevNextScrollToolboxController
: public PrevNextScrollToolboxController_Base
795 enum Type
{ PREVIOUS
, NEXT
};
797 PrevNextScrollToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
, Type eType
);
800 virtual OUString SAL_CALL
getImplementationName() override
;
801 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
802 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
805 virtual void SAL_CALL
dispose() override
;
808 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) override
;
816 PrevNextScrollToolboxController::PrevNextScrollToolboxController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
, Type eType
)
817 : PrevNextScrollToolboxController_Base( rxContext
,
818 css::uno::Reference
< css::frame::XFrame
>(),
819 (eType
== PREVIOUS
) ? OUString( ".uno:ScrollToPrevious" ): OUString( ".uno:ScrollToNext" ) ),
822 addStatusListener(".uno:NavElement");
826 OUString SAL_CALL
PrevNextScrollToolboxController::getImplementationName()
828 return meType
== PrevNextScrollToolboxController::PREVIOUS
?
829 OUString( "lo.writer.PreviousScrollToolboxController" ) :
830 OUString( "lo.writer.NextScrollToolboxController" );
833 sal_Bool SAL_CALL
PrevNextScrollToolboxController::supportsService( const OUString
& ServiceName
)
835 return cppu::supportsService(this, ServiceName
);
838 css::uno::Sequence
< OUString
> SAL_CALL
PrevNextScrollToolboxController::getSupportedServiceNames()
840 return { "com.sun.star.frame.ToolbarController" };
844 void SAL_CALL
PrevNextScrollToolboxController::dispose()
846 SolarMutexGuard aSolarMutexGuard
;
848 svt::ToolboxController::dispose();
852 void SAL_CALL
PrevNextScrollToolboxController::statusChanged( const css::frame::FeatureStateEvent
& rEvent
)
854 if (rEvent
.FeatureURL
.Path
== "NavElement")
857 m_pToolbar
->set_item_tooltip_text(m_aCommandURL
, lcl_GetScrollToolTip(meType
!= PrevNextScrollToolboxController::PREVIOUS
));
860 ToolBox
* pToolBox
= nullptr;
862 if (getToolboxId(nId
, &pToolBox
))
863 pToolBox
->SetQuickHelpText(nId
, lcl_GetScrollToolTip(meType
!= PrevNextScrollToolboxController::PREVIOUS
));
866 else if (rEvent
.FeatureURL
.Path
== "ScrollToPrevious" || rEvent
.FeatureURL
.Path
== "ScrollToNext")
869 m_pToolbar
->set_item_sensitive(m_aCommandURL
, rEvent
.IsEnabled
);
872 ToolBox
* pToolBox
= nullptr;
874 if (getToolboxId(nId
, &pToolBox
))
875 pToolBox
->EnableItem(nId
, rEvent
.IsEnabled
);
880 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
881 lo_writer_PreviousScrollToolboxController_get_implementation(
882 css::uno::XComponentContext
*context
,
883 css::uno::Sequence
<css::uno::Any
> const &)
885 return cppu::acquire( new PrevNextScrollToolboxController( context
, PrevNextScrollToolboxController::PREVIOUS
) );
888 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
889 lo_writer_NextScrollToolboxController_get_implementation(
890 css::uno::XComponentContext
*context
,
891 css::uno::Sequence
<css::uno::Any
> const &)
893 return cppu::acquire( new PrevNextScrollToolboxController( context
, PrevNextScrollToolboxController::NEXT
) );
896 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */