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