Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / sc / source / core / data / globalx.cxx
blob1fac6e9c11b426b187b485b9726160918f651856
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
21 #include <global.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())
47 return;
49 // multi paths separated by semicolons
50 SvtPathOptions aPathOpt;
51 const OUString& aMultiPath = aPathOpt.GetAddinPath();
52 if (aMultiPath.isEmpty())
53 return;
55 sal_Int32 nIdx {0};
58 OUString aPath = aMultiPath.getToken(0, ';', nIdx);
59 if (aPath.isEmpty())
60 continue;
62 OUString aUrl;
63 if ( osl::FileBase::getFileURLFromSystemPath( aPath, aUrl ) == osl::FileBase::E_None )
64 aPath = aUrl;
66 INetURLObject aObj;
67 aObj.SetSmartURL( aPath );
68 aObj.setFinalSlash();
69 try
71 ::ucbhelper::Content aCnt( aObj.GetMainURL(INetURLObject::DecodeMechanism::NONE),
72 Reference< XCommandEnvironment >(),
73 comphelper::getProcessComponentContext() );
74 Reference< sdbc::XResultSet > xResultSet;
75 Sequence< OUString > aProps;
76 try
78 xResultSet = aCnt.createCursor(
79 aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
81 catch ( Exception& )
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 );
90 try
92 if ( xResultSet->first() )
96 OUString aId = xContentAccess->queryContentIdentifierString();
97 InitExternalFunc( aId );
99 while ( xResultSet->next() );
102 catch ( Exception& )
104 TOOLS_WARN_EXCEPTION( "sc", "" );
108 catch ( Exception& )
110 TOOLS_WARN_EXCEPTION( "sc", "" );
112 catch ( ... )
114 OSL_FAIL( "unexpected exception caught!" );
117 while (nIdx>0);
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() )
131 return aSuffixes[0];
132 else
133 return OUString();
135 catch ( Exception& )
137 TOOLS_WARN_EXCEPTION( "sc", "GetOrdinalSuffix: exception caught during init" );
139 return OUString();
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */