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 /include | |
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 'include')
48 files changed, 145 insertions, 268 deletions
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 02ee8f19bba4..74f9236119d4 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -84,7 +84,7 @@ public: private: sal_Int32 mnXmlNamespace; sal_Int32 mnSeriesCount; - Fraction maFraction; + boost::rational<long> maFraction; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxChartModel; com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram; com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > mxNewDiagram; diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index 995ef356bae7..250729b243a3 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -66,7 +66,7 @@ protected: private: sal_Int32 mnXmlNamespace; - Fraction maFraction; + boost::rational<long> maFraction; MapMode maMapModeSrc, maMapModeDest; ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& ) const; diff --git a/include/sfx2/ipclient.hxx b/include/sfx2/ipclient.hxx index 10ab174bbdbd..350c7ac14944 100644 --- a/include/sfx2/ipclient.hxx +++ b/include/sfx2/ipclient.hxx @@ -34,7 +34,7 @@ class SfxInPlaceClient_Impl; class SfxViewShell; class SfxObjectShell; namespace vcl { class Window; } -class Fraction; +namespace boost { template<typename T> class rational; } @@ -74,10 +74,10 @@ public: bool SetObjArea( const Rectangle & ); Rectangle GetObjArea() const; Rectangle GetScaledObjArea() const; - void SetSizeScale( const Fraction & rScaleWidth, const Fraction & rScaleHeight ); - bool SetObjAreaAndScale( const Rectangle&, const Fraction&, const Fraction& ); - const Fraction& GetScaleWidth() const; - const Fraction& GetScaleHeight() const; + void SetSizeScale( const boost::rational<long> & rScaleWidth, const boost::rational<long> & rScaleHeight ); + bool SetObjAreaAndScale( const Rectangle&, const boost::rational<long>&, const boost::rational<long>& ); + const boost::rational<long>& GetScaleWidth() const; + const boost::rational<long>& GetScaleHeight() const; void Invalidate(); static SfxInPlaceClient* GetClient( SfxObjectShell* pDoc, const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& xObject ); sal_Int64 GetAspect() const; diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index d9d4e956e5cd..42487bcc8333 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -638,8 +638,8 @@ public: SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev, const Point & rViewPos, - const Fraction & rScaleX, - const Fraction & rScaleY, + const boost::rational<long>& rScaleX, + const boost::rational<long>& rScaleY, const JobSetup & rSetup, sal_uInt16 nAspect ); diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx index 1d043fcd2ded..9acc0e23fd85 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -43,7 +43,7 @@ class SfxProgress; class SvData; class SfxViewShell; class SystemWindow; -class Fraction; +namespace boost { template<typename T> class rational; } class Point; class Size; class SfxChildWindow; @@ -118,7 +118,7 @@ public: SfxBindings& GetBindings() { return *pBindings; } const SfxBindings& GetBindings() const { return *pBindings; } vcl::Window& GetWindow() const; - virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ); + virtual void SetZoomFactor( const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ); SfxProgress* GetProgress() const; diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 20114cfac991..827bdfd8a615 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -39,7 +39,7 @@ class SfxBaseController; class Size; -class Fraction; +namespace boost { template<typename T> class rational; } namespace vcl { class Window; } class KeyEvent; class WorkWindow; @@ -146,7 +146,7 @@ protected: virtual void InnerResizePixel( const Point &rOfs, const Size &rSize ); virtual void OuterResizePixel( const Point &rOfs, const Size &rSize ); - virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ); + virtual void SetZoomFactor( const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY ); virtual void Move(); diff --git a/include/svtools/imap.hxx b/include/svtools/imap.hxx index 951251d11bf0..37a513352778 100644 --- a/include/svtools/imap.hxx +++ b/include/svtools/imap.hxx @@ -27,7 +27,7 @@ class Point; class Rectangle; class Size; -class Fraction; +namespace boost { template<typename T> class rational; } class IMapObject; typedef ::std::vector< IMapObject* > IMapObjectList_impl; @@ -117,7 +117,7 @@ public: void SetName( const OUString& rName ) { aName = rName; } // skaliert alle Objekte der ImageMap entpr. dem uebergebenen Faktor - void Scale( const Fraction& rFractX, const Fraction& rFracY ); + void Scale( const boost::rational<long>& rFractX, const boost::rational<long>& rFracY ); // Im-/Export void Write ( SvStream& rOStm, const OUString& rBaseURL ) const; diff --git a/include/svtools/imapcirc.hxx b/include/svtools/imapcirc.hxx index 2ce4127b1bc7..fd6c164c439a 100644 --- a/include/svtools/imapcirc.hxx +++ b/include/svtools/imapcirc.hxx @@ -23,7 +23,7 @@ #include <tools/gen.hxx> #include <svtools/imapobj.hxx> -class Fraction; +namespace boost { template<typename T> class rational; } class SVT_DLLPUBLIC IMapCircleObject : public IMapObject { @@ -60,7 +60,7 @@ public: // liefert das BoundRect des Kreis-Objektes in 1/100mm virtual Rectangle GetBoundRect() const SAL_OVERRIDE; - void Scale( const Fraction& rFractX, const Fraction& rFracY ); + void Scale( const boost::rational<long>& rFractX, const boost::rational<long>& rFracY ); using IMapObject::IsEqual; bool IsEqual( const IMapCircleObject& rEqObj ); diff --git a/include/svtools/imappoly.hxx b/include/svtools/imappoly.hxx index 79ca52a0a1c7..e01b3114205b 100644 --- a/include/svtools/imappoly.hxx +++ b/include/svtools/imappoly.hxx @@ -24,7 +24,7 @@ #include <svtools/imapobj.hxx> #include <tools/poly.hxx> -class Fraction; +namespace boost { template<typename T> class rational; } class SVT_DLLPUBLIC IMapPolygonObject : public IMapObject { @@ -66,7 +66,7 @@ public: const Rectangle& GetExtraEllipse() const { return aEllipse; } void SetExtraEllipse( const Rectangle& rEllipse ); - void Scale( const Fraction& rFractX, const Fraction& rFracY ); + void Scale( const boost::rational<long>& rFractX, const boost::rational<long>& rFracY ); using IMapObject::IsEqual; bool IsEqual( const IMapPolygonObject& rEqObj ); diff --git a/include/svtools/imaprect.hxx b/include/svtools/imaprect.hxx index 17c96841a5d1..6855fb36926c 100644 --- a/include/svtools/imaprect.hxx +++ b/include/svtools/imaprect.hxx @@ -23,7 +23,7 @@ #include <svtools/imapobj.hxx> #include <tools/gen.hxx> -class Fraction; +namespace boost { template<typename T> class rational; } class SVT_DLLPUBLIC IMapRectangleObject : public IMapObject { @@ -58,7 +58,7 @@ public: // liefert das BoundRect des Rechteck-Objektes in 1/100mm virtual Rectangle GetBoundRect() const SAL_OVERRIDE { return aRect; } - void Scale( const Fraction& rFractX, const Fraction& rFracY ); + void Scale( const boost::rational<long>& rFractX, const boost::rational<long>& rFracY ); using IMapObject::IsEqual; bool IsEqual( const IMapRectangleObject& rEqObj ); diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx index 49d4e424da4b..a27a92175a5f 100644 --- a/include/svtools/ruler.hxx +++ b/include/svtools/ruler.hxx @@ -644,7 +644,7 @@ private: RulerType meDragType; MapUnit meSourceUnit; FieldUnit meUnit; - Fraction maZoom; + boost::rational<long> maZoom; bool mbCalc; bool mbFormat; bool mbDrag; @@ -745,8 +745,8 @@ public: void SetUnit( FieldUnit eNewUnit ); FieldUnit GetUnit() const { return meUnit; } - void SetZoom( const Fraction& rNewZoom ); - Fraction GetZoom() const { return maZoom; } + void SetZoom( const boost::rational<long>& rNewZoom ); + boost::rational<long> GetZoom() const { return maZoom; } void SetSourceUnit( MapUnit eNewUnit ) { meSourceUnit = eNewUnit; } MapUnit GetSourceUnit() const { return meSourceUnit; } diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx index ac7e52493ef7..c1e37963c70c 100644 --- a/include/svx/obj3d.hxx +++ b/include/svx/obj3d.hxx @@ -153,7 +153,7 @@ public: virtual void SetPage(SdrPage* pNewPage) SAL_OVERRIDE; virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE; virtual void NbcMove(const Size& rSize) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual SdrObjList* GetSubList() const SAL_OVERRIDE; // Insert 3D object into the group; transfer to other owner! diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx index 332fa2a7fa8d..b519126bea54 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -191,8 +191,8 @@ public: virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void NbcMove(const Size& rSize) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& rXFact, - const Fraction& rYFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& rXFact, + const boost::rational<long>& rYFact) SAL_OVERRIDE; virtual void RecalcSnapRect() SAL_OVERRIDE; virtual E3dScene* GetScene() const SAL_OVERRIDE; diff --git a/include/svx/sdr/properties/defaultproperties.hxx b/include/svx/sdr/properties/defaultproperties.hxx index 97fca16cb310..9e9defe1e65a 100644 --- a/include/svx/sdr/properties/defaultproperties.hxx +++ b/include/svx/sdr/properties/defaultproperties.hxx @@ -94,7 +94,7 @@ namespace sdr virtual void ForceDefaultAttributes(); // Scale the included ItemSet. - virtual void Scale(const Fraction& rScale) SAL_OVERRIDE; + virtual void Scale(const boost::rational<long>& rScale) SAL_OVERRIDE; }; } // end of namespace properties } // end of namespace sdr diff --git a/include/svx/sdr/properties/properties.hxx b/include/svx/sdr/properties/properties.hxx index 6229e45e388e..2bb32dfae246 100644 --- a/include/svx/sdr/properties/properties.hxx +++ b/include/svx/sdr/properties/properties.hxx @@ -30,7 +30,7 @@ class SdrObject; class SfxItemSet; class SfxPoolItem; class SfxStyleSheet; -class Fraction; +namespace boost { template<typename T> class rational; } class SfxItemPool; class SdrModel; @@ -146,7 +146,7 @@ namespace sdr // Scale the local ItemSet as far as it contains metric items. This needs to be // overloaded to do it for hierarchical objects like e.g. groups. - virtual void Scale(const Fraction& rScale); + virtual void Scale(const boost::rational<long>& rScale); // Move local items to a new ItemPool. This needs to be // overloaded to do it for hierarchical objects like e.g. groups. diff --git a/include/svx/svddrag.hxx b/include/svx/svddrag.hxx index fd43db2bf1d7..1a11e0c6f4bb 100644 --- a/include/svx/svddrag.hxx +++ b/include/svx/svddrag.hxx @@ -22,7 +22,7 @@ #include <tools/gen.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <svx/svxdllapi.h> // Status information for specialized object dragging. In order for the model @@ -146,8 +146,8 @@ public: bool CheckMinMoved(const Point& rPnt); long GetDX() const { return GetNow().X()-GetPrev().X(); } long GetDY() const { return GetNow().Y()-GetPrev().Y(); } - Fraction GetXFact() const; - Fraction GetYFact() const; + boost::rational<long> GetXFact() const; + boost::rational<long> GetYFact() const; SdrDragMethod* GetDragMethod() const { return pDragMethod; } void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; } diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx index 6e2fa4a87359..ad37eeee3099 100644 --- a/include/svx/svddrgmt.hxx +++ b/include/svx/svddrgmt.hxx @@ -258,8 +258,8 @@ public: class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod { protected: - Fraction aXFact; - Fraction aYFact; + boost::rational<long> aXFact; + boost::rational<long> aYFact; public: TYPEINFO_OVERRIDE(); diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx index 178282064075..12b27b84bb41 100644 --- a/include/svx/svdedtv.hxx +++ b/include/svx/svdedtv.hxx @@ -212,8 +212,8 @@ public: // waagerechte Linie hat z.B. immer eine Hoehe von 0. void SetMarkedObjRect(const Rectangle& rRect, bool bCopy=false); void MoveMarkedObj(const Size& rSiz, bool bCopy=false); - void ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false); - void ResizeMultMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, const bool bCopy, const bool bWdh, const bool bHgt); + void ResizeMarkedObj(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bCopy=false); + void ResizeMultMarkedObj(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, const bool bCopy, const bool bWdh, const bool bHgt); long GetMarkedObjRotate() const; void RotateMarkedObj(const Point& rRef, long nWink, bool bCopy=false); void MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy=false); @@ -228,7 +228,7 @@ public: void CopyMarkedObj(); void SetAllMarkedRect(const Rectangle& rRect, bool bCopy=false) { SetMarkedObjRect(rRect,bCopy); } void MoveAllMarked(const Size& rSiz, bool bCopy=false) { MoveMarkedObj (rSiz,bCopy); } - void ResizeAllMarked(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false) { ResizeMarkedObj (rRef,xFact,yFact,bCopy); } + void ResizeAllMarked(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bCopy=false) { ResizeMarkedObj (rRef,xFact,yFact,bCopy); } long GetAllMarkedRotate() const { return GetMarkedObjRotate(); } void RotateAllMarked(const Point& rRef, long nWink, bool bCopy=false) { RotateMarkedObj(rRef,nWink,bCopy); } void MirrorAllMarked(const Point& rRef1, const Point& rRef2, bool bCopy=false) { MirrorMarkedObj(rRef1,rRef2,bCopy); } diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx index e524364ed080..2ec177c4daa9 100644 --- a/include/svx/svdetc.hxx +++ b/include/svx/svdetc.hxx @@ -62,7 +62,7 @@ friend class SdrAttrObj; Color aFontColor; sal_uIntPtr nFontHeight; MapUnit eMapUnit; - Fraction aMapFraction; + boost::rational<long> aMapFraction; private: static SdrEngineDefaults& GetDefaults(); @@ -92,8 +92,8 @@ public: static void SetMapUnit(MapUnit eMap) { GetDefaults().eMapUnit=eMap; } static MapUnit GetMapUnit() { return GetDefaults().eMapUnit; } // Default MapFraction ist 1/1. - static void SetMapFraction(const Fraction& rMap) { GetDefaults().aMapFraction=rMap; } - static Fraction GetMapFraction() { return GetDefaults().aMapFraction; } + static void SetMapFraction(const boost::rational<long>& rMap) { GetDefaults().aMapFraction=rMap; } + static boost::rational<long> GetMapFraction() { return GetDefaults().aMapFraction; } // Einen Outliner mit den engineglobalen // Defaulteinstellungen auf dem Heap erzeugen. diff --git a/include/svx/svdglev.hxx b/include/svx/svdglev.hxx index 8a9e420815a2..b1576bda5047 100644 --- a/include/svx/svdglev.hxx +++ b/include/svx/svdglev.hxx @@ -78,7 +78,7 @@ public: void DeleteMarkedGluePoints(); void MoveMarkedGluePoints (const Size& rSiz, bool bCopy=false); - void ResizeMarkedGluePoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy=false); + void ResizeMarkedGluePoints(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bCopy=false); void RotateMarkedGluePoints(const Point& rRef, long nWink, bool bCopy=false); void MirrorMarkedGluePoints(const Point& rRef1, const Point& rRef2, bool bCopy=false); void MirrorMarkedGluePointsHorizontal(bool bCopy=false); diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index 0d9b03b3480a..850185edb581 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -155,12 +155,12 @@ protected: Link aIOProgressLink; OUString aTablePath; Size aMaxObjSize; // e.g. for auto-growing text - Fraction aObjUnit; // description of the coordinate units for ClipBoard, Drag&Drop, ... + boost::rational<long> aObjUnit; // description of the coordinate units for ClipBoard, Drag&Drop, ... MapUnit eObjUnit; // see above FieldUnit eUIUnit; // unit, scale (e.g. 1/1000) for the UI (status bar) is set by ImpSetUIUnit() - Fraction aUIScale; // see above + boost::rational<long> aUIScale; // see above OUString aUIUnitStr; // see above - Fraction aUIUnitFact; // see above + boost::rational<long> aUIUnitFact; // see above int nUIUnitKomma; // see above SdrLayerAdmin* pLayerAdmin; @@ -374,10 +374,10 @@ public: // with the correct sizes. MapUnit GetScaleUnit() const { return eObjUnit; } void SetScaleUnit(MapUnit eMap); - const Fraction& GetScaleFraction() const { return aObjUnit; } - void SetScaleFraction(const Fraction& rFrac); + const boost::rational<long>& GetScaleFraction() const { return aObjUnit; } + void SetScaleFraction(const boost::rational<long>& rFrac); // Setting both simultaneously performs a little better - void SetScaleUnit(MapUnit eMap, const Fraction& rFrac); + void SetScaleUnit(MapUnit eMap, const boost::rational<long>& rFrac); // maximal size e.g. for auto growing texts const Size& GetMaxObjSize() const { return aMaxObjSize; } @@ -387,12 +387,12 @@ public: void SetUIUnit(FieldUnit eUnit); FieldUnit GetUIUnit() const { return eUIUnit; } // The scale of the drawing. Default 1/1. - void SetUIScale(const Fraction& rScale); - const Fraction& GetUIScale() const { return aUIScale; } + void SetUIScale(const boost::rational<long>& rScale); + const boost::rational<long>& GetUIScale() const { return aUIScale; } // Setting both simultaneously performs a little better - void SetUIUnit(FieldUnit eUnit, const Fraction& rScale); + void SetUIUnit(FieldUnit eUnit, const boost::rational<long>& rScale); - const Fraction& GetUIUnitFact() const { return aUIUnitFact; } + const boost::rational<long>& GetUIUnitFact() const { return aUIUnitFact; } const OUString& GetUIUnitStr() const { return aUIUnitStr; } int GetUIUnitKomma() const { return nUIUnitKomma; } bool IsUIOnlyKomma() const { return bUIOnlyKomma; } @@ -400,7 +400,7 @@ public: static void TakeUnitStr(FieldUnit eUnit, OUString& rStr); void TakeMetricStr(long nVal, OUString& rStr, bool bNoUnitChars = false, sal_Int32 nNumDigits = -1) const; void TakeWinkStr(long nWink, OUString& rStr, bool bNoDegChar = false) const; - void TakePercentStr(const Fraction& rVal, OUString& rStr, bool bNoPercentChar = false) const; + void TakePercentStr(const boost::rational<long>& rVal, OUString& rStr, bool bNoPercentChar = false) const; // RecalcPageNums is ordinarily only called by the Page. bool IsPagNumsDirty() const { return bPagNumsDirty; }; diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index 169dd13b9dca..bca9283c6f93 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -188,13 +188,13 @@ public: virtual const Rectangle& GetLogicRect() const SAL_OVERRIDE; virtual void Move(const Size& rSiz) SAL_OVERRIDE; - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; + virtual void Resize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; virtual void SetSnapRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void SetLogicRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 81b176a668f5..f1dc3a3bf94c 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -672,13 +672,13 @@ public: // Objekte sollten i.d.R. nur die Nbc-Methoden ueberladen. // Nbc bedeutet: 'NoBroadcast'. virtual void NbcMove (const Size& rSiz); - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact); virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs); virtual void NbcMirror(const Point& rRef1, const Point& rRef2); virtual void NbcShear (const Point& rRef, long nWink, double tn, bool bVShear); virtual void Move (const Size& rSiz); - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true); + virtual void Resize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative = true); virtual void Rotate(const Point& rRef, long nWink, double sn, double cs); virtual void Mirror(const Point& rRef1, const Point& rRef2); virtual void Shear (const Point& rRef, long nWink, double tn, bool bVShear); diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx index e7e372866280..a10b0f7f6e1b 100644 --- a/include/svx/svdocapt.hxx +++ b/include/svx/svdocapt.hxx @@ -116,7 +116,7 @@ public: virtual Pointer GetCreatePointer() const SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcSetRelativePos(const Point& rPnt) SAL_OVERRIDE; virtual Point GetRelativePos() const SAL_OVERRIDE; diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx index 40386fdf989d..036a4bee4df4 100644 --- a/include/svx/svdocirc.hxx +++ b/include/svx/svdocirc.hxx @@ -112,7 +112,7 @@ public: virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const SAL_OVERRIDE; virtual Pointer GetCreatePointer() const SAL_OVERRIDE; virtual void NbcMove(const Size& aSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear (const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const SAL_OVERRIDE; diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx index 438c5e764188..8161ca55cf2b 100644 --- a/include/svx/svdoedge.hxx +++ b/include/svx/svdoedge.hxx @@ -264,7 +264,7 @@ public: virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void NbcMove(const Size& aSize) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRefPnt, const boost::rational<long>& aXFact, const boost::rational<long>& aYFact) SAL_OVERRIDE; // #i54102# added rotate, mirrorn and shear support virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index e60060968fae..3179369711e6 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -162,7 +162,7 @@ public: virtual sal_uInt32 GetHdlCount() const SAL_OVERRIDE; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear (const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx index 4a89e8f3a61d..4dc70df5b93d 100644 --- a/include/svx/svdogrp.hxx +++ b/include/svx/svdogrp.hxx @@ -85,7 +85,7 @@ public: virtual long GetShearAngle(bool bVertical = false) const SAL_OVERRIDE; virtual void Move(const Size& rSiz) SAL_OVERRIDE; - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; + virtual void Resize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; virtual void Rotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void Mirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; @@ -95,7 +95,7 @@ public: virtual void SetLogicRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index 5cea5fe2de8b..f0cb6a7b624c 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -117,7 +117,7 @@ public: virtual Pointer GetCreatePointer() const SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index f14646b20428..a27a35e8d0eb 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -136,7 +136,7 @@ public: SdrOle2Obj& operator=(const SdrOle2Obj& rObj); virtual void NbcMove(const Size& rSize) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE; virtual void SetGeoData(const SdrObjGeoData& rGeo) SAL_OVERRIDE; @@ -167,7 +167,7 @@ public: const OUString& aMediaType ); ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetParentXModel() const; - bool CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize ); + bool CalculateNewScaling( boost::rational<long>& aScaleWidth, boost::rational<long>& aScaleHeight, Size& aObjAreaSize ); bool AddOwnLightClient(); // handy to get the empty replacement graphic without accessing all the old stuff diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx index b9cb18f73630..f3e4a46b9004 100644 --- a/include/svx/svdopath.hxx +++ b/include/svx/svdopath.hxx @@ -114,7 +114,7 @@ public: basegfx::B2DPolyPolygon getDragPolyPolygon(const SdrDragStat& rDrag) const; virtual void NbcMove(const Size& aSize) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRefPnt, const boost::rational<long>& aXFact, const boost::rational<long>& aYFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRefPnt, long nAngle, double fSin, double fCos) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRefPnt, long nAngle, double fTan, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx index afd1d57b08b4..db40274f3496 100644 --- a/include/svx/svdorect.hxx +++ b/include/svx/svdorect.hxx @@ -105,7 +105,7 @@ public: virtual Pointer GetCreatePointer() const SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 2594a3544e3d..8b461b6c6aaa 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -241,7 +241,7 @@ public: virtual Pointer GetCreatePointer() const SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual bool BegTextEdit(SdrOutliner& rOutl) SAL_OVERRIDE; virtual void EndTextEdit(SdrOutliner& rOutl) SAL_OVERRIDE; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index a2b7b1f3e21c..94a032c2b585 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -264,7 +264,7 @@ private: Rectangle& rTextRect, Rectangle& rAnchorRect, Rectangle& rPaintRect, - Fraction& aFitXKorreg ) const; + boost::rational<long>& aFitXKorreg ) const; void ImpAutoFitText( SdrOutliner& rOutliner ) const; static void ImpAutoFitText( SdrOutliner& rOutliner, const Size& rShapeSize, bool bIsVerticalWriting ); SVX_DLLPRIVATE SdrObject* ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const; @@ -284,7 +284,7 @@ protected: SdrObject* ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed, bool bBezier, bool bNoSetAttr = false) const; SdrObject* ImpConvertAddText(SdrObject* pObj, bool bBezier) const; void ImpSetTextStyleSheetListeners(); - void ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXKorreg) const; + void ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, boost::rational<long>& rFitXKorreg) const; void ImpJustifyRect(Rectangle& rRect) const; void ImpCheckShear(); Rectangle ImpDragCalcRect(const SdrDragStat& rDrag) const; @@ -465,7 +465,7 @@ public: virtual Pointer GetCreatePointer() const SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx index 0a796da753ba..f22cb57f161f 100644 --- a/include/svx/svdouno.hxx +++ b/include/svx/svdouno.hxx @@ -80,7 +80,7 @@ public: virtual SdrUnoObj* Clone() const SAL_OVERRIDE; SdrUnoObj& operator= (const SdrUnoObj& rObj); - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcSetLayer(SdrLayerID nLayer) SAL_OVERRIDE; // SpecialDrag support diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx index 766b8070c9ec..82c311ef9c5f 100644 --- a/include/svx/svdovirt.hxx +++ b/include/svx/svdovirt.hxx @@ -101,13 +101,13 @@ public: virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const SAL_OVERRIDE; virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE; + virtual void NbcResize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact) SAL_OVERRIDE; virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; virtual void Move(const Size& rSiz) SAL_OVERRIDE; - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; + virtual void Resize(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bUnsetRelative = true) SAL_OVERRIDE; virtual void Rotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE; virtual void Mirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE; virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE; diff --git a/include/svx/svdpoev.hxx b/include/svx/svdpoev.hxx index ef73aa49b154..b0adf6d09f97 100644 --- a/include/svx/svdpoev.hxx +++ b/include/svx/svdpoev.hxx @@ -64,7 +64,7 @@ public: bool IsDeleteMarkedPointsPossible() const SAL_OVERRIDE; void MoveMarkedPoints(const Size& rSiz); - void ResizeMarkedPoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + void ResizeMarkedPoints(const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact); void RotateMarkedPoints(const Point& rRef, long nWink); // Hierbei entstehen eventuell beliebig viele neue Objekte: diff --git a/include/svx/svdsnpv.hxx b/include/svx/svdsnpv.hxx index 815656a77a39..c963d8031ad9 100644 --- a/include/svx/svdsnpv.hxx +++ b/include/svx/svdsnpv.hxx @@ -51,10 +51,10 @@ protected: class ImplHelpLineOverlay* mpHelpLineOverlay; Size aMagnSiz; - Fraction aSnapWdtX; - Fraction aSnapWdtY; + boost::rational<long> aSnapWdtX; + boost::rational<long> aSnapWdtY; - sal_uInt16 nMagnSizPix; + sal_uInt16 nMagnSizPix; long nSnapAngle; long nEliminatePolyPointLimitAngle; @@ -98,9 +98,9 @@ public: virtual void BrkAction() SAL_OVERRIDE; // f.abg.Klassen Actions z,B, Draggen abbrechen. virtual void TakeActionRect(Rectangle& rRect) const SAL_OVERRIDE; - void SetSnapGridWidth(const Fraction& rX, const Fraction& rY) { aSnapWdtX=rX; aSnapWdtY=rY; } - const Fraction& GetSnapGridWidthX() const { return aSnapWdtX; } - const Fraction& GetSnapGridWidthY() const { return aSnapWdtY; } + void SetSnapGridWidth(const boost::rational<long>& rX, const boost::rational<long>& rY) { aSnapWdtX=rX; aSnapWdtY=rY; } + const boost::rational<long>& GetSnapGridWidthX() const { return aSnapWdtX; } + const boost::rational<long>& GetSnapGridWidthY() const { return aSnapWdtY; } void SetSnapMagnetic(const Size& rSiz) { if (rSiz!=aMagnSiz) { aMagnSiz=rSiz; } } const Size& GetSnapMagnetic() const { return aMagnSiz; } diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx index b287c23816f3..d29ab1f77e9a 100644 --- a/include/svx/svdtrans.hxx +++ b/include/svx/svdtrans.hxx @@ -22,7 +22,7 @@ #include <rtl/ustring.hxx> #include <svx/svxdllapi.h> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/gen.hxx> #include <tools/poly.hxx> #include <vcl/field.hxx> @@ -55,10 +55,10 @@ inline void MovePoly(Polygon& rPoly, const Size& S) { rPoly.Move(S.Width(), inline void MovePoly(tools::PolyPolygon& rPoly, const Size& S) { rPoly.Move(S.Width(),S.Height()); } void MoveXPoly(XPolygon& rPoly, const Size& S); -SVX_DLLPUBLIC void ResizeRect(Rectangle& rRect, const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bNoJustify = false); -inline void ResizePoint(Point& rPnt, const Point& rRef, Fraction xFact, Fraction yFact); -void ResizePoly(Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact); -void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact); +SVX_DLLPUBLIC void ResizeRect(Rectangle& rRect, const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact, bool bNoJustify = false); +inline void ResizePoint(Point& rPnt, const Point& rRef, boost::rational<long> xFact, boost::rational<long> yFact); +void ResizePoly(Polygon& rPoly, const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact); +void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const boost::rational<long>& xFact, const boost::rational<long>& yFact); inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs); SVX_DLLPUBLIC void RotatePoly(Polygon& rPoly, const Point& rRef, double sn, double cs); @@ -102,12 +102,10 @@ void CrookStretchPoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rR /* Inline */ /**************************************************************************************************/ -inline void ResizePoint(Point& rPnt, const Point& rRef, Fraction xFact, Fraction yFact) +inline void ResizePoint(Point& rPnt, const Point& rRef, boost::rational<long> xFact, boost::rational<long> yFact) { - if (xFact.GetDenominator()==0) xFact=Fraction(xFact.GetNumerator(),1); // DivZero abfangen - if (yFact.GetDenominator()==0) yFact=Fraction(yFact.GetNumerator(),1); // DivZero abfangen - rPnt.X()=rRef.X()+ Round(((double)(rPnt.X()-rRef.X())*xFact.GetNumerator())/xFact.GetDenominator()); - rPnt.Y()=rRef.Y()+ Round(((double)(rPnt.Y()-rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator()); + rPnt.X()=rRef.X()+ Round(((double)(rPnt.X()-rRef.X())*xFact.numerator())/xFact.denominator()); + rPnt.Y()=rRef.Y()+ Round(((double)(rPnt.Y()-rRef.Y())*yFact.numerator())/yFact.denominator()); } inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs) @@ -221,25 +219,25 @@ SVX_DLLPUBLIC void OrthoDistance4(const Point& rPt0, Point& rPt, bool bBigOrtho) // Rechnung und Zwischenergebnis sind BigInt. SVX_DLLPUBLIC long BigMulDiv(long nVal, long nMul, long nDiv); -// Fehlerbehaftetes Kuerzen einer Fraction. +// Fehlerbehaftetes Kuerzen einer boost::rational<long>. // nDigits gibt an, wieviele signifikante Stellen in // Zaehler/Nenner mindestens erhalten bleiben sollen. -void Kuerzen(Fraction& rF, unsigned nDigits); +void Kuerzen(boost::rational<long>& rF, unsigned nDigits); class FrPair { - Fraction aX; - Fraction aY; + boost::rational<long> aX; + boost::rational<long> aY; public: FrPair() : aX(0,1),aY(0,1) {} - FrPair(const Fraction& rBoth) : aX(rBoth),aY(rBoth) {} - FrPair(const Fraction& rX, const Fraction& rY) : aX(rX),aY(rY) {} + FrPair(const boost::rational<long>& rBoth) : aX(rBoth),aY(rBoth) {} + FrPair(const boost::rational<long>& rX, const boost::rational<long>& rY) : aX(rX),aY(rY) {} FrPair(long nMul, long nDiv) : aX(nMul,nDiv),aY(nMul,nDiv) {} FrPair(long xMul, long xDiv, long yMul, long yDiv): aX(xMul,xDiv),aY(yMul,yDiv) {} - const Fraction& X() const { return aX; } - const Fraction& Y() const { return aY; } - Fraction& X() { return aX; } - Fraction& Y() { return aY; } + const boost::rational<long>& X() const { return aX; } + const boost::rational<long>& Y() const { return aY; } + boost::rational<long>& X() { return aX; } + boost::rational<long>& Y() { return aY; } }; // Fuer die Umrechnung von Masseinheiten @@ -265,7 +263,7 @@ inline bool IsInch(FieldUnit eU) { } class SVX_DLLPUBLIC SdrFormatter { - Fraction aScale; + boost::rational<long> aScale; long nMul_; long nDiv_; short nKomma_; diff --git a/include/svx/sxfiitm.hxx b/include/svx/sxfiitm.hxx index 570ebd02aa8c..6aa43ac3532d 100644 --- a/include/svx/sxfiitm.hxx +++ b/include/svx/sxfiitm.hxx @@ -20,26 +20,26 @@ #define INCLUDED_SVX_SXFIITM_HXX #include <svl/poolitem.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> /*************************************************************************/ /* FractionItem */ /*************************************************************************/ class SdrFractionItem: public SfxPoolItem { - Fraction nValue; + boost::rational<long> nValue; public: TYPEINFO_VISIBILITY( SVX_DLLPUBLIC ); SdrFractionItem(sal_uInt16 nId=0): SfxPoolItem(nId) {} - SdrFractionItem(sal_uInt16 nId, const Fraction& rVal): SfxPoolItem(nId), nValue(rVal) {} + SdrFractionItem(sal_uInt16 nId, const boost::rational<long>& rVal): SfxPoolItem(nId), nValue(rVal) {} SdrFractionItem(sal_uInt16 nId, SvStream& rIn); virtual bool operator==(const SfxPoolItem&) const SAL_OVERRIDE; virtual bool GetPresentation(SfxItemPresentation ePresentation, SfxMapUnit eCoreMetric, SfxMapUnit ePresentationMetric, OUString &rText, const IntlWrapper * = 0) const SAL_OVERRIDE; virtual SfxPoolItem* Create(SvStream&, sal_uInt16 nVer) const SAL_OVERRIDE; virtual SvStream& Store(SvStream&, sal_uInt16 nItemVers) const SAL_OVERRIDE; virtual SfxPoolItem* Clone(SfxItemPool *pPool=NULL) const SAL_OVERRIDE; - const Fraction& GetValue() const { return nValue; } - void SetValue(const Fraction& rVal) { nValue = rVal; } + const boost::rational<long>& GetValue() const { return nValue; } + void SetValue(const boost::rational<long>& rVal) { nValue = rVal; } }; diff --git a/include/svx/sxsiitm.hxx b/include/svx/sxsiitm.hxx index 29fdf624dd81..8a7625a576ad 100644 --- a/include/svx/sxsiitm.hxx +++ b/include/svx/sxsiitm.hxx @@ -24,8 +24,8 @@ class SdrScaleItem: public SdrFractionItem { public: TYPEINFO_OVERRIDE(); - SdrScaleItem(sal_uInt16 nId=0): SdrFractionItem(nId,Fraction(1,1)) {} - SdrScaleItem(sal_uInt16 nId, const Fraction& rVal): SdrFractionItem(nId,rVal) {} + SdrScaleItem(sal_uInt16 nId=0): SdrFractionItem(nId, boost::rational<long>(1,1) ) {} + SdrScaleItem(sal_uInt16 nId, const boost::rational<long>& rVal): SdrFractionItem(nId,rVal) {} SdrScaleItem(sal_uInt16 nId, SvStream& rIn): SdrFractionItem(nId,rIn) {} virtual bool GetPresentation(SfxItemPresentation ePresentation, SfxMapUnit eCoreMetric, SfxMapUnit ePresentationMetric, OUString &rText, const IntlWrapper * = 0) const SAL_OVERRIDE; virtual SfxPoolItem* Create(SvStream&, sal_uInt16 nVer) const SAL_OVERRIDE; diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx index 33d19bc67c0c..c4c1c6d7b9fe 100644 --- a/include/tools/bigint.hxx +++ b/include/tools/bigint.hxx @@ -28,8 +28,6 @@ class SvStream; #define MAX_DIGITS 8 -class Fraction; - class TOOLS_DLLPUBLIC SAL_WARN_UNUSED BigInt { private: @@ -144,8 +142,6 @@ public: TOOLS_DLLPUBLIC friend bool operator> ( const BigInt& rVal1, const BigInt& rVal2 ); friend inline bool operator<=( const BigInt& rVal1, const BigInt& rVal2 ); friend inline bool operator>=( const BigInt& rVal1, const BigInt& rVal2 ); - - friend class Fraction; }; inline BigInt::operator short() const diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx deleted file mode 100644 index 10e810ecb4ca..000000000000 --- a/include/tools/fract.hxx +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_TOOLS_FRACT_HXX -#define INCLUDED_TOOLS_FRACT_HXX - -#include <tools/toolsdllapi.h> - -class SvStream; - -class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Fraction -{ -private: - long nNumerator; - long nDenominator; - -public: - Fraction() { nNumerator = 0; nDenominator = 1; } - Fraction( const Fraction & rFrac ); - Fraction( long nNum, long nDen=1 ); - Fraction( double dVal ); - - bool IsValid() const; - - long GetNumerator() const { return nNumerator; } - long GetDenominator() const { return nDenominator; } - - operator long() const; - operator double() const; - - Fraction& operator=( const Fraction& rfrFrac ); - - Fraction& operator+=( const Fraction& rfrFrac ); - Fraction& operator-=( const Fraction& rfrFrac ); - Fraction& operator*=( const Fraction& rfrFrac ); - Fraction& operator/=( const Fraction& rfrFrac ); - - void ReduceInaccurate( unsigned nSignificantBits ); - - friend inline Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 ); - friend inline Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 ); - friend inline Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 ); - friend inline Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 ); - - TOOLS_DLLPUBLIC friend bool operator==( const Fraction& rVal1, const Fraction& rVal2 ); - friend inline bool operator!=( const Fraction& rVal1, const Fraction& rVal2 ); - TOOLS_DLLPUBLIC friend bool operator< ( const Fraction& rVal1, const Fraction& rVal2 ); - TOOLS_DLLPUBLIC friend bool operator> ( const Fraction& rVal1, const Fraction& rVal2 ); - friend inline bool operator<=( const Fraction& rVal1, const Fraction& rVal2 ); - friend inline bool operator>=( const Fraction& rVal1, const Fraction& rVal2 ); - - TOOLS_DLLPUBLIC friend SvStream& ReadFraction( SvStream& rIStream, Fraction& rFract ); - TOOLS_DLLPUBLIC friend SvStream& WriteFraction( SvStream& rOStream, const Fraction& rFract ); -}; - -inline Fraction::Fraction( const Fraction& rFrac ) -{ - nNumerator = rFrac.nNumerator; - nDenominator = rFrac.nDenominator; -} - -inline Fraction& Fraction::operator=( const Fraction& rFrac ) -{ - nNumerator = rFrac.nNumerator; - nDenominator = rFrac.nDenominator; - return *this; -} - -inline bool Fraction::IsValid() const -{ - return (nDenominator > 0); -} - -inline Fraction::operator long() const -{ - if ( nDenominator > 0 ) - return (nNumerator / nDenominator); - else - return 0; -} - -inline Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 ) -{ - Fraction aErg( rVal1 ); - aErg += rVal2; - return aErg; -} - -inline Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 ) -{ - Fraction aErg( rVal1 ); - aErg -= rVal2; - return aErg; -} - -inline Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 ) -{ - Fraction aErg( rVal1 ); - aErg *= rVal2; - return aErg; -} - -inline Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 ) -{ - Fraction aErg( rVal1 ); - aErg /= rVal2; - return aErg; -} - -inline bool operator !=( const Fraction& rVal1, const Fraction& rVal2 ) -{ - return !(rVal1 == rVal2); -} - -inline bool operator <=( const Fraction& rVal1, const Fraction& rVal2 ) -{ - return !(rVal1 > rVal2); -} - -inline bool operator >=( const Fraction& rVal1, const Fraction& rVal2 ) -{ - return !(rVal1 < rVal2); -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tools/rational.hxx b/include/tools/rational.hxx new file mode 100644 index 000000000000..0eeb1032a83c --- /dev/null +++ b/include/tools/rational.hxx @@ -0,0 +1,25 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ +#ifndef INCLUDED_TOOLS_RATIONAL_HXX +#define INCLUDED_TOOLS_RATIONAL_HXX + +#include <boost/rational.hpp> +#include <tools/toolsdllapi.h> + +class SvStream; + +TOOLS_DLLPUBLIC boost::rational<long> rational_FromDouble(double dVal); +TOOLS_DLLPUBLIC void rational_ReduceInaccurate(boost::rational<long>& rRational, unsigned nSignificantBits); +TOOLS_DLLPUBLIC SvStream& ReadFraction(SvStream& rIStream, boost::rational<long>& rRational); +TOOLS_DLLPUBLIC SvStream& WriteFraction(SvStream& rOStream, const boost::rational<long>& rRational); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index 5a80213a7550..128895fc0675 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -136,7 +136,7 @@ public: // additional Move method getting specifics how to handle MapMode( MAP_PIXEL ) void Move( long nX, long nY, long nDPIX, long nDPIY ); void Scale( double fScaleX, double fScaleY ); - void Scale( const Fraction& rScaleX, const Fraction& rScaleY ); + void Scale( const boost::rational<long>& rScaleX, const boost::rational<long>& rScaleY ); void Rotate( long nAngle10 ); void Clip( const Rectangle& ); /* get the bound rect of the contained actions diff --git a/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx index 10e06d2e9ca3..211727f39660 100644 --- a/include/vcl/mapmod.hxx +++ b/include/vcl/mapmod.hxx @@ -21,7 +21,7 @@ #define INCLUDED_VCL_MAPMOD_HXX #include <tools/gen.hxx> -#include <tools/fract.hxx> +#include <tools/rational.hxx> #include <tools/solar.h> #include <vcl/dllapi.h> #include <tools/resid.hxx> @@ -44,8 +44,8 @@ private: sal_uLong mnRefCount; MapUnit meUnit; Point maOrigin; - Fraction maScaleX; - Fraction maScaleY; + boost::rational<long> maScaleX; + boost::rational<long> maScaleY; bool mbSimple; friend SvStream& ReadImplMapMode( SvStream& rIStm, ImplMapMode& rMapMode ); @@ -75,7 +75,7 @@ public: MapMode( const MapMode& rMapMode ); MapMode( MapUnit eUnit ); MapMode( MapUnit eUnit, const Point& rLogicOrg, - const Fraction& rScaleX, const Fraction& rScaleY ); + const boost::rational<long>& rScaleX, const boost::rational<long>& rScaleY ); ~MapMode(); void SetMapUnit( MapUnit eUnit ); @@ -86,11 +86,11 @@ public: const Point& GetOrigin() const { return mpImplMapMode->maOrigin; } - void SetScaleX( const Fraction& rScaleX ); - const Fraction& GetScaleX() const + void SetScaleX( const boost::rational<long>& rScaleX ); + const boost::rational<long>& GetScaleX() const { return mpImplMapMode->maScaleX; } - void SetScaleY( const Fraction& rScaleY ); - const Fraction& GetScaleY() const + void SetScaleY( const boost::rational<long>& rScaleY ); + const boost::rational<long>& GetScaleY() const { return mpImplMapMode->maScaleY; } MapMode& operator=( const MapMode& rMapMode ); diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index 624cb2f0f31a..4886410bd2aa 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -124,7 +124,7 @@ public: bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true ); bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, - const Fraction& rScale, + const boost::rational<long>& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown = false ); diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index decc15c1c88e..14c23bdfbcff 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1009,8 +1009,8 @@ public: void SetCursor( vcl::Cursor* pCursor ); vcl::Cursor* GetCursor() const; - void SetZoom( const Fraction& rZoom ); - const Fraction& GetZoom() const; + void SetZoom( const boost::rational<long>& rZoom ); + const boost::rational<long>& GetZoom() const; bool IsZoom() const; long CalcZoom( long n ) const; |