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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
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 SwPrintData
const*const pPrintData
,
180 SwPageFrame
const& rPageFrame
,
181 const SwRect
& _rRect
,
182 const Color
* _pPageBackgrdColor
,
183 const bool _bIsPageRightToLeft
,
184 sdr::contact::ViewObjectContactRedirector
* pRedirector
);
187 * Is passed to the DrawEngine as a Link and decides what is painted
188 * or not and in what way
192 bool IsDragPossible( const Point
&rPoint
);
193 void NotifySizeChg( const Size
&rNewSz
);
195 /// SS for the Lay-/IdleAction and relatives
196 bool IsAction() const { return m_pLayAction
!= nullptr; }
197 bool IsIdleAction() const { return m_pIdleAct
!= nullptr; }
198 SwLayAction
&GetLayAction() { return *m_pLayAction
; }
199 const SwLayAction
&GetLayAction() const { return *m_pLayAction
; }
202 * If an Action is running we ask it to check whether it's time
203 * to enable the WaitCursor
205 void CheckWaitCursor();
207 /// Asks the LayAction if present
208 bool IsCalcLayoutProgress() const;
211 * @returns true if a LayAction is running
213 * There we also set the Flag for ExpressionFields
215 bool IsUpdateExpFields();
217 void SetRestoreActions(sal_uInt16 nSet
){m_nRestoreActions
= nSet
;}
218 sal_uInt16
GetRestoreActions() const{return m_nRestoreActions
;}
220 void InitPagePreviewLayout();
222 SwPagePreviewLayout
* PagePreviewLayout()
224 return m_pPagePreviewLayout
.get();
227 /// Is this view accessible?
228 bool IsAccessible() const { return m_pAccessibleMap
!= nullptr; }
230 inline SwAccessibleMap
& GetAccessibleMap();
232 /// Update (this) accessible view
233 void UpdateAccessible();
235 /// Remove a frame from the accessible view
236 void DisposeAccessible( const SwFrame
*pFrame
, const SdrObject
*pObj
,
237 bool bRecursive
, bool bCanSkipInvisible
);
238 inline void DisposeAccessibleFrame( const SwFrame
*pFrame
,
239 bool bRecursive
= false );
240 inline void DisposeAccessibleObj( const SdrObject
*pObj
, bool bCanSkipInvisible
);
242 /// Move a frame's position in the accessible view
243 void MoveAccessible( const SwFrame
*pFrame
, const SdrObject
*pObj
,
244 const SwRect
& rOldFrame
);
245 inline void MoveAccessibleFrame( const SwFrame
*pFrame
, const SwRect
& rOldFrame
);
247 /// Add a frame in the accessible view
248 inline void AddAccessibleFrame( const SwFrame
*pFrame
);
250 inline void AddAccessibleObj( const SdrObject
*pObj
);
252 /// Invalidate accessible frame's content
253 void InvalidateAccessibleFrameContent( const SwFrame
*pFrame
);
255 /// Invalidate accessible frame's cursor position
256 void InvalidateAccessibleCursorPosition( const SwFrame
*pFrame
);
258 /// Invalidate editable state for all accessible frames
259 void InvalidateAccessibleEditableState( bool bAllShells
,
260 const SwFrame
*pFrame
=nullptr );
262 /// Invalidate frame's relation set (for chained frames)
263 void InvalidateAccessibleRelationSet( const SwFlyFrame
*pMaster
,
264 const SwFlyFrame
*pFollow
);
266 /// update data for accessible preview
267 /// change method signature due to new page preview functionality
268 void UpdateAccessiblePreview( const std::vector
<std::unique_ptr
<PreviewPage
>>& _rPreviewPages
,
269 const Fraction
& _rScale
,
270 const SwPageFrame
* _pSelectedPageFrame
,
271 const Size
& _rPreviewWinSize
);
273 void InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage
);
275 /// Fire all accessible events that have been collected so far
276 void FireAccessibleEvents();
279 inline SwAccessibleMap
& SwViewShellImp::GetAccessibleMap()
281 if( !m_pAccessibleMap
)
282 CreateAccessibleMap();
284 return *m_pAccessibleMap
;
287 inline void SwViewShellImp::DisposeAccessibleFrame( const SwFrame
*pFrame
,
290 DisposeAccessible( pFrame
, nullptr, bRecursive
, true );
293 inline void SwViewShellImp::DisposeAccessibleObj( const SdrObject
*pObj
, bool bCanSkipInvisible
)
295 DisposeAccessible( nullptr, pObj
, false, bCanSkipInvisible
);
298 inline void SwViewShellImp::MoveAccessibleFrame( const SwFrame
*pFrame
,
299 const SwRect
& rOldFrame
)
301 MoveAccessible( pFrame
, nullptr, rOldFrame
);
304 inline void SwViewShellImp::AddAccessibleFrame( const SwFrame
*pFrame
)
307 MoveAccessible( pFrame
, nullptr, aEmptyRect
);
310 inline void SwViewShellImp::AddAccessibleObj( const SdrObject
*pObj
)
313 MoveAccessible( nullptr, pObj
, aEmptyRect
);
315 #endif // INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */