LibreOffice Module sfx2 (master) 1
backingwindow.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 "backingwindow.hxx"
21#include <utility>
22#include <vcl/event.hxx>
23#include <vcl/help.hxx>
24#include <vcl/ptrstyle.hxx>
25#include <vcl/settings.hxx>
26#include <vcl/svapp.hxx>
27#include <vcl/syswin.hxx>
28
32#include <svtools/colorcfg.hxx>
33#include <svtools/langhelp.hxx>
34#include <templateviewitem.hxx>
35
39#include <sfx2/app.hxx>
40#include <officecfg/Office/Common.hxx>
41
43
44#include <com/sun/star/configuration/theDefaultProvider.hpp>
45#include <com/sun/star/container/XNameAccess.hpp>
46#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
47#include <com/sun/star/document/MacroExecMode.hpp>
48#include <com/sun/star/document/UpdateDocMode.hpp>
49#include <com/sun/star/frame/Desktop.hpp>
50#include <com/sun/star/lang/XMultiServiceFactory.hpp>
51#include <com/sun/star/system/SystemShellExecute.hpp>
52#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
53#include <com/sun/star/util/URLTransformer.hpp>
54#include <com/sun/star/task/InteractionHandler.hpp>
55
56using namespace ::com::sun::star;
57using namespace ::com::sun::star::beans;
58using namespace ::com::sun::star::frame;
59using namespace ::com::sun::star::uno;
60using namespace ::com::sun::star::document;
61
62constexpr OUStringLiteral SERVICENAME_CFGREADACCESS = u"com.sun.star.configuration.ConfigurationAccess";
63
65{
66private:
68 bool mbIsDark = false;
70
71public:
72 const Size & getSize() { return m_BmpSize; }
73
74 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
75 {
77
79 OutputDevice& rDevice = pDrawingArea->get_ref_device();
80 rDevice.SetBackground(Wallpaper(rStyleSettings.GetWindowColor()));
81
82 SetPointer(PointerStyle::RefHand);
83 }
84
85 virtual void Resize() override
86 {
87 auto nWidth = GetOutputSizePixel().Width();
88 if (maBrandImage.GetSizePixel().Width() != nWidth)
89 LoadImageForWidth(nWidth);
91 }
92
93 void LoadImageForWidth(int nWidth)
94 {
96 SfxApplication::loadBrandSvg(mbIsDark ? "shell/logo-sc_inverted" : "shell/logo-sc",
97 maBrandImage, nWidth);
98 }
99
100 void ConfigureForWidth(int nWidth)
101 {
102 if (maBrandImage.GetSizePixel().Width() == nWidth)
103 return;
104 LoadImageForWidth(nWidth);
107 }
108
109 virtual void StyleUpdated() override
110 {
111 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
112
113 // tdf#141857 update background to current theme
115 rDevice.SetBackground(Wallpaper(rStyleSettings.GetWindowColor()));
116
117 const bool bIsDark = rStyleSettings.GetDialogColor().IsDark();
118 if (bIsDark != mbIsDark)
121 }
122
123 virtual bool MouseButtonUp(const MouseEvent& rMEvt) override
124 {
125 if (rMEvt.IsLeft())
126 {
127 OUString sURL = officecfg::Office::Common::Menus::VolunteerURL::get();
129
130 Reference<css::system::XSystemShellExecute> const xSystemShellExecute(
131 css::system::SystemShellExecute::create(
132 ::comphelper::getProcessComponentContext()));
133 xSystemShellExecute->execute(sURL, OUString(),
134 css::system::SystemShellExecuteFlags::URIS_ONLY);
135 }
136 return true;
137 }
138
139 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override
140 {
141 rRenderContext.DrawBitmapEx(Point(0, 0), maBrandImage);
142 }
143};
144
145// increase size of the text in the buttons on the left fMultiplier-times
146float const g_fMultiplier = 1.2f;
147
149 : InterimItemWindow(i_pParent, "sfx/ui/startcenter.ui", "StartCenter", false)
150 , mxOpenButton(m_xBuilder->weld_button("open_all"))
151 , mxRecentButton(m_xBuilder->weld_toggle_button("open_recent"))
152 , mxRemoteButton(m_xBuilder->weld_button("open_remote"))
153 , mxTemplateButton(m_xBuilder->weld_toggle_button("templates_all"))
154 , mxCreateLabel(m_xBuilder->weld_label("create_label"))
155 , mxAltHelpLabel(m_xBuilder->weld_label("althelplabel"))
156 , mxFilter(m_xBuilder->weld_combo_box("cbFilter"))
157 , mxActions(m_xBuilder->weld_menu_button("mbActions"))
158 , mxWriterAllButton(m_xBuilder->weld_button("writer_all"))
159 , mxCalcAllButton(m_xBuilder->weld_button("calc_all"))
160 , mxImpressAllButton(m_xBuilder->weld_button("impress_all"))
161 , mxDrawAllButton(m_xBuilder->weld_button("draw_all"))
162 , mxDBAllButton(m_xBuilder->weld_button("database_all"))
163 , mxMathAllButton(m_xBuilder->weld_button("math_all"))
164 , mxBrandImage(new BrandImage)
165 , mxBrandImageWeld(new weld::CustomWeld(*m_xBuilder, "daBrand", *mxBrandImage))
166 , mxHelpButton(m_xBuilder->weld_button("help"))
167 , mxExtensionsButton(m_xBuilder->weld_button("extensions"))
168 , mxAllButtonsBox(m_xBuilder->weld_container("all_buttons_box"))
169 , mxButtonsBox(m_xBuilder->weld_container("buttons_box"))
170 , mxSmallButtonsBox(m_xBuilder->weld_container("small_buttons_box"))
171 , mxAllRecentThumbnails(new sfx2::RecentDocsView(m_xBuilder->weld_scrolled_window("scrollrecent", true),
172 m_xBuilder->weld_menu("recentmenu")))
173 , mxAllRecentThumbnailsWin(new weld::CustomWeld(*m_xBuilder, "all_recent", *mxAllRecentThumbnails))
174 , mxLocalView(new TemplateDefaultView(m_xBuilder->weld_scrolled_window("scrolllocal", true),
175 m_xBuilder->weld_menu("localmenu")))
176 , mxLocalViewWin(new weld::CustomWeld(*m_xBuilder, "local_view", *mxLocalView))
177 , mbLocalViewInitialized(false)
178 , mbInitControls(false)
179{
180 // init background, undo InterimItemWindow defaults for this widget
181 SetPaintTransparent(false);
182
183 // square action button
184 auto nHeight = mxFilter->get_preferred_size().getHeight();
185 mxActions->set_size_request(nHeight, nHeight);
186
187 //set an alternative help label that doesn't hotkey the H of the Help menu
188 mxHelpButton->set_label(mxAltHelpLabel->get_label());
189 mxHelpButton->connect_clicked(LINK(this, BackingWindow, ClickHelpHdl));
190
191 mxDropTarget = mxAllRecentThumbnails->GetDropTarget();
192
193 try
194 {
195 mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
196 }
197 catch (const Exception&)
198 {
199 TOOLS_WARN_EXCEPTION( "fwk", "BackingWindow" );
200 }
201
203
204 // get dispatch provider
205 Reference<XDesktop2> xDesktop = Desktop::create( comphelper::getProcessComponentContext() );
206 mxDesktopDispatchProvider = xDesktop;
207
208}
209
210IMPL_LINK(BackingWindow, ClickHelpHdl, weld::Button&, rButton, void)
211{
212 if (Help* pHelp = Application::GetHelp())
213 pHelp->Start(m_xContainer->get_help_id(), &rButton);
214}
215
217{
218 disposeOnce();
219}
220
222{
223 // deregister drag&drop helper
224 if (mxDropTargetListener.is())
225 {
226 if (mxDropTarget.is())
227 {
228 mxDropTarget->removeDropTargetListener(mxDropTargetListener);
229 mxDropTarget->setActive(false);
230 }
231 mxDropTargetListener.clear();
232 }
233 mxDropTarget.clear();
234 mxOpenButton.reset();
235 mxRemoteButton.reset();
236 mxRecentButton.reset();
237 mxTemplateButton.reset();
238 mxCreateLabel.reset();
239 mxAltHelpLabel.reset();
240 mxFilter.reset();
241 mxActions.reset();
242 mxWriterAllButton.reset();
243 mxCalcAllButton.reset();
244 mxImpressAllButton.reset();
245 mxDrawAllButton.reset();
246 mxDBAllButton.reset();
247 mxMathAllButton.reset();
248 mxBrandImageWeld.reset();
249 mxBrandImage.reset();
250 mxHelpButton.reset();
251 mxExtensionsButton.reset();
252 mxAllButtonsBox.reset();
253 mxButtonsBox.reset();
254 mxSmallButtonsBox.reset();
256 mxAllRecentThumbnails.reset();
257 mxLocalViewWin.reset();
258 mxLocalView.reset();
260}
261
263{
264 if( mbInitControls )
265 return;
266
267 mbInitControls = true;
268
269 // collect the URLs of the entries in the File/New menu
270 SvtModuleOptions aModuleOptions;
271
274
277
280
283
286
289
291 mxAllRecentThumbnails->Reload();
292 mxAllRecentThumbnails->ShowTooltips( true );
293
294 mxRecentButton->set_active(true);
295 ToggleHdl(*mxRecentButton);
296
297 //set handlers
298 mxLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, CreateContextMenuHdl));
299 mxLocalView->setOpenTemplateHdl(LINK(this, BackingWindow, OpenTemplateHdl));
300 mxLocalView->setEditTemplateHdl(LINK(this, BackingWindow, EditTemplateHdl));
301 mxLocalView->ShowTooltips( true );
302
304
305 mxExtensionsButton->connect_clicked(LINK(this, BackingWindow, ExtLinkClickHdl));
306
307 mxOpenButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
308 mxRemoteButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
309 mxWriterAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
310 mxDrawAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
311 mxCalcAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
312 mxDBAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
313 mxImpressAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
314 mxMathAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl));
315
316 mxRecentButton->connect_toggled(LINK(this, BackingWindow, ToggleHdl));
317 mxTemplateButton->connect_toggled(LINK(this, BackingWindow, ToggleHdl));
318
319 mxFilter->connect_changed(LINK(this, BackingWindow, FilterHdl));
320 mxActions->connect_selected(LINK(this, BackingWindow, MenuSelectHdl));
321
323}
324
326{
327 if ((rDCEvt.GetType() != DataChangedEventType::SETTINGS)
328 || !(rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
329 {
331 return;
332 }
333
335 Invalidate();
336}
337
338template <typename WidgetClass>
339void BackingWindow::setLargerFont(WidgetClass& pWidget, const vcl::Font& rFont)
340{
341 vcl::Font aFont(rFont);
342 aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * g_fMultiplier));
343 pWidget->set_font(aFont);
344}
345
347{
348 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
349 const Color aButtonsBackground(rStyleSettings.GetWindowColor());
350 const vcl::Font& aButtonFont(rStyleSettings.GetPushButtonFont());
351 const vcl::Font& aLabelFont(rStyleSettings.GetLabelFont());
352
353 // setup larger fonts
354 setLargerFont(mxOpenButton, aButtonFont);
355 setLargerFont(mxOpenButton, aButtonFont);
356 setLargerFont(mxRemoteButton, aButtonFont);
357 setLargerFont(mxRecentButton, aButtonFont);
358 setLargerFont(mxTemplateButton, aButtonFont);
359 setLargerFont(mxWriterAllButton, aButtonFont);
360 setLargerFont(mxDrawAllButton, aButtonFont);
361 setLargerFont(mxCalcAllButton, aButtonFont);
362 setLargerFont(mxDBAllButton, aButtonFont);
363 setLargerFont(mxImpressAllButton, aButtonFont);
364 setLargerFont(mxMathAllButton, aButtonFont);
365 setLargerFont(mxCreateLabel, aLabelFont);
366
367 mxAllButtonsBox->set_background(aButtonsBackground);
368 mxSmallButtonsBox->set_background(aButtonsBackground);
369 SetBackground(aButtonsBackground);
370
371 // compute the menubar height
372 sal_Int32 nMenuHeight = 0;
373 if (SystemWindow* pSystemWindow = GetSystemWindow())
374 nMenuHeight = pSystemWindow->GetMenuBarHeight();
375
376 // fdo#34392: we do the layout dynamically, the layout depends on the font,
377 // so we should handle data changed events (font changing) of the last child
378 // control, at this point all the controls have updated settings (i.e. font).
379 Size aPrefSize(mxAllButtonsBox->get_preferred_size());
380 set_width_request(aPrefSize.Width());
381
382 // Now set a brand image wide enough to fill this width
383 weld::DrawingArea* pDrawingArea = mxBrandImage->GetDrawingArea();
384 mxBrandImage->ConfigureForWidth(aPrefSize.Width() -
385 (pDrawingArea->get_margin_start() + pDrawingArea->get_margin_end()));
386 // Refetch because the brand image height to match this width is now set
387 aPrefSize = mxAllButtonsBox->get_preferred_size();
388
389 set_height_request(nMenuHeight + aPrefSize.Height() + mxBrandImage->getSize().getHeight());
390}
391
393{
395 {
397 mxLocalView->Populate();
399 mxLocalView->showAllTemplates();
400 }
401}
402
404{
405 SvtModuleOptions aModuleOpt;
406
413}
414
416{
417 if( rNEvt.GetType() == NotifyEventType::KEYINPUT )
418 {
419 const KeyEvent* pEvt = rNEvt.GetKeyEvent();
420 const vcl::KeyCode& rKeyCode(pEvt->GetKeyCode());
421
422 bool bThumbnailHasFocus = mxAllRecentThumbnails->HasFocus() || mxLocalView->HasFocus();
423
424 // Subwindows of BackingWindow: Sidebar and Thumbnail view
425 if( rKeyCode.GetCode() == KEY_F6 )
426 {
427 if( rKeyCode.IsShift() ) // Shift + F6
428 {
429 if (bThumbnailHasFocus)
430 {
431 mxOpenButton->grab_focus();
432 return true;
433 }
434 }
435 else if ( rKeyCode.IsMod1() ) // Ctrl + F6
436 {
437 if(mxAllRecentThumbnails->IsVisible())
438 {
439 mxAllRecentThumbnails->GrabFocus();
440 return true;
441 }
442 else if(mxLocalView->IsVisible())
443 {
444 mxLocalView->GrabFocus();
445 return true;
446 }
447 }
448 else // F6
449 {
450 if (!bThumbnailHasFocus)
451 {
452 if(mxAllRecentThumbnails->IsVisible())
453 {
454 mxAllRecentThumbnails->GrabFocus();
455 return true;
456 }
457 else if(mxLocalView->IsVisible())
458 {
459 mxLocalView->GrabFocus();
460 return true;
461 }
462 }
463 }
464 }
465
466 // try the 'normal' accelerators (so that eg. Ctrl+Q works)
467 if (!mpAccExec)
468 {
471 }
472
473 const OUString aCommand = mpAccExec->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode));
474 if ((aCommand != "vnd.sun.star.findbar:FocusToFindbar") && pEvt && mpAccExec->execute(rKeyCode))
475 return true;
476 }
477 return InterimItemWindow::PreNotify( rNEvt );
478}
479
481{
483 if( nFlags & GetFocusFlags::F6 )
484 {
485 if( nFlags & GetFocusFlags::Forward ) // F6
486 {
487 mxOpenButton->grab_focus();
488 return;
489 }
490 else // Shift + F6 or Ctrl + F6
491 {
492 if(mxAllRecentThumbnails->IsVisible())
493 mxAllRecentThumbnails->GrabFocus();
494 else if(mxLocalView->IsVisible())
495 mxLocalView->GrabFocus();
496 return;
497 }
498 }
500}
501
502void BackingWindow::setOwningFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
503{
504 mxFrame = xFrame;
505 if( ! mbInitControls )
506 initControls();
507
508 // establish drag&drop mode
509 mxDropTargetListener.set(new OpenFileDropTargetListener(mxContext, mxFrame));
510
511 if (mxDropTarget.is())
512 {
513 mxDropTarget->addDropTargetListener(mxDropTargetListener);
514 mxDropTarget->setActive(true);
515 }
516
517 css::uno::Reference<XFramesSupplier> xFramesSupplier(mxDesktopDispatchProvider, UNO_QUERY);
518 if (xFramesSupplier)
519 xFramesSupplier->setActiveFrame(mxFrame);
520}
521
522IMPL_LINK(BackingWindow, ExtLinkClickHdl, weld::Button&, rButton, void)
523{
524 OUString aNode;
525
526 if (&rButton == mxExtensionsButton.get())
527 aNode = "AddFeatureURL";
528
529 if (aNode.isEmpty())
530 return;
531
532 try
533 {
534 uno::Sequence<uno::Any> args(comphelper::InitAnyPropertySequence(
535 {
536 {"nodepath", uno::Any(OUString("/org.openoffice.Office.Common/Help/StartCenter"))}
537 }));
538
539 Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
540 Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS, args), UNO_QUERY);
541 if (xNameAccess.is())
542 {
543 OUString sURL;
544 Any value(xNameAccess->getByName(aNode));
545
546 sURL = value.get<OUString>();
548
549 Reference<css::system::XSystemShellExecute> const
550 xSystemShellExecute(
551 css::system::SystemShellExecute::create(
552 ::comphelper::getProcessComponentContext()));
553 xSystemShellExecute->execute(sURL, OUString(),
554 css::system::SystemShellExecuteFlags::URIS_ONLY);
555 }
556 }
557 catch (const Exception&)
558 {
559 }
560}
561
563{
564 const int nFilter = mxFilter->get_active();
565 if (mxLocalView->IsVisible())
566 {
567 FILTER_APPLICATION aFilter = static_cast<FILTER_APPLICATION>(nFilter);
568 mxLocalView->filterItems(ViewFilter_Application(aFilter));
569 }
570 else
571 {
572 sfx2::ApplicationType aFilter;
573 if (nFilter == 0)
575 else
576 aFilter = static_cast<sfx2::ApplicationType>(1 << (nFilter - 1));
577 mxAllRecentThumbnails->setFilter(aFilter);
578 }
579}
580
582{
583 applyFilter();
584}
585
586IMPL_LINK( BackingWindow, ToggleHdl, weld::Toggleable&, rButton, void )
587{
588 bool bRecentMode;
589 if (&rButton == mxRecentButton.get())
590 bRecentMode = rButton.get_active();
591 else
592 bRecentMode = !rButton.get_active();
593
594 if (bRecentMode)
595 {
596 mxLocalView->Hide();
597 mxAllRecentThumbnails->Show();
598 mxAllRecentThumbnails->GrabFocus();
599 mxRecentButton->set_active(true);
600 mxTemplateButton->set_active(false);
601 mxActions->set_sensitive(true);
602 }
603 else
604 {
605 mxAllRecentThumbnails->Hide();
606 initializeLocalView();
607 mxLocalView->Show();
608 mxLocalView->reload();
609 mxLocalView->GrabFocus();
610 mxRecentButton->set_active(false);
611 mxTemplateButton->set_active(true);
612 mxActions->set_sensitive(false);
613 }
614 applyFilter();
615}
616
617IMPL_LINK( BackingWindow, ClickHdl, weld::Button&, rButton, void )
618{
619 // dispatch the appropriate URL and end the dialog
620 if( &rButton == mxWriterAllButton.get() )
621 dispatchURL( "private:factory/swriter" );
622 else if( &rButton == mxCalcAllButton.get() )
623 dispatchURL( "private:factory/scalc" );
624 else if( &rButton == mxImpressAllButton.get() )
625 dispatchURL( "private:factory/simpress?slot=6686" );
626 else if( &rButton == mxDrawAllButton.get() )
627 dispatchURL( "private:factory/sdraw" );
628 else if( &rButton == mxDBAllButton.get() )
629 dispatchURL( "private:factory/sdatabase?Interactive" );
630 else if( &rButton == mxMathAllButton.get() )
631 dispatchURL( "private:factory/smath" );
632 else if( &rButton == mxOpenButton.get() )
633 {
634 Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
635
636 dispatchURL( ".uno:Open", OUString(), xFrame, { comphelper::makePropertyValue("Referer", OUString("private:user")) } );
637 }
638 else if( &rButton == mxRemoteButton.get() )
639 {
640 Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
641
642 dispatchURL( ".uno:OpenRemote", OUString(), xFrame, {} );
643 }
644}
645
646IMPL_LINK (BackingWindow, MenuSelectHdl, const OUString&, rId, void)
647{
648 if (rId == "clear_all")
649 {
650 SvtHistoryOptions::Clear(EHistoryType::PickList);
651 mxAllRecentThumbnails->Reload();
652 return;
653 }
654 else if(rId == "clear_unavailable")
655 {
656 mxAllRecentThumbnails->clearUnavailableFiles();
657 }
658}
659
660IMPL_LINK(BackingWindow, CreateContextMenuHdl, ThumbnailViewItem*, pItem, void)
661{
662 const TemplateViewItem *pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
663
664 if (pViewItem)
665 mxLocalView->createContextMenu();
666}
667
668IMPL_LINK(BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem, void)
669{
670 uno::Sequence< PropertyValue > aArgs{
671 comphelper::makePropertyValue("AsTemplate", true),
672 comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG),
673 comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG),
674 comphelper::makePropertyValue("InteractionHandler", task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ))
675 };
676
677 TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem);
678
679 Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
680
681 try
682 {
683 dispatchURL( pTemplateItem->getPath(), "_default", xFrame, aArgs );
684 }
685 catch( const uno::Exception& )
686 {
687 }
688}
689
690IMPL_LINK(BackingWindow, EditTemplateHdl, ThumbnailViewItem*, pItem, void)
691{
692 uno::Sequence< PropertyValue > aArgs{
693 comphelper::makePropertyValue("AsTemplate", false),
694 comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG),
695 comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG),
696 };
697
698 TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
699
700 Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
701
702 try
703 {
704 dispatchURL( pViewItem->getPath(), "_default", xFrame, aArgs );
705 }
706 catch( const uno::Exception& )
707 {
708 }
709}
710
711namespace {
712
713struct ImplDelayedDispatch
714{
715 Reference< XDispatch > xDispatch;
716 css::util::URL aDispatchURL;
717 Sequence< PropertyValue > aArgs;
718
719 ImplDelayedDispatch( const Reference< XDispatch >& i_xDispatch,
720 css::util::URL i_aURL,
721 const Sequence< PropertyValue >& i_rArgs )
722 : xDispatch( i_xDispatch ),
723 aDispatchURL(std::move( i_aURL )),
724 aArgs( i_rArgs )
725 {
726 }
727};
728
729}
730
731static void implDispatchDelayed( void*, void* pArg )
732{
733 struct ImplDelayedDispatch* pDispatch = static_cast<ImplDelayedDispatch*>(pArg);
734 try
735 {
736 pDispatch->xDispatch->dispatch( pDispatch->aDispatchURL, pDispatch->aArgs );
737 }
738 catch (const Exception&)
739 {
740 }
741
742 // clean up
743 delete pDispatch;
744}
745
746void BackingWindow::dispatchURL( const OUString& i_rURL,
747 const OUString& rTarget,
748 const Reference< XDispatchProvider >& i_xProv,
749 const Sequence< PropertyValue >& i_rArgs )
750{
751 // if no special dispatch provider is given, get the desktop
752 Reference< XDispatchProvider > xProvider( i_xProv.is() ? i_xProv : mxDesktopDispatchProvider );
753
754 // check for dispatch provider
755 if( !xProvider.is())
756 return;
757
758 // get a URL transformer to clean up the URL
759 css::util::URL aDispatchURL;
760 aDispatchURL.Complete = i_rURL;
761
762 Reference < css::util::XURLTransformer > xURLTransformer(
763 css::util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
764 try
765 {
766 // clean up the URL
767 xURLTransformer->parseStrict( aDispatchURL );
768 // get a Dispatch for the URL and target
769 Reference< XDispatch > xDispatch(
770 xProvider->queryDispatch( aDispatchURL, rTarget, 0 )
771 );
772 // dispatch the URL
773 if ( xDispatch.is() )
774 {
775 std::unique_ptr<ImplDelayedDispatch> pDisp(new ImplDelayedDispatch( xDispatch, std::move(aDispatchURL), i_rArgs ));
776 if( Application::PostUserEvent( Link<void*,void>( nullptr, implDispatchDelayed ), pDisp.get() ) )
777 pDisp.release();
778 }
779 }
780 catch (const css::uno::RuntimeException&)
781 {
782 throw;
783 }
784 catch (const css::uno::Exception&)
785 {
786 }
787}
788
790{
791 mxAllRecentThumbnails->Clear();
792}
793/* vim:set shiftwidth=4 softtabstop=4 expandtab:*/
constexpr OUStringLiteral SERVICENAME_CFGREADACCESS
float const g_fMultiplier
static void implDispatchDelayed(void *, void *pArg)
IMPL_LINK_NOARG(BackingWindow, FilterHdl, weld::ComboBox &, void)
IMPL_LINK(BackingWindow, ClickHelpHdl, weld::Button &, rButton, void)
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static Help * GetHelp()
std::unique_ptr< sfx2::RecentDocsView > mxAllRecentThumbnails
std::unique_ptr< weld::Button > mxExtensionsButton
virtual bool PreNotify(NotifyEvent &rNEvt) override
std::unique_ptr< weld::CustomWeld > mxAllRecentThumbnailsWin
std::unique_ptr< weld::Button > mxDrawAllButton
std::unique_ptr< weld::Button > mxWriterAllButton
std::unique_ptr< weld::ToggleButton > mxRecentButton
std::unique_ptr< TemplateDefaultView > mxLocalView
void clearRecentFileList()
std::unique_ptr< weld::Container > mxSmallButtonsBox
std::unique_ptr< weld::MenuButton > mxActions
std::unique_ptr< BrandImage > mxBrandImage
css::uno::Reference< css::datatransfer::dnd::XDropTarget > mxDropTarget
void setLargerFont(WidgetClass &, const vcl::Font &)
bool mbLocalViewInitialized
css::uno::Reference< css::uno::XComponentContext > mxContext
std::unique_ptr< weld::Button > mxImpressAllButton
std::unique_ptr< weld::Button > mxCalcAllButton
std::unique_ptr< weld::CustomWeld > mxBrandImageWeld
BackingWindow(vcl::Window *pParent)
std::unique_ptr< weld::Container > mxButtonsBox
void ApplyStyleSettings()
void checkInstalledModules()
std::unique_ptr< weld::Container > mxAllButtonsBox
std::unique_ptr< weld::ComboBox > mxFilter
std::unique_ptr< weld::Button > mxMathAllButton
std::unique_ptr< weld::Button > mxDBAllButton
std::unique_ptr< weld::Button > mxOpenButton
void DataChanged(const DataChangedEvent &) override
virtual ~BackingWindow() override
void dispatchURL(const OUString &i_rURL, const OUString &i_rTarget=OUString("_default"), const css::uno::Reference< css::frame::XDispatchProvider > &i_xProv=css::uno::Reference< css::frame::XDispatchProvider >(), const css::uno::Sequence< css::beans::PropertyValue > &=css::uno::Sequence< css::beans::PropertyValue >())
std::unique_ptr< weld::Label > mxAltHelpLabel
css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > mxDropTargetListener
helper for drag&drop.
void initializeLocalView()
std::unique_ptr< weld::ToggleButton > mxTemplateButton
std::unique_ptr< weld::Button > mxHelpButton
void setOwningFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
std::unique_ptr< weld::CustomWeld > mxLocalViewWin
virtual void GetFocus() override
css::uno::Reference< css::frame::XFrame > mxFrame
std::unique_ptr< weld::Button > mxRemoteButton
css::uno::Reference< css::frame::XDispatchProvider > mxDesktopDispatchProvider
std::unique_ptr< weld::Label > mxCreateLabel
std::unique_ptr< svt::AcceleratorExecute > mpAccExec
virtual void dispose() override
const Size & GetSizePixel() const
const Size & getSize()
virtual void StyleUpdated() override
BitmapEx maBrandImage
virtual void Resize() override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
void ConfigureForWidth(int nWidth)
void LoadImageForWidth(int nWidth)
bool IsDark() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
virtual void dispose() override
virtual void GetFocus() override
const vcl::KeyCode & GetKeyCode() const
bool IsLeft() const
const KeyEvent * GetKeyEvent() const
NotifyEventType GetType() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void SetBackground()
static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth)
Definition: appmisc.cxx:129
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetWindowColor() const
const vcl::Font & GetLabelFont() const
const vcl::Font & GetPushButtonFont() const
const Color & GetDialogColor() const
bool IsModuleInstalled(EModule eModule) const
const OUString & getPath() const
static css::awt::KeyEvent st_VCLKey2AWTKey(const vcl::KeyCode &aKey)
static std::unique_ptr< AcceleratorExecute > createAcceleratorHelper()
void SetFontSize(const Size &)
const Size & GetFontSize() const
bool IsMod1() const
sal_uInt16 GetCode() const
bool IsShift() const
void SetStyle(WinBits nStyle)
vcl::Window * GetParent() const
GetFocusFlags GetGetFocusFlags() const
void set_height_request(sal_Int32 nHeightRequest)
WinBits GetStyle() const
const AllSettings & GetSettings() const
virtual bool PreNotify(NotifyEvent &rNEvt)
SystemWindow * GetSystemWindow() const
void set_width_request(sal_Int32 nWidthRequest)
virtual void DataChanged(const DataChangedEvent &rDCEvt)
void SetPaintTransparent(bool bTransparent)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
void SetBackground()
void SetPointer(PointerStyle ePointerStyle)
void set_size_request(int nWidth, int nHeight)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
weld::DrawingArea * GetDrawingArea() const
Size const & GetOutputSizePixel() const
virtual OutputDevice & get_ref_device()=0
virtual int get_margin_start() const=0
virtual int get_margin_end() const=0
Any value
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XDispatch > xDispatch
float u
FilterGroup & rTarget
constexpr sal_uInt16 KEY_F6
SVT_DLLPUBLIC void localizeWebserviceURI(OUString &io_rURI)
void Clear(EHistoryType eHistory)
@ Exception
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
args
Reference< XNameAccess > m_xContainer
Reference< XFrame > xFrame
FILTER_APPLICATION
OUString aCommand
GetFocusFlags
WinBits const WB_DIALOGCONTROL