summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-12-22 02:44:13 +0100
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2016-12-23 07:47:57 +0000
commitc31bc155106c99f0358d7a1f30dfdd7eb2e80f83 (patch)
tree2fea5e98599622215018a778595c8adf689b5740 /sw/source
parented40f5bbfa89d0957bb274e2f9448f4bf265048f (diff)
use an sw::LineAlign enum class instead of undoc'ed random ints
Change-Id: Ia8bc32495f3a62226558d5f6736f8ff797681d3f Reviewed-on: https://gerrit.libreoffice.org/32319 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/inc/ascharanchoredobjectposition.hxx18
-rw-r--r--sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx16
-rw-r--r--sw/source/core/text/porfly.cxx2
-rw-r--r--sw/source/core/text/porfly.hxx9
-rw-r--r--sw/source/core/text/porlay.cxx16
5 files changed, 36 insertions, 25 deletions
diff --git a/sw/source/core/inc/ascharanchoredobjectposition.hxx b/sw/source/core/inc/ascharanchoredobjectposition.hxx
index c039e45b5c54..6771253de3f0 100644
--- a/sw/source/core/inc/ascharanchoredobjectposition.hxx
+++ b/sw/source/core/inc/ascharanchoredobjectposition.hxx
@@ -43,6 +43,17 @@ namespace o3tl {
template<> struct typed_flags<AsCharFlags> : is_typed_flags<AsCharFlags, 0x3f> {};
};
+namespace sw
+{
+ // TODO: merge/migrate this to com::sun::star::VertOrientation instead of duplicating?
+ enum class LineAlign
+ {
+ NONE,
+ TOP,
+ CENTER,
+ BOTTOM
+ };
+};
namespace objectpositioning
{
class SwAsCharAnchoredObjectPosition : public SwAnchoredObjectPosition
@@ -70,9 +81,8 @@ namespace objectpositioning
Point maAnchorPos;
SwTwips mnRelPos;
SwRect maObjBoundRect;
- // line alignment relative to line height; gives feedback for line formatting
- // 0 - no line alignment, 1 - at top, 2 - at center, 3 - at bottom
- sal_uInt8 mnLineAlignment;
+ // line alignment relative to line height
+ sw::LineAlign mnLineAlignment;
// method to cast <SwAnchoredObjectPosition::GetAnchorFrame()>
const SwTextFrame& GetAnchorTextFrame() const;
@@ -142,7 +152,7 @@ namespace objectpositioning
const SwRect& GetObjBoundRectInclSpacing() const { return maObjBoundRect;}
// determined line alignment relative to line height
- sal_uInt8 GetLineAlignment() const { return mnLineAlignment;}
+ sw::LineAlign GetLineAlignment() const { return mnLineAlignment;}
};
}
diff --git a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
index 6af121ee3fec..ffb65593fdf5 100644
--- a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
@@ -52,7 +52,7 @@ SwAsCharAnchoredObjectPosition::SwAsCharAnchoredObjectPosition(
maAnchorPos ( Point() ),
mnRelPos ( 0 ),
maObjBoundRect ( SwRect() ),
- mnLineAlignment ( 0 )
+ mnLineAlignment ( sw::LineAlign::NONE )
{}
/** destructor */
@@ -337,7 +337,7 @@ SwTwips SwAsCharAnchoredObjectPosition::GetRelPosToBase(
{
SwTwips nRelPosToBase = 0;
- mnLineAlignment = 0;
+ mnLineAlignment = sw::LineAlign::NONE;
const sal_Int16 eVertOrient = _rVert.GetVertOrient();
@@ -365,26 +365,26 @@ SwTwips SwAsCharAnchoredObjectPosition::GetRelPosToBase(
// positioning necessary. Also, the max. ascent isn't changed.
nRelPosToBase -= mnLineAscentInclObjs;
if ( eVertOrient == text::VertOrientation::LINE_CENTER )
- mnLineAlignment = 2;
+ mnLineAlignment = sw::LineAlign::CENTER;
else if ( eVertOrient == text::VertOrientation::LINE_TOP )
- mnLineAlignment = 1;
+ mnLineAlignment = sw::LineAlign::TOP;
else if ( eVertOrient == text::VertOrientation::LINE_BOTTOM )
- mnLineAlignment = 3;
+ mnLineAlignment = sw::LineAlign::BOTTOM;
}
else if ( eVertOrient == text::VertOrientation::LINE_CENTER )
{
nRelPosToBase -= ( _nObjBoundHeight + mnLineAscentInclObjs - mnLineDescentInclObjs ) / 2;
- mnLineAlignment = 2;
+ mnLineAlignment = sw::LineAlign::CENTER;
}
else if ( eVertOrient == text::VertOrientation::LINE_TOP )
{
nRelPosToBase -= mnLineAscentInclObjs;
- mnLineAlignment = 1;
+ mnLineAlignment = sw::LineAlign::TOP;
}
else if ( eVertOrient == text::VertOrientation::LINE_BOTTOM )
{
nRelPosToBase += mnLineDescentInclObjs - _nObjBoundHeight;
- mnLineAlignment = 3;
+ mnLineAlignment = sw::LineAlign::BOTTOM;
}
}
}
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 8081c78c1c98..65d5ad7a4bd5 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -255,7 +255,7 @@ void sw::DrawFlyCntPortion::Paint(const SwTextPaintInfo&) const
*/
SwFlyCntPortion::SwFlyCntPortion()
: bMax(false)
- , nAlign(0)
+ , eAlign(sw::LineAlign::NONE)
{
nLineLength = 1;
SetWhichPor(POR_FLYCNT);
diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx
index 475e4b2dde26..e000d3d2bcbd 100644
--- a/sw/source/core/text/porfly.hxx
+++ b/sw/source/core/text/porfly.hxx
@@ -45,10 +45,9 @@ public:
/// This portion represents an as-character anchored fly (shape, frame, etc.)
class SwFlyCntPortion : public SwLinePortion
{
-protected:
Point aRef; // Relatively to this point we calculate the AbsPos
- bool bMax : 1; // Line adjustment and height == line height
- sal_uInt8 nAlign : 3; // Line adjustment? No, above, middle, bottom
+ bool bMax; // Line adjustment and height == line height
+ sw::LineAlign eAlign;
virtual SdrObject* GetSdrObj(const SwTextFrame&) =0;
@@ -56,8 +55,8 @@ public:
SwFlyCntPortion();
inline const Point& GetRefPoint() const { return aRef; }
inline bool IsMax() const { return bMax; }
- inline sal_uInt8 GetAlign() const { return nAlign; }
- inline void SetAlign(sal_uInt8 nNew) { nAlign = nNew; }
+ inline sw::LineAlign GetAlign() const { return eAlign; }
+ inline void SetAlign(sw::LineAlign eNew) { eAlign = eNew; }
inline void SetMax(bool bNew) { bMax = bNew; }
void SetBase(const SwTextFrame& rFrame, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAscent, long nFlyDescent, AsCharFlags nFlags);
virtual bool Format(SwTextFormatInfo& rInf) override;
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 338506eca272..6cdf8b8f7518 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -460,15 +460,17 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
// Just care about the portion height.
Height(nPosHeight);
}
- if( pPos->IsFlyCntPortion() || ( pPos->IsMultiPortion()
+ SwFlyCntPortion* pAsFly(nullptr);
+ if(pPos->IsFlyCntPortion())
+ pAsFly = static_cast<SwFlyCntPortion*>(pPos);
+ if( pAsFly || ( pPos->IsMultiPortion()
&& static_cast<SwMultiPortion*>(pPos)->HasFlyInContent() ) )
rLine.SetFlyInCntBase();
- if( pPos->IsFlyCntPortion() &&
- static_cast<SwFlyCntPortion*>(pPos)->GetAlign() )
+ if(pAsFly && pAsFly->GetAlign() != sw::LineAlign::NONE)
{
- static_cast<SwFlyCntPortion*>(pPos)->SetMax( false );
+ pAsFly->SetMax(false);
if( !pFlyCnt || pPos->Height() > pFlyCnt->Height() )
- pFlyCnt = static_cast<SwFlyCntPortion*>(pPos);
+ pFlyCnt = pAsFly;
}
else
{
@@ -508,9 +510,9 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
pFlyCnt->SetMax( true );
if( Height() > nMaxDescent + nAscent )
{
- if( 3 == pFlyCnt->GetAlign() ) // Bottom
+ if( sw::LineAlign::BOTTOM == pFlyCnt->GetAlign() )
nAscent = Height() - nMaxDescent;
- else if( 2 == pFlyCnt->GetAlign() ) // Center
+ else if( sw::LineAlign::CENTER == pFlyCnt->GetAlign() )
nAscent = ( Height() + nAscent - nMaxDescent ) / 2;
}
pFlyCnt->SetAscent( nAscent );