summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-03-07 11:19:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-08 06:30:49 +0000
commit9cb57a50d7eeaa1dda19d18bcb3cde7e4a7984e5 (patch)
tree790282bdd3d41f9ceda28267cb72dd119ac15230 /editeng
parentbb4cf1da125344d5ef4fe51b0f1549718a11affa (diff)
convert SvxAdjust to scoped enum
Change-Id: I0df7a5313d6d62d0c657e62ef6014a3ddbab4639 Reviewed-on: https://gerrit.libreoffice.org/34941 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/eehtml.cxx12
-rw-r--r--editeng/source/editeng/eerdll.cxx2
-rw-r--r--editeng/source/editeng/impedit2.cxx12
-rw-r--r--editeng/source/editeng/impedit3.cxx16
-rw-r--r--editeng/source/editeng/impedit4.cxx4
-rw-r--r--editeng/source/items/numitem.cxx4
-rw-r--r--editeng/source/items/paraitem.cxx25
-rw-r--r--editeng/source/outliner/outliner.cxx8
-rw-r--r--editeng/source/rtf/rtfitem.cxx8
-rw-r--r--editeng/source/uno/unonrule.cxx19
10 files changed, 53 insertions, 57 deletions
diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx
index b76fbe86b67f..965a18a1902d 100644
--- a/editeng/source/editeng/eehtml.cxx
+++ b/editeng/source/editeng/eehtml.cxx
@@ -217,7 +217,7 @@ void EditHTMLParser::NextToken( int nToken )
SfxItemSet aItems( aCurSel.Max().GetNode()->GetContentAttribs().GetItems() );
aItems.ClearItem( EE_PARA_JUST );
if ( nToken == HTML_CENTER_ON )
- aItems.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
+ aItems.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
mpEditEngine->SetParaAttribsOnly(nNode, aItems);
}
break;
@@ -698,7 +698,7 @@ void EditHTMLParser::StartPara( bool bReal )
if ( bReal )
{
const HTMLOptions& aOptions = GetOptions();
- SvxAdjust eAdjust = SVX_ADJUST_LEFT;
+ SvxAdjust eAdjust = SvxAdjust::Left;
for (const auto & aOption : aOptions)
{
switch( aOption.GetToken() )
@@ -707,13 +707,13 @@ void EditHTMLParser::StartPara( bool bReal )
{
OUString const& rTmp(aOption.GetString());
if (rTmp.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_AL_right))
- eAdjust = SVX_ADJUST_RIGHT;
+ eAdjust = SvxAdjust::Right;
else if (rTmp.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_AL_middle))
- eAdjust = SVX_ADJUST_CENTER;
+ eAdjust = SvxAdjust::Center;
else if (rTmp.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_AL_center))
- eAdjust = SVX_ADJUST_CENTER;
+ eAdjust = SvxAdjust::Center;
else
- eAdjust = SVX_ADJUST_LEFT;
+ eAdjust = SvxAdjust::Left;
}
break;
}
diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx
index 94f97607d18c..f2c298063391 100644
--- a/editeng/source/editeng/eerdll.cxx
+++ b/editeng/source/editeng/eerdll.cxx
@@ -123,7 +123,7 @@ std::vector<SfxPoolItem*>* GlobalEditData::GetDefItems()
rDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE );
rDefItems[12] = new SvxULSpaceItem( EE_PARA_ULSPACE );
rDefItems[13] = new SvxLineSpacingItem( 0, EE_PARA_SBL );
- rDefItems[14] = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST );
+ rDefItems[14] = new SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST );
rDefItems[15] = new SvxTabStopItem( 0, 0, SvxTabAdjust::Left, EE_PARA_TABS );
rDefItems[16] = new SvxJustifyMethodItem( SvxCellJustifyMethod::Auto, EE_PARA_JUST_METHOD );
rDefItems[17] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD, EE_PARA_VER_JUST );
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index ad99ca978c67..1341ec7b031f 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1993,7 +1993,7 @@ sal_uInt8 ImpEditEngine::GetRightToLeft( sal_Int32 nPara, sal_Int32 nPos, sal_In
SvxAdjust ImpEditEngine::GetJustification( sal_Int32 nPara ) const
{
- SvxAdjust eJustification = SVX_ADJUST_LEFT;
+ SvxAdjust eJustification = SvxAdjust::Left;
if ( !aStatus.IsOutliner() )
{
@@ -2001,10 +2001,10 @@ SvxAdjust ImpEditEngine::GetJustification( sal_Int32 nPara ) const
if ( IsRightToLeft( nPara ) )
{
- if ( eJustification == SVX_ADJUST_LEFT )
- eJustification = SVX_ADJUST_RIGHT;
- else if ( eJustification == SVX_ADJUST_RIGHT )
- eJustification = SVX_ADJUST_LEFT;
+ if ( eJustification == SvxAdjust::Left )
+ eJustification = SvxAdjust::Right;
+ else if ( eJustification == SvxAdjust::Right )
+ eJustification = SvxAdjust::Left;
}
}
return eJustification;
@@ -3126,7 +3126,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
break;
case PortionKind::TEXT:
{
- if ( ( eJustification != SVX_ADJUST_BLOCK ) || ( !bIgnoreExtraSpace ) )
+ if ( ( eJustification != SvxAdjust::Block ) || ( !bIgnoreExtraSpace ) )
{
nWidth += rTextPortion.GetSize().Width();
}
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 1453427b29cb..10ae5407dd51 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -525,7 +525,7 @@ void ImpEditEngine::CheckAutoPageSize()
ParaPortion* pParaPortion = GetParaPortions()[nPara];
ContentNode* pNode = pParaPortion->GetNode();
SvxAdjust eJustification = GetJustification( nPara );
- if ( eJustification != SVX_ADJUST_LEFT )
+ if ( eJustification != SvxAdjust::Left )
{
pParaPortion->MarkSelectionInvalid( 0, pNode->Len() );
CreateLines( nPara, 0 ); // 0: For AutoPageSize no TextRange!
@@ -1457,14 +1457,14 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
pLine->SetTextWidth( aTextSize.Width() );
switch ( eJustification )
{
- case SVX_ADJUST_CENTER:
+ case SvxAdjust::Center:
{
long n = ( nMaxLineWidth - aTextSize.Width() ) / 2;
n += nStartX; // Indentation is kept.
pLine->SetStartPosX( n );
}
break;
- case SVX_ADJUST_RIGHT:
+ case SvxAdjust::Right:
{
// For automatically wrapped lines, which has a blank at the end
// the blank must not be displayed!
@@ -1473,7 +1473,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
pLine->SetStartPosX( n );
}
break;
- case SVX_ADJUST_BLOCK:
+ case SvxAdjust::Block:
{
bool bDistLastLine = (GetJustifyMethod(nPara) == SvxCellJustifyMethod::Distribute);
long nRemainingSpace = nMaxLineWidth - aTextSize.Width();
@@ -1691,9 +1691,9 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uIn
long nTextXOffset = 0;
if ( nMaxLineWidth < 0 )
nMaxLineWidth = 1;
- if ( eJustification == SVX_ADJUST_CENTER )
+ if ( eJustification == SvxAdjust::Center )
nStartX = nMaxLineWidth / 2;
- else if ( eJustification == SVX_ADJUST_RIGHT )
+ else if ( eJustification == SvxAdjust::Right )
nStartX = nMaxLineWidth;
nStartX = nStartX + nTextXOffset;
@@ -1997,9 +1997,9 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
if ( !bCompressBlank && !bHangingPunctuation )
{
- // When justification is not SVX_ADJUST_LEFT, it's important to compress
+ // When justification is not SvxAdjust::Left, it's important to compress
// the trailing space even if there is enough room for the space...
- // Don't check for SVX_ADJUST_LEFT, doesn't matter to compress in this case too...
+ // Don't check for SvxAdjust::Left, doesn't matter to compress in this case too...
DBG_ASSERT( nBreakPos > pLine->GetStart(), "ImpBreakLines - BreakPos not expected!" );
if ( pNode->GetChar( nBreakPos-1 ) == ' ' )
bCompressBlank = true;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 53fe08351869..2a5f702b8732 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -769,9 +769,9 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput,
SvxAdjust eJustification = static_cast<const SvxAdjustItem&>(rItem).GetAdjust();
switch ( eJustification )
{
- case SVX_ADJUST_CENTER: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QC );
+ case SvxAdjust::Center: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QC );
break;
- case SVX_ADJUST_RIGHT: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QR );
+ case SvxAdjust::Right: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QR );
break;
default: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QL );
break;
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 54eef3e96bef..695e00f136bc 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -150,7 +150,7 @@ OUString SvxNumberType::GetNumStr( sal_uLong nNo, const css::lang::Locale& rLoca
SvxNumberFormat::SvxNumberFormat( SvxNumType eType,
SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
: SvxNumberType(eType),
- eNumAdjust(SVX_ADJUST_LEFT),
+ eNumAdjust(SvxAdjust::Left),
nInclUpperLevels(0),
nStart(1),
cBullet(SVX_DEF_BULLET),
@@ -255,7 +255,7 @@ void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverte
rStream.WriteUInt16( NUMITEM_VERSION_04 );
rStream.WriteUInt16( GetNumberingType() );
- rStream.WriteUInt16( eNumAdjust );
+ rStream.WriteUInt16( (sal_uInt16)eNumAdjust );
rStream.WriteUInt16( nInclUpperLevels );
rStream.WriteUInt16( nStart );
rStream.WriteUInt16( cBullet );
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx
index 760e77fa5ebf..2a99d6efb99f 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/style/LineSpacingMode.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/extract.hxx>
#include <unotools/syslocale.hxx>
#include <comphelper/types.hxx>
#include <tools/mapunit.hxx>
@@ -54,7 +55,7 @@ using namespace ::com::sun::star;
SfxPoolItem* SvxLineSpacingItem::CreateDefault() { return new SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT, 0);}
-SfxPoolItem* SvxAdjustItem::CreateDefault() { return new SvxAdjustItem(SVX_ADJUST_LEFT, 0);}
+SfxPoolItem* SvxAdjustItem::CreateDefault() { return new SvxAdjustItem(SvxAdjust::Left, 0);}
SfxPoolItem* SvxWidowsItem::CreateDefault() { return new SvxWidowsItem(0, 0);}
SfxPoolItem* SvxOrphansItem::CreateDefault() { return new SvxOrphansItem(0, 0);}
SfxPoolItem* SvxHyphenZoneItem::CreateDefault() { return new SvxHyphenZoneItem(false, 0);}
@@ -375,22 +376,16 @@ bool SvxAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
case MID_LAST_LINE_ADJUST :
{
sal_Int32 eVal = - 1;
- try
- {
- eVal = ::comphelper::getEnumAsINT32(rVal);
- }
- catch(...) {}
+ ::cppu::enum2int(eVal,rVal);
if(eVal >= 0 && eVal <= 4)
{
+ SvxAdjust eAdjust = (SvxAdjust)eVal;
if(MID_LAST_LINE_ADJUST == nMemberId &&
- eVal != SVX_ADJUST_LEFT &&
- eVal != SVX_ADJUST_BLOCK &&
- eVal != SVX_ADJUST_CENTER)
+ eAdjust != SvxAdjust::Left &&
+ eAdjust != SvxAdjust::Block &&
+ eAdjust != SvxAdjust::Center)
return false;
- if(eVal < (sal_uInt16)SVX_ADJUST_END)
- nMemberId == MID_PARA_ADJUST ?
- SetAdjust((SvxAdjust)eVal) :
- SetLastBlock((SvxAdjust)eVal);
+ nMemberId == MID_PARA_ADJUST ? SetAdjust(eAdjust) : SetLastBlock(eAdjust);
}
}
break;
@@ -430,13 +425,13 @@ bool SvxAdjustItem::GetPresentation
sal_uInt16 SvxAdjustItem::GetValueCount() const
{
- return SVX_ADJUST_END; // SVX_ADJUST_BLOCKLINE + 1
+ return (sal_uInt16)SvxAdjust::End; // SvxAdjust::BlockLine + 1
}
OUString SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos ) const
{
- DBG_ASSERT( nPos <= (sal_uInt16)SVX_ADJUST_BLOCKLINE, "enum overflow!" );
+ DBG_ASSERT( nPos <= (sal_uInt16)SvxAdjust::BlockLine, "enum overflow!" );
return EE_RESSTR(RID_SVXITEMS_ADJUST_BEGIN + nPos);
}
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 236e265e7d2d..ec6e5caa83b8 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -1535,8 +1535,8 @@ Rectangle Outliner::ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bRetu
{
// Adjust when centered or align right
const SvxAdjustItem& rItem = static_cast<const SvxAdjustItem&>(pEditEngine->GetParaAttrib( nPara, EE_PARA_JUST ));
- if ( ( !pEditEngine->IsRightToLeft( nPara ) && ( rItem.GetAdjust() != SVX_ADJUST_LEFT ) ) ||
- ( pEditEngine->IsRightToLeft( nPara ) && ( rItem.GetAdjust() != SVX_ADJUST_RIGHT ) ) )
+ if ( ( !pEditEngine->IsRightToLeft( nPara ) && ( rItem.GetAdjust() != SvxAdjust::Left ) ) ||
+ ( pEditEngine->IsRightToLeft( nPara ) && ( rItem.GetAdjust() != SvxAdjust::Right ) ) )
{
aTopLeft.X() = pEditEngine->GetFirstLineStartX( nPara ) - nBulletWidth;
}
@@ -1569,11 +1569,11 @@ Rectangle Outliner::ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, bool bRetu
}
// Horizontal:
- if( pFmt->GetNumAdjust() == SVX_ADJUST_RIGHT )
+ if( pFmt->GetNumAdjust() == SvxAdjust::Right )
{
aTopLeft.X() += nBulletWidth - aBulletSize.Width();
}
- else if( pFmt->GetNumAdjust() == SVX_ADJUST_CENTER )
+ else if( pFmt->GetNumAdjust() == SvxAdjust::Center )
{
aTopLeft.X() += ( nBulletWidth - aBulletSize.Width() ) / 2;
}
diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
index 1e4efcfc7524..8b8fb4330dac 100644
--- a/editeng/source/rtf/rtfitem.cxx
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -322,25 +322,25 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
case RTF_QL:
if( aPardMap.nAdjust )
{
- pSet->Put( SvxAdjustItem( SVX_ADJUST_LEFT, aPardMap.nAdjust ));
+ pSet->Put( SvxAdjustItem( SvxAdjust::Left, aPardMap.nAdjust ));
}
break;
case RTF_QR:
if( aPardMap.nAdjust )
{
- pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, aPardMap.nAdjust ));
+ pSet->Put( SvxAdjustItem( SvxAdjust::Right, aPardMap.nAdjust ));
}
break;
case RTF_QJ:
if( aPardMap.nAdjust )
{
- pSet->Put( SvxAdjustItem( SVX_ADJUST_BLOCK, aPardMap.nAdjust ));
+ pSet->Put( SvxAdjustItem( SvxAdjust::Block, aPardMap.nAdjust ));
}
break;
case RTF_QC:
if( aPardMap.nAdjust )
{
- pSet->Put( SvxAdjustItem( SVX_ADJUST_CENTER, aPardMap.nAdjust ));
+ pSet->Put( SvxAdjustItem( SvxAdjust::Center, aPardMap.nAdjust ));
}
break;
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 07a7703b2f50..e9b987799586 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -38,6 +38,7 @@
#include <editeng/unonrule.hxx>
#include <editeng/editids.hrc>
#include <editeng/numdef.hxx>
+#include <o3tl/enumarray.hxx>
#include <memory>
using ::com::sun::star::util::XCloneable;
@@ -52,16 +53,16 @@ using namespace ::com::sun::star::container;
const SvxAdjust aUnoToSvxAdjust[] =
{
- SVX_ADJUST_LEFT,
- SVX_ADJUST_RIGHT,
- SVX_ADJUST_CENTER,
- SVX_ADJUST_LEFT,
- SVX_ADJUST_LEFT,
- SVX_ADJUST_LEFT,
- SVX_ADJUST_BLOCK
+ SvxAdjust::Left,
+ SvxAdjust::Right,
+ SvxAdjust::Center,
+ SvxAdjust::Left,
+ SvxAdjust::Left,
+ SvxAdjust::Left,
+ SvxAdjust::Block
};
-const unsigned short aSvxToUnoAdjust[] =
+const o3tl::enumarray<SvxAdjust, unsigned short> aSvxToUnoAdjust
{
text::HoriOrientation::LEFT,
text::HoriOrientation::RIGHT,
@@ -79,7 +80,7 @@ SvxAdjust ConvertUnoAdjust( unsigned short nAdjust )
unsigned short ConvertUnoAdjust( SvxAdjust eAdjust )
{
- DBG_ASSERT( eAdjust <= 6, "Enum hat sich geaendert! [CL]" );
+ DBG_ASSERT( (int)eAdjust <= 6, "Enum hat sich geaendert! [CL]" );
return aSvxToUnoAdjust[eAdjust];
}