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 /sd | |
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 'sd')
39 files changed, 156 insertions, 158 deletions
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 772364fdb345..39cded4e3e74 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -192,12 +192,12 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) // Allow UI scale only for draw documents. if( eType == DOCUMENT_TYPE_DRAW ) - SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) ); // user-defined + SetUIUnit( (FieldUnit)pOptions->GetMetric(), boost::rational<long>( nX, nY ) ); // user-defined else - SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) ); // default + SetUIUnit( (FieldUnit)pOptions->GetMetric(), boost::rational<long>( 1, 1 ) ); // default SetScaleUnit(MAP_100TH_MM); - SetScaleFraction(Fraction(1, 1)); + SetScaleFraction(boost::rational<long>(1, 1)); SetDefaultFontHeight(847); // 24p pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM); diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 75e41fb8b085..1e96f6f0aa68 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -1843,8 +1843,8 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR long nOldWidth = GetWdt() - GetLftBorder() - GetRgtBorder(); long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder(); - Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth); - Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight); + boost::rational<long> aFractX( aNewPageSize.Width(), nOldWidth ); + boost::rational<long> aFractY( aNewPageSize.Height(), nOldHeight ); const size_t nObjCnt = (mbScaleObjects ? GetObjCount() : 0); @@ -1902,14 +1902,14 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT); sal_uLong nFontHeight = rOldHgt.GetHeight(); - nFontHeight = long(nFontHeight * (double) aFractY); + nFontHeight = long(nFontHeight * boost::rational_cast<double>(aFractY)); rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT)); if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) ) { rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK); nFontHeight = rOldHgt.GetHeight(); - nFontHeight = long(nFontHeight * (double) aFractY); + nFontHeight = long(nFontHeight * boost::rational_cast<double>(aFractY)); rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK)); } @@ -1917,7 +1917,7 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR { rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL); nFontHeight = rOldHgt.GetHeight(); - nFontHeight = long(nFontHeight * (double) aFractY); + nFontHeight = long(nFontHeight * boost::rational_cast<double>(aFractY)); rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL)); } @@ -1941,14 +1941,14 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT); sal_uLong nFontHeight = rOldHgt.GetHeight(); - nFontHeight = long(nFontHeight * (double) aFractY); + nFontHeight = long(nFontHeight * boost::rational_cast<double>(aFractY)); aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT)); if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) ) { rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK); nFontHeight = rOldHgt.GetHeight(); - nFontHeight = long(nFontHeight * (double) aFractY); + nFontHeight = long(nFontHeight * boost::rational_cast<double>(aFractY)); aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK)); } @@ -1956,7 +1956,7 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR { rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL); nFontHeight = rOldHgt.GetHeight(); - nFontHeight = long(nFontHeight * (double) aFractY); + nFontHeight = long(nFontHeight * boost::rational_cast<double>(aFractY)); aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL)); } @@ -2018,7 +2018,7 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR // use more modern method to scale the text height sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight(); - sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY); + sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * boost::rational_cast<double>(aFractY)); pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich)); } @@ -2034,8 +2034,8 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderR // corrected scaling; only distances may be scaled // use aTopLeft as original TopLeft - aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft; - aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper; + aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * boost::rational_cast<double>(aFractX)) + nLeft; + aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * boost::rational_cast<double>(aFractY)) + nUpper; Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y()); diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index 082b67a89655..d05ed1149d3b 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -1095,7 +1095,7 @@ void ImplExportComments( uno::Reference< drawing::XDrawPage > xPage, SvMemoryStr uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() ); geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() ); - MapMode aMapDest( MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) ); + MapMode aMapDest( MAP_INCH, Point(), boost::rational<long>( 1, 576 ), boost::rational<long>( 1, 576 ) ); Point aPoint( OutputDevice::LogicToLogic( Point( static_cast< sal_Int32 >( aRealPoint2D.X * 100.0 ), static_cast< sal_Int32 >( aRealPoint2D.Y * 100.0 ) ), MAP_100TH_MM, aMapDest ) ); diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx index 00eb6a1a3de8..9529d58a3ea1 100644 --- a/sd/source/filter/eppt/epptbase.hxx +++ b/sd/source/filter/eppt/epptbase.hxx @@ -347,7 +347,7 @@ protected: sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout ) sal_uInt32 mnMasterPages; - Fraction maFraction; + boost::rational<long> maFraction; MapMode maMapModeSrc; MapMode maMapModeDest; ::com::sun::star::awt::Size maDestPageSize; diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx index b2c25b55eb27..8e56d350e884 100644 --- a/sd/source/filter/eppt/pptx-text.cxx +++ b/sd/source/filter/eppt/pptx-text.cxx @@ -652,7 +652,7 @@ ParagraphObj::ParagraphObj(const ::com::sun::star::uno::Reference< ::com::sun::s , SOParagraph() , mvPortions() , maMapModeSrc(MAP_100TH_MM) - , maMapModeDest(MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 )) + , maMapModeDest(MAP_INCH, Point(), boost::rational<long>( 1, 576 ), boost::rational<long>( 1, 576 )) , mnTextSize(0) , mbFirstParagraph(false) , mbLastParagraph(false) @@ -682,7 +682,7 @@ ParagraphObj::ParagraphObj(::com::sun::star::uno::Reference< ::com::sun::star::t , SOParagraph() , mvPortions() , maMapModeSrc(MAP_100TH_MM) - , maMapModeDest(MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 )) + , maMapModeDest(MAP_INCH, Point(), boost::rational<long>( 1, 576 ), boost::rational<long>( 1, 576 )) , mnTextSize(0) , mbIsBullet(false) , mbFirstParagraph( aParaFlags.bFirstParagraph ) diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx index e5676c4d105f..a93091e8c56c 100644 --- a/sd/source/ui/animations/motionpathtag.cxx +++ b/sd/source/ui/animations/motionpathtag.cxx @@ -181,7 +181,7 @@ bool PathDragResize::EndSdrDrag(bool /*bCopy*/) { const Point aRef( DragStat().Ref1() ); basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-aRef.X(), -aRef.Y())); - aTrans.scale(double(aXFact), double(aYFact)); + aTrans.scale(boost::rational_cast<double>(aXFact), boost::rational_cast<double>(aYFact)); aTrans.translate(aRef.X(), aRef.Y()); basegfx::B2DPolyPolygon aDragPoly(pPathObj->GetPathPoly()); aDragPoly.transform(aTrans); diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx index 47063aad5fc8..19125096c0e1 100644 --- a/sd/source/ui/annotations/annotationwindow.cxx +++ b/sd/source/ui/annotations/annotationwindow.cxx @@ -376,7 +376,7 @@ void AnnotationWindow::Rescale() { vcl::Font aFont( mpMeta->GetSettings().GetStyleSettings().GetFieldFont() ); sal_Int32 nHeight = aFont.GetHeight(); - nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator(); + nHeight = nHeight * aMode.GetScaleY().numerator() / aMode.GetScaleY().denominator(); aFont.SetHeight( nHeight ); mpMeta->SetControlFont( aFont ); } diff --git a/sd/source/ui/app/optsitem.cxx b/sd/source/ui/app/optsitem.cxx index dca7ba140995..73db89fa54b9 100644 --- a/sd/source/ui/app/optsitem.cxx +++ b/sd/source/ui/app/optsitem.cxx @@ -1126,8 +1126,8 @@ SdOptionsGridItem::SdOptionsGridItem( sal_uInt16 _nWhich, SdOptions* pOpts, ::sd SetFldDrawY( pView->GetGridCoarse().Height() ); SetFldDivisionX( pView->GetGridFine().Width() ? ( GetFldDrawX() / pView->GetGridFine().Width() - 1 ) : 0 ); SetFldDivisionY( pView->GetGridFine().Height() ? ( GetFldDrawY() / pView->GetGridFine().Height() - 1 ) : 0 ); - SetFldSnapX( long(pView->GetSnapGridWidthX()) ); - SetFldSnapY( long(pView->GetSnapGridWidthY()) ); + SetFldSnapX( boost::rational_cast<long>(pView->GetSnapGridWidthX()) ); + SetFldSnapY( boost::rational_cast<long>(pView->GetSnapGridWidthY()) ); SetUseGridSnap( pView->IsGridSnap() ); SetGridVisible( pView->IsGridVisible() ); } diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx index 2c83b2d5102e..8db6f17d7f52 100644 --- a/sd/source/ui/app/sdmod2.cxx +++ b/sd/source/ui/app/sdmod2.cxx @@ -502,9 +502,9 @@ SfxItemSet* SdModule::CreateItemSet( sal_uInt16 nSlot ) if(pFrameView) { - const Fraction& rFraction = pDoc->GetUIScale(); - nX=rFraction.GetNumerator(); - nY=rFraction.GetDenominator(); + const boost::rational<long>& rFraction = pDoc->GetUIScale(); + nX=rFraction.numerator(); + nY=rFraction.denominator(); } else { @@ -595,7 +595,7 @@ void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet ) // Apply to document only if doc type match if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() ) { - pDoc->SetUIScale( Fraction( nX, nY ) ); + pDoc->SetUIScale( boost::rational<long>( nX, nY ) ); if( pViewShell ) pViewShell->SetRuler( pViewShell->HasRuler() ); } diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx index 019103ef4efb..2e9764b49efa 100644 --- a/sd/source/ui/dlg/animobjs.cxx +++ b/sd/source/ui/dlg/animobjs.cxx @@ -89,8 +89,8 @@ void SdDisplay::Paint( const Rectangle& ) Point aPt; Size aSize = GetOutputSize(); Size aBmpSize = aBitmapEx.GetBitmap().GetSizePixel(); - aBmpSize.Width() = (long) ( (double) aBmpSize.Width() * (double) aScale ); - aBmpSize.Height() = (long) ( (double) aBmpSize.Height() * (double) aScale ); + aBmpSize.Width() = (long) ( (double) aBmpSize.Width() * boost::rational_cast<double>(this->aScale) ); + aBmpSize.Height() = (long) ( (double) aBmpSize.Height() * boost::rational_cast<double>(this->aScale) ); if( aBmpSize.Width() < aSize.Width() ) aPt.X() = ( aSize.Width() - aBmpSize.Width() ) / 2; @@ -100,7 +100,7 @@ void SdDisplay::Paint( const Rectangle& ) aBitmapEx.Draw( this, aPt, aBmpSize ); } -void SdDisplay::SetScale( const Fraction& rFrac ) +void SdDisplay::SetScale( const boost::rational<long>& rFrac ) { aScale = rFrac; } @@ -468,7 +468,7 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn ) } // calculate and set zoom for DisplayWin - Fraction aFrac( GetScale() ); + boost::rational<long> aFrac( GetScale() ); aCtlDisplay.SetScale( aFrac ); UpdateControl(); @@ -643,9 +643,9 @@ void AnimationWindow::WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime, } } -Fraction AnimationWindow::GetScale() +boost::rational<long> AnimationWindow::GetScale() { - Fraction aFrac; + boost::rational<long> aFrac; size_t const nCount = m_FrameList.size(); if (nCount > 0) { @@ -662,7 +662,7 @@ Fraction AnimationWindow::GetScale() aBmpSize.Width() += 10; aBmpSize.Height() += 10; - aFrac = Fraction( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(), + aFrac = rational_FromDouble( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(), (double)aDisplaySize.Height() / (double)aBmpSize.Height() ) ); } return( aFrac ); @@ -733,7 +733,7 @@ void AnimationWindow::Resize() aGrpAnimation.SetPosPixel( aGrpAnimation.GetPosPixel() + aPt ); // calculate and set zoom for DisplayWin - Fraction aFrac( GetScale() ); + boost::rational<long> aFrac( GetScale() ); aCtlDisplay.SetScale( aFrac ); aBtnFirst.Show(); @@ -963,7 +963,7 @@ void AnimationWindow::AddObj (::sd::View& rView ) } // calculate and set zoom for DisplayWin - Fraction aFrac( GetScale() ); + boost::rational<long> aFrac( GetScale() ); aCtlDisplay.SetScale( aFrac ); UpdateControl(); diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx index 56e865215205..c55915884881 100644 --- a/sd/source/ui/dlg/copydlg.cxx +++ b/sd/source/ui/dlg/copydlg.cxx @@ -128,12 +128,12 @@ void CopyDlg::Reset() long nMoveX = 500L; if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_X, true, &pPoolItem ) ) nMoveX = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() ); - SetMetricValue( *m_pMtrFldMoveX, Fraction(nMoveX) / maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldMoveX, boost::rational_cast<long>(nMoveX / maUIScale), SFX_MAPUNIT_100TH_MM); long nMoveY = 500L; if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_Y, true, &pPoolItem ) ) nMoveY = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() ); - SetMetricValue( *m_pMtrFldMoveY, Fraction(nMoveY) / maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldMoveY, boost::rational_cast<long>(nMoveY / maUIScale), SFX_MAPUNIT_100TH_MM); if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_ANGLE, true, &pPoolItem ) ) m_pMtrFldAngle->SetValue( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() ); @@ -143,12 +143,12 @@ void CopyDlg::Reset() long nWidth = 0L; if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_WIDTH, true, &pPoolItem ) ) nWidth = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() ); - SetMetricValue( *m_pMtrFldWidth, Fraction(nWidth) / maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldWidth, boost::rational_cast<long>(nWidth / maUIScale), SFX_MAPUNIT_100TH_MM); long nHeight = 0L; if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_HEIGHT, true, &pPoolItem ) ) nHeight = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() ); - SetMetricValue( *m_pMtrFldHeight, Fraction(nHeight) / maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldHeight, boost::rational_cast<long>(nHeight / maUIScale), SFX_MAPUNIT_100TH_MM); if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) ) { @@ -199,10 +199,10 @@ void CopyDlg::Reset() */ void CopyDlg::GetAttr( SfxItemSet& rOutAttrs ) { - long nMoveX = Fraction( GetCoreValue( *m_pMtrFldMoveX, SFX_MAPUNIT_100TH_MM) ) * maUIScale; - long nMoveY = Fraction( GetCoreValue( *m_pMtrFldMoveY, SFX_MAPUNIT_100TH_MM) ) * maUIScale; - long nHeight = Fraction( GetCoreValue( *m_pMtrFldHeight, SFX_MAPUNIT_100TH_MM) ) * maUIScale; - long nWidth = Fraction( GetCoreValue( *m_pMtrFldWidth, SFX_MAPUNIT_100TH_MM) ) * maUIScale; + long nMoveX = boost::rational_cast<long>(GetCoreValue(*m_pMtrFldMoveX, SFX_MAPUNIT_100TH_MM) * maUIScale); + long nMoveY = boost::rational_cast<long>(GetCoreValue(*m_pMtrFldMoveY, SFX_MAPUNIT_100TH_MM) * maUIScale); + long nHeight = boost::rational_cast<long>(GetCoreValue(*m_pMtrFldHeight, SFX_MAPUNIT_100TH_MM) * maUIScale); + long nWidth = boost::rational_cast<long>(GetCoreValue(*m_pMtrFldWidth, SFX_MAPUNIT_100TH_MM) * maUIScale); rOutAttrs.Put( SfxUInt16Item( ATTR_COPY_NUMBER, (sal_uInt16) m_pNumFldCopies->GetValue() ) ); rOutAttrs.Put( SfxInt32Item( ATTR_COPY_MOVE_X, nMoveX ) ); @@ -249,10 +249,8 @@ IMPL_LINK_NOARG(CopyDlg, SetViewData) { Rectangle aRect = mpView->GetAllMarkedRect(); - SetMetricValue( *m_pMtrFldMoveX, Fraction( aRect.GetWidth() ) / - maUIScale, SFX_MAPUNIT_100TH_MM); - SetMetricValue( *m_pMtrFldMoveY, Fraction( aRect.GetHeight() ) / - maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldMoveX, boost::rational_cast<long>(aRect.GetWidth() / maUIScale), SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldMoveY, boost::rational_cast<long>(aRect.GetHeight() / maUIScale), SFX_MAPUNIT_100TH_MM); // sets color attribute const SfxPoolItem* pPoolItem = NULL; @@ -273,13 +271,13 @@ IMPL_LINK_NOARG(CopyDlg, SetDefault) m_pNumFldCopies->SetValue( 1L ); long nValue = 500L; - SetMetricValue( *m_pMtrFldMoveX, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM); - SetMetricValue( *m_pMtrFldMoveY, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldMoveX, boost::rational_cast<long>(nValue / maUIScale), SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldMoveY, boost::rational_cast<long>(nValue / maUIScale), SFX_MAPUNIT_100TH_MM); nValue = 0L; m_pMtrFldAngle->SetValue( nValue ); - SetMetricValue( *m_pMtrFldWidth, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM); - SetMetricValue( *m_pMtrFldHeight, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldWidth, boost::rational_cast<long>(nValue / maUIScale), SFX_MAPUNIT_100TH_MM); + SetMetricValue( *m_pMtrFldHeight, boost::rational_cast<long>(nValue / maUIScale), SFX_MAPUNIT_100TH_MM); // set color attribute const SfxPoolItem* pPoolItem = NULL; diff --git a/sd/source/ui/dlg/dlgsnap.cxx b/sd/source/ui/dlg/dlgsnap.cxx index ee8548f07c6a..b4565165da7f 100644 --- a/sd/source/ui/dlg/dlgsnap.cxx +++ b/sd/source/ui/dlg/dlgsnap.cxx @@ -78,33 +78,33 @@ SdSnapLineDlg::SdSnapLineDlg( SetMetricValue( *m_pMtrFldX, aLeftTop.X(), ePoolUnit ); long nValue = static_cast<long>(m_pMtrFldX->GetValue()); - nValue = Fraction( nValue ) / aUIScale; + nValue = boost::rational_cast<long>(nValue / aUIScale); m_pMtrFldX->SetMin( nValue ); m_pMtrFldX->SetFirst( nValue ); SetMetricValue( *m_pMtrFldX, aRightBottom.X(), ePoolUnit ); nValue = static_cast<long>(m_pMtrFldX->GetValue()); - nValue = Fraction( nValue ) / aUIScale; + nValue = boost::rational_cast<long>(nValue / aUIScale); m_pMtrFldX->SetMax( nValue ); m_pMtrFldX->SetLast( nValue ); SetMetricValue( *m_pMtrFldY, aLeftTop.Y(), ePoolUnit ); nValue = static_cast<long>(m_pMtrFldY->GetValue()); - nValue = Fraction( nValue ) / aUIScale; + nValue = boost::rational_cast<long>(nValue / aUIScale); m_pMtrFldY->SetMin( nValue ); m_pMtrFldY->SetFirst( nValue ); SetMetricValue( *m_pMtrFldY, aRightBottom.Y(), ePoolUnit ); nValue = static_cast<long>(m_pMtrFldY->GetValue()); - nValue = Fraction( nValue ) / aUIScale; + nValue = boost::rational_cast<long>(nValue / aUIScale); m_pMtrFldY->SetMax( nValue ); m_pMtrFldY->SetLast( nValue ); // set values nXValue = ((const SfxInt32Item&) rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue(); nYValue = ((const SfxInt32Item&) rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue(); - nXValue = Fraction(nXValue) / aUIScale; - nYValue = Fraction(nYValue) / aUIScale; + nXValue = boost::rational_cast<long>(nXValue / aUIScale); + nYValue = boost::rational_cast<long>(nYValue / aUIScale); SetMetricValue( *m_pMtrFldX, nXValue, SFX_MAPUNIT_100TH_MM); SetMetricValue( *m_pMtrFldY, nYValue, SFX_MAPUNIT_100TH_MM); @@ -135,8 +135,8 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs) else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL; else eKind = SK_POINT; - nXValue = Fraction( GetCoreValue( *m_pMtrFldX, SFX_MAPUNIT_100TH_MM) ) * aUIScale; - nYValue = Fraction( GetCoreValue( *m_pMtrFldY, SFX_MAPUNIT_100TH_MM) ) * aUIScale; + nXValue = boost::rational_cast<long>(GetCoreValue(*m_pMtrFldX, SFX_MAPUNIT_100TH_MM) * aUIScale); + nYValue = boost::rational_cast<long>(GetCoreValue(*m_pMtrFldY, SFX_MAPUNIT_100TH_MM) * aUIScale); rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, (sal_uInt16)eKind)); rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_X, nXValue)); diff --git a/sd/source/ui/dlg/docprev.cxx b/sd/source/ui/dlg/docprev.cxx index e6501b00e7b7..a6f2fa7787ae 100644 --- a/sd/source/ui/dlg/docprev.cxx +++ b/sd/source/ui/dlg/docprev.cxx @@ -237,7 +237,7 @@ void SdDocPreviewWin::updateViewSettings() VirtualDevice aVDev; - const Fraction aFrac( pDoc->GetScaleFraction() ); + const boost::rational<long> aFrac( pDoc->GetScaleFraction() ); const MapMode aMap( pDoc->GetScaleUnit(), Point(), aFrac, aFrac ); aVDev.SetMapMode( aMap ); diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx index ee7c184e5b37..ecb5a2966cbc 100644 --- a/sd/source/ui/dlg/vectdlg.cxx +++ b/sd/source/ui/dlg/vectdlg.cxx @@ -113,7 +113,7 @@ void SdVectorizeDlg::InitPreviewBmp() m_pBmpWin->SetGraphic( aPreviewBmp ); } -Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap& rBmp, Fraction& rScale ) +Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap& rBmp, boost::rational<long>& rScale ) { Bitmap aNew( rBmp ); const Size aSizePix( aNew.GetSizePixel() ); @@ -121,11 +121,11 @@ Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap& rBmp, Fraction& rScale ) if( aSizePix.Width() > VECTORIZE_MAX_EXTENT || aSizePix.Height() > VECTORIZE_MAX_EXTENT ) { const Rectangle aRect( GetRect( Size( VECTORIZE_MAX_EXTENT, VECTORIZE_MAX_EXTENT ), aSizePix ) ); - rScale = Fraction( aSizePix.Width(), aRect.GetWidth() ); + rScale = boost::rational<long>( aSizePix.Width(), aRect.GetWidth() ); aNew.Scale( aRect.GetSize() ); } else - rScale = Fraction( 1, 1 ); + rScale = boost::rational<long>( 1, 1 ); aNew.ReduceColors( (sal_uInt16) m_pNmLayers->GetValue(), BMP_REDUCE_SIMPLE ); @@ -137,7 +137,7 @@ void SdVectorizeDlg::Calculate( Bitmap& rBmp, GDIMetaFile& rMtf ) mpDocSh->SetWaitCursor( true ); m_pPrgs->SetValue( 0 ); - Fraction aScale; + boost::rational<long> aScale; Bitmap aTmp( GetPreparedBitmap( rBmp, aScale ) ); if( !!aTmp ) diff --git a/sd/source/ui/docshell/docshel2.cxx b/sd/source/ui/docshell/docshel2.cxx index c0bf1fcf8b34..923e70b407f2 100644 --- a/sd/source/ui/docshell/docshel2.cxx +++ b/sd/source/ui/docshell/docshel2.cxx @@ -199,7 +199,7 @@ Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage, sal_uInt16 nMaxEdgePixe const Size aPixSize( aVDev.LogicToPixel( aSize ) ); const sal_uLong nMaxEdgePix = std::max( aPixSize.Width(), aPixSize.Height() ); - Fraction aFrac( nMaxEdgePixel, nMaxEdgePix ); + boost::rational<long> aFrac( nMaxEdgePixel, nMaxEdgePix ); aMapMode.SetScaleX( aFrac ); aMapMode.SetScaleY( aFrac ); @@ -207,7 +207,7 @@ Bitmap DrawDocShell::GetPagePreviewBitmap(SdPage* pPage, sal_uInt16 nMaxEdgePixe aVDev.SetOutputSize( aSize ); // that we also get the dark lines at the right and bottom page margin - aFrac = Fraction( nMaxEdgePixel - 1, nMaxEdgePix ); + aFrac = boost::rational<long>( nMaxEdgePixel - 1, nMaxEdgePix ); aMapMode.SetScaleX( aFrac ); aMapMode.SetScaleY( aFrac ); aVDev.SetMapMode( aMapMode ); diff --git a/sd/source/ui/docshell/sdclient.cxx b/sd/source/ui/docshell/sdclient.cxx index 768ec5d94a72..0976289fb672 100644 --- a/sd/source/ui/docshell/sdclient.cxx +++ b/sd/source/ui/docshell/sdclient.cxx @@ -169,8 +169,8 @@ void Client::ViewChanged() Size aSize = pSdrOle2Obj->GetOrigObjSize( &aMap100 ); aVisArea.SetSize( aSize ); - Size aScaledSize( static_cast< long >( GetScaleWidth() * Fraction( aVisArea.GetWidth() ) ), - static_cast< long >( GetScaleHeight() * Fraction( aVisArea.GetHeight() ) ) ); + Size aScaledSize( boost::rational_cast<long>(GetScaleWidth() * aVisArea.GetWidth()), + boost::rational_cast<long>(GetScaleHeight() * aVisArea.GetHeight()) ); // react to the change if the difference is bigger than one pixel Size aPixelDiff = diff --git a/sd/source/ui/func/fucopy.cxx b/sd/source/ui/func/fucopy.cxx index 03477a588620..e1d0b57f76b2 100644 --- a/sd/source/ui/func/fucopy.cxx +++ b/sd/source/ui/func/fucopy.cxx @@ -235,8 +235,8 @@ void FuCopy::DoExecute( SfxRequest& rReq ) } } - Fraction aWidth( aRect.Right() - aRect.Left() + lWidth, aRect.Right() - aRect.Left() ); - Fraction aHeight( aRect.Bottom() - aRect.Top() + lHeight, aRect.Bottom() - aRect.Top() ); + boost::rational<long> aWidth( aRect.Right() - aRect.Left() + lWidth, aRect.Right() - aRect.Left() ); + boost::rational<long> aHeight( aRect.Bottom() - aRect.Top() + lHeight, aRect.Bottom() - aRect.Top() ); if( mpView->IsResizeAllowed() ) mpView->ResizeAllMarked( aRect.TopLeft(), aWidth, aHeight ); diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 42fbabe36d6a..8ffedbdf7569 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -408,7 +408,7 @@ protected: virtual SvxRuler* CreateVRuler(::sd::Window* pWin) SAL_OVERRIDE; virtual void UpdateHRuler() SAL_OVERRIDE; virtual void UpdateVRuler() 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; void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower, bool bSize, bool bMargin, bool bScaleAll ); diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index 74e2bd254227..18e3cd43be3c 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -537,8 +537,8 @@ protected: virtual void Activate(bool IsMDIActivate) SAL_OVERRIDE; virtual void Deactivate(bool IsMDIActivate) SAL_OVERRIDE; - virtual void SetZoomFactor( const Fraction &rZoomX, - const Fraction &rZoomY ); + virtual void SetZoomFactor( const boost::rational<long>& rZoomX, + const boost::rational<long>& rZoomY ); /** This must be called after the ctor, but before anything else. diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index af33977a8e33..c744a3d3a085 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -161,8 +161,8 @@ public: virtual void Activate (bool IsMDIActivate) SAL_OVERRIDE; virtual void Deactivate (bool IsMDIActivate) SAL_OVERRIDE; virtual void SetZoomFactor ( - const Fraction &rZoomX, - const Fraction &rZoomY) SAL_OVERRIDE; + const boost::rational<long>& rZoomX, + const boost::rational<long>& rZoomY) SAL_OVERRIDE; virtual bool PrepareClose (bool bUI = true) SAL_OVERRIDE; virtual void WriteUserData (OUString&, bool bBrowse = false) SAL_OVERRIDE; virtual void ReadUserData (const OUString&, bool bBrowse = false) SAL_OVERRIDE; diff --git a/sd/source/ui/inc/animobjs.hxx b/sd/source/ui/inc/animobjs.hxx index 9e720ad04260..2178f829108c 100644 --- a/sd/source/ui/inc/animobjs.hxx +++ b/sd/source/ui/inc/animobjs.hxx @@ -61,7 +61,7 @@ class SdDisplay : public Control { private: BitmapEx aBitmapEx; - Fraction aScale; + boost::rational<long> aScale; public: SdDisplay( vcl::Window* pWin, SdResId Id ); @@ -70,7 +70,7 @@ public: virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE; void SetBitmapEx( BitmapEx* pBmpEx ); - void SetScale( const Fraction& rFrac ); + void SetScale( const boost::rational<long>& rFrac ); virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; }; @@ -155,7 +155,7 @@ private: void ResetAttrs(); void WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime, SfxProgress* pStbMgr ) const; - Fraction GetScale(); + boost::rational<long> GetScale(); }; /** diff --git a/sd/source/ui/inc/copydlg.hxx b/sd/source/ui/inc/copydlg.hxx index 7994e0c1c08b..f62bf44f3b39 100644 --- a/sd/source/ui/inc/copydlg.hxx +++ b/sd/source/ui/inc/copydlg.hxx @@ -64,7 +64,7 @@ private: const SfxItemSet& mrOutAttrs; XColorListRef mpColorList; - Fraction maUIScale; + boost::rational<long> maUIScale; ::sd::View* mpView; DECL_LINK( SelectColorHdl, void * ); diff --git a/sd/source/ui/inc/dlgsnap.hxx b/sd/source/ui/inc/dlgsnap.hxx index ab431c856be3..befaa538ceba 100644 --- a/sd/source/ui/inc/dlgsnap.hxx +++ b/sd/source/ui/inc/dlgsnap.hxx @@ -25,7 +25,7 @@ #include <vcl/field.hxx> #include <vcl/group.hxx> #include <vcl/layout.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <vcl/dialog.hxx> #include "sdenumdef.hxx" /************************************************************************/ @@ -53,7 +53,7 @@ private: long nXValue; long nYValue; FieldUnit eUIUnit; - Fraction aUIScale; + boost::rational<long> aUIScale; DECL_LINK( ClickHdl, Button * ); diff --git a/sd/source/ui/inc/vectdlg.hxx b/sd/source/ui/inc/vectdlg.hxx index 153343dae933..6107c7ed99a1 100644 --- a/sd/source/ui/inc/vectdlg.hxx +++ b/sd/source/ui/inc/vectdlg.hxx @@ -67,7 +67,7 @@ class SdVectorizeDlg : public ModalDialog void UpdatePreviewMtf(); Rectangle GetRect( const Size& rDispSize, const Size& rBmpSize ) const; - Bitmap GetPreparedBitmap( Bitmap& rBmp, Fraction& rScale ); + Bitmap GetPreparedBitmap( Bitmap& rBmp, boost::rational<long>& rScale ); void Calculate( Bitmap& rBmp, GDIMetaFile& rMtf ); void AddTile( BitmapReadAccess* pRAcc, GDIMetaFile& rMtf, long nPosX, long nPosY, long nWidth, long nHeight ); diff --git a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx index 381bac6868f7..b6555cc5ac89 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsLayouter.hxx @@ -24,7 +24,7 @@ #include "view/SlsPageObjectLayouter.hxx" #include "view/SlsTheme.hxx" #include <sal/types.h> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <vcl/mapmod.hxx> #include <vector> #include <utility> @@ -114,7 +114,7 @@ public: /** Return the scale factor that can be set at the map mode of the output window. */ - Fraction GetScaleFactor (void) const; + boost::rational<long> GetScaleFactor (void) const; Size GetPageObjectSize (void) const; diff --git a/sd/source/ui/tools/PreviewRenderer.cxx b/sd/source/ui/tools/PreviewRenderer.cxx index 4de09a10c1a6..3113433ff3b9 100644 --- a/sd/source/ui/tools/PreviewRenderer.cxx +++ b/sd/source/ui/tools/PreviewRenderer.cxx @@ -383,9 +383,9 @@ void PreviewRenderer::SetupOutputSize ( { const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0); aMapMode.SetScaleX( - Fraction(rFramePixelSize.Width()-2*nFrameWidth-1, aPageModelSize.Width())); + boost::rational<long>(rFramePixelSize.Width()-2*nFrameWidth-1, aPageModelSize.Width())); aMapMode.SetScaleY( - Fraction(rFramePixelSize.Height()-2*nFrameWidth-1, aPageModelSize.Height())); + boost::rational<long>(rFramePixelSize.Height()-2*nFrameWidth-1, aPageModelSize.Height())); aMapMode.SetOrigin(mpPreviewDevice->PixelToLogic(Point(nFrameWidth,nFrameWidth),aMapMode)); } else diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx index 1a9c67f62b68..fc81e5383bb2 100644 --- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx +++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx @@ -677,7 +677,7 @@ throw (UnknownPropertyException, PropertyVetoException, sal_Int32 nValue = 0; if( *pValues >>= nValue ) { - Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() ); + boost::rational<long> aFract( nValue, pDoc->GetUIScale().denominator() ); pDoc->SetUIScale( aFract ); bOk = true; bChanged = true; @@ -689,7 +689,7 @@ throw (UnknownPropertyException, PropertyVetoException, sal_Int32 nValue = 0; if( *pValues >>= nValue ) { - Fraction aFract( pDoc->GetUIScale().GetNumerator(), nValue ); + boost::rational<long> aFract( pDoc->GetUIScale().numerator(), nValue ); pDoc->SetUIScale( aFract ); bOk = true; bChanged = true; @@ -1091,10 +1091,10 @@ throw (UnknownPropertyException, WrappedTargetException, RuntimeException) } break; case HANDLE_SCALE_NUM: - *pValue <<= (sal_Int32)pDoc->GetUIScale().GetNumerator(); + *pValue <<= (sal_Int32)pDoc->GetUIScale().numerator(); break; case HANDLE_SCALE_DOM: - *pValue <<= (sal_Int32)pDoc->GetUIScale().GetDenominator(); + *pValue <<= (sal_Int32)pDoc->GetUIScale().denominator(); break; case HANDLE_TABSTOP: *pValue <<= (sal_Int32)pDoc->GetDefaultTabulator(); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 291733159378..16fe7c1eca44 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2226,10 +2226,10 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, // that VirtualDevices use a DPI of 96. // We specifically calculate these scales first as we're still // in TWIPs, and might as well minimise the number of conversions. - Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) / - Fraction( nTileWidth); - Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) / - Fraction( nTileHeight); + boost::rational<long> scaleX = boost::rational<long>( nOutputWidth, 96 ) * boost::rational<long>(1440L) / + boost::rational<long>( nTileWidth ); + boost::rational<long> scaleY = boost::rational<long>( nOutputHeight, 96 ) * boost::rational<long>(1440L) / + boost::rational<long>( nTileHeight ); // svx seems to be the only component that works natively in // 100th mm rather than TWIP. It makes most sense just to diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index f61224fa1aef..5af3c448ed7d 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1608,8 +1608,8 @@ private: { MapMode aMap (rInfo.maMap); Point aPageOfs (rInfo.mpPrinter->GetPageOffset() ); - aMap.SetScaleX(Fraction(1,2)); - aMap.SetScaleY(Fraction(1,2)); + aMap.SetScaleX(boost::rational<long>(1,2)); + aMap.SetScaleY(boost::rational<long>(1,2)); mpPrinter->SetMapMode(aMap); Rectangle aOutRect(aPageOfs, rInfo.mpPrinter->GetOutputSize()); @@ -1803,11 +1803,11 @@ private: const double fHorz = (double) aPrintSize.Width() / aPageSize.Width(); const double fVert = (double) aPrintSize.Height() / aPageSize.Height(); - Fraction aFract; + boost::rational<long> aFract; if ( fHorz < fVert ) - aFract = Fraction(aPrintSize.Width(), aPageSize.Width()); + aFract = boost::rational<long>(aPrintSize.Width(), aPageSize.Width()); else - aFract = Fraction(aPrintSize.Height(), aPageSize.Height()); + aFract = boost::rational<long>(aPrintSize.Height(), aPageSize.Height()); aMap.SetScaleX(aFract); aMap.SetScaleY(aFract); @@ -1931,11 +1931,11 @@ private: const double fHorz ((double) rInfo.maPrintSize.Width() / aPageSize.Width()); const double fVert ((double) rInfo.maPrintSize.Height() / aPageSize.Height()); - Fraction aFract; + boost::rational<long> aFract; if (fHorz < fVert) - aFract = Fraction(rInfo.maPrintSize.Width(), aPageSize.Width()); + aFract = boost::rational<long>(rInfo.maPrintSize.Width(), aPageSize.Width()); else - aFract = Fraction(rInfo.maPrintSize.Height(), aPageSize.Height()); + aFract = boost::rational<long>(rInfo.maPrintSize.Height(), aPageSize.Height()); aMap.SetScaleX(aFract); aMap.SetScaleY(aFract); @@ -2013,8 +2013,8 @@ private: } MapMode aMap (rInfo.maMap); - aMap.SetScaleX( Fraction( aPageSize_2.Width(), rInfo.maPageSize.Width() ) ); - aMap.SetScaleY( Fraction( aPageSize_2.Height(), rInfo.maPageSize.Height() ) ); + aMap.SetScaleX( boost::rational<long>( aPageSize_2.Width(), rInfo.maPageSize.Width() ) ); + aMap.SetScaleY( boost::rational<long>( aPageSize_2.Height(), rInfo.maPageSize.Height() ) ); // calculate adjusted print size const Size aAdjustedPrintSize (OutputDevice::LogicToLogic( diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 723a6d814ed7..a5d7527c4c00 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -453,8 +453,8 @@ void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize) aSize.Height() -= (aBorder.Top() + aBorder.Bottom()); Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM ); SfxViewShell::SetZoomFactor( - Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ), - Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) ); + boost::rational<long>( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ), + boost::rational<long>( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) ); } mpImpl->ResizePixel(rOrigin, rSize, false); @@ -735,8 +735,8 @@ void ViewShellBase::Deactivate (bool bIsMDIActivate) } void ViewShellBase::SetZoomFactor ( - const Fraction &rZoomX, - const Fraction &rZoomY) + const boost::rational<long>& rZoomX, + const boost::rational<long>& rZoomY) { SfxViewShell::SetZoomFactor (rZoomX, rZoomY); // Forward call to main sub shell. diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 484bf2fda768..588cc5088b31 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -500,7 +500,7 @@ SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, bool bIsFirst) // ... and also set DefTab at the ruler pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // new - Fraction aUIScale(pWin->GetMapMode().GetScaleX()); + boost::rational<long> aUIScale(pWin->GetMapMode().GetScaleX()); aUIScale *= GetDoc()->GetUIScale(); pRuler->SetZoom(aUIScale); @@ -529,7 +529,7 @@ SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin) pRuler->SetUnit( FieldUnit( nMetric ) ); - Fraction aUIScale(pWin->GetMapMode().GetScaleY()); + boost::rational<long> aUIScale(pWin->GetMapMode().GetScaleY()); aUIScale *= GetDoc()->GetUIScale(); pRuler->SetZoom(aUIScale); diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx index 95b19f3f582c..e76fae8a5676 100644 --- a/sd/source/ui/view/drviews5.cxx +++ b/sd/source/ui/view/drviews5.cxx @@ -440,7 +440,7 @@ void DrawViewShell::Paint(const Rectangle& rRect, ::sd::Window* pWin) /** * adjust zoom factor for InPlace */ -void DrawViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY) +void DrawViewShell::SetZoomFactor(const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY) { ViewShell::SetZoomFactor(rZoomX, rZoomY); mbZoomOnPage = false; diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index 53c73ed65f6e..741bfe06a2a3 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -644,9 +644,9 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) { Point aPos = GetActiveWindow()->PixelToLogic(maMousePos); pPageView->LogicToPagePos(aPos); - Fraction aUIScale(GetDoc()->GetUIScale()); - aPos.X() = Fraction(aPos.X()) / aUIScale; - aPos.Y() = Fraction(aPos.Y()) / aUIScale; + boost::rational<long> aUIScale(GetDoc()->GetUIScale()); + aPos.X() = boost::rational_cast<long>(aPos.X() / aUIScale); + aPos.Y() = boost::rational_cast<long>(aPos.Y() / aUIScale); // position- and size items if ( mpDrawView->IsAction() ) @@ -660,12 +660,12 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) { pPageView->LogicToPagePos(aRect); aPos = aRect.TopLeft(); - aPos.X() = Fraction(aPos.X()) / aUIScale; - aPos.Y() = Fraction(aPos.Y()) / aUIScale; + aPos.X() = boost::rational_cast<long>(aPos.X() / aUIScale); + aPos.Y() = boost::rational_cast<long>(aPos.Y() / aUIScale); rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) ); Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); - aSize.Height() = Fraction(aSize.Height()) / aUIScale; - aSize.Width() = Fraction(aSize.Width()) / aUIScale; + aSize.Height() = boost::rational_cast<long>(aSize.Height() / aUIScale); + aSize.Width() = boost::rational_cast<long>(aSize.Width() / aUIScale); rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) ); } } @@ -678,13 +678,13 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) // Show the position of the selected shape(s) Point aShapePosition (aRect.TopLeft()); - aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale; - aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale; + aShapePosition.X() = boost::rational_cast<long>(aShapePosition.X() / aUIScale); + aShapePosition.Y() = boost::rational_cast<long>(aShapePosition.Y() / aUIScale); rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition)); Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); - aSize.Height() = Fraction(aSize.Height()) / aUIScale; - aSize.Width() = Fraction(aSize.Width()) / aUIScale; + aSize.Height() = boost::rational_cast<long>(aSize.Height() / aUIScale); + aSize.Width() = boost::rational_cast<long>(aSize.Width() / aUIScale); rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) ); } else diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx index 8ce1f57dad2b..470866dffd38 100644 --- a/sd/source/ui/view/frmview.cxx +++ b/sd/source/ui/view/frmview.cxx @@ -202,7 +202,7 @@ FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULK * maVisibleLayers.SetAll(); maPrintableLayers.SetAll(); SetGridCoarse( Size( 1000, 1000 ) ); - SetSnapGridWidth(Fraction(1000, 1), Fraction(1000, 1)); + SetSnapGridWidth(boost::rational<long>(1000, 1), boost::rational<long>(1000, 1)); SetActiveLayer( SD_RESSTR(STR_LAYER_LAYOUT) ); mbNoColors = true; mbNoAttribs = false; @@ -302,8 +302,8 @@ void FrameView::Update(SdOptions* pOptions) SetGridCoarse( Size( pOptions->GetFldDrawX(), pOptions->GetFldDrawY() ) ); SetGridFine( Size( pOptions->GetFldDivisionX(), pOptions->GetFldDivisionY() ) ); - Fraction aFractX(pOptions->GetFldDrawX(), pOptions->GetFldDrawX() / ( pOptions->GetFldDivisionX() ? pOptions->GetFldDivisionX() : 1 )); - Fraction aFractY(pOptions->GetFldDrawY(), pOptions->GetFldDrawY() / ( pOptions->GetFldDivisionY() ? pOptions->GetFldDivisionY() : 1 )); + boost::rational<long> aFractX(pOptions->GetFldDrawX(), pOptions->GetFldDrawX() / ( pOptions->GetFldDivisionX() ? pOptions->GetFldDivisionX() : 1 )); + boost::rational<long> aFractY(pOptions->GetFldDrawY(), pOptions->GetFldDrawY() / ( pOptions->GetFldDivisionY() ? pOptions->GetFldDivisionY() : 1 )); SetSnapGridWidth(aFractX, aFractY); SetQuickEdit(pOptions->IsQuickEdit()); @@ -464,10 +464,10 @@ void FrameView::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com: aUserData.addValue( sUNO_View_GridCoarseHeight, makeAny( (sal_Int32)GetGridCoarse().Height() ) ); aUserData.addValue( sUNO_View_GridFineWidth, makeAny( (sal_Int32)GetGridFine().Width() ) ); aUserData.addValue( sUNO_View_GridFineHeight, makeAny( (sal_Int32)GetGridFine().Height() ) ); - aUserData.addValue( sUNO_View_GridSnapWidthXNumerator, makeAny( (sal_Int32)GetSnapGridWidthX().GetNumerator() ) ); - aUserData.addValue( sUNO_View_GridSnapWidthXDenominator, makeAny( (sal_Int32)GetSnapGridWidthX().GetDenominator() ) ); - aUserData.addValue( sUNO_View_GridSnapWidthYNumerator, makeAny( (sal_Int32)GetSnapGridWidthY().GetNumerator() ) ); - aUserData.addValue( sUNO_View_GridSnapWidthYDenominator, makeAny( (sal_Int32)GetSnapGridWidthY().GetDenominator() ) ); + aUserData.addValue( sUNO_View_GridSnapWidthXNumerator, makeAny( (sal_Int32)GetSnapGridWidthX().numerator() ) ); + aUserData.addValue( sUNO_View_GridSnapWidthXDenominator, makeAny( (sal_Int32)GetSnapGridWidthX().denominator() ) ); + aUserData.addValue( sUNO_View_GridSnapWidthYNumerator, makeAny( (sal_Int32)GetSnapGridWidthY().numerator() ) ); + aUserData.addValue( sUNO_View_GridSnapWidthYDenominator, makeAny( (sal_Int32)GetSnapGridWidthY().denominator() ) ); aUserData.addValue( sUNO_View_IsAngleSnapEnabled, makeAny( IsAngleSnapEnabled() ) ); aUserData.addValue( sUNO_View_SnapAngle, makeAny( (sal_Int32)GetSnapAngle() ) ); @@ -561,11 +561,11 @@ void FrameView::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < : sal_Int16 nInt16 = 0; OUString aString; - sal_Int32 aSnapGridWidthXNum = GetSnapGridWidthX().GetNumerator(); - sal_Int32 aSnapGridWidthXDom = GetSnapGridWidthX().GetDenominator(); + sal_Int32 aSnapGridWidthXNum = GetSnapGridWidthX().numerator(); + sal_Int32 aSnapGridWidthXDom = GetSnapGridWidthX().denominator(); - sal_Int32 aSnapGridWidthYNum = GetSnapGridWidthY().GetNumerator(); - sal_Int32 aSnapGridWidthYDom = GetSnapGridWidthY().GetDenominator(); + sal_Int32 aSnapGridWidthYNum = GetSnapGridWidthY().numerator(); + sal_Int32 aSnapGridWidthYDom = GetSnapGridWidthY().denominator(); const com::sun::star::beans::PropertyValue *pValue = rSequence.getConstArray(); for (sal_Int16 i = 0 ; i < nLength; i++, pValue++ ) @@ -916,8 +916,8 @@ void FrameView::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < : default: SetViewShEditModeOnLoad(EM_PAGE); break; } - const Fraction aSnapGridWidthX( aSnapGridWidthXNum, aSnapGridWidthXDom ); - const Fraction aSnapGridWidthY( aSnapGridWidthYNum, aSnapGridWidthYDom ); + const boost::rational<long> aSnapGridWidthX( aSnapGridWidthXNum, aSnapGridWidthXDom ); + const boost::rational<long> aSnapGridWidthY( aSnapGridWidthYNum, aSnapGridWidthYDom ); SetSnapGridWidth( aSnapGridWidthX, aSnapGridWidthY ); } diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 3a4fc537f2c6..3a25f39be01d 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -876,8 +876,8 @@ void View::SetMarkedOriginalSize() Rectangle aDrawRect( pObj->GetLogicRect() ); pUndoGroup->AddAction( mrDoc.GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); - pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ), - Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) ); + pObj->Resize( aDrawRect.TopLeft(), boost::rational<long>( aOleSize.Width(), aDrawRect.GetWidth() ), + boost::rational<long>( aOleSize.Height(), aDrawRect.GetHeight() ) ); } } } @@ -938,10 +938,10 @@ void View::DoConnect(SdrOle2Obj* pObj) MapMode aMapMode( mrDoc.GetScaleUnit() ); Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode ); - Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // compatible to SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); + boost::rational<long> aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() ); + boost::rational<long> aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() ); + rational_ReduceInaccurate(aScaleWidth, 10); // compatible to SdrOle2Obj + rational_ReduceInaccurate(aScaleHeight, 10); pSdClient->SetSizeScale(aScaleWidth, aScaleHeight); // visible area is only changed in-place! diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index c620601d1d0f..3524a77565d2 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -703,8 +703,8 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, Rectangle aObjRect( pNewObj->GetCurrentBoundRect() ); Size aObjSize( aObjRect.GetSize() ); - Fraction aScaleWidth( aPickObjSize.Width(), aObjSize.Width() ); - Fraction aScaleHeight( aPickObjSize.Height(), aObjSize.Height() ); + boost::rational<long> aScaleWidth( aPickObjSize.Width(), aObjSize.Width() ); + boost::rational<long> aScaleHeight( aPickObjSize.Height(), aObjSize.Height() ); pNewObj->NbcResize( aObjRect.TopLeft(), aScaleWidth, aScaleHeight ); aVec -= aObjRect.TopLeft(); diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index 4e02e56ecfee..a1cb0f2c6740 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -227,8 +227,8 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, Rectangle aObjRect(pNewGrafObj->GetCurrentBoundRect()); Size aObjSize(aObjRect.GetSize()); - Fraction aScaleWidth(aPickObjSize.Width(), aObjSize.Width()); - Fraction aScaleHeight(aPickObjSize.Height(), aObjSize.Height()); + boost::rational<long> aScaleWidth(aPickObjSize.Width(), aObjSize.Width()); + boost::rational<long> aScaleHeight(aPickObjSize.Height(), aObjSize.Height()); pNewGrafObj->NbcResize(aObjRect.TopLeft(), aScaleWidth, aScaleHeight); Point aVec = aPickObjRect.TopLeft() - aObjRect.TopLeft(); diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx index b9af542b4354..6b83b61c829c 100644 --- a/sd/source/ui/view/sdwindow.cxx +++ b/sd/source/ui/view/sdwindow.cxx @@ -179,10 +179,10 @@ void Window::SetMaxZoom (long int nMax) long Window::GetZoom (void) const { - if( GetMapMode().GetScaleX().GetDenominator() ) + if( GetMapMode().GetScaleX().denominator() ) { - return GetMapMode().GetScaleX().GetNumerator() * 100L - / GetMapMode().GetScaleX().GetDenominator(); + return GetMapMode().GetScaleX().numerator() * 100L + / GetMapMode().GetScaleX().denominator(); } else { @@ -318,8 +318,8 @@ long Window::SetZoomFactor(long nZoom) // Set the zoom factor at the window's map mode. MapMode aMap(GetMapMode()); - aMap.SetScaleX(Fraction(nZoom, 100)); - aMap.SetScaleY(Fraction(nZoom, 100)); + aMap.SetScaleX(boost::rational<long>(nZoom, 100)); + aMap.SetScaleY(boost::rational<long>(nZoom, 100)); SetMapMode(aMap); // invalidate previous size - it was relative to the old scaling diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 7401fdffadc5..a7ba45ecbe6b 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -332,7 +332,7 @@ void ViewShell::Scroll(long nScrollX, long nScrollY) */ void ViewShell::SetZoom(long nZoom) { - Fraction aUIScale(nZoom, 100); + boost::rational<long> aUIScale(nZoom, 100); aUIScale *= GetDoc()->GetUIScale(); if (mpHorizontalRuler.get() != NULL) @@ -399,7 +399,7 @@ void ViewShell::ScrollCenter() void ViewShell::SetZoomRect(const Rectangle& rZoomRect) { long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect); - Fraction aUIScale(nZoom, 100); + boost::rational<long> aUIScale(nZoom, 100); aUIScale *= GetDoc()->GetUIScale(); Point aPos = GetActiveWindow()->GetWinViewPos(); @@ -651,9 +651,9 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, /** * Set zoom factor for InPlace */ -void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&) +void ViewShell::SetZoomFactor(const boost::rational<long>& rZoomX, const boost::rational<long>&) { - long nZoom = (long)((double) rZoomX * 100); + long nZoom = (long)(boost::rational_cast<double>(rZoomX) * 100); SetZoom(nZoom); } @@ -870,10 +870,10 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example aObjAreaSize = aDrawSize; - Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); + boost::rational<long> aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() ); + boost::rational<long> aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() ); + rational_ReduceInaccurate(aScaleWidth, 10); // kompatibel zum SdrOle2Obj + rational_ReduceInaccurate(aScaleHeight, 10); pSdClient->SetSizeScale(aScaleWidth, aScaleHeight); // visible section is only changed in-place! |