From aac260c00dc60b2890c88fea7e8c5f0b14b474ae Mon Sep 17 00:00:00 2001 From: Andrzej Hunt Date: Fri, 15 Aug 2014 16:06:06 +0200 Subject: Make nPrtToScreenFactor and GetOutputFactor fractions. These are then used for our output MapMode which required Fractions too. Change-Id: Icbfd9f808a6efe297096c94dc4043cef88c0ba0b --- sc/source/ui/docshell/docsh.cxx | 7 ++++--- sc/source/ui/docshell/docsh3.cxx | 10 ++++++---- sc/source/ui/docshell/sizedev.cxx | 2 +- sc/source/ui/inc/docsh.hxx | 4 ++-- sc/source/ui/view/drawvie4.cxx | 2 +- sc/source/ui/view/preview.cxx | 27 ++++++++++++++++++++------- sc/source/ui/view/tabview2.cxx | 6 ++++-- sc/source/ui/view/viewdata.cxx | 5 +++-- sc/source/ui/view/viewfunc.cxx | 4 +++- 9 files changed, 44 insertions(+), 23 deletions(-) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 67b5d5d4a31c..7e6429b105d0 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1455,7 +1455,8 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) if ( bRet && (bSetColWidths || bSetRowHeights) ) { // Adjust column width/row height; base 100% zoom Fraction aZoom( 1, 1 ); - double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / GetOutputFactor(); // Factor is printer display ratio + double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / + static_cast< double >( GetOutputFactor() ); // Factor is printer display ratio double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom; VirtualDevice aVirtDev; // all sheets (for Excel import) @@ -2630,7 +2631,7 @@ ScDocShell::ScDocShell( const ScDocShell& rShell ) : SfxListener(), aDocument ( SCDOCMODE_DOCUMENT, this ), aDdeTextFmt(OUString("TEXT")), - nPrtToScreenFactor( 1.0 ), + nPrtToScreenFactor( 1, 1 ), pImpl ( new DocShell_Impl ), bHeaderOn ( true ), bFooterOn ( true ), @@ -2675,7 +2676,7 @@ ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags ) : SfxObjectShell( i_nSfxCreationFlags ), aDocument ( SCDOCMODE_DOCUMENT, this ), aDdeTextFmt(OUString("TEXT")), - nPrtToScreenFactor( 1.0 ), + nPrtToScreenFactor( 1, 1 ), pImpl ( new DocShell_Impl ), bHeaderOn ( true ), bFooterOn ( true ), diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 950664ac7f18..88a124a4bddc 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -338,14 +338,14 @@ void ScDocShell::CalcOutputFactor() { if (bIsInplace) { - nPrtToScreenFactor = 1.0; // passt sonst nicht zur inaktiven Darstellung + nPrtToScreenFactor = Fraction( 1, 1 ); // passt sonst nicht zur inaktiven Darstellung return; } bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg(); if (bTextWysiwyg) { - nPrtToScreenFactor = 1.0; + nPrtToScreenFactor = Fraction( 1, 1 ); return; } @@ -376,11 +376,13 @@ void ScDocShell::CalcOutputFactor() nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS ); if (nPrinterWidth && nWindowWidth) - nPrtToScreenFactor = nPrinterWidth / (double) nWindowWidth; + { + nPrtToScreenFactor = Fraction( nPrinterWidth, nWindowWidth ); + } else { OSL_FAIL("GetTextSize gibt 0 ??"); - nPrtToScreenFactor = 1.0; + nPrtToScreenFactor = Fraction( 1, 1 ); } } diff --git a/sc/source/ui/docshell/sizedev.cxx b/sc/source/ui/docshell/sizedev.cxx index e0ff33c205c1..99524b6c69cc 100644 --- a/sc/source/ui/docshell/sizedev.cxx +++ b/sc/source/ui/docshell/sizedev.cxx @@ -49,7 +49,7 @@ ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh ) nPPTY = aLogic.Y() / 1000.0; if ( !bTextWysiwyg ) - nPPTX /= pDocSh->GetOutputFactor(); + nPPTX /= static_cast< double >( pDocSh->GetOutputFactor() ); } ScSizeDeviceProvider::~ScSizeDeviceProvider() diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 1f4793daff18..051ce0a466f8 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -87,7 +87,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener OUString aDdeTextFmt; - double nPrtToScreenFactor; + Fraction nPrtToScreenFactor; DocShell_Impl* pImpl; ScDocFunc* pDocFunc; @@ -367,7 +367,7 @@ public: void SetInUndo(bool bSet); void CalcOutputFactor(); - double GetOutputFactor() const { return nPrtToScreenFactor;} + Fraction GetOutputFactor() const { return nPrtToScreenFactor;} void GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet, SCTAB nCurTab, bool& rbHeader, diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index b3b6e849d20a..32f8ebf8c49d 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -443,7 +443,7 @@ void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const double nPPTY = ScGlobal::nScreenPPTY; if (pViewData) - nPPTX /= pViewData->GetDocShell()->GetOutputFactor(); + nPPTX /= static_cast< double >( pViewData->GetDocShell()->GetOutputFactor() ); SCCOL nEndCol = 0; SCROW nEndRow = 0; diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index e7977eacfa29..4fe38b8caab7 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -345,7 +345,9 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) } Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / + static_cast< double>( pDocShell->GetOutputFactor() ) ), + 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); bool bDoPrint = ( pFillLocation == NULL ); @@ -733,7 +735,9 @@ void ScPreview::SetZoom(sal_uInt16 nNewZoom) // apply new MapMode and call UpdateScrollBars to update aOffset Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / + static_cast< double >( pDocShell->GetOutputFactor() ) ), + 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); SetMapMode( aMMMode ); @@ -802,7 +806,8 @@ static Size lcl_GetDocPageSize( ScDocument* pDoc, SCTAB nTab ) sal_uInt16 ScPreview::GetOptimalZoom(bool bWidthOnly) { - double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor(); + double nWinScaleX = ScGlobal::nScreenPPTX / + static_cast< double >( pDocShell->GetOutputFactor() ); double nWinScaleY = ScGlobal::nScreenPPTY; Size aWinSize = GetOutputSizePixel(); @@ -962,7 +967,9 @@ void ScPreview::DataChanged( const DataChangedEvent& rDCEvt ) void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / + static_cast< double >( pDocShell->GetOutputFactor() ) ), + 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode ); @@ -1045,7 +1052,9 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / + static_cast< double >( pDocShell->GetOutputFactor() ) ), + 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode ); @@ -1295,7 +1304,9 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) void ScPreview::MouseMove( const MouseEvent& rMEvt ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / + static_cast< double >( pDocShell->GetOutputFactor() ) ), + 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode ); @@ -1541,7 +1552,9 @@ void ScPreview::SwitchView() void ScPreview::DragMove( long nDragMovePos, sal_uInt16 nFlags ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( (long)( 100 * nZoom / + static_cast< double >( pDocShell->GetOutputFactor() ) ), + 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); SetMapMode( aMMMode ); long nPos = nDragMovePos; diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index c79d356065ae..01f7c2a4958d 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -1238,7 +1238,8 @@ sal_uInt16 ScTabView::CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom ) aWinSize.Height() += GetGridHeight( SC_SPLIT_TOP ); ScDocShell* pDocSh = aViewData.GetDocShell(); - double nPPTX = ScGlobal::nScreenPPTX / pDocSh->GetOutputFactor(); + double nPPTX = ScGlobal::nScreenPPTX / + static_cast< double >( pDocSh->GetOutputFactor() ); double nPPTY = ScGlobal::nScreenPPTY; sal_uInt16 nMin = MINZOOM; @@ -1331,7 +1332,8 @@ sal_uInt16 ScTabView::CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom ) aWinSize.Height() = nOtherHeight; } - double nPPTX = ScGlobal::nScreenPPTX / aViewData.GetDocShell()->GetOutputFactor(); + double nPPTX = ScGlobal::nScreenPPTX / + static_cast< double >( aViewData.GetDocShell()->GetOutputFactor() ); double nPPTY = ScGlobal::nScreenPPTY; long nZoomX = (long) ( aWinSize.Width() * 100 / diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 188507b0e905..229865e689b8 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2404,7 +2404,8 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const rSplitPos = Point( bHSplit ? pViewTab->nHSplitPos : 0, bVSplit ? pViewTab->nVSplitPos : 0 ); rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MAP_TWIP ) ); if( pDocShell ) - rSplitPos.X() = (long)((double)rSplitPos.X() / pDocShell->GetOutputFactor()); + rSplitPos.X() = (long)((double)rSplitPos.X() / + static_cast< double >( pDocShell->GetOutputFactor()) ); } else if( bFrozen ) { @@ -2543,7 +2544,7 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) // effectively results in the nFactor = 1.0 regardless of the Option setting. if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg()) { - double nFactor = pDocShell->GetOutputFactor(); + double nFactor = static_cast< double >( pDocShell->GetOutputFactor() ); aPixel.X() = (long)( aPixel.X() * nFactor + 0.5 ); } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index ba1d4322dd60..03fac5cf2dd3 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2185,7 +2185,9 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal ) nMargin = sal::static_int_cast( nMargin + static_cast(pPattern->GetItem(ATTR_INDENT)).GetValue() ); - nWidth = (sal_uInt16)(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS) + nWidth = (sal_uInt16)( nEdit * + static_cast< double>( pDocSh->GetOutputFactor() ) / + HMM_PER_TWIPS ) + nMargin + STD_EXTRA_WIDTH; } } -- cgit v1.2.3