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

Generated by: LCOV version 1.11