Line data Source code
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 "inputdlg.hxx"
22 :
23 : #include <vcl/settings.hxx>
24 : #include <vcl/svapp.hxx>
25 : #include <vcl/virdev.hxx>
26 :
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>
36 :
37 : #include <vcl/menubtn.hxx>
38 :
39 : #include <comphelper/processfactory.hxx>
40 : #include <comphelper/sequenceashashmap.hxx>
41 :
42 : #include <toolkit/awt/vclxmenu.hxx>
43 :
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>
55 :
56 : #include <officecfg/Office/Common.hxx>
57 :
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;
63 :
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[] = "slot:5500";
71 : const char OPEN_URL[] = ".uno:Open";
72 : const char SERVICENAME_CFGREADACCESS[] = "com.sun.star.configuration.ConfigurationAccess";
73 :
74 : float fMultiplier = 1.4f;
75 317 : const Color aButtonsText(COL_WHITE);
76 :
77 : /***
78 : *
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)
81 : *
82 : ***/
83 :
84 0 : static bool cmpSelectionItems (const ThumbnailViewItem *pItem1, const ThumbnailViewItem *pItem2)
85 : {
86 0 : return pItem1->mnId > pItem2->mnId;
87 : }
88 :
89 :
90 2 : BackingWindow::BackingWindow( vcl::Window* i_pParent ) :
91 : Window( i_pParent ),
92 : mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
93 : mbIsSaveMode( false ),
94 : mbInitControls( false ),
95 : mnHideExternalLinks( 0 ),
96 : mpAccExec( NULL ),
97 : maSelTemplates(cmpSelectionItems),
98 2 : maSelFolders(cmpSelectionItems)
99 :
100 : {
101 2 : m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "sfx/ui/startcenter.ui", "StartCenter" );
102 :
103 2 : get(mpOpenButton, "open_all");
104 2 : get(mpRecentButton, "open_recent");
105 2 : get(mpTemplateButton, "templates_all");
106 :
107 2 : get(mpCreateLabel, "create_label");
108 :
109 2 : get(mpWriterAllButton, "writer_all");
110 2 : get(mpCalcAllButton, "calc_all");
111 2 : get(mpImpressAllButton, "impress_all");
112 2 : get(mpDrawAllButton, "draw_all");
113 2 : get(mpDBAllButton, "database_all");
114 2 : get(mpMathAllButton, "math_all");
115 :
116 2 : get(mpHelpButton, "help");
117 2 : get(mpExtensionsButton, "extensions");
118 :
119 : //Containers are invisible to cursor traversal
120 : //So on pressing "right" when in Help the
121 : //extension button is considered as a candidate
122 :
123 : //But the containers are not invisible to the PushButton ctor which checks
124 : //if the preceeding window of its parent is a button and if it then
125 : //defaults to grouping with it and if it is not a button defaults to
126 : //setting itself as the start of a new group.
127 :
128 : //So here take the second button and set it as explicitly not the start
129 : //of a group, i.e. allow it to be grouped with the preceeding
130 : //PushButton so when seen as a candidate by cursor travelling
131 : //it will be accepted as a continuation of the group.
132 2 : WinBits nBits = mpExtensionsButton->GetStyle();
133 2 : nBits &= ~WB_GROUP;
134 2 : nBits |= WB_NOGROUP;
135 2 : mpExtensionsButton->SetStyle(nBits);
136 : assert(mpHelpButton->GetStyle() & WB_GROUP);
137 : assert(!(mpExtensionsButton->GetStyle() & WB_GROUP));
138 :
139 2 : get(mpAllButtonsBox, "all_buttons_box");
140 2 : get(mpButtonsBox, "buttons_box");
141 2 : get(mpSmallButtonsBox, "small_buttons_box");
142 2 : get(mpThinBox1, "thin_box1");
143 2 : get(mpThinBox2, "thin_box2");
144 2 : get(mpHelpBox, "help_box");
145 2 : get(mpExtensionsBox, "extensions_box");
146 :
147 2 : get(mpAllRecentThumbnails, "all_recent");
148 2 : get(mpLocalView, "local_view");
149 2 : mpCurrentView = mpLocalView;
150 :
151 2 : maDndWindows.push_back(mpAllRecentThumbnails);
152 :
153 : try
154 : {
155 2 : mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
156 2 : Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( mxContext );
157 4 : Sequence<Any> args(1);
158 : PropertyValue val(
159 : "nodepath",
160 : 0,
161 : Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")),
162 4 : PropertyState_DIRECT_VALUE);
163 2 : args.getArray()[0] <<= val;
164 4 : Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
165 2 : if( xNameAccess.is() )
166 : {
167 : //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
168 2 : Any value( xNameAccess->getByName("StartCenterHideExternalLinks") );
169 2 : mnHideExternalLinks = value.get<sal_Int32>();
170 2 : }
171 : }
172 0 : catch (const Exception& e)
173 : {
174 : SAL_WARN( "fwk", "BackingWindow - caught an exception! " << e.Message );
175 : }
176 :
177 : // fdo#34392: we do the layout dynamically, the layout depends on the font,
178 : // so we should handle data changed events (font changing) of the last child
179 : // control, at this point all the controls have updated settings (i.e. font).
180 :
181 2 : EnableChildTransparentMode();
182 :
183 2 : SetStyle( GetStyle() | WB_DIALOGCONTROL );
184 :
185 : // get dispatch provider
186 2 : Reference<XDesktop2> xDesktop = Desktop::create( comphelper::getProcessComponentContext() );
187 2 : mxDesktopDispatchProvider = xDesktop;
188 :
189 : // init background
190 2 : SetBackground();
191 2 : }
192 :
193 :
194 6 : BackingWindow::~BackingWindow()
195 : {
196 : // deregister drag&drop helper
197 2 : if (mxDropTargetListener.is())
198 : {
199 6 : for (std::vector<vcl::Window*>::iterator aI = maDndWindows.begin(),
200 2 : aEnd = maDndWindows.end(); aI != aEnd; ++aI)
201 : {
202 2 : vcl::Window *pDndWin = *aI;
203 : css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
204 2 : pDndWin->GetDropTarget();
205 2 : if (xDropTarget.is())
206 : {
207 2 : xDropTarget->removeDropTargetListener(mxDropTargetListener);
208 2 : xDropTarget->setActive(false);
209 : }
210 2 : }
211 2 : mxDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
212 : }
213 4 : }
214 :
215 2 : void BackingWindow::initControls()
216 : {
217 2 : if( mbInitControls )
218 2 : return;
219 :
220 2 : mbInitControls = true;
221 :
222 : // collect the URLs of the entries in the File/New menu
223 2 : SvtModuleOptions aModuleOptions;
224 4 : std::set< OUString > aFileNewAppsAvailable;
225 4 : SvtDynamicMenuOptions aOpt;
226 4 : Sequence < Sequence < PropertyValue > > aNewMenu = aOpt.GetMenu( E_NEWMENU );
227 4 : const OUString sURLKey( "URL" );
228 :
229 2 : const Sequence< PropertyValue >* pNewMenu = aNewMenu.getConstArray();
230 2 : const Sequence< PropertyValue >* pNewMenuEnd = aNewMenu.getConstArray() + aNewMenu.getLength();
231 32 : for ( ; pNewMenu != pNewMenuEnd; ++pNewMenu )
232 : {
233 30 : comphelper::SequenceAsHashMap aEntryItems( *pNewMenu );
234 60 : OUString sURL( aEntryItems.getUnpackedValueOrDefault( sURLKey, OUString() ) );
235 30 : if ( !sURL.isEmpty() )
236 30 : aFileNewAppsAvailable.insert( sURL );
237 30 : }
238 :
239 2 : if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SWRITER))
240 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_WRITER;
241 :
242 2 : if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SCALC))
243 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_CALC;
244 :
245 2 : if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SIMPRESS))
246 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_IMPRESS;
247 :
248 2 : if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SDRAW))
249 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_DRAW;
250 :
251 2 : if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
252 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_DATABASE;
253 :
254 2 : if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SMATH))
255 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_MATH;
256 :
257 2 : mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
258 2 : mpAllRecentThumbnails->Reload();
259 2 : mpAllRecentThumbnails->ShowTooltips( true );
260 :
261 : //initialize Template view
262 2 : mpLocalView->SetStyle( mpLocalView->GetStyle() | WB_VSCROLL);
263 2 : mpLocalView->Populate();
264 2 : mpLocalView->showRootRegion();
265 2 : mpLocalView->Hide();
266 2 : mpLocalView->filterItems(ViewFilter_Application(FILTER_APP_NONE));
267 :
268 :
269 2 : mpCurrentView = mpLocalView;
270 :
271 2 : mpTemplateButton->SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
272 :
273 : //set handlers
274 2 : mpLocalView->setOpenRegionHdl(LINK(this, BackingWindow, OpenRegionHdl));
275 2 : mpLocalView->setOpenTemplateHdl(LINK(this,BackingWindow,OpenTemplateHdl));
276 :
277 2 : setupButton( mpOpenButton );
278 2 : setupButton( mpRecentButton );
279 2 : setupButton( mpTemplateButton );
280 2 : setupButton( mpWriterAllButton );
281 2 : setupButton( mpDrawAllButton );
282 2 : setupButton( mpCalcAllButton );
283 2 : setupButton( mpDBAllButton );
284 2 : setupButton( mpImpressAllButton );
285 2 : setupButton( mpMathAllButton );
286 :
287 2 : mpExtensionsButton->SetClickHdl(LINK(this, BackingWindow, ExtLinkClickHdl));
288 :
289 : // setup nice colors
290 2 : mpCreateLabel->SetControlForeground(aButtonsText);
291 4 : vcl::Font aFont(mpCreateLabel->GetSettings().GetStyleSettings().GetLabelFont());
292 2 : aFont.SetSize(Size(0, aFont.GetSize().Height() * fMultiplier));
293 2 : mpCreateLabel->SetControlFont(aFont);
294 :
295 2 : mpHelpButton->SetControlForeground(aButtonsText);
296 2 : mpExtensionsButton->SetControlForeground(aButtonsText);
297 :
298 2 : const Color aButtonsBackground(officecfg::Office::Common::Help::StartCenter::StartCenterBackgroundColor::get());
299 :
300 2 : mpAllButtonsBox->SetBackground(aButtonsBackground);
301 2 : mpSmallButtonsBox->SetBackground(aButtonsBackground);
302 2 : mpHelpBox->SetBackground(aButtonsBackground);
303 2 : mpExtensionsBox->SetBackground(aButtonsBackground);
304 :
305 : // motif image under the buttons
306 4 : Wallpaper aWallpaper(get<FixedImage>("motif")->GetImage().GetBitmapEx());
307 2 : aWallpaper.SetStyle(WALLPAPER_BOTTOMRIGHT);
308 2 : aWallpaper.SetColor(aButtonsBackground);
309 :
310 2 : mpButtonsBox->SetBackground(aWallpaper);
311 :
312 : // thin white rectangle aronud the Help and Extensions buttons
313 2 : mpThinBox1->SetBackground(aButtonsText);
314 2 : mpThinBox2->SetBackground(aButtonsText);
315 :
316 2 : Resize();
317 :
318 2 : set_width_request(mpAllRecentThumbnails->get_width_request() + mpAllButtonsBox->GetOptimalSize().Width());
319 4 : set_height_request(mpAllButtonsBox->GetOptimalSize().Height());
320 : }
321 :
322 16 : void BackingWindow::setupButton( PushButton* pButton )
323 : {
324 : // the buttons should have a bit bigger font
325 16 : vcl::Font aFont(pButton->GetSettings().GetStyleSettings().GetPushButtonFont());
326 16 : aFont.SetSize(Size(0, aFont.GetSize().Height() * fMultiplier));
327 16 : pButton->SetControlFont(aFont);
328 :
329 : // color that fits the theme
330 16 : pButton->SetControlForeground(aButtonsText);
331 16 : pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
332 16 : }
333 :
334 2 : void BackingWindow::setupButton( MenuButton* pButton )
335 : {
336 2 : vcl::Font aFont(pButton->GetSettings().GetStyleSettings().GetPushButtonFont());
337 2 : aFont.SetSize(Size(0, aFont.GetSize().Height() * fMultiplier));
338 2 : pButton->SetControlFont(aFont);
339 :
340 : // color that fits the theme
341 2 : pButton->SetControlForeground(aButtonsText);
342 :
343 2 : PopupMenu* pMenu = pButton->GetPopupMenu();
344 2 : pMenu->SetMenuFlags(pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
345 :
346 2 : pButton->SetClickHdl(LINK(this, BackingWindow, ClickHdl));
347 2 : pButton->SetSelectHdl(LINK(this, BackingWindow, MenuSelectHdl));
348 2 : }
349 :
350 2 : void BackingWindow::Paint( const Rectangle& )
351 : {
352 2 : Resize();
353 :
354 2 : Wallpaper aBack( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor );
355 4 : vcl::Region aClip( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
356 :
357 2 : aClip.Exclude( maStartCentButtons );
358 :
359 2 : Push( PushFlags::CLIPREGION );
360 2 : IntersectClipRegion( aClip );
361 2 : DrawWallpaper( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ), aBack );
362 2 : Pop();
363 :
364 4 : VirtualDevice aDev( *this );
365 2 : aDev.EnableRTL( IsRTLEnabled() );
366 2 : aDev.SetOutputSizePixel( maStartCentButtons.GetSize() );
367 2 : Point aOffset( Point( 0, 0 ) - maStartCentButtons.TopLeft());
368 2 : aDev.DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );
369 :
370 4 : DrawOutDev( maStartCentButtons.TopLeft(), maStartCentButtons.GetSize(),
371 2 : Point( 0, 0 ), maStartCentButtons.GetSize(),
372 10 : aDev );
373 2 : }
374 :
375 8 : bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
376 : {
377 8 : if( rNEvt.GetType() == EVENT_KEYINPUT )
378 : {
379 0 : const KeyEvent* pEvt = rNEvt.GetKeyEvent();
380 0 : const vcl::KeyCode& rKeyCode(pEvt->GetKeyCode());
381 : // Subwindows of BackingWindow: Sidebar and Thumbnail view
382 0 : if( rKeyCode.GetCode() == KEY_F6 )
383 : {
384 0 : if( rKeyCode.IsShift() ) // Shift + F6
385 : {
386 0 : if( mpAllRecentThumbnails->HasFocus() )
387 : {
388 0 : mpOpenButton->GrabFocus();
389 0 : return true;
390 : }
391 : }
392 0 : else if ( rKeyCode.IsMod1() ) // Ctrl + F6
393 : {
394 0 : mpAllRecentThumbnails->GrabFocus();
395 0 : return true;
396 : }
397 : else // F6
398 : {
399 0 : if( mpAllButtonsBox->HasChildPathFocus() )
400 : {
401 0 : mpAllRecentThumbnails->GrabFocus();
402 0 : return true;
403 : }
404 : }
405 : }
406 : }
407 8 : return Window::PreNotify( rNEvt );
408 : }
409 :
410 108 : bool BackingWindow::Notify( NotifyEvent& rNEvt )
411 : {
412 108 : if( rNEvt.GetType() == EVENT_KEYINPUT )
413 : {
414 : // try the 'normal' accelerators (so that eg. Ctrl+Q works)
415 0 : if( !mpAccExec )
416 : {
417 0 : mpAccExec = svt::AcceleratorExecute::createAcceleratorHelper();
418 0 : mpAccExec->init( comphelper::getProcessComponentContext(), mxFrame);
419 : }
420 0 : const KeyEvent* pEvt = rNEvt.GetKeyEvent();
421 0 : const vcl::KeyCode& rKeyCode(pEvt->GetKeyCode());
422 0 : const OUString aCommand = mpAccExec->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode));
423 0 : if((aCommand != "vnd.sun.star.findbar:FocusToFindbar") && pEvt && mpAccExec->execute(rKeyCode))
424 0 : return true;
425 : }
426 :
427 108 : return Window::Notify( rNEvt );
428 : }
429 :
430 2 : void BackingWindow::GetFocus()
431 : {
432 2 : sal_uInt16 nFlags = GetParent()->GetGetFocusFlags();
433 2 : if( nFlags & GETFOCUS_F6 )
434 : {
435 0 : if( nFlags & GETFOCUS_FORWARD ) // F6
436 : {
437 0 : mpOpenButton->GrabFocus();
438 0 : return;
439 : }
440 : else // Shift + F6 or Ctrl + F6
441 : {
442 0 : mpAllRecentThumbnails->GrabFocus();
443 0 : return;
444 : }
445 : }
446 2 : Window::GetFocus();
447 : }
448 :
449 2 : void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame )
450 : {
451 2 : mxFrame = xFrame;
452 2 : if( ! mbInitControls )
453 2 : initControls();
454 :
455 : // establish drag&drop mode
456 2 : mxDropTargetListener.set(new OpenFileDropTargetListener(mxContext, mxFrame));
457 :
458 6 : for (std::vector<vcl::Window*>::iterator aI = maDndWindows.begin(),
459 2 : aEnd = maDndWindows.end(); aI != aEnd; ++aI)
460 : {
461 2 : vcl::Window *pDndWin = *aI;
462 : css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
463 2 : pDndWin->GetDropTarget();
464 2 : if (xDropTarget.is())
465 : {
466 2 : xDropTarget->addDropTargetListener(mxDropTargetListener);
467 2 : xDropTarget->setActive(true);
468 : }
469 2 : }
470 2 : }
471 :
472 10 : void BackingWindow::Resize()
473 : {
474 10 : maStartCentButtons = Rectangle( Point(0, 0), GetOutputSizePixel() );
475 :
476 10 : if (isLayoutEnabled(this))
477 10 : VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD),
478 20 : maStartCentButtons.TopLeft(), maStartCentButtons.GetSize());
479 :
480 10 : if( !IsInPaint())
481 8 : Invalidate();
482 10 : }
483 :
484 0 : IMPL_LINK(BackingWindow, ExtLinkClickHdl, Button*, pButton)
485 : {
486 0 : OUString aNode;
487 :
488 0 : if (pButton == mpExtensionsButton)
489 0 : aNode = "AddFeatureURL";
490 :
491 0 : if (!aNode.isEmpty())
492 : {
493 : try
494 : {
495 0 : Sequence<Any> args(1);
496 0 : PropertyValue val("nodepath", 0, Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")), PropertyState_DIRECT_VALUE);
497 0 : args.getArray()[0] <<= val;
498 :
499 0 : Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
500 0 : Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS, args), UNO_QUERY);
501 0 : if (xNameAccess.is())
502 : {
503 0 : OUString sURL;
504 0 : Any value(xNameAccess->getByName(aNode));
505 :
506 0 : sURL = value.get<OUString>();
507 0 : localizeWebserviceURI(sURL);
508 :
509 : Reference<css::system::XSystemShellExecute> const
510 : xSystemShellExecute(
511 : css::system::SystemShellExecute::create(
512 0 : ::comphelper::getProcessComponentContext()));
513 0 : xSystemShellExecute->execute(sURL, OUString(),
514 0 : css::system::SystemShellExecuteFlags::URIS_ONLY);
515 0 : }
516 : }
517 0 : catch (const Exception&)
518 : {
519 : }
520 : }
521 0 : return 0;
522 : }
523 :
524 0 : IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
525 : {
526 : // dispatch the appropriate URL and end the dialog
527 0 : if( pButton == mpWriterAllButton )
528 0 : dispatchURL( WRITER_URL );
529 0 : else if( pButton == mpCalcAllButton )
530 0 : dispatchURL( CALC_URL );
531 0 : else if( pButton == mpImpressAllButton )
532 0 : dispatchURL( IMPRESS_WIZARD_URL );
533 0 : else if( pButton == mpDrawAllButton )
534 0 : dispatchURL( DRAW_URL );
535 0 : else if( pButton == mpDBAllButton )
536 0 : dispatchURL( BASE_URL );
537 0 : else if( pButton == mpMathAllButton )
538 0 : dispatchURL( MATH_URL );
539 0 : else if( pButton == mpOpenButton )
540 : {
541 0 : Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
542 :
543 0 : Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
544 0 : PropertyValue* pArg = aArgs.getArray();
545 0 : pArg[0].Name = "Referer";
546 0 : pArg[0].Value <<= OUString("private:user");
547 :
548 0 : dispatchURL( OPEN_URL, OUString(), xFrame, aArgs );
549 : }
550 0 : else if( pButton == mpRecentButton )
551 : {
552 0 : mpLocalView->Hide();
553 0 : mpAllRecentThumbnails->Show();
554 0 : mpAllRecentThumbnails->GrabFocus();
555 : }
556 0 : else if( pButton == mpTemplateButton )
557 : {
558 0 : mpAllRecentThumbnails->Hide();
559 0 : mpCurrentView->filterItems(ViewFilter_Application(FILTER_APP_NONE));
560 0 : mpLocalView->Show();
561 0 : mpLocalView->reload();
562 0 : mpLocalView->GrabFocus();
563 : }
564 0 : return 0;
565 : }
566 :
567 0 : IMPL_LINK( BackingWindow, MenuSelectHdl, MenuButton*, pButton )
568 : {
569 0 : OString sId = pButton->GetCurItemIdent();
570 :
571 0 : if( sId == "filter_writer" )
572 : {
573 0 : mpCurrentView->filterItems(ViewFilter_Application(FILTER_APP_WRITER));
574 : }
575 0 : else if( sId == "filter_calc" )
576 : {
577 0 : mpCurrentView->filterItems(ViewFilter_Application(FILTER_APP_CALC));
578 : }
579 0 : else if( sId == "filter_impress" )
580 : {
581 0 : mpCurrentView->filterItems(ViewFilter_Application(FILTER_APP_IMPRESS));
582 : }
583 0 : else if( sId == "filter_draw" )
584 : {
585 0 : mpCurrentView->filterItems(ViewFilter_Application(FILTER_APP_DRAW));
586 : }
587 0 : else if( sId == "edit" )
588 : {
589 0 : Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
590 :
591 0 : Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
592 0 : PropertyValue* pArg = aArgs.getArray();
593 0 : pArg[0].Name = "Referer";
594 0 : pArg[0].Value <<= OUString("private:user");
595 :
596 0 : dispatchURL( TEMPLATE_URL, OUString(), xFrame, aArgs );
597 :
598 : }
599 :
600 0 : mpAllRecentThumbnails->Hide();
601 0 : mpLocalView->Show();
602 0 : mpLocalView->reload();
603 0 : mpLocalView->GrabFocus();
604 :
605 0 : return 0;
606 : }
607 :
608 :
609 0 : IMPL_LINK_NOARG( BackingWindow, OpenRegionHdl)
610 : {
611 0 : maSelFolders.clear();
612 0 : maSelTemplates.clear();
613 :
614 0 : return 0;
615 : }
616 :
617 0 : IMPL_LINK(BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem)
618 : {
619 0 : if (!mbIsSaveMode)
620 : {
621 0 : uno::Sequence< PropertyValue > aArgs(4);
622 0 : aArgs[0].Name = "AsTemplate";
623 0 : aArgs[0].Value <<= sal_True;
624 0 : aArgs[1].Name = "MacroExecutionMode";
625 0 : aArgs[1].Value <<= MacroExecMode::USE_CONFIG;
626 0 : aArgs[2].Name = "UpdateDocMode";
627 0 : aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG;
628 0 : aArgs[3].Name = "InteractionHandler";
629 0 : aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 );
630 :
631 0 : TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem);
632 :
633 0 : Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
634 :
635 : try
636 : {
637 0 : dispatchURL( pTemplateItem->getPath(), "_default", xFrame, aArgs );
638 : }
639 0 : catch( const uno::Exception& )
640 : {
641 0 : }
642 : }
643 :
644 0 : return 0;
645 : }
646 :
647 : struct ImplDelayedDispatch
648 : {
649 : Reference< XDispatch > xDispatch;
650 : com::sun::star::util::URL aDispatchURL;
651 : Sequence< PropertyValue > aArgs;
652 :
653 0 : ImplDelayedDispatch( const Reference< XDispatch >& i_xDispatch,
654 : const com::sun::star::util::URL& i_rURL,
655 : const Sequence< PropertyValue >& i_rArgs )
656 : : xDispatch( i_xDispatch ),
657 : aDispatchURL( i_rURL ),
658 0 : aArgs( i_rArgs )
659 : {
660 0 : }
661 0 : ~ImplDelayedDispatch() {}
662 : };
663 :
664 0 : static long implDispatchDelayed( void*, void* pArg )
665 : {
666 0 : struct ImplDelayedDispatch* pDispatch = reinterpret_cast<ImplDelayedDispatch*>(pArg);
667 : try
668 : {
669 0 : pDispatch->xDispatch->dispatch( pDispatch->aDispatchURL, pDispatch->aArgs );
670 : }
671 0 : catch (const Exception&)
672 : {
673 : }
674 :
675 : // clean up
676 0 : delete pDispatch;
677 :
678 0 : return 0;
679 : }
680 :
681 0 : void BackingWindow::dispatchURL( const OUString& i_rURL,
682 : const OUString& rTarget,
683 : const Reference< XDispatchProvider >& i_xProv,
684 : const Sequence< PropertyValue >& i_rArgs )
685 : {
686 : // if no special dispatch provider is given, get the desktop
687 0 : Reference< XDispatchProvider > xProvider( i_xProv.is() ? i_xProv : mxDesktopDispatchProvider );
688 :
689 : // check for dispatch provider
690 0 : if( !xProvider.is())
691 0 : return;
692 :
693 : // get an URL transformer to clean up the URL
694 0 : com::sun::star::util::URL aDispatchURL;
695 0 : aDispatchURL.Complete = i_rURL;
696 :
697 : Reference < com::sun::star::util::XURLTransformer > xURLTransformer(
698 0 : com::sun::star::util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
699 : try
700 : {
701 : // clean up the URL
702 0 : xURLTransformer->parseStrict( aDispatchURL );
703 : // get a Dispatch for the URL and target
704 : Reference< XDispatch > xDispatch(
705 0 : xProvider->queryDispatch( aDispatchURL, rTarget, 0 )
706 0 : );
707 : // dispatch the URL
708 0 : if ( xDispatch.is() )
709 : {
710 0 : ImplDelayedDispatch* pDisp = new ImplDelayedDispatch( xDispatch, aDispatchURL, i_rArgs );
711 0 : if( Application::PostUserEvent( Link( NULL, implDispatchDelayed ), pDisp ) == 0 )
712 0 : delete pDisp; // event could not be posted for unknown reason, at least don't leak
713 0 : }
714 : }
715 0 : catch (const com::sun::star::uno::RuntimeException&)
716 : {
717 0 : throw;
718 : }
719 0 : catch (const com::sun::star::uno::Exception&)
720 : {
721 0 : }
722 : }
723 :
724 0 : Size BackingWindow::GetOptimalSize() const
725 : {
726 0 : if (isLayoutEnabled(this))
727 0 : return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
728 :
729 0 : return Window::GetOptimalSize();
730 : }
731 :
732 0 : void BackingWindow::clearRecentFileList()
733 : {
734 0 : mpAllRecentThumbnails->Clear();
735 0 : set_width_request(mpAllRecentThumbnails->get_width_request() + mpAllButtonsBox->GetOptimalSize().Width());
736 951 : }
737 : /* vim:set shiftwidth=4 softtabstop=4 expandtab:*/
|