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