summaryrefslogtreecommitdiffstats
path: root/sw/source/core/inc/viewimp.hxx
blob: aff1e701245a5228dd5d9c74f354276a753ef00e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
#define INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX

#include <tools/color.hxx>
#include <svx/svdtypes.hxx>
#include <swrect.hxx>
#include <vector>
#include <memory>

class OutputDevice;
class SwViewShell;
class SwFlyFrame;
class SwViewOption;
class SwRegionRects;
class SwFrame;
class SwLayAction;
class SwLayIdle;
class SwDrawView;
class SdrPageView;
class SwPageFrame;
class SwAccessibleMap;
class SdrObject;
class Fraction;
class SwPrintData;
class SwPagePreviewLayout;
struct PreviewPage;
class SwTextFrame;
// --> OD #i76669#
namespace sdr::contact { class ViewObjectContactRedirector; }
// <--

class SwViewShellImp
{
    friend class SwViewShell;

    friend class SwLayAction;   // Lay- and IdleAction register and deregister
    friend class SwLayIdle;

    // for paint of page preview
    friend class SwPagePreviewLayout;

    SwViewShell *m_pShell;           // If someone passes an Imp, but needs a SwViewShell, we
                                // keep a backlink here

    std::unique_ptr<SwDrawView> m_pDrawView; // Our DrawView
    SdrPageView *m_pSdrPageView;  // Exactly one Page for our DrawView

    SwPageFrame     *m_pFirstVisiblePage; // Always points to the first visible Page
    std::unique_ptr<SwRegionRects> m_pRegion; // Collector of Paintrects from the LayAction

    SwLayAction   *m_pLayAction;      // Is set if an Action object exists
                                 // Is registered by the SwLayAction ctor and deregistered by the dtor
    SwLayIdle     *m_pIdleAct;     // The same as SwLayAction for SwLayIdle

    /// note: the map is *uniquely* owned here - the shared_ptr is only
    /// used so that SwAccessibleContext can check via weak_ptr that it's alive
    std::shared_ptr<SwAccessibleMap> m_pAccessibleMap;

    bool m_bFirstPageInvalid : 1; // Pointer to the first Page invalid?
    bool m_bResetHdlHiddenPaint : 1; // Ditto
    bool m_bSmoothUpdate : 1; // For SmoothScroll
    bool m_bStopSmooth : 1;

    sal_uInt16 m_nRestoreActions  ; // Count for the Action that need to be restored (UNO)
    SwRect m_aSmoothRect;

    std::unique_ptr<SwPagePreviewLayout> m_pPagePreviewLayout;

    void SetFirstVisPage(OutputDevice const * pRenderContext); // Recalculate the first visible Page

    void StartAction();         // Show handle and hide
    void EndAction();           // Called by SwViewShell::ImplXXXAction
    void LockPaint();           // Ditto; called by SwViewShell::ImplLockPaint
    void UnlockPaint();

private:

    SwAccessibleMap *CreateAccessibleMap();

    /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs

        #i27138#
        implementation for wrapper method
        <SwViewShell::InvalidateAccessibleParaFlowRelation(..)>

        @param _pFromTextFrame
        input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
        has to be invalidated.
        If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated

        @param _pToTextFrame
        input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
        has to be invalidated.
        If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
    */
    void InvalidateAccessibleParaFlowRelation_( const SwTextFrame* _pFromTextFrame,
                                                const SwTextFrame* _pToTextFrame );

    /** invalidate text selection for paragraphs

        #i27301#
        implementation for wrapper method
        <SwViewShell::InvalidateAccessibleParaTextSelection(..)>
    */
    void InvalidateAccessibleParaTextSelection_();

    /** invalidate attributes for paragraphs and paragraph's characters

        #i88069#
        implementation for wrapper method
        <SwViewShell::InvalidateAccessibleParaAttrs(..)>
    */
    void InvalidateAccessibleParaAttrs_( const SwTextFrame& rTextFrame );

public:
    SwViewShellImp( SwViewShell * );
    ~SwViewShellImp();
    void Init( const SwViewOption * ); /// Only for SwViewShell::Init()

    const SwViewShell *GetShell() const { return m_pShell; }
          SwViewShell *GetShell()       { return m_pShell; }

    Color GetRetoucheColor() const;

    /// Management of the first visible Page
    const SwPageFrame *GetFirstVisPage(OutputDevice const * pRenderContext) const;
          SwPageFrame *GetFirstVisPage(OutputDevice const * pRenderContext);
    void SetFirstVisPageInvalid() { m_bFirstPageInvalid = true; }

    bool AddPaintRect( const SwRect &rRect );
    SwRegionRects *GetRegion()      { return m_pRegion.get(); }
    void DelRegion();

    /// New Interface for StarView Drawing
    bool  HasDrawView()             const { return nullptr != m_pDrawView; }
          SwDrawView* GetDrawView()       { return m_pDrawView.get(); }
    const SwDrawView* GetDrawView() const { return m_pDrawView.get(); }
          SdrPageView*GetPageView()       { return m_pSdrPageView; }
    const SdrPageView*GetPageView() const { return m_pSdrPageView; }
    void MakeDrawView();

