1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "backingwindow.hxx"
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>
29 #include <unotools/historyoptions.hxx>
30 #include <unotools/moduleoptions.hxx>
31 #include <unotools/configmgr.hxx>
32 #include <svtools/openfiledroptargetlistener.hxx>
33 #include <svtools/colorcfg.hxx>
34 #include <svtools/langhelp.hxx>
35 #include <templateviewitem.hxx>
37 #include <comphelper/processfactory.hxx>
38 #include <comphelper/propertysequence.hxx>
39 #include <comphelper/propertyvalue.hxx>
40 #include <sfx2/app.hxx>
41 #include <officecfg/Office/Common.hxx>
43 #include <i18nlangtag/languagetag.hxx>
44 #include <comphelper/diagnose_ex.hxx>
46 #include <com/sun/star/configuration/theDefaultProvider.hpp>
47 #include <com/sun/star/container/XNameAccess.hpp>
48 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
49 #include <com/sun/star/document/MacroExecMode.hpp>
50 #include <com/sun/star/document/UpdateDocMode.hpp>
51 #include <com/sun/star/frame/Desktop.hpp>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <com/sun/star/system/SystemShellExecute.hpp>
54 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
55 #include <com/sun/star/util/URLTransformer.hpp>
56 #include <com/sun/star/task/InteractionHandler.hpp>
58 using namespace ::com::sun::star
;
59 using namespace ::com::sun::star::beans
;
60 using namespace ::com::sun::star::frame
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::document
;
64 constexpr OUStringLiteral SERVICENAME_CFGREADACCESS
= u
"com.sun.star.configuration.ConfigurationAccess";
66 class BrandImage final
: public weld::CustomWidgetController
69 BitmapEx maBrandImage
;
70 bool mbIsDark
= false;
74 const Size
& getSize() { return m_BmpSize
; }
76 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
78 weld::CustomWidgetController::SetDrawingArea(pDrawingArea
);
80 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
81 OutputDevice
& rDevice
= pDrawingArea
->get_ref_device();
82 rDevice
.SetBackground(Wallpaper(rStyleSettings
.GetWindowColor()));
84 SetPointer(PointerStyle::RefHand
);
87 virtual void Resize() override
89 auto nWidth
= GetOutputSizePixel().Width();
90 if (maBrandImage
.GetSizePixel().Width() != nWidth
)
91 LoadImageForWidth(nWidth
);
92 weld::CustomWidgetController::Resize();
95 void LoadImageForWidth(int nWidth
)
97 mbIsDark
= Application::GetSettings().GetStyleSettings().GetDialogColor().IsDark();
98 SfxApplication::loadBrandSvg(mbIsDark
? "shell/logo-sc_inverted" : "shell/logo-sc",
99 maBrandImage
, nWidth
);
102 void ConfigureForWidth(int nWidth
)
104 if (maBrandImage
.GetSizePixel().Width() == nWidth
)
106 LoadImageForWidth(nWidth
);
107 m_BmpSize
= maBrandImage
.GetSizePixel();
108 set_size_request(m_BmpSize
.Width(), m_BmpSize
.Height());
111 virtual void StyleUpdated() override
113 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
115 // tdf#141857 update background to current theme
116 OutputDevice
& rDevice
= GetDrawingArea()->get_ref_device();
117 rDevice
.SetBackground(Wallpaper(rStyleSettings
.GetWindowColor()));
119 const bool bIsDark
= rStyleSettings
.GetDialogColor().IsDark();
120 if (bIsDark
!= mbIsDark
)
121 LoadImageForWidth(GetOutputSizePixel().Width());
122 weld::CustomWidgetController::StyleUpdated();
125 virtual bool MouseButtonUp(const MouseEvent
& rMEvt
) override
129 OUString sURL
= officecfg::Office::Common::Menus::ReleaseNotesURL::get();
130 // localizeWebserviceURI(sURL);
132 Reference
<css::system::XSystemShellExecute
> const xSystemShellExecute(
133 css::system::SystemShellExecute::create(
134 ::comphelper::getProcessComponentContext()));
135 xSystemShellExecute
->execute(sURL
, OUString(),
136 css::system::SystemShellExecuteFlags::URIS_ONLY
);
141 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
143 rRenderContext
.DrawBitmapEx(Point(0, 0), maBrandImage
);
147 // increase size of the text in the buttons on the left fMultiplier-times
148 float const g_fMultiplier
= 1.2f
;
150 BackingWindow::BackingWindow(vcl::Window
* i_pParent
)
151 : InterimItemWindow(i_pParent
, "sfx/ui/startcenter.ui", "StartCenter", false)
152 , mxOpenButton(m_xBuilder
->weld_button("open_all"))
153 , mxRecentButton(m_xBuilder
->weld_toggle_button("open_recent"))
154 , mxRemoteButton(m_xBuilder
->weld_button("open_remote"))
155 , mxTemplateButton(m_xBuilder
->weld_toggle_button("templates_all"))
156 , mxCreateLabel(m_xBuilder
->weld_label("create_label"))
157 , mxAltHelpLabel(m_xBuilder
->weld_label("althelplabel"))
158 , mxFilter(m_xBuilder
->weld_combo_box("cbFilter"))
159 , mxActions(m_xBuilder
->weld_menu_button("mbActions"))
160 , mxWriterAllButton(m_xBuilder
->weld_button("writer_all"))
161 , mxCalcAllButton(m_xBuilder
->weld_button("calc_all"))
162 , mxImpressAllButton(m_xBuilder
->weld_button("impress_all"))
163 , mxDrawAllButton(m_xBuilder
->weld_button("draw_all"))
164 , mxDBAllButton(m_xBuilder
->weld_button("database_all"))
165 , mxMathAllButton(m_xBuilder
->weld_button("math_all"))
166 , mxBrandImage(new BrandImage
)
167 , mxBrandImageWeld(new weld::CustomWeld(*m_xBuilder
, "daBrand", *mxBrandImage
))
168 , mxHelpButton(m_xBuilder
->weld_button("help"))
169 , mxExtensionsButton(m_xBuilder
->weld_button("extensions"))
170 , mxAllButtonsBox(m_xBuilder
->weld_container("all_buttons_box"))
171 , mxButtonsBox(m_xBuilder
->weld_container("buttons_box"))
172 , mxSmallButtonsBox(m_xBuilder
->weld_container("small_buttons_box"))
173 , mxAllRecentThumbnails(new sfx2::RecentDocsView(m_xBuilder
->weld_scrolled_window("scrollrecent", true),
174 m_xBuilder
->weld_menu("recentmenu")))
175 , mxAllRecentThumbnailsWin(new weld::CustomWeld(*m_xBuilder
, "all_recent", *mxAllRecentThumbnails
))
176 , mxLocalView(new TemplateDefaultView(m_xBuilder
->weld_scrolled_window("scrolllocal", true),
177 m_xBuilder
->weld_menu("localmenu")))
178 , mxLocalViewWin(new weld::CustomWeld(*m_xBuilder
, "local_view", *mxLocalView
))
179 , mbLocalViewInitialized(false)
180 , mbInitControls(false)
182 // init background, undo InterimItemWindow defaults for this widget
183 SetPaintTransparent(false);
185 // square action button
186 auto nHeight
= mxFilter
->get_preferred_size().getHeight();
187 mxActions
->set_size_request(nHeight
, nHeight
);
189 //set an alternative help label that doesn't hotkey the H of the Help menu
190 mxHelpButton
->set_label(mxAltHelpLabel
->get_label());
191 mxHelpButton
->connect_clicked(LINK(this, BackingWindow
, ClickHelpHdl
));
193 mxDropTarget
= mxAllRecentThumbnails
->GetDropTarget();
197 mxContext
.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW
);
199 catch (const Exception
&)
201 TOOLS_WARN_EXCEPTION( "fwk", "BackingWindow" );
204 SetStyle( GetStyle() | WB_DIALOGCONTROL
);
206 // get dispatch provider
207 Reference
<XDesktop2
> xDesktop
= Desktop::create( comphelper::getProcessComponentContext() );
208 mxDesktopDispatchProvider
= xDesktop
;
212 IMPL_LINK(BackingWindow
, ClickHelpHdl
, weld::Button
&, rButton
, void)
214 if (Help
* pHelp
= Application::GetHelp())
215 pHelp
->Start(m_xContainer
->get_help_id(), &rButton
);
218 BackingWindow::~BackingWindow()
223 void BackingWindow::dispose()
225 // deregister drag&drop helper
226 if (mxDropTargetListener
.is())
228 if (mxDropTarget
.is())
230 mxDropTarget
->removeDropTargetListener(mxDropTargetListener
);
231 mxDropTarget
->setActive(false);
233 mxDropTargetListener
.clear();
235 mxDropTarget
.clear();
236 mxOpenButton
.reset();
237 mxRemoteButton
.reset();
238 mxRecentButton
.reset();
239 mxTemplateButton
.reset();
240 mxCreateLabel
.reset();
241 mxAltHelpLabel
.reset();
244 mxWriterAllButton
.reset();
245 mxCalcAllButton
.reset();
246 mxImpressAllButton
.reset();
247 mxDrawAllButton
.reset();
248 mxDBAllButton
.reset();
249 mxMathAllButton
.reset();
250 mxBrandImageWeld
.reset();
251 mxBrandImage
.reset();
252 mxHelpButton
.reset();
253 mxExtensionsButton
.reset();
254 mxAllButtonsBox
.reset();
255 mxButtonsBox
.reset();
256 mxSmallButtonsBox
.reset();
257 mxAllRecentThumbnailsWin
.reset();
258 mxAllRecentThumbnails
.reset();
259 mxLocalViewWin
.reset();
261 InterimItemWindow::dispose();
264 void BackingWindow::initControls()
269 mbInitControls
= true;
271 // collect the URLs of the entries in the File/New menu
272 SvtModuleOptions aModuleOptions
;
274 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::WRITER
))
275 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_WRITER
;
277 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::CALC
))
278 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_CALC
;
280 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::IMPRESS
))
281 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_IMPRESS
;
283 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::DRAW
))
284 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_DRAW
;
286 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::DATABASE
))
287 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_DATABASE
;
289 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::MATH
))
290 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_MATH
;
292 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_OTHER
;
293 mxAllRecentThumbnails
->Reload();
294 mxAllRecentThumbnails
->ShowTooltips( true );
296 mxRecentButton
->set_active(true);
297 ToggleHdl(*mxRecentButton
);
300 mxLocalView
->setCreateContextMenuHdl(LINK(this, BackingWindow
, CreateContextMenuHdl
));
301 mxLocalView
->setOpenTemplateHdl(LINK(this, BackingWindow
, OpenTemplateHdl
));
302 mxLocalView
->setEditTemplateHdl(LINK(this, BackingWindow
, EditTemplateHdl
));
303 mxLocalView
->ShowTooltips( true );
305 checkInstalledModules();
307 mxExtensionsButton
->connect_clicked(LINK(this, BackingWindow
, ExtLinkClickHdl
));
309 mxOpenButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
310 mxRemoteButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
311 mxWriterAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
312 mxDrawAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
313 mxCalcAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
314 mxDBAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
315 mxImpressAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
316 mxMathAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
318 mxRecentButton
->connect_toggled(LINK(this, BackingWindow
, ToggleHdl
));
319 mxTemplateButton
->connect_toggled(LINK(this, BackingWindow
, ToggleHdl
));
321 mxFilter
->connect_changed(LINK(this, BackingWindow
, FilterHdl
));
322 mxActions
->connect_selected(LINK(this, BackingWindow
, MenuSelectHdl
));
324 ApplyStyleSettings();
327 void BackingWindow::DataChanged(const DataChangedEvent
& rDCEvt
)
329 if ((rDCEvt
.GetType() != DataChangedEventType::SETTINGS
)
330 || !(rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
))
332 InterimItemWindow::DataChanged(rDCEvt
);
336 ApplyStyleSettings();
340 template <typename WidgetClass
>
341 void BackingWindow::setLargerFont(WidgetClass
& pWidget
, const vcl::Font
& rFont
)
343 vcl::Font
aFont(rFont
);
344 aFont
.SetFontSize(Size(0, aFont
.GetFontSize().Height() * g_fMultiplier
));
345 pWidget
->set_font(aFont
);
348 void BackingWindow::ApplyStyleSettings()
350 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
351 const Color
aButtonsBackground(rStyleSettings
.GetWindowColor());
352 const vcl::Font
& aButtonFont(rStyleSettings
.GetPushButtonFont());
353 const vcl::Font
& aLabelFont(rStyleSettings
.GetLabelFont());
355 // setup larger fonts
356 setLargerFont(mxOpenButton
, aButtonFont
);
357 setLargerFont(mxOpenButton
, aButtonFont
);
358 setLargerFont(mxRemoteButton
, aButtonFont
);
359 setLargerFont(mxRecentButton
, aButtonFont
);
360 setLargerFont(mxTemplateButton
, aButtonFont
);
361 setLargerFont(mxWriterAllButton
, aButtonFont
);
362 setLargerFont(mxDrawAllButton
, aButtonFont
);
363 setLargerFont(mxCalcAllButton
, aButtonFont
);
364 setLargerFont(mxDBAllButton
, aButtonFont
);
365 setLargerFont(mxImpressAllButton
, aButtonFont
);
366 setLargerFont(mxMathAllButton
, aButtonFont
);
367 setLargerFont(mxCreateLabel
, aLabelFont
);
369 mxAllButtonsBox
->set_background(aButtonsBackground
);
370 mxSmallButtonsBox
->set_background(aButtonsBackground
);
371 SetBackground(aButtonsBackground
);
373 // compute the menubar height
374 sal_Int32 nMenuHeight
= 0;
375 if (SystemWindow
* pSystemWindow
= GetSystemWindow())
376 nMenuHeight
= pSystemWindow
->GetMenuBarHeight();
378 // fdo#34392: we do the layout dynamically, the layout depends on the font,
379 // so we should handle data changed events (font changing) of the last child
380 // control, at this point all the controls have updated settings (i.e. font).
381 Size
aPrefSize(mxAllButtonsBox
->get_preferred_size());
382 set_width_request(aPrefSize
.Width());
384 // Now set a brand image wide enough to fill this width
385 weld::DrawingArea
* pDrawingArea
= mxBrandImage
->GetDrawingArea();
386 mxBrandImage
->ConfigureForWidth(aPrefSize
.Width() -
387 (pDrawingArea
->get_margin_start() + pDrawingArea
->get_margin_end()));
388 // Refetch because the brand image height to match this width is now set
389 aPrefSize
= mxAllButtonsBox
->get_preferred_size();
391 set_height_request(nMenuHeight
+ aPrefSize
.Height() + mxBrandImage
->getSize().getHeight());
394 void BackingWindow::initializeLocalView()
396 if (!mbLocalViewInitialized
)
398 mbLocalViewInitialized
= true;
399 mxLocalView
->Populate();
400 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE
));
401 mxLocalView
->showAllTemplates();
405 void BackingWindow::checkInstalledModules()
407 SvtModuleOptions aModuleOpt
;
409 mxWriterAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::WRITER
));
410 mxCalcAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::CALC
) );
411 mxImpressAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS
) );
412 mxDrawAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::DRAW
) );
413 mxMathAllButton
->set_sensitive(aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::MATH
));
414 mxDBAllButton
->set_sensitive(aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::DATABASE
));
417 bool BackingWindow::PreNotify(NotifyEvent
& rNEvt
)
419 if( rNEvt
.GetType() == NotifyEventType::KEYINPUT
)
421 const KeyEvent
* pEvt
= rNEvt
.GetKeyEvent();
422 const vcl::KeyCode
& rKeyCode(pEvt
->GetKeyCode());
424 bool bThumbnailHasFocus
= mxAllRecentThumbnails
->HasFocus() || mxLocalView
->HasFocus();
426 // Subwindows of BackingWindow: Sidebar and Thumbnail view
427 if( rKeyCode
.GetCode() == KEY_F6
)
429 if( rKeyCode
.IsShift() ) // Shift + F6
431 if (bThumbnailHasFocus
)
433 mxOpenButton
->grab_focus();
437 else if ( rKeyCode
.IsMod1() ) // Ctrl + F6
439 if(mxAllRecentThumbnails
->IsVisible())
441 mxAllRecentThumbnails
->GrabFocus();
444 else if(mxLocalView
->IsVisible())
446 mxLocalView
->GrabFocus();
452 if (!bThumbnailHasFocus
)
454 if(mxAllRecentThumbnails
->IsVisible())
456 mxAllRecentThumbnails
->GrabFocus();
459 else if(mxLocalView
->IsVisible())
461 mxLocalView
->GrabFocus();
468 // try the 'normal' accelerators (so that eg. Ctrl+Q works)
471 mpAccExec
= svt::AcceleratorExecute::createAcceleratorHelper();
472 mpAccExec
->init( comphelper::getProcessComponentContext(), mxFrame
);
475 const OUString aCommand
= mpAccExec
->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode
));
476 if ((aCommand
!= "vnd.sun.star.findbar:FocusToFindbar") && pEvt
&& mpAccExec
->execute(rKeyCode
))
479 return InterimItemWindow::PreNotify( rNEvt
);
482 void BackingWindow::GetFocus()
484 GetFocusFlags nFlags
= GetParent()->GetGetFocusFlags();
485 if( nFlags
& GetFocusFlags::F6
)
487 if( nFlags
& GetFocusFlags::Forward
) // F6
489 mxOpenButton
->grab_focus();
492 else // Shift + F6 or Ctrl + F6
494 if(mxAllRecentThumbnails
->IsVisible())
495 mxAllRecentThumbnails
->GrabFocus();
496 else if(mxLocalView
->IsVisible())
497 mxLocalView
->GrabFocus();
501 InterimItemWindow::GetFocus();
504 void BackingWindow::setOwningFrame( const css::uno::Reference
< css::frame::XFrame
>& xFrame
)
507 if( ! mbInitControls
)
510 // establish drag&drop mode
511 mxDropTargetListener
.set(new OpenFileDropTargetListener(mxContext
, mxFrame
));
513 if (mxDropTarget
.is())
515 mxDropTarget
->addDropTargetListener(mxDropTargetListener
);
516 mxDropTarget
->setActive(true);
519 css::uno::Reference
<XFramesSupplier
> xFramesSupplier(mxDesktopDispatchProvider
, UNO_QUERY
);
521 xFramesSupplier
->setActiveFrame(mxFrame
);
524 IMPL_LINK(BackingWindow
, ExtLinkClickHdl
, weld::Button
&, rButton
,void)
526 if (&rButton
!= mxExtensionsButton
.get())
531 uno::Sequence
<uno::Any
> args(comphelper::InitAnyPropertySequence(
533 {"nodepath", uno::Any(OUString("/org.openoffice.Office.Common/Help/StartCenter"))}
536 Reference
<lang::XMultiServiceFactory
> xConfig
= configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
537 Reference
<container::XNameAccess
> xNameAccess(xConfig
->createInstanceWithArguments(SERVICENAME_CFGREADACCESS
, args
), UNO_QUERY
);
538 if (xNameAccess
.is())
540 OUString
sURL(officecfg::Office::Common::Menus::ExtensionsURL::get() +
541 "?LOvers=" + utl::ConfigManager::getProductVersion() +
542 "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47() );
544 Reference
<css::system::XSystemShellExecute
> const
546 css::system::SystemShellExecute::create(
547 ::comphelper::getProcessComponentContext()));
548 xSystemShellExecute
->execute(sURL
, OUString(),
549 css::system::SystemShellExecuteFlags::URIS_ONLY
);
552 catch (const Exception
&)
557 void BackingWindow::applyFilter()
559 const int nFilter
= mxFilter
->get_active();
560 if (mxLocalView
->IsVisible())
562 FILTER_APPLICATION aFilter
= static_cast<FILTER_APPLICATION
>(nFilter
);
563 mxLocalView
->filterItems(ViewFilter_Application(aFilter
));
567 sfx2::ApplicationType aFilter
;
569 aFilter
= sfx2::ApplicationType::TYPE_NONE
;
571 aFilter
= static_cast<sfx2::ApplicationType
>(1 << (nFilter
- 1));
572 mxAllRecentThumbnails
->setFilter(aFilter
);
576 IMPL_LINK_NOARG( BackingWindow
, FilterHdl
, weld::ComboBox
&, void )
581 IMPL_LINK( BackingWindow
, ToggleHdl
, weld::Toggleable
&, rButton
, void )
584 if (&rButton
== mxRecentButton
.get())
585 bRecentMode
= rButton
.get_active();
587 bRecentMode
= !rButton
.get_active();
592 mxAllRecentThumbnails
->Show();
593 mxAllRecentThumbnails
->GrabFocus();
594 mxRecentButton
->set_active(true);
595 mxTemplateButton
->set_active(false);
600 mxAllRecentThumbnails
->Hide();
601 initializeLocalView();
603 mxLocalView
->reload();
604 mxLocalView
->GrabFocus();
605 mxRecentButton
->set_active(false);
606 mxTemplateButton
->set_active(true);
612 IMPL_LINK( BackingWindow
, ClickHdl
, weld::Button
&, rButton
, void )
614 // dispatch the appropriate URL and end the dialog
615 if( &rButton
== mxWriterAllButton
.get() )
616 dispatchURL( "private:factory/swriter" );
617 else if( &rButton
== mxCalcAllButton
.get() )
618 dispatchURL( "private:factory/scalc" );
619 else if( &rButton
== mxImpressAllButton
.get() )
620 dispatchURL( "private:factory/simpress?slot=6686" );
621 else if( &rButton
== mxDrawAllButton
.get() )
622 dispatchURL( "private:factory/sdraw" );
623 else if( &rButton
== mxDBAllButton
.get() )
624 dispatchURL( "private:factory/sdatabase?Interactive" );
625 else if( &rButton
== mxMathAllButton
.get() )
626 dispatchURL( "private:factory/smath" );
627 else if( &rButton
== mxOpenButton
.get() )
629 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
631 dispatchURL( ".uno:Open", OUString(), xFrame
, { comphelper::makePropertyValue("Referer", OUString("private:user")) } );
633 else if( &rButton
== mxRemoteButton
.get() )
635 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
637 dispatchURL( ".uno:OpenRemote", OUString(), xFrame
, {} );
641 IMPL_LINK (BackingWindow
, MenuSelectHdl
, const OUString
&, rId
, void)
643 if (rId
== "clear_all")
645 SvtHistoryOptions::Clear(EHistoryType::PickList
, false);
646 mxAllRecentThumbnails
->Reload();
649 else if(rId
== "clear_unavailable")
651 mxAllRecentThumbnails
->clearUnavailableFiles();
655 IMPL_LINK(BackingWindow
, CreateContextMenuHdl
, ThumbnailViewItem
*, pItem
, void)
657 const TemplateViewItem
*pViewItem
= dynamic_cast<TemplateViewItem
*>(pItem
);
660 mxLocalView
->createContextMenu();
663 IMPL_LINK(BackingWindow
, OpenTemplateHdl
, ThumbnailViewItem
*, pItem
, void)
665 uno::Sequence
< PropertyValue
> aArgs
{
666 comphelper::makePropertyValue("AsTemplate", true),
667 comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG
),
668 comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG
),
669 comphelper::makePropertyValue("InteractionHandler", task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr ))
672 TemplateViewItem
*pTemplateItem
= static_cast<TemplateViewItem
*>(pItem
);
674 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
678 dispatchURL( pTemplateItem
->getPath(), "_default", xFrame
, aArgs
);
680 catch( const uno::Exception
& )
685 IMPL_LINK(BackingWindow
, EditTemplateHdl
, ThumbnailViewItem
*, pItem
, void)
687 uno::Sequence
< PropertyValue
> aArgs
{
688 comphelper::makePropertyValue("AsTemplate", false),
689 comphelper::makePropertyValue("MacroExecutionMode", MacroExecMode::USE_CONFIG
),
690 comphelper::makePropertyValue("UpdateDocMode", UpdateDocMode::ACCORDING_TO_CONFIG
),
693 TemplateViewItem
*pViewItem
= static_cast<TemplateViewItem
*>(pItem
);
695 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
699 dispatchURL( pViewItem
->getPath(), "_default", xFrame
, aArgs
);
701 catch( const uno::Exception
& )
708 struct ImplDelayedDispatch
710 Reference
< XDispatch
> xDispatch
;
711 css::util::URL aDispatchURL
;
712 Sequence
< PropertyValue
> aArgs
;
714 ImplDelayedDispatch( const Reference
< XDispatch
>& i_xDispatch
,
715 css::util::URL i_aURL
,
716 const Sequence
< PropertyValue
>& i_rArgs
)
717 : xDispatch( i_xDispatch
),
718 aDispatchURL(std::move( i_aURL
)),
726 static void implDispatchDelayed( void*, void* pArg
)
728 struct ImplDelayedDispatch
* pDispatch
= static_cast<ImplDelayedDispatch
*>(pArg
);
731 pDispatch
->xDispatch
->dispatch( pDispatch
->aDispatchURL
, pDispatch
->aArgs
);
733 catch (const Exception
&)
741 void BackingWindow::dispatchURL( const OUString
& i_rURL
,
742 const OUString
& rTarget
,
743 const Reference
< XDispatchProvider
>& i_xProv
,
744 const Sequence
< PropertyValue
>& i_rArgs
)
746 // if no special dispatch provider is given, get the desktop
747 Reference
< XDispatchProvider
> xProvider( i_xProv
.is() ? i_xProv
: mxDesktopDispatchProvider
);
749 // check for dispatch provider
753 // get a URL transformer to clean up the URL
754 css::util::URL aDispatchURL
;
755 aDispatchURL
.Complete
= i_rURL
;
757 Reference
< css::util::XURLTransformer
> xURLTransformer(
758 css::util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
762 xURLTransformer
->parseStrict( aDispatchURL
);
763 // get a Dispatch for the URL and target
764 Reference
< XDispatch
> xDispatch(
765 xProvider
->queryDispatch( aDispatchURL
, rTarget
, 0 )
768 if ( xDispatch
.is() )
770 std::unique_ptr
<ImplDelayedDispatch
> pDisp(new ImplDelayedDispatch( xDispatch
, std::move(aDispatchURL
), i_rArgs
));
771 if( Application::PostUserEvent( Link
<void*,void>( nullptr, implDispatchDelayed
), pDisp
.get() ) )
775 catch (const css::uno::RuntimeException
&)
779 catch (const css::uno::Exception
&)
784 void BackingWindow::clearRecentFileList()
786 mxAllRecentThumbnails
->Clear();
788 /* vim:set shiftwidth=4 softtabstop=4 expandtab:*/