merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / scripting / source / runtimemgr / StorageBridge.cxx
blobe441389f2b050cc1fe7c8440dcadf9a0b2c2825b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_scripting.hxx"
32 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
33 #include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
35 #include "StorageBridge.hxx"
36 #include <util/util.hxx>
38 using namespace ::rtl;
39 using namespace ::osl;
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::uno;
42 using namespace ::drafts::com::sun::star::script::framework;
44 namespace scripting_runtimemgr
47 const char* const SCRIPTIMPLACCESS_SERVICE =
48 "drafts.com.sun.star.script.framework.storage.StorageProxy";
49 const char* const SCRIPTSTORAGEMANAGER_SERVICE =
50 "/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager";
51 const int STORAGEID = 0;
52 const int STORAGEPROXY = 0;
55 //*************************************************************************
56 // StorageBridge Constructor
57 StorageBridge::StorageBridge( const Reference< XComponentContext >& xContext,
58 sal_Int32 sid ) : m_xContext( xContext ), m_sid( sid )
60 validateXRef( m_xContext, "StorageBridge::StorageBridge: invalid context" );
61 try
63 initStorage();
65 catch ( RuntimeException & re )
67 OUString temp = OUSTR( "StorageBridge::StorageBridge(salIn32&): " );
68 throw RuntimeException( temp.concat( re.Message ), Reference< XInterface >() );
72 //*************************************************************************
73 void
74 StorageBridge::initStorage() throw ( ::com::sun::star::uno::RuntimeException )
76 try
78 Reference< lang::XMultiComponentFactory > xMultiComFac =
79 m_xContext->getServiceManager();
80 validateXRef( xMultiComFac,
81 "StorageBridge::StorageBridge: cannot get multicomponentfactory from multiservice factory" );
82 Reference< XInterface > temp;
84 Any a = m_xContext->getValueByName(
85 OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) );
86 if ( sal_False == ( a >>= temp ) )
88 throw RuntimeException(
89 OUSTR( "StorageBridge::StorageBridge: could not obtain ScriptStorageManager singleton" ),
90 Reference< XInterface >() );
92 validateXRef( temp,
93 "StorageBridge::StorageBridge: cannot get Storage service" );
94 Reference< storage::XScriptStorageManager > xScriptStorageManager( temp, UNO_QUERY_THROW );
95 validateXRef( xScriptStorageManager,
96 "StorageBridge::StorageBridge: cannot get Script Storage Manager service" );
97 Reference< XInterface > xScriptStorage =
98 xScriptStorageManager->getScriptStorage( m_sid );
99 validateXRef( xScriptStorage,
100 "StorageBridge::StorageBridge: cannot get Script Storage service" );
101 m_xScriptInfoAccess =
102 Reference< storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW );
104 catch ( RuntimeException & re )
106 OUString temp = OUSTR( "StorageBridge::StorageBridge: " );
107 throw RuntimeException( temp.concat( re.Message ), Reference< XInterface >() );
109 catch ( Exception & e )
111 OUString temp = OUSTR( "StorageBridge::StorageBridge: " );
112 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
115 //*************************************************************************
116 Sequence< ::rtl::OUString >
117 StorageBridge::getScriptLogicalNames()
118 throw ( lang::IllegalArgumentException,
119 RuntimeException )
121 OSL_TRACE( "In StorageBridge getScriptLogicalNames...\n" );
122 Sequence < ::rtl::OUString > results;
125 results = m_xScriptInfoAccess->getScriptLogicalNames();
127 catch ( Exception e )
129 OUString temp = OUSTR( "StorageBridge::getScriptLogicalNames: " );
130 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
132 return results;
135 //*************************************************************************
136 Sequence < Reference< storage::XScriptInfo > >
137 StorageBridge::getImplementations( const ::rtl::OUString& queryURI )
138 throw ( lang::IllegalArgumentException, RuntimeException )
140 OSL_TRACE( "In StorageBridge getImplementations...\n" );
141 Sequence < Reference< storage::XScriptInfo > > results;
144 results = m_xScriptInfoAccess->getImplementations( queryURI );
146 catch ( Exception e )
148 OUString temp = OUSTR( "StorageBridge::getImplementations: " );
149 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
151 return results;
153 }// namespace
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */