1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <callform.hxx>
22 #include <osl/diagnose.h>
23 #include <osl/file.hxx>
24 #include <tools/urlobj.hxx>
25 #include <comphelper/diagnose_ex.hxx>
26 #include <ucbhelper/content.hxx>
28 #include <unotools/pathoptions.hxx>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <com/sun/star/ucb/XContentAccess.hpp>
33 #include <com/sun/star/i18n/OrdinalSuffix.hpp>
34 #include <comphelper/processfactory.hxx>
35 #include <comphelper/configuration.hxx>
36 #include <unotools/localedatawrapper.hxx>
38 namespace com::sun::star::ucb
{ class XCommandEnvironment
; }
40 using namespace ::com::sun::star
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::ucb
;
44 void ScGlobal::InitAddIns()
46 if (comphelper::IsFuzzing())
49 // multi paths separated by semicolons
50 SvtPathOptions aPathOpt
;
51 const OUString
& aMultiPath
= aPathOpt
.GetAddinPath();
52 if (aMultiPath
.isEmpty())
58 OUString aPath
= aMultiPath
.getToken(0, ';', nIdx
);
63 if ( osl::FileBase::getFileURLFromSystemPath( aPath
, aUrl
) == osl::FileBase::E_None
)
67 aObj
.SetSmartURL( aPath
);
71 ::ucbhelper::Content
aCnt( aObj
.GetMainURL(INetURLObject::DecodeMechanism::NONE
),
72 Reference
< XCommandEnvironment
>(),
73 comphelper::getProcessComponentContext() );
74 Reference
< sdbc::XResultSet
> xResultSet
;
75 Sequence
< OUString
> aProps
;
78 xResultSet
= aCnt
.createCursor(
79 aProps
, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY
);
83 // ucb may throw different exceptions on failure now
84 // no assertion if AddIn directory doesn't exist
87 if ( xResultSet
.is() )
89 Reference
< XContentAccess
> xContentAccess( xResultSet
, UNO_QUERY
);
92 if ( xResultSet
->first() )
96 OUString aId
= xContentAccess
->queryContentIdentifierString();
97 InitExternalFunc( aId
);
99 while ( xResultSet
->next() );
104 TOOLS_WARN_EXCEPTION( "sc", "" );
110 TOOLS_WARN_EXCEPTION( "sc", "" );
114 OSL_FAIL( "unexpected exception caught!" );
120 OUString
ScGlobal::GetOrdinalSuffix( sal_Int32 nNumber
)
124 if (!xOrdinalSuffix
.is())
126 xOrdinalSuffix
= i18n::OrdinalSuffix::create( ::comphelper::getProcessComponentContext() );
128 uno::Sequence
< OUString
> aSuffixes
= xOrdinalSuffix
->getOrdinalSuffix( nNumber
,
129 ScGlobal::getLocaleData().getLanguageTag().getLocale());
130 if ( aSuffixes
.hasElements() )
137 TOOLS_WARN_EXCEPTION( "sc", "GetOrdinalSuffix: exception caught during init" );
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */