1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/awt/XControlContainer.hpp>
23 #include <rtl/ustring.hxx>
24 #include <tools/color.hxx>
25 #include <svx/svdhlpln.hxx>
26 #include <svx/svdsob.hxx>
27 #include <svx/svdtypes.hxx>
28 #include <svx/svxdllapi.h>
32 #include <basegfx/range/b2irectangle.hxx>
35 namespace vcl
{ class Region
; }
45 namespace sdr::contact
47 class ViewObjectContactRedirector
;
49 class ViewObjectContactRedirector
;
52 // typedefs for a list of SdrPageWindow
55 class SVXCORE_DLLPUBLIC SdrPageView
60 Point aPgOrg
; // The Page's point of origin
62 tools::Rectangle aMarkBound
;
63 tools::Rectangle aMarkSnap
;
67 SdrLayerIDSet aLayerVisi
; // Set of visible Layers
68 SdrLayerIDSet aLayerLock
; // Set of non-editable Layers
69 SdrLayerIDSet aLayerPrn
; // Set of printable Layers
71 SdrObjList
* pCurrentList
; // Current List, usually the Page
72 SdrObject
* pCurrentGroup
; // Current Group; nullptr means none
74 SdrHelpLineList aHelpLines
; // Helper lines and points
76 // #103911# Use one reserved slot (bReserveBool2) for the document color
77 Color maDocumentColor
;
79 // #103834# Use one reserved slot (bReserveBool1) for the background color
80 Color maBackgroundColor
;
82 std::vector
< std::unique_ptr
<SdrPageWindow
> > maPageWindows
;
84 // #i72752# member to remember with which SdrPageWindow the BeginDrawLayer
86 SdrPageWindow
* mpPreparedPageWindow
;
89 sal_uInt32
PageWindowCount() const { return maPageWindows
.size(); }
90 SdrPageWindow
* FindPageWindow( const SdrPaintWindow
& rPaintWindow
) const;
91 SdrPageWindow
* FindPageWindow( const OutputDevice
& rOutDev
) const;
92 SdrPageWindow
* GetPageWindow(sal_uInt32 nIndex
) const;
95 * Finds the page window whose PaintWindow belongs to the given output device
96 * In opposite to FindPageWindow, this method also cares possibly patched PaintWindow instances.
97 * That is, a SdrPageWindow might have an original, and a patched SdrPaintWindow instance - if
98 * this is the case, then the original SdrPaintWindow is examined before the patched one.
100 const SdrPageWindow
* FindPatchedPageWindow( const OutputDevice
& rOutDev
) const;
103 void ImpInvalidateHelpLineArea(sal_uInt16 nNum
) const;
105 void SetLayer(const OUString
& rName
, SdrLayerIDSet
& rBS
, bool bJa
);
106 bool IsLayer(const OUString
& rName
, const SdrLayerIDSet
& rBS
) const;
108 /// Let's see if the current Group (pCurrentGroup) is still inserted
109 void CheckCurrentGroup();
114 SdrPageView(SdrPage
* pPage1
, SdrView
& rNewView
);
117 SdrPageView
& operator=( SdrPageView
const & ) = delete; // MSVC2017 workaround
118 SdrPageView( SdrPageView
const & ) = delete; // MSVC2017 workaround
121 /// Is called by PaintView, when modal changes have finished
122 void ModelHasChanged();
127 void AddPaintWindowToPageView(SdrPaintWindow
& rPaintWindow
);
128 void RemovePaintWindowFromPageView(SdrPaintWindow
& rPaintWindow
);
130 SdrView
& GetView() { return mrView
; }
131 const SdrView
& GetView() const { return mrView
; }
134 * Looks up the control container belonging to given output device
136 * If the given output device belongs to one of the SdrPageViewWinRecs associated with this
137 * SdrPageView instance, the XControlContainer for this output device is returned, <NULL/>
140 css::uno::Reference
< css::awt::XControlContainer
>
141 GetControlContainer( const OutputDevice
& _rDevice
) const;
143 /// Sets all elements in the view which support a design and an alive mode into the given mode
144 void SetDesignMode( bool _bDesignMode
) const;
146 bool IsVisible() const { return mbVisible
; }
148 /// Invalidates the Page's whole area
149 void InvalidateAllWin();
151 /// PrePaint call forwarded from app windows
154 /// @param rReg refers to the OutDev and not to the Page
155 void CompleteRedraw( SdrPaintWindow
& rPaintWindow
, const vcl::Region
& rReg
, sdr::contact::ViewObjectContactRedirector
* pRedirector
);
157 /// Write access to mpPreparedPageWindow
158 void setPreparedPageWindow(SdrPageWindow
* pKnownTarget
);
160 void DrawLayer(SdrLayerID nID
, OutputDevice
* pGivenTarget
, sdr::contact::ViewObjectContactRedirector
* pRedirector
= nullptr,
161 const tools::Rectangle
& rRect
= tools::Rectangle(),
162 basegfx::B2IRectangle
const* pPageFrame
= nullptr);
163 void DrawPageViewGrid(OutputDevice
& rOut
, const tools::Rectangle
& rRect
, Color aColor
= COL_BLACK
);
165 tools::Rectangle
GetPageRect() const;
166 SdrPage
* GetPage() const { return mpPage
; }
168 /// Return current List
169 SdrObjList
* GetObjList() const { return pCurrentList
; }
171 /// Return current Group
172 SdrObject
* GetCurrentGroup() const { return pCurrentGroup
; }
174 /// Set current Group and List
175 void SetCurrentGroupAndList(SdrObject
* pNewGroup
, SdrObjList
* pNewList
);
177 bool HasMarkedObjPageView() const { return mbHasMarked
; }
178 void SetHasMarkedObj(bool bOn
) { mbHasMarked
= bOn
; }
180 const tools::Rectangle
& MarkBound() const { return aMarkBound
; }
181 const tools::Rectangle
& MarkSnap() const { return aMarkSnap
; }
182 tools::Rectangle
& MarkBound() { return aMarkBound
; }
183 tools::Rectangle
& MarkSnap() { return aMarkSnap
; }
185 void SetLayerVisible(const OUString
& rName
, bool bShow
) {
186 SetLayer(rName
, aLayerVisi
, bShow
);
190 bool IsLayerVisible(const OUString
& rName
) const { return IsLayer(rName
, aLayerVisi
); }
192 void SetLayerLocked(const OUString
& rName
, bool bLock
) { SetLayer(rName
, aLayerLock
, bLock
); if(bLock
) AdjHdl(); }
193 bool IsLayerLocked(const OUString
& rName
) const { return IsLayer(rName
,aLayerLock
); }
195 void SetLayerPrintable(const OUString
& rName
, bool bPrn
) { SetLayer(rName
, aLayerPrn
, bPrn
); }
196 bool IsLayerPrintable(const OUString
& rName
) const { return IsLayer(rName
, aLayerPrn
); }
198 /// PV represents a RefPage or a SubList of a RefObj, or the Model is ReadOnly
199 bool IsReadOnly() const;
201 /// The Origin always refers to the upper left corner of the Page
202 const Point
& GetPageOrigin() const { return aPgOrg
; }
203 void SetPageOrigin(const Point
& rOrg
);
205 void LogicToPagePos(Point
& rPnt
) const { rPnt
-=aPgOrg
; }
206 void LogicToPagePos(tools::Rectangle
& rRect
) const { rRect
.Move(-aPgOrg
.X(),-aPgOrg
.Y()); }
207 void PagePosToLogic(Point
& rPnt
) const { rPnt
+=aPgOrg
; }
209 void SetVisibleLayers(const SdrLayerIDSet
& rSet
) { aLayerVisi
=rSet
; }
210 const SdrLayerIDSet
& GetVisibleLayers() const { return aLayerVisi
; }
211 void SetPrintableLayers(const SdrLayerIDSet
& rSet
) { aLayerPrn
=rSet
; }
212 const SdrLayerIDSet
& GetPrintableLayers() const { return aLayerPrn
; }
213 void SetLockedLayers(const SdrLayerIDSet
& rSet
) { aLayerLock
=rSet
; }
214 const SdrLayerIDSet
& GetLockedLayers() const { return aLayerLock
; }
216 const SdrHelpLineList
& GetHelpLines() const { return aHelpLines
; }
217 void SetHelpLines(const SdrHelpLineList
& rHLL
);
218 //void SetHelpLinePos(sal_uInt16 nNum, const Point& rNewPos);
219 void SetHelpLine(sal_uInt16 nNum
, const SdrHelpLine
& rNewHelpLine
);
220 void DeleteHelpLine(sal_uInt16 nNum
);
221 void InsertHelpLine(const SdrHelpLine
& rHL
);
223 /// At least one member must be visible for the Group object and
224 /// it must not be locked
226 /// true, if the object's layer is visible and not locked
227 bool IsObjMarkable(SdrObject
const * pObj
) const;
229 /// Entering (editing) an object group
230 /// After that, we have direct access to all member objects of the group.
231 /// All other objects are not editable in the meantime (until the next
233 bool EnterGroup(SdrObject
* pObj
);
235 /// Leave an object group we entered previously
236 void LeaveOneGroup();
238 /// Leave all object groups we entered previously
239 void LeaveAllGroup();
241 /// Determine, how deep we descended (0 = Root(Page))
242 sal_uInt16
GetEnteredLevel() const;
244 // #103834# Set background color for svx at SdrPageViews
245 void SetApplicationBackgroundColor(Color aBackgroundColor
);
247 const Color
& GetApplicationBackgroundColor() const { return maBackgroundColor
;}
249 // #103911# Set/Get document color for svx at SdrPageViews
250 void SetApplicationDocumentColor(Color aDocumentColor
);
251 const Color
& GetApplicationDocumentColor() const { return maDocumentColor
;}
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */