Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svx / svdpagv.hxx
blob9e82ec11fe4ee6a6afaa5fb57498f23aa8b85c67
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdpagv.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVDPAGV_HXX
32 #define _SVDPAGV_HXX
34 #ifndef _TOOLS_DEBUG_HXX
35 #include <tools/debug.hxx>
36 #endif
38 #ifndef _COM_SUN_STAR_AWT_XWINDOWLISTENER_HPP_
39 #include <com/sun/star/awt/XWindowListener.hpp>
40 #endif
41 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
42 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_AWT_XIMAGECONSUMER_HPP_
45 #include <com/sun/star/awt/XImageConsumer.hpp>
46 #endif
47 #ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_
48 #include <com/sun/star/awt/XControl.hpp>
49 #endif
50 #ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_
51 #include <com/sun/star/awt/XControlContainer.hpp>
52 #endif
53 #ifndef _COM_SUN_STAR_UTIL_XMODECHANGELISTENER_HPP_
54 #include <com/sun/star/util/XModeChangeListener.hpp>
55 #endif
57 #ifndef _SFXLSTNER_HXX //autogen
58 #include <bf_svtools/lstner.hxx>
59 #endif
60 #ifndef _APP_HXX //autogen
61 #include <vcl/svapp.hxx>
62 #endif
63 #ifndef _SVDLAYER_HXX
64 #include <bf_svx/svdlayer.hxx>
65 #endif
66 #ifndef _SVDHLPLN_HXX
67 #include <bf_svx/svdhlpln.hxx>
68 #endif
70 #ifndef _OSL_MUTEX_HXX_
71 #include <osl/mutex.hxx>
72 #endif
73 class Region;
74 class Link;
75 class OutputDevice;
76 class SdrObjListIter;
77 namespace binfilter {
79 ////////////////////////////////////////////////////////////////////////////////////////////////////
81 class ExtOutputDevice;
82 class SdrPaintInfoRec;
83 class XPolyPolygon;
84 class SdrObjList;
85 class SdrObject;
86 class SdrModel;
87 class SdrPage;
88 class SdrUnoObj;
89 class SdrPageObj;
90 class SdrView;
92 ////////////////////////////////////////////////////////////////////////////////////////////////////
94 class SdrPageViewWinList;
95 }//end of namespace binfilter
96 #if _SOLAR__PRIVATE
98 #include <cppuhelper/implbase4.hxx>
99 namespace binfilter {
100 #define SDRUNOCONTROL_NOTFOUND USHRT_MAX
102 class SdrUnoControlList;
104 // Listener an den UnoControls
105 class SdrUnoControlRec : public ::cppu::WeakImplHelper4<
106 ::com::sun::star::awt::XWindowListener,
107 ::com::sun::star::beans::XPropertyChangeListener,
108 ::com::sun::star::awt::XImageConsumer,
109 ::com::sun::star::util::XModeChangeListener
112 SdrUnoControlList* pParent;
113 SdrUnoObj* pObj;
114 bool bVisible : 1;
115 bool bDisposed : 1;
116 bool bIsListening : 1;
117 sal_uInt16 mnPaintLevel;
119 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > xControl;
121 public:
122 SdrUnoControlRec(SdrUnoControlList* _pParent, SdrUnoObj* _pObj, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > _xControl) throw();
123 ~SdrUnoControlRec() throw();
125 protected:
126 // XEventListener
127 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
129 // XWindowListener
130 virtual void SAL_CALL windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw(::com::sun::star::uno::RuntimeException);
131 virtual void SAL_CALL windowMoved( const ::com::sun::star::awt::WindowEvent& e ) throw(::com::sun::star::uno::RuntimeException);
132 virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& e ) throw(::com::sun::star::uno::RuntimeException);
133 virtual void SAL_CALL windowHidden( const ::com::sun::star::lang::EventObject& e ) throw(::com::sun::star::uno::RuntimeException);
135 // XPropertyChangeListener
136 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
138 // XImageConsumer
139 virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height ) throw(::com::sun::star::uno::RuntimeException);
140 virtual void SAL_CALL setColorModel( sal_Int16 BitCount, const ::com::sun::star::uno::Sequence< sal_Int32 >& RGBAPal, sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask, sal_Int32 AlphaMask ) throw(::com::sun::star::uno::RuntimeException);
141 virtual void SAL_CALL setPixelsByBytes( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, const ::com::sun::star::uno::Sequence< sal_Int8 >& aProducerData, sal_Int32 nOffset, sal_Int32 nScanSize ) throw(::com::sun::star::uno::RuntimeException);
142 virtual void SAL_CALL setPixelsByLongs( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, const ::com::sun::star::uno::Sequence< sal_Int32 >& aProducerData, sal_Int32 nOffset, sal_Int32 nScanSize ) throw(::com::sun::star::uno::RuntimeException);
143 virtual void SAL_CALL complete( sal_Int32 Status, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer >& xProducer ) throw(::com::sun::star::uno::RuntimeException);
145 // XModeChangeListener
146 virtual void SAL_CALL modeChanged( const ::com::sun::star::util::ModeChangeEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
148 public:
149 // More functions
150 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > GetControl() const {return xControl;}
151 BOOL IsVisible() const {return bVisible;}
152 BOOL IsListening() const {return bIsListening;}
153 SdrUnoObj* GetUnoObj() const { return pObj; }
155 // Setzen eines neuen Controls
156 void Clear(BOOL bDispose);
158 struct AccessControl { friend class SdrUnoControlPaintGuard; private: AccessControl() { } };
159 inline void EnterPaint( const AccessControl& ) { ++mnPaintLevel; }
160 inline void LeavePaint( const AccessControl& ) { DBG_ASSERT( mnPaintLevel, "SdrUnoControlRec::LeavePaint: not locked!" ); --mnPaintLevel; }
162 // in alive mode, the visibility of the control must be adjusted to the visibility of the layer
163 void adjustControlVisibility( bool _bForce );
165 private:
166 // starts or stops listening for any relevant events on the control or it's model
167 void switchControlListening( bool _bStart );
171 // class for temporarily (during painting) locking some functionality of the SdrUnoControlRec
172 class SdrUnoControlPaintGuard
174 private:
175 SdrUnoControlRec& m_rRec;
177 public:
178 inline SdrUnoControlPaintGuard( SdrUnoControlRec& _rRec )
179 :m_rRec( _rRec )
181 m_rRec.EnterPaint( SdrUnoControlRec::AccessControl( ) );
183 inline ~SdrUnoControlPaintGuard( )
185 m_rRec.LeavePaint( SdrUnoControlRec::AccessControl( ) );
189 // Klasse fuer den schnellen Zugriff auf Recs ueber das ControlModel
190 class SdrUnoControlAccess
192 public:
193 SdrUnoControlRec* pControlRec;
194 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xControlModel;
196 SdrUnoControlAccess(::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > _xControlModel, SdrUnoControlRec* _pControlRec = NULL)
197 :pControlRec( _pControlRec )
198 ,xControlModel( _xControlModel )
200 SdrUnoControlAccess()
202 pControlRec = NULL;
205 BOOL operator==( const SdrUnoControlAccess& rAcc ) const
207 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt1( xControlModel, ::com::sun::star::uno::UNO_QUERY );
208 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt2( rAcc.xControlModel, ::com::sun::star::uno::UNO_QUERY );
209 return ((::com::sun::star::uno::XInterface*)xInt1.get()) == ((::com::sun::star::uno::XInterface*)xInt2.get());
211 BOOL operator<( const SdrUnoControlAccess& rAcc ) const
213 return xControlModel.get() < rAcc.xControlModel.get();
217 typedef SdrUnoControlAccess* SdrUnoControlAccessPtr;
218 SV_DECL_PTRARR_SORT( SdrUnoControlAccessArr, SdrUnoControlAccessPtr, 16, 16 )
220 class SdrPageView;
221 class SdrUnoControlList
223 friend class SdrUnoControlRec;
225 Container aList;
226 SdrUnoControlAccessArr aAccessArr;
227 SdrPageView& rPageView;
229 protected:
230 SdrUnoControlRec* GetObject(USHORT i) const;
232 public:
233 SdrUnoControlList( SdrPageView& _rPageView )
234 :aList(1024,4,4)
235 ,rPageView( _rPageView )
237 ~SdrUnoControlList() { Clear(TRUE); }
238 void Clear(BOOL bDispose);
239 USHORT GetCount() const { return (USHORT)aList.Count(); }
240 void Insert(SdrUnoControlRec* pRec);
241 void Delete(USHORT nPos, BOOL bDispose);
242 SdrUnoControlRec& operator[](USHORT nPos) { return *GetObject(nPos); }
243 const SdrUnoControlRec& operator[](USHORT nPos) const { return *GetObject(nPos); }
244 USHORT Find(::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > rUnoControlModel) const;
247 class SdrPageViewWinRec
249 friend class SdrPageView;
250 SdrView& rView;
251 OutputDevice* pOutDev;
252 SdrUnoControlList aControlList;
253 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xControlContainer;
255 protected:
256 void CreateControlContainer();
258 public:
259 SdrPageViewWinRec(SdrPageView& rNewPageView, OutputDevice* pOutDev);
260 ~SdrPageViewWinRec();
262 BOOL MatchOutputDevice(OutputDevice* pOut) const;
263 OutputDevice* GetOutputDevice() const { return pOutDev; }
264 const SdrUnoControlList& GetControlList() const { return aControlList; }
265 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > GetControlContainerRef() const { return xControlContainer; }
268 #define SDRPAGEVIEWWIN_NOTFOUND 0xFFFF
270 class SdrPageViewWinList {
271 Container aList;
272 private:
273 SdrPageViewWinList(const SdrPageViewWinList& rSource): aList(1024,4,4) {}
274 void operator=(const SdrPageViewWinList& rSource) {}
275 protected:
276 SdrPageViewWinRec* GetObject(USHORT i) const { return (SdrPageViewWinRec*)(aList.GetObject(i)); }
277 public:
278 SdrPageViewWinList(): aList(1024,4,4) {}
279 ~SdrPageViewWinList() { Clear(); }
280 void Clear();
281 USHORT GetCount() const { return (USHORT)aList.Count(); }
282 void Insert(SdrPageViewWinRec* pVWR, USHORT nPos=0xFFFF) { aList.Insert(pVWR,nPos); }
283 void Delete(USHORT nPos) { delete (SdrPageViewWinRec*)aList.Remove(nPos); }
284 SdrPageViewWinRec& operator[](USHORT nPos) { return *GetObject(nPos); }
285 const SdrPageViewWinRec& operator[](USHORT nPos) const { return *GetObject(nPos); }
286 USHORT Find(OutputDevice* pW) const;
288 }//end of namespace binfilter
289 #endif // __PRIVATE
291 ////////////////////////////////////////////////////////////////////////////////////////////////////
292 namespace binfilter {
293 class SdrPageView: public SfxListener {
294 friend class SdrPaintView;
295 //friend class SdrSnapView;
296 //friend class SdrMarkView;
297 //friend class SdrView;
298 protected:
299 // Container aRedraw; // Ein Eintrag fuer jedes Win. Dieser Container
300 SdrView& rView; // deckt sich mit der Fensterliste der SdrView.
301 SdrPage* pPage;
302 Point aPgOrg; // Nullpunkt der Page
303 Point aOfs; // Offset der Page im Win
304 //Timer aGetBack;
306 Rectangle aMarkBound; // wird
307 Rectangle aMarkSnap; // von
308 XPolyPolygon* pDragPoly0; // SdrView
309 XPolyPolygon* pDragPoly; //
310 FASTBOOL bHasMarked; // verwendet
311 FASTBOOL bVisible; // Sichtbar?
313 SetOfByte aLayerVisi; // Menge der sichtbaren Layer
314 SetOfByte aLayerLock; // Menge der nicht editierbaren Layer
315 SetOfByte aLayerPrn; // Menge der druckbaren Layer
317 SdrObjList* pAktList; // Aktuelle Liste, in der Regel die Page.
318 SdrObject* pAktGroup; // Aktuelle Gruppe. NULL=Keine.
320 SdrHelpLineList aHelpLines; // Hilfslinien und -punkte
322 // Reserve fuer kompatible Erweiterungen die sonst inkompatibel wuerden
324 // #103834# Use one reserved slot (bReserveBool1) for the background color
325 Color maBackgroundColor;
327 // #103911# Use one reserved slot (bReserveBool2) for the document color
328 Color maDocumentColor;
330 long nReserveLong1;
331 long nReserveLong2;
332 SdrPageViewWinList* pWinList;
333 SdrPageObj* pPaintingPageObj;
334 Point aReservePoint1;
335 Point aReservePoint2;
336 Rectangle aReserveRect1;
337 String aReserveString1;
339 #if _SOLAR__PRIVATE
340 private:
341 SdrPageViewWinRec* ImpMakePageViewWinRec(OutputDevice* pOutDev1);
342 void ImpInsertControl(const SdrUnoObj* pObj, SdrPageViewWinRec* pRec);
343 void ImpUnoInserted(const SdrObject* pObj);
344 protected:
345 #endif // __PRIVATE
346 protected:
347 //USHORT GetWinCount() const { return USHORT(aRedraw.Count()); }
348 //SdrPageWin* GetWin(USHORT nNum) const { return (SdrPageWin*)(aRedraw.GetObject(nNum)); }
349 //void AddWin() { aRedraw.Insert(new SdrPageWin,CONTAINER_APPEND); }
350 //void DelWin(USHORT nNum) { delete aRedraw.Remove(nNum); }
351 //void ClearWinList();
352 // Jeder ContainerEntry muss auf ein OutputDevice zeigen:
353 //void SetWinList(const Container& rWinList);
355 void AddWin(OutputDevice* pOutDev1);
356 void DelWin(OutputDevice* pOutDev1);
358 FASTBOOL IsLayer(const String& rName, const SetOfByte& rBS) const;
360 virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType, const SfxHint& rHint, const TypeId& rHintType);
361 void Show();
362 void Hide();
363 // Nachsehen, ob AktGroup noch Inserted ist.
364 void CheckAktGroup();
365 // Wird von der PaintView gerufen, wenn Modelaenderungen abgeschlossen sind
366 void ModelHasChanged();
367 public:
368 TYPEINFO();
369 SdrPageView(SdrPage* pPage1, const Point& rOffs, SdrView& rNewView);
370 ~SdrPageView();
371 SdrView& GetView() { return rView; }
372 const SdrView& GetView() const { return rView; }
373 const SdrPageViewWinList& GetWinList() const { return *pWinList; }
375 FASTBOOL IsVisible() const { return bVisible; }
376 // Invalidiert den gesamten Bereich der Page
377 void InvalidateAllWin();
378 // rRect bezieht sich auf die Page
379 void InvalidateAllWin(const Rectangle& rRect, FASTBOOL bPlus1Pix=FALSE);
380 // rReg bezieht sich auf's OutDev, nicht auf die Page
381 void InitRedraw(OutputDevice* pOut, const Region& rReg, USHORT nPaintMode=0, const Link* pPaintProc=NULL){DBG_BF_ASSERT(0, "STRIP");}//STRIP001 void InitRedraw(OutputDevice* pOut, const Region& rReg, USHORT nPaintMode=0, const Link* pPaintProc=NULL);
382 // rReg bezieht sich auf's OutDev, nicht auf die Page
383 // Painten aller Objekte eines Layer der Page ohne MasterPage
384 // pOut==NULL -> alle OutputDevices
385 // Der Handler in pPaintProc hat folgendes aussehen:
386 // void __EXPORT class::PaintProcHdl(const SdrPaintProcRec& rPaintProcRec);
389 // MasterPage ueber VirtualDevice Painten
391 const Point& GetOffset() const { return aOfs; }
392 Rectangle GetPageRect() const;
393 SdrPage* GetPage() const { return pPage; }
395 // Betretene Liste rausreichen
396 SdrObjList* GetObjList() const { return pAktList; }
397 // Betretene Gruppe rausreichen
398 SdrObject* GetAktGroup() const { return pAktGroup; }
399 // Betretene Gruppe und Liste setzen
400 void SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList);
402 FASTBOOL HasMarkedObj() const { return bHasMarked; }
403 void SetHasMarkedObj(FASTBOOL bOn) { bHasMarked=bOn; }
405 const Rectangle& MarkBound() const { return aMarkBound; }
406 const Rectangle& MarkSnap() const { return aMarkSnap; }
407 Rectangle& MarkBound() { return aMarkBound; }
408 Rectangle& MarkSnap() { return aMarkSnap; }
411 FASTBOOL IsLayerVisible(const String& rName) const { return IsLayer(rName,aLayerVisi); }
413 FASTBOOL IsLayerLocked(const String& rName) const { return IsLayer(rName,aLayerLock); }
415 FASTBOOL IsLayerPrintable(const String& rName) const { return IsLayer(rName,aLayerPrn); }
417 // PV stellt eine RefPage oder eine SubList eines RefObj dar oder Model ist ReadOnly
419 // der Origin bezieht sich immer auf die obere linke Ecke der Page
420 const Point& GetPageOrigin() const { return aPgOrg; }
421 void LogicToPagePos(Point& rPnt) const { rPnt-=aPgOrg; }
422 void LogicToPagePos(Rectangle& rRect) const { rRect.Move(-aPgOrg.X(),-aPgOrg.Y()); }
423 void PagePosToLogic(Point& rPnt) const { rPnt+=aPgOrg; }
424 void PagePosToLogic(Rectangle& rRect) const { rRect.Move(aPgOrg.X(),aPgOrg.Y()); }
426 void SetVisibleLayers(const SetOfByte& rSet) { aLayerVisi=rSet; InvalidateAllWin(); }
427 const SetOfByte& GetVisibleLayers() const { return aLayerVisi; }
428 void SetPrintableLayers(const SetOfByte& rSet) { aLayerPrn=rSet; }
429 const SetOfByte& GetPrintableLayers() const { return aLayerPrn; }
430 void SetLockedLayers(const SetOfByte& rSet) { aLayerLock=rSet; }
431 const SetOfByte& GetLockedLayers() const { return aLayerLock; }
433 const SdrHelpLineList& GetHelpLines() const { return aHelpLines; }
434 void SetHelpLine(USHORT nNum, const SdrHelpLine& rNewHelpLine);
435 void MoveHelpLine(USHORT nNum, USHORT nNewNum) { aHelpLines.Move(nNum,nNewNum); }
437 // Liefert TRUE, wenn Layer des Obj sichtbar und nicht gesperrt.
438 // Beim Gruppenobjekt muss wenigstens ein Member sichtbar sein,
439 // gesperrt sein darf keiner.
440 FASTBOOL IsObjMarkable(SdrObject* pObj) const;
442 // Betreten (Editieren) einer Objektgruppe. Anschliessend liegen alle
443 // Memberobjekte der Gruppe im direkten Zugriff. Alle anderen Objekte
444 // koennen waerendessen nicht bearbeitet werden (bis zum naechsten
445 // LeaveGroup()). (wie MsDos chdir bla).
446 // Verlassen einer betretenen Objektgruppe. (wie MsDos chdir ..)
447 // Verlassen aller betretenen Objektgruppen. (wie MsDos chdir \)
448 void LeaveAllGroup();
449 // Name der aktuellen Objektgruppe
450 // Die Namen aller z.Zt. betretenen Gruppen
452 const XPolyPolygon& DragPoly0() const { return *pDragPoly0; }
453 const XPolyPolygon& DragPoly () const { return *pDragPoly; }
454 XPolyPolygon& DragPoly0() { return *pDragPoly0; }
455 XPolyPolygon& DragPoly () { return *pDragPoly; }
457 void SetPaintingPageObj( SdrPageObj* pObj ) { pPaintingPageObj = pObj; }
458 SdrPageObj* GetPaintingPageObj() const { return pPaintingPageObj; }
460 friend SvStream& operator<<(SvStream& rOut, const SdrPageView& rPageView);
461 friend SvStream& operator>>(SvStream& rIn, SdrPageView& rPageView);
463 // #103834# Set background color for svx at SdrPageViews
464 void SetApplicationBackgroundColor(Color aBackgroundColor);
466 // #103911# Set/Get document color for svx at SdrPageViews
467 void SetApplicationDocumentColor(Color aDocumentColor);
468 Color GetApplicationDocumentColor() const;
471 }//end of namespace binfilter
472 #endif //_SVDPAGV_HXX