LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sfx2/source/appl - appmisc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 86 46.5 %
Date: 2013-07-09 Functions: 15 18 83.3 %
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 <vcl/canvastools.hxx>
      21             : #include <vcl/status.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <svl/whiter.hxx>
      24             : #include <svl/stritem.hxx>
      25             : #include <svl/intitem.hxx>
      26             : #include <svl/eitem.hxx>
      27             : #include <vcl/graphicfilter.hxx>
      28             : #include <unotools/pathoptions.hxx>
      29             : #include <com/sun/star/registry/InvalidRegistryException.hpp>
      30             : #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
      31             : #include <com/sun/star/beans/PropertyValue.hpp>
      32             : #include <com/sun/star/frame/XFrame.hpp>
      33             : #include <com/sun/star/graphic/Primitive2DTools.hpp>
      34             : #include <com/sun/star/util/XURLTransformer.hpp>
      35             : #include <com/sun/star/frame/XFramesSupplier.hpp>
      36             : #include <com/sun/star/uno/Reference.h>
      37             : #include <tools/rcid.h>
      38             : #include <osl/mutex.hxx>
      39             : #include <unotools/configmgr.hxx>
      40             : #include <com/sun/star/frame/XDesktop.hpp>
      41             : #include <unotools/ucbstreamhelper.hxx>
      42             : #include <framework/menuconfiguration.hxx>
      43             : #include <comphelper/processfactory.hxx>
      44             : #include <unotools/localfilehelper.hxx>
      45             : #include <unotools/bootstrap.hxx>
      46             : #include <unotools/moduleoptions.hxx>
      47             : #include <osl/file.hxx>
      48             : #include <osl/process.h>
      49             : #include <rtl/bootstrap.hxx>
      50             : 
      51             : #include "sfx2/sfxresid.hxx"
      52             : #include <sfx2/app.hxx>
      53             : #include "appdata.hxx"
      54             : #include "arrdecl.hxx"
      55             : #include <sfx2/tbxctrl.hxx>
      56             : #include "sfx2/stbitem.hxx"
      57             : #include <sfx2/mnuitem.hxx>
      58             : #include <sfx2/docfac.hxx>
      59             : #include <sfx2/docfile.hxx>
      60             : #include <sfx2/docfilt.hxx>
      61             : #include <sfx2/request.hxx>
      62             : #include <sfx2/bindings.hxx>
      63             : #include <sfx2/dispatch.hxx>
      64             : #include "workwin.hxx"
      65             : #include <sfx2/fcontnr.hxx>
      66             : #include "sfxlocal.hrc"
      67             : #include <sfx2/sfx.hrc>
      68             : #include "app.hrc"
      69             : #include <sfx2/templdlg.hxx>
      70             : #include <sfx2/module.hxx>
      71             : #include <sfx2/msgpool.hxx>
      72             : #include <sfx2/viewfrm.hxx>
      73             : #include "openflag.hxx"
      74             : #include <sfx2/viewsh.hxx>
      75             : #include <sfx2/objface.hxx>
      76             : #include "helper.hxx"   // SfxContentHelper::Kill()
      77             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      78             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      79             : 
      80             : using namespace ::com::sun::star;
      81             : using namespace ::com::sun::star::uno;
      82             : using namespace ::com::sun::star::util;
      83             : using namespace ::com::sun::star::beans;
      84             : using namespace ::com::sun::star::container;
      85             : 
      86             : //===================================================================
      87             : 
      88             : #define SfxApplication
      89             : #include "sfxslots.hxx"
      90             : 
      91             : //====================================================================
      92             : 
      93             : #define SFX_ITEMTYPE_STATBAR             4
      94             : 
      95       33924 : SFX_IMPL_INTERFACE(SfxApplication,SfxShell,SfxResId(RID_DESKTOP))
      96             : {
      97         133 :     SFX_STATUSBAR_REGISTRATION(SfxResId(SFX_ITEMTYPE_STATBAR));
      98         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_0);
      99         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_1);
     100         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_2);
     101         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_3);
     102         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_4);
     103         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_5);
     104         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_6);
     105         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_7);
     106         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_8);
     107         133 :     SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_9);
     108         133 : }
     109             : 
     110             : //--------------------------------------------------------------------
     111        3029 : SfxProgress* SfxApplication::GetProgress() const
     112             : 
     113             : /*  [Description]
     114             : 
     115             :     Returns the running SfxProgress for the entire application or 0 if
     116             :     none is running for the entire application.
     117             : 
     118             :     [Cross-reference]
     119             : 
     120             :     <SfxProgress::GetActiveProgress(SfxViewFrame*)>
     121             :     <SfxViewFrame::GetProgress()const>
     122             : */
     123             : 
     124             : {
     125        3029 :     return pAppData_Impl->pProgress;
     126             : }
     127             : 
     128           0 : SfxModule* SfxApplication::GetModule_Impl()
     129             : {
     130           0 :     SfxModule* pModule = SfxModule::GetActiveModule();
     131           0 :     if ( !pModule )
     132           0 :         pModule = SfxModule::GetActiveModule( SfxViewFrame::GetFirst( 0, sal_False ) );
     133           0 :     if( pModule )
     134           0 :         return pModule;
     135             :     else
     136             :     {
     137             :         OSL_FAIL( "No module!" );
     138           0 :         return NULL;
     139             :     }
     140             : }
     141             : 
     142        4609 : ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings )
     143             : {
     144        4609 :     if( pAppData_Impl->pTemplateCommon )
     145           0 :         return pAppData_Impl->pTemplateCommon;
     146             :     SfxChildWindow *pChild = rBindings.GetWorkWindow_Impl()->GetChildWindow_Impl(
     147        4609 :         SfxTemplateDialogWrapper::GetChildWindowId() );
     148        4609 :     if ( pChild )
     149         592 :         return ((SfxTemplateDialog*) pChild->GetWindow())->GetISfxTemplateCommon();
     150        4017 :     return 0;
     151             : }
     152             : 
     153      109788 : sal_Bool  SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; }
     154        2176 : SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; }
     155        1456 : SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; }
     156             : 
     157           0 : bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth)
     158             : {
     159             :     // Load from disk
     160             :     // ---------------------------------------------------------------------
     161           0 :     OUString aBaseName = ( OUString("/") +
     162           0 :                                 OUString::createFromAscii( pName ) );
     163           0 :     OUString aSvg( ".svg" );
     164             : 
     165           0 :     rtl_Locale *pLoc = NULL;
     166           0 :     osl_getProcessLocale (&pLoc);
     167           0 :     LanguageTag aLanguageTag( *pLoc);
     168             : 
     169           0 :     OUString uri = OUString::createFromAscii( "$BRAND_BASE_DIR/program" ) + aBaseName+aSvg;
     170           0 :     rtl::Bootstrap::expandMacros( uri );
     171           0 :     INetURLObject aObj( uri );
     172           0 :     SvgData aSvgData(aObj.PathToFileName());
     173             : 
     174             :     // transform into [0,0,width,width*aspect] std dimensions
     175             :     // ---------------------------------------------------------------------
     176           0 :     basegfx::B2DRange aRange(aSvgData.getRange());
     177           0 :     const double fAspectRatio(aRange.getWidth()/aRange.getHeight());
     178             :     basegfx::B2DHomMatrix aTransform(
     179             :         basegfx::tools::createTranslateB2DHomMatrix(
     180           0 :             -aRange.getMinX(),
     181           0 :             -aRange.getMinY()));
     182             :     aTransform.scale(
     183           0 :         nWidth / aRange.getWidth(),
     184           0 :         nWidth / fAspectRatio / aRange.getHeight());
     185             :     const drawinglayer::primitive2d::Primitive2DReference xTransformRef(
     186             :         new drawinglayer::primitive2d::TransformPrimitive2D(
     187             :             aTransform,
     188           0 :             aSvgData.getPrimitive2DSequence()));
     189             : 
     190             :     // UNO dance to render from drawinglayer
     191             :     // ---------------------------------------------------------------------
     192           0 :     uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
     193             : 
     194             :     try
     195             :     {
     196             :         const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer =
     197           0 :             graphic::Primitive2DTools::create( xContext );
     198             : 
     199             :         // cancel out rasterize's mm2pixel conversion
     200             :         // see fFactor100th_mmToInch in
     201             :         // drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
     202           0 :         const double fFakeDPI=2.54 * 1000.0;
     203             : 
     204             :         geometry::RealRectangle2D aRealRect(
     205             :             0, 0,
     206           0 :             nWidth, nWidth / fAspectRatio);
     207             : 
     208             :         const uno::Reference< rendering::XBitmap > xBitmap(
     209           0 :             xPrimitive2DRenderer->rasterize(
     210             :                 drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1),
     211             :                 uno::Sequence< beans::PropertyValue >(),
     212             :                 fFakeDPI,
     213             :                 fFakeDPI,
     214             :                 aRealRect,
     215           0 :                 500000));
     216             : 
     217           0 :         if(xBitmap.is())
     218             :         {
     219           0 :             const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
     220             : 
     221           0 :             if(xIntBmp.is())
     222             :             {
     223           0 :                 rBitmap = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
     224           0 :                 return true;
     225           0 :             }
     226           0 :         }
     227             :     }
     228           0 :     catch(const uno::Exception&)
     229             :     {
     230             :         OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" );
     231             :     }
     232           0 :     return false;
     233             : }
     234             : 
     235             : /** loads the application logo as used in the impress slideshow pause screen */
     236           0 : BitmapEx SfxApplication::GetApplicationLogo(long nWidth)
     237             : {
     238           0 :     BitmapEx aBitmap;
     239           0 :     SfxApplication::loadBrandSvg("flat_logo", aBitmap, nWidth);
     240           0 :     Application::LoadBrandBitmap ("about", aBitmap);
     241           0 :     return aBitmap;
     242             : }
     243             : 
     244         244 : SfxChildWinFactArr_Impl::~SfxChildWinFactArr_Impl()
     245             : {
     246        2305 :     for( const_iterator it = begin(); it != end(); ++it )
     247        2183 :         delete *it;
     248         122 : }
     249             : 
     250         240 : SfxMenuCtrlFactArr_Impl::~SfxMenuCtrlFactArr_Impl()
     251             : {
     252         268 :     for( const_iterator it = begin(); it != end(); ++it )
     253         148 :         delete *it;
     254         120 : }
     255             : 
     256         244 : SfxStbCtrlFactArr_Impl::~SfxStbCtrlFactArr_Impl()
     257             : {
     258         463 :     for( const_iterator it = begin(); it != end(); ++it )
     259         341 :         delete *it;
     260         122 : }
     261             : 
     262         244 : SfxTbxCtrlFactArr_Impl::~SfxTbxCtrlFactArr_Impl()
     263             : {
     264        2604 :     for( const_iterator it = begin(); it != end(); ++it )
     265        2482 :         delete *it;
     266         530 : }
     267             : 
     268             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10