diff options
author | Juan Picca <jumapico@gmail.com> | 2014-09-19 14:19:30 -0300 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-10-09 11:33:33 +0000 |
commit | 47a2d7642d249d70b5da0c330a73f3a0032e4bba (patch) | |
tree | 202b04810382ea87cf8015a7b4de29e931408948 /sc | |
parent | ae77dc81c33ab0817264bcf5fc8bb71a55b78a73 (diff) |
fdo#81356: convert Fraction to boost::rational<long> - wip
* Added rational util functions used by Fraction class not
available in the boost::rational class.
* Replaced usage of Fraction by boost::rational<long>
* Removed code that relies on:
1. fraction.IsValid() -- rational only allow valid values, ie
denominator() != 0
2. rational.denominator() == 0 -- always false
3. rational.denominator() < 0 -- always false but implementation
detail: http://www.boost.org/doc/libs/release/libs/rational/rational.html#Internal%20representation
* Simplified code that relies on:
1. rational.denominator() != 0 -- always true
* BUGS EXIST because Fraction allows the creation of invalid values but
boost::rational throws the exception boost::bad_rational
Change-Id: I84970a4956afb3f91ac0c8f726547466319420f9
Reviewed-on: https://gerrit.libreoffice.org/11551
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'sc')
63 files changed, 283 insertions, 289 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 9398d2471581..6c33f74bed8d 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -69,7 +69,7 @@ class RefMovedHint; } -class Fraction; +namespace boost { template<typename T> class rational; } class OutputDevice; class SfxItemPoolCache; class SvtListener; @@ -456,12 +456,12 @@ public: long GetNeededSize( SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange ) const; sal_uInt16 GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const; void GetOptimalHeight( diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 063c9f6d9a9f..93f33bdc3cf3 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -37,7 +37,7 @@ #include "compressedarray.hxx" #include "calcmacros.hxx" #include "calcconfig.hxx" -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/gen.hxx> #include <svl/zforlist.hxx> @@ -1453,7 +1453,7 @@ public: void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY ); + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ); bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const; @@ -1521,7 +1521,7 @@ public: sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bFormula, const ScMarkData* pMarkData = NULL, const ScColWidthParam* pParam = NULL ); @@ -1534,7 +1534,7 @@ public: long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bWidth, bool bTotalSize = false ); SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow); diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx index 142650fa9fa1..d3f7b3be986d 100644 --- a/sc/inc/editutil.hxx +++ b/sc/inc/editutil.hxx @@ -27,7 +27,7 @@ #include <tools/date.hxx> #include <tools/time.hxx> #include <tools/gen.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> class OutputDevice; class ScDocument; @@ -44,8 +44,8 @@ class ScEditUtil OutputDevice* pDev; // MapMode has to be set double nPPTX; double nPPTY; - Fraction aZoomX; - Fraction aZoomY; + boost::rational<long> aZoomX; + boost::rational<long> aZoomY; static const char pCalcDelimiters[]; @@ -82,7 +82,7 @@ public: ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ, const Point& rScrPosPixel, OutputDevice* pDevice, double nScaleX, double nScaleY, - const Fraction& rX, const Fraction& rY ) : + const boost::rational<long>& rX, const boost::rational<long>& rY ) : pDoc(pDocument),nCol(nX),nRow(nY),nTab(nZ), aScrPos(rScrPosPixel),pDev(pDevice), nPPTX(nScaleX),nPPTY(nScaleY),aZoomX(rX),aZoomY(rY) {} diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index 90516ccf0c37..67b07f5eaf01 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -28,7 +28,7 @@ namespace vcl { class Font; } class OutputDevice; -class Fraction; +namespace boost { template<class T> class rational; } class ScStyleSheet; class SvNumberFormatter; class ScDocument; @@ -83,14 +83,14 @@ public: static void GetFont( vcl::Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, OutputDevice* pOutDev = NULL, - const Fraction* pScale = NULL, + const boost::rational<long>* pScale = NULL, const SfxItemSet* pCondSet = NULL, sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, const Color* pTextConfigColor = NULL ); /** Fills a font object from the own item set. */ void GetFont( vcl::Font& rFont, ScAutoFontColorMode eAutoMode, OutputDevice* pOutDev = NULL, - const Fraction* pScale = NULL, + const boost::rational<long>* pScale = NULL, const SfxItemSet* pCondSet = NULL, sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, const Color* pTextConfigColor = NULL ) const; diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index 5e4dada012d9..a78426ac22d9 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -876,7 +876,7 @@ #include <tools/datetime.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/gen.hxx> #include <tools/globname.hxx> #include <tools/mempool.hxx> diff --git a/sc/inc/rowheightcontext.hxx b/sc/inc/rowheightcontext.hxx index a33455444438..0db012c4a263 100644 --- a/sc/inc/rowheightcontext.hxx +++ b/sc/inc/rowheightcontext.hxx @@ -12,7 +12,7 @@ #include "scdllapi.h" -#include <tools/fract.hxx> +#include <tools/rational.hxx> class OutputDevice; @@ -22,8 +22,8 @@ class SC_DLLPUBLIC RowHeightContext { double mfPPTX; double mfPPTY; - Fraction maZoomX; - Fraction maZoomY; + boost::rational<long> maZoomX; + boost::rational<long> maZoomY; OutputDevice* mpOutDev; sal_uInt16 mnExtraHeight; @@ -31,15 +31,15 @@ class SC_DLLPUBLIC RowHeightContext public: RowHeightContext( - double fPPTX, double fPPTY, const Fraction& rZoomX, const Fraction& rZoomY, + double fPPTX, double fPPTY, const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, OutputDevice* pOutDev ); ~RowHeightContext(); double getPPTX() const { return mfPPTX;} double getPPTY() const { return mfPPTY;} - const Fraction& getZoomX() const { return maZoomX;} - const Fraction& getZoomY() const { return maZoomY;} + const boost::rational<long>& getZoomX() const { return maZoomX;} + const boost::rational<long>& getZoomY() const { return maZoomY;} OutputDevice* getOutputDevice() { return mpOutDev;} diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 30df498c71d0..c59dc473aeb6 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -637,7 +637,7 @@ public: void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY ); + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ); bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const; @@ -672,7 +672,7 @@ public: sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bFormula, const ScMarkData* pMarkData, const ScColWidthParam* pParam ); bool SetOptimalHeight( @@ -686,7 +686,7 @@ public: long GetNeededSize( SCCOL nCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bWidth, bool bTotalSize ); void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth ); void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth ); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 13cdee827c86..fd05c65a46e8 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -83,7 +83,7 @@ inline bool IsAmbiguousScript( sal_uInt8 nScript ) long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** ppPatternChange ) const { @@ -240,7 +240,7 @@ long ScColumn::GetNeededSize( // bGetFont is set also if script type changes if (rOptions.bGetFont) { - Fraction aFontZoom = ( eOrient == SVX_ORIENTATION_STANDARD ) ? rZoomX : rZoomY; + boost::rational<long> aFontZoom = ( eOrient == SVX_ORIENTATION_STANDARD ) ? rZoomX : rZoomY; vcl::Font aFont; // font color doesn't matter here pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &aFontZoom, pCondSet, nScript ); @@ -413,7 +413,7 @@ long ScColumn::GetNeededSize( // space for AutoFilter button: 20 * nZoom/100 if ( pFlag->HasAutoFilter() && !bTextWysiwyg ) - nDocWidth -= (rZoomX.GetNumerator()*20)/rZoomX.GetDenominator(); + nDocWidth -= (rZoomX.numerator()*20)/rZoomX.denominator(); aPaper.Width() = nDocWidth; @@ -501,7 +501,7 @@ long ScColumn::GetNeededSize( aHMMMode).Height(); // With non-100% zoom and several lines or paragraphs, don't shrink below the result with FORMAT100 set - if ( !bTextWysiwyg && ( rZoomY.GetNumerator() != 1 || rZoomY.GetDenominator() != 1 ) && + if ( !bTextWysiwyg && ( rZoomY.numerator() != 1 || rZoomY.denominator() != 1 ) && ( pEngine->GetParagraphCount() > 1 || ( bBreak && pEngine->GetLineCount(0) > 1 ) ) ) { pEngine->SetControlWord( nCtrl | EE_CNTRL_FORMAT100 ); @@ -551,7 +551,7 @@ long ScColumn::GetNeededSize( sal_Int16 nFlags = ((const ScMergeFlagAttr&)pPattern->GetItem(ATTR_MERGE_FLAG)).GetValue(); if (nFlags & SC_MF_AUTO) - nValue += (rZoomX.GetNumerator()*20)/rZoomX.GetDenominator(); + nValue += (rZoomX.numerator()*20)/rZoomX.denominator(); } return nValue; } @@ -616,7 +616,7 @@ public: } sal_uInt16 ScColumn::GetOptimalColWidth( - OutputDevice* pDev, double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY, + OutputDevice* pDev, double nPPTX, double nPPTY, const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const { if (maCells.block_size() == 1 && maCells.begin()->type == sc::element_type_empty) diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 2c5a59710f4a..3613477e948a 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -40,7 +40,7 @@ #include "scmatrix.hxx" #include <rowheightcontext.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <editeng/editobj.hxx> #include <svl/sharedstring.hxx> @@ -2544,7 +2544,7 @@ void ScDocRowHeightUpdater::update() ScProgress aProgress(mrDoc.GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nCellCount); - Fraction aZoom(1, 1); + boost::rational<long> aZoom(1, 1); itr = mpTabRangesArray->begin(); sal_uInt32 nProgressStart = 0; sc::RowHeightContext aCxt(mfPPTX, mfPPTY, aZoom, aZoom, mpOutDev); @@ -2582,7 +2582,7 @@ void ScDocRowHeightUpdater::updateAll() ScProgress aProgress(mrDoc.GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nCellCount); - Fraction aZoom(1, 1); + boost::rational<long> aZoom(1, 1); sc::RowHeightContext aCxt(mfPPTX, mfPPTY, aZoom, aZoom, mpOutDev); sal_uLong nProgressStart = 0; for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab) diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index ddb8acdbd5dc..a7ba4025851b 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -569,7 +569,7 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers } sal_uInt16 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); - Fraction aZoomFract(nZoom, 100); + boost::rational<long> aZoomFract(nZoom, 100); // Start at specified cell position (nCol, nRow, nTab). ScColumn* pCol = &pTab->aCol[aScope.Col()]; @@ -655,7 +655,7 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers if (getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0) { nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); - aZoomFract = Fraction(nZoom, 100); + aZoomFract = boost::rational<long>(nZoom, 100); } else nZoom = 0; diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index a582db4bbcab..fb0c664ded76 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3883,7 +3883,7 @@ sal_uLong ScDocument::GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero ) sal_uInt16 ScDocument::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bFormula, const ScMarkData* pMarkData, const ScColWidthParam* pParam ) { @@ -3897,7 +3897,7 @@ sal_uInt16 ScDocument::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* long ScDocument::GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bWidth, bool bTotalSize ) { if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) @@ -4594,7 +4594,7 @@ const ScStyleSheet* ScDocument::GetSelectionStyle( const ScMarkData& rMark ) con void ScDocument::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY ) + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ) { TableContainer::iterator it = maTabs.begin(); for (; it != maTabs.end(); ++it) diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index ca702d97de48..c6d58eff68c2 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -824,7 +824,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati double fXFrac = static_cast<double>(aNew.GetWidth()) / static_cast<double>(aOld.GetWidth()); double fYFrac = static_cast<double>(aNew.GetHeight()) / static_cast<double>(aOld.GetHeight()); - pObj->NbcResize(aNew.TopLeft(), Fraction(fXFrac), Fraction(fYFrac)); + pObj->NbcResize(aNew.TopLeft(), rational_FromDouble(fXFrac), rational_FromDouble(fYFrac)); } // order of these lines is important, modify rData.maLastRect carefully it is used as both // a value and a flag for initialisation @@ -1421,19 +1421,19 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const long nWidthDiff = nDestWidth - nSourceWidth; long nHeightDiff = nDestHeight - nSourceHeight; - Fraction aHorFract(1,1); - Fraction aVerFract(1,1); + boost::rational<long> aHorFract(1,1); + boost::rational<long> aVerFract(1,1); bool bResize = false; // sizes can differ by 1 from twips->1/100mm conversion for equal cell sizes, // don't resize to empty size when pasting into hidden columns or rows if ( std::abs(nWidthDiff) > 1 && nDestWidth > 1 && nSourceWidth > 1 ) { - aHorFract = Fraction( nDestWidth, nSourceWidth ); + aHorFract = boost::rational<long>( nDestWidth, nSourceWidth ); bResize = true; } if ( std::abs(nHeightDiff) > 1 && nDestHeight > 1 && nSourceHeight > 1 ) { - aVerFract = Fraction( nDestHeight, nSourceHeight ); + aVerFract = boost::rational<long>( nDestHeight, nSourceHeight ); bResize = true; } Point aRefPos = rDestRange.TopLeft(); // for resizing (after moving) diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index acbaeda1aaed..f0c6d478010a 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -216,7 +216,7 @@ SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet* pCondSet void ScPatternAttr::GetFont( vcl::Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, - OutputDevice* pOutDev, const Fraction* pScale, + OutputDevice* pOutDev, const boost::rational<long>* pScale, const SfxItemSet* pCondSet, sal_uInt8 nScript, const Color* pBackConfigColor, const Color* pTextConfigColor ) { @@ -376,7 +376,7 @@ void ScPatternAttr::GetFont( if ( pOutDev != NULL ) { Size aEffSize; - Fraction aFraction( 1,1 ); + boost::rational<long> aFraction( 1,1 ); if (pScale) aFraction = *pScale; Size aSize( 0, (long) nFontHeight ); @@ -386,7 +386,7 @@ void ScPatternAttr::GetFont( aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode ); else { - Fraction aFractOne(1,1); + boost::rational<long> aFractOne(1,1); aDestMode.SetScaleX( aFractOne ); aDestMode.SetScaleY( aFractOne ); aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode ); @@ -482,7 +482,7 @@ void ScPatternAttr::GetFont( void ScPatternAttr::GetFont( vcl::Font& rFont, ScAutoFontColorMode eAutoMode, - OutputDevice* pOutDev, const Fraction* pScale, + OutputDevice* pOutDev, const boost::rational<long>* pScale, const SfxItemSet* pCondSet, sal_uInt8 nScript, const Color* pBackConfigColor, const Color* pTextConfigColor ) const { diff --git a/sc/source/core/data/rowheightcontext.cxx b/sc/source/core/data/rowheightcontext.cxx index 5f51dfab0878..46cce64908fc 100644 --- a/sc/source/core/data/rowheightcontext.cxx +++ b/sc/source/core/data/rowheightcontext.cxx @@ -12,7 +12,7 @@ namespace sc { RowHeightContext::RowHeightContext( - double fPPTX, double fPPTY, const Fraction& rZoomX, const Fraction& rZoomY, + double fPPTX, double fPPTY, const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, OutputDevice* pOutDev ) : mfPPTX(fPPTX), mfPPTY(fPPTY), maZoomX(rZoomX), maZoomY(rZoomY), diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 88631d59acc2..9917e110698d 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -427,7 +427,7 @@ void ScTable::SetLink( sal_uInt8 nMode, sal_uInt16 ScTable::GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bFormula, const ScMarkData* pMarkData, const ScColWidthParam* pParam ) { @@ -438,7 +438,7 @@ sal_uInt16 ScTable::GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev, long ScTable::GetNeededSize( SCCOL nCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, bool bWidth, bool bTotalSize ) { ScNeededSizeOptions aOptions; @@ -1800,7 +1800,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d aOptions.bFormula = bFormula; aOptions.bSkipMerged = false; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); nPixel = aCol[rCol].GetNeededSize( nRow, pDev, nPPTX, nPPTY, aZoom, aZoom, true, aOptions, NULL ); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index f603c8b6c961..5e67a6ac8d1e 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2535,7 +2535,7 @@ bool ScTable::IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyle void ScTable::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved, OutputDevice* pDev, double nPPTX, double nPPTY, - const Fraction& rZoomX, const Fraction& rZoomY ) + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ) { ScFlatBoolRowSegments aUsedRows; for (SCCOL i = 0; i <= MAXCOL; ++i) diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 1989a2e9534b..1ba6ca2ad959 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -429,10 +429,10 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu } DELETEZ( pProgress ); // SetOptimalHeight has its own ProgressBar // Adjust line height, base is 100% zoom - Fraction aZoom( 1, 1 ); + boost::rational<long> aZoom( 1, 1 ); // Factor is printer to display ratio - double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / nOutputFactor; - double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom; + double nPPTX = ScGlobal::nScreenPPTX * boost::rational_cast<double>(aZoom) / nOutputFactor; + double nPPTY = ScGlobal::nScreenPPTY * boost::rational_cast<double>(aZoom); VirtualDevice aVirtDev; sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoom, aZoom, &aVirtDev); aCxt.setExtraHeight(ScGlobal::nLastRowHeightExtra); diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx index 7472b7435d5f..080b0f3ce212 100644 --- a/sc/source/ui/app/client.cxx +++ b/sc/source/ui/app/client.cxx @@ -213,11 +213,11 @@ void ScClient::ViewChanged() if (pDrawObj) { Rectangle aLogicRect = pDrawObj->GetLogicRect(); - Fraction aFractX = GetScaleWidth(); - Fraction aFractY = GetScaleHeight(); + boost::rational<long> aFractX = GetScaleWidth(); + boost::rational<long> aFractY = GetScaleHeight(); aFractX *= aVisSize.Width(); aFractY *= aVisSize.Height(); - aVisSize = Size( (long) aFractX, (long) aFractY ); // Scaled for Draw model + aVisSize = Size( boost::rational_cast<long>(aFractX), boost::rational_cast<long>(aFractY) ); // Scaled for Draw model // pClientData->SetObjArea before pDrawObj->SetLogicRect, so that we don't // calculate wrong scalings: diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 87cdfebb4d34..0dcc849ee080 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -569,7 +569,7 @@ ScInputHandler::~ScInputHandler() delete pFormulaDataPara; } -void ScInputHandler::SetRefScale( const Fraction& rX, const Fraction& rY ) +void ScInputHandler::SetRefScale( const boost::rational<long>& rX, const boost::rational<long>& rY ) { if ( rX != aScaleX || rY != aScaleY ) { diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 74caa07088af..ba9ae8c2b63c 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -27,7 +27,7 @@ #include "docpool.hxx" #include "patattr.hxx" -ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY, ScDocument* pDoc) : +ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const boost::rational<long>* pZoomX, const boost::rational<long>* pZoomY, ScDocument* pDoc) : mpDoc(pDoc), mpOutDev(pOutDev), mpStyle(pStyle), @@ -40,12 +40,12 @@ ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pSt if (pZoomX) maZoomX = *pZoomX; else - maZoomX = Fraction(1, 1); + maZoomX = boost::rational<long>(1, 1); if (pZoomY) maZoomY = *pZoomY; else - maZoomY = Fraction(1, 1); + maZoomY = boost::rational<long>(1, 1); } ScDPFieldButton::~ScDPFieldButton() diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index c529527cd46b..03a3a9dabd21 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -153,7 +153,7 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint ) SCROW nEndRow = rRange.aEnd.Row(); ScSizeDeviceProvider aProv( &rDocShell ); - Fraction aOne(1,1); + boost::rational<long> aOne(1,1); sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, aProv.GetDevice()); bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab); @@ -3290,7 +3290,7 @@ static sal_uInt16 lcl_GetOptimalColWidth( ScDocShell& rDocShell, SCCOL nCol, SCT double nPPTY = aProv.GetPPTY(); ScDocument& rDoc = rDocShell.GetDocument(); - Fraction aOne(1,1); + boost::rational<long> aOne(1,1); sal_uInt16 nTwips = rDoc.GetOptimalColWidth( nCol, nTab, pDev, nPPTX, nPPTY, aOne, aOne, bFormula, NULL ); @@ -3383,7 +3383,7 @@ bool ScDocFunc::SetWidthOrHeight( } ScSizeDeviceProvider aProv( &rDocShell ); - Fraction aOne(1,1); + boost::rational<long> aOne(1,1); sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, aProv.GetDevice()); aCxt.setForceAutoSize(bAll); rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 0db4a22e40ec..6b25a783e6fe 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1457,9 +1457,9 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) CalcOutputFactor(); 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 nPPTY = ScGlobal::nScreenPPTY * (double) aZoom; + boost::rational<long> aZoom( 1, 1 ); + double nPPTX = ScGlobal::nScreenPPTX * boost::rational_cast<double>(aZoom) / GetOutputFactor(); // Factor is printer display ratio + double nPPTY = ScGlobal::nScreenPPTY * boost::rational_cast<double>(aZoom); VirtualDevice aVirtDev; // all sheets (for Excel import) SCTAB nTabCount = aDocument.GetTableCount(); diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index c1ac7036c9b4..88fc80417e9f 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -368,7 +368,7 @@ void ScDocShell::CancelAutoDBRange() bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) { ScSizeDeviceProvider aProv(this); - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice()); bool bChange = aDocument.SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab); @@ -383,7 +383,7 @@ void ScDocShell::UpdateAllRowHeights( const ScMarkData* pTabMark ) // update automatic row heights ScSizeDeviceProvider aProv(this); - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); sc::RowHeightContext aCxt(aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice()); aDocument.UpdateAllRowHeights(aCxt, pTabMark); } diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx index 3c92010345c7..f8e5dfc35da5 100644 --- a/sc/source/ui/drawfunc/fuins1.cxx +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -131,7 +131,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic, MapMode aDestMap( MAP_100TH_MM ); if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView ) { - Fraction aScaleX, aScaleY; + boost::rational<long> aScaleX, aScaleY; pDrawView->CalcNormScale( aScaleX, aScaleY ); aDestMap.SetScaleX(aScaleX); aDestMap.SetScaleY(aScaleY); diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx index e574f672429b..461c1100fca8 100644 --- a/sc/source/ui/inc/dpcontrol.hxx +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -22,7 +22,7 @@ #include <rtl/ustring.hxx> #include <tools/gen.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> class OutputDevice; class Point; @@ -37,7 +37,7 @@ class ScDocument; class ScDPFieldButton { public: - ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL, + ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const boost::rational<long>* pZoomX = NULL, const boost::rational<long>* pZoomY = NULL, ScDocument* pDoc = NULL); ~ScDPFieldButton(); @@ -58,9 +58,9 @@ private: private: Point maPos; Size maSize; - OUString maText; - Fraction maZoomX; - Fraction maZoomY; + OUString maText; + boost::rational<long> maZoomX; + boost::rational<long> maZoomY; ScDocument* mpDoc; OutputDevice* mpOutDev; const StyleSettings* mpStyle; diff --git a/sc/source/ui/inc/drawutil.hxx b/sc/source/ui/inc/drawutil.hxx index 6a011ae290e2..740ee0380ada 100644 --- a/sc/source/ui/inc/drawutil.hxx +++ b/sc/source/ui/inc/drawutil.hxx @@ -22,7 +22,7 @@ #include "address.hxx" -class Fraction; +namespace boost { template<typename T> class rational; } class OutputDevice; class ScDocument; @@ -31,9 +31,9 @@ class ScDrawUtil public: static void CalcScale( ScDocument* pDoc, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, - OutputDevice* pDev, const Fraction& rZoomX, const Fraction& rZoomY, + OutputDevice* pDev, const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, double nPPTX, double nPPTY, - Fraction& rScaleX, Fraction& rScaleY ); + boost::rational<long>& rScaleX, boost::rational<long>& rScaleY ); }; #endif diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx index d19cb263a746..923af0f9a0fd 100644 --- a/sc/source/ui/inc/drawview.hxx +++ b/sc/source/ui/inc/drawview.hxx @@ -37,8 +37,8 @@ class ScDrawView: public FmFormView OutputDevice* pDev; //! needed ? ScDocument* pDoc; SCTAB nTab; - Fraction aScaleX; // Factor for Drawing-MapMode - Fraction aScaleY; + boost::rational<long> aScaleX; // Factor for Drawing-MapMode + boost::rational<long> aScaleY; SdrDropMarkerOverlay* pDropMarker; SdrObject* pDropMarkObj; bool bInConstruct; @@ -94,12 +94,12 @@ public: void DoCut(); void DoCopy(); - void GetScale( Fraction& rFractX, Fraction& rFractY ) const; + void GetScale( boost::rational<long>& rFractX, boost::rational<long>& rFractY ) const; void RecalcScale(); void UpdateWorkArea(); SCTAB GetTab() const { return nTab; } - void CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const; + void CalcNormScale( boost::rational<long>& rFractX, boost::rational<long>& rFractY ) const; void SetPageAnchored(); void SetCellAnchored(); diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx index 65ea47c3c927..dd8752a5c52d 100644 --- a/sc/source/ui/inc/inputhdl.hxx +++ b/sc/source/ui/inc/inputhdl.hxx @@ -24,7 +24,7 @@ #include "address.hxx" #include "typedstrdata.hxx" -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/gen.hxx> #include <tools/link.hxx> #include <vcl/vclevent.hxx> @@ -99,11 +99,11 @@ private: bool bCellHasPercentFormat:1; bool bLastIsSymbol:1; bool mbDocumentDisposing:1; - sal_uLong nValidation; + sal_uLong nValidation; SvxCellHorJustify eAttrAdjust; - Fraction aScaleX; // for ref MapMode - Fraction aScaleY; + boost::rational<long> aScaleX; // for ref MapMode + boost::rational<long> aScaleY; ScTabViewShell* pRefViewSh; ScTabViewShell* pActiveViewSh; @@ -209,7 +209,7 @@ public: void ShowTip( const OUString& rText ); // at Cursor void ShowTipBelow( const OUString& rText ); - void SetRefScale( const Fraction& rX, const Fraction& rY ); + void SetRefScale( const boost::rational<long>& rX, const boost::rational<long>& rY ); void UpdateRefDevice(); EditView* GetActiveView(); diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx index 8a9649848ba4..dd42cd8fe737 100644 --- a/sc/source/ui/inc/output.hxx +++ b/sc/source/ui/inc/output.hxx @@ -23,7 +23,7 @@ #include "address.hxx" #include "cellvalue.hxx" #include <tools/color.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <drawinglayer/processor2d/baseprocessor2d.hxx> @@ -164,8 +164,8 @@ private: ScOutputType eType; // Screen/Printer ... double mnPPTX; // Pixel per Twips double mnPPTY; - Fraction aZoomX; - Fraction aZoomY; + boost::rational<long> aZoomX; + boost::rational<long> aZoomY; SdrObject* pEditObj; // Omit when painting @@ -262,8 +262,8 @@ public: SCTAB nNewTab, long nNewScrX, long nNewScrY, SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2, double nPixelPerTwipsX, double nPixelPerTwipsY, - const Fraction* pZoomX = NULL, - const Fraction* pZoomY = NULL ); + const boost::rational<long>* pZoomX = NULL, + const boost::rational<long>* pZoomY = NULL ); ~ScOutputData(); diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 0bc4751487c4..1cbb87afec6a 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -298,7 +298,7 @@ public: * @param bSameTabButMoved true if the same sheet as before is activated. */ void TabChanged( bool bSameTabButMoved = false ); - void SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll ); + void SetZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY, bool bAll ); SC_DLLPUBLIC void RefreshZoom(); void SetPagebreakMode( bool bSet ); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 9020c2184c84..053a1e9053e6 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -208,7 +208,7 @@ protected: virtual void InnerResizePixel( const Point &rOfs, const Size &rSize ) SAL_OVERRIDE; // neu virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ) SAL_OVERRIDE; - virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) SAL_OVERRIDE; + virtual void SetZoomFactor( const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ) SAL_OVERRIDE; virtual void QueryObjAreaPixel( Rectangle& rRect ) const SAL_OVERRIDE; diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 515bc67a4f75..1505f4dd0ab8 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -109,10 +109,10 @@ class ScViewDataTable // per-sheet data friend class ScViewData; private: SvxZoomType eZoomType; // selected zoom type (normal view) - Fraction aZoomX; // selected zoom X - Fraction aZoomY; // selected zoom Y (displayed) - Fraction aPageZoomX; // zoom in page break preview mode - Fraction aPageZoomY; + boost::rational<long> aZoomX; // selected zoom X + boost::rational<long> aZoomY; // selected zoom Y (displayed) + boost::rational<long> aPageZoomX; // zoom in page break preview mode + boost::rational<long> aPageZoomY; long nTPosX[2]; // MapMode - Offset (Twips) long nTPosY[2]; @@ -174,10 +174,10 @@ private: MapMode aLogicMode; // skalierter 1/100mm-MapMode SvxZoomType eDefZoomType; // default zoom and type for missing TabData - Fraction aDefZoomX; - Fraction aDefZoomY; - Fraction aDefPageZoomX; // zoom in page break preview mode - Fraction aDefPageZoomY; + boost::rational<long> aDefZoomX; + boost::rational<long> aDefZoomY; + boost::rational<long> aDefPageZoomX; // zoom in page break preview mode + boost::rational<long> aDefPageZoomY; ScRefType eRefType; @@ -305,15 +305,15 @@ public: void SetZoomType( SvxZoomType eNew, bool bAll ); void SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs ); - void SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs ); - void SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll ); + void SetZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY, std::vector< SCTAB >& tabs ); + void SetZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY, bool bAll ); void RefreshZoom(); void SetSelCtrlMouseClick( bool bTmp ) { bSelCtrlMouseClick = bTmp; } SvxZoomType GetZoomType() const { return pThisTab->eZoomType; } - const Fraction& GetZoomX() const { return bPagebreak ? pThisTab->aPageZoomX : pThisTab->aZoomX; } - const Fraction& GetZoomY() const { return bPagebreak ? pThisTab->aPageZoomY : pThisTab->aZoomY; } + const boost::rational<long>& GetZoomX() const { return bPagebreak ? pThisTab->aPageZoomX : pThisTab->aZoomX; } + const boost::rational<long>& GetZoomY() const { return bPagebreak ? pThisTab->aPageZoomY : pThisTab->aZoomY; } void SetShowGrid( bool bShow ); bool GetShowGrid() const { return pThisTab->bShowGrid; } @@ -446,7 +446,7 @@ public: void SetScreen( const Rectangle& rVisArea ); void SetScreenPos( const Point& rVisAreaStart ); - void UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY ); + void UpdateScreenZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY ); Size GetScrSize() const { return aScrSize; } diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index 2e244ec1a9be..23bb99345fda 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -258,8 +258,8 @@ bool ScBlockUndo::AdjustHeight() ScDocument& rDoc = pDocShell->GetDocument(); VirtualDevice aVirtDev; - Fraction aZoomX( 1, 1 ); - Fraction aZoomY = aZoomX; + boost::rational<long> aZoomX( 1, 1 ); + boost::rational<long> aZoomY = aZoomX; double nPPTX, nPPTY; ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) @@ -356,8 +356,8 @@ void ScMultiBlockUndo::AdjustHeight() ScDocument& rDoc = pDocShell->GetDocument(); VirtualDevice aVirtDev; - Fraction aZoomX( 1, 1 ); - Fraction aZoomY = aZoomX; + boost::rational<long> aZoomX( 1, 1 ); + boost::rational<long> aZoomY = aZoomX; double nPPTX, nPPTY; ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 6b8c8cfd38c7..49e2280f7362 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -847,8 +847,8 @@ void ScUndoAutoFormat::Redo() if (bSize) { VirtualDevice aVirtDev; - Fraction aZoomX(1,1); - Fraction aZoomY = aZoomX; + boost::rational<long> aZoomX(1,1); + boost::rational<long> aZoomY = aZoomX; double nPPTX,nPPTY; ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx index d84d55abd4c2..01bfc89a1705 100644 --- a/sc/source/ui/undo/undostyl.cxx +++ b/sc/source/ui/undo/undostyl.cxx @@ -110,7 +110,7 @@ static void lcl_DocStyleChanged( ScDocument* pDoc, SfxStyleSheetBase* pStyle, bo Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP ); double nPPTX = aLogic.X() / 1000.0; double nPPTY = aLogic.Y() / 1000.0; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); pDoc->StyleSheetChanged( pStyle, bRemoved, &aVDev, nPPTX, nPPTY, aZoom, aZoom ); ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index f553e5153923..314dddb7ef79 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1283,17 +1283,13 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec // Scale and move the target rectangle from aLocationMM to aLocationPixel, // to get the target rectangle in pixels. - Fraction aScaleX( aLocationPixel.GetWidth(), aLocationMM.GetWidth() ); - Fraction aScaleY( aLocationPixel.GetHeight(), aLocationMM.GetHeight() ); - - long nX1 = aLocationPixel.Left() + (long) - ( Fraction( aTargetRect.Left() - aLocationMM.Left(), 1 ) * aScaleX ); - long nX2 = aLocationPixel.Left() + (long) - ( Fraction( aTargetRect.Right() - aLocationMM.Left(), 1 ) * aScaleX ); - long nY1 = aLocationPixel.Top() + (long) - ( Fraction( aTargetRect.Top() - aLocationMM.Top(), 1 ) * aScaleY ); - long nY2 = aLocationPixel.Top() + (long) - ( Fraction( aTargetRect.Bottom() - aLocationMM.Top(), 1 ) * aScaleY ); + boost::rational<long> aScaleX( aLocationPixel.GetWidth(), aLocationMM.GetWidth() ); + boost::rational<long> aScaleY( aLocationPixel.GetHeight(), aLocationMM.GetHeight() ); + + long nX1 = aLocationPixel.Left() + boost::rational_cast<long>( (aTargetRect.Left() - aLocationMM.Left()) * aScaleX ); + long nX2 = aLocationPixel.Left() + boost::rational_cast<long>( (aTargetRect.Right() - aLocationMM.Left()) * aScaleX ); + long nY1 = aLocationPixel.Top() + boost::rational_cast<long>( (aTargetRect.Top() - aLocationMM.Top()) * aScaleY ); + long nY2 = aLocationPixel.Top() + boost::rational_cast<long>( (aTargetRect.Bottom() - aLocationMM.Top()) * aScaleY ); if ( nX1 > aLocationPixel.Right() ) nX1 = aLocationPixel.Right(); if ( nX2 > aLocationPixel.Right() ) nX2 = aLocationPixel.Right(); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index d06f68bd1115..0817ec8ae23a 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -758,7 +758,7 @@ void SAL_CALL ScStyleFamilyObj::removeByName( const OUString& aName ) Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP ); double nPPTX = aLogic.X() / 1000.0; double nPPTY = aLogic.Y() / 1000.0; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom ); pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); pDocShell->SetDocumentModified(); @@ -1100,7 +1100,7 @@ void SAL_CALL ScStyleObj::setParentStyle( const OUString& rParentStyle ) Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP ); double nPPTX = aLogic.X() / 1000.0; double nPPTY = aLogic.Y() / 1000.0; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom ); pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); @@ -1464,7 +1464,7 @@ void SAL_CALL ScStyleObj::setAllPropertiesToDefault() Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP ); double nPPTX = aLogic.X() / 1000.0; double nPPTY = aLogic.Y() / 1000.0; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom ); pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); @@ -1843,7 +1843,7 @@ void ScStyleObj::SetOnePropertyValue( const OUString& rPropertyName, const SfxIt Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP ); double nPPTX = aLogic.X() / 1000.0; double nPPTY = aLogic.Y() / 1000.0; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); rDoc.StyleSheetChanged( pStyle, false, &aVDev, nPPTX, nPPTY, aZoom, aZoom ); pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT ); diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 4fa327f198f7..04c4f08c45ae 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -1446,8 +1446,8 @@ sal_Int16 ScTabViewObj::GetZoom(void) const ScTabViewShell* pViewSh = GetViewShell(); if (pViewSh) { - const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y wird angezeigt - return (sal_Int16)(( rZoomY.GetNumerator() * 100 ) / rZoomY.GetDenominator()); + const boost::rational<long>& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y wird angezeigt + return (sal_Int16)(( rZoomY.numerator() * 100 ) / rZoomY.denominator()); } return 0; } @@ -1468,7 +1468,7 @@ void ScTabViewObj::SetZoom(sal_Int16 nZoom) pScMod->SetAppOptions( aNewOpt ); } } - Fraction aFract( nZoom, 100 ); + boost::rational<long> aFract( nZoom, 100 ); pViewSh->SetZoom( aFract, aFract, true ); pViewSh->PaintGrid(); pViewSh->PaintTop(); diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 6a745588fc16..3771b6fcd3c9 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -97,7 +97,7 @@ getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ) { ScTabViewShell* pViewSh = excel::getBestViewShell( xModel ); - Fraction aFract( nZoom, 100 ); + boost::rational<long> aFract( nZoom, 100 ); pViewSh->GetViewData().SetZoom( aFract, aFract, nTabs ); pViewSh->RefreshZoom(); } diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx index 668337aac0da..21840f50ffaf 100644 --- a/sc/source/ui/view/drawutil.cxx +++ b/sc/source/ui/view/drawutil.cxx @@ -27,9 +27,9 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, OutputDevice* pDev, - const Fraction& rZoomX, const Fraction& rZoomY, + const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY, double nPPTX, double nPPTY, - Fraction& rScaleX, Fraction& rScaleY ) + boost::rational<long>& rScaleX, boost::rational<long>& rScaleY ) { long nPixelX = 0; long nTwipsX = 0; @@ -63,27 +63,27 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab, // because ReduceInaccurate is called later anyway. if ( aPixelLog.X() && nTwipsX ) - rScaleX = Fraction( ((double)aPixelLog.X()) * - ((double)rZoomX.GetNumerator()) / + rScaleX = rational_FromDouble( ((double)aPixelLog.X()) * + ((double)rZoomX.numerator()) / ((double)nTwipsX) / ((double)HMM_PER_TWIPS) / - ((double)rZoomX.GetDenominator()) ); + ((double)rZoomX.denominator()) ); else - rScaleX = Fraction( 1, 1 ); + rScaleX = boost::rational<long>( 1, 1 ); if ( aPixelLog.Y() && nTwipsY ) - rScaleY = Fraction( ((double)aPixelLog.Y()) * - ((double)rZoomY.GetNumerator()) / + rScaleY = rational_FromDouble( ((double)aPixelLog.Y()) * + ((double)rZoomY.numerator()) / ((double)nTwipsY) / ((double)HMM_PER_TWIPS) / - ((double)rZoomY.GetDenominator()) ); + ((double)rZoomY.denominator()) ); else - rScaleY = Fraction( 1, 1 ); + rScaleY = boost::rational<long>( 1, 1 ); // 25 bits of accuracy are needed to always hit the right part of // cells in the last rows (was 17 before 1M rows). - rScaleX.ReduceInaccurate( 25 ); - rScaleY.ReduceInaccurate( 25 ); + rational_ReduceInaccurate(rScaleX, 25); + rational_ReduceInaccurate(rScaleY, 25); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index 08a3565d28ca..6a8add5ccc4e 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -437,7 +437,7 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable() // Korrektur fuer 100% berechnen, unabhaengig von momentanen Einstellungen -void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const +void ScDrawView::CalcNormScale( boost::rational<long>& rFractX, boost::rational<long>& rFractY ) const { double nPPTX = ScGlobal::nScreenPPTX; double nPPTY = ScGlobal::nScreenPPTY; @@ -453,7 +453,7 @@ void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const if (nEndRow<20) nEndRow = 1000; - Fraction aZoom(1,1); + boost::rational<long> aZoom(1,1); ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom, nPPTX, nPPTY, rFractX,rFractY ); } @@ -513,7 +513,7 @@ void ScDrawView::SetMarkedOriginalSize() { // Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt - Fraction aNormScaleX, aNormScaleY; + boost::rational<long> aNormScaleX, aNormScaleY; CalcNormScale( aNormScaleX, aNormScaleY ); aDestMap.SetScaleX(aNormScaleX); aDestMap.SetScaleY(aNormScaleY); @@ -535,8 +535,8 @@ void ScDrawView::SetMarkedOriginalSize() Rectangle aDrawRect = pObj->GetLogicRect(); pUndoGroup->AddAction( new SdrUndoGeoObj( *pObj ) ); - pObj->Resize( aDrawRect.TopLeft(), Fraction( aOriginalSize.Width(), aDrawRect.GetWidth() ), - Fraction( aOriginalSize.Height(), aDrawRect.GetHeight() ) ); + pObj->Resize( aDrawRect.TopLeft(), boost::rational<long>( aOriginalSize.Width(), aDrawRect.GetWidth() ), + boost::rational<long>( aOriginalSize.Height(), aDrawRect.GetHeight() ) ); ++nDone; } } diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 718091033af3..00e31a2910d0 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -286,7 +286,7 @@ void ScDrawView::DoCut() EndUndo(); } -void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const +void ScDrawView::GetScale( boost::rational<long>& rFractX, boost::rational<long>& rFractY ) const { rFractX = aScaleX; rFractY = aScaleY; @@ -296,8 +296,8 @@ void ScDrawView::RecalcScale() { double nPPTX; double nPPTY; - Fraction aZoomX(1,1); - Fraction aZoomY(1,1); + boost::rational<long> aZoomX(1,1); + boost::rational<long> aZoomY(1,1); if (pViewData) { @@ -614,8 +614,8 @@ void ScDrawView::UpdateUserViewOptions() SetSnapEnabled( rGrid.GetUseGridSnap() ); SetGridSnap( rGrid.GetUseGridSnap() ); - Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 ); - Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 ); + boost::rational<long> aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 ); + boost::rational<long> aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 ); SetSnapGridWidth( aFractX, aFractY ); SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) ); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index e0d5b7a604e1..219adb2f3977 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4625,8 +4625,8 @@ void ScGridWindow::UpdateFormulas() ScTableInfo aTabInfo; rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, false ); - Fraction aZoomX = pViewData->GetZoomX(); - Fraction aZoomY = pViewData->GetZoomY(); + boost::rational<long> aZoomX = pViewData->GetZoomX(); + boost::rational<long> aZoomY = pViewData->GetZoomY(); ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab, nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY, &aZoomX, &aZoomY ); diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx index e9ac6ca2054a..9cbaa2a9139b 100644 --- a/sc/source/ui/view/gridwin3.cxx +++ b/sc/source/ui/view/gridwin3.cxx @@ -247,8 +247,8 @@ MapMode ScGridWindow::GetDrawMapMode( bool bForce ) ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); if ( pDrView || bForce ) { - Fraction aScaleX; - Fraction aScaleY; + boost::rational<long> aScaleX; + boost::rational<long> aScaleY; if (pDrView) pDrView->GetScale( aScaleX, aScaleY ); else diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 0991b7e5bed5..56f35ecb4496 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -77,7 +77,7 @@ static void lcl_LimitRect( Rectangle& rRect, const Rectangle& rVisible ) static void lcl_DrawOneFrame( OutputDevice* pDev, const Rectangle& rInnerPixel, const OUString& rTitle, const Color& rColor, bool bTextBelow, - double nPPTX, double nPPTY, const Fraction& rZoomY, + double nPPTX, double nPPTY, const boost::rational<long>& rZoomY, ScDocument* pDoc, ScViewData* pButtonViewData, bool bLayoutRTL ) { // pButtonViewData wird nur benutzt, um die Button-Groesse zu setzen, @@ -132,8 +132,8 @@ static void lcl_DrawOneFrame( OutputDevice* pDev, const Rectangle& rInnerPixel, ScDDComboBoxButton aComboButton((vcl::Window*)pDev); aComboButton.SetOptSizePixel(); - long nBWidth = ( aComboButton.GetSizePixel().Width() * rZoomY.GetNumerator() ) - / rZoomY.GetDenominator(); + long nBWidth = ( aComboButton.GetSizePixel().Width() * rZoomY.numerator() ) + / rZoomY.denominator(); long nBHeight = nVer + aTextSize.Height() + 1; Size aButSize( nBWidth, nBHeight ); long nButtonPos = bLayoutRTL ? aOuter.Left() : aOuter.Right()-nBWidth+1; @@ -470,8 +470,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod nPPTX, nPPTY, false, bFormulaMode, &pViewData->GetMarkData() ); - Fraction aZoomX = pViewData->GetZoomX(); - Fraction aZoomY = pViewData->GetZoomY(); + boost::rational<long> aZoomX = pViewData->GetZoomX(); + boost::rational<long> aZoomY = pViewData->GetZoomY(); ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab, nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY, &aZoomX, &aZoomY ); diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 1e94298dc046..617288e69ef2 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -145,7 +145,7 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType, SCTAB nNewTab, long nNewScrX, long nNewScrY, SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2, double nPixelPerTwipsX, double nPixelPerTwipsY, - const Fraction* pZoomX, const Fraction* pZoomY ) : + const boost::rational<long>* pZoomX, const boost::rational<long>* pZoomY ) : mpDev( pNewDev ), mpRefDevice( pNewDev ), // default is output device pFmtDevice( pNewDev ), // default is output device @@ -193,11 +193,11 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType, if (pZoomX) aZoomX = *pZoomX; else - aZoomX = Fraction(1,1); + aZoomX = boost::rational<long>(1,1); if (pZoomY) aZoomY = *pZoomY; else - aZoomY = Fraction(1,1); + aZoomY = boost::rational<long>(1,1); nVisX1 = nX1; nVisY1 = nY1; diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 9f7e48ff2276..a5a9af577aae 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -231,7 +231,7 @@ void ScDrawStringsVars::SetShrinkScale( long nScale, sal_uInt8 nScript ) // call GetFont with a modified fraction, use only the height - Fraction aFraction( nScale, 100 ); + boost::rational<long> aFraction( nScale, 100 ); if ( !bPixelToLogic ) aFraction *= pOutput->aZoomY; vcl::Font aTmpFont; @@ -810,12 +810,12 @@ double ScOutputData::GetStretch() if ( mpRefDevice == pFmtDevice ) { MapMode aOld = mpRefDevice->GetMapMode(); - return ((double)aOld.GetScaleY()) / ((double)aOld.GetScaleX()) * ((double)aZoomY) / ((double)aZoomX); + return boost::rational_cast<double>(aOld.GetScaleY()) / boost::rational_cast<double>(aOld.GetScaleX()) * boost::rational_cast<double>(this->aZoomY) / boost::rational_cast<double>(this->aZoomX); } else { // when formatting for printer, device map mode has already been taken care of - return ((double)aZoomY) / ((double)aZoomX); + return boost::rational_cast<double>(this->aZoomY) / boost::rational_cast<double>(this->aZoomX); } } @@ -2787,7 +2787,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) // #i85342# screen display and formatting for printer, // use same GetEditArea call as in ScViewData::SetEditEngine - Fraction aFract(1,1); + boost::rational<long> aFract(1,1); Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, nTab, Point(0,0), pFmtDevice, HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( rParam.mpPattern, false ); aLogicSize.Width() = aUtilRect.GetWidth(); @@ -3809,7 +3809,7 @@ void ScOutputData::DrawEditStacked(DrawEditParam& rParam) // #i85342# screen display and formatting for printer, // use same GetEditArea call as in ScViewData::SetEditEngine - Fraction aFract(1,1); + boost::rational<long> aFract(1,1); Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, nTab, Point(0,0), pFmtDevice, HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( rParam.mpPattern, false ); aLogicSize.Width() = aUtilRect.GetWidth(); @@ -4165,7 +4165,7 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam) // #i85342# screen display and formatting for printer, // use same GetEditArea call as in ScViewData::SetEditEngine - Fraction aFract(1,1); + boost::rational<long> aFract(1,1); Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, nTab, Point(0,0), pFmtDevice, HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( rParam.mpPattern, false ); aLogicSize.Width() = aUtilRect.GetWidth(); diff --git a/sc/source/ui/view/overlayobject.cxx b/sc/source/ui/view/overlayobject.cxx index 778e44f0dfe0..1e2fe00972fd 100644 --- a/sc/source/ui/view/overlayobject.cxx +++ b/sc/source/ui/view/overlayobject.cxx @@ -20,7 +20,6 @@ #include "overlayobject.hxx" #include <vcl/outdev.hxx> #include <vcl/lineinfo.hxx> -#include <tools/fract.hxx> #include <basegfx/range/b2drange.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index e7cad9911d72..e7b50e8993ee 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -344,8 +344,8 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) UpdateDrawView(); // Spreedsheet eventually changes } - Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + boost::rational<long> aPreviewZoom( nZoom, 100 ); + boost::rational<long> aHorPrevZoom( long( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); bool bDoPrint = ( pFillLocation == NULL ); @@ -732,8 +732,8 @@ 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 ); + boost::rational<long> aPreviewZoom( nZoom, 100 ); + boost::rational<long> aHorPrevZoom( long( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); SetMapMode( aMMMode ); @@ -961,8 +961,8 @@ void ScPreview::DataChanged( const DataChangedEvent& rDCEvt ) void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) { - Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + boost::rational<long> aPreviewZoom( nZoom, 100 ); + boost::rational<long> aHorPrevZoom( long( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode ); @@ -1044,8 +1044,8 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) { - Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + boost::rational<long> aPreviewZoom( nZoom, 100 ); + boost::rational<long> aHorPrevZoom( long( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode ); @@ -1294,8 +1294,8 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) void ScPreview::MouseMove( const MouseEvent& rMEvt ) { - Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + boost::rational<long> aPreviewZoom( nZoom, 100 ); + boost::rational<long> aHorPrevZoom( long( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode ); @@ -1540,8 +1540,8 @@ void ScPreview::SwitchView() void ScPreview::DragMove( long nDragMovePos, sal_uInt16 nFlags ) { - Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + boost::rational<long> aPreviewZoom( nZoom, 100 ); + boost::rational<long> aHorPrevZoom( long( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom ); SetMapMode( aMMMode ); long nPos = nDragMovePos; diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index bb379604e695..0e2bda3c4421 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1593,7 +1593,7 @@ void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, if ( !pPrinter ) { OutputDevice* pRefDev = pDoc->GetPrinter(); // use the printer also for Preview - Fraction aPrintFrac( nZoom, 100 ); // without nManualZoom + boost::rational<long> aPrintFrac( nZoom, 100 ); // without nManualZoom // MapMode, as it would arrive at the printer: pRefDev->SetMapMode( MapMode( MAP_100TH_MM, Point(), aPrintFrac, aPrintFrac ) ); @@ -2543,13 +2543,13 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc. long nEffZoom = nZoom * (long) nManualZoom; nScaleX = nScaleY = HMM_PER_TWIPS; // output in 1/100 mm - Fraction aZoomFract( nEffZoom,10000 ); - Fraction aHorFract = aZoomFract; + boost::rational<long> aZoomFract( nEffZoom,10000 ); + boost::rational<long> aHorFract = aZoomFract; if ( !pPrinter && !bIsRender ) // adjust scale for preview { double nFact = pDocShell->GetOutputFactor(); - aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 ); + aHorFract = boost::rational<long>( long( nEffZoom / nFact ), 10000 ); } aLogicMode = MapMode( MAP_100TH_MM, Point(), aHorFract, aZoomFract ); @@ -2557,7 +2557,7 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc. Point aLogicOfs( -aOffset.X(), -aOffset.Y() ); aOffsetMode = MapMode( MAP_100TH_MM, aLogicOfs, aHorFract, aZoomFract ); - Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) ); + Point aTwipsOfs( long( -aOffset.X() / nScaleX + 0.5 ), long( -aOffset.Y() / nScaleY + 0.5 ) ); aTwipMode = MapMode( MAP_TWIP, aTwipsOfs, aHorFract, aZoomFract ); } diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 9150af64bee9..6802dd0e7bf7 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -697,11 +697,11 @@ void ScTabView::UpdateVarZoom() if ( eZoomType != SVX_ZOOM_PERCENT && !bInZoomUpdate ) { bInZoomUpdate = true; - const Fraction& rOldX = GetViewData().GetZoomX(); - const Fraction& rOldY = GetViewData().GetZoomY(); - long nOldPercent = ( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator(); + const boost::rational<long>& rOldX = GetViewData().GetZoomX(); + const boost::rational<long>& rOldY = GetViewData().GetZoomY(); + long nOldPercent = ( rOldY.numerator() * 100 ) / rOldY.denominator(); sal_uInt16 nNewZoom = CalcZoom( eZoomType, (sal_uInt16)nOldPercent ); - Fraction aNew( nNewZoom, 100 ); + boost::rational<long> aNew( nNewZoom, 100 ); if ( aNew != rOldX || aNew != rOldY ) { @@ -924,8 +924,8 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) // for ole inplace editing, the scale is defined by the visarea and client size // and can't be changed directly - const Fraction& rOldY = aViewData.GetZoomY(); - long nOld = (long)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator()); + const boost::rational<long>& rOldY = aViewData.GetZoomY(); + long nOld = long(( rOldY.numerator() * 100 ) / rOldY.denominator()); long nNew = nOld; if ( pData->GetMode() == COMMAND_WHEEL_ZOOM_SCALE ) { @@ -943,7 +943,7 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom ); - Fraction aFract( nNew, 100 ); + boost::rational<long> aFract( nNew, 100 ); SetZoom( aFract, aFract, bSyncZoom ); PaintGrid(); PaintTop(); diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index c79d356065ae..e19348adeed2 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -1111,7 +1111,7 @@ static bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCCOL nFixPosX, SCROW nFixPosY ) { - double fZoomFactor = (double)Fraction(nZoom,100); + double fZoomFactor = boost::rational_cast<double>(boost::rational<long>(nZoom, 100)); fScaleX *= fZoomFactor; fScaleY *= fZoomFactor; diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 028a5ff6cce9..749f542747d4 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -2337,8 +2337,8 @@ void ScTabView::RecalcPPT() // call view SetZoom (including draw scale, split update etc) // and paint only if values changed - Fraction aZoomX = aViewData.GetZoomX(); - Fraction aZoomY = aViewData.GetZoomY(); + boost::rational<long> aZoomX = aViewData.GetZoomX(); + boost::rational<long> aZoomY = aViewData.GetZoomY(); SetZoom( aZoomX, aZoomY, false ); PaintGrid(); diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 4f263d61a450..e5acb09e0b92 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -370,7 +370,7 @@ void ScTabView::SetZoomType( SvxZoomType eNew, bool bAll ) aViewData.SetZoomType( eNew, bAll ); } -void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll ) +void ScTabView::SetZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY, bool bAll ) { aViewData.SetZoom( rNewX, rNewY, bAll ); if (pDrawView) diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index d32a366b4880..571532633499 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -627,9 +627,9 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); SvxZoomType eOldZoomType = GetZoomType(); SvxZoomType eNewZoomType = eOldZoomType; - const Fraction& rOldY = GetViewData().GetZoomY(); // Y wird angezeigt - sal_uInt16 nOldZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) - / rOldY.GetDenominator()); + const boost::rational<long>& rOldY = GetViewData().GetZoomY(); // Y wird angezeigt + sal_uInt16 nOldZoom = (sal_uInt16)(( rOldY.numerator() * 100 ) + / rOldY.denominator()); sal_uInt16 nZoom = nOldZoom; bool bCancel = false; @@ -720,7 +720,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) aNewOpt.SetZoomType( GetZoomType() ); pScMod->SetAppOptions( aNewOpt ); } - Fraction aFract( nZoom, 100 ); + boost::rational<long> aFract( nZoom, 100 ); SetZoom( aFract, aFract, bSyncZoom ); PaintGrid(); PaintTop(); @@ -749,7 +749,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) aNewOpt.SetZoomType( GetZoomType() ); pScMod->SetAppOptions( aNewOpt ); } - Fraction aFract( nCurrentZoom,100 ); + boost::rational<long> aFract( nCurrentZoom,100 ); SetZoom( aFract, aFract, bSyncZoom ); PaintGrid(); PaintTop(); diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index f04e93174755..b3c558d9ece0 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -333,8 +333,8 @@ void ScTabViewShell::UpdateOleZoom() { vcl::Window* pWin = GetActiveWin(); Size aWinHMM = pWin->PixelToLogic( pWin->GetOutputSizePixel(), MAP_100TH_MM ); - SetZoomFactor( Fraction( aWinHMM.Width(),aObjSize.Width() ), - Fraction( aWinHMM.Height(),aObjSize.Height() ) ); + SetZoomFactor( boost::rational<long>( aWinHMM.Width(),aObjSize.Width() ), + boost::rational<long>( aWinHMM.Height(),aObjSize.Height() ) ); } } } @@ -362,8 +362,8 @@ void ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize ) if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 ) { Size aLogicSize = GetWindow()->PixelToLogic( aSize, MAP_100TH_MM ); - SfxViewShell::SetZoomFactor( Fraction( aLogicSize.Width(),aObjSize.Width() ), - Fraction( aLogicSize.Height(),aObjSize.Height() ) ); + SfxViewShell::SetZoomFactor( boost::rational<long>( aLogicSize.Width(),aObjSize.Width() ), + boost::rational<long>( aLogicSize.Height(),aObjSize.Height() ) ); } Point aPos( rOfs ); @@ -401,19 +401,19 @@ void ScTabViewShell::OuterResizePixel( const Point &rOfs, const Size &rSize ) ForceMove(); } -void ScTabViewShell::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) +void ScTabViewShell::SetZoomFactor( const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ) { // fuer OLE... - Fraction aFrac20( 1,5 ); - Fraction aFrac400( 4,1 ); + boost::rational<long> aFrac20( 1,5 ); + boost::rational<long> aFrac400( 4,1 ); - Fraction aNewX( rZoomX ); + boost::rational<long> aNewX( rZoomX ); if ( aNewX < aFrac20 ) aNewX = aFrac20; if ( aNewX > aFrac400 ) aNewX = aFrac400; - Fraction aNewY( rZoomY ); + boost::rational<long> aNewY( rZoomY ); if ( aNewY < aFrac20 ) aNewY = aFrac20; if ( aNewY > aFrac400 ) @@ -1727,7 +1727,7 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, } else { - Fraction aFract( rAppOpt.GetZoom(), 100 ); + boost::rational<long> aFract( rAppOpt.GetZoom(), 100 ); SetZoom( aFract, aFract, true ); SetZoomType( rAppOpt.GetZoomType(), true ); } diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index adde73054bbb..5c2727a50667 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -287,9 +287,8 @@ void ScTabViewShell::GetState( SfxItemSet& rSet ) rSet.DisableItem( nWhich ); else { - const Fraction& rOldY = GetViewData().GetZoomY(); - sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) - / rOldY.GetDenominator()); + const boost::rational<long>& rOldY = GetViewData().GetZoomY(); + sal_uInt16 nZoom = (sal_uInt16)(( rOldY.numerator() * 100 ) / rOldY.denominator()); rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) ); } break; @@ -300,8 +299,8 @@ void ScTabViewShell::GetState( SfxItemSet& rSet ) rSet.DisableItem( nWhich ); else { - const Fraction& rOldY = GetViewData().GetZoomY(); - sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator()); + const boost::rational<long>& rOldY = GetViewData().GetZoomY(); + sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.numerator() * 100 ) / rOldY.denominator()); if( nCurrentZoom ) { diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index 5e635b01fca9..e010c86f07ac 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -85,10 +85,10 @@ void ScTabViewShell::ConnectObject( SdrOle2Obj* pObj ) Size aOleSize = pObj->GetOrigObjSize(); - Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); + boost::rational<long> aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); + boost::rational<long> aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); + rational_ReduceInaccurate(aScaleWidth, 10); // kompatibel zum SdrOle2Obj + rational_ReduceInaccurate(aScaleHeight, 10); pClient->SetSizeScale(aScaleWidth,aScaleHeight); // sichtbarer Ausschnitt wird nur inplace veraendert! @@ -145,17 +145,17 @@ bool ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, long nVerb ) awt::Size aSz( aOleSize.Width(), aOleSize.Height() ); xObj->setVisualAreaSize( pClient->GetAspect(), aSz ); } - Fraction aOne( 1, 1 ); + boost::rational<long> aOne( 1, 1 ); pClient->SetSizeScale( aOne, aOne ); } else { // calculate scale from client and VisArea size - Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); + boost::rational<long> aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); + boost::rational<long> aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); + rational_ReduceInaccurate(aScaleWidth, 10); // kompatibel zum SdrOle2Obj + rational_ReduceInaccurate(aScaleHeight, 10); pClient->SetSizeScale(aScaleWidth,aScaleHeight); } diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx index e427e1fae490..46503dae69a7 100644 --- a/sc/source/ui/view/tabvwshh.cxx +++ b/sc/source/ui/view/tabvwshh.cxx @@ -121,12 +121,12 @@ void ScTabViewShell::ExecuteObject( SfxRequest& rReq ) pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) ); else if ( nSlotId == SID_OBJECT_WIDTH ) pDrView->ResizeMarkedObj( aRect.TopLeft(), - Fraction( nNewVal, aRect.GetWidth() ), - Fraction( 1, 1 ) ); + boost::rational<long>( nNewVal, aRect.GetWidth() ), + boost::rational<long>( 1, 1 ) ); else // if ( nSlotId == SID_OBJECT_HEIGHT ) pDrView->ResizeMarkedObj( aRect.TopLeft(), - Fraction( 1, 1 ), - Fraction( nNewVal, aRect.GetHeight() ) ); + boost::rational<long>( 1, 1 ), + boost::rational<long>( nNewVal, aRect.GetHeight() ) ); bDone = true; } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index af08c7080b74..1dd2d255a0d7 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -144,8 +144,8 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue> pSettings[SC_POSITION_BOTTOM].Name = OUString(SC_POSITIONBOTTOM); pSettings[SC_POSITION_BOTTOM].Value <<= sal_Int32(nPosY[SC_SPLIT_BOTTOM]); - sal_Int32 nZoomValue ((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator()); - sal_Int32 nPageZoomValue ((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator()); + sal_Int32 nZoomValue ((aZoomY.numerator() * 100) / aZoomY.denominator()); + sal_Int32 nPageZoomValue ((aPageZoomY.numerator() * 100) / aPageZoomY.denominator()); pSettings[SC_TABLE_ZOOM_TYPE].Name = OUString(SC_ZOOMTYPE); pSettings[SC_TABLE_ZOOM_TYPE].Value <<= sal_Int16(eZoomType); pSettings[SC_TABLE_ZOOM_VALUE].Name = OUString(SC_ZOOMVALUE); @@ -248,14 +248,14 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV else if (sName.equalsAscii(SC_ZOOMVALUE) ) { aSettings[i].Value >>= nTemp32; - Fraction aZoom(nTemp32, 100); + boost::rational<long> aZoom(nTemp32, 100); aZoomX = aZoomY = aZoom; rHasZoom = true; } else if (sName.equalsAscii(SC_PAGEVIEWZOOMVALUE) ) { aSettings[i].Value >>= nTemp32; - Fraction aZoom(nTemp32, 100); + boost::rational<long> aZoom(nTemp32, 100); aPageZoomX = aPageZoomY = aZoom; rHasZoom = true; } @@ -616,21 +616,21 @@ void ScViewData::SetZoomType( SvxZoomType eNew, bool bAll ) SetZoomType( eNew, vTabs ); } -void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs ) +void ScViewData::SetZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY, std::vector< SCTAB >& tabs ) { bool bAll = ( tabs.empty() ); if ( !bAll ) // create associated table data CreateTabData( tabs ); - Fraction aFrac20( 1,5 ); - Fraction aFrac400( 4,1 ); + boost::rational<long> aFrac20( 1,5 ); + boost::rational<long> aFrac400( 4,1 ); - Fraction aValidX = rNewX; + boost::rational<long> aValidX = rNewX; if (aValidX<aFrac20) aValidX = aFrac20; if (aValidX>aFrac400) aValidX = aFrac400; - Fraction aValidY = rNewY; + boost::rational<long> aValidY = rNewY; if (aValidY<aFrac20) aValidY = aFrac20; if (aValidY>aFrac400) @@ -690,7 +690,7 @@ void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vec RefreshZoom(); } -void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll ) +void ScViewData::SetZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY, bool bAll ) { std::vector< SCTAB > vTabs; if ( !bAll ) // get selected tabs @@ -1033,7 +1033,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich, // if text is formatted for printer, use the exact same paper width // (and same line breaks) as for output. - Fraction aFract(1,1); + boost::rational<long> aFract(1,1); Rectangle aUtilRect = ScEditUtil( pDoc,nNewX,nNewY,nTabNo, Point(0,0), pWin, HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, false ); aPaperSize.Width() = aUtilRect.GetWidth(); @@ -2120,31 +2120,31 @@ bool ScViewData::IsMinimized() return pView->IsMinimized(); } -void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY ) +void ScViewData::UpdateScreenZoom( const boost::rational<long>& rNewX, const boost::rational<long>& rNewY ) { - Fraction aOldX = GetZoomX(); - Fraction aOldY = GetZoomY(); + boost::rational<long> aOldX = GetZoomX(); + boost::rational<long> aOldY = GetZoomY(); SetZoom( rNewX, rNewY, false ); - Fraction aWidth = GetZoomX(); - aWidth *= Fraction( aScrSize.Width(),1 ); + boost::rational<long> aWidth = GetZoomX(); + aWidth *= aScrSize.Width(); aWidth /= aOldX; - Fraction aHeight = GetZoomY(); - aHeight *= Fraction( aScrSize.Height(),1 ); + boost::rational<long> aHeight = GetZoomY(); + aHeight *= aScrSize.Height(); aHeight /= aOldY; - aScrSize.Width() = (long) aWidth; - aScrSize.Height() = (long) aHeight; + aScrSize.Width() = boost::rational_cast<long>(aWidth); + aScrSize.Height() = boost::rational_cast<long>(aHeight); } void ScViewData::CalcPPT() { - nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX(); + nPPTX = ScGlobal::nScreenPPTX * boost::rational_cast<double>(this->GetZoomX()); if (pDocShell) nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm - nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY(); + nPPTY = ScGlobal::nScreenPPTY * boost::rational_cast<double>(this->GetZoomY()); // if detective objects are present, // try to adjust horizontal scale so the most common column width has minimal rounding errors, @@ -2192,9 +2192,9 @@ void ScViewData::WriteUserData(OUString& rData) // PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten] // wenn Zeilen groesser 8192, "+" statt "/" - sal_uInt16 nZoom = (sal_uInt16)((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator()); + sal_uInt16 nZoom = (sal_uInt16)((pThisTab->aZoomY.numerator() * 100) / pThisTab->aZoomY.denominator()); rData = OUString::number( nZoom ) + "/"; - nZoom = (sal_uInt16)((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator()); + nZoom = (sal_uInt16)((pThisTab->aPageZoomY.numerator() * 100) / pThisTab->aPageZoomY.denominator()); rData += OUString::number( nZoom ) + "/"; if (bPagebreak) rData += "1"; @@ -2259,15 +2259,15 @@ void ScViewData::ReadUserData(const OUString& rData) // nicht pro Tabelle: SCTAB nTabStart = 2; - Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY; // evaluate (all sheets?) + boost::rational<long> aZoomX, aZoomY, aPageZoomX, aPageZoomY; // evaluate (all sheets?) OUString aZoomStr = rData.getToken(0, ';'); // Zoom/PageZoom/Modus sal_uInt16 nNormZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(0,'/').toInt32()); if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM ) - aZoomX = aZoomY = Fraction( nNormZoom, 100 ); // "normal" zoom (always) + aZoomX = aZoomY = boost::rational<long>( nNormZoom, 100 ); // "normal" zoom (always) sal_uInt16 nPageZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.getToken(1,'/').toInt32()); if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM ) - aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 ); // Pagebreak-zoom, if set + aPageZoomX = aPageZoomY = boost::rational<long>( nPageZoom, 100 ); // Pagebreak-zoom, if set sal_Unicode cMode = aZoomStr.getToken(2,'/')[0]; // 0 or "0"/"1" SetPagebreakMode( cMode == '1' ); // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos() @@ -2447,8 +2447,8 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const // view mode and zoom rTabSett.mbPageMode = bPagebreak; - rTabSett.mnNormalZoom = static_cast< long >( pViewTab->aZoomY * Fraction( 100.0 ) ); - rTabSett.mnPageZoom = static_cast< long >( pViewTab->aPageZoomY * Fraction( 100.0 ) ); + rTabSett.mnNormalZoom = boost::rational_cast<long>(pViewTab->aZoomY * rational_FromDouble(100.)); + rTabSett.mnPageZoom = boost::rational_cast<long>(pViewTab->aPageZoomY * rational_FromDouble(100.)); } } } @@ -2579,9 +2579,9 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) // zoom for each sheet if( rTabSett.mnNormalZoom ) - rViewTab.aZoomX = rViewTab.aZoomY = Fraction( rTabSett.mnNormalZoom, 100L ); + rViewTab.aZoomX = rViewTab.aZoomY = boost::rational<long>( rTabSett.mnNormalZoom, 100L ); if( rTabSett.mnPageZoom ) - rViewTab.aPageZoomX = rViewTab.aPageZoomY = Fraction( rTabSett.mnPageZoom, 100L ); + rViewTab.aPageZoomX = rViewTab.aPageZoomY = boost::rational<long>( rTabSett.mnPageZoom, 100L ); rViewTab.bShowGrid = rTabSett.mbShowGrid; @@ -2599,9 +2599,9 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) // view mode and default zoom (for new sheets) from current sheet if( rTabSett.mnNormalZoom ) - aDefZoomX = aDefZoomY = Fraction( rTabSett.mnNormalZoom, 100L ); + aDefZoomX = aDefZoomY = boost::rational<long>( rTabSett.mnNormalZoom, 100L ); if( rTabSett.mnPageZoom ) - aDefPageZoomX = aDefPageZoomY = Fraction( rTabSett.mnPageZoom, 100L ); + aDefPageZoomX = aDefPageZoomY = boost::rational<long>( rTabSett.mnPageZoom, 100L ); /* #i46820# set pagebreak mode via SetPagebreakMode(), this will update map modes that are needed to draw text correctly. */ SetPagebreakMode( rTabSett.mbPageMode ); @@ -2662,8 +2662,8 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe pSettings[SC_ACTIVE_TABLE].Value <<= sName; pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = OUString(SC_HORIZONTALSCROLLBARWIDTH); pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32(pView->GetTabBarWidth()); - sal_Int32 nZoomValue ((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator()); - sal_Int32 nPageZoomValue ((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator()); + sal_Int32 nZoomValue ((pThisTab->aZoomY.numerator() * 100) / pThisTab->aZoomY.denominator()); + sal_Int32 nPageZoomValue ((pThisTab->aPageZoomY.numerator() * 100) / pThisTab->aPageZoomY.denominator()); pSettings[SC_ZOOM_TYPE].Name = OUString(SC_ZOOMTYPE); pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16(pThisTab->eZoomType); pSettings[SC_ZOOM_VALUE].Name = OUString(SC_ZOOMVALUE); @@ -2787,7 +2787,7 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue> { if (rSettings[i].Value >>= nTemp32) { - Fraction aZoom(nTemp32, 100); + boost::rational<long> aZoom(nTemp32, 100); aDefZoomX = aDefZoomY = aZoom; } } @@ -2795,7 +2795,7 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue> { if (rSettings[i].Value >>= nTemp32) { - Fraction aZoom(nTemp32, 100); + boost::rational<long> aZoom(nTemp32, 100); aDefPageZoomX = aDefPageZoomY = aZoom; } } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 1f395fc4aad6..4a69e92182b0 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -114,15 +114,15 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData ) double nPPTX = GetViewData().GetPPTX(); double nPPTY = GetViewData().GetPPTY(); - Fraction aZoomX = GetViewData().GetZoomX(); - Fraction aZoomY = GetViewData().GetZoomY(); + boost::rational<long> aZoomX = GetViewData().GetZoomX(); + boost::rational<long> aZoomY = GetViewData().GetZoomY(); ScSizeDeviceProvider aProv(pDocSh); if (aProv.IsPrinter()) { nPPTX = aProv.GetPPTX(); nPPTY = aProv.GetPPTY(); - aZoomX = aZoomY = Fraction( 1, 1 ); + aZoomX = aZoomY = boost::rational<long>( 1, 1 ); } sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice()); @@ -163,8 +163,8 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, bool bPaint ) SCTAB nTab = GetViewData().GetTabNo(); double nPPTX = GetViewData().GetPPTX(); double nPPTY = GetViewData().GetPPTY(); - Fraction aZoomX = GetViewData().GetZoomX(); - Fraction aZoomY = GetViewData().GetZoomY(); + boost::rational<long> aZoomX = GetViewData().GetZoomX(); + boost::rational<long> aZoomY = GetViewData().GetZoomY(); sal_uInt16 nOldPixel = 0; if (nStartRow == nEndRow) nOldPixel = (sal_uInt16) (rDoc.GetRowHeight(nStartRow,nTab) * nPPTY); @@ -174,7 +174,7 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, bool bPaint ) { nPPTX = aProv.GetPPTX(); nPPTY = aProv.GetPPTY(); - aZoomX = aZoomY = Fraction( 1, 1 ); + aZoomX = aZoomY = boost::rational<long>( 1, 1 ); } sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice()); bool bChanged = rDoc.SetOptimalHeight(aCxt, nStartRow, nEndRow, nTab); diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index b937eb3bf121..1e27dd1e9be1 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -420,7 +420,7 @@ bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic, if (aSourceMap.GetMapUnit() == MAP_PIXEL) { // consider pixel correction, so bitmap fits to screen - Fraction aScaleX, aScaleY; + boost::rational<long> aScaleX, aScaleY; pScDrawView->CalcNormScale( aScaleX, aScaleY ); aDestMap.SetScaleX(aScaleX); aDestMap.SetScaleY(aScaleY); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index f1ab1ebd8dba..3ed06d2db3de 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -228,15 +228,15 @@ sal_uInt16 ScViewFunc::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, bool bFormula double nPPTX = GetViewData().GetPPTX(); double nPPTY = GetViewData().GetPPTY(); - Fraction aZoomX = GetViewData().GetZoomX(); - Fraction aZoomY = GetViewData().GetZoomY(); + boost::rational<long> aZoomX = GetViewData().GetZoomX(); + boost::rational<long> aZoomY = GetViewData().GetZoomY(); ScSizeDeviceProvider aProv(pDocSh); if (aProv.IsPrinter()) { nPPTX = aProv.GetPPTX(); nPPTY = aProv.GetPPTY(); - aZoomX = aZoomY = Fraction( 1, 1 ); + aZoomX = aZoomY = boost::rational<long>( 1, 1 ); } sal_uInt16 nTwips = rDoc.GetOptimalColWidth( nCol, nTab, aProv.GetDevice(), @@ -2031,15 +2031,15 @@ void ScViewFunc::SetWidthOrHeight( double nPPTX = GetViewData().GetPPTX(); double nPPTY = GetViewData().GetPPTY(); - Fraction aZoomX = GetViewData().GetZoomX(); - Fraction aZoomY = GetViewData().GetZoomY(); + boost::rational<long> aZoomX = GetViewData().GetZoomX(); + boost::rational<long> aZoomY = GetViewData().GetZoomY(); ScSizeDeviceProvider aProv(pDocSh); if (aProv.IsPrinter()) { nPPTX = aProv.GetPPTX(); nPPTY = aProv.GetPPTY(); - aZoomX = aZoomY = Fraction( 1, 1 ); + aZoomX = aZoomY = boost::rational<long>( 1, 1 ); } sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoomX, aZoomY, aProv.GetDevice()); @@ -2265,15 +2265,15 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal ) { double nPPTX = GetViewData().GetPPTX(); double nPPTY = GetViewData().GetPPTY(); - Fraction aZoomX = GetViewData().GetZoomX(); - Fraction aZoomY = GetViewData().GetZoomY(); + boost::rational<long> aZoomX = GetViewData().GetZoomX(); + boost::rational<long> aZoomY = GetViewData().GetZoomY(); ScSizeDeviceProvider aProv(pDocSh); if (aProv.IsPrinter()) { nPPTX = aProv.GetPPTX(); nPPTY = aProv.GetPPTY(); - aZoomX = aZoomY = Fraction( 1, 1 ); + aZoomX = aZoomY = boost::rational<long>( 1, 1 ); } long nPixel = rDoc.GetNeededSize( nCol, nRow, nTab, aProv.GetDevice(), |