convert SVX_ZOOM_ENABLE constants to enum class

Change-Id: Iead354b95b832edd72eb8e881855f228fd85be70
This commit is contained in:
Noel Grandin 2015-03-23 15:20:12 +02:00
parent 5d37fa2a71
commit ecec9afe85
13 changed files with 103 additions and 97 deletions

View File

@ -207,7 +207,7 @@ SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
const SvxZoomItem& rZoomItem = static_cast<const SvxZoomItem&>(rItem);
const sal_uInt16 nZoom = rZoomItem.GetValue();
const SvxZoomType eType = rZoomItem.GetType();
const sal_uInt16 nValSet = rZoomItem.GetValueSet();
const SvxZoomEnableFlags nValSet = rZoomItem.GetValueSet();
sal_uInt16 nButtonId = 0;
switch (eType)
@ -227,13 +227,13 @@ SvxZoomDialog::SvxZoomDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet )
break;
}
if (!(SVX_ZOOM_ENABLE_100 & nValSet))
if (!(SvxZoomEnableFlags::N100 & nValSet))
m_p100Btn->Disable();
if (!(SVX_ZOOM_ENABLE_OPTIMAL & nValSet))
if (!(SvxZoomEnableFlags::OPTIMAL & nValSet))
m_pOptimalBtn->Disable();
if (!(SVX_ZOOM_ENABLE_PAGEWIDTH & nValSet))
if (!(SvxZoomEnableFlags::PAGEWIDTH & nValSet))
m_pPageWidthBtn->Disable();
if (!(SVX_ZOOM_ENABLE_WHOLEPAGE & nValSet))
if (!(SvxZoomEnableFlags::WHOLEPAGE & nValSet))
m_pWholePageBtn->Disable();
SetFactor(nZoom, nButtonId);

View File

@ -22,7 +22,7 @@
#include <svl/intitem.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/dllapi.h>
#include <o3tl/typed_flags_set.hxx>
enum class SvxZoomType
@ -34,11 +34,27 @@ enum class SvxZoomType
PAGEWIDTH_NOBORDER // GetValue() pagewidth without border
};
enum class SvxZoomEnableFlags
{
NONE = 0x0000,
N50 = 0x0001,
N75 = 0x0002,
N100 = 0x0004,
N150 = 0x0008,
N200 = 0x0010,
OPTIMAL = 0x1000,
WHOLEPAGE = 0x2000,
PAGEWIDTH = 0x4000,
ALL = 0x701F
};
namespace o3tl
{
template<> struct typed_flags<SvxZoomEnableFlags> : is_typed_flags<SvxZoomEnableFlags, 0x701f> {};
}
class SFX2_DLLPUBLIC SvxZoomItem: public SfxUInt16Item
{
sal_uInt16 nValueSet; // allowed values (see #defines below)
SvxZoomEnableFlags nValueSet; // allowed values (see #defines below)
SvxZoomType eType;
public:
@ -49,14 +65,13 @@ public:
SvxZoomItem( const SvxZoomItem& );
virtual ~SvxZoomItem();
void SetValueSet( sal_uInt16 nValues ) { nValueSet = nValues; }
sal_uInt16 GetValueSet() const { return nValueSet; }
bool IsValueAllowed( sal_uInt16 nValue ) const
{ return nValue == ( nValue & nValueSet ); }
void SetValueSet( SvxZoomEnableFlags nValues ) { nValueSet = nValues; }
SvxZoomEnableFlags GetValueSet() const { return nValueSet; }
bool IsValueAllowed( SvxZoomEnableFlags nValue ) const
{ return bool( nValue & nValueSet ); }
SvxZoomType GetType() const { return eType; }
void SetType( SvxZoomType eNewType )
{ eType = eNewType; }
void SetType( SvxZoomType eNewType ) { eType = eNewType; }
virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
virtual SfxPoolItem* Create( SvStream& rStrm, sal_uInt16 nVersion ) const SAL_OVERRIDE;
@ -68,16 +83,6 @@ public:
#define SVX_ZOOM_ENABLE_50 0x0001
#define SVX_ZOOM_ENABLE_75 0x0002
#define SVX_ZOOM_ENABLE_100 0x0004
#define SVX_ZOOM_ENABLE_150 0x0008
#define SVX_ZOOM_ENABLE_200 0x0010
#define SVX_ZOOM_ENABLE_OPTIMAL 0x1000
#define SVX_ZOOM_ENABLE_WHOLEPAGE 0x2000
#define SVX_ZOOM_ENABLE_PAGEWIDTH 0x4000
#define SVX_ZOOM_ENABLE_ALL 0x701F
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -21,13 +21,14 @@
#include <sfx2/stbitem.hxx>
#include <svx/svxdllapi.h>
#include <sfx2/zoomitem.hxx>
#include <vcl/image.hxx>
class SVX_DLLPUBLIC SvxZoomStatusBarControl : public SfxStatusBarControl
{
private:
sal_uInt16 nZoom;
sal_uInt16 nValueSet;
sal_uInt16 nZoom;
SvxZoomEnableFlags nValueSet;
public:
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,

View File

@ -942,7 +942,7 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const
aReturn.bEnabled = true;
{
SvxZoomItem aZoom(m_eZoomType,m_nZoomValue);
aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_200);
aZoom.SetValueSet(SvxZoomEnableFlags::N50|SvxZoomEnableFlags::N75|SvxZoomEnableFlags::N100|SvxZoomEnableFlags::N200);
aZoom.QueryValue(aReturn.aValue);
}
break;
@ -4275,7 +4275,7 @@ void OReportController::openZoomDialog()
::std::unique_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
// fill it
SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM );
aZoomItem.SetValueSet(SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_WHOLEPAGE|SVX_ZOOM_ENABLE_PAGEWIDTH);
aZoomItem.SetValueSet(SvxZoomEnableFlags::N100|SvxZoomEnableFlags::WHOLEPAGE|SvxZoomEnableFlags::PAGEWIDTH);
pDescriptor->Put(aZoomItem);
::std::unique_ptr<AbstractSvxZoomDialog> pDlg( pFact->CreateSvxZoomDialog(NULL, *pDescriptor.get()) );

