LibreOffice Module svx (master) 1
fmtools.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SVX_FMTOOLS_HXX
20#define INCLUDED_SVX_FMTOOLS_HXX
21
22#include <config_options.h>
23#include <svx/svxdllapi.h>
24
25#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
26#include <com/sun/star/sdbc/XResultSet.hpp>
27#include <com/sun/star/sdbcx/XRowLocate.hpp>
28#include <com/sun/star/lang/EventObject.hpp>
29#include <com/sun/star/lang/XEventListener.hpp>
30
31#include <rtl/ref.hxx>
34#include <mutex>
35
36namespace com::sun::star::awt { class XWindow; }
37namespace com::sun::star::beans { class XPropertySet; }
38namespace com::sun::star::container { class XIndexAccess; }
39namespace com::sun::star::container { class XNameAccess; }
40namespace com::sun::star::lang { class XComponent; }
41namespace com::sun::star::lang { class XServiceInfo; }
42namespace com::sun::star::sdbc { class SQLException; }
43namespace com::sun::star::sdbc { class XRowSet; }
44namespace com::sun::star::sdb { class SQLContext; }
45namespace com::sun::star::sdb { struct SQLErrorEvent; }
46enum class SdrObjKind : sal_uInt16;
47
48// common types
49
50// displaying a database exception for the user
51// display info about a simple css::sdbc::SQLException
52void displayException(const css::sdbc::SQLException&, const css::uno::Reference<css::awt::XWindow>& rParent);
53SVXCORE_DLLPUBLIC void displayException(const css::sdb::SQLContext&, const css::uno::Reference<css::awt::XWindow>& rParent);
54void displayException(const css::sdb::SQLErrorEvent&, const css::uno::Reference<css::awt::XWindow>& rParent);
55void displayException(const css::uno::Any&, const css::uno::Reference<css::awt::XWindow>& rParent);
56
57sal_Int32 getElementPos(const css::uno::Reference< css::container::XIndexAccess>& xCont, const css::uno::Reference< css::uno::XInterface>& xElement);
58
59SVXCORE_DLLPUBLIC OUString getLabelName(const css::uno::Reference< css::beans::XPropertySet>& xControlModel);
60
61
62// = class CursorWrapper - a helper class which works in common with a css::uno::Reference<XDatabaseUpdateCursor>,
63// XDatabaseBookmarkCursor and XDatabaseDirectCursor each
64
65
67{
68private:
69 css::uno::Reference< css::uno::XInterface> m_xGeneric;
70 css::uno::Reference< css::sdbc::XResultSet> m_xMoveOperations;
71 css::uno::Reference< css::sdbcx::XRowLocate> m_xBookmarkOperations;
72 css::uno::Reference< css::sdbcx::XColumnsSupplier> m_xColumnsSupplier;
73 css::uno::Reference< css::beans::XPropertySet> m_xPropertyAccess;
74
75public:
76 // Construction/Destruction
77 CursorWrapper(const css::uno::Reference< css::sdbc::XRowSet>& _rxCursor, bool bUseCloned = false);
78 UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) CursorWrapper(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned = false);
79 // if bUseCloned == sal_True, the cursor is first doubled over the XCloneable interface (which it must implement)
80 // and then used
81
82 friend bool operator==(const CursorWrapper& lhs, const CursorWrapper& rhs)
83 {
84 return lhs.m_xGeneric.get() == rhs.m_xGeneric.get();
85 }
86
87 bool is() const { return m_xMoveOperations.is(); }
88 bool Is() const { return m_xMoveOperations.is(); }
89
90 operator const css::uno::Reference< css::uno::XInterface>& () const{ return m_xGeneric; }
91
92 // 'Conversions'
93 CursorWrapper& operator=(const css::uno::Reference< css::sdbc::XRowSet>& xCursor);
94 operator const css::uno::Reference< css::sdbc::XResultSet>& () const { return m_xMoveOperations; }
95
96 const css::uno::Reference< css::beans::XPropertySet >& getPropertySet() const { return m_xPropertyAccess; }
97
98 // css::uno::Reference< css::sdbcx::XRowLocate>
101 css::uno::Any getBookmark()
102 { return m_xBookmarkOperations->getBookmark(); }
105 bool moveToBookmark(const css::uno::Any& bookmark) { return m_xBookmarkOperations->moveToBookmark(bookmark); }
106
107 // css::sdbc::XResultSet
108 bool isBeforeFirst() const { return m_xMoveOperations->isBeforeFirst(); }
109 bool isAfterLast() const { return m_xMoveOperations->isAfterLast(); }
110 bool isFirst() const { return m_xMoveOperations->isFirst(); }
111 bool isLast() const { return m_xMoveOperations->isLast(); }
112 void beforeFirst() { m_xMoveOperations->beforeFirst(); }
113 bool first() { return m_xMoveOperations->first(); }
114 bool last() { return m_xMoveOperations->last(); }
115 sal_Int32 getRow() const { return m_xMoveOperations->getRow(); }
116 bool absolute(sal_Int32 nPosition) { return m_xMoveOperations->absolute(nPosition); }
117 bool relative(sal_Int32 nCount) { return m_xMoveOperations->relative(nCount); }
118 bool previous() { return m_xMoveOperations->previous(); }
119 bool next() { return m_xMoveOperations->next(); }
120 void refreshRow() { m_xMoveOperations->refreshRow(); }
121 bool rowDeleted() { return m_xMoveOperations->rowDeleted(); }
122 // css::sdbcx::XColumnsSupplier
124 css::uno::Reference< css::container::XNameAccess> getColumns() const { return m_xColumnsSupplier->getColumns(); }
125private:
126 void ImplConstruct(const css::uno::Reference< css::sdbc::XResultSet>& _rxCursor, bool bUseCloned);
127};
128
129
132{
134
136 std::mutex m_aMutex;
137
138public:
139 virtual ~FmXDisposeListener();
140
142 virtual void disposing(sal_Int16 _nId) = 0;
143
144protected:
145 void setAdapter(FmXDisposeMultiplexer* pAdapter);
146};
147
148class SAL_WARN_UNUSED FmXDisposeMultiplexer final : public cppu::WeakImplHelper< css::lang::XEventListener >
149{
150 css::uno::Reference< css::lang::XComponent> m_xObject;
152
153 virtual ~FmXDisposeMultiplexer() override;
154public:
155 FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const css::uno::Reference< css::lang::XComponent>& _rxObject);
156
157// css::lang::XEventListener
158 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
159
160 void dispose();
161};
162
163SdrObjKind getControlTypeByObject(const css::uno::Reference< css::lang::XServiceInfo>& _rxObject);
164 // get the object type (OBJ_FM_...) from the services the object supports
165
166
167bool isRowSetAlive(const css::uno::Reference< css::uno::XInterface>& _rxRowSet);
168 // checks if the css::sdbcx::XColumnsSupplier provided by _rxRowSet supplies any columns
169
170
171typedef ::o3tl::sorted_vector< css::uno::Reference< css::uno::XInterface > > InterfaceBag;
172
173#endif // INCLUDED_SVX_FMTOOLS_HXX
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 getRow() const
Definition: fmtools.hxx:115
css::uno::Reference< css::beans::XPropertySet > m_xPropertyAccess
Definition: fmtools.hxx:73
css::uno::Reference< css::sdbcx::XRowLocate > m_xBookmarkOperations
Definition: fmtools.hxx:71
bool rowDeleted()
Definition: fmtools.hxx:121
bool relative(sal_Int32 nCount)
Definition: fmtools.hxx:117
bool isLast() const
Definition: fmtools.hxx:111
bool isAfterLast() const
Definition: fmtools.hxx:109
css::uno::Reference< css::sdbc::XResultSet > m_xMoveOperations
Definition: fmtools.hxx:70
css::uno::Any getBookmark()
Definition: fmtools.hxx:101
css::uno::Reference< css::uno::XInterface > m_xGeneric
Definition: fmtools.hxx:69
bool is() const
Definition: fmtools.hxx:87
bool next()
Definition: fmtools.hxx:119
bool isBeforeFirst() const
Definition: fmtools.hxx:108
bool Is() const
Definition: fmtools.hxx:88
bool previous()
Definition: fmtools.hxx:118
UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) CursorWrapper(const css friend bool operator==(const CursorWrapper &lhs, const CursorWrapper &rhs)
Definition: fmtools.hxx:82
void beforeFirst()
Definition: fmtools.hxx:112
void refreshRow()
Definition: fmtools.hxx:120
css::uno::Reference< css::sdbcx::XColumnsSupplier > m_xColumnsSupplier
Definition: fmtools.hxx:72
const css::uno::Reference< css::beans::XPropertySet > & getPropertySet() const
Definition: fmtools.hxx:96
css::uno::Reference< css::container::XNameAccess > getColumns() const
Definition: fmtools.hxx:124
bool moveToBookmark(const css::uno::Any &bookmark)
Definition: fmtools.hxx:105
bool first()
Definition: fmtools.hxx:113
bool isFirst() const
Definition: fmtools.hxx:110
bool absolute(sal_Int32 nPosition)
Definition: fmtools.hxx:116
bool last()
Definition: fmtools.hxx:114
virtual void disposing(sal_Int16 _nId)=0
rtl::Reference< FmXDisposeMultiplexer > m_pAdapter
Definition: fmtools.hxx:135
std::mutex m_aMutex
Definition: fmtools.hxx:136
css::uno::Reference< css::lang::XComponent > m_xObject
Definition: fmtools.hxx:150
FmXDisposeListener * m_pListener
Definition: fmtools.hxx:151
int nCount
SVXCORE_DLLPUBLIC OUString getLabelName(const css::uno::Reference< css::beans::XPropertySet > &xControlModel)
void displayException(const css::sdbc::SQLException &, const css::uno::Reference< css::awt::XWindow > &rParent)
Definition: fmtools.cxx:100
sal_Int32 getElementPos(const css::uno::Reference< css::container::XIndexAccess > &xCont, const css::uno::Reference< css::uno::XInterface > &xElement)
::o3tl::sorted_vector< css::uno::Reference< css::uno::XInterface > > InterfaceBag
Definition: fmtools.hxx:171
SdrObjKind getControlTypeByObject(const css::uno::Reference< css::lang::XServiceInfo > &_rxObject)
bool isRowSetAlive(const css::uno::Reference< css::uno::XInterface > &_rxRowSet)
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:29
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchange class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) OLocalExchangeHelper
a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself
Definition: fmexch.hxx:86
void dispose()
SdrObjKind
Definition: svdobjkind.hxx:25
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
#define SAL_WARN_UNUSED