summaryrefslogtreecommitdiff
path: root/svx/source/sdr/contact/displayinfo.cxx
blob: b91ff1503a2d78c6a779f5166c321c1820e898ba (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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: displayinfo.cxx,v $
 *
 *  $Revision: 1.10 $
 *
 *  last change: $Author: obo $ $Date: 2006-09-17 05:33:52 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"

#ifndef _SDR_CONTACT_DISPLAYINFO_HXX
#include <svx/sdr/contact/displayinfo.hxx>
#endif

#ifndef _SV_OUTDEV_HXX
#include <vcl/outdev.hxx>
#endif

#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif

#ifndef _SVDOBJ_HXX
#include <svdobj.hxx>
#endif

#ifndef _SV_GDIMTF_HXX
#include <vcl/gdimtf.hxx>
#endif

#ifndef _SVDPAGV_HXX
#include <svdpagv.hxx>
#endif

#define ALL_GHOSTED_DRAWMODES (DRAWMODE_GHOSTEDLINE|DRAWMODE_GHOSTEDFILL|DRAWMODE_GHOSTEDTEXT|DRAWMODE_GHOSTEDBITMAP|DRAWMODE_GHOSTEDGRADIENT)

//////////////////////////////////////////////////////////////////////////////

namespace sdr
{
    namespace contact
    {
        // This uses Application::AnyInput() and may change mbContinuePaint
        // to interrupt the paint
        void DisplayInfo::CheckContinuePaint()
        {
            // #111111#
            // INPUT_PAINT and INPUT_TIMER removed again since this leads to
            // problems under Linux and Solaris when painting slow objects
            // (e.g. bitmaps)

            // #114335#
            // INPUT_OTHER removed too, leads to problems with added controls
            // from the form layer.
            if(Application::AnyInput(INPUT_KEYBOARD))
            {
                mbContinuePaint = sal_False;
            }
        }

        DisplayInfo::DisplayInfo(SdrPageView* pPageView)
        :   mpPageView(pPageView),
            mpProcessedPage(0L),
            mpLastDisplayInfo(0L),
            maProcessLayers(sal_True), // init layer info with all bits set to draw everything on default
            mpOutputDevice(0L),
            mpExtOutputDevice(0L),
            mpPaintInfoRec(0L),
            mpRootVOC(0L),
            mbControlLayerPainting(sal_False),
            mbPagePainting(sal_True),
            mbGhostedDrawModeActive(sal_False),
            mbBufferingAllowed(sal_True),
            mbContinuePaint(sal_True),
            mbMasterPagePainting(sal_False),
            mbPreRenderingAllowed(sal_False)
        {
        }

        DisplayInfo::~DisplayInfo()
        {
            SetProcessedPage( 0L );
        }

        // access to ProcessedPage, write for internal use only.
        void DisplayInfo::SetProcessedPage(SdrPage* pNew)
        {
            if(pNew != mpProcessedPage)
            {
                mpProcessedPage = pNew;

                if(mpPageView)
                {
                    if( pNew == NULL )
                    {
                        // DisplayInfo needs to be reset at PageView if set since DisplayInfo is no longer valid
                        if(mpPageView && mpPageView->GetCurrentPaintingDisplayInfo())
                        {
                            DBG_ASSERT( mpPageView->GetCurrentPaintingDisplayInfo() == this, "DisplayInfo::~DisplayInfo() : stack error!" );

                            // restore remembered DisplayInfo to build a stack, or delete
                            mpPageView->SetCurrentPaintingDisplayInfo(mpLastDisplayInfo);
                        }
                    }
                    else
                    {
                        // rescue current
                        mpLastDisplayInfo = mpPageView->GetCurrentPaintingDisplayInfo();

                        // set at PageView when a page is set
                        mpPageView->SetCurrentPaintingDisplayInfo(this);
                    }
                }
            }
        }

        const SdrPage* DisplayInfo::GetProcessedPage() const
        {
            return mpProcessedPage;
        }

        // Access to LayerInfos (which layers to proccess)
        void DisplayInfo::SetProcessLayers(const SetOfByte& rSet)
        {
            maProcessLayers = rSet;
        }

        const SetOfByte& DisplayInfo::GetProcessLayers() const
        {
            return maProcessLayers;
        }

        // access to ExtendedOutputDevice
        void DisplayInfo::SetExtendedOutputDevice(XOutputDevice* pExtOut)
        {
            if(mpExtOutputDevice != pExtOut)
            {
                mpExtOutputDevice = pExtOut;
            }
        }

        XOutputDevice* DisplayInfo::GetExtendedOutputDevice() const
        {
            return mpExtOutputDevice;
        }

        // access to PaintInfoRec
        void DisplayInfo::SetPaintInfoRec(SdrPaintInfoRec* pInfoRec)
        {
            if(mpPaintInfoRec != pInfoRec)
            {
                mpPaintInfoRec = pInfoRec;
            }
        }

        SdrPaintInfoRec* DisplayInfo::GetPaintInfoRec() const
        {
            return mpPaintInfoRec;
        }

        // access to OutputDevice
        void DisplayInfo::SetOutputDevice(OutputDevice* pOutDev)
        {
            if(mpOutputDevice != pOutDev)
            {
                mpOutputDevice = pOutDev;
            }
        }

        OutputDevice* DisplayInfo::GetOutputDevice() const
        {
            return mpOutputDevice;
        }

        // access to RedrawArea
        void DisplayInfo::SetRedrawArea(const Region& rRegion)
        {
            maRedrawArea = rRegion;
        }

        const Region& DisplayInfo::GetRedrawArea() const
        {
            return maRedrawArea;
        }

        // Is OutDev a printer?
        sal_Bool DisplayInfo::OutputToPrinter() const
        {
            if(mpOutputDevice && OUTDEV_PRINTER == mpOutputDevice->GetOutDevType())
            {
                return sal_True;
            }

            return sal_False;
        }

        // Is OutDev a window?
        sal_Bool DisplayInfo::OutputToWindow() const
        {
            if(mpOutputDevice && OUTDEV_WINDOW == mpOutputDevice->GetOutDevType())
            {
                return sal_True;
            }

            return sal_False;
        }

        // Is OutDev a VirtualDevice?
        sal_Bool DisplayInfo::OutputToVirtualDevice() const
        {
            if(mpOutputDevice && OUTDEV_VIRDEV == mpOutputDevice->GetOutDevType())
            {
                return sal_True;
            }

            return sal_False;
        }

        // Is OutDev a recording MetaFile?
        sal_Bool DisplayInfo::OutputToRecordingMetaFile() const
        {
            if(mpOutputDevice)
            {
                GDIMetaFile* pMetaFile = mpOutputDevice->GetConnectMetaFile();

                if(pMetaFile)
                {
                    sal_Bool bRecording = pMetaFile->IsRecord() && !pMetaFile->IsPause();
                    return bRecording;
                }
            }

            return sal_False;
        }

        void DisplayInfo::SetControlLayerPainting(sal_Bool bDoPaint)
        {
            if(mbControlLayerPainting != bDoPaint)
            {
                mbControlLayerPainting = bDoPaint;
            }
        }

        sal_Bool DisplayInfo::GetControlLayerPainting() const
        {
            return mbControlLayerPainting;
        }

        void DisplayInfo::SetPagePainting(sal_Bool bDoPaint)
        {
            if(mbPagePainting != bDoPaint)
            {
                mbPagePainting = bDoPaint;
            }
        }

        sal_Bool DisplayInfo::GetPagePainting() const
        {
            return mbPagePainting;
        }

        // Access to svtools::ColorConfig
        const svtools::ColorConfig& DisplayInfo::GetColorConfig() const
        {
            return maColorConfig;
        }

        sal_uInt32 DisplayInfo::GetOriginalDrawMode() const
        {
            // return DrawMode without ghosted stuff
            if(mpOutputDevice)
            {
                return (mpOutputDevice->GetDrawMode() & ~ALL_GHOSTED_DRAWMODES);
            }

            return 0L;
        }

        sal_uInt32 DisplayInfo::GetCurrentDrawMode() const
        {
            if(mpOutputDevice)
            {
                return mpOutputDevice->GetDrawMode();
            }

            return 0L;
        }

        void DisplayInfo::ClearGhostedDrawMode()
        {
            if(mpOutputDevice)
            {
                mpOutputDevice->SetDrawMode(mpOutputDevice->GetDrawMode() & ~ALL_GHOSTED_DRAWMODES);
            }

            mbGhostedDrawModeActive = sal_False;
        }

        void DisplayInfo::SetGhostedDrawMode()
        {
            if(mpOutputDevice)
            {
                mpOutputDevice->SetDrawMode(mpOutputDevice->GetDrawMode() | ALL_GHOSTED_DRAWMODES);
            }

            mbGhostedDrawModeActive = sal_True;
        }

        sal_Bool DisplayInfo::IsGhostedDrawModeActive() const
        {
            return mbGhostedDrawModeActive;
        }

        // access to buffering allowed flag
        void DisplayInfo::SetBufferingAllowed(sal_Bool bNew)
        {
            if(mbBufferingAllowed != bNew)
            {
                mbBufferingAllowed = bNew;
            }
        }

        sal_Bool DisplayInfo::IsBufferingAllowed() const
        {
            return mbBufferingAllowed;
        }

        // Check if painting should be continued. If not, return from paint
        // as soon as possible.
        sal_Bool DisplayInfo::DoContinuePaint()
        {
            if(mbContinuePaint
                && mpOutputDevice
                && OUTDEV_WINDOW == mpOutputDevice->GetOutDevType())
            {
                CheckContinuePaint();
            }

            return mbContinuePaint;
        }

        sal_Bool DisplayInfo::GetMasterPagePainting() const
        {
            return mbMasterPagePainting;
        }

        void DisplayInfo::SetMasterPagePainting(sal_Bool bNew)
        {
            if(mbMasterPagePainting != bNew)
            {
                mbMasterPagePainting = bNew;
            }
        }

        // access to PreRendering flag
        sal_Bool DisplayInfo::IsPreRenderingAllowed() const
        {
            return mbPreRenderingAllowed;
        }

        void DisplayInfo::SetPreRenderingAllowed(sal_Bool bNew)
        {
            if(mbPreRenderingAllowed != bNew)
            {
                mbPreRenderingAllowed = bNew;
            }
        }

        // Infos about draft painting. These may get bitfield members later.
        sal_Bool DisplayInfo::IsDraftText() const
        {
            return (0 != (mpPaintInfoRec->nPaintMode & SDRPAINTMODE_DRAFTTEXT));
        }
        sal_Bool DisplayInfo::IsDraftGraphic() const
        {
            return (0 != (mpPaintInfoRec->nPaintMode & SDRPAINTMODE_DRAFTGRAF));
        }
        sal_Bool DisplayInfo::IsDraftLine() const
        {
            return (0 != (mpPaintInfoRec->nPaintMode & SDRPAINTMODE_DRAFTLINE));
        }
        sal_Bool DisplayInfo::IsDraftFill() const
        {
            return (0 != (mpPaintInfoRec->nPaintMode & SDRPAINTMODE_DRAFTFILL));
        }
        sal_Bool DisplayInfo::IsHideDraftGraphic() const
        {
            return (0 != (mpPaintInfoRec->nPaintMode & SDRPAINTMODE_HIDEDRAFTGRAF));
        }
    } // end of namespace contact
} // end of namespace sdr

//////////////////////////////////////////////////////////////////////////////
// eof