View File

@ -829,7 +829,7 @@ void ScPreviewShell::GetState( SfxItemSet& rSet )
case SID_ATTR_ZOOM:
{
SvxZoomItem aZoom( eZoom, nZoom, nWhich );
aZoom.SetValueSet( SVX_ZOOM_ENABLE_ALL & ~SVX_ZOOM_ENABLE_OPTIMAL );
aZoom.SetValueSet( SvxZoomEnableFlags::ALL & ~SvxZoomEnableFlags::OPTIMAL );
rSet.Put( aZoom );
}
break;

View File

@ -640,16 +640,16 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
SvxZoomItem aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOM );
boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
ScMarkData& rMark = GetViewData().GetMarkData();
sal_uInt16 nBtnFlags = SVX_ZOOM_ENABLE_50
| SVX_ZOOM_ENABLE_75
| SVX_ZOOM_ENABLE_100
| SVX_ZOOM_ENABLE_150
| SVX_ZOOM_ENABLE_200
| SVX_ZOOM_ENABLE_WHOLEPAGE
| SVX_ZOOM_ENABLE_PAGEWIDTH;
SvxZoomEnableFlags nBtnFlags = SvxZoomEnableFlags::N50
| SvxZoomEnableFlags::N75
| SvxZoomEnableFlags::N100
| SvxZoomEnableFlags::N150
| SvxZoomEnableFlags::N200
| SvxZoomEnableFlags::WHOLEPAGE
| SvxZoomEnableFlags::PAGEWIDTH;
if ( rMark.IsMarked() || rMark.IsMultiMarked() )
nBtnFlags = nBtnFlags | SVX_ZOOM_ENABLE_OPTIMAL;
nBtnFlags = nBtnFlags | SvxZoomEnableFlags::OPTIMAL;
aZoomItem.SetValueSet( nBtnFlags );
aSet.Put( aZoomItem );

View File

@ -72,7 +72,7 @@ void FuScale::DoExecute( SfxRequest& rReq )
{
SfxItemSet aNewAttr( mpDoc->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
boost::scoped_ptr<SvxZoomItem> pZoomItem;
sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
nValue = (sal_Int16) mpWindow->GetZoom();
@ -96,14 +96,14 @@ void FuScale::DoExecute( SfxRequest& rReq )
if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
// || ( mpView->GetMarkedObjectList().GetMarkCount() == 0 ) )
{
nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
}
}
else if( mpViewShell->ISA( OutlineViewShell ) )
{
nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE;
nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH;
nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
}
}

View File

@ -590,13 +590,13 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
pZoomItem.reset(new SvxZoomItem( SvxZoomType::PERCENT, nZoom ));
// constrain area
sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
SdrPageView* pPageView = mpDrawView->GetSdrPageView();
if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
// || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
{
nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
}
pZoomItem->SetValueSet( nZoomValues );

View File

@ -1279,10 +1279,10 @@ void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
boost::scoped_ptr<SvxZoomItem> pZoomItem(new SvxZoomItem( SvxZoomType::PERCENT, nZoom ));
// limit area
sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE;
nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH;
SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
pZoomItem->SetValueSet( nZoomValues );
rSet.Put( *pZoomItem );

View File

