LCOV - code coverage report
Current view: top level - sc/source/core/data - globalx.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 47 66.0 %
Date: 2014-11-03 Functions: 4 4 100.0 %
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 "callform.hxx"
      21             : #include "global.hxx"
      22             : #include <tools/urlobj.hxx>
      23             : #include <ucbhelper/content.hxx>
      24             : #include <unotools/localfilehelper.hxx>
      25             : 
      26             : #include <unotools/pathoptions.hxx>
      27             : 
      28             : #include <com/sun/star/sdbc/XResultSet.hpp>
      29             : #include <com/sun/star/sdbc/XRow.hpp>
      30             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      31             : #include <com/sun/star/ucb/XContentAccess.hpp>
      32             : 
      33             : #include <com/sun/star/i18n/OrdinalSuffix.hpp>
      34             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35             : #include <comphelper/processfactory.hxx>
      36             : #include <comphelper/string.hxx>
      37             : #include <unotools/localedatawrapper.hxx>
      38             : 
      39             : using namespace ::com::sun::star;
      40             : using namespace ::com::sun::star::uno;
      41             : using namespace ::com::sun::star::ucb;
      42             : 
      43          76 : void ScGlobal::InitAddIns()
      44             : {
      45             :     // multi paths separated by semicolons
      46          76 :     SvtPathOptions aPathOpt;
      47         152 :     OUString aMultiPath = aPathOpt.GetAddinPath();
      48          76 :     if (aMultiPath.isEmpty())
      49          76 :         return;
      50             : 
      51          76 :     sal_Int32 nTokens = comphelper::string::getTokenCount(aMultiPath, ';');
      52         152 :     for (sal_Int32 j = 0; j < nTokens; ++j)
      53             :     {
      54          76 :         OUString aPath = comphelper::string::getToken(aMultiPath, j, ';');
      55          76 :         if (aPath.isEmpty())
      56           0 :             continue;
      57             : 
      58             :         //  use LocalFileHelper to convert the path to a URL that always points
      59             :         //  to the file on the server
      60         152 :         OUString aUrl;
      61          76 :         if ( utl::LocalFileHelper::ConvertPhysicalNameToURL( aPath, aUrl ) )
      62          76 :             aPath = aUrl;
      63             : 
      64         152 :         INetURLObject aObj;
      65          76 :         aObj.SetSmartURL( aPath );
      66          76 :         aObj.setFinalSlash();
      67             :         try
      68             :         {
      69             :             ::ucbhelper::Content aCnt( aObj.GetMainURL(INetURLObject::NO_DECODE),
      70             :                 Reference< XCommandEnvironment >(),
      71          76 :                 comphelper::getProcessComponentContext() );
      72         152 :             Reference< sdbc::XResultSet > xResultSet;
      73         152 :             Sequence< OUString > aProps;
      74             :             try
      75             :             {
      76          76 :                 xResultSet = aCnt.createCursor(
      77           0 :                     aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
      78             :             }
      79          76 :             catch ( Exception& )
      80             :             {
      81             :                 // ucb may throw different exceptions on failure now
      82             :                 // no assertion if AddIn directory doesn't exist
      83             :             }
      84             : 
      85          76 :             if ( xResultSet.is() )
      86             :             {
      87           0 :                 Reference< sdbc::XRow > xRow( xResultSet, UNO_QUERY );
      88             :                 Reference< XContentAccess >
      89           0 :                     xContentAccess( xResultSet, UNO_QUERY );
      90             :                 try
      91             :                 {
      92           0 :                     if ( xResultSet->first() )
      93             :                     {
      94           0 :                         do
      95             :                         {
      96           0 :                             OUString aId = xContentAccess->queryContentIdentifierString();
      97           0 :                             InitExternalFunc( aId );
      98             :                         }
      99           0 :                         while ( xResultSet->next() );
     100             :                     }
     101             :                 }
     102           0 :                 catch ( Exception& )
     103             :                 {
     104             :                     OSL_FAIL( "ResultSetException caught!" );
     105           0 :                 }
     106          76 :             }
     107             :         }
     108           0 :         catch ( Exception& )
     109             :         {
     110             :             OSL_FAIL( "Exception caught!" );
     111             :         }
     112           0 :         catch ( ... )
     113             :         {
     114             :             OSL_FAIL( "unexpected exception caught!" );
     115             :         }
     116         152 :     }
     117             : }
     118             : 
     119           4 : OUString ScGlobal::GetOrdinalSuffix( sal_Int32 nNumber)
     120             : {
     121             :     try
     122             :     {
     123           4 :         if (!xOrdinalSuffix.is())
     124             :         {
     125           2 :             xOrdinalSuffix = i18n::OrdinalSuffix::create( ::comphelper::getProcessComponentContext() );
     126             :         }
     127           4 :         uno::Sequence< OUString > aSuffixes = xOrdinalSuffix->getOrdinalSuffix( nNumber,
     128           4 :                 ScGlobal::pLocaleData->getLanguageTag().getLocale());
     129           4 :         if ( aSuffixes.getLength() > 0 )
     130           4 :             return aSuffixes[0];
     131             :         else
     132           0 :             return OUString();
     133             :     }
     134           0 :     catch ( Exception& )
     135             :     {
     136             :         OSL_FAIL( "GetOrdinalSuffix: exception caught during init" );
     137             :     }
     138           0 :     return OUString();
     139         228 : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10