Kaydet (Commit) 40251681 authored tarafından Tobias Lippert's avatar Tobias Lippert Kaydeden (comit) Caolán McNamara

Use SfxStyleSheetIterator to iterate over SfxStyles in sd/stlfamily.cxx

Change-Id: I535b47de0fb4e66dc4b02d4c75b6631eb7d87ed4
Reviewed-on: https://gerrit.libreoffice.org/8482Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst ed6b8c9f
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "sdpage.hxx" #include "sdpage.hxx"
#include "glob.hxx" #include "glob.hxx"
#include <boost/make_shared.hpp>
#include <map> #include <map>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -75,12 +76,21 @@ PresStyleMap& SdStyleFamilyImpl::getStyleSheets() ...@@ -75,12 +76,21 @@ PresStyleMap& SdStyleFamilyImpl::getStyleSheets()
{ {
maStyleSheets.clear(); maStyleSheets.clear();
const SfxStyles& rStyles = mxPool->GetStyles(); // The iterator will return only style sheets of family master page
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), SD_STYLE_FAMILY_MASTERPAGE);
for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
pStyle = aSSSIterator->Next() )
{ {
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() ); // we assume that we have only SdStyleSheets
if( pStyle && (pStyle->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) && pStyle->GetName().startsWith(aLayoutName) ) SdStyleSheet* pSdStyle = static_cast< SdStyleSheet* >( pStyle );
maStyleSheets[ pStyle->GetApiName() ] = rtl::Reference< SdStyleSheet >( pStyle ); if (!pSdStyle)
{
continue;
}
if (pSdStyle->GetName().startsWith(aLayoutName))
{
maStyleSheets[ pSdStyle->GetApiName() ] = rtl::Reference< SdStyleSheet >( pSdStyle );
}
} }
} }
} }
...@@ -137,8 +147,6 @@ SdStyleSheet* SdStyleFamily::GetValidNewSheet( const Any& rElement ) throw(Illeg ...@@ -137,8 +147,6 @@ SdStyleSheet* SdStyleFamily::GetValidNewSheet( const Any& rElement ) throw(Illeg
return pStyle; return pStyle;
} }
SdStyleSheet* SdStyleFamily::GetSheetByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException ) SdStyleSheet* SdStyleFamily::GetSheetByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException )
{ {
SdStyleSheet* pRet = 0; SdStyleSheet* pRet = 0;
...@@ -153,13 +161,15 @@ SdStyleSheet* SdStyleFamily::GetSheetByName( const OUString& rName ) throw(NoSuc ...@@ -153,13 +161,15 @@ SdStyleSheet* SdStyleFamily::GetSheetByName( const OUString& rName ) throw(NoSuc
} }
else else
{ {
const SfxStyles& rStyles = mxPool->GetStyles(); SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), mnFamily);
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
pStyle = aSSSIterator->Next() )
{ {
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() ); // we assume that we have only SdStyleSheets
if( pStyle && (pStyle->GetFamily() == mnFamily) && (pStyle->GetApiName() == rName) ) SdStyleSheet* pSdStyle = static_cast< SdStyleSheet* >( pStyle );
if( pSdStyle && pSdStyle->GetApiName() == rName)
{ {
pRet = pStyle; pRet = pSdStyle;
break; break;
} }
} }
...@@ -258,12 +268,16 @@ Sequence< OUString > SAL_CALL SdStyleFamily::getElementNames() throw(RuntimeExce ...@@ -258,12 +268,16 @@ Sequence< OUString > SAL_CALL SdStyleFamily::getElementNames() throw(RuntimeExce
else else
{ {
std::vector< OUString > aNames; std::vector< OUString > aNames;
const SfxStyles& rStyles = mxPool->GetStyles(); SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), mnFamily);
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
pStyle = aSSSIterator->Next() )
{
// we assume that we have only SdStyleSheets
SdStyleSheet* pSdStyle = static_cast< SdStyleSheet* >( pStyle );
if( pSdStyle )
{ {
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() ); aNames.push_back( pSdStyle->GetApiName() );
if( pStyle && (pStyle->GetFamily() == mnFamily) ) }
aNames.push_back( pStyle->GetApiName() );
} }
return Sequence< OUString >( &(*aNames.begin()), aNames.size() ); return Sequence< OUString >( &(*aNames.begin()), aNames.size() );
} }
...@@ -286,15 +300,22 @@ sal_Bool SAL_CALL SdStyleFamily::hasByName( const OUString& aName ) throw(Runtim ...@@ -286,15 +300,22 @@ sal_Bool SAL_CALL SdStyleFamily::hasByName( const OUString& aName ) throw(Runtim
} }
else else
{ {
const SfxStyles& rStyles = mxPool->GetStyles(); SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), mnFamily);
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
pStyle = aSSSIterator->Next() )
{
// we assume that we have only SdStyleSheets
SdStyleSheet* pSdStyle = static_cast< SdStyleSheet* >( pStyle );
if( pSdStyle )
{
if (pSdStyle->GetApiName() == aName)
{ {
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
if( pStyle && (pStyle->GetFamily() == mnFamily) && ( pStyle->GetApiName() == aName ) )
return sal_True; return sal_True;
} }
} }
} }
}
}
return sal_False; return sal_False;
} }
...@@ -321,11 +342,10 @@ sal_Bool SAL_CALL SdStyleFamily::hasElements() throw(RuntimeException, std::exce ...@@ -321,11 +342,10 @@ sal_Bool SAL_CALL SdStyleFamily::hasElements() throw(RuntimeException, std::exce
} }
else else
{ {
const SfxStyles& rStyles = mxPool->GetStyles(); SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), mnFamily);
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
pStyle = aSSSIterator->Next() )
{ {
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
if( pStyle && (pStyle->GetFamily() == mnFamily) )
return sal_True; return sal_True;
} }
} }
...@@ -349,11 +369,10 @@ sal_Int32 SAL_CALL SdStyleFamily::getCount() throw(RuntimeException, std::except ...@@ -349,11 +369,10 @@ sal_Int32 SAL_CALL SdStyleFamily::getCount() throw(RuntimeException, std::except
} }
else else
{ {
const SfxStyles& rStyles = mxPool->GetStyles(); SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), mnFamily);
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
pStyle = aSSSIterator->Next() )
{ {
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
if( pStyle && (pStyle->GetFamily() == mnFamily) )
nCount++; nCount++;
} }
} }
...@@ -385,14 +404,15 @@ Any SAL_CALL SdStyleFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBounds ...@@ -385,14 +404,15 @@ Any SAL_CALL SdStyleFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBounds
} }
else else
{ {
const SfxStyles& rStyles = mxPool->GetStyles(); SfxStyleSheetIteratorPtr aSSSIterator = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), mnFamily);
for( SfxStyles::const_iterator iter( rStyles.begin() ); iter != rStyles.end(); ++iter ) for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle;
{ pStyle = aSSSIterator->Next() )
SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
if( pStyle && (pStyle->GetFamily() == mnFamily) )
{ {
// we assume that we have only SdStyleSheets
SdStyleSheet* pSdStyle = static_cast< SdStyleSheet* >( pStyle );
if( Index-- == 0 ) if( Index-- == 0 )
return Any( Reference< XStyle >( pStyle ) ); {
return Any( Reference< XStyle >( pSdStyle ) );
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment