tdf#104816 sw: if non-section content, let all sections hide.
[LibreOffice.git] / sc / inc / viewuno.hxx
blob1846ca6cb84494db27a9b679b60c11c11ed169c9
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/XSelectionSupplier.hpp>
27 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
28 #include <com/sun/star/sheet/XViewSplitable.hpp>
29 #include <com/sun/star/sheet/XViewFreezable.hpp>
30 #include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp>
31 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
32 #include <com/sun/star/sheet/XEnhancedMouseClickBroadcaster.hpp>
33 #include <com/sun/star/sheet/XActivationBroadcaster.hpp>
34 #include <com/sun/star/sheet/XViewPane.hpp>
35 #include <com/sun/star/sheet/XRangeSelection.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/container/XEnumerationAccess.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/lang/XUnoTunnel.hpp>
40 #include <com/sun/star/datatransfer/XTransferableSupplier.hpp>
42 #include "types.hxx"
44 namespace com { namespace sun { namespace star { namespace view { class XSelectionChangeListener; } } } }
46 class ScTabViewShell;
47 class ScPreviewShell;
49 #define SC_VIEWPANE_ACTIVE 0xFFFF
51 // ScViewPaneBase not derived from OWeakObject
52 // to avoid duplicate OWeakObject in ScTabViewObj
54 class ScViewPaneBase : public css::sheet::XViewPane,
55 public css::sheet::XCellRangeReferrer,
56 public css::view::XFormLayerAccess,
57 public css::lang::XServiceInfo,
58 public css::lang::XTypeProvider,
59 public SfxListener
61 private:
62 ScTabViewShell* pViewShell;
63 sal_uInt16 const nPane; // ScSplitPos or SC_VIEWPANE_ACTIVE
65 protected:
66 css::awt::Rectangle GetVisArea() const;
68 public:
69 ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP);
70 virtual ~ScViewPaneBase() override;
72 ScTabViewShell* GetViewShell() const { return pViewShell; }
74 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
76 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
78 // XViewPane
79 virtual sal_Int32 SAL_CALL getFirstVisibleColumn() override;
80 virtual void SAL_CALL setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn ) override;
81 virtual sal_Int32 SAL_CALL getFirstVisibleRow() override;
82 virtual void SAL_CALL setFirstVisibleRow( sal_Int32 nFirstVisibleRow ) override;
83 virtual css::table::CellRangeAddress SAL_CALL getVisibleRange() override;
85 // XCellRangeReferrer
86 virtual css::uno::Reference< css::table::XCellRange > SAL_CALL
87 getReferredCells() override;
89 // XFormLayerAccess
90 virtual css::uno::Reference< css::form::runtime::XFormController > SAL_CALL
91 getFormController( const css::uno::Reference< css::form::XForm >& Form ) override;
92 virtual sal_Bool SAL_CALL
93 isFormDesignMode( ) override;
94 virtual void SAL_CALL setFormDesignMode( sal_Bool DesignMode ) override;
96 // XControlAccess
97 virtual css::uno::Reference< css::awt::XControl > SAL_CALL
98 getControl( const css::uno::Reference< css::awt::XControlModel >& xModel ) override;
100 // XServiceInfo
101 virtual OUString SAL_CALL getImplementationName() override;
102 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
103 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
105 // XTypeProvider
106 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
107 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
110 // ScViewPaneObj for direct use (including OWeakObject)
112 class ScViewPaneObj : public ScViewPaneBase, public cppu::OWeakObject
114 public:
115 ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP);
116 virtual ~ScViewPaneObj() override;
118 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
119 virtual void SAL_CALL acquire() throw() override;
120 virtual void SAL_CALL release() throw() override;
123 // OWeakObject is base of SfxBaseController -> use ScViewPaneBase
125 class ScTabViewObj : public ScViewPaneBase,
126 public SfxBaseController,
127 public css::sheet::XSpreadsheetView,
128 public css::sheet::XEnhancedMouseClickBroadcaster,
129 public css::sheet::XActivationBroadcaster,
130 public css::container::XEnumerationAccess,
131 public css::container::XIndexAccess,
132 public css::view::XSelectionSupplier,
133 public css::beans::XPropertySet,
134 public css::sheet::XViewSplitable,
135 public css::sheet::XViewFreezable,
136 public css::sheet::XRangeSelection,
137 public css::lang::XUnoTunnel,
138 public css::datatransfer::XTransferableSupplier,
139 public css::sheet::XSelectedSheetsSupplier
141 private:
142 typedef std::vector<css::uno::Reference<css::sheet::XRangeSelectionListener> > XRangeSelectionListenerVector;
143 typedef std::vector<css::uno::Reference<css::sheet::XRangeSelectionChangeListener> > XRangeSelectionChangeListenerVector;
144 typedef std::vector<css::uno::Reference<css::view::XSelectionChangeListener> > XSelectionChangeListenerVector;
145 typedef std::vector<css::uno::Reference<css::beans::XPropertyChangeListener> > XViewPropertyChangeListenerVector;
146 typedef std::vector<css::uno::Reference<css::awt::XEnhancedMouseClickHandler> > XMouseClickHandlerVector;
147 typedef std::vector<css::uno::Reference<css::sheet::XActivationEventListener> > XActivationEventListenerVector;
149 SfxItemPropertySet const aPropSet;
150 XSelectionChangeListenerVector aSelectionChgListeners;
151 XRangeSelectionListenerVector aRangeSelListeners;
152 XRangeSelectionChangeListenerVector aRangeChgListeners;
153 XViewPropertyChangeListenerVector aPropertyChgListeners;
154 XMouseClickHandlerVector aMouseClickHandlers;
155 XActivationEventListenerVector aActivationListeners;
156 SCTAB nPreviousTab;
157 bool bDrawSelModeSet;
158 bool bFilteredRangeSelection;
160 ScViewPaneObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) const;
161 sal_Int16 GetZoom() const;
162 void SetZoom(sal_Int16 Zoom);
163 sal_Int16 GetZoomType() const;
164 void SetZoomType(sal_Int16 ZoomType);
166 css::uno::Reference< css::uno::XInterface > GetClickedObject(const Point& rPoint) const;
167 void EndMouseListening();
168 void EndActivationListening();
169 bool mbLeftMousePressed;
170 public:
171 ScTabViewObj(ScTabViewShell* pViewSh);
172 ScTabViewObj() = delete;
173 virtual ~ScTabViewObj() override;
175 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
176 virtual void SAL_CALL acquire() throw() override;
177 virtual void SAL_CALL release() throw() override;
179 void SelectionChanged();
180 void VisAreaChanged();
181 // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet
182 void SheetChanged( bool bSameTabButMoved );
183 bool IsMouseListening() const;
184 /// @throws css::uno::RuntimeException
185 bool MousePressed( const css::awt::MouseEvent& e );
186 /// @throws css::uno::RuntimeException
187 bool MouseReleased( const css::awt::MouseEvent& e );
189 void RangeSelDone( const OUString& rText );
190 void RangeSelAborted( const OUString& rText );
191 void RangeSelChanged( const OUString& rText );
193 // XSelectionSupplier
194 virtual sal_Bool SAL_CALL select( const css::uno::Any& aSelection ) override;
195 virtual css::uno::Any SAL_CALL getSelection() override;
196 virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override;
197 virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override;
199 //! XPrintable?
201 // XPropertySet
202 virtual css::uno::Reference< css::beans::XPropertySetInfo >
203 SAL_CALL getPropertySetInfo() override;
204 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
205 const css::uno::Any& aValue ) override;
206 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
207 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
208 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
209 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
210 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
211 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
212 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
213 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
214 const css::uno::Reference<
215 css::beans::XVetoableChangeListener >& aListener ) override;
217 // XEnumerationAccess
218 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
219 createEnumeration() override;
221 // XIndexAccess
222 virtual sal_Int32 SAL_CALL getCount() override;
223 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
225 // XElementAccess
226 virtual css::uno::Type SAL_CALL getElementType() override;
227 virtual sal_Bool SAL_CALL hasElements() override;
229 // XSpreadsheetView
230 virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL
231 getActiveSheet() override;
232 virtual void SAL_CALL setActiveSheet( const css::uno::Reference< css::sheet::XSpreadsheet >& xActiveSheet ) override;
234 //XEnhancedMouseClickBroadcaster
236 virtual void SAL_CALL addEnhancedMouseClickHandler( const css::uno::Reference<
237 css::awt::XEnhancedMouseClickHandler >& aListener ) override;
238 virtual void SAL_CALL removeEnhancedMouseClickHandler( const css::uno::Reference< css::awt::XEnhancedMouseClickHandler >& aListener ) override;
240 //XActivationBroadcaster
242 virtual void SAL_CALL addActivationEventListener( const css::uno::Reference< css::sheet::XActivationEventListener >& aListener ) override;
243 virtual void SAL_CALL removeActivationEventListener( const css::uno::Reference< css::sheet::XActivationEventListener >& aListener ) override;
245 // XViewSplitable
246 virtual sal_Bool SAL_CALL getIsWindowSplit() override;
247 virtual sal_Int32 SAL_CALL getSplitHorizontal() override;
248 virtual sal_Int32 SAL_CALL getSplitVertical() override;
249 virtual sal_Int32 SAL_CALL getSplitColumn() override;
250 virtual sal_Int32 SAL_CALL getSplitRow() override;
251 virtual void SAL_CALL splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY ) override;
253 // XViewFreezable
254 virtual sal_Bool SAL_CALL hasFrozenPanes() override;
255 virtual void SAL_CALL freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows ) override;
257 // XRangeSelection
258 virtual void SAL_CALL startRangeSelection( const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
259 virtual void SAL_CALL abortRangeSelection() override;
260 virtual void SAL_CALL addRangeSelectionListener( const css::uno::Reference< css::sheet::XRangeSelectionListener >& aListener ) override;
261 virtual void SAL_CALL removeRangeSelectionListener( const css::uno::Reference< css::sheet::XRangeSelectionListener >& aListener ) override;
262 virtual void SAL_CALL addRangeSelectionChangeListener( const css::uno::Reference< css::sheet::XRangeSelectionChangeListener >& aListener ) override;
263 virtual void SAL_CALL removeRangeSelectionChangeListener( const css::uno::Reference< css::sheet::XRangeSelectionChangeListener >& aListener ) override;
265 // XServiceInfo
266 virtual OUString SAL_CALL getImplementationName() override;
267 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
268 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
270 // XUnoTunnel
271 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence<
272 sal_Int8 >& aIdentifier ) override;
274 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
275 static ScTabViewObj* getImplementation(const css::uno::Reference<css::uno::XInterface>& rObj);
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;
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;
285 // XSelectedSheetsSupplier
286 virtual css::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets() override;
289 class ScPreviewObj : public SfxBaseController,
290 public SfxListener,
291 public css::sheet::XSelectedSheetsSupplier
293 ScPreviewShell* mpViewShell;
294 public:
295 ScPreviewObj(ScPreviewShell* pViewSh);
296 virtual ~ScPreviewObj() override;
298 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType) override;
300 virtual void SAL_CALL acquire() throw() override;
301 virtual void SAL_CALL release() throw() override;
303 virtual void Notify(SfxBroadcaster&, const SfxHint& rHint) override;
305 // XSelectedSheetsSupplier
306 virtual css::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets() override;
309 #endif
311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */