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