/src/libreoffice/sc/inc/viewuno.hxx
Line | Count | Source |
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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <rtl/ref.hxx> |
23 | | #include <sfx2/sfxbasecontroller.hxx> |
24 | | #include <svl/itemprop.hxx> |
25 | | #include <svl/lstner.hxx> |
26 | | #include <tools/gen.hxx> |
27 | | #include <com/sun/star/view/XFormLayerAccess.hpp> |
28 | | #include <com/sun/star/view/XSelectionSupplier.hpp> |
29 | | #include <com/sun/star/sheet/XCellRangeReferrer.hpp> |
30 | | #include <com/sun/star/sheet/XViewSplitable.hpp> |
31 | | #include <com/sun/star/sheet/XViewFreezable.hpp> |
32 | | #include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp> |
33 | | #include <com/sun/star/sheet/XSpreadsheetView.hpp> |
34 | | #include <com/sun/star/sheet/XEnhancedMouseClickBroadcaster.hpp> |
35 | | #include <com/sun/star/sheet/XActivationBroadcaster.hpp> |
36 | | #include <com/sun/star/sheet/XViewPane.hpp> |
37 | | #include <com/sun/star/sheet/XRangeSelection.hpp> |
38 | | #include <com/sun/star/sheet/XSheetRange.hpp> |
39 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
40 | | #include <com/sun/star/container/XEnumerationAccess.hpp> |
41 | | #include <com/sun/star/beans/XPropertySet.hpp> |
42 | | #include <com/sun/star/datatransfer/XTransferableSupplier.hpp> |
43 | | #include <comphelper/servicehelper.hxx> |
44 | | |
45 | | #include "types.hxx" |
46 | | |
47 | | namespace com::sun::star::view { class XSelectionChangeListener; } |
48 | | |
49 | | class ScTabViewShell; |
50 | | class ScPreviewShell; |
51 | | class ScTableSheetObj; |
52 | | |
53 | 0 | #define SC_VIEWPANE_ACTIVE 0xFFFF |
54 | | |
55 | | // ScViewPaneBase not derived from OWeakObject |
56 | | // to avoid duplicate OWeakObject in ScTabViewObj |
57 | | |
58 | | class ScViewPaneBase : public css::sheet::XViewPane, |
59 | | public css::sheet::XCellRangeReferrer, |
60 | | public css::view::XFormLayerAccess, |
61 | | public css::lang::XServiceInfo, |
62 | | public css::lang::XTypeProvider, |
63 | | public SfxListener |
64 | | { |
65 | | private: |
66 | | ScTabViewShell* pViewShell; |
67 | | sal_uInt16 nPane; // ScSplitPos or SC_VIEWPANE_ACTIVE |
68 | | |
69 | | protected: |
70 | | css::awt::Rectangle GetVisArea() const; |
71 | | |
72 | | public: |
73 | | ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP); |
74 | | virtual ~ScViewPaneBase() override; |
75 | | |
76 | 0 | ScTabViewShell* GetViewShell() const { return pViewShell; } |
77 | | |
78 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; |
79 | | |
80 | | virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; |
81 | | |
82 | | // XViewPane |
83 | | virtual sal_Int32 SAL_CALL getFirstVisibleColumn() override; |
84 | | virtual void SAL_CALL setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn ) override; |
85 | | virtual sal_Int32 SAL_CALL getFirstVisibleRow() override; |
86 | | virtual void SAL_CALL setFirstVisibleRow( sal_Int32 nFirstVisibleRow ) override; |
87 | | virtual css::table::CellRangeAddress SAL_CALL getVisibleRange() override; |
88 | | |
89 | | // XCellRangeReferrer |
90 | | virtual css::uno::Reference< css::table::XCellRange > SAL_CALL |
91 | | getReferredCells() override; |
92 | | |
93 | | // XFormLayerAccess |
94 | | virtual css::uno::Reference< css::form::runtime::XFormController > SAL_CALL |
95 | | getFormController( const css::uno::Reference< css::form::XForm >& Form ) override; |
96 | | virtual sal_Bool SAL_CALL |
97 | | isFormDesignMode( ) override; |
98 | | virtual void SAL_CALL setFormDesignMode( sal_Bool DesignMode ) override; |
99 | | |
100 | | // XControlAccess |
101 | | virtual css::uno::Reference< css::awt::XControl > SAL_CALL |
102 | | getControl( const css::uno::Reference< css::awt::XControlModel >& xModel ) override; |
103 | | |
104 | | // XServiceInfo |
105 | | virtual OUString SAL_CALL getImplementationName() override; |
106 | | virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
107 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
108 | | |
109 | | // XTypeProvider |
110 | | virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; |
111 | | virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; |
112 | | }; |
113 | | |
114 | | // ScViewPaneObj for direct use (including OWeakObject) |
115 | | |
116 | | class ScViewPaneObj final : public ScViewPaneBase, public cppu::OWeakObject |
117 | | { |
118 | | public: |
119 | | ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP); |
120 | | virtual ~ScViewPaneObj() override; |
121 | | |
122 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; |
123 | | virtual void SAL_CALL acquire() noexcept override; |
124 | | virtual void SAL_CALL release() noexcept override; |
125 | | }; |
126 | | |
127 | | // OWeakObject is base of SfxBaseController -> use ScViewPaneBase |
128 | | |
129 | | class ScTabViewObj final : public ScViewPaneBase, |
130 | | public SfxBaseController, |
131 | | public css::sheet::XSpreadsheetView, |
132 | | public css::sheet::XEnhancedMouseClickBroadcaster, |
133 | | public css::sheet::XActivationBroadcaster, |
134 | | public css::container::XEnumerationAccess, |
135 | | public css::container::XIndexAccess, |
136 | | public css::view::XSelectionSupplier, |
137 | | public css::beans::XPropertySet, |
138 | | public css::sheet::XViewSplitable, |
139 | | public css::sheet::XViewFreezable, |
140 | | public css::sheet::XRangeSelection, |
141 | | public css::sheet::XSheetRange, |
142 | | public css::datatransfer::XTransferableSupplier, |
143 | | public css::sheet::XSelectedSheetsSupplier |
144 | | { |
145 | | private: |
146 | | typedef std::vector<css::uno::Reference<css::sheet::XRangeSelectionListener>> RangeSelListeners; |
147 | | |
148 | | SfxItemPropertySet aPropSet; |
149 | | std::vector<css::uno::Reference<css::view::XSelectionChangeListener> > |
150 | | aSelectionChgListeners; |
151 | | RangeSelListeners aRangeSelListeners; |
152 | | std::vector<css::uno::Reference<css::sheet::XRangeSelectionChangeListener> > |
153 | | aRangeChgListeners; |
154 | | std::vector<css::uno::Reference<css::beans::XPropertyChangeListener> > |
155 | | aPropertyChgListeners; |
156 | | std::vector<css::uno::Reference<css::awt::XEnhancedMouseClickHandler> > |
157 | | aMouseClickHandlers; |
158 | | std::vector<css::uno::Reference<css::sheet::XActivationEventListener> > |
159 | | aActivationListeners; |
160 | | SCTAB nPreviousTab; |
161 | | bool bDrawSelModeSet; |
162 | | bool bFilteredRangeSelection; |
163 | | |
164 | | rtl::Reference<ScViewPaneObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) const; |
165 | | sal_Int16 GetZoom() const; |
166 | | void SetZoom(sal_Int16 Zoom); |
167 | | sal_Int16 GetZoomType() const; |
168 | | void SetZoomType(sal_Int16 ZoomType); |
169 | | |
170 | | css::uno::Reference< css::uno::XInterface > GetClickedObject(const Point& rPoint) const; |
171 | | void EndMouseListening(); |
172 | | void EndActivationListening(); |
173 | | bool mbLeftMousePressed; |
174 | | public: |
175 | | ScTabViewObj(ScTabViewShell* pViewSh); |
176 | | ScTabViewObj() = delete; |
177 | | virtual ~ScTabViewObj() override; |
178 | | |
179 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; |
180 | | virtual void SAL_CALL acquire() noexcept override; |
181 | | virtual void SAL_CALL release() noexcept override; |
182 | | |
183 | | void SelectionChanged(); |
184 | | void VisAreaChanged(); |
185 | | // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet |
186 | | void SheetChanged( bool bSameTabButMoved ); |
187 | | bool IsMouseListening() const; |
188 | | /// @throws css::uno::RuntimeException |
189 | | bool MousePressed( const css::awt::MouseEvent& e ); |
190 | | /// @throws css::uno::RuntimeException |
191 | | bool MouseReleased( const css::awt::MouseEvent& e ); |
192 | | |
193 | | void RangeSelDone( const OUString& rText ); |
194 | | void RangeSelAborted( const OUString& rText ); |
195 | | void RangeSelChanged( const OUString& rText ); |
196 | | |
197 | | // XSelectionSupplier |
198 | | virtual sal_Bool SAL_CALL select( const css::uno::Any& aSelection ) override; |
199 | | virtual css::uno::Any SAL_CALL getSelection() override; |
200 | | virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; |
201 | | virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; |
202 | | |
203 | | // XSheetRange |
204 | | virtual css::uno::Any SAL_CALL getSelectionFromString( const OUString& aStrRange ) override; |
205 | | |
206 | | //! XPrintable? |
207 | | |
208 | | // XPropertySet |
209 | | virtual css::uno::Reference< css::beans::XPropertySetInfo > |
210 | | SAL_CALL getPropertySetInfo() override; |
211 | | virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, |
212 | | const css::uno::Any& aValue ) override; |
213 | | virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; |
214 | | virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, |
215 | | const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; |
216 | | virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, |
217 | | const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; |
218 | | virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, |
219 | | const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
220 | | virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, |
221 | | const css::uno::Reference< |
222 | | css::beans::XVetoableChangeListener >& aListener ) override; |
223 | | |
224 | | // XEnumerationAccess |
225 | | virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL |
226 | | createEnumeration() override; |
227 | | |
228 | | // XIndexAccess |
229 | | virtual sal_Int32 SAL_CALL getCount() override; |
230 | | virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; |
231 | | |
232 | | // XElementAccess |
233 | | virtual css::uno::Type SAL_CALL getElementType() override; |
234 | | virtual sal_Bool SAL_CALL hasElements() override; |
235 | | |
236 | | // XSpreadsheetView |
237 | | virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL |
238 | | getActiveSheet() override; |
239 | | virtual void SAL_CALL setActiveSheet( const css::uno::Reference< css::sheet::XSpreadsheet >& xActiveSheet ) override; |
240 | | |
241 | | //XEnhancedMouseClickBroadcaster |
242 | | |
243 | | virtual void SAL_CALL addEnhancedMouseClickHandler( const css::uno::Reference< |
244 | | css::awt::XEnhancedMouseClickHandler >& aListener ) override; |
245 | | virtual void SAL_CALL removeEnhancedMouseClickHandler( const css::uno::Reference< css::awt::XEnhancedMouseClickHandler >& aListener ) override; |
246 | | |
247 | | //XActivationBroadcaster |
248 | | |
249 | | virtual void SAL_CALL addActivationEventListener( const css::uno::Reference< css::sheet::XActivationEventListener >& aListener ) override; |
250 | | virtual void SAL_CALL removeActivationEventListener( const css::uno::Reference< css::sheet::XActivationEventListener >& aListener ) override; |
251 | | |
252 | | // XViewSplitable |
253 | | virtual sal_Bool SAL_CALL getIsWindowSplit() override; |
254 | | virtual sal_Int32 SAL_CALL getSplitHorizontal() override; |
255 | | virtual sal_Int32 SAL_CALL getSplitVertical() override; |
256 | | virtual sal_Int32 SAL_CALL getSplitColumn() override; |
257 | | virtual sal_Int32 SAL_CALL getSplitRow() override; |
258 | | virtual void SAL_CALL splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY ) override; |
259 | | |
260 | | // XViewFreezable |
261 | | virtual sal_Bool SAL_CALL hasFrozenPanes() override; |
262 | | virtual void SAL_CALL freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows ) override; |
263 | | |
264 | | // XRangeSelection |
265 | | virtual void SAL_CALL startRangeSelection( const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; |
266 | | virtual void SAL_CALL abortRangeSelection() override; |
267 | | virtual void SAL_CALL addRangeSelectionListener( const css::uno::Reference< css::sheet::XRangeSelectionListener >& aListener ) override; |
268 | | virtual void SAL_CALL removeRangeSelectionListener( const css::uno::Reference< css::sheet::XRangeSelectionListener >& aListener ) override; |
269 | | virtual void SAL_CALL addRangeSelectionChangeListener( const css::uno::Reference< css::sheet::XRangeSelectionChangeListener >& aListener ) override; |
270 | | virtual void SAL_CALL removeRangeSelectionChangeListener( const css::uno::Reference< css::sheet::XRangeSelectionChangeListener >& aListener ) override; |
271 | | |
272 | | // XServiceInfo |
273 | | virtual OUString SAL_CALL getImplementationName() override; |
274 | | virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
275 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
276 | | |
277 | | // XTypeProvider |
278 | | virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; |
279 | | virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; |
280 | | |
281 | | // XTransferableSupplier |
282 | | virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getTransferable() override; |
283 | | virtual void SAL_CALL insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans ) override; |
284 | | |
285 | | // XSelectedSheetsSupplier |
286 | | virtual css::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets() override; |
287 | | |
288 | | rtl::Reference< ScTableSheetObj > getActiveScSheet(); |
289 | | }; |
290 | | |
291 | | class ScPreviewObj final : public SfxBaseController, |
292 | | public SfxListener, |
293 | | public css::sheet::XSelectedSheetsSupplier |
294 | | { |
295 | | ScPreviewShell* mpViewShell; |
296 | | public: |
297 | | ScPreviewObj(ScPreviewShell* pViewSh); |
298 | | virtual ~ScPreviewObj() override; |
299 | | |
300 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType) override; |
301 | | |
302 | | virtual void SAL_CALL acquire() noexcept override; |
303 | | virtual void SAL_CALL release() noexcept override; |
304 | | |
305 | | virtual void Notify(SfxBroadcaster&, const SfxHint& rHint) override; |
306 | | |
307 | | // XSelectedSheetsSupplier |
308 | | virtual css::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets() override; |
309 | | }; |
310 | | |
311 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |