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