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"
21 #include <vcl/event.hxx>
22 #include <vcl/help.hxx>
23 #include <vcl/ptrstyle.hxx>
24 #include <vcl/settings.hxx>
25 #include <vcl/svapp.hxx>
26 #include <vcl/syswin.hxx>
27 #include <vcl/virdev.hxx>
29 #include <unotools/historyoptions.hxx>
30 #include <unotools/moduleoptions.hxx>
31 #include <svtools/openfiledroptargetlistener.hxx>
32 #include <svtools/colorcfg.hxx>
33 #include <svtools/langhelp.hxx>
34 #include <templateviewitem.hxx>
36 #include <comphelper/processfactory.hxx>
37 #include <comphelper/propertysequence.hxx>
38 #include <comphelper/propertyvalue.hxx>
39 #include <sfx2/app.hxx>
40 #include <officecfg/Office/Common.hxx>
42 #include <tools/diagnose_ex.h>
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>
56 using namespace ::com::sun::star
;
57 using namespace ::com::sun::star::beans
;
58 using namespace ::com::sun::star::frame
;
59 using namespace ::com::sun::star::uno
;
60 using namespace ::com::sun::star::document
;
62 constexpr OUStringLiteral SERVICENAME_CFGREADACCESS
= u
"com.sun.star.configuration.ConfigurationAccess";
64 class BrandImage final
: public weld::CustomWidgetController
67 BitmapEx maBrandImage
;
68 bool mbIsDark
= false;
72 Size
getSize() { return m_BmpSize
; }
74 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
76 weld::CustomWidgetController::SetDrawingArea(pDrawingArea
);
77 SetPointer(PointerStyle::RefHand
);
80 virtual void Resize() override
82 auto nWidth
= GetOutputSizePixel().Width();
83 if (maBrandImage
.GetSizePixel().Width() != nWidth
)
84 LoadImageForWidth(nWidth
);
85 weld::CustomWidgetController::Resize();
88 void LoadImageForWidth(int nWidth
)
90 mbIsDark
= Application::GetSettings().GetStyleSettings().GetDialogColor().IsDark();
91 SfxApplication::loadBrandSvg(mbIsDark
? "shell/logo-sc_inverted" : "shell/logo-sc",
92 maBrandImage
, nWidth
);
95 void ConfigureForWidth(int nWidth
)
97 if (maBrandImage
.GetSizePixel().Width() == nWidth
)
99 LoadImageForWidth(nWidth
);
100 m_BmpSize
= maBrandImage
.GetSizePixel();
101 set_size_request(m_BmpSize
.Width(), m_BmpSize
.Height());
104 virtual void StyleUpdated() override
106 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
108 // tdf#141857 update background to current theme
109 OutputDevice
& rDevice
= GetDrawingArea()->get_ref_device();
110 rDevice
.SetBackground(Wallpaper(rStyleSettings
.GetWindowColor()));
112 const bool bIsDark
= rStyleSettings
.GetDialogColor().IsDark();
113 if (bIsDark
!= mbIsDark
)
114 LoadImageForWidth(GetOutputSizePixel().Width());
115 weld::CustomWidgetController::StyleUpdated();
118 virtual bool MouseButtonUp(const MouseEvent
& rMEvt
) override
122 OUString sURL
= officecfg::Office::Common::Menus::VolunteerURL::get();
123 localizeWebserviceURI(sURL
);
125 Reference
<css::system::XSystemShellExecute
> const xSystemShellExecute(
126 css::system::SystemShellExecute::create(
127 ::comphelper::getProcessComponentContext()));
128 xSystemShellExecute
->execute(sURL
, OUString(),
129 css::system::SystemShellExecuteFlags::URIS_ONLY
);
134 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
136 rRenderContext
.DrawBitmapEx(Point(0, 0), maBrandImage
);
140 // increase size of the text in the buttons on the left fMultiplier-times
141 float const g_fMultiplier
= 1.2f
;
143 BackingWindow::BackingWindow(vcl::Window
* i_pParent
)
144 : InterimItemWindow(i_pParent
, "sfx/ui/startcenter.ui", "StartCenter", false)
145 , mxOpenButton(m_xBuilder
->weld_button("open_all"))
146 , mxRecentButton(m_xBuilder
->weld_menu_toggle_button("open_recent"))
147 , mxRemoteButton(m_xBuilder
->weld_button("open_remote"))
148 , mxTemplateButton(m_xBuilder
->weld_menu_toggle_button("templates_all"))
149 , mxCreateLabel(m_xBuilder
->weld_label("create_label"))
150 , mxAltHelpLabel(m_xBuilder
->weld_label("althelplabel"))
151 , mxWriterAllButton(m_xBuilder
->weld_button("writer_all"))
152 , mxCalcAllButton(m_xBuilder
->weld_button("calc_all"))
153 , mxImpressAllButton(m_xBuilder
->weld_button("impress_all"))
154 , mxDrawAllButton(m_xBuilder
->weld_button("draw_all"))
155 , mxDBAllButton(m_xBuilder
->weld_button("database_all"))
156 , mxMathAllButton(m_xBuilder
->weld_button("math_all"))
157 , mxBrandImage(new BrandImage
)
158 , mxBrandImageWeld(new weld::CustomWeld(*m_xBuilder
, "daBrand", *mxBrandImage
))
159 , mxHelpButton(m_xBuilder
->weld_button("help"))
160 , mxExtensionsButton(m_xBuilder
->weld_button("extensions"))
161 , mxAllButtonsBox(m_xBuilder
->weld_container("all_buttons_box"))
162 , mxButtonsBox(m_xBuilder
->weld_container("buttons_box"))
163 , mxSmallButtonsBox(m_xBuilder
->weld_container("small_buttons_box"))
164 , mxAllRecentThumbnails(new sfx2::RecentDocsView(m_xBuilder
->weld_scrolled_window("scrollrecent", true),
165 m_xBuilder
->weld_menu("recentmenu")))
166 , mxAllRecentThumbnailsWin(new weld::CustomWeld(*m_xBuilder
, "all_recent", *mxAllRecentThumbnails
))
167 , mxLocalView(new TemplateDefaultView(m_xBuilder
->weld_scrolled_window("scrolllocal", true),
168 m_xBuilder
->weld_menu("localmenu")))
169 , mxLocalViewWin(new weld::CustomWeld(*m_xBuilder
, "local_view", *mxLocalView
))
170 , mbLocalViewInitialized(false)
171 , mbInitControls(false)
174 SetPaintTransparent(false);
175 SetBackground(svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND
).nColor
);
177 //set an alternative help label that doesn't hotkey the H of the Help menu
178 mxHelpButton
->set_label(mxAltHelpLabel
->get_label());
179 mxHelpButton
->connect_clicked(LINK(this, BackingWindow
, ClickHelpHdl
));
181 mxDropTarget
= mxAllRecentThumbnails
->GetDropTarget();
185 mxContext
.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW
);
187 catch (const Exception
&)
189 TOOLS_WARN_EXCEPTION( "fwk", "BackingWindow" );
192 SetStyle( GetStyle() | WB_DIALOGCONTROL
);
194 // get dispatch provider
195 Reference
<XDesktop2
> xDesktop
= Desktop::create( comphelper::getProcessComponentContext() );
196 mxDesktopDispatchProvider
= xDesktop
;
200 IMPL_LINK(BackingWindow
, ClickHelpHdl
, weld::Button
&, rButton
, void)
202 if (Help
* pHelp
= Application::GetHelp())
203 pHelp
->Start(OUString::fromUtf8(m_xContainer
->get_help_id()), &rButton
);
206 BackingWindow::~BackingWindow()
211 void BackingWindow::dispose()
213 // deregister drag&drop helper
214 if (mxDropTargetListener
.is())
216 if (mxDropTarget
.is())
218 mxDropTarget
->removeDropTargetListener(mxDropTargetListener
);
219 mxDropTarget
->setActive(false);
221 mxDropTargetListener
.clear();
223 mxDropTarget
.clear();
224 mxOpenButton
.reset();
225 mxRemoteButton
.reset();
226 mxRecentButton
.reset();
227 mxTemplateButton
.reset();
228 mxCreateLabel
.reset();
229 mxAltHelpLabel
.reset();
230 mxWriterAllButton
.reset();
231 mxCalcAllButton
.reset();
232 mxImpressAllButton
.reset();
233 mxDrawAllButton
.reset();
234 mxDBAllButton
.reset();
235 mxMathAllButton
.reset();
236 mxBrandImageWeld
.reset();
237 mxBrandImage
.reset();
238 mxHelpButton
.reset();
239 mxExtensionsButton
.reset();
240 mxAllButtonsBox
.reset();
241 mxButtonsBox
.reset();
242 mxSmallButtonsBox
.reset();
243 mxAllRecentThumbnailsWin
.reset();
244 mxAllRecentThumbnails
.reset();
245 mxLocalViewWin
.reset();
247 InterimItemWindow::dispose();
250 void BackingWindow::initControls()
255 mbInitControls
= true;
257 // collect the URLs of the entries in the File/New menu
258 SvtModuleOptions aModuleOptions
;
260 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::WRITER
))
261 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_WRITER
;
263 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::CALC
))
264 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_CALC
;
266 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::IMPRESS
))
267 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_IMPRESS
;
269 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::DRAW
))
270 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_DRAW
;
272 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::DATABASE
))
273 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_DATABASE
;
275 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::MATH
))
276 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_MATH
;
278 mxAllRecentThumbnails
->mnFileTypes
|= sfx2::ApplicationType::TYPE_OTHER
;
279 mxAllRecentThumbnails
->Reload();
280 mxAllRecentThumbnails
->ShowTooltips( true );
281 mxRecentButton
->set_active(true);
282 mxRecentButton
->grab_focus();
284 //initialize Template view
288 mxLocalView
->setCreateContextMenuHdl(LINK(this, BackingWindow
, CreateContextMenuHdl
));
289 mxLocalView
->setOpenTemplateHdl(LINK(this, BackingWindow
, OpenTemplateHdl
));
290 mxLocalView
->setEditTemplateHdl(LINK(this, BackingWindow
, EditTemplateHdl
));
291 mxLocalView
->ShowTooltips( true );
293 checkInstalledModules();
295 mxExtensionsButton
->connect_clicked(LINK(this, BackingWindow
, ExtLinkClickHdl
));
297 mxOpenButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
298 mxRemoteButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
299 mxRecentButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
300 mxTemplateButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
301 mxWriterAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
302 mxDrawAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
303 mxCalcAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
304 mxDBAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
305 mxImpressAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
306 mxMathAllButton
->connect_clicked(LINK(this, BackingWindow
, ClickHdl
));
308 mxRecentButton
->connect_selected(LINK(this, BackingWindow
, MenuSelectHdl
));
309 mxTemplateButton
->connect_selected(LINK(this, BackingWindow
, MenuSelectHdl
));
311 ApplyStyleSettings();
314 void BackingWindow::DataChanged(const DataChangedEvent
& rDCEvt
)
316 if ((rDCEvt
.GetType() != DataChangedEventType::SETTINGS
)
317 || !(rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
))
319 InterimItemWindow::DataChanged(rDCEvt
);
323 ApplyStyleSettings();
327 template <typename WidgetClass
>
328 void BackingWindow::setLargerFont(WidgetClass
& pWidget
, const vcl::Font
& rFont
)
330 vcl::Font
aFont(rFont
);
331 aFont
.SetFontSize(Size(0, aFont
.GetFontSize().Height() * g_fMultiplier
));
332 pWidget
->set_font(aFont
);
335 void BackingWindow::ApplyStyleSettings()
337 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
338 const Color
aButtonsBackground(rStyleSettings
.GetWindowColor());
339 const vcl::Font
& aButtonFont(rStyleSettings
.GetPushButtonFont());
340 const vcl::Font
& aLabelFont(rStyleSettings
.GetLabelFont());
342 // setup larger fonts
343 setLargerFont(mxOpenButton
, aButtonFont
);
344 setLargerFont(mxOpenButton
, aButtonFont
);
345 setLargerFont(mxRemoteButton
, aButtonFont
);
346 setLargerFont(mxRecentButton
, aButtonFont
);
347 setLargerFont(mxTemplateButton
, aButtonFont
);
348 setLargerFont(mxWriterAllButton
, aButtonFont
);
349 setLargerFont(mxDrawAllButton
, aButtonFont
);
350 setLargerFont(mxCalcAllButton
, aButtonFont
);
351 setLargerFont(mxDBAllButton
, aButtonFont
);
352 setLargerFont(mxImpressAllButton
, aButtonFont
);
353 setLargerFont(mxMathAllButton
, aButtonFont
);
354 setLargerFont(mxCreateLabel
, aLabelFont
);
356 mxAllButtonsBox
->set_background(aButtonsBackground
);
357 mxSmallButtonsBox
->set_background(aButtonsBackground
);
359 // compute the menubar height
360 sal_Int32 nMenuHeight
= 0;
361 if (SystemWindow
* pSystemWindow
= GetSystemWindow())
362 nMenuHeight
= pSystemWindow
->GetMenuBarHeight();
364 // fdo#34392: we do the layout dynamically, the layout depends on the font,
365 // so we should handle data changed events (font changing) of the last child
366 // control, at this point all the controls have updated settings (i.e. font).
367 Size
aPrefSize(mxAllButtonsBox
->get_preferred_size());
368 set_width_request(aPrefSize
.Width());
370 // Now set a brand image wide enough to fill this width
371 weld::DrawingArea
* pDrawingArea
= mxBrandImage
->GetDrawingArea();
372 mxBrandImage
->ConfigureForWidth(aPrefSize
.Width() -
373 (pDrawingArea
->get_margin_start() + pDrawingArea
->get_margin_end()));
374 // Refetch because the brand image height to match this width is now set
375 aPrefSize
= mxAllButtonsBox
->get_preferred_size();
377 set_height_request(nMenuHeight
+ aPrefSize
.Height() + mxBrandImage
->getSize().getHeight());
380 void BackingWindow::initializeLocalView()
382 if (!mbLocalViewInitialized
)
384 mbLocalViewInitialized
= true;
385 mxLocalView
->Populate();
386 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE
));
387 mxLocalView
->showAllTemplates();
391 void BackingWindow::checkInstalledModules()
393 SvtModuleOptions aModuleOpt
;
395 mxWriterAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::WRITER
));
396 mxCalcAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::CALC
) );
397 mxImpressAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS
) );
398 mxDrawAllButton
->set_sensitive( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::DRAW
) );
399 mxMathAllButton
->set_sensitive(aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::MATH
));
400 mxDBAllButton
->set_sensitive(aModuleOpt
.IsModuleInstalled( SvtModuleOptions::EModule::DATABASE
));
403 bool BackingWindow::PreNotify(NotifyEvent
& rNEvt
)
405 if( rNEvt
.GetType() == MouseNotifyEvent::KEYINPUT
)
407 const KeyEvent
* pEvt
= rNEvt
.GetKeyEvent();
408 const vcl::KeyCode
& rKeyCode(pEvt
->GetKeyCode());
410 bool bThumbnailHasFocus
= mxAllRecentThumbnails
->HasFocus() || mxLocalView
->HasFocus();
412 // Subwindows of BackingWindow: Sidebar and Thumbnail view
413 if( rKeyCode
.GetCode() == KEY_F6
)
415 if( rKeyCode
.IsShift() ) // Shift + F6
417 if (bThumbnailHasFocus
)
419 mxOpenButton
->grab_focus();
423 else if ( rKeyCode
.IsMod1() ) // Ctrl + F6
425 if(mxAllRecentThumbnails
->IsVisible())
427 mxAllRecentThumbnails
->GrabFocus();
430 else if(mxLocalView
->IsVisible())
432 mxLocalView
->GrabFocus();
438 if (!bThumbnailHasFocus
)
440 if(mxAllRecentThumbnails
->IsVisible())
442 mxAllRecentThumbnails
->GrabFocus();
445 else if(mxLocalView
->IsVisible())
447 mxLocalView
->GrabFocus();
454 // try the 'normal' accelerators (so that eg. Ctrl+Q works)
457 mpAccExec
= svt::AcceleratorExecute::createAcceleratorHelper();
458 mpAccExec
->init( comphelper::getProcessComponentContext(), mxFrame
);
461 const OUString aCommand
= mpAccExec
->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode
));
462 if ((aCommand
!= "vnd.sun.star.findbar:FocusToFindbar") && pEvt
&& mpAccExec
->execute(rKeyCode
))
465 return InterimItemWindow::PreNotify( rNEvt
);
468 void BackingWindow::GetFocus()
470 GetFocusFlags nFlags
= GetParent()->GetGetFocusFlags();
471 if( nFlags
& GetFocusFlags::F6
)
473 if( nFlags
& GetFocusFlags::Forward
) // F6
475 mxOpenButton
->grab_focus();
478 else // Shift + F6 or Ctrl + F6
480 if(mxAllRecentThumbnails
->IsVisible())
481 mxAllRecentThumbnails
->GrabFocus();
482 else if(mxLocalView
->IsVisible())
483 mxLocalView
->GrabFocus();
487 InterimItemWindow::GetFocus();
490 void BackingWindow::setOwningFrame( const css::uno::Reference
< css::frame::XFrame
>& xFrame
)
493 if( ! mbInitControls
)
496 // establish drag&drop mode
497 mxDropTargetListener
.set(new OpenFileDropTargetListener(mxContext
, mxFrame
));
499 if (mxDropTarget
.is())
501 mxDropTarget
->addDropTargetListener(mxDropTargetListener
);
502 mxDropTarget
->setActive(true);
505 css::uno::Reference
<XFramesSupplier
> xFramesSupplier(mxDesktopDispatchProvider
, UNO_QUERY
);
507 xFramesSupplier
->setActiveFrame(mxFrame
);
510 IMPL_LINK(BackingWindow
, ExtLinkClickHdl
, weld::Button
&, rButton
, void)
514 if (&rButton
== mxExtensionsButton
.get())
515 aNode
= "AddFeatureURL";
522 uno::Sequence
<uno::Any
> args(comphelper::InitAnyPropertySequence(
524 {"nodepath", uno::Any(OUString("/org.openoffice.Office.Common/Help/StartCenter"))}
527 Reference
<lang::XMultiServiceFactory
> xConfig
= configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
528 Reference
<container::XNameAccess
> xNameAccess(xConfig
->createInstanceWithArguments(SERVICENAME_CFGREADACCESS
, args
), UNO_QUERY
);
529 if (xNameAccess
.is())
532 Any
value(xNameAccess
->getByName(aNode
));
534 sURL
= value
.get
<OUString
>();
535 localizeWebserviceURI(sURL
);
537 Reference
<css::system::XSystemShellExecute
> const
539 css::system::SystemShellExecute::create(
540 ::comphelper::getProcessComponentContext()));
541 xSystemShellExecute
->execute(sURL
, OUString(),
542 css::system::SystemShellExecuteFlags::URIS_ONLY
);
545 catch (const Exception
&)
550 IMPL_LINK( BackingWindow
, ClickHdl
, weld::Button
&, rButton
, void )
552 // dispatch the appropriate URL and end the dialog
553 if( &rButton
== mxWriterAllButton
.get() )
554 dispatchURL( "private:factory/swriter" );
555 else if( &rButton
== mxCalcAllButton
.get() )
556 dispatchURL( "private:factory/scalc" );
557 else if( &rButton
== mxImpressAllButton
.get() )
558 dispatchURL( "private:factory/simpress?slot=6686" );
559 else if( &rButton
== mxDrawAllButton
.get() )
560 dispatchURL( "private:factory/sdraw" );
561 else if( &rButton
== mxDBAllButton
.get() )
562 dispatchURL( "private:factory/sdatabase?Interactive" );
563 else if( &rButton
== mxMathAllButton
.get() )
564 dispatchURL( "private:factory/smath" );
565 else if( &rButton
== mxOpenButton
.get() )
567 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
569 Sequence
< css::beans::PropertyValue
> aArgs(1);
570 PropertyValue
* pArg
= aArgs
.getArray();
571 pArg
[0].Name
= "Referer";
572 pArg
[0].Value
<<= OUString("private:user");
574 dispatchURL( ".uno:Open", OUString(), xFrame
, aArgs
);
576 else if( &rButton
== mxRemoteButton
.get() )
578 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
580 Sequence
< css::beans::PropertyValue
> aArgs(0);
582 dispatchURL( ".uno:OpenRemote", OUString(), xFrame
, aArgs
);
584 else if( &rButton
== mxRecentButton
.get() )
587 mxAllRecentThumbnails
->Show();
588 mxAllRecentThumbnails
->GrabFocus();
589 mxRecentButton
->set_active(true);
590 mxTemplateButton
->set_active(false);
592 else if( &rButton
== mxTemplateButton
.get() )
594 mxAllRecentThumbnails
->Hide();
595 initializeLocalView();
596 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE
));
598 mxLocalView
->reload();
599 mxLocalView
->GrabFocus();
600 mxRecentButton
->set_active(false);
601 mxTemplateButton
->set_active(true);
605 IMPL_LINK (BackingWindow
, MenuSelectHdl
, const OString
&, rId
, void)
607 if (rId
== "clear_all")
609 SvtHistoryOptions::Clear(EHistoryType::PickList
);
610 mxAllRecentThumbnails
->Reload();
613 else if (!rId
.isEmpty())
615 initializeLocalView();
617 if( rId
== "filter_writer" )
619 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::WRITER
));
621 else if( rId
== "filter_calc" )
623 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::CALC
));
625 else if( rId
== "filter_impress" )
627 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::IMPRESS
));
629 else if( rId
== "filter_draw" )
631 mxLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::DRAW
));
633 else if( rId
== "manage" )
635 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
637 Sequence
< css::beans::PropertyValue
> aArgs(1);
638 PropertyValue
* pArg
= aArgs
.getArray();
639 pArg
[0].Name
= "Referer";
640 pArg
[0].Value
<<= OUString("private:user");
642 dispatchURL( ".uno:NewDoc", OUString(), xFrame
, aArgs
);
646 mxAllRecentThumbnails
->Hide();
648 mxLocalView
->reload();
649 mxLocalView
->GrabFocus();
650 mxRecentButton
->set_active(false);
651 mxTemplateButton
->set_active(true);
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 const css::util::URL
& i_rURL
,
716 const Sequence
< PropertyValue
>& i_rArgs
)
717 : xDispatch( i_xDispatch
),
718 aDispatchURL( i_rURL
),
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
, 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:*/