summaryrefslogtreecommitdiff
path: root/sfx2/source/dialog
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-25 16:35:48 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-26 12:02:40 +0100
commitc14b9d036ac8549feb588764b3596c0eb42cf97c (patch)
tree695b0e480549c55df4da70720b3669825b8b8228 /sfx2/source/dialog
parent88ec5de1c950d5b9c32fb98054557436d2aa426d (diff)
assemble SfxStyleFamilies from more generic resource components
Change-Id: I25aa0d8bca1f16f5fc27d3b299709479a1635ea3
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r--sfx2/source/dialog/mgetempl.cxx18
-rw-r--r--sfx2/source/dialog/styfitem.cxx148
-rw-r--r--sfx2/source/dialog/templdlg.cxx50
3 files changed, 42 insertions, 174 deletions
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index 8a5e89e18b56..523a47648aa1 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -179,7 +179,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(vcl::Window* pParent, const Sfx
size_t i;
for ( i = 0; i < nCount; ++i )
{
- pItem = pFamilies->at( i );
+ pItem = &(pFamilies->at(i));
if ( pItem->GetFamily() == pStyle->GetFamily() )
break;
@@ -199,17 +199,17 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(vcl::Window* pParent, const Sfx
for ( i = 0; i < nCount; ++i )
{
- SfxFilterTupel* pTupel = rList[ i ];
+ const SfxFilterTupel& rTupel = rList[ i ];
- if ( pTupel->nFlags != SFXSTYLEBIT_AUTO &&
- pTupel->nFlags != SFXSTYLEBIT_USED &&
- pTupel->nFlags != SFXSTYLEBIT_ALL_VISIBLE &&
- pTupel->nFlags != SFXSTYLEBIT_ALL )
+ if ( rTupel.nFlags != SFXSTYLEBIT_AUTO &&
+ rTupel.nFlags != SFXSTYLEBIT_USED &&
+ rTupel.nFlags != SFXSTYLEBIT_ALL_VISIBLE &&
+ rTupel.nFlags != SFXSTYLEBIT_ALL )
{
- m_pFilterLb->InsertEntry( pTupel->aName, nIdx );
+ m_pFilterLb->InsertEntry( rTupel.aName, nIdx );
m_pFilterLb->SetEntryData(nIdx, reinterpret_cast<void*>(i));
- if ( ( pTupel->nFlags & nMask ) == nMask )
+ if ( ( rTupel.nFlags & nMask ) == nMask )
nStyleFilterIdx = nIdx;
++nIdx;
}
@@ -469,7 +469,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;
+ sal_uInt16 nMask = pItem->GetFilterList()[ reinterpret_cast<size_t>(m_pFilterLb->GetEntryData( nFilterIdx )) ].nFlags | SFXSTYLEBIT_USERDEF;
pStyle->SetMask( nMask );
}
if(m_pAutoCB->IsVisible() &&
diff --git a/sfx2/source/dialog/styfitem.cxx b/sfx2/source/dialog/styfitem.cxx
index 5ae6a03a5e02..5821500bd928 100644
--- a/sfx2/source/dialog/styfitem.cxx
+++ b/sfx2/source/dialog/styfitem.cxx
@@ -23,147 +23,17 @@
#include <tools/rcid.h>
#include <tools/debug.hxx>
-// Implementierung des Resource-Konstruktors
-
-SfxStyleFamilyItem::SfxStyleFamilyItem( const ResId &rResId ) :
-
- Resource( rResId.SetRT( RSC_SFX_STYLE_FAMILY_ITEM ) )
-
+SfxStyleFamilyItem::SfxStyleFamilyItem(SfxStyleFamily nFamily_, const OUString &rName, const Image& rImage, const ResId &rStringArrayId)
+ : nFamily(nFamily_)
+ , aText(rName)
+ , aImage(rImage)
{
- const sal_Int32 nMask = ReadLongRes();
-
- if(nMask & (sal_uInt32)SfxStyleItem::List)
+ ResStringArray aResList(rStringArrayId);
+ aFilterList.resize(aResList.Count());
+ for (sal_uInt32 i = 0; i < aResList.Count(); ++i)
{
- const sal_Int32 nCount = ReadLongRes();
- for( sal_Int32 i = 0; i < nCount; ++i )
- {
- SfxFilterTupel *pTupel = new SfxFilterTupel;
- pTupel->aName = ReadStringRes();
- pTupel->nFlags = static_cast<sal_uInt16>(ReadLongRes());
- aFilterList.push_back( pTupel );
- }
- }
- if(nMask & (sal_uInt32)SfxStyleItem::Bitmap)
- {
- aBitmap = Bitmap(ResId(static_cast<RSHEADER_TYPE *>(GetClassRes()),*rResId.GetResMgr()));
- IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE *>(GetClassRes()) ) );
- }
- if(nMask & (sal_uInt32)SfxStyleItem::Text)
- {
- aText = ReadStringRes();
- }
- if(nMask & (sal_uInt32)SfxStyleItem::HelpText)
- {
- aHelpText = ReadStringRes();
- }
- if(nMask & (sal_uInt32)SfxStyleItem::StyleFamily)
- {
- nFamily = static_cast<SfxStyleFamily>(ReadLongRes());
- }
- else
- nFamily = SfxStyleFamily::Para;
-
- if(nMask & (sal_uInt32)SfxStyleItem::Image)
- {
- aImage = Image(ResId(static_cast<RSHEADER_TYPE *>(GetClassRes()),*rResId.GetResMgr()));
- IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE *>(GetClassRes()) ) );
- }
- else
- aImage = Image(aBitmap);
-}
-
-
-// Destructor; releases the internal data
-
-SfxStyleFamilyItem::~SfxStyleFamilyItem()
-{
- for (SfxFilterTupel* p : aFilterList)
- delete p;
- aFilterList.clear();
-}
-
-
-// Implementation of the resource constructor
-
-SfxStyleFamilies::SfxStyleFamilies( const ResId& rResId ) :
- Resource( rResId.SetRT( RSC_SFX_STYLE_FAMILIES ).SetAutoRelease( false ) )
-{
- const sal_Int32 nCount = ReadLongRes();
- for( sal_Int32 i = 0; i < nCount; ++i )
- {
- const ResId aResId(static_cast<RSHEADER_TYPE *>(GetClassRes()), *rResId.GetResMgr());
- SfxStyleFamilyItem *pItem = new SfxStyleFamilyItem(aResId);
- IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE *>(GetClassRes()) ) );
- aEntryList.push_back( pItem );
- }
-
- FreeResource();
-
- updateImages( rResId );
-}
-
-
-// Destructor; releases the internal data
-
-SfxStyleFamilies::~SfxStyleFamilies()
-{
- for (SfxStyleFamilyItem* p : aEntryList)
- delete p;
- aEntryList.clear();
-}
-
-namespace
-{
- class OLocalResourceAccess : public Resource
- {
- protected:
- ResMgr* m_pManager;
-
- public:
- OLocalResourceAccess( const ResId& _rId )
- :Resource( _rId.SetAutoRelease( false ) )
- ,m_pManager( _rId.GetResMgr() )
- {
- }
-
- ~OLocalResourceAccess()
- {
- if ( m_pManager )
- m_pManager->Increment( m_pManager->GetRemainSize() );
- FreeResource();
- }
-
- bool IsAvailableRes( const ResId& _rId ) const
- {
- return Resource::IsAvailableRes( _rId );
- }
- };
-}
-
-void SfxStyleFamilies::updateImages( const ResId& _rId )
-{
- OLocalResourceAccess aLocalRes( _rId );
-
- // check if the image list is present
- ResId aImageListId( (sal_uInt16) 1, *_rId.GetResMgr() );
- aImageListId.SetRT( RSC_IMAGELIST );
-
- if ( aLocalRes.IsAvailableRes( aImageListId ) )
- { // there is such a list
- ImageList aImages( aImageListId );
-
- // number of styles items/images
- sal_uInt16 nCount = aImages.GetImageCount( );
- DBG_ASSERT( aEntryList.size() == nCount, "SfxStyleFamilies::updateImages: found the image list, but missing some bitmaps!" );
- if ( nCount > aEntryList.size() )
- nCount = aEntryList.size();
-
- // set the images on the items
- for ( size_t i = 0; i < nCount; ++i )
- {
- SfxStyleFamilyItem* pItem = aEntryList[ i ];
- pItem->SetImage( aImages.GetImage( aImages.GetImageId( i ) ) );
- }
+ aFilterList[i].aName = aResList.GetString(i);
+ aFilterList[i].nFlags = aResList.GetValue(i);
}
}
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index cb21669e2f8d..025e5e00d9a3 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -716,8 +716,8 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl
sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId)
{
- const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nId );
- return SfxTemplate::SfxFamilyIdToNId(pItem->GetFamily())-1;
+ const SfxStyleFamilyItem& rItem = pStyleFamilies->at( nId );
+ return SfxTemplate::SfxFamilyIdToNId(rItem.GetFamily())-1;
}
void SfxTemplateDialog_Impl::EnableEdit(bool bEnable)
@@ -755,7 +755,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
for (i = 0; i < nCount; ++i)
{
sal_uInt16 nSlot = 0;
- switch( pStyleFamilies->at( i )->GetFamily() )
+ switch (pStyleFamilies->at(i).GetFamily())
{
case SfxStyleFamily::Char:
nSlot = SID_STYLE_FAMILY1; break;
@@ -812,9 +812,9 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
for( ; nCount--; )
{
- const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nCount );
- sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId( pItem->GetFamily() );
- InsertFamilyItem( nId, pItem );
+ const SfxStyleFamilyItem &rItem = pStyleFamilies->at( nCount );
+ sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId( rItem.GetFamily() );
+ InsertFamilyItem(nId, rItem);
}
LoadedFamilies();
@@ -904,10 +904,10 @@ const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() con
const size_t nCount = pStyleFamilies->size();
for(size_t i = 0; i < nCount; ++i)
{
- const SfxStyleFamilyItem *pItem = pStyleFamilies->at( i );
- sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId(pItem->GetFamily());
+ const SfxStyleFamilyItem &rItem = pStyleFamilies->at( i );
+ sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId(rItem.GetFamily());
if(nId == nActFamily)
- return pItem;
+ return &rItem;
}
return nullptr;
}
@@ -1133,8 +1133,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
const SfxStyleFamily eFam = pItem->GetFamily();
- SfxFilterTupel* pT = ( nActFilter < pItem->GetFilterList().size() ? pItem->GetFilterList()[nActFilter] : nullptr );
- sal_uInt16 nFilter = pT ? pT->nFlags : 0;
+ sal_uInt16 nFilter (nActFilter < pItem->GetFilterList().size() ? pItem->GetFilterList()[nActFilter].nFlags : 0);
if(!nFilter) // automatic
nFilter = nAppFilter;
@@ -1152,10 +1151,10 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
sal_Int32 nPos = aFilterLb->InsertEntry(SfxResId(STR_STYLE_FILTER_HIERARCHICAL).toString(), 0);
aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(SFXSTYLEBIT_ALL) );
const SfxStyleFilter& rFilter = pItem->GetFilterList();
- for(const SfxFilterTupel* i : rFilter)
+ for(const SfxFilterTupel& i : rFilter)
{
- sal_uIntPtr nFilterFlags = i->nFlags;
- nPos = aFilterLb->InsertEntry( i->aName );
+ sal_uIntPtr nFilterFlags = i.nFlags;
+ nPos = aFilterLb->InsertEntry( i.aName );
aFilterLb->SetEntryData( nPos, reinterpret_cast<void*>(nFilterFlags) );
}
if(nActFilter < aFilterLb->GetEntryCount() - 1)
@@ -1164,8 +1163,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
{
nActFilter = 0;
aFilterLb->SelectEntryPos(1);
- SfxFilterTupel* pActT = ( nActFilter < rFilter.size() ) ? rFilter[ nActFilter ] : nullptr;
- sal_uInt16 nFilterFlags = pActT ? pActT->nFlags : 0;
+ sal_uInt16 nFilterFlags = (nActFilter < rFilter.size()) ? rFilter[nActFilter].nFlags : 0;
pStyleSheetPool->SetSearchMask(eFam, nFilterFlags);
}
@@ -1395,7 +1393,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 && 0 == pStyleItem->GetFilterList()[nActFilter].nFlags
&& nAppFilter != pItem->GetValue())
{
nAppFilter = pItem->GetValue();
@@ -1605,9 +1603,9 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl(
for ( size_t i = 0; i < nFilterCount; ++i )
{
- const SfxFilterTupel *pTupel = pFamilyItem->GetFilterList()[ i ];
+ const SfxFilterTupel &rTupel = pFamilyItem->GetFilterList()[ i ];
- if ( ( pTupel->nFlags & nFilterFlags ) == nFilterFlags && pIdx )
+ if ( ( rTupel.nFlags & nFilterFlags ) == nFilterFlags && pIdx )
*pIdx = i;
}
}
@@ -1730,7 +1728,7 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
sal_uInt16 nFilter;
if( pItem && nActFilter != SFXSTYLEBIT_ALL )
{
- nFilter = pItem->GetFilterList()[ nActFilter ]->nFlags;
+ nFilter = pItem->GetFilterList()[nActFilter].nFlags;
if(!nFilter) // automatisch
nFilter = nAppFilter;
}
@@ -1848,7 +1846,7 @@ void SfxCommonTemplateDialog_Impl::NewHdl()
sal_uInt16 nMask;
if( nActFilter != SFXSTYLEBIT_ALL )
{
- nMask = pItem->GetFilterList()[ nActFilter ]->nFlags;
+ nMask = pItem->GetFilterList()[nActFilter].nFlags;
if(!nMask) // automatic
nMask = nAppFilter;
}
@@ -1997,8 +1995,8 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
const SfxStyleFamily eFam = pItem->GetFamily();
sal_uInt16 nFilter = 0;
- if(pItem->GetFilterList().size() > nActFilter)
- nFilter = pItem->GetFilterList()[ nActFilter ]->nFlags;
+ if (pItem->GetFilterList().size() > nActFilter)
+ nFilter = pItem->GetFilterList()[nActFilter].nFlags;
if(!nFilter) // automatic
nFilter = nAppFilter;
const SfxStyleSheetBase *pStyle =
@@ -2263,10 +2261,10 @@ void SfxTemplateDialog_Impl::EnableFamilyItem( sal_uInt16 nId, bool bEnable )
}
// Insert element into dropdown filter "Frame Styles", "List Styles", etc.
-void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamilyItem *pItem)
+void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamilyItem &rItem)
{
OString sHelpId;
- switch( pItem->GetFamily() )
+ switch( rItem.GetFamily() )
{
case SfxStyleFamily::Char: sHelpId = ".uno:CharStyle"; break;
case SfxStyleFamily::Para: sHelpId = ".uno:ParaStyle"; break;
@@ -2276,7 +2274,7 @@ void SfxTemplateDialog_Impl::InsertFamilyItem(sal_uInt16 nId,const SfxStyleFamil
case SfxStyleFamily::Table: sHelpId = ".uno:TableStyle"; break;
default: OSL_FAIL("unknown StyleFamily"); break;
}
- m_aActionTbL->InsertItem( nId, pItem->GetImage(), pItem->GetText(), ToolBoxItemBits::NONE, 0);
+ m_aActionTbL->InsertItem( nId, rItem.GetImage(), rItem.GetText(), ToolBoxItemBits::NONE, 0);
m_aActionTbL->SetHelpId( nId, sHelpId );
}