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->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* pPt = &(pPointAry[i]);
546  Point aPt;
547  aPt.setX( ImplLogicToPixel( pPt->X()+maMapRes.mnMapOfsX, mnDPIX,
550  aPt.setY( ImplLogicToPixel( pPt->Y()+maMapRes.mnMapOfsY, mnDPIY,
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 )
659  mpMetaFile->AddAction( new MetaMapModeAction( MapMode() ) );
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;
670 
671  // #106426# Adapt logical offset when changing mapmode
672  mnOutOffLogicX = mnOutOffOrigX; // no mapping -> equal offsets
674 
675  // #i75163#
677  }
678 
679  if( mpAlphaVDev )
681 }
682 
683 void OutputDevice::SetMapMode( const MapMode& rNewMapMode )
684 {
685 
686  bool bRelMap = (rNewMapMode.GetMapUnit() == MapUnit::MapRelative);
687 
688  if ( mpMetaFile )
689  {
690  mpMetaFile->AddAction( new MetaMapModeAction( rNewMapMode ) );
691  }
692 
693  // do nothing if MapMode was not changed
694  if ( maMapMode == rNewMapMode )
695  return;
696 
697  if( mpAlphaVDev )
698  mpAlphaVDev->SetMapMode( rNewMapMode );
699 
700  // if default MapMode calculate nothing
701  bool bOldMap = mbMap;
702  mbMap = !rNewMapMode.IsDefault();
703  if ( mbMap )
704  {
705  // if only the origin is converted, do not scale new
706  if ( (rNewMapMode.GetMapUnit() == maMapMode.GetMapUnit()) &&
707  (rNewMapMode.GetScaleX() == maMapMode.GetScaleX()) &&
708  (rNewMapMode.GetScaleY() == maMapMode.GetScaleY()) &&
709  (bOldMap == mbMap) )
710  {
711  // set offset
712  Point aOrigin = rNewMapMode.GetOrigin();
713  maMapRes.mnMapOfsX = aOrigin.X();
714  maMapRes.mnMapOfsY = aOrigin.Y();
715  maMapMode = rNewMapMode;
716 
717  // #i75163#
719 
720  return;
721  }
722  if ( !bOldMap && bRelMap )
723  {
724  maMapRes.mnMapScNumX = 1;
725  maMapRes.mnMapScNumY = 1;
728  maMapRes.mnMapOfsX = 0;
729  maMapRes.mnMapOfsY = 0;
730  }
731 
732  // calculate new MapMode-resolution
734  }
735 
736  // set new MapMode
737  if ( bRelMap )
738  {
740  // aScale? = maMapMode.GetScale?() * rNewMapMode.GetScale?()
742  rNewMapMode.GetScaleX().GetNumerator(),
744  rNewMapMode.GetScaleX().GetDenominator() );
746  rNewMapMode.GetScaleY().GetNumerator(),
748  rNewMapMode.GetScaleY().GetDenominator() );
749  maMapMode.SetOrigin( aOrigin );
750  maMapMode.SetScaleX( aScaleX );
751  maMapMode.SetScaleY( aScaleY );
752  }
753  else
754  maMapMode = rNewMapMode;
755 
756  // create new objects (clip region are not re-scaled)
757  mbNewFont = true;
758  mbInitFont = true;
760 
761  // #106426# Adapt logical offset when changing mapmode
768 
769  // #i75163#
771 }
772 
774 
775 void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
776 {
777  // do nothing if MapMode did not change
778  if ( maMapMode == rNewMapMode )
779  return;
780 
781  MapUnit eOld = maMapMode.GetMapUnit();
782  MapUnit eNew = rNewMapMode.GetMapUnit();
783 
784  // a?F = rNewMapMode.GetScale?() / maMapMode.GetScale?()
785  Fraction aXF = ImplMakeFraction( rNewMapMode.GetScaleX().GetNumerator(),
787  rNewMapMode.GetScaleX().GetDenominator(),
789  Fraction aYF = ImplMakeFraction( rNewMapMode.GetScaleY().GetNumerator(),
791  rNewMapMode.GetScaleY().GetDenominator(),
793 
794  Point aPt( LogicToLogic( Point(), nullptr, &rNewMapMode ) );
795  if ( eNew != eOld )
796  {
797  if ( eOld > MapUnit::MapPixel )
798  {
799  SAL_WARN( "vcl.gdi", "Not implemented MapUnit" );
800  }
801  else if ( eNew > MapUnit::MapPixel )
802  {
803  SAL_WARN( "vcl.gdi", "Not implemented MapUnit" );
804  }
805  else
806  {
807  Fraction aF( aImplNumeratorAry[eNew] * aImplDenominatorAry[eOld],
808  aImplNumeratorAry[eOld] * aImplDenominatorAry[eNew] );
809 
810  // a?F = a?F * aF
811  aXF = ImplMakeFraction( aXF.GetNumerator(), aF.GetNumerator(),
812  aXF.GetDenominator(), aF.GetDenominator() );
813  aYF = ImplMakeFraction( aYF.GetNumerator(), aF.GetNumerator(),
814  aYF.GetDenominator(), aF.GetDenominator() );
815  if ( eOld == MapUnit::MapPixel )
816  {
817  aXF *= Fraction( mnDPIX, 1 );
818  aYF *= Fraction( mnDPIY, 1 );
819  }
820  else if ( eNew == MapUnit::MapPixel )
821  {
822  aXF *= Fraction( 1, mnDPIX );
823  aYF *= Fraction( 1, mnDPIY );
824  }
825  }
826  }
827 
828  MapMode aNewMapMode( MapUnit::MapRelative, Point( -aPt.X(), -aPt.Y() ), aXF, aYF );
829  SetMapMode( aNewMapMode );
830 
831  if ( eNew != eOld )
832  maMapMode = rNewMapMode;
833 
834  // #106426# Adapt logical offset when changing MapMode
841 
842  if( mpAlphaVDev )
843  mpAlphaVDev->SetRelativeMapMode( rNewMapMode );
844 }
845 
846 // #i75163#
848 {
849  if(mbMap && mpOutDevData)
850  {
851  if(!mpOutDevData->mpViewTransform)
852  {
853  mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix;
854 
855  const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(maMapRes.mnMapScNumX) / static_cast<double>(maMapRes.mnMapScDenomX));
856  const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(maMapRes.mnMapScNumY) / static_cast<double>(maMapRes.mnMapScDenomY));
857  const double fZeroPointX((static_cast<double>(maMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX));
858  const double fZeroPointY((static_cast<double>(maMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY));
859 
860  mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX);
861  mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY);
862  mpOutDevData->mpViewTransform->set(0, 2, fZeroPointX);
863  mpOutDevData->mpViewTransform->set(1, 2, fZeroPointY);
864  }
865 
866  return *mpOutDevData->mpViewTransform;
867  }
868  else
869  {
870  return basegfx::B2DHomMatrix();
871  }
872 }
873 
874 // #i75163#
876 {
877  if(mbMap && mpOutDevData)
878  {
879  if(!mpOutDevData->mpInverseViewTransform)
880  {
882  mpOutDevData->mpInverseViewTransform = new basegfx::B2DHomMatrix(*mpOutDevData->mpViewTransform);
883  mpOutDevData->mpInverseViewTransform->invert();
884  }
885 
886  return *mpOutDevData->mpInverseViewTransform;
887  }
888  else
889  {
890  return basegfx::B2DHomMatrix();
891  }
892 }
893 
894 // #i75163#
896 {
897  // #i82615#
898  ImplMapRes aMapRes;
899  ImplThresholdRes aThresRes;
900  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
901 
902  basegfx::B2DHomMatrix aTransform;
903 
904  const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(aMapRes.mnMapScNumX) / static_cast<double>(aMapRes.mnMapScDenomX));
905  const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(aMapRes.mnMapScNumY) / static_cast<double>(aMapRes.mnMapScDenomY));
906  const double fZeroPointX((static_cast<double>(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX));
907  const double fZeroPointY((static_cast<double>(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY));
908 
909  aTransform.set(0, 0, fScaleFactorX);
910  aTransform.set(1, 1, fScaleFactorY);
911  aTransform.set(0, 2, fZeroPointX);
912  aTransform.set(1, 2, fZeroPointY);
913 
914  return aTransform;
915 }
916 
917 // #i75163#
919 {
920  basegfx::B2DHomMatrix aMatrix( GetViewTransformation( rMapMode ) );
921  aMatrix.invert();
922  return aMatrix;
923 }
924 
926 {
927  basegfx::B2DHomMatrix aTransformation = GetViewTransformation();
928  // TODO: is it worth to cache the transformed result?
929  if( mnOutOffX || mnOutOffY )
930  aTransformation.translate( mnOutOffX, mnOutOffY );
931  return aTransformation;
932 }
933 
934 Point OutputDevice::LogicToPixel( const Point& rLogicPt ) const
935 {
936 
937  if ( !mbMap )
938  return rLogicPt;
939 
940  return Point( ImplLogicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, mnDPIX,
943  ImplLogicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, mnDPIY,
946 }
947 
948 Size OutputDevice::LogicToPixel( const Size& rLogicSize ) const
949 {
950 
951  if ( !mbMap )
952  return rLogicSize;
953 
954  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
957  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
960 }
961 
963 {
964 
965  if ( !mbMap || rLogicRect.IsEmpty() )
966  return rLogicRect;
967 
971  ImplLogicToPixel( rLogicRect.Top() + maMapRes.mnMapOfsY, mnDPIY,
980 }
981 
983 {
984 
985  if ( !mbMap )
986  return rLogicPoly;
987 
988  sal_uInt16 i;
989  sal_uInt16 nPoints = rLogicPoly.GetSize();
990  tools::Polygon aPoly( rLogicPoly );
991 
992  // get pointer to Point-array (copy data)
993  const Point* pPointAry = aPoly.GetConstPointAry();
994 
995  for ( i = 0; i < nPoints; i++ )
996  {
997  const Point* pPt = &(pPointAry[i]);
998  Point aPt;
999  aPt.setX( ImplLogicToPixel( pPt->X() + maMapRes.mnMapOfsX, mnDPIX,
1002  aPt.setY( ImplLogicToPixel( pPt->Y() + maMapRes.mnMapOfsY, mnDPIY,
1005  aPoly[i] = aPt;
1006  }
1007 
1008  return aPoly;
1009 }
1010 
1012 {
1013 
1014  if ( !mbMap )
1015  return rLogicPolyPoly;
1016 
1017  tools::PolyPolygon aPolyPoly( rLogicPolyPoly );
1018  sal_uInt16 nPoly = aPolyPoly.Count();
1019  for( sal_uInt16 i = 0; i < nPoly; i++ )
1020  {
1021  tools::Polygon& rPoly = aPolyPoly[i];
1022  rPoly = LogicToPixel( rPoly );
1023  }
1024  return aPolyPoly;
1025 }
1026 
1028 {
1029  basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly;
1030  const basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation();
1031  aTransformedPoly.transform( rTransformationMatrix );
1032  return aTransformedPoly;
1033 }
1034 
1036 {
1037 
1038  if(!mbMap || rLogicRegion.IsNull() || rLogicRegion.IsEmpty())
1039  {
1040  return rLogicRegion;
1041  }
1042 
1043  vcl::Region aRegion;
1044 
1045  if(rLogicRegion.getB2DPolyPolygon())
1046  {
1047  aRegion = vcl::Region(LogicToPixel(*rLogicRegion.getB2DPolyPolygon()));
1048  }
1049  else if(rLogicRegion.getPolyPolygon())
1050  {
1051  aRegion = vcl::Region(LogicToPixel(*rLogicRegion.getPolyPolygon()));
1052  }
1053  else if(rLogicRegion.getRegionBand())
1054  {
1055  RectangleVector aRectangles;
1056  rLogicRegion.GetRegionRectangles(aRectangles);
1057  const RectangleVector& rRectangles(aRectangles); // needed to make the '!=' work
1058 
1059  // make reverse run to fill new region bottom-up, this will speed it up due to the used data structuring
1060  for(RectangleVector::const_reverse_iterator aRectIter(rRectangles.rbegin()); aRectIter != rRectangles.rend(); ++aRectIter)
1061  {
1062  aRegion.Union(LogicToPixel(*aRectIter));
1063  }
1064  }
1065 
1066  return aRegion;
1067 }
1068 
1069 Point OutputDevice::LogicToPixel( const Point& rLogicPt,
1070  const MapMode& rMapMode ) const
1071 {
1072 
1073  if ( rMapMode.IsDefault() )
1074  return rLogicPt;
1075 
1076  // convert MapMode resolution and convert
1077  ImplMapRes aMapRes;
1078  ImplThresholdRes aThresRes;
1079  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1080 
1081  return Point( ImplLogicToPixel( rLogicPt.X() + aMapRes.mnMapOfsX, mnDPIX,
1082  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1083  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1084  ImplLogicToPixel( rLogicPt.Y() + aMapRes.mnMapOfsY, mnDPIY,
1085  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1086  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1087 }
1088 
1090  const MapMode& rMapMode ) const
1091 {
1092 
1093  if ( rMapMode.IsDefault() )
1094  return rLogicSize;
1095 
1096  // convert MapMode resolution and convert
1097  ImplMapRes aMapRes;
1098  ImplThresholdRes aThresRes;
1099  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1100 
1101  return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX,
1102  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1103  aThresRes.mnThresLogToPixX ),
1104  ImplLogicToPixel( rLogicSize.Height(), mnDPIY,
1105  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1106  aThresRes.mnThresLogToPixY ) );
1107 }
1108 
1110  const MapMode& rMapMode ) const
1111 {
1112 
1113  if ( rMapMode.IsDefault() || rLogicRect.IsEmpty() )
1114  return rLogicRect;
1115 
1116  // convert MapMode resolution and convert
1117  ImplMapRes aMapRes;
1118  ImplThresholdRes aThresRes;
1119  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1120 
1121  return tools::Rectangle( ImplLogicToPixel( rLogicRect.Left() + aMapRes.mnMapOfsX, mnDPIX,
1122  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1123  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1124  ImplLogicToPixel( rLogicRect.Top() + aMapRes.mnMapOfsY, mnDPIY,
1125  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1126  aThresRes.mnThresLogToPixY )+mnOutOffOrigY,
1127  ImplLogicToPixel( rLogicRect.Right() + aMapRes.mnMapOfsX, mnDPIX,
1128  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1129  aThresRes.mnThresLogToPixX )+mnOutOffOrigX,
1130  ImplLogicToPixel( rLogicRect.Bottom() + aMapRes.mnMapOfsY, mnDPIY,
1131  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1132  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1133 }
1134 
1136  const MapMode& rMapMode ) const
1137 {
1138 
1139  if ( rMapMode.IsDefault() )
1140  return rLogicPoly;
1141 
1142  // convert MapMode resolution and convert
1143  ImplMapRes aMapRes;
1144  ImplThresholdRes aThresRes;
1145  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1146 
1147  sal_uInt16 i;
1148  sal_uInt16 nPoints = rLogicPoly.GetSize();
1149  tools::Polygon aPoly( rLogicPoly );
1150 
1151  // get pointer to Point-array (copy data)
1152  const Point* pPointAry = aPoly.GetConstPointAry();
1153 
1154  for ( i = 0; i < nPoints; i++ )
1155  {
1156  const Point* pPt = &(pPointAry[i]);
1157  Point aPt;
1158  aPt.setX( ImplLogicToPixel( pPt->X() + aMapRes.mnMapOfsX, mnDPIX,
1159  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1160  aThresRes.mnThresLogToPixX )+mnOutOffOrigX );
1161  aPt.setY( ImplLogicToPixel( pPt->Y() + aMapRes.mnMapOfsY, mnDPIY,
1162  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1163  aThresRes.mnThresLogToPixY )+mnOutOffOrigY );
1164  aPoly[i] = aPt;
1165  }
1166 
1167  return aPoly;
1168 }
1169 
1171  const MapMode& rMapMode ) const
1172 {
1173  basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly;
1174  const basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode );
1175  aTransformedPoly.transform( rTransformationMatrix );
1176  return aTransformedPoly;
1177 }
1178 
1179 Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const
1180 {
1181 
1182  if ( !mbMap )
1183  return rDevicePt;
1184 
1185  return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX,
1188  ImplPixelToLogic( rDevicePt.Y(), mnDPIY,
1191 }
1192 
1193 Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const
1194 {
1195 
1196  if ( !mbMap )
1197  return rDeviceSize;
1198 
1199  return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX,
1202  ImplPixelToLogic( rDeviceSize.Height(), mnDPIY,
1205 }
1206 
1208 {
1209 
1210  if ( !mbMap || rDeviceRect.IsEmpty() )
1211  return rDeviceRect;
1212 
1213  return tools::Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX,
1216  ImplPixelToLogic( rDeviceRect.Top(), mnDPIY,
1219  ImplPixelToLogic( rDeviceRect.Right(), mnDPIX,
1222  ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY,
1225 }
1226 
1228 {
1229 
1230  if ( !mbMap )
1231  return rDevicePoly;
1232 
1233  sal_uInt16 i;
1234  sal_uInt16 nPoints = rDevicePoly.GetSize();
1235  tools::Polygon aPoly( rDevicePoly );
1236 
1237  // get pointer to Point-array (copy data)
1238  const Point* pPointAry = aPoly.GetConstPointAry();
1239 
1240  for ( i = 0; i < nPoints; i++ )
1241  {
1242  const Point* pPt = &(pPointAry[i]);
1243  Point aPt;
1244  aPt.setX( ImplPixelToLogic( pPt->X(), mnDPIX,
1247  aPt.setY( ImplPixelToLogic( pPt->Y(), mnDPIY,
1250  aPoly[i] = aPt;
1251  }
1252 
1253  return aPoly;
1254 }
1255 
1257 {
1258 
1259  if ( !mbMap )
1260  return rDevicePolyPoly;
1261 
1262  tools::PolyPolygon aPolyPoly( rDevicePolyPoly );
1263  sal_uInt16 nPoly = aPolyPoly.Count();
1264  for( sal_uInt16 i = 0; i < nPoly; i++ )
1265  {
1266  tools::Polygon& rPoly = aPolyPoly[i];
1267  rPoly = PixelToLogic( rPoly );
1268  }
1269  return aPolyPoly;
1270 }
1271 
1273 {
1274  basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly;
1275  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation();
1276  aTransformedPoly.transform( rTransformationMatrix );
1277  return aTransformedPoly;
1278 }
1279 
1281 {
1282 
1283  if(!mbMap || rDeviceRegion.IsNull() || rDeviceRegion.IsEmpty())
1284  {
1285  return rDeviceRegion;
1286  }
1287 
1288  vcl::Region aRegion;
1289 
1290  if(rDeviceRegion.getB2DPolyPolygon())
1291  {
1292  aRegion = vcl::Region(PixelToLogic(*rDeviceRegion.getB2DPolyPolygon()));
1293  }
1294  else if(rDeviceRegion.getPolyPolygon())
1295  {
1296  aRegion = vcl::Region(PixelToLogic(*rDeviceRegion.getPolyPolygon()));
1297  }
1298  else if(rDeviceRegion.getRegionBand())
1299  {
1300  RectangleVector aRectangles;
1301  rDeviceRegion.GetRegionRectangles(aRectangles);
1302  const RectangleVector& rRectangles(aRectangles); // needed to make the '!=' work
1303 
1304  // make reverse run to fill new region bottom-up, this will speed it up due to the used data structuring
1305  for(RectangleVector::const_reverse_iterator aRectIter(rRectangles.rbegin()); aRectIter != rRectangles.rend(); ++aRectIter)
1306  {
1307  aRegion.Union(PixelToLogic(*aRectIter));
1308  }
1309  }
1310 
1311  return aRegion;
1312 }
1313 
1314 Point OutputDevice::PixelToLogic( const Point& rDevicePt,
1315  const MapMode& rMapMode ) const
1316 {
1317 
1318  // calculate nothing if default-MapMode
1319  if ( rMapMode.IsDefault() )
1320  return rDevicePt;
1321 
1322  // calculate MapMode-resolution and convert
1323  ImplMapRes aMapRes;
1324  ImplThresholdRes aThresRes;
1325  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1326 
1327  return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX,
1328  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1329  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1330  ImplPixelToLogic( rDevicePt.Y(), mnDPIY,
1331  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1332  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1333 }
1334 
1336  const MapMode& rMapMode ) const
1337 {
1338 
1339  // calculate nothing if default-MapMode
1340  if ( rMapMode.IsDefault() )
1341  return rDeviceSize;
1342 
1343  // calculate MapMode-resolution and convert
1344  ImplMapRes aMapRes;
1345  ImplThresholdRes aThresRes;
1346  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1347 
1348  return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX,
1349  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1350  aThresRes.mnThresPixToLogX ),
1351  ImplPixelToLogic( rDeviceSize.Height(), mnDPIY,
1352  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1353  aThresRes.mnThresPixToLogY ) );
1354 }
1355 
1357  const MapMode& rMapMode ) const
1358 {
1359 
1360  // calculate nothing if default-MapMode
1361  if ( rMapMode.IsDefault() || rDeviceRect.IsEmpty() )
1362  return rDeviceRect;
1363 
1364  // calculate MapMode-resolution and convert
1365  ImplMapRes aMapRes;
1366  ImplThresholdRes aThresRes;
1367  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1368 
1369  return tools::Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX,
1370  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1371  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1372  ImplPixelToLogic( rDeviceRect.Top(), mnDPIY,
1373  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1374  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY,
1375  ImplPixelToLogic( rDeviceRect.Right(), mnDPIX,
1376  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1377  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX,
1378  ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY,
1379  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1380  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1381 }
1382 
1384  const MapMode& rMapMode ) const
1385 {
1386 
1387  // calculate nothing if default-MapMode
1388  if ( rMapMode.IsDefault() )
1389  return rDevicePoly;
1390 
1391  // calculate MapMode-resolution and convert
1392  ImplMapRes aMapRes;
1393  ImplThresholdRes aThresRes;
1394  ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes );
1395 
1396  sal_uInt16 i;
1397  sal_uInt16 nPoints = rDevicePoly.GetSize();
1398  tools::Polygon aPoly( rDevicePoly );
1399 
1400  // get pointer to Point-array (copy data)
1401  const Point* pPointAry = aPoly.GetConstPointAry();
1402 
1403  for ( i = 0; i < nPoints; i++ )
1404  {
1405  const Point* pPt = &(pPointAry[i]);
1406  Point aPt;
1407  aPt.setX( ImplPixelToLogic( pPt->X(), mnDPIX,
1408  aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX,
1409  aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX );
1410  aPt.setY( ImplPixelToLogic( pPt->Y(), mnDPIY,
1411  aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY,
1412  aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY );
1413  aPoly[i] = aPt;
1414  }
1415 
1416  return aPoly;
1417 }
1418 
1420  const MapMode& rMapMode ) const
1421 {
1422  basegfx::B2DPolygon aTransformedPoly = rPixelPoly;
1423  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode );
1424  aTransformedPoly.transform( rTransformationMatrix );
1425  return aTransformedPoly;
1426 }
1427 
1429  const MapMode& rMapMode ) const
1430 {
1431  basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly;
1432  const basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode );
1433  aTransformedPoly.transform( rTransformationMatrix );
1434  return aTransformedPoly;
1435 }
1436 
1437 #define ENTER1( rSource, pMapModeSource, pMapModeDest ) \
1438  if ( !pMapModeSource ) \
1439  pMapModeSource = &maMapMode; \
1440  if ( !pMapModeDest ) \
1441  pMapModeDest = &maMapMode; \
1442  if ( *pMapModeSource == *pMapModeDest ) \
1443  return rSource; \
1444  \
1445  ImplMapRes aMapResSource; \
1446  aMapResSource.mnMapOfsX = 0; \
1447  aMapResSource.mnMapOfsY = 0; \
1448  aMapResSource.mnMapScNumX = 1; \
1449  aMapResSource.mnMapScNumY = 1; \
1450  aMapResSource.mnMapScDenomX = 1; \
1451  aMapResSource.mnMapScDenomY = 1; \
1452  ImplMapRes aMapResDest(aMapResSource); \
1453  \
1454  if ( !mbMap || pMapModeSource != &maMapMode ) \
1455  { \
1456  if ( pMapModeSource->GetMapUnit() == MapUnit::MapRelative ) \
1457  aMapResSource = maMapRes; \
1458  ImplCalcMapResolution( *pMapModeSource, \
1459  mnDPIX, mnDPIY, aMapResSource ); \
1460  } \
1461  else \
1462  aMapResSource = maMapRes; \
1463  if ( !mbMap || pMapModeDest != &maMapMode ) \
1464  { \
1465  if ( pMapModeDest->GetMapUnit() == MapUnit::MapRelative ) \
1466  aMapResDest = maMapRes; \
1467  ImplCalcMapResolution( *pMapModeDest, \
1468  mnDPIX, mnDPIY, aMapResDest ); \
1469  } \
1470  else \
1471  aMapResDest = maMapRes
1472 
1473 static void verifyUnitSourceDest( MapUnit eUnitSource, MapUnit eUnitDest )
1474 {
1475  DBG_ASSERT( eUnitSource != MapUnit::MapSysFont
1476  && eUnitSource != MapUnit::MapAppFont
1477  && eUnitSource != MapUnit::MapRelative,
1478  "Source MapUnit is not permitted" );
1479  DBG_ASSERT( eUnitDest != MapUnit::MapSysFont
1480  && eUnitDest != MapUnit::MapAppFont
1481  && eUnitDest != MapUnit::MapRelative,
1482  "Destination MapUnit is not permitted" );
1483 }
1484 
1485 #define ENTER3( eUnitSource, eUnitDest ) \
1486  long nNumerator = 1; \
1487  long nDenominator = 1; \
1488  SAL_WARN_IF( eUnitSource > s_MaxValidUnit, "vcl.gdi", "Invalid source map unit"); \
1489  SAL_WARN_IF( eUnitDest > s_MaxValidUnit, "vcl.gdi", "Invalid destination map unit"); \
1490  if( (eUnitSource <= s_MaxValidUnit) && (eUnitDest <= s_MaxValidUnit) ) \
1491  { \
1492  nNumerator = aImplNumeratorAry[eUnitSource] * \
1493  aImplDenominatorAry[eUnitDest]; \
1494  nDenominator = aImplNumeratorAry[eUnitDest] * \
1495  aImplDenominatorAry[eUnitSource]; \
1496  } \
1497  if ( eUnitSource == MapUnit::MapPixel ) \
1498  nDenominator *= 72; \
1499  else if( eUnitDest == MapUnit::MapPixel ) \
1500  nNumerator *= 72
1501 
1502 #define ENTER4( rMapModeSource, rMapModeDest ) \
1503  ImplMapRes aMapResSource; \
1504  aMapResSource.mnMapOfsX = 0; \
1505  aMapResSource.mnMapOfsY = 0; \
1506  aMapResSource.mnMapScNumX = 1; \
1507  aMapResSource.mnMapScNumY = 1; \
1508  aMapResSource.mnMapScDenomX = 1; \
1509  aMapResSource.mnMapScDenomY = 1; \
1510  ImplMapRes aMapResDest(aMapResSource); \
1511  \
1512  ImplCalcMapResolution( rMapModeSource, 72, 72, aMapResSource ); \
1513  ImplCalcMapResolution( rMapModeDest, 72, 72, aMapResDest )
1514 
1515 // return (n1 * n2 * n3) / (n4 * n5)
1516 static long fn5( const long n1,
1517  const long n2,
1518  const long n3,
1519  const long n4,
1520  const long n5 )
1521 {
1522  if ( n1 == 0 || n2 == 0 || n3 == 0 || n4 == 0 || n5 == 0 )
1523  return 0;
1524  if ( LONG_MAX / std::abs(n2) < std::abs(n3) )
1525  {
1526  // a6 is skipped
1527  BigInt a7 = n2;
1528  a7 *= n3;
1529  a7 *= n1;
1530 
1531  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1532  {
1533  BigInt a8 = n4;
1534  a8 *= n5;
1535 
1536  BigInt a9 = a8;
1537  a9 /= 2;
1538  if ( a7.IsNeg() )
1539  a7 -= a9;
1540  else
1541  a7 += a9;
1542 
1543  a7 /= a8;
1544  } // of if
1545  else
1546  {
1547  long n8 = n4 * n5;
1548 
1549  if ( a7.IsNeg() )
1550  a7 -= n8 / 2;
1551  else
1552  a7 += n8 / 2;
1553 
1554  a7 /= n8;
1555  } // of else
1556  return static_cast<long>(a7);
1557  } // of if
1558  else
1559  {
1560  long n6 = n2 * n3;
1561 
1562  if ( LONG_MAX / std::abs(n1) < std::abs(n6) )
1563  {
1564  BigInt a7 = n1;
1565  a7 *= n6;
1566 
1567  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1568  {
1569  BigInt a8 = n4;
1570  a8 *= n5;
1571 
1572  BigInt a9 = a8;
1573  a9 /= 2;
1574  if ( a7.IsNeg() )
1575  a7 -= a9;
1576  else
1577  a7 += a9;
1578 
1579  a7 /= a8;
1580  } // of if
1581  else
1582  {
1583  long n8 = n4 * n5;
1584 
1585  if ( a7.IsNeg() )
1586  a7 -= n8 / 2;
1587  else
1588  a7 += n8 / 2;
1589 
1590  a7 /= n8;
1591  } // of else
1592  return static_cast<long>(a7);
1593  } // of if
1594  else
1595  {
1596  long n7 = n1 * n6;
1597 
1598  if ( LONG_MAX / std::abs(n4) < std::abs(n5) )
1599  {
1600  BigInt a7 = n7;
1601  BigInt a8 = n4;
1602  a8 *= n5;
1603 
1604  BigInt a9 = a8;
1605  a9 /= 2;
1606  if ( a7.IsNeg() )
1607  a7 -= a9;
1608  else
1609  a7 += a9;
1610 
1611  a7 /= a8;
1612  return static_cast<long>(a7);
1613  } // of if
1614  else
1615  {
1616  const long n8 = n4 * n5;
1617  const long n8_2 = n8 / 2;
1618 
1619  if( n7 < 0 )
1620  {
1621  if( ( n7 - LONG_MIN ) >= n8_2 )
1622  n7 -= n8_2;
1623  }
1624  else if( ( LONG_MAX - n7 ) >= n8_2 )
1625  n7 += n8_2;
1626 
1627  return n7 / n8;
1628  } // of else
1629  } // of else
1630  } // of else
1631 }
1632 
1633 // return (n1 * n2) / n3
1634 static long fn3( const long n1, const long n2, const long n3 )
1635 {
1636  if ( n1 == 0 || n2 == 0 || n3 == 0 )
1637  return 0;
1638  if ( LONG_MAX / std::abs(n1) < std::abs(n2) )
1639  {
1640  BigInt a4 = n1;
1641  a4 *= n2;
1642 
1643  if ( a4.IsNeg() )
1644  a4 -= n3 / 2;
1645  else
1646  a4 += n3 / 2;
1647 
1648  a4 /= n3;
1649  return static_cast<long>(a4);
1650  } // of if
1651  else
1652  {
1653  long n4 = n1 * n2;
1654  const long n3_2 = n3 / 2;
1655 
1656  if( n4 < 0 )
1657  {
1658  if( ( n4 - LONG_MIN ) >= n3_2 )
1659  n4 -= n3_2;
1660  }
1661  else if( ( LONG_MAX - n4 ) >= n3_2 )
1662  n4 += n3_2;
1663 
1664  return n4 / n3;
1665  } // of else
1666 }
1667 
1668 Point OutputDevice::LogicToLogic( const Point& rPtSource,
1669  const MapMode* pMapModeSource,
1670  const MapMode* pMapModeDest ) const
1671 {
1672  ENTER1( rPtSource, pMapModeSource, pMapModeDest );
1673 
1674  return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
1675  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1676  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1677  aMapResDest.mnMapOfsX,
1678  fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
1679  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1680  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1681  aMapResDest.mnMapOfsY );
1682 }
1683 
1685  const MapMode* pMapModeSource,
1686  const MapMode* pMapModeDest ) const
1687 {
1688  ENTER1( rSzSource, pMapModeSource, pMapModeDest );
1689 
1690  return Size( fn5( rSzSource.Width(),
1691  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1692  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ),
1693  fn5( rSzSource.Height(),
1694  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1695  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) );
1696 }
1697 
1699  const MapMode* pMapModeSource,
1700  const MapMode* pMapModeDest ) const
1701 {
1702  ENTER1( rRectSource, pMapModeSource, pMapModeDest );
1703 
1704  return tools::Rectangle( fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
1705  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1706  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1707  aMapResDest.mnMapOfsX,
1708  fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
1709  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1710  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1711  aMapResDest.mnMapOfsY,
1712  fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
1713  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1714  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1715  aMapResDest.mnMapOfsX,
1716  fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
1717  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1718  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1719  aMapResDest.mnMapOfsY );
1720 }
1721 
1722 Point OutputDevice::LogicToLogic( const Point& rPtSource,
1723  const MapMode& rMapModeSource,
1724  const MapMode& rMapModeDest )
1725 {
1726  if ( rMapModeSource == rMapModeDest )
1727  return rPtSource;
1728 
1729  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1730  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1731  verifyUnitSourceDest( eUnitSource, eUnitDest );
1732 
1733  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1734  {
1735  ENTER3( eUnitSource, eUnitDest );
1736 
1737  return Point( fn3( rPtSource.X(), nNumerator, nDenominator ),
1738  fn3( rPtSource.Y(), nNumerator, nDenominator ) );
1739  }
1740  else
1741  {
1742  ENTER4( rMapModeSource, rMapModeDest );
1743 
1744  return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
1745  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1746  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1747  aMapResDest.mnMapOfsX,
1748  fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
1749  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1750  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1751  aMapResDest.mnMapOfsY );
1752  }
1753 }
1754 
1756  const MapMode& rMapModeSource,
1757  const MapMode& rMapModeDest )
1758 {
1759  if ( rMapModeSource == rMapModeDest )
1760  return rSzSource;
1761 
1762  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1763  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1764  verifyUnitSourceDest( eUnitSource, eUnitDest );
1765 
1766  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1767  {
1768  ENTER3( eUnitSource, eUnitDest );
1769 
1770  return Size( fn3( rSzSource.Width(), nNumerator, nDenominator ),
1771  fn3( rSzSource.Height(), nNumerator, nDenominator ) );
1772  }
1773  else
1774  {
1775  ENTER4( rMapModeSource, rMapModeDest );
1776 
1777  return Size( fn5( rSzSource.Width(),
1778  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1779  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ),
1780  fn5( rSzSource.Height(),
1781  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1782  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) );
1783  }
1784 }
1785 
1787  const MapMode& rMapModeSource,
1788  const MapMode& rMapModeDest )
1789 {
1790  if(rMapModeSource == rMapModeDest)
1791  {
1792  return rPolySource;
1793  }
1794 
1795  const basegfx::B2DHomMatrix aTransform(LogicToLogic(rMapModeSource, rMapModeDest));
1796  basegfx::B2DPolygon aPoly(rPolySource);
1797 
1798  aPoly.transform(aTransform);
1799  return aPoly;
1800 }
1801 
1802 basegfx::B2DHomMatrix OutputDevice::LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest)
1803 {
1804  basegfx::B2DHomMatrix aTransform;
1805 
1806  if(rMapModeSource == rMapModeDest)
1807  {
1808  return aTransform;
1809  }
1810 
1811  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1812  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1813  verifyUnitSourceDest(eUnitSource, eUnitDest);
1814 
1815  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1816  {
1817  ENTER3(eUnitSource, eUnitDest);
1818 
1819  const double fScaleFactor(static_cast<double>(nNumerator) / static_cast<double>(nDenominator));
1820  aTransform.set(0, 0, fScaleFactor);
1821  aTransform.set(1, 1, fScaleFactor);
1822  }
1823  else
1824  {
1825  ENTER4(rMapModeSource, rMapModeDest);
1826 
1827  const double fScaleFactorX((double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)));
1828  const double fScaleFactorY((double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)));
1829  const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX));
1830  const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY));
1831 
1832  aTransform.set(0, 0, fScaleFactorX);
1833  aTransform.set(1, 1, fScaleFactorY);
1834  aTransform.set(0, 2, fZeroPointX);
1835  aTransform.set(1, 2, fZeroPointY);
1836  }
1837 
1838  return aTransform;
1839 }
1840 
1842  const MapMode& rMapModeSource,
1843  const MapMode& rMapModeDest )
1844 {
1845  if ( rMapModeSource == rMapModeDest )
1846  return rRectSource;
1847 
1848  MapUnit eUnitSource = rMapModeSource.GetMapUnit();
1849  MapUnit eUnitDest = rMapModeDest.GetMapUnit();
1850  verifyUnitSourceDest( eUnitSource, eUnitDest );
1851 
1852  if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
1853  {
1854  ENTER3( eUnitSource, eUnitDest );
1855 
1856  auto left = fn3( rRectSource.Left(), nNumerator, nDenominator );
1857  auto top = fn3( rRectSource.Top(), nNumerator, nDenominator );
1858  if (rRectSource.IsEmpty())
1859  return tools::Rectangle( left, top );
1860 
1861  auto right = fn3( rRectSource.Right(), nNumerator, nDenominator );
1862  auto bottom = fn3( rRectSource.Bottom(), nNumerator, nDenominator );
1863  return tools::Rectangle(left, top, right, bottom);
1864  }
1865  else
1866  {
1867  ENTER4( rMapModeSource, rMapModeDest );
1868 
1869  auto left = fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
1870  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1871  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1872  aMapResDest.mnMapOfsX;
1873  auto top = fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
1874  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1875  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1876  aMapResDest.mnMapOfsY;
1877  if (rRectSource.IsEmpty())
1878  return tools::Rectangle(left, top);
1879 
1880  auto right = fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
1881  aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX,
1882  aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) -
1883  aMapResDest.mnMapOfsX;
1884  auto bottom = fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
1885  aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY,
1886  aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) -
1887  aMapResDest.mnMapOfsY;
1888  return tools::Rectangle(left, top, right, bottom);
1889  }
1890 }
1891 
1892 long OutputDevice::LogicToLogic( long nLongSource,
1893  MapUnit eUnitSource, MapUnit eUnitDest )
1894 {
1895  if ( eUnitSource == eUnitDest )
1896  return nLongSource;
1897 
1898  verifyUnitSourceDest( eUnitSource, eUnitDest );
1899  ENTER3( eUnitSource, eUnitDest );
1900 
1901  return fn3( nLongSource, nNumerator, nDenominator );
1902 }
1903 
1904 void OutputDevice::SetPixelOffset( const Size& rOffset )
1905 {
1906  mnOutOffOrigX = rOffset.Width();
1907  mnOutOffOrigY = rOffset.Height();
1908 
1915 
1916  if( mpAlphaVDev )
1917  mpAlphaVDev->SetPixelOffset( rOffset );
1918 }
1919 
1920 
1922 {
1923  if ( !mbMap )
1924  return static_cast<DeviceCoordinate>(nWidth);
1925 
1926 #if VCL_FLOAT_DEVICE_PIXEL
1927  return (double)nWidth * maMapRes.mfScaleX * mnDPIX;
1928 #else
1929 
1930  return ImplLogicToPixel( nWidth, mnDPIX,
1933 #endif
1934 }
1935 
1936 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 Count() const
basegfx::B2DHomMatrix GetInverseViewTransformation() const
Definition: map.cxx:875
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:342
void SetPixelOffset(const Size &rOffset)
Set an offset in pixel.
Definition: map.cxx:1904
void SetRelativeMapMode(const MapMode &rNewMapMode)
Definition: map.cxx:775
static void verifyUnitSourceDest(MapUnit eUnitSource, MapUnit eUnitDest)
Definition: map.cxx:1473
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
static const MapUnit s_MaxValidUnit
Definition: map.cxx:39
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1668
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:1165
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: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: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: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:1516
ImplSVGDIData maGDIData
Definition: svdata.hxx:394
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:1437
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
long Right() const
#define ENTER4(rMapModeSource, rMapModeDest)
Definition: map.cxx:1502
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
if(nullptr==pCandidateA||nullptr==pCandidateB)
SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const
Get device transformation.
Definition: map.cxx:925
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
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:1634
void SetScaleX(const Fraction &rScaleX)
Definition: mapmod.cxx:108
virtual void ImplInitMapModeObjects()
Definition: map.cxx:773
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:338
const Point * GetConstPointAry() const
long mnOutOffLogicX
Additional output offset in logical coordinates, applied in PixelToLogic (used by SetPixelOffset/GetP...
Definition: outdev.hxx:336
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:102
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:115
sal_uInt16 GetSize() const
static const o3tl::enumarray< MapUnit, long > aImplDenominatorAry
Definition: map.cxx:42
MapUnit GetMapUnit() const
Definition: mapmod.cxx:168
bool IsNeg() const
#define ENTER3(eUnitSource, eUnitDest)
Definition: map.cxx:1485
long mnAppFontX
Definition: svdata.hxx:227
const long LONG_MAX
void transform(const basegfx::B2DHomMatrix &rMatrix)
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1179
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:934
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
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:543
const tools::PolyPolygon * getPolyPolygon() const
Definition: region.hxx:80
ImplSVFrameData maFrameData
Definition: svdata.hxx:395
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: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:238
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:228
SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate(long nWidth) const
Definition: map.cxx:1921
long mnMapOfsX
Definition: outdevmap.hxx:25
basegfx::B2DHomMatrix GetViewTransformation() const
Definition: map.cxx:847
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:319
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo