1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
29 #define EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
31 #include <com/sun/star/uno/Reference.hxx>
32 #include "abptypes.hxx"
34 //========================================================================
35 namespace com
{ namespace sun
{ namespace star
{
37 class XMultiServiceFactory
;
47 //.........................................................................
50 //.........................................................................
52 //=====================================================================
53 //= ODataSourceContext
54 //=====================================================================
55 struct ODataSourceContextImpl
;
57 /// a non-UNO wrapper for the data source context
58 class ODataSourceContext
61 ODataSourceContextImpl
* m_pImpl
;
65 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
68 /// retrieves the names of all data sources
69 void getDataSourceNames( StringBag
& _rNames
) const SAL_THROW (( ));
71 /// disambiguates the given name by appending auccessive numbers
72 ::rtl::OUString
& disambiguate(::rtl::OUString
& _rDataSourceName
);
74 /// creates a new MORK data source
75 ODataSource
createNewMORK( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
77 /// creates a new Thunderbird data source
78 ODataSource
createNewThunderbird( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
80 /// creates a new Evolution local data source
81 ODataSource
createNewEvolution( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
83 /// creates a new Evolution LDAP data source
84 ODataSource
createNewEvolutionLdap( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
86 /// creates a new Evolution GROUPWISE data source
87 ODataSource
createNewEvolutionGroupwise( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
89 /// creates a new KDE address book data source
90 ODataSource
createNewKab( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
92 /// creates a new Mac OS X address book data source
93 ODataSource
createNewMacab( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
95 /// creates a new LDAP data source
96 ODataSource
createNewLDAP( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
98 /// creates a new Outlook data source
99 ODataSource
createNewOutlook( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
101 /// creates a new Outlook express data source
102 ODataSource
createNewOE( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
104 /// creates a new dBase data source
105 ODataSource
createNewDBase( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
108 //=====================================================================
110 //=====================================================================
111 struct ODataSourceImpl
;
112 struct PackageAccessControl
;
113 /** a non-UNO wrapper for a data source
114 <p>This class allows to access data sources without the need to compile the respective file with
115 exception handling enabled (hopefully :).</p>
116 <p>In addition to wrapping an UNO data source, an instance of this class can handle at most
117 one valid connection, as obtained from the data source.</p>
122 ODataSourceImpl
* m_pImpl
;
125 // ----------------------------------------------------------------
126 // - ctor/dtor/assignment
127 // ----------------------------------------------------------------
128 /// constructs an object which is initially invalid
130 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
134 ODataSource( const ODataSource
& _rSource
);
140 ODataSource
& operator=( const ODataSource
& _rSource
);
142 // ----------------------------------------------------------------
143 /// checks whether or not the object represents a valid data source
144 sal_Bool
isValid() const SAL_THROW (( ));
146 // ----------------------------------------------------------------
147 /// removes the data source represented by the object from the data source context
148 void remove() SAL_THROW (( ));
149 // TODO: put this into the context class
151 /// returns the name of the data source
153 getName() const SAL_THROW (( ));
155 /// renames the data source
156 sal_Bool
rename( const ::rtl::OUString
& _rName
) SAL_THROW (( ));
157 // TODO: put this into the context class
159 // ----------------------------------------------------------------
160 // - connection handling
161 // ----------------------------------------------------------------
162 /** connects to the data source represented by this object
163 @param _pMessageParent
164 the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
168 sal_Bool
connect( Window
* _pMessageParent
) SAL_THROW (( ));
170 /// returns <TRUE/> if the object has a valid connection, obtained from it's data source
171 sal_Bool
isConnected( ) const SAL_THROW (( ));
173 /// disconnects from the data source (i.e. disposes the UNO connection hold internally)
174 void disconnect( ) SAL_THROW (( ));
176 /// stores the database file
177 void store() SAL_THROW (( ));
179 /// register the data source under the given name in the configuration
180 void registerDataSource( const ::rtl::OUString
& _sRegisteredDataSourceName
) SAL_THROW (( ));
182 // ----------------------------------------------------------------
183 /** retrieves the tables names from the connection
184 <p>to be called when <method>isConnection</method> returns <TRUE/> only</p>
186 const StringBag
& getTableNames() const SAL_THROW (( ));
188 /** determines whether a given table exists
190 bool hasTable( const ::rtl::OUString
& _rTableName
) const;
192 /// return the intern data source object
193 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getDataSource() const SAL_THROW (( ));
196 // ----------------------------------------------------------------
197 /** set a new data source.
198 <p>Available to selected clients only</p>
201 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxDS
202 ,const ::rtl::OUString
& _sName
203 ,PackageAccessControl
207 ODataSource( ); // never implemented
210 //.........................................................................
212 //.........................................................................
214 #endif // EXTENSIONS_ABP_DATASOURCEHANDLING_HXX