summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-15 16:06:06 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-09-29 06:30:41 +0100
commitab0ccff829847653f2d745acfc1aa56528dca0b9 (patch)
tree853c6a278b4ce84c9b19f8386984e5ad1167c26f
parent6a7051c30b57ba86f8847587f7f74cc93307288b (diff)
Make nPrtToScreenFactor and GetOutputFactor fractions.
These are then used for our output MapMode which required Fractions too. Change-Id: Icbfd9f808a6efe297096c94dc4043cef88c0ba0b
-rw-r--r--sc/source/ui/docshell/docsh.cxx7
-rw-r--r--sc/source/ui/docshell/docsh3.cxx10
-rw-r--r--sc/source/ui/docshell/sizedev.cxx2
-rw-r--r--sc/source/ui/inc/docsh.hxx4
-rw-r--r--sc/source/ui/view/drawvie4.cxx2
-rw-r--r--sc/source/ui/view/preview.cxx27
-rw-r--r--sc/source/ui/view/tabview2.cxx6
-rw-r--r--sc/source/ui/view/viewdata.cxx5
-rw-r--r--sc/source/ui/view/viewfunc.cxx4
9 files changed, 44 insertions, 23 deletions
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 0db4a22e40ec..b42155fc2543 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1458,7 +1458,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)
@@ -2633,7 +2634,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 ),
@@ -2678,7 +2679,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 74ed3063c01e..f59c068bb0e6 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 98f71096f23d..7ea78b65d63f 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -88,7 +88,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener
OUString aDdeTextFmt;
- double nPrtToScreenFactor;
+ Fraction nPrtToScreenFactor;
DocShell_Impl* pImpl;
ScDocFunc* pDocFunc;
@@ -372,7 +372,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 c2f73702bddf..2dc2e3b0d183 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 dbd970d60af7..911b0ec32a22 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 da88b3b7b3ce..d7c25b2c146a 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 )
{
@@ -2534,7 +2535,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 c3782e46561f..179cc1c57af6 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2308,7 +2308,9 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal )
nMargin = sal::static_int_cast<sal_uInt16>(
nMargin + ((const SfxUInt16Item&)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;
}
}