Branch data Line data Source code
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 <com/sun/star/registry/MergeConflictException.hpp>
21 : : #include <com/sun/star/registry/XSimpleRegistry.hpp>
22 : : #include <com/sun/star/container/XNameAccess.hpp>
23 : : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
24 : : #include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
25 : : #include <com/sun/star/document/XTypeDetection.hpp>
26 : : #include <com/sun/star/frame/XLoadable.hpp>
27 : : #include <com/sun/star/frame/XStorable.hpp>
28 : : #include <comphelper/processfactory.hxx>
29 : : #include <unotools/pathoptions.hxx>
30 : : #include <unotools/moduleoptions.hxx>
31 : : #include <unotools/ucbstreamhelper.hxx>
32 : : #include <unotools/localfilehelper.hxx>
33 : : #include <comphelper/componentcontext.hxx>
34 : : #include <comphelper/sequenceashashmap.hxx>
35 : : #include <comphelper/configurationhelper.hxx>
36 : :
37 : : #include <sfx2/sfx.hrc>
38 : : #include <sfx2/docfilt.hxx>
39 : : #include <sfx2/docfac.hxx>
40 : : #include "sfx2/viewfac.hxx"
41 : : #include "fltfnc.hxx"
42 : : #include "arrdecl.hxx"
43 : : #include <sfx2/app.hxx>
44 : : #include <sfx2/module.hxx>
45 : : #include <sfx2/mnumgr.hxx>
46 : : #include "sfx2/sfxresid.hxx"
47 : : #include <sfx2/sfxuno.hxx>
48 : : #include "syspath.hxx"
49 : : #include <osl/file.hxx>
50 : : #include <osl/security.hxx>
51 : : #include "doc.hrc"
52 : :
53 : : #include <rtl/strbuf.hxx>
54 : :
55 : : #include <assert.h>
56 : :
57 : : namespace css = ::com::sun::star;
58 : : using namespace ::com::sun::star;
59 : :
60 : : //========================================================================
61 : :
62 : 12087 : DECL_PTRARRAY( SfxViewFactoryArr_Impl, SfxViewFactory*, 2, 2 )
63 : :
64 : : //========================================================================
65 : :
66 : : DBG_NAME(SfxObjectFactory)
67 : :
68 : : //========================================================================
69 : :
70 [ + - ][ + - ]: 318 : struct SfxObjectFactory_Impl
71 : : {
72 : : SfxViewFactoryArr_Impl aViewFactoryArr;// List of <SfxViewFactory>s
73 : : ResId* pNameResId;
74 : : ::rtl::OUString aServiceName;
75 : : SfxFilterContainer* pFilterContainer;
76 : : SfxModule* pModule;
77 : : sal_uInt16 nImageId;
78 : : String aStandardTemplate;
79 : : sal_Bool bTemplateInitialized;
80 : : SvGlobalName aClassName;
81 : :
82 : 318 : SfxObjectFactory_Impl() :
83 : : pNameResId ( NULL ),
84 : : pFilterContainer ( NULL ),
85 : : pModule ( NULL ),
86 : : nImageId ( 0 ),
87 [ + - ][ + - ]: 318 : bTemplateInitialized( sal_False )
88 : 318 : {}
89 : : };
90 : :
91 : : //========================================================================
92 : :
93 : 2898 : SfxFilterContainer* SfxObjectFactory::GetFilterContainer( sal_Bool /*bForceLoad*/ ) const
94 : : {
95 : 2898 : return pImpl->pFilterContainer;
96 : : }
97 : :
98 : : //--------------------------------------------------------------------
99 : :
100 : 318 : SfxObjectFactory::SfxObjectFactory
101 : : (
102 : : const SvGlobalName& rName,
103 : : SfxObjectShellFlags nFlagsP,
104 : : const char* pName
105 : : ) : pShortName( pName ),
106 [ + - ]: 318 : pImpl( new SfxObjectFactory_Impl ),
107 : 318 : nFlags( nFlagsP )
108 : : {
109 : : DBG_CTOR(SfxObjectFactory, 0);
110 [ + - ][ + - ]: 318 : pImpl->pFilterContainer = new SfxFilterContainer( rtl::OUString::createFromAscii( pName ) );
[ + - ][ + - ]
111 : :
112 [ + - ]: 318 : String aShortName( rtl::OUString::createFromAscii( pShortName ) );
113 [ + - ]: 318 : aShortName.ToLowerAscii();
114 [ + - ]: 318 : pImpl->aClassName = rName;
115 [ + - ][ + + ]: 318 : if ( aShortName.EqualsAscii( "swriter" ) )
116 [ + - ][ + - ]: 73 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_SW );
117 [ + - ][ + + ]: 245 : else if ( aShortName.EqualsAscii( "swriter/web" ) )
118 [ + - ][ + - ]: 73 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_SWWEB );
119 [ + - ][ + + ]: 172 : else if ( aShortName.EqualsAscii( "swriter/globaldocument" ) )
120 [ + - ][ + - ]: 67 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_SWGLOB );
121 [ + - ][ + + ]: 105 : else if ( aShortName.EqualsAscii( "scalc" ) )
122 [ + - ][ + - ]: 51 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_SC );
123 [ + - ][ + + ]: 54 : else if ( aShortName.EqualsAscii( "simpress" ) )
124 [ + - ][ + - ]: 22 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_SI );
125 [ + - ][ + + ]: 32 : else if ( aShortName.EqualsAscii( "sdraw" ) )
126 [ + - ][ + - ]: 22 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_SD );
127 [ + - ][ - + ]: 10 : else if ( aShortName.EqualsAscii( "message" ) )
128 [ # # ][ # # ]: 318 : pImpl->pNameResId = new SfxResId( STR_DOCTYPENAME_MESSAGE );
[ + - ]
129 : 318 : }
130 : :
131 : : //--------------------------------------------------------------------
132 : :
133 : 318 : SfxObjectFactory::~SfxObjectFactory()
134 : : {
135 : : DBG_DTOR(SfxObjectFactory, 0);
136 : :
137 : 318 : delete pImpl->pNameResId;
138 [ + - ]: 318 : delete pImpl->pFilterContainer;
139 [ + - ]: 318 : delete pImpl;
140 : 318 : }
141 : :
142 : : //--------------------------------------------------------------------
143 : :
144 : 697 : void SfxObjectFactory::RegisterViewFactory
145 : : (
146 : : SfxViewFactory &rFactory
147 : : )
148 : : {
149 : : #if OSL_DEBUG_LEVEL > 0
150 : : {
151 : : const String sViewName( rFactory.GetAPIViewName() );
152 : : for ( sal_uInt16 i = 0; i < pImpl->aViewFactoryArr.Count(); ++i )
153 : : {
154 : : if ( !pImpl->aViewFactoryArr[i]->GetAPIViewName().Equals( sViewName ) )
155 : : continue;
156 : : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
157 : : "SfxObjectFactory::RegisterViewFactory: duplicate view name '"));
158 : : aStr.append(rtl::OUStringToOString(sViewName, RTL_TEXTENCODING_ASCII_US));
159 : : aStr.append(RTL_CONSTASCII_STRINGPARAM("'!"));
160 : : OSL_FAIL(aStr.getStr());
161 : : break;
162 : : }
163 : : }
164 : : #endif
165 : : sal_uInt16 nPos;
166 [ + + + - ]: 2430 : for ( nPos = 0;
[ + + ]
167 : 1215 : nPos < pImpl->aViewFactoryArr.Count() &&
168 : 518 : pImpl->aViewFactoryArr[nPos]->GetOrdinal() <= rFactory.GetOrdinal();
169 : : ++nPos )
170 : : /* empty loop */;
171 : 697 : pImpl->aViewFactoryArr.Insert(nPos, &rFactory);
172 : 697 : }
173 : :
174 : : //--------------------------------------------------------------------
175 : :
176 : 6846 : sal_uInt16 SfxObjectFactory::GetViewFactoryCount() const
177 : : {
178 : 6846 : return pImpl->aViewFactoryArr.Count();
179 : : }
180 : :
181 : : //--------------------------------------------------------------------
182 : :
183 : 10236 : SfxViewFactory& SfxObjectFactory::GetViewFactory(sal_uInt16 i) const
184 : : {
185 : 10236 : return *pImpl->aViewFactoryArr[i];
186 : : }
187 : :
188 : : //--------------------------------------------------------------------
189 : :
190 : 479644 : SfxModule* SfxObjectFactory::GetModule() const
191 : : {
192 : 479644 : return pImpl->pModule;
193 : : }
194 : :
195 : 312 : void SfxObjectFactory::SetModule_Impl( SfxModule *pMod )
196 : : {
197 : 312 : pImpl->pModule = pMod;
198 : 312 : }
199 : :
200 : 0 : void SfxObjectFactory::SetSystemTemplate( const String& rServiceName, const String& rTemplateName )
201 : : {
202 : : static const int nMaxPathSize = 16000;
203 [ # # ][ # # ]: 0 : static ::rtl::OUString SERVICE_FILTER_FACTORY("com.sun.star.document.FilterFactory");
204 [ # # ][ # # ]: 0 : static ::rtl::OUString SERVICE_TYPE_DECTECTION("com.sun.star.document.TypeDetection");
205 : :
206 [ # # ][ # # ]: 0 : static ::rtl::OUString CONF_ROOT("/org.openoffice.Setup");
207 [ # # ][ # # ]: 0 : static ::rtl::OUString CONF_PATH = ::rtl::OUString("Office/Factories/" ) + ::rtl::OUString( rServiceName );
[ # # ][ # # ]
208 [ # # ][ # # ]: 0 : static ::rtl::OUString PROP_DEF_TEMPL_CHANGED("ooSetupFactorySystemDefaultTemplateChanged");
209 [ # # ][ # # ]: 0 : static ::rtl::OUString PROP_ACTUAL_FILTER("ooSetupFactoryActualFilter");
210 : :
211 [ # # ][ # # ]: 0 : static ::rtl::OUString DEF_TPL_STR("/soffice.");
212 : :
213 : 0 : rtl::OUString sURL;
214 [ # # ]: 0 : String sPath;
215 : : sal_Unicode aPathBuffer[nMaxPathSize];
216 [ # # ][ # # ]: 0 : if ( SystemPath::GetUserTemplateLocation( aPathBuffer, nMaxPathSize ))
217 [ # # ]: 0 : sPath = rtl::OUString( aPathBuffer );
218 [ # # ][ # # ]: 0 : ::utl::LocalFileHelper::ConvertPhysicalNameToURL( sPath, sURL );
219 : :
220 : 0 : ::rtl::OUString aUserTemplateURL( sURL );
221 [ # # ]: 0 : if ( !aUserTemplateURL.isEmpty())
222 : : {
223 : : try
224 : : {
225 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
226 : : uno::Reference< uno::XInterface > xConfig = ::comphelper::ConfigurationHelper::openConfig(
227 [ # # ]: 0 : xFactory, CONF_ROOT, ::comphelper::ConfigurationHelper::E_STANDARD );
228 : :
229 : 0 : ::rtl::OUString aActualFilter;
230 [ # # ]: 0 : ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, CONF_PATH, PROP_ACTUAL_FILTER ) >>= aActualFilter;
231 : 0 : sal_Bool bChanged(sal_False);
232 [ # # ]: 0 : ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED ) >>= bChanged;
233 : :
234 : : uno::Reference< container::XNameAccess > xFilterFactory(
235 [ # # ][ # # ]: 0 : xFactory->createInstance( SERVICE_FILTER_FACTORY ), uno::UNO_QUERY_THROW );
[ # # ]
236 : : uno::Reference< container::XNameAccess > xTypeDetection(
237 [ # # ][ # # ]: 0 : xFactory->createInstance( SERVICE_TYPE_DECTECTION ), uno::UNO_QUERY_THROW );
[ # # ]
238 : :
239 : 0 : ::rtl::OUString aActualFilterTypeName;
240 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aActuralFilterData;
241 [ # # ][ # # ]: 0 : xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData;
[ # # ]
242 [ # # ]: 0 : for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); nInd++ )
243 [ # # ][ # # ]: 0 : if ( aActuralFilterData[nInd].Name == "Type" )
244 [ # # ]: 0 : aActuralFilterData[nInd].Value >>= aActualFilterTypeName;
245 [ # # ][ # # ]: 0 : ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( aActualFilterTypeName ) );
[ # # ]
246 : : uno::Sequence< ::rtl::OUString > aAllExt =
247 [ # # ][ # # ]: 0 : aProps1.getUnpackedValueOrDefault( ::rtl::OUString("Extensions"), uno::Sequence< ::rtl::OUString >() );
[ # # ]
248 : : //To-do: check if aAllExt is empty first
249 [ # # ]: 0 : ::rtl::OUString aExt = aAllExt[0];
250 : :
251 : 0 : aUserTemplateURL += DEF_TPL_STR;
252 : 0 : aUserTemplateURL += aExt;
253 : :
254 : : uno::Reference<ucb::XSimpleFileAccess2> xSimpleFileAccess(
255 [ # # ][ # # ]: 0 : ucb::SimpleFileAccess::create( ::comphelper::ComponentContext(xFactory).getUNOContext() ) );
[ # # ][ # # ]
256 : :
257 : 0 : ::rtl::OUString aBackupURL;
258 [ # # ][ # # ]: 0 : ::osl::Security().getConfigDir(aBackupURL);
[ # # ]
259 : 0 : aBackupURL += ::rtl::OUString("/temp");
260 : :
261 [ # # ][ # # ]: 0 : if ( !xSimpleFileAccess->exists( aBackupURL ) )
[ # # ]
262 [ # # ][ # # ]: 0 : xSimpleFileAccess->createFolder( aBackupURL );
263 : :
264 : 0 : aBackupURL += DEF_TPL_STR;
265 : 0 : aBackupURL += aExt;
266 : :
267 [ # # ]: 0 : if ( rTemplateName.Len() != 0 )
268 : : {
269 [ # # ][ # # ]: 0 : if ( xSimpleFileAccess->exists( aUserTemplateURL ) && !bChanged )
[ # # ][ # # ]
[ # # ]
270 [ # # ][ # # ]: 0 : xSimpleFileAccess->copy( aUserTemplateURL, aBackupURL );
271 : :
272 [ # # ]: 0 : uno::Reference< document::XTypeDetection > xTypeDetector( xTypeDetection, uno::UNO_QUERY );
273 [ # # ][ # # ]: 0 : ::comphelper::SequenceAsHashMap aProps2( xTypeDetection->getByName( xTypeDetector->queryTypeByURL( rTemplateName ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
274 : : ::rtl::OUString aFilterName =
275 [ # # ]: 0 : aProps2.getUnpackedValueOrDefault( ::rtl::OUString("PreferredFilter"), ::rtl::OUString() );
276 : :
277 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aArgs( 3 );
278 [ # # ]: 0 : aArgs[0].Name = ::rtl::OUString("FilterName");
279 [ # # ][ # # ]: 0 : aArgs[0].Value <<= aFilterName;
280 [ # # ]: 0 : aArgs[1].Name = ::rtl::OUString("AsTemplate");
281 [ # # ][ # # ]: 0 : aArgs[1].Value <<= sal_True;
282 [ # # ]: 0 : aArgs[2].Name = ::rtl::OUString("URL");
283 [ # # ][ # # ]: 0 : aArgs[2].Value <<= ::rtl::OUString( rTemplateName );
[ # # ]
284 : :
285 [ # # ][ # # ]: 0 : uno::Reference< frame::XLoadable > xLoadable( xFactory->createInstance( ::rtl::OUString( rServiceName ) ), uno::UNO_QUERY );
[ # # ][ # # ]
286 [ # # ][ # # ]: 0 : xLoadable->load( aArgs );
287 : :
288 [ # # ]: 0 : aArgs.realloc( 2 );
289 [ # # ]: 0 : aArgs[1].Name = ::rtl::OUString("Overwrite");
290 [ # # ][ # # ]: 0 : aArgs[1].Value <<= sal_True;
291 : :
292 [ # # ]: 0 : uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY );
293 [ # # ][ # # ]: 0 : xStorable->storeToURL( aUserTemplateURL, aArgs );
294 [ # # ][ # # ]: 0 : ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED, uno::makeAny( sal_True ));
295 [ # # ][ # # ]: 0 : ::comphelper::ConfigurationHelper::flush( xConfig );
[ # # ]
296 : : }
297 : : else
298 : : {
299 : : DBG_ASSERT( bChanged, "invalid ooSetupFactorySystemDefaultTemplateChanged value!" );
300 : :
301 [ # # ][ # # ]: 0 : xSimpleFileAccess->copy( aBackupURL, aUserTemplateURL );
302 [ # # ][ # # ]: 0 : xSimpleFileAccess->kill( aBackupURL );
303 [ # # ][ # # ]: 0 : ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED, uno::makeAny( sal_False ));
304 [ # # ]: 0 : ::comphelper::ConfigurationHelper::flush( xConfig );
305 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
306 : : }
307 [ # # ]: 0 : catch(const uno::Exception&)
308 : : {
309 : : }
310 [ # # ]: 0 : }
311 : 0 : }
312 : :
313 : 0 : void SfxObjectFactory::SetStandardTemplate( const String& rServiceName, const String& rTemplate )
314 : : {
315 [ # # ]: 0 : SvtModuleOptions::EFactory eFac = SvtModuleOptions::ClassifyFactoryByServiceName(rServiceName);
316 [ # # ]: 0 : if (eFac == SvtModuleOptions::E_UNKNOWN_FACTORY)
317 [ # # ]: 0 : eFac = SvtModuleOptions::ClassifyFactoryByShortName(rServiceName);
318 [ # # ]: 0 : if (eFac != SvtModuleOptions::E_UNKNOWN_FACTORY)
319 : : {
320 : 0 : SetSystemTemplate( rServiceName, rTemplate );
321 [ # # ][ # # ]: 0 : SvtModuleOptions().SetFactoryStandardTemplate(eFac, rTemplate);
[ # # ]
322 : : }
323 : 0 : }
324 : :
325 : 1093 : String SfxObjectFactory::GetStandardTemplate( const String& rServiceName )
326 : : {
327 [ + - ]: 1093 : SvtModuleOptions::EFactory eFac = SvtModuleOptions::ClassifyFactoryByServiceName(rServiceName);
328 [ - + ]: 1093 : if (eFac == SvtModuleOptions::E_UNKNOWN_FACTORY)
329 [ # # ]: 0 : eFac = SvtModuleOptions::ClassifyFactoryByShortName(rServiceName);
330 : :
331 : 1093 : String sTemplate;
332 [ + - ]: 1093 : if (eFac != SvtModuleOptions::E_UNKNOWN_FACTORY)
333 [ + - ][ + - ]: 1093 : sTemplate = SvtModuleOptions().GetFactoryStandardTemplate(eFac);
[ + - ][ + - ]
334 : :
335 : 1093 : return sTemplate;
336 : : }
337 : :
338 : 0 : const SfxFilter* SfxObjectFactory::GetTemplateFilter() const
339 : : {
340 : 0 : sal_uInt16 nVersion=0;
341 [ # # ][ # # ]: 0 : SfxFilterMatcher aMatcher ( rtl::OUString::createFromAscii( pShortName ) );
[ # # ]
342 [ # # ]: 0 : SfxFilterMatcherIter aIter( aMatcher );
343 : 0 : const SfxFilter *pFilter = 0;
344 [ # # ]: 0 : const SfxFilter *pTemp = aIter.First();
345 [ # # ]: 0 : while ( pTemp )
346 : : {
347 [ # # ][ # # ]: 0 : if( pTemp->IsOwnFormat() && pTemp->IsOwnTemplateFormat() && ( pTemp->GetVersion() > nVersion ) )
[ # # ][ # # ]
348 : : {
349 : 0 : pFilter = pTemp;
350 : 0 : nVersion = (sal_uInt16) pTemp->GetVersion();
351 : : }
352 : :
353 [ # # ]: 0 : pTemp = aIter.Next();
354 : : }
355 : :
356 [ # # ][ # # ]: 0 : return pFilter;
357 : : }
358 : :
359 : 312 : void SfxObjectFactory::SetDocumentServiceName( const ::rtl::OUString& rServiceName )
360 : : {
361 : 312 : pImpl->aServiceName = rServiceName;
362 : 312 : }
363 : :
364 : 154493 : const ::rtl::OUString& SfxObjectFactory::GetDocumentServiceName() const
365 : : {
366 : 154493 : return pImpl->aServiceName;
367 : : }
368 : :
369 : 0 : const SvGlobalName& SfxObjectFactory::GetClassId() const
370 : : {
371 : 0 : return pImpl->aClassName;
372 : : }
373 : :
374 : 0 : String SfxObjectFactory::GetFactoryURL() const
375 : : {
376 : 0 : ::rtl::OUStringBuffer aURLComposer;
377 [ # # ]: 0 : aURLComposer.appendAscii(RTL_CONSTASCII_STRINGPARAM("private:factory/"));
378 [ # # ]: 0 : aURLComposer.appendAscii(GetShortName());
379 [ # # ][ # # ]: 0 : return aURLComposer.makeStringAndClear();
380 : : }
381 : :
382 : 46 : String SfxObjectFactory::GetModuleName() const
383 : : {
384 : : try
385 : : {
386 [ + - ]: 46 : css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
387 : :
388 : : css::uno::Reference< css::container::XNameAccess > xModuleManager(
389 [ + - ]: 46 : xSMGR->createInstance("com.sun.star.frame.ModuleManager"),
390 [ + - ][ + - ]: 46 : css::uno::UNO_QUERY_THROW);
391 : :
392 [ + - ]: 46 : ::rtl::OUString sDocService(GetDocumentServiceName());
393 [ + - ][ + - ]: 46 : ::comphelper::SequenceAsHashMap aPropSet( xModuleManager->getByName(sDocService) );
[ + - ]
394 [ + - ]: 46 : ::rtl::OUString sModuleName = aPropSet.getUnpackedValueOrDefault("ooSetupFactoryUIName", ::rtl::OUString());
395 [ + - ][ + - ]: 46 : return String(sModuleName);
396 : : }
397 [ # # # ]: 0 : catch(const css::uno::RuntimeException&)
398 : : {
399 : 0 : throw;
400 : : }
401 : 0 : catch(const css::uno::Exception&)
402 : : {
403 : : }
404 : :
405 : 0 : return String();
406 : : }
407 : :
408 : :
409 : 3492 : sal_uInt16 SfxObjectFactory::GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const
410 : : {
411 [ + - ]: 3540 : for ( sal_uInt16 curViewNo = 0; curViewNo < GetViewFactoryCount(); ++curViewNo )
412 : : {
413 : 3540 : const sal_uInt16 curViewId = GetViewFactory( curViewNo ).GetOrdinal();
414 [ + + ]: 3540 : if ( i_nViewId == curViewId )
415 : 3492 : return curViewNo;
416 : : }
417 : 3492 : return i_nFallback;
418 : : }
419 : :
420 : 3270 : SfxViewFactory* SfxObjectFactory::GetViewFactoryByViewName( const String& i_rViewName ) const
421 : : {
422 [ + + ]: 6580 : for ( sal_uInt16 nViewNo = 0;
423 : 3290 : nViewNo < GetViewFactoryCount();
424 : : ++nViewNo
425 : : )
426 : : {
427 : 3288 : SfxViewFactory& rViewFac( GetViewFactory( nViewNo ) );
428 [ + - ][ + + ]: 8137 : if ( ( rViewFac.GetAPIViewName() == i_rViewName )
[ + + ][ + - ]
[ + + # # ]
[ + - ]
429 [ + - ][ + - ]: 4849 : || ( rViewFac.GetLegacyViewName() == i_rViewName )
[ + + ][ + - ]
[ # # ]
430 : : )
431 : 3268 : return &rViewFac;
432 : : }
433 : 3270 : return NULL;
434 : : }
435 : :
436 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|