summaryrefslogtreecommitdiff
path: root/sfx2/source/dialog
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-18 12:14:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-19 08:35:42 +0200
commit0035573ee7798cdf54ef44a54306a0515eeb90a7 (patch)
tree29f89470e725120dbb6378a64ab0bf01970ecf89 /sfx2/source/dialog
parent694f3ed0825d75bf855a74b2294ba0ff370afbb6 (diff)
convert SFXSTYLEBIT to scoped enum
drop SFXSTYLEBIT_HIERARCHY because it has no overlap with these values, it's used an extra bit in SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter Change-Id: I8ee5ecb9b5f8d2087d8eedd1f5526260ec1e4018 Reviewed-on: https://gerrit.libreoffice.org/53089 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r--sfx2/source/dialog/mgetempl.cxx16
-rw-r--r--sfx2/source/dialog/styfitem.cxx4
-rw-r--r--sfx2/source/dialog/templdlg.cxx76
-rw-r--r--sfx2/source/dialog/tplpitem.cxx6
4 files changed, 52 insertions, 50 deletions
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index f7f29f4e0010..77eed3e403e7 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -189,19 +189,19 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(vcl::Window* pParent, const Sfx
const SfxStyleFilter& rList = pItem->GetFilterList();
nCount = rList.size();
sal_uInt16 nIdx = 0;
- sal_uInt16 nMask = pStyle->GetMask() & ~SFXSTYLEBIT_USERDEF;
+ SfxStyleSearchBits nMask = pStyle->GetMask() & ~SfxStyleSearchBits::UserDefined;
- if ( !nMask ) // User Template?
+ if ( nMask == SfxStyleSearchBits::Auto ) // User Template?
nMask = pStyle->GetMask();
for ( i = 0; i < nCount; ++i )
{
const SfxFilterTupel& rTupel = rList[ i ];
- if ( rTupel.nFlags != SFXSTYLEBIT_AUTO &&
- rTupel.nFlags != SFXSTYLEBIT_USED &&
- rTupel.nFlags != SFXSTYLEBIT_ALL_VISIBLE &&
- rTupel.nFlags != SFXSTYLEBIT_ALL )
+ if ( rTupel.nFlags != SfxStyleSearchBits::Auto &&
+ rTupel.nFlags != SfxStyleSearchBits::Used &&
+ rTupel.nFlags != SfxStyleSearchBits::AllVisible &&
+ rTupel.nFlags != SfxStyleSearchBits::All )
{
m_pFilterLb->InsertEntry( rTupel.aName, nIdx );
m_pFilterLb->SetEntryData(nIdx, reinterpret_cast<void*>(i));
@@ -453,7 +453,7 @@ bool SfxManageStyleSheetPage::FillItemSet( SfxItemSet* rSet )
bModified = true;
OSL_ENSURE( pItem, "No Item" );
// is only possibly for user templates
- sal_uInt16 nMask = pItem->GetFilterList()[ reinterpret_cast<size_t>(m_pFilterLb->GetEntryData( nFilterIdx )) ].nFlags | SFXSTYLEBIT_USERDEF;
+ SfxStyleSearchBits nMask = pItem->GetFilterList()[ reinterpret_cast<size_t>(m_pFilterLb->GetEntryData( nFilterIdx )) ].nFlags | SfxStyleSearchBits::UserDefined;
pStyle->SetMask( nMask );
}
if(m_pAutoCB->IsVisible() &&
@@ -525,7 +525,7 @@ void SfxManageStyleSheetPage::Reset( const SfxItemSet* /*rAttrSet*/ )
if ( m_pFilterLb->IsEnabled() )
{
- sal_uInt16 nCmp = pStyle->GetMask();
+ SfxStyleSearchBits nCmp = pStyle->GetMask();
if ( nCmp != nFlags )
pStyle->SetMask( nFlags );
diff --git a/sfx2/source/dialog/styfitem.cxx b/sfx2/source/dialog/styfitem.cxx
index 40d02cbeb480..33b731691596 100644
--- a/sfx2/source/dialog/styfitem.cxx
+++ b/sfx2/source/dialog/styfitem.cxx
@@ -20,12 +20,12 @@
#include <sfx2/styfitem.hxx>
#include <unotools/resmgr.hxx>
-SfxStyleFamilyItem::SfxStyleFamilyItem(SfxStyleFamily nFamily_, const OUString &rName, const Image& rImage, const std::pair<const char*, int>* pStringArray, const std::locale& rResLocale)
+SfxStyleFamilyItem::SfxStyleFamilyItem(SfxStyleFamily nFamily_, const OUString &rName, const Image& rImage, const std::pair<const char*, SfxStyleSearchBits>* pStringArray, const std::locale& rResLocale)
: nFamily(nFamily_)
, aText(rName)
, aImage(rImage)
{
- for (const std::pair<const char*, int>* pItem = pStringArray; pItem->first; ++pItem)
+ for (const std::pair<const char*, SfxStyleSearchBits>* pItem = pStringArray; pItem->first; ++pItem)
aFilterList.emplace_back(Translate::get(pItem->first, rResLocale), pItem->second);
}
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 79f4970b98d0..31ffd4cdbc5c 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -650,7 +650,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
, nActFamily(0xffff)
, nActFilter(0)
- , nAppFilter(0)
+ , nAppFilter(SfxStyleSearchBits::Auto)
, bDontUpdate(false)
, bIsWater(false)
@@ -711,9 +711,13 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
if (!pStyleFamilies)
pStyleFamilies = new SfxStyleFamilies;
- nActFilter = pCurObjShell ? static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : SFXSTYLEBIT_ALL;
- if ( pCurObjShell && SFXSTYLEBIT_ALL == nActFilter )
- nActFilter = pCurObjShell->GetAutoStyleFilterIndex();
+ nActFilter = 0xffff;
+ if (pCurObjShell)
+ {
+ nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) );
+ if ( 0xffff == nActFilter )
+ nActFilter = pCurObjShell->GetAutoStyleFilterIndex();
+ }
// Paste in the toolbox
// reverse order, since always inserted at the head
@@ -911,7 +915,7 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( rStr, eFam );
if( pStyle )
{
- bool bReadWrite = !(pStyle->GetMask() & SFXSTYLEBIT_READONLY);
+ bool bReadWrite = !(pStyle->GetMask() & SfxStyleSearchBits::ReadOnly);
EnableEdit( bReadWrite );
EnableHide( bReadWrite && !pStyle->IsHidden( ) && !pStyle->IsUsed( ) );
EnableShow( bReadWrite && pStyle->IsHidden( ) );
@@ -1017,7 +1021,7 @@ void SfxCommonTemplateDialog_Impl::FillTreeBox()
const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
if (!pItem)
return;
- pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SFXSTYLEBIT_ALL_VISIBLE);
+ pStyleSheetPool->SetSearchMask(pItem->GetFamily(), SfxStyleSearchBits::AllVisible);
StyleTreeArr_Impl aArr;
SfxStyleSheetBase* pStyle = pStyleSheetPool->First();
@@ -1101,8 +1105,8 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
const SfxStyleFamily eFam = pItem->GetFamily();
- sal_uInt16 nFilter (nActFilter < pItem->GetFilterList().size() ? pItem->GetFilterList()[nActFilter].nFlags : 0);
- if(!nFilter) // automatic
+ SfxStyleSearchBits nFilter (nActFilter < pItem->GetFilterList().size() ? pItem->GetFilterList()[nActFilter].nFlags : SfxStyleSearchBits::Auto);
+ if(nFilter == SfxStyleSearchBits::Auto) // automatic
nFilter = nAppFilter;
OSL_ENSURE(pStyleSheetPool, "no StyleSheetPool");
@@ -1117,11 +1121,11 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
aFilterLb->Clear();
//insert hierarchical at the beginning
sal_Int32 nPos = aFilterLb->InsertEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL), 0);
- aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(SFXSTYLEBIT_ALL) );
+ aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(SfxStyleSearchBits::All) );
const SfxStyleFilter& rFilter = pItem->GetFilterList();
for(const SfxFilterTupel& i : rFilter)
{
- sal_uIntPtr nFilterFlags = i.nFlags;
+ SfxStyleSearchBits nFilterFlags = i.nFlags;
nPos = aFilterLb->InsertEntry( i.aName );
aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(nFilterFlags) );
}
@@ -1131,7 +1135,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
{
nActFilter = 0;
aFilterLb->SelectEntryPos(1);
- sal_uInt16 nFilterFlags = (nActFilter < rFilter.size()) ? rFilter[nActFilter].nFlags : 0;
+ SfxStyleSearchBits nFilterFlags = (nActFilter < rFilter.size()) ? rFilter[nActFilter].nFlags : SfxStyleSearchBits::Auto;
pStyleSheetPool->SetSearchMask(eFam, nFilterFlags);
}
@@ -1345,7 +1349,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
// other DocShell -> all new
CheckItem( nActFamily );
nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) );
- if ( SFXSTYLEBIT_ALL == nActFilter )
+ if ( 0xffff == nActFilter )
nActFilter = pDocShell->GetAutoStyleFilterIndex();
nAppFilter = pItem->GetValue();
@@ -1361,7 +1365,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
// other filters for automatic
CheckItem( nActFamily );
const SfxStyleFamilyItem *pStyleItem = GetFamilyItem_Impl();
- if ( pStyleItem && 0 == pStyleItem->GetFilterList()[nActFilter].nFlags
+ if ( pStyleItem && SfxStyleSearchBits::Auto == pStyleItem->GetFilterList()[nActFilter].nFlags
&& nAppFilter != pItem->GetValue())
{
nAppFilter = pItem->GetValue();
@@ -1442,7 +1446,7 @@ void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint
SfxStyleSheetBase *pStyle = pStyleSheetPool->Find( aStr, eFam );
if( pStyle )
{
- bool bReadWrite = !(pStyle->GetMask() & SFXSTYLEBIT_READONLY);
+ bool bReadWrite = !(pStyle->GetMask() & SfxStyleSearchBits::ReadOnly);
EnableEdit( bReadWrite );
EnableHide( bReadWrite && !pStyle->IsUsed( ) && !pStyle->IsHidden( ) );
EnableShow( bReadWrite && pStyle->IsHidden( ) );
@@ -1521,12 +1525,12 @@ void SfxCommonTemplateDialog_Impl::FilterSelect(
// Internal: Perform functions through the Dispatcher
bool SfxCommonTemplateDialog_Impl::Execute_Impl(
sal_uInt16 nId, const OUString &rStr, const OUString& rRefStr, sal_uInt16 nFamily,
- sal_uInt16 nMask, sal_uInt16 *pIdx, const sal_uInt16* pModifier)
+ SfxStyleSearchBits nMask, sal_uInt16 *pIdx, const sal_uInt16* pModifier)
{
SfxDispatcher &rDispatcher = *SfxGetpApp()->GetDispatcher_Impl();
SfxStringItem aItem(nId, rStr);
SfxUInt16Item aFamily(SID_STYLE_FAMILY, nFamily);
- SfxUInt16Item aMask( SID_STYLE_MASK, nMask );
+ SfxUInt16Item aMask( SID_STYLE_MASK, static_cast<sal_uInt16>(nMask) );
SfxStringItem aUpdName(SID_STYLE_UPD_BY_EX_NAME, rStr);
SfxStringItem aRefName( SID_STYLE_REFERENCE, rRefStr );
const SfxPoolItem* pItems[ 6 ];
@@ -1534,7 +1538,7 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl(
if( !rStr.isEmpty() )
pItems[ nCount++ ] = &aItem;
pItems[ nCount++ ] = &aFamily;
- if( nMask )
+ if( nMask != SfxStyleSearchBits::Auto )
pItems[ nCount++ ] = &aMask;
if(SID_STYLE_UPDATE_BY_EXAMPLE == nId)
{
@@ -1564,9 +1568,9 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl(
{
const SfxUInt16Item *pFilterItem = dynamic_cast< const SfxUInt16Item* >(pItem);
OSL_ENSURE(pFilterItem, "SfxUINT16Item expected");
- sal_uInt16 nFilterFlags = pFilterItem->GetValue() & ~SFXSTYLEBIT_USERDEF;
- if(!nFilterFlags) // User Template?
- nFilterFlags = pFilterItem->GetValue();
+ SfxStyleSearchBits nFilterFlags = static_cast<SfxStyleSearchBits>(pFilterItem->GetValue()) & ~SfxStyleSearchBits::UserDefined;
+ if(nFilterFlags == SfxStyleSearchBits::Auto) // User Template?
+ nFilterFlags = static_cast<SfxStyleSearchBits>(pFilterItem->GetValue());
const SfxStyleFamilyItem *pFamilyItem = GetFamilyItem_Impl();
const size_t nFilterCount = pFamilyItem->GetFilterList().size();
@@ -1694,16 +1698,16 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
{
const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily();
const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
- sal_uInt16 nFilter;
- if( pItem && nActFilter != SFXSTYLEBIT_ALL )
+ SfxStyleSearchBits nFilter;
+ if( pItem && nActFilter != 0xffff )
{
nFilter = pItem->GetFilterList()[nActFilter].nFlags;
- if(!nFilter) // automatisch
+ if(nFilter == SfxStyleSearchBits::Auto) // automatic
nFilter = nAppFilter;
}
else
nFilter=pStyleSheetPool->GetSearchMask();
- pStyleSheetPool->SetSearchMask( eFam, SFXSTYLEBIT_USERDEF );
+ pStyleSheetPool->SetSearchMask( eFam, SfxStyleSearchBits::UserDefined );
ScopedVclPtrInstance< SfxNewStyleDlg > pDlg(pWindow, *pStyleSheetPool);
// why? : FloatingWindow must not be parent of a modal dialog
@@ -1765,9 +1769,8 @@ sal_Int32 SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter( SfxObjectShell c
xModuleManager->getByName( getModuleIdentifier( xModuleManager, i_pObjSh ) ) );
sal_Int32 nFilter = aFactoryProps.getUnpackedValueOrDefault( "ooSetupFactoryStyleFilter", sal_Int32(-1) );
- m_bWantHierarchical =
- (nFilter & SFXSTYLEBIT_HIERARCHY) != 0;
- nFilter &= ~SFXSTYLEBIT_HIERARCHY; // clear it
+ m_bWantHierarchical = (nFilter & 0x1000) != 0;
+ nFilter &= ~0x1000; // clear it
return nFilter;
}
@@ -1777,8 +1780,7 @@ void SfxCommonTemplateDialog_Impl::SaveFactoryStyleFilter( SfxObjectShell const
OSL_ENSURE( i_pObjSh, "SfxCommonTemplateDialog_Impl::LoadFactoryStyleFilter(): no ObjectShell" );
Sequence< PropertyValue > lProps(1);
lProps[0].Name = "ooSetupFactoryStyleFilter";
- lProps[0].Value <<=
- i_nFilter | (m_bWantHierarchical ? SFXSTYLEBIT_HIERARCHY : 0);
+ lProps[0].Value <<= i_nFilter | (m_bWantHierarchical ? 0x1000 : 0);
xModuleManager->replaceByName( getModuleIdentifier( xModuleManager, i_pObjSh ), makeAny( lProps ) );
}
@@ -1811,11 +1813,11 @@ void SfxCommonTemplateDialog_Impl::NewHdl()
{
const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
const SfxStyleFamily eFam=pItem->GetFamily();
- sal_uInt16 nMask;
- if( nActFilter != SFXSTYLEBIT_ALL )
+ SfxStyleSearchBits nMask;
+ if( nActFilter != 0xffff )
{
nMask = pItem->GetFilterList()[nActFilter].nFlags;
- if(!nMask) // automatic
+ if(nMask == SfxStyleSearchBits::Auto) // automatic
nMask = nAppFilter;
}
else
@@ -1839,7 +1841,7 @@ void SfxCommonTemplateDialog_Impl::EditHdl()
OUString aTemplName(GetSelectedEntry());
GetSelectedStyle(); // -Wall required??
Execute_Impl( SID_STYLE_EDIT, aTemplName, OUString(),
- static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()), 0, &nFilter );
+ static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()), SfxStyleSearchBits::Auto, &nFilter );
}
}
@@ -1954,13 +1956,13 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
const OUString aTemplName(GetSelectedEntry());
const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
const SfxStyleFamily eFam = pItem->GetFamily();
- sal_uInt16 nFilter = 0;
+ SfxStyleSearchBits nFilter = SfxStyleSearchBits::Auto;
if (pItem->GetFilterList().size() > nActFilter)
nFilter = pItem->GetFilterList()[nActFilter].nFlags;
- if(!nFilter) // automatic
+ if(nFilter == SfxStyleSearchBits::Auto) // automatic
nFilter = nAppFilter;
const SfxStyleSheetBase *pStyle =
- pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SFXSTYLEBIT_ALL : nFilter);
+ pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SfxStyleSearchBits::All : nFilter);
OSL_ENSURE(pStyle, "Style not found");
if(pStyle && pStyle->IsUserDefined())
@@ -1995,7 +1997,7 @@ IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, ApplyHdl, LinkParamNone*, void )
Execute_Impl(SID_STYLE_APPLY,
GetSelectedEntry(), OUString(),
static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()),
- 0, nullptr, &nModifier );
+ SfxStyleSearchBits::Auto, nullptr, &nModifier );
}
// After selecting a focused item if possible again on the app window
if ( dynamic_cast< const SfxTemplateDialog_Impl* >(this) != nullptr )
diff --git a/sfx2/source/dialog/tplpitem.cxx b/sfx2/source/dialog/tplpitem.cxx
index 154f7688575b..60156ad6d4f3 100644
--- a/sfx2/source/dialog/tplpitem.cxx
+++ b/sfx2/source/dialog/tplpitem.cxx
@@ -32,7 +32,7 @@ SfxTemplateItem::SfxTemplateItem
(
sal_uInt16 nWhichId, // Slot-ID
const OUString& rStyle // Name of the current Styles
-) : SfxFlagItem( nWhichId, SFXSTYLEBIT_ALL ),
+) : SfxFlagItem( nWhichId, static_cast<sal_uInt16>(SfxStyleSearchBits::All) ),
aStyle( rStyle )
{
}
@@ -56,7 +56,7 @@ bool SfxTemplateItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{
css::frame::status::Template aTemplate;
- aTemplate.Value = GetValue();
+ aTemplate.Value = static_cast<sal_uInt16>(GetValue());
aTemplate.StyleName = aStyle;
rVal <<= aTemplate;
@@ -70,7 +70,7 @@ bool SfxTemplateItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId
if ( rVal >>= aTemplate )
{
- SetValue( sal::static_int_cast< sal_uInt16 >( aTemplate.Value ) );
+ SetValue( static_cast<SfxStyleSearchBits>(aTemplate.Value) );
aStyle = aTemplate.StyleName;
return true;
}