LibreOffice Module vcl (master)  1
outdev.cxx
Go to the documentation of this file.
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 
20 #include <sal/config.h>
21 #include <sal/log.hxx>
22 
23 #include <tools/debug.hxx>
24 #include <vcl/gdimtf.hxx>
25 #include <vcl/graph.hxx>
26 #include <vcl/metaact.hxx>
27 #include <vcl/virdev.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/toolkit/unowrap.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/sysdata.hxx>
32 #include <vcl/lazydelete.hxx>
34 
36 #include <salgdi.hxx>
37 #include <window.h>
38 #include <outdev.h>
39 
40 #include <com/sun/star/awt/DeviceCapability.hpp>
41 #include <com/sun/star/awt/XWindow.hpp>
42 #include <com/sun/star/rendering/CanvasFactory.hpp>
43 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
44 
45 #ifdef DISABLE_DYNLOADING
46 // Linking all needed LO code into one .so/executable, these already
47 // exist in the tools library, so put them in the anonymous namespace
48 // here to avoid clash...
49 namespace {
50 #endif
51 #ifdef DISABLE_DYNLOADING
52 }
53 #endif
54 
55 using namespace ::com::sun::star::uno;
56 
57 // Begin initializer and accessor public functions
58 
60  meOutDevType(eOutDevType),
61  maRegion(true),
63  maTextLineColor( COL_TRANSPARENT ),
64  mxSettings( new AllSettings(Application::GetSettings()) )
65 {
66  mpGraphics = nullptr;
67  mpUnoGraphicsList = nullptr;
68  mpPrevGraphics = nullptr;
69  mpNextGraphics = nullptr;
70  mpMetaFile = nullptr;
71  mpFontInstance = nullptr;
72  mpFontFaceCollection = nullptr;
73  mpDeviceFontSizeList = nullptr;
74  mpAlphaVDev = nullptr;
75  mpExtOutDevData = nullptr;
76  mnOutOffX = 0;
77  mnOutOffY = 0;
78  mnOutWidth = 0;
79  mnOutHeight = 0;
80  mnDPIX = 0;
81  mnDPIY = 0;
83  mnTextOffX = 0;
84  mnTextOffY = 0;
85  mnOutOffOrigX = 0;
86  mnOutOffLogicX = 0;
87  mnOutOffOrigY = 0;
88  mnOutOffLogicY = 0;
89  mnEmphasisAscent = 0;
93 
94  if( AllSettings::GetLayoutRTL() ) //#i84553# tip BiDi preference to RTL
96 
98  mbMap = false;
99  mbClipRegion = false;
100  mbBackground = false;
101  mbOutput = true;
102  mbDevOutput = false;
103  mbOutputClipped = false;
108  meTextLanguage = LANGUAGE_SYSTEM; // TODO: get default from configuration?
109  mbLineColor = true;
110  mbFillColor = true;
111  mbInitLineColor = true;
112  mbInitFillColor = true;
113  mbInitFont = true;
114  mbInitTextColor = true;
115  mbInitClipRegion = true;
116  mbClipRegionSet = false;
117  mbNewFont = true;
118  mbTextLines = false;
119  mbTextSpecial = false;
120  mbRefPoint = false;
121  mbEnableRTL = false; // mirroring must be explicitly allowed (typically for windows only)
122 
123  // struct ImplMapRes
124  maMapRes.mnMapOfsX = 0;
125  maMapRes.mnMapOfsY = 0;
126  maMapRes.mnMapScNumX = 1;
127  maMapRes.mnMapScNumY = 1;
130 
131  // struct ImplOutDevData- see #i82615#
132  mpOutDevData.reset(new ImplOutDevData);
133  mpOutDevData->mpRotateDev = nullptr;
134  mpOutDevData->mpRecordLayout = nullptr;
135 
136  // #i75163#
137  mpOutDevData->mpViewTransform = nullptr;
138  mpOutDevData->mpInverseViewTransform = nullptr;
139 }
140 
142 {
143  disposeOnce();
144 }
145 
147 {
148  if ( GetUnoGraphicsList() )
149  {
150  UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper( false );
151  if ( pWrapper )
152  pWrapper->ReleaseAllGraphics( this );
153  delete mpUnoGraphicsList;
154  mpUnoGraphicsList = nullptr;
155  }
156 
157  mpOutDevData->mpRotateDev.disposeAndClear();
158 
159  // #i75163#
161 
162  mpOutDevData.reset();
163 
164  // for some reason, we haven't removed state from the stack properly
165  if ( !maOutDevStateStack.empty() )
166  SAL_WARN( "vcl.gdi", "OutputDevice::~OutputDevice(): OutputDevice::Push() calls != OutputDevice::Pop() calls" );
167  maOutDevStateStack.clear();
168 
169  // release the active font instance
170  mpFontInstance.clear();
171 
172  // remove cached results of GetDevFontList/GetDevSizeList
173  mpFontFaceCollection.reset();
174  mpDeviceFontSizeList.reset();
175 
176  // release ImplFontCache specific to this OutputDevice
177  mxFontCache.reset();
178 
179  // release ImplFontList specific to this OutputDevice
180  mxFontCollection.reset();
181 
186 }
187 
189 {
190  return false;
191 }
192 
194 {
196 
197  if (!mpGraphics && !AcquireGraphics())
198  SAL_WARN("vcl.gdi", "No mpGraphics set");
199 
200  return mpGraphics;
201 }
202 
204 {
206 
207  if (!mpGraphics && !AcquireGraphics())
208  SAL_WARN("vcl.gdi", "No mpGraphics set");
209 
210  return mpGraphics;
211 }
212 
214 {
215  mpMetaFile = pMtf;
216 }
217 
218 void OutputDevice::SetSettings( const AllSettings& rSettings )
219 {
220  *mxSettings = rSettings;
221 
222  if( mpAlphaVDev )
223  mpAlphaVDev->SetSettings( rSettings );
224 }
225 
227 {
228  if (!mpGraphics && !AcquireGraphics())
229  return SystemGraphicsData();
230  assert(mpGraphics);
231 
232  return mpGraphics->GetGraphicsData();
233 }
234 
235 #if ENABLE_CAIRO_CANVAS
236 
237 bool OutputDevice::SupportsCairo() const
238 {
239  if (!mpGraphics && !AcquireGraphics())
240  return false;
241  assert(mpGraphics);
242 
243  return mpGraphics->SupportsCairo();
244 }
245 
247 {
248  if (!mpGraphics && !AcquireGraphics())
249  return cairo::SurfaceSharedPtr();
250  assert(mpGraphics);
251  return mpGraphics->CreateSurface(rSurface);
252 }
253 
254 cairo::SurfaceSharedPtr OutputDevice::CreateSurface(int x, int y, int width, int height) const
255 {
256  if (!mpGraphics && !AcquireGraphics())
257  return cairo::SurfaceSharedPtr();
258  assert(mpGraphics);
259  return mpGraphics->CreateSurface(*this, x, y, width, height);
260 }
261 
263 {
264  if (!mpGraphics && !AcquireGraphics())
265  return cairo::SurfaceSharedPtr();
266  assert(mpGraphics);
267  return mpGraphics->CreateBitmapSurface(*this, rData, rSize);
268 }
269 
270 css::uno::Any OutputDevice::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const
271 {
272  if (!mpGraphics && !AcquireGraphics())
273  return css::uno::Any();
274  assert(mpGraphics);
275  return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize);
276 }
277 
278 #endif // ENABLE_CAIRO_CANVAS
279 
281 {
282  const SystemGraphicsData aSysData = GetSystemGfxData();
283  css::uno::Sequence< sal_Int8 > aSeq( reinterpret_cast<sal_Int8 const *>(&aSysData),
284  aSysData.nSize );
285 
286  return css::uno::makeAny(aSeq);
287 }
288 
290 {
291  if ( mpMetaFile )
292  mpMetaFile->AddAction( new MetaRefPointAction( Point(), false ) );
293 
294  mbRefPoint = false;
295  maRefPoint.setX(0);
296  maRefPoint.setY(0);
297 
298  if( mpAlphaVDev )
300 }
301 
302 void OutputDevice::SetRefPoint( const Point& rRefPoint )
303 {
304  if ( mpMetaFile )
305  mpMetaFile->AddAction( new MetaRefPointAction( rRefPoint, true ) );
306 
307  mbRefPoint = true;
308  maRefPoint = rRefPoint;
309 
310  if( mpAlphaVDev )
311  mpAlphaVDev->SetRefPoint( rRefPoint );
312 }
313 
315 {
316  if ( mpMetaFile )
317  mpMetaFile->AddAction( new MetaRasterOpAction( eRasterOp ) );
318 
319  if ( meRasterOp != eRasterOp )
320  {
321  meRasterOp = eRasterOp;
323 
324  if( mpGraphics || AcquireGraphics() )
325  {
326  assert(mpGraphics);
328  }
329  }
330 
331  if( mpAlphaVDev )
332  mpAlphaVDev->SetRasterOp( eRasterOp );
333 }
334 
335 void OutputDevice::EnableOutput( bool bEnable )
336 {
337  mbOutput = bEnable;
338 
339  if( mpAlphaVDev )
340  mpAlphaVDev->EnableOutput( bEnable );
341 }
342 
344 {
345  if ( mnAntialiasing != nMode )
346  {
347  mnAntialiasing = nMode;
348  mbInitFont = true;
349 
350  if(mpGraphics)
351  {
353  }
354  }
355 
356  if( mpAlphaVDev )
357  mpAlphaVDev->SetAntialiasing( nMode );
358 }
359 
361 {
362  mnDrawMode = nDrawMode;
363 
364  if (mpAlphaVDev)
365  mpAlphaVDev->SetDrawMode(nDrawMode);
366 }
367 
368 sal_uInt16 OutputDevice::GetBitCount() const
369 {
370  // we need a graphics instance
371  if ( !mpGraphics && !AcquireGraphics() )
372  return 0;
373  assert(mpGraphics);
374 
375  return mpGraphics->GetBitCount();
376 }
377 
379 {
380  mnOutOffX = nOutOffX;
381 }
382 
384 {
385  mnOutOffY = nOutOffY;
386 }
387 
388 css::uno::Reference< css::awt::XGraphics > OutputDevice::CreateUnoGraphics()
389 {
391  return pWrapper ? pWrapper->CreateGraphics( this ) : css::uno::Reference< css::awt::XGraphics >();
392 }
393 
394 std::vector< VCLXGraphics* > *OutputDevice::CreateUnoGraphicsList()
395 {
396  mpUnoGraphicsList = new std::vector< VCLXGraphics* >;
397  return mpUnoGraphicsList;
398 }
399 
400 // Helper public function
401 
403 {
404  if( !mpGraphics && !AcquireGraphics() )
405  return false;
406  assert(mpGraphics);
407  const bool bHasSupport = mpGraphics->supportsOperation( eType );
408  return bHasSupport;
409 }
410 
411 // Direct OutputDevice drawing public functions
412 
413 void OutputDevice::DrawOutDev( const Point& rDestPt, const Size& rDestSize,
414  const Point& rSrcPt, const Size& rSrcSize )
415 {
416  if( ImplIsRecordLayout() )
417  return;
418 
419  if ( RasterOp::Invert == meRasterOp )
420  {
421  DrawRect( tools::Rectangle( rDestPt, rDestSize ) );
422  return;
423  }
424 
425  if ( mpMetaFile )
426  {
427  const Bitmap aBmp( GetBitmap( rSrcPt, rSrcSize ) );
428  mpMetaFile->AddAction( new MetaBmpScaleAction( rDestPt, rDestSize, aBmp ) );
429  }
430 
431  if ( !IsDeviceOutputNecessary() )
432  return;
433 
434  if ( !mpGraphics && !AcquireGraphics() )
435  return;
436  assert(mpGraphics);
437 
438  if ( mbInitClipRegion )
439  InitClipRegion();
440 
441  if ( mbOutputClipped )
442  return;
443 
444  tools::Long nSrcWidth = ImplLogicWidthToDevicePixel( rSrcSize.Width() );
445  tools::Long nSrcHeight = ImplLogicHeightToDevicePixel( rSrcSize.Height() );
446  tools::Long nDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() );
447  tools::Long nDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() );
448 
449  if (nSrcWidth && nSrcHeight && nDestWidth && nDestHeight)
450  {
451  SalTwoRect aPosAry(ImplLogicXToDevicePixel(rSrcPt.X()), ImplLogicYToDevicePixel(rSrcPt.Y()),
452  nSrcWidth, nSrcHeight,
453  ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
454  nDestWidth, nDestHeight);
455 
456  AdjustTwoRect( aPosAry, GetOutputRectPixel() );
457 
458  if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
459  mpGraphics->CopyBits(aPosAry, *this);
460  }
461 
462  if( mpAlphaVDev )
463  mpAlphaVDev->DrawOutDev( rDestPt, rDestSize, rSrcPt, rSrcSize );
464 }
465 
466 void OutputDevice::DrawOutDev( const Point& rDestPt, const Size& rDestSize,
467  const Point& rSrcPt, const Size& rSrcSize,
468  const OutputDevice& rOutDev )
469 {
470  if ( ImplIsRecordLayout() )
471  return;
472 
473  if ( RasterOp::Invert == meRasterOp )
474  {
475  DrawRect( tools::Rectangle( rDestPt, rDestSize ) );
476  return;
477  }
478 
479  if ( mpMetaFile )
480  {
481  if (rOutDev.mpAlphaVDev)
482  {
483  const BitmapEx aBmpEx(rOutDev.GetBitmapEx(rSrcPt, rSrcSize));
484  mpMetaFile->AddAction(new MetaBmpExScaleAction(rDestPt, rDestSize, aBmpEx));
485  }
486  else
487  {
488  const Bitmap aBmp(rOutDev.GetBitmap(rSrcPt, rSrcSize));
489  mpMetaFile->AddAction(new MetaBmpScaleAction(rDestPt, rDestSize, aBmp));
490  }
491  }
492 
493  if ( !IsDeviceOutputNecessary() )
494  return;
495 
496  if ( !mpGraphics && !AcquireGraphics() )
497  return;
498  assert(mpGraphics);
499 
500  if ( mbInitClipRegion )
501  InitClipRegion();
502 
503  if ( mbOutputClipped )
504  return;
505 
506  if (rOutDev.mpAlphaVDev)
507  {
508  // alpha-blend source over destination
509  DrawBitmapEx(rDestPt, rDestSize, rOutDev.GetBitmapEx(rSrcPt, rSrcSize));
510  }
511  else
512  {
513  SalTwoRect aPosAry(rOutDev.ImplLogicXToDevicePixel(rSrcPt.X()),
514  rOutDev.ImplLogicYToDevicePixel(rSrcPt.Y()),
515  rOutDev.ImplLogicWidthToDevicePixel(rSrcSize.Width()),
516  rOutDev.ImplLogicHeightToDevicePixel(rSrcSize.Height()),
517  ImplLogicXToDevicePixel(rDestPt.X()),
518  ImplLogicYToDevicePixel(rDestPt.Y()),
519  ImplLogicWidthToDevicePixel(rDestSize.Width()),
520  ImplLogicHeightToDevicePixel(rDestSize.Height()));
521 
522  drawOutDevDirect(rOutDev, aPosAry);
523 
524  // #i32109#: make destination rectangle opaque - source has no alpha
525  if (mpAlphaVDev)
527  }
528 }
529 
530 void OutputDevice::CopyArea( const Point& rDestPt,
531  const Point& rSrcPt, const Size& rSrcSize,
532  bool bWindowInvalidate )
533 {
534  if ( ImplIsRecordLayout() )
535  return;
536 
537  RasterOp eOldRop = GetRasterOp();
539 
540  if ( !IsDeviceOutputNecessary() )
541  return;
542 
543  if ( !mpGraphics && !AcquireGraphics() )
544  return;
545  assert(mpGraphics);
546 
547  if ( mbInitClipRegion )
548  InitClipRegion();
549 
550  if ( mbOutputClipped )
551  return;
552 
553  tools::Long nSrcWidth = ImplLogicWidthToDevicePixel( rSrcSize.Width() );
554  tools::Long nSrcHeight = ImplLogicHeightToDevicePixel( rSrcSize.Height() );
555  if (nSrcWidth && nSrcHeight)
556  {
557  SalTwoRect aPosAry(ImplLogicXToDevicePixel(rSrcPt.X()), ImplLogicYToDevicePixel(rSrcPt.Y()),
558  nSrcWidth, nSrcHeight,
559  ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
560  nSrcWidth, nSrcHeight);
561 
562  AdjustTwoRect( aPosAry, GetOutputRectPixel() );
563 
564  CopyDeviceArea( aPosAry, bWindowInvalidate );
565  }
566 
567  SetRasterOp( eOldRop );
568 
569  if( mpAlphaVDev )
570  mpAlphaVDev->CopyArea( rDestPt, rSrcPt, rSrcSize, bWindowInvalidate );
571 }
572 
573 // Direct OutputDevice drawing protected function
574 
575 void OutputDevice::CopyDeviceArea( SalTwoRect& aPosAry, bool /*bWindowInvalidate*/)
576 {
577  if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
578  return;
579 
580  aPosAry.mnDestWidth = aPosAry.mnSrcWidth;
581  aPosAry.mnDestHeight = aPosAry.mnSrcHeight;
582  mpGraphics->CopyBits(aPosAry, *this);
583 }
584 
585 // Direct OutputDevice drawing private function
587 {
588  SalGraphics* pSrcGraphics;
589  if (const OutputDevice* pCheckedSrc = DrawOutDevDirectCheck(rSrcDev))
590  {
591  if (!pCheckedSrc->mpGraphics && !pCheckedSrc->AcquireGraphics())
592  return;
593  pSrcGraphics = pCheckedSrc->mpGraphics;
594  }
595  else
596  pSrcGraphics = nullptr;
597 
598  if (!mpGraphics && !AcquireGraphics())
599  return;
600  assert(mpGraphics);
601 
602  // #102532# Offset only has to be pseudo window offset
603 
604  AdjustTwoRect( rPosAry, rSrcDev.GetOutputRectPixel() );
605 
606  if ( rPosAry.mnSrcWidth && rPosAry.mnSrcHeight && rPosAry.mnDestWidth && rPosAry.mnDestHeight )
607  {
608  // if this is no window, but rSrcDev is a window
609  // mirroring may be required
610  // because only windows have a SalGraphicsLayout
611  // mirroring is performed here
612  DrawOutDevDirectProcess(rSrcDev, rPosAry, pSrcGraphics);
613  }
614 }
615 
617 {
618  return this == &rSrcDev ? nullptr : &rSrcDev;
619 }
620 
621 void OutputDevice::DrawOutDevDirectProcess(const OutputDevice& rSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics)
622 {
623  if( pSrcGraphics && (pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) )
624  {
625  SalTwoRect aPosAry2 = rPosAry;
626  pSrcGraphics->mirror( aPosAry2.mnSrcX, aPosAry2.mnSrcWidth, rSrcDev );
627  mpGraphics->CopyBits( aPosAry2, *pSrcGraphics, *this, rSrcDev );
628  return;
629  }
630  if (pSrcGraphics)
631  mpGraphics->CopyBits( rPosAry, *pSrcGraphics, *this, rSrcDev );
632  else
633  mpGraphics->CopyBits( rPosAry, *this );
634 }
635 
637 {
638  return tools::Rectangle( Point( 0, 0 ), GetOutputSizePixel() );
639 }
640 
641 // Layout public functions
642 
643 void OutputDevice::EnableRTL( bool bEnable )
644 {
645  mbEnableRTL = bEnable;
646 
647  if( mpAlphaVDev )
648  mpAlphaVDev->EnableRTL( bEnable );
649 }
650 
652 {
653  bool bRet = false;
654  if( AcquireGraphics() )
655  {
658  {
659  bRet = true;
660  }
661  }
662  return bRet;
663 }
664 
665 // note: the coordinates to be remirrored are in frame coordinates !
666 
667 void OutputDevice::ReMirror( Point &rPoint ) const
668 {
669  rPoint.setX( mnOutOffX + mnOutWidth - 1 - rPoint.X() + mnOutOffX );
670 }
672 {
673  tools::Long nWidth = rRect.Right() - rRect.Left();
674 
675  //long lc_x = rRect.nLeft - mnOutOffX; // normalize
676  //lc_x = mnOutWidth - nWidth - 1 - lc_x; // mirror
677  //rRect.nLeft = lc_x + mnOutOffX; // re-normalize
678 
679  rRect.SetLeft( mnOutOffX + mnOutWidth - nWidth - 1 - rRect.Left() + mnOutOffX );
680  rRect.SetRight( rRect.Left() + nWidth );
681 }
682 
683 void OutputDevice::ReMirror( vcl::Region &rRegion ) const
684 {
685  RectangleVector aRectangles;
686  rRegion.GetRegionRectangles(aRectangles);
687  vcl::Region aMirroredRegion;
688 
689  for (auto & rectangle : aRectangles)
690  {
692  aMirroredRegion.Union(rectangle);
693  }
694 
695  rRegion = aMirroredRegion;
696 
697 }
698 
700 {
702 }
703 
705 {
706  if (!mpOutDevData)
707  return false;
708 
709  return mpOutDevData->mpRecordLayout;
710 }
711 
712 // EPS public function
713 
714 bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
715  const GfxLink& rGfxLink, GDIMetaFile* pSubst )
716 {
717  bool bDrawn(true);
718 
719  if ( mpMetaFile )
720  {
721  GDIMetaFile aSubst;
722 
723  if( pSubst )
724  aSubst = *pSubst;
725 
726  mpMetaFile->AddAction( new MetaEPSAction( rPoint, rSize, rGfxLink, aSubst ) );
727  }
728 
730  return bDrawn;
731 
732  if( mbOutputClipped )
733  return bDrawn;
734 
735  tools::Rectangle aRect( ImplLogicToDevicePixel( tools::Rectangle( rPoint, rSize ) ) );
736 
737  if( !aRect.IsEmpty() )
738  {
739  // draw the real EPS graphics
740  if( rGfxLink.GetData() && rGfxLink.GetDataSize() )
741  {
742  if( !mpGraphics && !AcquireGraphics() )
743  return bDrawn;
744  assert(mpGraphics);
745 
746  if( mbInitClipRegion )
747  InitClipRegion();
748 
749  aRect.Justify();
750  bDrawn = mpGraphics->DrawEPS( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(),
751  const_cast<sal_uInt8*>(rGfxLink.GetData()), rGfxLink.GetDataSize(), *this );
752  }
753 
754  // else draw the substitution graphics
755  if( !bDrawn && pSubst )
756  {
757  GDIMetaFile* pOldMetaFile = mpMetaFile;
758 
759  mpMetaFile = nullptr;
760  Graphic(*pSubst).Draw(*this, rPoint, rSize);
761  mpMetaFile = pOldMetaFile;
762  }
763  }
764 
765  if( mpAlphaVDev )
766  mpAlphaVDev->DrawEPS( rPoint, rSize, rGfxLink, pSubst );
767 
768  return bDrawn;
769 }
770 
771 css::awt::DeviceInfo OutputDevice::GetCommonDeviceInfo(Size const& rDevSz) const
772 {
773  css::awt::DeviceInfo aInfo;
774 
775  aInfo.Width = rDevSz.Width();
776  aInfo.Height = rDevSz.Height();
777 
778  Size aTmpSz = LogicToPixel(Size(1000, 1000), MapMode(MapUnit::MapCM));
779  aInfo.PixelPerMeterX = aTmpSz.Width() / 10;
780  aInfo.PixelPerMeterY = aTmpSz.Height() / 10;
781  aInfo.BitsPerPixel = GetBitCount();
782 
783  aInfo.Capabilities = css::awt::DeviceCapability::RASTEROPERATIONS |
784  css::awt::DeviceCapability::GETBITS;
785 
786  return aInfo;
787 }
788 
789 css::awt::DeviceInfo OutputDevice::GetDeviceInfo() const
790 {
791  css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(GetOutputSizePixel());
792 
793  aInfo.LeftInset = 0;
794  aInfo.TopInset = 0;
795  aInfo.RightInset = 0;
796  aInfo.BottomInset = 0;
797 
798  return aInfo;
799 }
800 
801 Reference< css::rendering::XCanvas > OutputDevice::GetCanvas() const
802 {
803  // try to retrieve hard reference from weak member
804  Reference< css::rendering::XCanvas > xCanvas( mxCanvas );
805  // canvas still valid? Then we're done.
806  if( xCanvas.is() )
807  return xCanvas;
808  xCanvas = ImplGetCanvas( false );
809  mxCanvas = xCanvas;
810  return xCanvas;
811 }
812 
813 Reference< css::rendering::XSpriteCanvas > OutputDevice::GetSpriteCanvas() const
814 {
815  Reference< css::rendering::XCanvas > xCanvas( mxCanvas );
816  Reference< css::rendering::XSpriteCanvas > xSpriteCanvas( xCanvas, UNO_QUERY );
817  if( xSpriteCanvas.is() )
818  return xSpriteCanvas;
819  xCanvas = ImplGetCanvas( true );
820  mxCanvas = xCanvas;
821  return Reference< css::rendering::XSpriteCanvas >( xCanvas, UNO_QUERY );
822 }
823 
824 // Generic implementation, Window will override.
826 {
827  /* Arguments:
828  0: ptr to creating instance (Window or VirtualDevice)
829  1: current bounds of creating instance
830  2: bool, denoting always on top state for Window (always false for VirtualDevice)
831  3: XWindow for creating Window (or empty for VirtualDevice)
832  4: SystemGraphicsData as a streamed Any
833  */
834  Sequence< Any > aArg(5);
835  aArg[ 0 ] <<= reinterpret_cast<sal_Int64>(this);
836  aArg[ 1 ] <<= css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
837  aArg[ 2 ] <<= false;
838  aArg[ 3 ] <<= Reference< css::awt::XWindow >();
839  aArg[ 4 ] = GetSystemGfxDataAny();
840 
842 
844  css::rendering::CanvasFactory::create( xContext ) );
845  Reference<css::lang::XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
846  Reference< css::rendering::XCanvas > xCanvas;
847 
848  if(xCanvasFactory.is())
849  {
850  xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
851  bSpriteCanvas ?
852  OUString( "com.sun.star.rendering.SpriteCanvas" ) :
853  OUString( "com.sun.star.rendering.Canvas" ),
854  aArg,
855  xContext ),
856  UNO_QUERY );
857  }
858 
859  // no factory??? Empty reference, then.
860  return xCanvas;
861 }
862 
864 {
865  css::uno::Reference< css::rendering::XCanvas > xCanvas( mxCanvas );
866  if( xCanvas.is() )
867  {
868  css::uno::Reference< css::lang::XComponent > xCanvasComponent( xCanvas, css::uno::UNO_QUERY );
869  if( xCanvasComponent.is() )
870  xCanvasComponent->dispose();
871  }
872 }
873 
874 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
void EnableOutput(bool bEnable=true)
Definition: outdev.cxx:335
sal_Int32 mnDPIScalePercentage
For HiDPI displays, we want to draw elements for a percentage larger.
Definition: outdev.hxx:214
Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit template class makes sure that a static UNO...
Definition: lazydelete.hxx:112
VclPtr< OutputDevice > mpNextGraphics
Next output device in list.
Definition: outdev.hxx:183
virtual css::uno::Reference< css::rendering::XCanvas > ImplGetCanvas(bool bSpriteCanvas) const
Definition: outdev.cxx:825
tools::Long mnTextOffX
font specific text alignment offsets in pixel units
Definition: outdev.hxx:216
tools::Long mnOutOffLogicX
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:201
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:704
void SetAntialiasing(AntialiasingFlags nMode)
Definition: outdev.cxx:343
tools::Long mnOutOffOrigY
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:203
AntialiasingFlags
OutputDevice(const OutputDevice &)=delete
bool mbOutput
Definition: outdev.hxx:243
virtual bool IsVirtual() const
Definition: outdev.cxx:188
Color maTextColor
Definition: outdev.hxx:229
bool SupportsCairo() const
virtual ~OutputDevice() override
Definition: outdev.cxx:141
constexpr tools::Long Left() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: bitmapex.cxx:33
virtual bool supportsOperation(OutDevSupportType) const =0
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:505
bool mbTextSpecial
Definition: outdev.hxx:256
DrawModeFlags mnDrawMode
Definition: outdev.hxx:220
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
void disposeAndClear()
Definition: vclptr.hxx:200
BmpMirrorFlags AdjustTwoRect(SalTwoRect &rTwoRect, const Size &rSizePix)
Definition: rect.cxx:341
css::uno::Reference< I > get()
Definition: lazydelete.hxx:120
SAL_DLLPRIVATE void ImplDisposeCanvas()
Definition: outdev.cxx:863
bool mbOutputClipped
Definition: outdev.hxx:245
void CopyBits(const SalTwoRect &rPosAry, const OutputDevice &rOutDev)
tools::Long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:209
cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr &rSurface) const
Create Surface from given cairo surface.
std::shared_ptr< PhysicalFontCollection > mxFontCollection
Definition: outdev.hxx:261
sal_Int32 mnDPIY
Definition: outdev.hxx:213
tools::Long mnSrcHeight
Definition: salgtype.hxx:43
std::vector< VCLXGraphics * > * mpUnoGraphicsList
Definition: outdev.hxx:190
void Draw(OutputDevice &rOutDev, const Point &rDestPt) const
Definition: graph.cxx:428
std::unique_ptr< ImplDeviceFontSizeList > mpDeviceFontSizeList
Definition: outdev.hxx:187
tools::Long mnSrcWidth
Definition: salgtype.hxx:42
cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData &rData, const Size &rSize) const
Create Surface for given bitmap data.
sal_Int32 mnDPIX
Definition: outdev.hxx:212
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:218
bool SupportsOperation(OutDevSupportType) const
Query an OutputDevice to see whether it supports a specific operation.
Definition: outdev.cxx:402
bool mbMap
Definition: outdev.hxx:240
std::vector< VCLXGraphics * > * CreateUnoGraphicsList()
Definition: outdev.cxx:394
virtual void DrawOutDevDirectProcess(const OutputDevice &rSrcDev, SalTwoRect &rPosAry, SalGraphics *pSrcGraphics)
Definition: outdev.cxx:621
tools::Long mnMapScDenomX
Scaling factor - denominator in X direction.
Definition: ImplMapRes.hxx:32
bool mbEnableRTL
Definition: outdev.hxx:258
tools::Long mnEmphasisDescent
Definition: outdev.hxx:219
tools::Long mnOutOffOrigX
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:199
OutDevSupportType
Definition: vclenum.hxx:194
bool DrawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, void *pPtr, sal_uInt32 nSize, const OutputDevice &rOutDev)
tools::Long mnDestWidth
Definition: salgtype.hxx:46
std::vector< tools::Rectangle > RectangleVector
Definition: region.hxx:34
void SetDrawMode(DrawModeFlags nDrawMode)
Definition: outdev.cxx:360
std::unique_ptr< vcl::font::PhysicalFontFaceCollection > mpFontFaceCollection
Definition: outdev.hxx:186
constexpr tools::Long Width() const
Color maOverlineColor
Definition: outdev.hxx:231
void SetOutOffYPixel(tools::Long nOutOffY)
Definition: outdev.cxx:383
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:667
virtual void ReleaseAllGraphics(OutputDevice *pOutDev)=0
SAL_DLLPRIVATE tools::Long ImplLogicXToDevicePixel(tools::Long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
Definition: map.cxx:304
sal_uInt32 nSize
Definition: sysdata.hxx:143
OutDevViewType meOutDevViewType
Definition: outdev.hxx:224
AntialiasingFlags mnAntialiasing
Definition: outdev.hxx:237
bool mbBackground
Definition: outdev.hxx:242
virtual Bitmap GetBitmap(const Point &rSrcPt, const Size &rSize) const
constexpr tools::Long GetWidth() const
tools::Long mnMapScDenomY
Scaling factor - denominator in Y direction.
Definition: ImplMapRes.hxx:33
virtual void EnableRTL(bool bEnable=true)
Definition: outdev.cxx:643
bool mbClipRegionSet
Definition: outdev.hxx:253
SystemGraphicsData GetSystemGfxData() const
Definition: outdev.cxx:226
virtual void CopyDeviceArea(SalTwoRect &aPosAry, bool bWindowInvalidate)
Definition: outdev.cxx:575
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
std::unique_ptr< AllSettings > mxSettings
Definition: outdev.hxx:234
constexpr bool IsEmpty() const
constexpr void SetLeft(tools::Long v)
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:181
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
std::vector< OutDevState > maOutDevStateStack
Definition: outdev.hxx:188
virtual void CopyArea(const Point &rDestPt, const Point &rSrcPt, const Size &rSrcSize, bool bWindowInvalidate=false)
Definition: outdev.cxx:530
SAL_DLLPRIVATE void ImplInvalidateViewTransform()
Invalidate the view transformation.
Definition: map.cxx:224
tools::Long mnDestHeight
Definition: salgtype.hxx:47
void SetRefPoint()
Definition: outdev.cxx:289
void clear()
Definition: vclptr.hxx:190
void SetConnectMetaFile(GDIMetaFile *pMtf)
Definition: outdev.cxx:213
bool IsRTLEnabled() const
Definition: outdev.hxx:1244
virtual tools::Rectangle GetBackgroundComponentBounds() const
Definition: outdev.cxx:636
css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr &rSurface, const basegfx::B2ISize &rSize) const
Return native handle for underlying surface.
OutDevType
Definition: outdev.hxx:142
virtual void dispose() override
Definition: outdev.cxx:146
#define LANGUAGE_SYSTEM
virtual const OutputDevice * DrawOutDevDirectCheck(const OutputDevice &rSrcDev) const
Definition: outdev.cxx:616
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
virtual void EnableRTL(bool bEnable=true) override
Definition: virdev.cxx:389
SAL_DLLPRIVATE bool ImplIsAntiparallel() const
Definition: outdev.cxx:651
virtual bool HasMirroredGraphics() const
Definition: outdev.cxx:699
bool mbInitLineColor
Definition: outdev.hxx:248
constexpr tools::Long Right() const
tools::Long mnOutHeight
Definition: outdev.hxx:211
bool mbNewFont
Definition: outdev.hxx:254
SAL_DLLPRIVATE void drawOutDevDirect(const OutputDevice &rSrcDev, SalTwoRect &rPosAry)
Definition: outdev.cxx:586
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:322
SAL_DLLPRIVATE void ImplFillOpaqueRectangle(const tools::Rectangle &rRect)
Used for alpha VDev, to set areas to opaque.
Definition: virdev.cxx:340
bool mbTextLines
Definition: outdev.hxx:255
static bool GetLayoutRTL()
css::uno::WeakReference< css::rendering::XCanvas > mxCanvas
Definition: outdev.hxx:193
constexpr tools::Long Top() const
bool mbLineColor
Definition: outdev.hxx:246
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
constexpr void SetRight(tools::Long v)
tools::Long mnMapOfsX
Offset in X direction.
Definition: ImplMapRes.hxx:28
RasterOp meRasterOp
Definition: outdev.hxx:232
css::uno::Reference< css::rendering::XCanvas > GetCanvas() const
request XCanvas render interface
Definition: outdev.cxx:801
Size GetOutputSizePixel() const
Definition: outdev.hxx:311
bool mbInitTextColor
Definition: outdev.hxx:251
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:233
css::uno::Any GetSystemGfxDataAny() const
Definition: outdev.cxx:280
virtual SystemGraphicsData GetGraphicsData() const =0
void mirror(tools::Long &nX, const OutputDevice &rOutDev) const
virtual sal_uInt16 GetBitCount() const
Definition: outdev.cxx:368
RasterOp
Definition: RasterOp.hxx:22
tools::Long mnMapOfsY
Offset in Y direction.
Definition: ImplMapRes.hxx:29
tools::Long mnEmphasisAscent
Definition: outdev.hxx:218
tools::Long mnSrcX
Definition: salgtype.hxx:40
bool mbRefPoint
Definition: outdev.hxx:257
virtual void dispose()
std::vector< VCLXGraphics * > * GetUnoGraphicsList() const
Definition: outdev.hxx:329
virtual css::uno::Reference< css::awt::XGraphics > CreateGraphics(OutputDevice *pOutDev)=0
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:876
uno::Sequence< double > maFillColor
virtual void SetXORMode(bool bSet, bool bInvertOnly)=0
VclPtr< OutputDevice > mpPrevGraphics
Previous output device in list.
Definition: outdev.hxx:182
virtual sal_uInt16 GetBitCount() const =0
void setAntiAlias(bool bNew)
Definition: salgdi.hxx:83
bool mbFillColor
Definition: outdev.hxx:247
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:196
def rectangle(l)
ImplMapRes maMapRes
Definition: outdev.hxx:222
bool mbClipRegion
Definition: outdev.hxx:241
tools::Long mnMapScNumY
Scaling factor - numerator in Y direction.
Definition: ImplMapRes.hxx:31
css::awt::DeviceInfo GetCommonDeviceInfo(Size const &aDevSize) const
Definition: outdev.cxx:771
constexpr tools::Long Height() const
unsigned char sal_uInt8
SalLayoutFlags GetLayout() const
Definition: salgdi.hxx:210
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:562
tools::Rectangle GetOutputRectPixel() const
Definition: outdev.hxx:321
tools::Long mnMapScNumX
Scaling factor - numerator in X direction.
Definition: ImplMapRes.hxx:30
bool mbInitClipRegion
Definition: outdev.hxx:252
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
void GetRegionRectangles(RectangleVector &rTarget) const
Definition: region.cxx:1662
void SetRasterOp(RasterOp eRasterOp)
Definition: outdev.cxx:314
void SetOutOffXPixel(tools::Long nOutOffX)
Definition: outdev.cxx:378
bool DrawEPS(const Point &rPt, const Size &rSz, const GfxLink &rGfxLink, GDIMetaFile *pSubst=nullptr)
Definition: outdev.cxx:714
SalGraphics const * GetGraphics() const
Get the graphic context that the output device uses to draw on.
Definition: outdev.cxx:203
css::uno::Reference< css::awt::XGraphics > CreateUnoGraphics()
Definition: outdev.cxx:388
virtual void InitClipRegion()
Reference< XComponentContext > getProcessComponentContext()
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
Sequence< sal_Int8 > aSeq
bool mbInitFont
Definition: outdev.hxx:250
RasterOp GetRasterOp() const
Definition: outdev.hxx:493
virtual void DrawOutDev(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPt, const Size &rSrcSize)
Definition: outdev.cxx:413
rtl::Reference< LogicalFontInstance > mpFontInstance
Definition: outdev.hxx:185
bool mbInitFillColor
Definition: outdev.hxx:249
tools::Long mnOutWidth
Definition: outdev.hxx:210
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:384
ComplexTextLayoutFlags mnTextLayoutMode
Definition: outdev.hxx:221
bool mbDevOutput
Definition: outdev.hxx:244
BitmapEx GetBitmapEx(const Point &rSrcPt, const Size &rSize) const
Query extended bitmap (with alpha channel, if available).
Definition: bitmapex.cxx:131
std::shared_ptr< ImplFontCache > mxFontCache
Definition: outdev.hxx:262
tools::Long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:207
#define SAL_WARN(area, stream)
std::unique_ptr< ImplOutDevData > mpOutDevData
Definition: outdev.hxx:189
SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel(tools::Long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
Definition: map.cxx:313
vcl::ExtOutDevData * mpExtOutDevData
Definition: outdev.hxx:191
#define DBG_TESTSOLARMUTEX()
static UnoWrapperBase * GetUnoWrapper(bool bCreateIfNotExists=true)
Get the application's UNO wrapper object.
Definition: svapp.cxx:1489
tools::Long mnOutOffLogicY
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:205
css::uno::Reference< css::rendering::XSpriteCanvas > GetSpriteCanvas() const
request XSpriteCanvas render interface
Definition: outdev.cxx:813
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:478
Point maRefPoint
Definition: outdev.hxx:236
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel(tools::Long nHeight) const
Convert a logical height to a height in units of device pixels.
Definition: map.cxx:330
tools::Long mnTextOffY
Definition: outdev.hxx:217
DrawModeFlags
virtual css::awt::DeviceInfo GetDeviceInfo() const
Definition: outdev.cxx:789
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:184
constexpr tools::Long GetHeight() const
LanguageType meTextLanguage
Definition: outdev.hxx:238