LibreOffice Module vcl (master)  1
gdimtf.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 <cstdlib>
21 #include <memory>
22 #include <sal/log.hxx>
23 #include <osl/diagnose.h>
24 #include <tools/diagnose_ex.h>
25 #include <tools/helpers.hxx>
26 #include <tools/stream.hxx>
27 #include <tools/vcompat.hxx>
28 #include <tools/fract.hxx>
29 #include <vcl/BitmapPalette.hxx>
30 #include <vcl/metaact.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/window.hxx>
33 #include <vcl/virdev.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/gdimtf.hxx>
36 #include <vcl/graphictools.hxx>
38 #include <vcl/canvastools.hxx>
39 #include <vcl/mtfxmldump.hxx>
40 
41 #include <svmconverter.hxx>
42 
43 #include <com/sun/star/beans/XFastPropertySet.hpp>
44 #include <com/sun/star/rendering/MtfRenderer.hpp>
45 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
46 #include <com/sun/star/rendering/XCanvas.hpp>
48 
49 using namespace com::sun::star;
50 
51 #define GAMMA( _def_cVal, _def_InvGamma ) (static_cast<sal_uInt8>(MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255)))
52 
54 {
55  std::unique_ptr<sal_uInt8[]> pMapR;
56  std::unique_ptr<sal_uInt8[]> pMapG;
57  std::unique_ptr<sal_uInt8[]> pMapB;
58 };
59 
61 {
67  double fGamma;
68  bool bInvert;
69 };
70 
72 {
74 };
75 
77 {
79 };
80 
82 {
84 };
85 
87 {
89 };
90 
92 {
93  std::unique_ptr<sal_uLong[]> pMinR;
94  std::unique_ptr<sal_uLong[]> pMaxR;
95  std::unique_ptr<sal_uLong[]> pMinG;
96  std::unique_ptr<sal_uLong[]> pMaxG;
97  std::unique_ptr<sal_uLong[]> pMinB;
98  std::unique_ptr<sal_uLong[]> pMaxB;
99  const Color * pDstCols;
101 };
102 
104 {
105  const Color* pSrcCols;
106  const Color* pDstCols;
108 };
109 
111  m_nCurrentActionElement( 0 ),
112  m_aPrefSize ( 1, 1 ),
113  m_pPrev ( nullptr ),
114  m_pNext ( nullptr ),
115  m_pOutDev ( nullptr ),
116  m_bPause ( false ),
117  m_bRecord ( false ),
118  m_bUseCanvas ( false )
119 {
120 }
121 
123  m_nCurrentActionElement( rMtf.m_nCurrentActionElement ),
124  m_aPrefMapMode ( rMtf.m_aPrefMapMode ),
125  m_aPrefSize ( rMtf.m_aPrefSize ),
126  m_pPrev ( rMtf.m_pPrev ),
127  m_pNext ( rMtf.m_pNext ),
128  m_pOutDev ( nullptr ),
129  m_bPause ( false ),
130  m_bRecord ( false ),
131  m_bUseCanvas ( rMtf.m_bUseCanvas )
132 {
133  for( size_t i = 0, n = rMtf.GetActionSize(); i < n; ++i )
134  {
135  m_aList.push_back( rMtf.GetAction( i ) );
136  }
137 
138  if( rMtf.m_bRecord )
139  {
140  Record( rMtf.m_pOutDev );
141 
142  if ( rMtf.m_bPause )
143  Pause( true );
144  }
145 }
146 
148 {
149  Clear();
150 }
151 
153 {
154  return m_aList.size();
155 }
156 
157 MetaAction* GDIMetaFile::GetAction( size_t nAction ) const
158 {
159  return (nAction < m_aList.size()) ? m_aList[ nAction ].get() : nullptr;
160 }
161 
163 {
165  return m_aList.empty() ? nullptr : m_aList[ 0 ].get();
166 }
167 
169 {
170  return ( m_nCurrentActionElement + 1 < m_aList.size() ) ? m_aList[ ++m_nCurrentActionElement ].get() : nullptr;
171 }
172 
174 {
175  if ( nAction >= m_aList.size() )
176  {
177  return;
178  }
179  //fdo#39995 This doesn't increment the incoming action ref-count nor does it
180  //decrement the outgoing action ref-count
181  std::swap(pAction, m_aList[nAction]);
182 }
183 
185 {
186  if( this != &rMtf )
187  {
188  Clear();
189 
190  // Increment RefCount of MetaActions
191  for( size_t i = 0, n = rMtf.GetActionSize(); i < n; ++i )
192  {
193  m_aList.push_back( rMtf.GetAction( i ) );
194  }
195 
197  m_aPrefSize = rMtf.m_aPrefSize;
198  m_pPrev = rMtf.m_pPrev;
199  m_pNext = rMtf.m_pNext;
200  m_pOutDev = nullptr;
201  m_bPause = false;
202  m_bRecord = false;
203  m_bUseCanvas = rMtf.m_bUseCanvas;
204 
205  if( rMtf.m_bRecord )
206  {
207  Record( rMtf.m_pOutDev );
208 
209  if( rMtf.m_bPause )
210  Pause( true );
211  }
212  }
213 
214  return *this;
215 }
216 
217 bool GDIMetaFile::operator==( const GDIMetaFile& rMtf ) const
218 {
219  const size_t nObjCount = m_aList.size();
220  bool bRet = false;
221 
222  if( this == &rMtf )
223  bRet = true;
224  else if( rMtf.GetActionSize() == nObjCount &&
225  rMtf.GetPrefSize() == m_aPrefSize &&
226  rMtf.GetPrefMapMode() == m_aPrefMapMode )
227  {
228  bRet = true;
229 
230  for( size_t n = 0; n < nObjCount; n++ )
231  {
232  if( m_aList[ n ] != rMtf.GetAction( n ) )
233  {
234  bRet = false;
235  break;
236  }
237  }
238  }
239 
240  return bRet;
241 }
242 
244 {
245  if( m_bRecord )
246  Stop();
247 
248  m_aList.clear();
249 }
250 
251 void GDIMetaFile::Linker( OutputDevice* pOut, bool bLink )
252 {
253  if( bLink )
254  {
255  m_pNext = nullptr;
256  m_pPrev = pOut->GetConnectMetaFile();
257  pOut->SetConnectMetaFile( this );
258 
259  if( m_pPrev )
260  m_pPrev->m_pNext = this;
261  }
262  else
263  {
264  if( m_pNext )
265  {
267 
268  if( m_pPrev )
270  }
271  else
272  {
273  if( m_pPrev )
274  m_pPrev->m_pNext = nullptr;
275 
276  pOut->SetConnectMetaFile( m_pPrev );
277  }
278 
279  m_pPrev = nullptr;
280  m_pNext = nullptr;
281  }
282 }
283 
285 {
286  if( m_bRecord )
287  Stop();
288 
289  m_nCurrentActionElement = m_aList.empty() ? 0 : (m_aList.size() - 1);
290  m_pOutDev = pOut;
291  m_bRecord = true;
292  Linker( pOut, true );
293 }
294 
296 {
297  if ( !m_bRecord && !rMtf.m_bRecord )
298  {
299  MetaAction* pAction = GetCurAction();
300  const size_t nObjCount = m_aList.size();
301 
302  rMtf.UseCanvas( rMtf.GetUseCanvas() || m_bUseCanvas );
303 
304  for( size_t nCurPos = m_nCurrentActionElement; nCurPos < nObjCount; nCurPos++ )
305  {
306  if( pAction )
307  {
308  rMtf.AddAction( pAction );
309  }
310 
311  pAction = NextAction();
312  }
313  }
314 }
315 
316 void GDIMetaFile::Play( OutputDevice* pOut, size_t nPos )
317 {
318  if( !m_bRecord )
319  {
320  MetaAction* pAction = GetCurAction();
321  const size_t nObjCount = m_aList.size();
322  size_t nSyncCount = ( pOut->GetOutDevType() == OUTDEV_WINDOW ) ? 0x000000ff : 0xffffffff;
323 
324  if( nPos > nObjCount )
325  nPos = nObjCount;
326 
327  // #i23407# Set backwards-compatible text language and layout mode
328  // This is necessary, since old metafiles don't even know of these
329  // recent add-ons. Newer metafiles must of course explicitly set
330  // those states.
334 
335  SAL_INFO( "vcl.gdi", "GDIMetaFile::Play on device of size: " << pOut->GetOutputSizePixel().Width() << " " << pOut->GetOutputSizePixel().Height());
336 
337  if( !ImplPlayWithRenderer( pOut, Point(0,0), pOut->GetOutputSize() ) ) {
338  size_t i = 0;
339  for( size_t nCurPos = m_nCurrentActionElement; nCurPos < nPos; nCurPos++ )
340  {
341  if( pAction )
342  {
343  pAction->Execute( pOut );
344 
345  // flush output from time to time
346  if( i++ > nSyncCount )
347  {
348  static_cast<vcl::Window*>( pOut )->Flush();
349  i = 0;
350  }
351  }
352 
353  pAction = NextAction();
354  }
355  }
356  pOut->Pop();
357  }
358 }
359 
360 bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize )
361 {
362  if (!m_bUseCanvas)
363  return false;
364 
365  Size rDestSize( pOut->LogicToPixel( rLogicDestSize ) );
366 
367  const vcl::Window* win = dynamic_cast <vcl::Window*> ( pOut );
368 
369  if (!win)
371  if (!win)
373 
374  if (!win)
375  return false;
376 
377  try
378  {
379  uno::Reference<rendering::XCanvas> xCanvas = win->GetCanvas ();
380 
381  if (!xCanvas.is())
382  return false;
383 
384  Size aSize (rDestSize.Width () + 1, rDestSize.Height () + 1);
385  uno::Reference<rendering::XBitmap> xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap (vcl::unotools::integerSize2DFromSize( aSize));
386  if( xBitmap.is () )
387  {
388  uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
389  if( xBitmapCanvas.is() )
390  {
391  uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
392  uno::Reference< rendering::XMtfRenderer > xMtfRenderer = rendering::MtfRenderer::createWithBitmapCanvas( xContext, xBitmapCanvas );
393 
394  xBitmapCanvas->clear();
395  uno::Reference< beans::XFastPropertySet > xMtfFastPropertySet( xMtfRenderer, uno::UNO_QUERY );
396  if( xMtfFastPropertySet.is() )
397  // set this metafile to the renderer to
398  // speedup things (instead of copying data to
399  // sequence of bytes passed to renderer)
400  xMtfFastPropertySet->setFastPropertyValue( 0, uno::Any( reinterpret_cast<sal_Int64>( this ) ) );
401 
402  xMtfRenderer->draw( rDestSize.Width(), rDestSize.Height() );
403 
404  BitmapEx aBitmapEx;
405  if( aBitmapEx.Create( xBitmapCanvas, aSize ) )
406  {
407  if (pOut->GetMapMode().GetMapUnit() == MapUnit::MapPixel)
408  pOut->DrawBitmapEx( rPos, aBitmapEx );
409  else
410  pOut->DrawBitmapEx( rPos, rLogicDestSize, aBitmapEx );
411  return true;
412  }
413  }
414  }
415  }
416  catch (const uno::RuntimeException& )
417  {
418  throw; // runtime errors are fatal
419  }
420  catch (const uno::Exception&)
421  {
422  // ignore errors, no way of reporting them here
423  TOOLS_WARN_EXCEPTION("vcl.gdi", "GDIMetaFile::ImplPlayWithRenderer");
424  }
425 
426  return false;
427 }
428 
429 void GDIMetaFile::Play( OutputDevice* pOut, const Point& rPos,
430  const Size& rSize )
431 {
432  vcl::Region aDrawClipRegion;
433  MapMode aDrawMap( GetPrefMapMode() );
434  Size aDestSize( pOut->LogicToPixel( rSize ) );
435 
436  if( !aDestSize.Width() || !aDestSize.Height() )
437  return;
438 
439  GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
440 
441  if( ImplPlayWithRenderer( pOut, rPos, rSize ) )
442  return;
443 
444  Size aTmpPrefSize( pOut->LogicToPixel( GetPrefSize(), aDrawMap ) );
445 
446  if( !aTmpPrefSize.Width() )
447  aTmpPrefSize.setWidth( aDestSize.Width() );
448 
449  if( !aTmpPrefSize.Height() )
450  aTmpPrefSize.setHeight( aDestSize.Height() );
451 
452  Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() );
453  Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() );
454 
455  aScaleX *= aDrawMap.GetScaleX(); aDrawMap.SetScaleX( aScaleX );
456  aScaleY *= aDrawMap.GetScaleY(); aDrawMap.SetScaleY( aScaleY );
457 
458  // #i47260# Convert logical output position to offset within
459  // the metafile's mapmode. Therefore, disable pixel offset on
460  // outdev, it's inverse mnOutOffLogicX/Y is calculated for a
461  // different mapmode (the one currently set on pOut, that is)
462  // - thus, aDrawMap's origin would generally be wrong. And
463  // even _if_ aDrawMap is similar to pOutDev's current mapmode,
464  // it's _still_ undesirable to have pixel offset unequal zero,
465  // because one would still get round-off errors (the
466  // round-trip error for LogicToPixel( PixelToLogic() ) was the
467  // reason for having pixel offset in the first place).
468  const Size& rOldOffset( pOut->GetPixelOffset() );
469  const Size aEmptySize;
470  pOut->SetPixelOffset( aEmptySize );
471  aDrawMap.SetOrigin( pOut->PixelToLogic( pOut->LogicToPixel( rPos ), aDrawMap ) );
472  pOut->SetPixelOffset( rOldOffset );
473 
474  pOut->Push();
475 
476  if ( pMtf && pMtf->IsRecord() && ( pOut->GetOutDevType() != OUTDEV_PRINTER ) )
477  pOut->SetRelativeMapMode( aDrawMap );
478  else
479  pOut->SetMapMode( aDrawMap );
480 
481  // #i23407# Set backwards-compatible text language and layout mode
482  // This is necessary, since old metafiles don't even know of these
483  // recent add-ons. Newer metafiles must of course explicitly set
484  // those states.
487 
488  Play( pOut );
489 
490  pOut->Pop();
491 
492 }
493 
494 void GDIMetaFile::Pause( bool _bPause )
495 {
496  if( m_bRecord )
497  {
498  if( _bPause )
499  {
500  if( !m_bPause )
501  Linker( m_pOutDev, false );
502  }
503  else
504  {
505  if( m_bPause )
506  Linker( m_pOutDev, true );
507  }
508 
509  m_bPause = _bPause;
510  }
511 }
512 
514 {
515  if( m_bRecord )
516  {
517  m_bRecord = false;
518 
519  if( !m_bPause )
520  Linker( m_pOutDev, false );
521  else
522  m_bPause = false;
523  }
524 }
525 
527 {
528  if( !m_bRecord )
530 }
531 
533 {
534  if( !m_bRecord )
535  if ( m_nCurrentActionElement > 0 )
537 }
538 
540 {
541  m_aList.push_back( pAction );
542 
543  if( m_pPrev )
544  {
545  m_pPrev->AddAction( pAction );
546  }
547 }
548 
549 void GDIMetaFile::AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos)
550 {
551  if ( nPos < m_aList.size() )
552  {
553  m_aList.insert( m_aList.begin() + nPos, pAction );
554  }
555  else
556  {
557  m_aList.push_back( pAction );
558  }
559 
560  if( m_pPrev )
561  {
562  m_pPrev->AddAction( pAction, nPos );
563  }
564 }
565 
567 {
568  m_aList.push_back( pAction );
569 }
570 
572 {
573  const Size aOldPrefSize( GetPrefSize() );
574  long nMoveX, nMoveY;
575  double fScaleX, fScaleY;
576 
577  if( nMirrorFlags & BmpMirrorFlags::Horizontal )
578  {
579  nMoveX = std::abs( aOldPrefSize.Width() ) - 1;
580  fScaleX = -1.0;
581  }
582  else
583  {
584  nMoveX = 0;
585  fScaleX = 1.0;
586  }
587 
588  if( nMirrorFlags & BmpMirrorFlags::Vertical )
589  {
590  nMoveY = std::abs( aOldPrefSize.Height() ) - 1;
591  fScaleY = -1.0;
592  }
593  else
594  {
595  nMoveY = 0;
596  fScaleY = 1.0;
597  }
598 
599  if( ( fScaleX != 1.0 ) || ( fScaleY != 1.0 ) )
600  {
601  Scale( fScaleX, fScaleY );
602  Move( nMoveX, nMoveY );
603  SetPrefSize( aOldPrefSize );
604  }
605 }
606 
607 void GDIMetaFile::Move( long nX, long nY )
608 {
609  const Size aBaseOffset( nX, nY );
610  Size aOffset( aBaseOffset );
612 
613  aMapVDev->EnableOutput( false );
614  aMapVDev->SetMapMode( GetPrefMapMode() );
615 
616  for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
617  {
618  const MetaActionType nType = pAct->GetType();
619  MetaAction* pModAct;
620 
621  if( pAct->GetRefCount() > 1 )
622  {
623  m_aList[ m_nCurrentActionElement ] = pAct->Clone();
624  pModAct = m_aList[ m_nCurrentActionElement ].get();
625  }
626  else
627  pModAct = pAct;
628 
629  if( ( MetaActionType::MAPMODE == nType ) ||
630  ( MetaActionType::PUSH == nType ) ||
631  ( MetaActionType::POP == nType ) )
632  {
633  pModAct->Execute( aMapVDev.get() );
634  aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() );
635  }
636 
637  pModAct->Move( aOffset.Width(), aOffset.Height() );
638  }
639 }
640 
641 void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY )
642 {
643  const Size aBaseOffset( nX, nY );
644  Size aOffset( aBaseOffset );
646 
647  aMapVDev->EnableOutput( false );
648  aMapVDev->SetReferenceDevice( nDPIX, nDPIY );
649  aMapVDev->SetMapMode( GetPrefMapMode() );
650 
651  for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
652  {
653  const MetaActionType nType = pAct->GetType();
654  MetaAction* pModAct;
655 
656  if( pAct->GetRefCount() > 1 )
657  {
658  m_aList[ m_nCurrentActionElement ] = pAct->Clone();
659  pModAct = m_aList[ m_nCurrentActionElement ].get();
660  }
661  else
662  pModAct = pAct;
663 
664  if( ( MetaActionType::MAPMODE == nType ) ||
665  ( MetaActionType::PUSH == nType ) ||
666  ( MetaActionType::POP == nType ) )
667  {
668  pModAct->Execute( aMapVDev.get() );
669  if( aMapVDev->GetMapMode().GetMapUnit() == MapUnit::MapPixel )
670  {
671  aOffset = aMapVDev->LogicToPixel( aBaseOffset, GetPrefMapMode() );
672  MapMode aMap( aMapVDev->GetMapMode() );
673  aOffset.setWidth( static_cast<long>(aOffset.Width() * static_cast<double>(aMap.GetScaleX())) );
674  aOffset.setHeight( static_cast<long>(aOffset.Height() * static_cast<double>(aMap.GetScaleY())) );
675  }
676  else
677  aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() );
678  }
679 
680  pModAct->Move( aOffset.Width(), aOffset.Height() );
681  }
682 }
683 
684 void GDIMetaFile::Scale( double fScaleX, double fScaleY )
685 {
686  for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
687  {
688  MetaAction* pModAct;
689 
690  if( pAct->GetRefCount() > 1 )
691  {
692  m_aList[ m_nCurrentActionElement ] = pAct->Clone();
693  pModAct = m_aList[ m_nCurrentActionElement ].get();
694  }
695  else
696  pModAct = pAct;
697 
698  pModAct->Scale( fScaleX, fScaleY );
699  }
700 
701  m_aPrefSize.setWidth( FRound( m_aPrefSize.Width() * fScaleX ) );
702  m_aPrefSize.setHeight( FRound( m_aPrefSize.Height() * fScaleY ) );
703 }
704 
705 void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY )
706 {
707  Scale( static_cast<double>(rScaleX), static_cast<double>(rScaleY) );
708 }
709 
710 void GDIMetaFile::Clip( const tools::Rectangle& i_rClipRect )
711 {
712  tools::Rectangle aCurRect( i_rClipRect );
714 
715  aMapVDev->EnableOutput( false );
716  aMapVDev->SetMapMode( GetPrefMapMode() );
717 
718  for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() )
719  {
720  const MetaActionType nType = pAct->GetType();
721 
722  if( ( MetaActionType::MAPMODE == nType ) ||
723  ( MetaActionType::PUSH == nType ) ||
724  ( MetaActionType::POP == nType ) )
725  {
726  pAct->Execute( aMapVDev.get() );
727  aCurRect = OutputDevice::LogicToLogic( i_rClipRect, GetPrefMapMode(), aMapVDev->GetMapMode() );
728  }
729  else if( nType == MetaActionType::CLIPREGION )
730  {
731  MetaClipRegionAction* pOldAct = static_cast<MetaClipRegionAction*>(pAct);
732  vcl::Region aNewReg( aCurRect );
733  if( pOldAct->IsClipping() )
734  aNewReg.Intersect( pOldAct->GetRegion() );
735  MetaClipRegionAction* pNewAct = new MetaClipRegionAction( aNewReg, true );
736  m_aList[ m_nCurrentActionElement ] = pNewAct;
737  }
738  }
739 }
740 
741 Point GDIMetaFile::ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt,
742  const Size& rOffset, double fSin, double fCos )
743 {
744  const long nX = rPt.X() - rRotatePt.X();
745  const long nY = rPt.Y() - rRotatePt.Y();
746 
747  return Point( FRound( fCos * nX + fSin * nY ) + rRotatePt.X() + rOffset.Width(),
748  -FRound( fSin * nX - fCos * nY ) + rRotatePt.Y() + rOffset.Height() );
749 }
750 
752  const Size& rOffset, double fSin, double fCos )
753 {
754  tools::Polygon aRet( rPoly );
755 
756  aRet.Rotate( rRotatePt, fSin, fCos );
757  aRet.Move( rOffset.Width(), rOffset.Height() );
758 
759  return aRet;
760 }
761 
763  const Size& rOffset, double fSin, double fCos )
764 {
765  tools::PolyPolygon aRet( rPolyPoly );
766 
767  aRet.Rotate( rRotatePt, fSin, fCos );
768  aRet.Move( rOffset.Width(), rOffset.Height() );
769 
770  return aRet;
771 }
772 
774  const OutputDevice& rMapDev,
775  const tools::PolyPolygon& rPolyPoly,
776  const Gradient& rGrad )
777 {
778  // Generate comment, GradientEx and Gradient actions (within DrawGradient)
780  aVDev->EnableOutput( false );
781  GDIMetaFile aGradMtf;
782 
783  aGradMtf.Record( aVDev.get() );
784  aVDev->DrawGradient( rPolyPoly, rGrad );
785  aGradMtf.Stop();
786 
787  size_t i, nAct( aGradMtf.GetActionSize() );
788  for( i=0; i < nAct; ++i )
789  {
790  MetaAction* pMetaAct = aGradMtf.GetAction( i );
791  rMtf.AddAction( pMetaAct );
792  }
793 }
794 
795 void GDIMetaFile::Rotate( long nAngle10 )
796 {
797  nAngle10 %= 3600;
798  nAngle10 = ( nAngle10 < 0 ) ? ( 3599 + nAngle10 ) : nAngle10;
799 
800  if( !nAngle10 )
801  return;
802 
803  GDIMetaFile aMtf;
805  const double fAngle = F_PI1800 * nAngle10;
806  const double fSin = sin( fAngle );
807  const double fCos = cos( fAngle );
808  tools::Rectangle aRect( Point(), GetPrefSize() );
809  tools::Polygon aPoly( aRect );
810 
811  aPoly.Rotate( Point(), fSin, fCos );
812 
813  aMapVDev->EnableOutput( false );
814  aMapVDev->SetMapMode( GetPrefMapMode() );
815 
816  const tools::Rectangle aNewBound( aPoly.GetBoundRect() );
817 
818  const Point aOrigin( GetPrefMapMode().GetOrigin().X(), GetPrefMapMode().GetOrigin().Y() );
819  const Size aOffset( -aNewBound.Left(), -aNewBound.Top() );
820 
821  Point aRotAnchor( aOrigin );
822  Size aRotOffset( aOffset );
823 
824  for( MetaAction* pAction = FirstAction(); pAction; pAction = NextAction() )
825  {
826  const MetaActionType nActionType = pAction->GetType();
827 
828  switch( nActionType )
829  {
831  {
832  MetaPixelAction* pAct = static_cast<MetaPixelAction*>(pAction);
833  aMtf.AddAction( new MetaPixelAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
834  pAct->GetColor() ) );
835  }
836  break;
837 
839  {
840  MetaPointAction* pAct = static_cast<MetaPointAction*>(pAction);
841  aMtf.AddAction( new MetaPointAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
842  }
843  break;
844 
846  {
847  MetaLineAction* pAct = static_cast<MetaLineAction*>(pAction);
848  aMtf.AddAction( new MetaLineAction( ImplGetRotatedPoint( pAct->GetStartPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
849  ImplGetRotatedPoint( pAct->GetEndPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
850  pAct->GetLineInfo() ) );
851  }
852  break;
853 
855  {
856  MetaRectAction* pAct = static_cast<MetaRectAction*>(pAction);
857  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
858  }
859  break;
860 
862  {
863  MetaRoundRectAction* pAct = static_cast<MetaRoundRectAction*>(pAction);
864  const tools::Polygon aRoundRectPoly( pAct->GetRect(), pAct->GetHorzRound(), pAct->GetVertRound() );
865 
866  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aRoundRectPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
867  }
868  break;
869 
871  {
872  MetaEllipseAction* pAct = static_cast<MetaEllipseAction*>(pAction);
873  const tools::Polygon aEllipsePoly( pAct->GetRect().Center(), pAct->GetRect().GetWidth() >> 1, pAct->GetRect().GetHeight() >> 1 );
874 
875  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aEllipsePoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
876  }
877  break;
878 
879  case MetaActionType::ARC:
880  {
881  MetaArcAction* pAct = static_cast<MetaArcAction*>(pAction);
882  const tools::Polygon aArcPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Arc );
883 
884  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aArcPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
885  }
886  break;
887 
888  case MetaActionType::PIE:
889  {
890  MetaPieAction* pAct = static_cast<MetaPieAction*>(pAction);
891  const tools::Polygon aPiePoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Pie );
892 
893  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aPiePoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
894  }
895  break;
896 
898  {
899  MetaChordAction* pAct = static_cast<MetaChordAction*>(pAction);
900  const tools::Polygon aChordPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Chord );
901 
902  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aChordPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
903  }
904  break;
905 
907  {
908  MetaPolyLineAction* pAct = static_cast<MetaPolyLineAction*>(pAction);
909  aMtf.AddAction( new MetaPolyLineAction( ImplGetRotatedPolygon( pAct->GetPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->GetLineInfo() ) );
910  }
911  break;
912 
914  {
915  MetaPolygonAction* pAct = static_cast<MetaPolygonAction*>(pAction);
916  aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( pAct->GetPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
917  }
918  break;
919 
921  {
922  MetaPolyPolygonAction* pAct = static_cast<MetaPolyPolygonAction*>(pAction);
923  aMtf.AddAction( new MetaPolyPolygonAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
924  }
925  break;
926 
928  {
929  MetaTextAction* pAct = static_cast<MetaTextAction*>(pAction);
930  aMtf.AddAction( new MetaTextAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
931  pAct->GetText(), pAct->GetIndex(), pAct->GetLen() ) );
932  }
933  break;
934 
936  {
937  MetaTextArrayAction* pAct = static_cast<MetaTextArrayAction*>(pAction);
938  aMtf.AddAction( new MetaTextArrayAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
939  pAct->GetText(), pAct->GetDXArray(), pAct->GetIndex(), pAct->GetLen() ) );
940  }
941  break;
942 
944  {
945  MetaStretchTextAction* pAct = static_cast<MetaStretchTextAction*>(pAction);
946  aMtf.AddAction( new MetaStretchTextAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
947  pAct->GetWidth(), pAct->GetText(), pAct->GetIndex(), pAct->GetLen() ) );
948  }
949  break;
950 
952  {
953  MetaTextLineAction* pAct = static_cast<MetaTextLineAction*>(pAction);
954  aMtf.AddAction( new MetaTextLineAction( ImplGetRotatedPoint( pAct->GetStartPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
955  pAct->GetWidth(), pAct->GetStrikeout(), pAct->GetUnderline(), pAct->GetOverline() ) );
956  }
957  break;
958 
960  {
961  MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
962  tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
963  tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
964  BitmapEx aBmpEx( pAct->GetBitmap() );
965 
966  aBmpEx.Rotate( nAngle10, COL_TRANSPARENT );
967  aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(),
968  aBmpEx ) );
969  }
970  break;
971 
973  {
974  MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
975  tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetDestPoint(), pAct->GetDestSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
976  tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
977  BitmapEx aBmpEx( pAct->GetBitmap() );
978 
979  aBmpEx.Crop( tools::Rectangle( pAct->GetSrcPoint(), pAct->GetSrcSize() ) );
980  aBmpEx.Rotate( nAngle10, COL_TRANSPARENT );
981 
982  aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
983  }
984  break;
985 
987  {
988  MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
989  tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
990  tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
991  BitmapEx aBmpEx( pAct->GetBitmapEx() );
992 
993  aBmpEx.Rotate( nAngle10, COL_TRANSPARENT );
994 
995  aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
996  }
997  break;
998 
1000  {
1001  MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
1002  tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetDestPoint(), pAct->GetDestSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
1003  tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
1004  BitmapEx aBmpEx( pAct->GetBitmapEx() );
1005 
1006  aBmpEx.Crop( tools::Rectangle( pAct->GetSrcPoint(), pAct->GetSrcSize() ) );
1007  aBmpEx.Rotate( nAngle10, COL_TRANSPARENT );
1008 
1009  aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
1010  }
1011  break;
1012 
1014  {
1015  MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
1016 
1017  ImplAddGradientEx( aMtf, *aMapVDev,
1018  ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ),
1019  pAct->GetGradient() );
1020  }
1021  break;
1022 
1024  {
1025  MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
1026  aMtf.AddAction( new MetaGradientExAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
1027  pAct->GetGradient() ) );
1028  }
1029  break;
1030 
1031  // Handle gradientex comment block correctly
1033  {
1034  MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
1035  if( pCommentAct->GetComment() == "XGRAD_SEQ_BEGIN" )
1036  {
1037  int nBeginComments( 1 );
1038  pAction = NextAction();
1039 
1040  // skip everything, except gradientex action
1041  while( pAction )
1042  {
1043  const MetaActionType nType = pAction->GetType();
1044 
1045  if( MetaActionType::GRADIENTEX == nType )
1046  {
1047  // Add rotated gradientex
1048  MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
1049  ImplAddGradientEx( aMtf, *aMapVDev,
1050  ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
1051  pAct->GetGradient() );
1052  }
1053  else if( MetaActionType::COMMENT == nType)
1054  {
1055  MetaCommentAction* pAct = static_cast<MetaCommentAction*>(pAction);
1056  if( pAct->GetComment() == "XGRAD_SEQ_END" )
1057  {
1058  // handle nested blocks
1059  --nBeginComments;
1060 
1061  // gradientex comment block: end reached, done.
1062  if( !nBeginComments )
1063  break;
1064  }
1065  else if( pAct->GetComment() == "XGRAD_SEQ_BEGIN" )
1066  {
1067  // handle nested blocks
1068  ++nBeginComments;
1069  }
1070 
1071  }
1072 
1073  pAction =NextAction();
1074  }
1075  }
1076  else
1077  {
1078  bool bPathStroke = (pCommentAct->GetComment() == "XPATHSTROKE_SEQ_BEGIN");
1079  if ( bPathStroke || pCommentAct->GetComment() == "XPATHFILL_SEQ_BEGIN" )
1080  {
1081  if ( pCommentAct->GetDataSize() )
1082  {
1083  SvMemoryStream aMemStm( const_cast<sal_uInt8 *>(pCommentAct->GetData()), pCommentAct->GetDataSize(), StreamMode::READ );
1084  SvMemoryStream aDest;
1085  if ( bPathStroke )
1086  {
1087  SvtGraphicStroke aStroke;
1088  ReadSvtGraphicStroke( aMemStm, aStroke );
1089  tools::Polygon aPath;
1090  aStroke.getPath( aPath );
1091  aStroke.setPath( ImplGetRotatedPolygon( aPath, aRotAnchor, aRotOffset, fSin, fCos ) );
1092  WriteSvtGraphicStroke( aDest, aStroke );
1093  aMtf.AddAction( new MetaCommentAction( "XPATHSTROKE_SEQ_BEGIN", 0,
1094  static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
1095  }
1096  else
1097  {
1098  SvtGraphicFill aFill;
1099  ReadSvtGraphicFill( aMemStm, aFill );
1100  tools::PolyPolygon aPath;
1101  aFill.getPath( aPath );
1102  aFill.setPath( ImplGetRotatedPolyPolygon( aPath, aRotAnchor, aRotOffset, fSin, fCos ) );
1103  WriteSvtGraphicFill( aDest, aFill );
1104  aMtf.AddAction( new MetaCommentAction( "XPATHFILL_SEQ_BEGIN", 0,
1105  static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
1106  }
1107  }
1108  }
1109  else if ( pCommentAct->GetComment() == "XPATHSTROKE_SEQ_END"
1110  || pCommentAct->GetComment() == "XPATHFILL_SEQ_END" )
1111  {
1112  pAction->Execute( aMapVDev.get() );
1113  aMtf.AddAction( pAction );
1114  }
1115  }
1116  }
1117  break;
1118 
1119  case MetaActionType::HATCH:
1120  {
1121  MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction);
1122  Hatch aHatch( pAct->GetHatch() );
1123 
1124  aHatch.SetAngle( aHatch.GetAngle() + static_cast<sal_uInt16>(nAngle10) );
1125  aMtf.AddAction( new MetaHatchAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
1126  aHatch ) );
1127  }
1128  break;
1129 
1131  {
1132  MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pAction);
1133  aMtf.AddAction( new MetaTransparentAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
1134  pAct->GetTransparence() ) );
1135  }
1136  break;
1137 
1139  {
1140  MetaFloatTransparentAction* pAct = static_cast<MetaFloatTransparentAction*>(pAction);
1141  GDIMetaFile aTransMtf( pAct->GetGDIMetaFile() );
1142  tools::Polygon aMtfPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
1143  tools::Rectangle aMtfRect( aMtfPoly.GetBoundRect() );
1144 
1145  aTransMtf.Rotate( nAngle10 );
1146  aMtf.AddAction( new MetaFloatTransparentAction( aTransMtf, aMtfRect.TopLeft(), aMtfRect.GetSize(),
1147  pAct->GetGradient() ) );
1148  }
1149  break;
1150 
1151  case MetaActionType::EPS:
1152  {
1153  MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
1154  GDIMetaFile aEPSMtf( pAct->GetSubstitute() );
1155  tools::Polygon aEPSPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
1156  tools::Rectangle aEPSRect( aEPSPoly.GetBoundRect() );
1157 
1158  aEPSMtf.Rotate( nAngle10 );
1159  aMtf.AddAction( new MetaEPSAction( aEPSRect.TopLeft(), aEPSRect.GetSize(),
1160  pAct->GetLink(), aEPSMtf ) );
1161  }
1162  break;
1163 
1165  {
1166  MetaClipRegionAction* pAct = static_cast<MetaClipRegionAction*>(pAction);
1167 
1168  if( pAct->IsClipping() && pAct->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
1169  aMtf.AddAction( new MetaClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( pAct->GetRegion().GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ), true ) );
1170  else
1171  {
1172  aMtf.AddAction( pAction );
1173  }
1174  }
1175  break;
1176 
1178  {
1179  MetaISectRectClipRegionAction* pAct = static_cast<MetaISectRectClipRegionAction*>(pAction);
1181  ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor,
1182  aRotOffset, fSin, fCos )) ) );
1183  }
1184  break;
1185 
1187  {
1189  const vcl::Region& rRegion = pAct->GetRegion();
1190 
1191  if( rRegion.HasPolyPolygonOrB2DPolyPolygon() )
1192  aMtf.AddAction( new MetaISectRegionClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( rRegion.GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) ) );
1193  else
1194  {
1195  aMtf.AddAction( pAction );
1196  }
1197  }
1198  break;
1199 
1201  {
1202  MetaRefPointAction* pAct = static_cast<MetaRefPointAction*>(pAction);
1203  aMtf.AddAction( new MetaRefPointAction( ImplGetRotatedPoint( pAct->GetRefPoint(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->IsSetting() ) );
1204  }
1205  break;
1206 
1207  case MetaActionType::FONT:
1208  {
1209  MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction);
1210  vcl::Font aFont( pAct->GetFont() );
1211 
1212  aFont.SetOrientation( aFont.GetOrientation() + static_cast<sal_uInt16>(nAngle10) );
1213  aMtf.AddAction( new MetaFontAction( aFont ) );
1214  }
1215  break;
1216 
1217  case MetaActionType::BMP:
1218  case MetaActionType::BMPEX:
1219  case MetaActionType::MASK:
1225  {
1226  OSL_FAIL( "GDIMetaFile::Rotate(): unsupported action" );
1227  }
1228  break;
1229 
1230  default:
1231  {
1232  pAction->Execute( aMapVDev.get() );
1233  aMtf.AddAction( pAction );
1234 
1235  // update rotation point and offset, if necessary
1236  if( ( MetaActionType::MAPMODE == nActionType ) ||
1237  ( MetaActionType::PUSH == nActionType ) ||
1238  ( MetaActionType::POP == nActionType ) )
1239  {
1240  aRotAnchor = OutputDevice::LogicToLogic( aOrigin, m_aPrefMapMode, aMapVDev->GetMapMode() );
1241  aRotOffset = OutputDevice::LogicToLogic( aOffset, m_aPrefMapMode, aMapVDev->GetMapMode() );
1242  }
1243  }
1244  break;
1245  }
1246  }
1247 
1249  aMtf.m_aPrefSize = aNewBound.GetSize();
1250 
1251  *this = aMtf;
1252 
1253 }
1254 
1255 static void ImplActionBounds( tools::Rectangle& o_rOutBounds,
1256  const tools::Rectangle& i_rInBounds,
1257  const std::vector<tools::Rectangle>& i_rClipStack,
1258  tools::Rectangle* o_pHairline )
1259 {
1260  tools::Rectangle aBounds( i_rInBounds );
1261  if( ! i_rInBounds.IsEmpty() && ! i_rClipStack.empty() && ! i_rClipStack.back().IsEmpty() )
1262  aBounds.Intersection( i_rClipStack.back() );
1263  if( ! aBounds.IsEmpty() )
1264  {
1265  if( ! o_rOutBounds.IsEmpty() )
1266  o_rOutBounds.Union( aBounds );
1267  else
1268  o_rOutBounds = aBounds;
1269 
1270  if(o_pHairline)
1271  {
1272  if( ! o_pHairline->IsEmpty() )
1273  o_pHairline->Union( aBounds );
1274  else
1275  *o_pHairline = aBounds;
1276  }
1277  }
1278 }
1279 
1281 {
1282  GDIMetaFile aMtf;
1283  ScopedVclPtrInstance< VirtualDevice > aMapVDev( i_rReference );
1284 
1285  aMapVDev->EnableOutput( false );
1286  aMapVDev->SetMapMode( GetPrefMapMode() );
1287 
1288  std::vector<tools::Rectangle> aClipStack( 1, tools::Rectangle() );
1289  std::vector<PushFlags> aPushFlagStack;
1290 
1291  tools::Rectangle aBound;
1292 
1293  if(pHairline)
1294  *pHairline = tools::Rectangle();
1295 
1296  const sal_uLong nCount(GetActionSize());
1297 
1298  for(sal_uLong a(0); a < nCount; a++)
1299  {
1300  MetaAction* pAction = GetAction(a);
1301  const MetaActionType nActionType = pAction->GetType();
1302  tools::Rectangle* pUseHairline = (pHairline && aMapVDev->IsLineColor()) ? pHairline : nullptr;
1303 
1304  switch( nActionType )
1305  {
1306  case MetaActionType::PIXEL:
1307  {
1308  MetaPixelAction* pAct = static_cast<MetaPixelAction*>(pAction);
1309  ImplActionBounds( aBound,
1310  tools::Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ),
1311  aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
1312  aClipStack, pUseHairline );
1313  }
1314  break;
1315 
1316  case MetaActionType::POINT:
1317  {
1318  MetaPointAction* pAct = static_cast<MetaPointAction*>(pAction);
1319  ImplActionBounds( aBound,
1320  tools::Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ),
1321  aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
1322  aClipStack, pUseHairline );
1323  }
1324  break;
1325 
1326  case MetaActionType::LINE:
1327  {
1328  MetaLineAction* pAct = static_cast<MetaLineAction*>(pAction);
1329  Point aP1( pAct->GetStartPoint() ), aP2( pAct->GetEndPoint() );
1330  tools::Rectangle aRect( aP1, aP2 );
1331  aRect.Justify();
1332 
1333  if(pUseHairline)
1334  {
1335  const LineInfo& rLineInfo = pAct->GetLineInfo();
1336 
1337  if(0 != rLineInfo.GetWidth())
1338  pUseHairline = nullptr;
1339  }
1340 
1341  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1342  }
1343  break;
1344 
1345  case MetaActionType::RECT:
1346  {
1347  MetaRectAction* pAct = static_cast<MetaRectAction*>(pAction);
1348  ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1349  }
1350  break;
1351 
1353  {
1354  MetaRoundRectAction* pAct = static_cast<MetaRoundRectAction*>(pAction);
1355  ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1356  }
1357  break;
1358 
1360  {
1361  MetaEllipseAction* pAct = static_cast<MetaEllipseAction*>(pAction);
1362  ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1363  }
1364  break;
1365 
1366  case MetaActionType::ARC:
1367  {
1368  MetaArcAction* pAct = static_cast<MetaArcAction*>(pAction);
1369  // FIXME: this is imprecise
1370  // e.g. for small arcs the whole rectangle is WAY too large
1371  ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1372  }
1373  break;
1374 
1375  case MetaActionType::PIE:
1376  {
1377  MetaPieAction* pAct = static_cast<MetaPieAction*>(pAction);
1378  // FIXME: this is imprecise
1379  // e.g. for small arcs the whole rectangle is WAY too large
1380  ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1381  }
1382  break;
1383 
1384  case MetaActionType::CHORD:
1385  {
1386  MetaChordAction* pAct = static_cast<MetaChordAction*>(pAction);
1387  // FIXME: this is imprecise
1388  // e.g. for small arcs the whole rectangle is WAY too large
1389  ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1390  }
1391  break;
1392 
1394  {
1395  MetaPolyLineAction* pAct = static_cast<MetaPolyLineAction*>(pAction);
1396  tools::Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
1397 
1398  if(pUseHairline)
1399  {
1400  const LineInfo& rLineInfo = pAct->GetLineInfo();
1401 
1402  if(0 != rLineInfo.GetWidth())
1403  pUseHairline = nullptr;
1404  }
1405 
1406  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1407  }
1408  break;
1409 
1411  {
1412  MetaPolygonAction* pAct = static_cast<MetaPolygonAction*>(pAction);
1413  tools::Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
1414  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1415  }
1416  break;
1417 
1419  {
1420  MetaPolyPolygonAction* pAct = static_cast<MetaPolyPolygonAction*>(pAction);
1421  tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
1422  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline );
1423  }
1424  break;
1425 
1426  case MetaActionType::TEXT:
1427  {
1428  MetaTextAction* pAct = static_cast<MetaTextAction*>(pAction);
1429  tools::Rectangle aRect;
1430  // hdu said base = index
1431  aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() );
1432  Point aPt( pAct->GetPoint() );
1433  aRect.Move( aPt.X(), aPt.Y() );
1434  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1435  }
1436  break;
1437 
1439  {
1440  MetaTextArrayAction* pAct = static_cast<MetaTextArrayAction*>(pAction);
1441  tools::Rectangle aRect;
1442  // hdu said base = index
1443  aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
1444  0, pAct->GetDXArray() );
1445  Point aPt( pAct->GetPoint() );
1446  aRect.Move( aPt.X(), aPt.Y() );
1447  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1448  }
1449  break;
1450 
1452  {
1453  MetaStretchTextAction* pAct = static_cast<MetaStretchTextAction*>(pAction);
1454  tools::Rectangle aRect;
1455  // hdu said base = index
1456  aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
1457  pAct->GetWidth() );
1458  Point aPt( pAct->GetPoint() );
1459  aRect.Move( aPt.X(), aPt.Y() );
1460  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1461  }
1462  break;
1463 
1465  {
1466  MetaTextLineAction* pAct = static_cast<MetaTextLineAction*>(pAction);
1467  // measure a test string to get ascend and descent right
1468  static const sal_Unicode pStr[] = { 0xc4, 0x67, 0 };
1469  OUString aStr( pStr );
1470 
1471  tools::Rectangle aRect;
1472  aMapVDev->GetTextBoundRect( aRect, aStr, 0, 0, aStr.getLength() );
1473  Point aPt( pAct->GetStartPoint() );
1474  aRect.Move( aPt.X(), aPt.Y() );
1475  aRect.SetRight( aRect.Left() + pAct->GetWidth() );
1476  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1477  }
1478  break;
1479 
1481  {
1482  MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
1483  tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
1484  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1485  }
1486  break;
1487 
1489  {
1490  MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
1491  tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
1492  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1493  }
1494  break;
1495 
1497  {
1498  MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
1499  tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
1500  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1501  }
1502  break;
1503 
1505  {
1506  MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
1507  tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
1508  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1509  }
1510  break;
1511 
1513  {
1514  MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
1515  tools::Rectangle aRect( pAct->GetRect() );
1516  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1517  }
1518  break;
1519 
1521  {
1522  MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
1523  tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
1524  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1525  }
1526  break;
1527 
1529  {
1530  // nothing to do
1531  };
1532  break;
1533 
1534  case MetaActionType::HATCH:
1535  {
1536  MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction);
1537  tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
1538  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1539  }
1540  break;
1541 
1543  {
1544  MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pAction);
1545  tools::Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
1546  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1547  }
1548  break;
1549 
1551  {
1552  MetaFloatTransparentAction* pAct = static_cast<MetaFloatTransparentAction*>(pAction);
1553  // MetaFloatTransparentAction is defined limiting its content Metafile
1554  // to its geometry definition(Point, Size), so use these directly
1555  const tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
1556  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1557  }
1558  break;
1559 
1560  case MetaActionType::EPS:
1561  {
1562  MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
1563  tools::Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
1564  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1565  }
1566  break;
1567 
1569  {
1570  MetaClipRegionAction* pAct = static_cast<MetaClipRegionAction*>(pAction);
1571  if( pAct->IsClipping() )
1572  aClipStack.back() = OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev->GetMapMode(), GetPrefMapMode() );
1573  else
1574  aClipStack.back() = tools::Rectangle();
1575  }
1576  break;
1577 
1579  {
1580  MetaISectRectClipRegionAction* pAct = static_cast<MetaISectRectClipRegionAction*>(pAction);
1581  tools::Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ) );
1582  if( aClipStack.back().IsEmpty() )
1583  aClipStack.back() = aRect;
1584  else
1585  aClipStack.back().Intersection( aRect );
1586  }
1587  break;
1588 
1590  {
1592  tools::Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ) );
1593  if( aClipStack.back().IsEmpty() )
1594  aClipStack.back() = aRect;
1595  else
1596  aClipStack.back().Intersection( aRect );
1597  }
1598  break;
1599 
1600  case MetaActionType::BMP:
1601  {
1602  MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction);
1603  tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
1604  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1605  }
1606  break;
1607 
1608  case MetaActionType::BMPEX:
1609  {
1610  MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction);
1611  tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) );
1612  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1613  }
1614  break;
1615 
1616  case MetaActionType::MASK:
1617  {
1618  MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pAction);
1619  tools::Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
1620  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1621  }
1622  break;
1623 
1625  {
1626  MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
1627  tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
1628  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1629  }
1630  break;
1631 
1633  {
1634  MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
1635  tools::Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
1636  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1637  }
1638  break;
1639 
1641  {
1642  MetaWallpaperAction* pAct = static_cast<MetaWallpaperAction*>(pAction);
1643  tools::Rectangle aRect( pAct->GetRect() );
1644  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1645  }
1646  break;
1647 
1649  {
1650  MetaTextRectAction* pAct = static_cast<MetaTextRectAction*>(pAction);
1651  tools::Rectangle aRect( pAct->GetRect() );
1652  ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, nullptr );
1653  }
1654  break;
1655 
1657  {
1658  MetaMoveClipRegionAction* pAct = static_cast<MetaMoveClipRegionAction*>(pAction);
1659  if( ! aClipStack.back().IsEmpty() )
1660  {
1661  Size aDelta( pAct->GetHorzMove(), pAct->GetVertMove() );
1662  aDelta = OutputDevice::LogicToLogic( aDelta, aMapVDev->GetMapMode(), GetPrefMapMode() );
1663  aClipStack.back().Move( aDelta.Width(), aDelta.Width() );
1664  }
1665  }
1666  break;
1667 
1668  default:
1669  {
1670  pAction->Execute( aMapVDev.get() );
1671 
1672  if( nActionType == MetaActionType::PUSH )
1673  {
1674  MetaPushAction* pAct = static_cast<MetaPushAction*>(pAction);
1675  aPushFlagStack.push_back( pAct->GetFlags() );
1676  if( aPushFlagStack.back() & PushFlags::CLIPREGION )
1677  {
1678  tools::Rectangle aRect( aClipStack.back() );
1679  aClipStack.push_back( aRect );
1680  }
1681  }
1682  else if( nActionType == MetaActionType::POP )
1683  {
1684  // sanity check
1685  if( ! aPushFlagStack.empty() )
1686  {
1687  if( aPushFlagStack.back() & PushFlags::CLIPREGION )
1688  {
1689  if( aClipStack.size() > 1 )
1690  aClipStack.pop_back();
1691  }
1692  aPushFlagStack.pop_back();
1693  }
1694  }
1695  }
1696  break;
1697  }
1698  }
1699  return aBound;
1700 }
1701 
1702 Color GDIMetaFile::ImplColAdjustFnc( const Color& rColor, const void* pColParam )
1703 {
1704  return Color( rColor.GetTransparency(),
1705  static_cast<const ImplColAdjustParam*>(pColParam)->pMapR[ rColor.GetRed() ],
1706  static_cast<const ImplColAdjustParam*>(pColParam)->pMapG[ rColor.GetGreen() ],
1707  static_cast<const ImplColAdjustParam*>(pColParam)->pMapB[ rColor.GetBlue() ] );
1708 
1709 }
1710 
1711 BitmapEx GDIMetaFile::ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam )
1712 {
1713  const ImplBmpAdjustParam* p = static_cast<const ImplBmpAdjustParam*>(pBmpParam);
1714  BitmapEx aRet( rBmpEx );
1715 
1718  p->fGamma, p->bInvert );
1719 
1720  return aRet;
1721 }
1722 
1723 Color GDIMetaFile::ImplColConvertFnc( const Color& rColor, const void* pColParam )
1724 {
1725  sal_uInt8 cLum = rColor.GetLuminance();
1726 
1727  if( MtfConversion::N1BitThreshold == static_cast<const ImplColConvertParam*>(pColParam)->eConversion )
1728  cLum = ( cLum < 128 ) ? 0 : 255;
1729 
1730  return Color( rColor.GetTransparency(), cLum, cLum, cLum );
1731 }
1732 
1733 BitmapEx GDIMetaFile::ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam )
1734 {
1735  BitmapEx aRet( rBmpEx );
1736 
1737  aRet.Convert( static_cast<const ImplBmpConvertParam*>(pBmpParam)->eConversion );
1738 
1739  return aRet;
1740 }
1741 
1742 Color GDIMetaFile::ImplColMonoFnc( const Color&, const void* pColParam )
1743 {
1744  return static_cast<const ImplColMonoParam*>(pColParam)->aColor;
1745 }
1746 
1747 BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam )
1748 {
1749  BitmapPalette aPal( 3 );
1750 
1751  aPal[ 0 ] = COL_BLACK;
1752  aPal[ 1 ] = COL_WHITE;
1753  aPal[ 2 ] = static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor;
1754 
1755  Bitmap aBmp( rBmpEx.GetSizePixel(), 4, &aPal );
1756  aBmp.Erase( static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor );
1757 
1758  if( rBmpEx.IsAlpha() )
1759  return BitmapEx( aBmp, rBmpEx.GetAlpha() );
1760  else if( rBmpEx.IsTransparent() )
1761  return BitmapEx( aBmp, rBmpEx.GetMask() );
1762  else
1763  return BitmapEx( aBmp );
1764 }
1765 
1766 Color GDIMetaFile::ImplColReplaceFnc( const Color& rColor, const void* pColParam )
1767 {
1768  const sal_uLong nR = rColor.GetRed(), nG = rColor.GetGreen(), nB = rColor.GetBlue();
1769 
1770  for( sal_uLong i = 0; i < static_cast<const ImplColReplaceParam*>(pColParam)->nCount; i++ )
1771  {
1772  if( ( static_cast<const ImplColReplaceParam*>(pColParam)->pMinR[ i ] <= nR ) &&
1773  ( static_cast<const ImplColReplaceParam*>(pColParam)->pMaxR[ i ] >= nR ) &&
1774  ( static_cast<const ImplColReplaceParam*>(pColParam)->pMinG[ i ] <= nG ) &&
1775  ( static_cast<const ImplColReplaceParam*>(pColParam)->pMaxG[ i ] >= nG ) &&
1776  ( static_cast<const ImplColReplaceParam*>(pColParam)->pMinB[ i ] <= nB ) &&
1777  ( static_cast<const ImplColReplaceParam*>(pColParam)->pMaxB[ i ] >= nB ) )
1778  {
1779  return static_cast<const ImplColReplaceParam*>(pColParam)->pDstCols[ i ];
1780  }
1781  }
1782 
1783  return rColor;
1784 }
1785 
1786 BitmapEx GDIMetaFile::ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam )
1787 {
1788  const ImplBmpReplaceParam* p = static_cast<const ImplBmpReplaceParam*>(pBmpParam);
1789  BitmapEx aRet( rBmpEx );
1790 
1791  aRet.Replace( p->pSrcCols, p->pDstCols, p->nCount );
1792 
1793  return aRet;
1794 }
1795 
1796 void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
1797  BmpExchangeFnc pFncBmp, const void* pBmpParam )
1798 {
1799  GDIMetaFile aMtf;
1800 
1801  aMtf.m_aPrefSize = m_aPrefSize;
1803  aMtf.m_bUseCanvas = m_bUseCanvas;
1804 
1805  for( MetaAction* pAction = FirstAction(); pAction; pAction = NextAction() )
1806  {
1807  const MetaActionType nType = pAction->GetType();
1808 
1809  switch( nType )
1810  {
1811  case MetaActionType::PIXEL:
1812  {
1813  MetaPixelAction* pAct = static_cast<MetaPixelAction*>(pAction);
1814  aMtf.push_back( new MetaPixelAction( pAct->GetPoint(), pFncCol( pAct->GetColor(), pColParam ) ) );
1815  }
1816  break;
1817 
1819  {
1820  MetaLineColorAction* pAct = static_cast<MetaLineColorAction*>(pAction);
1821 
1822  if( pAct->IsSetting() )
1823  pAct = new MetaLineColorAction( pFncCol( pAct->GetColor(), pColParam ), true );
1824 
1825  aMtf.push_back( pAct );
1826  }
1827  break;
1828 
1830  {
1831  MetaFillColorAction* pAct = static_cast<MetaFillColorAction*>(pAction);
1832 
1833  if( pAct->IsSetting() )
1834  pAct = new MetaFillColorAction( pFncCol( pAct->GetColor(), pColParam ), true );
1835 
1836  aMtf.push_back( pAct );
1837  }
1838  break;
1839 
1841  {
1842  MetaTextColorAction* pAct = static_cast<MetaTextColorAction*>(pAction);
1843  aMtf.push_back( new MetaTextColorAction( pFncCol( pAct->GetColor(), pColParam ) ) );
1844  }
1845  break;
1846 
1848  {
1849  MetaTextFillColorAction* pAct = static_cast<MetaTextFillColorAction*>(pAction);
1850 
1851  if( pAct->IsSetting() )
1852  pAct = new MetaTextFillColorAction( pFncCol( pAct->GetColor(), pColParam ), true );
1853 
1854  aMtf.push_back( pAct );
1855  }
1856  break;
1857 
1859  {
1860  MetaTextLineColorAction* pAct = static_cast<MetaTextLineColorAction*>(pAction);
1861 
1862  if( pAct->IsSetting() )
1863  pAct = new MetaTextLineColorAction( pFncCol( pAct->GetColor(), pColParam ), true );
1864 
1865  aMtf.push_back( pAct );
1866  }
1867  break;
1868 
1870  {
1871  MetaOverlineColorAction* pAct = static_cast<MetaOverlineColorAction*>(pAction);
1872 
1873  if( pAct->IsSetting() )
1874  pAct = new MetaOverlineColorAction( pFncCol( pAct->GetColor(), pColParam ), true );
1875 
1876  aMtf.push_back( pAct );
1877  }
1878  break;
1879 
1880  case MetaActionType::FONT:
1881  {
1882  MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction);
1883  vcl::Font aFont( pAct->GetFont() );
1884 
1885  aFont.SetColor( pFncCol( aFont.GetColor(), pColParam ) );
1886  aFont.SetFillColor( pFncCol( aFont.GetFillColor(), pColParam ) );
1887  aMtf.push_back( new MetaFontAction( aFont ) );
1888  }
1889  break;
1890 
1892  {
1893  MetaWallpaperAction* pAct = static_cast<MetaWallpaperAction*>(pAction);
1894  Wallpaper aWall( pAct->GetWallpaper() );
1895  const tools::Rectangle& rRect = pAct->GetRect();
1896 
1897  aWall.SetColor( pFncCol( aWall.GetColor(), pColParam ) );
1898 
1899  if( aWall.IsBitmap() )
1900  aWall.SetBitmap( pFncBmp( aWall.GetBitmap(), pBmpParam ) );
1901 
1902  if( aWall.IsGradient() )
1903  {
1904  Gradient aGradient( aWall.GetGradient() );
1905 
1906  aGradient.SetStartColor( pFncCol( aGradient.GetStartColor(), pColParam ) );
1907  aGradient.SetEndColor( pFncCol( aGradient.GetEndColor(), pColParam ) );
1908  aWall.SetGradient( aGradient );
1909  }
1910 
1911  aMtf.push_back( new MetaWallpaperAction( rRect, aWall ) );
1912  }
1913  break;
1914 
1915  case MetaActionType::BMP:
1916  case MetaActionType::BMPEX:
1917  case MetaActionType::MASK:
1918  {
1919  OSL_FAIL( "Don't use bitmap actions of this type in metafiles!" );
1920  }
1921  break;
1922 
1924  {
1925  MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
1926  aMtf.push_back( new MetaBmpScaleAction( pAct->GetPoint(), pAct->GetSize(),
1927  pFncBmp( BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() ) );
1928  }
1929  break;
1930 
1932  {
1933  MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
1934  aMtf.push_back( new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1935  pAct->GetSrcPoint(), pAct->GetSrcSize(),
1936  pFncBmp( BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() )
1937  );
1938  }
1939  break;
1940 
1942  {
1943  MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
1944  aMtf.push_back( new MetaBmpExScaleAction( pAct->GetPoint(), pAct->GetSize(),
1945  pFncBmp( pAct->GetBitmapEx(), pBmpParam ) )
1946  );
1947  }
1948  break;
1949 
1951  {
1952  MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
1953  aMtf.push_back( new MetaBmpExScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1954  pAct->GetSrcPoint(), pAct->GetSrcSize(),
1955  pFncBmp( pAct->GetBitmapEx(), pBmpParam ) )
1956  );
1957  }
1958  break;
1959 
1961  {
1962  MetaMaskScaleAction* pAct = static_cast<MetaMaskScaleAction*>(pAction);
1963  aMtf.push_back( new MetaMaskScaleAction( pAct->GetPoint(), pAct->GetSize(),
1964  pAct->GetBitmap(),
1965  pFncCol( pAct->GetColor(), pColParam ) )
1966  );
1967  }
1968  break;
1969 
1971  {
1972  MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
1973  aMtf.push_back( new MetaMaskScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1974  pAct->GetSrcPoint(), pAct->GetSrcSize(),
1975  pAct->GetBitmap(),
1976  pFncCol( pAct->GetColor(), pColParam ) )
1977  );
1978  }
1979  break;
1980 
1982  {
1983  MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
1984  Gradient aGradient( pAct->GetGradient() );
1985 
1986  aGradient.SetStartColor( pFncCol( aGradient.GetStartColor(), pColParam ) );
1987  aGradient.SetEndColor( pFncCol( aGradient.GetEndColor(), pColParam ) );
1988  aMtf.push_back( new MetaGradientAction( pAct->GetRect(), aGradient ) );
1989  }
1990  break;
1991 
1993  {
1994  MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
1995  Gradient aGradient( pAct->GetGradient() );
1996 
1997  aGradient.SetStartColor( pFncCol( aGradient.GetStartColor(), pColParam ) );
1998  aGradient.SetEndColor( pFncCol( aGradient.GetEndColor(), pColParam ) );
1999  aMtf.push_back( new MetaGradientExAction( pAct->GetPolyPolygon(), aGradient ) );
2000  }
2001  break;
2002 
2003  case MetaActionType::HATCH:
2004  {
2005  MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction);
2006  Hatch aHatch( pAct->GetHatch() );
2007 
2008  aHatch.SetColor( pFncCol( aHatch.GetColor(), pColParam ) );
2009  aMtf.push_back( new MetaHatchAction( pAct->GetPolyPolygon(), aHatch ) );
2010  }
2011  break;
2012 
2014  {
2015  MetaFloatTransparentAction* pAct = static_cast<MetaFloatTransparentAction*>(pAction);
2016  GDIMetaFile aTransMtf( pAct->GetGDIMetaFile() );
2017 
2018  aTransMtf.ImplExchangeColors( pFncCol, pColParam, pFncBmp, pBmpParam );
2019  aMtf.push_back( new MetaFloatTransparentAction( aTransMtf,
2020  pAct->GetPoint(), pAct->GetSize(),
2021  pAct->GetGradient() )
2022  );
2023  }
2024  break;
2025 
2026  case MetaActionType::EPS:
2027  {
2028  MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
2029  GDIMetaFile aSubst( pAct->GetSubstitute() );
2030 
2031  aSubst.ImplExchangeColors( pFncCol, pColParam, pFncBmp, pBmpParam );
2032  aMtf.push_back( new MetaEPSAction( pAct->GetPoint(), pAct->GetSize(),
2033  pAct->GetLink(), aSubst )
2034  );
2035  }
2036  break;
2037 
2038  default:
2039  {
2040  aMtf.push_back( pAction );
2041  }
2042  break;
2043  }
2044  }
2045 
2046  *this = aMtf;
2047 }
2048 
2049 void GDIMetaFile::Adjust( short nLuminancePercent, short nContrastPercent,
2050  short nChannelRPercent, short nChannelGPercent,
2051  short nChannelBPercent, double fGamma, bool bInvert, bool msoBrightness )
2052 {
2053  // nothing to do? => return quickly
2054  if( !(nLuminancePercent || nContrastPercent ||
2055  nChannelRPercent || nChannelGPercent || nChannelBPercent ||
2056  ( fGamma != 1.0 ) || bInvert) )
2057  return;
2058 
2059  double fM, fROff, fGOff, fBOff, fOff;
2060  ImplColAdjustParam aColParam;
2061  ImplBmpAdjustParam aBmpParam;
2062 
2063  aColParam.pMapR.reset(new sal_uInt8[ 256 ]);
2064  aColParam.pMapG.reset(new sal_uInt8[ 256 ]);
2065  aColParam.pMapB.reset(new sal_uInt8[ 256 ]);
2066 
2067  // calculate slope
2068  if( nContrastPercent >= 0 )
2069  fM = 128.0 / ( 128.0 - 1.27 * MinMax( nContrastPercent, 0, 100 ) );
2070  else
2071  fM = ( 128.0 + 1.27 * MinMax( nContrastPercent, -100, 0 ) ) / 128.0;
2072 
2073  if(!msoBrightness)
2074  // total offset = luminance offset + contrast offset
2075  fOff = MinMax( nLuminancePercent, -100, 100 ) * 2.55 + 128.0 - fM * 128.0;
2076  else
2077  fOff = MinMax( nLuminancePercent, -100, 100 ) * 2.55;
2078 
2079  // channel offset = channel offset + total offset
2080  fROff = nChannelRPercent * 2.55 + fOff;
2081  fGOff = nChannelGPercent * 2.55 + fOff;
2082  fBOff = nChannelBPercent * 2.55 + fOff;
2083 
2084  // calculate gamma value
2085  fGamma = ( fGamma <= 0.0 || fGamma > 10.0 ) ? 1.0 : ( 1.0 / fGamma );
2086  const bool bGamma = ( fGamma != 1.0 );
2087 
2088  // create mapping table
2089  for( long nX = 0; nX < 256; nX++ )
2090  {
2091  if(!msoBrightness)
2092  {
2093  aColParam.pMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fROff ), 0, 255 ));
2094  aColParam.pMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fGOff ), 0, 255 ));
2095  aColParam.pMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fBOff ), 0, 255 ));
2096  }
2097  else
2098  {
2099  aColParam.pMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 ));
2100  aColParam.pMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 ));
2101  aColParam.pMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 ));
2102  }
2103  if( bGamma )
2104  {
2105  aColParam.pMapR[ nX ] = GAMMA( aColParam.pMapR[ nX ], fGamma );
2106  aColParam.pMapG[ nX ] = GAMMA( aColParam.pMapG[ nX ], fGamma );
2107  aColParam.pMapB[ nX ] = GAMMA( aColParam.pMapB[ nX ], fGamma );
2108  }
2109 
2110  if( bInvert )
2111  {
2112  aColParam.pMapR[ nX ] = ~aColParam.pMapR[ nX ];
2113  aColParam.pMapG[ nX ] = ~aColParam.pMapG[ nX ];
2114  aColParam.pMapB[ nX ] = ~aColParam.pMapB[ nX ];
2115  }
2116  }
2117 
2118  aBmpParam.nLuminancePercent = nLuminancePercent;
2119  aBmpParam.nContrastPercent = nContrastPercent;
2120  aBmpParam.nChannelRPercent = nChannelRPercent;
2121  aBmpParam.nChannelGPercent = nChannelGPercent;
2122  aBmpParam.nChannelBPercent = nChannelBPercent;
2123  aBmpParam.fGamma = fGamma;
2124  aBmpParam.bInvert = bInvert;
2125 
2126  // do color adjustment
2127  ImplExchangeColors( ImplColAdjustFnc, &aColParam, ImplBmpAdjustFnc, &aBmpParam );
2128 }
2129 
2131 {
2132  ImplColConvertParam aColParam;
2133  ImplBmpConvertParam aBmpParam;
2134 
2135  aColParam.eConversion = eConversion;
2137 
2138  ImplExchangeColors( ImplColConvertFnc, &aColParam, ImplBmpConvertFnc, &aBmpParam );
2139 }
2140 
2141 void GDIMetaFile::ReplaceColors( const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount )
2142 {
2143  ImplColReplaceParam aColParam;
2144  ImplBmpReplaceParam aBmpParam;
2145 
2146  aColParam.pMinR.reset(new sal_uLong[ nColorCount ]);
2147  aColParam.pMaxR.reset(new sal_uLong[ nColorCount ]);
2148  aColParam.pMinG.reset(new sal_uLong[ nColorCount ]);
2149  aColParam.pMaxG.reset(new sal_uLong[ nColorCount ]);
2150  aColParam.pMinB.reset(new sal_uLong[ nColorCount ]);
2151  aColParam.pMaxB.reset(new sal_uLong[ nColorCount ]);
2152 
2153  for( sal_uLong i = 0; i < nColorCount; i++ )
2154  {
2155  long nVal;
2156 
2157  nVal = pSearchColors[ i ].GetRed();
2158  aColParam.pMinR[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L ));
2159  aColParam.pMaxR[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L ));
2160 
2161  nVal = pSearchColors[ i ].GetGreen();
2162  aColParam.pMinG[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L ));
2163  aColParam.pMaxG[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L ));
2164 
2165  nVal = pSearchColors[ i ].GetBlue();
2166  aColParam.pMinB[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L ));
2167  aColParam.pMaxB[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L ));
2168  }
2169 
2170  aColParam.pDstCols = pReplaceColors;
2171  aColParam.nCount = nColorCount;
2172 
2173  aBmpParam.pSrcCols = pSearchColors;
2174  aBmpParam.pDstCols = pReplaceColors;
2175  aBmpParam.nCount = nColorCount;
2176 
2177  ImplExchangeColors( ImplColReplaceFnc, &aColParam, ImplBmpReplaceFnc, &aBmpParam );
2178 };
2179 
2181 {
2182  GDIMetaFile aRet( *this );
2183 
2184  ImplColMonoParam aColParam;
2185  ImplBmpMonoParam aBmpParam;
2186 
2187  aColParam.aColor = rColor;
2188  aBmpParam.aColor = rColor;
2189 
2190  aRet.ImplExchangeColors( ImplColMonoFnc, &aColParam, ImplBmpMonoFnc, &aBmpParam );
2191 
2192  return aRet;
2193 }
2194 
2196 {
2197  GDIMetaFile aMtf;
2198  SvMemoryStream aMemStm( 65535, 65535 );
2199  ImplMetaWriteData aWriteData;
2200  SVBT16 aBT16;
2201  SVBT32 aBT32;
2203  BitmapChecksum nCrc = 0;
2204 
2205  aWriteData.meActualCharSet = aMemStm.GetStreamCharSet();
2206  for( size_t i = 0, nObjCount = GetActionSize(); i < nObjCount; i++ )
2207  {
2208  MetaAction* pAction = GetAction( i );
2209 
2210  switch( pAction->GetType() )
2211  {
2212  case MetaActionType::BMP:
2213  {
2214  MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pAction);
2215 
2216  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2217  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2218 
2219  BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2220  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2221 
2222  Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
2223  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2224 
2225  Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
2226  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2227  }
2228  break;
2229 
2231  {
2232  MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
2233 
2234  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2235  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2236 
2237  BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2238  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2239 
2240  Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
2241  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2242 
2243  Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
2244  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2245 
2246  Int32ToSVBT32( pAct->GetSize().Width(), aBT32 );
2247  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2248 
2249  Int32ToSVBT32( pAct->GetSize().Height(), aBT32 );
2250  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2251  }
2252  break;
2253 
2255  {
2256  MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
2257 
2258  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2259  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2260 
2261  BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2262  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2263 
2264  Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
2265  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2266 
2267  Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
2268  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2269 
2270  Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
2271  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2272 
2273  Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
2274  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2275 
2276  Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
2277  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2278 
2279  Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
2280  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2281 
2282  Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
2283  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2284 
2285  Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
2286  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2287  }
2288  break;
2289 
2290  case MetaActionType::BMPEX:
2291  {
2292  MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pAction);
2293 
2294  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2295  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2296 
2297  BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
2298  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2299 
2300  Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
2301  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2302 
2303  Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
2304  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2305  }
2306  break;
2307 
2309  {
2310  MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
2311 
2312  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2313  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2314 
2315  BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
2316  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2317 
2318  Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
2319  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2320 
2321  Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
2322  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2323 
2324  Int32ToSVBT32( pAct->GetSize().Width(), aBT32 );
2325  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2326 
2327  Int32ToSVBT32( pAct->GetSize().Height(), aBT32 );
2328  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2329  }
2330  break;
2331 
2333  {
2334  MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
2335 
2336  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2337  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2338 
2339  BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
2340  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2341 
2342  Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
2343  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2344 
2345  Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
2346  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2347 
2348  Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
2349  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2350 
2351  Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
2352  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2353 
2354  Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
2355  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2356 
2357  Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
2358  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2359 
2360  Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
2361  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2362 
2363  Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
2364  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2365  }
2366  break;
2367 
2368  case MetaActionType::MASK:
2369  {
2370  MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pAction);
2371 
2372  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2373  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2374 
2375  BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2376  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2377 
2378  UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 );
2379  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2380 
2381  Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
2382  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2383 
2384  Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
2385  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2386  }
2387  break;
2388 
2390  {
2391  MetaMaskScaleAction* pAct = static_cast<MetaMaskScaleAction*>(pAction);
2392 
2393  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2394  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2395 
2396  BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2397  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2398 
2399  UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 );
2400  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2401 
2402  Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
2403  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2404 
2405  Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
2406  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2407 
2408  Int32ToSVBT32( pAct->GetSize().Width(), aBT32 );
2409  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2410 
2411  Int32ToSVBT32( pAct->GetSize().Height(), aBT32 );
2412  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2413  }
2414  break;
2415 
2417  {
2418  MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pAction);
2419 
2420  ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2421  nCrc = vcl_get_checksum( nCrc, aBT16, 2 );
2422 
2423  BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2424  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
2425 
2426  UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 );
2427  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2428 
2429  Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
2430  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2431 
2432  Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
2433  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2434 
2435  Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
2436  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2437 
2438  Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
2439  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2440 
2441  Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
2442  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2443 
2444  Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
2445  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2446 
2447  Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
2448  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2449 
2450  Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
2451  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
2452  }
2453  break;
2454 
2455  case MetaActionType::EPS :
2456  {
2457  MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
2458  nCrc = vcl_get_checksum( nCrc, pAct->GetLink().GetData(), pAct->GetLink().GetDataSize() );
2459  }
2460  break;
2461 
2463  {
2464  MetaClipRegionAction& rAct = static_cast<MetaClipRegionAction&>(*pAction);
2465  const vcl::Region& rRegion = rAct.GetRegion();
2466 
2467  if(rRegion.HasPolyPolygonOrB2DPolyPolygon())
2468  {
2469  // It has shown that this is a possible bottleneck for checksum calculation.
2470  // In worst case a very expensive RegionHandle representation gets created.
2471  // In this case it's cheaper to use the PolyPolygon
2472  const basegfx::B2DPolyPolygon aPolyPolygon(rRegion.GetAsB2DPolyPolygon());
2473  SVBT64 aSVBT64;
2474 
2475  for(auto const& rPolygon : aPolyPolygon)
2476  {
2477  const sal_uInt32 nPointCount(rPolygon.count());
2478  const bool bControl(rPolygon.areControlPointsUsed());
2479 
2480  for(sal_uInt32 b(0); b < nPointCount; b++)
2481  {
2482  const basegfx::B2DPoint aPoint(rPolygon.getB2DPoint(b));
2483 
2484  DoubleToSVBT64(aPoint.getX(), aSVBT64);
2485  nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
2486  DoubleToSVBT64(aPoint.getY(), aSVBT64);
2487  nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
2488 
2489  if(bControl)
2490  {
2491  if(rPolygon.isPrevControlPointUsed(b))
2492  {
2493  const basegfx::B2DPoint aCtrl(rPolygon.getPrevControlPoint(b));
2494 
2495  DoubleToSVBT64(aCtrl.getX(), aSVBT64);
2496  nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
2497  DoubleToSVBT64(aCtrl.getY(), aSVBT64);
2498  nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
2499  }
2500 
2501  if(rPolygon.isNextControlPointUsed(b))
2502  {
2503  const basegfx::B2DPoint aCtrl(rPolygon.getNextControlPoint(b));
2504 
2505  DoubleToSVBT64(aCtrl.getX(), aSVBT64);
2506  nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
2507  DoubleToSVBT64(aCtrl.getY(), aSVBT64);
2508  nCrc = vcl_get_checksum(nCrc, aSVBT64, 8);
2509  }
2510  }
2511  }
2512  }
2513 
2514  sal_uInt8 tmp = static_cast<sal_uInt8>(rAct.IsClipping());
2515  nCrc = vcl_get_checksum(nCrc, &tmp, 1);
2516  }
2517  else
2518  {
2519  pAction->Write( aMemStm, &aWriteData );
2520  nCrc = vcl_get_checksum( nCrc, aMemStm.GetData(), aMemStm.Tell() );
2521  aMemStm.Seek( 0 );
2522  }
2523  }
2524  break;
2525 
2526  default:
2527  {
2528  pAction->Write( aMemStm, &aWriteData );
2529  nCrc = vcl_get_checksum( nCrc, aMemStm.GetData(), aMemStm.Tell() );
2530  aMemStm.Seek( 0 );
2531  }
2532  break;
2533  }
2534  }
2535 
2536  return nCrc;
2537 }
2538 
2540 {
2541  sal_uLong nSizeBytes = 0;
2542 
2543  for( size_t i = 0, nObjCount = GetActionSize(); i < nObjCount; ++i )
2544  {
2545  MetaAction* pAction = GetAction( i );
2546 
2547  // default action size is set to 32 (=> not the exact value)
2548  nSizeBytes += 32;
2549 
2550  // add sizes for large action content
2551  switch( pAction->GetType() )
2552  {
2553  case MetaActionType::BMP: nSizeBytes += static_cast<MetaBmpAction*>( pAction )->GetBitmap().GetSizeBytes(); break;
2554  case MetaActionType::BMPSCALE: nSizeBytes += static_cast<MetaBmpScaleAction*>( pAction )->GetBitmap().GetSizeBytes(); break;
2555  case MetaActionType::BMPSCALEPART: nSizeBytes += static_cast<MetaBmpScalePartAction*>( pAction )->GetBitmap().GetSizeBytes(); break;
2556 
2557  case MetaActionType::BMPEX: nSizeBytes += static_cast<MetaBmpExAction*>( pAction )->GetBitmapEx().GetSizeBytes(); break;
2558  case MetaActionType::BMPEXSCALE: nSizeBytes += static_cast<MetaBmpExScaleAction*>( pAction )->GetBitmapEx().GetSizeBytes(); break;
2559  case MetaActionType::BMPEXSCALEPART: nSizeBytes += static_cast<MetaBmpExScalePartAction*>( pAction )->GetBitmapEx().GetSizeBytes(); break;
2560 
2561  case MetaActionType::MASK: nSizeBytes += static_cast<MetaMaskAction*>( pAction )->GetBitmap().GetSizeBytes(); break;
2562  case MetaActionType::MASKSCALE: nSizeBytes += static_cast<MetaMaskScaleAction*>( pAction )->GetBitmap().GetSizeBytes(); break;
2563  case MetaActionType::MASKSCALEPART: nSizeBytes += static_cast<MetaMaskScalePartAction*>( pAction )->GetBitmap().GetSizeBytes(); break;
2564 
2565  case MetaActionType::POLYLINE: nSizeBytes += static_cast<MetaPolyLineAction*>( pAction )->GetPolygon().GetSize() * sizeof( Point ); break;
2566  case MetaActionType::POLYGON: nSizeBytes += static_cast<MetaPolygonAction*>( pAction )->GetPolygon().GetSize() * sizeof( Point ); break;
2568  {
2569  const tools::PolyPolygon& rPolyPoly = static_cast<MetaPolyPolygonAction*>( pAction )->GetPolyPolygon();
2570 
2571  for( sal_uInt16 n = 0; n < rPolyPoly.Count(); ++n )
2572  nSizeBytes += ( rPolyPoly[ n ].GetSize() * sizeof( Point ) );
2573  }
2574  break;
2575 
2576  case MetaActionType::TEXT: nSizeBytes += static_cast<MetaTextAction*>( pAction )->GetText().getLength() * sizeof( sal_Unicode ); break;
2577  case MetaActionType::STRETCHTEXT: nSizeBytes += static_cast<MetaStretchTextAction*>( pAction )->GetText().getLength() * sizeof( sal_Unicode ); break;
2578  case MetaActionType::TEXTRECT: nSizeBytes += static_cast<MetaTextRectAction*>( pAction )->GetText().getLength() * sizeof( sal_Unicode ); break;
2580  {
2581  MetaTextArrayAction* pTextArrayAction = static_cast<MetaTextArrayAction*>(pAction);
2582 
2583  nSizeBytes += ( pTextArrayAction->GetText().getLength() * sizeof( sal_Unicode ) );
2584 
2585  if( pTextArrayAction->GetDXArray() )
2586  nSizeBytes += ( pTextArrayAction->GetLen() << 2 );
2587  }
2588  break;
2589  default: break;
2590  }
2591  }
2592 
2593  return nSizeBytes;
2594 }
2595 
2596 namespace
2597 {
2598  class DepthGuard
2599  {
2600  private:
2601  ImplMetaReadData& m_rData;
2602  rtl_TextEncoding const m_eOrigCharSet;
2603  public:
2604  DepthGuard(ImplMetaReadData& rData, SvStream const & rIStm)
2605  : m_rData(rData)
2606  , m_eOrigCharSet(m_rData.meActualCharSet)
2607  {
2608  ++m_rData.mnParseDepth;
2609  m_rData.meActualCharSet = rIStm.GetStreamCharSet();
2610  }
2611  bool TooDeep() const { return m_rData.mnParseDepth > 1024; }
2612  ~DepthGuard()
2613  {
2614  --m_rData.mnParseDepth;
2615  m_rData.meActualCharSet = m_eOrigCharSet;
2616  }
2617  };
2618 }
2619 
2621 {
2622  if (rIStm.GetError())
2623  {
2624  SAL_WARN("vcl.gdi", "Stream error: " << rIStm.GetError());
2625  return rIStm;
2626  }
2627 
2628  sal_uLong nStmPos = rIStm.Tell();
2629  SvStreamEndian nOldFormat = rIStm.GetEndian();
2630 
2631  rIStm.SetEndian( SvStreamEndian::LITTLE );
2632 
2633  try
2634  {
2635  char aId[7];
2636  aId[0] = 0;
2637  aId[6] = 0;
2638  rIStm.ReadBytes( aId, 6 );
2639 
2640  if ( !strcmp( aId, "VCLMTF" ) )
2641  {
2642  // new format
2643  sal_uInt32 nStmCompressMode = 0;
2644  sal_uInt32 nCount = 0;
2645  std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
2646 
2647  rIStm.ReadUInt32( nStmCompressMode );
2648  ReadMapMode( rIStm, rGDIMetaFile.m_aPrefMapMode );
2649  ReadPair( rIStm, rGDIMetaFile.m_aPrefSize );
2650  rIStm.ReadUInt32( nCount );
2651 
2652  pCompat.reset(); // destructor writes stuff into the header
2653 
2654  std::unique_ptr<ImplMetaReadData> xReadData;
2655  if (!pData)
2656  {
2657  xReadData.reset(new ImplMetaReadData);
2658  pData = xReadData.get();
2659  }
2660  DepthGuard aDepthGuard(*pData, rIStm);
2661 
2662  if (aDepthGuard.TooDeep())
2663  throw std::runtime_error("too much recursion");
2664 
2665  for( sal_uInt32 nAction = 0; ( nAction < nCount ) && !rIStm.eof(); nAction++ )
2666  {
2667  MetaAction* pAction = MetaAction::ReadMetaAction(rIStm, pData);
2668  if( pAction )
2669  {
2670  if (pAction->GetType() == MetaActionType::COMMENT)
2671  {
2672  MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
2673  if ( pCommentAct->GetComment() == "EMF_PLUS" )
2674  rGDIMetaFile.UseCanvas( true );
2675  }
2676  rGDIMetaFile.AddAction( pAction );
2677  }
2678  }
2679  }
2680  else
2681  {
2682  rIStm.Seek( nStmPos );
2683  SVMConverter( rIStm, rGDIMetaFile );
2684  }
2685  }
2686  catch (...)
2687  {
2688  SAL_WARN("vcl", "GDIMetaFile exception during load");
2690  };
2691 
2692  // check for errors
2693  if( rIStm.GetError() )
2694  {
2695  rGDIMetaFile.Clear();
2696  rIStm.Seek( nStmPos );
2697  }
2698 
2699  rIStm.SetEndian( nOldFormat );
2700  return rIStm;
2701 }
2702 
2703 SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile )
2704 {
2705  if( !rOStm.GetError() )
2706  {
2707  const_cast< GDIMetaFile& >( rGDIMetaFile ).Write( rOStm );
2708  }
2709  return rOStm;
2710 }
2711 
2713 {
2714  Clear();
2715  ReadGDIMetaFile( rIStm, *this );
2716 
2717  return rIStm;
2718 }
2719 
2721 {
2722  VersionCompat* pCompat;
2723  const SvStreamCompressFlags nStmCompressMode = rOStm.GetCompressMode();
2724  SvStreamEndian nOldFormat = rOStm.GetEndian();
2725 
2726  rOStm.SetEndian( SvStreamEndian::LITTLE );
2727  rOStm.WriteBytes( "VCLMTF", 6 );
2728 
2729  pCompat = new VersionCompat( rOStm, StreamMode::WRITE, 1 );
2730 
2731  rOStm.WriteUInt32( static_cast<sal_uInt32>(nStmCompressMode) );
2732  WriteMapMode( rOStm, m_aPrefMapMode );
2733  WritePair( rOStm, m_aPrefSize );
2734  rOStm.WriteUInt32( GetActionSize() );
2735 
2736  delete pCompat;
2737 
2738  ImplMetaWriteData aWriteData;
2739 
2740  aWriteData.meActualCharSet = rOStm.GetStreamCharSet();
2741 
2742  MetaAction* pAct = FirstAction();
2743  while ( pAct )
2744  {
2745  pAct->Write( rOStm, &aWriteData );
2746  pAct = NextAction();
2747  }
2748 
2749  rOStm.SetEndian( nOldFormat );
2750 
2751  return rOStm;
2752 }
2753 
2754 bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, BmpConversion eColorConversion, BmpScaleFlag nScaleFlag) const
2755 {
2756  // initialization seems to be complicated but is used to avoid rounding errors
2758  const Point aNullPt;
2759  const Point aTLPix( aVDev->LogicToPixel( aNullPt, GetPrefMapMode() ) );
2760  const Point aBRPix( aVDev->LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) );
2761  Size aDrawSize( aVDev->LogicToPixel( GetPrefSize(), GetPrefMapMode() ) );
2762  Size aSizePix( labs( aBRPix.X() - aTLPix.X() ) + 1, labs( aBRPix.Y() - aTLPix.Y() ) + 1 );
2763  sal_uInt32 nMaximumExtent = 256;
2764 
2765  if (!rBitmapEx.IsEmpty())
2766  rBitmapEx.SetEmpty();
2767 
2768  // determine size that has the same aspect ratio as image size and
2769  // fits into the rectangle determined by nMaximumExtent
2770  if ( aSizePix.Width() && aSizePix.Height()
2771  && ( sal::static_int_cast< unsigned long >(aSizePix.Width()) >
2772  nMaximumExtent ||
2773  sal::static_int_cast< unsigned long >(aSizePix.Height()) >
2774  nMaximumExtent ) )
2775  {
2776  const Size aOldSizePix( aSizePix );
2777  double fWH = static_cast< double >( aSizePix.Width() ) / aSizePix.Height();
2778 
2779  if ( fWH <= 1.0 )
2780  {
2781  aSizePix.setWidth( FRound( nMaximumExtent * fWH ) );
2782  aSizePix.setHeight( nMaximumExtent );
2783  }
2784  else
2785  {
2786  aSizePix.setWidth( nMaximumExtent );
2787  aSizePix.setHeight( FRound( nMaximumExtent / fWH ) );
2788  }
2789 
2790  aDrawSize.setWidth( FRound( ( static_cast< double >( aDrawSize.Width() ) * aSizePix.Width() ) / aOldSizePix.Width() ) );
2791  aDrawSize.setHeight( FRound( ( static_cast< double >( aDrawSize.Height() ) * aSizePix.Height() ) / aOldSizePix.Height() ) );
2792  }
2793 
2794  // draw image(s) into VDev and get resulting image
2795  // do it 4x larger to be able to scale it down & get beautiful antialias
2796  Size aAntialiasSize(aSizePix.Width() * 4, aSizePix.Height() * 4);
2797  if (aVDev->SetOutputSizePixel(aAntialiasSize))
2798  {
2799  // antialias: provide 4x larger size, and then scale down the result
2800  Size aAntialias(aDrawSize.Width() * 4, aDrawSize.Height() * 4);
2801 
2802  // draw metafile into VDev
2803  const_cast<GDIMetaFile *>(this)->WindStart();
2804  const_cast<GDIMetaFile *>(this)->Play(aVDev.get(), Point(), aAntialias);
2805 
2806  // get paint bitmap
2807  BitmapEx aBitmap( aVDev->GetBitmapEx( aNullPt, aVDev->GetOutputSizePixel() ) );
2808 
2809  // scale down the image to the desired size - use the input scaler for the scaling operation
2810  aBitmap.Scale(aDrawSize, nScaleFlag);
2811 
2812  // convert to desired bitmap color format
2813  Size aSize(aBitmap.GetSizePixel());
2814  if (aSize.Width() && aSize.Height())
2815  aBitmap.Convert(eColorConversion);
2816 
2817  rBitmapEx = aBitmap;
2818  }
2819 
2820  return !rBitmapEx.IsEmpty();
2821 }
2822 
2823 void GDIMetaFile::UseCanvas( bool _bUseCanvas )
2824 {
2825  m_bUseCanvas = _bUseCanvas;
2826 }
2827 
2828 void GDIMetaFile::dumpAsXml(const char* pFileName) const
2829 {
2830  SvFileStream aStream(pFileName ? OUString::fromUtf8(pFileName) : OUString("metafile.xml"),
2831  StreamMode::STD_READWRITE | StreamMode::TRUNC);
2832  MetafileXmlDump aDumper;
2833  aDumper.dump(*this, aStream);
2834 }
2835 
2836 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 Count() const
static SAL_DLLPRIVATE BitmapEx ImplBmpAdjustFnc(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.cxx:1711
const Fraction & GetScaleX() const
Definition: mapmod.cxx:167
long Width() const
const Gradient & GetGradient() const
Definition: metaact.hxx:1560
void Mirror(BmpMirrorFlags nMirrorFlags)
Definition: gdimtf.cxx:571
OutDevType GetOutDevType() const
Definition: outdev.hxx:522
virtual void Execute(OutputDevice *pOut)
Definition: metaact.cxx:168
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:182
void dump(const GDIMetaFile &rMetaFile, SvStream &rStream)
The actual result that will be used for testing.
Definition: mtfxmldump.cxx:516
void SetDigitLanguage(LanguageType)
std::unique_ptr< sal_uInt8[]> pMapB
Definition: gdimtf.cxx:57
void SetPixelOffset(const Size &rOffset)
Set an offset in pixel.
Definition: map.cxx:1914
GDIMetaFile * m_pPrev
Definition: gdimtf.hxx:65
Bitmap GetMask() const
Definition: bitmapex.cxx:258
long GetWidth() const
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
const Size & GetDestSize() const
Definition: metaact.hxx:950
Definition: hatch.hxx:44
VclPtr< OutputDevice > m_pOutDev
Definition: gdimtf.hxx:67
const LineInfo & GetLineInfo() const
Definition: metaact.hxx:401
bool IsClipping() const
Definition: metaact.hxx:1103
void SetRelativeMapMode(const MapMode &rNewMapMode)
Definition: map.cxx:781
const Color & GetColor() const
Definition: metaact.hxx:1347
const Bitmap & GetBitmap() const
Definition: metaact.hxx:908
std::unique_ptr< sal_uLong[]> pMinG
Definition: gdimtf.cxx:95
sal_Int32 GetLen() const
Definition: metaact.hxx:492
MetaAction * GetCurAction() const
Definition: gdimtf.hxx:171
long GetHeight() const
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
const Point & GetPoint() const
Definition: metaact.hxx:701
sal_uInt8 GetRed() const
rtl_TextEncoding meActualCharSet
Definition: metaact.hxx:46
static MetaAction * ReadMetaAction(SvStream &rIStm, ImplMetaReadData *pData)
Definition: metaact.cxx:195
void ReplaceColors(const Color *pSearchColors, const Color *rReplaceColors, sal_uLong nColorCount)
Definition: gdimtf.cxx:2141
const Point & GetEndPoint() const
Definition: metaact.hxx:337
sal_uInt8 SVBT16[2]
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
long FRound(double fVal)
SAL_DLLPRIVATE bool ImplPlayWithRenderer(OutputDevice *pOut, const Point &rPos, Size rLogicDestSize)
Definition: gdimtf.cxx:360
const GDIMetaFile & GetGDIMetaFile() const
Definition: metaact.hxx:1557
void Replace(const Color &rSearchColor, const Color &rReplaceColor)
Replace all pixel having the search color with the specified color.
Definition: bitmapex.cxx:596
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Change various global color characteristics.
Definition: bitmapex.cxx:608
std::unique_ptr< sal_uLong[]> pMaxG
Definition: gdimtf.cxx:96
const Point & GetSrcPoint() const
Definition: metaact.hxx:739
sal_uInt32 GetVertRound() const
Definition: metaact.hxx:243
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1011
SvStream & WriteMapMode(SvStream &rOStm, const MapMode &rMapMode)
Definition: mapmod.cxx:149
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1678
GDIMetaFile & operator=(const GDIMetaFile &rMtf)
Definition: gdimtf.cxx:184
long Height() 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...
SvStream & WriteSvtGraphicStroke(SvStream &rOStm, const SvtGraphicStroke &rClass)
bool IsSetting() const
Definition: metaact.hxx:1294
const Point & GetPoint() const
Definition: metaact.hxx:526
SvStream & Read(SvStream &rIStm)
Definition: gdimtf.cxx:2712
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:241
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:176
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmapex.cxx:370
sal_uInt8 GetTransparency() const
sal_uIntPtr sal_uLong
MtfConversion
Definition: gdimtf.hxx:44
void dumpAsXml(const char *pFileName=nullptr) const
Dumps the meta actions as XML in metafile.xml.
Definition: gdimtf.cxx:2828
MetaAction * NextAction()
Definition: gdimtf.cxx:168
#define F_PI1800
sal_uLong nCount
Definition: gdimtf.cxx:107
sal_uInt8 GetLuminance() const
const Point & GetPoint() const
Definition: metaact.hxx:1594
Encapsulates geometry and associated attributes of a graphical 'pen stroke'.
short nChannelBPercent
Definition: gdimtf.cxx:66
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:174
const Point & GetPoint() const
Definition: metaact.hxx:1558
BmpConversion eConversion
Definition: gdimtf.cxx:78
void Clear()
Definition: gdimtf.cxx:243
static SAL_DLLPRIVATE Color ImplColMonoFnc(const Color &rColor, const void *pColParam)
Definition: gdimtf.cxx:1742
sal_uInt64 Seek(sal_uInt64 nPos)
const Size & GetSize() const
Definition: metaact.hxx:702
const MapMode & GetMapMode() const
Definition: outdev.hxx:1674
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1524
sal_Int32 GetIndex() const
Definition: metaact.hxx:528
void SetLayoutMode(ComplexTextLayoutFlags nTextLayoutMode)
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
Definition: checksum.hxx:72
const Point & GetEndPoint() const
Definition: metaact.hxx:181
GDIMetaFile * GetConnectMetaFile() const
Definition: outdev.hxx:417
const Color * pDstCols
Definition: gdimtf.cxx:99
const OUString & GetText() const
Definition: metaact.hxx:565
bool IsRecord() const
Definition: gdimtf.hxx:142
Size GetSizePixel() const
SvStream & ReadSvtGraphicStroke(SvStream &rIStm, SvtGraphicStroke &rClass)
static SAL_DLLPRIVATE void ImplAddGradientEx(GDIMetaFile &rMtf, const OutputDevice &rMapDev, const tools::PolyPolygon &rPolyPoly, const Gradient &rGrad)
Definition: gdimtf.cxx:773
const Size & GetSrcSize() const
Definition: metaact.hxx:740
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1214
void SetOrientation(short nLineOrientation)
Definition: font/font.cxx:191
SvStreamCompressFlags GetCompressMode() const
static SAL_DLLPRIVATE BitmapEx ImplBmpReplaceFnc(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.cxx:1786
void Clip(const tools::Rectangle &)
Definition: gdimtf.cxx:710
std::unique_ptr< sal_uInt8[]> pMapG
Definition: gdimtf.cxx:56
void SetMapMode()
Definition: map.cxx:655
const Point & GetPoint() const
Definition: metaact.hxx:910
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Definition: bitmapex.cxx:454
BitmapChecksum GetChecksum() const
Definition: bitmapex.cxx:292
SvStream & ReadSvtGraphicFill(SvStream &rIStm, SvtGraphicFill &rClass)
std::unique_ptr< sal_uLong[]> pMaxB
Definition: gdimtf.cxx:98
sal_uInt8 SVBT32[4]
void Move(long nHorzMoveDelta, long nVertMoveDelta)
const sal_uInt8 * GetData() const
Definition: metaact.hxx:1656
bool IsEmpty() const
sal_uInt16 sal_Unicode
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
void Rotate(long nAngle10)
Definition: gdimtf.cxx:795
bool IsAlpha() const
Definition: bitmapex.cxx:226
static SAL_DLLPRIVATE tools::Polygon ImplGetRotatedPolygon(const tools::Polygon &rPoly, const Point &rRotatePt, const Size &rOffset, double fSin, double fCos)
Definition: gdimtf.cxx:751
ErrCode GetError() const
const Point & GetPoint() const
Definition: metaact.hxx:802
void Record(OutputDevice *pOutDev)
Definition: gdimtf.cxx:284
void push_back(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:566
FUNC_TYPE const nType
bool eof() const
const OUString & GetText() const
Definition: metaact.hxx:490
const Color * pSrcCols
Definition: gdimtf.cxx:105
const Fraction & GetScaleY() const
Definition: mapmod.cxx:169
const Color & GetColor() const
Definition: metaact.hxx:874
SvStream & WriteGDIMetaFile(SvStream &rOStm, const GDIMetaFile &rGDIMetaFile)
Definition: gdimtf.cxx:2703
geometry::IntegerSize2D integerSize2DFromSize(const Size &rSize)
#define X
Definition: field.cxx:1015
const Bitmap & GetBitmap() const
Definition: metaact.hxx:668
void Rotate(const Point &rCenter, double fSin, double fCos)
void Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent=0, short nChannelGPercent=0, short nChannelBPercent=0, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Definition: gdimtf.cxx:2049
short nChannelRPercent
Definition: gdimtf.cxx:64
short nContrastPercent
Definition: gdimtf.cxx:63
long GetWidth() const
Definition: metaact.hxx:636
const vcl::Region & GetRegion() const
Definition: metaact.hxx:1102
bool CreateThumbnail(BitmapEx &rBitmapEx, BmpConversion nColorConversion=BmpConversion::N24Bit, BmpScaleFlag nScaleFlag=BmpScaleFlag::BestQuality) const
Creates an antialiased thumbnail.
Definition: gdimtf.cxx:2754
void SetStartColor(const Color &rColor)
const Gradient & GetGradient() const
Definition: metaact.hxx:982
SvStream & WriteUInt32(sal_uInt32 nUInt32)
const Point & GetStartPoint() const
Definition: metaact.hxx:303
const Color & GetColor() const
Definition: metaact.hxx:1214
MetaActionType
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1131
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:295
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:457
BitmapEx(* BmpExchangeFnc)(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.hxx:52
const Size & GetSize() const
Definition: metaact.hxx:803
GDIMetaFile GetMonochromeMtf(const Color &rCol) const
Definition: gdimtf.cxx:2180
sal_uInt8 GetBlue() const
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:271
FontLineStyle GetUnderline() const
Definition: metaact.hxx:638
Size m_aPrefSize
Definition: gdimtf.hxx:64
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:429
tools::PolyPolygon GetAsPolyPolygon() const
Definition: region.cxx:1261
sal_uInt32 GetHorzRound() const
Definition: metaact.hxx:242
std::unique_ptr< sal_uLong[]> pMinB
Definition: gdimtf.cxx:97
void Move(long nHorzMove, long nVertMove)
void Rotate(const Point &rCenter, double fSin, double fCos)
void setPath(const tools::PolyPolygon &rPath)
Set path to fill.
const vcl::Region & GetRegion() const
Definition: metaact.hxx:1159
static SAL_DLLPRIVATE tools::PolyPolygon ImplGetRotatedPolyPolygon(const tools::PolyPolygon &rPoly, const Point &rRotatePt, const Size &rOffset, double fSin, double fCos)
Definition: gdimtf.cxx:762
const Size & GetSrcSize() const
Definition: metaact.hxx:952
bool m_bPause
Definition: gdimtf.hxx:68
static SAL_DLLPRIVATE Point ImplGetRotatedPoint(const Point &rPt, const Point &rRotatePt, const Size &rOffset, double fSin, double fCos)
Definition: gdimtf.cxx:741
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
void SetEmpty()
Definition: bitmapex.cxx:208
static vcl::Window * GetFirstTopLevelWindow()
Get the first top-level window of the application.
Definition: svapp.cxx:1060
bool IsEmpty() const
Definition: bitmapex.cxx:203
void Move(long nHorzMove, long nVertMove)
sal_uLong nCount
Definition: gdimtf.cxx:100
bool GetUseCanvas() const
Definition: gdimtf.hxx:199
bool Create(const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas, const Size &rSize)
populate from a canvas implementation
Definition: bitmapex.cxx:772
#define BITMAP_CHECKSUM_SIZE
Definition: checksum.hxx:28
void SetConnectMetaFile(GDIMetaFile *pMtf)
Definition: outdev.cxx:208
void SetScaleX(const Fraction &rScaleX)
Definition: mapmod.cxx:107
#define TOOLS_WARN_EXCEPTION(area, stream)
friend VCL_DLLPUBLIC SvStream & ReadGDIMetaFile(SvStream &rIStm, GDIMetaFile &rGDIMetaFile, ImplMetaReadData *pReadData)
Definition: gdimtf.cxx:2620
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:210
static SAL_DLLPRIVATE BitmapEx ImplBmpConvertFnc(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.cxx:1733
const Size & GetPrefSize() const
Definition: gdimtf.hxx:173
~GDIMetaFile()
Definition: gdimtf.cxx:147
const tools::Polygon & GetPolygon() const
Definition: metaact.hxx:400
GDIMetaFile * m_pNext
Definition: gdimtf.hxx:66
::std::vector< rtl::Reference< MetaAction > > m_aList
Definition: gdimtf.hxx:60
sal_uInt16 GetTransparence() const
Definition: metaact.hxx:1525
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:837
virtual void Scale(double fScaleX, double fScaleY)
Definition: metaact.cxx:181
const Size & GetSize() const
Definition: metaact.hxx:911
const Point & GetDestPoint() const
Definition: metaact.hxx:838
const Point & GetPoint() const
Definition: metaact.hxx:489
SAL_DLLPRIVATE void ImplExchangeColors(ColorExchangeFnc pFncCol, const void *pColParam, BmpExchangeFnc pFncBmp, const void *pBmpParam)
Definition: gdimtf.cxx:1796
void Convert(MtfConversion eConversion)
Definition: gdimtf.cxx:2130
bool IsSetting() const
Definition: metaact.hxx:1215
std::unique_ptr< sal_uInt8[]> pMapR
Definition: gdimtf.cxx:55
#define LANGUAGE_SYSTEM
BitmapChecksum GetChecksum() const
Color(* ColorExchangeFnc)(const Color &rColor, const void *pColParam)
Definition: gdimtf.hxx:51
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:769
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:981
const OUString & GetText() const
Definition: metaact.hxx:527
int i
const Bitmap & GetBitmap() const
Definition: metaact.hxx:736
const Color & GetColor() const
Definition: metaact.hxx:1293
Size GetOutputSize() const
Definition: outdev.hxx:450
const Size & GetSize() const
Definition: metaact.hxx:1559
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:101
sal_uInt32 GetWidth() const
Definition: metaact.hxx:566
void SetRight(long v)
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
std::size_t WriteBytes(const void *pData, std::size_t nSize)
rtl_TextEncoding meActualCharSet
Definition: metaact.hxx:57
long * GetDXArray() const
Definition: metaact.hxx:530
const Point & GetEndPoint() const
Definition: metaact.hxx:304
SvStreamCompressFlags
BmpMirrorFlags
Definition: bitmap.hxx:36
void SetScaleY(const Fraction &rScaleY)
Definition: mapmod.cxx:114
void UseCanvas(bool _bUseCanvas)
Definition: gdimtf.cxx:2823
void SetError(ErrCode nErrorCode)
BmpScaleFlag
Definition: bitmap.hxx:48
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:584
void getPath(tools::Polygon &) const
Query path to stroke.
const Point & GetStartPoint() const
Definition: metaact.hxx:369
const Point & GetSrcPoint() const
Definition: metaact.hxx:840
sal_Int32 GetLen() const
Definition: metaact.hxx:568
const Point & GetPoint() const
Definition: metaact.hxx:770
bool m_bRecord
Definition: gdimtf.hxx:69
const Bitmap & GetBitmap() const
Definition: metaact.hxx:873
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
MapUnit GetMapUnit() const
Definition: mapmod.cxx:163
short nChannelGPercent
Definition: gdimtf.cxx:65
sal_uInt8 SVBT64[8]
SvStream & WritePair(SvStream &rOStream, const Pair &rPair)
BmpConversion
Definition: bitmap.hxx:65
void WindStart()
Definition: gdimtf.cxx:526
bool IsTransparent() const
Definition: bitmapex.cxx:221
const Bitmap & GetBitmap() const
Definition: metaact.hxx:947
const Point & GetPoint() const
Definition: metaact.hxx:875
long X() const
static vcl::Window * GetActiveTopWindow()
Get the "active" top window.
Definition: svapp.cxx:1104
static SAL_DLLPRIVATE Color ImplColAdjustFnc(const Color &rColor, const void *pColParam)
Definition: gdimtf.cxx:1702
FontStrikeout GetStrikeout() const
Definition: metaact.hxx:637
tools::Rectangle GetBoundRect(OutputDevice &i_rReference, tools::Rectangle *pHairline=nullptr) const
Definition: gdimtf.cxx:1280
#define Y
const Size & GetSize() const
Definition: metaact.hxx:1595
const Bitmap & GetBitmap() const
Definition: metaact.hxx:700
const Point & GetDestPoint() const
Definition: metaact.hxx:737
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:302
void SetColor(const Color &)
Definition: font/font.cxx:79
const Size & GetDestSize() const
Definition: metaact.hxx:738
PushFlags GetFlags() const
Definition: metaact.hxx:1452
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:368
std::size_t ReadBytes(void *pData, std::size_t nSize)
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1185
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:940
const tools::PolyPolygon & GetPolyPolygon() const
Definition: metaact.hxx:1041
SvStream & WriteSvtGraphicFill(SvStream &rOStm, const SvtGraphicFill &rClass)
const GfxLink & GetLink() const
Definition: metaact.hxx:1592
const Point & GetPoint() const
Definition: metaact.hxx:564
bool IsSetting() const
Definition: metaact.hxx:1348
void SetAngle(sal_uInt16 nAngle10)
Definition: gdi/hatch.cxx:74
bool IsSetting() const
Definition: metaact.hxx:1242
sal_uInt8 GetGreen() const
bool IsSetting() const
Definition: metaact.hxx:1321
SvStreamEndian GetEndian() const
const Color & GetColor() const
Definition: metaact.hxx:1267
void Stop()
Definition: gdimtf.cxx:513
const Color & GetColor() const
Definition: metaact.hxx:909
MapMode m_aPrefMapMode
Definition: gdimtf.hxx:63
const Point & GetStartPoint() const
Definition: metaact.hxx:180
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:1072
sal_uInt32 GetDataSize() const
Definition: metaact.hxx:1655
bool operator==(const GDIMetaFile &rMtf) const
Definition: gdimtf.cxx:217
const BitmapEx & GetBitmapEx() const
Definition: metaact.hxx:801
void Pause(bool bPause)
Definition: gdimtf.cxx:494
bool IsSetting() const
Definition: metaact.hxx:1622
const Point & GetStartPoint() const
Definition: metaact.hxx:336
AlphaMask GetAlpha() const
Definition: bitmapex.cxx:268
BitmapChecksum GetChecksum() const
Definition: gdimtf.cxx:2195
const Point & GetPoint() const
Definition: metaact.hxx:120
MtfConversion eConversion
Definition: gdimtf.cxx:73
const Size & GetSrcSize() const
Definition: metaact.hxx:841
const Color & GetColor() const
Definition: metaact.hxx:948
tools::Rectangle & Union(const tools::Rectangle &rRect)
unsigned char sal_uInt8
void ReplaceAction(rtl::Reference< MetaAction > pAction, size_t nAction)
Definition: gdimtf.cxx:173
void BCToBCOA(BitmapChecksum n, BitmapChecksumOctetArray p)
Definition: checksum.hxx:34
const Point & GetStartPoint() const
Definition: metaact.hxx:635
static SAL_DLLPRIVATE Color ImplColReplaceFnc(const Color &rColor, const void *pColParam)
Definition: gdimtf.cxx:1766
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:539
MetaAction * GetAction(size_t nAction) const
Definition: gdimtf.cxx:157
void Move(long nX, long nY)
Definition: gdimtf.cxx:607
SvStream & ReadGDIMetaFile(SvStream &rIStm, GDIMetaFile &rGDIMetaFile, ImplMetaReadData *pData)
Definition: gdimtf.cxx:2620
void SetEndian(SvStreamEndian SvStreamEndian)
#define SAL_INFO(area, stream)
const Gradient & GetGradient() const
Definition: metaact.hxx:1012
const Point & GetPoint() const
Definition: metaact.hxx:148
const Point & GetPoint() const
Definition: metaact.hxx:669
bool m_bUseCanvas
Definition: gdimtf.hxx:70
void Linker(OutputDevice *pOut, bool bLink)
Definition: gdimtf.cxx:251
const Point & GetDestPoint() const
Definition: metaact.hxx:949
#define SVSTREAM_FILEFORMAT_ERROR
Definition: errcode.hxx:262
rtl_TextEncoding GetStreamCharSet() const
void Scale(double fScaleX, double fScaleY)
Definition: gdimtf.cxx:684
static SAL_DLLPRIVATE BitmapEx ImplBmpMonoFnc(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.cxx:1747
bool HasPolyPolygonOrB2DPolyPolygon() const
Definition: region.hxx:110
sal_uInt64 Tell() const
Reference< XComponentContext > getProcessComponentContext()
size_t GetActionSize() const
Definition: gdimtf.cxx:152
short nLuminancePercent
Definition: gdimtf.cxx:62
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
const Wallpaper & GetWallpaper() const
Definition: metaact.hxx:1073
MetaActionType GetType() const
Definition: metaact.hxx:89
long Left() const
const Color & GetColor() const
Definition: metaact.hxx:1320
void setPath(const tools::Polygon &)
Set path to stroke.
long GetHorzMove() const
Definition: metaact.hxx:1187
std::unique_ptr< sal_uLong[]> pMaxR
Definition: gdimtf.cxx:94
const Point & GetEndPoint() const
Definition: metaact.hxx:370
const Hatch & GetHatch() const
Definition: metaact.hxx:1042
const Point & GetSrcPoint() const
Definition: metaact.hxx:951
FontLineStyle GetOverline() const
Definition: metaact.hxx:639
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
Definition: bitmappaint.cxx:34
const Color & GetColor() const
Definition: metaact.hxx:121
basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const
Definition: region.cxx:1289
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:335
long GetVertMove() const
Definition: metaact.hxx:1188
MetaAction * FirstAction()
Definition: gdimtf.cxx:162
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
Size GetPixelOffset() const
Get the offset in pixel.
Definition: outdev.hxx:1714
tools::Rectangle GetBoundRect() const
void Move(long nHorzMove, long nVertMove)
#define SAL_WARN(area, stream)
const Point & GetRefPoint() const
Definition: metaact.hxx:1621
DepthGuard(HWPFile &rFile)
sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE]
Definition: checksum.hxx:31
SvStreamEndian
SvStream & ReadMapMode(SvStream &rIStm, MapMode &rMapMode)
Definition: mapmod.cxx:135
const OString & GetComment() const
Definition: metaact.hxx:1653
const Color * pDstCols
Definition: gdimtf.cxx:106
Encapsulates geometry and associated attributes of a filled area.
tools::Rectangle GetBoundRect() const
static void ImplActionBounds(tools::Rectangle &o_rOutBounds, const tools::Rectangle &i_rInBounds, const std::vector< tools::Rectangle > &i_rClipStack, tools::Rectangle *o_pHairline)
Definition: gdimtf.cxx:1255
virtual void Move(long nHorzMove, long nVertMove)
Definition: metaact.cxx:177
size_t m_nCurrentActionElement
Definition: gdimtf.hxx:61
sal_Int32 GetLen() const
Definition: metaact.hxx:529
void getPath(tools::PolyPolygon &) const
Query path to fill.
SvStream & ReadPair(SvStream &rIStream, Pair &rPair)
Converts old SVGDI aka SVM1 format data to current VCLMTF aka SVM2 format metafile data...
const Size & GetDestSize() const
Definition: metaact.hxx:839
std::enable_if< std::is_signed< T >::value||std::is_floating_point< T >::value, long >::type MinMax(T nVal, long nMin, long nMax)
const Size & GetSizePixel() const
Definition: bitmapex.hxx:83
const Color & GetColor() const
Definition: metaact.hxx:1241
virtual void Write(SvStream &rOStm, ImplMetaWriteData *pData)
Definition: metaact.cxx:185
const GDIMetaFile & GetSubstitute() const
Definition: metaact.hxx:1593
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
void SetColor(const Color &rColor)
Definition: gdi/hatch.cxx:64
void setWidth(long nWidth)
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
Definition: bitmapex.cxx:434
const vcl::Font & GetFont() const
Definition: metaact.hxx:1427
const tools::Rectangle & GetRect() const
Definition: metaact.hxx:599
#define GAMMA(_def_cVal, _def_InvGamma)
Definition: gdimtf.cxx:51
aStr
sal_Int32 GetIndex() const
Definition: metaact.hxx:567
sal_Int32 GetIndex() const
Definition: metaact.hxx:491
std::unique_ptr< sal_uLong[]> pMinR
Definition: gdimtf.cxx:93
SvStream & Write(SvStream &rOStm)
Definition: gdimtf.cxx:2720
Point Center() const
long Y() const
static SAL_DLLPRIVATE Color ImplColConvertFnc(const Color &rColor, const void *pColParam)
Definition: gdimtf.cxx:1723
void WindPrev()
Definition: gdimtf.cxx:532
const void * GetData()
void setHeight(long nHeight)
bool Rotate(long nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
Definition: bitmapex.cxx:390
sal_uLong GetSizeBytes() const
Definition: gdimtf.cxx:2539