LibreOffice Module sw (master) 1
workctrl.cxx
Go to the documentation of this file.
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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
22#include <i18nutil/unicode.hxx>
23#include <sfx2/dispatch.hxx>
24#include <sfx2/bindings.hxx>
25#include <swmodule.hxx>
26#include <utility>
27#include <view.hxx>
28#include <initui.hxx>
29#include <docsh.hxx>
30#include <gloshdl.hxx>
31#include <gloslst.hxx>
32#include <workctrl.hxx>
33#include <strings.hrc>
34#include <cmdid.h>
35#include <helpids.h>
36#include <wrtsh.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>
51#include <com/sun/star/frame/XFrame.hpp>
52
53#include <sfx2/viewfrm.hxx>
54
55// Size check
56#define NAVI_ENTRIES 21
57
58using namespace ::com::sun::star;
59using namespace ::com::sun::star::uno;
60using namespace ::com::sun::star::beans;
61using namespace ::com::sun::star::frame;
62
64
66 sal_uInt16 nSlotId,
67 ToolBoxItemId nId,
68 ToolBox& rTbx ) :
69 SfxToolBoxControl( nSlotId, nId, rTbx )
70{
71 rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
72}
73
75{
76}
77
79{
80 SwView* pView = ::GetActiveView();
81 if(pView && !pView->GetDocShell()->IsReadOnly() &&
82 !pView->GetWrtShell().HasReadonlySel() )
83 {
84 Link<Menu*,bool> aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl);
85
88 const size_t nGroupCount = pGlossaryList->GetGroupCount();
89 for(size_t i = 1; i <= nGroupCount; ++i)
90 {
91 OUString sTitle = pGlossaryList->GetGroupTitle(i - 1);
92 const sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1);
93 if(nBlockCount)
94 {
95 sal_uInt16 nIndex = o3tl::narrowing<sal_uInt16>(100*i);
96 // but insert without extension
97 pPopup->InsertItem( i, sTitle);
99 pSub->SetSelectHdl(aLnk);
100 pPopup->SetPopupMenu(i, pSub);
101 for(sal_uInt16 j = 0; j < nBlockCount; j++)
102 {
103 OUString sLongName(pGlossaryList->GetBlockLongName(i - 1, j));
104 OUString sShortName(pGlossaryList->GetBlockShortName(i - 1, j));
105
106 OUString sEntry = sShortName + " - " + sLongName;
107 pSub->InsertItem(++nIndex, sEntry);
108 }
109 }
110 }
111
112 ToolBox* pToolBox = &GetToolBox();
114 pToolBox->SetItemDown( nId, true );
115
116 pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ),
117 (pToolBox->GetAlign() == WindowAlign::Top || pToolBox->GetAlign() == WindowAlign::Bottom) ?
118 PopupMenuFlags::ExecuteDown : PopupMenuFlags::ExecuteRight );
119
120 pToolBox->SetItemDown( nId, false );
121 }
123}
124
127 const SfxPoolItem* pState )
128{
129 GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SfxItemState::DISABLED) );
130}
131
132IMPL_STATIC_LINK(SwTbxAutoTextCtrl, PopupHdl, Menu*, pMenu, bool)
133{
134 sal_uInt16 nId = pMenu->GetCurItemId();
135
136 sal_uInt16 nBlock = nId / 100;
137
139 OUString sGroup = pGlossaryList->GetGroupName(nBlock - 1);
140 OUString sShortName =
141 pGlossaryList->GetBlockShortName(nBlock - 1, nId - (100 * nBlock) - 1);
142
143 if (SwView* pView = GetActiveView())
144 {
145 SwGlossaryHdl* pGlosHdl = pView->GetGlosHdl();
147 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
148 if ( fnSetActGroup )
149 (*fnSetActGroup)( sGroup );
150 pGlosHdl->SetCurGroup(sGroup, true);
151 pGlosHdl->InsertGlossary(sShortName);
152 }
153
154 return false;
155}
156
157// Navigation-Popup
158// determine the order of the toolbox items
159static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] =
160{
161 NID_TBL,
162 NID_FRM,
163 NID_GRF,
164 NID_OLE,
165 NID_PGE,
166 NID_OUTL,
167 NID_MARK,
168 NID_DRW,
169 NID_CTRL,
170 NID_REG,
171 NID_BKM,
172 NID_SEL,
173 NID_FTN,
180 NID_FIELD,
182};
183
184rtl::OUStringConstExpr constexpr aNavigationImgIds[ NAVI_ENTRIES ] =
185{
186 RID_BMP_RIBBAR_TBL,
187 RID_BMP_RIBBAR_FRM,
188 RID_BMP_RIBBAR_GRF,
189 RID_BMP_RIBBAR_OLE,
190 RID_BMP_RIBBAR_PGE,
191 RID_BMP_RIBBAR_OUTL,
192 RID_BMP_RIBBAR_MARK,
193 RID_BMP_RIBBAR_DRW,
194 RID_BMP_RIBBAR_CTRL,
195 RID_BMP_RIBBAR_REG,
196 RID_BMP_RIBBAR_BKM,
197 RID_BMP_RIBBAR_SEL,
198 RID_BMP_RIBBAR_FTN,
199 RID_BMP_RIBBAR_POSTIT,
200 RID_BMP_RIBBAR_REP,
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
207};
208
210{
211 STR_CONTENT_TYPE_TABLE,
212 STR_CONTENT_TYPE_FRAME,
213 STR_CONTENT_TYPE_GRAPHIC,
214 STR_CONTENT_TYPE_OLE,
215 ST_PGE,
216 STR_CONTENT_TYPE_OUTLINE,
217 ST_MARK,
218 STR_CONTENT_TYPE_DRAWOBJECT,
219 ST_CTRL,
220 STR_CONTENT_TYPE_REGION,
221 STR_CONTENT_TYPE_BOOKMARK,
222 ST_SEL,
223 STR_CONTENT_TYPE_FOOTNOTE,
224 STR_CONTENT_TYPE_POSTIT,
225 ST_SRCH_REP,
226 STR_CONTENT_TYPE_INDEX,
227 ST_TABLE_FORMULA,
228 ST_TABLE_FORMULA_ERROR,
229 ST_RECENCY,
230 STR_CONTENT_TYPE_TEXTFIELD,
231 ST_FIELD_BYTYPE
232};
233
234// these are global strings
236{
237 STR_IMGBTN_TBL_DOWN,
238 STR_IMGBTN_FRM_DOWN,
239 STR_IMGBTN_PGE_DOWN,
240 STR_IMGBTN_DRW_DOWN,
241 STR_IMGBTN_CTRL_DOWN,
242 STR_IMGBTN_REG_DOWN,
243 STR_IMGBTN_BKM_DOWN,
244 STR_IMGBTN_GRF_DOWN,
245 STR_IMGBTN_OLE_DOWN,
246 STR_IMGBTN_OUTL_DOWN,
247 STR_IMGBTN_SEL_DOWN,
248 STR_IMGBTN_FTN_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,
258 STR_IMGBTN_TBL_UP,
259 STR_IMGBTN_FRM_UP,
260 STR_IMGBTN_PGE_UP,
261 STR_IMGBTN_DRW_UP,
262 STR_IMGBTN_CTRL_UP,
263 STR_IMGBTN_REG_UP,
264 STR_IMGBTN_BKM_UP,
265 STR_IMGBTN_GRF_UP,
266 STR_IMGBTN_OLE_UP,
267 STR_IMGBTN_OUTL_UP,
268 STR_IMGBTN_SEL_UP,
269 STR_IMGBTN_FTN_UP,
270 STR_IMGBTN_MARK_UP,
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,
277 STR_IMGBTN_FIELD_UP,
278 STR_IMGBTN_FIELD_BYTYPE_UP,
279};
280
281static OUString lcl_GetScrollToolTip(bool bNext)
282{
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)
286 {
287 OUString sFieldType;
288 SwWrtShell* pWrtSh = GetActiveWrtShell();
289 if (pWrtSh)
290 {
291 SwField* pCurField = pWrtSh->GetCurField(true);
292 if (pCurField)
293 sFieldType = SwFieldType::GetTypeStr(pCurField->GetTypeId());
294 }
295 if (!sFieldType.isEmpty())
296 sToolTip = sToolTip.replaceFirst(u"%FIELDTYPE", sFieldType);
297 else
298 sToolTip = SwResId(SW_STR_NONE);
299 }
300 return sToolTip;
301}
302
303namespace {
304
305class SwZoomBox_Impl final : public InterimItemWindow
306{
307 std::unique_ptr<weld::ComboBox> m_xWidget;
308 sal_uInt16 m_nSlotId;
309 bool m_bRelease;
310
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);
315
316 void Select();
317
318 void ReleaseFocus();
319
320public:
321 SwZoomBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot);
322
323 virtual void dispose() override
324 {
325 m_xWidget.reset();
327 }
328
329 void save_value()
330 {
331 m_xWidget->save_value();
332 }
333
334 void set_entry_text(const OUString& rText)
335 {
336 m_xWidget->set_entry_text(rText);
337 }
338
339 virtual ~SwZoomBox_Impl() override
340 {
341 disposeOnce();
342 }
343};
344
345}
346
347SwZoomBox_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"))
350 , m_nSlotId(nSlot)
351 , m_bRelease(true)
352{
353 InitControlBase(m_xWidget.get());
354
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));
361
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)
369 {
370 OUString sEntry = SvxResId(pZoomValue);
371 m_xWidget->append_text(sEntry);
372 }
373
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()));
376
377 SetSizePixel(m_xWidget->get_preferred_size());
378}
379
380IMPL_LINK(SwZoomBox_Impl, SelectHdl, weld::ComboBox&, rComboBox, void)
381{
382 if (rComboBox.changed_by_direct_pick()) // only when picked from the list
383 Select();
384}
385
386IMPL_LINK_NOARG(SwZoomBox_Impl, ActivateHdl, weld::ComboBox&, bool)
387{
388 Select();
389 return true;
390}
391
392void SwZoomBox_Impl::Select()
393{
394 if( FN_PREVIEW_ZOOM == m_nSlotId )
395 {
396 bool bNonNumeric = true;
397
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);
406 else
407 {
408 bNonNumeric = false;
409
410 sal_uInt16 nZoom = o3tl::narrowing<sal_uInt16>(sEntry.toInt32());
411 if(nZoom < MINZOOM)
412 nZoom = MINZOOM;
413 if(nZoom > MAXZOOM)
414 nZoom = MAXZOOM;
415 aZoom.SetValue(nZoom);
416 }
417
418 if (bNonNumeric)
419 {
420 // put old value back, in case its effectively the same
421 // as the picked option and no update to number comes
422 // back from writer
423 m_xWidget->set_entry_text(m_xWidget->get_saved_value());
424 }
425
426 if (SfxObjectShell* pCurrentShell = SfxObjectShell::Current())
427 {
428 pCurrentShell->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM,
429 SfxCallMode::ASYNCHRON, { &aZoom });
430 }
431 }
432 ReleaseFocus();
433}
434
435IMPL_LINK(SwZoomBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
436{
437 bool bHandled = false;
438
439 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
440
441 switch (nCode)
442 {
443 case KEY_TAB:
444 m_bRelease = false;
445 Select();
446 break;
447
448 case KEY_ESCAPE:
449 m_xWidget->set_entry_text(m_xWidget->get_saved_value());
450 ReleaseFocus();
451 bHandled = true;
452 break;
453 }
454
455 return bHandled || ChildKeyInput(rKEvt);
456}
457
458IMPL_LINK_NOARG(SwZoomBox_Impl, FocusOutHdl, weld::Widget&, void)
459{
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());
462}
463
464void SwZoomBox_Impl::ReleaseFocus()
465{
466 if ( !m_bRelease )
467 {
468 m_bRelease = true;
469 return;
470 }
472
473 if ( pCurSh )
474 {
475 vcl::Window* pShellWnd = pCurSh->GetWindow();
476
477 if ( pShellWnd )
478 pShellWnd->GrabFocus();
479 }
480}
481
483
485 sal_uInt16 nSlotId,
486 ToolBoxItemId nId,
487 ToolBox& rTbx) :
488 SfxToolBoxControl( nSlotId, nId, rTbx )
489{
490}
491
493{
494}
495
497 SfxItemState eState,
498 const SfxPoolItem* pState )
499{
501 GetToolBox().EnableItem( nId, (GetItemState(pState) != SfxItemState::DISABLED) );
502 SwZoomBox_Impl* pBox = static_cast<SwZoomBox_Impl*>(GetToolBox().GetItemWindow( GetId() ));
503 if(SfxItemState::DEFAULT <= eState)
504 {
505 OUString sZoom(unicode::formatPercent(static_cast<const SfxUInt16Item*>(pState)->GetValue(),
506 Application::GetSettings().GetUILanguageTag()));
507 pBox->set_entry_text(sZoom);
508 pBox->save_value();
509 }
510}
511
513{
514 VclPtrInstance<SwZoomBox_Impl> pRet( pParent, GetSlotId() );
515 return pRet.get();
516}
517
518namespace {
519
520class SwJumpToSpecificBox_Impl final : public InterimItemWindow
521{
522 std::unique_ptr<weld::Entry> m_xWidget;
523
524 sal_uInt16 m_nSlotId;
525
526 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
527 DECL_LINK(SelectHdl, weld::Entry&, bool);
528public:
529 SwJumpToSpecificBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot);
530 virtual void dispose() override
531 {
532 m_xWidget.reset();
534 }
535 virtual ~SwJumpToSpecificBox_Impl() override
536 {
537 disposeOnce();
538 }
539};
540
541}
542
543IMPL_LINK(SwJumpToSpecificBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
544{
545 return ChildKeyInput(rKEvt);
546}
547
548SwJumpToSpecificBox_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"))
551 , m_nSlotId(nSlot)
552{
553 InitControlBase(m_xWidget.get());
554
555 m_xWidget->connect_key_press(LINK(this, SwJumpToSpecificBox_Impl, KeyInputHdl));
556 m_xWidget->connect_activate(LINK(this, SwJumpToSpecificBox_Impl, SelectHdl));
557
558 SetSizePixel(m_xWidget->get_preferred_size());
559}
560
561IMPL_LINK_NOARG(SwJumpToSpecificBox_Impl, SelectHdl, weld::Entry&, bool)
562{
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())
567 {
568 pCurrentShell->GetDispatcher()->ExecuteList(m_nSlotId, SfxCallMode::ASYNCHRON,
569 { &aPageNum });
570 }
571 return true;
572}
573
575
577 sal_uInt16 nSlotId,
578 ToolBoxItemId nId,
579 ToolBox& rTbx) :
580 SfxToolBoxControl( nSlotId, nId, rTbx )
581{}
582
584{}
585
587{
589 return pRet.get();
590}
591
592NavElementBox_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))
596{
597 m_xComboBox->set_size_request(150, -1);
598
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]),
604 m_xComboBox->thaw();
605
606 m_xComboBox->connect_changed(LINK(this, NavElementBox_Base, SelectHdl));
607 m_xComboBox->connect_key_press(LINK(this, NavElementBox_Base, KeyInputHdl));
608}
609
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)
614{
615 SetSizePixel(m_xContainer->get_preferred_size());
616}
617
619{
620 if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
621 m_xFrame->getContainerWindow()->setFocus();
622}
623
625{
626 if (!rComboBox.changed_by_direct_pick()) // only when picked from the list
627 return;
629 if (!pViewFrm)
630 return;
631 SfxUInt32Item aParam(FN_NAV_ELEMENT, rComboBox.get_active_id().toUInt32());
632 const SfxPoolItem* aArgs[2];
633 aArgs[0] = &aParam;
634 aArgs[1] = nullptr;
635 SfxDispatcher* pDispatch = pViewFrm->GetBindings().GetDispatcher();
636 pDispatch->Execute(FN_NAV_ELEMENT, SfxCallMode::SYNCHRON, aArgs);
637}
638
640{
641 sal_uInt16 nMoveType = SwView::GetMoveType();
642 for (size_t i = 0; i < SAL_N_ELEMENTS(aNavigationInsertIds); ++i)
643 {
644 if (nMoveType == aNavigationInsertIds[i])
645 {
646 m_xComboBox->set_active_text(SwResId(aNavigationStrIds[i]));
647 break;
648 }
649 }
650}
651
652IMPL_LINK(NavElementBox_Base, KeyInputHdl, const KeyEvent&, rKEvt, bool)
653{
654 return DoKeyInput(rKEvt);
655}
656
658{
659 return false;
660}
661
663{
664 if (KEY_ESCAPE == rKEvt.GetKeyCode().GetCode())
665 {
667 return true;
668 }
669 return ChildKeyInput(rKEvt);
670}
671
672NavElementToolBoxControl::NavElementToolBoxControl( const uno::Reference< uno::XComponentContext >& rxContext )
674 uno::Reference< frame::XFrame >(),
675 ".uno:NavElement" ),
676 m_pBox( nullptr )
677{
678}
679
680// XServiceInfo
681sal_Bool SAL_CALL NavElementToolBoxControl::supportsService( const OUString& ServiceName )
682{
683 return cppu::supportsService( this, ServiceName );
684}
685
687{
688 return "lo.writer.NavElementToolBoxController";
689}
690
691uno::Sequence< OUString > SAL_CALL NavElementToolBoxControl::getSupportedServiceNames()
692{
693 return { "com.sun.star.frame.ToolbarController" };
694}
695
696// XComponent
698{
700
701 SolarMutexGuard aSolarMutexGuard;
703 m_xWeldBox.reset();
704 m_pBox = nullptr;
705}
706
707// XStatusListener
708void SAL_CALL NavElementToolBoxControl::statusChanged( const frame::FeatureStateEvent& rEvent )
709{
710 if (!m_pBox)
711 return;
712
713 SolarMutexGuard aSolarMutexGuard;
714 if ( rEvent.FeatureURL.Path != "NavElement" )
715 return;
716
717 if ( rEvent.IsEnabled )
718 {
719 m_pBox->set_sensitive(true);
720 m_pBox->UpdateBox();
721 }
722 else
723 m_pBox->set_sensitive(true);
724
725 if (SwView* pView = GetActiveView())
726 {
727 pView->GetViewFrame().GetBindings().Invalidate(FN_SCROLL_NEXT);
728 pView->GetViewFrame().GetBindings().Invalidate(FN_SCROLL_PREV);
729 }
730}
731
732// XToolbarController
733void SAL_CALL NavElementToolBoxControl::execute( sal_Int16 /*KeyModifier*/ )
734{
735}
736
738{
739}
740
742{
743}
744
745uno::Reference< awt::XWindow > SAL_CALL NavElementToolBoxControl::createPopupWindow()
746{
747 return uno::Reference< awt::XWindow >();
748}
749
750uno::Reference< awt::XWindow > SAL_CALL NavElementToolBoxControl::createItemWindow(
751 const uno::Reference< awt::XWindow >& xParent )
752{
753 uno::Reference< awt::XWindow > xItemWindow;
754
755 if (m_pBuilder)
756 {
757 SolarMutexGuard aSolarMutexGuard;
758
759 std::unique_ptr<weld::ComboBox> xWidget(m_pBuilder->weld_combo_box("NavElementWidget"));
760
761 xItemWindow = css::uno::Reference<css::awt::XWindow>(new weld::TransportAsXWindow(xWidget.get()));
762
763 m_xWeldBox.reset(new NavElementBox_Base(std::move(xWidget), m_xFrame));
764 m_pBox = m_xWeldBox.get();
765 }
766 else
767 {
768 VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent );
769 if ( pParent )
770 {
771 SolarMutexGuard aSolarMutexGuard;
773 m_pBox = m_xVclBox.get();
775 }
776 }
777
778 return xItemWindow;
779}
780
781extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
783 css::uno::XComponentContext *rxContext,
784 css::uno::Sequence<css::uno::Any> const &)
785{
786 return cppu::acquire( new NavElementToolBoxControl( rxContext ) );
787}
788
789namespace {
790
791typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> PrevNextScrollToolboxController_Base;
792class PrevNextScrollToolboxController : public PrevNextScrollToolboxController_Base
793{
794public:
795 enum Type { PREVIOUS, NEXT };
796
797 PrevNextScrollToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, Type eType );
798
799 // XServiceInfo
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;
803
804 // XComponent
805 virtual void SAL_CALL dispose() override;
806
807 // XStatusListener
808 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
809
810private:
811 Type meType;
812};
813
814}
815
816PrevNextScrollToolboxController::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" ) ),
820 meType( eType )
821{
822 addStatusListener(".uno:NavElement");
823}
824
825// XServiceInfo
826OUString SAL_CALL PrevNextScrollToolboxController::getImplementationName()
827{
828 return meType == PrevNextScrollToolboxController::PREVIOUS?
829 OUString( "lo.writer.PreviousScrollToolboxController" ) :
830 OUString( "lo.writer.NextScrollToolboxController" );
831}
832
833sal_Bool SAL_CALL PrevNextScrollToolboxController::supportsService( const OUString& ServiceName )
834{
835 return cppu::supportsService(this, ServiceName);
836}
837
838css::uno::Sequence< OUString > SAL_CALL PrevNextScrollToolboxController::getSupportedServiceNames()
839{
840 return { "com.sun.star.frame.ToolbarController" };
841}
842
843// XComponent
845{
846 SolarMutexGuard aSolarMutexGuard;
847
849}
850
851// XStatusListener
852void SAL_CALL PrevNextScrollToolboxController::statusChanged( const css::frame::FeatureStateEvent& rEvent )
853{
854 if (rEvent.FeatureURL.Path == "NavElement")
855 {
856 if (m_pToolbar)
857 m_pToolbar->set_item_tooltip_text(m_aCommandURL, lcl_GetScrollToolTip(meType != PrevNextScrollToolboxController::PREVIOUS));
858 else
859 {
860 ToolBox* pToolBox = nullptr;
862 if (getToolboxId(nId, &pToolBox))
863 pToolBox->SetQuickHelpText(nId, lcl_GetScrollToolTip(meType != PrevNextScrollToolboxController::PREVIOUS));
864 }
865 }
866 else if (rEvent.FeatureURL.Path == "ScrollToPrevious" || rEvent.FeatureURL.Path == "ScrollToNext")
867 {
868 if (m_pToolbar)
869 m_pToolbar->set_item_sensitive(m_aCommandURL, rEvent.IsEnabled);
870 else
871 {
872 ToolBox* pToolBox = nullptr;
874 if (getToolboxId(nId, &pToolBox))
875 pToolBox->EnableItem(nId, rEvent.IsEnabled);
876 }
877 }
878}
879
880extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
882 css::uno::XComponentContext *context,
883 css::uno::Sequence<css::uno::Any> const &)
884{
885 return cppu::acquire( new PrevNextScrollToolboxController( context, PrevNextScrollToolboxController::PREVIOUS ) );
886}
887
888extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
890 css::uno::XComponentContext *context,
891 css::uno::Sequence<css::uno::Any> const &)
892{
893 return cppu::acquire( new PrevNextScrollToolboxController( context, PrevNextScrollToolboxController::NEXT ) );
894}
895
896/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Image > m_xWidget
css::uno::Reference< css::lang::XComponent > m_xFrame
static const AllSettings & GetSettings()
void SetValue(sal_uInt16 nTheValue)
bool ChildKeyInput(const KeyEvent &rKEvt)
virtual void dispose() override
std::unique_ptr< weld::Container > m_xContainer
const vcl::KeyCode & GetKeyCode() const
std::unique_ptr< weld::ComboBox > m_xComboBox
Definition: workctrl.hxx:118
virtual bool DoKeyInput(const KeyEvent &)
Definition: workctrl.cxx:657
NavElementBox_Base(std::unique_ptr< weld::ComboBox > xComboBox, uno::Reference< frame::XFrame > xFrame)
Definition: workctrl.cxx:592
void set_sensitive(bool bSensitive)
Definition: workctrl.hxx:110
uno::Reference< frame::XFrame > m_xFrame
Definition: workctrl.hxx:119
void ReleaseFocus_Impl()
Definition: workctrl.cxx:618
NavElementBox_Impl(vcl::Window *pParent, const uno::Reference< frame::XFrame > &xFrame)
Definition: workctrl.cxx:610
virtual bool DoKeyInput(const KeyEvent &rKEvt) override
Definition: workctrl.cxx:662
VclPtr< NavElementBox_Impl > m_xVclBox
Definition: workctrl.hxx:184
NavElementBox_Base * m_pBox
Definition: workctrl.hxx:186
std::unique_ptr< NavElementBox_Base > m_xWeldBox
Definition: workctrl.hxx:185
NavElementToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rServiceManager)
Definition: workctrl.cxx:672
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: workctrl.cxx:681
virtual OUString SAL_CALL getImplementationName() override
Definition: workctrl.cxx:686
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(const css::uno::Reference< css::awt::XWindow > &Parent) override
Definition: workctrl.cxx:750
virtual void SAL_CALL click() override
Definition: workctrl.cxx:737
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: workctrl.cxx:691
virtual void SAL_CALL dispose() override
Definition: workctrl.cxx:697
virtual void SAL_CALL doubleClick() override
Definition: workctrl.cxx:741
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override
Definition: workctrl.cxx:745
virtual void SAL_CALL execute(sal_Int16 KeyModifier) override
Definition: workctrl.cxx:733
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &Event) override
Definition: workctrl.cxx:708
SfxDispatcher * GetDispatcher() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
bool IsReadOnly() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
ToolBoxItemId GetId() const
unsigned short GetSlotId() const
ToolBox & GetToolBox() const
static SfxItemState GetItemState(const SfxPoolItem *pState)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
vcl::Window * GetWindow() const
virtual GlossarySetActGroup SetGlossaryActGroupFunc()=0
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:1073
bool HasReadonlySel(bool isReplace=false) const
Definition: crsrsh.cxx:3662
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:124
Base class of all fields.
Definition: fldbas.hxx:296
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:270
bool InsertGlossary(const OUString &rName)
Definition: gloshdl.cxx:512
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
Definition: gloshdl.cxx:95
OUString GetBlockShortName(size_t nGroup, sal_uInt16 nBlock)
Definition: gloslst.cxx:223
OUString GetGroupName(size_t nPos)
Definition: gloslst.cxx:178
size_t GetGroupCount()
Definition: gloslst.cxx:171
OUString GetBlockLongName(size_t nGroup, sal_uInt16 nBlock)
Definition: gloslst.cxx:212
OUString GetGroupTitle(size_t nPos)
Definition: gloslst.cxx:190
sal_uInt16 GetBlockCount(size_t nGroup)
Definition: gloslst.cxx:201
virtual ~SwJumpToSpecificPageControl() override
Definition: workctrl.cxx:583
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: workctrl.cxx:586
SwJumpToSpecificPageControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: workctrl.cxx:576
SwPreviewZoomControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: workctrl.cxx:484
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: workctrl.cxx:512
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: workctrl.cxx:496
virtual ~SwPreviewZoomControl() override
Definition: workctrl.cxx:492
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: workctrl.cxx:125
virtual void CreatePopupWindow() override
Definition: workctrl.cxx:78
SwTbxAutoTextCtrl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: workctrl.cxx:65
virtual ~SwTbxAutoTextCtrl() override
Definition: workctrl.cxx:74
Definition: view.hxx:146
SwWrtShell & GetWrtShell() const
Definition: view.hxx:423
SwDocShell * GetDocShell()
Definition: view.cxx:1193
static sal_uInt16 GetMoveType()
Definition: viewmdi.cxx:734
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void EndSelection()
void SetQuickHelpText(ToolBoxItemId nItemId, const OUString &rText)
void SetItemDown(ToolBoxItemId nItemId, bool bDown)
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
tools::Rectangle GetItemRect(ToolBoxItemId nItemId)
vcl::Window * GetItemWindow(ToolBoxItemId nItemId) const
WindowAlign GetAlign() const
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
void disposeAndClear()
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void SAL_CALL dispose() override
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
sal_uInt16 GetCode() const
virtual void SetSizePixel(const Size &rNewSize)
void GrabFocus()
virtual std::unique_ptr< ComboBox > weld_combo_box(const OUString &id)=0
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:182
#define FN_NAV_ELEMENT
Definition: cmdid.h:188
#define FN_SCROLL_NEXT
Definition: cmdid.h:190
#define FN_SCROLL_PREV
Definition: cmdid.h:189
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
float u
DocumentType eType
constexpr OUStringLiteral HID_PVIEW_ZOOM_LB
Definition: helpids.h:104
static SwGlossaryList * pGlossaryList
Definition: initui.cxx:41
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:174
sal_Int32 nIndex
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_TAB
#define SAL_N_ELEMENTS(arr)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
Type
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference
int i
PREVIOUS
sal_Int16 nId
const char GetValue[]
SfxItemState
Reference< XFrame > xFrame
void(* GlossarySetActGroup)(const OUString &rNewGroup)
Definition: swabstdlg.hxx:89
SwView * GetActiveView()
Definition: swmodul1.cxx:115
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:108
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
NEXT
weld::Builder * m_pBuilder
unsigned char sal_Bool
#define MINZOOM
Definition: view.hxx:81
#define MAXZOOM
Definition: view.hxx:82
IMPL_STATIC_LINK(SwTbxAutoTextCtrl, PopupHdl, Menu *, pMenu, bool)
Definition: workctrl.cxx:132
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * lo_writer_NextScrollToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: workctrl.cxx:889
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * lo_writer_PreviousScrollToolboxController_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: workctrl.cxx:881
static sal_uInt16 aNavigationInsertIds[NAVI_ENTRIES]
Definition: workctrl.cxx:159
SFX_IMPL_TOOLBOX_CONTROL(SwTbxAutoTextCtrl, SfxVoidItem)
IMPL_LINK(SwZoomBox_Impl, SelectHdl, weld::ComboBox &, rComboBox, void)
Definition: workctrl.cxx:380
const TranslateId aNavigationStrIds[NAVI_ENTRIES]
Definition: workctrl.cxx:209
IMPL_LINK_NOARG(SwZoomBox_Impl, ActivateHdl, weld::ComboBox &, bool)
Definition: workctrl.cxx:386
const TranslateId STR_IMGBTN_ARY[]
Definition: workctrl.cxx:235
#define NAVI_ENTRIES
Definition: workctrl.cxx:56
rtl::OUStringConstExpr constexpr aNavigationImgIds[NAVI_ENTRIES]
Definition: workctrl.cxx:184
static OUString lcl_GetScrollToolTip(bool bNext)
Definition: workctrl.cxx:281
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * lo_writer_NavElementToolBoxController_get_implementation(css::uno::XComponentContext *rxContext, css::uno::Sequence< css::uno::Any > const &)
Definition: workctrl.cxx:782
#define NID_SEL
Definition: workctrl.hxx:45
#define NID_TABLE_FORMULA
Definition: workctrl.hxx:51
#define NID_MARK
Definition: workctrl.hxx:47
cppu::ImplInheritanceHelper< ::svt::ToolboxController, lang::XServiceInfo > NavElementToolBoxControl_Base
Definition: workctrl.hxx:156
#define NID_START
Definition: workctrl.hxx:34
#define NID_POSTIT
Definition: workctrl.hxx:48
#define NID_TABLE_FORMULA_ERROR
Definition: workctrl.hxx:52
#define NID_OUTL
Definition: workctrl.hxx:44
#define NID_BKM
Definition: workctrl.hxx:41
#define NID_COUNT
Definition: workctrl.hxx:56
#define NID_CTRL
Definition: workctrl.hxx:39
#define NID_FIELD_BYTYPE
Definition: workctrl.hxx:55
#define NID_TBL
Definition: workctrl.hxx:35
#define NID_GRF
Definition: workctrl.hxx:42
#define NID_REG
Definition: workctrl.hxx:40
#define NID_DRW
Definition: workctrl.hxx:38
#define NID_PGE
Definition: workctrl.hxx:37
#define NID_FTN
Definition: workctrl.hxx:46
#define NID_RECENCY
Definition: workctrl.hxx:53
#define NID_OLE
Definition: workctrl.hxx:43
#define NID_FRM
Definition: workctrl.hxx:36
#define NID_INDEX_ENTRY
Definition: workctrl.hxx:50
#define NID_FIELD
Definition: workctrl.hxx:54
#define NID_SRCH_REP
Definition: workctrl.hxx:49
RedlineType meType