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 "inputdlg.hxx"
23 #include <vcl/settings.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/virdev.hxx>
27 #include <unotools/dynamicmenuoptions.hxx>
28 #include <svtools/openfiledroptargetlistener.hxx>
29 #include <svtools/colorcfg.hxx>
30 #include <svtools/langhelp.hxx>
31 #include <sfx2/filedlghelper.hxx>
32 #include <sfx2/sfxresid.hxx>
33 #include <sfx2/templatecontaineritem.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <vcl/toolbox.hxx>
37 #include <vcl/menubtn.hxx>
39 #include <comphelper/processfactory.hxx>
40 #include <comphelper/sequenceashashmap.hxx>
42 #include <toolkit/awt/vclxmenu.hxx>
44 #include <com/sun/star/configuration/theDefaultProvider.hpp>
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/document/MacroExecMode.hpp>
47 #include <com/sun/star/document/UpdateDocMode.hpp>
48 #include <com/sun/star/frame/Desktop.hpp>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/system/SystemShellExecute.hpp>
51 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
52 #include <com/sun/star/util/URLTransformer.hpp>
53 #include <com/sun/star/task/InteractionHandler.hpp>
54 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
56 #include <officecfg/Office/Common.hxx>
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 const char WRITER_URL
[] = "private:factory/swriter";
65 const char CALC_URL
[] = "private:factory/scalc";
66 const char IMPRESS_WIZARD_URL
[] = "private:factory/simpress?slot=6686";
67 const char DRAW_URL
[] = "private:factory/sdraw";
68 const char BASE_URL
[] = "private:factory/sdatabase?Interactive";
69 const char MATH_URL
[] = "private:factory/smath";
70 const char TEMPLATE_URL
[] = ".uno:NewDoc";
71 const char OPEN_URL
[] = ".uno:Open";
72 const char SERVICENAME_CFGREADACCESS
[] = "com.sun.star.configuration.ConfigurationAccess";
74 // increase size of the text in the buttons on the left fMultiplier-times
75 float fMultiplier
= 1.4f
;
79 * Order items in ascending order (useful for the selection sets and move/copy operations since the associated ids
80 * change when processed by the SfxDocumentTemplates class so we want to process to ones with higher id first)
84 static bool cmpSelectionItems (const ThumbnailViewItem
*pItem1
, const ThumbnailViewItem
*pItem2
)
86 return pItem1
->mnId
> pItem2
->mnId
;
90 BackingWindow::BackingWindow( vcl::Window
* i_pParent
) :
92 mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
93 mbLocalViewInitialized(false),
94 maButtonsTextColor(officecfg::Office::Common::Help::StartCenter::StartCenterTextColor::get()),
95 mbIsSaveMode( false ),
96 mbInitControls( false ),
97 mnHideExternalLinks( 0 ),
99 maSelTemplates(cmpSelectionItems
),
100 maSelFolders(cmpSelectionItems
)
103 m_pUIBuilder
= new VclBuilder(this, getUIRootDir(), "sfx/ui/startcenter.ui", "StartCenter" );
105 get(mpOpenButton
, "open_all");
106 get(mpRecentButton
, "open_recent");
107 get(mpTemplateButton
, "templates_all");
109 get(mpCreateLabel
, "create_label");
111 get(mpWriterAllButton
, "writer_all");
112 get(mpCalcAllButton
, "calc_all");
113 get(mpImpressAllButton
, "impress_all");
114 get(mpDrawAllButton
, "draw_all");
115 get(mpDBAllButton
, "database_all");
116 get(mpMathAllButton
, "math_all");
118 get(mpHelpButton
, "help");
119 //set an alternative help label that doesn't hotkey the H of the Help menu
120 mpHelpButton
->SetText(get
<Window
>("althelplabel")->GetText());
121 get(mpExtensionsButton
, "extensions");
123 //Containers are invisible to cursor traversal
124 //So on pressing "right" when in Help the
125 //extension button is considered as a candidate
127 //But the containers are not invisible to the PushButton ctor which checks
128 //if the preceding window of its parent is a button and if it then
129 //defaults to grouping with it and if it is not a button defaults to
130 //setting itself as the start of a new group.
132 //So here take the second button and set it as explicitly not the start
133 //of a group, i.e. allow it to be grouped with the preceding
134 //PushButton so when seen as a candidate by cursor travelling
135 //it will be accepted as a continuation of the group.
136 WinBits nBits
= mpExtensionsButton
->GetStyle();
139 mpExtensionsButton
->SetStyle(nBits
);
140 assert(mpHelpButton
->GetStyle() & WB_GROUP
);
141 assert(!(mpExtensionsButton
->GetStyle() & WB_GROUP
));
143 get(mpAllButtonsBox
, "all_buttons_box");
144 get(mpButtonsBox
, "buttons_box");
145 get(mpSmallButtonsBox
, "small_buttons_box");
147 get(mpAllRecentThumbnails
, "all_recent");
148 get(mpLocalView
, "local_view");
150 maDndWindows
.push_back(mpAllRecentThumbnails
);
154 mxContext
.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW
);
155 Reference
<lang::XMultiServiceFactory
> xConfig
= configuration::theDefaultProvider::get( mxContext
);
156 Sequence
<Any
> args(1);
160 Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")),
161 PropertyState_DIRECT_VALUE
);
162 args
.getArray()[0] <<= val
;
163 Reference
<container::XNameAccess
> xNameAccess(xConfig
->createInstanceWithArguments(SERVICENAME_CFGREADACCESS
,args
), UNO_QUERY
);
164 if( xNameAccess
.is() )
166 //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
167 Any
value( xNameAccess
->getByName("StartCenterHideExternalLinks") );
168 mnHideExternalLinks
= value
.get
<sal_Int32
>();
171 catch (const Exception
& e
)
173 SAL_WARN( "fwk", "BackingWindow - caught an exception! " << e
.Message
);
176 // fdo#34392: we do the layout dynamically, the layout depends on the font,
177 // so we should handle data changed events (font changing) of the last child
178 // control, at this point all the controls have updated settings (i.e. font).
180 EnableChildTransparentMode();
182 SetStyle( GetStyle() | WB_DIALOGCONTROL
);
184 // get dispatch provider
185 Reference
<XDesktop2
> xDesktop
= Desktop::create( comphelper::getProcessComponentContext() );
186 mxDesktopDispatchProvider
= xDesktop
;
193 BackingWindow::~BackingWindow()
198 void BackingWindow::dispose()
200 // deregister drag&drop helper
201 if (mxDropTargetListener
.is())
203 for (auto aI
= maDndWindows
.begin(), aEnd
= maDndWindows
.end(); aI
!= aEnd
; ++aI
)
205 vcl::Window
*pDndWin
= *aI
;
206 css::uno::Reference
< css::datatransfer::dnd::XDropTarget
> xDropTarget
=
207 pDndWin
->GetDropTarget();
208 if (xDropTarget
.is())
210 xDropTarget
->removeDropTargetListener(mxDropTargetListener
);
211 xDropTarget
->setActive(false);
214 mxDropTargetListener
= css::uno::Reference
< css::datatransfer::dnd::XDropTargetListener
>();
217 mpOpenButton
.clear();
218 mpRecentButton
.clear();
219 mpTemplateButton
.clear();
220 mpCreateLabel
.clear();
221 mpWriterAllButton
.clear();
222 mpCalcAllButton
.clear();
223 mpImpressAllButton
.clear();
224 mpDrawAllButton
.clear();
225 mpDBAllButton
.clear();
226 mpMathAllButton
.clear();
227 mpHelpButton
.clear();
228 mpExtensionsButton
.clear();
229 mpAllButtonsBox
.clear();
230 mpButtonsBox
.clear();
231 mpSmallButtonsBox
.clear();
232 mpAllRecentThumbnails
.clear();
234 vcl::Window::dispose();
237 void BackingWindow::initControls()
242 mbInitControls
= true;
244 // collect the URLs of the entries in the File/New menu
245 SvtModuleOptions aModuleOptions
;
246 std::set
< OUString
> aFileNewAppsAvailable
;
247 SvtDynamicMenuOptions aOpt
;
248 Sequence
< Sequence
< PropertyValue
> > aNewMenu
= aOpt
.GetMenu( E_NEWMENU
);
249 const OUString
sURLKey( "URL" );
251 const Sequence
< PropertyValue
>* pNewMenu
= aNewMenu
.getConstArray();
252 const Sequence
< PropertyValue
>* pNewMenuEnd
= aNewMenu
.getConstArray() + aNewMenu
.getLength();
253 for ( ; pNewMenu
!= pNewMenuEnd
; ++pNewMenu
)
255 comphelper::SequenceAsHashMap
aEntryItems( *pNewMenu
);
256 OUString
sURL( aEntryItems
.getUnpackedValueOrDefault( sURLKey
, OUString() ) );
257 if ( !sURL
.isEmpty() )
258 aFileNewAppsAvailable
.insert( sURL
);
261 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::WRITER
))
262 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_WRITER
;
264 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::CALC
))
265 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_CALC
;
267 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::IMPRESS
))
268 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_IMPRESS
;
270 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::DRAW
))
271 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_DRAW
;
273 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::DATABASE
))
274 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_DATABASE
;
276 if (aModuleOptions
.IsModuleInstalled(SvtModuleOptions::EModule::MATH
))
277 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_MATH
;
279 mpAllRecentThumbnails
->mnFileTypes
|= TYPE_OTHER
;
280 mpAllRecentThumbnails
->Reload();
281 mpAllRecentThumbnails
->ShowTooltips( true );
283 //initialize Template view
284 mpLocalView
->SetStyle( mpLocalView
->GetStyle() | WB_VSCROLL
);
287 mpTemplateButton
->SetMenuMode( MENUBUTTON_MENUMODE_TIMED
);
290 mpLocalView
->setOpenRegionHdl(LINK(this, BackingWindow
, OpenRegionHdl
));
291 mpLocalView
->setOpenTemplateHdl(LINK(this,BackingWindow
,OpenTemplateHdl
));
293 setupButton( mpOpenButton
);
294 setupButton( mpRecentButton
);
295 setupButton( mpTemplateButton
);
296 setupButton( mpWriterAllButton
);
297 setupButton( mpDrawAllButton
);
298 setupButton( mpCalcAllButton
);
299 setupButton( mpDBAllButton
);
300 setupButton( mpImpressAllButton
);
301 setupButton( mpMathAllButton
);
303 mpExtensionsButton
->SetClickHdl(LINK(this, BackingWindow
, ExtLinkClickHdl
));
306 mpCreateLabel
->SetControlForeground(maButtonsTextColor
);
307 vcl::Font
aFont(mpCreateLabel
->GetSettings().GetStyleSettings().GetLabelFont());
308 aFont
.SetSize(Size(0, aFont
.GetSize().Height() * fMultiplier
));
309 mpCreateLabel
->SetControlFont(aFont
);
311 mpHelpButton
->SetControlForeground(maButtonsTextColor
);
312 mpExtensionsButton
->SetControlForeground(maButtonsTextColor
);
314 const Color
aButtonsBackground(officecfg::Office::Common::Help::StartCenter::StartCenterBackgroundColor::get());
316 mpAllButtonsBox
->SetBackground(aButtonsBackground
);
317 mpSmallButtonsBox
->SetBackground(aButtonsBackground
);
319 // motif image under the buttons
320 Wallpaper
aWallpaper(get
<FixedImage
>("motif")->GetImage().GetBitmapEx());
321 aWallpaper
.SetStyle(WALLPAPER_BOTTOMRIGHT
);
322 aWallpaper
.SetColor(aButtonsBackground
);
324 mpButtonsBox
->SetBackground(aWallpaper
);
328 // compute the menubar height
329 sal_Int32 nMenuHeight
= 0;
330 SystemWindow
* pSystemWindow
= GetSystemWindow();
333 MenuBar
* pMenuBar
= pSystemWindow
->GetMenuBar();
335 nMenuHeight
= pMenuBar
->ImplGetWindow()->GetOutputSizePixel().Height();
338 set_width_request(mpAllRecentThumbnails
->get_width_request() + mpAllButtonsBox
->GetOptimalSize().Width());
339 set_height_request(nMenuHeight
+ mpAllButtonsBox
->GetOptimalSize().Height());
342 void BackingWindow::initializeLocalView()
344 if (!mbLocalViewInitialized
)
346 mbLocalViewInitialized
= true;
347 mpLocalView
->Populate();
348 mpLocalView
->showRootRegion();
349 mpLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE
));
353 void BackingWindow::setupButton( PushButton
* pButton
)
355 // the buttons should have a bit bigger font
356 vcl::Font
aFont(pButton
->GetSettings().GetStyleSettings().GetPushButtonFont());
357 aFont
.SetSize(Size(0, aFont
.GetSize().Height() * fMultiplier
));
358 pButton
->SetControlFont(aFont
);
360 // color that fits the theme
361 pButton
->SetControlForeground(maButtonsTextColor
);
362 pButton
->SetClickHdl( LINK( this, BackingWindow
, ClickHdl
) );
365 void BackingWindow::setupButton( MenuButton
* pButton
)
367 vcl::Font
aFont(pButton
->GetSettings().GetStyleSettings().GetPushButtonFont());
368 aFont
.SetSize(Size(0, aFont
.GetSize().Height() * fMultiplier
));
369 pButton
->SetControlFont(aFont
);
371 // color that fits the theme
372 pButton
->SetControlForeground(maButtonsTextColor
);
374 PopupMenu
* pMenu
= pButton
->GetPopupMenu();
375 pMenu
->SetMenuFlags(pMenu
->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries
);
377 pButton
->SetClickHdl(LINK(this, BackingWindow
, ClickHdl
));
378 pButton
->SetSelectHdl(LINK(this, BackingWindow
, MenuSelectHdl
));
381 void BackingWindow::Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
&)
385 Wallpaper
aBack(svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND
).nColor
);
386 vcl::Region
aClip(Rectangle(Point(0, 0), GetOutputSizePixel()));
388 aClip
.Exclude(maStartCentButtons
);
390 rRenderContext
.Push(PushFlags::CLIPREGION
);
391 rRenderContext
.IntersectClipRegion(aClip
);
392 rRenderContext
.DrawWallpaper(Rectangle(Point(0, 0), GetOutputSizePixel()), aBack
);
393 rRenderContext
.Pop();
395 ScopedVclPtrInstance
<VirtualDevice
> pVDev(rRenderContext
);
396 pVDev
->EnableRTL(rRenderContext
.IsRTLEnabled());
397 pVDev
->SetOutputSizePixel(maStartCentButtons
.GetSize());
398 Point
aOffset(Point(0, 0) - maStartCentButtons
.TopLeft());
399 pVDev
->DrawWallpaper(Rectangle(aOffset
, GetOutputSizePixel()), aBack
);
401 rRenderContext
.DrawOutDev(maStartCentButtons
.TopLeft(), maStartCentButtons
.GetSize(),
402 Point(0, 0), maStartCentButtons
.GetSize(),
406 bool BackingWindow::PreNotify( NotifyEvent
& rNEvt
)
408 if( rNEvt
.GetType() == MouseNotifyEvent::KEYINPUT
)
410 const KeyEvent
* pEvt
= rNEvt
.GetKeyEvent();
411 const vcl::KeyCode
& rKeyCode(pEvt
->GetKeyCode());
412 // Subwindows of BackingWindow: Sidebar and Thumbnail view
413 if( rKeyCode
.GetCode() == KEY_F6
)
415 if( rKeyCode
.IsShift() ) // Shift + F6
417 if( mpAllRecentThumbnails
->HasFocus() )
419 mpOpenButton
->GrabFocus();
423 else if ( rKeyCode
.IsMod1() ) // Ctrl + F6
425 mpAllRecentThumbnails
->GrabFocus();
430 if( mpAllButtonsBox
->HasChildPathFocus() )
432 mpAllRecentThumbnails
->GrabFocus();
438 return Window::PreNotify( rNEvt
);
441 bool BackingWindow::Notify( NotifyEvent
& rNEvt
)
443 if( rNEvt
.GetType() == MouseNotifyEvent::KEYINPUT
)
445 // try the 'normal' accelerators (so that eg. Ctrl+Q works)
448 mpAccExec
= svt::AcceleratorExecute::createAcceleratorHelper();
449 mpAccExec
->init( comphelper::getProcessComponentContext(), mxFrame
);
451 const KeyEvent
* pEvt
= rNEvt
.GetKeyEvent();
452 const vcl::KeyCode
& rKeyCode(pEvt
->GetKeyCode());
453 const OUString aCommand
= mpAccExec
->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode
));
454 if((aCommand
!= "vnd.sun.star.findbar:FocusToFindbar") && pEvt
&& mpAccExec
->execute(rKeyCode
))
458 return Window::Notify( rNEvt
);
461 void BackingWindow::GetFocus()
463 sal_uInt16 nFlags
= GetParent()->GetGetFocusFlags();
464 if( nFlags
& GETFOCUS_F6
)
466 if( nFlags
& GETFOCUS_FORWARD
) // F6
468 mpOpenButton
->GrabFocus();
471 else // Shift + F6 or Ctrl + F6
473 mpAllRecentThumbnails
->GrabFocus();
480 void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& xFrame
)
483 if( ! mbInitControls
)
486 // establish drag&drop mode
487 mxDropTargetListener
.set(new OpenFileDropTargetListener(mxContext
, mxFrame
));
489 for (auto aI
= maDndWindows
.begin(), aEnd
= maDndWindows
.end(); aI
!= aEnd
; ++aI
)
491 vcl::Window
*pDndWin
= *aI
;
492 css::uno::Reference
< css::datatransfer::dnd::XDropTarget
> xDropTarget
=
493 pDndWin
->GetDropTarget();
494 if (xDropTarget
.is())
496 xDropTarget
->addDropTargetListener(mxDropTargetListener
);
497 xDropTarget
->setActive(true);
502 void BackingWindow::Resize()
504 maStartCentButtons
= Rectangle( Point(0, 0), GetOutputSizePixel() );
506 if (isLayoutEnabled(this))
507 VclContainer::setLayoutAllocation(*GetWindow(GetWindowType::FirstChild
),
508 maStartCentButtons
.TopLeft(), maStartCentButtons
.GetSize());
514 IMPL_LINK(BackingWindow
, ExtLinkClickHdl
, Button
*, pButton
)
518 if (pButton
== mpExtensionsButton
)
519 aNode
= "AddFeatureURL";
521 if (!aNode
.isEmpty())
525 Sequence
<Any
> args(1);
526 PropertyValue
val("nodepath", 0, Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")), PropertyState_DIRECT_VALUE
);
527 args
.getArray()[0] <<= val
;
529 Reference
<lang::XMultiServiceFactory
> xConfig
= configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
530 Reference
<container::XNameAccess
> xNameAccess(xConfig
->createInstanceWithArguments(SERVICENAME_CFGREADACCESS
, args
), UNO_QUERY
);
531 if (xNameAccess
.is())
534 Any
value(xNameAccess
->getByName(aNode
));
536 sURL
= value
.get
<OUString
>();
537 localizeWebserviceURI(sURL
);
539 Reference
<css::system::XSystemShellExecute
> const
541 css::system::SystemShellExecute::create(
542 ::comphelper::getProcessComponentContext()));
543 xSystemShellExecute
->execute(sURL
, OUString(),
544 css::system::SystemShellExecuteFlags::URIS_ONLY
);
547 catch (const Exception
&)
554 IMPL_LINK( BackingWindow
, ClickHdl
, Button
*, pButton
)
556 // dispatch the appropriate URL and end the dialog
557 if( pButton
== mpWriterAllButton
)
558 dispatchURL( WRITER_URL
);
559 else if( pButton
== mpCalcAllButton
)
560 dispatchURL( CALC_URL
);
561 else if( pButton
== mpImpressAllButton
)
562 dispatchURL( IMPRESS_WIZARD_URL
);
563 else if( pButton
== mpDrawAllButton
)
564 dispatchURL( DRAW_URL
);
565 else if( pButton
== mpDBAllButton
)
566 dispatchURL( BASE_URL
);
567 else if( pButton
== mpMathAllButton
)
568 dispatchURL( MATH_URL
);
569 else if( pButton
== mpOpenButton
)
571 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
573 Sequence
< com::sun::star::beans::PropertyValue
> aArgs(1);
574 PropertyValue
* pArg
= aArgs
.getArray();
575 pArg
[0].Name
= "Referer";
576 pArg
[0].Value
<<= OUString("private:user");
578 dispatchURL( OPEN_URL
, OUString(), xFrame
, aArgs
);
580 else if( pButton
== mpRecentButton
)
583 mpAllRecentThumbnails
->Show();
584 mpAllRecentThumbnails
->GrabFocus();
586 else if( pButton
== mpTemplateButton
)
588 mpAllRecentThumbnails
->Hide();
589 initializeLocalView();
590 mpLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE
));
592 mpLocalView
->reload();
593 mpLocalView
->GrabFocus();
598 IMPL_LINK_TYPED( BackingWindow
, MenuSelectHdl
, MenuButton
*, pButton
, void )
600 initializeLocalView();
602 OString sId
= pButton
->GetCurItemIdent();
604 if( sId
== "filter_writer" )
606 mpLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::WRITER
));
608 else if( sId
== "filter_calc" )
610 mpLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::CALC
));
612 else if( sId
== "filter_impress" )
614 mpLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::IMPRESS
));
616 else if( sId
== "filter_draw" )
618 mpLocalView
->filterItems(ViewFilter_Application(FILTER_APPLICATION::DRAW
));
620 else if( sId
== "edit" )
622 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
624 Sequence
< com::sun::star::beans::PropertyValue
> aArgs(1);
625 PropertyValue
* pArg
= aArgs
.getArray();
626 pArg
[0].Name
= "Referer";
627 pArg
[0].Value
<<= OUString("private:user");
629 dispatchURL( TEMPLATE_URL
, OUString(), xFrame
, aArgs
);
633 mpAllRecentThumbnails
->Hide();
635 mpLocalView
->reload();
636 mpLocalView
->GrabFocus();
640 IMPL_LINK_NOARG( BackingWindow
, OpenRegionHdl
)
642 maSelFolders
.clear();
643 maSelTemplates
.clear();
648 IMPL_LINK(BackingWindow
, OpenTemplateHdl
, ThumbnailViewItem
*, pItem
)
652 uno::Sequence
< PropertyValue
> aArgs(4);
653 aArgs
[0].Name
= "AsTemplate";
654 aArgs
[0].Value
<<= sal_True
;
655 aArgs
[1].Name
= "MacroExecutionMode";
656 aArgs
[1].Value
<<= MacroExecMode::USE_CONFIG
;
657 aArgs
[2].Name
= "UpdateDocMode";
658 aArgs
[2].Value
<<= UpdateDocMode::ACCORDING_TO_CONFIG
;
659 aArgs
[3].Name
= "InteractionHandler";
660 aArgs
[3].Value
<<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 );
662 TemplateViewItem
*pTemplateItem
= static_cast<TemplateViewItem
*>(pItem
);
664 Reference
< XDispatchProvider
> xFrame( mxFrame
, UNO_QUERY
);
668 dispatchURL( pTemplateItem
->getPath(), "_default", xFrame
, aArgs
);
670 catch( const uno::Exception
& )
678 struct ImplDelayedDispatch
680 Reference
< XDispatch
> xDispatch
;
681 com::sun::star::util::URL aDispatchURL
;
682 Sequence
< PropertyValue
> aArgs
;
684 ImplDelayedDispatch( const Reference
< XDispatch
>& i_xDispatch
,
685 const com::sun::star::util::URL
& i_rURL
,
686 const Sequence
< PropertyValue
>& i_rArgs
)
687 : xDispatch( i_xDispatch
),
688 aDispatchURL( i_rURL
),
692 ~ImplDelayedDispatch() {}
695 static sal_IntPtr
implDispatchDelayed( void*, void* pArg
)
697 struct ImplDelayedDispatch
* pDispatch
= static_cast<ImplDelayedDispatch
*>(pArg
);
700 pDispatch
->xDispatch
->dispatch( pDispatch
->aDispatchURL
, pDispatch
->aArgs
);
702 catch (const Exception
&)
712 void BackingWindow::dispatchURL( const OUString
& i_rURL
,
713 const OUString
& rTarget
,
714 const Reference
< XDispatchProvider
>& i_xProv
,
715 const Sequence
< PropertyValue
>& i_rArgs
)
717 // if no special dispatch provider is given, get the desktop
718 Reference
< XDispatchProvider
> xProvider( i_xProv
.is() ? i_xProv
: mxDesktopDispatchProvider
);
720 // check for dispatch provider
724 // get an URL transformer to clean up the URL
725 com::sun::star::util::URL aDispatchURL
;
726 aDispatchURL
.Complete
= i_rURL
;
728 Reference
< com::sun::star::util::XURLTransformer
> xURLTransformer(
729 com::sun::star::util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
733 xURLTransformer
->parseStrict( aDispatchURL
);
734 // get a Dispatch for the URL and target
735 Reference
< XDispatch
> xDispatch(
736 xProvider
->queryDispatch( aDispatchURL
, rTarget
, 0 )
739 if ( xDispatch
.is() )
741 ImplDelayedDispatch
* pDisp
= new ImplDelayedDispatch( xDispatch
, aDispatchURL
, i_rArgs
);
742 if( Application::PostUserEvent( Link
<>( NULL
, implDispatchDelayed
), pDisp
) == 0 )
743 delete pDisp
; // event could not be posted for unknown reason, at least don't leak
746 catch (const com::sun::star::uno::RuntimeException
&)
750 catch (const com::sun::star::uno::Exception
&)
755 Size
BackingWindow::GetOptimalSize() const
757 if (isLayoutEnabled(this))
758 return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild
));
760 return Window::GetOptimalSize();
763 void BackingWindow::clearRecentFileList()
765 mpAllRecentThumbnails
->Clear();
766 set_width_request(mpAllRecentThumbnails
->get_width_request() + mpAllButtonsBox
->GetOptimalSize().Width());
768 /* vim:set shiftwidth=4 softtabstop=4 expandtab:*/