diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 5e60959b0b8f..ed031996b06a 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -153,7 +153,8 @@ void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect class OutputDevice; -namespace vcl { +namespace vcl +{ typedef OutputDevice RenderContext; } @@ -193,14 +194,6 @@ private: // The canvas interface for this output device. Is persistent after the first GetCanvas() call mutable css::uno::WeakReference< css::rendering::XCanvas > mxCanvas; - /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) - tools::Long mnOutOffOrigX; - /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) - tools::Long mnOutOffLogicX; - /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) - tools::Long mnOutOffOrigY; - /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) - tools::Long mnOutOffLogicY; /// Output offset for device output in pixel (pseudo window offset within window system's frames) tools::Long mnOutOffX; /// Output offset for device output in pixel (pseudo window offset within window system's frames) @@ -212,7 +205,6 @@ private: mutable tools::Long mnEmphasisDescent; DrawModeFlags mnDrawMode; vcl::text::ComplexTextLayoutFlags mnTextLayoutMode; - ImplMapRes maMapRes; const OutDevType meOutDevType; OutDevViewType meOutDevViewType; vcl::Region maRegion; // contains the clip region, see SetClipRegion(...) @@ -1627,7 +1619,7 @@ public: @return the current offset in pixel */ - SAL_WARN_UNUSED_RESULT Size GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY);} + SAL_WARN_UNUSED_RESULT Size GetPixelOffset() const; SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point& rLogicPt) const; SAL_WARN_UNUSED_RESULT Size LogicToPixel(const Size& rLogicSize) const; diff --git a/include/vcl/rendercontext/ImplMapRes.hxx b/include/vcl/rendercontext/ImplMapRes.hxx index 37d38c283648..8a042eb2ff8d 100644 --- a/include/vcl/rendercontext/ImplMapRes.hxx +++ b/include/vcl/rendercontext/ImplMapRes.hxx @@ -29,6 +29,8 @@ struct ImplMapRes ImplMapRes() = default; void SetMapRes(const o3tl::Length eUnit); void CalcMapResolution(const MapMode& rMapMode, tools::Long nDPIX, tools::Long nDPIY); + ImplMapRes ResolveMapRes(const MapMode* pMode, const MapMode& rDefaultMapMode, bool bMap, + tools::Long nDPIX, tools::Long nDPIY); tools::Long mnMapOfsX = 0; ///< Offset in X direction tools::Long mnMapOfsY = 0; ///< Offset in Y direction diff --git a/vcl/inc/CoordinateMapper.hxx b/vcl/inc/CoordinateMapper.hxx index 304fc0e6cceb..f85678f8f7fd 100644 --- a/vcl/inc/CoordinateMapper.hxx +++ b/vcl/inc/CoordinateMapper.hxx @@ -30,18 +30,29 @@ class CoordinateMapper private: bool mbMap = false; MapMode maMapMode; + ImplMapRes maMapRes; sal_Int32 mnDPIX = 0; sal_Int32 mnDPIY = 0; sal_Int32 mnDPIScalePercentage = 100; /// Output offset for device output in pixel (pseudo window offset within window system's frames) - tools::Long mnOutOffX; + tools::Long mnOutOffX = 0; /// Output offset for device output in pixel (pseudo window offset within window system's frames) - tools::Long mnOutOffY; + tools::Long mnOutOffY = 0; - tools::Long mnOutWidth; - tools::Long mnOutHeight; + /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) + tools::Long mnOutOffOrigX = 0; + /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) + tools::Long mnOutOffOrigY = 0; + + /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) + tools::Long mnOutOffLogicX = 0; + /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) + tools::Long mnOutOffLogicY = 0; + + tools::Long mnOutWidth = 0; + tools::Long mnOutHeight = 0; public: bool IsMapModeEnabled() const { return mbMap; } @@ -54,6 +65,7 @@ public: void SetDPIY(sal_Int32 nDPIY); sal_Int32 GetDPIScalePercentage() const; + float GetDPIScaleFactor() const; void SetDPIScalePercentage(sal_Int32 nPercentage); tools::Long GetOutOffXPixel() const; @@ -68,6 +80,15 @@ public: tools::Long GetOutputHeightPixel() const; Size GetOutputSizePixel() const; + Size GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY); } + void SetPixelOffset(const Size& rSize); + tools::Long GetPixelXOffset() { return mnOutOffOrigX; } + tools::Long GetPixelYOffset() { return mnOutOffOrigY; } + + void SetLogicalOffset(const Size& rSize); + tools::Long GetLogicalXOffset() { return mnOutOffLogicX; } + tools::Long GetLogicalYOffset() { return mnOutOffLogicY; } + void SetOutputWidthPixel(tools::Long nWidth); void SetOutputHeightPixel(tools::Long nHeight); @@ -83,6 +104,20 @@ public: void SetScaleY(double nY) { maMapMode.SetScaleY(nY); } void SetOrigin(const Point& rPt) { maMapMode.SetOrigin(rPt); } + + tools::Long GetMappingXOffset() const { return maMapRes.mnMapOfsX; } + tools::Long GetMappingYOffset() const { return maMapRes.mnMapOfsY; } + double GetMapResolutionScaleX() const { return maMapRes.mfMapScX; } + double GetMapResolutionScaleY() const { return maMapRes.mfMapScY; } + + void SetMappingXOffset(tools::Long nOffset) { maMapRes.mnMapOfsX = nOffset; } + void SetMappingYOffset(tools::Long nOffset) { maMapRes.mnMapOfsY = nOffset; } + void SetMapResolutionScaleX(double fX) { maMapRes.mfMapScX = fX; } + void SetMapResolutionScaleY(double fY) { maMapRes.mfMapScY = fY; } + + void CalcMapResolution(const MapMode& rMapMode, tools::Long nDPIX, tools::Long nDPIY); + + ImplMapRes ResolveMapRes(const MapMode* pMode); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/outdev/CoordinateMapper.cxx b/vcl/source/outdev/CoordinateMapper.cxx index bc929bb56a8f..67c3e422fd4a 100644 --- a/vcl/source/outdev/CoordinateMapper.cxx +++ b/vcl/source/outdev/CoordinateMapper.cxx @@ -39,6 +39,20 @@ void CoordinateMapper::SetDPIScalePercentage(sal_Int32 nPercent) mnDPIScalePercentage = nPercent; } +float CoordinateMapper::GetDPIScaleFactor() const { return mnDPIScalePercentage / 100.0f; } + +void CoordinateMapper::SetPixelOffset(const Size& rSize) +{ + mnOutOffOrigX = rSize.getWidth(); + mnOutOffOrigY = rSize.getHeight(); +} + +void CoordinateMapper::SetLogicalOffset(const Size& rSize) +{ + mnOutOffLogicX = rSize.getWidth(); + mnOutOffLogicY = rSize.getHeight(); +} + tools::Long CoordinateMapper::GetOutOffXPixel() const { return mnOutOffX; } tools::Long CoordinateMapper::GetOutOffYPixel() const { return mnOutOffY; } @@ -57,4 +71,15 @@ void CoordinateMapper::SetOutputWidthPixel(tools::Long nWidth) { mnOutWidth = nW void CoordinateMapper::SetOutputHeightPixel(tools::Long nHeight) { mnOutHeight = nHeight; } +void CoordinateMapper::CalcMapResolution(const MapMode& rMapMode, tools::Long nDPIX, + tools::Long nDPIY) +{ + maMapRes.CalcMapResolution(rMapMode, nDPIX, nDPIY); +} + +ImplMapRes CoordinateMapper::ResolveMapRes(const MapMode* pMode) +{ + return maMapRes.ResolveMapRes(pMode, maMapMode, mbMap, mnDPIX, mnDPIY); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/outdev/ImplMapRes.cxx b/vcl/source/outdev/ImplMapRes.cxx index f8434c2adb2e..0ad0c72444d4 100644 --- a/vcl/source/outdev/ImplMapRes.cxx +++ b/vcl/source/outdev/ImplMapRes.cxx @@ -125,4 +125,22 @@ void ImplMapRes::CalcMapResolution(const MapMode& rMapMode, tools::Long nDPIX, t mfMapScY = fScaleY * mfMapScY; } +ImplMapRes ImplMapRes::ResolveMapRes(const MapMode* pMode, const MapMode& rDefaultMapMode, + bool bMap, tools::Long nDPIX, tools::Long nDPIY) +{ + const MapMode* pEffectiveMode = pMode ? pMode : &rDefaultMapMode; + + if (bMap && pEffectiveMode == &rDefaultMapMode) + return *this; + + ImplMapRes aRes; + + if (pEffectiveMode->GetMapUnit() == MapUnit::MapRelative) + aRes = *this; + + aRes.CalcMapResolution(*pEffectiveMode, nDPIX, nDPIY); + + return aRes; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index c98b15f98033..8a71a2ef0b86 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -842,9 +842,9 @@ bool OutputDevice::ImplNewFont() const bool OutputDevice::AttemptOLEFontScaleFix(vcl::Font& rFont, tools::Long nHeight) const { - if (maMapRes.mfMapScY == 0.0) + if (mpMapper->GetMapResolutionScaleY() == 0.0) return false; - const double fStretch = maMapRes.mfMapScX / maMapRes.mfMapScY; + const double fStretch = mpMapper->GetMapResolutionScaleX() / mpMapper->GetMapResolutionScaleY(); const int nOrigWidth = mpFontInstance->mxFontMetric->GetWidth(); const int nNewWidth = static_cast(nOrigWidth * fStretch + 0.5); diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 7b4d29dbab43..7ab211900e68 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -105,8 +105,8 @@ tools::Long OutputDevice::ImplLogicXToDevicePixel( tools::Long nX ) const if ( !mpMapper->IsMapModeEnabled() ) return nX+GetOutOffXPixel(); - return lcl_logicToPixel( nX + maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX; + return lcl_logicToPixel( nX + mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(); } tools::Long OutputDevice::ImplLogicYToDevicePixel( tools::Long nY ) const @@ -114,8 +114,8 @@ tools::Long OutputDevice::ImplLogicYToDevicePixel( tools::Long nY ) const if ( !mpMapper->IsMapModeEnabled() ) return nY+GetOutOffYPixel(); - return lcl_logicToPixel( nY + maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY; + return lcl_logicToPixel( nY + mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset(); } tools::Long OutputDevice::LogicWidthToDevicePixel(tools::Long nWidth) const @@ -123,7 +123,7 @@ tools::Long OutputDevice::LogicWidthToDevicePixel(tools::Long nWidth) const if ( !mpMapper->IsMapModeEnabled() ) return nWidth; - return lcl_logicToPixel(nWidth, GetDPIX(), maMapRes.mfMapScX); + return lcl_logicToPixel(nWidth, GetDPIX(), mpMapper->GetMapResolutionScaleX()); } tools::Long OutputDevice::LogicHeightToDevicePixel( tools::Long nHeight ) const @@ -131,7 +131,7 @@ tools::Long OutputDevice::LogicHeightToDevicePixel( tools::Long nHeight ) const if ( !mpMapper->IsMapModeEnabled() ) return nHeight; - return lcl_logicToPixel(nHeight, GetDPIY(), maMapRes.mfMapScY); + return lcl_logicToPixel(nHeight, GetDPIY(), mpMapper->GetMapResolutionScaleY()); } tools::Long OutputDevice::DevicePixelToLogicWidth( tools::Long nWidth ) const @@ -139,7 +139,7 @@ tools::Long OutputDevice::DevicePixelToLogicWidth( tools::Long nWidth ) const if ( !mpMapper->IsMapModeEnabled() ) return nWidth; - return lcl_pixelToLogic(nWidth, GetDPIX(), maMapRes.mfMapScX); + return lcl_pixelToLogic(nWidth, GetDPIX(), mpMapper->GetMapResolutionScaleX()); } SAL_DLLPRIVATE double OutputDevice::ImplDevicePixelToLogicWidthDouble(double nWidth) const @@ -147,7 +147,7 @@ SAL_DLLPRIVATE double OutputDevice::ImplDevicePixelToLogicWidthDouble(double nWi if (!mpMapper->IsMapModeEnabled()) return nWidth; - return lcl_pixelToLogicDouble(nWidth, GetDPIX(), maMapRes.mfMapScX); + return lcl_pixelToLogicDouble(nWidth, GetDPIX(), mpMapper->GetMapResolutionScaleX()); } tools::Long OutputDevice::DevicePixelToLogicHeight( tools::Long nHeight ) const @@ -155,7 +155,7 @@ tools::Long OutputDevice::DevicePixelToLogicHeight( tools::Long nHeight ) const if ( !mpMapper->IsMapModeEnabled() ) return nHeight; - return lcl_pixelToLogic(nHeight, GetDPIY(), maMapRes.mfMapScY); + return lcl_pixelToLogic(nHeight, GetDPIY(), mpMapper->GetMapResolutionScaleY()); } double OutputDevice::ImplDevicePixelToLogicHeightDouble(double nHeight) const @@ -163,7 +163,7 @@ double OutputDevice::ImplDevicePixelToLogicHeightDouble(double nHeight) const if (!mpMapper->IsMapModeEnabled()) return nHeight; - return lcl_pixelToLogicDouble(nHeight, GetDPIY(), maMapRes.mfMapScY); + return lcl_pixelToLogicDouble(nHeight, GetDPIY(), mpMapper->GetMapResolutionScaleY()); } Point OutputDevice::LogicToDevicePixel(const Point& rLogicPt) const @@ -171,10 +171,10 @@ Point OutputDevice::LogicToDevicePixel(const Point& rLogicPt) const if ( !mpMapper->IsMapModeEnabled() ) return Point( rLogicPt.X()+GetOutOffXPixel(), rLogicPt.Y()+GetOutOffYPixel() ); - return Point( lcl_logicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - lcl_logicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY ); + return Point( lcl_logicToPixel( rLogicPt.X() + mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rLogicPt.Y() + mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset() ); } Size OutputDevice::ImplLogicToDevicePixel( const Size& rLogicSize ) const @@ -183,9 +183,9 @@ Size OutputDevice::ImplLogicToDevicePixel( const Size& rLogicSize ) const return rLogicSize; return Size( lcl_logicToPixel( rLogicSize.Width(), GetDPIX(), - maMapRes.mfMapScX ), + mpMapper->GetMapResolutionScaleX() ), lcl_logicToPixel( rLogicSize.Height(), GetDPIY(), - maMapRes.mfMapScY ) ); + mpMapper->GetMapResolutionScaleY() ) ); } tools::Rectangle OutputDevice::LogicToDevicePixel(const tools::Rectangle& rLogicRect) const @@ -219,10 +219,10 @@ tools::Rectangle OutputDevice::LogicToDevicePixel(const tools::Rectangle& rLogic else { aRetval = tools::Rectangle( - lcl_logicToPixel( rLogicRect.Left()+maMapRes.mnMapOfsX, GetDPIX(), maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - lcl_logicToPixel( rLogicRect.Top()+maMapRes.mnMapOfsY, GetDPIY(), maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY, - rLogicRect.IsWidthEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Right()+maMapRes.mnMapOfsX, GetDPIX(), maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - rLogicRect.IsHeightEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Bottom()+maMapRes.mnMapOfsY, GetDPIY(), maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY ); + lcl_logicToPixel( rLogicRect.Left()+mpMapper->GetMappingXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rLogicRect.Top()+mpMapper->GetMappingYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset(), + rLogicRect.IsWidthEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Right()+mpMapper->GetMappingXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + rLogicRect.IsHeightEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Bottom()+mpMapper->GetMappingYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset() ); } if(rLogicRect.IsWidthEmpty()) @@ -250,10 +250,10 @@ tools::Polygon OutputDevice::ImplLogicToDevicePixel( const tools::Polygon& rLogi for (sal_uInt16 i = 0; i < nPoints; i++) { const Point& rPt = pPointAry[i]; - Point aPt(lcl_logicToPixel( rPt.X()+maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - lcl_logicToPixel( rPt.Y()+maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY); + Point aPt(lcl_logicToPixel( rPt.X()+mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rPt.Y()+mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset()); aPoly[i] = aPt; } } @@ -287,20 +287,20 @@ basegfx::B2DPolygon OutputDevice::ImplLogicToDevicePixel(const basegfx::B2DPolyg for (sal_uInt32 i = 0; i < nPoints; ++i) { const basegfx::B2DPoint& rPt = aPoly.getB2DPoint(i); - basegfx::B2DPoint aPt(lcl_logicToPixel( rPt.getX()+maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - lcl_logicToPixel( rPt.getY()+maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY); + basegfx::B2DPoint aPt(lcl_logicToPixel( rPt.getX()+mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rPt.getY()+mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset()); const bool bC1 = aPoly.isPrevControlPointUsed(i); if (bC1) { const basegfx::B2DPoint aB2DC1(aPoly.getPrevControlPoint(i)); - aC1 = basegfx::B2DPoint(lcl_logicToPixel( aB2DC1.getX()+maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - lcl_logicToPixel( aB2DC1.getY()+maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY); + aC1 = basegfx::B2DPoint(lcl_logicToPixel( aB2DC1.getX()+mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( aB2DC1.getY()+mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset()); } const bool bC2 = aPoly.isNextControlPointUsed(i); @@ -308,10 +308,10 @@ basegfx::B2DPolygon OutputDevice::ImplLogicToDevicePixel(const basegfx::B2DPolyg { const basegfx::B2DPoint aB2DC2(aPoly.getNextControlPoint(i)); - aC2 = basegfx::B2DPoint(lcl_logicToPixel( aB2DC2.getX()+maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+GetOutOffXPixel()+mnOutOffOrigX, - lcl_logicToPixel( aB2DC2.getY()+maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+GetOutOffYPixel()+mnOutOffOrigY); + aC2 = basegfx::B2DPoint(lcl_logicToPixel( aB2DC2.getX()+mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+GetOutOffXPixel()+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( aB2DC2.getY()+mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+GetOutOffYPixel()+mpMapper->GetPixelYOffset()); } aPoly.setB2DPoint(i, aPt); @@ -418,10 +418,10 @@ tools::Rectangle OutputDevice::ImplDevicePixelToLogic( const tools::Rectangle& r else { aRetval = tools::Rectangle( - lcl_pixelToLogic( rPixelRect.Left()-GetOutOffXPixel()-mnOutOffOrigX, GetDPIX(), maMapRes.mfMapScX )-maMapRes.mnMapOfsX, - lcl_pixelToLogic( rPixelRect.Top()-GetOutOffYPixel()-mnOutOffOrigY, GetDPIY(), maMapRes.mfMapScY )-maMapRes.mnMapOfsY, - rPixelRect.IsWidthEmpty() ? 0 : lcl_pixelToLogic( rPixelRect.Right()-GetOutOffXPixel()-mnOutOffOrigX, GetDPIX(), maMapRes.mfMapScX )-maMapRes.mnMapOfsX, - rPixelRect.IsHeightEmpty() ? 0 : lcl_pixelToLogic( rPixelRect.Bottom()-GetOutOffYPixel()-mnOutOffOrigY, GetDPIY(), maMapRes.mfMapScY )-maMapRes.mnMapOfsY ); + lcl_pixelToLogic( rPixelRect.Left()-GetOutOffXPixel()-mpMapper->GetPixelXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX() )-mpMapper->GetMappingXOffset(), + lcl_pixelToLogic( rPixelRect.Top()-GetOutOffYPixel()-mpMapper->GetPixelYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY() )-mpMapper->GetMappingYOffset(), + rPixelRect.IsWidthEmpty() ? 0 : lcl_pixelToLogic( rPixelRect.Right()-GetOutOffXPixel()-mpMapper->GetPixelXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX() )-mpMapper->GetMappingXOffset(), + rPixelRect.IsHeightEmpty() ? 0 : lcl_pixelToLogic( rPixelRect.Bottom()-GetOutOffYPixel()-mpMapper->GetPixelYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY() )-mpMapper->GetMappingYOffset() ); } if(rPixelRect.IsWidthEmpty()) @@ -439,7 +439,7 @@ vcl::Region OutputDevice::ImplPixelToDevicePixel( const vcl::Region& rRegion ) c return rRegion; vcl::Region aRegion( rRegion ); - aRegion.Move( GetOutOffXPixel()+mnOutOffOrigX, GetOutOffYPixel()+mnOutOffOrigY ); + aRegion.Move( GetOutOffXPixel()+mpMapper->GetPixelXOffset(), GetOutOffYPixel()+mpMapper->GetPixelYOffset() ); return aRegion; } @@ -463,6 +463,8 @@ void OutputDevice::SetOutOffYPixel(tools::Long nOutOffY) { return mpMapper->SetO Point OutputDevice::GetOutputOffPixel() const { return mpMapper->GetOutputOffPixel(); } +Size OutputDevice::GetPixelOffset() const { return mpMapper->GetPixelOffset(); } + bool OutputDevice::IsMapModeEnabled() const { return mpMapper->IsMapModeEnabled(); } void OutputDevice::EnableMapMode(bool bEnabled) { mpMapper->EnableMapMode(bEnabled); } @@ -486,8 +488,7 @@ void OutputDevice::SetMapMode() ImplInitMapModeObjects(); // #106426# Adapt logical offset when changing mapmode - mnOutOffLogicX = mnOutOffOrigX; // no mapping -> equal offsets - mnOutOffLogicY = mnOutOffOrigY; + mpMapper->SetLogicalOffset(Size(mpMapper->GetPixelXOffset(), mpMapper->GetPixelYOffset())); // #i75163# ImplInvalidateViewTransform(); @@ -520,8 +521,8 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) { // set offset Point aOrigin = rNewMapMode.GetOrigin(); - maMapRes.mnMapOfsX = aOrigin.X(); - maMapRes.mnMapOfsY = aOrigin.Y(); + mpMapper->SetMappingXOffset(aOrigin.X()); + mpMapper->SetMappingYOffset(aOrigin.Y()); mpMapper->ResetMapMode(rNewMapMode); // #i75163# @@ -531,14 +532,14 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) } if ( !bOldMap && bRelMap ) { - maMapRes.mfMapScX = 1.0 / GetDPIX(); - maMapRes.mfMapScY = 1.0 / GetDPIY(); - maMapRes.mnMapOfsX = 0; - maMapRes.mnMapOfsY = 0; + mpMapper->SetMapResolutionScaleX(1.0 / GetDPIX()); + mpMapper->SetMapResolutionScaleY(1.0 / GetDPIY()); + mpMapper->SetMappingXOffset(0); + mpMapper->SetMappingYOffset(0); } // calculate new MapMode-resolution - maMapRes.CalcMapResolution(rNewMapMode, GetDPIX(), GetDPIY()); + mpMapper->CalcMapResolution(rNewMapMode, GetDPIX(), GetDPIY()); } // set new MapMode @@ -546,7 +547,7 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) { mpMapper->SetScaleX(mpMapper->GetScaleX() * rNewMapMode.GetScaleX()); mpMapper->SetScaleY(mpMapper->GetScaleY() * rNewMapMode.GetScaleY()); - mpMapper->SetOrigin(Point(maMapRes.mnMapOfsX, maMapRes.mnMapOfsY)); + mpMapper->SetOrigin(Point(mpMapper->GetMappingXOffset(), mpMapper->GetMappingYOffset())); } else { @@ -559,10 +560,8 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode ) ImplInitMapModeObjects(); // #106426# Adapt logical offset when changing mapmode - mnOutOffLogicX = lcl_pixelToLogic( mnOutOffOrigX, GetDPIX(), - maMapRes.mfMapScX ); - mnOutOffLogicY = lcl_pixelToLogic( mnOutOffOrigY, GetDPIY(), - maMapRes.mfMapScY ); + mpMapper->SetLogicalOffset(Size(lcl_pixelToLogic(mpMapper->GetPixelXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX()), + lcl_pixelToLogic(mpMapper->GetPixelYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY()))); // #i75163# ImplInvalidateViewTransform(); @@ -631,10 +630,8 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode ) mpMapper->ResetMapMode(rNewMapMode); // #106426# Adapt logical offset when changing MapMode - mnOutOffLogicX = lcl_pixelToLogic( mnOutOffOrigX, GetDPIX(), - maMapRes.mfMapScX ); - mnOutOffLogicY = lcl_pixelToLogic( mnOutOffOrigY, GetDPIY(), - maMapRes.mfMapScY ); + mpMapper->SetLogicalOffset(Size(lcl_pixelToLogic(mpMapper->GetPixelXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX()), + lcl_pixelToLogic(mpMapper->GetPixelYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY()))); } // #i75163# @@ -647,10 +644,10 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const { mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix; - const double fScaleFactorX(static_cast(GetDPIX()) * maMapRes.mfMapScX); - const double fScaleFactorY(static_cast(GetDPIY()) * maMapRes.mfMapScY); - const double fZeroPointX((static_cast(maMapRes.mnMapOfsX) * fScaleFactorX) + static_cast(mnOutOffOrigX)); - const double fZeroPointY((static_cast(maMapRes.mnMapOfsY) * fScaleFactorY) + static_cast(mnOutOffOrigY)); + const double fScaleFactorX(static_cast(GetDPIX()) * mpMapper->GetMapResolutionScaleX()); + const double fScaleFactorY(static_cast(GetDPIY()) * mpMapper->GetMapResolutionScaleY()); + const double fZeroPointX((static_cast(mpMapper->GetMappingXOffset()) * fScaleFactorX) + static_cast(mpMapper->GetPixelXOffset())); + const double fZeroPointY((static_cast(mpMapper->GetMappingYOffset()) * fScaleFactorY) + static_cast(mpMapper->GetPixelYOffset())); mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX); mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY); @@ -688,8 +685,8 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation( const MapMode& rMapMo const double fScaleFactorX(static_cast(GetDPIX()) * aMapRes.mfMapScX); const double fScaleFactorY(static_cast(GetDPIY()) * aMapRes.mfMapScY); - const double fZeroPointX((static_cast(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast(mnOutOffOrigX)); - const double fZeroPointY((static_cast(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast(mnOutOffOrigY)); + const double fZeroPointX((static_cast(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast(mpMapper->GetPixelXOffset())); + const double fZeroPointY((static_cast(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast(mpMapper->GetPixelYOffset())); aTransform.set(0, 0, fScaleFactorX); aTransform.set(1, 1, fScaleFactorY); @@ -722,10 +719,10 @@ Point OutputDevice::LogicToPixel( const Point& rLogicPt ) const if ( !mpMapper->IsMapModeEnabled() ) return rLogicPt; - return Point( lcl_logicToPixel( rLogicPt.X() + maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+mnOutOffOrigX, - lcl_logicToPixel( rLogicPt.Y() + maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+mnOutOffOrigY ); + return Point( lcl_logicToPixel( rLogicPt.X() + mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rLogicPt.Y() + mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+mpMapper->GetPixelYOffset() ); } Size OutputDevice::LogicToPixel( const Size& rLogicSize ) const @@ -735,9 +732,9 @@ Size OutputDevice::LogicToPixel( const Size& rLogicSize ) const return rLogicSize; return Size( lcl_logicToPixel( rLogicSize.Width(), GetDPIX(), - maMapRes.mfMapScX ), + mpMapper->GetMapResolutionScaleX() ), lcl_logicToPixel( rLogicSize.Height(), GetDPIY(), - maMapRes.mfMapScY ) ); + mpMapper->GetMapResolutionScaleY() ) ); } tools::Rectangle OutputDevice::LogicToPixel( const tools::Rectangle& rLogicRect ) const @@ -747,10 +744,10 @@ tools::Rectangle OutputDevice::LogicToPixel( const tools::Rectangle& rLogicRect return rLogicRect; tools::Rectangle aRetval( - lcl_logicToPixel( rLogicRect.Left() + maMapRes.mnMapOfsX, GetDPIX(), maMapRes.mfMapScX )+mnOutOffOrigX, - lcl_logicToPixel( rLogicRect.Top() + maMapRes.mnMapOfsY, GetDPIY(), maMapRes.mfMapScY )+mnOutOffOrigY, - rLogicRect.IsWidthEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Right() + maMapRes.mnMapOfsX, GetDPIX(), maMapRes.mfMapScX )+mnOutOffOrigX, - rLogicRect.IsHeightEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Bottom() + maMapRes.mnMapOfsY, GetDPIY(), maMapRes.mfMapScY )+mnOutOffOrigY ); + lcl_logicToPixel( rLogicRect.Left() + mpMapper->GetMappingXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX() )+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rLogicRect.Top() + mpMapper->GetMappingYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY() )+mpMapper->GetPixelYOffset(), + rLogicRect.IsWidthEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Right() + mpMapper->GetMappingXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX() )+mpMapper->GetPixelXOffset(), + rLogicRect.IsHeightEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Bottom() + mpMapper->GetMappingYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY() )+mpMapper->GetPixelYOffset() ); if(rLogicRect.IsWidthEmpty()) aRetval.SetWidthEmpty(); @@ -777,10 +774,10 @@ tools::Polygon OutputDevice::LogicToPixel( const tools::Polygon& rLogicPoly ) co { const Point* pPt = &(pPointAry[i]); Point aPt; - aPt.setX( lcl_logicToPixel( pPt->X() + maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX )+mnOutOffOrigX ); - aPt.setY( lcl_logicToPixel( pPt->Y() + maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY )+mnOutOffOrigY ); + aPt.setX( lcl_logicToPixel( pPt->X() + mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX() )+mpMapper->GetPixelXOffset() ); + aPt.setY( lcl_logicToPixel( pPt->Y() + mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY() )+mpMapper->GetPixelYOffset() ); aPoly[i] = aPt; } @@ -858,9 +855,9 @@ Point OutputDevice::LogicToPixel( const Point& rLogicPt, aMapRes.CalcMapResolution(rMapMode, GetDPIX(), GetDPIY()); return Point( lcl_logicToPixel( rLogicPt.X() + aMapRes.mnMapOfsX, GetDPIX(), - aMapRes.mfMapScX )+mnOutOffOrigX, + aMapRes.mfMapScX )+mpMapper->GetPixelXOffset(), lcl_logicToPixel( rLogicPt.Y() + aMapRes.mnMapOfsY, GetDPIY(), - aMapRes.mfMapScY )+mnOutOffOrigY ); + aMapRes.mfMapScY )+mpMapper->GetPixelYOffset() ); } Size OutputDevice::LogicToPixel( const Size& rLogicSize, @@ -892,10 +889,10 @@ tools::Rectangle OutputDevice::LogicToPixel( const tools::Rectangle& rLogicRect, aMapRes.CalcMapResolution(rMapMode, GetDPIX(), GetDPIY()); tools::Rectangle aRetval( - lcl_logicToPixel( rLogicRect.Left() + aMapRes.mnMapOfsX, GetDPIX(), aMapRes.mfMapScX )+mnOutOffOrigX, - lcl_logicToPixel( rLogicRect.Top() + aMapRes.mnMapOfsY, GetDPIY(), aMapRes.mfMapScY )+mnOutOffOrigY, - rLogicRect.IsWidthEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Right() + aMapRes.mnMapOfsX, GetDPIX(), aMapRes.mfMapScX )+mnOutOffOrigX, - rLogicRect.IsHeightEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Bottom() + aMapRes.mnMapOfsY, GetDPIY(), aMapRes.mfMapScY )+mnOutOffOrigY ); + lcl_logicToPixel( rLogicRect.Left() + aMapRes.mnMapOfsX, GetDPIX(), aMapRes.mfMapScX )+mpMapper->GetPixelXOffset(), + lcl_logicToPixel( rLogicRect.Top() + aMapRes.mnMapOfsY, GetDPIY(), aMapRes.mfMapScY )+mpMapper->GetPixelYOffset(), + rLogicRect.IsWidthEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Right() + aMapRes.mnMapOfsX, GetDPIX(), aMapRes.mfMapScX )+mpMapper->GetPixelXOffset(), + rLogicRect.IsHeightEmpty() ? 0 : lcl_logicToPixel( rLogicRect.Bottom() + aMapRes.mnMapOfsY, GetDPIY(), aMapRes.mfMapScY )+mpMapper->GetPixelYOffset() ); if(rLogicRect.IsWidthEmpty()) aRetval.SetWidthEmpty(); @@ -928,9 +925,9 @@ tools::Polygon OutputDevice::LogicToPixel( const tools::Polygon& rLogicPoly, const Point* pPt = &(pPointAry[i]); Point aPt; aPt.setX( lcl_logicToPixel( pPt->X() + aMapRes.mnMapOfsX, GetDPIX(), - aMapRes.mfMapScX )+mnOutOffOrigX ); + aMapRes.mfMapScX )+mpMapper->GetPixelXOffset() ); aPt.setY( lcl_logicToPixel( pPt->Y() + aMapRes.mnMapOfsY, GetDPIY(), - aMapRes.mfMapScY )+mnOutOffOrigY ); + aMapRes.mfMapScY )+mpMapper->GetPixelYOffset() ); aPoly[i] = aPt; } @@ -953,9 +950,9 @@ Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const return rDevicePt; return Point( lcl_pixelToLogic( rDevicePt.X(), GetDPIX(), - maMapRes.mfMapScX ) - maMapRes.mnMapOfsX - mnOutOffLogicX, + mpMapper->GetMapResolutionScaleX() ) - mpMapper->GetMappingXOffset() - mpMapper->GetLogicalXOffset(), lcl_pixelToLogic( rDevicePt.Y(), GetDPIY(), - maMapRes.mfMapScY ) - maMapRes.mnMapOfsY - mnOutOffLogicY ); + mpMapper->GetMapResolutionScaleY() ) - mpMapper->GetMappingYOffset() - mpMapper->GetLogicalYOffset() ); } Point OutputDevice::SubPixelToLogic(const basegfx::B2DPoint& rDevicePt) const @@ -967,9 +964,9 @@ Point OutputDevice::SubPixelToLogic(const basegfx::B2DPoint& rDevicePt) const } return Point(ImplSubPixelToLogic(rDevicePt.getX(), GetDPIX(), - maMapRes.mfMapScX) - maMapRes.mnMapOfsX - mnOutOffLogicX, + mpMapper->GetMapResolutionScaleX()) - mpMapper->GetMappingXOffset() - mpMapper->GetLogicalXOffset(), ImplSubPixelToLogic(rDevicePt.getY(), GetDPIY(), - maMapRes.mfMapScY) - maMapRes.mnMapOfsY - mnOutOffLogicY); + mpMapper->GetMapResolutionScaleY()) - mpMapper->GetMappingYOffset() - mpMapper->GetLogicalYOffset()); } Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const @@ -979,9 +976,9 @@ Size OutputDevice::PixelToLogic( const Size& rDeviceSize ) const return rDeviceSize; return Size( lcl_pixelToLogic( rDeviceSize.Width(), GetDPIX(), - maMapRes.mfMapScX ), + mpMapper->GetMapResolutionScaleX() ), lcl_pixelToLogic( rDeviceSize.Height(), GetDPIY(), - maMapRes.mfMapScY ) ); + mpMapper->GetMapResolutionScaleY() ) ); } tools::Rectangle OutputDevice::PixelToLogic( const tools::Rectangle& rDeviceRect ) const @@ -991,10 +988,10 @@ tools::Rectangle OutputDevice::PixelToLogic( const tools::Rectangle& rDeviceRect return rDeviceRect; tools::Rectangle aRetval( - lcl_pixelToLogic( rDeviceRect.Left(), GetDPIX(), maMapRes.mfMapScX ) - maMapRes.mnMapOfsX - mnOutOffLogicX, - lcl_pixelToLogic( rDeviceRect.Top(), GetDPIY(), maMapRes.mfMapScY ) - maMapRes.mnMapOfsY - mnOutOffLogicY, - rDeviceRect.IsWidthEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Right(), GetDPIX(), maMapRes.mfMapScX ) - maMapRes.mnMapOfsX - mnOutOffLogicX, - rDeviceRect.IsHeightEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Bottom(), GetDPIY(), maMapRes.mfMapScY ) - maMapRes.mnMapOfsY - mnOutOffLogicY ); + lcl_pixelToLogic( rDeviceRect.Left(), GetDPIX(), mpMapper->GetMapResolutionScaleX() ) - mpMapper->GetMappingXOffset() - mpMapper->GetLogicalXOffset(), + lcl_pixelToLogic( rDeviceRect.Top(), GetDPIY(), mpMapper->GetMapResolutionScaleY() ) - mpMapper->GetMappingYOffset() - mpMapper->GetLogicalYOffset(), + rDeviceRect.IsWidthEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Right(), GetDPIX(), mpMapper->GetMapResolutionScaleX() ) - mpMapper->GetMappingXOffset() - mpMapper->GetLogicalXOffset(), + rDeviceRect.IsHeightEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Bottom(), GetDPIY(), mpMapper->GetMapResolutionScaleY() ) - mpMapper->GetMappingYOffset() - mpMapper->GetLogicalYOffset() ); if(rDeviceRect.IsWidthEmpty()) aRetval.SetWidthEmpty(); @@ -1022,9 +1019,9 @@ tools::Polygon OutputDevice::PixelToLogic( const tools::Polygon& rDevicePoly ) c const Point* pPt = &(pPointAry[i]); Point aPt; aPt.setX( lcl_pixelToLogic( pPt->X(), GetDPIX(), - maMapRes.mfMapScX ) - maMapRes.mnMapOfsX - mnOutOffLogicX ); + mpMapper->GetMapResolutionScaleX() ) - mpMapper->GetMappingXOffset() - mpMapper->GetLogicalXOffset() ); aPt.setY( lcl_pixelToLogic( pPt->Y(), GetDPIY(), - maMapRes.mfMapScY ) - maMapRes.mnMapOfsY - mnOutOffLogicY ); + mpMapper->GetMapResolutionScaleY() ) - mpMapper->GetMappingYOffset() - mpMapper->GetLogicalYOffset() ); aPoly[i] = aPt; } @@ -1111,9 +1108,9 @@ Point OutputDevice::PixelToLogic( const Point& rDevicePt, aMapRes.CalcMapResolution(rMapMode, GetDPIX(), GetDPIY()); return Point( lcl_pixelToLogic( rDevicePt.X(), GetDPIX(), - aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mnOutOffLogicX, + aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mpMapper->GetLogicalXOffset(), lcl_pixelToLogic( rDevicePt.Y(), GetDPIY(), - aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mnOutOffLogicY ); + aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mpMapper->GetLogicalYOffset() ); } Size OutputDevice::PixelToLogic( const Size& rDeviceSize, @@ -1147,10 +1144,10 @@ tools::Rectangle OutputDevice::PixelToLogic( const tools::Rectangle& rDeviceRect aMapRes.CalcMapResolution(rMapMode, GetDPIX(), GetDPIY()); tools::Rectangle aRetval( - lcl_pixelToLogic( rDeviceRect.Left(), GetDPIX(), aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mnOutOffLogicX, - lcl_pixelToLogic( rDeviceRect.Top(), GetDPIY(), aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mnOutOffLogicY, - rDeviceRect.IsWidthEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Right(), GetDPIX(), aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mnOutOffLogicX, - rDeviceRect.IsHeightEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Bottom(), GetDPIY(), aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mnOutOffLogicY ); + lcl_pixelToLogic( rDeviceRect.Left(), GetDPIX(), aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mpMapper->GetLogicalXOffset(), + lcl_pixelToLogic( rDeviceRect.Top(), GetDPIY(), aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mpMapper->GetLogicalYOffset(), + rDeviceRect.IsWidthEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Right(), GetDPIX(), aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mpMapper->GetLogicalXOffset(), + rDeviceRect.IsHeightEmpty() ? 0 : lcl_pixelToLogic( rDeviceRect.Bottom(), GetDPIY(), aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mpMapper->GetLogicalYOffset() ); if(rDeviceRect.IsWidthEmpty()) aRetval.SetWidthEmpty(); @@ -1184,9 +1181,9 @@ tools::Polygon OutputDevice::PixelToLogic( const tools::Polygon& rDevicePoly, const Point* pPt = &(pPointAry[i]); Point aPt; aPt.setX( lcl_pixelToLogic( pPt->X(), GetDPIX(), - aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mnOutOffLogicX ); + aMapRes.mfMapScX ) - aMapRes.mnMapOfsX - mpMapper->GetLogicalXOffset() ); aPt.setY( lcl_pixelToLogic( pPt->Y(), GetDPIY(), - aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mnOutOffLogicY ); + aMapRes.mfMapScY ) - aMapRes.mnMapOfsY - mpMapper->GetLogicalYOffset() ); aPoly[i] = aPt; } @@ -1211,24 +1208,6 @@ basegfx::B2DPolyPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolyPolygo return aTransformedPoly; } -static ImplMapRes lcl_resolveMapRes(const MapMode* pMode, const MapMode& rDefaultMapMode, const ImplMapRes& rDefaultMapRes, - bool bMap, tools::Long nDPIX, tools::Long nDPIY) -{ - const MapMode* pEffectiveMode = pMode ? pMode : &rDefaultMapMode; - - if (bMap && pEffectiveMode == &rDefaultMapMode) - return rDefaultMapRes; - - ImplMapRes aRes; - - if (pEffectiveMode->GetMapUnit() == MapUnit::MapRelative) - aRes = rDefaultMapRes; // Pre-fill, do NOT return early - - aRes.CalcMapResolution(*pEffectiveMode, nDPIX, nDPIY); - - return aRes; -} - static void lcl_verifyUnitSourceDest( MapUnit eUnitSource, MapUnit eUnitDest ) { DBG_ASSERT( eUnitSource != MapUnit::MapSysFont @@ -1316,8 +1295,8 @@ Point OutputDevice::LogicToLogic( const Point& rPtSource, if (*pSrc == *pDst) return rPtSource; - ImplMapRes aMapResSource = lcl_resolveMapRes(pMapModeSource, mpMapper->GetMapMode(), maMapRes, mpMapper->IsMapModeEnabled(), GetDPIX(), GetDPIY()); - ImplMapRes aMapResDest = lcl_resolveMapRes(pMapModeDest, mpMapper->GetMapMode(), maMapRes, mpMapper->IsMapModeEnabled(), GetDPIX(), GetDPIY()); + ImplMapRes aMapResSource = mpMapper->ResolveMapRes(pMapModeSource); + ImplMapRes aMapResDest = mpMapper->ResolveMapRes(pMapModeDest); return Point( lcl_scaleLogicValue( rPtSource.X() + aMapResSource.mnMapOfsX, aMapResSource.mfMapScX, aMapResDest.mfMapScX ) - @@ -1337,8 +1316,8 @@ Size OutputDevice::LogicToLogic( const Size& rSzSource, if (*pSrc == *pDst) return rSzSource; - ImplMapRes aMapResSource = lcl_resolveMapRes(pMapModeSource, mpMapper->GetMapMode(), maMapRes, mpMapper->IsMapModeEnabled(), GetDPIX(), GetDPIY()); - ImplMapRes aMapResDest = lcl_resolveMapRes(pMapModeDest, mpMapper->GetMapMode(), maMapRes, mpMapper->IsMapModeEnabled(), GetDPIX(), GetDPIY()); + ImplMapRes aMapResSource = mpMapper->ResolveMapRes(pMapModeSource); + ImplMapRes aMapResDest = mpMapper->ResolveMapRes(pMapModeDest); return Size( lcl_scaleLogicValue( rSzSource.Width(), aMapResSource.mfMapScX, aMapResDest.mfMapScX ), @@ -1356,8 +1335,8 @@ tools::Rectangle OutputDevice::LogicToLogic( const tools::Rectangle& rRectSource if (*pSrc == *pDst) return rRectSource; - ImplMapRes aMapResSource = lcl_resolveMapRes(pMapModeSource, mpMapper->GetMapMode(), maMapRes, mpMapper->IsMapModeEnabled(), GetDPIX(), GetDPIY()); - ImplMapRes aMapResDest = lcl_resolveMapRes(pMapModeDest, mpMapper->GetMapMode(), maMapRes, mpMapper->IsMapModeEnabled(), GetDPIX(), GetDPIY()); + ImplMapRes aMapResSource = mpMapper->ResolveMapRes(pMapModeSource); + ImplMapRes aMapResDest = mpMapper->ResolveMapRes(pMapModeDest); return tools::Rectangle( lcl_scaleLogicValue( rRectSource.Left() + aMapResSource.mnMapOfsX, aMapResSource.mfMapScX, aMapResDest.mfMapScX ) - @@ -1551,23 +1530,19 @@ tools::Long OutputDevice::LogicToLogic( tools::Long nLongSource, void OutputDevice::SetPixelOffset( const Size& rOffset ) { - mnOutOffOrigX = rOffset.Width(); - mnOutOffOrigY = rOffset.Height(); + mpMapper->SetPixelOffset(rOffset); - mnOutOffLogicX = lcl_pixelToLogic( mnOutOffOrigX, GetDPIX(), - maMapRes.mfMapScX ); - mnOutOffLogicY = lcl_pixelToLogic( mnOutOffOrigY, GetDPIY(), - maMapRes.mfMapScY ); + mpMapper->SetLogicalOffset(Size(lcl_pixelToLogic(mpMapper->GetPixelXOffset(), GetDPIX(), mpMapper->GetMapResolutionScaleX()), + lcl_pixelToLogic(mpMapper->GetPixelYOffset(), GetDPIY(), mpMapper->GetMapResolutionScaleY()))); } - double OutputDevice::LogicWidthToDeviceSubPixel(tools::Long nWidth) const { if (!mpMapper->IsMapModeEnabled()) return nWidth; return ImplLogicToSubPixel(nWidth, GetDPIX(), - maMapRes.mfMapScX); + mpMapper->GetMapResolutionScaleX()); } double OutputDevice::LogicHeightToDeviceSubPixel(tools::Long nHeight) const @@ -1576,7 +1551,7 @@ double OutputDevice::LogicHeightToDeviceSubPixel(tools::Long nHeight) const return nHeight; return ImplLogicToSubPixel(nHeight, GetDPIY(), - maMapRes.mfMapScY); + mpMapper->GetMapResolutionScaleY()); } basegfx::B2DPoint OutputDevice::LogicToDeviceSubPixel(const Point& rPoint) const @@ -1584,12 +1559,12 @@ basegfx::B2DPoint OutputDevice::LogicToDeviceSubPixel(const Point& rPoint) const if (!mpMapper->IsMapModeEnabled()) return basegfx::B2DPoint(rPoint.X() + GetOutOffXPixel(), rPoint.Y() + GetOutOffYPixel()); - return basegfx::B2DPoint(ImplLogicToSubPixel(rPoint.X() + maMapRes.mnMapOfsX, GetDPIX(), - maMapRes.mfMapScX) - + GetOutOffXPixel() + mnOutOffOrigX, - ImplLogicToSubPixel(rPoint.Y() + maMapRes.mnMapOfsY, GetDPIY(), - maMapRes.mfMapScY) - + GetOutOffYPixel() + mnOutOffOrigY); + return basegfx::B2DPoint(ImplLogicToSubPixel(rPoint.X() + mpMapper->GetMappingXOffset(), GetDPIX(), + mpMapper->GetMapResolutionScaleX()) + + GetOutOffXPixel() + mpMapper->GetPixelXOffset(), + ImplLogicToSubPixel(rPoint.Y() + mpMapper->GetMappingYOffset(), GetDPIY(), + mpMapper->GetMapResolutionScaleY()) + + GetOutOffYPixel() + mpMapper->GetPixelYOffset()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 3d597210db1a..8dfc0e3c0bb0 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -79,10 +79,6 @@ OutputDevice::OutputDevice(OutDevType eOutDevType) : mpExtOutDevData = nullptr; mnTextOffX = 0; mnTextOffY = 0; - mnOutOffOrigX = 0; - mnOutOffLogicX = 0; - mnOutOffOrigY = 0; - mnOutOffLogicY = 0; mnEmphasisAscent = 0; mnEmphasisDescent = 0; mnDrawMode = DrawModeFlags::Default; @@ -117,12 +113,6 @@ OutputDevice::OutputDevice(OutDevType eOutDevType) : mbEnableRTL = false; // mirroring must be explicitly allowed (typically for windows only) mbSubpixelPositioning = false; // tdf#168002 allow SubpixelPositioning (default: false) - // struct ImplMapRes - maMapRes.mnMapOfsX = 0; - maMapRes.mnMapOfsY = 0; - maMapRes.mfMapScX = 1; - maMapRes.mfMapScY = 1; - // struct ImplOutDevData- see #i82615# mpOutDevData.reset(new ImplOutDevData); mpOutDevData->mpRotateDev = nullptr; diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 3c756b651322..eba15eb608b6 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -2086,7 +2086,7 @@ bool OutputDevice::GetTextBoundRect(basegfx::B2DRectangle& rRect, const OUString rRect = PixelToLogic( aPixelRect ); if (mpMapper->IsMapModeEnabled()) { - rRect.translate(maMapRes.mnMapOfsX, maMapRes.mnMapOfsY); + rRect.translate(mpMapper->GetMappingXOffset(), mpMapper->GetMappingYOffset()); } } }