    /**
     * @param _pPageBackgrdColor for setting this color as the background color
     * at the outliner of the draw view for painting layers "hell" and "heaven"
     *
     * @param _bIsPageRightToLeft for the horizontal text direction of the page
     * in order to set the default horizontal text direction at the outliner of
     * the draw view for painting layers "hell" and "heaven"
     */
    void   PaintLayer( const SdrLayerID _nLayerID,
                       SwPrintData const*const pPrintData,
                       SwPageFrame const& rPageFrame,
                       const SwRect& _rRect,
                       const Color* _pPageBackgrdColor,
                       const bool _bIsPageRightToLeft,
                       sdr::contact::ViewObjectContactRedirector* pRedirector );

    /**
     * Is passed to the DrawEngine as a Link and decides what is painted
     * or not and in what way
     */

    // Interface Drawing
    bool IsDragPossible( const Point &rPoint );
    void NotifySizeChg( const Size &rNewSz );

    /// SS for the Lay-/IdleAction and relatives
    bool  IsAction() const                   { return m_pLayAction  != nullptr; }
    bool  IsIdleAction() const               { return m_pIdleAct != nullptr; }
          SwLayAction &GetLayAction()        { return *m_pLayAction; }
    const SwLayAction &GetLayAction() const  { return *m_pLayAction; }

    /**
     * If an Action is running we ask it to check whether it's time
     * to enable the WaitCursor
     */
    void CheckWaitCursor();

    /// Asks the LayAction if present
    bool IsCalcLayoutProgress() const;

    /**
     * @returns true if a LayAction is running
     *
     * There we also set the Flag for ExpressionFields
     */
    bool IsUpdateExpFields();

    void    SetRestoreActions(sal_uInt16 nSet){m_nRestoreActions = nSet;}
    sal_uInt16  GetRestoreActions() const{return m_nRestoreActions;}

    void InitPagePreviewLayout();

    SwPagePreviewLayout* PagePreviewLayout()
    {
        return m_pPagePreviewLayout.get();
    }

    /// Is this view accessible?
    bool IsAccessible() const { return m_pAccessibleMap != nullptr; }

    inline SwAccessibleMap& GetAccessibleMap();

    /// Update (this) accessible view
    void UpdateAccessible();

    /// Remove a frame from the accessible view
    void DisposeAccessible( const SwFrame *pFrame, const SdrObject *pObj,
                            bool bRecursive, bool bCanSkipInvisible );
    inline void DisposeAccessibleFrame( const SwFrame *pFrame,
                               bool bRecursive = false );
    inline void DisposeAccessibleObj( const SdrObject *pObj, bool bCanSkipInvisible );

    /// Move a frame's position in the accessible view
    void MoveAccessible( const SwFrame *pFrame, const SdrObject *pObj,
                         const SwRect& rOldFrame );
    inline void MoveAccessibleFrame( const SwFrame *pFrame, const SwRect& rOldFrame );

    /// Add a frame in the accessible view
    inline void AddAccessibleFrame( const SwFrame *pFrame );

    inline void AddAccessibleObj( const SdrObject *pObj );

    /// Invalidate accessible frame's content
    void InvalidateAccessibleFrameContent( const SwFrame *pFrame );

    /// Invalidate accessible frame's cursor position
    void InvalidateAccessibleCursorPosition( const SwFrame *pFrame );

    /// Invalidate editable state for all accessible frames
    void InvalidateAccessibleEditableState( bool bAllShells,
                                               const SwFrame *pFrame=nullptr );

    /// Invalidate frame's relation set (for chained frames)
    void InvalidateAccessibleRelationSet( const SwFlyFrame *pMaster,
                                          const SwFlyFrame *pFollow );

    /// update data for accessible preview
    /// change method signature due to new page preview functionality
    void UpdateAccessiblePreview( const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
                                  const Fraction&  _rScale,
                                  const SwPageFrame* _pSelectedPageFrame,
                                  const Size&      _rPreviewWinSize );

    void InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage );

    /// Fire all accessible events that have been collected so far
    void FireAccessibleEvents();
};

inline SwAccessibleMap& SwViewShellImp::GetAccessibleMap()
{
    if( !m_pAccessibleMap )
        CreateAccessibleMap();

    return *m_pAccessibleMap;
}

inline void SwViewShellImp::DisposeAccessibleFrame( const SwFrame *pFrame,
                               bool bRecursive )
{
    DisposeAccessible( pFrame, nullptr, bRecursive, true );
}

inline void SwViewShellImp::DisposeAccessibleObj( const SdrObject *pObj, bool bCanSkipInvisible )
{
    DisposeAccessible( nullptr, pObj, false, bCanSkipInvisible );
}

inline void SwViewShellImp::MoveAccessibleFrame( const SwFrame *pFrame,
                                          const SwRect& rOldFrame )
{
    MoveAccessible( pFrame, nullptr, rOldFrame );
}

inline void SwViewShellImp::AddAccessibleFrame( const SwFrame *pFrame )
{
    SwRect aEmptyRect;
    MoveAccessible( pFrame, nullptr, aEmptyRect );
}

inline void SwViewShellImp::AddAccessibleObj( const SdrObject *pObj )
{
    SwRect aEmptyRect;
    MoveAccessible( nullptr, pObj, aEmptyRect );
}
#endif // INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */