summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2016-03-31 07:30:25 +0200
committerNoel Grandin <noel@peralex.com>2016-03-31 13:23:03 +0200
commit77c494de9bf9191a66fb6f90cc2148f60c25c088 (patch)
tree357a0997c1919f773ab64eeeeb28863469e7004d
parente15299b327734a622cab29bd682803a86b5a8c9e (diff)
tdf#84938 convert AS_CHAR_ constants to scoped enum
Change-Id: I8800c0ae0b028d2c4c4eb4609c44190928a2de9e
-rw-r--r--sw/source/core/inc/ascharanchoredobjectposition.hxx49
-rw-r--r--sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx20
-rw-r--r--sw/source/core/text/itrform2.cxx22
-rw-r--r--sw/source/core/text/porfly.cxx12
-rw-r--r--sw/source/core/text/porfly.hxx6
5 files changed, 57 insertions, 52 deletions
diff --git a/sw/source/core/inc/ascharanchoredobjectposition.hxx b/sw/source/core/inc/ascharanchoredobjectposition.hxx
index 207130b40663..2f802e632ee0 100644
--- a/sw/source/core/inc/ascharanchoredobjectposition.hxx
+++ b/sw/source/core/inc/ascharanchoredobjectposition.hxx
@@ -24,22 +24,27 @@
#include <sal/types.h>
#include <swtypes.hxx>
#include <swrect.hxx>
+#include <o3tl/typed_flags_set.hxx>
class SwTextFrame;
class SwFormatVertOrient;
+// flags for positioning algorithm of as-character-anchored objects
+enum class AsCharFlags {
+ None = 0x00,
+ Quick = 0x01,
+ UlSpace = 0x02,
+ Init = 0x04,
+ Rotate = 0x08,
+ Reverse = 0x10,
+ Bidi = 0x20,
+};
+namespace o3tl {
+ template<> struct typed_flags<AsCharFlags> : is_typed_flags<AsCharFlags, 0x3f> {};
+};
+
namespace objectpositioning
{
- // flags for positioning algorithm of as-character-anchored objects
- typedef sal_uInt8 AsCharFlags;
- #define AS_CHAR_NOFLAG 0
- #define AS_CHAR_QUICK 1
- #define AS_CHAR_ULSPACE 2
- #define AS_CHAR_INIT 4
- #define AS_CHAR_ROTATE 8
- #define AS_CHAR_REVERSE 16
- #define AS_CHAR_BIDI 32
-
class SwAsCharAnchoredObjectPosition : public SwAnchoredObjectPosition
{
private:
@@ -48,12 +53,12 @@ namespace objectpositioning
// of the object position.
const Point& mrProposedAnchorPos;
// flags that influences the calculation of the anchor position
- // AS_CHAR_QUICK : quick formatting - calculated position not set at object
- // AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
- // AS_CHAR_INIT : initial calculation
- // AS_CHAR_ROTATE : object is rotated by 90 degrees
- // AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
- // AS_CHAR_BIDI : object belongs to a BIDI-multi-portion
+ // AsCharFlags::Quick : quick formatting - calculated position not set at object
+ // AsCharFlags::UlSpace : consider upper/lower spacing - adjustment of anchor position
+ // AsCharFlags::Init : initial calculation
+ // AsCharFlags::Rotate : object is rotated by 90 degrees
+ // AsCharFlags::Reverse : object is reversed (rotated by 270 degrees)
+ // AsCharFlags::Bidi : object belongs to a BIDI-multi-portion
const AsCharFlags mnFlags;
// needed line values for the different alignments.
const SwTwips mnLineAscent;
@@ -99,12 +104,12 @@ namespace objectpositioning
@param _nFlags
flags that influences the calculation of the anchor position
- AS_CHAR_QUICK : quick formatting - calculated position not set at object
- AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
- AS_CHAR_INIT : initial calculation
- AS_CHAR_ROTATE : object is rotated by 90 degrees
- AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
- AS_CHAR_BIDI : object belongs to a BIDI-multi-portion
+ AsCharFlags::Quick : quick formatting - calculated position not set at object
+ AsCharFlags::UlSpace : consider upper/lower spacing - adjustment of anchor position
+ AsCharFlags::Init : initial calculation
+ AsCharFlags::Rotate : object is rotated by 90 degrees
+ AsCharFlags::Reverse : object is reversed (rotated by 270 degrees)
+ AsCharFlags::Bidi : object belongs to a BIDI-multi-portion
@param _nLineAscent, _nLineDescent, _nLineAscentInclObjs,
_nLineDescentInclObjs - needed line values for the different
diff --git a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
index 3082bb50e8e5..412b46014c45 100644
--- a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
@@ -129,7 +129,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
// consider left and upper spacing by adjusting anchor position.
// left spacing is only considered, if requested.
- if( mnFlags & AS_CHAR_ULSPACE )
+ if( mnFlags & AsCharFlags::UlSpace )
{
aAnchorPos.X() += nLRSpaceLeft;
}
@@ -146,7 +146,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
rAnchorFrame.SwitchVerticalToHorizontal( aSnapRect );
}
- if( mnFlags & AS_CHAR_ULSPACE )
+ if( mnFlags & AsCharFlags::UlSpace )
{
aAnchorPos.X() += aSnapRect.Left() - aObjBoundRect.Left();
}
@@ -161,7 +161,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
// calculate relative position to given base line.
const SwFormatVertOrient& rVert = rFrameFormat.GetVertOrient();
- const SwTwips nObjBoundHeight = ( mnFlags & AS_CHAR_ROTATE )
+ const SwTwips nObjBoundHeight = ( mnFlags & AsCharFlags::Rotate )
? aObjBoundRect.Width()
: aObjBoundRect.Height();
const SwTwips nRelPos = _GetRelPosToBase( nObjBoundHeight, rVert );
@@ -171,25 +171,25 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
// calculated relative position to base line and current maximal line ascent.
// Note: In the following line formatting the base line will be adjusted
// by the same difference.
- if( mnFlags & AS_CHAR_INIT && nRelPos < 0 && mnLineAscentInclObjs < -nRelPos )
+ if( mnFlags & AsCharFlags::Init && nRelPos < 0 && mnLineAscentInclObjs < -nRelPos )
{
- if( mnFlags & AS_CHAR_ROTATE )
+ if( mnFlags & AsCharFlags::Rotate )
aAnchorPos.X() -= mnLineAscentInclObjs + nRelPos;
else
aAnchorPos.Y() -= mnLineAscentInclObjs + nRelPos;
}
// consider BIDI-multiportion by adjusting proposed anchor position
- if( mnFlags & AS_CHAR_BIDI )
+ if( mnFlags & AsCharFlags::Bidi )
aAnchorPos.X() -= aObjBoundRect.Width();
// calculate relative position considering rotation and inside rotation
// reverse direction.
Point aRelPos;
{
- if( mnFlags & AS_CHAR_ROTATE )
+ if( mnFlags & AsCharFlags::Rotate )
{
- if( mnFlags & AS_CHAR_REVERSE )
+ if( mnFlags & AsCharFlags::Reverse )
aRelPos.X() = -nRelPos - aObjBoundRect.Width();
else
{
@@ -203,7 +203,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
if( !IsObjFly() )
{
- if( !( mnFlags & AS_CHAR_QUICK ) )
+ if( !( mnFlags & AsCharFlags::Quick ) )
{
// save calculated Y-position value for 'automatic' vertical positioning,
// in order to avoid a switch to 'manual' vertical positioning in
@@ -297,7 +297,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
"<SwAsCharAnchoredObjectPosition::CalcPosition()> - wrong anchored object." );
const SwFlyInContentFrame& rFlyInContentFrame =
static_cast<const SwFlyInContentFrame&>(GetAnchoredObj());
- if ( !(mnFlags & AS_CHAR_QUICK) &&
+ if ( !(mnFlags & AsCharFlags::Quick) &&
( aAnchorPos != rFlyInContentFrame.GetRefPoint() ||
aRelAttr != rFlyInContentFrame.GetCurrRelPos() ) )
{
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 185fd6496f25..db36bf6dabfc 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -2034,16 +2034,16 @@ void SwTextFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart,
const sal_uInt16 nTmpHeight = pCurrent->GetRealHeight();
sal_uInt16 nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height();
- objectpositioning::AsCharFlags nFlags = AS_CHAR_ULSPACE;
+ AsCharFlags nFlags = AsCharFlags::UlSpace;
if( GetMulti() )
{
aTmpInf.SetDirection( GetMulti()->GetDirection() );
if( GetMulti()->HasRotation() )
{
- nFlags |= AS_CHAR_ROTATE;
+ nFlags |= AsCharFlags::Rotate;
if( GetMulti()->IsRevers() )
{
- nFlags |= AS_CHAR_REVERSE;
+ nFlags |= AsCharFlags::Reverse;
aTmpInf.X( aTmpInf.X() - nAscent );
}
else
@@ -2052,7 +2052,7 @@ void SwTextFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart,
else
{
if ( GetMulti()->IsBidi() )
- nFlags |= AS_CHAR_BIDI;
+ nFlags |= AsCharFlags::Bidi;
aTmpInf.Y( aTmpInf.Y() + nAscent );
}
}
@@ -2140,12 +2140,12 @@ void SwTextFormatter::AlignFlyInCntBase( long nBaseLine ) const
return;
SwLinePortion *pFirst = m_pCurr->GetFirstPortion();
SwLinePortion *pPos = pFirst;
- objectpositioning::AsCharFlags nFlags = AS_CHAR_NOFLAG;
+ AsCharFlags nFlags = AsCharFlags::None;
if( GetMulti() && GetMulti()->HasRotation() )
{
- nFlags |= AS_CHAR_ROTATE;
+ nFlags |= AsCharFlags::Rotate;
if( GetMulti()->IsRevers() )
- nFlags |= AS_CHAR_REVERSE;
+ nFlags |= AsCharFlags::Reverse;
}
long nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
@@ -2523,12 +2523,12 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
nFlyAsc = nAscent;
Point aBase( GetLeftMargin() + rInf.X(), Y() + nAscent );
- objectpositioning::AsCharFlags nMode = IsQuick() ? AS_CHAR_QUICK : 0;
+ AsCharFlags nMode = IsQuick() ? AsCharFlags::Quick : AsCharFlags::None;
if( GetMulti() && GetMulti()->HasRotation() )
{
- nMode |= AS_CHAR_ROTATE;
+ nMode |= AsCharFlags::Rotate;
if( GetMulti()->IsRevers() )
- nMode |= AS_CHAR_REVERSE;
+ nMode |= AsCharFlags::Reverse;
}
Point aTmpBase( aBase );
@@ -2548,7 +2548,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
if( pRet->GetAscent() > nAscent )
{
aBase.Y() = Y() + pRet->GetAscent();
- nMode |= AS_CHAR_ULSPACE;
+ nMode |= AsCharFlags::UlSpace;
if( !rInf.IsTest() )
{
aTmpBase = aBase;
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index d48d10a9b70d..0e2788e51b16 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -262,7 +262,7 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame,
SwFlyInContentFrame *pFly, const Point &rBase,
long nLnAscent, long nLnDescent,
long nFlyAsc, long nFlyDesc,
- objectpositioning::AsCharFlags nFlags ) :
+ AsCharFlags nFlags ) :
pContact( pFly ),
bDraw( false ),
bMax( false ),
@@ -270,7 +270,7 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame,
{
OSL_ENSURE( pFly, "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!" );
nLineLength = 1;
- nFlags |= AS_CHAR_ULSPACE | AS_CHAR_INIT;
+ nFlags |= AsCharFlags::UlSpace | AsCharFlags::Init;
SetBase( rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags );
SetWhichPor( POR_FLYCNT );
}
@@ -279,7 +279,7 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame,
SwDrawContact *pDrawContact, const Point &rBase,
long nLnAscent, long nLnDescent,
long nFlyAsc, long nFlyDesc,
- objectpositioning::AsCharFlags nFlags ) :
+ AsCharFlags nFlags ) :
pContact( pDrawContact ),
bDraw( true ),
bMax( false ),
@@ -295,7 +295,7 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame,
pDrawContact->MoveObjToVisibleLayer( pDrawContact->GetMaster() );
}
nLineLength = 1;
- nFlags |= AS_CHAR_ULSPACE | AS_CHAR_INIT;
+ nFlags |= AsCharFlags::UlSpace | AsCharFlags::Init;
SetBase( rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags );
@@ -311,7 +311,7 @@ SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame,
void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
long nLnAscent, long nLnDescent,
long nFlyAsc, long nFlyDesc,
- objectpositioning::AsCharFlags nFlags )
+ AsCharFlags nFlags )
{
// Use new class to position object
// Determine drawing object
@@ -386,7 +386,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
SetAlign( aObjPositioning.GetLineAlignment() );
aRef = aObjPositioning.GetAnchorPos();
- if( nFlags & AS_CHAR_ROTATE )
+ if( nFlags & AsCharFlags::Rotate )
SvXSize( aObjPositioning.GetObjBoundRectInclSpacing().SSize() );
else
SvLSize( aObjPositioning.GetObjBoundRectInclSpacing().SSize() );
diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx
index f78765f267ba..b51efd9dc259 100644
--- a/sw/source/core/text/porfly.hxx
+++ b/sw/source/core/text/porfly.hxx
@@ -56,12 +56,12 @@ public:
SwFlyCntPortion( const SwTextFrame& rFrame, SwFlyInContentFrame *pFly,
const Point &rBase,
long nAscent, long nDescent, long nFlyAsc, long nFlyDesc,
- objectpositioning::AsCharFlags nFlags );
+ AsCharFlags nFlags );
// Use new datatype for parameter <nFlags>
SwFlyCntPortion( const SwTextFrame& rFrame, SwDrawContact *pDrawContact,
const Point &rBase,
long nAscent, long nDescent, long nFlyAsc, long nFlyDesc,
- objectpositioning::AsCharFlags nFlags );
+ AsCharFlags nFlags );
inline const Point& GetRefPoint() const { return aRef; }
inline SwFlyInContentFrame *GetFlyFrame() { return static_cast<SwFlyInContentFrame*>(pContact); }
inline const SwFlyInContentFrame *GetFlyFrame() const
@@ -78,7 +78,7 @@ public:
void SetBase( const SwTextFrame& rFrame, const Point &rBase,
long nLnAscent, long nLnDescent,
long nFlyAscent, long nFlyDescent,
- objectpositioning::AsCharFlags nFlags );
+ AsCharFlags nFlags );
sal_Int32 GetFlyCursorOfst( const sal_uInt16 nOfst, const Point &rPoint,
SwPosition *pPos, SwCursorMoveState* pCMS ) const;
virtual bool Format( SwTextFormatInfo &rInf ) override;