@ -43,7 +43,7 @@ SvxZoomItem::SvxZoomItem
sal_uInt16 _nWhich
)
: SfxUInt16Item( _nWhich, nVal ),
nValueSet( SVX_ZOOM_ENABLE_ALL ),
nValueSet( SvxZoomEnableFlags::ALL ),
eType( eZoomType )
{
}
@ -79,7 +79,7 @@ SfxPoolItem* SvxZoomItem::Create( SvStream& rStrm, sal_uInt16 /*nVersion*/ ) con
sal_Int8 nType;
rStrm.ReadUInt16( nValue ).ReadUInt16( nValSet ).ReadSChar( nType );
SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() );
pNew->SetValueSet( nValSet );
pNew->SetValueSet( static_cast<SvxZoomEnableFlags>(nValSet) );
return pNew;
}
@ -88,7 +88,7 @@ SfxPoolItem* SvxZoomItem::Create( SvStream& rStrm, sal_uInt16 /*nVersion*/ ) con
SvStream& SvxZoomItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
{
rStrm.WriteUInt16( GetValue() )
.WriteUInt16( nValueSet )
.WriteUInt16( static_cast<sal_uInt16>(nValueSet) )
.WriteSChar( static_cast<int>(eType) );
return rStrm;
}
@ -172,8 +172,8 @@ bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMem
if ( bAllConverted && nConvertedCount == ZOOM_PARAMS )
{
SetValue( (sal_uInt16)nValueTmp );
nValueSet = nValueSetTmp;
eType = SvxZoomType( nTypeTmp );
nValueSet = static_cast<SvxZoomEnableFlags>(nValueSetTmp);
eType = static_cast<SvxZoomType>(nTypeTmp);
return true;
}
}
@ -194,13 +194,13 @@ bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMem
case MID_VALUESET:
case MID_TYPE:
{
sal_Int16 nVal = sal_Int16();
sal_Int16 nVal;
if ( rVal >>= nVal )
{
if ( nMemberId == MID_VALUESET )
nValueSet = (sal_Int16) nVal;
nValueSet = static_cast<SvxZoomEnableFlags>(nVal);
else if ( nMemberId == MID_TYPE )
eType = SvxZoomType( (sal_Int16) nVal );
eType = static_cast<SvxZoomType>(nVal);
return true;
}
else

View File

@ -39,7 +39,7 @@ SFX_IMPL_STATUSBAR_CONTROL(SvxZoomStatusBarControl,SvxZoomItem);
class ZoomPopup_Impl : public PopupMenu
{
public:
ZoomPopup_Impl( sal_uInt16 nZ, sal_uInt16 nValueSet );
ZoomPopup_Impl( sal_uInt16 nZ, SvxZoomEnableFlags nValueSet );
sal_uInt16 GetZoom() const { return nZoom; }
sal_uInt16 GetCurId() const { return nCurId; }
@ -53,25 +53,25 @@ private:
ZoomPopup_Impl::ZoomPopup_Impl( sal_uInt16 nZ, sal_uInt16 nValueSet )
ZoomPopup_Impl::ZoomPopup_Impl( sal_uInt16 nZ, SvxZoomEnableFlags nValueSet )
: PopupMenu(ResId(RID_SVXMNU_ZOOM, DIALOG_MGR()))
, nZoom(nZ)
, nCurId(0)
{
static const sal_uInt16 aTable[] =
{
SVX_ZOOM_ENABLE_50, ZOOM_50,
SVX_ZOOM_ENABLE_100, ZOOM_100,
SVX_ZOOM_ENABLE_150, ZOOM_150,
SVX_ZOOM_ENABLE_200, ZOOM_200,
SVX_ZOOM_ENABLE_OPTIMAL, ZOOM_OPTIMAL,
SVX_ZOOM_ENABLE_WHOLEPAGE, ZOOM_WHOLE_PAGE,
SVX_ZOOM_ENABLE_PAGEWIDTH, ZOOM_PAGE_WIDTH
};
for ( sal_uInt16 nPos = 0; nPos < SAL_N_ELEMENTS(aTable); nPos += 2 )
if ( ( aTable[nPos] != ( aTable[nPos] & nValueSet ) ) )
EnableItem( aTable[nPos+1], false );
if ( !(SvxZoomEnableFlags::N50 & nValueSet) )
EnableItem( ZOOM_50, false );
if ( !(SvxZoomEnableFlags::N100 & nValueSet) )
EnableItem( ZOOM_100, false );
if ( !(SvxZoomEnableFlags::N150 & nValueSet) )
EnableItem( ZOOM_150, false );
if ( !(SvxZoomEnableFlags::N200 & nValueSet) )
EnableItem( ZOOM_200, false );
if ( !(SvxZoomEnableFlags::OPTIMAL & nValueSet) )
EnableItem( ZOOM_OPTIMAL, false );
if ( !(SvxZoomEnableFlags::WHOLEPAGE & nValueSet) )
EnableItem( ZOOM_WHOLE_PAGE, false );
if ( !(SvxZoomEnableFlags::PAGEWIDTH & nValueSet) )
EnableItem( ZOOM_PAGE_WIDTH, false );
}
@ -101,7 +101,7 @@ SvxZoomStatusBarControl::SvxZoomStatusBarControl( sal_uInt16 _nSlotId,
SfxStatusBarControl( _nSlotId, _nId, rStb ),
nZoom( 100 ),
nValueSet( SVX_ZOOM_ENABLE_ALL )
nValueSet( SvxZoomEnableFlags::ALL )
{
GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(RID_SVXSTR_ZOOMTOOL_HINT));
}
@ -112,7 +112,7 @@ void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState,
if( SfxItemState::DEFAULT != eState )
{
GetStatusBar().SetItemText( GetId(), "" );
nValueSet = 0;
nValueSet = SvxZoomEnableFlags::NONE;
}
else if ( pState->ISA( SfxUInt16Item) )
{
@ -129,7 +129,7 @@ void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState,
else
{
DBG_WARNING( "use SfxZoomItem for SID_ATTR_ZOOM" );
nValueSet = SVX_ZOOM_ENABLE_ALL;
nValueSet = SvxZoomEnableFlags::ALL;
}
}
}
@ -142,7 +142,7 @@ void SvxZoomStatusBarControl::Paint( const UserDrawEvent& )
void SvxZoomStatusBarControl::Command( const CommandEvent& rCEvt )
{
if ( COMMAND_CONTEXTMENU & rCEvt.GetCommand() && 0 != nValueSet )
if ( COMMAND_CONTEXTMENU & rCEvt.GetCommand() && bool(nValueSet) )
{
ZoomPopup_Impl aPop( nZoom, nValueSet );
StatusBar& rStatusbar = GetStatusBar();

View File

@ -750,12 +750,12 @@ void SwPagePreview::Execute( SfxRequest &rReq )
SvxZoomItem aZoom( (SvxZoomType)pVOpt->GetZoomType(),
pVOpt->GetZoom() );
aZoom.SetValueSet(
SVX_ZOOM_ENABLE_50|
SVX_ZOOM_ENABLE_75|
SVX_ZOOM_ENABLE_100|
SVX_ZOOM_ENABLE_150|
SVX_ZOOM_ENABLE_200|
SVX_ZOOM_ENABLE_WHOLEPAGE);
SvxZoomEnableFlags::N50|
SvxZoomEnableFlags::N75|
SvxZoomEnableFlags::N100|
SvxZoomEnableFlags::N150|
SvxZoomEnableFlags::N200|
SvxZoomEnableFlags::WHOLEPAGE);
aCoreSet.Put( aZoom );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
@ -992,11 +992,11 @@ void SwPagePreview::GetState( SfxItemSet& rSet )
SvxZoomItem aZoom((SvxZoomType)pVOpt->GetZoomType(),
pVOpt->GetZoom());
aZoom.SetValueSet(
SVX_ZOOM_ENABLE_50|
SVX_ZOOM_ENABLE_75|
SVX_ZOOM_ENABLE_100|
SVX_ZOOM_ENABLE_150|
SVX_ZOOM_ENABLE_200);
SvxZoomEnableFlags::N50|
SvxZoomEnableFlags::N75|
SvxZoomEnableFlags::N100|
SvxZoomEnableFlags::N150|
SvxZoomEnableFlags::N200);
rSet.Put( aZoom );
}
break;

