LCOV - code coverage report
Current view: top level - sfx2/source/dialog - backingwindow.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 215 387 55.6 %
Date: 2015-06-13 12:38:46 Functions: 13 33 39.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11