LibreOffice Module vcl (master)  1
map.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 <tools/bigint.hxx>
21 #include <tools/debug.hxx>
22 #include <vcl/cursor.hxx>
23 #include <vcl/gdimtf.hxx>
24 #include <vcl/lineinfo.hxx>
25 #include <vcl/metaact.hxx>
26 #include <vcl/virdev.hxx>
27 #include <vcl/wrkwin.hxx>
28 #include <sal/log.hxx>
29 #include <osl/diagnose.h>
30 
31 #include <svdata.hxx>
32 #include <window.h>
33 #include <outdev.h>
34 
36 #include <o3tl/enumarray.hxx>
37 
38 // we don't actually handle units beyond, hence the zeros in the arrays
39 const MapUnit s_MaxValidUnit = MapUnit::MapPixel;
41  { 1, 1, 5, 50, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 };
43  { 2540, 254, 127, 127, 1000, 100, 10, 1, 72, 1440, 1, 0, 0, 0 };
44 
45 /*
46 Reduces accuracy until it is a fraction (should become
47 ctor fraction once); we could also do this with BigInts
48 */
49 
50 static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 )
51 {
52  if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following while loop will be endless
53  {
54  SAL_WARN("vcl.gdi", "Invalid parameter for ImplMakeFraction");
55  return Fraction( 1, 1 );
56  }
57 
58  long i = 1;
59 
60  if ( nN1 < 0 ) { i = -i; nN1 = -nN1; }
61  if ( nN2 < 0 ) { i = -i; nN2 = -nN2; }
62  if ( nD1 < 0 ) { i = -i; nD1 = -nD1; }
63  if ( nD2 < 0 ) { i = -i; nD2 = -nD2; }
64  // all positive; i sign
65 
66  Fraction aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 );
67 
68  while ( !aF.IsValid() ) {
69  if ( nN1 > nN2 )
70  nN1 = (nN1 + 1) / 2;
71  else
72  nN2 = (nN2 + 1) / 2;
73  if ( nD1 > nD2 )
74  nD1 = (nD1 + 1) / 2;
75  else
76  nD2 = (nD2 + 1) / 2;
77 
78  aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 );
79  }
80 
81  aF.ReduceInaccurate(32);
82  return aF;
83 }
84 
85 // Fraction.GetNumerator()
86 // Fraction.GetDenominator() > 0
87 // rOutRes.nPixPerInch? > 0
88 // rMapRes.nMapScNum?
89 // rMapRes.nMapScDenom? > 0
90 
91 static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY,
92  const ImplMapRes& rMapRes,
93  ImplThresholdRes& rThresRes )
94 {
95  if ( nDPIX && (LONG_MAX / nDPIX < std::abs( rMapRes.mnMapScNumX ) ) ) // #111139# avoid div by zero
96  {
97  rThresRes.mnThresLogToPixX = 0;
98  rThresRes.mnThresPixToLogX = 0;
99  }
100  else
101  {
102  // calculate thresholds for BigInt arithmetic
103  long nDenomHalfX = rMapRes.mnMapScDenomX / 2;
104  sal_uLong nDenomX = rMapRes.mnMapScDenomX;
105  long nProductX = nDPIX * rMapRes.mnMapScNumX;
106 
107  if ( !nProductX )
108  rThresRes.mnThresLogToPixX = LONG_MAX;
109  else
110  rThresRes.mnThresLogToPixX = std::abs( (LONG_MAX - nDenomHalfX) / nProductX );
111 
112  if ( !nDenomX )
113  rThresRes.mnThresPixToLogX = LONG_MAX;
114  else if ( nProductX >= 0 )
115  rThresRes.mnThresPixToLogX = static_cast<long>((sal_uLong(LONG_MAX) - static_cast<sal_uLong>( nProductX/2)) / nDenomX);
116  else
117  rThresRes.mnThresPixToLogX = static_cast<long>((sal_uLong(LONG_MAX) + static_cast<sal_uLong>(-nProductX/2)) / nDenomX);
118  }
119 
120  if ( nDPIY && (LONG_MAX / nDPIY < std::abs( rMapRes.mnMapScNumY ) ) ) // #111139# avoid div by zero
121  {
122  rThresRes.mnThresLogToPixY = 0;
123  rThresRes.mnThresPixToLogY = 0;
124  }
125  else
126  {
127  // calculate thresholds for BigInt arithmetic
128  long nDenomHalfY = rMapRes.mnMapScDenomY / 2;
129  sal_uLong nDenomY = rMapRes.mnMapScDenomY;
130  long nProductY = nDPIY * rMapRes.mnMapScNumY;
131 
132  if ( !nProductY )
133  rThresRes.mnThresLogToPixY = LONG_MAX;
134  else
135  rThresRes.mnThresLogToPixY = std::abs( (LONG_MAX - nDenomHalfY) / nProductY );
136 
137  if ( !nDenomY )
138  rThresRes.mnThresPixToLogY = LONG_MAX;
139  else if ( nProductY >= 0 )
140  rThresRes.mnThresPixToLogY = static_cast<long>((sal_uLong(LONG_MAX) - static_cast<sal_uLong>( nProductY/2)) / nDenomY);
141  else
142  rThresRes.mnThresPixToLogY = static_cast<long>((sal_uLong(LONG_MAX) + static_cast<sal_uLong>(-nProductY/2)) / nDenomY);
143  }
144 
145  rThresRes.mnThresLogToPixX /= 2;
146  rThresRes.mnThresLogToPixY /= 2;
147  rThresRes.mnThresPixToLogX /= 2;
148  rThresRes.mnThresPixToLogY /= 2;
149 }
150 
151 static void ImplCalcMapResolution( const MapMode& rMapMode,
152  long nDPIX, long nDPIY, ImplMapRes& rMapRes )
153 {
154  switch ( rMapMode.GetMapUnit() )
155  {
156  case MapUnit::MapRelative:
157  break;
158  case MapUnit::Map100thMM:
159  rMapRes.mnMapScNumX = 1;
160  rMapRes.mnMapScDenomX = 2540;
161  rMapRes.mnMapScNumY = 1;
162  rMapRes.mnMapScDenomY = 2540;
163  break;
164  case MapUnit::Map10thMM:
165  rMapRes.mnMapScNumX = 1;
166  rMapRes.mnMapScDenomX = 254;
167  rMapRes.mnMapScNumY = 1;
168  rMapRes.mnMapScDenomY = 254;
169  break;
170  case MapUnit::MapMM:
171  rMapRes.mnMapScNumX = 5; // 10
172  rMapRes.mnMapScDenomX = 127; // 254
173  rMapRes.mnMapScNumY = 5; // 10
174  rMapRes.mnMapScDenomY = 127; // 254
175  break;
176  case MapUnit::MapCM:
177  rMapRes.mnMapScNumX = 50; // 100
178  rMapRes.mnMapScDenomX = 127; // 254
179  rMapRes.mnMapScNumY = 50; // 100
180  rMapRes.mnMapScDenomY = 127; // 254
181  break;
182  case MapUnit::Map1000thInch:
183  rMapRes.mnMapScNumX = 1;
184  rMapRes.mnMapScDenomX = 1000;
185  rMapRes.mnMapScNumY = 1;
186  rMapRes.mnMapScDenomY = 1000;
187  break;
188  case MapUnit::Map100thInch:
189  rMapRes.mnMapScNumX = 1;
190  rMapRes.mnMapScDenomX = 100;
191  rMapRes.mnMapScNumY = 1;
192  rMapRes.mnMapScDenomY = 100;
193  break;
194  case MapUnit::Map10thInch:
195  rMapRes.mnMapScNumX = 1;
196  rMapRes.mnMapScDenomX = 10;
197  rMapRes.mnMapScNumY = 1;
198  rMapRes.mnMapScDenomY = 10;
199  break;
200  case MapUnit::MapInch:
201  rMapRes.mnMapScNumX = 1;
202  rMapRes.mnMapScDenomX = 1;
203  rMapRes.mnMapScNumY = 1;
204  rMapRes.mnMapScDenomY = 1;
205  break;
206  case MapUnit::MapPoint:
207  rMapRes.mnMapScNumX = 1;
208  rMapRes.mnMapScDenomX = 72;
209  rMapRes.mnMapScNumY = 1;
210  rMapRes.mnMapScDenomY = 72;
211  break;
212  case MapUnit::MapTwip:
213  rMapRes.mnMapScNumX = 1;
214  rMapRes.mnMapScDenomX = 1440;
215  rMapRes.mnMapScNumY = 1;
216  rMapRes.mnMapScDenomY = 1440;
217  break;
218  case MapUnit::MapPixel:
219  rMapRes.mnMapScNumX = 1;
220  rMapRes.mnMapScDenomX = nDPIX;
221  rMapRes.mnMapScNumY = 1;
222  rMapRes.mnMapScDenomY = nDPIY;
223  break;
224  case MapUnit::MapSysFont:
225  case MapUnit::MapAppFont:
226  {
227  ImplSVData* pSVData = ImplGetSVData();
228  if ( !pSVData->maGDIData.mnAppFontX )
229  {
230  if (pSVData->maFrameData.mpFirstFrame)
232  else
233  {
234  ScopedVclPtrInstance<WorkWindow> pWin( nullptr, 0 );
236  }
237  }
238  rMapRes.mnMapScNumX = pSVData->maGDIData.mnAppFontX;
239  rMapRes.mnMapScDenomX = nDPIX * 40;
240  rMapRes.mnMapScNumY = pSVData->maGDIData.mnAppFontY;
241  rMapRes.mnMapScDenomY = nDPIY * 80;
242  }
243  break;
244  default:
245  OSL_FAIL( "unhandled MapUnit" );
246  break;
247  }
248 
249  const Fraction& aScaleX = rMapMode.GetScaleX();
250  const Fraction& aScaleY = rMapMode.GetScaleY();
251 
252  // set offset according to MapMode
253  Point aOrigin = rMapMode.GetOrigin();
254  if ( rMapMode.GetMapUnit() != MapUnit::MapRelative )
255  {
256  rMapRes.mnMapOfsX = aOrigin.X();
257  rMapRes.mnMapOfsY = aOrigin.Y();
258  }
259  else
260  {
261  auto nXNumerator = aScaleX.GetNumerator();
262  auto nYNumerator = aScaleY.GetNumerator();
263  assert(nXNumerator != 0 && nYNumerator != 0);
264 
265  BigInt aX( rMapRes.mnMapOfsX );
266  aX *= BigInt( aScaleX.GetDenominator() );
267  if ( rMapRes.mnMapOfsX >= 0 )
268  {
269  if (nXNumerator >= 0)
270  aX += BigInt(nXNumerator / 2);
271  else
272  aX -= BigInt((nXNumerator + 1) / 2);
273  }
274  else
275  {
276  if (nXNumerator >= 0 )
277  aX -= BigInt((nXNumerator - 1) / 2);
278  else
279  aX += BigInt(nXNumerator / 2);
280  }
281  aX /= BigInt(nXNumerator);
282  rMapRes.mnMapOfsX = static_cast<long>(aX) + aOrigin.X();
283  BigInt aY( rMapRes.mnMapOfsY );
284  aY *= BigInt( aScaleY.GetDenominator() );
285  if( rMapRes.mnMapOfsY >= 0 )
286  {
287  if (nYNumerator >= 0)
288  aY += BigInt(nYNumerator / 2);
289  else
290  aY -= BigInt((nYNumerator + 1) / 2);
291  }
292  else
293  {
294  if (nYNumerator >= 0)
295  aY -= BigInt((nYNumerator - 1) / 2);
296  else
297  aY += BigInt(nYNumerator / 2);
298  }
299  aY /= BigInt(nYNumerator);
300  rMapRes.mnMapOfsY = static_cast<long>(aY) + aOrigin.Y();
301  }
302 
303  // calculate scaling factor according to MapMode
304  // aTemp? = rMapRes.mnMapSc? * aScale?
305  Fraction aTempX = ImplMakeFraction( rMapRes.mnMapScNumX,
306  aScaleX.GetNumerator(),
307  rMapRes.mnMapScDenomX,
308  aScaleX.GetDenominator() );
309  Fraction aTempY = ImplMakeFraction( rMapRes.mnMapScNumY,
310  aScaleY.GetNumerator(),
311  rMapRes.mnMapScDenomY,
312  aScaleY.GetDenominator() );
313  rMapRes.mnMapScNumX = aTempX.GetNumerator();
314  rMapRes.mnMapScDenomX = aTempX.GetDenominator();
315  rMapRes.mnMapScNumY = aTempY.GetNumerator();
316  rMapRes.mnMapScDenomY = aTempY.GetDenominator();
317 }
318 
319 static void ImplCalcMapResolution( const MapMode& rMapMode,
320  long nDPIX, long nDPIY,
321  ImplMapRes& rMapRes,
322  ImplThresholdRes& rThresRes )
323 {
324  ImplCalcMapResolution( rMapMode, nDPIX, nDPIY, rMapRes );
325  ImplCalcBigIntThreshold( nDPIX, nDPIY, rMapRes, rThresRes );
326 }
327 
328 // #i75163#
330 {
331  if(!mpOutDevData)
332  return;
333 
334  if(mpOutDevData->mpViewTransform)
335  {
336  delete mpOutDevData->mpViewTransform;
337  mpOutDevData->mpViewTransform = nullptr;
338  }
339 
340  if(mpOutDevData->mpInverseViewTransform)
341  {
342  delete mpOutDevData->mpInverseViewTransform;
343  mpOutDevData->mpInverseViewTransform = nullptr;
344  }
345 }
346 
347 static long ImplLogicToPixel( long n, long nDPI, long nMapNum, long nMapDenom,
348  long nThres )
349 {
350  assert(nDPI > 0);
351 #if (SAL_TYPES_SIZEOFLONG < 8)
352  if( (+n < nThres) && (-n < nThres) )
353  {
354  n *= nMapNum * nDPI;
355  if( nMapDenom != 1 )
356  {
357  n = (2 * n) / nMapDenom;
358  if( n < 0 ) --n; else ++n;
359  n /= 2;
360  }
361  }
362  else
363 #else
364  (void) nThres;
365  assert(nMapNum >= 0);
366  assert(nMapNum == 0 || std::abs(n) < std::numeric_limits<long>::max() / nMapNum / nDPI); //detect overflows
367 #endif
368  {
369  sal_Int64 n64 = n;
370  n64 *= nMapNum;
371  n64 *= nDPI;
372  if( nMapDenom == 1 )
373  n = static_cast<long>(n64);
374  else
375  {
376  n = static_cast<long>(2 * n64 / nMapDenom);
377  if( n < 0 ) --n; else ++n;
378  n /= 2;
379  }
380  }
381  return n;
382 }
383 
384 static long ImplPixelToLogic( long n, long nDPI, long nMapNum, long nMapDenom,
385  long nThres )
386 {
387  assert(nDPI > 0);
388  long nDenom = nDPI * nMapNum;
389  if (nDenom == 0)
390  {
391  return 0;
392  }
393 
394 #if (SAL_TYPES_SIZEOFLONG < 8)
395  if( (+n < nThres) && (-n < nThres) )
396  n = (2 * n * nMapDenom) / nDenom;
397  else
398 #else
399  (void) nThres;
400 #endif
401  {
402  sal_Int64 n64 = n;
403  n64 *= nMapDenom;
404  n = static_cast<long>(2 * n64 / nDenom);
405  }
406  if( n < 0 ) --n; else ++n;
407  return (n / 2);
408 }
409 
411 {
412  if ( !mbMap )
413  return nX+mnOutOffX;
414 
418 }
419 
421 {
422  if ( !mbMap )
423  return nY+mnOutOffY;
424 
428 }
429 
431 {
432  if ( !mbMap )
433  return nWidth;
434 
435  return ImplLogicToPixel( nWidth, mnDPIX,
438 }
439 
441 {
442  if ( !mbMap )
443  return nHeight;
444 
445  return ImplLogicToPixel( nHeight, mnDPIY,
448 }
449 
450 float OutputDevice::ImplFloatLogicHeightToDevicePixel( float fLogicHeight) const
451 {
452  if( !mbMap)
453  return fLogicHeight;
454  float fPixelHeight = (fLogicHeight * mnDPIY * maMapRes.mnMapScNumY) / maMapRes.mnMapScDenomY;
455  return fPixelHeight;
456 }
457 
459 {
460  if ( !mbMap )
461  return nWidth;
462 
463  return ImplPixelToLogic( nWidth, mnDPIX,
466 }
467 
469 {
470  if ( !mbMap )
471  return nHeight;
472 
473  return ImplPixelToLogic( nHeight, mnDPIY,
476 }
477 
478 Point OutputDevice::ImplLogicToDevicePixel( const Point& rLogicPt ) const
479 {
480  if ( !mbMap )
481  return Point( rLogicPt.X()+mnOutOffX, rLogicPt.Y()+mnOutOffY );
482 
483  return Point( ImplLogicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, mnDPIX,
486  ImplLogicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, mnDPIY,
489 }
490 
492 {
493  if ( !mbMap )
494  return rLogicSize;
495 
496  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
499  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
502 }
503 
505 {
506  if ( rLogicRect.IsEmpty() )
507  return rLogicRect;
508 
509  if ( !mbMap )
510  {
511  return tools::Rectangle( rLogicRect.Left()+mnOutOffX, rLogicRect.Top()+mnOutOffY,
512  rLogicRect.Right()+mnOutOffX, rLogicRect.Bottom()+mnOutOffY );
513  }
514 
527 }
528 
530 {
531  if ( !mbMap && !mnOutOffX && !mnOutOffY )
532  return rLogicPoly;
533 
534  sal_uInt16 i;
535  sal_uInt16 nPoints = rLogicPoly.GetSize();
536  tools::Polygon aPoly( rLogicPoly );
537 
538  // get pointer to Point-array (copy data)
539  const Point* pPointAry = aPoly.GetConstPointAry();
540 
541  if ( mbMap )
542  {
543  for ( i = 0; i < nPoints; i++ )
544  {
545  const Point& rPt = pPointAry[i];
552  aPoly[i] = aPt;
553  }
554  }
555  else
556  {
557  for ( i = 0; i < nPoints; i++ )
558  {
559  Point aPt = pPointAry[i];
560  aPt.AdjustX(mnOutOffX );
561  aPt.AdjustY(mnOutOffY );
562  aPoly[i] = aPt;
563  }
564  }
565 
566  return aPoly;
567 }
568 
570 {
571  if ( !mbMap && !mnOutOffX && !mnOutOffY )
572  return rLogicPolyPoly;
573 
574  tools::PolyPolygon aPolyPoly( rLogicPolyPoly );
575  sal_uInt16 nPoly = aPolyPoly.Count();
576  for( sal_uInt16 i = 0; i < nPoly; i++ )
577  {
578  tools::Polygon& rPoly = aPolyPoly[i];
579  rPoly = ImplLogicToDevicePixel( rPoly );
580  }
581  return aPolyPoly;
582 }
583 
585 {
586  LineInfo aInfo( rLineInfo );
587 
588  if( aInfo.GetStyle() == LineStyle::Dash )
589  {
590  if( aInfo.GetDotCount() && aInfo.GetDotLen() )
591  aInfo.SetDotLen( std::max( ImplLogicWidthToDevicePixel( aInfo.GetDotLen() ), 1L ) );
592  else
593  aInfo.SetDotCount( 0 );
594 
595  if( aInfo.GetDashCount() && aInfo.GetDashLen() )
596  aInfo.SetDashLen( std::max( ImplLogicWidthToDevicePixel( aInfo.GetDashLen() ), 1L ) );
597  else
598  aInfo.SetDashCount( 0 );
599 
600  aInfo.SetDistance( ImplLogicWidthToDevicePixel( aInfo.GetDistance() ) );
601 
602  if( ( !aInfo.GetDashCount() && !aInfo.GetDotCount() ) || !aInfo.GetDistance() )
603  aInfo.SetStyle( LineStyle::Solid );
604  }
605 
606  aInfo.SetWidth( ImplLogicWidthToDevicePixel( aInfo.GetWidth() ) );
607 
608  return aInfo;
609 }
610 
612 {
613  if ( rPixelRect.IsEmpty() )
614  return rPixelRect;
615 
616  if ( !mbMap )
617  {
618  return tools::Rectangle( rPixelRect.Left()-mnOutOffX, rPixelRect.Top()-mnOutOffY,
619  rPixelRect.Right()-mnOutOffX, rPixelRect.Bottom()-mnOutOffY );
620  }
621 
634 }
635 
637 {
638  if ( !mnOutOffX && !mnOutOffY )
639  return rRegion;
640 
641  vcl::Region aRegion( rRegion );
643  return aRegion;
644 }
645 
646 void OutputDevice::EnableMapMode( bool bEnable )
647 {
648  mbMap = bEnable;
649 
650  if( mpAlphaVDev )
651  mpAlphaVDev->EnableMapMode( bEnable );
652 }
653 
655 {
656 
657  if ( mpMetaFile )
658  mpMetaFile->AddAction( new MetaMapModeAction( MapMode() ) );
659 
660  if ( mbMap || !maMapMode.IsDefault() )
661  {
662  mbMap = false;
663  maMapMode = MapMode();
664 
665  // create new objects (clip region are not re-scaled)
666  mbNewFont = true;
667  mbInitFont = true;
669 
670  // #106426# Adapt logical offset when changing mapmode
671  mnOutOffLogicX = mnOutOffOrigX; // no mapping -> equal offsets
673 
674  // #i75163#
676  }
677 
678  if( mpAlphaVDev )
680 }
681 
682 void OutputDevice::SetMapMode( const MapMode& rNewMapMode )
683 {
684 
685  bool bRelMap = (rNewMapMode.GetMapUnit() == MapUnit::MapRelative);
686 
687  if ( mpMetaFile )
688  {
689  mpMetaFile->AddAction( new MetaMapModeAction( rNewMapMode ) );
690  }
691 
692  // do nothing if MapMode was not changed
693  if ( maMapMode == rNewMapMode )
694  return;
695 
696  if( mpAlphaVDev )
697  mpAlphaVDev->SetMapMode( rNewMapMode );
698 
699  // if default MapMode calculate nothing
700  bool bOldMap = mbMap;
701  mbMap = !rNewMapMode.IsDefault();
702  if ( mbMap )
703  {
704  // if only the origin is converted, do not scale new
705  if ( (rNewMapMode.GetMapUnit() == maMapMode.GetMapUnit()) &&
706  (rNewMapMode.GetScaleX() == maMapMode.GetScaleX()) &&
707  (rNewMapMode.GetScaleY() == maMapMode.GetScaleY()) &&
708  (bOldMap == mbMap) )
709  {
710  // set offset
711  Point aOrigin = rNewMapMode.GetOrigin();
712  maMapRes.mnMapOfsX = aOrigin.X();
713  maMapRes.mnMapOfsY = aOrigin.Y();
714  maMapMode = rNewMapMode;
715 
716  // #i75163#
718 
719  return;
720  }
721  if ( !bOldMap && bRelMap )
722  {
723  maMapRes.mnMapScNumX = 1;
724  maMapRes.mnMapScNumY = 1;
727  maMapRes.mnMapOfsX = 0;
728  maMapRes.mnMapOfsY = 0;
729  }
730 
731  // calculate new MapMode-resolution
733  }
734 
735  // set new MapMode
736  if ( bRelMap )
737  {
739  // aScale? = maMapMode.GetScale?() * rNewMapMode.GetScale?()
741  rNewMapMode.GetScaleX().GetNumerator(),
743  rNewMapMode.GetScaleX().GetDenominator() );
745  rNewMapMode.GetScaleY().GetNumerator(),
747  rNewMapMode.GetScaleY().GetDenominator() );
748  maMapMode.SetOrigin( aOrigin );
749  maMapMode.SetScaleX( aScaleX );
750  maMapMode.SetScaleY( aScaleY );
751  }
752  else
753  maMapMode = rNewMapMode;
754 
755  // create new objects (clip region are not re-scaled)
756  mbNewFont = true;
757  mbInitFont = true;
759 
760  // #106426# Adapt logical offset when changing mapmode
767 
768  // #i75163#
770 }
771 
772 void OutputDevice::SetMetafileMapMode(const MapMode& rNewMapMode, bool bIsRecord)
773 {
774  if (bIsRecord)
775  SetRelativeMapMode(rNewMapMode);
776  else
777  SetMapMode(rNewMapMode);
778 }
779 
781 
782 void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
783 {
784  // do nothing if MapMode did not change
785  if ( maMapMode == rNewMapMode )
786  return;
787 
788  MapUnit eOld = maMapMode.GetMapUnit();
789  MapUnit eNew = rNewMapMode.GetMapUnit();
790 
791  // a?F = rNewMapMode.GetScale?() / maMapMode.GetScale?()
792  Fraction aXF = ImplMakeFraction( rNewMapMode.GetScaleX().GetNumerator(),
794  rNewMapMode.GetScaleX().GetDenominator(),
796  Fraction aYF = ImplMakeFraction( rNewMapMode.GetScaleY().GetNumerator(),
798  rNewMapMode.GetScaleY().GetDenominator(),
800 
801  Point aPt( LogicToLogic( Point(), nullptr, &rNewMapMode ) );
802  if ( eNew != eOld )
803  {
804  if ( eOld > MapUnit::MapPixel )
805  {
806  SAL_WARN( "vcl.gdi", "Not implemented MapUnit" );
807  }
808  else if ( eNew > MapUnit::MapPixel )
809  {
810  SAL_WARN( "vcl.gdi", "Not implemented MapUnit" );
811  }
812  else
813  {
814  Fraction aF( aImplNumeratorAry[eNew] * aImplDenominatorAry[eOld],
815  aImplNumeratorAry[eOld] * aImplDenominatorAry[eNew] );
816 
817  // a?F = a?F * aF
818  aXF = ImplMakeFraction( aXF.GetNumerator(), aF.GetNumerator(),
819  aXF.GetDenominator(), aF.GetDenominator() );
820  aYF = ImplMakeFraction( aYF.GetNumerator(), aF.GetNumerator(),
821  aYF.GetDenominator(), aF.GetDenominator() );
822  if ( eOld == MapUnit::MapPixel )
823  {
824  aXF *= Fraction( mnDPIX, 1 );
825  aYF *= Fraction( mnDPIY, 1 );
826  }
827  else if ( eNew == MapUnit::MapPixel )
828  {
829  aXF *= Fraction( 1, mnDPIX );
830  aYF *= Fraction( 1, mnDPIY );
831  }
832  }
833  }
834 
835  MapMode aNewMapMode( MapUnit::MapRelative, Point( -aPt.X(), -aPt.Y() ), aXF, aYF );
836  SetMapMode( aNewMapMode );
837 
838  if ( eNew != eOld )
839  maMapMode = rNewMapMode;
840 
841  // #106426# Adapt logical offset when changing MapMode
848 
849  if( mpAlphaVDev )
850  mpAlphaVDev->SetRelativeMapMode( rNewMapMode );
851 }
852 
853 // #i75163#
855 {
856  if(mbMap && mpOutDevData)
857  {
858  if(!mpOutDevData->mpViewTransform)
859  {
860  mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix;
861 
862  const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(maMapRes.mnMapScNumX) / static_cast<double>(maMapRes.mnMapScDenomX));
863  const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(maMapRes.mnMapScNumY) / static_cast<double>(maMapRes.mnMapScDenomY));
864  const double fZeroPointX((static_cast<double>(maMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX));
865  const double fZeroPointY((static_cast<double>(maMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY));
866 
867  mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX);
868  mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY);
869  mpOutDevData->mpViewTransform->set(0, 2, fZeroPointX);
870  mpOutDevData->mpViewTransform->set(1, 2, fZeroPointY);
871  }
872 
873  return *mpOutDevData->mpViewTransform;
874  }
875  else
876  {
877  return basegfx::B2DHomMatrix();
878  }
879 }
880 
881 // #i75163#
883 {
884  if(mbMap && mpOutDevData)
885  {
886  if(!mpOutDevData->mpInverseViewTransform)
887  {
889  mpOutDevData->mpInverseViewTransform = new basegfx::B2DHomMatrix(*mpOutDevData->mpViewTransform);
890  mpOutDevData->mpInverseViewTransform->invert();
891  }
892 
893  return *mpOutDevData->mpInverseViewTransform;
894  }
895  else
896  {
897  return basegfx::B2DHomMatrix();
898  }
899 }
900 
901 // #i75163#
903 {
904  // #i82615#
905  ImplMapRes aMapRes;
906  ImplThresholdRes aThresRes;
907  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
908 
909  basegfx::B2DHomMatrix aTransform;
910 
911  const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(aMapRes.mnMapScNumX) / static_cast<double>(aMapRes.mnMapScDenomX));
912  const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(aMapRes.mnMapScNumY) / static_cast<double>(aMapRes.mnMapScDenomY));
913  const double fZeroPointX((static_cast<double>(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX));
914  const double fZeroPointY((static_cast<double>(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY));
915 
916  aTransform.set(0, 0, fScaleFactorX);
917  aTransform.set(1, 1, fScaleFactorY);
918  aTransform.set(0, 2, fZeroPointX);
919  aTransform.set(1, 2, fZeroPointY);
920 
921  return aTransform;
922 }
923 
924 // #i75163#
926 {
927  basegfx::B2DHomMatrix aMatrix( GetViewTransformation( rMapMode ) );
928  aMatrix.invert();
929  return aMatrix;
930 }
931 
933 {
934  basegfx::B2DHomMatrix aTransformation = GetViewTransformation();
935  // TODO: is it worth to cache the transformed result?
936  if( mnOutOffX || mnOutOffY )
937  aTransformation.translate( mnOutOffX, mnOutOffY );
938  return aTransformation;
939 }
940 
941 Point OutputDevice::LogicToPixel( const Point& rLogicPt ) const
942 {
943 
944  if ( !mbMap )
945  return rLogicPt;
946 
947  return Point( ImplLogicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, mnDPIX,
950  ImplLogicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, mnDPIY,
953 }
954 
955 Size OutputDevice::LogicToPixel( const Size& rLogicSize ) const
956 {
957 
958  if ( !mbMap )
959  return rLogicSize;
960 
961  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
964  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
967 }
968 
970 {
971 
972  if ( !mbMap || rLogicRect.IsEmpty() )
973  return rLogicRect;
974 
978  ImplLogicToPixel( rLogicRect.Top() + maMapRes.mnMapOfsY, mnDPIY,
987 }
988 
990 {
991 
992  if ( !mbMap )
993  return rLogicPoly;
994 
995  sal_uInt16 i;
996  sal_uInt16 nPoints = rLogicPoly.GetSize();
997  tools::Polygon aPoly( rLogicPoly );
998 
999  // get pointer to Point-array (copy data)
1000  const Point* pPointAry = aPoly.GetConstPointAry();
1001 
1002  for ( i = 0; i < nPoints; i++ )
1003  {
1004  const Point* pPt = &(pPointAry[i]);
1005  Point aPt;
1006  aPt.setX( ImplLogicToPixel( pPt->X() + maMapRes.mnMapOfsX, mnDPIX,
1009  aPt.setY( ImplLogicToPixel( pPt->Y() + maMapRes.mnMapOfsY, mnDPIY,
1012  aPoly[i] = aPt;
1013  }
1014 
1015  return aPoly;
1016 }
1017 
1019 {
1020 
1021  if ( !mbMap )
1022  return rLogicPolyPoly;
1023 
1024  tools::PolyPolygon aPolyPoly( rLogicPolyPoly );
1025  sal_uInt16 nPoly = aPolyPoly.Count();
1026  for( sal_uInt16 i = 0; i < nPoly; i++ )
1027  {
1028  tools::Polygon& rPoly = aPolyPoly[i];
1029  rPoly = LogicToPixel( rPoly );
1030  }
1031  return aPolyPoly;
1032 }
1033 
1035 {
1036  basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly;
1037  const basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation();
1038  aTransformedPoly.transform( rTransformationMatrix );
1039  return aTransformedPoly;
1040 }
1041 
1043 {
1044 
1045  if(!mbMap || rLogicRegion.IsNull() || rLogicRegion.IsEmpty())
1046  {
1047  return rLogicRegion;
1048  }
1049 
1050  vcl::Region aRegion;
1051 
1052  if(rLogicRegion.getB2DPolyPolygon())
1053  {
1054  aRegion = vcl::Region(LogicToPixel(*rLogicRegion.getB2DPolyPolygon()));
1055  }
1056  else if(rLogicRegion.getPolyPolygon())
1057  {
1058  aRegion = vcl::Region(LogicToPixel(*rLogicRegion.getPolyPolygon()));
1059  }
1060  else if(rLogicRegion.getRegionBand())
1061  {
1062  RectangleVector aRectangles;
1063  rLogicRegion.GetRegionRectangles(aRectangles);
1064  const RectangleVector& rRectangles(aRectangles); // needed to make the '!=' work
1065 
1066  // make reverse run to fill new region bottom-up, this will speed it up due to the used data structuring
1067  for(RectangleVector::const_reverse_iterator aRectIter(rRectangles.rbegin()); aRectIter != rRectangles.rend(); ++aRectIter)
1068  {
1069  aRegion.Union(LogicToPixel(*aRectIter));
1070  }
1071  }
1072 
1073  return aRegion;
1074 }
1075 
1076 Point OutputDevice::LogicToPixel( const Point& rLogicPt,
1077  const MapMode& rMapMode ) const
1078 {
1079 
1080  if ( rMapMode.IsDefault() )
1081  return rLogicPt;
1082 
1083  // convert MapMode resolution and convert
1084  ImplMapRes aMapRes;
1085  ImplThresholdRes aThresRes;
1086  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1087 
1088  return Point( ImplLogicToPixel( rLogicPt.X() + aMapRes.mnMapOfsX, mnDPIX,
1089  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1090  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1091  ImplLogicToPixel( rLogicPt.Y() + aMapRes.mnMapOfsY, mnDPIY,
1092  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1093  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1094 }
1095 
1097  const MapMode& rMapMode ) const
1098 {
1099 
1100  if ( rMapMode.IsDefault() )
1101  return rLogicSize;
1102 
1103  // convert MapMode resolution and convert
1104  ImplMapRes aMapRes;
1105  ImplThresholdRes aThresRes;
1106  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1107 
1108  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
1109  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1110  aThresRes.mnThresLogToPixX ),
1111  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
1112  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1113  aThresRes.mnThresLogToPixY ) );
1114 }
1115 
1117  const MapMode& rMapMode ) const
1118 {
1119 
1120  if ( rMapMode.IsDefault() || rLogicRect.IsEmpty() )
1121  return rLogicRect;
1122 
1123  // convert MapMode resolution and convert
1124  ImplMapRes aMapRes;
1125  ImplThresholdRes aThresRes;
1126  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1127 
1128  return tools::Rectangle( ImplLogicToPixel( rLogicRect.Left() + aMapRes.mnMapOfsX, mnDPIX,
1129  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1130  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1131  ImplLogicToPixel( rLogicRect.Top() + aMapRes.mnMapOfsY, mnDPIY,
1132  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1133  aThresRes.mnThresLogToPixY )+mnOutOffOrigY,
1134  ImplLogicToPixel( rLogicRect.Right() + aMapRes.mnMapOfsX, mnDPIX,
1135  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1136  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1137  ImplLogicToPixel( rLogicRect.Bottom() + aMapRes.mnMapOfsY, mnDPIY,
1138  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1139  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1140 }
1141 
1143  const MapMode& rMapMode ) const
1144 {
1145 
1146  if ( rMapMode.IsDefault() )
1147  return rLogicPoly;
1148 
1149  // convert MapMode resolution and convert
1150  ImplMapRes aMapRes;
1151  ImplThresholdRes aThresRes;
1152  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1153 
1154  sal_uInt16 i;
1155  sal_uInt16 nPoints = rLogicPoly.GetSize();
1156  tools::Polygon aPoly( rLogicPoly );
1157 
1158  // get pointer to Point-array (copy data)
1159  const Point* pPointAry = aPoly.GetConstPointAry();
1160 
1161  for ( i = 0; i < nPoints; i++ )
1162  {
1163  const Point* pPt = &(pPointAry[i]);
1164  Point aPt;
1165  aPt.setX( ImplLogicToPixel( pPt->X() + aMapRes.mnMapOfsX, mnDPIX,
1166  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1167  aThresRes.mnThresLogToPixX )+mnOutOffOrigX );
1168  aPt.setY( ImplLogicToPixel( pPt->Y() + aMapRes.mnMapOfsY, mnDPIY,
1169  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1170  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1171  aPoly[i] = aPt;
1172  }
1173 
1174  return aPoly;
1175 }
1176 
1178  const MapMode& rMapMode ) const
1179 {
1180  basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly;
1181  const basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode );
1182  aTransformedPoly.transform( rTransformationMatrix );
1183  return aTransformedPoly;
1184 }
1185 
1186 Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const
1187 {
1188 
1189  if ( !mbMap )
1190  return rDevicePt;
1191 
1192  return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX,
1195  ImplPixelToLogic( rDevicePt.Y(), mnDPIY,
1198 }
1199 
1200 Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const
1201 {
1202 
1203  if ( !mbMap )
1204  return rDeviceSize;
1205 
1206  return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX,
1209  ImplPixelToLogic( rDeviceSize.Height(), mnDPIY,
1212 }
1213 
1215 {
1216 
1217  if ( !mbMap || rDeviceRect.IsEmpty() )
1218  return rDeviceRect;
1219 
1220  return tools::Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX,
1223  ImplPixelToLogic( rDeviceRect.Top(), mnDPIY,
1226  ImplPixelToLogic( rDeviceRect.Right(), mnDPIX,
1229  ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY,
1232 }
1233 
1235 {
1236 
1237  if ( !mbMap )
1238  return rDevicePoly;
1239 
1240  sal_uInt16 i;
1241  sal_uInt16 nPoints = rDevicePoly.GetSize();
1242  tools::Polygon aPoly( rDevicePoly );
1243 
1244  // get pointer to Point-array (copy data)
1245  const Point* pPointAry = aPoly.GetConstPointAry();
1246 
1247  for ( i = 0; i < nPoints; i++ )
1248  {
1249  const Point* pPt = &(pPointAry[i]);
1250  Point aPt;
1251  aPt.setX( ImplPixelToLogic( pPt->X(), mnDPIX,
1254  aPt.setY( ImplPixelToLogic( pPt->Y(), mnDPIY,
1257  aPoly[i] = aPt;
1258  }
1259 
1260  return aPoly;
1261 }
1262 
1264 {
1265 
1266  if ( !mbMap )
1267  return rDevicePolyPoly;
1268 
1269  tools::PolyPolygon aPolyPoly( rDevicePolyPoly );
1270  sal_uInt16 nPoly = aPolyPoly.Count();
1271  for( sal_uInt16 i = 0; i < nPoly; i++ )
1272  {
1273  tools::Polygon& rPoly = aPolyPoly[i];
1274  rPoly = PixelToLogic( rPoly );
1275  }
1276  return aPolyPoly;
1277 }
1278 
1280 {
1281  basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly;
1282  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation();
1283  aTransformedPoly.transform( rTransformationMatrix );
1284  return aTransformedPoly;
1285 }
1286 
1288 {
1289 
1290  if(!mbMap || rDeviceRegion.IsNull() || rDeviceRegion.IsEmpty())
1291  {
1292  return rDeviceRegion;
1293  }
1294 
1295  vcl::Region aRegion;
1296 
1297  if(rDeviceRegion.getB2DPolyPolygon())
1298  {
1299  aRegion = vcl::Region(PixelToLogic(*rDeviceRegion.getB2DPolyPolygon()));
1300  }
1301  else if(rDeviceRegion.getPolyPolygon())
1302  {
1303  aRegion = vcl::Region(PixelToLogic(*rDeviceRegion.getPolyPolygon()));
1304  }
1305  else if(rDeviceRegion.getRegionBand())
1306  {
1307  RectangleVector aRectangles;
1308  rDeviceRegion.GetRegionRectangles(aRectangles);
1309  const RectangleVector& rRectangles(aRectangles); // needed to make the '!=' work
1310 
1311  // make reverse run to fill new region bottom-up, this will speed it up due to the used data structuring
1312  for(RectangleVector::const_reverse_iterator aRectIter(rRectangles.rbegin()); aRectIter != rRectangles.rend(); ++aRectIter)
1313  {
1314  aRegion.Union(PixelToLogic(*aRectIter));
1315  }
1316  }
1317 
1318  return aRegion;
1319 }
1320 
1321 Point OutputDevice::PixelToLogic( const Point& rDevicePt,
1322  const MapMode& rMapMode ) const
1323 {
1324 
1325  // calculate nothing if default-MapMode
1326  if ( rMapMode.IsDefault() )
1327  return rDevicePt;
1328 
1329  // calculate MapMode-resolution and convert
1330  ImplMapRes aMapRes;
1331  ImplThresholdRes aThresRes;
1332  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1333 
1334  return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX,
1335  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1336  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1337  ImplPixelToLogic( rDevicePt.Y(), mnDPIY,
1338  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1339  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1340 }
1341 
1343  const MapMode& rMapMode ) const
1344 {
1345 
1346  // calculate nothing if default-MapMode
1347  if ( rMapMode.IsDefault() )
1348  return rDeviceSize;
1349 
1350  // calculate MapMode-resolution and convert
1351  ImplMapRes aMapRes;
1352  ImplThresholdRes aThresRes;
1353  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1354 
1355  return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX,
1356  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1357  aThresRes.mnThresPixToLogX ),
1358  ImplPixelToLogic( rDeviceSize.Height(), mnDPIY,
1359  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1360  aThresRes.mnThresPixToLogY ) );
1361 }
1362 
1364  const MapMode& rMapMode ) const
1365 {
1366 
1367  // calculate nothing if default-MapMode
1368  if ( rMapMode.IsDefault() || rDeviceRect.IsEmpty() )
1369  return rDeviceRect;
1370 
1371  // calculate MapMode-resolution and convert
1372  ImplMapRes aMapRes;
1373  ImplThresholdRes aThresRes;
1374  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1375 
1376  return tools::Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX,
1377  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1378  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1379  ImplPixelToLogic( rDeviceRect.Top(), mnDPIY,
1380  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1381  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY,
1382  ImplPixelToLogic( rDeviceRect.Right(), mnDPIX,
1383  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1384  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1385  ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY,
1386  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1387  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1388 }
1389 
1391  const MapMode& rMapMode ) const
1392 {
1393 
1394  // calculate nothing if default-MapMode
1395  if ( rMapMode.IsDefault() )
1396  return rDevicePoly;
1397 
1398  // calculate MapMode-resolution and convert
1399  ImplMapRes aMapRes;
1400  ImplThresholdRes aThresRes;
1401  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1402 
1403  sal_uInt16 i;
1404  sal_uInt16 nPoints = rDevicePoly.GetSize();
1405  tools::Polygon aPoly( rDevicePoly );
1406 
1407  // get pointer to Point-array (copy data)
1408  const Point* pPointAry = aPoly.GetConstPointAry();
1409 
1410  for ( i = 0; i < nPoints; i++ )
1411  {
1412  const Point* pPt = &(pPointAry[i]);
1413  Point aPt;
1414  aPt.setX( ImplPixelToLogic( pPt->X(), mnDPIX,
1415  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1416  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX );
1417  aPt.setY( ImplPixelToLogic( pPt->Y(), mnDPIY,
1418  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1419  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1420  aPoly[i] = aPt;
1421  }
1422 
1423  return aPoly;
1424 }
1425 
1427  const MapMode& rMapMode ) const
1428 {
1429  basegfx::B2DPolygon aTransformedPoly = rPixelPoly;
1430  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode );
1431  aTransformedPoly.transform( rTransformationMatrix );
1432  return aTransformedPoly;
1433 }
1434 
1436  const MapMode& rMapMode ) const
1437 {
1438  basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly;
1439  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode );
1440  aTransformedPoly.transform( rTransformationMatrix );
1441  return aTransformedPoly;
1442 }
1443 
1444 #define ENTER1( rSource, pMapModeSource, pMapModeDest ) \
1445  if ( !pMapModeSource ) \
1446  pMapModeSource = &maMapMode; \
1447  if ( !pMapModeDest ) \
1448  pMapModeDest = &maMapMode; \
1449  if ( *pMapModeSource == *pMapModeDest ) \
1450  return rSource; \
1451  \
1452  ImplMapRes aMapResSource; \
1453  aMapResSource.mnMapOfsX = 0; \
1454  aMapResSource.mnMapOfsY = 0; \
1455  aMapResSource.mnMapScNumX = 1; \
1456  aMapResSource.mnMapScNumY = 1; \
1457  aMapResSource.mnMapScDenomX = 1; \
1458  aMapResSource.mnMapScDenomY = 1; \
1459  ImplMapRes aMapResDest(aMapResSource); \
1460  \
1461  if ( !mbMap || pMapModeSource != &maMapMode ) \
1462  { \
1463  if ( pMapModeSource->GetMapUnit() == MapUnit::MapRelative ) \
1464  aMapResSource = maMapRes; \
1465  ImplCalcMapResolution( *pMapModeSource, \
1466  mnDPIX, mnDPIY, aMapResSource ); \
1467  } \
1468  else \
1469  aMapResSource = maMapRes; \
1470  if ( !mbMap || pMapModeDest != &maMapMode ) \
1471  { \
1472  if ( pMapModeDest->GetMapUnit() == MapUnit::MapRelative ) \
1473  aMapResDest = maMapRes; \
1474  ImplCalcMapResolution( *pMapModeDest, \
1475  mnDPIX, mnDPIY, aMapResDest ); \
1476  } \
1477  else \
1478  aMapResDest = maMapRes
1479 
1480 static void verifyUnitSourceDest( MapUnit eUnitSource, MapUnit eUnitDest )
1481 {
1482  DBG_ASSERT( eUnitSource != MapUnit::MapSysFont
1483  && eUnitSource != MapUnit::MapAppFont
1484  && eUnitSource != MapUnit::MapRelative,
1485  "Source MapUnit is not permitted" );
1486  DBG_ASSERT( eUnitDest != MapUnit::MapSysFont
1487  && eUnitDest != MapUnit::MapAppFont
1488  && eUnitDest != MapUnit::MapRelative,
1489  "Destination MapUnit is not permitted" );
1490 }
1491 
1492 #define ENTER3( eUnitSource, eUnitDest ) \
1493  long nNumerator = 1; \
1494  long nDenominator = 1; \
1495  SAL_WARN_IF( eUnitSource > s_MaxValidUnit, "vcl.gdi", "Invalid source map unit"); \
1496  SAL_WARN_IF( eUnitDest > s_MaxValidUnit, "vcl.gdi", "Invalid destination map unit"); \
1497  if( (eUnitSource <= s_MaxValidUnit) && (eUnitDest <= s_MaxValidUnit) ) \
1498  { \
1499  nNumerator = aImplNumeratorAry[eUnitSource] * \
1500  aImplDenominatorAry[eUnitDest]; \
1501  nDenominator = aImplNumeratorAry[eUnitDest] * \
1502  aImplDenominatorAry[eUnitSource]; \
1503  } \
1504  if ( eUnitSource == MapUnit::MapPixel ) \
1505  nDenominator *= 72; \
1506  else if( eUnitDest == MapUnit::MapPixel ) \
1507  nNumerator *= 72
1508 
1509 #define ENTER4( rMapModeSource, rMapModeDest ) \
1510  ImplMapRes aMapResSource; \
1511  aMapResSource.mnMapOfsX = 0; \
1512  aMapResSource.mnMapOfsY = 0; \
1513  aMapResSource.mnMapScNumX = 1; \
1514  aMapResSource.mnMapScNumY = 1; \
1515  aMapResSource.mnMapScDenomX = 1; \
1516  aMapResSource.mnMapScDenomY = 1; \
1517  ImplMapRes aMapResDest(aMapResSource); \
1518  \
1519  ImplCalcMapResolution( rMapModeSource, 72, 72, aMapResSource ); \
1520  ImplCalcMapResolution( rMapModeDest, 72, 72, aMapResDest )
1521 
1522 // return (n1 * n2 * n3) / (n4 * n5)
1523 static long fn5( const long n1,
1524  const long n2,
1525  const long n3,
1526  const long n4,
1527  const long n5 )
1528 {
1529  if ( n1 == 0 || n2 == 0 || n3 == 0 || n4 == 0 || n5 == 0 )
1530  return 0;
1531  if ( LONG_MAX / std::abs(n2) < std::abs(n3) )
1532  {
1533  // a6 is skipped
1534  BigInt a7 = n2;
1535  a7 *= n3;
1536  a7 *= n1;
1537 
1538  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1539  {
1540  BigInt a8 = n4;
1541  a8 *= n5;
1542 
1543  BigInt a9 = a8;
1544  a9 /= 2;
1545  if ( a7.IsNeg() )
1546  a7 -= a9;
1547  else
1548  a7 += a9;
1549 
1550  a7 /= a8;
1551  } // of if
1552  else
1553  {
1554  long n8 = n4 * n5;
1555 
1556  if ( a7.IsNeg() )
1557  a7 -= n8 / 2;
1558  else
1559  a7 += n8 / 2;
1560 
1561  a7 /= n8;
1562  } // of else
1563  return static_cast<long>(a7);
1564  } // of if
1565  else
1566  {
1567  long n6 = n2 * n3;
1568 
1569  if ( LONG_MAX / std::abs(n1) < std::abs(n6) )
1570  {
1571  BigInt a7 = n1;
1572  a7 *= n6;
1573 
1574  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1575  {
1576  BigInt a8 = n4;
1577  a8 *= n5;
1578 
1579  BigInt a9 = a8;
1580  a9 /= 2;
1581  if ( a7.IsNeg() )
1582  a7 -= a9;
1583  else
1584  a7 += a9;
1585 
1586  a7 /= a8;
1587  } // of if
1588  else
1589  {
1590  long n8 = n4 * n5;
1591 
1592  if ( a7.IsNeg() )
1593  a7 -= n8 / 2;
1594  else
1595  a7 += n8 / 2;
1596 
1597  a7 /= n8;
1598  } // of else
1599  return static_cast<long>(a7);
1600  } // of if
1601  else
1602  {
1603  long n7 = n1 * n6;
1604 
1605  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1606  {
1607  BigInt a7 = n7;
1608  BigInt a8 = n4;
1609  a8 *= n5;
1610 
1611  BigInt a9 = a8;
1612  a9 /= 2;
1613  if ( a7.IsNeg() )
1614  a7 -= a9;
1615  else
1616  a7 += a9;
1617 
1618  a7 /= a8;
1619  return static_cast<long>(a7);
1620  } // of if
1621  else
1622  {
1623  const long n8 = n4 * n5;
1624  const long n8_2 = n8 / 2;
1625 
1626  if( n7 < 0 )
1627  {
1628  if( ( n7 - LONG_MIN ) >= n8_2 )
1629  n7 -= n8_2;
1630  }
1631  else if( ( LONG_MAX - n7 ) >= n8_2 )
1632  n7 += n8_2;
1633 
1634  return n7 / n8;
1635  } // of else
1636  } // of else
1637  } // of else
1638 }
1639 
1640 // return (n1 * n2) / n3
1641 static long fn3( const long n1, const long n2, const long n3 )
1642 {
1643  if ( n1 == 0 || n2 == 0 || n3 == 0 )
1644  return 0;
1645  if ( LONG_MAX / std::abs(n1) < std::abs(n2) )
1646  {
1647  BigInt a4 = n1;
1648  a4 *= n2;
1649 
1650  if ( a4.IsNeg() )
1651  a4 -= n3 / 2;
1652  else
1653  a4 += n3 / 2;
1654 
1655  a4 /= n3;
1656  return static_cast<long>(a4);
1657  } // of if
1658  else
1659  {
1660  long n4 = n1 * n2;
1661  const long n3_2 = n3 / 2;
1662 
1663  if( n4 < 0 )
1664  {
1665  if( ( n4 - LONG_MIN ) >= n3_2 )
1666  n4 -= n3_2;
1667  }
1668  else if( ( LONG_MAX - n4 ) >= n3_2 )
1669  n4 += n3_2;
1670 
1671  return n4 / n3;
1672  } // of else
1673 }
1674 
1675 Point OutputDevice::LogicToLogic( const Point& rPtSource,
1676  const MapMode* pMapModeSource,
1677  const MapMode* pMapModeDest ) const
1678 {
1679  ENTER1( rPtSource, pMapModeSource, pMapModeDest );
1680 
1681  return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
1682  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1683  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1684  aMapResDest.mnMapOfsX,
1685  fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
1686  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1687  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1688  aMapResDest.mnMapOfsY );
1689 }
1690 
1692  const MapMode* pMapModeSource,
1693  const MapMode* pMapModeDest ) const
1694 {
1695  ENTER1( rSzSource, pMapModeSource, pMapModeDest );
1696 
1697  return Size( fn5( rSzSource.Width(),
1698  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1699  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ),
1700  fn5( rSzSource.Height(),
1701  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1702  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) );
1703 }
1704 
1706  const MapMode* pMapModeSource,
1707  const MapMode* pMapModeDest ) const
1708 {
1709  ENTER1( rRectSource, pMapModeSource, pMapModeDest );
1710 
1711  return tools::Rectangle( fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
1712  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1713  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1714  aMapResDest.mnMapOfsX,
1715  fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
1716  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1717  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1718  aMapResDest.mnMapOfsY,
1719  fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
1720  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1721  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1722  aMapResDest.mnMapOfsX,
1723  fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
1724  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1725  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1726  aMapResDest.mnMapOfsY );
1727 }
1728 
1729 Point OutputDevice::LogicToLogic( const Point& rPtSource,
1730  const MapMode& rMapModeSource,
1731  const MapMode& rMapModeDest )
1732 {
1733  if ( rMapModeSource == rMapModeDest )
1734  return rPtSource;
1735 
1736  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1737  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1738  verifyUnitSourceDest( eUnitSource, eUnitDest );
1739 
1740  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1741  {
1742  ENTER3( eUnitSource, eUnitDest );
1743 
1744  return Point( fn3( rPtSource.X(), nNumerator, nDenominator ),
1745  fn3( rPtSource.Y(), nNumerator, nDenominator ) );
1746  }
1747  else
1748  {
1749  ENTER4( rMapModeSource, rMapModeDest );
1750 
1751  return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
1752  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1753  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1754  aMapResDest.mnMapOfsX,
1755  fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
1756  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1757  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1758  aMapResDest.mnMapOfsY );
1759  }
1760 }
1761 
1763  const MapMode& rMapModeSource,
1764  const MapMode& rMapModeDest )
1765 {
1766  if ( rMapModeSource == rMapModeDest )
1767  return rSzSource;
1768 
1769  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1770  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1771  verifyUnitSourceDest( eUnitSource, eUnitDest );
1772 
1773  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1774  {
1775  ENTER3( eUnitSource, eUnitDest );
1776 
1777  return Size( fn3( rSzSource.Width(), nNumerator, nDenominator ),
1778  fn3( rSzSource.Height(), nNumerator, nDenominator ) );
1779  }
1780  else
1781  {
1782  ENTER4( rMapModeSource, rMapModeDest );
1783 
1784  return Size( fn5( rSzSource.Width(),
1785  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1786  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ),
1787  fn5( rSzSource.Height(),
1788  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1789  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) );
1790  }
1791 }
1792 
1794  const MapMode& rMapModeSource,
1795  const MapMode& rMapModeDest )
1796 {
1797  if(rMapModeSource == rMapModeDest)
1798  {
1799  return rPolySource;
1800  }
1801 
1802  const basegfx::B2DHomMatrix aTransform(LogicToLogic(rMapModeSource, rMapModeDest));
1803  basegfx::B2DPolygon aPoly(rPolySource);
1804 
1805  aPoly.transform(aTransform);
1806  return aPoly;
1807 }
1808 
1809 basegfx::B2DHomMatrix OutputDevice::LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest)
1810 {
1811  basegfx::B2DHomMatrix aTransform;
1812 
1813  if(rMapModeSource == rMapModeDest)
1814  {
1815  return aTransform;
1816  }
1817 
1818  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1819  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1820  verifyUnitSourceDest(eUnitSource, eUnitDest);
1821 
1822  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1823  {
1824  ENTER3(eUnitSource, eUnitDest);
1825 
1826  const double fScaleFactor(static_cast<double>(nNumerator) / static_cast<double>(nDenominator));
1827  aTransform.set(0, 0, fScaleFactor);
1828  aTransform.set(1, 1, fScaleFactor);
1829  }
1830  else
1831  {
1832  ENTER4(rMapModeSource, rMapModeDest);
1833 
1834  const double fScaleFactorX((double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)));
1835  const double fScaleFactorY((double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)));
1836  const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX));
1837  const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY));
1838 
1839  aTransform.set(0, 0, fScaleFactorX);
1840  aTransform.set(1, 1, fScaleFactorY);
1841  aTransform.set(0, 2, fZeroPointX);
1842  aTransform.set(1, 2, fZeroPointY);
1843  }
1844 
1845  return aTransform;
1846 }
1847 
1849  const MapMode& rMapModeSource,
1850  const MapMode& rMapModeDest )
1851 {
1852  if ( rMapModeSource == rMapModeDest )
1853  return rRectSource;
1854 
1855  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1856  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1857  verifyUnitSourceDest( eUnitSource, eUnitDest );
1858 
1859  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1860  {
1861  ENTER3( eUnitSource, eUnitDest );
1862 
1863  auto left = fn3( rRectSource.Left(), nNumerator, nDenominator );
1864  auto top = fn3( rRectSource.Top(), nNumerator, nDenominator );
1865  if (rRectSource.IsEmpty())
1866  return tools::Rectangle( left, top );
1867 
1868  auto right = fn3( rRectSource.Right(), nNumerator, nDenominator );
1869  auto bottom = fn3( rRectSource.Bottom(), nNumerator, nDenominator );
1870  return tools::Rectangle(left, top, right, bottom);
1871  }
1872  else
1873  {
1874  ENTER4( rMapModeSource, rMapModeDest );
1875 
1876  auto left = fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
1877  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1878  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1879  aMapResDest.mnMapOfsX;
1880  auto top = fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
1881  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1882  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1883  aMapResDest.mnMapOfsY;
1884  if (rRectSource.IsEmpty())
1885  return tools::Rectangle(left, top);
1886 
1887  auto right = fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
1888  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1889  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1890  aMapResDest.mnMapOfsX;
1891  auto bottom = fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
1892  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1893  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1894  aMapResDest.mnMapOfsY;
1895  return tools::Rectangle(left, top, right, bottom);
1896  }
1897 }
1898 
1899 long OutputDevice::LogicToLogic( long nLongSource,
1900  MapUnit eUnitSource, MapUnit eUnitDest )
1901 {
1902  if ( eUnitSource == eUnitDest )
1903  return nLongSource;
1904 
1905  verifyUnitSourceDest( eUnitSource, eUnitDest );
1906  ENTER3( eUnitSource, eUnitDest );
1907 
1908  return fn3( nLongSource, nNumerator, nDenominator );
1909 }
1910 
1911 void OutputDevice::SetPixelOffset( const Size& rOffset )
1912 {
1913  mnOutOffOrigX = rOffset.Width();
1914  mnOutOffOrigY = rOffset.Height();
1915 
1922 
1923  if( mpAlphaVDev )
1924  mpAlphaVDev->SetPixelOffset( rOffset );
1925 }
1926 
1927 
1929 {
1930  if ( !mbMap )
1931  return static_cast<DeviceCoordinate>(nWidth);
1932 
1933 #if VCL_FLOAT_DEVICE_PIXEL
1934  return (double)nWidth * maMapRes.mfScaleX * mnDPIX;
1935 #else
1936 
1937  return ImplLogicToPixel( nWidth, mnDPIX,
1940 #endif
1941 }
1942 
1943 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 Count() const
basegfx::B2DHomMatrix GetInverseViewTransformation() const
Definition: map.cxx:882
const Fraction & GetScaleX() const
Definition: mapmod.cxx:172
long Width() const
long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:340
void SetPixelOffset(const Size &rOffset)
Set an offset in pixel.
Definition: map.cxx:1911
void SetRelativeMapMode(const MapMode &rNewMapMode)
Definition: map.cxx:782
static void verifyUnitSourceDest(MapUnit eUnitSource, MapUnit eUnitDest)
Definition: map.cxx:1480
static void ImplCalcBigIntThreshold(long nDPIX, long nDPIY, const ImplMapRes &rMapRes, ImplThresholdRes &rThresRes)
Definition: map.cxx:91
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
bool IsNull() const
Definition: region.hxx:102
sal_uInt64 left
const MapUnit s_MaxValidUnit
Definition: map.cxx:39
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1675
ImplThresholdRes maThresRes
Definition: outdev.hxx:356
long Height() const
long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:342
static SAL_DLLPRIVATE void ImplInitAppFontData(vcl::Window const *pWindow)
Definition: window.cxx:1167
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:508
sal_uIntPtr sal_uLong
SAL_DLLPRIVATE bool IsSimple() const
Definition: mapmod.cxx:176
long mnMapOfsY
Definition: outdevmap.hxx:26
sal_Int32 mnDPIY
Definition: outdev.hxx:346
sal_Int32 mnDPIX
Definition: outdev.hxx:345
void EnableMapMode(bool bEnable=true)
Definition: map.cxx:646
bool mbMap
Definition: outdev.hxx:374
bool IsDefault() const
Definition: mapmod.cxx:131
const RegionBand * getRegionBand() const
Definition: region.hxx:81
long mnOutOffOrigX
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:332
void SetMapMode()
Definition: map.cxx:654
static long fn5(const long n1, const long n2, const long n3, const long n4, const long n5)
Definition: map.cxx:1523
ImplSVGDIData maGDIData
Definition: svdata.hxx:393
const basegfx::B2DPolyPolygon * getB2DPolyPolygon() const
Definition: region.hxx:79
std::vector< tools::Rectangle > RectangleVector
Definition: region.hxx:37
MapMode maMapMode
Definition: outdev.hxx:369
#define ENTER1(rSource, pMapModeSource, pMapModeDest)
Definition: map.cxx:1444
bool IsEmpty() const
const o3tl::enumarray< MapUnit, long > aImplNumeratorAry
Definition: map.cxx:40
A construction helper for ScopedVclPtr.
Definition: vclptr.hxx:407
static Fraction ImplMakeFraction(long nN1, long nN2, long nD1, long nD2)
Definition: map.cxx:50
static long ImplPixelToLogic(long n, long nDPI, long nMapNum, long nMapDenom, long nThres)
Definition: map.cxx:384
long Right() const
#define ENTER4(rMapModeSource, rMapModeDest)
Definition: map.cxx:1509
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const Fraction & GetScaleY() const
Definition: mapmod.cxx:174
long DeviceCoordinate
long Top() const
void Move(long nHorzMove, long nVertMove)
Definition: region.cxx:414
SAL_DLLPRIVATE long ImplLogicXToDevicePixel(long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
Definition: map.cxx:410
SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const
Get device transformation.
Definition: map.cxx:932
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
SAL_DLLPRIVATE void ImplInvalidateViewTransform()
Invalidate the view transformation.
Definition: map.cxx:329
bool IsEmpty() const
Definition: region.cxx:228
void ReduceInaccurate(unsigned nSignificantBits)
def right
static long fn3(const long n1, const long n2, const long n3)
Definition: map.cxx:1641
void SetScaleX(const Fraction &rScaleX)
Definition: mapmod.cxx:108
virtual void ImplInitMapModeObjects()
Definition: map.cxx:780
SAL_DLLPRIVATE long ImplLogicYToDevicePixel(long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
Definition: map.cxx:420
#define DBG_ASSERT(sCon, aError)
int i
SAL_DLLPRIVATE float ImplFloatLogicHeightToDevicePixel(float fLogicHeight) const
Convert logical height to device pixels, with exact sub-pixel value.
Definition: map.cxx:450
static long ImplLogicToPixel(long n, long nDPI, long nMapNum, long nMapDenom, long nThres)
Definition: map.cxx:347
long mnOutOffOrigY
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:336
const Point * GetConstPointAry() const
long mnOutOffLogicX
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:334
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:102
long mnMapScNumX
Definition: outdevmap.hxx:27
bool mbNewFont
Definition: outdev.hxx:388
long Bottom() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
void SetScaleY(const Fraction &rScaleY)
Definition: mapmod.cxx:115
sal_uInt16 GetSize() const
const o3tl::enumarray< MapUnit, long > aImplDenominatorAry
Definition: map.cxx:42
MapUnit GetMapUnit() const
Definition: mapmod.cxx:168
bool IsNeg() const
virtual void SetMetafileMapMode(const MapMode &rNewMapMode, bool bIsRecord)
Definition: map.cxx:772
#define ENTER3(eUnitSource, eUnitDest)
Definition: map.cxx:1492
long mnAppFontX
Definition: svdata.hxx:226
const long LONG_MAX
void transform(const basegfx::B2DHomMatrix &rMatrix)
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1186
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:941
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:329
SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel(const vcl::Region &rRegion) const
Convert a region in pixel units to a region in device pixel units and coords.
Definition: map.cxx:636
long mnMapScDenomY
Definition: outdevmap.hxx:30
ImplMapRes maMapRes
Definition: outdev.hxx:355
sal_Int32 GetDenominator() const
long mnOutOffLogicY
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:338
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:566
const tools::PolyPolygon * getPolyPolygon() const
Definition: region.hxx:80
ImplSVFrameData maFrameData
Definition: svdata.hxx:394
SAL_DLLPRIVATE long ImplDevicePixelToLogicHeight(long nHeight) const
Convert device pixels to a height in logical units.
Definition: map.cxx:468
void GetRegionRectangles(RectangleVector &rTarget) const
Definition: region.cxx:1659
sal_Int32 GetNumerator() const
bool mbInitFont
Definition: outdev.hxx:384
const Point & GetOrigin() const
Definition: mapmod.cxx:170
SAL_DLLPRIVATE long ImplLogicWidthToDevicePixel(long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:430
long mnMapScDenomX
Definition: outdevmap.hxx:29
long Left() const
void translate(double fX, double fY)
static void ImplCalcMapResolution(const MapMode &rMapMode, long nDPIX, long nDPIY, ImplMapRes &rMapRes)
Definition: map.cxx:151
SAL_DLLPRIVATE long ImplLogicHeightToDevicePixel(long nHeight) const
Convert a logical height to a height in units of device pixels.
Definition: map.cxx:440
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:504
SAL_DLLPRIVATE long ImplDevicePixelToLogicWidth(long nWidth) const
Convert device pixels to a width in logical units.
Definition: map.cxx:458
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:237
MapUnit
#define SAL_WARN(area, stream)
std::unique_ptr< ImplOutDevData > mpOutDevData
Definition: outdev.hxx:324
SAL_DLLPRIVATE tools::Rectangle ImplDevicePixelToLogic(const tools::Rectangle &rPixelRect) const
Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords...
Definition: map.cxx:611
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
bool IsValid() const
long mnMapScNumY
Definition: outdevmap.hxx:28
long mnAppFontY
Definition: svdata.hxx:227
SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate(long nWidth) const
Definition: map.cxx:1928
long mnMapOfsX
Definition: outdevmap.hxx:25
basegfx::B2DHomMatrix GetViewTransformation() const
Definition: map.cxx:854
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:317
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo