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 <tools/color.hxx>
23 #include <svx/svdtypes.hxx>
25 #include <swregion.hxx>
40 class SwAccessibleMap
;
44 class SwPagePreviewLayout
;
48 namespace sdr::contact
{ class ViewObjectContactRedirector
; }
53 friend class SwViewShell
;
55 friend class SwLayAction
; // Lay- and IdleAction register and deregister
56 friend class SwLayIdle
;
58 // for paint of page preview
59 friend class SwPagePreviewLayout
;
61 SwViewShell
*m_pShell
; // If someone passes an Imp, but needs a SwViewShell, we
62 // keep a backlink here
64 std::unique_ptr
<SwDrawView
> m_pDrawView
; // Our DrawView
65 SdrPageView
*m_pSdrPageView
; // Exactly one Page for our DrawView
67 SwPageFrame
*m_pFirstVisiblePage
; // Always points to the first visible Page
68 std::optional
<SwRegionRects
> m_oPaintRegion
; // Collector of Paintrects from the LayAction
70 std::vector
<SwRect
> m_pendingLOKInvalidations
;
72 SwLayAction
*m_pLayAction
; // Is set if an Action object exists
73 // Is registered by the SwLayAction ctor and deregistered by the dtor
74 SwLayIdle
*m_pIdleAct
; // The same as SwLayAction for SwLayIdle
76 /// note: the map is *uniquely* owned here - the shared_ptr is only
77 /// used so that SwAccessibleContext can check via weak_ptr that it's alive
78 std::shared_ptr
<SwAccessibleMap
> m_pAccessibleMap
;
80 bool m_bFirstPageInvalid
: 1; // Pointer to the first Page invalid?
81 bool m_bResetHdlHiddenPaint
: 1; // Ditto
82 bool m_bSmoothUpdate
: 1; // For SmoothScroll
83 bool m_bStopSmooth
: 1;
85 sal_uInt16 m_nRestoreActions
; // Count for the Action that need to be restored (UNO)
88 std::unique_ptr
<SwPagePreviewLayout
> m_pPagePreviewLayout
;
90 void SetFirstVisPage(OutputDevice
const * pRenderContext
); // Recalculate the first visible Page
92 void StartAction(); // Show handle and hide
93 void EndAction(); // Called by SwViewShell::ImplXXXAction
94 void LockPaint(); // Ditto; called by SwViewShell::ImplLockPaint
99 SwAccessibleMap
*CreateAccessibleMap();
101 /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
104 implementation for wrapper method
105 <SwViewShell::InvalidateAccessibleParaFlowRelation(..)>
107 @param _pFromTextFrame
108 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
109 has to be invalidated.
110 If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated
113 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
114 has to be invalidated.
115 If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
117 void InvalidateAccessibleParaFlowRelation_( const SwTextFrame
* _pFromTextFrame
,
118 const SwTextFrame
* _pToTextFrame
);
120 /** invalidate text selection for paragraphs
123 implementation for wrapper method
124 <SwViewShell::InvalidateAccessibleParaTextSelection(..)>
126 void InvalidateAccessibleParaTextSelection_();
128 /** invalidate attributes for paragraphs and paragraph's characters
131 implementation for wrapper method
132 <SwViewShell::InvalidateAccessibleParaAttrs(..)>
134 void InvalidateAccessibleParaAttrs_( const SwTextFrame
& rTextFrame
);
137 SwViewShellImp( SwViewShell
* );
139 void Init( const SwViewOption
* ); /// Only for SwViewShell::Init()
141 const SwViewShell
*GetShell() const { return m_pShell
; }
142 SwViewShell
*GetShell() { return m_pShell
; }
144 Color
GetRetoucheColor() const;
146 /// Management of the first visible Page
147 const SwPageFrame
*GetFirstVisPage(OutputDevice
const * pRenderContext
) const;
148 SwPageFrame
*GetFirstVisPage(OutputDevice
const * pRenderContext
);
149 void SetFirstVisPageInvalid() { m_bFirstPageInvalid
= true; }
151 const SwPageFrame
* GetLastVisPage(const OutputDevice
* pRenderContext
) const;
153 bool AddPaintRect( const SwRect
&rRect
);
154 bool HasPaintRegion() { return m_oPaintRegion
.has_value(); }
155 std::optional
<SwRegionRects
> TakePaintRegion() { auto ret
= std::move(m_oPaintRegion
); m_oPaintRegion
.reset(); return ret
; }
156 const std::optional
<SwRegionRects
>& GetPaintRegion() { return m_oPaintRegion
; }
157 void DeletePaintRegion() { m_oPaintRegion
.reset(); }
159 void AddPendingLOKInvalidation( const SwRect
& rRect
);
160 std::vector
<SwRect
> TakePendingLOKInvalidations();
162 /// New Interface for StarView Drawing
163 bool HasDrawView() const { return nullptr != m_pDrawView
; }
164 SwDrawView
* GetDrawView() { return m_pDrawView
.get(); }
165 const SwDrawView
* GetDrawView() const { return m_pDrawView
.get(); }
166 SdrPageView
*GetPageView() { return m_pSdrPageView
; }
167 const SdrPageView
*GetPageView() const { return m_pSdrPageView
; }
171 * @param _pPageBackgrdColor for setting this color as the background color
172 * at the outliner of the draw view for painting layers "hell" and "heaven"
174 * @param _bIsPageRightToLeft for the horizontal text direction of the page
175 * in order to set the default horizontal text direction at the outliner of
176 * the draw view for painting layers "hell" and "heaven"
178 void PaintLayer( const SdrLayerID _nLayerID
,
179 SwPageFrame
const& rPageFrame
,
180 const SwRect
& _rRect
,
181 const Color
* _pPageBackgrdColor
,
182 const bool _bIsPageRightToLeft
,
183 sdr::contact::ViewObjectContactRedirector
* pRedirector
);
186 * Is passed to the DrawEngine as a Link and decides what is painted
187 * or not and in what way
191 bool IsDragPossible( const Point
&rPoint
);
192 void NotifySizeChg( const Size
&rNewSz
);
194 /// SS for the Lay-/IdleAction and relatives
195 bool IsAction() const { return m_pLayAction
!= nullptr; }
196 bool IsIdleAction() const { return m_pIdleAct
!= nullptr; }
197 SwLayAction
&GetLayAction() { return *m_pLayAction
; }
198 const SwLayAction
&GetLayAction() const { return *m_pLayAction
; }
201 * If an Action is running we ask it to check whether it's time
202 * to enable the WaitCursor
204 void CheckWaitCursor();
206 /// Asks the LayAction if present
207 bool IsCalcLayoutProgress() const;
210 * @returns true if a LayAction is running
212 * There we also set the Flag for ExpressionFields
214 bool IsUpdateExpFields();
216 void SetRestoreActions(sal_uInt16 nSet
){m_nRestoreActions
= nSet
;}
217 sal_uInt16
GetRestoreActions() const{return m_nRestoreActions
;}
219 void InitPagePreviewLayout();
221 SwPagePreviewLayout
* PagePreviewLayout()
223 return m_pPagePreviewLayout
.get();
226 /// Is this view accessible?
227 bool IsAccessible() const { return m_pAccessibleMap
!= nullptr; }
229 inline SwAccessibleMap
& GetAccessibleMap();
231 /// Update (this) accessible view
232 void UpdateAccessible();
234 /// Remove a frame from the accessible view
235 void DisposeAccessible( const SwFrame
*pFrame
, const SdrObject
*pObj
,
236 bool bRecursive
, bool bCanSkipInvisible
);
237 inline void DisposeAccessibleFrame( const SwFrame
*pFrame
,
238 bool bRecursive
= false );
239 inline void DisposeAccessibleObj( const SdrObject
*pObj
, bool bCanSkipInvisible
);
241 /// Move a frame's position in the accessible view
242 void MoveAccessible( const SwFrame
*pFrame
, const SdrObject
*pObj
,
243 const SwRect
& rOldFrame
);
244 inline void MoveAccessibleFrame( const SwFrame
*pFrame
, const SwRect
& rOldFrame
);
246 /// Add a frame in the accessible view
247 inline void AddAccessibleFrame( const SwFrame
*pFrame
);
249 inline void AddAccessibleObj( const SdrObject
*pObj
);
251 /// Invalidate accessible frame's content
252 void InvalidateAccessibleFrameContent( const SwFrame
*pFrame
);
254 /// Invalidate accessible frame's cursor position
255 void InvalidateAccessibleCursorPosition( const SwFrame
*pFrame
);
257 /// Invalidate editable state for all accessible frames
258 void InvalidateAccessibleEditableState( bool bAllShells
,
259 const SwFrame
*pFrame
=nullptr );
261 /// Invalidate frame's relation set (for chained frames)
262 void InvalidateAccessibleRelationSet( const SwFlyFrame
*pMaster
,
263 const SwFlyFrame
*pFollow
);
265 /// update data for accessible preview
266 /// change method signature due to new page preview functionality
267 void UpdateAccessiblePreview( const std::vector
<std::unique_ptr
<PreviewPage
>>& _rPreviewPages
,
268 const Fraction
& _rScale
,
269 const SwPageFrame
* _pSelectedPageFrame
,
270 const Size
& _rPreviewWinSize
);
272 void InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage
);
274 /// Fire all accessible events that have been collected so far
275 void FireAccessibleEvents();
278 inline SwAccessibleMap
& SwViewShellImp::GetAccessibleMap()
280 if( !m_pAccessibleMap
)
281 CreateAccessibleMap();
283 return *m_pAccessibleMap
;
286 inline void SwViewShellImp::DisposeAccessibleFrame( const SwFrame
*pFrame
,
289 DisposeAccessible( pFrame
, nullptr, bRecursive
, true );
292 inline void SwViewShellImp::DisposeAccessibleObj( const SdrObject
*pObj
, bool bCanSkipInvisible
)
294 DisposeAccessible( nullptr, pObj
, false, bCanSkipInvisible
);
297 inline void SwViewShellImp::MoveAccessibleFrame( const SwFrame
*pFrame
,
298 const SwRect
& rOldFrame
)
300 MoveAccessible( pFrame
, nullptr, rOldFrame
);
303 inline void SwViewShellImp::AddAccessibleFrame( const SwFrame
*pFrame
)
306 MoveAccessible( pFrame
, nullptr, aEmptyRect
);
309 inline void SwViewShellImp::AddAccessibleObj( const SdrObject
*pObj
)
312 MoveAccessible( nullptr, pObj
, aEmptyRect
);
315 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */