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 static 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->maWinData.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 
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* pPt = &(pPointAry[i]);
546  Point aPt;
553  aPoly[i] = aPt;
554  }
555  }
556  else
557  {
558  for ( i = 0; i < nPoints; i++ )
559  {
560  Point aPt = pPointAry[i];
561  aPt.AdjustX(mnOutOffX );
562  aPt.AdjustY(mnOutOffY );
563  aPoly[i] = aPt;
564  }
565  }
566 
567  return aPoly;
568 }
569 
571 {
572  if ( !mbMap && !mnOutOffX && !mnOutOffY )
573  return rLogicPolyPoly;
574 
575  tools::PolyPolygon aPolyPoly( rLogicPolyPoly );
576  sal_uInt16 nPoly = aPolyPoly.Count();
577  for( sal_uInt16 i = 0; i < nPoly; i++ )
578  {
579  tools::Polygon& rPoly = aPolyPoly[i];
580  rPoly = ImplLogicToDevicePixel( rPoly );
581  }
582  return aPolyPoly;
583 }
584 
586 {
587  LineInfo aInfo( rLineInfo );
588 
589  if( aInfo.GetStyle() == LineStyle::Dash )
590  {
591  if( aInfo.GetDotCount() && aInfo.GetDotLen() )
592  aInfo.SetDotLen( std::max( ImplLogicWidthToDevicePixel( aInfo.GetDotLen() ), 1L ) );
593  else
594  aInfo.SetDotCount( 0 );
595 
596  if( aInfo.GetDashCount() && aInfo.GetDashLen() )
597  aInfo.SetDashLen( std::max( ImplLogicWidthToDevicePixel( aInfo.GetDashLen() ), 1L ) );
598  else
599  aInfo.SetDashCount( 0 );
600 
601  aInfo.SetDistance( ImplLogicWidthToDevicePixel( aInfo.GetDistance() ) );
602 
603  if( ( !aInfo.GetDashCount() && !aInfo.GetDotCount() ) || !aInfo.GetDistance() )
604  aInfo.SetStyle( LineStyle::Solid );
605  }
606 
607  aInfo.SetWidth( ImplLogicWidthToDevicePixel( aInfo.GetWidth() ) );
608 
609  return aInfo;
610 }
611 
613 {
614  if ( rPixelRect.IsEmpty() )
615  return rPixelRect;
616 
617  if ( !mbMap )
618  {
619  return tools::Rectangle( rPixelRect.Left()-mnOutOffX, rPixelRect.Top()-mnOutOffY,
620  rPixelRect.Right()-mnOutOffX, rPixelRect.Bottom()-mnOutOffY );
621  }
622 
635 }
636 
638 {
639  if ( !mnOutOffX && !mnOutOffY )
640  return rRegion;
641 
642  vcl::Region aRegion( rRegion );
644  return aRegion;
645 }
646 
647 void OutputDevice::EnableMapMode( bool bEnable )
648 {
649  mbMap = bEnable;
650 
651  if( mpAlphaVDev )
652  mpAlphaVDev->EnableMapMode( bEnable );
653 }
654 
656 {
657 
658  if ( mpMetaFile )
660 
661  if ( mbMap || !maMapMode.IsDefault() )
662  {
663  mbMap = false;
664  maMapMode = MapMode();
665 
666  // create new objects (clip region are not re-scaled)
667  mbNewFont = true;
668  mbInitFont = true;
669  if ( GetOutDevType() == OUTDEV_WINDOW )
670  {
671  if ( static_cast<vcl::Window*>(this)->mpWindowImpl->mpCursor )
672  static_cast<vcl::Window*>(this)->mpWindowImpl->mpCursor->ImplNew();
673  }
674 
675  // #106426# Adapt logical offset when changing mapmode
676  mnOutOffLogicX = mnOutOffOrigX; // no mapping -> equal offsets
678 
679  // #i75163#
681  }
682 
683  if( mpAlphaVDev )
685 }
686 
687 void OutputDevice::SetMapMode( const MapMode& rNewMapMode )
688 {
689 
690  bool bRelMap = (rNewMapMode.GetMapUnit() == MapUnit::MapRelative);
691 
692  if ( mpMetaFile )
693  {
694  mpMetaFile->AddAction( new MetaMapModeAction( rNewMapMode ) );
695  }
696 
697  // do nothing if MapMode was not changed
698  if ( maMapMode == rNewMapMode )
699  return;
700 
701  if( mpAlphaVDev )
702  mpAlphaVDev->SetMapMode( rNewMapMode );
703 
704  // if default MapMode calculate nothing
705  bool bOldMap = mbMap;
706  mbMap = !rNewMapMode.IsDefault();
707  if ( mbMap )
708  {
709  // if only the origin is converted, do not scale new
710  if ( (rNewMapMode.GetMapUnit() == maMapMode.GetMapUnit()) &&
711  (rNewMapMode.GetScaleX() == maMapMode.GetScaleX()) &&
712  (rNewMapMode.GetScaleY() == maMapMode.GetScaleY()) &&
713  (bOldMap == mbMap) )
714  {
715  // set offset
716  Point aOrigin = rNewMapMode.GetOrigin();
717  maMapRes.mnMapOfsX = aOrigin.X();
718  maMapRes.mnMapOfsY = aOrigin.Y();
719  maMapMode = rNewMapMode;
720 
721  // #i75163#
723 
724  return;
725  }
726  if ( !bOldMap && bRelMap )
727  {
728  maMapRes.mnMapScNumX = 1;
729  maMapRes.mnMapScNumY = 1;
732  maMapRes.mnMapOfsX = 0;
733  maMapRes.mnMapOfsY = 0;
734  }
735 
736  // calculate new MapMode-resolution
738  }
739 
740  // set new MapMode
741  if ( bRelMap )
742  {
744  // aScale? = maMapMode.GetScale?() * rNewMapMode.GetScale?()
746  rNewMapMode.GetScaleX().GetNumerator(),
748  rNewMapMode.GetScaleX().GetDenominator() );
750  rNewMapMode.GetScaleY().GetNumerator(),
752  rNewMapMode.GetScaleY().GetDenominator() );
753  maMapMode.SetOrigin( aOrigin );
754  maMapMode.SetScaleX( aScaleX );
755  maMapMode.SetScaleY( aScaleY );
756  }
757  else
758  maMapMode = rNewMapMode;
759 
760  // create new objects (clip region are not re-scaled)
761  mbNewFont = true;
762  mbInitFont = true;
763  if ( GetOutDevType() == OUTDEV_WINDOW )
764  {
765  if ( static_cast<vcl::Window*>(this)->mpWindowImpl->mpCursor )
766  static_cast<vcl::Window*>(this)->mpWindowImpl->mpCursor->ImplNew();
767  }
768 
769  // #106426# Adapt logical offset when changing mapmode
776 
777  // #i75163#
779 }
780 
781 void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
782 {
783  // do nothing if MapMode did not change
784  if ( maMapMode == rNewMapMode )
785  return;
786 
787  MapUnit eOld = maMapMode.GetMapUnit();
788  MapUnit eNew = rNewMapMode.GetMapUnit();
789 
790  // a?F = rNewMapMode.GetScale?() / maMapMode.GetScale?()
791  Fraction aXF = ImplMakeFraction( rNewMapMode.GetScaleX().GetNumerator(),
793  rNewMapMode.GetScaleX().GetDenominator(),
795  Fraction aYF = ImplMakeFraction( rNewMapMode.GetScaleY().GetNumerator(),
797  rNewMapMode.GetScaleY().GetDenominator(),
799 
800  Point aPt( LogicToLogic( Point(), nullptr, &rNewMapMode ) );
801  if ( eNew != eOld )
802  {
803  if ( eOld > MapUnit::MapPixel )
804  {
805  SAL_WARN( "vcl.gdi", "Not implemented MapUnit" );
806  }
807  else if ( eNew > MapUnit::MapPixel )
808  {
809  SAL_WARN( "vcl.gdi", "Not implemented MapUnit" );
810  }
811  else
812  {
813  Fraction aF( aImplNumeratorAry[eNew] * aImplDenominatorAry[eOld],
814  aImplNumeratorAry[eOld] * aImplDenominatorAry[eNew] );
815 
816  // a?F = a?F * aF
817  aXF = ImplMakeFraction( aXF.GetNumerator(), aF.GetNumerator(),
818  aXF.GetDenominator(), aF.GetDenominator() );
819  aYF = ImplMakeFraction( aYF.GetNumerator(), aF.GetNumerator(),
820  aYF.GetDenominator(), aF.GetDenominator() );
821  if ( eOld == MapUnit::MapPixel )
822  {
823  aXF *= Fraction( mnDPIX, 1 );
824  aYF *= Fraction( mnDPIY, 1 );
825  }
826  else if ( eNew == MapUnit::MapPixel )
827  {
828  aXF *= Fraction( 1, mnDPIX );
829  aYF *= Fraction( 1, mnDPIY );
830  }
831  }
832  }
833 
834  MapMode aNewMapMode( MapUnit::MapRelative, Point( -aPt.X(), -aPt.Y() ), aXF, aYF );
835  SetMapMode( aNewMapMode );
836 
837  if ( eNew != eOld )
838  maMapMode = rNewMapMode;
839 
840  // #106426# Adapt logical offset when changing MapMode
847 
848  if( mpAlphaVDev )
849  mpAlphaVDev->SetRelativeMapMode( rNewMapMode );
850 }
851 
852 // #i75163#
854 {
855  if(mbMap && mpOutDevData)
856  {
857  if(!mpOutDevData->mpViewTransform)
858  {
859  mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix;
860 
861  const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(maMapRes.mnMapScNumX) / static_cast<double>(maMapRes.mnMapScDenomX));
862  const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(maMapRes.mnMapScNumY) / static_cast<double>(maMapRes.mnMapScDenomY));
863  const double fZeroPointX((static_cast<double>(maMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX));
864  const double fZeroPointY((static_cast<double>(maMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY));
865 
866  mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX);
867  mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY);
868  mpOutDevData->mpViewTransform->set(0, 2, fZeroPointX);
869  mpOutDevData->mpViewTransform->set(1, 2, fZeroPointY);
870  }
871 
872  return *mpOutDevData->mpViewTransform;
873  }
874  else
875  {
876  return basegfx::B2DHomMatrix();
877  }
878 }
879 
880 // #i75163#
882 {
883  if(mbMap && mpOutDevData)
884  {
885  if(!mpOutDevData->mpInverseViewTransform)
886  {
888  mpOutDevData->mpInverseViewTransform = new basegfx::B2DHomMatrix(*mpOutDevData->mpViewTransform);
889  mpOutDevData->mpInverseViewTransform->invert();
890  }
891 
892  return *mpOutDevData->mpInverseViewTransform;
893  }
894  else
895  {
896  return basegfx::B2DHomMatrix();
897  }
898 }
899 
900 // #i75163#
902 {
903  // #i82615#
904  ImplMapRes aMapRes;
905  ImplThresholdRes aThresRes;
906  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
907 
908  basegfx::B2DHomMatrix aTransform;
909 
910  const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(aMapRes.mnMapScNumX) / static_cast<double>(aMapRes.mnMapScDenomX));
911  const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(aMapRes.mnMapScNumY) / static_cast<double>(aMapRes.mnMapScDenomY));
912  const double fZeroPointX((static_cast<double>(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX));
913  const double fZeroPointY((static_cast<double>(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY));
914 
915  aTransform.set(0, 0, fScaleFactorX);
916  aTransform.set(1, 1, fScaleFactorY);
917  aTransform.set(0, 2, fZeroPointX);
918  aTransform.set(1, 2, fZeroPointY);
919 
920  return aTransform;
921 }
922 
923 // #i75163#
925 {
926  basegfx::B2DHomMatrix aMatrix( GetViewTransformation( rMapMode ) );
927  aMatrix.invert();
928  return aMatrix;
929 }
930 
932 {
933  basegfx::B2DHomMatrix aTransformation = GetViewTransformation();
934  // TODO: is it worth to cache the transformed result?
935  if( mnOutOffX || mnOutOffY )
936  aTransformation.translate( mnOutOffX, mnOutOffY );
937  return aTransformation;
938 }
939 
940 Point OutputDevice::LogicToPixel( const Point& rLogicPt ) const
941 {
942 
943  if ( !mbMap )
944  return rLogicPt;
945 
946  return Point( ImplLogicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, mnDPIX,
949  ImplLogicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, mnDPIY,
952 }
953 
954 Size OutputDevice::LogicToPixel( const Size& rLogicSize ) const
955 {
956 
957  if ( !mbMap )
958  return rLogicSize;
959 
960  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
963  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
966 }
967 
969 {
970 
971  if ( !mbMap || rLogicRect.IsEmpty() )
972  return rLogicRect;
973 
977  ImplLogicToPixel( rLogicRect.Top() + maMapRes.mnMapOfsY, mnDPIY,
986 }
987 
989 {
990 
991  if ( !mbMap )
992  return rLogicPoly;
993 
994  sal_uInt16 i;
995  sal_uInt16 nPoints = rLogicPoly.GetSize();
996  tools::Polygon aPoly( rLogicPoly );
997 
998  // get pointer to Point-array (copy data)
999  const Point* pPointAry = aPoly.GetConstPointAry();
1000 
1001  for ( i = 0; i < nPoints; i++ )
1002  {
1003  const Point* pPt = &(pPointAry[i]);
1004  Point aPt;
1005  aPt.setX( ImplLogicToPixel( pPt->X() + maMapRes.mnMapOfsX, mnDPIX,
1008  aPt.setY( ImplLogicToPixel( pPt->Y() + maMapRes.mnMapOfsY, mnDPIY,
1011  aPoly[i] = aPt;
1012  }
1013 
1014  return aPoly;
1015 }
1016 
1018 {
1019 
1020  if ( !mbMap )
1021  return rLogicPolyPoly;
1022 
1023  tools::PolyPolygon aPolyPoly( rLogicPolyPoly );
1024  sal_uInt16 nPoly = aPolyPoly.Count();
1025  for( sal_uInt16 i = 0; i < nPoly; i++ )
1026  {
1027  tools::Polygon& rPoly = aPolyPoly[i];
1028  rPoly = LogicToPixel( rPoly );
1029  }
1030  return aPolyPoly;
1031 }
1032 
1034 {
1035  basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly;
1036  const basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation();
1037  aTransformedPoly.transform( rTransformationMatrix );
1038  return aTransformedPoly;
1039 }
1040 
1042 {
1043 
1044  if(!mbMap || rLogicRegion.IsNull() || rLogicRegion.IsEmpty())
1045  {
1046  return rLogicRegion;
1047  }
1048 
1049  vcl::Region aRegion;
1050 
1051  if(rLogicRegion.getB2DPolyPolygon())
1052  {
1053  aRegion = vcl::Region(LogicToPixel(*rLogicRegion.getB2DPolyPolygon()));
1054  }
1055  else if(rLogicRegion.getPolyPolygon())
1056  {
1057  aRegion = vcl::Region(LogicToPixel(*rLogicRegion.getPolyPolygon()));
1058  }
1059  else if(rLogicRegion.getRegionBand())
1060  {
1061  RectangleVector aRectangles;
1062  rLogicRegion.GetRegionRectangles(aRectangles);
1063  const RectangleVector& rRectangles(aRectangles); // needed to make the '!=' work
1064 
1065  // make reverse run to fill new region bottom-up, this will speed it up due to the used data structuring
1066  for(RectangleVector::const_reverse_iterator aRectIter(rRectangles.rbegin()); aRectIter != rRectangles.rend(); ++aRectIter)
1067  {
1068  aRegion.Union(LogicToPixel(*aRectIter));
1069  }
1070  }
1071 
1072  return aRegion;
1073 }
1074 
1076  const MapMode& rMapMode ) const
1077 {
1078 
1079  if ( rMapMode.IsDefault() )
1080  return rLogicPt;
1081 
1082  // convert MapMode resolution and convert
1083  ImplMapRes aMapRes;
1084  ImplThresholdRes aThresRes;
1085  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1086 
1087  return Point( ImplLogicToPixel( rLogicPt.X() + aMapRes.mnMapOfsX, mnDPIX,
1088  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1089  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1090  ImplLogicToPixel( rLogicPt.Y() + aMapRes.mnMapOfsY, mnDPIY,
1091  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1092  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1093 }
1094 
1096  const MapMode& rMapMode ) const
1097 {
1098 
1099  if ( rMapMode.IsDefault() )
1100  return rLogicSize;
1101 
1102  // convert MapMode resolution and convert
1103  ImplMapRes aMapRes;
1104  ImplThresholdRes aThresRes;
1105  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1106 
1107  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
1108  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1109  aThresRes.mnThresLogToPixX ),
1110  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
1111  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1112  aThresRes.mnThresLogToPixY ) );
1113 }
1114 
1116  const MapMode& rMapMode ) const
1117 {
1118 
1119  if ( rMapMode.IsDefault() || rLogicRect.IsEmpty() )
1120  return rLogicRect;
1121 
1122  // convert MapMode resolution and convert
1123  ImplMapRes aMapRes;
1124  ImplThresholdRes aThresRes;
1125  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1126 
1127  return tools::Rectangle( ImplLogicToPixel( rLogicRect.Left() + aMapRes.mnMapOfsX, mnDPIX,
1128  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1129  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1130  ImplLogicToPixel( rLogicRect.Top() + aMapRes.mnMapOfsY, mnDPIY,
1131  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1132  aThresRes.mnThresLogToPixY )+mnOutOffOrigY,
1133  ImplLogicToPixel( rLogicRect.Right() + aMapRes.mnMapOfsX, mnDPIX,
1134  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1135  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1136  ImplLogicToPixel( rLogicRect.Bottom() + aMapRes.mnMapOfsY, mnDPIY,
1137  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1138  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1139 }
1140 
1142  const MapMode& rMapMode ) const
1143 {
1144 
1145  if ( rMapMode.IsDefault() )
1146  return rLogicPoly;
1147 
1148  // convert MapMode resolution and convert
1149  ImplMapRes aMapRes;
1150  ImplThresholdRes aThresRes;
1151  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1152 
1153  sal_uInt16 i;
1154  sal_uInt16 nPoints = rLogicPoly.GetSize();
1155  tools::Polygon aPoly( rLogicPoly );
1156 
1157  // get pointer to Point-array (copy data)
1158  const Point* pPointAry = aPoly.GetConstPointAry();
1159 
1160  for ( i = 0; i < nPoints; i++ )
1161  {
1162  const Point* pPt = &(pPointAry[i]);
1163  Point aPt;
1164  aPt.setX( ImplLogicToPixel( pPt->X() + aMapRes.mnMapOfsX, mnDPIX,
1165  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1166  aThresRes.mnThresLogToPixX )+mnOutOffOrigX );
1167  aPt.setY( ImplLogicToPixel( pPt->Y() + aMapRes.mnMapOfsY, mnDPIY,
1168  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1169  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1170  aPoly[i] = aPt;
1171  }
1172 
1173  return aPoly;
1174 }
1175 
1177  const MapMode& rMapMode ) const
1178 {
1179  basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly;
1180  const basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode );
1181  aTransformedPoly.transform( rTransformationMatrix );
1182  return aTransformedPoly;
1183 }
1184 
1185 Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const
1186 {
1187 
1188  if ( !mbMap )
1189  return rDevicePt;
1190 
1191  return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX,
1194  ImplPixelToLogic( rDevicePt.Y(), mnDPIY,
1197 }
1198 
1199 Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const
1200 {
1201 
1202  if ( !mbMap )
1203  return rDeviceSize;
1204 
1205  return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX,
1208  ImplPixelToLogic( rDeviceSize.Height(), mnDPIY,
1211 }
1212 
1214 {
1215 
1216  if ( !mbMap || rDeviceRect.IsEmpty() )
1217  return rDeviceRect;
1218 
1219  return tools::Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX,
1222  ImplPixelToLogic( rDeviceRect.Top(), mnDPIY,
1225  ImplPixelToLogic( rDeviceRect.Right(), mnDPIX,
1228  ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY,
1231 }
1232 
1234 {
1235 
1236  if ( !mbMap )
1237  return rDevicePoly;
1238 
1239  sal_uInt16 i;
1240  sal_uInt16 nPoints = rDevicePoly.GetSize();
1241  tools::Polygon aPoly( rDevicePoly );
1242 
1243  // get pointer to Point-array (copy data)
1244  const Point* pPointAry = aPoly.GetConstPointAry();
1245 
1246  for ( i = 0; i < nPoints; i++ )
1247  {
1248  const Point* pPt = &(pPointAry[i]);
1249  Point aPt;
1250  aPt.setX( ImplPixelToLogic( pPt->X(), mnDPIX,
1253  aPt.setY( ImplPixelToLogic( pPt->Y(), mnDPIY,
1256  aPoly[i] = aPt;
1257  }
1258 
1259  return aPoly;
1260 }
1261 
1263 {
1264 
1265  if ( !mbMap )
1266  return rDevicePolyPoly;
1267 
1268  tools::PolyPolygon aPolyPoly( rDevicePolyPoly );
1269  sal_uInt16 nPoly = aPolyPoly.Count();
1270  for( sal_uInt16 i = 0; i < nPoly; i++ )
1271  {
1272  tools::Polygon& rPoly = aPolyPoly[i];
1273  rPoly = PixelToLogic( rPoly );
1274  }
1275  return aPolyPoly;
1276 }
1277 
1279 {
1280  basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly;
1281  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation();
1282  aTransformedPoly.transform( rTransformationMatrix );
1283  return aTransformedPoly;
1284 }
1285 
1287 {
1288 
1289  if(!mbMap || rDeviceRegion.IsNull() || rDeviceRegion.IsEmpty())
1290  {
1291  return rDeviceRegion;
1292  }
1293 
1294  vcl::Region aRegion;
1295 
1296  if(rDeviceRegion.getB2DPolyPolygon())
1297  {
1298  aRegion = vcl::Region(PixelToLogic(*rDeviceRegion.getB2DPolyPolygon()));
1299  }
1300  else if(rDeviceRegion.getPolyPolygon())
1301  {
1302  aRegion = vcl::Region(PixelToLogic(*rDeviceRegion.getPolyPolygon()));
1303  }
1304  else if(rDeviceRegion.getRegionBand())
1305  {
1306  RectangleVector aRectangles;
1307  rDeviceRegion.GetRegionRectangles(aRectangles);
1308  const RectangleVector& rRectangles(aRectangles); // needed to make the '!=' work
1309 
1310  // make reverse run to fill new region bottom-up, this will speed it up due to the used data structuring
1311  for(RectangleVector::const_reverse_iterator aRectIter(rRectangles.rbegin()); aRectIter != rRectangles.rend(); ++aRectIter)
1312  {
1313  aRegion.Union(PixelToLogic(*aRectIter));
1314  }
1315  }
1316 
1317  return aRegion;
1318 }
1319 
1321  const MapMode& rMapMode ) const
1322 {
1323 
1324  // calculate nothing if default-MapMode
1325  if ( rMapMode.IsDefault() )
1326  return rDevicePt;
1327 
1328  // calculate MapMode-resolution and convert
1329  ImplMapRes aMapRes;
1330  ImplThresholdRes aThresRes;
1331  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1332 
1333  return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX,
1334  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1335  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1336  ImplPixelToLogic( rDevicePt.Y(), mnDPIY,
1337  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1338  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1339 }
1340 
1342  const MapMode& rMapMode ) const
1343 {
1344 
1345  // calculate nothing if default-MapMode
1346  if ( rMapMode.IsDefault() )
1347  return rDeviceSize;
1348 
1349  // calculate MapMode-resolution and convert
1350  ImplMapRes aMapRes;
1351  ImplThresholdRes aThresRes;
1352  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1353 
1354  return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX,
1355  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1356  aThresRes.mnThresPixToLogX ),
1357  ImplPixelToLogic( rDeviceSize.Height(), mnDPIY,
1358  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1359  aThresRes.mnThresPixToLogY ) );
1360 }
1361 
1363  const MapMode& rMapMode ) const
1364 {
1365 
1366  // calculate nothing if default-MapMode
1367  if ( rMapMode.IsDefault() || rDeviceRect.IsEmpty() )
1368  return rDeviceRect;
1369 
1370  // calculate MapMode-resolution and convert
1371  ImplMapRes aMapRes;
1372  ImplThresholdRes aThresRes;
1373  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1374 
1375  return tools::Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX,
1376  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1377  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1378  ImplPixelToLogic( rDeviceRect.Top(), mnDPIY,
1379  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1380  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY,
1381  ImplPixelToLogic( rDeviceRect.Right(), mnDPIX,
1382  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1383  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1384  ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY,
1385  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1386  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1387 }
1388 
1390  const MapMode& rMapMode ) const
1391 {
1392 
1393  // calculate nothing if default-MapMode
1394  if ( rMapMode.IsDefault() )
1395  return rDevicePoly;
1396 
1397  // calculate MapMode-resolution and convert
1398  ImplMapRes aMapRes;
1399  ImplThresholdRes aThresRes;
1400  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1401 
1402  sal_uInt16 i;
1403  sal_uInt16 nPoints = rDevicePoly.GetSize();
1404  tools::Polygon aPoly( rDevicePoly );
1405 
1406  // get pointer to Point-array (copy data)
1407  const Point* pPointAry = aPoly.GetConstPointAry();
1408 
1409  for ( i = 0; i < nPoints; i++ )
1410  {
1411  const Point* pPt = &(pPointAry[i]);
1412  Point aPt;
1413  aPt.setX( ImplPixelToLogic( pPt->X(), mnDPIX,
1414  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1415  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX );
1416  aPt.setY( ImplPixelToLogic( pPt->Y(), mnDPIY,
1417  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1418  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1419  aPoly[i] = aPt;
1420  }
1421 
1422  return aPoly;
1423 }
1424 
1426  const MapMode& rMapMode ) const
1427 {
1428  basegfx::B2DPolygon aTransformedPoly = rPixelPoly;
1429  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode );
1430  aTransformedPoly.transform( rTransformationMatrix );
1431  return aTransformedPoly;
1432 }
1433 
1435  const MapMode& rMapMode ) const
1436 {
1437  basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly;
1438  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode );
1439  aTransformedPoly.transform( rTransformationMatrix );
1440  return aTransformedPoly;
1441 }
1442 
1443 #define ENTER1( rSource, pMapModeSource, pMapModeDest ) \
1444  if ( !pMapModeSource ) \
1445  pMapModeSource = &maMapMode; \
1446  if ( !pMapModeDest ) \
1447  pMapModeDest = &maMapMode; \
1448  if ( *pMapModeSource == *pMapModeDest ) \
1449  return rSource; \
1450  \
1451  ImplMapRes aMapResSource; \
1452  aMapResSource.mnMapOfsX = 0; \
1453  aMapResSource.mnMapOfsY = 0; \
1454  aMapResSource.mnMapScNumX = 1; \
1455  aMapResSource.mnMapScNumY = 1; \
1456  aMapResSource.mnMapScDenomX = 1; \
1457  aMapResSource.mnMapScDenomY = 1; \
1458  ImplMapRes aMapResDest(aMapResSource); \
1459  \
1460  if ( !mbMap || pMapModeSource != &maMapMode ) \
1461  { \
1462  if ( pMapModeSource->GetMapUnit() == MapUnit::MapRelative ) \
1463  aMapResSource = maMapRes; \
1464  ImplCalcMapResolution( *pMapModeSource, \
1465  mnDPIX, mnDPIY, aMapResSource ); \
1466  } \
1467  else \
1468  aMapResSource = maMapRes; \
1469  if ( !mbMap || pMapModeDest != &maMapMode ) \
1470  { \
1471  if ( pMapModeDest->GetMapUnit() == MapUnit::MapRelative ) \
1472  aMapResDest = maMapRes; \
1473  ImplCalcMapResolution( *pMapModeDest, \
1474  mnDPIX, mnDPIY, aMapResDest ); \
1475  } \
1476  else \
1477  aMapResDest = maMapRes
1478 
1479 static void verifyUnitSourceDest( MapUnit eUnitSource, MapUnit eUnitDest )
1480 {
1481  DBG_ASSERT( eUnitSource != MapUnit::MapSysFont
1482  && eUnitSource != MapUnit::MapAppFont
1483  && eUnitSource != MapUnit::MapRelative,
1484  "Source MapUnit is not permitted" );
1485  DBG_ASSERT( eUnitDest != MapUnit::MapSysFont
1486  && eUnitDest != MapUnit::MapAppFont
1487  && eUnitDest != MapUnit::MapRelative,
1488  "Destination MapUnit is not permitted" );
1489  SAL_WARN_IF( eUnitSource == MapUnit::MapPixel, "vcl.gdi",
1490  "MapUnit::MapPixel approximated with 72dpi" );
1491  SAL_WARN_IF( eUnitDest == MapUnit::MapPixel, "vcl.gdi",
1492  "MapUnit::MapPixel approximated with 72dpi" );
1493 }
1494 
1495 #define ENTER3( eUnitSource, eUnitDest ) \
1496  long nNumerator = 1; \
1497  long nDenominator = 1; \
1498  SAL_WARN_IF( eUnitSource > s_MaxValidUnit, "vcl.gdi", "Invalid source map unit"); \
1499  SAL_WARN_IF( eUnitDest > s_MaxValidUnit, "vcl.gdi", "Invalid destination map unit"); \
1500  if( (eUnitSource <= s_MaxValidUnit) && (eUnitDest <= s_MaxValidUnit) ) \
1501  { \
1502  nNumerator = aImplNumeratorAry[eUnitSource] * \
1503  aImplDenominatorAry[eUnitDest]; \
1504  nDenominator = aImplNumeratorAry[eUnitDest] * \
1505  aImplDenominatorAry[eUnitSource]; \
1506  } \
1507  if ( eUnitSource == MapUnit::MapPixel ) \
1508  nDenominator *= 72; \
1509  else if( eUnitDest == MapUnit::MapPixel ) \
1510  nNumerator *= 72
1511 
1512 #define ENTER4( rMapModeSource, rMapModeDest ) \
1513  ImplMapRes aMapResSource; \
1514  aMapResSource.mnMapOfsX = 0; \
1515  aMapResSource.mnMapOfsY = 0; \
1516  aMapResSource.mnMapScNumX = 1; \
1517  aMapResSource.mnMapScNumY = 1; \
1518  aMapResSource.mnMapScDenomX = 1; \
1519  aMapResSource.mnMapScDenomY = 1; \
1520  ImplMapRes aMapResDest(aMapResSource); \
1521  \
1522  ImplCalcMapResolution( rMapModeSource, 72, 72, aMapResSource ); \
1523  ImplCalcMapResolution( rMapModeDest, 72, 72, aMapResDest )
1524 
1525 // return (n1 * n2 * n3) / (n4 * n5)
1526 static long fn5( const long n1,
1527  const long n2,
1528  const long n3,
1529  const long n4,
1530  const long n5 )
1531 {
1532  if ( n1 == 0 || n2 == 0 || n3 == 0 || n4 == 0 || n5 == 0 )
1533  return 0;
1534  if ( LONG_MAX / std::abs(n2) < std::abs(n3) )
1535  {
1536  // a6 is skipped
1537  BigInt a7 = n2;
1538  a7 *= n3;
1539  a7 *= n1;
1540 
1541  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1542  {
1543  BigInt a8 = n4;
1544  a8 *= n5;
1545 
1546  BigInt a9 = a8;
1547  a9 /= 2;
1548  if ( a7.IsNeg() )
1549  a7 -= a9;
1550  else
1551  a7 += a9;
1552 
1553  a7 /= a8;
1554  } // of if
1555  else
1556  {
1557  long n8 = n4 * n5;
1558 
1559  if ( a7.IsNeg() )
1560  a7 -= n8 / 2;
1561  else
1562  a7 += n8 / 2;
1563 
1564  a7 /= n8;
1565  } // of else
1566  return static_cast<long>(a7);
1567  } // of if
1568  else
1569  {
1570  long n6 = n2 * n3;
1571 
1572  if ( LONG_MAX / std::abs(n1) < std::abs(n6) )
1573  {
1574  BigInt a7 = n1;
1575  a7 *= n6;
1576 
1577  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1578  {
1579  BigInt a8 = n4;
1580  a8 *= n5;
1581 
1582  BigInt a9 = a8;
1583  a9 /= 2;
1584  if ( a7.IsNeg() )
1585  a7 -= a9;
1586  else
1587  a7 += a9;
1588 
1589  a7 /= a8;
1590  } // of if
1591  else
1592  {
1593  long n8 = n4 * n5;
1594 
1595  if ( a7.IsNeg() )
1596  a7 -= n8 / 2;
1597  else
1598  a7 += n8 / 2;
1599 
1600  a7 /= n8;
1601  } // of else
1602  return static_cast<long>(a7);
1603  } // of if
1604  else
1605  {
1606  long n7 = n1 * n6;
1607 
1608  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1609  {
1610  BigInt a7 = n7;
1611  BigInt a8 = n4;
1612  a8 *= n5;
1613 
1614  BigInt a9 = a8;
1615  a9 /= 2;
1616  if ( a7.IsNeg() )
1617  a7 -= a9;
1618  else
1619  a7 += a9;
1620 
1621  a7 /= a8;
1622  return static_cast<long>(a7);
1623  } // of if
1624  else
1625  {
1626  const long n8 = n4 * n5;
1627  const long n8_2 = n8 / 2;
1628 
1629  if( n7 < 0 )
1630  {
1631  if( ( n7 - LONG_MIN ) >= n8_2 )
1632  n7 -= n8_2;
1633  }
1634  else if( ( LONG_MAX - n7 ) >= n8_2 )
1635  n7 += n8_2;
1636 
1637  return n7 / n8;
1638  } // of else
1639  } // of else
1640  } // of else
1641 }
1642 
1643 // return (n1 * n2) / n3
1644 static long fn3( const long n1, const long n2, const long n3 )
1645 {
1646  if ( n1 == 0 || n2 == 0 || n3 == 0 )
1647  return 0;
1648  if ( LONG_MAX / std::abs(n1) < std::abs(n2) )
1649  {
1650  BigInt a4 = n1;
1651  a4 *= n2;
1652 
1653  if ( a4.IsNeg() )
1654  a4 -= n3 / 2;
1655  else
1656  a4 += n3 / 2;
1657 
1658  a4 /= n3;
1659  return static_cast<long>(a4);
1660  } // of if
1661  else
1662  {
1663  long n4 = n1 * n2;
1664  const long n3_2 = n3 / 2;
1665 
1666  if( n4 < 0 )
1667  {
1668  if( ( n4 - LONG_MIN ) >= n3_2 )
1669  n4 -= n3_2;
1670  }
1671  else if( ( LONG_MAX - n4 ) >= n3_2 )
1672  n4 += n3_2;
1673 
1674  return n4 / n3;
1675  } // of else
1676 }
1677 
1679  const MapMode* pMapModeSource,
1680  const MapMode* pMapModeDest ) const
1681 {
1682  ENTER1( rPtSource, pMapModeSource, pMapModeDest );
1683 
1684  return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
1685  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1686  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1687  aMapResDest.mnMapOfsX,
1688  fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
1689  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1690  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1691  aMapResDest.mnMapOfsY );
1692 }
1693 
1695  const MapMode* pMapModeSource,
1696  const MapMode* pMapModeDest ) const
1697 {
1698  ENTER1( rSzSource, pMapModeSource, pMapModeDest );
1699 
1700  return Size( fn5( rSzSource.Width(),
1701  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1702  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ),
1703  fn5( rSzSource.Height(),
1704  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1705  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) );
1706 }
1707 
1709  const MapMode* pMapModeSource,
1710  const MapMode* pMapModeDest ) const
1711 {
1712  ENTER1( rRectSource, pMapModeSource, pMapModeDest );
1713 
1714  return tools::Rectangle( fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
1715  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1716  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1717  aMapResDest.mnMapOfsX,
1718  fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
1719  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1720  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1721  aMapResDest.mnMapOfsY,
1722  fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
1723  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1724  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1725  aMapResDest.mnMapOfsX,
1726  fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
1727  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1728  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1729  aMapResDest.mnMapOfsY );
1730 }
1731 
1733  const MapMode& rMapModeSource,
1734  const MapMode& rMapModeDest )
1735 {
1736  if ( rMapModeSource == rMapModeDest )
1737  return rPtSource;
1738 
1739  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1740  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1741  verifyUnitSourceDest( eUnitSource, eUnitDest );
1742 
1743  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1744  {
1745  ENTER3( eUnitSource, eUnitDest );
1746 
1747  return Point( fn3( rPtSource.X(), nNumerator, nDenominator ),
1748  fn3( rPtSource.Y(), nNumerator, nDenominator ) );
1749  }
1750  else
1751  {
1752  ENTER4( rMapModeSource, rMapModeDest );
1753 
1754  return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
1755  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1756  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1757  aMapResDest.mnMapOfsX,
1758  fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
1759  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1760  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1761  aMapResDest.mnMapOfsY );
1762  }
1763 }
1764 
1766  const MapMode& rMapModeSource,
1767  const MapMode& rMapModeDest )
1768 {
1769  if ( rMapModeSource == rMapModeDest )
1770  return rSzSource;
1771 
1772  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1773  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1774  verifyUnitSourceDest( eUnitSource, eUnitDest );
1775 
1776  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1777  {
1778  ENTER3( eUnitSource, eUnitDest );
1779 
1780  return Size( fn3( rSzSource.Width(), nNumerator, nDenominator ),
1781  fn3( rSzSource.Height(), nNumerator, nDenominator ) );
1782  }
1783  else
1784  {
1785  ENTER4( rMapModeSource, rMapModeDest );
1786 
1787  return Size( fn5( rSzSource.Width(),
1788  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1789  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ),
1790  fn5( rSzSource.Height(),
1791  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1792  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) );
1793  }
1794 }
1795 
1797  const MapMode& rMapModeSource,
1798  const MapMode& rMapModeDest )
1799 {
1800  if(rMapModeSource == rMapModeDest)
1801  {
1802  return rPolySource;
1803  }
1804 
1805  const basegfx::B2DHomMatrix aTransform(LogicToLogic(rMapModeSource, rMapModeDest));
1806  basegfx::B2DPolygon aPoly(rPolySource);
1807 
1808  aPoly.transform(aTransform);
1809  return aPoly;
1810 }
1811 
1812 basegfx::B2DHomMatrix OutputDevice::LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest)
1813 {
1814  basegfx::B2DHomMatrix aTransform;
1815 
1816  if(rMapModeSource == rMapModeDest)
1817  {
1818  return aTransform;
1819  }
1820 
1821  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1822  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1823  verifyUnitSourceDest(eUnitSource, eUnitDest);
1824 
1825  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1826  {
1827  ENTER3(eUnitSource, eUnitDest);
1828 
1829  const double fScaleFactor(static_cast<double>(nNumerator) / static_cast<double>(nDenominator));
1830  aTransform.set(0, 0, fScaleFactor);
1831  aTransform.set(1, 1, fScaleFactor);
1832  }
1833  else
1834  {
1835  ENTER4(rMapModeSource, rMapModeDest);
1836 
1837  const double fScaleFactorX((double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)));
1838  const double fScaleFactorY((double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)));
1839  const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX));
1840  const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY));
1841 
1842  aTransform.set(0, 0, fScaleFactorX);
1843  aTransform.set(1, 1, fScaleFactorY);
1844  aTransform.set(0, 2, fZeroPointX);
1845  aTransform.set(1, 2, fZeroPointY);
1846  }
1847 
1848  return aTransform;
1849 }
1850 
1852  const MapMode& rMapModeSource,
1853  const MapMode& rMapModeDest )
1854 {
1855  if ( rMapModeSource == rMapModeDest )
1856  return rRectSource;
1857 
1858  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1859  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1860  verifyUnitSourceDest( eUnitSource, eUnitDest );
1861 
1862  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1863  {
1864  ENTER3( eUnitSource, eUnitDest );
1865 
1866  auto left = fn3( rRectSource.Left(), nNumerator, nDenominator );
1867  auto top = fn3( rRectSource.Top(), nNumerator, nDenominator );
1868  if (rRectSource.IsEmpty())
1869  return tools::Rectangle( left, top );
1870 
1871  auto right = fn3( rRectSource.Right(), nNumerator, nDenominator );
1872  auto bottom = fn3( rRectSource.Bottom(), nNumerator, nDenominator );
1873  return tools::Rectangle(left, top, right, bottom);
1874  }
1875  else
1876  {
1877  ENTER4( rMapModeSource, rMapModeDest );
1878 
1879  auto left = fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
1880  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1881  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1882  aMapResDest.mnMapOfsX;
1883  auto top = fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
1884  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1885  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1886  aMapResDest.mnMapOfsY;
1887  if (rRectSource.IsEmpty())
1888  return tools::Rectangle(left, top);
1889 
1890  auto right = fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
1891  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1892  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1893  aMapResDest.mnMapOfsX;
1894  auto bottom = fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
1895  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1896  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1897  aMapResDest.mnMapOfsY;
1898  return tools::Rectangle(left, top, right, bottom);
1899  }
1900 }
1901 
1902 long OutputDevice::LogicToLogic( long nLongSource,
1903  MapUnit eUnitSource, MapUnit eUnitDest )
1904 {
1905  if ( eUnitSource == eUnitDest )
1906  return nLongSource;
1907 
1908  verifyUnitSourceDest( eUnitSource, eUnitDest );
1909  ENTER3( eUnitSource, eUnitDest );
1910 
1911  return fn3( nLongSource, nNumerator, nDenominator );
1912 }
1913 
1914 void OutputDevice::SetPixelOffset( const Size& rOffset )
1915 {
1916  mnOutOffOrigX = rOffset.Width();
1917  mnOutOffOrigY = rOffset.Height();
1918 
1925 
1926  if( mpAlphaVDev )
1927  mpAlphaVDev->SetPixelOffset( rOffset );
1928 }
1929 
1930 
1932 {
1933  if ( !mbMap )
1934  return static_cast<DeviceCoordinate>(nWidth);
1935 
1936 #if VCL_FLOAT_DEVICE_PIXEL
1937  return (double)nWidth * maMapRes.mfScaleX * mnDPIX;
1938 #else
1939 
1940  return ImplLogicToPixel( nWidth, mnDPIX,
1943 #endif
1944 }
1945 
1946 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 Count() const
basegfx::B2DHomMatrix GetInverseViewTransformation() const
Definition: map.cxx:881
const Fraction & GetScaleX() const
Definition: mapmod.cxx:167
long Width() const
OutDevType GetOutDevType() const
Definition: outdev.hxx:522
long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:342
void SetPixelOffset(const Size &rOffset)
Set an offset in pixel.
Definition: map.cxx:1914
void SetRelativeMapMode(const MapMode &rNewMapMode)
Definition: map.cxx:781
static void verifyUnitSourceDest(MapUnit eUnitSource, MapUnit eUnitDest)
Definition: map.cxx:1479
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
long AdjustX(long nHorzMove)
static const MapUnit s_MaxValidUnit
Definition: map.cxx:39
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1678
ImplThresholdRes maThresRes
Definition: outdev.hxx:358
long Height() const
long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:344
static SAL_DLLPRIVATE void ImplInitAppFontData(vcl::Window const *pWindow)
Definition: window.cxx:1163
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:508
sal_uIntPtr sal_uLong
SAL_DLLPRIVATE bool IsSimple() const
Definition: mapmod.cxx:171
long mnMapOfsY
Definition: outdevmap.hxx:26
sal_Int32 mnDPIY
Definition: outdev.hxx:348
sal_Int32 mnDPIX
Definition: outdev.hxx:347
void EnableMapMode(bool bEnable=true)
Definition: map.cxx:647
bool mbMap
Definition: outdev.hxx:376
bool IsDefault() const
Definition: mapmod.cxx:130
const RegionBand * getRegionBand() const
Definition: region.hxx:81
long mnOutOffOrigX
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:334
void SetMapMode()
Definition: map.cxx:655
static long fn5(const long n1, const long n2, const long n3, const long n4, const long n5)
Definition: map.cxx:1526
ImplSVGDIData maGDIData
Definition: svdata.hxx:353
const basegfx::B2DPolyPolygon * getB2DPolyPolygon() const
Definition: region.hxx:79
std::vector< tools::Rectangle > RectangleVector
Definition: region.hxx:37
MapMode maMapMode
Definition: outdev.hxx:371
#define ENTER1(rSource, pMapModeSource, pMapModeDest)
Definition: map.cxx:1443
bool IsEmpty() const
static 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
def left
long Right() const
#define ENTER4(rMapModeSource, rMapModeDest)
Definition: map.cxx:1512
void setX(long nX)
const Fraction & GetScaleY() const
Definition: mapmod.cxx:169
long DeviceCoordinate
long Top() const
void Move(long nHorzMove, long nVertMove)
Definition: region.cxx:414
void setY(long nY)
SAL_DLLPRIVATE long ImplLogicXToDevicePixel(long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
Definition: map.cxx:410
if(nullptr==pCandidateA||nullptr==pCandidateB)
SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const
Get device transformation.
Definition: map.cxx:931
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:67
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:1644
void SetScaleX(const Fraction &rScaleX)
Definition: mapmod.cxx:107
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)
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 AdjustY(long nVertMove)
long mnOutOffOrigY
Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) ...
Definition: outdev.hxx:338
const Point * GetConstPointAry() const
long mnOutOffLogicX
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:336
int i
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:101
long mnMapScNumX
Definition: outdevmap.hxx:27
bool mbNewFont
Definition: outdev.hxx:390
long Bottom() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
void SetScaleY(const Fraction &rScaleY)
Definition: mapmod.cxx:114
sal_uInt16 GetSize() const
static const o3tl::enumarray< MapUnit, long > aImplDenominatorAry
Definition: map.cxx:42
MapUnit GetMapUnit() const
Definition: mapmod.cxx:163
bool IsNeg() const
#define ENTER3(eUnitSource, eUnitDest)
Definition: map.cxx:1495
long mnAppFontX
Definition: svdata.hxx:187
long X() const
const long LONG_MAX
void transform(const basegfx::B2DHomMatrix &rMatrix)
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1185
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:940
ImplSVWinData maWinData
Definition: svdata.hxx:354
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:331
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:637
long mnMapScDenomY
Definition: outdevmap.hxx:30
ImplMapRes maMapRes
Definition: outdev.hxx:357
sal_Int32 GetDenominator() const
long mnOutOffLogicY
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:340
#define SAL_WARN_IF(condition, area, stream)
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:539
const tools::PolyPolygon * getPolyPolygon() const
Definition: region.hxx:80
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:386
const Point & GetOrigin() const
Definition: mapmod.cxx:165
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
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:198
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
MapUnit
#define SAL_WARN(area, stream)
std::unique_ptr< ImplOutDevData > mpOutDevData
Definition: outdev.hxx:326
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:612
bool IsValid() const
long mnMapScNumY
Definition: outdevmap.hxx:28
long mnAppFontY
Definition: svdata.hxx:188
SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate(long nWidth) const
Definition: map.cxx:1931
long mnMapOfsX
Definition: outdevmap.hxx:25
basegfx::B2DHomMatrix GetViewTransformation() const
Definition: map.cxx:853
long Y() const
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:319
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo