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