LibreOffice Module sc (master)  1
globalx.cxx
Go to the documentation of this file.
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 <osl/file.hxx>
24 #include <tools/urlobj.hxx>
25 #include <tools/diagnose_ex.h>
26 #include <ucbhelper/content.hxx>
27 
28 #include <unotools/pathoptions.hxx>
29 
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <com/sun/star/ucb/XContentAccess.hpp>
32 
33 #include <com/sun/star/i18n/OrdinalSuffix.hpp>
35 #include <unotools/configmgr.hxx>
37 
38 namespace com::sun::star::ucb { class XCommandEnvironment; }
39 
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::ucb;
43 
45 {
47  return;
48 
49  // multi paths separated by semicolons
50  SvtPathOptions aPathOpt;
51  const OUString& aMultiPath = aPathOpt.GetAddinPath();
52  if (aMultiPath.isEmpty())
53  return;
54 
55  sal_Int32 nIdx {0};
56  do
57  {
58  OUString aPath = aMultiPath.getToken(0, ';', nIdx);
59  if (aPath.isEmpty())
60  continue;
61 
62  OUString aUrl;
63  if ( osl::FileBase::getFileURLFromSystemPath( aPath, aUrl ) == osl::FileBase::E_None )
64  aPath = aUrl;
65 
66  INetURLObject aObj;
67  aObj.SetSmartURL( aPath );
68  aObj.setFinalSlash();
69  try
70  {
74  Reference< sdbc::XResultSet > xResultSet;
75  Sequence< OUString > aProps;
76  try
77  {
78  xResultSet = aCnt.createCursor(
80  }
81  catch ( Exception& )
82  {
83  // ucb may throw different exceptions on failure now
84  // no assertion if AddIn directory doesn't exist
85  }
86 
87  if ( xResultSet.is() )
88  {
89  Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
90  try
91  {
92  if ( xResultSet->first() )
93  {
94  do
95  {
96  OUString aId = xContentAccess->queryContentIdentifierString();
97  InitExternalFunc( aId );
98  }
99  while ( xResultSet->next() );
100  }
101  }
102  catch ( Exception& )
103  {
104  TOOLS_WARN_EXCEPTION( "sc", "" );
105  }
106  }
107  }
108  catch ( Exception& )
109  {
110  TOOLS_WARN_EXCEPTION( "sc", "" );
111  }
112  catch ( ... )
113  {
114  OSL_FAIL( "unexpected exception caught!" );
115  }
116  }
117  while (nIdx>0);
118 }
119 
120 OUString ScGlobal::GetOrdinalSuffix( sal_Int32 nNumber)
121 {
122  try
123  {
124  if (!xOrdinalSuffix.is())
125  {
126  xOrdinalSuffix = i18n::OrdinalSuffix::create( ::comphelper::getProcessComponentContext() );
127  }
128  uno::Sequence< OUString > aSuffixes = xOrdinalSuffix->getOrdinalSuffix( nNumber,
130  if ( aSuffixes.hasElements() )
131  return aSuffixes[0];
132  else
133  return OUString();
134  }
135  catch ( Exception& )
136  {
137  TOOLS_WARN_EXCEPTION( "sc", "GetOrdinalSuffix: exception caught during init" );
138  }
139  return OUString();
140 }
141 
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool InitExternalFunc(const OUString &rModuleName)
Definition: callform.cxx:160
static OUString GetOrdinalSuffix(sal_Int32 nNumber)
Obtain the ordinal suffix for a number according to the system locale.
Definition: globalx.cxx:120
OUString aId
bool setFinalSlash()
static bool IsFuzzing()
#define TOOLS_WARN_EXCEPTION(area, stream)
const LanguageTag & getLanguageTag()
const LanguageTag & getLocale()
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static SC_DLLPUBLIC const LocaleDataWrapper * getLocaleDataPtr()
Definition: global.cxx:1000
static void InitAddIns()
Definition: globalx.cxx:44
Reference< XComponentContext > getProcessComponentContext()
const OUString & GetAddinPath() const
INCLUDE_DOCUMENTS_ONLY
bool SetSmartURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
static css::uno::Reference< css::i18n::XOrdinalSuffix > xOrdinalSuffix
Definition: global.hxx:522