diff options
-rw-r--r-- | include/svtools/ruler.hxx | 17 | ||||
-rw-r--r-- | svtools/source/control/ruler.cxx | 26 | ||||
-rw-r--r-- | svx/source/dialog/svxruler.cxx | 14 |
3 files changed, 32 insertions, 25 deletions
diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx index 0db49dc6561e..f7708ba76b36 100644 --- a/include/svtools/ruler.hxx +++ b/include/svtools/ruler.hxx @@ -484,7 +484,14 @@ enum class RulerDragSize { #define RULER_MOUSE_MARGINWIDTH 3 -#define RULER_MARGIN_SIZEABLE ((sal_uInt16)0x0001) +enum class RulerMarginStyle { + NONE = 0x0000, + Sizeable = 0x0001, + Invisible = 0x0002 +}; +namespace o3tl { + template<> struct typed_flags<RulerMarginStyle> : is_typed_flags<RulerMarginStyle, 0x0003> {}; +} enum class RulerBorderStyle { @@ -764,11 +771,11 @@ public: void SetNullOffset( long nPos ); long GetNullOffset() const; - void SetMargin1() { SetMargin1( 0, RULER_STYLE_INVISIBLE ); } - void SetMargin1( long nPos, sal_uInt16 nMarginStyle = RULER_MARGIN_SIZEABLE ); + void SetMargin1() { SetMargin1( 0, RulerMarginStyle::Invisible ); } + void SetMargin1( long nPos, RulerMarginStyle nMarginStyle = RulerMarginStyle::Sizeable ); long GetMargin1() const; - void SetMargin2() { SetMargin2( 0, RULER_STYLE_INVISIBLE ); } - void SetMargin2( long nPos, sal_uInt16 nMarginStyle = RULER_MARGIN_SIZEABLE ); + void SetMargin2() { SetMargin2( 0, RulerMarginStyle::Invisible ); } + void SetMargin2( long nPos, RulerMarginStyle nMarginStyle = RulerMarginStyle::Sizeable ); long GetMargin2() const; void SetLeftFrameMargin( long nPos ); diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index e97a0980435d..5022bc3c6c1b 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -81,8 +81,8 @@ private: long nMargin2; long nLeftFrameMargin; long nRightFrameMargin; - sal_uInt16 nMargin1Style; - sal_uInt16 nMargin2Style; + RulerMarginStyle nMargin1Style; + RulerMarginStyle nMargin2Style; bool bAutoPageWidth; bool bTextRTL; @@ -104,8 +104,8 @@ ImplRulerData::ImplRulerData() : nMargin2 (0), nLeftFrameMargin (0), nRightFrameMargin (0), - nMargin1Style (0), - nMargin2Style (0), + nMargin1Style (RulerMarginStyle::NONE), + nMargin2Style (RulerMarginStyle::NONE), bAutoPageWidth (true), // Page width == EditWin width bTextRTL (false) { @@ -603,7 +603,7 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM if (nStart > nMin) { // 0 is only painted when Margin1 is not equal to zero - if ((mpData->nMargin1Style & RULER_STYLE_INVISIBLE) || (mpData->nMargin1 != 0)) + if ((mpData->nMargin1Style & RulerMarginStyle::Invisible) || (mpData->nMargin1 != 0)) { aNumString = "0"; ImplVDrawText(rRenderContext, nStart, nCenter, aNumString); @@ -1200,7 +1200,7 @@ void Ruler::ImplFormat(vcl::RenderContext& rRenderContext) maVirDev->Erase(); // calculate margins - if (!(mpData->nMargin1Style & RULER_STYLE_INVISIBLE)) + if (!(mpData->nMargin1Style & RulerMarginStyle::Invisible)) { nM1 = mpData->nMargin1 + nNullVirOff; if (mpData->bAutoPageWidth) @@ -1217,7 +1217,7 @@ void Ruler::ImplFormat(vcl::RenderContext& rRenderContext) nM1 = nVirLeft-1; nP1 = nM1; } - if (!(mpData->nMargin2Style & RULER_STYLE_INVISIBLE)) + if (!(mpData->nMargin2Style & RulerMarginStyle::Invisible)) { nM2 = mpData->nMargin2 + nNullVirOff; if (mpData->bAutoPageWidth) @@ -1699,7 +1699,7 @@ bool Ruler::ImplHitTest( const Point& rPos, RulerSelection* pHitTest, // Margins int nMarginTolerance = pHitTest->bExpandTest ? nBorderTolerance : RULER_MOUSE_MARGINWIDTH; - if ( (mpData->nMargin1Style & (RULER_MARGIN_SIZEABLE | RULER_STYLE_INVISIBLE)) == RULER_MARGIN_SIZEABLE ) + if ( (mpData->nMargin1Style & (RulerMarginStyle::Sizeable | RulerMarginStyle::Invisible)) == RulerMarginStyle::Sizeable ) { n1 = mpData->nMargin1; if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) ) @@ -1709,7 +1709,7 @@ bool Ruler::ImplHitTest( const Point& rPos, RulerSelection* pHitTest, return true; } } - if ( (mpData->nMargin2Style & (RULER_MARGIN_SIZEABLE | RULER_STYLE_INVISIBLE)) == RULER_MARGIN_SIZEABLE ) + if ( (mpData->nMargin2Style & (RulerMarginStyle::Sizeable | RulerMarginStyle::Invisible)) == RulerMarginStyle::Sizeable ) { n1 = mpData->nMargin2; if ( (nX >= n1 - nMarginTolerance) && (nX <= n1 + nMarginTolerance) ) @@ -2545,7 +2545,7 @@ void Ruler::SetRightFrameMargin( long nPos ) } } -void Ruler::SetMargin1( long nPos, sal_uInt16 nMarginStyle ) +void Ruler::SetMargin1( long nPos, RulerMarginStyle nMarginStyle ) { if ( (mpData->nMargin1 != nPos) || (mpData->nMargin1Style != nMarginStyle) ) { @@ -2555,11 +2555,11 @@ void Ruler::SetMargin1( long nPos, sal_uInt16 nMarginStyle ) } } -void Ruler::SetMargin2( long nPos, sal_uInt16 nMarginStyle ) +void Ruler::SetMargin2( long nPos, RulerMarginStyle nMarginStyle ) { DBG_ASSERT( (nPos >= mpData->nMargin1) || - (mpData->nMargin1Style & RULER_STYLE_INVISIBLE) || - (mpData->nMargin2Style & RULER_STYLE_INVISIBLE), + (mpData->nMargin1Style & RulerMarginStyle::Invisible) || + (mpData->nMargin2Style & RulerMarginStyle::Invisible), "Ruler::SetMargin2() - Margin2 < Margin1" ); if ( (mpData->nMargin2 != nPos) || (mpData->nMargin2Style != nMarginStyle) ) diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx index 5994360f2b3d..91bf4339236f 100644 --- a/svx/source/dialog/svxruler.cxx +++ b/svx/source/dialog/svxruler.cxx @@ -495,10 +495,10 @@ inline sal_uInt16 SvxRuler::GetObjectBordersOff(sal_uInt16 nIdx) const */ void SvxRuler::UpdateFrame() { - const sal_uInt16 nMarginStyle = + const RulerMarginStyle nMarginStyle = ( mxRulerImpl->aProtectItem.IsSizeProtected() || mxRulerImpl->aProtectItem.IsPosProtected() ) ? - 0 : RULER_MARGIN_SIZEABLE; + RulerMarginStyle::NONE : RulerMarginStyle::Sizeable; if(mxLRSpaceItem.get() && mxPagePosItem.get()) { @@ -1398,8 +1398,8 @@ void SvxRuler::AdjustMargin1(long lInputDiff) mxRulerImpl->aProtectItem.IsSizeProtected() || mxRulerImpl->aProtectItem.IsPosProtected(); - const sal_uInt16 nMarginStyle = - bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE; + const RulerMarginStyle nMarginStyle = + bProtectColumns ? RulerMarginStyle::NONE : RulerMarginStyle::Sizeable; if(!bAppSetNullOffset) { @@ -1527,7 +1527,7 @@ void SvxRuler::DragMargin2() mxRulerImpl->aProtectItem.IsSizeProtected() || mxRulerImpl->aProtectItem.IsPosProtected(); - const sal_uInt16 nMarginStyle = bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE; + const RulerMarginStyle nMarginStyle = bProtectColumns ? RulerMarginStyle::NONE : RulerMarginStyle::Sizeable; SetMargin2( aDragPosition, nMarginStyle ); @@ -1882,7 +1882,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mxRulerImpl->lLastLMargin)) //otherwise the right borders are moved for(int i = mxColumnItem->Count() - 1; i > nIndex; --i) mpBorders[i].nPos += lDiff; - SetMargin2( GetMargin2() + lDiff, 0 ); + SetMargin2( GetMargin2() + lDiff, RulerMarginStyle::NONE ); } } } @@ -1918,7 +1918,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mxRulerImpl->lLastLMargin)) { mpBorders[i].nPos += lDiff; } - SetMargin2( GetMargin2() + lDiff, 0 ); + SetMargin2( GetMargin2() + lDiff, RulerMarginStyle::NONE ); } } else |