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

Generated by: LCOV version 1.11