[Libreoffice-commits] core.git: 6 commits - basctl/source include/tools sc/source svtools/source sw/source
Noel Grandin
noel at peralex.com
Tue Aug 25 00:59:04 PDT 2015
basctl/source/dlged/dlgedview.cxx | 4 -
include/tools/gen.hxx | 98 +++++++++--------------------------
sc/source/ui/cctrl/cbuttonw.cxx | 2
svtools/source/hatchwindow/ipwin.cxx | 38 ++-----------
sw/source/core/draw/dcontact.cxx | 2
sw/source/core/draw/dflyobj.cxx | 8 --
6 files changed, 39 insertions(+), 113 deletions(-)
New commits:
commit 2a0f9f08914fad8ec858d2a8d6e9d16ceddaa7e3
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 20 16:46:41 2015 +0200
simplify some declarations
Change-Id: I348e7f984e5e8b4b915d11de8182da07a6356f8d
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index e0b7ace..74e97ba 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -39,8 +39,8 @@ enum TriState { TRISTATE_FALSE, TRISTATE_TRUE, TRISTATE_INDET };
class SAL_WARN_UNUSED Pair
{
public:
- Pair();
- Pair( long nA, long nB );
+ Pair() : nA(0), nB(0) {}
+ Pair( long _nA, long _nB ) : nA(_nA), nB(_nB) {}
long A() const { return nA; }
long B() const { return nB; }
@@ -59,17 +59,6 @@ protected:
long nB;
};
-inline Pair::Pair()
-{
- nA = nB = 0;
-}
-
-inline Pair::Pair( long _nA, long _nB )
-{
- Pair::nA = _nA;
- Pair::nB = _nB;
-}
-
inline bool Pair::operator == ( const Pair& rPair ) const
{
return ((nA == rPair.nA) && (nB == rPair.nB));
@@ -85,8 +74,8 @@ inline bool Pair::operator != ( const Pair& rPair ) const
class SAL_DLLPUBLIC_EXPORT SAL_WARN_UNUSED Point : public Pair
{
public:
- Point();
- Point( long nX, long nY );
+ Point() {}
+ Point( long nX, long nY ) : Pair( nX, nY ) {}
long X() const { return nA; }
long Y() const { return nB; }
@@ -115,14 +104,6 @@ public:
void setY(long nY) { Y() = nY; }
};
-inline Point::Point()
-{
-}
-
-inline Point::Point( long nX, long nY ) : Pair( nX, nY )
-{
-}
-
inline void Point::Move( long nHorzMove, long nVertMove )
{
nA += nHorzMove;
@@ -189,8 +170,8 @@ inline std::basic_ostream<charT, traits> & operator <<(
class SAL_WARN_UNUSED Size : public Pair
{
public:
- Size();
- Size( long nWidth, long nHeight );
+ Size() {}
+ Size( long nWidth, long nHeight ) : Pair( nWidth, nHeight ) {}
long Width() const { return nA; }
long Height() const { return nB; }
@@ -204,15 +185,6 @@ public:
void setHeight(long nHeight) { Height() = nHeight; }
};
-inline Size::Size()
-{
-}
-
-inline Size::Size( long nWidth, long nHeight ) :
- Pair( nWidth, nHeight )
-{
-}
-
template< typename charT, typename traits >
inline std::basic_ostream<charT, traits> & operator <<(
std::basic_ostream<charT, traits> & stream, const Size& size )
@@ -227,8 +199,8 @@ inline std::basic_ostream<charT, traits> & operator <<(
class SAL_WARN_UNUSED Range : public Pair
{
public:
- Range();
- Range( long nMin, long nMax );
+ Range() {}
+ Range( long nMin, long nMax ) : Pair( nMin, nMax ) {}
long Min() const { return nA; }
long Max() const { return nB; }
@@ -242,14 +214,6 @@ public:
void Justify();
};
-inline Range::Range()
-{
-}
-
-inline Range::Range( long nMin, long nMax ) : Pair( nMin, nMax )
-{
-}
-
inline bool Range::IsInside( long nIs ) const
{
return ((nA <= nIs) && (nIs <= nB ));
@@ -280,9 +244,9 @@ inline std::basic_ostream<charT, traits> & operator <<(
class SAL_WARN_UNUSED Selection : public Pair
{
public:
- Selection();
- Selection( long nPos );
- Selection( long nMin, long nMax );
+ Selection() {}
+ Selection( long nPos ) : Pair( nPos, nPos ) {}
+ Selection( long nMin, long nMax ) : Pair( nMin, nMax ) {}
long Min() const { return nA; }
long Max() const { return nB; }
@@ -302,19 +266,6 @@ public:
void setMax(long nMax) { Max() = nMax; }
};
-inline Selection::Selection()
-{
-}
-
-inline Selection::Selection( long nPos ) : Pair( nPos, nPos )
-{
-}
-
-inline Selection::Selection( long nMin, long nMax ) :
- Pair( nMin, nMax )
-{
-}
-
inline bool Selection::IsInside( long nIs ) const
{
return ((nA <= nIs) && (nIs < nB ));
@@ -470,7 +421,7 @@ inline Rectangle::Rectangle( const Point& rLT, const Size& rSize )
inline bool Rectangle::IsEmpty() const
{
- return ((nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY));
+ return (nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY);
}
inline Point Rectangle::TopLeft() const
@@ -623,18 +574,18 @@ inline Rectangle Rectangle::GetIntersection( const Rectangle& rRect ) const
inline bool Rectangle::operator == ( const Rectangle& rRect ) const
{
- return ((nLeft == rRect.nLeft ) &&
- (nTop == rRect.nTop ) &&
- (nRight == rRect.nRight ) &&
- (nBottom == rRect.nBottom ));
+ return (nLeft == rRect.nLeft ) &&
+ (nTop == rRect.nTop ) &&
+ (nRight == rRect.nRight ) &&
+ (nBottom == rRect.nBottom );
}
inline bool Rectangle::operator != ( const Rectangle& rRect ) const
{
- return ((nLeft != rRect.nLeft ) ||
- (nTop != rRect.nTop ) ||
- (nRight != rRect.nRight ) ||
- (nBottom != rRect.nBottom ));
+ return (nLeft != rRect.nLeft ) ||
+ (nTop != rRect.nTop ) ||
+ (nRight != rRect.nRight ) ||
+ (nBottom != rRect.nBottom );
}
inline Rectangle& Rectangle::operator +=( const Point& rPt )
commit b3705c21e16ae693cba26630ce524bc43c28aae7
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 20 16:35:21 2015 +0200
SvResizeHelper::ValidateRect, simplify logic
Change-Id: Ie1c9891e8095172f53efc027eec9a68bde39ed1f
diff --git a/svtools/source/hatchwindow/ipwin.cxx b/svtools/source/hatchwindow/ipwin.cxx
index 62ea003..2930e95 100644
--- a/svtools/source/hatchwindow/ipwin.cxx
+++ b/svtools/source/hatchwindow/ipwin.cxx
@@ -347,73 +347,51 @@ void SvResizeHelper::ValidateRect( Rectangle & rValidate ) const
{
case 0:
if( rValidate.Top() > rValidate.Bottom() )
- {
rValidate.Top() = rValidate.Bottom();
- rValidate.Bottom() = RECT_EMPTY;
- }
if( rValidate.Left() > rValidate.Right() )
- {
rValidate.Left() = rValidate.Right();
- rValidate.Right() = RECT_EMPTY;
- }
break;
case 1:
if( rValidate.Top() > rValidate.Bottom() )
- {
rValidate.Top() = rValidate.Bottom();
- rValidate.Bottom() = RECT_EMPTY;
- }
break;
case 2:
if( rValidate.Top() > rValidate.Bottom() )
- {
rValidate.Top() = rValidate.Bottom();
- rValidate.Bottom() = RECT_EMPTY;
- }
if( rValidate.Left() > rValidate.Right() )
- rValidate.Right() = RECT_EMPTY;
+ rValidate.Right() = rValidate.Left();
break;
case 3:
if( rValidate.Left() > rValidate.Right() )
- rValidate.Right() = RECT_EMPTY;
+ rValidate.Right() = rValidate.Left();
break;
case 4:
if( rValidate.Top() > rValidate.Bottom() )
- rValidate.Bottom() = RECT_EMPTY;
+ rValidate.Bottom() = rValidate.Top();
if( rValidate.Left() > rValidate.Right() )
- rValidate.Right() = RECT_EMPTY;
+ rValidate.Right() = rValidate.Left();
break;
case 5:
if( rValidate.Top() > rValidate.Bottom() )
- rValidate.Bottom() = RECT_EMPTY;
+ rValidate.Bottom() = rValidate.Top();
break;
case 6:
if( rValidate.Top() > rValidate.Bottom() )
- rValidate.Bottom() = RECT_EMPTY;
+ rValidate.Bottom() = rValidate.Top();
if( rValidate.Left() > rValidate.Right() )
- {
rValidate.Left() = rValidate.Right();
- rValidate.Right() = RECT_EMPTY;
- }
break;
case 7:
if( rValidate.Left() > rValidate.Right() )
- {
rValidate.Left() = rValidate.Right();
- rValidate.Right() = RECT_EMPTY;
- }
break;
}
- if( rValidate.Right() == RECT_EMPTY )
- rValidate.Right() = rValidate.Left();
- if( rValidate.Bottom() == RECT_EMPTY )
- rValidate.Bottom() = rValidate.Top();
// Mindestgr"osse 5 x 5
if( rValidate.Left() + 5 > rValidate.Right() )
- rValidate.Right() = rValidate.Left() +5;
+ rValidate.Right() = rValidate.Left() + 5;
if( rValidate.Top() + 5 > rValidate.Bottom() )
- rValidate.Bottom() = rValidate.Top() +5;
+ rValidate.Bottom() = rValidate.Top() + 5;
}
/*************************************************************************
commit 3b4794132776a4fe8ad5999d14a85885e3f942b0
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 20 16:28:19 2015 +0200
remove useless comment
Change-Id: Id253acad170e3d8f7a1278a10c731c6bd1927b92
diff --git a/sc/source/ui/cctrl/cbuttonw.cxx b/sc/source/ui/cctrl/cbuttonw.cxx
index d8a95bd..47b3833 100644
--- a/sc/source/ui/cctrl/cbuttonw.cxx
+++ b/sc/source/ui/cctrl/cbuttonw.cxx
@@ -54,7 +54,7 @@ void ScDDComboBoxButton::Draw( const Point& rAt,
bool bBtnIn /* = false */ )
{
if ( rSize.Width() == 0 || rSize.Height() == 0 )
- return; // #i43092# rectangle with size 0 would have RECT_EMPTY as end position
+ return;
// save old state
bool bHadFill = pOut->IsFillColor();
commit 6234e5e005f22b2222eebb59a275db28fa951fa6
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 20 16:28:08 2015 +0200
using RECT_EMPTY here is very dodgy
lets rather use something smaller, so as not too potentially bump
into the RECT_EMPTY checks in the Rectange code
Change-Id: Ief8200763cac29e3099a2717f20c6f10cbc7d579
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 4d582bf..95f12dd 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2165,7 +2165,7 @@ SwDrawVirtObj::SwDrawVirtObj( SdrObject& _rNewObj,
// #i26791#
maAnchoredDrawObj.SetDrawObj( *this );
// #i35635# - set initial position out of sight
- NbcMove( Size( -RECT_EMPTY, -RECT_EMPTY ) );
+ NbcMove( Size( -16000, -16000 ) );
}
SwDrawVirtObj::~SwDrawVirtObj()
commit 3f02a38cfb7d2e2efe944244c9be264965481426
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 20 16:21:32 2015 +0200
simplify, IsEmpty() checks both Right and Bottom already
Change-Id: I81fa9f80593bdea5098215f71c44b35e0087a6fc
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
index 4bd0a5d..cacb081 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -148,9 +148,7 @@ SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt
// will access aOutRect directly
const Rectangle aOuterRectangle(pDlgEdObj->GetLastBoundRect());
- if(!aOuterRectangle.IsEmpty()
- && RECT_EMPTY != aOuterRectangle.Right()
- && RECT_EMPTY != aOuterRectangle.Bottom())
+ if(!aOuterRectangle.IsEmpty())
{
basegfx::B2DRange aOuterRange(
aOuterRectangle.Left(), aOuterRectangle.Top(),
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index a69ac3d..8a4b261 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -332,9 +332,7 @@ basegfx::B2DRange SwVirtFlyDrawObj::getOuterBound() const
{
const Rectangle aOuterRectangle(pFlyFrame->Frm().Pos(), pFlyFrame->Frm().SSize());
- if(!aOuterRectangle.IsEmpty()
- && RECT_EMPTY != aOuterRectangle.Right()
- && RECT_EMPTY != aOuterRectangle.Bottom())
+ if(!aOuterRectangle.IsEmpty())
{
aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Left(), aOuterRectangle.Top()));
aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Right(), aOuterRectangle.Bottom()));
@@ -358,9 +356,7 @@ basegfx::B2DRange SwVirtFlyDrawObj::getInnerBound() const
{
const Rectangle aInnerRectangle(pFlyFrame->Frm().Pos() + pFlyFrame->Prt().Pos(), pFlyFrame->Prt().SSize());
- if(!aInnerRectangle.IsEmpty()
- && RECT_EMPTY != aInnerRectangle.Right()
- && RECT_EMPTY != aInnerRectangle.Bottom())
+ if(!aInnerRectangle.IsEmpty())
{
aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Left(), aInnerRectangle.Top()));
aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Right(), aInnerRectangle.Bottom()));
commit 258643235c1d6ac21f7b53c94493625a0a6c95bc
Author: Noel Grandin <noel at peralex.com>
Date: Thu Aug 20 14:22:06 2015 +0200
add some comments to Rectangle mutation methods
Change-Id: I7e1d737fc1e7a431afd3cde74c2c974e0cbef9ef
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index bd02f23..e0b7ace 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -371,7 +371,8 @@ public:
inline Point RightCenter() const;
inline Point Center() const;
- inline void Move( long nHorzMove, long nVertMove );
+ /// Move the top and left edges by a delta, preserving width and height
+ inline void Move( long nHorzMoveDelta, long nVertMoveDelta );
inline void Transpose();
inline void SetPos( const Point& rPoint );
void SetSize( const Size& rSize );
@@ -415,8 +416,10 @@ public:
long getWidth() const { return nRight - nLeft; }
/// Returns the difference between bottom and top, assuming the range includes one end, but not the other.
long getHeight() const { return nBottom - nTop; }
- void setX( long n ) { nRight += n-nLeft; nLeft = n; }
- void setY( long n ) { nBottom += n-nTop; nTop = n; }
+ /// Set the left edge of the rectangle to x, preserving the width
+ void setX( long x ) { nLeft = x; nRight += x - nLeft; }
+ /// Set the top edge of the rectangle to y, preserving the height
+ void setY( long y ) { nTop = y; nBottom += y - nTop; }
void setWidth( long n ) { nRight = nLeft + n; }
void setHeight( long n ) { nBottom = nTop + n; }
/// Returns the string representation of the rectangle, format is "x, y, width, height".
More information about the Libreoffice-commits
mailing list