Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / inc / viewuno.hxx
blobeddaed3731c7c75472e783d2f0aba2f6a0aa0224
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 SC_VIEWUNO_HXX
21 #define SC_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"
44 #include "boost/ptr_container/ptr_vector.hpp"
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 com::sun::star::sheet::XViewPane,
55 public com::sun::star::sheet::XCellRangeReferrer,
56 public com::sun::star::view::XFormLayerAccess,
57 public com::sun::star::lang::XServiceInfo,
58 public com::sun::star::lang::XTypeProvider,
59 public SfxListener
61 private:
62 ScTabViewShell* pViewShell;
63 sal_uInt16 nPane; // ScSplitPos oder SC_VIEWPANE_ACTIVE
65 protected:
66 ::com::sun::star::awt::Rectangle GetVisArea() const;
68 public:
69 ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP);
70 virtual ~ScViewPaneBase();
72 ScTabViewShell* GetViewShell() const { return pViewShell; }
74 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
75 const ::com::sun::star::uno::Type & rType )
76 throw(::com::sun::star::uno::RuntimeException);
78 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
80 // XViewPane
81 virtual sal_Int32 SAL_CALL getFirstVisibleColumn() throw(::com::sun::star::uno::RuntimeException);
82 virtual void SAL_CALL setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn )
83 throw(::com::sun::star::uno::RuntimeException);
84 virtual sal_Int32 SAL_CALL getFirstVisibleRow() throw(::com::sun::star::uno::RuntimeException);
85 virtual void SAL_CALL setFirstVisibleRow( sal_Int32 nFirstVisibleRow )
86 throw(::com::sun::star::uno::RuntimeException);
87 virtual ::com::sun::star::table::CellRangeAddress SAL_CALL getVisibleRange()
88 throw(::com::sun::star::uno::RuntimeException);
90 // XCellRangeReferrer
91 virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL
92 getReferredCells() throw(::com::sun::star::uno::RuntimeException);
94 // XFormLayerAccess
95 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL
96 getFormController( const ::com::sun::star::uno::Reference<
97 ::com::sun::star::form::XForm >& Form )
98 throw (::com::sun::star::uno::RuntimeException);
99 virtual ::sal_Bool SAL_CALL
100 isFormDesignMode( )
101 throw (::com::sun::star::uno::RuntimeException);
102 virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode )
103 throw (::com::sun::star::uno::RuntimeException);
105 // XControlAccess
106 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL
107 getControl( const ::com::sun::star::uno::Reference<
108 ::com::sun::star::awt::XControlModel >& xModel )
109 throw(::com::sun::star::container::NoSuchElementException,
110 ::com::sun::star::uno::RuntimeException);
112 // XServiceInfo
113 virtual OUString SAL_CALL getImplementationName()
114 throw(::com::sun::star::uno::RuntimeException);
115 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
116 throw(::com::sun::star::uno::RuntimeException);
117 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
118 throw(::com::sun::star::uno::RuntimeException);
120 // XTypeProvider
121 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
122 throw(::com::sun::star::uno::RuntimeException);
123 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
124 throw(::com::sun::star::uno::RuntimeException);
128 // ScViewPaneObj for direct use (including OWeakObject)
130 class ScViewPaneObj : public ScViewPaneBase, public cppu::OWeakObject
132 public:
133 ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP);
134 virtual ~ScViewPaneObj();
136 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
137 const ::com::sun::star::uno::Type & rType )
138 throw(::com::sun::star::uno::RuntimeException);
139 virtual void SAL_CALL acquire() throw();
140 virtual void SAL_CALL release() throw();
143 // OWeakObject is base of SfxBaseController -> use ScViewPaneBase
145 class ScTabViewObj : public ScViewPaneBase,
146 public SfxBaseController,
147 public com::sun::star::sheet::XSpreadsheetView,
148 public com::sun::star::sheet::XEnhancedMouseClickBroadcaster,
149 public com::sun::star::sheet::XActivationBroadcaster,
150 public com::sun::star::container::XEnumerationAccess,
151 public com::sun::star::container::XIndexAccess,
152 public com::sun::star::view::XSelectionSupplier,
153 public com::sun::star::beans::XPropertySet,
154 public com::sun::star::sheet::XViewSplitable,
155 public com::sun::star::sheet::XViewFreezable,
156 public com::sun::star::sheet::XRangeSelection,
157 public com::sun::star::lang::XUnoTunnel,
158 public com::sun::star::datatransfer::XTransferableSupplier,
159 public com::sun::star::sheet::XSelectedSheetsSupplier
161 private:
162 typedef ::com::sun::star::uno::Reference<
163 ::com::sun::star::sheet::XRangeSelectionListener > XRangeSelectionListenerUnoRef;
164 typedef boost::ptr_vector<XRangeSelectionListenerUnoRef> XRangeSelectionListenerVector;
166 typedef ::com::sun::star::uno::Reference<
167 ::com::sun::star::sheet::XRangeSelectionChangeListener > XRangeSelectionChangeListenerUnoRef;
168 typedef boost::ptr_vector<XRangeSelectionChangeListenerUnoRef> XRangeSelectionChangeListenerVector;
170 typedef ::com::sun::star::uno::Reference<
171 ::com::sun::star::view::XSelectionChangeListener > XSelectionChangeListenerUnoRef;
172 typedef boost::ptr_vector<XSelectionChangeListenerUnoRef> XSelectionChangeListenerVector;
174 typedef ::com::sun::star::uno::Reference<
175 ::com::sun::star::beans::XPropertyChangeListener > XViewPropertyChangeListenerUnoRef;
176 typedef boost::ptr_vector<XViewPropertyChangeListenerUnoRef> XViewPropertyChangeListenerVector;
178 typedef ::com::sun::star::uno::Reference<
179 ::com::sun::star::awt::XEnhancedMouseClickHandler > XMouseClickHandlerUnoRef;
180 typedef boost::ptr_vector<XMouseClickHandlerUnoRef> XMouseClickHandlerVector;
182 typedef ::com::sun::star::uno::Reference<
183 ::com::sun::star::sheet::XActivationEventListener > XActivationEventListenerUnoRef;
184 typedef boost::ptr_vector<XActivationEventListenerUnoRef> XActivationEventListenerVector;
186 SfxItemPropertySet aPropSet;
187 XSelectionChangeListenerVector aSelectionChgListeners;
188 XRangeSelectionListenerVector aRangeSelListeners;
189 XRangeSelectionChangeListenerVector aRangeChgListeners;
190 XViewPropertyChangeListenerVector aPropertyChgListeners;
191 XMouseClickHandlerVector aMouseClickHandlers;
192 XActivationEventListenerVector aActivationListeners;
193 SCTAB nPreviousTab;
194 sal_Bool bDrawSelModeSet;
195 sal_Bool bFilteredRangeSelection;
197 ScViewPaneObj* GetObjectByIndex_Impl(sal_uInt16 nIndex) const;
198 sal_Int16 GetZoom(void) const;
199 void SetZoom(sal_Int16 Zoom);
200 sal_Int16 GetZoomType(void) const;
201 void SetZoomType(sal_Int16 ZoomType);
203 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > GetClickedObject(const Point& rPoint) const;
204 void StartMouseListening();
205 void EndMouseListening();
206 void StartActivationListening();
207 void EndActivationListening();
208 bool mbLeftMousePressed;
209 bool mbPendingSelectionChanged;
210 ScTabViewObj(); // disabled
211 public:
212 ScTabViewObj(ScTabViewShell* pViewSh);
213 virtual ~ScTabViewObj();
215 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
216 const ::com::sun::star::uno::Type & rType )
217 throw(::com::sun::star::uno::RuntimeException);
218 virtual void SAL_CALL acquire() throw();
219 virtual void SAL_CALL release() throw();
221 void SelectionChanged();
222 void VisAreaChanged();
223 // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet
224 void SheetChanged( bool bSameTabButMoved = false );
225 bool IsMouseListening() const;
226 sal_Bool MousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
227 sal_Bool MouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
229 void RangeSelDone( const OUString& rText );
230 void RangeSelAborted( const OUString& rText );
231 void RangeSelChanged( const OUString& rText );
233 // XSelectionSupplier
234 virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection )
235 throw(::com::sun::star::lang::IllegalArgumentException,
236 ::com::sun::star::uno::RuntimeException);
237 virtual ::com::sun::star::uno::Any SAL_CALL getSelection()
238 throw(::com::sun::star::uno::RuntimeException);
239 virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference<
240 ::com::sun::star::view::XSelectionChangeListener >& xListener )
241 throw(::com::sun::star::uno::RuntimeException);
242 virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference<
243 ::com::sun::star::view::XSelectionChangeListener >& xListener )
244 throw(::com::sun::star::uno::RuntimeException);
246 //! XPrintable?
248 // XPropertySet
249 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
250 SAL_CALL getPropertySetInfo()
251 throw(::com::sun::star::uno::RuntimeException);
252 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
253 const ::com::sun::star::uno::Any& aValue )
254 throw(::com::sun::star::beans::UnknownPropertyException,
255 ::com::sun::star::beans::PropertyVetoException,
256 ::com::sun::star::lang::IllegalArgumentException,
257 ::com::sun::star::lang::WrappedTargetException,
258 ::com::sun::star::uno::RuntimeException);
259 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
260 const OUString& PropertyName )
261 throw(::com::sun::star::beans::UnknownPropertyException,
262 ::com::sun::star::lang::WrappedTargetException,
263 ::com::sun::star::uno::RuntimeException);
264 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
265 const ::com::sun::star::uno::Reference<
266 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
267 throw(::com::sun::star::beans::UnknownPropertyException,
268 ::com::sun::star::lang::WrappedTargetException,
269 ::com::sun::star::uno::RuntimeException);
270 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
271 const ::com::sun::star::uno::Reference<
272 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
273 throw(::com::sun::star::beans::UnknownPropertyException,
274 ::com::sun::star::lang::WrappedTargetException,
275 ::com::sun::star::uno::RuntimeException);
276 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
277 const ::com::sun::star::uno::Reference<
278 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
279 throw(::com::sun::star::beans::UnknownPropertyException,
280 ::com::sun::star::lang::WrappedTargetException,
281 ::com::sun::star::uno::RuntimeException);
282 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
283 const ::com::sun::star::uno::Reference<
284 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
285 throw(::com::sun::star::beans::UnknownPropertyException,
286 ::com::sun::star::lang::WrappedTargetException,
287 ::com::sun::star::uno::RuntimeException);
289 // XEnumerationAccess
290 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
291 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
293 // XIndexAccess
294 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
295 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
296 throw(::com::sun::star::lang::IndexOutOfBoundsException,
297 ::com::sun::star::lang::WrappedTargetException,
298 ::com::sun::star::uno::RuntimeException);
300 // XElementAccess
301 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
302 throw(::com::sun::star::uno::RuntimeException);
303 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
305 // XSpreadsheetView
306 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > SAL_CALL
307 getActiveSheet() throw(::com::sun::star::uno::RuntimeException);
308 virtual void SAL_CALL setActiveSheet( const ::com::sun::star::uno::Reference<
309 ::com::sun::star::sheet::XSpreadsheet >& xActiveSheet )
310 throw(::com::sun::star::uno::RuntimeException);
312 //XEnhancedMouseClickBroadcaster
314 virtual void SAL_CALL addEnhancedMouseClickHandler( const ::com::sun::star::uno::Reference<
315 ::com::sun::star::awt::XEnhancedMouseClickHandler >& aListener )
316 throw (::com::sun::star::uno::RuntimeException);
317 virtual void SAL_CALL removeEnhancedMouseClickHandler( const ::com::sun::star::uno::Reference<
318 ::com::sun::star::awt::XEnhancedMouseClickHandler >& aListener )
319 throw (::com::sun::star::uno::RuntimeException);
321 //XActivationBroadcaster
323 virtual void SAL_CALL addActivationEventListener( const ::com::sun::star::uno::Reference<
324 ::com::sun::star::sheet::XActivationEventListener >& aListener )
325 throw (::com::sun::star::uno::RuntimeException);
326 virtual void SAL_CALL removeActivationEventListener( const ::com::sun::star::uno::Reference<
327 ::com::sun::star::sheet::XActivationEventListener >& aListener )
328 throw (::com::sun::star::uno::RuntimeException);
330 // XViewSplitable
331 virtual sal_Bool SAL_CALL getIsWindowSplit() throw(::com::sun::star::uno::RuntimeException);
332 virtual sal_Int32 SAL_CALL getSplitHorizontal() throw(::com::sun::star::uno::RuntimeException);
333 virtual sal_Int32 SAL_CALL getSplitVertical() throw(::com::sun::star::uno::RuntimeException);
334 virtual sal_Int32 SAL_CALL getSplitColumn() throw(::com::sun::star::uno::RuntimeException);
335 virtual sal_Int32 SAL_CALL getSplitRow() throw(::com::sun::star::uno::RuntimeException);
336 virtual void SAL_CALL splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
337 throw(::com::sun::star::uno::RuntimeException);
339 // XViewFreezable
340 virtual sal_Bool SAL_CALL hasFrozenPanes() throw(::com::sun::star::uno::RuntimeException);
341 virtual void SAL_CALL freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
342 throw(::com::sun::star::uno::RuntimeException);
344 // XRangeSelection
345 virtual void SAL_CALL startRangeSelection( const ::com::sun::star::uno::Sequence<
346 ::com::sun::star::beans::PropertyValue >& aArguments )
347 throw(::com::sun::star::uno::RuntimeException);
348 virtual void SAL_CALL abortRangeSelection() throw(::com::sun::star::uno::RuntimeException);
349 virtual void SAL_CALL addRangeSelectionListener( const ::com::sun::star::uno::Reference<
350 ::com::sun::star::sheet::XRangeSelectionListener >& aListener )
351 throw(::com::sun::star::uno::RuntimeException);
352 virtual void SAL_CALL removeRangeSelectionListener( const ::com::sun::star::uno::Reference<
353 ::com::sun::star::sheet::XRangeSelectionListener >& aListener )
354 throw(::com::sun::star::uno::RuntimeException);
355 virtual void SAL_CALL addRangeSelectionChangeListener( const ::com::sun::star::uno::Reference<
356 ::com::sun::star::sheet::XRangeSelectionChangeListener >& aListener )
357 throw(::com::sun::star::uno::RuntimeException);
358 virtual void SAL_CALL removeRangeSelectionChangeListener( const ::com::sun::star::uno::Reference<
359 ::com::sun::star::sheet::XRangeSelectionChangeListener >& aListener )
360 throw(::com::sun::star::uno::RuntimeException);
362 // XServiceInfo
363 virtual OUString SAL_CALL getImplementationName()
364 throw(::com::sun::star::uno::RuntimeException);
365 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
366 throw(::com::sun::star::uno::RuntimeException);
367 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
368 throw(::com::sun::star::uno::RuntimeException);
370 // XUnoTunnel
371 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
372 sal_Int8 >& aIdentifier )
373 throw(::com::sun::star::uno::RuntimeException);
375 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
376 static ScTabViewObj* getImplementation( const com::sun::star::uno::Reference<
377 com::sun::star::uno::XInterface> xObj );
379 // XTypeProvider
380 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
381 throw(::com::sun::star::uno::RuntimeException);
382 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
383 throw(::com::sun::star::uno::RuntimeException);
385 // XTransferableSupplier
386 virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable( ) throw (::com::sun::star::uno::RuntimeException);
387 virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException);
389 // XSelectedSheetsSupplier
390 virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets()
391 throw(::com::sun::star::uno::RuntimeException);
394 class ScPreviewObj : public SfxBaseController,
395 public SfxListener,
396 public com::sun::star::sheet::XSelectedSheetsSupplier
398 ScPreviewShell* mpViewShell;
399 public:
400 ScPreviewObj(ScPreviewShell* pViewSh);
401 virtual ~ScPreviewObj();
403 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
404 const ::com::sun::star::uno::Type & rType)
405 throw(::com::sun::star::uno::RuntimeException);
407 virtual void SAL_CALL acquire() throw();
408 virtual void SAL_CALL release() throw();
410 virtual void Notify(SfxBroadcaster&, const SfxHint& rHint);
412 // XSelectedSheetsSupplier
413 virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets()
414 throw(::com::sun::star::uno::RuntimeException);
417 #endif
419 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */