Fraction->double in MapMode
Change-Id: I865fe1c2b0377eebda6f9f19e163928cbe7c9056 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202631 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
a4eba67c99
commit
e77b23fa1c
@@ -1141,9 +1141,9 @@ static double GetDialogZoomFactor( bool bX, tools::Long nValue )
|
||||
if( pDevice )
|
||||
{
|
||||
Size aRefSize( nValue, nValue );
|
||||
Fraction aFracX( 1, 26 );
|
||||
Fraction aFracY( 1, 24 );
|
||||
MapMode aMap( MapUnit::MapAppFont, Point(), aFracX, aFracY );
|
||||
double fFracX = 1.0 / 26;
|
||||
double fFracY = 1.0 / 24;
|
||||
MapMode aMap( MapUnit::MapAppFont, Point(), fFracX, fFracY );
|
||||
Size aScaledSize = pDevice->LogicToPixel( aRefSize, aMap );
|
||||
aRefSize = pDevice->LogicToPixel( aRefSize, MapMode(MapUnit::MapTwip) );
|
||||
|
||||
|
||||
@@ -249,26 +249,26 @@ void SAL_CALL ChartController::setPosSize(
|
||||
//todo: for standalone chart: detect whether we are standalone
|
||||
//change map mode to fit new size
|
||||
awt::Size aModelPageSize = getChartModel()->getPageSize();
|
||||
sal_Int32 nScaleXNumerator = aLogicSize.Width();
|
||||
sal_Int32 nScaleXDenominator = aModelPageSize.Width;
|
||||
sal_Int32 nScaleYNumerator = aLogicSize.Height();
|
||||
sal_Int32 nScaleYDenominator = aModelPageSize.Height;
|
||||
double fScaleX = double(aLogicSize.Width()) / aModelPageSize.Width;
|
||||
double fScaleY = double(aLogicSize.Height()) / aModelPageSize.Height;
|
||||
MapMode aNewMapMode(
|
||||
MapUnit::Map100thMM,
|
||||
Point(0,0),
|
||||
Fraction(nScaleXNumerator, nScaleXDenominator),
|
||||
Fraction(nScaleYNumerator, nScaleYDenominator) );
|
||||
fScaleX,
|
||||
fScaleY );
|
||||
pChartWindow->SetMapMode(aNewMapMode);
|
||||
pChartWindow->setPosSizePixel( X, Y, Width, Height, static_cast<PosSizeFlags>(Flags) );
|
||||
|
||||
//#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
|
||||
if( m_xChartView.is() )
|
||||
{
|
||||
Fraction aScaleXFrac(fScaleX);
|
||||
Fraction aScaleYFrac(fScaleY);
|
||||
auto aZoomFactors(::comphelper::InitPropertySequence({
|
||||
{ "ScaleXNumerator", uno::Any( nScaleXNumerator ) },
|
||||
{ "ScaleXDenominator", uno::Any( nScaleXDenominator ) },
|
||||
{ "ScaleYNumerator", uno::Any( nScaleYNumerator ) },
|
||||
{ "ScaleYDenominator", uno::Any( nScaleYDenominator ) }
|
||||
{ "ScaleXNumerator", uno::Any( aScaleXFrac.GetNumerator() ) },
|
||||
{ "ScaleXDenominator", uno::Any( aScaleXFrac.GetDenominator() ) },
|
||||
{ "ScaleYNumerator", uno::Any( aScaleYFrac.GetNumerator() ) },
|
||||
{ "ScaleYDenominator", uno::Any( aScaleYFrac.GetDenominator() ) }
|
||||
}));
|
||||
m_xChartView->setPropertyValue( u"ZoomFactors"_ustr, uno::Any( aZoomFactors ));
|
||||
}
|
||||
|
||||
@@ -287,20 +287,17 @@ void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle)
|
||||
{
|
||||
MapMode aCWMapMode = GetMapMode();
|
||||
constexpr auto p = o3tl::getConversionMulDiv(o3tl::Length::px, o3tl::Length::twip);
|
||||
const auto& scaleX = aCWMapMode.GetScaleX();
|
||||
const auto& scaleY = aCWMapMode.GetScaleY();
|
||||
const auto nXNum = p.first * scaleX.GetDenominator();
|
||||
const auto nXDen = p.second * scaleX.GetNumerator();
|
||||
const auto nYNum = p.first * scaleY.GetDenominator();
|
||||
const auto nYDen = p.second * scaleY.GetNumerator();
|
||||
const double scaleX = aCWMapMode.GetScaleX();
|
||||
const double scaleY = aCWMapMode.GetScaleY();
|
||||
const double nX = p.first * scaleX / p.second;
|
||||
const double nY = p.first * scaleY / p.second;
|
||||
|
||||
if (!IsMapModeEnabled())
|
||||
{
|
||||
aRectangle = aRectangle.scale(scaleX.GetDenominator(), scaleX.GetNumerator(),
|
||||
scaleY.GetDenominator(), scaleY.GetNumerator());
|
||||
aRectangle = aRectangle.scale(1.0 / scaleX, 1.0 / scaleY);
|
||||
}
|
||||
|
||||
Point aOffset = this->GetOffsetPixelFrom(*pEditWin).scale(nXNum, nXDen, nYNum, nYDen);
|
||||
Point aOffset = this->GetOffsetPixelFrom(*pEditWin).scale(nX, nY);
|
||||
|
||||
aRectangle = tools::Rectangle(aRectangle.TopLeft() + aOffset, aRectangle.GetSize());
|
||||
}
|
||||
@@ -355,19 +352,17 @@ tools::Rectangle ChartWindow::GetBoundingBox()
|
||||
// returns the chart bounding box in twips.
|
||||
MapMode aCWMapMode = GetMapMode();
|
||||
constexpr auto p = o3tl::getConversionMulDiv(o3tl::Length::px, o3tl::Length::twip);
|
||||
const auto& scaleX = aCWMapMode.GetScaleX();
|
||||
const auto& scaleY = aCWMapMode.GetScaleY();
|
||||
const auto nXNum = p.first * scaleX.GetDenominator();
|
||||
const auto nXDen = p.second * scaleX.GetNumerator();
|
||||
const auto nYNum = p.first * scaleY.GetDenominator();
|
||||
const auto nYDen = p.second * scaleY.GetNumerator();
|
||||
const double scaleX = aCWMapMode.GetScaleX();
|
||||
const double scaleY = aCWMapMode.GetScaleY();
|
||||
const double nX = p.first * scaleX / p.second;
|
||||
const double nY = p.first * scaleY / p.second;
|
||||
|
||||
Point aOffset = GetOffsetPixelFrom(*pRootWin);
|
||||
aOffset.setX( o3tl::convert(aOffset.X(), nXNum, nXDen) );
|
||||
aOffset.setY( o3tl::convert(aOffset.Y(), nYNum, nYDen) );
|
||||
aOffset.setX( aOffset.X() * nX );
|
||||
aOffset.setY( aOffset.Y() * nY );
|
||||
Size aSize = GetSizePixel();
|
||||
aSize.setWidth( o3tl::convert(aSize.Width(), nXNum, nXDen) );
|
||||
aSize.setHeight( o3tl::convert(aSize.Height(), nYNum, nYDen) );
|
||||
aSize.setWidth( aSize.Width() * nX );
|
||||
aSize.setHeight( aSize.Height() * nY );
|
||||
aBBox = tools::Rectangle(aOffset, aSize);
|
||||
}
|
||||
return aBBox;
|
||||
|
||||
@@ -824,14 +824,14 @@ void SvxCropExample::SetFrameSize( const Size& rSz )
|
||||
if (!m_aFrameSize.Height())
|
||||
m_aFrameSize.setHeight( 1 );
|
||||
Size aWinSize( GetOutputSizePixel() );
|
||||
Fraction aXScale( aWinSize.Width() * 4, m_aFrameSize.Width() * 5 );
|
||||
Fraction aYScale( aWinSize.Height() * 4, m_aFrameSize.Height() * 5 );
|
||||
double fXScale = double( aWinSize.Width() * 4 ) / (m_aFrameSize.Width() * 5 );
|
||||
double fYScale = double( aWinSize.Height() * 4) / (m_aFrameSize.Height() * 5 );
|
||||
|
||||
if( aYScale < aXScale )
|
||||
aXScale = aYScale;
|
||||
if( fYScale < fXScale )
|
||||
fXScale = fYScale;
|
||||
|
||||
m_aMapMode.SetScaleX(aXScale);
|
||||
m_aMapMode.SetScaleY(aXScale);
|
||||
m_aMapMode.SetScaleX(fXScale);
|
||||
m_aMapMode.SetScaleY(fXScale);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace
|
||||
basegfx::B2DHomMatrix getTransformFromMapMode(const MapMode& rMapMode)
|
||||
{
|
||||
basegfx::B2DHomMatrix aMapping;
|
||||
const Fraction aNoScale(1, 1);
|
||||
const double fNoScale = 1.0;
|
||||
const Point& rOrigin(rMapMode.GetOrigin());
|
||||
|
||||
if (0 != rOrigin.X() || 0 != rOrigin.Y())
|
||||
@@ -106,9 +106,9 @@ basegfx::B2DHomMatrix getTransformFromMapMode(const MapMode& rMapMode)
|
||||
aMapping.translate(rOrigin.X(), rOrigin.Y());
|
||||
}
|
||||
|
||||
if (rMapMode.GetScaleX() != aNoScale || rMapMode.GetScaleY() != aNoScale)
|
||||
if (rMapMode.GetScaleX() != fNoScale || rMapMode.GetScaleY() != fNoScale)
|
||||
{
|
||||
aMapping.scale(double(rMapMode.GetScaleX()), double(rMapMode.GetScaleY()));
|
||||
aMapping.scale(rMapMode.GetScaleX(), rMapMode.GetScaleY());
|
||||
}
|
||||
|
||||
return aMapping;
|
||||
@@ -361,22 +361,11 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
|
||||
basegfx::fround<tools::Long>(aCurrentTranslate.getY()
|
||||
/ aCurrentScaling.getY()));
|
||||
|
||||
Fraction aScaleX(aCurrentScaling.getX());
|
||||
if (!aScaleX.IsValid())
|
||||
{
|
||||
SAL_WARN("drawinglayer", "invalid X Scale");
|
||||
return;
|
||||
}
|
||||
double fScaleX(aCurrentScaling.getX());
|
||||
double fScaleY(aCurrentScaling.getY());
|
||||
|
||||
Fraction aScaleY(aCurrentScaling.getY());
|
||||
if (!aScaleY.IsValid())
|
||||
{
|
||||
SAL_WARN("drawinglayer", "invalid Y Scale");
|
||||
return;
|
||||
}
|
||||
|
||||
MapMode aMapMode(mpOutputDevice->GetMapMode().GetMapUnit(), aOrigin, aScaleX,
|
||||
aScaleY);
|
||||
MapMode aMapMode(mpOutputDevice->GetMapMode().GetMapUnit(), aOrigin, fScaleX,
|
||||
fScaleY);
|
||||
bChangeMapMode = aMapMode != mpOutputDevice->GetMapMode();
|
||||
if (bChangeMapMode)
|
||||
{
|
||||
@@ -434,24 +423,17 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
|
||||
aMapMode.SetScaleX(aMapMode.GetScaleX() * nFontScalingFixX);
|
||||
aMapMode.SetScaleY(aMapMode.GetScaleY() * nFontScalingFixY);
|
||||
|
||||
const bool bValidScaling
|
||||
= aMapMode.GetScaleX().IsValid() && aMapMode.GetScaleY().IsValid();
|
||||
if (!bValidScaling)
|
||||
SAL_WARN("drawinglayer", "skipping invalid scaling");
|
||||
else
|
||||
{
|
||||
assert(nFontScalingFixX != 0 && nFontScalingFixY != 0
|
||||
&& "or bValidScaling would be false");
|
||||
assert(nFontScalingFixX != 0 && nFontScalingFixY != 0
|
||||
&& "or bValidScaling would be false");
|
||||
|
||||
Point origin = aMapMode.GetOrigin();
|
||||
Point origin = aMapMode.GetOrigin();
|
||||
|
||||
mpOutputDevice->Push(vcl::PushFlags::MAPMODE);
|
||||
mpOutputDevice->SetRelativeMapMode(aMapMode);
|
||||
bChangeMapMode = true;
|
||||
mpOutputDevice->Push(vcl::PushFlags::MAPMODE);
|
||||
mpOutputDevice->SetRelativeMapMode(aMapMode);
|
||||
bChangeMapMode = true;
|
||||
|
||||
aPointX = (aPointX + origin.X()) / nFontScalingFixX - origin.X();
|
||||
aPointY = (aPointY + origin.Y()) / nFontScalingFixY - origin.Y();
|
||||
}
|
||||
aPointX = (aPointX + origin.X()) / nFontScalingFixX - origin.X();
|
||||
aPointY = (aPointY + origin.Y()) / nFontScalingFixY - origin.Y();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ namespace
|
||||
basegfx::B2DHomMatrix getTransformFromMapMode(const MapMode& rMapMode)
|
||||
{
|
||||
basegfx::B2DHomMatrix aMapping;
|
||||
const Fraction aNoScale(1, 1);
|
||||
const double fNoScale = 1.0;
|
||||
const Point& rOrigin(rMapMode.GetOrigin());
|
||||
|
||||
if(0 != rOrigin.X() || 0 != rOrigin.Y())
|
||||
@@ -414,11 +414,9 @@ namespace
|
||||
aMapping.translate(rOrigin.X(), rOrigin.Y());
|
||||
}
|
||||
|
||||
if(rMapMode.GetScaleX() != aNoScale || rMapMode.GetScaleY() != aNoScale)
|
||||
if(rMapMode.GetScaleX() != fNoScale || rMapMode.GetScaleY() != fNoScale)
|
||||
{
|
||||
aMapping.scale(
|
||||
double(rMapMode.GetScaleX()),
|
||||
double(rMapMode.GetScaleY()));
|
||||
aMapping.scale(rMapMode.GetScaleX(), rMapMode.GetScaleY());
|
||||
}
|
||||
|
||||
return aMapping;
|
||||
|
||||
@@ -1544,8 +1544,8 @@ namespace emfio
|
||||
Size aDevExt( 10000, 10000 );
|
||||
if( ( std::abs( aWMFSize.Width() ) > 1 ) && ( std::abs( aWMFSize.Height() ) > 1 ) )
|
||||
{
|
||||
const Fraction aFrac( 1, mnUnitsPerInch);
|
||||
MapMode aWMFMap( MapUnit::MapInch, Point(), aFrac, aFrac );
|
||||
const double fFrac = 1.0 / mnUnitsPerInch;
|
||||
MapMode aWMFMap( MapUnit::MapInch, Point(), fFrac, fFrac );
|
||||
Size aSize100(OutputDevice::LogicToLogic(aWMFSize, aWMFMap, MapMode(MapUnit::Map100thMM)));
|
||||
aDevExt = Size( std::abs( aSize100.Width() ), std::abs( aSize100.Height() ) );
|
||||
}
|
||||
|
||||
@@ -211,9 +211,9 @@ void Impl_OlePres::Write( SvStream & rStm )
|
||||
{
|
||||
// Always to 1/100 mm, until Mtf-Solution found
|
||||
// Assumption (no scaling, no origin translation)
|
||||
DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleX() == Fraction( 1, 1 ),
|
||||
DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleX() == 1.0,
|
||||
"x-scale in the Mtf is wrong" );
|
||||
DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleY() == Fraction( 1, 1 ),
|
||||
DBG_ASSERT( pMtf->GetPrefMapMode().GetScaleY() == 1.0,
|
||||
"y-scale in the Mtf is wrong" );
|
||||
DBG_ASSERT( pMtf->GetPrefMapMode().GetOrigin() == Point(),
|
||||
"origin-shift in the Mtf is wrong" );
|
||||
|
||||
@@ -4191,16 +4191,16 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm,
|
||||
{
|
||||
MapMode aMapMode( rMtf.GetPrefMapMode() );
|
||||
Size aPrefSize( rMtf.GetPrefSize() );
|
||||
Fraction aFractionX( aMapMode.GetScaleX() );
|
||||
Fraction aFractionY( aMapMode.GetScaleY() );
|
||||
double fFractionX( aMapMode.GetScaleX() );
|
||||
double fFractionY( aMapMode.GetScaleY() );
|
||||
|
||||
auto popIt = mpVDev->ScopedPush();
|
||||
|
||||
Size aSize( OutputDevice::LogicToLogic(rSize100thmm, MapMode(MapUnit::Map100thMM), aMapMode) );
|
||||
aFractionX *= Fraction( aSize.Width(), aPrefSize.Width() );
|
||||
aMapMode.SetScaleX( aFractionX );
|
||||
aFractionY *= Fraction( aSize.Height(), aPrefSize.Height() );
|
||||
aMapMode.SetScaleY( aFractionY );
|
||||
fFractionX *= double( aSize.Width() ) / aPrefSize.Width();
|
||||
aMapMode.SetScaleX( fFractionX );
|
||||
fFractionY *= double( aSize.Height() ) / aPrefSize.Height();
|
||||
aMapMode.SetScaleY( fFractionY );
|
||||
|
||||
Point aOffset( OutputDevice::LogicToLogic(rPos100thmm, MapMode(MapUnit::Map100thMM), aMapMode ) );
|
||||
aOffset += aMapMode.GetOrigin();
|
||||
|
||||
@@ -165,8 +165,8 @@ public:
|
||||
MapMode aDeviceMapMode(rDevice.GetMapMode());
|
||||
|
||||
const double scale = conversionFract(o3tl::Length::px, o3tl::Length::twip);
|
||||
Fraction scaleX = Fraction(aOutputSize.Width(), rTileRect.GetWidth()) * scale;
|
||||
Fraction scaleY = Fraction(aOutputSize.Height(), rTileRect.GetHeight()) * scale;
|
||||
double scaleX = double(aOutputSize.Width()) / rTileRect.GetWidth() * scale;
|
||||
double scaleY = double(aOutputSize.Height()) / rTileRect.GetHeight() * scale;
|
||||
aDeviceMapMode.SetScaleX(scaleX);
|
||||
aDeviceMapMode.SetScaleY(scaleY);
|
||||
aDeviceMapMode.SetMapUnit(MapUnit::MapPixel);
|
||||
@@ -189,8 +189,8 @@ public:
|
||||
// need to draw the control.
|
||||
if (aObjectRectHMM.Overlaps(aTileRectHMM))
|
||||
{
|
||||
drawUnoControl(pDrawView, pUnoObect, rMainWindow, rDevice, aTileRectHMM,
|
||||
double(scaleX), double(scaleY));
|
||||
drawUnoControl(pDrawView, pUnoObect, rMainWindow, rDevice, aTileRectHMM, scaleX,
|
||||
scaleY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,12 @@ public:
|
||||
o3tl::convert(getY(), nMulY, nDivY));
|
||||
}
|
||||
|
||||
// Scales relative to 0,0
|
||||
constexpr PointT scale(double fX, double fY) const
|
||||
{
|
||||
return PointT(std::llround(getX() * fX), std::llround(getY() * fY));
|
||||
}
|
||||
|
||||
using Pair::toString;
|
||||
using Pair::GetHashValue;
|
||||
};
|
||||
@@ -863,6 +869,20 @@ public:
|
||||
aRect.SetBottom(o3tl::convert(Bottom(), nMulY, nDivY));
|
||||
return aRect;
|
||||
}
|
||||
|
||||
// Scales relative to 0,0
|
||||
constexpr RectangleT scale(double fX, double fY) const
|
||||
{
|
||||
// 1. Create an empty rectangle with correct left and top
|
||||
RectangleT aRect(std::llround(Left() * fX),
|
||||
std::llround(Top() * fY));
|
||||
// 2. If source has width/height, set respective right and bottom
|
||||
if (!IsWidthEmpty())
|
||||
aRect.SetRight(std::llround(Right() * fX));
|
||||
if (!IsHeightEmpty())
|
||||
aRect.SetBottom(std::llround(Bottom() * fY));
|
||||
return aRect;
|
||||
}
|
||||
};
|
||||
|
||||
namespace tools
|
||||
|
||||
+5
-13
@@ -26,7 +26,6 @@
|
||||
#include <ostream>
|
||||
|
||||
class Point;
|
||||
class Fraction;
|
||||
enum class MapUnit : sal_uInt8;
|
||||
|
||||
class SAL_WARN_UNUSED VCL_DLLPUBLIC MapMode
|
||||
@@ -39,9 +38,7 @@ public:
|
||||
MapMode();
|
||||
MapMode( const MapMode& rMapMode );
|
||||
explicit MapMode( MapUnit eUnit );
|
||||
MapMode( MapUnit eUnit, const Point& rLogicOrg,
|
||||
const Fraction& rScaleX, const Fraction& rScaleY );
|
||||
MapMode( MapUnit eUnit, const Point& rLogicOrg, double rScaleX, double rScaleY );
|
||||
MapMode( MapUnit eUnit, const Point& rLogicOrg, double fScaleX, double fScaleY );
|
||||
~MapMode();
|
||||
|
||||
void SetMapUnit( MapUnit eUnit );
|
||||
@@ -50,13 +47,10 @@ public:
|
||||
void SetOrigin( const Point& rOrigin );
|
||||
const Point& GetOrigin() const;
|
||||
|
||||
void SetScaleX( const Fraction& rScaleX );
|
||||
const Fraction& GetScaleX() const;
|
||||
void SetScaleY( const Fraction& rScaleY );
|
||||
const Fraction& GetScaleY() const;
|
||||
|
||||
void SetScaleX( double rScaleX );
|
||||
void SetScaleY( double rScaleY );
|
||||
void SetScaleX( double fScaleX );
|
||||
double GetScaleX() const;
|
||||
void SetScaleY( double fScaleY );
|
||||
double GetScaleY() const;
|
||||
|
||||
MapMode& operator=( const MapMode& rMapMode );
|
||||
MapMode& operator=( MapMode&& rMapMode );
|
||||
@@ -89,8 +83,6 @@ inline std::basic_ostream<charT, traits> & operator <<(
|
||||
return rStream;
|
||||
}
|
||||
|
||||
bool TooLargeScaleForMapMode(const Fraction& rScale, int nDPI);
|
||||
|
||||
#endif // INCLUDED_VCL_MAPMOD_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -62,10 +62,10 @@ OSectionWindow::OSectionWindow( OViewsWindow* _pParent,const uno::Reference< rep
|
||||
|
||||
m_aStartMarker->setCollapsedHdl(LINK(this,OSectionWindow,Collapsed));
|
||||
|
||||
m_aStartMarker->zoom(double(rMapMode.GetScaleX()));
|
||||
setZoomFactor(double(rMapMode.GetScaleX()), *m_aReportSection);
|
||||
setZoomFactor(double(rMapMode.GetScaleX()), *m_aSplitter);
|
||||
setZoomFactor(double(rMapMode.GetScaleX()), *m_aEndMarker);
|
||||
m_aStartMarker->zoom(rMapMode.GetScaleX());
|
||||
setZoomFactor(rMapMode.GetScaleX(), *m_aReportSection);
|
||||
setZoomFactor(rMapMode.GetScaleX(), *m_aSplitter);
|
||||
setZoomFactor(rMapMode.GetScaleX(), *m_aEndMarker);
|
||||
|
||||
m_aSplitter->Show();
|
||||
m_aStartMarker->Show();
|
||||
@@ -260,7 +260,7 @@ void OSectionWindow::Resize()
|
||||
// set splitter
|
||||
aReportPos.AdjustY(aSectionSize.Height() );
|
||||
m_aSplitter->SetPosSizePixel(aReportPos,Size(aSectionSize.Width(),m_aSplitter->GetSizePixel().Height()));
|
||||
aSectionSize.setHeight( static_cast<tools::Long>(1000 * static_cast<double>(GetMapMode().GetScaleY())) );
|
||||
aSectionSize.setHeight( static_cast<tools::Long>(1000 * GetMapMode().GetScaleY()) );
|
||||
m_aSplitter->SetDragRectPixel( tools::Rectangle(Point(nStartWidth,0),aSectionSize));
|
||||
|
||||
// set end marker
|
||||
|
||||
@@ -102,7 +102,7 @@ void OStartMarker::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
|
||||
auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::TEXTCOLOR);
|
||||
|
||||
Size aSize(GetOutputSizePixel());
|
||||
const tools::Long nCornerWidth = tools::Long(CORNER_SPACE * double(GetMapMode().GetScaleX()));
|
||||
const tools::Long nCornerWidth = tools::Long(CORNER_SPACE * GetMapMode().GetScaleX());
|
||||
|
||||
if (isCollapsed())
|
||||
{
|
||||
@@ -154,7 +154,7 @@ void OStartMarker::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
|
||||
|
||||
if (m_bMarked)
|
||||
{
|
||||
const tools::Long nCornerHeight = tools::Long(CORNER_SPACE * double(GetMapMode().GetScaleY()));
|
||||
const tools::Long nCornerHeight = tools::Long(CORNER_SPACE * GetMapMode().GetScaleY());
|
||||
tools::Rectangle aRect(Point(nCornerWidth, nCornerHeight),
|
||||
Size(aSize.Width() - nCornerWidth - nCornerWidth,
|
||||
aSize.Height() - nCornerHeight - nCornerHeight));
|
||||
@@ -226,8 +226,8 @@ void OStartMarker::Resize()
|
||||
|
||||
Size aImageSize = m_aImage.GetSizePixel();
|
||||
const MapMode& rMapMode = GetMapMode();
|
||||
aImageSize.setWidth( tools::Long(aImageSize.Width() * static_cast<double>(rMapMode.GetScaleX())) );
|
||||
aImageSize.setHeight( tools::Long(aImageSize.Height() * static_cast<double>(rMapMode.GetScaleY())) );
|
||||
aImageSize.setWidth( tools::Long(aImageSize.Width() * rMapMode.GetScaleX()) );
|
||||
aImageSize.setHeight( tools::Long(aImageSize.Height() * rMapMode.GetScaleY()) );
|
||||
|
||||
tools::Long nExtraWidth = tools::Long(REPORT_EXTRA_SPACE * rMapMode.GetScaleX());
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ void OViewsWindow::impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Poin
|
||||
{
|
||||
aSectionSize.setHeight( nMinHeight );
|
||||
}
|
||||
aSectionSize.AdjustHeight(static_cast<tools::Long>(StyleSettings::GetSplitSize() * static_cast<double>(_rSectionWindow.GetMapMode().GetScaleY())) );
|
||||
aSectionSize.AdjustHeight(static_cast<tools::Long>(StyleSettings::GetSplitSize() * _rSectionWindow.GetMapMode().GetScaleY()) );
|
||||
|
||||
if ( _bSet )
|
||||
_rSectionWindow.SetPosSizePixel(_rStartPoint,aSectionSize);
|
||||
@@ -1628,7 +1628,7 @@ void OViewsWindow::zoom(double _fZoom)
|
||||
const MapMode& aMapMode = GetMapMode();
|
||||
|
||||
Fraction aStartWidth(tools::Long(REPORT_STARTMARKER_WIDTH));
|
||||
if ( _fZoom < double(aMapMode.GetScaleX()) )
|
||||
if ( _fZoom < aMapMode.GetScaleX() )
|
||||
aStartWidth *= aMapMode.GetScaleX();
|
||||
else
|
||||
aStartWidth *= _fZoom;
|
||||
|
||||
@@ -3184,9 +3184,9 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testInputHandlerSyncedZoom)
|
||||
EditEngine& rEditEngine1 = pEditView1->getEditEngine();
|
||||
// These must match, if they don't then text will have a different width in edit and view modes
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("EditEngine Ref Dev Zoom and ViewData Zoom should match",
|
||||
pViewData1->GetZoomX(), double(rEditEngine1.GetRefMapMode().GetScaleX()), 0.000001);
|
||||
pViewData1->GetZoomX(), rEditEngine1.GetRefMapMode().GetScaleX(), 0.000001);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("EditEngine Ref Dev Zoom and ViewData Zoom should match",
|
||||
pViewData1->GetZoomY(), double(rEditEngine1.GetRefMapMode().GetScaleY()), 0.000001);
|
||||
pViewData1->GetZoomY(), rEditEngine1.GetRefMapMode().GetScaleY(), 0.000001);
|
||||
|
||||
// Create a View #2
|
||||
SfxLokHelper::createView();
|
||||
|
||||
@@ -733,19 +733,19 @@ void ScPatternAttr::fillFontOnly(
|
||||
if ( pOutDev != nullptr )
|
||||
{
|
||||
Size aEffSize;
|
||||
Fraction aFraction( 1,1 );
|
||||
double fFraction( 1.0 );
|
||||
if (pScale)
|
||||
aFraction = *pScale;
|
||||
fFraction = *pScale;
|
||||
Size aSize( 0, static_cast<tools::Long>(nFontHeight) );
|
||||
MapMode aDestMode = pOutDev->GetMapMode();
|
||||
MapMode aSrcMode( MapUnit::MapTwip, Point(), aFraction, aFraction );
|
||||
MapMode aSrcMode( MapUnit::MapTwip, Point(), fFraction, fFraction );
|
||||
if (aDestMode.GetMapUnit() == MapUnit::MapPixel && pOutDev->GetDPIX() > 0)
|
||||
aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode );
|
||||
else
|
||||
{
|
||||
Fraction aFractOne(1,1);
|
||||
aDestMode.SetScaleX( aFractOne );
|
||||
aDestMode.SetScaleY( aFractOne );
|
||||
double fFractOne(1.0);
|
||||
aDestMode.SetScaleX( fFractOne );
|
||||
aDestMode.SetScaleY( fFractOne );
|
||||
aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode );
|
||||
}
|
||||
rFont.SetFontSize( aEffSize );
|
||||
|
||||
@@ -422,13 +422,13 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt
|
||||
// that Skia can handle may need to be raised or lowered for
|
||||
// platforms other than macOS.
|
||||
static constexpr tools::Long nCopyToImageMaxPixels = 8192 * 8192;
|
||||
Fraction aScale(1.0);
|
||||
double fScale(1.0);
|
||||
Size aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM));
|
||||
tools::Long nPixels(aPixelSize.Width() * aPixelSize.Height());
|
||||
if (nPixels < 0 || nPixels > nCopyToImageMaxPixels)
|
||||
{
|
||||
aScale = Fraction(nCopyToImageMaxPixels, nPixels);
|
||||
aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM, Point(), aScale, aScale));
|
||||
fScale = double(nCopyToImageMaxPixels) / nPixels;
|
||||
aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM, Point(), fScale, fScale));
|
||||
nPixels = aPixelSize.Width() * aPixelSize.Height();
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt
|
||||
|
||||
PaintToDev( pVirtDev, *m_pDoc, 1.0, aReducedBlock );
|
||||
|
||||
pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel, Point(), aScale, aScale ) );
|
||||
pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel, Point(), fScale, fScale ) );
|
||||
Bitmap aBmp( pVirtDev->GetBitmap( Point(), pVirtDev->GetOutputSize() ) );
|
||||
bOK = SetBitmap(aBmp, rFlavor);
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void ScGridWindow::DoPushPivotToggle( SCCOL nCol, SCROW nRow, const MouseEvent&
|
||||
sal_uInt16 nIndent = rIndentItem.GetValue();
|
||||
|
||||
// Check if the mouse cursor is clicking on the toggle +/- box.
|
||||
ScDPFieldButton aBtn(GetOutDev(), GetSettings().GetStyleSettings(), double(GetMapMode().GetScaleY()), mrViewData.GetDocument());
|
||||
ScDPFieldButton aBtn(GetOutDev(), GetSettings().GetStyleSettings(), GetMapMode().GetScaleY(), mrViewData.GetDocument());
|
||||
aBtn.setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
|
||||
aBtn.setDrawToggleButton(true, true, nIndent);
|
||||
Point aPopupPos;
|
||||
@@ -408,7 +408,7 @@ bool ScGridWindow::DPTestFieldPopupArrow(
|
||||
Size aScrSize(nSizeX-1, nSizeY-1);
|
||||
|
||||
// Check if the mouse cursor is clicking on the popup arrow box.
|
||||
ScDPFieldButton aBtn(GetOutDev(), GetSettings().GetStyleSettings(), double(GetMapMode().GetScaleY()), mrViewData.GetDocument());
|
||||
ScDPFieldButton aBtn(GetOutDev(), GetSettings().GetStyleSettings(), GetMapMode().GetScaleY(), mrViewData.GetDocument());
|
||||
aBtn.setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
|
||||
aBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now
|
||||
Point aPopupPos;
|
||||
@@ -438,7 +438,7 @@ bool ScGridWindow::DPTestMultiFieldPopupArrow(
|
||||
Size aScrSize(nSizeX - 1, nSizeY - 1);
|
||||
|
||||
// Check if the mouse cursor is clicking on the popup arrow box.
|
||||
ScDPFieldButton aBtn(GetOutDev(), GetSettings().GetStyleSettings(), double(GetMapMode().GetScaleY()), mrViewData.GetDocument());
|
||||
ScDPFieldButton aBtn(GetOutDev(), GetSettings().GetStyleSettings(), GetMapMode().GetScaleY(), mrViewData.GetDocument());
|
||||
aBtn.setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
|
||||
aBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now
|
||||
aBtn.setDrawPopupButtonMulti(true);
|
||||
|
||||
@@ -1090,9 +1090,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
|
||||
aOrigin.AdjustY(o3tl::toTwips(aOutputData.mnScrY, o3tl::Length::px));
|
||||
aOrigin = o3tl::convert(aOrigin, o3tl::Length::twip, o3tl::Length::mm100);
|
||||
// keep into account the zoom factor
|
||||
aOrigin = aOrigin.scale(
|
||||
aDrawMode.GetScaleX().GetDenominator(), aDrawMode.GetScaleX().GetNumerator(),
|
||||
aDrawMode.GetScaleY().GetDenominator(), aDrawMode.GetScaleY().GetNumerator());
|
||||
aOrigin = aOrigin.scale(1.0 / aDrawMode.GetScaleX(), 1.0 / aDrawMode.GetScaleY());
|
||||
|
||||
MapMode aNew = rDevice.GetMapMode();
|
||||
aNew.SetOrigin(aOrigin);
|
||||
@@ -1187,9 +1185,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
|
||||
|
||||
// keep into account the zoom factor
|
||||
Point aNewOrigin(o3tl::convert(aOriginAbsTw, o3tl::Length::twip, o3tl::Length::mm100));
|
||||
aNewOrigin = aNewOrigin.scale(
|
||||
aDrawMode.GetScaleX().GetDenominator(), aDrawMode.GetScaleX().GetNumerator(),
|
||||
aDrawMode.GetScaleY().GetDenominator(), aDrawMode.GetScaleY().GetNumerator());
|
||||
aNewOrigin = aNewOrigin.scale(1.0 / aDrawMode.GetScaleX(), 1.0 / aDrawMode.GetScaleY());
|
||||
|
||||
MapMode aNewMM = rDevice.GetMapMode();
|
||||
aNewMM.SetOrigin(aNewOrigin);
|
||||
@@ -1298,7 +1294,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
|
||||
aCursorRect.setWidth(0);
|
||||
aCursorRect.Move(aCursPos.getX(), 0);
|
||||
// Sends view cursor position to views of all matching zooms if needed (avoids duplicates).
|
||||
InvalidateLOKViewCursor(aCursorRect, double(aMM.GetScaleX()), double(aMM.GetScaleY()));
|
||||
InvalidateLOKViewCursor(aCursorRect, aMM.GetScaleX(), aMM.GetScaleY());
|
||||
}
|
||||
|
||||
// Rollback the mapmode and 'output area'.
|
||||
|
||||
@@ -864,7 +864,7 @@ double ScOutputData::GetStretch() const
|
||||
if ( mpRefDevice == pFmtDevice )
|
||||
{
|
||||
MapMode aOld = mpRefDevice->GetMapMode();
|
||||
return static_cast<double>(aOld.GetScaleY()) / static_cast<double>(aOld.GetScaleX()) * mfZoomY / mfZoomX;
|
||||
return aOld.GetScaleY() / aOld.GetScaleX() * mfZoomY / mfZoomX;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1392,7 +1392,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, tools::Long nPosX, too
|
||||
( !bBreak || mpRefDevice == pFmtDevice ) )
|
||||
{
|
||||
// filter drop-down width depends on row height
|
||||
double fZoom = mpRefDevice ? static_cast<double>(mpRefDevice->GetMapMode().GetScaleY()) : 1.0;
|
||||
double fZoom = mpRefDevice ? mpRefDevice->GetMapMode().GetScaleY() : 1.0;
|
||||
fZoom = fZoom > 1.0 ? fZoom : 1.0;
|
||||
const tools::Long nFilter = fZoom * DROPDOWN_BITMAP_SIZE;
|
||||
bool bFit = ( nNeeded + nFilter <= nMergeSizeX );
|
||||
@@ -5218,7 +5218,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
|
||||
pInfo->bAutoFilter)
|
||||
{
|
||||
// filter drop-down width depends on row height
|
||||
double fZoom = mpRefDevice ? static_cast<double>(mpRefDevice->GetMapMode().GetScaleY()) : 1.0;
|
||||
double fZoom = mpRefDevice ? mpRefDevice->GetMapMode().GetScaleY() : 1.0;
|
||||
fZoom = fZoom > 1.0 ? fZoom : 1.0;
|
||||
if (bPixelToLogic)
|
||||
nAvailWidth -= mpRefDevice->PixelToLogic(Size(0,fZoom * DROPDOWN_BITMAP_SIZE)).Height();
|
||||
|
||||
@@ -335,9 +335,9 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
|
||||
UpdateDrawView(); // Spreadsheet eventually changes
|
||||
}
|
||||
|
||||
Fraction aPreviewZoom( nZoom, 100 );
|
||||
Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
|
||||
double fPreviewZoom = double(nZoom) / 100;
|
||||
double fHorPrevZoom = 100.0 * nZoom / pDocShell->GetOutputFactor() / 10000;
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), fHorPrevZoom, fPreviewZoom );
|
||||
|
||||
bool bDoPrint = ( pFillLocation == nullptr );
|
||||
bool bValidPage = ( nPageNo < nTotalPages );
|
||||
@@ -723,9 +723,9 @@ void ScPreview::SetZoom(sal_uInt16 nNewZoom)
|
||||
|
||||
// apply new MapMode and call UpdateScrollBars to update aOffset
|
||||
|
||||
Fraction aPreviewZoom( nZoom, 100 );
|
||||
Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
|
||||
double fPreviewZoom = double(nZoom) / 100;
|
||||
double fHorPrevZoom = 100.0 * nZoom / pDocShell->GetOutputFactor() / 10000;
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), fHorPrevZoom, fPreviewZoom );
|
||||
SetMapMode( aMMMode );
|
||||
|
||||
bInSetZoom = true; // don't scroll during SetYOffset in UpdateScrollBars
|
||||
@@ -950,9 +950,9 @@ void ScPreview::DataChanged( const DataChangedEvent& rDCEvt )
|
||||
|
||||
void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
|
||||
{
|
||||
Fraction aPreviewZoom( nZoom, 100 );
|
||||
Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
|
||||
double fPreviewZoom = double(nZoom) / 100;
|
||||
double fHorPrevZoom = 100.0 * nZoom / pDocShell->GetOutputFactor() / 10000;
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), fHorPrevZoom, fPreviewZoom );
|
||||
|
||||
aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
|
||||
aButtonDownPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
|
||||
@@ -1033,9 +1033,9 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
|
||||
|
||||
void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
|
||||
{
|
||||
Fraction aPreviewZoom( nZoom, 100 );
|
||||
Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
|
||||
double fPreviewZoom = double(nZoom) / 100;
|
||||
double fHorPrevZoom = 100.0 * nZoom / pDocShell->GetOutputFactor() / 10000;
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), fHorPrevZoom, fPreviewZoom );
|
||||
|
||||
aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
|
||||
|
||||
@@ -1297,9 +1297,9 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
|
||||
|
||||
void ScPreview::MouseMove( const MouseEvent& rMEvt )
|
||||
{
|
||||
Fraction aPreviewZoom( nZoom, 100 );
|
||||
Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
|
||||
double fPreviewZoom = double(nZoom) / 100;
|
||||
double fHorPrevZoom = 100.0 * nZoom / pDocShell->GetOutputFactor() / 10000;
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), fHorPrevZoom, fPreviewZoom );
|
||||
Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode );
|
||||
|
||||
tools::Long nLeftMargin = 0;
|
||||
@@ -1527,9 +1527,9 @@ rtl::Reference<comphelper::OAccessible> ScPreview::CreateAccessible()
|
||||
|
||||
void ScPreview::DragMove( tools::Long nDragMovePos, PointerStyle nFlags )
|
||||
{
|
||||
Fraction aPreviewZoom( nZoom, 100 );
|
||||
Fraction aHorPrevZoom( static_cast<tools::Long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom );
|
||||
double fPreviewZoom = double(nZoom) / 100;
|
||||
double fHorPrevZoom = 100.0 * nZoom / pDocShell->GetOutputFactor() / 10000;
|
||||
MapMode aMMMode( MapUnit::Map100thMM, Point(), fHorPrevZoom, fPreviewZoom );
|
||||
SetMapMode( aMMMode );
|
||||
tools::Long nPos = nDragMovePos;
|
||||
if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
|
||||
|
||||
@@ -1667,9 +1667,9 @@ void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
|
||||
if ( !pPrinter )
|
||||
{
|
||||
OutputDevice* pRefDev = rDoc.GetPrinter(); // use the printer also for Preview
|
||||
Fraction aPrintFrac( nZoom, 100 ); // without nManualZoom
|
||||
double fPrintFrac = double(nZoom) / 100.0; // without nManualZoom
|
||||
// MapMode, as it would arrive at the printer:
|
||||
pRefDev->SetMapMode( MapMode( MapUnit::Map100thMM, Point(), aPrintFrac, aPrintFrac ) );
|
||||
pRefDev->SetMapMode( MapMode( MapUnit::Map100thMM, Point(), fPrintFrac, fPrintFrac ) );
|
||||
|
||||
// when rendering (PDF), don't use printer as ref device, but printer's MapMode
|
||||
// has to be set anyway, as charts still use it (#106409#)
|
||||
@@ -2629,22 +2629,22 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc.
|
||||
constexpr auto HMM_PER_TWIPS = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::mm100);
|
||||
nScaleX = nScaleY = HMM_PER_TWIPS; // output in 1/100 mm
|
||||
|
||||
Fraction aZoomFract( nEffZoom,10000 );
|
||||
Fraction aHorFract = aZoomFract;
|
||||
double fZoomFract = double(nEffZoom) / 10000;
|
||||
double fHorFract = fZoomFract;
|
||||
|
||||
if ( !pPrinter && !bIsRender ) // adjust scale for preview
|
||||
{
|
||||
double nFact = rDocShell.GetOutputFactor();
|
||||
aHorFract = Fraction( static_cast<tools::Long>( nEffZoom / nFact ), 10000 );
|
||||
fHorFract = double(nEffZoom) / nFact / 10000;
|
||||
}
|
||||
|
||||
aLogicMode = MapMode( MapUnit::Map100thMM, Point(), aHorFract, aZoomFract );
|
||||
aLogicMode = MapMode( MapUnit::Map100thMM, Point(), fHorFract, fZoomFract );
|
||||
|
||||
Point aLogicOfs( -aOffset.X(), -aOffset.Y() );
|
||||
aOffsetMode = MapMode( MapUnit::Map100thMM, aLogicOfs, aHorFract, aZoomFract );
|
||||
aOffsetMode = MapMode( MapUnit::Map100thMM, aLogicOfs, fHorFract, fZoomFract );
|
||||
|
||||
Point aTwipsOfs( static_cast<tools::Long>( -aOffset.X() / nScaleX + 0.5 ), static_cast<tools::Long>( -aOffset.Y() / nScaleY + 0.5 ) );
|
||||
aTwipMode = MapMode( MapUnit::MapTwip, aTwipsOfs, aHorFract, aZoomFract );
|
||||
aTwipMode = MapMode( MapUnit::MapTwip, aTwipsOfs, fHorFract, fZoomFract );
|
||||
}
|
||||
|
||||
void ScPrintFunc::ApplyPrintSettings()
|
||||
|
||||
@@ -103,7 +103,7 @@ PHLayout const pPHLayout[] =
|
||||
{ EppLayout::TWOCOLUMNSANDTITLE, { 0x0d, 0x16, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0x16, 0x0d, 0x12, true, true, false }
|
||||
};
|
||||
|
||||
const Fraction gPPTFraction(1,576);
|
||||
const double gPPTFraction = 1.0 / 576;
|
||||
|
||||
PPTWriterBase::PPTWriterBase()
|
||||
: mbStatusIndicator(false)
|
||||
|
||||
@@ -189,17 +189,17 @@ Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage)
|
||||
|
||||
const Size aPixSize( pVDev->LogicToPixel( aSize ) );
|
||||
const sal_uLong nMaxEdgePix = std::max( aPixSize.Width(), aPixSize.Height() );
|
||||
Fraction aFrac( nMaxEdgePixel, nMaxEdgePix );
|
||||
double fFrac = double(nMaxEdgePixel) / nMaxEdgePix;
|
||||
|
||||
aMapMode.SetScaleX( aFrac );
|
||||
aMapMode.SetScaleY( aFrac );
|
||||
aMapMode.SetScaleX( fFrac );
|
||||
aMapMode.SetScaleY( fFrac );
|
||||
pVDev->SetMapMode( aMapMode );
|
||||
pVDev->SetOutputSize( aSize );
|
||||
|
||||
// that we also get the dark lines at the right and bottom page margin
|
||||
aFrac = Fraction( nMaxEdgePixel - 1, nMaxEdgePix );
|
||||
aMapMode.SetScaleX( aFrac );
|
||||
aMapMode.SetScaleY( aFrac );
|
||||
fFrac = double(nMaxEdgePixel - 1) / nMaxEdgePix;
|
||||
aMapMode.SetScaleX( fFrac );
|
||||
aMapMode.SetScaleY( fFrac );
|
||||
pVDev->SetMapMode( aMapMode );
|
||||
|
||||
std::optional<ClientView> pView( std::in_place, this, pVDev );
|
||||
|
||||
@@ -159,9 +159,9 @@ Image PreviewRenderer::RenderSubstitution (
|
||||
// visible.
|
||||
MapMode aMapMode (mpPreviewDevice->GetMapMode());
|
||||
aMapMode.SetMapUnit(MapUnit::Map100thMM);
|
||||
Fraction aFinalScale(25 * rPreviewPixelSize.Width(), 28000);
|
||||
aMapMode.SetScaleX(aFinalScale);
|
||||
aMapMode.SetScaleY(aFinalScale);
|
||||
double fFinalScale = double(25 * rPreviewPixelSize.Width()) / 28000;
|
||||
aMapMode.SetScaleX(fFinalScale);
|
||||
aMapMode.SetScaleY(fFinalScale);
|
||||
const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
|
||||
aMapMode.SetOrigin(mpPreviewDevice->PixelToLogic(
|
||||
Point(nFrameWidth,nFrameWidth),aMapMode));
|
||||
@@ -363,9 +363,9 @@ void PreviewRenderer::SetupOutputSize (
|
||||
{
|
||||
const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
|
||||
aMapMode.SetScaleX(
|
||||
Fraction(rFramePixelSize.Width()-2*nFrameWidth-1, aPageModelSize.Width()));
|
||||
double(rFramePixelSize.Width()-2*nFrameWidth-1) / aPageModelSize.Width());
|
||||
aMapMode.SetScaleY(
|
||||
Fraction(rFramePixelSize.Height()-2*nFrameWidth-1, aPageModelSize.Height()));
|
||||
double(rFramePixelSize.Height()-2*nFrameWidth-1) / aPageModelSize.Height());
|
||||
aMapMode.SetOrigin(mpPreviewDevice->PixelToLogic(Point(nFrameWidth,nFrameWidth),aMapMode));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -119,13 +119,13 @@ public:
|
||||
Size aPageSize(rPage.GetSize());
|
||||
|
||||
MapMode aMapMode(MapUnit::Map100thMM);
|
||||
const Fraction aFracX(rSlideSize.Width(),
|
||||
maVirtualDevice->LogicToPixel(aPageSize, aMapMode).Width());
|
||||
aMapMode.SetScaleX(aFracX);
|
||||
const double fFracX = double(rSlideSize.Width())
|
||||
/ maVirtualDevice->LogicToPixel(aPageSize, aMapMode).Width();
|
||||
aMapMode.SetScaleX(fFracX);
|
||||
|
||||
const Fraction aFracY(rSlideSize.Height(),
|
||||
maVirtualDevice->LogicToPixel(aPageSize, aMapMode).Height());
|
||||
aMapMode.SetScaleY(aFracY);
|
||||
const double fFracY = double(rSlideSize.Height())
|
||||
/ maVirtualDevice->LogicToPixel(aPageSize, aMapMode).Height();
|
||||
aMapMode.SetScaleY(fFracY);
|
||||
|
||||
maVirtualDevice->SetMapMode(aMapMode);
|
||||
}
|
||||
|
||||
@@ -3881,8 +3881,8 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
|
||||
// We specifically calculate these scales first as we're still
|
||||
// in TWIPs, and might as well minimize the number of conversions.
|
||||
const double scale = conversionFract(o3tl::Length::px, o3tl::Length::twip);
|
||||
Fraction scaleX = Fraction(nOutputWidth, nTileWidth) * scale;
|
||||
Fraction scaleY = Fraction(nOutputHeight, nTileHeight) * scale;
|
||||
double scaleX = double(nOutputWidth) / nTileWidth * scale;
|
||||
double scaleY = double(nOutputHeight) / nTileHeight * scale;
|
||||
|
||||
// svx seems to be the only component that works natively in
|
||||
// 100th mm rather than TWIP. It makes most sense just to
|
||||
|
||||
@@ -2107,14 +2107,14 @@ private:
|
||||
const double fHorz = static_cast<double>(aPrintSize.Width()) / aPageSize.Width();
|
||||
const double fVert = static_cast<double>(aPrintSize.Height()) / aPageSize.Height();
|
||||
|
||||
Fraction aFract;
|
||||
double fFract;
|
||||
if ( fHorz < fVert )
|
||||
aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
|
||||
fFract = double(aPrintSize.Width()) / aPageSize.Width();
|
||||
else
|
||||
aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
|
||||
fFract = double(aPrintSize.Height()) / aPageSize.Height();
|
||||
|
||||
aMap.SetScaleX(aFract);
|
||||
aMap.SetScaleY(aFract);
|
||||
aMap.SetScaleX(fFract);
|
||||
aMap.SetScaleY(fFract);
|
||||
aMap.SetOrigin(Point());
|
||||
}
|
||||
|
||||
@@ -2238,14 +2238,14 @@ private:
|
||||
const double fHorz(static_cast<double>(aPrintSize.Width()) / aPageSize.Width());
|
||||
const double fVert(static_cast<double>(aPrintSize.Height()) / aPageSize.Height());
|
||||
|
||||
Fraction aFract;
|
||||
double fFract;
|
||||
if (fHorz < fVert)
|
||||
aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
|
||||
fFract = double(aPrintSize.Width()) / aPageSize.Width();
|
||||
else
|
||||
aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
|
||||
fFract = double(aPrintSize.Height()) / aPageSize.Height();
|
||||
|
||||
aMap.SetScaleX(aFract);
|
||||
aMap.SetScaleY(aFract);
|
||||
aMap.SetScaleX(fFract);
|
||||
aMap.SetScaleY(fFract);
|
||||
aMap.SetOrigin(Point());
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ void Window::SetMaxZoom (::tools::Long nMax)
|
||||
|
||||
::tools::Long Window::GetZoom() const
|
||||
{
|
||||
if( GetMapMode().GetScaleX().GetDenominator() )
|
||||
if( GetMapMode().GetScaleX() != 0 )
|
||||
{
|
||||
return ::tools::Long(GetMapMode().GetScaleX() * 100);
|
||||
}
|
||||
|
||||
@@ -104,12 +104,10 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
|
||||
// returns the chart bounding box in twips.
|
||||
const MapMode& aCWMapMode = pWindow->GetMapMode();
|
||||
constexpr auto p = o3tl::getConversionMulDiv(o3tl::Length::px, o3tl::Length::twip);
|
||||
const auto& scaleX = aCWMapMode.GetScaleX();
|
||||
const auto& scaleY = aCWMapMode.GetScaleY();
|
||||
const auto nXNum = p.first * scaleX.GetDenominator();
|
||||
const auto nXDen = p.second * scaleX.GetNumerator();
|
||||
const auto nYNum = p.first * scaleY.GetDenominator();
|
||||
const auto nYDen = p.second * scaleY.GetNumerator();
|
||||
const double scaleX = aCWMapMode.GetScaleX();
|
||||
const double scaleY = aCWMapMode.GetScaleY();
|
||||
const double nX = p.first * scaleX / p.second;
|
||||
const double nY = p.first * scaleY / p.second;
|
||||
|
||||
Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin);
|
||||
if (mbNegativeX && AllSettings::GetLayoutRTL())
|
||||
@@ -121,8 +119,8 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
|
||||
|
||||
}
|
||||
|
||||
aOffset = aOffset.scale(nXNum, nXDen, nYNum, nYDen);
|
||||
Size aSize = pWindow->GetSizePixel().scale(nXNum, nXDen, nYNum, nYDen);
|
||||
aOffset = aOffset.scale(nX, nY);
|
||||
Size aSize = pWindow->GetSizePixel().scale(nX, nY);
|
||||
aBBox = tools::Rectangle(aOffset, aSize);
|
||||
}
|
||||
}
|
||||
@@ -237,8 +235,8 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice,
|
||||
// Scaling. Must convert from pixels to twips. We know
|
||||
// that VirtualDevices use a DPI of 96.
|
||||
const double scale = conversionFract(o3tl::Length::px, o3tl::Length::twip);
|
||||
Fraction scaleX = Fraction(nOutputWidth, nTileWidth) * scale;
|
||||
Fraction scaleY = Fraction(nOutputHeight, nTileHeight) * scale;
|
||||
double scaleX = double(nOutputWidth) / nTileWidth * scale;
|
||||
double scaleY = double(nOutputHeight) / nTileHeight * scale;
|
||||
aMapMode.SetScaleX(scaleX);
|
||||
aMapMode.SetScaleY(scaleY);
|
||||
rDevice.SetMapMode(aMapMode);
|
||||
|
||||
@@ -228,8 +228,8 @@ void LokStarMathHelper::PaintAllInPlaceOnTile(VirtualDevice& rDevice, int nOutpu
|
||||
|
||||
// Scaling. Must convert from pixels to twips. We know that VirtualDevices use a DPI of 96.
|
||||
const double scale = conversionFract(o3tl::Length::px, o3tl::Length::twip);
|
||||
const Fraction scaleX = Fraction(nOutputWidth, nTileWidth) * scale;
|
||||
const Fraction scaleY = Fraction(nOutputHeight, nTileHeight) * scale;
|
||||
const double scaleX = double(nOutputWidth) / nTileWidth * scale;
|
||||
const double scaleY = double(nOutputHeight) / nTileHeight * scale;
|
||||
aMapMode.SetScaleX(scaleX);
|
||||
aMapMode.SetScaleY(scaleY);
|
||||
aMapMode.SetMapUnit(MapUnit::MapTwip);
|
||||
|
||||
@@ -1536,9 +1536,9 @@ void SmDocShell::Impl_Print(OutputDevice& rOutDev, const SmPrintUIOptions& rPrin
|
||||
o3tl::convert(aOutRect.GetHeight(), 100, aSize.Height()));
|
||||
if (bIsPrintFrame && nZ > MINZOOM)
|
||||
nZ -= 10;
|
||||
Fraction aFraction(std::clamp(nZ, MINZOOM, MAXZOOM), 100);
|
||||
double fFraction(std::clamp(nZ, MINZOOM, MAXZOOM) / 100.0);
|
||||
|
||||
OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
|
||||
OutputMapMode = MapMode(SmMapUnit(), Point(), fFraction, fFraction);
|
||||
}
|
||||
else
|
||||
OutputMapMode = MapMode(SmMapUnit());
|
||||
@@ -1546,9 +1546,9 @@ void SmDocShell::Impl_Print(OutputDevice& rOutDev, const SmPrintUIOptions& rPrin
|
||||
|
||||
case PRINT_SIZE_ZOOMED:
|
||||
{
|
||||
Fraction aFraction(nZoomFactor, 100);
|
||||
double fFraction = nZoomFactor / 100.0;
|
||||
|
||||
OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
|
||||
OutputMapMode = MapMode(SmMapUnit(), Point(), fFraction, fFraction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,8 +340,7 @@ void SmGraphicWidget::SetDrawingArea(weld::DrawingArea* pDrawingArea)
|
||||
}
|
||||
else
|
||||
{
|
||||
const Fraction aFraction(1, 1);
|
||||
rDevice.SetMapMode(MapMode(SmMapUnit(), Point(), aFraction, aFraction));
|
||||
rDevice.SetMapMode(MapMode(SmMapUnit(), Point(), 1.0, 1.0));
|
||||
}
|
||||
|
||||
SetTotalSize();
|
||||
@@ -887,8 +886,8 @@ void SmGraphicWindow::SetZoom(sal_uInt16 Factor)
|
||||
if (comphelper::LibreOfficeKit::isActive())
|
||||
return;
|
||||
nZoom = std::clamp(Factor, MINZOOM, MAXZOOM);
|
||||
Fraction aFraction(nZoom, 100);
|
||||
SetGraphicMapMode(MapMode(SmMapUnit(), Point(), aFraction, aFraction));
|
||||
double fFraction = nZoom / 100.0;
|
||||
SetGraphicMapMode(MapMode(SmMapUnit(), Point(), fFraction, fFraction));
|
||||
mxGraphic->SetTotalSize();
|
||||
SmViewShell& rViewSh = mxGraphic->GetView();
|
||||
rViewSh.GetViewFrame().GetBindings().Invalidate(SID_ATTR_ZOOM);
|
||||
@@ -1187,11 +1186,11 @@ void SmViewShell::InnerResizePixel(const Point &rOfs, const Size &rSize, bool)
|
||||
if ( !aObjSize.IsEmpty() )
|
||||
{
|
||||
Size aProvidedSize = GetWindow()->PixelToLogic(rSize, MapMode(SmMapUnit()));
|
||||
Fraction aZoomX(aProvidedSize.Width(), aObjSize.Width());
|
||||
Fraction aZoomY(aProvidedSize.Height(), aObjSize.Height());
|
||||
double fZoomX = double(aProvidedSize.Width()) / aObjSize.Width();
|
||||
double fZoomY = double(aProvidedSize.Height()) / aObjSize.Height();
|
||||
MapMode aMap(mxGraphicWindow->GetGraphicMapMode());
|
||||
aMap.SetScaleX(aZoomX);
|
||||
aMap.SetScaleY(aZoomY);
|
||||
aMap.SetScaleX(fZoomX);
|
||||
aMap.SetScaleY(fZoomY);
|
||||
mxGraphicWindow->SetGraphicMapMode(aMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -1072,11 +1072,11 @@ IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeX, weld::SpinButton&, void)
|
||||
}
|
||||
else
|
||||
{
|
||||
Fraction aFract( 1, 100 );
|
||||
double fFract = 1.0 / 100;
|
||||
sal_Int32 nWidth = mxMfSizeX->get_value();
|
||||
sal_Int32 nHeight= static_cast< sal_Int32 >( nWidth * fRatio );
|
||||
const Size aSource( nWidth, nHeight );
|
||||
MapMode aSourceMapMode( GetMapUnit( mxLbSizeX->get_active() ),Point(), aFract, aFract );
|
||||
MapMode aSourceMapMode( GetMapUnit( mxLbSizeX->get_active() ),Point(), fFract, fFract );
|
||||
Size aDest(OutputDevice::LogicToLogic(aSource, aSourceMapMode, MapMode(MapUnit::Map100thMM)));
|
||||
|
||||
maSize.Width = aDest.Width();
|
||||
@@ -1108,11 +1108,11 @@ IMPL_LINK_NOARG(ExportDialog, UpdateHdlMtfSizeY, weld::SpinButton&, void)
|
||||
}
|
||||
else
|
||||
{
|
||||
Fraction aFract( 1, 100 );
|
||||
double fFract = 1.0 / 100;
|
||||
sal_Int32 nHeight= mxMfSizeY->get_value();
|
||||
sal_Int32 nWidth = static_cast< sal_Int32 >( nHeight * fRatio );
|
||||
const Size aSource( nWidth, nHeight );
|
||||
MapMode aSourceMapMode( GetMapUnit( mxLbSizeX->get_active() ),Point(), aFract, aFract );
|
||||
MapMode aSourceMapMode( GetMapUnit( mxLbSizeX->get_active() ),Point(), fFract, fFract );
|
||||
Size aDest( OutputDevice::LogicToLogic(aSource, aSourceMapMode, MapMode(MapUnit::Map100thMM)) );
|
||||
|
||||
maSize.Height = aDest.Height();
|
||||
|
||||
@@ -98,13 +98,13 @@ void SvxXConnectionPreview::AdaptSize()
|
||||
aNewSize.setHeight( static_cast<tools::Long>( static_cast<double>(nWidth) / fRectWH ) );
|
||||
}
|
||||
|
||||
Fraction aFrac1( aWinSize.Width(), aRect.GetWidth() );
|
||||
Fraction aFrac2( aWinSize.Height(), aRect.GetHeight() );
|
||||
Fraction aMinFrac( aFrac1 <= aFrac2 ? aFrac1 : aFrac2 );
|
||||
double fFrac1 = double( aWinSize.Width() ) / aRect.GetWidth();
|
||||
double fFrac2 = double( aWinSize.Height() ) / aRect.GetHeight();
|
||||
double fMinFrac( fFrac1 <= fFrac2 ? fFrac1 : fFrac2 );
|
||||
|
||||
// Implement MapMode
|
||||
aDisplayMap.SetScaleX( aMinFrac );
|
||||
aDisplayMap.SetScaleY( aMinFrac );
|
||||
aDisplayMap.SetScaleX( fMinFrac );
|
||||
aDisplayMap.SetScaleY( fMinFrac );
|
||||
|
||||
// Centering
|
||||
aNewPos.setX( ( nWidth - aNewSize.Width() ) >> 1 );
|
||||
@@ -252,40 +252,40 @@ bool SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt )
|
||||
if( bZoomIn || bZoomOut )
|
||||
{
|
||||
MapMode aMapMode = GetMapMode();
|
||||
Fraction aXFrac = aMapMode.GetScaleX();
|
||||
Fraction aYFrac = aMapMode.GetScaleY();
|
||||
std::optional<double> oMultFrac;
|
||||
double fXFrac = aMapMode.GetScaleX();
|
||||
double fYFrac = aMapMode.GetScaleY();
|
||||
double fMultFrac;
|
||||
|
||||
if( bZoomIn )
|
||||
{
|
||||
if( bCtrl )
|
||||
oMultFrac = 3.0 / 2;
|
||||
fMultFrac = 3.0 / 2;
|
||||
else
|
||||
oMultFrac = 11.0 / 10;
|
||||
fMultFrac = 11.0 / 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( bCtrl )
|
||||
oMultFrac = 2.0 / 3;
|
||||
fMultFrac = 2.0 / 3;
|
||||
else
|
||||
oMultFrac = 10.0 / 11;
|
||||
fMultFrac = 10.0 / 11;
|
||||
}
|
||||
|
||||
aXFrac *= *oMultFrac;
|
||||
aYFrac *= *oMultFrac;
|
||||
if( static_cast<double>(aXFrac) > 0.001 && static_cast<double>(aXFrac) < 1000.0 &&
|
||||
static_cast<double>(aYFrac) > 0.001 && static_cast<double>(aYFrac) < 1000.0 )
|
||||
fXFrac *= fMultFrac;
|
||||
fYFrac *= fMultFrac;
|
||||
if( fXFrac > 0.001 && fXFrac < 1000.0 &&
|
||||
fYFrac > 0.001 && fYFrac < 1000.0 )
|
||||
{
|
||||
aMapMode.SetScaleX( aXFrac );
|
||||
aMapMode.SetScaleY( aYFrac );
|
||||
aMapMode.SetScaleX( fXFrac );
|
||||
aMapMode.SetScaleY( fYFrac );
|
||||
SetMapMode( aMapMode );
|
||||
|
||||
Size aOutSize(GetOutputSizePixel());
|
||||
aOutSize = GetDrawingArea()->get_ref_device().PixelToLogic(aOutSize);
|
||||
|
||||
Point aPt( aMapMode.GetOrigin() );
|
||||
tools::Long nX = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Width()) - ( static_cast<double>(aOutSize.Width()) * *oMultFrac ) ) / 2.0 + 0.5 );
|
||||
tools::Long nY = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Height()) - ( static_cast<double>(aOutSize.Height()) * *oMultFrac ) ) / 2.0 + 0.5 );
|
||||
tools::Long nX = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Width()) - ( static_cast<double>(aOutSize.Width()) * fMultFrac ) ) / 2.0 + 0.5 );
|
||||
tools::Long nY = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Height()) - ( static_cast<double>(aOutSize.Height()) * fMultFrac ) ) / 2.0 + 0.5 );
|
||||
aPt.AdjustX(nX );
|
||||
aPt.AdjustY(nY );
|
||||
|
||||
|
||||
@@ -99,33 +99,32 @@ bool SvxXMeasurePreview::MouseButtonDown(const MouseEvent& rMEvt)
|
||||
|
||||
if (bZoomIn || bZoomOut)
|
||||
{
|
||||
Fraction aXFrac = m_aMapMode.GetScaleX();
|
||||
Fraction aYFrac = m_aMapMode.GetScaleY();
|
||||
std::unique_ptr<Fraction> pMultFrac;
|
||||
double fXFrac = m_aMapMode.GetScaleX();
|
||||
double fYFrac = m_aMapMode.GetScaleY();
|
||||
double fMultFrac;
|
||||
|
||||
if (bZoomIn)
|
||||
{
|
||||
if (bCtrl)
|
||||
pMultFrac.reset(new Fraction(3, 2));
|
||||
fMultFrac = 3.0 / 2;
|
||||
else
|
||||
pMultFrac.reset(new Fraction(11, 10));
|
||||
fMultFrac = 11.0 / 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bCtrl)
|
||||
pMultFrac.reset(new Fraction(2, 3));
|
||||
fMultFrac = 2.0 / 3;
|
||||
else
|
||||
pMultFrac.reset(new Fraction(10, 11));
|
||||
fMultFrac = 10.0 / 11;
|
||||
}
|
||||
|
||||
aXFrac *= *pMultFrac;
|
||||
aYFrac *= *pMultFrac;
|
||||
fXFrac *= fMultFrac;
|
||||
fYFrac *= fMultFrac;
|
||||
|
||||
if (double(aXFrac) > 0.001 && double(aXFrac) < 1000.0 && double(aYFrac) > 0.001
|
||||
&& double(aYFrac) < 1000.0)
|
||||
if (fXFrac > 0.001 && fXFrac < 1000.0 && fYFrac > 0.001 && fYFrac < 1000.0)
|
||||
{
|
||||
m_aMapMode.SetScaleX(aXFrac);
|
||||
m_aMapMode.SetScaleY(aYFrac);
|
||||
m_aMapMode.SetScaleX(fXFrac);
|
||||
m_aMapMode.SetScaleY(fYFrac);
|
||||
|
||||
OutputDevice& rRefDevice = GetDrawingArea()->get_ref_device();
|
||||
rRefDevice.Push(vcl::PushFlags::MAPMODE);
|
||||
@@ -135,11 +134,9 @@ bool SvxXMeasurePreview::MouseButtonDown(const MouseEvent& rMEvt)
|
||||
|
||||
Point aPt(m_aMapMode.GetOrigin());
|
||||
tools::Long nX = tools::Long(
|
||||
(double(aOutSize.Width()) - (double(aOutSize.Width()) * double(*pMultFrac))) / 2.0
|
||||
+ 0.5);
|
||||
(double(aOutSize.Width()) - (double(aOutSize.Width()) * fMultFrac)) / 2.0 + 0.5);
|
||||
tools::Long nY = tools::Long(
|
||||
(double(aOutSize.Height()) - (double(aOutSize.Height()) * double(*pMultFrac))) / 2.0
|
||||
+ 0.5);
|
||||
(double(aOutSize.Height()) - (double(aOutSize.Height()) * fMultFrac)) / 2.0 + 0.5);
|
||||
aPt.AdjustX(nX);
|
||||
aPt.AdjustY(nY);
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ void SvxPageWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
|
||||
auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::MAPMODE);
|
||||
rRenderContext.SetMapMode(MapMode(MapUnit::MapTwip));
|
||||
|
||||
Fraction aXScale(m_aWinSize.Width(), std::max(m_aSize.Width() * 2 + m_aSize.Width() / 8, tools::Long(1)));
|
||||
Fraction aYScale(m_aWinSize.Height(), std::max(m_aSize.Height(), tools::Long(1)));
|
||||
double aXScale = double(m_aWinSize.Width()) / std::max(m_aSize.Width() * 2 + m_aSize.Width() / 8, tools::Long(1));
|
||||
double aYScale = double(m_aWinSize.Height()) / std::max(m_aSize.Height(), tools::Long(1));
|
||||
MapMode aMapMode(rRenderContext.GetMapMode());
|
||||
|
||||
if(aYScale < aXScale)
|
||||
@@ -97,9 +97,9 @@ void SvxPageWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
|
||||
if (m_aSize.Width() > m_aSize.Height())
|
||||
{
|
||||
// Draw Landscape page of the same size
|
||||
Fraction aX = aMapMode.GetScaleX();
|
||||
Fraction aY = aMapMode.GetScaleY();
|
||||
Fraction a2(1.5);
|
||||
double aX = aMapMode.GetScaleX();
|
||||
double aY = aMapMode.GetScaleY();
|
||||
double a2(1.5);
|
||||
aX *= a2;
|
||||
aY *= a2;
|
||||
aMapMode.SetScaleX(aX);
|
||||
|
||||
@@ -862,8 +862,8 @@ namespace sdr::contact {
|
||||
|
||||
::basegfx::B2DHomMatrix aScaleNormalization;
|
||||
const MapMode& aCurrentDeviceMapMode( rPageViewDevice.GetMapMode() );
|
||||
aScaleNormalization.set( 0, 0, static_cast<double>(aCurrentDeviceMapMode.GetScaleX()) );
|
||||
aScaleNormalization.set( 1, 1, static_cast<double>(aCurrentDeviceMapMode.GetScaleY()) );
|
||||
aScaleNormalization.set( 0, 0, aCurrentDeviceMapMode.GetScaleX() );
|
||||
aScaleNormalization.set( 1, 1, aCurrentDeviceMapMode.GetScaleY() );
|
||||
m_aZoomLevelNormalization *= aScaleNormalization;
|
||||
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
|
||||
@@ -1057,13 +1057,12 @@ void SdrPaintView::MakeVisible(const tools::Rectangle& rRect, vcl::Window& rWin)
|
||||
{
|
||||
bNewScale=true;
|
||||
// set new MapMode (Size+Org) and invalidate everything
|
||||
Fraction aXFact(aNewSize.Width(),aActualSize.Width());
|
||||
Fraction aYFact(aNewSize.Height(),aActualSize.Height());
|
||||
if (aYFact>aXFact) aXFact=aYFact;
|
||||
aXFact*=aMap.GetScaleX();
|
||||
aXFact.ReduceInaccurate(10); // to avoid runovers and BigInt mapping
|
||||
aMap.SetScaleX(aXFact);
|
||||
aMap.SetScaleY(aYFact);
|
||||
double fXFact = double(aNewSize.Width()) / aActualSize.Width();
|
||||
double fYFact = double(aNewSize.Height()) / aActualSize.Height();
|
||||
if (fYFact>fXFact) fXFact=fYFact;
|
||||
fXFact*=aMap.GetScaleX();
|
||||
aMap.SetScaleX(fXFact);
|
||||
aMap.SetScaleY(fYFact);
|
||||
rWin.SetMapMode(aMap);
|
||||
aActualSize=rWin.GetOutDev()->GetOutputSize();
|
||||
}
|
||||
|
||||
@@ -396,8 +396,8 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
|
||||
MapUnit eSrcMU=rMap.GetMapUnit();
|
||||
MapUnit eDstMU = GetModel().GetScaleUnit();
|
||||
FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU));
|
||||
nSizX *= double(aMapFact.X() * rMap.GetScaleX());
|
||||
nSizY *= double(aMapFact.Y() * rMap.GetScaleY());
|
||||
nSizX *= aMapFact.X() * rMap.GetScaleX();
|
||||
nSizY *= aMapFact.Y() * rMap.GetScaleY();
|
||||
tools::Long xs=nSizX;
|
||||
tools::Long ys=nSizY;
|
||||
// set the pos to 0, 0 for online case
|
||||
|
||||
@@ -312,22 +312,22 @@ VclPtr<VirtualDevice> GraphicExporter::CreatePageVDev( SdrPage* pPage, tools::Lo
|
||||
// use scaling?
|
||||
if( nWidthPixel != 0 )
|
||||
{
|
||||
const Fraction aFrac( nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() );
|
||||
const double fFrac = double( nWidthPixel ) / pVDev->LogicToPixel( aPageSize, aMM ).Width();
|
||||
|
||||
aMM.SetScaleX( aFrac );
|
||||
aMM.SetScaleX( fFrac );
|
||||
|
||||
if( nHeightPixel == 0 )
|
||||
aMM.SetScaleY( aFrac );
|
||||
aMM.SetScaleY( fFrac );
|
||||
}
|
||||
|
||||
if( nHeightPixel != 0 )
|
||||
{
|
||||
const Fraction aFrac( nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() );
|
||||
const double fFrac = double( nHeightPixel ) / pVDev->LogicToPixel( aPageSize, aMM ).Height();
|
||||
|
||||
if( nWidthPixel == 0 )
|
||||
aMM.SetScaleX( aFrac );
|
||||
aMM.SetScaleX( fFrac );
|
||||
|
||||
aMM.SetScaleY( aFrac );
|
||||
aMM.SetScaleY( fFrac );
|
||||
}
|
||||
|
||||
pVDev->SetMapMode( aMM );
|
||||
@@ -569,7 +569,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
|
||||
return false;
|
||||
|
||||
ScopedVclPtrInstance< VirtualDevice > aVDev;
|
||||
const MapMode aMap( mpDoc->GetScaleUnit(), Point(), rSettings.maScaleX, rSettings.maScaleY );
|
||||
const MapMode aMap( mpDoc->GetScaleUnit(), Point(), double(rSettings.maScaleX), double(rSettings.maScaleY) );
|
||||
|
||||
SdrOutliner& rOutl=mpDoc->GetDrawOutliner();
|
||||
maOldCalcFieldValueHdl = rOutl.GetCalcFieldValueHdl();
|
||||
|
||||
@@ -404,8 +404,8 @@ void SwCalcPixStatics( vcl::RenderContext const *pOut )
|
||||
gProp.nSMinDistPixelH = gProp.nSPixelSzH * 2 + 1;
|
||||
|
||||
const MapMode &rMap = pOut->GetMapMode();
|
||||
gProp.aSScaleX = double(rMap.GetScaleX());
|
||||
gProp.aSScaleY = double(rMap.GetScaleY());
|
||||
gProp.aSScaleX = rMap.GetScaleX();
|
||||
gProp.aSScaleY = rMap.GetScaleY();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -1146,9 +1146,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
|
||||
|
||||
if ( bDirectPrint )
|
||||
{
|
||||
const Fraction aTmp( 1, 1 );
|
||||
const double fTmp = 1.0;
|
||||
bool bStretch = rInf.GetWidth() && (rInf.GetLen() > TextFrameIndex(1)) && bPrt
|
||||
&& ( aTmp != rInf.GetOut().GetMapMode().GetScaleX() );
|
||||
&& ( fTmp != rInf.GetOut().GetMapMode().GetScaleX() );
|
||||
|
||||
if ( bSwitchL2R )
|
||||
rInf.GetFrame()->SwitchLTRtoRTL( aTextOriginPos );
|
||||
|
||||
@@ -204,22 +204,16 @@ void SwPagePreviewLayout::Init( const sal_uInt16 _nCols,
|
||||
// calculate scaling
|
||||
MapMode aMapMode( MapUnit::MapTwip );
|
||||
Size aWinSize = mrParentViewShell.GetOut()->PixelToLogic( _rPxWinSize, aMapMode );
|
||||
Fraction aXScale( aWinSize.Width(), mnPreviewLayoutWidth );
|
||||
Fraction aYScale( aWinSize.Height(), mnPreviewLayoutHeight );
|
||||
if( aXScale < aYScale )
|
||||
aYScale = aXScale;
|
||||
double fXScale = double(aWinSize.Width()) / mnPreviewLayoutWidth;
|
||||
double fYScale = double(aWinSize.Height()) / mnPreviewLayoutHeight;
|
||||
if( fXScale < fYScale )
|
||||
fYScale = fXScale;
|
||||
{
|
||||
// adjust scaling for Drawing layer.
|
||||
aYScale *= Fraction( 1000, 1 );
|
||||
tools::Long nNewNuminator = aYScale.operator long();
|
||||
if( nNewNuminator < 1 )
|
||||
nNewNuminator = 1;
|
||||
aYScale = Fraction( nNewNuminator, 1000 );
|
||||
// propagate scaling as zoom percentage to view options for font cache
|
||||
ApplyNewZoomAtViewShell( static_cast<sal_uInt8>(nNewNuminator/10) );
|
||||
ApplyNewZoomAtViewShell( std::round(fYScale * 100) );
|
||||
|
||||
aMapMode.SetScaleY( aYScale );
|
||||
aMapMode.SetScaleX( aYScale );
|
||||
aMapMode.SetScaleY( fYScale );
|
||||
aMapMode.SetScaleX( fYScale );
|
||||
// set created mapping mode with calculated scaling at output device.
|
||||
mrParentViewShell.GetOut()->SetMapMode( aMapMode );
|
||||
// update statics for paint.
|
||||
@@ -1141,7 +1135,7 @@ bool SwPagePreviewLayout::Paint(vcl::RenderContext& rRenderContext, const tools:
|
||||
// update at accessibility interface
|
||||
mrParentViewShell.Imp()->UpdateAccessiblePreview(
|
||||
maPreviewPages,
|
||||
double(aMapMode.GetScaleX()),
|
||||
aMapMode.GetScaleX(),
|
||||
mrLayoutRootFrame.GetPageByPageNum( mnSelectedPageNum ),
|
||||
maWinSize );
|
||||
}
|
||||
|
||||
@@ -159,24 +159,13 @@ void SwViewShell::PrintProspect(
|
||||
// set the MapMode
|
||||
aMapMode.SetOrigin( Point() );
|
||||
{
|
||||
Fraction aScX( aPrtSize.Width(), nMaxColSz );
|
||||
Fraction aScY( aPrtSize.Height(), nMaxRowSz );
|
||||
if( aScX < aScY )
|
||||
aScY = aScX;
|
||||
double fScX = double(aPrtSize.Width()) / nMaxColSz;
|
||||
double fScY = double(aPrtSize.Height()) / nMaxRowSz;
|
||||
if( fScX < fScY )
|
||||
fScY = fScX;
|
||||
|
||||
{
|
||||
// Round percentages for Drawings so that these can paint their objects properly
|
||||
aScY *= Fraction( 1000, 1 );
|
||||
tools::Long nTmp = static_cast<tools::Long>(aScY);
|
||||
if( 1 < nTmp )
|
||||
--nTmp;
|
||||
else
|
||||
nTmp = 1;
|
||||
aScY = Fraction( nTmp, 1000 );
|
||||
}
|
||||
|
||||
aMapMode.SetScaleY( aScY );
|
||||
aMapMode.SetScaleX( aScY );
|
||||
aMapMode.SetScaleY( fScY );
|
||||
aMapMode.SetScaleX( fScY );
|
||||
}
|
||||
|
||||
Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
|
||||
|
||||
@@ -2177,8 +2177,8 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
|
||||
// Scaling. Must convert from pixels to twips. We know
|
||||
// that VirtualDevices use a DPI of 96.
|
||||
const double scale = conversionFract(o3tl::Length::px, o3tl::Length::twip);
|
||||
Fraction scaleX = Fraction(contextWidth, tileWidth) * scale;
|
||||
Fraction scaleY = Fraction(contextHeight, tileHeight) * scale;
|
||||
double scaleX = double(contextWidth) / tileWidth * scale;
|
||||
double scaleY = double(contextHeight) / tileHeight * scale;
|
||||
aMapMode.SetScaleX(scaleX);
|
||||
aMapMode.SetScaleY(scaleY);
|
||||
rDevice.SetMapMode(aMapMode);
|
||||
@@ -2187,7 +2187,7 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
|
||||
sal_uInt16 nOldZoomValue = 0;
|
||||
if (GetWin() && GetWin()->GetMapMode().GetScaleX() != scaleX)
|
||||
{
|
||||
double fScale = double(scaleX);
|
||||
double fScale = scaleX;
|
||||
SwViewOption aOption(*GetViewOptions());
|
||||
nOldZoomValue = aOption.GetZoom();
|
||||
aOption.SetZoom(fScale * 100);
|
||||
@@ -2502,9 +2502,9 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
|
||||
if( mpOpt->GetZoom() != rOpt.GetZoom() && !IsPreview() )
|
||||
{
|
||||
MapMode aMode( pMyWin->GetMapMode() );
|
||||
Fraction aNewFactor( rOpt.GetZoom(), 100 );
|
||||
aMode.SetScaleX( aNewFactor );
|
||||
aMode.SetScaleY( aNewFactor );
|
||||
double fNewFactor = double(rOpt.GetZoom()) / 100;
|
||||
aMode.SetScaleX( fNewFactor );
|
||||
aMode.SetScaleY( fNewFactor );
|
||||
pMyWin->SetMapMode( aMode );
|
||||
// if not a reference device (printer) is used for formatting,
|
||||
// but the screen, new formatting is needed for zoomfactor changes.
|
||||
@@ -2758,7 +2758,7 @@ rtl::Reference<comphelper::OAccessible> SwViewShell::CreateAccessiblePreview()
|
||||
{
|
||||
return Imp()->GetAccessibleMap().GetDocumentPreview(
|
||||
PagePreviewLayout()->maPreviewPages,
|
||||
double(GetWin()->GetMapMode().GetScaleX()),
|
||||
GetWin()->GetMapMode().GetScaleX(),
|
||||
GetLayout()->GetPageByPageNum( PagePreviewLayout()->mnSelectedPageNum ),
|
||||
PagePreviewLayout()->maWinSize );
|
||||
}
|
||||
|
||||
@@ -81,9 +81,9 @@ void SwViewShell::Init( const SwViewOption *pNewOpt, tools::Long const nFlags)
|
||||
if( GetWin() && 100 != mpOpt->GetZoom() )
|
||||
{
|
||||
MapMode aMode( mpWin->GetMapMode() );
|
||||
const Fraction aNewFactor( mpOpt->GetZoom(), 100 );
|
||||
aMode.SetScaleX( aNewFactor );
|
||||
aMode.SetScaleY( aNewFactor );
|
||||
double fNewFactor = double(mpOpt->GetZoom()) / 100;
|
||||
aMode.SetScaleX( fNewFactor );
|
||||
aMode.SetScaleY( fNewFactor );
|
||||
mpWin->SetMapMode( aMode );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,11 +494,11 @@ void SwAnnotationWin::SetMenuButtonColors()
|
||||
SwWrtShell* pWrtShell = mrView.GetWrtShellPtr();
|
||||
if (!pWrtShell)
|
||||
return;
|
||||
const Fraction& rFraction = pWrtShell->GetOut()->GetMapMode().GetScaleY();
|
||||
double fFraction = pWrtShell->GetOut()->GetMapMode().GetScaleY();
|
||||
|
||||
ScopedVclPtrInstance<VirtualDevice> xVirDev;
|
||||
Size aSize(tools::Long(METABUTTON_WIDTH * rFraction),
|
||||
tools::Long(METABUTTON_HEIGHT * rFraction));
|
||||
Size aSize(tools::Long(METABUTTON_WIDTH * fFraction),
|
||||
tools::Long(METABUTTON_HEIGHT * fFraction));
|
||||
tools::Rectangle aRect(Point(0, 0), aSize);
|
||||
xVirDev->SetOutputSizePixel(aSize);
|
||||
|
||||
@@ -552,10 +552,10 @@ void SwAnnotationWin::Rescale()
|
||||
SwWrtShell* pWrtShell = mrView.GetWrtShellPtr();
|
||||
if (!pWrtShell)
|
||||
return;
|
||||
const Fraction& rFraction = pWrtShell->GetOut()->GetMapMode().GetScaleY();
|
||||
double fFraction = pWrtShell->GetOut()->GetMapMode().GetScaleY();
|
||||
|
||||
vcl::Font aFont = maLabelFont;
|
||||
sal_Int32 nHeight = tools::Long(aFont.GetFontHeight() * rFraction);
|
||||
sal_Int32 nHeight = tools::Long(aFont.GetFontHeight() * fFraction);
|
||||
aFont.SetFontHeight( nHeight );
|
||||
|
||||
if (mxMetadataAuthor)
|
||||
@@ -1306,7 +1306,7 @@ int SwAnnotationWin::GetPrefScrollbarWidth() const
|
||||
{
|
||||
if (SwWrtShell* pWrtShell = mrView.GetWrtShellPtr())
|
||||
{
|
||||
const Fraction& f(pWrtShell->GetOut()->GetMapMode().GetScaleY());
|
||||
double f(pWrtShell->GetOut()->GetMapMode().GetScaleY());
|
||||
return tools::Long(Application::GetSettings().GetStyleSettings().GetScrollBarSize() * f);
|
||||
}
|
||||
else
|
||||
@@ -1339,7 +1339,7 @@ sal_Int32 SwAnnotationWin::GetMinimumSizeWithoutMeta() const
|
||||
{
|
||||
if (SwWrtShell* pWrtShell = mrView.GetWrtShellPtr())
|
||||
{
|
||||
const Fraction& f(pWrtShell->GetOut()->GetMapMode().GetScaleY());
|
||||
double f(pWrtShell->GetOut()->GetMapMode().GetScaleY());
|
||||
return tools::Long(POSTIT_MINIMUMSIZE_WITHOUT_META * f);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2476,7 +2476,7 @@ tools::ULong SwPostItMgr::GetSidebarWidth(bool bPx) const
|
||||
if (comphelper::LibreOfficeKit::isActive() && !bEnableMapMode)
|
||||
{
|
||||
// The output device is the tile and contains the real wanted scale factor.
|
||||
double fScaleX = double(mpWrtShell->GetOut()->GetMapMode().GetScaleX());
|
||||
double fScaleX = mpWrtShell->GetOut()->GetMapMode().GetScaleX();
|
||||
nZoom = fScaleX * 100;
|
||||
}
|
||||
double fDisplayWidthFactor;
|
||||
@@ -2610,31 +2610,31 @@ void SwPostItMgr::Rescale()
|
||||
|
||||
sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const
|
||||
{
|
||||
const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
double f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
return sal_Int32(POSTIT_INITIAL_ANCHOR_DISTANCE * f);
|
||||
}
|
||||
|
||||
sal_Int32 SwPostItMgr::GetSpaceBetween() const
|
||||
{
|
||||
const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
double f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
return sal_Int32(POSTIT_SPACE_BETWEEN * f);
|
||||
}
|
||||
|
||||
sal_Int32 SwPostItMgr::GetScrollSize() const
|
||||
{
|
||||
const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
double f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
return sal_Int32((POSTIT_SPACE_BETWEEN + POSTIT_MINIMUMSIZE_WITH_META) * f);
|
||||
}
|
||||
|
||||
sal_Int32 SwPostItMgr::GetMinimumSizeWithMeta() const
|
||||
{
|
||||
const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
double f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
return sal_Int32(POSTIT_MINIMUMSIZE_WITH_META * f);
|
||||
}
|
||||
|
||||
sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const
|
||||
{
|
||||
const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
double f( mpEditWin->GetMapMode().GetScaleY() );
|
||||
return sal_Int32(POSTIT_SCROLL_SIDEBAR_HEIGHT * f);
|
||||
}
|
||||
|
||||
|
||||
@@ -316,10 +316,10 @@ void SwColumnOnlyExample::Paint(vcl::RenderContext& rRenderContext, const tools:
|
||||
auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::MAPMODE);
|
||||
rRenderContext.Erase();
|
||||
|
||||
Fraction aScale(m_aWinSize.Height(), m_aFrameSize.Height());
|
||||
double fScale = double(m_aWinSize.Height()) / m_aFrameSize.Height();
|
||||
MapMode aMapMode(MapUnit::MapTwip);
|
||||
aMapMode.SetScaleX(aScale);
|
||||
aMapMode.SetScaleY(aScale);
|
||||
aMapMode.SetScaleX(fScale);
|
||||
aMapMode.SetScaleY(fScale);
|
||||
rRenderContext.SetMapMode(aMapMode);
|
||||
|
||||
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
|
||||
|
||||
@@ -236,7 +236,7 @@ void SwPagePreviewWin::CalcWish( sal_Int16 nNewRow, sal_Int16 nNewCol )
|
||||
mnSttPage, maPaintedPreviewDocRect );
|
||||
SetSelectedPage( mnSttPage );
|
||||
SetPagePreview(mnRow, mnCol);
|
||||
mfScale = double(GetMapMode().GetScaleX());
|
||||
mfScale = GetMapMode().GetScaleX();
|
||||
|
||||
// If changes have taken place at the columns, the special case "single column"
|
||||
// must be considered and corrected if necessary.
|
||||
@@ -379,7 +379,7 @@ void SwPagePreviewWin::SetWinSize( const Size& rNewSize )
|
||||
if ( mbCalcScaleForPreviewLayout )
|
||||
{
|
||||
mpPgPreviewLayout->Init( mnCol, mnRow, maPxWinSize );
|
||||
mfScale = double(GetMapMode().GetScaleX());
|
||||
mfScale = GetMapMode().GetScaleX();
|
||||
}
|
||||
mpPgPreviewLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
|
||||
mnSttPage, maPaintedPreviewDocRect );
|
||||
@@ -389,7 +389,7 @@ void SwPagePreviewWin::SetWinSize( const Size& rNewSize )
|
||||
mbCalcScaleForPreviewLayout = false;
|
||||
}
|
||||
SetPagePreview(mnRow, mnCol);
|
||||
mfScale = double(GetMapMode().GetScaleX());
|
||||
mfScale = GetMapMode().GetScaleX();
|
||||
}
|
||||
|
||||
OUString SwPagePreviewWin::GetStatusStr( sal_uInt16 nPageCnt ) const
|
||||
@@ -1751,7 +1751,7 @@ void SwPagePreviewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
|
||||
mnSttPage, maPaintedPreviewDocRect );
|
||||
SetSelectedPage( mnSttPage );
|
||||
SetPagePreview(mnRow, mnCol);
|
||||
mfScale = double(GetMapMode().GetScaleX());
|
||||
mfScale = GetMapMode().GetScaleX();
|
||||
}
|
||||
else if ( _nZoomFactor != 0 )
|
||||
{
|
||||
|
||||
@@ -1003,14 +1003,12 @@ void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize, bool )
|
||||
|
||||
if( m_pHRuler->IsVisible() || m_pVRuler->IsVisible() )
|
||||
{
|
||||
const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX();
|
||||
tools::Long nZoom = 100;
|
||||
if (rFrac.IsValid())
|
||||
nZoom = tools::Long(rFrac * 100);
|
||||
double fFrac = GetEditWin().GetMapMode().GetScaleX();
|
||||
tools::Long nZoom = tools::Long(fFrac * 100);
|
||||
|
||||
const double aFrac = double(nZoom) / 100;
|
||||
m_pVRuler->SetZoom( aFrac );
|
||||
m_pHRuler->SetZoom( aFrac );
|
||||
fFrac = double(nZoom) / 100;
|
||||
m_pVRuler->SetZoom( fFrac );
|
||||
m_pHRuler->SetZoom( fFrac );
|
||||
InvalidateRulerPos(); // Invalidate content.
|
||||
}
|
||||
// Reset the cursor stack because the cursor positions for PageUp/Down
|
||||
|
||||
@@ -346,7 +346,7 @@ void TypeSerializerTest::testMapMode()
|
||||
CPPUNIT_ASSERT_EQUAL(true, aReadMapMode.IsSimple());
|
||||
}
|
||||
{ // "complex" case - map unit, origin and scale are set, IsSimple = false
|
||||
MapMode aMapMode(MapUnit::MapTwip, Point(5, 10), Fraction(1, 2), Fraction(2, 3));
|
||||
MapMode aMapMode(MapUnit::MapTwip, Point(5, 10), 1.0 / 2, 2.0 / 3);
|
||||
|
||||
SvMemoryStream aStream;
|
||||
TypeSerializer aSerializer(aStream);
|
||||
@@ -358,10 +358,8 @@ void TypeSerializerTest::testMapMode()
|
||||
CPPUNIT_ASSERT_EQUAL(MapUnit::MapTwip, aReadMapMode.GetMapUnit());
|
||||
CPPUNIT_ASSERT_EQUAL(tools::Long(5), aReadMapMode.GetOrigin().X());
|
||||
CPPUNIT_ASSERT_EQUAL(tools::Long(10), aReadMapMode.GetOrigin().Y());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aReadMapMode.GetScaleX().GetNumerator());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aReadMapMode.GetScaleX().GetDenominator());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aReadMapMode.GetScaleY().GetNumerator());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aReadMapMode.GetScaleY().GetDenominator());
|
||||
CPPUNIT_ASSERT_EQUAL(0.5, aReadMapMode.GetScaleX());
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0 / 3, aReadMapMode.GetScaleY(), 1E-9);
|
||||
CPPUNIT_ASSERT_EQUAL(false, aReadMapMode.IsSimple());
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1957,14 +1957,14 @@ void SvmTest::checkMapMode(const GDIMetaFile& rMetafile)
|
||||
{"x", u"0"},
|
||||
{"y", u"1"},
|
||||
{"scalex", u"(1/2)"},
|
||||
{"scaley", u"(2/3)"}
|
||||
{"scaley", u"(333333333/500000000)"} // approximation of 2/3
|
||||
});
|
||||
|
||||
assertXPathAttrs(pDoc, "/metafile/mapmode[3]", {
|
||||
{"mapunit", u"MapRelative"},
|
||||
{"x", u"0"},
|
||||
{"y", u"-1"},
|
||||
{"scalex", u"(25/12)"},
|
||||
{"scalex", u"(2083333333/1000000000)"}, // approximation of 25/12
|
||||
{"scaley", u"(25/16)"}
|
||||
});
|
||||
}
|
||||
@@ -1983,8 +1983,8 @@ void SvmTest::testMapMode()
|
||||
|
||||
MapMode aMapMode1(MapUnit::Map100thInch);
|
||||
aMapMode1.SetOrigin(Point(0, 1));
|
||||
aMapMode1.SetScaleX(Fraction(1, 2));
|
||||
aMapMode1.SetScaleY(Fraction(2, 3));
|
||||
aMapMode1.SetScaleX(1.0 / 2);
|
||||
aMapMode1.SetScaleY(2.0 / 3);
|
||||
|
||||
pVirtualDev->SetMetafileMapMode(aMapMode1, false);
|
||||
|
||||
@@ -2220,7 +2220,7 @@ void SvmTest::checkEPS(const GDIMetaFile& rMetaFile)
|
||||
{"x", u"0"},
|
||||
{"y", u"1"},
|
||||
{"scalex", u"(1/2)"},
|
||||
{"scaley", u"(2/3)"}
|
||||
{"scaley", u"(333333333/500000000)"} // approximation of 2/3
|
||||
});
|
||||
|
||||
assertXPathAttrs(pDoc, "/metafile/eps[1]/metafile[1]/point[1]", {
|
||||
@@ -2246,8 +2246,8 @@ void SvmTest::testEPS()
|
||||
|
||||
MapMode aMapMode1(MapUnit::Map100thInch);
|
||||
aMapMode1.SetOrigin(Point(0, 1));
|
||||
aMapMode1.SetScaleX(Fraction(1, 2));
|
||||
aMapMode1.SetScaleY(Fraction(2, 3));
|
||||
aMapMode1.SetScaleX(1.0 / 2);
|
||||
aMapMode1.SetScaleY(2.0 / 3);
|
||||
|
||||
GDIMetaFile aGDIMetaFile1;
|
||||
ScopedVclPtrInstance<VirtualDevice> pVirtualDev1;
|
||||
|
||||
@@ -50,8 +50,8 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testFractionScaling)
|
||||
// Converting 100 Source -> 50 Dest
|
||||
|
||||
MapMode aSource(MapUnit::MapMM);
|
||||
aSource.SetScaleX(Fraction(1, 2));
|
||||
aSource.SetScaleY(Fraction(1, 2));
|
||||
aSource.SetScaleX(0.5);
|
||||
aSource.SetScaleY(0.5);
|
||||
|
||||
MapMode aDest(MapUnit::MapMM); // Default 1:1
|
||||
|
||||
@@ -70,10 +70,10 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testIntermediateOverflow)
|
||||
constexpr tools::Long nExpected = static_cast<tools::Long>(25400000000);
|
||||
|
||||
MapMode aSource(MapUnit::MapInch);
|
||||
aSource.SetScaleX(Fraction(nLarge, 1));
|
||||
aSource.SetScaleX(nLarge);
|
||||
|
||||
MapMode aDest(MapUnit::Map100thMM);
|
||||
aDest.SetScaleX(Fraction(nLarge, 1));
|
||||
aDest.SetScaleX(nLarge);
|
||||
|
||||
// n1 (Coord) = 10,000,000
|
||||
// n2 (Scale) = 2^30 (~10^9)
|
||||
@@ -219,8 +219,8 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testZoomScaling)
|
||||
// Dest: 100thMM at 100% zoom (Scale 1:1)
|
||||
|
||||
MapMode aSource(MapUnit::Map100thMM);
|
||||
aSource.SetScaleX(Fraction(4, 1));
|
||||
aSource.SetScaleY(Fraction(4, 1));
|
||||
aSource.SetScaleX(4.0);
|
||||
aSource.SetScaleY(4.0);
|
||||
|
||||
MapMode aDest(MapUnit::Map100thMM);
|
||||
|
||||
@@ -244,10 +244,10 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testComplexFractions)
|
||||
// Conversion: Val * (1/3) / (1/7) = Val * 7/3 ~= Val * 2.333
|
||||
|
||||
MapMode aSource(MapUnit::MapMM);
|
||||
aSource.SetScaleX(Fraction(1, 3));
|
||||
aSource.SetScaleX(1.0 / 3);
|
||||
|
||||
MapMode aDest(MapUnit::MapMM);
|
||||
aDest.SetScaleX(Fraction(1, 7));
|
||||
aDest.SetScaleX(1.0 / 7);
|
||||
|
||||
Point aPt(300, 0);
|
||||
// 300 * 7 / 3 = 100 * 7 = 700
|
||||
|
||||
@@ -1012,8 +1012,8 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uI
|
||||
MapMode aMapMode(
|
||||
MapUnit::MapMM,
|
||||
Point(),
|
||||
Fraction(1000, aHeader.nXPelsPerMeter),
|
||||
Fraction(1000, aHeader.nYPelsPerMeter));
|
||||
1000.0 / aHeader.nXPelsPerMeter,
|
||||
1000.0 / aHeader.nYPelsPerMeter);
|
||||
|
||||
aNewBmp.SetPrefMapMode(aMapMode);
|
||||
aNewBmp.SetPrefSize(Size(aHeader.nWidth, aHeader.nHeight));
|
||||
|
||||
@@ -223,10 +223,10 @@ static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& r
|
||||
MapMode aMap( MapUnit::Map100thInch );
|
||||
|
||||
sal_Int32 nDPI = rConfigItem.ReadInt32( u"Resolution"_ustr, 75 );
|
||||
Fraction aFrac( 1, std::clamp( nDPI, sal_Int32(75), sal_Int32(600) ) );
|
||||
double fFrac = 1.0 / std::clamp( nDPI, sal_Int32(75), sal_Int32(600) );
|
||||
|
||||
aMap.SetScaleX( aFrac );
|
||||
aMap.SetScaleY( aFrac );
|
||||
aMap.SetScaleX( fFrac );
|
||||
aMap.SetScaleY( fFrac );
|
||||
|
||||
Size aOldSize = aBitmap.GetSizePixel();
|
||||
aGraphic = rGraphic;
|
||||
|
||||
@@ -147,9 +147,9 @@ bool PSDReader::ReadPSD(Graphic & rGraphic )
|
||||
|
||||
if ( mnXResFixed && mnYResFixed )
|
||||
{
|
||||
Fraction aFractX( 1, mnXResFixed >> 16 );
|
||||
Fraction aFractY( 1, mnYResFixed >> 16 );
|
||||
MapMode aMapMode( MapUnit::MapInch, Point(), aFractX, aFractY );
|
||||
double fFractX = 1.0 / (mnXResFixed >> 16);
|
||||
double fFractY = 1.0 / (mnYResFixed >> 16);
|
||||
MapMode aMapMode( MapUnit::MapInch, Point(), fFractX, fFractY );
|
||||
Size aPrefSize = OutputDevice::LogicToLogic(aBitmapSize, aMapMode, MapMode(MapUnit::Map100thMM));
|
||||
rGraphic.SetPrefSize( aPrefSize );
|
||||
rGraphic.SetPrefMapMode( MapMode( MapUnit::Map100thMM ) );
|
||||
|
||||
@@ -222,9 +222,9 @@ bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam)
|
||||
|
||||
if (((1 == nUnit) || (2 == nUnit)) && rParam.X_density && rParam.Y_density )
|
||||
{
|
||||
Fraction aFractX( 1, rParam.X_density );
|
||||
Fraction aFractY( 1, rParam.Y_density );
|
||||
MapMode aMapMode( nUnit == 1 ? MapUnit::MapInch : MapUnit::MapCM, Point(), aFractX, aFractY );
|
||||
double fFractX = 1.0 / rParam.X_density;
|
||||
double fFractY = 1.0 / rParam.Y_density;
|
||||
MapMode aMapMode( nUnit == 1 ? MapUnit::MapInch : MapUnit::MapCM, Point(), fFractX, fFractY );
|
||||
Size aPrefSize = OutputDevice::LogicToLogic(aSize, aMapMode, MapMode(MapUnit::Map100thMM));
|
||||
|
||||
mpBitmap->SetPrefSize(aPrefSize);
|
||||
|
||||
@@ -1398,44 +1398,20 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
|
||||
if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative )
|
||||
{
|
||||
const MapMode& aMM = pA->GetMapMode();
|
||||
Fraction aScaleX = aMM.GetScaleX();
|
||||
Fraction aScaleY = aMM.GetScaleY();
|
||||
double fScaleX = aMM.GetScaleX();
|
||||
double fScaleY = aMM.GetScaleY();
|
||||
|
||||
Point aOrigin = aSrcMapMode.GetOrigin();
|
||||
BigInt aX( aOrigin.X() );
|
||||
aX *= BigInt( aScaleX.GetDenominator() );
|
||||
if( aOrigin.X() >= 0 )
|
||||
if( aScaleX.GetNumerator() >= 0 )
|
||||
aX += BigInt( aScaleX.GetNumerator()/2 );
|
||||
else
|
||||
aX -= BigInt( (aScaleX.GetNumerator()+1)/2 );
|
||||
else
|
||||
if( aScaleX.GetNumerator() >= 0 )
|
||||
aX -= BigInt( (aScaleX.GetNumerator()-1)/2 );
|
||||
else
|
||||
aX += BigInt( aScaleX.GetNumerator()/2 );
|
||||
aX /= BigInt( aScaleX.GetNumerator() );
|
||||
aOrigin.setX( static_cast<tools::Long>(aX) + aMM.GetOrigin().X() );
|
||||
BigInt aY( aOrigin.Y() );
|
||||
aY *= BigInt( aScaleY.GetDenominator() );
|
||||
if( aOrigin.Y() >= 0 )
|
||||
if( aScaleY.GetNumerator() >= 0 )
|
||||
aY += BigInt( aScaleY.GetNumerator()/2 );
|
||||
else
|
||||
aY -= BigInt( (aScaleY.GetNumerator()+1)/2 );
|
||||
else
|
||||
if( aScaleY.GetNumerator() >= 0 )
|
||||
aY -= BigInt( (aScaleY.GetNumerator()-1)/2 );
|
||||
else
|
||||
aY += BigInt( aScaleY.GetNumerator()/2 );
|
||||
aY /= BigInt( aScaleY.GetNumerator() );
|
||||
aOrigin.setY( static_cast<tools::Long>(aY) + aMM.GetOrigin().Y() );
|
||||
tools::Long aX = std::llround(double( aOrigin.X() ) / fScaleX);
|
||||
aOrigin.setX( aX + aMM.GetOrigin().X() );
|
||||
tools::Long aY = std::llround(double( aOrigin.Y() ) / fScaleY);
|
||||
aOrigin.setY( aY + aMM.GetOrigin().Y() );
|
||||
aSrcMapMode.SetOrigin( aOrigin );
|
||||
|
||||
aScaleX *= aSrcMapMode.GetScaleX();
|
||||
aScaleY *= aSrcMapMode.GetScaleY();
|
||||
aSrcMapMode.SetScaleX( aScaleX );
|
||||
aSrcMapMode.SetScaleY( aScaleY );
|
||||
fScaleX *= aSrcMapMode.GetScaleX();
|
||||
fScaleY *= aSrcMapMode.GetScaleY();
|
||||
aSrcMapMode.SetScaleX( fScaleX );
|
||||
aSrcMapMode.SetScaleY( fScaleY );
|
||||
}
|
||||
else
|
||||
aSrcMapMode=pA->GetMapMode();
|
||||
@@ -1724,10 +1700,10 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream,
|
||||
aTargetMapMode = MapMode( MapUnit::MapInch );
|
||||
|
||||
const tools::Long nUnit = pVirDev->LogicToPixel( Size( 1, 1 ), aTargetMapMode ).Width();
|
||||
const Fraction aFrac( 1, nUnit );
|
||||
const double fFrac = 1.0 / nUnit;
|
||||
|
||||
aTargetMapMode.SetScaleX( aFrac );
|
||||
aTargetMapMode.SetScaleY( aFrac );
|
||||
aTargetMapMode.SetScaleX( fFrac );
|
||||
aTargetMapMode.SetScaleY( fFrac );
|
||||
aTargetSize = OutputDevice::LogicToLogic( rMTF.GetPrefSize(), aSrcMapMode, aTargetMapMode );
|
||||
}
|
||||
|
||||
@@ -1807,20 +1783,20 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream,
|
||||
sal_uInt16 WMFWriter::CalcSaveTargetMapMode(MapMode& rMapMode,
|
||||
const Size& rPrefSize)
|
||||
{
|
||||
Fraction aDivFrac(2, 1);
|
||||
double fDivFrac = 2.0;
|
||||
sal_uInt16 nDivisor = 1;
|
||||
|
||||
Size aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
|
||||
|
||||
while( nDivisor <= 64 && (aSize.Width() > 32767 || aSize.Height() > 32767) )
|
||||
{
|
||||
Fraction aFrac = rMapMode.GetScaleX();
|
||||
double fFrac = rMapMode.GetScaleX();
|
||||
|
||||
aFrac *= aDivFrac;
|
||||
rMapMode.SetScaleX(aFrac);
|
||||
aFrac = rMapMode.GetScaleY();
|
||||
aFrac *= aDivFrac;
|
||||
rMapMode.SetScaleY(aFrac);
|
||||
fFrac *= fDivFrac;
|
||||
rMapMode.SetScaleX(fFrac);
|
||||
fFrac = rMapMode.GetScaleY();
|
||||
fFrac *= fDivFrac;
|
||||
rMapMode.SetScaleY(fFrac);
|
||||
nDivisor <<= 1;
|
||||
aSize = OutputDevice::LogicToLogic( rPrefSize, aSrcMapMode, rMapMode );
|
||||
}
|
||||
|
||||
@@ -444,17 +444,6 @@ void TypeSerializer::writeGraphic(const Graphic& rGraphic)
|
||||
}
|
||||
}
|
||||
|
||||
bool TooLargeScaleForMapMode(const Fraction& rScale, int nDPI)
|
||||
{
|
||||
// ImplLogicToPixel will multiply its values by this numerator * dpi and then double that
|
||||
// result before dividing
|
||||
if (rScale.GetNumerator() > std::numeric_limits<sal_Int32>::max() / nDPI / 2)
|
||||
return true;
|
||||
if (rScale.GetNumerator() < std::numeric_limits<sal_Int32>::min() / nDPI / 2)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool UselessScaleForMapMode(const Fraction& rScale)
|
||||
{
|
||||
if (!rScale.IsValid())
|
||||
@@ -517,7 +506,7 @@ bool TypeSerializer::readMapMode(MapMode& rMapMode)
|
||||
SAL_WARN("vcl", "invalid scale");
|
||||
return false;
|
||||
}
|
||||
rMapMode = MapMode(eUnit, aOrigin, aScaleX, aScaleY);
|
||||
rMapMode = MapMode(eUnit, aOrigin, double(aScaleX), double(aScaleY));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -528,8 +517,8 @@ void TypeSerializer::writeMapMode(MapMode const& rMapMode)
|
||||
|
||||
mrStream.WriteUInt16(sal_uInt16(rMapMode.GetMapUnit()));
|
||||
writePoint(rMapMode.GetOrigin());
|
||||
writeFraction(rMapMode.GetScaleX());
|
||||
writeFraction(rMapMode.GetScaleY());
|
||||
writeFraction(Fraction(rMapMode.GetScaleX()));
|
||||
writeFraction(Fraction(rMapMode.GetScaleY()));
|
||||
mrStream.WriteBool(rMapMode.IsSimple());
|
||||
}
|
||||
|
||||
|
||||
@@ -472,26 +472,14 @@ void GDIMetaFile::Play(OutputDevice& rOut, const Point& rPos,
|
||||
if( !aTmpPrefSize.Height() )
|
||||
aTmpPrefSize.setHeight( aDestSize.Height() );
|
||||
|
||||
Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() );
|
||||
Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() );
|
||||
double fScaleX = double( aDestSize.Width() ) / aTmpPrefSize.Width();
|
||||
double fScaleY = double( aDestSize.Height() ) / aTmpPrefSize.Height();
|
||||
|
||||
aScaleX *= aDrawMap.GetScaleX();
|
||||
aScaleY *= aDrawMap.GetScaleY();
|
||||
// try reducing inaccurary first and abandon if the scaling
|
||||
// still cannot be achieved
|
||||
if (TooLargeScaleForMapMode(aScaleX, rOut.GetDPIX()))
|
||||
aScaleX.ReduceInaccurate(10);
|
||||
if (TooLargeScaleForMapMode(aScaleY, rOut.GetDPIY()))
|
||||
aScaleY.ReduceInaccurate(10);
|
||||
if (TooLargeScaleForMapMode(aScaleX, rOut.GetDPIX()) ||
|
||||
TooLargeScaleForMapMode(aScaleY, rOut.GetDPIY()))
|
||||
{
|
||||
SAL_WARN("vcl", "GDIMetaFile Scaling is too high");
|
||||
return;
|
||||
}
|
||||
fScaleX *= aDrawMap.GetScaleX();
|
||||
fScaleY *= aDrawMap.GetScaleY();
|
||||
|
||||
aDrawMap.SetScaleX(aScaleX);
|
||||
aDrawMap.SetScaleY(aScaleY);
|
||||
aDrawMap.SetScaleX(fScaleX);
|
||||
aDrawMap.SetScaleY(fScaleY);
|
||||
|
||||
// #i47260# Convert logical output position to offset within
|
||||
// the metafile's mapmode. Therefore, disable pixel offset on
|
||||
@@ -703,8 +691,8 @@ void GDIMetaFile::Move( tools::Long nX, tools::Long nY, tools::Long nDPIX, tools
|
||||
{
|
||||
aOffset = aMapVDev->LogicToPixel( aBaseOffset, GetPrefMapMode() );
|
||||
MapMode aMap( aMapVDev->GetMapMode() );
|
||||
aOffset.setWidth( static_cast<tools::Long>(aOffset.Width() * static_cast<double>(aMap.GetScaleX())) );
|
||||
aOffset.setHeight( static_cast<tools::Long>(aOffset.Height() * static_cast<double>(aMap.GetScaleY())) );
|
||||
aOffset.setWidth( static_cast<tools::Long>(aOffset.Width() * aMap.GetScaleX()) );
|
||||
aOffset.setHeight( static_cast<tools::Long>(aOffset.Height() * aMap.GetScaleY()) );
|
||||
}
|
||||
else
|
||||
aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() );
|
||||
|
||||
@@ -395,7 +395,7 @@ basegfx::B2DSize Graphic::GetPPI() const { return GetPPUnit(MapMode(MapUnit::Map
|
||||
|
||||
basegfx::B2DSize Graphic::GetPPM() const
|
||||
{
|
||||
return GetPPUnit(MapMode(MapUnit::MapMM, {}, { 1000, 1 }, { 1000, 1 }));
|
||||
return GetPPUnit(MapMode(MapUnit::MapMM, {}, 1000.0, 1000.0));
|
||||
}
|
||||
|
||||
Size Graphic::GetSizePixel( const OutputDevice* pRefDevice ) const
|
||||
|
||||
+19
-41
@@ -36,8 +36,8 @@ struct MapMode::ImplMapMode
|
||||
// because ReadFraction / WriteFraction do only 32 bits, so more than
|
||||
// that cannot be stored in MetaFiles!
|
||||
// => call ReduceInaccurate whenever setting these
|
||||
Fraction maScaleX;
|
||||
Fraction maScaleY;
|
||||
double mfScaleX;
|
||||
double mfScaleY;
|
||||
|
||||
ImplMapMode();
|
||||
ImplMapMode(MapUnit eMapUnit);
|
||||
@@ -48,8 +48,8 @@ struct MapMode::ImplMapMode
|
||||
|
||||
MapMode::ImplMapMode::ImplMapMode() :
|
||||
maOrigin( 0, 0 ),
|
||||
maScaleX( 1, 1 ),
|
||||
maScaleY( 1, 1 )
|
||||
mfScaleX( 1.0 ),
|
||||
mfScaleY( 1.0 )
|
||||
{
|
||||
meUnit = MapUnit::MapPixel;
|
||||
mbSimple = true;
|
||||
@@ -57,8 +57,8 @@ MapMode::ImplMapMode::ImplMapMode() :
|
||||
|
||||
MapMode::ImplMapMode::ImplMapMode(MapUnit eMapUnit) :
|
||||
maOrigin( 0, 0 ),
|
||||
maScaleX( 1, 1 ),
|
||||
maScaleY( 1, 1 )
|
||||
mfScaleX( 1.0 ),
|
||||
mfScaleY( 1.0 )
|
||||
{
|
||||
meUnit = eMapUnit;
|
||||
mbSimple = true;
|
||||
@@ -70,8 +70,8 @@ bool MapMode::ImplMapMode::operator==( const ImplMapMode& rImpMapMode ) const
|
||||
{
|
||||
return meUnit == rImpMapMode.meUnit
|
||||
&& maOrigin == rImpMapMode.maOrigin
|
||||
&& maScaleX == rImpMapMode.maScaleX
|
||||
&& maScaleY == rImpMapMode.maScaleY;
|
||||
&& mfScaleX == rImpMapMode.mfScaleX
|
||||
&& mfScaleY == rImpMapMode.mfScaleY;
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -120,22 +120,12 @@ MapMode::MapMode( MapUnit eUnit ) : mpImplMapMode(GetUnitDefault(eUnit))
|
||||
}
|
||||
|
||||
MapMode::MapMode( MapUnit eUnit, const Point& rLogicOrg,
|
||||
const Fraction& rScaleX, const Fraction& rScaleY )
|
||||
double fScaleX, double fScaleY )
|
||||
{
|
||||
mpImplMapMode->meUnit = eUnit;
|
||||
mpImplMapMode->maOrigin = rLogicOrg;
|
||||
mpImplMapMode->maScaleX = rScaleX;
|
||||
mpImplMapMode->maScaleY = rScaleY;
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
MapMode::MapMode( MapUnit eUnit, const Point& rLogicOrg,
|
||||
double rScaleX, double rScaleY )
|
||||
{
|
||||
mpImplMapMode->meUnit = eUnit;
|
||||
mpImplMapMode->maOrigin = rLogicOrg;
|
||||
mpImplMapMode->maScaleX = rScaleX;
|
||||
mpImplMapMode->maScaleY = rScaleY;
|
||||
mpImplMapMode->mfScaleX = fScaleX;
|
||||
mpImplMapMode->mfScaleY = fScaleY;
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
@@ -152,27 +142,15 @@ void MapMode::SetOrigin( const Point& rLogicOrg )
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
void MapMode::SetScaleX( const Fraction& rScaleX )
|
||||
void MapMode::SetScaleX( double fScaleX )
|
||||
{
|
||||
mpImplMapMode->maScaleX = rScaleX;
|
||||
mpImplMapMode->mfScaleX = fScaleX;
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
void MapMode::SetScaleX( double rScaleX )
|
||||
void MapMode::SetScaleY( double fScaleY )
|
||||
{
|
||||
mpImplMapMode->maScaleX = rScaleX;
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
void MapMode::SetScaleY( const Fraction& rScaleY )
|
||||
{
|
||||
mpImplMapMode->maScaleY = rScaleY;
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
void MapMode::SetScaleY( double rScaleY )
|
||||
{
|
||||
mpImplMapMode->maScaleY = rScaleY;
|
||||
mpImplMapMode->mfScaleY = fScaleY;
|
||||
mpImplMapMode->mbSimple = false;
|
||||
}
|
||||
|
||||
@@ -195,8 +173,8 @@ size_t MapMode::GetHashValue() const
|
||||
size_t hash = 0;
|
||||
o3tl::hash_combine( hash, mpImplMapMode->meUnit );
|
||||
o3tl::hash_combine( hash, mpImplMapMode->maOrigin.GetHashValue());
|
||||
o3tl::hash_combine( hash, mpImplMapMode->maScaleX.GetHashValue());
|
||||
o3tl::hash_combine( hash, mpImplMapMode->maScaleY.GetHashValue());
|
||||
o3tl::hash_combine( hash, mpImplMapMode->mfScaleX);
|
||||
o3tl::hash_combine( hash, mpImplMapMode->mfScaleY);
|
||||
o3tl::hash_combine( hash, mpImplMapMode->mbSimple );
|
||||
return hash;
|
||||
}
|
||||
@@ -205,9 +183,9 @@ MapUnit MapMode::GetMapUnit() const { return mpImplMapMode->meUnit; }
|
||||
|
||||
const Point& MapMode::GetOrigin() const { return mpImplMapMode->maOrigin; }
|
||||
|
||||
const Fraction& MapMode::GetScaleX() const { return mpImplMapMode->maScaleX; }
|
||||
double MapMode::GetScaleX() const { return mpImplMapMode->mfScaleX; }
|
||||
|
||||
const Fraction& MapMode::GetScaleY() const { return mpImplMapMode->maScaleY; }
|
||||
double MapMode::GetScaleY() const { return mpImplMapMode->mfScaleY; }
|
||||
|
||||
bool MapMode::IsSimple() const { return mpImplMapMode->mbSimple; }
|
||||
|
||||
|
||||
@@ -377,11 +377,11 @@ OUString convertMapUnitToString(MapUnit eUnit)
|
||||
}
|
||||
}
|
||||
|
||||
OUString convertFractionToString(const Fraction& aFraction)
|
||||
OUString convertFractionToString(double fFraction)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << aFraction;
|
||||
ss << Fraction(fFraction);
|
||||
|
||||
return OUString::createFromAscii(ss.str());
|
||||
}
|
||||
|
||||
+21
-52
@@ -108,8 +108,8 @@ static void ImplCalcMapResolution( const MapMode& rMapMode,
|
||||
break;
|
||||
}
|
||||
|
||||
const Fraction& aScaleX = rMapMode.GetScaleX();
|
||||
const Fraction& aScaleY = rMapMode.GetScaleY();
|
||||
double fScaleX = rMapMode.GetScaleX();
|
||||
double fScaleY = rMapMode.GetScaleY();
|
||||
|
||||
// set offset according to MapMode
|
||||
Point aOrigin = rMapMode.GetOrigin();
|
||||
@@ -120,39 +120,20 @@ static void ImplCalcMapResolution( const MapMode& rMapMode,
|
||||
}
|
||||
else
|
||||
{
|
||||
auto funcCalcOffset = [](const Fraction& rScale, tools::Long& rnMapOffset, tools::Long nOrigin)
|
||||
auto funcCalcOffset = [](double fScale, tools::Long& rnMapOffset, tools::Long nOrigin)
|
||||
{
|
||||
auto nNumerator = rScale.GetNumerator();
|
||||
assert(nNumerator != 0);
|
||||
|
||||
BigInt aX( rnMapOffset );
|
||||
aX *= BigInt( rScale.GetDenominator() );
|
||||
if ( rnMapOffset >= 0 )
|
||||
{
|
||||
if (nNumerator >= 0)
|
||||
aX += BigInt(nNumerator / 2);
|
||||
else
|
||||
aX -= BigInt((nNumerator + 1) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nNumerator >= 0 )
|
||||
aX -= BigInt((nNumerator - 1) / 2);
|
||||
else
|
||||
aX += BigInt(nNumerator / 2);
|
||||
}
|
||||
aX /= BigInt(nNumerator);
|
||||
rnMapOffset = static_cast<tools::Long>(aX) + nOrigin;
|
||||
assert(fScale != 0);
|
||||
rnMapOffset = std::llround(double( rnMapOffset ) / fScale) + nOrigin;
|
||||
};
|
||||
|
||||
funcCalcOffset(aScaleX, rMapRes.mnMapOfsX, aOrigin.X());
|
||||
funcCalcOffset(aScaleY, rMapRes.mnMapOfsY, aOrigin.Y());
|
||||
funcCalcOffset(fScaleX, rMapRes.mnMapOfsX, aOrigin.X());
|
||||
funcCalcOffset(fScaleY, rMapRes.mnMapOfsY, aOrigin.Y());
|
||||
}
|
||||
|
||||
// calculate scaling factor according to MapMode
|
||||
// aTemp? = rMapRes.mnMapSc? * aScale?
|
||||
rMapRes.mfMapScX = double(aScaleX) * rMapRes.mfMapScX;
|
||||
rMapRes.mfMapScY = double(aScaleY) * rMapRes.mfMapScY;
|
||||
rMapRes.mfMapScX = fScaleX * rMapRes.mfMapScX;
|
||||
rMapRes.mfMapScY = fScaleY * rMapRes.mfMapScY;
|
||||
}
|
||||
|
||||
// #i75163#
|
||||
@@ -639,13 +620,9 @@ void OutputDevice::SetMapMode( const MapMode& rNewMapMode )
|
||||
// set new MapMode
|
||||
if (bRelMap)
|
||||
{
|
||||
maMapMode.SetScaleX(Fraction::MakeFraction(
|
||||
maMapMode.GetScaleX().GetNumerator(), rNewMapMode.GetScaleX().GetNumerator(),
|
||||
maMapMode.GetScaleX().GetDenominator(), rNewMapMode.GetScaleX().GetDenominator()));
|
||||
maMapMode.SetScaleX(maMapMode.GetScaleX() * rNewMapMode.GetScaleX());
|
||||
|
||||
maMapMode.SetScaleY(Fraction::MakeFraction(
|
||||
maMapMode.GetScaleY().GetNumerator(), rNewMapMode.GetScaleY().GetNumerator(),
|
||||
maMapMode.GetScaleY().GetDenominator(), rNewMapMode.GetScaleY().GetDenominator()));
|
||||
maMapMode.SetScaleY(maMapMode.GetScaleY() * rNewMapMode.GetScaleY());
|
||||
|
||||
maMapMode.SetOrigin(Point(maMapRes.mnMapOfsX, maMapRes.mnMapOfsY));
|
||||
}
|
||||
@@ -689,14 +666,8 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
|
||||
MapUnit eNew = rNewMapMode.GetMapUnit();
|
||||
|
||||
// a?F = rNewMapMode.GetScale?() / maMapMode.GetScale?()
|
||||
Fraction aXF = Fraction::MakeFraction( rNewMapMode.GetScaleX().GetNumerator(),
|
||||
maMapMode.GetScaleX().GetDenominator(),
|
||||
rNewMapMode.GetScaleX().GetDenominator(),
|
||||
maMapMode.GetScaleX().GetNumerator() );
|
||||
Fraction aYF = Fraction::MakeFraction( rNewMapMode.GetScaleY().GetNumerator(),
|
||||
maMapMode.GetScaleY().GetDenominator(),
|
||||
rNewMapMode.GetScaleY().GetDenominator(),
|
||||
maMapMode.GetScaleY().GetNumerator() );
|
||||
double fXF = rNewMapMode.GetScaleX() / maMapMode.GetScaleX();
|
||||
double fYF = rNewMapMode.GetScaleY() / maMapMode.GetScaleY();
|
||||
|
||||
Point aPt( LogicToLogic( Point(), nullptr, &rNewMapMode ) );
|
||||
if ( eNew != eOld )
|
||||
@@ -714,27 +685,25 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
|
||||
const auto eFrom = MapToO3tlLength(eOld, o3tl::Length::in);
|
||||
const auto eTo = MapToO3tlLength(eNew, o3tl::Length::in);
|
||||
const auto [mul, div] = o3tl::getConversionMulDiv(eFrom, eTo);
|
||||
Fraction aF(div, mul);
|
||||
double aF = double(div) / mul;
|
||||
|
||||
// a?F = a?F * aF
|
||||
aXF = Fraction::MakeFraction( aXF.GetNumerator(), aF.GetNumerator(),
|
||||
aXF.GetDenominator(), aF.GetDenominator() );
|
||||
aYF = Fraction::MakeFraction( aYF.GetNumerator(), aF.GetNumerator(),
|
||||
aYF.GetDenominator(), aF.GetDenominator() );
|
||||
fXF = fXF * aF;
|
||||
fYF = fYF * aF;
|
||||
if ( eOld == MapUnit::MapPixel )
|
||||
{
|
||||
aXF *= Fraction( mnDPIX, 1 );
|
||||
aYF *= Fraction( mnDPIY, 1 );
|
||||
fXF *= mnDPIX;
|
||||
fYF *= mnDPIY;
|
||||
}
|
||||
else if ( eNew == MapUnit::MapPixel )
|
||||
{
|
||||
aXF *= Fraction( 1, mnDPIX );
|
||||
aYF *= Fraction( 1, mnDPIY );
|
||||
fXF /= mnDPIX;
|
||||
fYF /= mnDPIY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MapMode aNewMapMode( MapUnit::MapRelative, Point( -aPt.X(), -aPt.Y() ), aXF, aYF );
|
||||
MapMode aNewMapMode( MapUnit::MapRelative, Point( -aPt.X(), -aPt.Y() ), fXF, fYF );
|
||||
SetMapMode( aNewMapMode );
|
||||
|
||||
if ( eNew != eOld )
|
||||
|
||||
@@ -603,7 +603,7 @@ void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::O
|
||||
m_nCurrentPage = m_aPages.size();
|
||||
m_aPages.emplace_back(this, nPageWidth, nPageHeight, eOrientation );
|
||||
|
||||
const Fraction frac(m_aPages.back().m_nUserUnit, pointToPixel(1));
|
||||
const double frac = double(m_aPages.back().m_nUserUnit) / pointToPixel(1);
|
||||
m_aMapMode = MapMode(MapUnit::MapPoint, Point(), frac, frac);
|
||||
|
||||
m_aPages.back().beginStream();
|
||||
@@ -5891,7 +5891,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
|
||||
// if the mapmode is distorted we need to adjust for that also
|
||||
if( m_aCurrentPDFState.m_aMapMode.GetScaleX() != m_aCurrentPDFState.m_aMapMode.GetScaleY() )
|
||||
{
|
||||
fXScale *= double(m_aCurrentPDFState.m_aMapMode.GetScaleX()) / double(m_aCurrentPDFState.m_aMapMode.GetScaleY());
|
||||
fXScale *= m_aCurrentPDFState.m_aMapMode.GetScaleX() / m_aCurrentPDFState.m_aMapMode.GetScaleY();
|
||||
}
|
||||
|
||||
Degree10 nAngle = m_aCurrentPDFState.m_aFont.GetOrientation();
|
||||
|
||||
Reference in New Issue
Block a user