LCOV - code coverage report
Current view: top level - sfx2/source/dialog - backingwindow.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 175 288 60.8 %
Date: 2014-04-11 Functions: 13 23 56.5 %
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             : 
      22             : #include <vcl/svapp.hxx>
      23             : #include <vcl/virdev.hxx>
      24             : 
      25             : #include <unotools/dynamicmenuoptions.hxx>
      26             : #include <svtools/openfiledroptargetlistener.hxx>
      27             : #include <svtools/colorcfg.hxx>
      28             : #include <svtools/langhelp.hxx>
      29             : 
      30             : #include <comphelper/processfactory.hxx>
      31             : #include <comphelper/sequenceashashmap.hxx>
      32             : 
      33             : #include <toolkit/awt/vclxmenu.hxx>
      34             : 
      35             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      36             : #include <com/sun/star/container/XNameAccess.hpp>
      37             : #include <com/sun/star/document/MacroExecMode.hpp>
      38             : #include <com/sun/star/document/UpdateDocMode.hpp>
      39             : #include <com/sun/star/frame/Desktop.hpp>
      40             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      41             : #include <com/sun/star/system/SystemShellExecute.hpp>
      42             : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
      43             : #include <com/sun/star/util/URLTransformer.hpp>
      44             : #include <com/sun/star/task/InteractionHandler.hpp>
      45             : 
      46             : using namespace ::com::sun::star;
      47             : using namespace ::com::sun::star::beans;
      48             : using namespace ::com::sun::star::frame;
      49             : using namespace ::com::sun::star::uno;
      50             : using namespace ::com::sun::star::document;
      51             : 
      52             : const char WRITER_URL[] =         "private:factory/swriter";
      53             : const char CALC_URL[] =           "private:factory/scalc";
      54             : const char IMPRESS_WIZARD_URL[] = "private:factory/simpress?slot=6686";
      55             : const char DRAW_URL[] =           "private:factory/sdraw";
      56             : const char BASE_URL[] =           "private:factory/sdatabase?Interactive";
      57             : const char MATH_URL[] =           "private:factory/smath";
      58             : const char TEMPLATE_URL[] =       "slot:5500";
      59             : const char OPEN_URL[] =           ".uno:Open";
      60             : const char SERVICENAME_CFGREADACCESS[] = "com.sun.star.configuration.ConfigurationAccess";
      61             : 
      62             : const int nButtonsFontSize = 15;
      63         149 : const Color aButtonsBackground(114, 168, 84); // TDF green
      64         149 : const Color aButtonsText(COL_WHITE);
      65             : 
      66           1 : BackingWindow::BackingWindow( Window* i_pParent ) :
      67             :     Window( i_pParent ),
      68             :     mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
      69             :     mbInitControls( false ),
      70             :     mnHideExternalLinks( 0 ),
      71           1 :     mpAccExec( NULL )
      72             : {
      73           1 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "sfx/ui/startcenter.ui", "StartCenter" );
      74             : 
      75           1 :     get(mpOpenButton, "open_all");
      76           1 :     get(mpTemplateButton, "templates_all");
      77             : 
      78           1 :     get(mpCreateLabel, "create_label");
      79             : 
      80           1 :     get(mpWriterAllButton, "writer_all");
      81           1 :     get(mpCalcAllButton, "calc_all");
      82           1 :     get(mpImpressAllButton, "impress_all");
      83           1 :     get(mpDrawAllButton, "draw_all");
      84           1 :     get(mpDBAllButton, "database_all");
      85           1 :     get(mpMathAllButton, "math_all");
      86             : 
      87           1 :     get(mpHelpButton, "help");
      88           1 :     get(mpExtensionsButton, "extensions");
      89             : 
      90             :     //Containers are invisible to cursor traversal
      91             :     //So on pressing "right" when in Help the
      92             :     //extension button is considered as a candidate
      93             : 
      94             :     //But the containers are not invisible to the PushButton ctor which checks
      95             :     //if the preceeding window of its parent is a button and if it then
      96             :     //defaults to grouping with it and if it is not a button defaults to
      97             :     //setting itself as the start of a new group.
      98             : 
      99             :     //So here take the second button and set it as explicitly not the start
     100             :     //of a group, i.e. allow it to be grouped with the preceeding
     101             :     //PushButton so when seen as a candidate by cursor travelling
     102             :     //it will be accepted as a continuation of the group.
     103           1 :     WinBits nBits = mpExtensionsButton->GetStyle();
     104           1 :     nBits &= ~WB_GROUP;
     105           1 :     nBits |= WB_NOGROUP;
     106           1 :     mpExtensionsButton->SetStyle(nBits);
     107             :     assert(mpHelpButton->GetStyle() & WB_GROUP);
     108             :     assert(!(mpExtensionsButton->GetStyle() & WB_GROUP));
     109             : 
     110           1 :     get(mpAllButtonsBox, "all_buttons_box");
     111           1 :     get(mpButtonsBox, "buttons_box");
     112           1 :     get(mpSmallButtonsBox, "small_buttons_box");
     113           1 :     get(mpThinBox1, "thin_box1");
     114           1 :     get(mpThinBox2, "thin_box2");
     115           1 :     get(mpHelpBox, "help_box");
     116           1 :     get(mpExtensionsBox, "extensions_box");
     117             : 
     118           1 :     get(mpAllRecentThumbnails, "all_recent");
     119             : 
     120           1 :     maDndWindows.push_back(mpAllRecentThumbnails);
     121             : 
     122             :     try
     123             :     {
     124           1 :         mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
     125           1 :         Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( mxContext );
     126           2 :         Sequence<Any> args(1);
     127             :         PropertyValue val(
     128             :             "nodepath",
     129             :             0,
     130             :             Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")),
     131           2 :             PropertyState_DIRECT_VALUE);
     132           1 :         args.getArray()[0] <<= val;
     133           2 :         Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
     134           1 :         if( xNameAccess.is() )
     135             :         {
     136             :             //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
     137           1 :             Any value( xNameAccess->getByName("StartCenterHideExternalLinks") );
     138           1 :             mnHideExternalLinks = value.get<sal_Int32>();
     139           1 :         }
     140             :     }
     141           0 :     catch (const Exception& e)
     142             :     {
     143             :         SAL_WARN( "fwk", "BackingWindow - caught an exception! " << e.Message );
     144             :     }
     145             : 
     146             :     // fdo#34392: we do the layout dynamically, the layout depends on the font,
     147             :     // so we should handle data changed events (font changing) of the last child
     148             :     // control, at this point all the controls have updated settings (i.e. font).
     149             : 
     150           1 :     EnableChildTransparentMode();
     151             : 
     152           1 :     SetStyle( GetStyle() | WB_DIALOGCONTROL );
     153             : 
     154             :     // get dispatch provider
     155           1 :     Reference<XDesktop2> xDesktop = Desktop::create( comphelper::getProcessComponentContext() );
     156           1 :     mxDesktopDispatchProvider = xDesktop;
     157             : 
     158             :     // init background
     159           1 :     SetBackground();
     160           1 : }
     161             : 
     162             : 
     163           3 : BackingWindow::~BackingWindow()
     164             : {
     165             :     // deregister drag&drop helper
     166           1 :     if (mxDropTargetListener.is())
     167             :     {
     168           3 :         for (std::vector<Window*>::iterator aI = maDndWindows.begin(),
     169           1 :             aEnd = maDndWindows.end(); aI != aEnd; ++aI)
     170             :         {
     171           1 :             Window *pDndWin = *aI;
     172             :             css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
     173           1 :                     pDndWin->GetDropTarget();
     174           1 :             if (xDropTarget.is())
     175             :             {
     176           1 :                 xDropTarget->removeDropTargetListener(mxDropTargetListener);
     177           1 :                 xDropTarget->setActive(false);
     178             :             }
     179           1 :         }
     180           1 :         mxDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
     181             :     }
     182           2 : }
     183             : 
     184           1 : void BackingWindow::initControls()
     185             : {
     186           1 :     if( mbInitControls )
     187           1 :         return;
     188             : 
     189           1 :     mbInitControls = true;
     190             : 
     191             :     // collect the URLs of the entries in the File/New menu
     192           1 :     SvtModuleOptions    aModuleOptions;
     193           2 :     std::set< OUString > aFileNewAppsAvailable;
     194           2 :     SvtDynamicMenuOptions aOpt;
     195           2 :     Sequence < Sequence < PropertyValue > > aNewMenu = aOpt.GetMenu( E_NEWMENU );
     196           2 :     const OUString sURLKey( "URL"  );
     197             : 
     198           1 :     const Sequence< PropertyValue >* pNewMenu = aNewMenu.getConstArray();
     199           1 :     const Sequence< PropertyValue >* pNewMenuEnd = aNewMenu.getConstArray() + aNewMenu.getLength();
     200          16 :     for ( ; pNewMenu != pNewMenuEnd; ++pNewMenu )
     201             :     {
     202          15 :         comphelper::SequenceAsHashMap aEntryItems( *pNewMenu );
     203          30 :         OUString sURL( aEntryItems.getUnpackedValueOrDefault( sURLKey, OUString() ) );
     204          15 :         if ( !sURL.isEmpty() )
     205          15 :             aFileNewAppsAvailable.insert( sURL );
     206          15 :     }
     207             : 
     208           1 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SWRITER))
     209           1 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_WRITER;
     210             : 
     211           1 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SCALC))
     212           1 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_CALC;
     213             : 
     214           1 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SIMPRESS))
     215           1 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_IMPRESS;
     216             : 
     217           1 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SDRAW))
     218           1 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_DRAW;
     219             : 
     220           1 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
     221           1 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_DATABASE;
     222             : 
     223           1 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SMATH))
     224           1 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_MATH;
     225             : 
     226           1 :     mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
     227           1 :     mpAllRecentThumbnails->loadRecentDocs();
     228           1 :     mpAllRecentThumbnails->ShowTooltips( true );
     229             : 
     230           1 :     setupButton( mpOpenButton );
     231           1 :     setupButton( mpTemplateButton );
     232             : 
     233           1 :     setupButton( mpWriterAllButton );
     234           1 :     setupButton( mpDrawAllButton );
     235           1 :     setupButton( mpCalcAllButton );
     236           1 :     setupButton( mpDBAllButton );
     237           1 :     setupButton( mpImpressAllButton );
     238           1 :     setupButton( mpMathAllButton );
     239             : 
     240           1 :     mpExtensionsButton->SetClickHdl(LINK(this, BackingWindow, ExtLinkClickHdl));
     241             : 
     242             :     // setup nice colors
     243           1 :     mpCreateLabel->SetControlForeground(aButtonsText);
     244           2 :     Font aFont(mpCreateLabel->GetControlFont());
     245           1 :     aFont.SetHeight(nButtonsFontSize);
     246           1 :     mpCreateLabel->SetControlFont(aFont);
     247             : 
     248           1 :     mpHelpButton->SetControlForeground(aButtonsText);
     249           1 :     mpExtensionsButton->SetControlForeground(aButtonsText);
     250             : 
     251           1 :     mpAllButtonsBox->SetBackground(aButtonsBackground);
     252           1 :     mpSmallButtonsBox->SetBackground(aButtonsBackground);
     253           1 :     mpHelpBox->SetBackground(aButtonsBackground);
     254           1 :     mpExtensionsBox->SetBackground(aButtonsBackground);
     255             : 
     256             :     // motif image under the buttons
     257           2 :     Wallpaper aWallpaper(get<FixedImage>("motif")->GetImage().GetBitmapEx());
     258           1 :     aWallpaper.SetStyle(WALLPAPER_BOTTOMRIGHT);
     259           1 :     aWallpaper.SetColor(aButtonsBackground);
     260             : 
     261           1 :     mpButtonsBox->SetBackground(aWallpaper);
     262             : 
     263             :     // thin white rectangle aronud the Help and Extensions buttons
     264           1 :     mpThinBox1->SetBackground(aButtonsText);
     265           1 :     mpThinBox2->SetBackground(aButtonsText);
     266             : 
     267           1 :     Resize();
     268             : 
     269           1 :     set_width_request(mpAllRecentThumbnails->get_width_request() + mpAllButtonsBox->GetOptimalSize().Width());
     270           2 :     set_height_request(mpAllButtonsBox->GetOptimalSize().Height());
     271             : }
     272             : 
     273           8 : void BackingWindow::setupButton( PushButton* pButton )
     274             : {
     275             :     // the buttons should have a bit bigger font
     276           8 :     Font aFont(pButton->GetControlFont());
     277           8 :     aFont.SetHeight(nButtonsFontSize);
     278           8 :     pButton->SetControlFont(aFont);
     279             : 
     280             :     // color that fits the theme
     281           8 :     pButton->SetControlForeground(aButtonsText);
     282             : 
     283           8 :     pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
     284           8 : }
     285             : 
     286           1 : void BackingWindow::Paint( const Rectangle& )
     287             : {
     288           1 :     Resize();
     289             : 
     290           1 :     Wallpaper aBack( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor );
     291           2 :     Region aClip( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
     292             : 
     293           1 :     aClip.Exclude( maStartCentButtons );
     294             : 
     295           1 :     Push( PUSH_CLIPREGION );
     296           1 :     IntersectClipRegion( aClip );
     297           1 :     DrawWallpaper( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ), aBack );
     298           1 :     Pop();
     299             : 
     300           2 :     VirtualDevice aDev( *this );
     301           1 :     aDev.EnableRTL( IsRTLEnabled() );
     302           1 :     aDev.SetOutputSizePixel( maStartCentButtons.GetSize() );
     303           1 :     Point aOffset( Point( 0, 0 ) - maStartCentButtons.TopLeft());
     304           1 :     aDev.DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );
     305             : 
     306           2 :     DrawOutDev( maStartCentButtons.TopLeft(), maStartCentButtons.GetSize(),
     307           1 :                 Point( 0, 0 ), maStartCentButtons.GetSize(),
     308           5 :                 aDev );
     309           1 : }
     310             : 
     311          11 : bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
     312             : {
     313          11 :     if( rNEvt.GetType() == EVENT_KEYINPUT )
     314             :     {
     315           0 :         const KeyEvent* pEvt = rNEvt.GetKeyEvent();
     316           0 :         const KeyCode& rKeyCode(pEvt->GetKeyCode());
     317             :         // Subwindows of BackingWindow: Sidebar and Thumbnail view
     318           0 :         if( rKeyCode.GetCode() == KEY_F6 )
     319             :         {
     320           0 :             if( rKeyCode.IsShift() ) // Shift + F6
     321             :             {
     322           0 :                 if( mpAllRecentThumbnails->HasFocus() )
     323             :                 {
     324           0 :                     mpOpenButton->GrabFocus();
     325           0 :                     return true;
     326             :                 }
     327             :             }
     328           0 :             else if ( rKeyCode.IsMod1() ) // Ctrl + F6
     329             :             {
     330           0 :                 mpAllRecentThumbnails->GrabFocus();
     331           0 :                 return true;
     332             :             }
     333             :             else // F6
     334             :             {
     335           0 :                 if( mpAllButtonsBox->HasChildPathFocus() )
     336             :                 {
     337           0 :                     mpAllRecentThumbnails->GrabFocus();
     338           0 :                     return true;
     339             :                 }
     340             :             }
     341             :         }
     342             :     }
     343          11 :     return Window::PreNotify( rNEvt );
     344             : }
     345             : 
     346          42 : bool BackingWindow::Notify( NotifyEvent& rNEvt )
     347             : {
     348          42 :     if( rNEvt.GetType() == EVENT_KEYINPUT )
     349             :     {
     350             :         // try the 'normal' accelerators (so that eg. Ctrl+Q works)
     351           0 :         if( !mpAccExec )
     352             :         {
     353           0 :             mpAccExec = svt::AcceleratorExecute::createAcceleratorHelper();
     354           0 :             mpAccExec->init( comphelper::getProcessComponentContext(), mxFrame);
     355             :         }
     356           0 :         const KeyEvent* pEvt = rNEvt.GetKeyEvent();
     357           0 :         const KeyCode& rKeyCode(pEvt->GetKeyCode());
     358           0 :         const OUString aCommand = mpAccExec->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rKeyCode));
     359           0 :         if((aCommand != "vnd.sun.star.findbar:FocusToFindbar") && pEvt && mpAccExec->execute(rKeyCode))
     360           0 :             return true;
     361             :     }
     362             : 
     363          42 :     return Window::Notify( rNEvt );
     364             : }
     365             : 
     366           2 : void BackingWindow::GetFocus()
     367             : {
     368           2 :     sal_uInt16 nFlags = GetParent()->GetGetFocusFlags();
     369           2 :     if( nFlags & GETFOCUS_F6 )
     370             :     {
     371           0 :         if( nFlags & GETFOCUS_FORWARD ) // F6
     372             :         {
     373           0 :             mpOpenButton->GrabFocus();
     374           0 :             return;
     375             :         }
     376             :         else // Shift + F6 or Ctrl + F6
     377             :         {
     378           0 :             mpAllRecentThumbnails->GrabFocus();
     379           0 :             return;
     380             :         }
     381             :     }
     382           2 :     Window::GetFocus();
     383             : }
     384             : 
     385           1 : void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame )
     386             : {
     387           1 :     mxFrame = xFrame;
     388           1 :     if( ! mbInitControls )
     389           1 :         initControls();
     390             : 
     391             :     // establish drag&drop mode
     392           1 :     mxDropTargetListener.set(new OpenFileDropTargetListener(mxContext, mxFrame));
     393             : 
     394           3 :     for (std::vector<Window*>::iterator aI = maDndWindows.begin(),
     395           1 :         aEnd = maDndWindows.end(); aI != aEnd; ++aI)
     396             :     {
     397           1 :         Window *pDndWin = *aI;
     398             :         css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
     399           1 :             pDndWin->GetDropTarget();
     400           1 :         if (xDropTarget.is())
     401             :         {
     402           1 :             xDropTarget->addDropTargetListener(mxDropTargetListener);
     403           1 :             xDropTarget->setActive(true);
     404             :         }
     405           1 :     }
     406           1 : }
     407             : 
     408           5 : void BackingWindow::Resize()
     409             : {
     410           5 :     maStartCentButtons = Rectangle( Point(0, 0), GetOutputSizePixel() );
     411             : 
     412           5 :     if (isLayoutEnabled(this))
     413           5 :         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD),
     414          10 :             maStartCentButtons.TopLeft(), maStartCentButtons.GetSize());
     415             : 
     416           5 :     if( !IsInPaint())
     417           4 :         Invalidate();
     418           5 : }
     419             : 
     420           0 : IMPL_LINK(BackingWindow, ExtLinkClickHdl, Button*, pButton)
     421             : {
     422           0 :     OUString aNode;
     423             : 
     424           0 :     if (pButton == mpExtensionsButton)
     425           0 :         aNode = "AddFeatureURL";
     426             : 
     427           0 :     if (!aNode.isEmpty())
     428             :     {
     429             :         try
     430             :         {
     431           0 :             Sequence<Any> args(1);
     432           0 :             PropertyValue val("nodepath", 0, Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")), PropertyState_DIRECT_VALUE);
     433           0 :             args.getArray()[0] <<= val;
     434             : 
     435           0 :             Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
     436           0 :             Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS, args), UNO_QUERY);
     437           0 :             if (xNameAccess.is())
     438             :             {
     439           0 :                 OUString sURL;
     440           0 :                 Any value(xNameAccess->getByName(aNode));
     441             : 
     442           0 :                 sURL = value.get<OUString>();
     443           0 :                 localizeWebserviceURI(sURL);
     444             : 
     445             :                 Reference<css::system::XSystemShellExecute> const
     446             :                     xSystemShellExecute(
     447             :                         css::system::SystemShellExecute::create(
     448           0 :                             ::comphelper::getProcessComponentContext()));
     449           0 :                 xSystemShellExecute->execute(sURL, OUString(),
     450           0 :                     css::system::SystemShellExecuteFlags::URIS_ONLY);
     451           0 :             }
     452             :         }
     453           0 :         catch (const Exception&)
     454             :         {
     455             :         }
     456             :     }
     457           0 :     return 0;
     458             : }
     459             : 
     460           0 : IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
     461             : {
     462             :     // dispatch the appropriate URL and end the dialog
     463           0 :     if( pButton == mpWriterAllButton )
     464           0 :         dispatchURL( WRITER_URL );
     465           0 :     else if( pButton == mpCalcAllButton )
     466           0 :         dispatchURL( CALC_URL );
     467           0 :     else if( pButton == mpImpressAllButton )
     468           0 :         dispatchURL( IMPRESS_WIZARD_URL );
     469           0 :     else if( pButton == mpDrawAllButton )
     470           0 :         dispatchURL( DRAW_URL );
     471           0 :     else if( pButton == mpDBAllButton )
     472           0 :         dispatchURL( BASE_URL );
     473           0 :     else if( pButton == mpMathAllButton )
     474           0 :         dispatchURL( MATH_URL );
     475           0 :     else if( pButton == mpOpenButton )
     476             :     {
     477           0 :         Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
     478             : 
     479           0 :         Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
     480           0 :         PropertyValue* pArg = aArgs.getArray();
     481           0 :         pArg[0].Name = "Referer";
     482           0 :         pArg[0].Value <<= OUString("private:user");
     483             : 
     484           0 :         dispatchURL( OPEN_URL, OUString(), xFrame, aArgs );
     485             :     }
     486           0 :     else if( pButton == mpTemplateButton )
     487             :     {
     488           0 :         Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
     489             : 
     490           0 :         Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
     491           0 :         PropertyValue* pArg = aArgs.getArray();
     492           0 :         pArg[0].Name = "Referer";
     493           0 :         pArg[0].Value <<= OUString("private:user");
     494             : 
     495           0 :         dispatchURL( TEMPLATE_URL, OUString(), xFrame, aArgs );
     496             :     }
     497           0 :     return 0;
     498             : }
     499             : 
     500             : struct ImplDelayedDispatch
     501             : {
     502             :     Reference< XDispatch >      xDispatch;
     503             :     com::sun::star::util::URL   aDispatchURL;
     504             :     Sequence< PropertyValue >   aArgs;
     505             : 
     506           0 :     ImplDelayedDispatch( const Reference< XDispatch >& i_xDispatch,
     507             :                          const com::sun::star::util::URL& i_rURL,
     508             :                          const Sequence< PropertyValue >& i_rArgs )
     509             :     : xDispatch( i_xDispatch ),
     510             :       aDispatchURL( i_rURL ),
     511           0 :       aArgs( i_rArgs )
     512             :     {
     513           0 :     }
     514           0 :     ~ImplDelayedDispatch() {}
     515             : };
     516             : 
     517           0 : static long implDispatchDelayed( void*, void* pArg )
     518             : {
     519           0 :     struct ImplDelayedDispatch* pDispatch = reinterpret_cast<ImplDelayedDispatch*>(pArg);
     520             :     try
     521             :     {
     522           0 :         pDispatch->xDispatch->dispatch( pDispatch->aDispatchURL, pDispatch->aArgs );
     523             :     }
     524           0 :     catch (const Exception&)
     525             :     {
     526             :     }
     527             : 
     528             :     // clean up
     529           0 :     delete pDispatch;
     530             : 
     531           0 :     return 0;
     532             : }
     533             : 
     534           0 : void BackingWindow::dispatchURL( const OUString& i_rURL,
     535             :                                  const OUString& rTarget,
     536             :                                  const Reference< XDispatchProvider >& i_xProv,
     537             :                                  const Sequence< PropertyValue >& i_rArgs )
     538             : {
     539             :     // if no special dispatch provider is given, get the desktop
     540           0 :     Reference< XDispatchProvider > xProvider( i_xProv.is() ? i_xProv : mxDesktopDispatchProvider );
     541             : 
     542             :     // check for dispatch provider
     543           0 :     if( !xProvider.is())
     544           0 :         return;
     545             : 
     546             :     // get an URL transformer to clean up the URL
     547           0 :     com::sun::star::util::URL aDispatchURL;
     548           0 :     aDispatchURL.Complete = i_rURL;
     549             : 
     550             :     Reference < com::sun::star::util::XURLTransformer > xURLTransformer(
     551           0 :         com::sun::star::util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
     552             :     try
     553             :     {
     554             :         // clean up the URL
     555           0 :         xURLTransformer->parseStrict( aDispatchURL );
     556             :         // get a Dispatch for the URL and target
     557             :         Reference< XDispatch > xDispatch(
     558           0 :             xProvider->queryDispatch( aDispatchURL, rTarget, 0 )
     559           0 :             );
     560             :         // dispatch the URL
     561           0 :         if ( xDispatch.is() )
     562             :         {
     563           0 :             ImplDelayedDispatch* pDisp = new ImplDelayedDispatch( xDispatch, aDispatchURL, i_rArgs );
     564           0 :             sal_uLong nEventId = 0;
     565           0 :             if( ! Application::PostUserEvent( nEventId, Link( NULL, implDispatchDelayed ), pDisp ) )
     566           0 :                 delete pDisp; // event could not be posted for unknown reason, at least don't leak
     567           0 :         }
     568             :     }
     569           0 :     catch (const com::sun::star::uno::RuntimeException&)
     570             :     {
     571           0 :         throw;
     572             :     }
     573           0 :     catch (const com::sun::star::uno::Exception&)
     574             :     {
     575           0 :     }
     576             : }
     577             : 
     578           0 : Size BackingWindow::GetOptimalSize() const
     579             : {
     580           0 :     if (isLayoutEnabled(this))
     581           0 :         return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
     582             : 
     583           0 :     return Window::GetOptimalSize();
     584             : }
     585             : 
     586           0 : void BackingWindow::clearRecentFileList()
     587             : {
     588           0 :     mpAllRecentThumbnails->Clear();
     589           0 :     set_width_request(mpAllRecentThumbnails->get_width_request() + mpAllButtonsBox->GetOptimalSize().Width());
     590         447 : }
     591             : /* vim:set shiftwidth=4 softtabstop=4 expandtab:*/

Generated by: LCOV version 1.10