View File

@ -1403,11 +1403,11 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
if( pVOpt->getBrowseMode() )
{
aZoom.SetValueSet(
SVX_ZOOM_ENABLE_50|
SVX_ZOOM_ENABLE_75|
SVX_ZOOM_ENABLE_100|
SVX_ZOOM_ENABLE_150|
SVX_ZOOM_ENABLE_200);
SvxZoomEnableFlags::N50|
SvxZoomEnableFlags::N75|
SvxZoomEnableFlags::N100|
SvxZoomEnableFlags::N150|
SvxZoomEnableFlags::N200);
}
rSet.Put( aZoom );
}
@ -1690,11 +1690,11 @@ void SwView::ExecuteStatusLine(SfxRequest &rReq)
if( bBrowseMode )
{
aZoom.SetValueSet(
SVX_ZOOM_ENABLE_50|
SVX_ZOOM_ENABLE_75|
SVX_ZOOM_ENABLE_100|
SVX_ZOOM_ENABLE_150|
SVX_ZOOM_ENABLE_200);
SvxZoomEnableFlags::N50|
SvxZoomEnableFlags::N75|
SvxZoomEnableFlags::N100|
SvxZoomEnableFlags::N150|
SvxZoomEnableFlags::N200);
}
aCoreSet.Put( aZoom );