LCOV - code coverage report
Current view: top level - sfx2/source/dialog - backingwindow.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 3 288 1.0 %
Date: 2014-04-14 Functions: 2 23 8.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             : #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           1 : const Color aButtonsBackground(114, 168, 84); // TDF green
      64           1 : const Color aButtonsText(COL_WHITE);
      65             : 
      66           0 : BackingWindow::BackingWindow( Window* i_pParent ) :
      67             :     Window( i_pParent ),
      68             :     mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
      69             :     mbInitControls( false ),
      70             :     mnHideExternalLinks( 0 ),
      71           0 :     mpAccExec( NULL )
      72             : {
      73           0 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "sfx/ui/startcenter.ui", "StartCenter" );
      74             : 
      75           0 :     get(mpOpenButton, "open_all");
      76           0 :     get(mpTemplateButton, "templates_all");
      77             : 
      78           0 :     get(mpCreateLabel, "create_label");
      79             : 
      80           0 :     get(mpWriterAllButton, "writer_all");
      81           0 :     get(mpCalcAllButton, "calc_all");
      82           0 :     get(mpImpressAllButton, "impress_all");
      83           0 :     get(mpDrawAllButton, "draw_all");
      84           0 :     get(mpDBAllButton, "database_all");
      85           0 :     get(mpMathAllButton, "math_all");
      86             : 
      87           0 :     get(mpHelpButton, "help");
      88           0 :     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           0 :     WinBits nBits = mpExtensionsButton->GetStyle();
     104           0 :     nBits &= ~WB_GROUP;
     105           0 :     nBits |= WB_NOGROUP;
     106           0 :     mpExtensionsButton->SetStyle(nBits);
     107             :     assert(mpHelpButton->GetStyle() & WB_GROUP);
     108             :     assert(!(mpExtensionsButton->GetStyle() & WB_GROUP));
     109             : 
     110           0 :     get(mpAllButtonsBox, "all_buttons_box");
     111           0 :     get(mpButtonsBox, "buttons_box");
     112           0 :     get(mpSmallButtonsBox, "small_buttons_box");
     113           0 :     get(mpThinBox1, "thin_box1");
     114           0 :     get(mpThinBox2, "thin_box2");
     115           0 :     get(mpHelpBox, "help_box");
     116           0 :     get(mpExtensionsBox, "extensions_box");
     117             : 
     118           0 :     get(mpAllRecentThumbnails, "all_recent");
     119             : 
     120           0 :     maDndWindows.push_back(mpAllRecentThumbnails);
     121             : 
     122             :     try
     123             :     {
     124           0 :         mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
     125           0 :         Reference<lang::XMultiServiceFactory> xConfig = configuration::theDefaultProvider::get( mxContext );
     126           0 :         Sequence<Any> args(1);
     127             :         PropertyValue val(
     128             :             "nodepath",
     129             :             0,
     130             :             Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")),
     131           0 :             PropertyState_DIRECT_VALUE);
     132           0 :         args.getArray()[0] <<= val;
     133           0 :         Reference<container::XNameAccess> xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,args), UNO_QUERY);
     134           0 :         if( xNameAccess.is() )
     135             :         {
     136             :             //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
     137           0 :             Any value( xNameAccess->getByName("StartCenterHideExternalLinks") );
     138           0 :             mnHideExternalLinks = value.get<sal_Int32>();
     139           0 :         }
     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           0 :     EnableChildTransparentMode();
     151             : 
     152           0 :     SetStyle( GetStyle() | WB_DIALOGCONTROL );
     153             : 
     154             :     // get dispatch provider
     155           0 :     Reference<XDesktop2> xDesktop = Desktop::create( comphelper::getProcessComponentContext() );
     156           0 :     mxDesktopDispatchProvider = xDesktop;
     157             : 
     158             :     // init background
     159           0 :     SetBackground();
     160           0 : }
     161             : 
     162             : 
     163           0 : BackingWindow::~BackingWindow()
     164             : {
     165             :     // deregister drag&drop helper
     166           0 :     if (mxDropTargetListener.is())
     167             :     {
     168           0 :         for (std::vector<Window*>::iterator aI = maDndWindows.begin(),
     169           0 :             aEnd = maDndWindows.end(); aI != aEnd; ++aI)
     170             :         {
     171           0 :             Window *pDndWin = *aI;
     172             :             css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
     173           0 :                     pDndWin->GetDropTarget();
     174           0 :             if (xDropTarget.is())
     175             :             {
     176           0 :                 xDropTarget->removeDropTargetListener(mxDropTargetListener);
     177           0 :                 xDropTarget->setActive(false);
     178             :             }
     179           0 :         }
     180           0 :         mxDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
     181             :     }
     182           0 : }
     183             : 
     184           0 : void BackingWindow::initControls()
     185             : {
     186           0 :     if( mbInitControls )
     187           0 :         return;
     188             : 
     189           0 :     mbInitControls = true;
     190             : 
     191             :     // collect the URLs of the entries in the File/New menu
     192           0 :     SvtModuleOptions    aModuleOptions;
     193           0 :     std::set< OUString > aFileNewAppsAvailable;
     194           0 :     SvtDynamicMenuOptions aOpt;
     195           0 :     Sequence < Sequence < PropertyValue > > aNewMenu = aOpt.GetMenu( E_NEWMENU );
     196           0 :     const OUString sURLKey( "URL"  );
     197             : 
     198           0 :     const Sequence< PropertyValue >* pNewMenu = aNewMenu.getConstArray();
     199           0 :     const Sequence< PropertyValue >* pNewMenuEnd = aNewMenu.getConstArray() + aNewMenu.getLength();
     200           0 :     for ( ; pNewMenu != pNewMenuEnd; ++pNewMenu )
     201             :     {
     202           0 :         comphelper::SequenceAsHashMap aEntryItems( *pNewMenu );
     203           0 :         OUString sURL( aEntryItems.getUnpackedValueOrDefault( sURLKey, OUString() ) );
     204           0 :         if ( !sURL.isEmpty() )
     205           0 :             aFileNewAppsAvailable.insert( sURL );
     206           0 :     }
     207             : 
     208           0 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SWRITER))
     209           0 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_WRITER;
     210             : 
     211           0 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SCALC))
     212           0 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_CALC;
     213             : 
     214           0 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SIMPRESS))
     215           0 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_IMPRESS;
     216             : 
     217           0 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SDRAW))
     218           0 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_DRAW;
     219             : 
     220           0 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
     221           0 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_DATABASE;
     222             : 
     223           0 :     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::E_SMATH))
     224           0 :         mpAllRecentThumbnails->mnFileTypes |= TYPE_MATH;
     225             : 
     226           0 :     mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
     227           0 :     mpAllRecentThumbnails->loadRecentDocs();
     228           0 :     mpAllRecentThumbnails->ShowTooltips( true );
     229             : 
     230           0 :     setupButton( mpOpenButton );
     231           0 :     setupButton( mpTemplateButton );
     232             : 
     233           0 :     setupButton( mpWriterAllButton );
     234           0 :     setupButton( mpDrawAllButton );
     235           0 :     setupButton( mpCalcAllButton );
     236           0 :     setupButton( mpDBAllButton );
     237           0 :     setupButton( mpImpressAllButton );
     238           0 :     setupButton( mpMathAllButton );
     239             : 
     240           0 :     mpExtensionsButton->SetClickHdl(LINK(this, BackingWindow, ExtLinkClickHdl));
     241             : 
     242             :     // setup nice colors
     243           0 :     mpCreateLabel->SetControlForeground(aButtonsText);
     244           0 :     Font aFont(mpCreateLabel->GetControlFont());
     245           0 :     aFont.SetHeight(nButtonsFontSize);
     246           0 :     mpCreateLabel->SetControlFont(aFont);
     247             : 
     248           0 :     mpHelpButton->SetControlForeground(aButtonsText);
     249           0 :     mpExtensionsButton->SetControlForeground(aButtonsText);
     250             : 
     251           0 :     mpAllButtonsBox->SetBackground(aButtonsBackground);
     252           0 :     mpSmallButtonsBox->SetBackground(aButtonsBackground);
     253           0 :     mpHelpBox->SetBackground(aButtonsBackground);
     254           0 :     mpExtensionsBox->SetBackground(aButtonsBackground);
     255             : 
     256             :     // motif image under the buttons
     257           0 :     Wallpaper aWallpaper(get<FixedImage>("motif")->GetImage().GetBitmapEx());
     258           0 :     aWallpaper.SetStyle(WALLPAPER_BOTTOMRIGHT);
     259           0 :     aWallpaper.SetColor(aButtonsBackground);
     260             : 
     261           0 :     mpButtonsBox->SetBackground(aWallpaper);
     262             : 
     263             :     // thin white rectangle aronud the Help and Extensions buttons
     264           0 :     mpThinBox1->SetBackground(aButtonsText);
     265           0 :     mpThinBox2->SetBackground(aButtonsText);
     266             : 
     267           0 :     Resize();
     268             : 
     269           0 :     set_width_request(mpAllRecentThumbnails->get_width_request() + mpAllButtonsBox->GetOptimalSize().Width());
     270           0 :     set_height_request(mpAllButtonsBox->GetOptimalSize().Height());
     271             : }
     272             : 
     273           0 : void BackingWindow::setupButton( PushButton* pButton )
     274             : {
     275             :     // the buttons should have a bit bigger font
     276           0 :     Font aFont(pButton->GetControlFont());
     277           0 :     aFont.SetHeight(nButtonsFontSize);
     278           0 :     pButton->SetControlFont(aFont);
     279             : 
     280             :     // color that fits the theme
     281           0 :     pButton->SetControlForeground(aButtonsText);
     282             : 
     283           0 :     pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
     284           0 : }
     285             : 
     286           0 : void BackingWindow::Paint( const Rectangle& )
     287             : {
     288           0 :     Resize();
     289             : 
     290           0 :     Wallpaper aBack( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor );
     291           0 :     Region aClip( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
     292             : 
     293           0 :     aClip.Exclude( maStartCentButtons );
     294             : 
     295           0 :     Push( PUSH_CLIPREGION );
     296           0 :     IntersectClipRegion( aClip );
     297           0 :     DrawWallpaper( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ), aBack );
     298           0 :     Pop();
     299             : 
     300           0 :     VirtualDevice aDev( *this );
     301           0 :     aDev.EnableRTL( IsRTLEnabled() );
     302           0 :     aDev.SetOutputSizePixel( maStartCentButtons.GetSize() );
     303           0 :     Point aOffset( Point( 0, 0 ) - maStartCentButtons.TopLeft());
     304           0 :     aDev.DrawWallpaper( Rectangle( aOffset, GetOutputSizePixel() ), aBack );
     305             : 
     306           0 :     DrawOutDev( maStartCentButtons.TopLeft(), maStartCentButtons.GetSize(),
     307           0 :                 Point( 0, 0 ), maStartCentButtons.GetSize(),
     308           0 :                 aDev );
     309           0 : }
     310             : 
     311           0 : bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
     312             : {
     313           0 :     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           0 :     return Window::PreNotify( rNEvt );
     344             : }
     345             : 
     346           0 : bool BackingWindow::Notify( NotifyEvent& rNEvt )
     347             : {
     348           0 :     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           0 :     return Window::Notify( rNEvt );
     364             : }
     365             : 
     366           0 : void BackingWindow::GetFocus()
     367             : {
     368           0 :     sal_uInt16 nFlags = GetParent()->GetGetFocusFlags();
     369           0 :     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           0 :     Window::GetFocus();
     383             : }
     384             : 
     385           0 : void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame )
     386             : {
     387           0 :     mxFrame = xFrame;
     388           0 :     if( ! mbInitControls )
     389           0 :         initControls();
     390             : 
     391             :     // establish drag&drop mode
     392           0 :     mxDropTargetListener.set(new OpenFileDropTargetListener(mxContext, mxFrame));
     393             : 
     394           0 :     for (std::vector<Window*>::iterator aI = maDndWindows.begin(),
     395           0 :         aEnd = maDndWindows.end(); aI != aEnd; ++aI)
     396             :     {
     397           0 :         Window *pDndWin = *aI;
     398             :         css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
     399           0 :             pDndWin->GetDropTarget();
     400           0 :         if (xDropTarget.is())
     401             :         {
     402           0 :             xDropTarget->addDropTargetListener(mxDropTargetListener);
     403           0 :             xDropTarget->setActive(true);
     404             :         }
     405           0 :     }
     406           0 : }
     407             : 
     408           0 : void BackingWindow::Resize()
     409             : {
     410           0 :     maStartCentButtons = Rectangle( Point(0, 0), GetOutputSizePixel() );
     411             : 
     412           0 :     if (isLayoutEnabled(this))
     413           0 :         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD),
     414           0 :             maStartCentButtons.TopLeft(), maStartCentButtons.GetSize());
     415             : 
     416           0 :     if( !IsInPaint())
     417           0 :         Invalidate();
     418           0 : }
     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           3 : }
     591             : /* vim:set shiftwidth=4 softtabstop=4 expandtab:*/

Generated by: LCOV version 1.10