tdf#124953: Use rangelist's combined range top-left address...
[LibreOffice.git] / include / svx / fmtools.hxx
blob6322cc3720d01500eb4a1fa8559e65cc464127e3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_FMTOOLS_HXX
20 #define INCLUDED_SVX_FMTOOLS_HXX
22 #include <svx/svxdllapi.h>
24 #include <com/sun/star/sdb/SQLContext.hpp>
25 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
26 #include <com/sun/star/sdbcx/Privilege.hpp>
27 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
28 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
29 #include <com/sun/star/sdbc/XRowSet.hpp>
30 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
31 #include <com/sun/star/sdb/XColumn.hpp>
32 #include <com/sun/star/sdb/XColumnUpdate.hpp>
33 #include <com/sun/star/sdb/SQLErrorEvent.hpp>
34 #include <com/sun/star/sdbc/XConnection.hpp>
35 #include <com/sun/star/sdbc/XResultSet.hpp>
36 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
37 #include <com/sun/star/sdbcx/XRowLocate.hpp>
38 #include <com/sun/star/sdbc/XDataSource.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/container/XIndexContainer.hpp>
41 #include <com/sun/star/container/XNameAccess.hpp>
42 #include <com/sun/star/container/XEnumeration.hpp>
43 #include <com/sun/star/container/XIndexAccess.hpp>
44 #include <com/sun/star/awt/XControlModel.hpp>
45 #include <com/sun/star/awt/XControl.hpp>
46 #include <com/sun/star/awt/FontSlant.hpp>
47 #include <com/sun/star/awt/FontDescriptor.hpp>
48 #include <com/sun/star/awt/FontUnderline.hpp>
49 #include <com/sun/star/awt/FontStrikeout.hpp>
50 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <com/sun/star/io/XObjectInputStream.hpp>
53 #include <com/sun/star/io/XObjectOutputStream.hpp>
54 #include <com/sun/star/io/XPersistObject.hpp>
55 #include <com/sun/star/util/XNumberFormatter.hpp>
56 #include <com/sun/star/util/XNumberFormats.hpp>
58 #include <rtl/ref.hxx>
59 #include <tools/wintypes.hxx>
60 #include <cppuhelper/weakref.hxx>
61 #include <cppuhelper/implbase.hxx>
63 #include <set>
65 namespace vcl { class Window; }
68 // common types
70 // displaying a database exception for the user
71 // display info about a simple css::sdbc::SQLException
72 void displayException(const css::sdbc::SQLException&, vcl::Window* _pParent);
73 SVX_DLLPUBLIC void displayException(const css::sdb::SQLContext&, vcl::Window* _pParent);
74 void displayException(const css::sdb::SQLErrorEvent&, vcl::Window* _pParent = nullptr);
75 void displayException(const css::uno::Any&, vcl::Window* _pParent = nullptr);
77 sal_Int32 getElementPos(const css::uno::Reference< css::container::XIndexAccess>& xCont, const css::uno::Reference< css::uno::XInterface>& xElement);
79 SVX_DLLPUBLIC OUString getLabelName(const css::uno::Reference< css::beans::XPropertySet>& xControlModel);
82 // = class CursorWrapper - a helper class which works in common with a css::uno::Reference<XDatabaseUpdateCursor>,
83 // XDatabaseBookmarkCursor and XDatabaseDirectCursor each
86 class SAL_WARN_UNUSED CursorWrapper
88 private:
89 css::uno::Reference< css::uno::XInterface> m_xGeneric;
90 css::uno::Reference< css::sdbc::XResultSet> m_xMoveOperations;
91 css::uno::Reference< css::sdbcx::XRowLocate> m_xBookmarkOperations;
92 css::uno::Reference< css::sdbcx::XColumnsSupplier> m_xColumnsSupplier;
93 css::uno::Reference< css::beans::XPropertySet> m_xPropertyAccess;
95 public:
96 // Construction/Destruction
97 CursorWrapper(const css::uno::Reference< css::sdbc::XRowSet>& _rxCursor, bool bUseCloned = false);
98 SVX_DLLPUBLIC CursorWrapper(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned = false);
99 // if bUseCloned == sal_True, the cursor is first doubled over the XCloneable interface (which it must implement)
100 // and then used
102 friend bool operator==(const CursorWrapper& lhs, const CursorWrapper& rhs)
104 return lhs.m_xGeneric.get() == rhs.m_xGeneric.get();
107 bool is() const { return m_xMoveOperations.is(); }
108 bool Is() const { return m_xMoveOperations.is(); }
110 operator const css::uno::Reference< css::uno::XInterface>& () const{ return m_xGeneric; }
112 // 'Conversions'
113 CursorWrapper& operator=(const css::uno::Reference< css::sdbc::XRowSet>& xCursor);
114 operator const css::uno::Reference< css::sdbc::XResultSet>& () const { return m_xMoveOperations; }
116 const css::uno::Reference< css::beans::XPropertySet >& getPropertySet() const { return m_xPropertyAccess; }
118 // css::uno::Reference< css::sdbcx::XRowLocate>
119 /// @throws css::sdbc::SQLException
120 /// @throws css::uno::RuntimeException
121 css::uno::Any getBookmark()
122 { return m_xBookmarkOperations->getBookmark(); }
123 /// @throws css::sdbc::SQLException
124 /// @throws css::uno::RuntimeException
125 bool moveToBookmark(const css::uno::Any& bookmark) { return m_xBookmarkOperations->moveToBookmark(bookmark); }
127 // css::sdbc::XResultSet
128 bool isBeforeFirst() const { return m_xMoveOperations->isBeforeFirst(); }
129 bool isAfterLast() const { return m_xMoveOperations->isAfterLast(); }
130 bool isFirst() const { return m_xMoveOperations->isFirst(); }
131 bool isLast() const { return m_xMoveOperations->isLast(); }
132 void beforeFirst() { m_xMoveOperations->beforeFirst(); }
133 bool first() { return m_xMoveOperations->first(); }
134 bool last() { return m_xMoveOperations->last(); }
135 sal_Int32 getRow() const { return m_xMoveOperations->getRow(); }
136 bool absolute(sal_Int32 nPosition) { return m_xMoveOperations->absolute(nPosition); }
137 bool relative(sal_Int32 nCount) { return m_xMoveOperations->relative(nCount); }
138 bool previous() { return m_xMoveOperations->previous(); }
139 bool next() { return m_xMoveOperations->next(); }
140 void refreshRow() { m_xMoveOperations->refreshRow(); }
141 bool rowDeleted() { return m_xMoveOperations->rowDeleted(); }
142 // css::sdbcx::XColumnsSupplier
143 /// @throws css::uno::RuntimeException
144 css::uno::Reference< css::container::XNameAccess> getColumns() const { return m_xColumnsSupplier->getColumns(); }
145 private:
146 void ImplConstruct(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned);
150 class FmXDisposeMultiplexer;
151 class SAL_WARN_UNUSED FmXDisposeListener
153 friend class FmXDisposeMultiplexer;
155 rtl::Reference<FmXDisposeMultiplexer> m_pAdapter;
156 osl::Mutex m_aMutex;
158 public:
159 virtual ~FmXDisposeListener();
161 /// @throws css::uno::RuntimeException
162 virtual void disposing(const css::lang::EventObject& _rEvent, sal_Int16 _nId) = 0;
164 protected:
165 void setAdapter(FmXDisposeMultiplexer* pAdapter);
168 class SAL_WARN_UNUSED FmXDisposeMultiplexer : public cppu::WeakImplHelper< css::lang::XEventListener >
170 css::uno::Reference< css::lang::XComponent> m_xObject;
171 FmXDisposeListener* m_pListener;
173 virtual ~FmXDisposeMultiplexer() override;
174 public:
175 FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const css::uno::Reference< css::lang::XComponent>& _rxObject);
177 // css::lang::XEventListener
178 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
180 void dispose();
183 sal_Int16 getControlTypeByObject(const css::uno::Reference< css::lang::XServiceInfo>& _rxObject);
184 // get the object type (OBJ_FM_...) from the services the object supports
187 bool isRowSetAlive(const css::uno::Reference< css::uno::XInterface>& _rxRowSet);
188 // checks if the css::sdbcx::XColumnsSupplier provided by _rxRowSet supplies any columns
191 typedef ::std::set< css::uno::Reference< css::uno::XInterface > > InterfaceBag;
193 #endif // INCLUDED_SVX_FMTOOLS_HXX
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */