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 : : #ifndef _SVX_FMTOOLS_HXX
29 : : #define _SVX_FMTOOLS_HXX
30 : :
31 : : #include "svx/svxdllapi.h"
32 : :
33 : : #include <com/sun/star/sdb/SQLContext.hpp>
34 : : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
35 : : #include <com/sun/star/sdbcx/Privilege.hpp>
36 : : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
37 : : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
38 : : #include <com/sun/star/sdbc/XRowSet.hpp>
39 : : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
40 : : #include <com/sun/star/sdb/XColumn.hpp>
41 : : #include <com/sun/star/sdb/XColumnUpdate.hpp>
42 : : #include <com/sun/star/sdb/SQLErrorEvent.hpp>
43 : : #include <com/sun/star/sdbc/XConnection.hpp>
44 : : #include <com/sun/star/sdbc/XResultSet.hpp>
45 : : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
46 : : #include <com/sun/star/sdbcx/XRowLocate.hpp>
47 : : #include <com/sun/star/sdbc/XDataSource.hpp>
48 : : #include <com/sun/star/beans/XPropertySet.hpp>
49 : : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
50 : : #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
51 : : #include <com/sun/star/container/XIndexContainer.hpp>
52 : : #include <com/sun/star/frame/XDispatch.hpp>
53 : : #include <com/sun/star/frame/XStatusListener.hpp>
54 : : #include <com/sun/star/frame/FeatureStateEvent.hpp>
55 : : #include <com/sun/star/frame/XModel.hpp>
56 : : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
57 : : #include <com/sun/star/container/XNameAccess.hpp>
58 : : #include <com/sun/star/container/XEnumeration.hpp>
59 : : #include <com/sun/star/container/XIndexAccess.hpp>
60 : : #include <com/sun/star/awt/XControlModel.hpp>
61 : : #include <com/sun/star/awt/XControl.hpp>
62 : : #include <com/sun/star/awt/FontSlant.hpp>
63 : : #include <com/sun/star/awt/FontDescriptor.hpp>
64 : : #include <com/sun/star/awt/FontUnderline.hpp>
65 : : #include <com/sun/star/awt/FontStrikeout.hpp>
66 : : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
67 : : #include <com/sun/star/lang/XServiceInfo.hpp>
68 : : #include <com/sun/star/io/XObjectInputStream.hpp>
69 : : #include <com/sun/star/io/XObjectOutputStream.hpp>
70 : : #include <com/sun/star/io/XPersistObject.hpp>
71 : : #include <com/sun/star/util/XNumberFormatter.hpp>
72 : : #include <com/sun/star/util/XNumberFormats.hpp>
73 : :
74 : : #include <tools/wintypes.hxx>
75 : : #include <cppuhelper/weakref.hxx>
76 : : #include <comphelper/uno3.hxx>
77 : : #include <comphelper/stl_types.hxx>
78 : : #include <cppuhelper/implbase1.hxx>
79 : :
80 : : #include <set>
81 : :
82 : : class Window;
83 : :
84 : : //==================================================================
85 : : // common types
86 : : //==================================================================
87 : : // displaying a database exception for the user
88 : : // display info about a simple ::com::sun::star::sdbc::SQLException
89 : : void displayException(const ::com::sun::star::sdbc::SQLException&, Window* _pParent = NULL);
90 : : void displayException(const ::com::sun::star::sdbc::SQLWarning&, Window* _pParent = NULL);
91 : : SVX_DLLPUBLIC void displayException(const ::com::sun::star::sdb::SQLContext&, Window* _pParent = NULL);
92 : : void displayException(const ::com::sun::star::sdb::SQLErrorEvent&, Window* _pParent = NULL);
93 : : void displayException(const ::com::sun::star::uno::Any&, Window* _pParent = NULL);
94 : :
95 : : sal_Int32 getElementPos(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& xCont, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElement);
96 : :
97 : : SVX_DLLPUBLIC ::rtl::OUString getLabelName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xControlModel);
98 : :
99 : : // ===================================================================================================
100 : : // = class CursorWrapper - a helper class which works in common with a ::com::sun::star::uno::Reference<XDatabaseUpdateCursor>,
101 : : // XDatabaseBookmarkCursor and XDatabaseDirectCursor each
102 : : // ===================================================================================================
103 : :
104 : 4 : class CursorWrapper
105 : : {
106 : : private:
107 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xGeneric;
108 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xMoveOperations;
109 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate> m_xBookmarkOperations;
110 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> m_xColumnsSupplier;
111 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xPropertyAccess;
112 : :
113 : : public:
114 : : // Construction/Destruction
115 : 0 : CursorWrapper() { }
116 : : CursorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor, sal_Bool bUseCloned = sal_False);
117 : : SVX_DLLPUBLIC CursorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned = sal_False);
118 : : // if bUseCloned == sal_True, the cursor is first doubled over the XCloneable interface (which it must implement)
119 : : // and then used
120 : :
121 : : friend bool operator==(const CursorWrapper& lhs, const CursorWrapper& rhs)
122 : : {
123 : : return lhs.m_xGeneric.get() == rhs.m_xGeneric.get();
124 : : }
125 : :
126 : : sal_Bool is() const { return m_xMoveOperations.is(); }
127 : 20 : sal_Bool Is() const { return m_xMoveOperations.is(); }
128 : :
129 : : CursorWrapper* operator ->() { return this; }
130 : 64 : operator const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& () const{ return m_xGeneric; }
131 : :
132 : : // 'Conversions'
133 : : const CursorWrapper& operator=(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& xCursor);
134 : 0 : operator const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& () const { return m_xMoveOperations; }
135 : : operator const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate>& () const { return m_xBookmarkOperations; }
136 : : operator const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& () const { return m_xColumnsSupplier; }
137 : :
138 : 12 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& getPropertySet() const { return m_xPropertyAccess; }
139 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& getResultSet() const { return m_xMoveOperations; }
140 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate >& getRowLocate() const { return m_xBookmarkOperations; }
141 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& getColumnsSupplier() const { return m_xColumnsSupplier; }
142 : :
143 : : // the usual queryInterface
144 : : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException )
145 : : { return m_xMoveOperations->queryInterface(type); }
146 : :
147 : : // ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate>
148 : 22 : ::com::sun::star::uno::Any getBookmark(void)
149 : : throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException )
150 : 22 : { return m_xBookmarkOperations->getBookmark(); }
151 : 2 : sal_Bool moveToBookmark(const ::com::sun::star::uno::Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) { return m_xBookmarkOperations->moveToBookmark(bookmark); }
152 : : sal_Bool moveRelativeToBookmark(const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) { return m_xBookmarkOperations->moveRelativeToBookmark(bookmark, rows); }
153 : : sal_Int32 compareBookmarks(const ::com::sun::star::uno::Any& lhs, const ::com::sun::star::uno::Any& rhs) const throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) { return m_xBookmarkOperations->compareBookmarks(lhs, rhs); }
154 : : sal_Int32 hasOrderedBookmarks(void) const throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) { return m_xBookmarkOperations->hasOrderedBookmarks(); }
155 : : sal_Int32 hashBookmark(const ::com::sun::star::uno::Any& bookmark) const throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) { return m_xBookmarkOperations->hashBookmark(bookmark); }
156 : :
157 : : // ::com::sun::star::sdbc::XResultSet
158 : 20 : sal_Bool isBeforeFirst() const { return m_xMoveOperations->isBeforeFirst(); }
159 : 20 : sal_Bool isAfterLast() const { return m_xMoveOperations->isAfterLast(); }
160 : 0 : sal_Bool isFirst() const { return m_xMoveOperations->isFirst(); }
161 : 0 : sal_Bool isLast() const { return m_xMoveOperations->isLast(); }
162 : 0 : void beforeFirst() { m_xMoveOperations->beforeFirst(); }
163 : 0 : sal_Bool first() { return m_xMoveOperations->first(); }
164 : 0 : sal_Bool last() { return m_xMoveOperations->last(); }
165 : 36 : sal_Int32 getRow() const { return m_xMoveOperations->getRow(); }
166 : 2 : sal_Bool absolute(sal_Int32 nPosition) { return m_xMoveOperations->absolute(nPosition); }
167 : 14 : sal_Bool relative(sal_Int32 nCount) { return m_xMoveOperations->relative(nCount); }
168 : 0 : sal_Bool previous() { return m_xMoveOperations->previous(); }
169 : 0 : sal_Bool next() { return m_xMoveOperations->next(); }
170 : 0 : void refreshRow() { m_xMoveOperations->refreshRow(); }
171 : : sal_Bool rowUpdated() { return m_xMoveOperations->rowUpdated(); }
172 : : sal_Bool rowInserted() { return m_xMoveOperations->rowInserted(); }
173 : 40 : sal_Bool rowDeleted() { return m_xMoveOperations->rowDeleted(); }
174 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> getStatement() { return m_xMoveOperations->getStatement(); }
175 : : // ::com::sun::star::sdbcx::XColumnsSupplier
176 : 4 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getColumns() const throw( ::com::sun::star::uno::RuntimeException ) { return m_xColumnsSupplier->getColumns(); }
177 : : private:
178 : : void ImplConstruct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned);
179 : : };
180 : :
181 : :
182 : : class FmXDisposeMultiplexer;
183 : : class FmXDisposeListener
184 : : {
185 : : friend class FmXDisposeMultiplexer;
186 : :
187 : : FmXDisposeMultiplexer* m_pAdapter;
188 : : ::osl::Mutex& m_rMutex;
189 : :
190 : : public:
191 : 2 : FmXDisposeListener(::osl::Mutex& _rMutex) : m_pAdapter(NULL), m_rMutex(_rMutex) { }
192 : : virtual ~FmXDisposeListener();
193 : :
194 : : virtual void disposing(const ::com::sun::star::lang::EventObject& _rEvent, sal_Int16 _nId) throw( ::com::sun::star::uno::RuntimeException ) = 0;
195 : :
196 : : protected:
197 : : void setAdapter(FmXDisposeMultiplexer* pAdapter);
198 : : };
199 : :
200 : : //==============================================================================
201 : :
202 : : class FmXDisposeMultiplexer :public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener>
203 : : {
204 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> m_xObject;
205 : : FmXDisposeListener* m_pListener;
206 : : sal_Int16 m_nId;
207 : :
208 : : virtual ~FmXDisposeMultiplexer();
209 : : public:
210 : : FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>& _rxObject, sal_Int16 _nId = -1);
211 : :
212 : : // ::com::sun::star::lang::XEventListener
213 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
214 : :
215 : : void dispose();
216 : : };
217 : :
218 : : // ==================================================================
219 : :
220 : : sal_Int16 getControlTypeByObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject);
221 : : // get the object type (OBJ_FM_...) from the services the object supports
222 : :
223 : : //==================================================================
224 : : sal_Bool isRowSetAlive(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxRowSet);
225 : : // checks if the ::com::sun::star::sdbcx::XColumnsSupplier provided by _rxRowSet supllies any columns
226 : :
227 : : //==================================================================
228 : : typedef ::std::set < ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
229 : : , ::comphelper::OInterfaceCompare< ::com::sun::star::uno::XInterface >
230 : : > InterfaceBag;
231 : :
232 : : #endif // _SVX_FMTOOLS_HXX
233 : :
234 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|