LCOV - code coverage report
Current view: top level - toolkit/source/helper - tkresmgr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 35 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 58 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <toolkit/helper/tkresmgr.hxx>
      30                 :            : #include <tools/simplerm.hxx>
      31                 :            : #include <comphelper/processfactory.hxx>
      32                 :            : #include <comphelper/componentcontext.hxx>
      33                 :            : #include <comphelper/namedvaluecollection.hxx>
      34                 :            : #include <com/sun/star/graphic/GraphicProvider.hpp>
      35                 :            : #include <com/sun/star/graphic/XGraphicProvider.hpp>
      36                 :            : #include <tools/resmgr.hxx>
      37                 :            : #include <tools/diagnose_ex.h>
      38                 :            : 
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : 
      41                 :            : using ::com::sun::star::uno::Reference;
      42                 :            : using ::com::sun::star::graphic::XGraphic;
      43                 :            : using ::com::sun::star::graphic::XGraphicProvider;
      44                 :            : using namespace ::com::sun::star;
      45                 :            : // -----------------------------------------------------------------------------
      46                 :            : // TkResMgr
      47                 :            : // -----------------------------------------------------------------------------
      48                 :            : 
      49                 :            : SimpleResMgr*   TkResMgr::m_pSimpleResMgr = NULL;
      50                 :            : ResMgr*         TkResMgr::m_pResMgr = NULL;
      51                 :            : 
      52                 :            : // -----------------------------------------------------------------------------
      53                 :            : 
      54                 :          0 : TkResMgr::EnsureDelete::~EnsureDelete()
      55                 :            : {
      56         [ #  # ]:          0 :     delete TkResMgr::m_pSimpleResMgr;
      57                 :            : //    delete TkResMgr::m_pResMgr;
      58                 :          0 : }
      59                 :            : 
      60                 :            : // -----------------------------------------------------------------------------
      61                 :            : 
      62                 :          0 : void TkResMgr::ensureImplExists()
      63                 :            : {
      64         [ #  # ]:          0 :     if (m_pSimpleResMgr)
      65                 :          0 :         return;
      66                 :            : 
      67 [ #  # ][ #  # ]:          0 :     ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
      68                 :            : 
      69         [ #  # ]:          0 :     m_pSimpleResMgr = SimpleResMgr::Create( "tk", aLocale );
      70         [ #  # ]:          0 :     m_pResMgr = ResMgr::CreateResMgr( "tk" );
      71                 :            : 
      72         [ #  # ]:          0 :     if (m_pSimpleResMgr)
      73                 :            :     {
      74                 :            :         // now that we have a impl class, make sure it's deleted on unloading the library
      75 [ #  # ][ #  # ]:          0 :         static TkResMgr::EnsureDelete s_aDeleteTheImplClass;
      76                 :          0 :     }
      77                 :            : }
      78                 :            : 
      79                 :            : // -----------------------------------------------------------------------------
      80                 :          0 : ::rtl::OUString TkResMgr::loadString( sal_uInt16 nResId )
      81                 :            : {
      82                 :          0 :     ::rtl::OUString sReturn;
      83                 :            : 
      84         [ #  # ]:          0 :     ensureImplExists();
      85         [ #  # ]:          0 :     if ( m_pSimpleResMgr )
      86         [ #  # ]:          0 :         sReturn = m_pSimpleResMgr->ReadString( nResId );
      87                 :            : 
      88                 :          0 :     return sReturn;
      89                 :            : }
      90                 :            : 
      91                 :            : // -----------------------------------------------------------------------------
      92                 :          0 : Image TkResMgr::loadImage( sal_uInt16 nResId )
      93                 :            : {
      94                 :          0 :     Image aReturn;
      95                 :            : 
      96         [ #  # ]:          0 :     ensureImplExists();
      97         [ #  # ]:          0 :     if ( m_pResMgr )
      98 [ #  # ][ #  # ]:          0 :         aReturn = Image( ResId( nResId, *m_pResMgr ) );
                 [ #  # ]
      99                 :            : 
     100                 :          0 :     return aReturn;
     101                 :            : }
     102                 :            : 
     103                 :            : // -----------------------------------------------------------------------------
     104                 :          0 : Image TkResMgr::getImageFromURL( const ::rtl::OUString& i_rImageURL )
     105                 :            : {
     106         [ #  # ]:          0 :     if ( i_rImageURL.isEmpty() )
     107                 :          0 :         return Image();
     108                 :            : 
     109                 :            :     try
     110                 :            :     {
     111         [ #  # ]:          0 :         Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     112         [ #  # ]:          0 :         Reference< XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) );
     113         [ #  # ]:          0 :         ::comphelper::NamedValueCollection aMediaProperties;
     114         [ #  # ]:          0 :         aMediaProperties.put( "URL", i_rImageURL );
     115 [ #  # ][ #  # ]:          0 :         Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() );
         [ #  # ][ #  # ]
     116 [ #  # ][ #  # ]:          0 :         return Image( xGraphic );
                 [ #  # ]
     117                 :            :     }
     118                 :          0 :     catch( const uno::Exception& )
     119                 :            :     {
     120                 :            :         DBG_UNHANDLED_EXCEPTION();
     121                 :            :     }
     122                 :          0 :     return Image();
     123                 :            : }
     124                 :            : 
     125                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10