Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
21 :
22 : #include <rtl/ustring.hxx>
23 : #include <tools/color.hxx>
24 : #include <svx/svdtypes.hxx>
25 : #include <vcl/timer.hxx>
26 : #include <swrect.hxx>
27 : #include <swtypes.hxx>
28 : #include <vector>
29 :
30 : class SwViewShell;
31 : class SwFlyFrm;
32 : class SwViewOption;
33 : class SwRegionRects;
34 : class SwFrm;
35 : class SwLayAction;
36 : class SwLayIdle;
37 : class SwDrawView;
38 : class SdrPageView;
39 : class SwPageFrm;
40 : class SwRegionRects;
41 : class SwAccessibleMap;
42 : class SdrObject;
43 : class Fraction;
44 : class SwPrintData;
45 : class SwPagePreviewLayout;
46 : struct PreviewPage;
47 : class SwTxtFrm;
48 : // --> OD #i76669#
49 : namespace sdr { namespace contact {
50 : class ViewObjectContactRedirector;
51 : } }
52 : // <--
53 :
54 : class SwViewImp
55 : {
56 : friend class SwViewShell;
57 :
58 : friend class SwLayAction; // Lay- and IdleAction register and deregister
59 : friend class SwLayIdle;
60 :
61 : // for paint of page preview
62 : friend class SwPagePreviewLayout;
63 :
64 : SwViewShell *pSh; // If someone passes an Imp, but needs a SwViewShell, we
65 : // keep a backlink here
66 :
67 : SwDrawView *pDrawView; // Our DrawView
68 : SdrPageView *pSdrPageView; // Exactly one Page for our DrawView
69 :
70 : SwPageFrm *pFirstVisPage; // Always points to the first visible Page
71 : SwRegionRects *pRegion; // Collector of Paintrects from the LayAction
72 :
73 : SwLayAction *pLayAct; // Is set if an Action object exists
74 : // Is registered by the SwLayAction ctor and deregistered by the dtor
75 : SwLayIdle *pIdleAct; // The same as SwLayAction for SwLayIdle
76 :
77 : SwAccessibleMap *pAccMap; // Accessible wrappers
78 :
79 : mutable const SdrObject * pSdrObjCached;
80 : mutable OUString sSdrObjCachedComment;
81 :
82 : bool bFirstPageInvalid : 1; // Pointer to the first Page invalid?
83 : bool bResetHdlHiddenPaint : 1; // Ditto
84 : bool bSmoothUpdate : 1; // For SmoothScroll
85 : bool bStopSmooth : 1;
86 :
87 : sal_uInt16 nRestoreActions ; // Count for the Action that need to be restored (UNO)
88 : SwRect aSmoothRect;
89 :
90 : SwPagePreviewLayout* mpPgPreviewLayout;
91 :
92 : void SetFirstVisPage(); // Recalculate the first visible Page
93 :
94 : void StartAction(); // Show handle and hide
95 : void EndAction(); // Called by SwViewShell::ImplXXXAction
96 : void LockPaint(); // Ditto; called by SwViewShell::ImplLockPaint
97 : void UnlockPaint();
98 :
99 : private:
100 :
101 : SwAccessibleMap *CreateAccessibleMap();
102 :
103 : /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
104 :
105 : #i27138#
106 : implementation for wrapper method
107 : <SwViewShell::InvalidateAccessibleParaFlowRelation(..)>
108 :
109 : @param _pFromTxtFrm
110 : input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
111 : has to be invalidated.
112 : If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated
113 :
114 : @param _pToTxtFrm
115 : input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
116 : has to be invalidated.
117 : If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
118 : */
119 : void _InvalidateAccessibleParaFlowRelation( const SwTxtFrm* _pFromTxtFrm,
120 : const SwTxtFrm* _pToTxtFrm );
121 :
122 : /** invalidate text selection for paragraphs
123 :
124 : #i27301#
125 : implementation for wrapper method
126 : <SwViewShell::InvalidateAccessibleParaTextSelection(..)>
127 : */
128 : void _InvalidateAccessibleParaTextSelection();
129 :
130 : /** invalidate attributes for paragraphs and paragraph's characters
131 :
132 : #i88069#
133 : implementation for wrapper method
134 : <SwViewShell::InvalidateAccessibleParaAttrs(..)>
135 : */
136 : void _InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm );
137 :
138 : public:
139 : SwViewImp( SwViewShell * );
140 : ~SwViewImp();
141 : void Init( const SwViewOption * ); /// Only for SwViewShell::Init()
142 :
143 89471 : const SwViewShell *GetShell() const { return pSh; }
144 640806 : SwViewShell *GetShell() { return pSh; }
145 :
146 : Color GetRetoucheColor() const;
147 :
148 : /// Management of the first visible Page
149 : inline const SwPageFrm *GetFirstVisPage() const;
150 : inline SwPageFrm *GetFirstVisPage();
151 38658 : void SetFirstVisPageInvalid() { bFirstPageInvalid = true; }
152 :
153 : bool AddPaintRect( const SwRect &rRect );
154 183531 : SwRegionRects *GetRegion() { return pRegion; }
155 : void DelRegion();
156 :
157 : /// New Interface for StarView Drawing
158 845671 : bool HasDrawView() const { return 0 != pDrawView; }
159 790999 : SwDrawView* GetDrawView() { return pDrawView; }
160 454933 : const SwDrawView* GetDrawView() const { return pDrawView; }
161 41164 : SdrPageView*GetPageView() { return pSdrPageView; }
162 25552 : const SdrPageView*GetPageView() const { return pSdrPageView; }
163 : void MakeDrawView();
164 :
165 : /**
166 : * @param _pPageBackgrdColor for setting this color as the background color
167 : * at the outliner of the draw view for painting layers "hell" and "heaven"
168 : *
169 : * @param _bIsPageRightToLeft for the horizontal text direction of the page
170 : * in order to set the default horizontal text direction at the outliner of
171 : * the draw view for painting layers "hell" and "heaven"
172 : */
173 : void PaintLayer( const SdrLayerID _nLayerID,
174 : SwPrintData const*const pPrintData,
175 : const SwRect& _rRect,
176 : const Color* _pPageBackgrdColor = 0,
177 : const bool _bIsPageRightToLeft = false,
178 : sdr::contact::ViewObjectContactRedirector* pRedirector = 0 ) const;
179 :
180 : /**
181 : * Is passed to the DrawEngine as a Link and decides what is painted
182 : * or not and in what way
183 : */
184 :
185 : // Interface Drawing
186 : bool IsDragPossible( const Point &rPoint );
187 : void NotifySizeChg( const Size &rNewSz );
188 :
189 : /// SS for the Lay-/IdleAction and relatives
190 32837 : bool IsAction() const { return pLayAct != 0; }
191 144458 : bool IsIdleAction() const { return pIdleAct != 0; }
192 8293 : SwLayAction &GetLayAction() { return *pLayAct; }
193 3784 : const SwLayAction &GetLayAction() const { return *pLayAct; }
194 : SwLayIdle &GetIdleAction() { return *pIdleAct;}
195 : const SwLayIdle &GetIdleAction() const { return *pIdleAct;}
196 :
197 : /**
198 : * If an Action is running we ask it to check whether it's time
199 : * to enable the WaitCrsr
200 : */
201 : void CheckWaitCrsr();
202 :
203 : /// Asks the LayAction if present
204 : bool IsCalcLayoutProgress() const;
205 :
206 : /**
207 : * @returns true if a LayAction is running
208 : *
209 : * There we also set the Flag for ExpressionFields
210 : */
211 : bool IsUpdateExpFlds();
212 :
213 688 : void SetRestoreActions(sal_uInt16 nSet){nRestoreActions = nSet;}
214 344 : sal_uInt16 GetRestoreActions() const{return nRestoreActions;}
215 :
216 : void InitPagePreviewLayout();
217 :
218 0 : inline SwPagePreviewLayout* PagePreviewLayout()
219 : {
220 0 : return mpPgPreviewLayout;
221 : }
222 :
223 : /// Is this view accessible?
224 181800 : bool IsAccessible() const { return pAccMap != 0; }
225 :
226 : inline SwAccessibleMap& GetAccessibleMap();
227 :
228 : /// Update (this) accessible view
229 : void UpdateAccessible();
230 :
231 : /// Remove a frame from the accessible view
232 : void DisposeAccessible( const SwFrm *pFrm, const SdrObject *pObj,
233 : bool bRecursive );
234 : inline void DisposeAccessibleFrm( const SwFrm *pFrm,
235 : bool bRecursive = false );
236 : inline void DisposeAccessibleObj( const SdrObject *pObj );
237 :
238 : /// Move a frame's position in the accessible view
239 : void MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj,
240 : const SwRect& rOldFrm );
241 : inline void MoveAccessibleFrm( const SwFrm *pFrm, const SwRect& rOldFrm );
242 :
243 : /// Add a frame in the accessible view
244 : inline void AddAccessibleFrm( const SwFrm *pFrm );
245 :
246 : inline void AddAccessibleObj( const SdrObject *pObj );
247 :
248 : /// Invalidate accessible frame's frame's content
249 : void InvalidateAccessibleFrmContent( const SwFrm *pFrm );
250 :
251 : /// Invalidate accessible frame's cursor position
252 : void InvalidateAccessibleCursorPosition( const SwFrm *pFrm );
253 :
254 : /// Invalidate editable state for all accessible frames
255 : void InvalidateAccessibleEditableState( bool bAllShells = true,
256 : const SwFrm *pFrm=0 );
257 :
258 : /// Invalidate frame's relation set (for chained frames)
259 : void InvalidateAccessibleRelationSet( const SwFlyFrm *pMaster,
260 : const SwFlyFrm *pFollow );
261 :
262 : /// update data for accessible preview
263 : /// change method signature due to new page preview functionality
264 : void UpdateAccessiblePreview( const std::vector<PreviewPage*>& _rPreviewPages,
265 : const Fraction& _rScale,
266 : const SwPageFrm* _pSelectedPageFrm,
267 : const Size& _rPreviewWinSize );
268 :
269 : void InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage );
270 :
271 : /// Fire all accessible events that have been collected so far
272 : void FireAccessibleEvents();
273 : };
274 :
275 106999 : inline SwPageFrm *SwViewImp::GetFirstVisPage()
276 : {
277 106999 : if ( bFirstPageInvalid )
278 28198 : SetFirstVisPage();
279 106999 : return pFirstVisPage;
280 : }
281 :
282 11 : inline const SwPageFrm *SwViewImp::GetFirstVisPage() const
283 : {
284 11 : if ( bFirstPageInvalid )
285 0 : ((SwViewImp*)this)->SetFirstVisPage();
286 11 : return pFirstVisPage;
287 : }
288 :
289 694 : inline SwAccessibleMap& SwViewImp::GetAccessibleMap()
290 : {
291 694 : if( !pAccMap )
292 24 : CreateAccessibleMap();
293 :
294 694 : return *pAccMap;
295 : }
296 :
297 0 : inline void SwViewImp::DisposeAccessibleFrm( const SwFrm *pFrm,
298 : bool bRecursive )
299 : {
300 0 : DisposeAccessible( pFrm, 0, bRecursive );
301 0 : }
302 :
303 0 : inline void SwViewImp::DisposeAccessibleObj( const SdrObject *pObj )
304 : {
305 0 : DisposeAccessible( 0, pObj, false );
306 0 : }
307 :
308 120 : inline void SwViewImp::MoveAccessibleFrm( const SwFrm *pFrm,
309 : const SwRect& rOldFrm )
310 : {
311 120 : MoveAccessible( pFrm, 0, rOldFrm );
312 120 : }
313 :
314 0 : inline void SwViewImp::AddAccessibleFrm( const SwFrm *pFrm )
315 : {
316 0 : SwRect aEmptyRect;
317 0 : MoveAccessible( pFrm, 0, aEmptyRect );
318 0 : }
319 :
320 0 : inline void SwViewImp::AddAccessibleObj( const SdrObject *pObj )
321 : {
322 0 : SwRect aEmptyRect;
323 0 : MoveAccessible( 0, pObj, aEmptyRect );
324 0 : }
325 : #endif // INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
326 :
327 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|