Bump version to 6.4-15
[LibreOffice.git] / include / svx / fmtools.hxx
blob4ed9b7efcf7b3bc5e9190ec62955e35a3274d2ff
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/sdbcx/XColumnsSupplier.hpp>
25 #include <com/sun/star/sdbc/XResultSet.hpp>
26 #include <com/sun/star/sdbcx/XRowLocate.hpp>
27 #include <com/sun/star/lang/EventObject.hpp>
28 #include <com/sun/star/lang/XEventListener.hpp>
30 #include <rtl/ref.hxx>
31 #include <cppuhelper/implbase.hxx>
33 #include <set>
35 namespace com::sun::star::beans { class XPropertySet; }
36 namespace com::sun::star::container { class XIndexAccess; }
37 namespace com::sun::star::container { class XNameAccess; }
38 namespace com::sun::star::lang { class XComponent; }
39 namespace com::sun::star::lang { class XServiceInfo; }
40 namespace com::sun::star::sdbc { class SQLException; }
41 namespace com::sun::star::sdbc { class XRowSet; }
42 namespace com::sun::star::sdb { class SQLContext; }
43 namespace com::sun::star::sdb { struct SQLErrorEvent; }
44 namespace vcl { class Window; }
47 // common types
49 // displaying a database exception for the user
50 // display info about a simple css::sdbc::SQLException
51 void displayException(const css::sdbc::SQLException&, vcl::Window* _pParent);
52 SVX_DLLPUBLIC void displayException(const css::sdb::SQLContext&, vcl::Window* _pParent);
53 void displayException(const css::sdb::SQLErrorEvent&, vcl::Window* _pParent = nullptr);
54 void displayException(const css::uno::Any&, vcl::Window* _pParent = nullptr);
56 sal_Int32 getElementPos(const css::uno::Reference< css::container::XIndexAccess>& xCont, const css::uno::Reference< css::uno::XInterface>& xElement);
58 SVX_DLLPUBLIC OUString getLabelName(const css::uno::Reference< css::beans::XPropertySet>& xControlModel);
61 // = class CursorWrapper - a helper class which works in common with a css::uno::Reference<XDatabaseUpdateCursor>,
62 // XDatabaseBookmarkCursor and XDatabaseDirectCursor each
65 class SAL_WARN_UNUSED CursorWrapper
67 private:
68 css::uno::Reference< css::uno::XInterface> m_xGeneric;
69 css::uno::Reference< css::sdbc::XResultSet> m_xMoveOperations;
70 css::uno::Reference< css::sdbcx::XRowLocate> m_xBookmarkOperations;
71 css::uno::Reference< css::sdbcx::XColumnsSupplier> m_xColumnsSupplier;
72 css::uno::Reference< css::beans::XPropertySet> m_xPropertyAccess;
74 public:
75 // Construction/Destruction
76 CursorWrapper(const css::uno::Reference< css::sdbc::XRowSet>& _rxCursor, bool bUseCloned = false);
77 SVX_DLLPUBLIC CursorWrapper(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned = false);
78 // if bUseCloned == sal_True, the cursor is first doubled over the XCloneable interface (which it must implement)
79 // and then used
81 friend bool operator==(const CursorWrapper& lhs, const CursorWrapper& rhs)
83 return lhs.m_xGeneric.get() == rhs.m_xGeneric.get();
86 bool is() const { return m_xMoveOperations.is(); }
87 bool Is() const { return m_xMoveOperations.is(); }
89 operator const css::uno::Reference< css::uno::XInterface>& () const{ return m_xGeneric; }
91 // 'Conversions'
92 CursorWrapper& operator=(const css::uno::Reference< css::sdbc::XRowSet>& xCursor);
93 operator const css::uno::Reference< css::sdbc::XResultSet>& () const { return m_xMoveOperations; }
95 const css::uno::Reference< css::beans::XPropertySet >& getPropertySet() const { return m_xPropertyAccess; }
97 // css::uno::Reference< css::sdbcx::XRowLocate>
98 /// @throws css::sdbc::SQLException
99 /// @throws css::uno::RuntimeException
100 css::uno::Any getBookmark()
101 { return m_xBookmarkOperations->getBookmark(); }
102 /// @throws css::sdbc::SQLException
103 /// @throws css::uno::RuntimeException
104 bool moveToBookmark(const css::uno::Any& bookmark) { return m_xBookmarkOperations->moveToBookmark(bookmark); }
106 // css::sdbc::XResultSet
107 bool isBeforeFirst() const { return m_xMoveOperations->isBeforeFirst(); }
108 bool isAfterLast() const { return m_xMoveOperations->isAfterLast(); }
109 bool isFirst() const { return m_xMoveOperations->isFirst(); }
110 bool isLast() const { return m_xMoveOperations->isLast(); }
111 void beforeFirst() { m_xMoveOperations->beforeFirst(); }
112 bool first() { return m_xMoveOperations->first(); }
113 bool last() { return m_xMoveOperations->last(); }
114 sal_Int32 getRow() const { return m_xMoveOperations->getRow(); }
115 bool absolute(sal_Int32 nPosition) { return m_xMoveOperations->absolute(nPosition); }
116 bool relative(sal_Int32 nCount) { return m_xMoveOperations->relative(nCount); }
117 bool previous() { return m_xMoveOperations->previous(); }
118 bool next() { return m_xMoveOperations->next(); }
119 void refreshRow() { m_xMoveOperations->refreshRow(); }
120 bool rowDeleted() { return m_xMoveOperations->rowDeleted(); }
121 // css::sdbcx::XColumnsSupplier
122 /// @throws css::uno::RuntimeException
123 css::uno::Reference< css::container::XNameAccess> getColumns() const { return m_xColumnsSupplier->getColumns(); }
124 private:
125 void ImplConstruct(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned);
129 class FmXDisposeMultiplexer;
130 class SAL_WARN_UNUSED FmXDisposeListener
132 friend class FmXDisposeMultiplexer;
134 rtl::Reference<FmXDisposeMultiplexer> m_pAdapter;
135 osl::Mutex m_aMutex;
137 public:
138 virtual ~FmXDisposeListener();
140 /// @throws css::uno::RuntimeException
141 virtual void disposing(sal_Int16 _nId) = 0;
143 protected:
144 void setAdapter(FmXDisposeMultiplexer* pAdapter);
147 class SAL_WARN_UNUSED FmXDisposeMultiplexer : public cppu::WeakImplHelper< css::lang::XEventListener >
149 css::uno::Reference< css::lang::XComponent> m_xObject;
150 FmXDisposeListener* m_pListener;
152 virtual ~FmXDisposeMultiplexer() override;
153 public:
154 FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const css::uno::Reference< css::lang::XComponent>& _rxObject);
156 // css::lang::XEventListener
157 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
159 void dispose();
162 sal_Int16 getControlTypeByObject(const css::uno::Reference< css::lang::XServiceInfo>& _rxObject);
163 // get the object type (OBJ_FM_...) from the services the object supports
166 bool isRowSetAlive(const css::uno::Reference< css::uno::XInterface>& _rxRowSet);
167 // checks if the css::sdbcx::XColumnsSupplier provided by _rxRowSet supplies any columns
170 typedef ::std::set< css::uno::Reference< css::uno::XInterface > > InterfaceBag;
172 #endif // INCLUDED_SVX_FMTOOLS_HXX
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */