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
145 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc();
146 if ( fnSetActGroup )
147 (*fnSetActGroup)( sGroup );
148 pGlosHdl->SetCurGroup(sGroup, true);
149 pGlosHdl->InsertGlossary(sShortName);
150
151 return false;
152}
153
154// Navigation-Popup
155// determine the order of the toolbox items
156static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] =
157{
158 NID_TBL,
159 NID_FRM,
160 NID_GRF,
161 NID_OLE,
162 NID_PGE,
163 NID_OUTL,
164 NID_MARK,
165 NID_DRW,
166 NID_CTRL,
167 NID_REG,
168 NID_BKM,
169 NID_SEL,
170 NID_FTN,
177 NID_FIELD,
179};
180
181rtl::OUStringConstExpr constexpr aNavigationImgIds[ NAVI_ENTRIES ] =
182{
183 RID_BMP_RIBBAR_TBL,
184 RID_BMP_RIBBAR_FRM,
185 RID_BMP_RIBBAR_GRF,
186 RID_BMP_RIBBAR_OLE,
187 RID_BMP_RIBBAR_PGE,
188 RID_BMP_RIBBAR_OUTL,
189 RID_BMP_RIBBAR_MARK,
190 RID_BMP_RIBBAR_DRW,
191 RID_BMP_RIBBAR_CTRL,
192 RID_BMP_RIBBAR_REG,
193 RID_BMP_RIBBAR_BKM,
194 RID_BMP_RIBBAR_SEL,
195 RID_BMP_RIBBAR_FTN,
196 RID_BMP_RIBBAR_POSTIT,
197 RID_BMP_RIBBAR_REP,
198 RID_BMP_RIBBAR_ENTRY,
199 RID_BMP_RIBBAR_FORMULA,
200 RID_BMP_RIBBAR_ERROR,
201 RID_BMP_RIBBAR_RECENCY,
202 RID_BMP_RIBBAR_FIELD,
203 RID_BMP_RIBBAR_FIELD_BYTYPE
204};
205
207{
208 STR_CONTENT_TYPE_TABLE,
209 STR_CONTENT_TYPE_FRAME,
210 STR_CONTENT_TYPE_GRAPHIC,
211 STR_CONTENT_TYPE_OLE,
212 ST_PGE,
213 STR_CONTENT_TYPE_OUTLINE,
214 ST_MARK,
215 STR_CONTENT_TYPE_DRAWOBJECT,
216 ST_CTRL,
217 STR_CONTENT_TYPE_REGION,
218 STR_CONTENT_TYPE_BOOKMARK,
219 ST_SEL,
220 STR_CONTENT_TYPE_FOOTNOTE,
221 STR_CONTENT_TYPE_POSTIT,
222 ST_SRCH_REP,
223 STR_CONTENT_TYPE_INDEX,
224 ST_TABLE_FORMULA,
225 ST_TABLE_FORMULA_ERROR,
226 ST_RECENCY,
227 STR_CONTENT_TYPE_TEXTFIELD,
228 ST_FIELD_BYTYPE
229};
230
231// these are global strings
233{
234 STR_IMGBTN_TBL_DOWN,
235 STR_IMGBTN_FRM_DOWN,
236 STR_IMGBTN_PGE_DOWN,
237 STR_IMGBTN_DRW_DOWN,
238 STR_IMGBTN_CTRL_DOWN,
239 STR_IMGBTN_REG_DOWN,
240 STR_IMGBTN_BKM_DOWN,
241 STR_IMGBTN_GRF_DOWN,
242 STR_IMGBTN_OLE_DOWN,
243 STR_IMGBTN_OUTL_DOWN,
244 STR_IMGBTN_SEL_DOWN,
245 STR_IMGBTN_FTN_DOWN,
246 STR_IMGBTN_MARK_DOWN,
247 STR_IMGBTN_POSTIT_DOWN,
248 STR_IMGBTN_SRCH_REP_DOWN,
249 STR_IMGBTN_INDEX_ENTRY_DOWN,
250 STR_IMGBTN_TBLFML_DOWN,
251 STR_IMGBTN_TBLFML_ERR_DOWN,
252 STR_IMGBTN_RECENCY_DOWN,
253 STR_IMGBTN_FIELD_DOWN,
254 STR_IMGBTN_FIELD_BYTYPE_DOWN,
255 STR_IMGBTN_TBL_UP,
256 STR_IMGBTN_FRM_UP,
257 STR_IMGBTN_PGE_UP,
258 STR_IMGBTN_DRW_UP,
259 STR_IMGBTN_CTRL_UP,
260 STR_IMGBTN_REG_UP,
261 STR_IMGBTN_BKM_UP,
262 STR_IMGBTN_GRF_UP,
263 STR_IMGBTN_OLE_UP,
264 STR_IMGBTN_OUTL_UP,
265 STR_IMGBTN_SEL_UP,
266 STR_IMGBTN_FTN_UP,
267 STR_IMGBTN_MARK_UP,
268 STR_IMGBTN_POSTIT_UP,
269 STR_IMGBTN_SRCH_REP_UP,
270 STR_IMGBTN_INDEX_ENTRY_UP,
271 STR_IMGBTN_TBLFML_UP,
272 STR_IMGBTN_TBLFML_ERR_UP,
273 STR_IMGBTN_RECENCY_UP,
274 STR_IMGBTN_FIELD_UP,
275 STR_IMGBTN_FIELD_BYTYPE_UP,
276};
277
278static OUString lcl_GetScrollToolTip(bool bNext)
279{
280 sal_uInt16 nResId = SwView::GetMoveType();
281 OUString sToolTip = SwResId(STR_IMGBTN_ARY[(!bNext ? NID_COUNT : 0) + nResId - NID_START]);
282 if (nResId == NID_FIELD_BYTYPE)
283 {
284 OUString sFieldType;
285 SwWrtShell* pWrtSh = GetActiveWrtShell();
286 if (pWrtSh)
287 {
288 SwField* pCurField = pWrtSh->GetCurField(true);
289 if (pCurField)
290 sFieldType = SwFieldType::GetTypeStr(pCurField->GetTypeId());
291 }
292 if (!sFieldType.isEmpty())
293 sToolTip = sToolTip.replaceFirst(u"%FIELDTYPE", sFieldType);
294 else
295 sToolTip = SwResId(SW_STR_NONE);
296 }
297 return sToolTip;
298}
299
300namespace {
301
302class SwZoomBox_Impl final : public InterimItemWindow
303{
304 std::unique_ptr<weld::ComboBox> m_xWidget;
305 sal_uInt16 m_nSlotId;
306 bool m_bRelease;
307
308 DECL_LINK(SelectHdl, weld::ComboBox&, void);
309 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
310 DECL_LINK(ActivateHdl, weld::ComboBox&, bool);
311 DECL_LINK(FocusOutHdl, weld::Widget&, void);
312
313 void Select();
314
315 void ReleaseFocus();
316
317public:
318 SwZoomBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot);
319
320 virtual void dispose() override
321 {
322 m_xWidget.reset();
324 }
325
326 void save_value()
327 {
328 m_xWidget->save_value();
329 }
330
331 void set_entry_text(const OUString& rText)
332 {
333 m_xWidget->set_entry_text(rText);
334 }
335
336 virtual ~SwZoomBox_Impl() override
337 {
338 disposeOnce();
339 }
340};
341
342}
343
344SwZoomBox_Impl::SwZoomBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot)
345 : InterimItemWindow(pParent, "modules/swriter/ui/zoombox.ui", "ZoomBox")
346 , m_xWidget(m_xBuilder->weld_combo_box("zoom"))
347 , m_nSlotId(nSlot)
348 , m_bRelease(true)
349{
350 InitControlBase(m_xWidget.get());
351
352 m_xWidget->set_help_id(HID_PVIEW_ZOOM_LB);
353 m_xWidget->set_entry_completion(false);
354 m_xWidget->connect_changed(LINK(this, SwZoomBox_Impl, SelectHdl));
355 m_xWidget->connect_key_press(LINK(this, SwZoomBox_Impl, KeyInputHdl));
356 m_xWidget->connect_entry_activate(LINK(this, SwZoomBox_Impl, ActivateHdl));
357 m_xWidget->connect_focus_out(LINK(this, SwZoomBox_Impl, FocusOutHdl));
358
359 const TranslateId aZoomValues[] =
360 { RID_SVXSTR_ZOOM_25 , RID_SVXSTR_ZOOM_50 ,
361 RID_SVXSTR_ZOOM_75 , RID_SVXSTR_ZOOM_100 ,
362 RID_SVXSTR_ZOOM_150 , RID_SVXSTR_ZOOM_200 ,
363 RID_SVXSTR_ZOOM_WHOLE_PAGE, RID_SVXSTR_ZOOM_PAGE_WIDTH ,
364 RID_SVXSTR_ZOOM_OPTIMAL_VIEW };
365 for(const TranslateId& pZoomValue : aZoomValues)
366 {
367 OUString sEntry = SvxResId(pZoomValue);
368 m_xWidget->append_text(sEntry);
369 }
370
371 int nWidth = m_xWidget->get_pixel_size(SvxResId(RID_SVXSTR_ZOOM_200)).Width();
372 m_xWidget->set_entry_width_chars(std::ceil(nWidth / m_xWidget->get_approximate_digit_width()));
373
374 SetSizePixel(m_xWidget->get_preferred_size());
375}
376
377IMPL_LINK(SwZoomBox_Impl, SelectHdl, weld::ComboBox&, rComboBox, void)
378{
379 if (rComboBox.changed_by_direct_pick()) // only when picked from the list
380 Select();
381}
382
383IMPL_LINK_NOARG(SwZoomBox_Impl, ActivateHdl, weld::ComboBox&, bool)
384{
385 Select();
386 return true;
387}
388
389void SwZoomBox_Impl::Select()
390{
391 if( FN_PREVIEW_ZOOM == m_nSlotId )
392 {
393 bool bNonNumeric = true;
394
395 OUString sEntry = m_xWidget->get_active_text().replaceAll("%", "");
396 SvxZoomItem aZoom(SvxZoomType::PERCENT,100);
397 if(sEntry == SvxResId( RID_SVXSTR_ZOOM_PAGE_WIDTH ) )
398 aZoom.SetType(SvxZoomType::PAGEWIDTH);
399 else if(sEntry == SvxResId( RID_SVXSTR_ZOOM_OPTIMAL_VIEW ) )
400 aZoom.SetType(SvxZoomType::OPTIMAL);
401 else if(sEntry == SvxResId( RID_SVXSTR_ZOOM_WHOLE_PAGE) )
402 aZoom.SetType(SvxZoomType::WHOLEPAGE);
403 else
404 {
405 bNonNumeric = false;
406
407 sal_uInt16 nZoom = o3tl::narrowing<sal_uInt16>(sEntry.toInt32());
408 if(nZoom < MINZOOM)
409 nZoom = MINZOOM;
410 if(nZoom > MAXZOOM)
411 nZoom = MAXZOOM;
412 aZoom.SetValue(nZoom);
413 }
414
415 if (bNonNumeric)
416 {
417 // put old value back, in case its effectively the same
418 // as the picked option and no update to number comes
419 // back from writer
420 m_xWidget->set_entry_text(m_xWidget->get_saved_value());
421 }
422
423 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
424
425 pCurrentShell->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM,
426 SfxCallMode::ASYNCHRON, { &aZoom });
427 }
428 ReleaseFocus();
429}
430
431IMPL_LINK(SwZoomBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
432{
433 bool bHandled = false;
434
435 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
436
437 switch (nCode)
438 {
439 case KEY_TAB:
440 m_bRelease = false;
441 Select();
442 break;
443
444 case KEY_ESCAPE:
445 m_xWidget->set_entry_text(m_xWidget->get_saved_value());
446 ReleaseFocus();
447 bHandled = true;
448 break;
449 }
450
451 return bHandled || ChildKeyInput(rKEvt);
452}
453
454IMPL_LINK_NOARG(SwZoomBox_Impl, FocusOutHdl, weld::Widget&, void)
455{
456 if (!m_xWidget->has_focus()) // a combobox can be comprised of different subwidget so double-check if none of those has focus
457 m_xWidget->set_entry_text(m_xWidget->get_saved_value());
458}
459
460void SwZoomBox_Impl::ReleaseFocus()
461{
462 if ( !m_bRelease )
463 {
464 m_bRelease = true;
465 return;
466 }
468
469 if ( pCurSh )
470 {
471 vcl::Window* pShellWnd = pCurSh->GetWindow();
472
473 if ( pShellWnd )
474 pShellWnd->GrabFocus();
475 }
476}
477
479
481 sal_uInt16 nSlotId,
482 ToolBoxItemId nId,
483 ToolBox& rTbx) :
484 SfxToolBoxControl( nSlotId, nId, rTbx )
485{
486}
487
489{
490}
491
493 SfxItemState eState,
494 const SfxPoolItem* pState )
495{
497 GetToolBox().EnableItem( nId, (GetItemState(pState) != SfxItemState::DISABLED) );
498 SwZoomBox_Impl* pBox = static_cast<SwZoomBox_Impl*>(GetToolBox().GetItemWindow( GetId() ));
499 if(SfxItemState::DEFAULT <= eState)
500 {
501 OUString sZoom(unicode::formatPercent(static_cast<const SfxUInt16Item*>(pState)->GetValue(),
502 Application::GetSettings().GetUILanguageTag()));
503 pBox->set_entry_text(sZoom);
504 pBox->save_value();
505 }
506}
507
509{
510 VclPtrInstance<SwZoomBox_Impl> pRet( pParent, GetSlotId() );
511 return pRet.get();
512}
513
514namespace {
515
516class SwJumpToSpecificBox_Impl final : public InterimItemWindow
517{
518 std::unique_ptr<weld::Entry> m_xWidget;
519
520 sal_uInt16 m_nSlotId;
521
522 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
523 DECL_LINK(SelectHdl, weld::Entry&, bool);
524public:
525 SwJumpToSpecificBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot);
526 virtual void dispose() override
527 {
528 m_xWidget.reset();
530 }
531 virtual ~SwJumpToSpecificBox_Impl() override
532 {
533 disposeOnce();
534 }
535};
536
537}
538
539IMPL_LINK(SwJumpToSpecificBox_Impl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
540{
541 return ChildKeyInput(rKEvt);
542}
543
544SwJumpToSpecificBox_Impl::SwJumpToSpecificBox_Impl(vcl::Window* pParent, sal_uInt16 nSlot)
545 : InterimItemWindow(pParent, "modules/swriter/ui/jumpposbox.ui", "JumpPosBox")
546 , m_xWidget(m_xBuilder->weld_entry("jumppos"))
547 , m_nSlotId(nSlot)
548{
549 InitControlBase(m_xWidget.get());
550
551 m_xWidget->connect_key_press(LINK(this, SwJumpToSpecificBox_Impl, KeyInputHdl));
552 m_xWidget->connect_activate(LINK(this, SwJumpToSpecificBox_Impl, SelectHdl));
553
554 SetSizePixel(m_xWidget->get_preferred_size());
555}
556
557IMPL_LINK_NOARG(SwJumpToSpecificBox_Impl, SelectHdl, weld::Entry&, bool)
558{
559 OUString sEntry(m_xWidget->get_text());
560 SfxUInt16Item aPageNum(m_nSlotId);
561 aPageNum.SetValue(o3tl::narrowing<sal_uInt16>(sEntry.toInt32()));
562 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
563 pCurrentShell->GetDispatcher()->ExecuteList(m_nSlotId, SfxCallMode::ASYNCHRON,
564 { &aPageNum });
565 return true;
566}
567
569
571 sal_uInt16 nSlotId,
572 ToolBoxItemId nId,
573 ToolBox& rTbx) :
574 SfxToolBoxControl( nSlotId, nId, rTbx )
575{}
576
578{}
579
581{
583 return pRet.get();
584}
585
586NavElementBox_Base::NavElementBox_Base(std::unique_ptr<weld::ComboBox> xComboBox,
587 uno::Reference<frame::XFrame> xFrame)
588 : m_xComboBox(std::move(xComboBox))
589 ,m_xFrame(std::move(xFrame))
590 ,m_bRelease(true)
591{
592 m_xComboBox->set_size_request(150, -1);
593
594 m_xComboBox->make_sorted();
595 m_xComboBox->freeze();
596 for (sal_uInt16 i = 0; i < NID_COUNT; i++)
597 m_xComboBox->append(OUString::number(aNavigationInsertIds[i]),
599 m_xComboBox->thaw();
600
601 m_xComboBox->connect_changed(LINK(this, NavElementBox_Base, SelectHdl));
602 m_xComboBox->connect_key_press(LINK(this, NavElementBox_Base, KeyInputHdl));
603}
604
606 const uno::Reference<frame::XFrame>& xFrame)
607 : InterimItemWindow(pParent, "modules/swriter/ui/combobox.ui", "ComboBox")
608 ,NavElementBox_Base(m_xBuilder->weld_combo_box("combobox"), xFrame)
609{
610 SetSizePixel(m_xContainer->get_preferred_size());
611}
612
614{
615 if ( !m_bRelease )
616 {
617 m_bRelease = true;
618 return;
619 }
620
621 if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
622 m_xFrame->getContainerWindow()->setFocus();
623}
624
626{
627 if (!rComboBox.changed_by_direct_pick()) // only when picked from the list
628 return;
629 SfxUInt32Item aParam(FN_NAV_ELEMENT, rComboBox.get_active_id().toUInt32());
630 const SfxPoolItem* aArgs[2];
631 aArgs[0] = &aParam;
632 aArgs[1] = nullptr;
634 pDispatch->Execute(FN_NAV_ELEMENT, SfxCallMode::SYNCHRON, aArgs);
635}
636
638{
639 sal_uInt16 nMoveType = SwView::GetMoveType();
640 for (size_t i = 0; i < SAL_N_ELEMENTS(aNavigationInsertIds); ++i)
641 {
642 if (nMoveType == aNavigationInsertIds[i])
643 {
644 m_xComboBox->set_active_text(SwResId(aNavigationStrIds[i]));
645 break;
646 }
647 }
648}
649
650IMPL_LINK(NavElementBox_Base, KeyInputHdl, const KeyEvent&, rKEvt, bool)
651{
652 return DoKeyInput(rKEvt);
653}
654
656{
657 return false;
658}
659
661{
662 if (KEY_ESCAPE == rKEvt.GetKeyCode().GetCode())
663 {
665 return true;
666 }
667 return ChildKeyInput(rKEvt);
668}
669
670NavElementToolBoxControl::NavElementToolBoxControl( const uno::Reference< uno::XComponentContext >& rxContext )
671 : svt::ToolboxController( rxContext,
672 uno::Reference< frame::XFrame >(),
673 ".uno:NavElement" ),
674 m_pBox( nullptr )
675{
676}
677
678// XInterface
679css::uno::Any SAL_CALL NavElementToolBoxControl::queryInterface( const css::uno::Type& aType )
680{
681 uno::Any a = ToolboxController::queryInterface( aType );
682 if ( a.hasValue() )
683 return a;
684
685 return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ) );
686}
687
688void SAL_CALL NavElementToolBoxControl::acquire() noexcept
689{
690 ToolboxController::acquire();
691}
692
693void SAL_CALL NavElementToolBoxControl::release() noexcept
694{
695 ToolboxController::release();
696}
697
698// XServiceInfo
699sal_Bool SAL_CALL NavElementToolBoxControl::supportsService( const OUString& ServiceName )
700{
701 return cppu::supportsService( this, ServiceName );
702}
703
705{
706 return "lo.writer.NavElementToolBoxController";
707}
708
709uno::Sequence< OUString > SAL_CALL NavElementToolBoxControl::getSupportedServiceNames()
710{
711 return { "com.sun.star.frame.ToolbarController" };
712}
713
714// XComponent
716{
718
719 SolarMutexGuard aSolarMutexGuard;
721 m_xWeldBox.reset();
722 m_pBox = nullptr;
723}
724
725// XStatusListener
726void SAL_CALL NavElementToolBoxControl::statusChanged( const frame::FeatureStateEvent& rEvent )
727{
728 if (!m_pBox)
729 return;
730
731 SolarMutexGuard aSolarMutexGuard;
732 if ( rEvent.FeatureURL.Path != "NavElement" )
733 return;
734
735 if ( rEvent.IsEnabled )
736 {
737 m_pBox->set_sensitive(true);
738 m_pBox->UpdateBox();
739 }
740 else
741 m_pBox->set_sensitive(true);
742
743 SwView* pView = GetActiveView();
744 if (pView && pView->GetViewFrame())
745 {
748 }
749}
750
751// XToolbarController
752void SAL_CALL NavElementToolBoxControl::execute( sal_Int16 /*KeyModifier*/ )
753{
754}
755
757{
758}
759
761{
762}
763
764uno::Reference< awt::XWindow > SAL_CALL NavElementToolBoxControl::createPopupWindow()
765{
766 return uno::Reference< awt::XWindow >();
767}
768
769uno::Reference< awt::XWindow > SAL_CALL NavElementToolBoxControl::createItemWindow(
770 const uno::Reference< awt::XWindow >& xParent )
771{
772 uno::Reference< awt::XWindow > xItemWindow;
773
774 if (m_pBuilder)
775 {
776 SolarMutexGuard aSolarMutexGuard;
777
778 std::unique_ptr<weld::ComboBox> xWidget(m_pBuilder->weld_combo_box("NavElementWidget"));
779
780 xItemWindow = css::uno::Reference<css::awt::XWindow>(new weld::TransportAsXWindow(xWidget.get()));
781
782 m_xWeldBox.reset(new NavElementBox_Base(std::move(xWidget), m_xFrame));
783 m_pBox = m_xWeldBox.get();
784 }
785 else
786 {
787 VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent );
788 if ( pParent )
789 {
790 SolarMutexGuard aSolarMutexGuard;
792 m_pBox = m_xVclBox.get();
794 }
795 }
796
797 return xItemWindow;
798}
799
800extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
802 css::uno::XComponentContext *rxContext,
803 css::uno::Sequence<css::uno::Any> const &)
804{
805 return cppu::acquire( new NavElementToolBoxControl( rxContext ) );
806}
807
808namespace {
809
810class PrevNextScrollToolboxController : public svt::ToolboxController,
811 public css::lang::XServiceInfo
812{
813public:
814 enum Type { PREVIOUS, NEXT };
815
816 PrevNextScrollToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, Type eType );
817
818 // XInterface
819 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
820 virtual void SAL_CALL acquire() noexcept override;
821 virtual void SAL_CALL release() noexcept override;
822
823 // XServiceInfo
824 virtual OUString SAL_CALL getImplementationName() override;
825 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
826 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
827
828 // XComponent
829 virtual void SAL_CALL dispose() override;
830
831 // XStatusListener
832 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
833
834private:
835 Type meType;
836};
837
838}
839
840PrevNextScrollToolboxController::PrevNextScrollToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext, Type eType )
841 : svt::ToolboxController( rxContext,
842 css::uno::Reference< css::frame::XFrame >(),
843 (eType == PREVIOUS) ? OUString( ".uno:ScrollToPrevious" ): OUString( ".uno:ScrollToNext" ) ),
844 meType( eType )
845{
846 addStatusListener(".uno:NavElement");
847}
848
849// XInterface
850css::uno::Any SAL_CALL PrevNextScrollToolboxController::queryInterface( const css::uno::Type& aType )
851{
852 css::uno::Any a = ToolboxController::queryInterface( aType );
853 if ( a.hasValue() )
854 return a;
855
856 return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
857}
858
859void SAL_CALL PrevNextScrollToolboxController::acquire() noexcept
860{
862}
863
864void SAL_CALL PrevNextScrollToolboxController::release() noexcept
865{
867}
868
869// XServiceInfo
870OUString SAL_CALL PrevNextScrollToolboxController::getImplementationName()
871{
872 return meType == PrevNextScrollToolboxController::PREVIOUS?
873 OUString( "lo.writer.PreviousScrollToolboxController" ) :
874 OUString( "lo.writer.NextScrollToolboxController" );
875}
876
877sal_Bool SAL_CALL PrevNextScrollToolboxController::supportsService( const OUString& ServiceName )
878{
879 return cppu::supportsService(this, ServiceName);
880}
881
882css::uno::Sequence< OUString > SAL_CALL PrevNextScrollToolboxController::getSupportedServiceNames()
883{
884 return { "com.sun.star.frame.ToolbarController" };
885}
886
887// XComponent
889{
890 SolarMutexGuard aSolarMutexGuard;
891
893}
894
895// XStatusListener
896void SAL_CALL PrevNextScrollToolboxController::statusChanged( const css::frame::FeatureStateEvent& rEvent )
897{
898 if (rEvent.FeatureURL.Path == "NavElement")
899 {
900 if (m_pToolbar)
901 m_pToolbar->set_item_tooltip_text(m_aCommandURL.toUtf8(), lcl_GetScrollToolTip(meType != PrevNextScrollToolboxController::PREVIOUS));
902 else
903 {
904 ToolBox* pToolBox = nullptr;
906 if (getToolboxId(nId, &pToolBox))
907 pToolBox->SetQuickHelpText(nId, lcl_GetScrollToolTip(meType != PrevNextScrollToolboxController::PREVIOUS));
908 }
909 }
910 else if (rEvent.FeatureURL.Path == "ScrollToPrevious" || rEvent.FeatureURL.Path == "ScrollToNext")
911 {
912 if (m_pToolbar)
913 m_pToolbar->set_item_sensitive(m_aCommandURL.toUtf8(), rEvent.IsEnabled);
914 else
915 {
916 ToolBox* pToolBox = nullptr;
918 if (getToolboxId(nId, &pToolBox))
919 pToolBox->EnableItem(nId, rEvent.IsEnabled);
920 }
921 }
922}
923
924extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
926 css::uno::XComponentContext *context,
927 css::uno::Sequence<css::uno::Any> const &)
928{
929 return cppu::acquire( new PrevNextScrollToolboxController( context, PrevNextScrollToolboxController::PREVIOUS ) );
930}
931
932extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
934 css::uno::XComponentContext *context,
935 css::uno::Sequence<css::uno::Any> const &)
936{
937 return cppu::acquire( new PrevNextScrollToolboxController( context, PrevNextScrollToolboxController::NEXT ) );
938}
939
940/* 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:655
NavElementBox_Base(std::unique_ptr< weld::ComboBox > xComboBox, uno::Reference< frame::XFrame > xFrame)
Definition: workctrl.cxx:586
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:613
NavElementBox_Impl(vcl::Window *pParent, const uno::Reference< frame::XFrame > &xFrame)
Definition: workctrl.cxx:605
virtual bool DoKeyInput(const KeyEvent &rKEvt) override
Definition: workctrl.cxx:660
VclPtr< NavElementBox_Impl > m_xVclBox
Definition: workctrl.hxx:189
virtual void SAL_CALL release() noexcept override
Definition: workctrl.cxx:693
NavElementBox_Base * m_pBox
Definition: workctrl.hxx:191
std::unique_ptr< NavElementBox_Base > m_xWeldBox
Definition: workctrl.hxx:190
NavElementToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rServiceManager)
Definition: workctrl.cxx:670
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: workctrl.cxx:679
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: workctrl.cxx:699
virtual OUString SAL_CALL getImplementationName() override
Definition: workctrl.cxx:704
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow(const css::uno::Reference< css::awt::XWindow > &Parent) override
Definition: workctrl.cxx:769
virtual void SAL_CALL click() override
Definition: workctrl.cxx:756
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: workctrl.cxx:709
virtual void SAL_CALL dispose() override
Definition: workctrl.cxx:715
virtual void SAL_CALL doubleClick() override
Definition: workctrl.cxx:760
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override
Definition: workctrl.cxx:764
virtual void SAL_CALL acquire() noexcept override
Definition: workctrl.cxx:688
virtual void SAL_CALL execute(sal_Int16 KeyModifier) override
Definition: workctrl.cxx:752
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &Event) override
Definition: workctrl.cxx:726
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
bool IsReadOnly() const
static SfxObjectShell * Current()
SfxDispatcher * GetDispatcher() const
ToolBoxItemId GetId() const
unsigned short GetSlotId() const
ToolBox & GetToolBox() const
static SfxItemState GetItemState(const SfxPoolItem *pState)
static SfxViewFrame * Current()
SfxBindings & GetBindings()
SfxViewFrame * GetViewFrame() const
static 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:942
bool HasReadonlySel(bool isReplace=false) const
Definition: crsrsh.cxx:3359
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:122
Base class of all fields.
Definition: fldbas.hxx:292
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:257
bool InsertGlossary(const OUString &rName)
Definition: gloshdl.cxx:490
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:221
OUString GetGroupName(size_t nPos)
Definition: gloslst.cxx:176
size_t GetGroupCount()
Definition: gloslst.cxx:169
OUString GetBlockLongName(size_t nGroup, sal_uInt16 nBlock)
Definition: gloslst.cxx:210
OUString GetGroupTitle(size_t nPos)
Definition: gloslst.cxx:188
sal_uInt16 GetBlockCount(size_t nGroup)
Definition: gloslst.cxx:199
virtual ~SwJumpToSpecificPageControl() override
Definition: workctrl.cxx:577
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: workctrl.cxx:580
SwJumpToSpecificPageControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: workctrl.cxx:570
SwPreviewZoomControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: workctrl.cxx:480
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
Definition: workctrl.cxx:508
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: workctrl.cxx:492
virtual ~SwPreviewZoomControl() override
Definition: workctrl.cxx:488
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:416
SwGlossaryHdl * GetGlosHdl()
Definition: view.cxx:1674
SwDocShell * GetDocShell()
Definition: view.cxx:1160
static sal_uInt16 GetMoveType()
Definition: viewmdi.cxx:707
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)
void addStatusListener(const OUString &aCommandURL)
virtual void SAL_CALL dispose() override
weld::Builder * m_pBuilder
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL release() noexcept override
bool getToolboxId(ToolBoxItemId &rItemId, ToolBox **ppToolBox)
css::uno::Reference< css::frame::XFrame > m_xFrame
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 OString &id)=0
#define FN_PREVIEW_ZOOM
Definition: cmdid.h:177
#define FN_NAV_ELEMENT
Definition: cmdid.h:183
#define FN_SCROLL_NEXT
Definition: cmdid.h:185
#define FN_SCROLL_PREV
Definition: cmdid.h:184
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
float u
constexpr OStringLiteral HID_PVIEW_ZOOM_LB
Definition: helpids.h:101
static SwGlossaryList * pGlossaryList
Definition: initui.cxx:41
SwGlossaryList * GetGlossaryList()
Definition: initui.cxx:174
sal_Int32 nIndex
uno_Any a
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_TAB
#define SAL_N_ELEMENTS(arr)
sal_uInt16 nCode
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:88
SwView * GetActiveView()
Definition: swmodul1.cxx:116
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:108
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
NEXT
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:933
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:925
static sal_uInt16 aNavigationInsertIds[NAVI_ENTRIES]
Definition: workctrl.cxx:156
SFX_IMPL_TOOLBOX_CONTROL(SwTbxAutoTextCtrl, SfxVoidItem)
IMPL_LINK(SwZoomBox_Impl, SelectHdl, weld::ComboBox &, rComboBox, void)
Definition: workctrl.cxx:377
const TranslateId aNavigationStrIds[NAVI_ENTRIES]
Definition: workctrl.cxx:206
IMPL_LINK_NOARG(SwZoomBox_Impl, ActivateHdl, weld::ComboBox &, bool)
Definition: workctrl.cxx:383
const TranslateId STR_IMGBTN_ARY[]
Definition: workctrl.cxx:232
#define NAVI_ENTRIES
Definition: workctrl.cxx:56
rtl::OUStringConstExpr constexpr aNavigationImgIds[NAVI_ENTRIES]
Definition: workctrl.cxx:181
static OUString lcl_GetScrollToolTip(bool bNext)
Definition: workctrl.cxx:278
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:801
#define NID_SEL
Definition: workctrl.hxx:45
#define NID_TABLE_FORMULA
Definition: workctrl.hxx:51
#define NID_MARK
Definition: workctrl.hxx:47
#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