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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
|
/* -*- 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 .
*/
#include <sal/config.h>
#include <sal/log.hxx>
#include <tools/debug.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/graph.hxx>
#include <vcl/metaact.hxx>
#include <vcl/virdev.hxx>
#include <vcl/outdev.hxx>
#include <vcl/toolkit/unowrap.hxx>
#include <vcl/svapp.hxx>
#include <vcl/sysdata.hxx>
#include <salgdi.hxx>
#include <window.h>
#include <outdev.h>
#ifdef DISABLE_DYNLOADING
// Linking all needed LO code into one .so/executable, these already
// exist in the tools library, so put them in the anonymous namespace
// here to avoid clash...
namespace {
#endif
#ifdef DISABLE_DYNLOADING
}
#endif
// Begin initializer and accessor public functions
OutputDevice::OutputDevice(OutDevType eOutDevType) :
meOutDevType(eOutDevType),
maRegion(true),
maFillColor( COL_WHITE ),
maTextLineColor( COL_TRANSPARENT ),
mxSettings( new AllSettings(Application::GetSettings()) )
{
mpGraphics = nullptr;
mpUnoGraphicsList = nullptr;
mpPrevGraphics = nullptr;
mpNextGraphics = nullptr;
mpMetaFile = nullptr;
mpFontInstance = nullptr;
mpDeviceFontList = nullptr;
mpDeviceFontSizeList = nullptr;
mpAlphaVDev = nullptr;
mpExtOutDevData = nullptr;
mnOutOffX = 0;
mnOutOffY = 0;
mnOutWidth = 0;
mnOutHeight = 0;
mnDPIX = 0;
mnDPIY = 0;
mnDPIScalePercentage = 100;
mnTextOffX = 0;
mnTextOffY = 0;
mnOutOffOrigX = 0;
mnOutOffLogicX = 0;
mnOutOffOrigY = 0;
mnOutOffLogicY = 0;
mnEmphasisAscent = 0;
mnEmphasisDescent = 0;
mnDrawMode = DrawModeFlags::Default;
mnTextLayoutMode = ComplexTextLayoutFlags::Default;
if( AllSettings::GetLayoutRTL() ) //#i84553# tip BiDi preference to RTL
mnTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft;
meOutDevViewType = OutDevViewType::DontKnow;
mbMap = false;
mbClipRegion = false;
mbBackground = false;
mbOutput = true;
mbDevOutput = false;
mbOutputClipped = false;
maTextColor = COL_BLACK;
maOverlineColor = COL_TRANSPARENT;
meRasterOp = RasterOp::OverPaint;
mnAntialiasing = AntialiasingFlags::NONE;
meTextLanguage = LANGUAGE_SYSTEM; // TODO: get default from configuration?
mbLineColor = true;
mbFillColor = true;
mbInitLineColor = true;
mbInitFillColor = true;
mbInitFont = true;
mbInitTextColor = true;
mbInitClipRegion = true;
mbClipRegionSet = false;
mbNewFont = true;
mbTextLines = false;
mbTextSpecial = false;
mbRefPoint = false;
mbEnableRTL = false; // mirroring must be explicitly allowed (typically for windows only)
// struct ImplMapRes
maMapRes.mnMapOfsX = 0;
maMapRes.mnMapOfsY = 0;
maMapRes.mnMapScNumX = 1;
maMapRes.mnMapScNumY = 1;
maMapRes.mnMapScDenomX = 1;
maMapRes.mnMapScDenomY = 1;
// struct ImplThresholdRes
maThresRes.mnThresLogToPixX = 0;
maThresRes.mnThresLogToPixY = 0;
maThresRes.mnThresPixToLogX = 0;
maThresRes.mnThresPixToLogY = 0;
// struct ImplOutDevData- see #i82615#
mpOutDevData.reset(new ImplOutDevData);
mpOutDevData->mpRotateDev = nullptr;
mpOutDevData->mpRecordLayout = nullptr;
// #i75163#
mpOutDevData->mpViewTransform = nullptr;
mpOutDevData->mpInverseViewTransform = nullptr;
}
OutputDevice::~OutputDevice()
{
disposeOnce();
}
void OutputDevice::dispose()
{
if ( GetUnoGraphicsList() )
{
UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper( false );
if ( pWrapper )
pWrapper->ReleaseAllGraphics( this );
delete mpUnoGraphicsList;
mpUnoGraphicsList = nullptr;
}
mpOutDevData->mpRotateDev.disposeAndClear();
// #i75163#
ImplInvalidateViewTransform();
mpOutDevData.reset();
// for some reason, we haven't removed state from the stack properly
if ( !maOutDevStateStack.empty() )
SAL_WARN( "vcl.gdi", "OutputDevice::~OutputDevice(): OutputDevice::Push() calls != OutputDevice::Pop() calls" );
maOutDevStateStack.clear();
// release the active font instance
mpFontInstance.clear();
// remove cached results of GetDevFontList/GetDevSizeList
mpDeviceFontList.reset();
mpDeviceFontSizeList.reset();
// release ImplFontCache specific to this OutputDevice
mxFontCache.reset();
// release ImplFontList specific to this OutputDevice
mxFontCollection.reset();
mpAlphaVDev.disposeAndClear();
mpPrevGraphics.clear();
mpNextGraphics.clear();
VclReferenceBase::dispose();
}
bool OutputDevice::IsVirtual() const
{
return false;
}
SalGraphics* OutputDevice::GetGraphics()
{
DBG_TESTSOLARMUTEX();
if (!mpGraphics && !AcquireGraphics())
SAL_WARN("vcl.gdi", "No mpGraphics set");
return mpGraphics;
}
SalGraphics const *OutputDevice::GetGraphics() const
{
DBG_TESTSOLARMUTEX();
if (!mpGraphics && !AcquireGraphics())
SAL_WARN("vcl.gdi", "No mpGraphics set");
return mpGraphics;
}
void OutputDevice::SetConnectMetaFile( GDIMetaFile* pMtf )
{
mpMetaFile = pMtf;
}
void OutputDevice::SetSettings( const AllSettings& rSettings )
{
*mxSettings = rSettings;
if( mpAlphaVDev )
mpAlphaVDev->SetSettings( rSettings );
}
SystemGraphicsData OutputDevice::GetSystemGfxData() const
{
if (!mpGraphics && !AcquireGraphics())
return SystemGraphicsData();
return mpGraphics->GetGraphicsData();
}
#if ENABLE_CAIRO_CANVAS
bool OutputDevice::SupportsCairo() const
{
if (!mpGraphics && !AcquireGraphics())
return false;
return mpGraphics->SupportsCairo();
}
cairo::SurfaceSharedPtr OutputDevice::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
{
if (!mpGraphics && !AcquireGraphics())
return cairo::SurfaceSharedPtr();
return mpGraphics->CreateSurface(rSurface);
}
cairo::SurfaceSharedPtr OutputDevice::CreateSurface(int x, int y, int width, int height) const
{
if (!mpGraphics && !AcquireGraphics())
return cairo::SurfaceSharedPtr();
return mpGraphics->CreateSurface(*this, x, y, width, height);
}
cairo::SurfaceSharedPtr OutputDevice::CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const
{
if (!mpGraphics && !AcquireGraphics())
return cairo::SurfaceSharedPtr();
return mpGraphics->CreateBitmapSurface(*this, rData, rSize);
}
css::uno::Any OutputDevice::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const
{
if (!mpGraphics && !AcquireGraphics())
return css::uno::Any();
return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize);
}
#endif // ENABLE_CAIRO_CANVAS
css::uno::Any OutputDevice::GetSystemGfxDataAny() const
{
const SystemGraphicsData aSysData = GetSystemGfxData();
css::uno::Sequence< sal_Int8 > aSeq( reinterpret_cast<sal_Int8 const *>(&aSysData),
aSysData.nSize );
return css::uno::makeAny(aSeq);
}
void OutputDevice::SetRefPoint()
{
if ( mpMetaFile )
mpMetaFile->AddAction( new MetaRefPointAction( Point(), false ) );
mbRefPoint = false;
maRefPoint.setX(0);
maRefPoint.setY(0);
if( mpAlphaVDev )
mpAlphaVDev->SetRefPoint();
}
void OutputDevice::SetRefPoint( const Point& rRefPoint )
{
if ( mpMetaFile )
mpMetaFile->AddAction( new MetaRefPointAction( rRefPoint, true ) );
mbRefPoint = true;
maRefPoint = rRefPoint;
if( mpAlphaVDev )
mpAlphaVDev->SetRefPoint( rRefPoint );
}
sal_uInt16 OutputDevice::GetBitCount() const
{
// we need a graphics instance
if ( !mpGraphics && !AcquireGraphics() )
return 0;
return mpGraphics->GetBitCount();
}
void OutputDevice::SetOutOffXPixel(long nOutOffX)
{
mnOutOffX = nOutOffX;
}
void OutputDevice::SetOutOffYPixel(long nOutOffY)
{
mnOutOffY = nOutOffY;
}
css::uno::Reference< css::awt::XGraphics > OutputDevice::CreateUnoGraphics()
{
UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper();
return pWrapper ? pWrapper->CreateGraphics( this ) : css::uno::Reference< css::awt::XGraphics >();
}
std::vector< VCLXGraphics* > *OutputDevice::CreateUnoGraphicsList()
{
mpUnoGraphicsList = new std::vector< VCLXGraphics* >;
return mpUnoGraphicsList;
}
// Helper public function
bool OutputDevice::SupportsOperation( OutDevSupportType eType ) const
{
if( !mpGraphics && !AcquireGraphics() )
return false;
const bool bHasSupport = mpGraphics->supportsOperation( eType );
return bHasSupport;
}
// Direct OutputDevice drawing public functions
void OutputDevice::DrawOutDev( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPt, const Size& rSrcSize )
{
if( ImplIsRecordLayout() )
return;
if ( RasterOp::Invert == meRasterOp )
{
DrawRect( tools::Rectangle( rDestPt, rDestSize ) );
return;
}
if ( mpMetaFile )
{
const Bitmap aBmp( GetBitmap( rSrcPt, rSrcSize ) );
mpMetaFile->AddAction( new MetaBmpScaleAction( rDestPt, rDestSize, aBmp ) );
}
if ( !IsDeviceOutputNecessary() )
return;
if ( !mpGraphics && !AcquireGraphics() )
return;
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
long nSrcWidth = ImplLogicWidthToDevicePixel( rSrcSize.Width() );
long nSrcHeight = ImplLogicHeightToDevicePixel( rSrcSize.Height() );
long nDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() );
long nDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() );
if (nSrcWidth && nSrcHeight && nDestWidth && nDestHeight)
{
SalTwoRect aPosAry(ImplLogicXToDevicePixel(rSrcPt.X()), ImplLogicYToDevicePixel(rSrcPt.Y()),
nSrcWidth, nSrcHeight,
ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
nDestWidth, nDestHeight);
const tools::Rectangle aSrcOutRect( Point( mnOutOffX, mnOutOffY ),
Size( mnOutWidth, mnOutHeight ) );
AdjustTwoRect( aPosAry, aSrcOutRect );
if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
mpGraphics->CopyBits( aPosAry, nullptr, this, nullptr );
}
if( mpAlphaVDev )
mpAlphaVDev->DrawOutDev( rDestPt, rDestSize, rSrcPt, rSrcSize );
}
void OutputDevice::DrawOutDev( const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPt, const Size& rSrcSize,
const OutputDevice& rOutDev )
{
if ( ImplIsRecordLayout() )
return;
if ( RasterOp::Invert == meRasterOp )
{
DrawRect( tools::Rectangle( rDestPt, rDestSize ) );
return;
}
if ( mpMetaFile )
{
if (rOutDev.mpAlphaVDev)
{
const BitmapEx aBmpEx(rOutDev.GetBitmapEx(rSrcPt, rSrcSize));
mpMetaFile->AddAction(new MetaBmpExScaleAction(rDestPt, rDestSize, aBmpEx));
}
else
{
const Bitmap aBmp(rOutDev.GetBitmap(rSrcPt, rSrcSize));
mpMetaFile->AddAction(new MetaBmpScaleAction(rDestPt, rDestSize, aBmp));
}
}
if ( !IsDeviceOutputNecessary() )
return;
if ( !mpGraphics && !AcquireGraphics() )
return;
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
if (rOutDev.mpAlphaVDev)
{
// alpha-blend source over destination
DrawBitmapEx(rDestPt, rDestSize, rOutDev.GetBitmapEx(rSrcPt, rSrcSize));
}
else
{
SalTwoRect aPosAry(rOutDev.ImplLogicXToDevicePixel(rSrcPt.X()),
rOutDev.ImplLogicYToDevicePixel(rSrcPt.Y()),
rOutDev.ImplLogicWidthToDevicePixel(rSrcSize.Width()),
rOutDev.ImplLogicHeightToDevicePixel(rSrcSize.Height()),
ImplLogicXToDevicePixel(rDestPt.X()),
ImplLogicYToDevicePixel(rDestPt.Y()),
ImplLogicWidthToDevicePixel(rDestSize.Width()),
ImplLogicHeightToDevicePixel(rDestSize.Height()));
drawOutDevDirect(&rOutDev, aPosAry);
// #i32109#: make destination rectangle opaque - source has no alpha
if (mpAlphaVDev)
mpAlphaVDev->ImplFillOpaqueRectangle(tools::Rectangle(rDestPt, rDestSize));
}
}
void OutputDevice::CopyArea( const Point& rDestPt,
const Point& rSrcPt, const Size& rSrcSize,
bool bWindowInvalidate )
{
if ( ImplIsRecordLayout() )
return;
RasterOp eOldRop = GetRasterOp();
SetRasterOp( RasterOp::OverPaint );
if ( !IsDeviceOutputNecessary() )
return;
if ( !mpGraphics && !AcquireGraphics() )
return;
if ( mbInitClipRegion )
InitClipRegion();
if ( mbOutputClipped )
return;
long nSrcWidth = ImplLogicWidthToDevicePixel( rSrcSize.Width() );
long nSrcHeight = ImplLogicHeightToDevicePixel( rSrcSize.Height() );
if (nSrcWidth && nSrcHeight)
{
SalTwoRect aPosAry(ImplLogicXToDevicePixel(rSrcPt.X()), ImplLogicYToDevicePixel(rSrcPt.Y()),
nSrcWidth, nSrcHeight,
ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
nSrcWidth, nSrcHeight);
const tools::Rectangle aSrcOutRect( Point( mnOutOffX, mnOutOffY ),
Size( mnOutWidth, mnOutHeight ) );
AdjustTwoRect( aPosAry, aSrcOutRect );
CopyDeviceArea( aPosAry, bWindowInvalidate );
}
SetRasterOp( eOldRop );
if( mpAlphaVDev )
mpAlphaVDev->CopyArea( rDestPt, rSrcPt, rSrcSize, bWindowInvalidate );
}
// Direct OutputDevice drawing protected function
void OutputDevice::CopyDeviceArea( SalTwoRect& aPosAry, bool /*bWindowInvalidate*/)
{
if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
return;
aPosAry.mnDestWidth = aPosAry.mnSrcWidth;
aPosAry.mnDestHeight = aPosAry.mnSrcHeight;
mpGraphics->CopyBits(aPosAry, nullptr, this, nullptr);
}
// Direct OutputDevice drawing private function
void OutputDevice::drawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& rPosAry )
{
SalGraphics* pSrcGraphics;
if (const OutputDevice* pCheckedSrc = DrawOutDevDirectCheck(pSrcDev))
{
if (!pCheckedSrc->mpGraphics && !pCheckedSrc->AcquireGraphics())
return;
pSrcGraphics = pCheckedSrc->mpGraphics;
}
else
pSrcGraphics = nullptr;
if (!mpGraphics && !AcquireGraphics())
return;
// #102532# Offset only has to be pseudo window offset
const tools::Rectangle aSrcOutRect( Point( pSrcDev->mnOutOffX, pSrcDev->mnOutOffY ),
Size( pSrcDev->mnOutWidth, pSrcDev->mnOutHeight ) );
AdjustTwoRect( rPosAry, aSrcOutRect );
if ( rPosAry.mnSrcWidth && rPosAry.mnSrcHeight && rPosAry.mnDestWidth && rPosAry.mnDestHeight )
{
// if this is no window, but pSrcDev is a window
// mirroring may be required
// because only windows have a SalGraphicsLayout
// mirroring is performed here
DrawOutDevDirectProcess( pSrcDev, rPosAry, pSrcGraphics);
}
}
const OutputDevice* OutputDevice::DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const
{
return this == pSrcDev ? nullptr : pSrcDev;
}
void OutputDevice::DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
{
if( pSrcGraphics && (pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) )
{
SalTwoRect aPosAry2 = rPosAry;
pSrcGraphics->mirror( aPosAry2.mnSrcX, aPosAry2.mnSrcWidth, pSrcDev );
mpGraphics->CopyBits( aPosAry2, pSrcGraphics, this, pSrcDev );
}
else
mpGraphics->CopyBits( rPosAry, pSrcGraphics, this, pSrcDev );
}
tools::Rectangle OutputDevice::GetBackgroundComponentBounds() const
{
return tools::Rectangle( Point( 0, 0 ), GetOutputSizePixel() );
}
// Layout public functions
void OutputDevice::EnableRTL( bool bEnable )
{
mbEnableRTL = bEnable;
if( mpAlphaVDev )
mpAlphaVDev->EnableRTL( bEnable );
}
bool OutputDevice::ImplIsAntiparallel() const
{
bool bRet = false;
if( AcquireGraphics() )
{
if( ( (mpGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) && ! IsRTLEnabled() ) ||
( ! (mpGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) && IsRTLEnabled() ) )
{
bRet = true;
}
}
return bRet;
}
// note: the coordinates to be remirrored are in frame coordinates !
void OutputDevice::ReMirror( Point &rPoint ) const
{
rPoint.setX( mnOutOffX + mnOutWidth - 1 - rPoint.X() + mnOutOffX );
}
void OutputDevice::ReMirror( tools::Rectangle &rRect ) const
{
long nWidth = rRect.Right() - rRect.Left();
//long lc_x = rRect.nLeft - mnOutOffX; // normalize
//lc_x = mnOutWidth - nWidth - 1 - lc_x; // mirror
//rRect.nLeft = lc_x + mnOutOffX; // re-normalize
rRect.SetLeft( mnOutOffX + mnOutWidth - nWidth - 1 - rRect.Left() + mnOutOffX );
rRect.SetRight( rRect.Left() + nWidth );
}
void OutputDevice::ReMirror( vcl::Region &rRegion ) const
{
RectangleVector aRectangles;
rRegion.GetRegionRectangles(aRectangles);
vcl::Region aMirroredRegion;
for (auto & rectangle : aRectangles)
{
ReMirror(rectangle);
aMirroredRegion.Union(rectangle);
}
rRegion = aMirroredRegion;
}
bool OutputDevice::HasMirroredGraphics() const
{
return ( AcquireGraphics() && (mpGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) );
}
bool OutputDevice::ImplIsRecordLayout() const
{
if (!mpOutDevData)
return false;
return mpOutDevData->mpRecordLayout;
}
// EPS public function
bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
const GfxLink& rGfxLink, GDIMetaFile* pSubst )
{
bool bDrawn(true);
if ( mpMetaFile )
{
GDIMetaFile aSubst;
if( pSubst )
aSubst = *pSubst;
mpMetaFile->AddAction( new MetaEPSAction( rPoint, rSize, rGfxLink, aSubst ) );
}
if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
return bDrawn;
if( mbOutputClipped )
return bDrawn;
tools::Rectangle aRect( ImplLogicToDevicePixel( tools::Rectangle( rPoint, rSize ) ) );
if( !aRect.IsEmpty() )
{
// draw the real EPS graphics
if( rGfxLink.GetData() && rGfxLink.GetDataSize() )
{
if( !mpGraphics && !AcquireGraphics() )
return bDrawn;
if( mbInitClipRegion )
InitClipRegion();
aRect.Justify();
bDrawn = mpGraphics->DrawEPS( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(),
const_cast<sal_uInt8*>(rGfxLink.GetData()), rGfxLink.GetDataSize(), this );
}
// else draw the substitution graphics
if( !bDrawn && pSubst )
{
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = nullptr;
Graphic( *pSubst ).Draw( this, rPoint, rSize );
mpMetaFile = pOldMetaFile;
}
}
if( mpAlphaVDev )
mpAlphaVDev->DrawEPS( rPoint, rSize, rGfxLink, pSubst );
return bDrawn;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|