LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/framework/source/services - backingwindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 319 521 61.2 %
Date: 2013-07-09 Functions: 22 34 64.7 %
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             : // autogen include statement, do not remove
      21             : 
      22             : #include "backingwindow.hxx"
      23             : #include "classes/resource.hrc"
      24             : #include "framework.hrc"
      25             : #include "classes/fwkresid.hxx"
      26             : #include <services.h>
      27             : 
      28             : #include <sal/macros.h>
      29             : 
      30             : #include "vcl/metric.hxx"
      31             : #include "vcl/mnemonic.hxx"
      32             : #include "vcl/menu.hxx"
      33             : #include "vcl/svapp.hxx"
      34             : #include "vcl/virdev.hxx"
      35             : 
      36             : #include "tools/urlobj.hxx"
      37             : 
      38             : #include "unotools/dynamicmenuoptions.hxx"
      39             : #include "unotools/historyoptions.hxx"
      40             : #include "svtools/imagemgr.hxx"
      41             : #include "svtools/svtools.hrc"
      42             : #include "svtools/langhelp.hxx"
      43             : #include "svtools/colorcfg.hxx"
      44             : 
      45             : #include "comphelper/processfactory.hxx"
      46             : #include "comphelper/sequenceashashmap.hxx"
      47             : #include "comphelper/configurationhelper.hxx"
      48             : 
      49             : #include <toolkit/awt/vclxmenu.hxx>
      50             : 
      51             : #include "cppuhelper/implbase1.hxx"
      52             : 
      53             : #include "rtl/strbuf.hxx"
      54             : #include "rtl/ustrbuf.hxx"
      55             : #include "osl/file.h"
      56             : 
      57             : #include "com/sun/star/frame/Desktop.hpp"
      58             : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
      59             : #include "com/sun/star/container/XNameAccess.hpp"
      60             : #include "com/sun/star/configuration/theDefaultProvider.hpp"
      61             : #include "com/sun/star/system/SystemShellExecute.hpp"
      62             : #include "com/sun/star/system/SystemShellExecuteFlags.hpp"
      63             : #include "com/sun/star/task/XJobExecutor.hpp"
      64             : #include "com/sun/star/util/XStringWidth.hpp"
      65             : #include <com/sun/star/util/URLTransformer.hpp>
      66             : #include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
      67             : 
      68             : using namespace ::com::sun::star::beans;
      69             : using namespace ::com::sun::star::frame;
      70             : using namespace ::com::sun::star::uno;
      71             : using namespace ::com::sun::star;
      72             : using namespace framework;
      73             : 
      74             : #define RECENT_FILE_LIST    ".uno:RecentFileList"
      75             : 
      76             : #define WRITER_URL      "private:factory/swriter"
      77             : #define CALC_URL        "private:factory/scalc"
      78             : #define IMPRESS_WIZARD_URL     "private:factory/simpress?slot=6686"
      79             : #define DRAW_URL        "private:factory/sdraw"
      80             : #define BASE_URL        "private:factory/sdatabase?Interactive"
      81             : #define MATH_URL        "private:factory/smath"
      82             : #define TEMPLATE_URL    "slot:5500"
      83             : #define OPEN_URL        ".uno:Open"
      84             : 
      85           1 : DecoToolBox::DecoToolBox( Window* pParent, WinBits nStyle ) :
      86           1 :     ToolBox( pParent, nStyle )
      87             : {
      88           1 :         SetBackground();
      89           1 :         SetPaintTransparent( sal_True );
      90           1 : }
      91             : 
      92           0 : void DecoToolBox::DataChanged( const DataChangedEvent& rDCEvt )
      93             : {
      94           0 :     Window::DataChanged( rDCEvt );
      95             : 
      96           0 :     if ( rDCEvt.GetFlags() & SETTINGS_STYLE )
      97             :     {
      98           0 :         calcMinSize();
      99           0 :         SetBackground();
     100           0 :         SetPaintTransparent( sal_True );
     101             :     }
     102           0 : }
     103             : 
     104           5 : void DecoToolBox::calcMinSize()
     105             : {
     106           5 :     ToolBox aTbx( GetParent() );
     107           5 :     sal_uInt16 nItems = GetItemCount();
     108          20 :     for( sal_uInt16 i = 0; i < nItems; i++ )
     109             :     {
     110          15 :         sal_uInt16 nId = GetItemId( i );
     111          15 :         aTbx.InsertItem( nId, GetItemImage( nId ) );
     112             :     }
     113           5 :     aTbx.SetOutStyle( TOOLBOX_STYLE_FLAT );
     114           5 :     maMinSize = aTbx.CalcWindowSizePixel();
     115           5 : }
     116             : 
     117           5 : Size DecoToolBox::getMinSize()
     118             : {
     119           5 :     return maMinSize;
     120             : }
     121             : 
     122             : class RecentFilesStringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XStringWidth >
     123             : {
     124             :     public:
     125             :         RecentFilesStringLength() {}
     126             :         virtual ~RecentFilesStringLength() {}
     127             : 
     128             :         // XStringWidth
     129             :         sal_Int32 SAL_CALL queryStringWidth( const OUString& aString )
     130             :             throw (::com::sun::star::uno::RuntimeException)
     131             :         {
     132             :             return aString.getLength();
     133             :         }
     134             : };
     135             : 
     136             : #define STC_BUTTON_STYLE  (WB_LEFT | WB_VCENTER | WB_FLATBUTTON | WB_BEVELBUTTON)
     137             : 
     138           1 : BackingWindow::BackingWindow( Window* i_pParent ) :
     139             :     Window( i_pParent, FwkResId( DLG_BACKING ) ),
     140             :     maWriterButton( this, STC_BUTTON_STYLE ),
     141             :     maCalcButton( this, STC_BUTTON_STYLE ),
     142             :     maImpressButton( this, STC_BUTTON_STYLE ),
     143             :     maOpenButton( this, STC_BUTTON_STYLE ),
     144             :     maDrawButton( this, STC_BUTTON_STYLE ),
     145             :     maDBButton( this, STC_BUTTON_STYLE ),
     146             :     maMathButton( this, STC_BUTTON_STYLE ),
     147             :     maTemplateButton( this, STC_BUTTON_STYLE ),
     148             :     maToolbox( this, WB_DIALOGCONTROL ),
     149             :     maOpenString( FwkResId( STR_BACKING_FILE ) ),
     150             :     maTemplateString( FwkResId( STR_BACKING_TEMPLATE ) ),
     151             :     maButtonImageSize( 10, 10 ),
     152             :     mbInitControls( false ),
     153             :     mnHideExternalLinks( 0 ),
     154             :     mpAccExec( NULL ),
     155             :     mnBtnPos( 120 ),
     156           1 :     mnBtnTop( 150 )
     157             : {
     158           1 :     mnColumnWidth[0] = mnColumnWidth[1] = 0;
     159           1 :     mnTextColumnWidth[0] = mnTextColumnWidth[1] = 0;
     160             : 
     161             :     try
     162             :     {
     163           1 :         mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
     164           1 :         Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( mxContext );
     165           2 :         Sequence<Any> args(1);
     166             :         PropertyValue val(
     167             :             "nodepath",
     168             :             0,
     169             :             Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")),
     170           2 :             PropertyState_DIRECT_VALUE);
     171           1 :         args.getArray()[0] <<= val;
     172           2 :         Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
     173           1 :         if( xNameAccess.is() )
     174             :         {
     175             :             //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
     176           1 :             Any value( xNameAccess->getByName("StartCenterHideExternalLinks") );
     177           1 :             mnHideExternalLinks = value.get<sal_Int32>();
     178             :         }
     179             : 
     180             :         mxPopupMenuFactory.set(
     181           1 :             frame::PopupMenuControllerFactory::create( mxContext ) );
     182             :         // TODO If there is no PopupMenuController, the button should be a nomral one not a MenuButton
     183           3 :         if ( mxPopupMenuFactory->hasController(
     184           2 :             OUString( RECENT_FILE_LIST ) , OUString("com.sun.star.frame.StartModule") ) )
     185             :         {
     186           2 :             mxPopupMenu.set( mxContext->getServiceManager()->createInstanceWithContext(
     187           1 :                 OUString( "com.sun.star.awt.PopupMenu" ), mxContext ), uno::UNO_QUERY_THROW );
     188           1 :         }
     189             :     }
     190           0 :     catch (const Exception& e)
     191             :     {
     192             :         SAL_WARN( "fwk", "BackingWindow - caught an exception! " << e.Message );
     193             :     }
     194             : 
     195           1 :     OUString aExtHelpText( FwkResId( STR_BACKING_EXTHELP ) );
     196           2 :     OUString aInfoHelpText( FwkResId( STR_BACKING_INFOHELP ) );
     197           2 :     OUString aTplRepHelpText( FwkResId( STR_BACKING_TPLREP ) );
     198             : 
     199             :     // clean up resource stack
     200           1 :     FreeResource();
     201             : 
     202             :     // fdo#34392: we do the layout dynamically, the layout depends on the font,
     203             :     // so we should handle data changed events (font changing) of the last child
     204             :     // control, at this point all the controls have updated settings (i.e. font).
     205           1 :     maToolbox.AddEventListener( LINK( this, BackingWindow, WindowEventListener ) );
     206           1 :     EnableChildTransparentMode();
     207             : 
     208           1 :     SetStyle( GetStyle() | WB_DIALOGCONTROL );
     209             : 
     210             :     // force tab cycling in toolbox
     211           1 :     maToolbox.SetStyle( maToolbox.GetStyle() | WB_FORCETABCYCLE );
     212             : 
     213             :     // insert toolbox items
     214           1 :     maToolbox.InsertItem( nItemId_TplRep, Image() );
     215           1 :     maToolbox.SetItemText( nItemId_TplRep, aTplRepHelpText );
     216           1 :     maToolbox.SetQuickHelpText( nItemId_TplRep, aTplRepHelpText );
     217           1 :     maToolbox.SetItemCommand( nItemId_TplRep, String( ".HelpId:StartCenter:TemplateRepository"  ) );
     218           1 :     maToolbox.ShowItem( nItemId_TplRep );
     219             : 
     220           1 :     maToolbox.InsertItem( nItemId_Extensions, Image() );
     221           1 :     maToolbox.SetQuickHelpText( nItemId_Extensions, aExtHelpText );
     222           1 :     maToolbox.SetItemText( nItemId_Extensions, aExtHelpText );
     223           1 :     maToolbox.SetItemCommand( nItemId_Extensions, String( ".HelpId:StartCenter:Extensions"  ) );
     224           1 :     maToolbox.ShowItem( nItemId_Extensions );
     225             : 
     226           1 :     maToolbox.InsertItem( nItemId_Info, Image() );
     227           1 :     maToolbox.SetItemText( nItemId_Info, aInfoHelpText );
     228           1 :     maToolbox.SetQuickHelpText( nItemId_Info, aInfoHelpText );
     229           1 :     maToolbox.SetItemCommand( nItemId_Info, String( ".HelpId:StartCenter:Info"  ) );
     230           1 :     maToolbox.ShowItem( nItemId_Info );
     231             : 
     232             :     // get dispatch provider
     233           2 :     Reference<XDesktop2> xDesktop = Desktop::create( comphelper::getProcessComponentContext() );
     234           1 :     mxDesktopDispatchProvider = xDesktop;
     235             : 
     236           1 :     maWriterButton.SetHelpId( ".HelpId:StartCenter:WriterButton" );
     237           1 :     maCalcButton.SetHelpId( ".HelpId:StartCenter:CalcButton" );
     238           1 :     maImpressButton.SetHelpId( ".HelpId:StartCenter:ImpressButton" );
     239           1 :     maDrawButton.SetHelpId( ".HelpId:StartCenter:DrawButton" );
     240           1 :     maDBButton.SetHelpId( ".HelpId:StartCenter:DBButton" );
     241           1 :     maMathButton.SetHelpId( ".HelpId:StartCenter:MathButton" );
     242           1 :     maTemplateButton.SetHelpId( ".HelpId:StartCenter:TemplateButton" );
     243           1 :     maOpenButton.SetHelpId( ".HelpId:StartCenter:OpenButton" );
     244           1 :     maToolbox.SetHelpId( ".HelpId:StartCenter:Toolbox" );
     245             : 
     246             :     // init background
     247           1 :     initBackground();
     248             : 
     249             :     // add some breathing space for the images
     250           1 :     maButtonImageSize.Width() += 12;
     251           1 :     maButtonImageSize.Height() += 12;
     252             : 
     253             :     // set a slighly larger font than normal labels on the texts
     254           1 :     maTextFont.SetSize( Size( 0, 11 ) );
     255           2 :     maTextFont.SetWeight( WEIGHT_NORMAL );
     256           1 : }
     257             : 
     258             : 
     259           3 : BackingWindow::~BackingWindow()
     260             : {
     261           1 :     maToolbox.RemoveEventListener( LINK( this, BackingWindow, WindowEventListener ) );
     262           1 :     delete mpAccExec;
     263             : 
     264           1 :     if( mxPopupMenuController.is() )
     265             :     {
     266           0 :         Reference< lang::XComponent > xComponent( mxPopupMenuController, UNO_QUERY );
     267           0 :         if( xComponent.is() )
     268             :         {
     269             :             try
     270             :             {
     271           0 :                 xComponent->dispose();
     272             :             }
     273           0 :             catch (...)
     274             :             {}
     275             :         }
     276           0 :         mxPopupMenuController.clear();
     277             :     }
     278           1 :     mxPopupMenuFactory.clear();
     279           1 :     mxPopupMenu.clear();
     280           2 : }
     281             : 
     282           2 : void BackingWindow::GetFocus()
     283             : {
     284           2 :     if( IsVisible() )
     285           2 :         maWriterButton.GrabFocus();
     286           2 :     Window::GetFocus();
     287           2 : }
     288             : 
     289             : class ImageContainerRes : public Resource
     290             : {
     291             :     public:
     292           1 :     ImageContainerRes( const ResId& i_rId ) : Resource( i_rId ) {}
     293           1 :     ~ImageContainerRes() { FreeResource(); }
     294             : };
     295             : 
     296          34 : IMPL_LINK( BackingWindow, WindowEventListener, VclSimpleEvent*, pEvent )
     297             : {
     298          17 :     VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>( pEvent );
     299          17 :     if ( pWinEvent && pWinEvent->GetId() == VCLEVENT_WINDOW_DATACHANGED )
     300             :     {
     301             :         DataChangedEvent* pDCEvt =
     302           0 :             static_cast<DataChangedEvent*>( pWinEvent->GetData() );
     303           0 :         if ( pDCEvt->GetFlags() & SETTINGS_STYLE )
     304             :         {
     305           0 :             initBackground();
     306           0 :             Invalidate();
     307             :             // fdo#34392: Resize buttons to match the new text size.
     308           0 :             Resize();
     309             :         }
     310             :     }
     311          17 :     return 0;
     312             : }
     313             : 
     314           0 : void BackingWindow::prepareRecentFileMenu()
     315             : {
     316           0 :     if( ! mxPopupMenu.is() )
     317           0 :         return;
     318             : 
     319           0 :     if ( !mxPopupMenuController.is() )
     320             :     {
     321           0 :         uno::Sequence< uno::Any > aArgs( 2 );
     322           0 :         beans::PropertyValue aProp;
     323             : 
     324           0 :         aProp.Name = OUString( "Frame" );
     325           0 :         aProp.Value <<= mxFrame;
     326           0 :         aArgs[0] <<= aProp;
     327             : 
     328           0 :         aProp.Name = OUString( "ModuleIdentifier" );
     329           0 :         aProp.Value <<= OUString("com.sun.star.frame.StartModule");
     330           0 :         aArgs[1] <<= aProp;
     331             :         try
     332             :         {
     333             :             mxPopupMenuController.set(
     334           0 :                 mxPopupMenuFactory->createInstanceWithArgumentsAndContext(
     335           0 :                     OUString( RECENT_FILE_LIST ), aArgs, mxContext),
     336           0 :                         uno::UNO_QUERY_THROW );
     337           0 :             mxPopupMenuController->setPopupMenu( mxPopupMenu );
     338             :         }
     339           0 :         catch ( const Exception &e )
     340             :         {
     341             :             SAL_WARN( "fwk", "BackingWindow - caught an exception! " << e.Message );
     342             :         }
     343             : 
     344           0 :         PopupMenu *pRecentMenu = NULL;
     345           0 :         VCLXMenu* pTKMenu = VCLXMenu::GetImplementation( mxPopupMenu );
     346           0 :         if ( pTKMenu )
     347           0 :             pRecentMenu = dynamic_cast< PopupMenu * >( pTKMenu->GetMenu() );
     348           0 :         maOpenButton.SetPopupMenu( pRecentMenu );
     349             :     }
     350             : }
     351             : 
     352             : namespace
     353             : {
     354           8 : static void lcl_SetBlackButtonTextColor( PushButton& rButton )
     355             : {
     356           8 :     AllSettings aSettings = rButton.GetSettings();
     357          16 :     StyleSettings aStyleSettings = aSettings.GetStyleSettings();
     358           8 :     aStyleSettings.SetButtonTextColor( Color(COL_BLACK) );
     359           8 :     aSettings.SetStyleSettings( aStyleSettings );
     360          16 :     rButton.SetSettings( aSettings );
     361           8 : }
     362             : }
     363             : 
     364           1 : void BackingWindow::initBackground()
     365             : {
     366           1 :     SetBackground();
     367             : 
     368             :     // select image set
     369           1 :     ImageContainerRes aRes( FwkResId( RES_BACKING_IMAGES ) );
     370             : 
     371             :     // scale middle segment
     372           1 :     Size aMiddleSize;
     373           1 :     if( !! maBackgroundMiddle )
     374           0 :         aMiddleSize = maBackgroundMiddle.GetSizePixel();
     375             :     // load middle segment
     376             : 
     377           1 :     Application::LoadBrandBitmap ("shell/backing_space", maBackgroundMiddle);
     378             : 
     379             :     // and scale it to previous size
     380           1 :     if( aMiddleSize.Width() && aMiddleSize.Height() )
     381           0 :         maBackgroundMiddle.Scale( aMiddleSize );
     382             : 
     383           1 :     if( GetSettings().GetLayoutRTL() )
     384             :     {
     385             :         // replace images by RTL versions
     386           0 :         Application::LoadBrandBitmap ("shell/backing_rtl_right", maBackgroundLeft);
     387           0 :         Application::LoadBrandBitmap ("shell/backing_rtl_left", maBackgroundRight);
     388             :     }
     389             :     else
     390             :     {
     391           1 :         Application::LoadBrandBitmap ("shell/backing_left", maBackgroundLeft);
     392           1 :         Application::LoadBrandBitmap ("shell/backing_right", maBackgroundRight);
     393             :     }
     394           1 :     maToolbox.SetItemImage( nItemId_Extensions, BitmapEx( FwkResId( BMP_BACKING_EXT ) ) );
     395             : //###    maToolbox.SetItemImage( nItemId_Reg, BitmapEx( FwkResId( BMP_BACKING_REG ) ) );
     396           1 :     maToolbox.SetItemImage( nItemId_Info, BitmapEx( FwkResId( BMP_BACKING_INFO ) ) );
     397           1 :     maToolbox.SetItemImage( nItemId_TplRep, BitmapEx( FwkResId( BMP_BACKING_TPLREP ) ) );
     398             : 
     399             :     // get icon images from fwk resource and set them on the appropriate buttons
     400           1 :     loadImage( FwkResId( BMP_BACKING_WRITER ), maWriterButton );
     401           1 :     loadImage( FwkResId( BMP_BACKING_CALC ), maCalcButton );
     402           1 :     loadImage( FwkResId( BMP_BACKING_IMPRESS ), maImpressButton );
     403           1 :     loadImage( FwkResId( BMP_BACKING_DRAW ), maDrawButton );
     404           1 :     loadImage( FwkResId( BMP_BACKING_DATABASE ), maDBButton );
     405           1 :     loadImage( FwkResId( BMP_BACKING_FORMULA ), maMathButton );
     406           1 :     loadImage( FwkResId( BMP_BACKING_OPENFILE ), maOpenButton );
     407           1 :     loadImage( FwkResId( BMP_BACKING_OPENTEMPLATE ), maTemplateButton );
     408             : 
     409           1 :     maOpenButton.SetMenuMode( MENUBUTTON_MENUMODE_TIMED );
     410           1 :     maOpenButton.SetActivateHdl( LINK( this, BackingWindow, ActivateHdl ) );
     411             : 
     412             :     // fdo#41440: force black text color, since the background image is white.
     413           1 :     lcl_SetBlackButtonTextColor( maWriterButton );
     414           1 :     lcl_SetBlackButtonTextColor( maCalcButton );
     415           1 :     lcl_SetBlackButtonTextColor( maImpressButton );
     416           1 :     lcl_SetBlackButtonTextColor( maOpenButton );
     417           1 :     lcl_SetBlackButtonTextColor( maDrawButton );
     418           1 :     lcl_SetBlackButtonTextColor( maDBButton );
     419           1 :     lcl_SetBlackButtonTextColor( maMathButton );
     420           1 :     lcl_SetBlackButtonTextColor( maTemplateButton );
     421           1 : }
     422             : 
     423           1 : void BackingWindow::initControls()
     424             : {
     425           1 :     if( mbInitControls )
     426           1 :         return;
     427             : 
     428           1 :     mbInitControls = true;
     429             : 
     430             :     // calculate dialog size
     431             :     // begin with background bitmap
     432           1 :     maControlRect = Rectangle( Point(), maBackgroundLeft.GetSizePixel() );
     433           1 :     maControlRect.Left() += nShadowLeft;
     434           1 :     maControlRect.Right() -= nShadowRight;
     435           1 :     maControlRect.Top() += nShadowTop;
     436           1 :     maControlRect.Bottom() -= nShadowBottom;
     437             : 
     438           1 :     long nYPos = 0;
     439             : 
     440           1 :     if( maControlRect.GetWidth() < mnBtnPos + 20 )
     441           0 :         maControlRect.Right() = maControlRect.Left() + mnBtnPos + 20;
     442             : 
     443           1 :     if( maControlRect.GetWidth() < mnBtnPos + 10 )
     444           0 :         maControlRect.Right() = maControlRect.Left() + mnBtnPos + 10;
     445             : 
     446             :     // collect the URLs of the entries in the File/New menu
     447           1 :     SvtModuleOptions    aModuleOptions;
     448           2 :     std::set< OUString > aFileNewAppsAvailable;
     449           2 :     SvtDynamicMenuOptions aOpt;
     450           2 :     Sequence < Sequence < PropertyValue > > aNewMenu = aOpt.GetMenu( E_NEWMENU );
     451           2 :     const OUString sURLKey( "URL"  );
     452             : 
     453           1 :     const Sequence< PropertyValue >* pNewMenu = aNewMenu.getConstArray();
     454           1 :     const Sequence< PropertyValue >* pNewMenuEnd = aNewMenu.getConstArray() + aNewMenu.getLength();
     455          16 :     for ( ; pNewMenu != pNewMenuEnd; ++pNewMenu )
     456             :     {
     457          15 :         comphelper::SequenceAsHashMap aEntryItems( *pNewMenu );
     458          30 :         OUString sURL( aEntryItems.getUnpackedValueOrDefault( sURLKey, OUString() ) );
     459          15 :         if ( !sURL.isEmpty() )
     460          15 :             aFileNewAppsAvailable.insert( sURL );
     461          15 :     }
     462             : 
     463             :     // create mnemonics on the fly, preregister the mnemonics of the menu
     464           2 :     MnemonicGenerator aMnemns;
     465           1 :     maTemplateString = MnemonicGenerator::EraseAllMnemonicChars( maTemplateString );
     466           1 :     maOpenString = MnemonicGenerator::EraseAllMnemonicChars( maOpenString );
     467             : 
     468           1 :     SystemWindow* pSysWin = GetSystemWindow();
     469           1 :     if( pSysWin )
     470             :     {
     471           1 :         MenuBar* pMBar = pSysWin->GetMenuBar();
     472           1 :         if( pMBar )
     473             :         {
     474           7 :             for( sal_uInt16 i = 0; i < pMBar->GetItemCount(); i++ )
     475             :             {
     476           6 :                 sal_uInt16 nItemId = pMBar->GetItemId( i );
     477           6 :                 String aItemText( pMBar->GetItemText( nItemId ) );
     478           6 :                 if( aItemText.Len() )
     479           6 :                     aMnemns.RegisterMnemonic( aItemText );
     480           6 :             }
     481             :         }
     482             :     }
     483             : 
     484             :     // layout the buttons
     485             :     layoutButton( WRITER_URL, 0, 0, aFileNewAppsAvailable,
     486             :                   aModuleOptions, SvtModuleOptions::E_SWRITER,
     487           1 :                   maWriterButton, aMnemns );
     488             :     layoutButton( DRAW_URL, 1, 0, aFileNewAppsAvailable,
     489             :                   aModuleOptions, SvtModuleOptions::E_SDRAW,
     490           1 :                   maDrawButton, aMnemns );
     491           1 :     nYPos += maButtonImageSize.Height() + 10;
     492             :     layoutButton( CALC_URL, 0, 0, aFileNewAppsAvailable,
     493             :                   aModuleOptions, SvtModuleOptions::E_SCALC,
     494           1 :                   maCalcButton, aMnemns );
     495             :     layoutButton( BASE_URL, 1, 0, aFileNewAppsAvailable,
     496             :                   aModuleOptions, SvtModuleOptions::E_SDATABASE,
     497           1 :                   maDBButton, aMnemns );
     498           1 :     nYPos += maButtonImageSize.Height() + 10;
     499             :     layoutButton( IMPRESS_WIZARD_URL, 0, 0, aFileNewAppsAvailable,
     500             :                   aModuleOptions, SvtModuleOptions::E_SIMPRESS,
     501           1 :                   maImpressButton, aMnemns );
     502             :     layoutButton( MATH_URL, 1, 0, aFileNewAppsAvailable,
     503             :                   aModuleOptions, SvtModuleOptions::E_SMATH,
     504           1 :                   maMathButton, aMnemns );
     505             : 
     506           1 :     nYPos += 3*maButtonImageSize.Height() / 2;
     507             : 
     508             :     layoutButton( NULL, 0, 18, aFileNewAppsAvailable,
     509             :                   aModuleOptions, SvtModuleOptions::E_SWRITER,
     510           1 :                   maOpenButton, aMnemns, maOpenString );
     511             :     layoutButton( NULL, 1, 0, aFileNewAppsAvailable,
     512             :                   aModuleOptions, SvtModuleOptions::E_SWRITER,
     513           1 :                   maTemplateButton, aMnemns, maTemplateString );
     514           1 :     nYPos += 10;
     515             : 
     516             :     DBG_ASSERT( nYPos < maControlRect.GetHeight(), "misformatting !" );
     517           1 :     if( mnColumnWidth[0] + mnColumnWidth[1] + mnBtnPos + 20 > maControlRect.GetWidth() )
     518           1 :         maControlRect.Right() = maControlRect.Left() + mnColumnWidth[0] + mnColumnWidth[1] + mnBtnPos + 20;
     519             : 
     520           1 :     mnTextColumnWidth[0] = mnColumnWidth[0];
     521           1 :     mnTextColumnWidth[1] = mnColumnWidth[1];
     522             : 
     523           1 :     if( mnTextColumnWidth[1] > mnTextColumnWidth[0] )
     524             :     {
     525           0 :         mnColumnWidth[0]     = mnColumnWidth[1];
     526           0 :         mnTextColumnWidth[0] = mnTextColumnWidth[1];
     527             :     }
     528             :     else
     529             :     {
     530           1 :         mnColumnWidth[1]     = mnColumnWidth[0];
     531           1 :         mnTextColumnWidth[1] = mnTextColumnWidth[0];
     532             :     }
     533           1 :     if( maControlRect.GetWidth() < maControlRect.GetHeight() * 3 / 2 )
     534             :     {
     535           1 :         maControlRect.Right() = maControlRect.Left() + maControlRect.GetHeight() * 3 / 2;
     536           1 :         long nDelta = (maControlRect.GetWidth() - mnBtnPos - mnColumnWidth[1] - mnColumnWidth[0] - 20);
     537           1 :         mnColumnWidth[0] += nDelta/2;
     538           1 :         mnColumnWidth[1] += nDelta/2;
     539             :     }
     540             : 
     541           1 :     maToolbox.SetSelectHdl( LINK( this, BackingWindow, ToolboxHdl ) );
     542           1 :     if( mnHideExternalLinks == 0 )
     543           1 :         maToolbox.Show();
     544             : 
     545             :     // scale middle map to formatted width
     546           2 :     Size aMiddleSegmentSize( maControlRect.GetSize().Width() + nShadowLeft + nShadowRight,
     547           2 :                              maBackgroundMiddle.GetSizePixel().Height() );
     548             : 
     549           1 :     long nLW = maBackgroundLeft.GetSizePixel().Width();
     550           1 :     long nRW = maBackgroundRight.GetSizePixel().Width();
     551           1 :     if( aMiddleSegmentSize.Width() > nLW + nRW )
     552             :     {
     553           1 :         aMiddleSegmentSize.Width() -= nLW;
     554           1 :         aMiddleSegmentSize.Width() -= nRW;
     555           1 :         maBackgroundMiddle.Scale( aMiddleSegmentSize );
     556             :     }
     557             :     else
     558           0 :         maBackgroundMiddle = BitmapEx();
     559             : 
     560           1 :     Resize();
     561             : 
     562           2 :     maWriterButton.GrabFocus();
     563             : }
     564             : 
     565           8 : void BackingWindow::loadImage( const ResId& i_rId, PushButton& i_rButton )
     566             : {
     567           8 :     BitmapEx aBmp( i_rId );
     568           8 :     Size aImgSize( aBmp.GetSizePixel() );
     569           8 :     if( aImgSize.Width() > maButtonImageSize.Width() )
     570           1 :         maButtonImageSize.Width() = aImgSize.Width();
     571           8 :     if( aImgSize.Height() > maButtonImageSize.Height() )
     572           1 :         maButtonImageSize.Height() = aImgSize.Height();
     573           8 :     i_rButton.SetModeImage( aBmp );
     574           8 : }
     575             : 
     576           8 : void BackingWindow::layoutButton(
     577             :                           const char* i_pURL, int nColumn, int i_nExtraWidth,
     578             :                           const std::set<OUString>& i_rURLS,
     579             :                           SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod,
     580             :                           PushButton& i_rBtn,
     581             :                           MnemonicGenerator& i_rMnemns,
     582             :                           const String& i_rStr
     583             :                           )
     584             : {
     585           8 :     OUString aURL( i_pURL ? OUString::createFromAscii( i_pURL ) : OUString() );
     586             :     // setup button
     587           8 :     i_rBtn.SetPaintTransparent( sal_True );
     588           8 :     i_rBtn.SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
     589           8 :     if( i_pURL && (! i_rOpt.IsModuleInstalled( i_eMod ) || i_rURLS.find( aURL ) == i_rURLS.end()) )
     590             :     {
     591           0 :         i_rBtn.Enable( sal_False );
     592             :     }
     593             : 
     594             :     // setup text
     595           8 :     i_rBtn.SetFont( maTextFont );
     596           8 :     i_rBtn.SetControlFont( maTextFont );
     597          16 :     String aText( i_rStr.Len() ? i_rStr : SvFileInformationManager::GetDescription( INetURLObject( aURL ) ) );
     598           8 :     i_rMnemns.CreateMnemonic( aText );
     599           8 :     i_rBtn.SetText( aText );
     600             : 
     601           8 :     long nTextWidth = i_rBtn.GetTextWidth( i_rBtn.GetText() );
     602             : 
     603           8 :     nTextWidth += maButtonImageSize.Width() + 8 + i_nExtraWidth; // add some fuzz to be on the safe side
     604           8 :     if( nColumn >= 0 && nColumn < static_cast<int>(sizeof (mnColumnWidth) / sizeof (mnColumnWidth[0])) )
     605             :     {
     606           8 :         if( nTextWidth > mnColumnWidth[nColumn] )
     607           4 :             mnColumnWidth[nColumn] = nTextWidth;
     608             :     }
     609             : 
     610           8 :     i_rBtn.SetImageAlign( IMAGEALIGN_LEFT );
     611             :     // show the controls
     612          16 :     i_rBtn.Show();
     613           8 : }
     614             : 
     615           2 : void BackingWindow::Paint( const Rectangle& )
     616             : {
     617           2 :     Resize();
     618             : 
     619           2 :     Wallpaper aBack( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor );
     620           4 :     Region aClip( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
     621           2 :     Rectangle aBmpRect(maControlRect);
     622           2 :     aBmpRect.Left()   -= nShadowLeft;
     623           2 :     aBmpRect.Top()    -= nShadowTop;
     624           2 :     aBmpRect.Right()  += nShadowRight;
     625           2 :     aBmpRect.Bottom() += nShadowBottom;
     626           2 :     aClip.Exclude( aBmpRect );
     627           2 :     Push( PUSH_CLIPREGION );
     628           2 :     IntersectClipRegion( aClip );
     629           2 :     DrawWallpaper( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ), aBack );
     630           2 :     Pop();
     631             : 
     632           4 :     VirtualDevice aDev( *this );
     633           2 :     aDev.EnableRTL( IsRTLEnabled() );
     634           2 :     aDev.SetOutputSizePixel( aBmpRect.GetSize() );
     635           2 :     Point aOffset( Point( 0, 0 ) - aBmpRect.TopLeft() );
     636           2 :     aDev.DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );
     637             : 
     638             :     // draw bitmap
     639           2 :     Point aTL( 0, 0 );
     640           2 :     aDev.DrawBitmapEx( aTL, maBackgroundLeft );
     641           2 :     aTL.X() += maBackgroundLeft.GetSizePixel().Width();
     642           2 :     if( !!maBackgroundMiddle )
     643             :     {
     644           2 :         aDev.DrawBitmapEx( aTL, maBackgroundMiddle );
     645           2 :         aTL.X() += maBackgroundMiddle.GetSizePixel().Width();
     646             :     }
     647           2 :     aDev.DrawBitmapEx( aTL, maBackgroundRight );
     648             : 
     649             :     DrawOutDev( aBmpRect.TopLeft(), aBmpRect.GetSize(),
     650             :                 Point( 0, 0 ), aBmpRect.GetSize(),
     651           4 :                 aDev );
     652           2 : }
     653             : 
     654          19 : long BackingWindow::Notify( NotifyEvent& rNEvt )
     655             : {
     656          19 :     if( rNEvt.GetType() == EVENT_KEYINPUT )
     657             :     {
     658           0 :         if( ! mpAccExec )
     659             :         {
     660           0 :             mpAccExec = svt::AcceleratorExecute::createAcceleratorHelper();
     661           0 :             mpAccExec->init( comphelper::getProcessComponentContext(), mxFrame);
     662             :         }
     663             : 
     664           0 :         const KeyEvent* pEvt = rNEvt.GetKeyEvent();
     665           0 :         const KeyCode& rKeyCode(pEvt->GetKeyCode());
     666           0 :         if( pEvt && mpAccExec->execute(rKeyCode) )
     667           0 :             return 1;
     668             :         // #i110344# extrawurst: specialized arrow key control
     669           0 :         if( rKeyCode.GetModifier() == 0 )
     670             :         {
     671           0 :             if( rKeyCode.GetCode() == KEY_RIGHT )
     672             :             {
     673           0 :                 if( maWriterButton.HasFocus() )
     674           0 :                     maDrawButton.GrabFocus();
     675           0 :                 else if( maCalcButton.HasFocus() )
     676           0 :                     maDBButton.GrabFocus();
     677           0 :                 else if( maImpressButton.HasFocus() )
     678           0 :                     maMathButton.GrabFocus();
     679           0 :                 else if( maOpenButton.HasFocus() )
     680           0 :                     maTemplateButton.GrabFocus();
     681           0 :                 return 1;
     682             :             }
     683           0 :             else if( rKeyCode.GetCode() == KEY_LEFT )
     684             :             {
     685           0 :                 if( maDrawButton.HasFocus() )
     686           0 :                     maWriterButton.GrabFocus();
     687           0 :                 else if( maDBButton.HasFocus() )
     688           0 :                     maCalcButton.GrabFocus();
     689           0 :                 else if( maMathButton.HasFocus() )
     690           0 :                     maImpressButton.GrabFocus();
     691           0 :                 else if( maTemplateButton.HasFocus() )
     692           0 :                     maOpenButton.GrabFocus();
     693           0 :                 return 1;
     694             :             }
     695           0 :             else if( rKeyCode.GetCode() == KEY_UP )
     696             :             {
     697             :                 // first column
     698           0 :                 if( maOpenButton.HasFocus() )
     699           0 :                     maImpressButton.GrabFocus();
     700           0 :                 else if( maImpressButton.HasFocus() )
     701           0 :                     maCalcButton.GrabFocus();
     702           0 :                 else if( maCalcButton.HasFocus() )
     703           0 :                     maWriterButton.GrabFocus();
     704             :                 // second column
     705           0 :                 else if( maTemplateButton.HasFocus() )
     706           0 :                     maMathButton.GrabFocus();
     707           0 :                 else if( maMathButton.HasFocus() )
     708           0 :                     maDBButton.GrabFocus();
     709           0 :                 else if( maDBButton.HasFocus() )
     710           0 :                     maDrawButton.GrabFocus();
     711           0 :                 return 1;
     712             :             }
     713           0 :             else if( rKeyCode.GetCode() == KEY_DOWN )
     714             :             {
     715             :                 // first column
     716           0 :                 if( maWriterButton.HasFocus() )
     717           0 :                     maCalcButton.GrabFocus();
     718           0 :                 else if( maCalcButton.HasFocus() )
     719           0 :                     maImpressButton.GrabFocus();
     720           0 :                 else if( maImpressButton.HasFocus() )
     721           0 :                     maOpenButton.GrabFocus();
     722             :                 // second column
     723           0 :                 else if( maDrawButton.HasFocus() )
     724           0 :                     maDBButton.GrabFocus();
     725           0 :                 else if( maDBButton.HasFocus() )
     726           0 :                     maMathButton.GrabFocus();
     727           0 :                 else if( maMathButton.HasFocus() )
     728           0 :                     maTemplateButton.GrabFocus();
     729           0 :                 return 1;
     730             :             }
     731             :         }
     732             :     }
     733          19 :     return Window::Notify( rNEvt );
     734             : }
     735             : 
     736           1 : void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame )
     737             : {
     738           1 :     mxFrame = xFrame;
     739           1 :     if( ! mbInitControls )
     740           1 :         initControls();
     741           1 : }
     742             : 
     743           5 : void BackingWindow::Resize()
     744             : {
     745           5 :     Size aWindowSize( GetSizePixel() );
     746           5 :     Size aControlSize = maControlRect.GetSize();
     747           5 :     maControlRect = Rectangle( Point( (aWindowSize.Width() - aControlSize.Width()) / 2,
     748           5 :                                       (aWindowSize.Height() - aControlSize.Height()) / 2 ),
     749          10 :                                aControlSize );
     750             : 
     751           5 :     maToolbox.calcMinSize();
     752           5 :     Size aTBSize( maToolbox.getMinSize() );
     753           5 :     Point aTBPos( maControlRect.Left() + mnBtnPos,
     754          10 :                   maControlRect.Bottom() - aTBSize.Height() - 10 );
     755           5 :     if( Application::GetSettings().GetLayoutRTL() )
     756           0 :         aTBPos.X() = maControlRect.Right() - aTBSize.Width() - mnBtnPos;
     757           5 :     maToolbox.SetPosSizePixel( aTBPos, aTBSize );
     758             : 
     759             :     // #i93631# squeeze controls so they fit into the box
     760             :     // this can be necessary due to application font height which has small deviations
     761             :     // from the size set
     762           5 :     const long nBDelta    = maButtonImageSize.Height() + 10;
     763           5 :     const long nB2Delta   = 3*maButtonImageSize.Height()/2;
     764           5 :     const long nLastDelta = maButtonImageSize.Height();
     765           5 :     long nDiff = 0;
     766       28631 :     while( ( maControlRect.Top()   -
     767       19084 :              3 * nDiff +
     768       19084 :              3 * (nBDelta - nDiff) +
     769       19084 :                  (nB2Delta- nDiff) +
     770             :                  nLastDelta
     771        9542 :             ) > aTBPos.Y() )
     772             :     {
     773        9537 :         nDiff++;
     774             :     }
     775             : 
     776           5 :     long nYPos = maControlRect.Top() + mnBtnTop;
     777             : 
     778             :     // Recompute column widths
     779           5 :     mnTextColumnWidth[0] = maWriterButton.GetTextWidth( maWriterButton.GetText() ) + maButtonImageSize.Width() + 8;
     780           5 :     if( mnTextColumnWidth[0] < maCalcButton.GetTextWidth( maCalcButton.GetText() ) + maButtonImageSize.Width() + 8 )
     781           0 :         mnTextColumnWidth[0] = maCalcButton.GetTextWidth( maCalcButton.GetText() ) + maButtonImageSize.Width() + 8;
     782           5 :     if( mnTextColumnWidth[0] < maImpressButton.GetTextWidth( maImpressButton.GetText() ) + maButtonImageSize.Width() + 8 )
     783           0 :         mnTextColumnWidth[0] = maImpressButton.GetTextWidth( maImpressButton.GetText() ) + maButtonImageSize.Width() + 8;
     784           5 :     if( mnTextColumnWidth[0] < maOpenButton.GetTextWidth( maOpenButton.GetText() ) + maButtonImageSize.Width() + 26 )
     785           2 :         mnTextColumnWidth[0] = maOpenButton.GetTextWidth( maOpenButton.GetText() ) + maButtonImageSize.Width() + 26;
     786             : 
     787           5 :     mnTextColumnWidth[1] = maDrawButton.GetTextWidth( maDrawButton.GetText() ) + maButtonImageSize.Width() + 8;
     788           5 :     if( mnTextColumnWidth[1] < maDBButton.GetTextWidth( maDBButton.GetText() ) + maButtonImageSize.Width() + 8 )
     789           3 :         mnTextColumnWidth[1] = maDBButton.GetTextWidth( maDBButton.GetText() ) + maButtonImageSize.Width() + 8;
     790           5 :     if( mnTextColumnWidth[1] < maMathButton.GetTextWidth( maMathButton.GetText() ) + maButtonImageSize.Width() + 8 )
     791           0 :         mnTextColumnWidth[1] = maMathButton.GetTextWidth( maMathButton.GetText() ) + maButtonImageSize.Width() + 8;
     792           5 :     if( mnTextColumnWidth[1] < maTemplateButton.GetTextWidth( maTemplateButton.GetText() ) + maButtonImageSize.Width() + 8 )
     793           3 :         mnTextColumnWidth[1] = maTemplateButton.GetTextWidth( maTemplateButton.GetText() ) + maButtonImageSize.Width() + 8;
     794             : 
     795           5 :     maWriterButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
     796           5 :     maDrawButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
     797           5 :     nYPos += nBDelta - nDiff;
     798           5 :     maCalcButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
     799           5 :     maDBButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
     800           5 :     nYPos += nBDelta - nDiff;
     801           5 :     maImpressButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
     802           5 :     maMathButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
     803             : 
     804           5 :     nYPos += nB2Delta - nDiff;
     805           5 :     maOpenButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos, nYPos ), Size( mnTextColumnWidth[0], maButtonImageSize.Height() ) );
     806           5 :     maTemplateButton.SetPosSizePixel( Point( maControlRect.Left() + mnBtnPos + mnColumnWidth[0], nYPos ), Size( mnTextColumnWidth[1], maButtonImageSize.Height() ) );
     807             : 
     808           5 :     if( !IsInPaint())
     809           3 :         Invalidate();
     810           5 : }
     811             : 
     812           0 : IMPL_LINK_NOARG(BackingWindow, ToolboxHdl)
     813             : {
     814           0 :     const char* pNodePath = NULL;
     815           0 :     const char* pNode = NULL;
     816             : 
     817           0 :     switch( maToolbox.GetCurItemId() )
     818             :     {
     819             :     case nItemId_Extensions:
     820           0 :         pNodePath = "/org.openoffice.Office.Common/Help/StartCenter";
     821           0 :         pNode = "AddFeatureURL";
     822           0 :         break;
     823             :     case nItemId_Info:
     824           0 :         pNodePath = "/org.openoffice.Office.Common/Help/StartCenter";
     825           0 :         pNode = "InfoURL";
     826           0 :         break;
     827             :     case nItemId_TplRep:
     828           0 :         pNodePath = "/org.openoffice.Office.Common/Help/StartCenter";
     829           0 :         pNode = "TemplateRepositoryURL";
     830           0 :         break;
     831             :     default:
     832           0 :         break;
     833             :     }
     834           0 :     if( pNodePath && pNode )
     835             :     {
     836             :         try
     837             :         {
     838           0 :             Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
     839           0 :             Sequence<Any> args(1);
     840             :             PropertyValue val(
     841             :                 "nodepath",
     842             :                 0,
     843             :                 Any(OUString::createFromAscii(pNodePath)),
     844           0 :                 PropertyState_DIRECT_VALUE);
     845           0 :             args.getArray()[0] <<= val;
     846           0 :             Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
     847           0 :             if( xNameAccess.is() )
     848             :             {
     849           0 :                 OUString sURL;
     850             :                 //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
     851           0 :                 Any value( xNameAccess->getByName(OUString::createFromAscii(pNode)) );
     852           0 :                 sURL = value.get<OUString> ();
     853           0 :                 localizeWebserviceURI(sURL);
     854             : 
     855             :                 Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
     856           0 :                     com::sun::star::system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
     857             :                 //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
     858           0 :                 xSystemShellExecute->execute( sURL, OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY);
     859           0 :             }
     860             :         }
     861           0 :         catch (const Exception&)
     862             :         {
     863             :         }
     864             :     }
     865             : 
     866           0 :     return 0;
     867             : }
     868             : 
     869           0 : IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
     870             : {
     871             :     // dispatch the appropriate URL and end the dialog
     872           0 :     if( pButton == &maWriterButton )
     873           0 :         dispatchURL( WRITER_URL );
     874           0 :     else if( pButton == &maCalcButton )
     875           0 :         dispatchURL( CALC_URL );
     876           0 :     else if( pButton == &maImpressButton )
     877           0 :         dispatchURL( IMPRESS_WIZARD_URL );
     878           0 :     else if( pButton == &maDrawButton )
     879           0 :         dispatchURL( DRAW_URL );
     880           0 :     else if( pButton == &maDBButton )
     881           0 :         dispatchURL( BASE_URL );
     882           0 :     else if( pButton == &maMathButton )
     883           0 :         dispatchURL( MATH_URL );
     884           0 :     else if( pButton == &maOpenButton )
     885             :     {
     886           0 :         Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
     887             : 
     888           0 :         Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
     889           0 :         PropertyValue* pArg = aArgs.getArray();
     890           0 :         pArg[0].Name = "Referer";
     891           0 :         pArg[0].Value <<= OUString("private:user");
     892             : 
     893           0 :         dispatchURL( OPEN_URL, OUString(), xFrame, aArgs );
     894             :     }
     895           0 :     else if( pButton == &maTemplateButton )
     896             :     {
     897           0 :         Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
     898             : 
     899           0 :         Sequence< com::sun::star::beans::PropertyValue > aArgs(1);
     900           0 :         PropertyValue* pArg = aArgs.getArray();
     901           0 :         pArg[0].Name = OUString("Referer");
     902           0 :         pArg[0].Value <<= OUString("private:user");
     903             : 
     904           0 :         dispatchURL( TEMPLATE_URL, OUString(), xFrame, aArgs );
     905             :     }
     906           0 :     return 0;
     907             : }
     908             : 
     909           0 : IMPL_LINK( BackingWindow, ActivateHdl, Button*, pButton )
     910             : {
     911           0 :     if( pButton == &maOpenButton )
     912           0 :         prepareRecentFileMenu();
     913           0 :     return 0;
     914             : }
     915             : 
     916             : struct ImplDelayedDispatch
     917             : {
     918             :     Reference< XDispatch >      xDispatch;
     919             :     com::sun::star::util::URL   aDispatchURL;
     920             :     Sequence< PropertyValue >   aArgs;
     921             : 
     922           0 :     ImplDelayedDispatch( const Reference< XDispatch >& i_xDispatch,
     923             :                          const com::sun::star::util::URL& i_rURL,
     924             :                          const Sequence< PropertyValue >& i_rArgs )
     925             :     : xDispatch( i_xDispatch ),
     926             :       aDispatchURL( i_rURL ),
     927           0 :       aArgs( i_rArgs )
     928             :     {
     929           0 :     }
     930           0 :     ~ImplDelayedDispatch() {}
     931             : };
     932             : 
     933           0 : static long implDispatchDelayed( void*, void* pArg )
     934             : {
     935           0 :     struct ImplDelayedDispatch* pDispatch = reinterpret_cast<ImplDelayedDispatch*>(pArg);
     936             :     try
     937             :     {
     938           0 :         pDispatch->xDispatch->dispatch( pDispatch->aDispatchURL, pDispatch->aArgs );
     939             :     }
     940           0 :     catch (const Exception&)
     941             :     {
     942             :     }
     943             : 
     944             :     // clean up
     945           0 :     delete pDispatch;
     946             : 
     947           0 :     return 0;
     948             : }
     949             : 
     950           0 : void BackingWindow::dispatchURL( const OUString& i_rURL,
     951             :                                  const OUString& rTarget,
     952             :                                  const Reference< XDispatchProvider >& i_xProv,
     953             :                                  const Sequence< PropertyValue >& i_rArgs )
     954             : {
     955             :     // if no special dispatch provider is given, get the desktop
     956           0 :     Reference< XDispatchProvider > xProvider( i_xProv.is() ? i_xProv : mxDesktopDispatchProvider );
     957             : 
     958             :     // check for dispatch provider
     959           0 :     if( !xProvider.is())
     960           0 :         return;
     961             : 
     962             :     // get an URL transformer to clean up the URL
     963           0 :     com::sun::star::util::URL aDispatchURL;
     964           0 :     aDispatchURL.Complete = i_rURL;
     965             : 
     966             :     Reference < com::sun::star::util::XURLTransformer > xURLTransformer(
     967           0 :         com::sun::star::util::URLTransformer::create( comphelper::getProcessComponentContext() ) );
     968             :     try
     969             :     {
     970             :         // clean up the URL
     971           0 :         xURLTransformer->parseStrict( aDispatchURL );
     972             :         // get a Dispatch for the URL and target
     973             :         Reference< XDispatch > xDispatch(
     974           0 :             xProvider->queryDispatch( aDispatchURL, rTarget, 0 )
     975           0 :             );
     976             :         // dispatch the URL
     977           0 :         if ( xDispatch.is() )
     978             :         {
     979           0 :             ImplDelayedDispatch* pDisp = new ImplDelayedDispatch( xDispatch, aDispatchURL, i_rArgs );
     980           0 :             sal_uLong nEventId = 0;
     981           0 :             if( ! Application::PostUserEvent( nEventId, Link( NULL, implDispatchDelayed ), pDisp ) )
     982           0 :                 delete pDisp; // event could not be posted for unknown reason, at least don't leak
     983           0 :         }
     984             :     }
     985           0 :     catch (const com::sun::star::uno::RuntimeException&)
     986             :     {
     987           0 :         throw;
     988             :     }
     989           0 :     catch (const com::sun::star::uno::Exception&)
     990             :     {
     991           0 :     }
     992         402 : }
     993             : 
     994             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10