Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "callform.hxx"
30 : : #include "global.hxx"
31 : : #include <tools/urlobj.hxx>
32 : : #include <ucbhelper/contentbroker.hxx>
33 : : #include <ucbhelper/content.hxx>
34 : : #include <unotools/localfilehelper.hxx>
35 : :
36 : : #include <unotools/pathoptions.hxx>
37 : :
38 : : #include <com/sun/star/sdbc/XResultSet.hpp>
39 : : #include <com/sun/star/sdbc/XRow.hpp>
40 : : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
41 : : #include <com/sun/star/ucb/XContentAccess.hpp>
42 : :
43 : : #include <com/sun/star/i18n/XOrdinalSuffix.hpp>
44 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 : : #include <comphelper/processfactory.hxx>
46 : : #include <comphelper/string.hxx>
47 : : #include <unotools/localedatawrapper.hxx>
48 : :
49 : :
50 : : using namespace ::com::sun::star;
51 : : using namespace ::com::sun::star::uno;
52 : : using namespace ::com::sun::star::ucb;
53 : :
54 : :
55 : 51 : void ScGlobal::InitAddIns()
56 : : {
57 : : // multi paths separated by semicolons
58 [ + - ]: 51 : SvtPathOptions aPathOpt;
59 [ + - ][ + - ]: 51 : rtl::OUString aMultiPath = aPathOpt.GetAddinPath();
60 [ + + ]: 51 : if (aMultiPath.isEmpty())
61 : 51 : return;
62 : :
63 [ + - ]: 18 : sal_Int32 nTokens = comphelper::string::getTokenCount(aMultiPath, ';');
64 [ + + ]: 36 : for (sal_Int32 j = 0; j < nTokens; ++j)
65 : : {
66 : 18 : rtl::OUString aPath = comphelper::string::getToken(aMultiPath, j, ';');
67 [ - + ]: 18 : if (aPath.isEmpty())
68 : 0 : continue;
69 : :
70 : : // use LocalFileHelper to convert the path to a URL that always points
71 : : // to the file on the server
72 : 18 : rtl::OUString aUrl;
73 [ + - ][ + - ]: 18 : if ( utl::LocalFileHelper::ConvertPhysicalNameToURL( aPath, aUrl ) )
74 : 18 : aPath = aUrl;
75 : :
76 [ + - ]: 18 : INetURLObject aObj;
77 [ + - ]: 18 : aObj.SetSmartURL( aPath );
78 [ + - ]: 18 : aObj.setFinalSlash();
79 : : try
80 : : {
81 : : ::ucbhelper::Content aCnt( aObj.GetMainURL(INetURLObject::NO_DECODE),
82 [ + - ][ + - ]: 18 : Reference< XCommandEnvironment > () );
83 : 18 : Reference< sdbc::XResultSet > xResultSet;
84 [ + - ]: 18 : Sequence< rtl::OUString > aProps;
85 : : try
86 : : {
87 : : xResultSet = aCnt.createCursor(
88 [ + - ][ + - ]: 18 : aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
[ # # ]
89 : : }
90 [ # # ]: 0 : catch ( Exception& )
91 : : {
92 : : // ucb may throw different exceptions on failure now
93 : : // no assertion if AddIn directory doesn't exist
94 : : }
95 : :
96 [ + - ]: 18 : if ( xResultSet.is() )
97 : : {
98 [ + - ]: 18 : Reference< sdbc::XRow > xRow( xResultSet, UNO_QUERY );
99 : : Reference< XContentAccess >
100 [ + - ]: 18 : xContentAccess( xResultSet, UNO_QUERY );
101 : : try
102 : : {
103 [ + - ][ + - ]: 18 : if ( xResultSet->first() )
[ - + ]
104 : : {
105 [ # # ]: 0 : do
106 : : {
107 [ # # ][ # # ]: 0 : rtl::OUString aId = xContentAccess->queryContentIdentifierString();
108 [ # # ][ # # ]: 0 : InitExternalFunc( aId );
109 : : }
110 [ # # ][ # # ]: 0 : while ( xResultSet->next() );
111 : : }
112 : : }
113 [ # # ]: 0 : catch ( Exception& )
114 : : {
115 : : OSL_FAIL( "ResultSetException caught!" );
116 : 18 : }
117 [ + - ][ + - ]: 18 : }
[ # # ]
118 : : }
119 [ # # ]: 0 : catch ( Exception& )
120 : : {
121 : : OSL_FAIL( "Exception caught!" );
122 : : }
123 [ # # ]: 0 : catch ( ... )
124 : : {
125 : : OSL_FAIL( "unexpected exception caught!" );
126 : : }
127 [ + - ][ + - ]: 69 : }
[ + + ][ + - ]
[ + + ]
128 : : }
129 : :
130 : :
131 : 6 : String ScGlobal::GetOrdinalSuffix( sal_Int32 nNumber)
132 : : {
133 [ + + ]: 6 : if (!xOrdinalSuffix.is())
134 : : {
135 : : try
136 : : {
137 : : Reference< lang::XMultiServiceFactory > xServiceManager =
138 [ + - ]: 3 : ::comphelper::getProcessServiceFactory();
139 : : Reference< XInterface > xInterface =
140 [ + - ]: 3 : xServiceManager->createInstance(
141 [ + - ][ + - ]: 3 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.OrdinalSuffix")));
142 [ + - ]: 3 : if (xInterface.is())
143 [ + - ][ + - ]: 3 : xOrdinalSuffix = Reference< i18n::XOrdinalSuffix >( xInterface, UNO_QUERY);
[ # # ]
144 : : }
145 : 0 : catch ( Exception& )
146 : : {
147 : : OSL_FAIL( "GetOrdinalSuffix: exception caught during init" );
148 : : }
149 : : }
150 : : OSL_ENSURE( xOrdinalSuffix.is(), "GetOrdinalSuffix: createInstance failed");
151 [ + - ]: 6 : if (xOrdinalSuffix.is())
152 : : {
153 : : try
154 : : {
155 [ + - ]: 6 : uno::Sequence< rtl::OUString > aSuffixes = xOrdinalSuffix->getOrdinalSuffix( nNumber,
156 [ + - ][ + - ]: 6 : ScGlobal::pLocaleData->getLocale());
157 [ - + ]: 6 : if ( aSuffixes.getLength() > 0 )
158 [ # # ][ # # ]: 0 : return aSuffixes[0];
159 : : else
160 [ + - ][ + - ]: 6 : return String();
[ # # ]
161 : : }
162 : 0 : catch ( Exception& )
163 : : {
164 : : OSL_FAIL( "GetOrdinalSuffix: exception caught during getOrdinalSuffix" );
165 : : }
166 : : }
167 : 6 : return String();
168 : : }
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|