1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10*9f62ea84SAndrew Rist * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9f62ea84SAndrew Rist * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19*9f62ea84SAndrew Rist * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <limits.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <tools/bigint.hxx> 30cdf0e10cSrcweir #include <tools/debug.hxx> 31cdf0e10cSrcweir #include <tools/poly.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vcl/virdev.hxx> 34cdf0e10cSrcweir #include <vcl/region.hxx> 35cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 36cdf0e10cSrcweir #include <vcl/cursor.hxx> 37cdf0e10cSrcweir #include <vcl/metaact.hxx> 38cdf0e10cSrcweir #include <vcl/gdimtf.hxx> 39cdf0e10cSrcweir #include <vcl/lineinfo.hxx> 40cdf0e10cSrcweir #include <vcl/outdev.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <svdata.hxx> 43cdf0e10cSrcweir #include <region.h> 44cdf0e10cSrcweir #include <window.h> 45cdf0e10cSrcweir #include <outdev.h> 46cdf0e10cSrcweir #include <salgdi.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 49cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 50cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #define USE_64BIT_INTS 53cdf0e10cSrcweir 54cdf0e10cSrcweir // ======================================================================= 55cdf0e10cSrcweir 56cdf0e10cSrcweir DBG_NAMEEX( OutputDevice ) 57cdf0e10cSrcweir DBG_NAMEEX( Polygon ) 58cdf0e10cSrcweir DBG_NAMEEX( PolyPolygon ) 59cdf0e10cSrcweir DBG_NAMEEX( Region ) 60cdf0e10cSrcweir 61cdf0e10cSrcweir // ======================================================================= 62cdf0e10cSrcweir 63cdf0e10cSrcweir static long aImplNumeratorAry[MAP_PIXEL+1] = 64cdf0e10cSrcweir { 1, 1, 5, 50, 1, 1, 1, 1, 1, 1, 1 }; 65cdf0e10cSrcweir static long aImplDenominatorAry[MAP_PIXEL+1] = 66cdf0e10cSrcweir { 2540, 254, 127, 127, 1000, 100, 10, 1, 72, 1440, 1 }; 67cdf0e10cSrcweir 68cdf0e10cSrcweir // ----------------------------------------------------------------------- 69cdf0e10cSrcweir 70cdf0e10cSrcweir /* 71cdf0e10cSrcweir Reduziert die Genauigkeit bis eine Fraction draus wird (sollte mal 72cdf0e10cSrcweir ein Fraction ctor werden) koennte man dann auch mit BigInts machen 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir 75cdf0e10cSrcweir static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir long i = 1; 78cdf0e10cSrcweir 79cdf0e10cSrcweir if ( nN1 < 0 ) { i = -i; nN1 = -nN1; } 80cdf0e10cSrcweir if ( nN2 < 0 ) { i = -i; nN2 = -nN2; } 81cdf0e10cSrcweir if ( nD1 < 0 ) { i = -i; nD1 = -nD1; } 82cdf0e10cSrcweir if ( nD2 < 0 ) { i = -i; nD2 = -nD2; } 83cdf0e10cSrcweir // alle positiv; i Vorzeichen 84cdf0e10cSrcweir 85cdf0e10cSrcweir Fraction aF( i*nN1, nD1 ); 86cdf0e10cSrcweir aF *= Fraction( nN2, nD2 ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir if( nD1 == 0 || nD2 == 0 ) //under these bad circumstances the following while loop will be endless 89cdf0e10cSrcweir { 90cdf0e10cSrcweir DBG_ASSERT(false,"Invalid parameter for ImplMakeFraction"); 91cdf0e10cSrcweir return Fraction( 1, 1 ); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir while ( aF.GetDenominator() == -1 ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir if ( nN1 > nN2 ) 97cdf0e10cSrcweir nN1 = (nN1 + 1) / 2; 98cdf0e10cSrcweir else 99cdf0e10cSrcweir nN2 = (nN2 + 1) / 2; 100cdf0e10cSrcweir if ( nD1 > nD2 ) 101cdf0e10cSrcweir nD1 = (nD1 + 1) / 2; 102cdf0e10cSrcweir else 103cdf0e10cSrcweir nD2 = (nD2 + 1) / 2; 104cdf0e10cSrcweir 105cdf0e10cSrcweir aF = Fraction( i*nN1, nD1 ); 106cdf0e10cSrcweir aF *= Fraction( nN2, nD2 ); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir return aF; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir // ----------------------------------------------------------------------- 113cdf0e10cSrcweir 114cdf0e10cSrcweir // Fraction.GetNumerator() 115cdf0e10cSrcweir // Fraction.GetDenominator() > 0 116cdf0e10cSrcweir // rOutRes.nPixPerInch? > 0 117cdf0e10cSrcweir // rMapRes.nMapScNum? 118cdf0e10cSrcweir // rMapRes.nMapScDenom? > 0 119cdf0e10cSrcweir 120cdf0e10cSrcweir static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY, 121cdf0e10cSrcweir const ImplMapRes& rMapRes, 122cdf0e10cSrcweir ImplThresholdRes& rThresRes ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir if ( nDPIX && (LONG_MAX / nDPIX < Abs( rMapRes.mnMapScNumX ) ) ) // #111139# avoid div by zero 125cdf0e10cSrcweir { 126cdf0e10cSrcweir rThresRes.mnThresLogToPixX = 0; 127cdf0e10cSrcweir rThresRes.mnThresPixToLogX = 0; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else 130cdf0e10cSrcweir { 131cdf0e10cSrcweir // Schwellenwerte fuer BigInt Arithmetik berechnen 132cdf0e10cSrcweir long nDenomHalfX = rMapRes.mnMapScDenomX / 2; 133cdf0e10cSrcweir sal_uLong nDenomX = rMapRes.mnMapScDenomX; 134cdf0e10cSrcweir long nProductX = nDPIX * rMapRes.mnMapScNumX; 135cdf0e10cSrcweir 136cdf0e10cSrcweir if ( !nProductX ) 137cdf0e10cSrcweir rThresRes.mnThresLogToPixX = LONG_MAX; 138cdf0e10cSrcweir else 139cdf0e10cSrcweir rThresRes.mnThresLogToPixX = Abs( (LONG_MAX - nDenomHalfX) / nProductX ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir if ( !nDenomX ) 142cdf0e10cSrcweir rThresRes.mnThresPixToLogX = LONG_MAX; 143cdf0e10cSrcweir else if ( nProductX >= 0 ) 144cdf0e10cSrcweir rThresRes.mnThresPixToLogX = (long)(((sal_uLong)LONG_MAX - (sal_uLong)( nProductX/2)) / nDenomX); 145cdf0e10cSrcweir else 146cdf0e10cSrcweir rThresRes.mnThresPixToLogX = (long)(((sal_uLong)LONG_MAX + (sal_uLong)(-nProductX/2)) / nDenomX); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir if ( nDPIY && (LONG_MAX / nDPIY < Abs( rMapRes.mnMapScNumY ) ) ) // #111139# avoid div by zero 150cdf0e10cSrcweir { 151cdf0e10cSrcweir rThresRes.mnThresLogToPixY = 0; 152cdf0e10cSrcweir rThresRes.mnThresPixToLogY = 0; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir else 155cdf0e10cSrcweir { 156cdf0e10cSrcweir // Schwellenwerte fuer BigInt Arithmetik berechnen 157cdf0e10cSrcweir long nDenomHalfY = rMapRes.mnMapScDenomY / 2; 158cdf0e10cSrcweir sal_uLong nDenomY = rMapRes.mnMapScDenomY; 159cdf0e10cSrcweir long nProductY = nDPIY * rMapRes.mnMapScNumY; 160cdf0e10cSrcweir 161cdf0e10cSrcweir if ( !nProductY ) 162cdf0e10cSrcweir rThresRes.mnThresLogToPixY = LONG_MAX; 163cdf0e10cSrcweir else 164cdf0e10cSrcweir rThresRes.mnThresLogToPixY = Abs( (LONG_MAX - nDenomHalfY) / nProductY ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir if ( !nDenomY ) 167cdf0e10cSrcweir rThresRes.mnThresPixToLogY = LONG_MAX; 168cdf0e10cSrcweir else if ( nProductY >= 0 ) 169cdf0e10cSrcweir rThresRes.mnThresPixToLogY = (long)(((sal_uLong)LONG_MAX - (sal_uLong)( nProductY/2)) / nDenomY); 170cdf0e10cSrcweir else 171cdf0e10cSrcweir rThresRes.mnThresPixToLogY = (long)(((sal_uLong)LONG_MAX + (sal_uLong)(-nProductY/2)) / nDenomY); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir #ifdef USE_64BIT_INTS 175cdf0e10cSrcweir rThresRes.mnThresLogToPixX /= 2; 176cdf0e10cSrcweir rThresRes.mnThresLogToPixY /= 2; 177cdf0e10cSrcweir rThresRes.mnThresPixToLogX /= 2; 178cdf0e10cSrcweir rThresRes.mnThresPixToLogY /= 2; 179cdf0e10cSrcweir #endif 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir // ----------------------------------------------------------------------- 183cdf0e10cSrcweir 184cdf0e10cSrcweir static void ImplCalcMapResolution( const MapMode& rMapMode, 185cdf0e10cSrcweir long nDPIX, long nDPIY, ImplMapRes& rMapRes ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir switch ( rMapMode.GetMapUnit() ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir case MAP_RELATIVE: 190cdf0e10cSrcweir break; 191cdf0e10cSrcweir case MAP_100TH_MM: 192cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 193cdf0e10cSrcweir rMapRes.mnMapScDenomX = 2540; 194cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 195cdf0e10cSrcweir rMapRes.mnMapScDenomY = 2540; 196cdf0e10cSrcweir break; 197cdf0e10cSrcweir case MAP_10TH_MM: 198cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 199cdf0e10cSrcweir rMapRes.mnMapScDenomX = 254; 200cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 201cdf0e10cSrcweir rMapRes.mnMapScDenomY = 254; 202cdf0e10cSrcweir break; 203cdf0e10cSrcweir case MAP_MM: 204cdf0e10cSrcweir rMapRes.mnMapScNumX = 5; // 10 205cdf0e10cSrcweir rMapRes.mnMapScDenomX = 127; // 254 206cdf0e10cSrcweir rMapRes.mnMapScNumY = 5; // 10 207cdf0e10cSrcweir rMapRes.mnMapScDenomY = 127; // 254 208cdf0e10cSrcweir break; 209cdf0e10cSrcweir case MAP_CM: 210cdf0e10cSrcweir rMapRes.mnMapScNumX = 50; // 100 211cdf0e10cSrcweir rMapRes.mnMapScDenomX = 127; // 254 212cdf0e10cSrcweir rMapRes.mnMapScNumY = 50; // 100 213cdf0e10cSrcweir rMapRes.mnMapScDenomY = 127; // 254 214cdf0e10cSrcweir break; 215cdf0e10cSrcweir case MAP_1000TH_INCH: 216cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 217cdf0e10cSrcweir rMapRes.mnMapScDenomX = 1000; 218cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 219cdf0e10cSrcweir rMapRes.mnMapScDenomY = 1000; 220cdf0e10cSrcweir break; 221cdf0e10cSrcweir case MAP_100TH_INCH: 222cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 223cdf0e10cSrcweir rMapRes.mnMapScDenomX = 100; 224cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 225cdf0e10cSrcweir rMapRes.mnMapScDenomY = 100; 226cdf0e10cSrcweir break; 227cdf0e10cSrcweir case MAP_10TH_INCH: 228cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 229cdf0e10cSrcweir rMapRes.mnMapScDenomX = 10; 230cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 231cdf0e10cSrcweir rMapRes.mnMapScDenomY = 10; 232cdf0e10cSrcweir break; 233cdf0e10cSrcweir case MAP_INCH: 234cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 235cdf0e10cSrcweir rMapRes.mnMapScDenomX = 1; 236cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 237cdf0e10cSrcweir rMapRes.mnMapScDenomY = 1; 238cdf0e10cSrcweir break; 239cdf0e10cSrcweir case MAP_POINT: 240cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 241cdf0e10cSrcweir rMapRes.mnMapScDenomX = 72; 242cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 243cdf0e10cSrcweir rMapRes.mnMapScDenomY = 72; 244cdf0e10cSrcweir break; 245cdf0e10cSrcweir case MAP_TWIP: 246cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 247cdf0e10cSrcweir rMapRes.mnMapScDenomX = 1440; 248cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 249cdf0e10cSrcweir rMapRes.mnMapScDenomY = 1440; 250cdf0e10cSrcweir break; 251cdf0e10cSrcweir case MAP_PIXEL: 252cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 253cdf0e10cSrcweir rMapRes.mnMapScDenomX = nDPIX; 254cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 255cdf0e10cSrcweir rMapRes.mnMapScDenomY = nDPIY; 256cdf0e10cSrcweir break; 257cdf0e10cSrcweir case MAP_SYSFONT: 258cdf0e10cSrcweir case MAP_APPFONT: 259cdf0e10cSrcweir case MAP_REALAPPFONT: 260cdf0e10cSrcweir { 261cdf0e10cSrcweir ImplSVData* pSVData = ImplGetSVData(); 262cdf0e10cSrcweir if ( !pSVData->maGDIData.mnAppFontX ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir if( pSVData->maWinData.mpFirstFrame ) 265cdf0e10cSrcweir Window::ImplInitAppFontData( pSVData->maWinData.mpFirstFrame ); 266cdf0e10cSrcweir else 267cdf0e10cSrcweir { 268cdf0e10cSrcweir WorkWindow* pWin = new WorkWindow( NULL, 0 ); 269cdf0e10cSrcweir Window::ImplInitAppFontData( pWin ); 270cdf0e10cSrcweir delete pWin; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir } 273cdf0e10cSrcweir if ( rMapMode.GetMapUnit() == MAP_REALAPPFONT ) 274cdf0e10cSrcweir rMapRes.mnMapScNumX = pSVData->maGDIData.mnRealAppFontX; 275cdf0e10cSrcweir else 276cdf0e10cSrcweir rMapRes.mnMapScNumX = pSVData->maGDIData.mnAppFontX; 277cdf0e10cSrcweir rMapRes.mnMapScDenomX = nDPIX * 40; 278cdf0e10cSrcweir rMapRes.mnMapScNumY = pSVData->maGDIData.mnAppFontY;; 279cdf0e10cSrcweir rMapRes.mnMapScDenomY = nDPIY * 80; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir break; 282cdf0e10cSrcweir default: 283cdf0e10cSrcweir DBG_ERROR( "unhandled MapUnit" ); 284cdf0e10cSrcweir break; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir Fraction aScaleX = rMapMode.GetScaleX(); 288cdf0e10cSrcweir Fraction aScaleY = rMapMode.GetScaleY(); 289cdf0e10cSrcweir 290cdf0e10cSrcweir // Offset laut MapMode setzen 291cdf0e10cSrcweir Point aOrigin = rMapMode.GetOrigin(); 292cdf0e10cSrcweir if ( rMapMode.GetMapUnit() != MAP_RELATIVE ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir rMapRes.mnMapOfsX = aOrigin.X(); 295cdf0e10cSrcweir rMapRes.mnMapOfsY = aOrigin.Y(); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir else 298cdf0e10cSrcweir { 299cdf0e10cSrcweir BigInt aX( rMapRes.mnMapOfsX ); 300cdf0e10cSrcweir aX *= BigInt( aScaleX.GetDenominator() ); 301cdf0e10cSrcweir if ( rMapRes.mnMapOfsX >= 0 ) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir if ( aScaleX.GetNumerator() >= 0 ) 304cdf0e10cSrcweir aX += BigInt( aScaleX.GetNumerator()/2 ); 305cdf0e10cSrcweir else 306cdf0e10cSrcweir aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir else 309cdf0e10cSrcweir { 310cdf0e10cSrcweir if ( aScaleX.GetNumerator() >= 0 ) 311cdf0e10cSrcweir aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); 312cdf0e10cSrcweir else 313cdf0e10cSrcweir aX += BigInt( aScaleX.GetNumerator()/2 ); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir aX /= BigInt( aScaleX.GetNumerator() ); 316cdf0e10cSrcweir rMapRes.mnMapOfsX = (long)aX + aOrigin.X(); 317cdf0e10cSrcweir BigInt aY( rMapRes.mnMapOfsY ); 318cdf0e10cSrcweir aY *= BigInt( aScaleY.GetDenominator() ); 319cdf0e10cSrcweir if( rMapRes.mnMapOfsY >= 0 ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir if ( aScaleY.GetNumerator() >= 0 ) 322cdf0e10cSrcweir aY += BigInt( aScaleY.GetNumerator()/2 ); 323cdf0e10cSrcweir else 324cdf0e10cSrcweir aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir else 327cdf0e10cSrcweir { 328cdf0e10cSrcweir if ( aScaleY.GetNumerator() >= 0 ) 329cdf0e10cSrcweir aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); 330cdf0e10cSrcweir else 331cdf0e10cSrcweir aY += BigInt( aScaleY.GetNumerator()/2 ); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir aY /= BigInt( aScaleY.GetNumerator() ); 334cdf0e10cSrcweir rMapRes.mnMapOfsY = (long)aY + aOrigin.Y(); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir // Scaling Faktor laut MapMode einberechnen 338cdf0e10cSrcweir // aTemp? = rMapRes.mnMapSc? * aScale? 339cdf0e10cSrcweir Fraction aTempX = ImplMakeFraction( rMapRes.mnMapScNumX, 340cdf0e10cSrcweir aScaleX.GetNumerator(), 341cdf0e10cSrcweir rMapRes.mnMapScDenomX, 342cdf0e10cSrcweir aScaleX.GetDenominator() ); 343cdf0e10cSrcweir Fraction aTempY = ImplMakeFraction( rMapRes.mnMapScNumY, 344cdf0e10cSrcweir aScaleY.GetNumerator(), 345cdf0e10cSrcweir rMapRes.mnMapScDenomY, 346cdf0e10cSrcweir aScaleY.GetDenominator() ); 347cdf0e10cSrcweir rMapRes.mnMapScNumX = aTempX.GetNumerator(); 348cdf0e10cSrcweir rMapRes.mnMapScDenomX = aTempX.GetDenominator(); 349cdf0e10cSrcweir rMapRes.mnMapScNumY = aTempY.GetNumerator(); 350cdf0e10cSrcweir rMapRes.mnMapScDenomY = aTempY.GetDenominator(); 351cdf0e10cSrcweir 352cdf0e10cSrcweir // hack: 0/n ungef"ahr 1/max 353cdf0e10cSrcweir if ( !rMapRes.mnMapScNumX ) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir rMapRes.mnMapScNumX = 1; 356cdf0e10cSrcweir rMapRes.mnMapScDenomX = LONG_MAX; 357cdf0e10cSrcweir } 358cdf0e10cSrcweir if ( !rMapRes.mnMapScNumY ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir rMapRes.mnMapScNumY = 1; 361cdf0e10cSrcweir rMapRes.mnMapScDenomY = LONG_MAX; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir // ----------------------------------------------------------------------- 366cdf0e10cSrcweir 367cdf0e10cSrcweir inline void ImplCalcMapResolution( const MapMode& rMapMode, 368cdf0e10cSrcweir long nDPIX, long nDPIY, 369cdf0e10cSrcweir ImplMapRes& rMapRes, 370cdf0e10cSrcweir ImplThresholdRes& rThresRes ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, nDPIX, nDPIY, rMapRes ); 373cdf0e10cSrcweir ImplCalcBigIntThreshold( nDPIX, nDPIY, rMapRes, rThresRes ); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir // ----------------------------------------------------------------------- 377cdf0e10cSrcweir 378cdf0e10cSrcweir static long ImplLogicToPixel( long n, long nDPI, long nMapNum, long nMapDenom, 379cdf0e10cSrcweir long nThres ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir // To "use" it... 382cdf0e10cSrcweir (void) nThres; 383cdf0e10cSrcweir #ifdef USE_64BIT_INTS 384cdf0e10cSrcweir #if (SAL_TYPES_SIZEOFLONG < 8) 385cdf0e10cSrcweir if( (+n < nThres) && (-n < nThres) ) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir n *= nMapNum * nDPI; 388cdf0e10cSrcweir if( nMapDenom != 1 ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir n = (2 * n) / nMapDenom; 391cdf0e10cSrcweir if( n < 0 ) --n; else ++n; 392cdf0e10cSrcweir n /= 2; 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir else 396cdf0e10cSrcweir #endif 397cdf0e10cSrcweir { 398cdf0e10cSrcweir sal_Int64 n64 = n; 399cdf0e10cSrcweir n64 *= nMapNum; 400cdf0e10cSrcweir n64 *= nDPI; 401cdf0e10cSrcweir if( nMapDenom == 1 ) 402cdf0e10cSrcweir n = (long)n64; 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir n = (long)(2 * n64 / nMapDenom); 406cdf0e10cSrcweir if( n < 0 ) --n; else ++n; 407cdf0e10cSrcweir n /= 2; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir } 410cdf0e10cSrcweir return n; 411cdf0e10cSrcweir #else // USE_64BIT_INTS 412cdf0e10cSrcweir if ( Abs( n ) < nThres ) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir n *= nDPI * nMapNum; 415cdf0e10cSrcweir n += n >= 0 ? nMapDenom/2 : -((nMapDenom-1)/2); 416cdf0e10cSrcweir return (n / nMapDenom); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir else 419cdf0e10cSrcweir { 420cdf0e10cSrcweir BigInt aTemp( n ); 421cdf0e10cSrcweir aTemp *= BigInt( nDPI ); 422cdf0e10cSrcweir aTemp *= BigInt( nMapNum ); 423cdf0e10cSrcweir 424cdf0e10cSrcweir if ( aTemp.IsNeg() ) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir BigInt aMapScDenom2( (nMapDenom-1)/2 ); 427cdf0e10cSrcweir aTemp -= aMapScDenom2; 428cdf0e10cSrcweir } 429cdf0e10cSrcweir else 430cdf0e10cSrcweir { 431cdf0e10cSrcweir BigInt aMapScDenom2( nMapDenom/2 ); 432cdf0e10cSrcweir aTemp += aMapScDenom2; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir aTemp /= BigInt( nMapDenom ); 436cdf0e10cSrcweir return (long)aTemp; 437cdf0e10cSrcweir } 438cdf0e10cSrcweir #endif 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir // ----------------------------------------------------------------------- 442cdf0e10cSrcweir 443cdf0e10cSrcweir static long ImplPixelToLogic( long n, long nDPI, long nMapNum, long nMapDenom, 444cdf0e10cSrcweir long nThres ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir // To "use" it... 447cdf0e10cSrcweir (void) nThres; 448cdf0e10cSrcweir #ifdef USE_64BIT_INTS 449cdf0e10cSrcweir #if (SAL_TYPES_SIZEOFLONG < 8) 450cdf0e10cSrcweir if( (+n < nThres) && (-n < nThres) ) 451cdf0e10cSrcweir n = (2 * n * nMapDenom) / (nDPI * nMapNum); 452cdf0e10cSrcweir else 453cdf0e10cSrcweir #endif 454cdf0e10cSrcweir { 455cdf0e10cSrcweir sal_Int64 n64 = n; 456cdf0e10cSrcweir n64 *= nMapDenom; 457cdf0e10cSrcweir long nDenom = nDPI * nMapNum; 458cdf0e10cSrcweir n = (long)(2 * n64 / nDenom); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir if( n < 0 ) --n; else ++n; 461cdf0e10cSrcweir return (n / 2); 462cdf0e10cSrcweir #else // USE_64BIT_INTS 463cdf0e10cSrcweir if ( Abs( n ) < nThres ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir long nDenom = nDPI * nMapNum; 466cdf0e10cSrcweir long nNum = n * nMapDenom; 467cdf0e10cSrcweir if( (nNum ^ nDenom) >= 0 ) 468cdf0e10cSrcweir nNum += nDenom/2; 469cdf0e10cSrcweir else 470cdf0e10cSrcweir nNum -= nDenom/2; 471cdf0e10cSrcweir return (nNum / nDenom); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir else 474cdf0e10cSrcweir { 475cdf0e10cSrcweir BigInt aDenom( nDPI ); 476cdf0e10cSrcweir aDenom *= BigInt( nMapNum ); 477cdf0e10cSrcweir 478cdf0e10cSrcweir BigInt aNum( n ); 479cdf0e10cSrcweir aNum *= BigInt( nMapDenom ); 480cdf0e10cSrcweir 481cdf0e10cSrcweir BigInt aDenom2( aDenom ); 482cdf0e10cSrcweir if ( aNum.IsNeg() ) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir if ( aDenom.IsNeg() ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir aDenom2 /= BigInt(2); 487cdf0e10cSrcweir aNum += aDenom2; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir else 490cdf0e10cSrcweir { 491cdf0e10cSrcweir aDenom2 -= 1; 492cdf0e10cSrcweir aDenom2 /= BigInt(2); 493cdf0e10cSrcweir aNum -= aDenom2; 494cdf0e10cSrcweir } 495cdf0e10cSrcweir } 496cdf0e10cSrcweir else 497cdf0e10cSrcweir { 498cdf0e10cSrcweir if ( aDenom.IsNeg() ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir aDenom2 += 1; 501cdf0e10cSrcweir aDenom2 /= BigInt(2); 502cdf0e10cSrcweir aNum -= aDenom2; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir else 505cdf0e10cSrcweir { 506cdf0e10cSrcweir aDenom2 /= BigInt(2); 507cdf0e10cSrcweir aNum += aDenom2; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir aNum /= aDenom; 512cdf0e10cSrcweir return (long)aNum; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir #endif 515cdf0e10cSrcweir } 516cdf0e10cSrcweir 517cdf0e10cSrcweir // ----------------------------------------------------------------------- 518cdf0e10cSrcweir 519cdf0e10cSrcweir long OutputDevice::ImplLogicXToDevicePixel( long nX ) const 520cdf0e10cSrcweir { 521cdf0e10cSrcweir if ( !mbMap ) 522cdf0e10cSrcweir return nX+mnOutOffX; 523cdf0e10cSrcweir 524cdf0e10cSrcweir return ImplLogicToPixel( nX + maMapRes.mnMapOfsX, mnDPIX, 525cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 526cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffX+mnOutOffOrigX; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir 529cdf0e10cSrcweir // ----------------------------------------------------------------------- 530cdf0e10cSrcweir 531cdf0e10cSrcweir long OutputDevice::ImplLogicYToDevicePixel( long nY ) const 532cdf0e10cSrcweir { 533cdf0e10cSrcweir if ( !mbMap ) 534cdf0e10cSrcweir return nY+mnOutOffY; 535cdf0e10cSrcweir 536cdf0e10cSrcweir return ImplLogicToPixel( nY + maMapRes.mnMapOfsY, mnDPIY, 537cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 538cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffY+mnOutOffOrigY; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir // ----------------------------------------------------------------------- 542cdf0e10cSrcweir 543cdf0e10cSrcweir long OutputDevice::ImplLogicWidthToDevicePixel( long nWidth ) const 544cdf0e10cSrcweir { 545cdf0e10cSrcweir if ( !mbMap ) 546cdf0e10cSrcweir return nWidth; 547cdf0e10cSrcweir 548cdf0e10cSrcweir return ImplLogicToPixel( nWidth, mnDPIX, 549cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 550cdf0e10cSrcweir maThresRes.mnThresLogToPixX ); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir float OutputDevice::ImplFloatLogicWidthToDevicePixel( float fLogicWidth) const 554cdf0e10cSrcweir { 555cdf0e10cSrcweir if( !mbMap) 556cdf0e10cSrcweir return fLogicWidth; 557cdf0e10cSrcweir // TODO: consolidate the calculation into one multiplication 558cdf0e10cSrcweir float fPixelWidth = (fLogicWidth * mnDPIX * maMapRes.mnMapScNumX) / maMapRes.mnMapScDenomX; 559cdf0e10cSrcweir return fPixelWidth; 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir // ----------------------------------------------------------------------- 563cdf0e10cSrcweir 564cdf0e10cSrcweir long OutputDevice::ImplLogicHeightToDevicePixel( long nHeight ) const 565cdf0e10cSrcweir { 566cdf0e10cSrcweir if ( !mbMap ) 567cdf0e10cSrcweir return nHeight; 568cdf0e10cSrcweir 569cdf0e10cSrcweir return ImplLogicToPixel( nHeight, mnDPIY, 570cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 571cdf0e10cSrcweir maThresRes.mnThresLogToPixY ); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir float OutputDevice::ImplFloatLogicHeightToDevicePixel( float fLogicHeight) const 575cdf0e10cSrcweir { 576cdf0e10cSrcweir if( !mbMap) 577cdf0e10cSrcweir return fLogicHeight; 578cdf0e10cSrcweir float fPixelHeight = (fLogicHeight * mnDPIY * maMapRes.mnMapScNumY) / maMapRes.mnMapScDenomY; 579cdf0e10cSrcweir return fPixelHeight; 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir // ----------------------------------------------------------------------- 583cdf0e10cSrcweir 584cdf0e10cSrcweir long OutputDevice::ImplDevicePixelToLogicWidth( long nWidth ) const 585cdf0e10cSrcweir { 586cdf0e10cSrcweir if ( !mbMap ) 587cdf0e10cSrcweir return nWidth; 588cdf0e10cSrcweir 589cdf0e10cSrcweir return ImplPixelToLogic( nWidth, mnDPIX, 590cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 591cdf0e10cSrcweir maThresRes.mnThresPixToLogX ); 592cdf0e10cSrcweir } 593cdf0e10cSrcweir 594cdf0e10cSrcweir float OutputDevice::ImplFloatDevicePixelToLogicWidth( float fPixelWidth) const 595cdf0e10cSrcweir { 596cdf0e10cSrcweir if( !mbMap) 597cdf0e10cSrcweir return fPixelWidth; 598cdf0e10cSrcweir float fLogicHeight = (fPixelWidth * maMapRes.mnMapScDenomX) / (mnDPIX * maMapRes.mnMapScNumX); 599cdf0e10cSrcweir return fLogicHeight; 600cdf0e10cSrcweir } 601cdf0e10cSrcweir 602cdf0e10cSrcweir // ----------------------------------------------------------------------- 603cdf0e10cSrcweir 604cdf0e10cSrcweir long OutputDevice::ImplDevicePixelToLogicHeight( long nHeight ) const 605cdf0e10cSrcweir { 606cdf0e10cSrcweir if ( !mbMap ) 607cdf0e10cSrcweir return nHeight; 608cdf0e10cSrcweir 609cdf0e10cSrcweir return ImplPixelToLogic( nHeight, mnDPIY, 610cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 611cdf0e10cSrcweir maThresRes.mnThresPixToLogY ); 612cdf0e10cSrcweir } 613cdf0e10cSrcweir 614cdf0e10cSrcweir float OutputDevice::ImplFloatDevicePixelToLogicHeight( float fPixelHeight) const 615cdf0e10cSrcweir { 616cdf0e10cSrcweir if( !mbMap) 617cdf0e10cSrcweir return fPixelHeight; 618cdf0e10cSrcweir float fLogicHeight = (fPixelHeight * maMapRes.mnMapScDenomY) / (mnDPIY * maMapRes.mnMapScNumY); 619cdf0e10cSrcweir return fLogicHeight; 620cdf0e10cSrcweir } 621cdf0e10cSrcweir 622cdf0e10cSrcweir 623cdf0e10cSrcweir // ----------------------------------------------------------------------- 624cdf0e10cSrcweir 625cdf0e10cSrcweir Point OutputDevice::ImplLogicToDevicePixel( const Point& rLogicPt ) const 626cdf0e10cSrcweir { 627cdf0e10cSrcweir if ( !mbMap ) 628cdf0e10cSrcweir return Point( rLogicPt.X()+mnOutOffX, rLogicPt.Y()+mnOutOffY ); 629cdf0e10cSrcweir 630cdf0e10cSrcweir return Point( ImplLogicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, mnDPIX, 631cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 632cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffX+mnOutOffOrigX, 633cdf0e10cSrcweir ImplLogicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, mnDPIY, 634cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 635cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffY+mnOutOffOrigY ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir 638cdf0e10cSrcweir // ----------------------------------------------------------------------- 639cdf0e10cSrcweir 640cdf0e10cSrcweir Size OutputDevice::ImplLogicToDevicePixel( const Size& rLogicSize ) const 641cdf0e10cSrcweir { 642cdf0e10cSrcweir if ( !mbMap ) 643cdf0e10cSrcweir return rLogicSize; 644cdf0e10cSrcweir 645cdf0e10cSrcweir return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX, 646cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 647cdf0e10cSrcweir maThresRes.mnThresLogToPixX ), 648cdf0e10cSrcweir ImplLogicToPixel( rLogicSize.Height(), mnDPIY, 649cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 650cdf0e10cSrcweir maThresRes.mnThresLogToPixY ) ); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir 653cdf0e10cSrcweir // ----------------------------------------------------------------------- 654cdf0e10cSrcweir 655cdf0e10cSrcweir Rectangle OutputDevice::ImplLogicToDevicePixel( const Rectangle& rLogicRect ) const 656cdf0e10cSrcweir { 657cdf0e10cSrcweir if ( rLogicRect.IsEmpty() ) 658cdf0e10cSrcweir return rLogicRect; 659cdf0e10cSrcweir 660cdf0e10cSrcweir if ( !mbMap ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir return Rectangle( rLogicRect.Left()+mnOutOffX, rLogicRect.Top()+mnOutOffY, 663cdf0e10cSrcweir rLogicRect.Right()+mnOutOffX, rLogicRect.Bottom()+mnOutOffY ); 664cdf0e10cSrcweir } 665cdf0e10cSrcweir 666cdf0e10cSrcweir return Rectangle( ImplLogicToPixel( rLogicRect.Left()+maMapRes.mnMapOfsX, mnDPIX, 667cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 668cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffX+mnOutOffOrigX, 669cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Top()+maMapRes.mnMapOfsY, mnDPIY, 670cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 671cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffY+mnOutOffOrigY, 672cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Right()+maMapRes.mnMapOfsX, mnDPIX, 673cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 674cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffX+mnOutOffOrigX, 675cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Bottom()+maMapRes.mnMapOfsY, mnDPIY, 676cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 677cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffY+mnOutOffOrigY ); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir // ----------------------------------------------------------------------- 681cdf0e10cSrcweir 682cdf0e10cSrcweir Polygon OutputDevice::ImplLogicToDevicePixel( const Polygon& rLogicPoly ) const 683cdf0e10cSrcweir { 684cdf0e10cSrcweir if ( !mbMap && !mnOutOffX && !mnOutOffY ) 685cdf0e10cSrcweir return rLogicPoly; 686cdf0e10cSrcweir 687cdf0e10cSrcweir sal_uInt16 i; 688cdf0e10cSrcweir sal_uInt16 nPoints = rLogicPoly.GetSize(); 689cdf0e10cSrcweir Polygon aPoly( rLogicPoly ); 690cdf0e10cSrcweir 691cdf0e10cSrcweir // Pointer auf das Point-Array holen (Daten werden kopiert) 692cdf0e10cSrcweir const Point* pPointAry = aPoly.GetConstPointAry(); 693cdf0e10cSrcweir 694cdf0e10cSrcweir if ( mbMap ) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir for ( i = 0; i < nPoints; i++ ) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir const Point* pPt = &(pPointAry[i]); 699cdf0e10cSrcweir Point aPt; 700cdf0e10cSrcweir aPt.X() = ImplLogicToPixel( pPt->X()+maMapRes.mnMapOfsX, mnDPIX, 701cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 702cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffX+mnOutOffOrigX; 703cdf0e10cSrcweir aPt.Y() = ImplLogicToPixel( pPt->Y()+maMapRes.mnMapOfsY, mnDPIY, 704cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 705cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffY+mnOutOffOrigY; 706cdf0e10cSrcweir aPoly[i] = aPt; 707cdf0e10cSrcweir } 708cdf0e10cSrcweir } 709cdf0e10cSrcweir else 710cdf0e10cSrcweir { 711cdf0e10cSrcweir for ( i = 0; i < nPoints; i++ ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir Point aPt = pPointAry[i]; 714cdf0e10cSrcweir aPt.X() += mnOutOffX; 715cdf0e10cSrcweir aPt.Y() += mnOutOffY; 716cdf0e10cSrcweir aPoly[i] = aPt; 717cdf0e10cSrcweir } 718cdf0e10cSrcweir } 719cdf0e10cSrcweir 720cdf0e10cSrcweir return aPoly; 721cdf0e10cSrcweir } 722cdf0e10cSrcweir 723cdf0e10cSrcweir // ----------------------------------------------------------------------- 724cdf0e10cSrcweir 725cdf0e10cSrcweir PolyPolygon OutputDevice::ImplLogicToDevicePixel( const PolyPolygon& rLogicPolyPoly ) const 726cdf0e10cSrcweir { 727cdf0e10cSrcweir if ( !mbMap && !mnOutOffX && !mnOutOffY ) 728cdf0e10cSrcweir return rLogicPolyPoly; 729cdf0e10cSrcweir 730cdf0e10cSrcweir PolyPolygon aPolyPoly( rLogicPolyPoly ); 731cdf0e10cSrcweir sal_uInt16 nPoly = aPolyPoly.Count(); 732cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nPoly; i++ ) 733cdf0e10cSrcweir { 734cdf0e10cSrcweir Polygon& rPoly = aPolyPoly[i]; 735cdf0e10cSrcweir rPoly = ImplLogicToDevicePixel( rPoly ); 736cdf0e10cSrcweir } 737cdf0e10cSrcweir return aPolyPoly; 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir // ----------------------------------------------------------------------- 741cdf0e10cSrcweir 742cdf0e10cSrcweir LineInfo OutputDevice::ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const 743cdf0e10cSrcweir { 744cdf0e10cSrcweir LineInfo aInfo( rLineInfo ); 745cdf0e10cSrcweir 746cdf0e10cSrcweir if( aInfo.GetStyle() == LINE_DASH ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir if( aInfo.GetDotCount() && aInfo.GetDotLen() ) 749cdf0e10cSrcweir aInfo.SetDotLen( Max( ImplLogicWidthToDevicePixel( aInfo.GetDotLen() ), 1L ) ); 750cdf0e10cSrcweir else 751cdf0e10cSrcweir aInfo.SetDotCount( 0 ); 752cdf0e10cSrcweir 753cdf0e10cSrcweir if( aInfo.GetDashCount() && aInfo.GetDashLen() ) 754cdf0e10cSrcweir aInfo.SetDashLen( Max( ImplLogicWidthToDevicePixel( aInfo.GetDashLen() ), 1L ) ); 755cdf0e10cSrcweir else 756cdf0e10cSrcweir aInfo.SetDashCount( 0 ); 757cdf0e10cSrcweir 758cdf0e10cSrcweir aInfo.SetDistance( ImplLogicWidthToDevicePixel( aInfo.GetDistance() ) ); 759cdf0e10cSrcweir 760cdf0e10cSrcweir if( ( !aInfo.GetDashCount() && !aInfo.GetDotCount() ) || !aInfo.GetDistance() ) 761cdf0e10cSrcweir aInfo.SetStyle( LINE_SOLID ); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir aInfo.SetWidth( ImplLogicWidthToDevicePixel( aInfo.GetWidth() ) ); 765cdf0e10cSrcweir 766cdf0e10cSrcweir return aInfo; 767cdf0e10cSrcweir } 768cdf0e10cSrcweir 769cdf0e10cSrcweir // ----------------------------------------------------------------------- 770cdf0e10cSrcweir 771cdf0e10cSrcweir Rectangle OutputDevice::ImplDevicePixelToLogic( const Rectangle& rPixelRect ) const 772cdf0e10cSrcweir { 773cdf0e10cSrcweir if ( rPixelRect.IsEmpty() ) 774cdf0e10cSrcweir return rPixelRect; 775cdf0e10cSrcweir 776cdf0e10cSrcweir if ( !mbMap ) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir return Rectangle( rPixelRect.Left()-mnOutOffX, rPixelRect.Top()-mnOutOffY, 779cdf0e10cSrcweir rPixelRect.Right()-mnOutOffX, rPixelRect.Bottom()-mnOutOffY ); 780cdf0e10cSrcweir } 781cdf0e10cSrcweir 782cdf0e10cSrcweir return Rectangle( ImplPixelToLogic( rPixelRect.Left()-mnOutOffX-mnOutOffOrigX, mnDPIX, 783cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 784cdf0e10cSrcweir maThresRes.mnThresPixToLogX )-maMapRes.mnMapOfsX, 785cdf0e10cSrcweir ImplPixelToLogic( rPixelRect.Top()-mnOutOffY-mnOutOffOrigY, mnDPIY, 786cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 787cdf0e10cSrcweir maThresRes.mnThresPixToLogY )-maMapRes.mnMapOfsY, 788cdf0e10cSrcweir ImplPixelToLogic( rPixelRect.Right()-mnOutOffX-mnOutOffOrigX, mnDPIX, 789cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 790cdf0e10cSrcweir maThresRes.mnThresPixToLogX )-maMapRes.mnMapOfsX, 791cdf0e10cSrcweir ImplPixelToLogic( rPixelRect.Bottom()-mnOutOffY-mnOutOffOrigY, mnDPIY, 792cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 793cdf0e10cSrcweir maThresRes.mnThresPixToLogY )-maMapRes.mnMapOfsY ); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir 796cdf0e10cSrcweir // ----------------------------------------------------------------------- 797cdf0e10cSrcweir 798cdf0e10cSrcweir Region OutputDevice::ImplPixelToDevicePixel( const Region& rRegion ) const 799cdf0e10cSrcweir { 800cdf0e10cSrcweir DBG_CHKOBJ( &rRegion, Region, ImplDbgTestRegion ); 801cdf0e10cSrcweir 802cdf0e10cSrcweir if ( !mnOutOffX && !mnOutOffY ) 803cdf0e10cSrcweir return rRegion; 804cdf0e10cSrcweir 805cdf0e10cSrcweir Region aRegion( rRegion ); 806cdf0e10cSrcweir aRegion.Move( mnOutOffX+mnOutOffOrigX, mnOutOffY+mnOutOffOrigY ); 807cdf0e10cSrcweir return aRegion; 808cdf0e10cSrcweir } 809cdf0e10cSrcweir 810cdf0e10cSrcweir // ----------------------------------------------------------------------- 811cdf0e10cSrcweir 812cdf0e10cSrcweir void OutputDevice::EnableMapMode( sal_Bool bEnable ) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir mbMap = (bEnable != 0); 815cdf0e10cSrcweir 816cdf0e10cSrcweir if( mpAlphaVDev ) 817cdf0e10cSrcweir mpAlphaVDev->EnableMapMode( bEnable ); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir 820cdf0e10cSrcweir // ----------------------------------------------------------------------- 821cdf0e10cSrcweir 822cdf0e10cSrcweir void OutputDevice::SetMapMode() 823cdf0e10cSrcweir { 824cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 825cdf0e10cSrcweir 826cdf0e10cSrcweir if ( mpMetaFile ) 827cdf0e10cSrcweir mpMetaFile->AddAction( new MetaMapModeAction( MapMode() ) ); 828cdf0e10cSrcweir 829cdf0e10cSrcweir if ( mbMap || !maMapMode.IsDefault() ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir mbMap = sal_False; 832cdf0e10cSrcweir maMapMode = MapMode(); 833cdf0e10cSrcweir 834cdf0e10cSrcweir // create new objects (clip region werden nicht neu skaliert) 835cdf0e10cSrcweir mbNewFont = sal_True; 836cdf0e10cSrcweir mbInitFont = sal_True; 837cdf0e10cSrcweir if ( GetOutDevType() == OUTDEV_WINDOW ) 838cdf0e10cSrcweir { 839cdf0e10cSrcweir if ( ((Window*)this)->mpWindowImpl->mpCursor ) 840cdf0e10cSrcweir ((Window*)this)->mpWindowImpl->mpCursor->ImplNew(); 841cdf0e10cSrcweir } 842cdf0e10cSrcweir 843cdf0e10cSrcweir // #106426# Adapt logical offset when changing mapmode 844cdf0e10cSrcweir mnOutOffLogicX = mnOutOffOrigX; // no mapping -> equal offsets 845cdf0e10cSrcweir mnOutOffLogicY = mnOutOffOrigY; 846cdf0e10cSrcweir 847cdf0e10cSrcweir // #i75163# 848cdf0e10cSrcweir ImplInvalidateViewTransform(); 849cdf0e10cSrcweir } 850cdf0e10cSrcweir 851cdf0e10cSrcweir if( mpAlphaVDev ) 852cdf0e10cSrcweir mpAlphaVDev->SetMapMode(); 853cdf0e10cSrcweir } 854cdf0e10cSrcweir 855cdf0e10cSrcweir // ----------------------------------------------------------------------- 856cdf0e10cSrcweir 857cdf0e10cSrcweir void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) 858cdf0e10cSrcweir { 859cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 860cdf0e10cSrcweir 861cdf0e10cSrcweir sal_Bool bRelMap = (rNewMapMode.GetMapUnit() == MAP_RELATIVE); 862cdf0e10cSrcweir 863cdf0e10cSrcweir if ( mpMetaFile ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir mpMetaFile->AddAction( new MetaMapModeAction( rNewMapMode ) ); 866cdf0e10cSrcweir #ifdef DBG_UTIL 867cdf0e10cSrcweir if ( GetOutDevType() != OUTDEV_PRINTER ) 868cdf0e10cSrcweir DBG_ASSERTWARNING( bRelMap, "Please record only relative MapModes!" ); 869cdf0e10cSrcweir #endif 870cdf0e10cSrcweir } 871cdf0e10cSrcweir 872cdf0e10cSrcweir // Ist der MapMode der gleiche wie vorher, dann mache nichts 873cdf0e10cSrcweir if ( maMapMode == rNewMapMode ) 874cdf0e10cSrcweir return; 875cdf0e10cSrcweir 876cdf0e10cSrcweir if( mpAlphaVDev ) 877cdf0e10cSrcweir mpAlphaVDev->SetMapMode( rNewMapMode ); 878cdf0e10cSrcweir 879cdf0e10cSrcweir // Ist Default-MapMode, dann bereche nichts 880cdf0e10cSrcweir sal_Bool bOldMap = mbMap; 881cdf0e10cSrcweir mbMap = !rNewMapMode.IsDefault(); 882cdf0e10cSrcweir if ( mbMap ) 883cdf0e10cSrcweir { 884cdf0e10cSrcweir // Falls nur der Orign umgesetzt wird, dann scaliere nichts neu 885cdf0e10cSrcweir if ( (rNewMapMode.GetMapUnit() == maMapMode.GetMapUnit()) && 886cdf0e10cSrcweir (rNewMapMode.GetScaleX() == maMapMode.GetScaleX()) && 887cdf0e10cSrcweir (rNewMapMode.GetScaleY() == maMapMode.GetScaleY()) && 888cdf0e10cSrcweir (bOldMap == mbMap) ) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir // Offset setzen 891cdf0e10cSrcweir Point aOrigin = rNewMapMode.GetOrigin(); 892cdf0e10cSrcweir maMapRes.mnMapOfsX = aOrigin.X(); 893cdf0e10cSrcweir maMapRes.mnMapOfsY = aOrigin.Y(); 894cdf0e10cSrcweir maMapMode = rNewMapMode; 895cdf0e10cSrcweir 896cdf0e10cSrcweir // #i75163# 897cdf0e10cSrcweir ImplInvalidateViewTransform(); 898cdf0e10cSrcweir 899cdf0e10cSrcweir return; 900cdf0e10cSrcweir } 901cdf0e10cSrcweir if ( !bOldMap && bRelMap ) 902cdf0e10cSrcweir { 903cdf0e10cSrcweir maMapRes.mnMapScNumX = 1; 904cdf0e10cSrcweir maMapRes.mnMapScNumY = 1; 905cdf0e10cSrcweir maMapRes.mnMapScDenomX = mnDPIX; 906cdf0e10cSrcweir maMapRes.mnMapScDenomY = mnDPIY; 907cdf0e10cSrcweir maMapRes.mnMapOfsX = 0; 908cdf0e10cSrcweir maMapRes.mnMapOfsY = 0; 909cdf0e10cSrcweir } 910cdf0e10cSrcweir 911cdf0e10cSrcweir // Neue MapMode-Aufloesung berechnen 912cdf0e10cSrcweir ImplCalcMapResolution( rNewMapMode, mnDPIX, mnDPIY, maMapRes, maThresRes ); 913cdf0e10cSrcweir } 914cdf0e10cSrcweir 915cdf0e10cSrcweir // Neuen MapMode setzen 916cdf0e10cSrcweir if ( bRelMap ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir Point aOrigin( maMapRes.mnMapOfsX, maMapRes.mnMapOfsY ); 919cdf0e10cSrcweir // aScale? = maMapMode.GetScale?() * rNewMapMode.GetScale?() 920cdf0e10cSrcweir Fraction aScaleX = ImplMakeFraction( maMapMode.GetScaleX().GetNumerator(), 921cdf0e10cSrcweir rNewMapMode.GetScaleX().GetNumerator(), 922cdf0e10cSrcweir maMapMode.GetScaleX().GetDenominator(), 923cdf0e10cSrcweir rNewMapMode.GetScaleX().GetDenominator() ); 924cdf0e10cSrcweir Fraction aScaleY = ImplMakeFraction( maMapMode.GetScaleY().GetNumerator(), 925cdf0e10cSrcweir rNewMapMode.GetScaleY().GetNumerator(), 926cdf0e10cSrcweir maMapMode.GetScaleY().GetDenominator(), 927cdf0e10cSrcweir rNewMapMode.GetScaleY().GetDenominator() ); 928cdf0e10cSrcweir maMapMode.SetOrigin( aOrigin ); 929cdf0e10cSrcweir maMapMode.SetScaleX( aScaleX ); 930cdf0e10cSrcweir maMapMode.SetScaleY( aScaleY ); 931cdf0e10cSrcweir } 932cdf0e10cSrcweir else 933cdf0e10cSrcweir maMapMode = rNewMapMode; 934cdf0e10cSrcweir 935cdf0e10cSrcweir // create new objects (clip region werden nicht neu skaliert) 936cdf0e10cSrcweir mbNewFont = sal_True; 937cdf0e10cSrcweir mbInitFont = sal_True; 938cdf0e10cSrcweir if ( GetOutDevType() == OUTDEV_WINDOW ) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir if ( ((Window*)this)->mpWindowImpl->mpCursor ) 941cdf0e10cSrcweir ((Window*)this)->mpWindowImpl->mpCursor->ImplNew(); 942cdf0e10cSrcweir } 943cdf0e10cSrcweir 944cdf0e10cSrcweir // #106426# Adapt logical offset when changing mapmode 945cdf0e10cSrcweir mnOutOffLogicX = ImplPixelToLogic( mnOutOffOrigX, mnDPIX, 946cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 947cdf0e10cSrcweir maThresRes.mnThresPixToLogX ); 948cdf0e10cSrcweir mnOutOffLogicY = ImplPixelToLogic( mnOutOffOrigY, mnDPIY, 949cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 950cdf0e10cSrcweir maThresRes.mnThresPixToLogY ); 951cdf0e10cSrcweir 952cdf0e10cSrcweir // #i75163# 953cdf0e10cSrcweir ImplInvalidateViewTransform(); 954cdf0e10cSrcweir } 955cdf0e10cSrcweir 956cdf0e10cSrcweir // ----------------------------------------------------------------------- 957cdf0e10cSrcweir 958cdf0e10cSrcweir void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode ) 959cdf0e10cSrcweir { 960cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 961cdf0e10cSrcweir 962cdf0e10cSrcweir // Ist der MapMode der gleiche wie vorher, dann mache nichts 963cdf0e10cSrcweir if ( maMapMode == rNewMapMode ) 964cdf0e10cSrcweir return; 965cdf0e10cSrcweir 966cdf0e10cSrcweir MapUnit eOld = maMapMode.GetMapUnit(); 967cdf0e10cSrcweir MapUnit eNew = rNewMapMode.GetMapUnit(); 968cdf0e10cSrcweir 969cdf0e10cSrcweir // a?F = rNewMapMode.GetScale?() / maMapMode.GetScale?() 970cdf0e10cSrcweir Fraction aXF = ImplMakeFraction( rNewMapMode.GetScaleX().GetNumerator(), 971cdf0e10cSrcweir maMapMode.GetScaleX().GetDenominator(), 972cdf0e10cSrcweir rNewMapMode.GetScaleX().GetDenominator(), 973cdf0e10cSrcweir maMapMode.GetScaleX().GetNumerator() ); 974cdf0e10cSrcweir Fraction aYF = ImplMakeFraction( rNewMapMode.GetScaleY().GetNumerator(), 975cdf0e10cSrcweir maMapMode.GetScaleY().GetDenominator(), 976cdf0e10cSrcweir rNewMapMode.GetScaleY().GetDenominator(), 977cdf0e10cSrcweir maMapMode.GetScaleY().GetNumerator() ); 978cdf0e10cSrcweir 979cdf0e10cSrcweir Point aPt( LogicToLogic( Point(), NULL, &rNewMapMode ) ); 980cdf0e10cSrcweir if ( eNew != eOld ) 981cdf0e10cSrcweir { 982cdf0e10cSrcweir if ( eOld > MAP_PIXEL ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir DBG_ERRORFILE( "Not implemented MapUnit" ); 985cdf0e10cSrcweir } 986cdf0e10cSrcweir else if ( eNew > MAP_PIXEL ) 987cdf0e10cSrcweir { 988cdf0e10cSrcweir DBG_ERRORFILE( "Not implemented MapUnit" ); 989cdf0e10cSrcweir } 990cdf0e10cSrcweir else 991cdf0e10cSrcweir { 992cdf0e10cSrcweir Fraction aF( aImplNumeratorAry[eNew] * aImplDenominatorAry[eOld], 993cdf0e10cSrcweir aImplNumeratorAry[eOld] * aImplDenominatorAry[eNew] ); 994cdf0e10cSrcweir 995cdf0e10cSrcweir // a?F = a?F * aF 996cdf0e10cSrcweir aXF = ImplMakeFraction( aXF.GetNumerator(), aF.GetNumerator(), 997cdf0e10cSrcweir aXF.GetDenominator(), aF.GetDenominator() ); 998cdf0e10cSrcweir aYF = ImplMakeFraction( aYF.GetNumerator(), aF.GetNumerator(), 999cdf0e10cSrcweir aYF.GetDenominator(), aF.GetDenominator() ); 1000cdf0e10cSrcweir if ( eOld == MAP_PIXEL ) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir aXF *= Fraction( mnDPIX, 1 ); 1003cdf0e10cSrcweir aYF *= Fraction( mnDPIY, 1 ); 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir else if ( eNew == MAP_PIXEL ) 1006cdf0e10cSrcweir { 1007cdf0e10cSrcweir aXF *= Fraction( 1, mnDPIX ); 1008cdf0e10cSrcweir aYF *= Fraction( 1, mnDPIY ); 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir } 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir MapMode aNewMapMode( MAP_RELATIVE, Point( -aPt.X(), -aPt.Y() ), aXF, aYF ); 1014cdf0e10cSrcweir SetMapMode( aNewMapMode ); 1015cdf0e10cSrcweir 1016cdf0e10cSrcweir if ( eNew != eOld ) 1017cdf0e10cSrcweir maMapMode = rNewMapMode; 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir // #106426# Adapt logical offset when changing mapmode 1020cdf0e10cSrcweir mnOutOffLogicX = ImplPixelToLogic( mnOutOffOrigX, mnDPIX, 1021cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1022cdf0e10cSrcweir maThresRes.mnThresPixToLogX ); 1023cdf0e10cSrcweir mnOutOffLogicY = ImplPixelToLogic( mnOutOffOrigY, mnDPIY, 1024cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1025cdf0e10cSrcweir maThresRes.mnThresPixToLogY ); 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir if( mpAlphaVDev ) 1028cdf0e10cSrcweir mpAlphaVDev->SetRelativeMapMode( rNewMapMode ); 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir 1031cdf0e10cSrcweir // ----------------------------------------------------------------------- 1032cdf0e10cSrcweir 1033cdf0e10cSrcweir // #i75163# 1034cdf0e10cSrcweir basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const 1035cdf0e10cSrcweir { 1036cdf0e10cSrcweir if(mbMap) 1037cdf0e10cSrcweir { 1038cdf0e10cSrcweir // #i82615# 1039cdf0e10cSrcweir if(!mpOutDevData) 1040cdf0e10cSrcweir { 1041cdf0e10cSrcweir const_cast< OutputDevice* >(this)->ImplInitOutDevData(); 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir if(!mpOutDevData->mpViewTransform) 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix; 1047cdf0e10cSrcweir 1048cdf0e10cSrcweir const double fScaleFactorX((double)mnDPIX * (double)maMapRes.mnMapScNumX / (double)maMapRes.mnMapScDenomX); 1049cdf0e10cSrcweir const double fScaleFactorY((double)mnDPIY * (double)maMapRes.mnMapScNumY / (double)maMapRes.mnMapScDenomY); 1050cdf0e10cSrcweir const double fZeroPointX(((double)maMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); 1051cdf0e10cSrcweir const double fZeroPointY(((double)maMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX); 1054cdf0e10cSrcweir mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY); 1055cdf0e10cSrcweir mpOutDevData->mpViewTransform->set(0, 2, fZeroPointX); 1056cdf0e10cSrcweir mpOutDevData->mpViewTransform->set(1, 2, fZeroPointY); 1057cdf0e10cSrcweir } 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir return *mpOutDevData->mpViewTransform; 1060cdf0e10cSrcweir } 1061cdf0e10cSrcweir else 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir return basegfx::B2DHomMatrix(); 1064cdf0e10cSrcweir } 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir // ----------------------------------------------------------------------- 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir // #i75163# 1070cdf0e10cSrcweir basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation() const 1071cdf0e10cSrcweir { 1072cdf0e10cSrcweir if(mbMap) 1073cdf0e10cSrcweir { 1074cdf0e10cSrcweir // #i82615# 1075cdf0e10cSrcweir if(!mpOutDevData) 1076cdf0e10cSrcweir { 1077cdf0e10cSrcweir const_cast< OutputDevice* >(this)->ImplInitOutDevData(); 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir if(!mpOutDevData->mpInverseViewTransform) 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir GetViewTransformation(); 1083cdf0e10cSrcweir mpOutDevData->mpInverseViewTransform = new basegfx::B2DHomMatrix(*mpOutDevData->mpViewTransform); 1084cdf0e10cSrcweir mpOutDevData->mpInverseViewTransform->invert(); 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir return *mpOutDevData->mpInverseViewTransform; 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir else 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir return basegfx::B2DHomMatrix(); 1092cdf0e10cSrcweir } 1093cdf0e10cSrcweir } 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir // ----------------------------------------------------------------------- 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir // #i75163# 1098cdf0e10cSrcweir basegfx::B2DHomMatrix OutputDevice::GetViewTransformation( const MapMode& rMapMode ) const 1099cdf0e10cSrcweir { 1100cdf0e10cSrcweir // #i82615# 1101cdf0e10cSrcweir ImplMapRes aMapRes; 1102cdf0e10cSrcweir ImplThresholdRes aThresRes; 1103cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir basegfx::B2DHomMatrix aTransform; 1106cdf0e10cSrcweir 1107cdf0e10cSrcweir const double fScaleFactorX((double)mnDPIX * (double)aMapRes.mnMapScNumX / (double)aMapRes.mnMapScDenomX); 1108cdf0e10cSrcweir const double fScaleFactorY((double)mnDPIY * (double)aMapRes.mnMapScNumY / (double)aMapRes.mnMapScDenomY); 1109cdf0e10cSrcweir const double fZeroPointX(((double)aMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); 1110cdf0e10cSrcweir const double fZeroPointY(((double)aMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir aTransform.set(0, 0, fScaleFactorX); 1113cdf0e10cSrcweir aTransform.set(1, 1, fScaleFactorY); 1114cdf0e10cSrcweir aTransform.set(0, 2, fZeroPointX); 1115cdf0e10cSrcweir aTransform.set(1, 2, fZeroPointY); 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir return aTransform; 1118cdf0e10cSrcweir } 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir // ----------------------------------------------------------------------- 1121cdf0e10cSrcweir 1122cdf0e10cSrcweir // #i75163# 1123cdf0e10cSrcweir basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation( const MapMode& rMapMode ) const 1124cdf0e10cSrcweir { 1125cdf0e10cSrcweir basegfx::B2DHomMatrix aMatrix( GetViewTransformation( rMapMode ) ); 1126cdf0e10cSrcweir aMatrix.invert(); 1127cdf0e10cSrcweir return aMatrix; 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir // ----------------------------------------------------------------------- 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir basegfx::B2DHomMatrix OutputDevice::ImplGetDeviceTransformation() const 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir basegfx::B2DHomMatrix aTransformation = GetViewTransformation(); 1135cdf0e10cSrcweir // TODO: is it worth to cache the transformed result? 1136cdf0e10cSrcweir if( mnOutOffX || mnOutOffY ) 1137cdf0e10cSrcweir aTransformation.translate( mnOutOffX, mnOutOffY ); 1138cdf0e10cSrcweir return aTransformation; 1139cdf0e10cSrcweir } 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir // ----------------------------------------------------------------------- 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir Point OutputDevice::LogicToPixel( const Point& rLogicPt ) const 1144cdf0e10cSrcweir { 1145cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir if ( !mbMap ) 1148cdf0e10cSrcweir return rLogicPt; 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir return Point( ImplLogicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, mnDPIX, 1151cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1152cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffOrigX, 1153cdf0e10cSrcweir ImplLogicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, mnDPIY, 1154cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1155cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffOrigY ); 1156cdf0e10cSrcweir } 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir // ----------------------------------------------------------------------- 1159cdf0e10cSrcweir 1160cdf0e10cSrcweir Size OutputDevice::LogicToPixel( const Size& rLogicSize ) const 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir if ( !mbMap ) 1165cdf0e10cSrcweir return rLogicSize; 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX, 1168cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1169cdf0e10cSrcweir maThresRes.mnThresLogToPixX ), 1170cdf0e10cSrcweir ImplLogicToPixel( rLogicSize.Height(), mnDPIY, 1171cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1172cdf0e10cSrcweir maThresRes.mnThresLogToPixY ) ); 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir // ----------------------------------------------------------------------- 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir Rectangle OutputDevice::LogicToPixel( const Rectangle& rLogicRect ) const 1178cdf0e10cSrcweir { 1179cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir if ( !mbMap || rLogicRect.IsEmpty() ) 1182cdf0e10cSrcweir return rLogicRect; 1183cdf0e10cSrcweir 1184cdf0e10cSrcweir return Rectangle( ImplLogicToPixel( rLogicRect.Left() + maMapRes.mnMapOfsX, mnDPIX, 1185cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1186cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffOrigX, 1187cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Top() + maMapRes.mnMapOfsY, mnDPIY, 1188cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1189cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffOrigY, 1190cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Right() + maMapRes.mnMapOfsX, mnDPIX, 1191cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1192cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffOrigX, 1193cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Bottom() + maMapRes.mnMapOfsY, mnDPIY, 1194cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1195cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffOrigY ); 1196cdf0e10cSrcweir } 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir // ----------------------------------------------------------------------- 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir Polygon OutputDevice::LogicToPixel( const Polygon& rLogicPoly ) const 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1203cdf0e10cSrcweir DBG_CHKOBJ( &rLogicPoly, Polygon, NULL ); 1204cdf0e10cSrcweir 1205cdf0e10cSrcweir if ( !mbMap ) 1206cdf0e10cSrcweir return rLogicPoly; 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir sal_uInt16 i; 1209cdf0e10cSrcweir sal_uInt16 nPoints = rLogicPoly.GetSize(); 1210cdf0e10cSrcweir Polygon aPoly( rLogicPoly ); 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir // Pointer auf das Point-Array holen (Daten werden kopiert) 1213cdf0e10cSrcweir const Point* pPointAry = aPoly.GetConstPointAry(); 1214cdf0e10cSrcweir 1215cdf0e10cSrcweir for ( i = 0; i < nPoints; i++ ) 1216cdf0e10cSrcweir { 1217cdf0e10cSrcweir const Point* pPt = &(pPointAry[i]); 1218cdf0e10cSrcweir Point aPt; 1219cdf0e10cSrcweir aPt.X() = ImplLogicToPixel( pPt->X() + maMapRes.mnMapOfsX, mnDPIX, 1220cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1221cdf0e10cSrcweir maThresRes.mnThresLogToPixX )+mnOutOffOrigX; 1222cdf0e10cSrcweir aPt.Y() = ImplLogicToPixel( pPt->Y() + maMapRes.mnMapOfsY, mnDPIY, 1223cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1224cdf0e10cSrcweir maThresRes.mnThresLogToPixY )+mnOutOffOrigY; 1225cdf0e10cSrcweir aPoly[i] = aPt; 1226cdf0e10cSrcweir } 1227cdf0e10cSrcweir 1228cdf0e10cSrcweir return aPoly; 1229cdf0e10cSrcweir } 1230cdf0e10cSrcweir 1231cdf0e10cSrcweir // ----------------------------------------------------------------------- 1232cdf0e10cSrcweir 1233cdf0e10cSrcweir PolyPolygon OutputDevice::LogicToPixel( const PolyPolygon& rLogicPolyPoly ) const 1234cdf0e10cSrcweir { 1235cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1236cdf0e10cSrcweir DBG_CHKOBJ( &rLogicPolyPoly, PolyPolygon, NULL ); 1237cdf0e10cSrcweir 1238cdf0e10cSrcweir if ( !mbMap ) 1239cdf0e10cSrcweir return rLogicPolyPoly; 1240cdf0e10cSrcweir 1241cdf0e10cSrcweir PolyPolygon aPolyPoly( rLogicPolyPoly ); 1242cdf0e10cSrcweir sal_uInt16 nPoly = aPolyPoly.Count(); 1243cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nPoly; i++ ) 1244cdf0e10cSrcweir { 1245cdf0e10cSrcweir Polygon& rPoly = aPolyPoly[i]; 1246cdf0e10cSrcweir rPoly = LogicToPixel( rPoly ); 1247cdf0e10cSrcweir } 1248cdf0e10cSrcweir return aPolyPoly; 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir 1251cdf0e10cSrcweir // ----------------------------------------------------------------------- 1252cdf0e10cSrcweir 1253cdf0e10cSrcweir basegfx::B2DPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolygon& rLogicPoly ) const 1254cdf0e10cSrcweir { 1255cdf0e10cSrcweir basegfx::B2DPolygon aTransformedPoly = rLogicPoly; 1256cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation(); 1257cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1258cdf0e10cSrcweir return aTransformedPoly; 1259cdf0e10cSrcweir } 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir // ----------------------------------------------------------------------- 1262cdf0e10cSrcweir 1263cdf0e10cSrcweir basegfx::B2DPolyPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const 1264cdf0e10cSrcweir { 1265cdf0e10cSrcweir basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly; 1266cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation(); 1267cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1268cdf0e10cSrcweir return aTransformedPoly; 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir 1271cdf0e10cSrcweir // ----------------------------------------------------------------------- 1272cdf0e10cSrcweir 1273cdf0e10cSrcweir Region OutputDevice::LogicToPixel( const Region& rLogicRegion ) const 1274cdf0e10cSrcweir { 1275cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1276cdf0e10cSrcweir DBG_CHKOBJ( &rLogicRegion, Region, ImplDbgTestRegion ); 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir RegionType eType = rLogicRegion.GetType(); 1279cdf0e10cSrcweir 1280cdf0e10cSrcweir if ( !mbMap || (eType == REGION_EMPTY) || (eType == REGION_NULL) ) 1281cdf0e10cSrcweir return rLogicRegion; 1282cdf0e10cSrcweir 1283cdf0e10cSrcweir Region aRegion; 1284cdf0e10cSrcweir const ImplRegion& rImplRegion = *rLogicRegion.ImplGetImplRegion(); 1285cdf0e10cSrcweir const PolyPolygon* pPolyPoly = rImplRegion.mpPolyPoly; 1286cdf0e10cSrcweir const basegfx::B2DPolyPolygon* pB2DPolyPoly = rImplRegion.mpB2DPolyPoly; 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir if ( pPolyPoly ) 1289cdf0e10cSrcweir aRegion = Region( LogicToPixel( *pPolyPoly ) ); 1290cdf0e10cSrcweir else if( pB2DPolyPoly ) 1291cdf0e10cSrcweir { 1292cdf0e10cSrcweir basegfx::B2DPolyPolygon aTransformedPoly = *pB2DPolyPoly; 1293cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation(); 1294cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1295cdf0e10cSrcweir aRegion = Region( aTransformedPoly ); 1296cdf0e10cSrcweir } 1297cdf0e10cSrcweir else 1298cdf0e10cSrcweir { 1299cdf0e10cSrcweir long nX; 1300cdf0e10cSrcweir long nY; 1301cdf0e10cSrcweir long nWidth; 1302cdf0e10cSrcweir long nHeight; 1303cdf0e10cSrcweir ImplRegionInfo aInfo; 1304cdf0e10cSrcweir sal_Bool bRegionRect; 1305cdf0e10cSrcweir 1306cdf0e10cSrcweir aRegion.ImplBeginAddRect(); 1307cdf0e10cSrcweir bRegionRect = rLogicRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 1308cdf0e10cSrcweir while ( bRegionRect ) 1309cdf0e10cSrcweir { 1310cdf0e10cSrcweir Rectangle aRect( Point( nX, nY ), Size( nWidth, nHeight ) ); 1311cdf0e10cSrcweir aRegion.ImplAddRect( LogicToPixel( aRect ) ); 1312cdf0e10cSrcweir bRegionRect = rLogicRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir aRegion.ImplEndAddRect(); 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir return aRegion; 1318cdf0e10cSrcweir } 1319cdf0e10cSrcweir 1320cdf0e10cSrcweir // ----------------------------------------------------------------------- 1321cdf0e10cSrcweir 1322cdf0e10cSrcweir Point OutputDevice::LogicToPixel( const Point& rLogicPt, 1323cdf0e10cSrcweir const MapMode& rMapMode ) const 1324cdf0e10cSrcweir { 1325cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1326cdf0e10cSrcweir 1327cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1328cdf0e10cSrcweir return rLogicPt; 1329cdf0e10cSrcweir 1330cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1331cdf0e10cSrcweir ImplMapRes aMapRes; 1332cdf0e10cSrcweir ImplThresholdRes aThresRes; 1333cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir return Point( ImplLogicToPixel( rLogicPt.X() + aMapRes.mnMapOfsX, mnDPIX, 1336cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1337cdf0e10cSrcweir aThresRes.mnThresLogToPixX )+mnOutOffOrigX, 1338cdf0e10cSrcweir ImplLogicToPixel( rLogicPt.Y() + aMapRes.mnMapOfsY, mnDPIY, 1339cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1340cdf0e10cSrcweir aThresRes.mnThresLogToPixY )+mnOutOffOrigY ); 1341cdf0e10cSrcweir } 1342cdf0e10cSrcweir 1343cdf0e10cSrcweir // ----------------------------------------------------------------------- 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir Size OutputDevice::LogicToPixel( const Size& rLogicSize, 1346cdf0e10cSrcweir const MapMode& rMapMode ) const 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1349cdf0e10cSrcweir 1350cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1351cdf0e10cSrcweir return rLogicSize; 1352cdf0e10cSrcweir 1353cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1354cdf0e10cSrcweir ImplMapRes aMapRes; 1355cdf0e10cSrcweir ImplThresholdRes aThresRes; 1356cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1357cdf0e10cSrcweir 1358cdf0e10cSrcweir return Size( ImplLogicToPixel( rLogicSize.Width(), mnDPIX, 1359cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1360cdf0e10cSrcweir aThresRes.mnThresLogToPixX ), 1361cdf0e10cSrcweir ImplLogicToPixel( rLogicSize.Height(), mnDPIY, 1362cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1363cdf0e10cSrcweir aThresRes.mnThresLogToPixY ) ); 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir 1366cdf0e10cSrcweir // ----------------------------------------------------------------------- 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir Rectangle OutputDevice::LogicToPixel( const Rectangle& rLogicRect, 1369cdf0e10cSrcweir const MapMode& rMapMode ) const 1370cdf0e10cSrcweir { 1371cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1372cdf0e10cSrcweir 1373cdf0e10cSrcweir if ( rMapMode.IsDefault() || rLogicRect.IsEmpty() ) 1374cdf0e10cSrcweir return rLogicRect; 1375cdf0e10cSrcweir 1376cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1377cdf0e10cSrcweir ImplMapRes aMapRes; 1378cdf0e10cSrcweir ImplThresholdRes aThresRes; 1379cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1380cdf0e10cSrcweir 1381cdf0e10cSrcweir return Rectangle( ImplLogicToPixel( rLogicRect.Left() + aMapRes.mnMapOfsX, mnDPIX, 1382cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1383cdf0e10cSrcweir aThresRes.mnThresLogToPixX )+mnOutOffOrigX, 1384cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Top() + aMapRes.mnMapOfsY, mnDPIY, 1385cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1386cdf0e10cSrcweir aThresRes.mnThresLogToPixY )+mnOutOffOrigY, 1387cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Right() + aMapRes.mnMapOfsX, mnDPIX, 1388cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1389cdf0e10cSrcweir aThresRes.mnThresLogToPixX )+mnOutOffOrigX, 1390cdf0e10cSrcweir ImplLogicToPixel( rLogicRect.Bottom() + aMapRes.mnMapOfsY, mnDPIY, 1391cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1392cdf0e10cSrcweir aThresRes.mnThresLogToPixY )+mnOutOffOrigY ); 1393cdf0e10cSrcweir } 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir // ----------------------------------------------------------------------- 1396cdf0e10cSrcweir 1397cdf0e10cSrcweir Polygon OutputDevice::LogicToPixel( const Polygon& rLogicPoly, 1398cdf0e10cSrcweir const MapMode& rMapMode ) const 1399cdf0e10cSrcweir { 1400cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1401cdf0e10cSrcweir DBG_CHKOBJ( &rLogicPoly, Polygon, NULL ); 1402cdf0e10cSrcweir 1403cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1404cdf0e10cSrcweir return rLogicPoly; 1405cdf0e10cSrcweir 1406cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1407cdf0e10cSrcweir ImplMapRes aMapRes; 1408cdf0e10cSrcweir ImplThresholdRes aThresRes; 1409cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1410cdf0e10cSrcweir 1411cdf0e10cSrcweir sal_uInt16 i; 1412cdf0e10cSrcweir sal_uInt16 nPoints = rLogicPoly.GetSize(); 1413cdf0e10cSrcweir Polygon aPoly( rLogicPoly ); 1414cdf0e10cSrcweir 1415cdf0e10cSrcweir // Pointer auf das Point-Array holen (Daten werden kopiert) 1416cdf0e10cSrcweir const Point* pPointAry = aPoly.GetConstPointAry(); 1417cdf0e10cSrcweir 1418cdf0e10cSrcweir for ( i = 0; i < nPoints; i++ ) 1419cdf0e10cSrcweir { 1420cdf0e10cSrcweir const Point* pPt = &(pPointAry[i]); 1421cdf0e10cSrcweir Point aPt; 1422cdf0e10cSrcweir aPt.X() = ImplLogicToPixel( pPt->X() + aMapRes.mnMapOfsX, mnDPIX, 1423cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1424cdf0e10cSrcweir aThresRes.mnThresLogToPixX )+mnOutOffOrigX; 1425cdf0e10cSrcweir aPt.Y() = ImplLogicToPixel( pPt->Y() + aMapRes.mnMapOfsY, mnDPIY, 1426cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1427cdf0e10cSrcweir aThresRes.mnThresLogToPixY )+mnOutOffOrigY; 1428cdf0e10cSrcweir aPoly[i] = aPt; 1429cdf0e10cSrcweir } 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir return aPoly; 1432cdf0e10cSrcweir } 1433cdf0e10cSrcweir 1434cdf0e10cSrcweir // ----------------------------------------------------------------------- 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir PolyPolygon OutputDevice::LogicToPixel( const PolyPolygon& rLogicPolyPoly, 1437cdf0e10cSrcweir const MapMode& rMapMode ) const 1438cdf0e10cSrcweir { 1439cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1440cdf0e10cSrcweir DBG_CHKOBJ( &rLogicPolyPoly, PolyPolygon, NULL ); 1441cdf0e10cSrcweir 1442cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1443cdf0e10cSrcweir return rLogicPolyPoly; 1444cdf0e10cSrcweir 1445cdf0e10cSrcweir PolyPolygon aPolyPoly( rLogicPolyPoly ); 1446cdf0e10cSrcweir sal_uInt16 nPoly = aPolyPoly.Count(); 1447cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nPoly; i++ ) 1448cdf0e10cSrcweir { 1449cdf0e10cSrcweir Polygon& rPoly = aPolyPoly[i]; 1450cdf0e10cSrcweir rPoly = LogicToPixel( rPoly, rMapMode ); 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir return aPolyPoly; 1453cdf0e10cSrcweir } 1454cdf0e10cSrcweir 1455cdf0e10cSrcweir // ----------------------------------------------------------------------- 1456cdf0e10cSrcweir 1457cdf0e10cSrcweir basegfx::B2DPolyPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, 1458cdf0e10cSrcweir const MapMode& rMapMode ) const 1459cdf0e10cSrcweir { 1460cdf0e10cSrcweir basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly; 1461cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode ); 1462cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1463cdf0e10cSrcweir return aTransformedPoly; 1464cdf0e10cSrcweir } 1465cdf0e10cSrcweir 1466cdf0e10cSrcweir // ----------------------------------------------------------------------- 1467cdf0e10cSrcweir 1468cdf0e10cSrcweir basegfx::B2DPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolygon& rLogicPoly, 1469cdf0e10cSrcweir const MapMode& rMapMode ) const 1470cdf0e10cSrcweir { 1471cdf0e10cSrcweir basegfx::B2DPolygon aTransformedPoly = rLogicPoly; 1472cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode ); 1473cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1474cdf0e10cSrcweir return aTransformedPoly; 1475cdf0e10cSrcweir } 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir // ----------------------------------------------------------------------- 1478cdf0e10cSrcweir 1479cdf0e10cSrcweir Region OutputDevice::LogicToPixel( const Region& rLogicRegion, 1480cdf0e10cSrcweir const MapMode& rMapMode ) const 1481cdf0e10cSrcweir { 1482cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1483cdf0e10cSrcweir DBG_CHKOBJ( &rLogicRegion, Region, ImplDbgTestRegion ); 1484cdf0e10cSrcweir 1485cdf0e10cSrcweir RegionType eType = rLogicRegion.GetType(); 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir if ( rMapMode.IsDefault() || (eType == REGION_EMPTY) || (eType == REGION_NULL) ) 1488cdf0e10cSrcweir return rLogicRegion; 1489cdf0e10cSrcweir 1490cdf0e10cSrcweir Region aRegion; 1491cdf0e10cSrcweir PolyPolygon* pPolyPoly = rLogicRegion.ImplGetImplRegion()->mpPolyPoly; 1492cdf0e10cSrcweir 1493cdf0e10cSrcweir if( pPolyPoly ) 1494cdf0e10cSrcweir aRegion = Region( LogicToPixel( *pPolyPoly, rMapMode ) ); 1495cdf0e10cSrcweir else 1496cdf0e10cSrcweir { 1497cdf0e10cSrcweir long nX; 1498cdf0e10cSrcweir long nY; 1499cdf0e10cSrcweir long nWidth; 1500cdf0e10cSrcweir long nHeight; 1501cdf0e10cSrcweir ImplRegionInfo aInfo; 1502cdf0e10cSrcweir sal_Bool bRegionRect; 1503cdf0e10cSrcweir 1504cdf0e10cSrcweir aRegion.ImplBeginAddRect(); 1505cdf0e10cSrcweir bRegionRect = rLogicRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 1506cdf0e10cSrcweir while ( bRegionRect ) 1507cdf0e10cSrcweir { 1508cdf0e10cSrcweir Rectangle aRect( Point( nX, nY ), Size( nWidth, nHeight ) ); 1509cdf0e10cSrcweir aRegion.ImplAddRect( LogicToPixel( aRect, rMapMode ) ); 1510cdf0e10cSrcweir bRegionRect = rLogicRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 1511cdf0e10cSrcweir } 1512cdf0e10cSrcweir aRegion.ImplEndAddRect(); 1513cdf0e10cSrcweir } 1514cdf0e10cSrcweir 1515cdf0e10cSrcweir return aRegion; 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir // ----------------------------------------------------------------------- 1519cdf0e10cSrcweir 1520cdf0e10cSrcweir Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const 1521cdf0e10cSrcweir { 1522cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir if ( !mbMap ) 1525cdf0e10cSrcweir return rDevicePt; 1526cdf0e10cSrcweir 1527cdf0e10cSrcweir return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX, 1528cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1529cdf0e10cSrcweir maThresRes.mnThresPixToLogX ) - maMapRes.mnMapOfsX - mnOutOffLogicX, 1530cdf0e10cSrcweir ImplPixelToLogic( rDevicePt.Y(), mnDPIY, 1531cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1532cdf0e10cSrcweir maThresRes.mnThresPixToLogY ) - maMapRes.mnMapOfsY - mnOutOffLogicY ); 1533cdf0e10cSrcweir } 1534cdf0e10cSrcweir 1535cdf0e10cSrcweir // ----------------------------------------------------------------------- 1536cdf0e10cSrcweir 1537cdf0e10cSrcweir Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const 1538cdf0e10cSrcweir { 1539cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1540cdf0e10cSrcweir 1541cdf0e10cSrcweir if ( !mbMap ) 1542cdf0e10cSrcweir return rDeviceSize; 1543cdf0e10cSrcweir 1544cdf0e10cSrcweir return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX, 1545cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1546cdf0e10cSrcweir maThresRes.mnThresPixToLogX ), 1547cdf0e10cSrcweir ImplPixelToLogic( rDeviceSize.Height(), mnDPIY, 1548cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1549cdf0e10cSrcweir maThresRes.mnThresPixToLogY ) ); 1550cdf0e10cSrcweir } 1551cdf0e10cSrcweir 1552cdf0e10cSrcweir // ----------------------------------------------------------------------- 1553cdf0e10cSrcweir 1554cdf0e10cSrcweir Rectangle OutputDevice::PixelToLogic( const Rectangle& rDeviceRect ) const 1555cdf0e10cSrcweir { 1556cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir if ( !mbMap || rDeviceRect.IsEmpty() ) 1559cdf0e10cSrcweir return rDeviceRect; 1560cdf0e10cSrcweir 1561cdf0e10cSrcweir return Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX, 1562cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1563cdf0e10cSrcweir maThresRes.mnThresPixToLogX ) - maMapRes.mnMapOfsX - mnOutOffLogicX, 1564cdf0e10cSrcweir ImplPixelToLogic( rDeviceRect.Top(), mnDPIY, 1565cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1566cdf0e10cSrcweir maThresRes.mnThresPixToLogY ) - maMapRes.mnMapOfsY - mnOutOffLogicY, 1567cdf0e10cSrcweir ImplPixelToLogic( rDeviceRect.Right(), mnDPIX, 1568cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1569cdf0e10cSrcweir maThresRes.mnThresPixToLogX ) - maMapRes.mnMapOfsX - mnOutOffLogicX, 1570cdf0e10cSrcweir ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY, 1571cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1572cdf0e10cSrcweir maThresRes.mnThresPixToLogY ) - maMapRes.mnMapOfsY - mnOutOffLogicY ); 1573cdf0e10cSrcweir } 1574cdf0e10cSrcweir 1575cdf0e10cSrcweir // ----------------------------------------------------------------------- 1576cdf0e10cSrcweir 1577cdf0e10cSrcweir Polygon OutputDevice::PixelToLogic( const Polygon& rDevicePoly ) const 1578cdf0e10cSrcweir { 1579cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1580cdf0e10cSrcweir DBG_CHKOBJ( &rDevicePoly, Polygon, NULL ); 1581cdf0e10cSrcweir 1582cdf0e10cSrcweir if ( !mbMap ) 1583cdf0e10cSrcweir return rDevicePoly; 1584cdf0e10cSrcweir 1585cdf0e10cSrcweir sal_uInt16 i; 1586cdf0e10cSrcweir sal_uInt16 nPoints = rDevicePoly.GetSize(); 1587cdf0e10cSrcweir Polygon aPoly( rDevicePoly ); 1588cdf0e10cSrcweir 1589cdf0e10cSrcweir // Pointer auf das Point-Array holen (Daten werden kopiert) 1590cdf0e10cSrcweir const Point* pPointAry = aPoly.GetConstPointAry(); 1591cdf0e10cSrcweir 1592cdf0e10cSrcweir for ( i = 0; i < nPoints; i++ ) 1593cdf0e10cSrcweir { 1594cdf0e10cSrcweir const Point* pPt = &(pPointAry[i]); 1595cdf0e10cSrcweir Point aPt; 1596cdf0e10cSrcweir aPt.X() = ImplPixelToLogic( pPt->X(), mnDPIX, 1597cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 1598cdf0e10cSrcweir maThresRes.mnThresPixToLogX ) - maMapRes.mnMapOfsX - mnOutOffLogicX; 1599cdf0e10cSrcweir aPt.Y() = ImplPixelToLogic( pPt->Y(), mnDPIY, 1600cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 1601cdf0e10cSrcweir maThresRes.mnThresPixToLogY ) - maMapRes.mnMapOfsY - mnOutOffLogicY; 1602cdf0e10cSrcweir aPoly[i] = aPt; 1603cdf0e10cSrcweir } 1604cdf0e10cSrcweir 1605cdf0e10cSrcweir return aPoly; 1606cdf0e10cSrcweir } 1607cdf0e10cSrcweir 1608cdf0e10cSrcweir // ----------------------------------------------------------------------- 1609cdf0e10cSrcweir 1610cdf0e10cSrcweir PolyPolygon OutputDevice::PixelToLogic( const PolyPolygon& rDevicePolyPoly ) const 1611cdf0e10cSrcweir { 1612cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1613cdf0e10cSrcweir DBG_CHKOBJ( &rDevicePolyPoly, PolyPolygon, NULL ); 1614cdf0e10cSrcweir 1615cdf0e10cSrcweir if ( !mbMap ) 1616cdf0e10cSrcweir return rDevicePolyPoly; 1617cdf0e10cSrcweir 1618cdf0e10cSrcweir PolyPolygon aPolyPoly( rDevicePolyPoly ); 1619cdf0e10cSrcweir sal_uInt16 nPoly = aPolyPoly.Count(); 1620cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nPoly; i++ ) 1621cdf0e10cSrcweir { 1622cdf0e10cSrcweir Polygon& rPoly = aPolyPoly[i]; 1623cdf0e10cSrcweir rPoly = PixelToLogic( rPoly ); 1624cdf0e10cSrcweir } 1625cdf0e10cSrcweir return aPolyPoly; 1626cdf0e10cSrcweir } 1627cdf0e10cSrcweir 1628cdf0e10cSrcweir // ----------------------------------------------------------------------- 1629cdf0e10cSrcweir 1630cdf0e10cSrcweir basegfx::B2DPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolygon& rPixelPoly ) const 1631cdf0e10cSrcweir { 1632cdf0e10cSrcweir basegfx::B2DPolygon aTransformedPoly = rPixelPoly; 1633cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation(); 1634cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1635cdf0e10cSrcweir return aTransformedPoly; 1636cdf0e10cSrcweir } 1637cdf0e10cSrcweir 1638cdf0e10cSrcweir // ----------------------------------------------------------------------- 1639cdf0e10cSrcweir 1640cdf0e10cSrcweir basegfx::B2DPolyPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolyPolygon& rPixelPolyPoly ) const 1641cdf0e10cSrcweir { 1642cdf0e10cSrcweir basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly; 1643cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation(); 1644cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1645cdf0e10cSrcweir return aTransformedPoly; 1646cdf0e10cSrcweir } 1647cdf0e10cSrcweir 1648cdf0e10cSrcweir // ----------------------------------------------------------------------- 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir Region OutputDevice::PixelToLogic( const Region& rDeviceRegion ) const 1651cdf0e10cSrcweir { 1652cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1653cdf0e10cSrcweir DBG_CHKOBJ( &rDeviceRegion, Region, ImplDbgTestRegion ); 1654cdf0e10cSrcweir 1655cdf0e10cSrcweir RegionType eType = rDeviceRegion.GetType(); 1656cdf0e10cSrcweir 1657cdf0e10cSrcweir if ( !mbMap || (eType == REGION_EMPTY) || (eType == REGION_NULL) ) 1658cdf0e10cSrcweir return rDeviceRegion; 1659cdf0e10cSrcweir 1660cdf0e10cSrcweir Region aRegion; 1661cdf0e10cSrcweir PolyPolygon* pPolyPoly = rDeviceRegion.ImplGetImplRegion()->mpPolyPoly; 1662cdf0e10cSrcweir 1663cdf0e10cSrcweir if ( pPolyPoly ) 1664cdf0e10cSrcweir aRegion = Region( PixelToLogic( *pPolyPoly ) ); 1665cdf0e10cSrcweir else 1666cdf0e10cSrcweir { 1667cdf0e10cSrcweir long nX; 1668cdf0e10cSrcweir long nY; 1669cdf0e10cSrcweir long nWidth; 1670cdf0e10cSrcweir long nHeight; 1671cdf0e10cSrcweir ImplRegionInfo aInfo; 1672cdf0e10cSrcweir sal_Bool bRegionRect; 1673cdf0e10cSrcweir 1674cdf0e10cSrcweir aRegion.ImplBeginAddRect(); 1675cdf0e10cSrcweir bRegionRect = rDeviceRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 1676cdf0e10cSrcweir while ( bRegionRect ) 1677cdf0e10cSrcweir { 1678cdf0e10cSrcweir Rectangle aRect( Point( nX, nY ), Size( nWidth, nHeight ) ); 1679cdf0e10cSrcweir aRegion.ImplAddRect( PixelToLogic( aRect ) ); 1680cdf0e10cSrcweir bRegionRect = rDeviceRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir aRegion.ImplEndAddRect(); 1683cdf0e10cSrcweir } 1684cdf0e10cSrcweir 1685cdf0e10cSrcweir return aRegion; 1686cdf0e10cSrcweir } 1687cdf0e10cSrcweir 1688cdf0e10cSrcweir // ----------------------------------------------------------------------- 1689cdf0e10cSrcweir 1690cdf0e10cSrcweir Point OutputDevice::PixelToLogic( const Point& rDevicePt, 1691cdf0e10cSrcweir const MapMode& rMapMode ) const 1692cdf0e10cSrcweir { 1693cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1694cdf0e10cSrcweir 1695cdf0e10cSrcweir // Ist Default-MapMode, dann bereche nichts 1696cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1697cdf0e10cSrcweir return rDevicePt; 1698cdf0e10cSrcweir 1699cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1700cdf0e10cSrcweir ImplMapRes aMapRes; 1701cdf0e10cSrcweir ImplThresholdRes aThresRes; 1702cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir return Point( ImplPixelToLogic( rDevicePt.X(), mnDPIX, 1705cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1706cdf0e10cSrcweir aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX, 1707cdf0e10cSrcweir ImplPixelToLogic( rDevicePt.Y(), mnDPIY, 1708cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1709cdf0e10cSrcweir aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY ); 1710cdf0e10cSrcweir } 1711cdf0e10cSrcweir 1712cdf0e10cSrcweir // ----------------------------------------------------------------------- 1713cdf0e10cSrcweir 1714cdf0e10cSrcweir Size OutputDevice::PixelToLogic( const Size& rDeviceSize, 1715cdf0e10cSrcweir const MapMode& rMapMode ) const 1716cdf0e10cSrcweir { 1717cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1718cdf0e10cSrcweir 1719cdf0e10cSrcweir // Ist Default-MapMode, dann bereche nichts 1720cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1721cdf0e10cSrcweir return rDeviceSize; 1722cdf0e10cSrcweir 1723cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1724cdf0e10cSrcweir ImplMapRes aMapRes; 1725cdf0e10cSrcweir ImplThresholdRes aThresRes; 1726cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir return Size( ImplPixelToLogic( rDeviceSize.Width(), mnDPIX, 1729cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1730cdf0e10cSrcweir aThresRes.mnThresPixToLogX ), 1731cdf0e10cSrcweir ImplPixelToLogic( rDeviceSize.Height(), mnDPIY, 1732cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1733cdf0e10cSrcweir aThresRes.mnThresPixToLogY ) ); 1734cdf0e10cSrcweir } 1735cdf0e10cSrcweir 1736cdf0e10cSrcweir // ----------------------------------------------------------------------- 1737cdf0e10cSrcweir 1738cdf0e10cSrcweir Rectangle OutputDevice::PixelToLogic( const Rectangle& rDeviceRect, 1739cdf0e10cSrcweir const MapMode& rMapMode ) const 1740cdf0e10cSrcweir { 1741cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1742cdf0e10cSrcweir 1743cdf0e10cSrcweir // Ist Default-MapMode, dann bereche nichts 1744cdf0e10cSrcweir if ( rMapMode.IsDefault() || rDeviceRect.IsEmpty() ) 1745cdf0e10cSrcweir return rDeviceRect; 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1748cdf0e10cSrcweir ImplMapRes aMapRes; 1749cdf0e10cSrcweir ImplThresholdRes aThresRes; 1750cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1751cdf0e10cSrcweir 1752cdf0e10cSrcweir return Rectangle( ImplPixelToLogic( rDeviceRect.Left(), mnDPIX, 1753cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1754cdf0e10cSrcweir aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX, 1755cdf0e10cSrcweir ImplPixelToLogic( rDeviceRect.Top(), mnDPIY, 1756cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1757cdf0e10cSrcweir aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY, 1758cdf0e10cSrcweir ImplPixelToLogic( rDeviceRect.Right(), mnDPIX, 1759cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1760cdf0e10cSrcweir aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX, 1761cdf0e10cSrcweir ImplPixelToLogic( rDeviceRect.Bottom(), mnDPIY, 1762cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1763cdf0e10cSrcweir aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY ); 1764cdf0e10cSrcweir } 1765cdf0e10cSrcweir 1766cdf0e10cSrcweir // ----------------------------------------------------------------------- 1767cdf0e10cSrcweir 1768cdf0e10cSrcweir Polygon OutputDevice::PixelToLogic( const Polygon& rDevicePoly, 1769cdf0e10cSrcweir const MapMode& rMapMode ) const 1770cdf0e10cSrcweir { 1771cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1772cdf0e10cSrcweir DBG_CHKOBJ( &rDevicePoly, Polygon, NULL ); 1773cdf0e10cSrcweir 1774cdf0e10cSrcweir // Ist Default-MapMode, dann bereche nichts 1775cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1776cdf0e10cSrcweir return rDevicePoly; 1777cdf0e10cSrcweir 1778cdf0e10cSrcweir // MapMode-Aufloesung berechnen und Umrechnen 1779cdf0e10cSrcweir ImplMapRes aMapRes; 1780cdf0e10cSrcweir ImplThresholdRes aThresRes; 1781cdf0e10cSrcweir ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); 1782cdf0e10cSrcweir 1783cdf0e10cSrcweir sal_uInt16 i; 1784cdf0e10cSrcweir sal_uInt16 nPoints = rDevicePoly.GetSize(); 1785cdf0e10cSrcweir Polygon aPoly( rDevicePoly ); 1786cdf0e10cSrcweir 1787cdf0e10cSrcweir // Pointer auf das Point-Array holen (Daten werden kopiert) 1788cdf0e10cSrcweir const Point* pPointAry = aPoly.GetConstPointAry(); 1789cdf0e10cSrcweir 1790cdf0e10cSrcweir for ( i = 0; i < nPoints; i++ ) 1791cdf0e10cSrcweir { 1792cdf0e10cSrcweir const Point* pPt = &(pPointAry[i]); 1793cdf0e10cSrcweir Point aPt; 1794cdf0e10cSrcweir aPt.X() = ImplPixelToLogic( pPt->X(), mnDPIX, 1795cdf0e10cSrcweir aMapRes.mnMapScNumX, aMapRes.mnMapScDenomX, 1796cdf0e10cSrcweir aThresRes.mnThresPixToLogX ) - aMapRes.mnMapOfsX - mnOutOffLogicX; 1797cdf0e10cSrcweir aPt.Y() = ImplPixelToLogic( pPt->Y(), mnDPIY, 1798cdf0e10cSrcweir aMapRes.mnMapScNumY, aMapRes.mnMapScDenomY, 1799cdf0e10cSrcweir aThresRes.mnThresPixToLogY ) - aMapRes.mnMapOfsY - mnOutOffLogicY; 1800cdf0e10cSrcweir aPoly[i] = aPt; 1801cdf0e10cSrcweir } 1802cdf0e10cSrcweir 1803cdf0e10cSrcweir return aPoly; 1804cdf0e10cSrcweir } 1805cdf0e10cSrcweir 1806cdf0e10cSrcweir // ----------------------------------------------------------------------- 1807cdf0e10cSrcweir 1808cdf0e10cSrcweir PolyPolygon OutputDevice::PixelToLogic( const PolyPolygon& rDevicePolyPoly, 1809cdf0e10cSrcweir const MapMode& rMapMode ) const 1810cdf0e10cSrcweir { 1811cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1812cdf0e10cSrcweir DBG_CHKOBJ( &rDevicePolyPoly, PolyPolygon, NULL ); 1813cdf0e10cSrcweir 1814cdf0e10cSrcweir if ( rMapMode.IsDefault() ) 1815cdf0e10cSrcweir return rDevicePolyPoly; 1816cdf0e10cSrcweir 1817cdf0e10cSrcweir PolyPolygon aPolyPoly( rDevicePolyPoly ); 1818cdf0e10cSrcweir sal_uInt16 nPoly = aPolyPoly.Count(); 1819cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nPoly; i++ ) 1820cdf0e10cSrcweir { 1821cdf0e10cSrcweir Polygon& rPoly = aPolyPoly[i]; 1822cdf0e10cSrcweir rPoly = PixelToLogic( rPoly, rMapMode ); 1823cdf0e10cSrcweir } 1824cdf0e10cSrcweir return aPolyPoly; 1825cdf0e10cSrcweir } 1826cdf0e10cSrcweir 1827cdf0e10cSrcweir // ----------------------------------------------------------------------- 1828cdf0e10cSrcweir 1829cdf0e10cSrcweir basegfx::B2DPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolygon& rPixelPoly, 1830cdf0e10cSrcweir const MapMode& rMapMode ) const 1831cdf0e10cSrcweir { 1832cdf0e10cSrcweir basegfx::B2DPolygon aTransformedPoly = rPixelPoly; 1833cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode ); 1834cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1835cdf0e10cSrcweir return aTransformedPoly; 1836cdf0e10cSrcweir } 1837cdf0e10cSrcweir 1838cdf0e10cSrcweir // ----------------------------------------------------------------------- 1839cdf0e10cSrcweir 1840cdf0e10cSrcweir basegfx::B2DPolyPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolyPolygon& rPixelPolyPoly, 1841cdf0e10cSrcweir const MapMode& rMapMode ) const 1842cdf0e10cSrcweir { 1843cdf0e10cSrcweir basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly; 1844cdf0e10cSrcweir const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode ); 1845cdf0e10cSrcweir aTransformedPoly.transform( rTransformationMatrix ); 1846cdf0e10cSrcweir return aTransformedPoly; 1847cdf0e10cSrcweir } 1848cdf0e10cSrcweir 1849cdf0e10cSrcweir // ----------------------------------------------------------------------- 1850cdf0e10cSrcweir 1851cdf0e10cSrcweir Region OutputDevice::PixelToLogic( const Region& rDeviceRegion, 1852cdf0e10cSrcweir const MapMode& rMapMode ) const 1853cdf0e10cSrcweir { 1854cdf0e10cSrcweir DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); 1855cdf0e10cSrcweir DBG_CHKOBJ( &rDeviceRegion, Region, ImplDbgTestRegion ); 1856cdf0e10cSrcweir 1857cdf0e10cSrcweir RegionType eType = rDeviceRegion.GetType(); 1858cdf0e10cSrcweir 1859cdf0e10cSrcweir if ( rMapMode.IsDefault() || (eType == REGION_EMPTY) || (eType == REGION_NULL) ) 1860cdf0e10cSrcweir return rDeviceRegion; 1861cdf0e10cSrcweir 1862cdf0e10cSrcweir Region aRegion; 1863cdf0e10cSrcweir PolyPolygon* pPolyPoly = rDeviceRegion.ImplGetImplRegion()->mpPolyPoly; 1864cdf0e10cSrcweir 1865cdf0e10cSrcweir if ( pPolyPoly ) 1866cdf0e10cSrcweir aRegion = Region( PixelToLogic( *pPolyPoly, rMapMode ) ); 1867cdf0e10cSrcweir else 1868cdf0e10cSrcweir { 1869cdf0e10cSrcweir long nX; 1870cdf0e10cSrcweir long nY; 1871cdf0e10cSrcweir long nWidth; 1872cdf0e10cSrcweir long nHeight; 1873cdf0e10cSrcweir ImplRegionInfo aInfo; 1874cdf0e10cSrcweir sal_Bool bRegionRect; 1875cdf0e10cSrcweir 1876cdf0e10cSrcweir aRegion.ImplBeginAddRect(); 1877cdf0e10cSrcweir bRegionRect = rDeviceRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 1878cdf0e10cSrcweir while ( bRegionRect ) 1879cdf0e10cSrcweir { 1880cdf0e10cSrcweir Rectangle aRect( Point( nX, nY ), Size( nWidth, nHeight ) ); 1881cdf0e10cSrcweir aRegion.ImplAddRect( PixelToLogic( aRect, rMapMode ) ); 1882cdf0e10cSrcweir bRegionRect = rDeviceRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 1883cdf0e10cSrcweir } 1884cdf0e10cSrcweir aRegion.ImplEndAddRect(); 1885cdf0e10cSrcweir } 1886cdf0e10cSrcweir 1887cdf0e10cSrcweir return aRegion; 1888cdf0e10cSrcweir } 1889cdf0e10cSrcweir 1890cdf0e10cSrcweir // ----------------------------------------------------------------------- 1891cdf0e10cSrcweir 1892cdf0e10cSrcweir #define ENTER0( rSource, pMapModeSource, pMapModeDest ) \ 1893cdf0e10cSrcweir if ( !pMapModeSource ) \ 1894cdf0e10cSrcweir pMapModeSource = &maMapMode; \ 1895cdf0e10cSrcweir if ( !pMapModeDest ) \ 1896cdf0e10cSrcweir pMapModeDest = &maMapMode; \ 1897cdf0e10cSrcweir if ( *pMapModeSource == *pMapModeDest ) \ 1898cdf0e10cSrcweir return rSource 1899cdf0e10cSrcweir 1900cdf0e10cSrcweir // ----------------------------------------------------------------------- 1901cdf0e10cSrcweir 1902cdf0e10cSrcweir #define ENTER1( rSource, pMapModeSource, pMapModeDest ) \ 1903cdf0e10cSrcweir ENTER0( rSource, pMapModeSource, pMapModeDest ); \ 1904cdf0e10cSrcweir \ 1905cdf0e10cSrcweir ImplMapRes aMapResSource; \ 1906cdf0e10cSrcweir ImplMapRes aMapResDest; \ 1907cdf0e10cSrcweir \ 1908cdf0e10cSrcweir if ( !mbMap || pMapModeSource != &maMapMode ) \ 1909cdf0e10cSrcweir { \ 1910cdf0e10cSrcweir if ( pMapModeSource->GetMapUnit() == MAP_RELATIVE ) \ 1911cdf0e10cSrcweir aMapResSource = maMapRes; \ 1912cdf0e10cSrcweir ImplCalcMapResolution( *pMapModeSource, \ 1913cdf0e10cSrcweir mnDPIX, mnDPIY, aMapResSource ); \ 1914cdf0e10cSrcweir } \ 1915cdf0e10cSrcweir else \ 1916cdf0e10cSrcweir aMapResSource = maMapRes; \ 1917cdf0e10cSrcweir if ( !mbMap || pMapModeDest != &maMapMode ) \ 1918cdf0e10cSrcweir { \ 1919cdf0e10cSrcweir if ( pMapModeDest->GetMapUnit() == MAP_RELATIVE ) \ 1920cdf0e10cSrcweir aMapResDest = maMapRes; \ 1921cdf0e10cSrcweir ImplCalcMapResolution( *pMapModeDest, \ 1922cdf0e10cSrcweir mnDPIX, mnDPIY, aMapResDest ); \ 1923cdf0e10cSrcweir } \ 1924cdf0e10cSrcweir else \ 1925cdf0e10cSrcweir aMapResDest = maMapRes 1926cdf0e10cSrcweir 1927cdf0e10cSrcweir // ----------------------------------------------------------------------- 1928cdf0e10cSrcweir 1929cdf0e10cSrcweir #define ENTER2( eUnitSource, eUnitDest ) \ 1930cdf0e10cSrcweir DBG_ASSERT( eUnitSource != MAP_SYSFONT \ 1931cdf0e10cSrcweir && eUnitSource != MAP_APPFONT \ 1932cdf0e10cSrcweir && eUnitSource != MAP_RELATIVE, \ 1933cdf0e10cSrcweir "Source MapUnit nicht erlaubt" ); \ 1934cdf0e10cSrcweir DBG_ASSERT( eUnitDest != MAP_SYSFONT \ 1935cdf0e10cSrcweir && eUnitDest != MAP_APPFONT \ 1936cdf0e10cSrcweir && eUnitDest != MAP_RELATIVE, \ 1937cdf0e10cSrcweir "Destination MapUnit nicht erlaubt" ); \ 1938cdf0e10cSrcweir DBG_ASSERTWARNING( eUnitSource != MAP_PIXEL, \ 1939cdf0e10cSrcweir "MAP_PIXEL mit 72dpi angenaehert" ); \ 1940cdf0e10cSrcweir DBG_ASSERTWARNING( eUnitDest != MAP_PIXEL, \ 1941cdf0e10cSrcweir "MAP_PIXEL mit 72dpi angenaehert" ) 1942cdf0e10cSrcweir 1943cdf0e10cSrcweir // ----------------------------------------------------------------------- 1944cdf0e10cSrcweir 1945cdf0e10cSrcweir #define ENTER3( eUnitSource, eUnitDest ) \ 1946cdf0e10cSrcweir long nNumerator = 1; \ 1947cdf0e10cSrcweir long nDenominator = 1; \ 1948cdf0e10cSrcweir DBG_ASSERT( eUnitSource < MAP_LASTENUMDUMMY, "Invalid source map unit"); \ 1949cdf0e10cSrcweir DBG_ASSERT( eUnitDest < MAP_LASTENUMDUMMY, "Invalid destination map unit"); \ 1950cdf0e10cSrcweir if( (eUnitSource < MAP_LASTENUMDUMMY) && (eUnitDest < MAP_LASTENUMDUMMY) ) \ 1951cdf0e10cSrcweir { \ 1952cdf0e10cSrcweir nNumerator = aImplNumeratorAry[eUnitSource] * \ 1953cdf0e10cSrcweir aImplDenominatorAry[eUnitDest]; \ 1954cdf0e10cSrcweir nDenominator = aImplNumeratorAry[eUnitDest] * \ 1955cdf0e10cSrcweir aImplDenominatorAry[eUnitSource]; \ 1956cdf0e10cSrcweir } \ 1957cdf0e10cSrcweir if ( eUnitSource == MAP_PIXEL ) \ 1958cdf0e10cSrcweir nDenominator *= 72; \ 1959cdf0e10cSrcweir else if( eUnitDest == MAP_PIXEL ) \ 1960cdf0e10cSrcweir nNumerator *= 72 1961cdf0e10cSrcweir 1962cdf0e10cSrcweir // ----------------------------------------------------------------------- 1963cdf0e10cSrcweir 1964cdf0e10cSrcweir #define ENTER4( rMapModeSource, rMapModeDest ) \ 1965cdf0e10cSrcweir ImplMapRes aMapResSource; \ 1966cdf0e10cSrcweir ImplMapRes aMapResDest; \ 1967cdf0e10cSrcweir \ 1968cdf0e10cSrcweir ImplCalcMapResolution( rMapModeSource, 72, 72, aMapResSource ); \ 1969cdf0e10cSrcweir ImplCalcMapResolution( rMapModeDest, 72, 72, aMapResDest ) 1970cdf0e10cSrcweir 1971cdf0e10cSrcweir // ----------------------------------------------------------------------- 1972cdf0e10cSrcweir 1973cdf0e10cSrcweir // return (n1 * n2 * n3) / (n4 * n5) 1974cdf0e10cSrcweir static long fn5( const long n1, 1975cdf0e10cSrcweir const long n2, 1976cdf0e10cSrcweir const long n3, 1977cdf0e10cSrcweir const long n4, 1978cdf0e10cSrcweir const long n5 ) 1979cdf0e10cSrcweir { 1980cdf0e10cSrcweir if ( n1 == 0 || n2 == 0 || n3 == 0 || n4 == 0 || n5 == 0 ) 1981cdf0e10cSrcweir return 0; 1982cdf0e10cSrcweir if ( LONG_MAX / Abs(n2) < Abs(n3) ) 1983cdf0e10cSrcweir { 1984cdf0e10cSrcweir // a6 wird "ubersprungen 1985cdf0e10cSrcweir BigInt a7 = n2; 1986cdf0e10cSrcweir a7 *= n3; 1987cdf0e10cSrcweir a7 *= n1; 1988cdf0e10cSrcweir 1989cdf0e10cSrcweir if ( LONG_MAX / Abs(n4) < Abs(n5) ) 1990cdf0e10cSrcweir { 1991cdf0e10cSrcweir BigInt a8 = n4; 1992cdf0e10cSrcweir a8 *= n5; 1993cdf0e10cSrcweir 1994cdf0e10cSrcweir BigInt a9 = a8; 1995cdf0e10cSrcweir a9 /= 2; 1996cdf0e10cSrcweir if ( a7.IsNeg() ) 1997cdf0e10cSrcweir a7 -= a9; 1998cdf0e10cSrcweir else 1999cdf0e10cSrcweir a7 += a9; 2000cdf0e10cSrcweir 2001cdf0e10cSrcweir a7 /= a8; 2002cdf0e10cSrcweir } // of if 2003cdf0e10cSrcweir else 2004cdf0e10cSrcweir { 2005cdf0e10cSrcweir long n8 = n4 * n5; 2006cdf0e10cSrcweir 2007cdf0e10cSrcweir if ( a7.IsNeg() ) 2008cdf0e10cSrcweir a7 -= n8 / 2; 2009cdf0e10cSrcweir else 2010cdf0e10cSrcweir a7 += n8 / 2; 2011cdf0e10cSrcweir 2012cdf0e10cSrcweir a7 /= n8; 2013cdf0e10cSrcweir } // of else 2014cdf0e10cSrcweir return (long)a7; 2015cdf0e10cSrcweir } // of if 2016cdf0e10cSrcweir else 2017cdf0e10cSrcweir { 2018cdf0e10cSrcweir long n6 = n2 * n3; 2019cdf0e10cSrcweir 2020cdf0e10cSrcweir if ( LONG_MAX / Abs(n1) < Abs(n6) ) 2021cdf0e10cSrcweir { 2022cdf0e10cSrcweir BigInt a7 = n1; 2023cdf0e10cSrcweir a7 *= n6; 2024cdf0e10cSrcweir 2025cdf0e10cSrcweir if ( LONG_MAX / Abs(n4) < Abs(n5) ) 2026cdf0e10cSrcweir { 2027cdf0e10cSrcweir BigInt a8 = n4; 2028cdf0e10cSrcweir a8 *= n5; 2029cdf0e10cSrcweir 2030cdf0e10cSrcweir BigInt a9 = a8; 2031cdf0e10cSrcweir a9 /= 2; 2032cdf0e10cSrcweir if ( a7.IsNeg() ) 2033cdf0e10cSrcweir a7 -= a9; 2034cdf0e10cSrcweir else 2035cdf0e10cSrcweir a7 += a9; 2036cdf0e10cSrcweir 2037cdf0e10cSrcweir a7 /= a8; 2038cdf0e10cSrcweir } // of if 2039cdf0e10cSrcweir else 2040cdf0e10cSrcweir { 2041cdf0e10cSrcweir long n8 = n4 * n5; 2042cdf0e10cSrcweir 2043cdf0e10cSrcweir if ( a7.IsNeg() ) 2044cdf0e10cSrcweir a7 -= n8 / 2; 2045cdf0e10cSrcweir else 2046cdf0e10cSrcweir a7 += n8 / 2; 2047cdf0e10cSrcweir 2048cdf0e10cSrcweir a7 /= n8; 2049cdf0e10cSrcweir } // of else 2050cdf0e10cSrcweir return (long)a7; 2051cdf0e10cSrcweir } // of if 2052cdf0e10cSrcweir else 2053cdf0e10cSrcweir { 2054cdf0e10cSrcweir long n7 = n1 * n6; 2055cdf0e10cSrcweir 2056cdf0e10cSrcweir if ( LONG_MAX / Abs(n4) < Abs(n5) ) 2057cdf0e10cSrcweir { 2058cdf0e10cSrcweir BigInt a7 = n7; 2059cdf0e10cSrcweir BigInt a8 = n4; 2060cdf0e10cSrcweir a8 *= n5; 2061cdf0e10cSrcweir 2062cdf0e10cSrcweir BigInt a9 = a8; 2063cdf0e10cSrcweir a9 /= 2; 2064cdf0e10cSrcweir if ( a7.IsNeg() ) 2065cdf0e10cSrcweir a7 -= a9; 2066cdf0e10cSrcweir else 2067cdf0e10cSrcweir a7 += a9; 2068cdf0e10cSrcweir 2069cdf0e10cSrcweir a7 /= a8; 2070cdf0e10cSrcweir return (long)a7; 2071cdf0e10cSrcweir } // of if 2072cdf0e10cSrcweir else 2073cdf0e10cSrcweir { 2074cdf0e10cSrcweir const long n8 = n4 * n5; 2075cdf0e10cSrcweir const long n8_2 = n8 / 2; 2076cdf0e10cSrcweir 2077cdf0e10cSrcweir if( n7 < 0 ) 2078cdf0e10cSrcweir { 2079cdf0e10cSrcweir if( ( n7 - LONG_MIN ) >= n8_2 ) 2080cdf0e10cSrcweir n7 -= n8_2; 2081cdf0e10cSrcweir } 2082cdf0e10cSrcweir else if( ( LONG_MAX - n7 ) >= n8_2 ) 2083cdf0e10cSrcweir n7 += n8_2; 2084cdf0e10cSrcweir 2085cdf0e10cSrcweir return n7 / n8; 2086cdf0e10cSrcweir } // of else 2087cdf0e10cSrcweir } // of else 2088cdf0e10cSrcweir } // of else 2089cdf0e10cSrcweir } 2090cdf0e10cSrcweir 2091cdf0e10cSrcweir // ----------------------------------------------------------------------- 2092cdf0e10cSrcweir 2093cdf0e10cSrcweir // return (n1 * n2) / n3 2094cdf0e10cSrcweir static long fn3( const long n1, const long n2, const long n3 ) 2095cdf0e10cSrcweir { 2096cdf0e10cSrcweir if ( n1 == 0 || n2 == 0 || n3 == 0 ) 2097cdf0e10cSrcweir return 0; 2098cdf0e10cSrcweir if ( LONG_MAX / Abs(n1) < Abs(n2) ) 2099cdf0e10cSrcweir { 2100cdf0e10cSrcweir BigInt a4 = n1; 2101cdf0e10cSrcweir a4 *= n2; 2102cdf0e10cSrcweir 2103cdf0e10cSrcweir if ( a4.IsNeg() ) 2104cdf0e10cSrcweir a4 -= n3 / 2; 2105cdf0e10cSrcweir else 2106cdf0e10cSrcweir a4 += n3 / 2; 2107cdf0e10cSrcweir 2108cdf0e10cSrcweir a4 /= n3; 2109cdf0e10cSrcweir return (long)a4; 2110cdf0e10cSrcweir } // of if 2111cdf0e10cSrcweir else 2112cdf0e10cSrcweir { 2113cdf0e10cSrcweir long n4 = n1 * n2; 2114cdf0e10cSrcweir const long n3_2 = n3 / 2; 2115cdf0e10cSrcweir 2116cdf0e10cSrcweir if( n4 < 0 ) 2117cdf0e10cSrcweir { 2118cdf0e10cSrcweir if( ( n4 - LONG_MIN ) >= n3_2 ) 2119cdf0e10cSrcweir n4 -= n3_2; 2120cdf0e10cSrcweir } 2121cdf0e10cSrcweir else if( ( LONG_MAX - n4 ) >= n3_2 ) 2122cdf0e10cSrcweir n4 += n3_2; 2123cdf0e10cSrcweir 2124cdf0e10cSrcweir return n4 / n3; 2125cdf0e10cSrcweir } // of else 2126cdf0e10cSrcweir } 2127cdf0e10cSrcweir 2128cdf0e10cSrcweir // ----------------------------------------------------------------------- 2129cdf0e10cSrcweir 2130cdf0e10cSrcweir Point OutputDevice::LogicToLogic( const Point& rPtSource, 2131cdf0e10cSrcweir const MapMode* pMapModeSource, 2132cdf0e10cSrcweir const MapMode* pMapModeDest ) const 2133cdf0e10cSrcweir { 2134cdf0e10cSrcweir ENTER1( rPtSource, pMapModeSource, pMapModeDest ); 2135cdf0e10cSrcweir 2136cdf0e10cSrcweir return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX, 2137cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2138cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) - 2139cdf0e10cSrcweir aMapResDest.mnMapOfsX, 2140cdf0e10cSrcweir fn5( rPtSource.Y() + aMapResSource.mnMapOfsY, 2141cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2142cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) - 2143cdf0e10cSrcweir aMapResDest.mnMapOfsY ); 2144cdf0e10cSrcweir } 2145cdf0e10cSrcweir 2146cdf0e10cSrcweir // ----------------------------------------------------------------------- 2147cdf0e10cSrcweir 2148cdf0e10cSrcweir Size OutputDevice::LogicToLogic( const Size& rSzSource, 2149cdf0e10cSrcweir const MapMode* pMapModeSource, 2150cdf0e10cSrcweir const MapMode* pMapModeDest ) const 2151cdf0e10cSrcweir { 2152cdf0e10cSrcweir ENTER1( rSzSource, pMapModeSource, pMapModeDest ); 2153cdf0e10cSrcweir 2154cdf0e10cSrcweir return Size( fn5( rSzSource.Width(), 2155cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2156cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ), 2157cdf0e10cSrcweir fn5( rSzSource.Height(), 2158cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2159cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) ); 2160cdf0e10cSrcweir } 2161cdf0e10cSrcweir 2162cdf0e10cSrcweir // ----------------------------------------------------------------------- 2163cdf0e10cSrcweir 2164cdf0e10cSrcweir Rectangle OutputDevice::LogicToLogic( const Rectangle& rRectSource, 2165cdf0e10cSrcweir const MapMode* pMapModeSource, 2166cdf0e10cSrcweir const MapMode* pMapModeDest ) const 2167cdf0e10cSrcweir { 2168cdf0e10cSrcweir ENTER1( rRectSource, pMapModeSource, pMapModeDest ); 2169cdf0e10cSrcweir 2170cdf0e10cSrcweir return Rectangle( fn5( rRectSource.Left() + aMapResSource.mnMapOfsX, 2171cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2172cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) - 2173cdf0e10cSrcweir aMapResDest.mnMapOfsX, 2174cdf0e10cSrcweir fn5( rRectSource.Top() + aMapResSource.mnMapOfsY, 2175cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2176cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) - 2177cdf0e10cSrcweir aMapResDest.mnMapOfsY, 2178cdf0e10cSrcweir fn5( rRectSource.Right() + aMapResSource.mnMapOfsX, 2179cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2180cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) - 2181cdf0e10cSrcweir aMapResDest.mnMapOfsX, 2182cdf0e10cSrcweir fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY, 2183cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2184cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) - 2185cdf0e10cSrcweir aMapResDest.mnMapOfsY ); 2186cdf0e10cSrcweir } 2187cdf0e10cSrcweir 2188cdf0e10cSrcweir // ----------------------------------------------------------------------- 2189cdf0e10cSrcweir 2190cdf0e10cSrcweir long* OutputDevice::LogicToLogic( long* pX, sal_uInt16 nCount, 2191cdf0e10cSrcweir const MapMode* pMapModeSource, 2192cdf0e10cSrcweir const MapMode* pMapModeDest ) const 2193cdf0e10cSrcweir { 2194cdf0e10cSrcweir ENTER1( pX, pMapModeSource, pMapModeDest ); 2195cdf0e10cSrcweir 2196cdf0e10cSrcweir for( ; nCount; nCount--, pX++ ) 2197cdf0e10cSrcweir { 2198cdf0e10cSrcweir *pX = fn5( *pX, 2199cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2200cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ); 2201cdf0e10cSrcweir } 2202cdf0e10cSrcweir 2203cdf0e10cSrcweir return NULL; 2204cdf0e10cSrcweir } 2205cdf0e10cSrcweir 2206cdf0e10cSrcweir // ----------------------------------------------------------------------- 2207cdf0e10cSrcweir 2208cdf0e10cSrcweir Point OutputDevice::LogicToLogic( const Point& rPtSource, 2209cdf0e10cSrcweir const MapMode& rMapModeSource, 2210cdf0e10cSrcweir const MapMode& rMapModeDest ) 2211cdf0e10cSrcweir { 2212cdf0e10cSrcweir if ( rMapModeSource == rMapModeDest ) 2213cdf0e10cSrcweir return rPtSource; 2214cdf0e10cSrcweir 2215cdf0e10cSrcweir MapUnit eUnitSource = rMapModeSource.GetMapUnit(); 2216cdf0e10cSrcweir MapUnit eUnitDest = rMapModeDest.GetMapUnit(); 2217cdf0e10cSrcweir ENTER2( eUnitSource, eUnitDest ); 2218cdf0e10cSrcweir 2219cdf0e10cSrcweir if ( rMapModeSource.mpImplMapMode->mbSimple && 2220cdf0e10cSrcweir rMapModeDest.mpImplMapMode->mbSimple ) 2221cdf0e10cSrcweir { 2222cdf0e10cSrcweir ENTER3( eUnitSource, eUnitDest ); 2223cdf0e10cSrcweir 2224cdf0e10cSrcweir return Point( fn3( rPtSource.X(), nNumerator, nDenominator ), 2225cdf0e10cSrcweir fn3( rPtSource.Y(), nNumerator, nDenominator ) ); 2226cdf0e10cSrcweir } 2227cdf0e10cSrcweir else 2228cdf0e10cSrcweir { 2229cdf0e10cSrcweir ENTER4( rMapModeSource, rMapModeDest ); 2230cdf0e10cSrcweir 2231cdf0e10cSrcweir return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX, 2232cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2233cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) - 2234cdf0e10cSrcweir aMapResDest.mnMapOfsX, 2235cdf0e10cSrcweir fn5( rPtSource.Y() + aMapResSource.mnMapOfsY, 2236cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2237cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) - 2238cdf0e10cSrcweir aMapResDest.mnMapOfsY ); 2239cdf0e10cSrcweir } 2240cdf0e10cSrcweir } 2241cdf0e10cSrcweir 2242cdf0e10cSrcweir // ----------------------------------------------------------------------- 2243cdf0e10cSrcweir 2244cdf0e10cSrcweir Size OutputDevice::LogicToLogic( const Size& rSzSource, 2245cdf0e10cSrcweir const MapMode& rMapModeSource, 2246cdf0e10cSrcweir const MapMode& rMapModeDest ) 2247cdf0e10cSrcweir { 2248cdf0e10cSrcweir if ( rMapModeSource == rMapModeDest ) 2249cdf0e10cSrcweir return rSzSource; 2250cdf0e10cSrcweir 2251cdf0e10cSrcweir MapUnit eUnitSource = rMapModeSource.GetMapUnit(); 2252cdf0e10cSrcweir MapUnit eUnitDest = rMapModeDest.GetMapUnit(); 2253cdf0e10cSrcweir ENTER2( eUnitSource, eUnitDest ); 2254cdf0e10cSrcweir 2255cdf0e10cSrcweir if ( rMapModeSource.mpImplMapMode->mbSimple && 2256cdf0e10cSrcweir rMapModeDest.mpImplMapMode->mbSimple ) 2257cdf0e10cSrcweir { 2258cdf0e10cSrcweir ENTER3( eUnitSource, eUnitDest ); 2259cdf0e10cSrcweir 2260cdf0e10cSrcweir return Size( fn3( rSzSource.Width(), nNumerator, nDenominator ), 2261cdf0e10cSrcweir fn3( rSzSource.Height(), nNumerator, nDenominator ) ); 2262cdf0e10cSrcweir } 2263cdf0e10cSrcweir else 2264cdf0e10cSrcweir { 2265cdf0e10cSrcweir ENTER4( rMapModeSource, rMapModeDest ); 2266cdf0e10cSrcweir 2267cdf0e10cSrcweir return Size( fn5( rSzSource.Width(), 2268cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2269cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ), 2270cdf0e10cSrcweir fn5( rSzSource.Height(), 2271cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2272cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) ); 2273cdf0e10cSrcweir } 2274cdf0e10cSrcweir } 2275cdf0e10cSrcweir 2276cdf0e10cSrcweir // ----------------------------------------------------------------------- 2277cdf0e10cSrcweir 2278cdf0e10cSrcweir basegfx::B2DPolygon OutputDevice::LogicToLogic( const basegfx::B2DPolygon& rPolySource, 2279cdf0e10cSrcweir const MapMode& rMapModeSource, 2280cdf0e10cSrcweir const MapMode& rMapModeDest ) 2281cdf0e10cSrcweir { 2282cdf0e10cSrcweir if ( rMapModeSource == rMapModeDest ) 2283cdf0e10cSrcweir return rPolySource; 2284cdf0e10cSrcweir 2285cdf0e10cSrcweir MapUnit eUnitSource = rMapModeSource.GetMapUnit(); 2286cdf0e10cSrcweir MapUnit eUnitDest = rMapModeDest.GetMapUnit(); 2287cdf0e10cSrcweir ENTER2( eUnitSource, eUnitDest ); 2288cdf0e10cSrcweir 2289cdf0e10cSrcweir basegfx::B2DHomMatrix aTransform; 2290cdf0e10cSrcweir 2291cdf0e10cSrcweir if ( rMapModeSource.mpImplMapMode->mbSimple && 2292cdf0e10cSrcweir rMapModeDest.mpImplMapMode->mbSimple ) 2293cdf0e10cSrcweir { 2294cdf0e10cSrcweir ENTER3( eUnitSource, eUnitDest ); 2295cdf0e10cSrcweir 2296cdf0e10cSrcweir const double fScaleFactor((double)nNumerator / (double)nDenominator); 2297cdf0e10cSrcweir aTransform.set(0, 0, fScaleFactor); 2298cdf0e10cSrcweir aTransform.set(1, 1, fScaleFactor); 2299cdf0e10cSrcweir } 2300cdf0e10cSrcweir else 2301cdf0e10cSrcweir { 2302cdf0e10cSrcweir ENTER4( rMapModeSource, rMapModeDest ); 2303cdf0e10cSrcweir 2304cdf0e10cSrcweir const double fScaleFactorX( (double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) 2305cdf0e10cSrcweir / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)) ); 2306cdf0e10cSrcweir const double fScaleFactorY( (double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) 2307cdf0e10cSrcweir / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)) ); 2308cdf0e10cSrcweir const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX)); 2309cdf0e10cSrcweir const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY)); 2310cdf0e10cSrcweir 2311cdf0e10cSrcweir aTransform.set(0, 0, fScaleFactorX); 2312cdf0e10cSrcweir aTransform.set(1, 1, fScaleFactorY); 2313cdf0e10cSrcweir aTransform.set(0, 2, fZeroPointX); 2314cdf0e10cSrcweir aTransform.set(1, 2, fZeroPointY); 2315cdf0e10cSrcweir } 2316cdf0e10cSrcweir basegfx::B2DPolygon aPoly( rPolySource ); 2317cdf0e10cSrcweir aPoly.transform( aTransform ); 2318cdf0e10cSrcweir return aPoly; 2319cdf0e10cSrcweir } 2320cdf0e10cSrcweir 2321cdf0e10cSrcweir // ----------------------------------------------------------------------- 2322cdf0e10cSrcweir 2323cdf0e10cSrcweir basegfx::B2DPolyPolygon OutputDevice::LogicToLogic( const basegfx::B2DPolyPolygon& rPolySource, 2324cdf0e10cSrcweir const MapMode& rMapModeSource, 2325cdf0e10cSrcweir const MapMode& rMapModeDest ) 2326cdf0e10cSrcweir { 2327cdf0e10cSrcweir if ( rMapModeSource == rMapModeDest ) 2328cdf0e10cSrcweir return rPolySource; 2329cdf0e10cSrcweir 2330cdf0e10cSrcweir MapUnit eUnitSource = rMapModeSource.GetMapUnit(); 2331cdf0e10cSrcweir MapUnit eUnitDest = rMapModeDest.GetMapUnit(); 2332cdf0e10cSrcweir ENTER2( eUnitSource, eUnitDest ); 2333cdf0e10cSrcweir 2334cdf0e10cSrcweir basegfx::B2DHomMatrix aTransform; 2335cdf0e10cSrcweir 2336cdf0e10cSrcweir if ( rMapModeSource.mpImplMapMode->mbSimple && 2337cdf0e10cSrcweir rMapModeDest.mpImplMapMode->mbSimple ) 2338cdf0e10cSrcweir { 2339cdf0e10cSrcweir ENTER3( eUnitSource, eUnitDest ); 2340cdf0e10cSrcweir 2341cdf0e10cSrcweir const double fScaleFactor((double)nNumerator / (double)nDenominator); 2342cdf0e10cSrcweir aTransform.set(0, 0, fScaleFactor); 2343cdf0e10cSrcweir aTransform.set(1, 1, fScaleFactor); 2344cdf0e10cSrcweir } 2345cdf0e10cSrcweir else 2346cdf0e10cSrcweir { 2347cdf0e10cSrcweir ENTER4( rMapModeSource, rMapModeDest ); 2348cdf0e10cSrcweir 2349cdf0e10cSrcweir const double fScaleFactorX( (double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) 2350cdf0e10cSrcweir / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)) ); 2351cdf0e10cSrcweir const double fScaleFactorY( (double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) 2352cdf0e10cSrcweir / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)) ); 2353cdf0e10cSrcweir const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX)); 2354cdf0e10cSrcweir const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY)); 2355cdf0e10cSrcweir 2356cdf0e10cSrcweir aTransform.set(0, 0, fScaleFactorX); 2357cdf0e10cSrcweir aTransform.set(1, 1, fScaleFactorY); 2358cdf0e10cSrcweir aTransform.set(0, 2, fZeroPointX); 2359cdf0e10cSrcweir aTransform.set(1, 2, fZeroPointY); 2360cdf0e10cSrcweir } 2361cdf0e10cSrcweir basegfx::B2DPolyPolygon aPoly( rPolySource ); 2362cdf0e10cSrcweir aPoly.transform( aTransform ); 2363cdf0e10cSrcweir return aPoly; 2364cdf0e10cSrcweir } 2365cdf0e10cSrcweir 2366cdf0e10cSrcweir // ----------------------------------------------------------------------- 2367cdf0e10cSrcweir 2368cdf0e10cSrcweir Rectangle OutputDevice::LogicToLogic( const Rectangle& rRectSource, 2369cdf0e10cSrcweir const MapMode& rMapModeSource, 2370cdf0e10cSrcweir const MapMode& rMapModeDest ) 2371cdf0e10cSrcweir { 2372cdf0e10cSrcweir if ( rMapModeSource == rMapModeDest ) 2373cdf0e10cSrcweir return rRectSource; 2374cdf0e10cSrcweir 2375cdf0e10cSrcweir MapUnit eUnitSource = rMapModeSource.GetMapUnit(); 2376cdf0e10cSrcweir MapUnit eUnitDest = rMapModeDest.GetMapUnit(); 2377cdf0e10cSrcweir ENTER2( eUnitSource, eUnitDest ); 2378cdf0e10cSrcweir 2379cdf0e10cSrcweir if ( rMapModeSource.mpImplMapMode->mbSimple && 2380cdf0e10cSrcweir rMapModeDest.mpImplMapMode->mbSimple ) 2381cdf0e10cSrcweir { 2382cdf0e10cSrcweir ENTER3( eUnitSource, eUnitDest ); 2383cdf0e10cSrcweir 2384cdf0e10cSrcweir return Rectangle( fn3( rRectSource.Left(), nNumerator, nDenominator ), 2385cdf0e10cSrcweir fn3( rRectSource.Top(), nNumerator, nDenominator ), 2386cdf0e10cSrcweir fn3( rRectSource.Right(), nNumerator, nDenominator ), 2387cdf0e10cSrcweir fn3( rRectSource.Bottom(), nNumerator, nDenominator ) ); 2388cdf0e10cSrcweir } 2389cdf0e10cSrcweir else 2390cdf0e10cSrcweir { 2391cdf0e10cSrcweir ENTER4( rMapModeSource, rMapModeDest ); 2392cdf0e10cSrcweir 2393cdf0e10cSrcweir return Rectangle( fn5( rRectSource.Left() + aMapResSource.mnMapOfsX, 2394cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2395cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) - 2396cdf0e10cSrcweir aMapResDest.mnMapOfsX, 2397cdf0e10cSrcweir fn5( rRectSource.Top() + aMapResSource.mnMapOfsY, 2398cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2399cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) - 2400cdf0e10cSrcweir aMapResDest.mnMapOfsY, 2401cdf0e10cSrcweir fn5( rRectSource.Right() + aMapResSource.mnMapOfsX, 2402cdf0e10cSrcweir aMapResSource.mnMapScNumX, aMapResDest.mnMapScDenomX, 2403cdf0e10cSrcweir aMapResSource.mnMapScDenomX, aMapResDest.mnMapScNumX ) - 2404cdf0e10cSrcweir aMapResDest.mnMapOfsX, 2405cdf0e10cSrcweir fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY, 2406cdf0e10cSrcweir aMapResSource.mnMapScNumY, aMapResDest.mnMapScDenomY, 2407cdf0e10cSrcweir aMapResSource.mnMapScDenomY, aMapResDest.mnMapScNumY ) - 2408cdf0e10cSrcweir aMapResDest.mnMapOfsY ); 2409cdf0e10cSrcweir } 2410cdf0e10cSrcweir } 2411cdf0e10cSrcweir 2412cdf0e10cSrcweir // ----------------------------------------------------------------------- 2413cdf0e10cSrcweir 2414cdf0e10cSrcweir long OutputDevice::LogicToLogic( long nLongSource, 2415cdf0e10cSrcweir MapUnit eUnitSource, MapUnit eUnitDest ) 2416cdf0e10cSrcweir { 2417cdf0e10cSrcweir if ( eUnitSource == eUnitDest ) 2418cdf0e10cSrcweir return nLongSource; 2419cdf0e10cSrcweir 2420cdf0e10cSrcweir ENTER2( eUnitSource, eUnitDest ); 2421cdf0e10cSrcweir ENTER3( eUnitSource, eUnitDest ); 2422cdf0e10cSrcweir 2423cdf0e10cSrcweir return fn3( nLongSource, nNumerator, nDenominator ); 2424cdf0e10cSrcweir } 2425cdf0e10cSrcweir 2426cdf0e10cSrcweir // ----------------------------------------------------------------------- 2427cdf0e10cSrcweir 2428cdf0e10cSrcweir void OutputDevice::SetPixelOffset( const Size& rOffset ) 2429cdf0e10cSrcweir { 2430cdf0e10cSrcweir mnOutOffOrigX = rOffset.Width(); 2431cdf0e10cSrcweir mnOutOffOrigY = rOffset.Height(); 2432cdf0e10cSrcweir 2433cdf0e10cSrcweir mnOutOffLogicX = ImplPixelToLogic( mnOutOffOrigX, mnDPIX, 2434cdf0e10cSrcweir maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX, 2435cdf0e10cSrcweir maThresRes.mnThresPixToLogX ); 2436cdf0e10cSrcweir mnOutOffLogicY = ImplPixelToLogic( mnOutOffOrigY, mnDPIY, 2437cdf0e10cSrcweir maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY, 2438cdf0e10cSrcweir maThresRes.mnThresPixToLogY ); 2439cdf0e10cSrcweir 2440cdf0e10cSrcweir if( mpAlphaVDev ) 2441cdf0e10cSrcweir mpAlphaVDev->SetPixelOffset( rOffset ); 2442cdf0e10cSrcweir } 2443cdf0e10cSrcweir 2444cdf0e10cSrcweir // ----------------------------------------------------------------------- 2445cdf0e10cSrcweir 2446cdf0e10cSrcweir Size OutputDevice::GetPixelOffset() const 2447cdf0e10cSrcweir { 2448cdf0e10cSrcweir return Size(mnOutOffOrigX, mnOutOffOrigY); 2449cdf0e10cSrcweir } 2450cdf0e10cSrcweir 2451cdf0e10cSrcweir // ----------------------------------------------------------------------- 2452cdf0e10cSrcweir 2453cdf0e10cSrcweir long Window::ImplLogicUnitToPixelX( long nX, MapUnit eUnit ) 2454cdf0e10cSrcweir { 2455cdf0e10cSrcweir if ( eUnit != MAP_PIXEL ) 2456cdf0e10cSrcweir { 2457cdf0e10cSrcweir ImplFrameData* pFrameData = mpWindowImpl->mpFrameData; 2458cdf0e10cSrcweir 2459cdf0e10cSrcweir // Map-Einheit verschieden, dann neu berechnen 2460cdf0e10cSrcweir if ( pFrameData->meMapUnit != eUnit ) 2461cdf0e10cSrcweir { 2462cdf0e10cSrcweir pFrameData->meMapUnit = eUnit; 2463cdf0e10cSrcweir ImplCalcMapResolution( MapMode( eUnit ), mnDPIX, mnDPIY, 2464cdf0e10cSrcweir pFrameData->maMapUnitRes ); 2465cdf0e10cSrcweir } 2466cdf0e10cSrcweir 2467cdf0e10cSrcweir // Es wird kein BigInt gebraucht, da diese Funktion nur zur Umrechnung 2468cdf0e10cSrcweir // von Fensterposition benutzt wird 2469cdf0e10cSrcweir nX = nX * mnDPIX * pFrameData->maMapUnitRes.mnMapScNumX; 2470cdf0e10cSrcweir nX += nX >= 0 ? (pFrameData->maMapUnitRes.mnMapScDenomX/2) : 2471cdf0e10cSrcweir -((pFrameData->maMapUnitRes.mnMapScDenomX-1)/2); 2472cdf0e10cSrcweir nX /= pFrameData->maMapUnitRes.mnMapScDenomX; 2473cdf0e10cSrcweir } 2474cdf0e10cSrcweir 2475cdf0e10cSrcweir return nX; 2476cdf0e10cSrcweir } 2477cdf0e10cSrcweir 2478cdf0e10cSrcweir // ----------------------------------------------------------------------- 2479cdf0e10cSrcweir 2480cdf0e10cSrcweir long Window::ImplLogicUnitToPixelY( long nY, MapUnit eUnit ) 2481cdf0e10cSrcweir { 2482cdf0e10cSrcweir if ( eUnit != MAP_PIXEL ) 2483cdf0e10cSrcweir { 2484cdf0e10cSrcweir ImplFrameData* pFrameData = mpWindowImpl->mpFrameData; 2485cdf0e10cSrcweir 2486cdf0e10cSrcweir // Map-Einheit verschieden, dann neu berechnen 2487cdf0e10cSrcweir if ( pFrameData->meMapUnit != eUnit ) 2488cdf0e10cSrcweir { 2489cdf0e10cSrcweir pFrameData->meMapUnit = eUnit; 2490cdf0e10cSrcweir ImplCalcMapResolution( MapMode( eUnit ), mnDPIX, mnDPIY, 2491cdf0e10cSrcweir pFrameData->maMapUnitRes ); 2492cdf0e10cSrcweir } 2493cdf0e10cSrcweir 2494cdf0e10cSrcweir // Es wird kein BigInt gebraucht, da diese Funktion nur zur Umrechnung 2495cdf0e10cSrcweir // von Fensterposition benutzt wird 2496cdf0e10cSrcweir nY = nY * mnDPIY * pFrameData->maMapUnitRes.mnMapScNumY; 2497cdf0e10cSrcweir nY += nY >= 0 ? (pFrameData->maMapUnitRes.mnMapScDenomY/2) : 2498cdf0e10cSrcweir -((pFrameData->maMapUnitRes.mnMapScDenomY-1)/2); 2499cdf0e10cSrcweir nY /= pFrameData->maMapUnitRes.mnMapScDenomY; 2500cdf0e10cSrcweir } 2501cdf0e10cSrcweir 2502cdf0e10cSrcweir return nY; 2503cdf0e10cSrcweir } 2504