20#include <com/sun/star/lang/DisposedException.hpp>
21#include <com/sun/star/lang/IllegalAccessException.hpp>
22#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
35#include <stlsheet.hxx>
49typedef std::map< OUString, rtl::Reference< SdStyleSheet > >
PresStyleMap;
75 aLayoutName = aLayoutName.copy(0, nLen );
82 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(), SfxStyleFamily::Page);
84 pStyle = aSSSIterator->Next() )
88 if (pSdStyle->GetName().startsWith(aLayoutName))
101, mxPool(
std::move( xPool ))
110 mpImpl->mxMasterPage =
const_cast< SdPage*
>( pMasterPage );
116 DBG_ASSERT( !
mxPool.is(),
"SdStyleFamily::~SdStyleFamily(), dispose me first!" );
122 throw DisposedException();
127 Reference< XStyle > xStyle( rElement, UNO_QUERY );
130 if( pStyle ==
nullptr || (pStyle->GetFamily() !=
mnFamily) || (pStyle->GetPool() !=
mxPool.get()) || (
mxPool->Find( pStyle->GetName(),
mnFamily) !=
nullptr) )
131 throw IllegalArgumentException();
139 if( !rName.isEmpty() )
141 if(
mnFamily == SfxStyleFamily::Page )
144 PresStyleMap::iterator iter( rStyleMap.find(rName) );
145 if( iter != rStyleMap.end() )
146 pRet = (*iter).second.get();
150 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(),
mnFamily);
152 pStyle = aSSSIterator->Next() )
167 throw NoSuchElementException();
173 return "SdStyleFamily";
183 return {
"com.sun.star.style.StyleFamily" };
189 if(
mnFamily == SfxStyleFamily::Page )
192 if( pPage ==
nullptr )
193 throw DisposedException();
195 OUString aLayoutName( pPage->GetLayoutName() );
198 aLayoutName = aLayoutName.copy(0,
nIndex);
227 if(
mnFamily == SfxStyleFamily::Page )
230 Sequence< OUString > aNames( rStyleMap.size() );
232 OUString* pNames = aNames.getArray();
233 for(
const auto& rEntry : rStyleMap )
238 *pNames++ = xStyle->GetApiName();
246 std::vector< OUString > aNames;
247 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(),
mnFamily);
249 pStyle = aSSSIterator->Next() )
255 return Sequence< OUString >( &(*aNames.begin()), aNames.size() );
264 if( !
aName.isEmpty() )
266 if(
mnFamily == SfxStyleFamily::Page )
269 PresStyleMap::iterator iter( rStyleSheets.find(
aName) );
270 return iter != rStyleSheets.end();
274 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(),
mnFamily);
276 pStyle = aSSSIterator->Next() )
303 if(
mnFamily == SfxStyleFamily::Page )
309 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(),
mnFamily);
310 if (aSSSIterator->First())
327 if(
mnFamily == SfxStyleFamily::Page )
329 return mpImpl->getStyleSheets().size();
333 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(),
mnFamily);
335 pStyle = aSSSIterator->Next() )
351 if(
mnFamily == SfxStyleFamily::Page )
354 if(
Index <
static_cast<sal_Int32
>(rStyleSheets.size()) )
356 PresStyleMap::iterator iter( rStyleSheets.begin() );
357 std::advance(iter,
Index);
358 return Any( Reference< XStyle >( (*iter).second ) );
363 std::shared_ptr<SfxStyleSheetIterator> aSSSIterator = std::make_shared<SfxStyleSheetIterator>(
mxPool.get(),
mnFamily);
365 pStyle = aSSSIterator->Next() )
371 return Any( Reference< XStyle >( pSdStyle ) );
377 throw IndexOutOfBoundsException();
388 throw IllegalArgumentException();
391 if( !pStyle->
SetName( rName ) )
392 throw ElementExistException();
405 if( !pStyle->IsUserDefined() )
406 throw WrappedTargetException();
421 mxPool->Remove( pOldStyle );
422 mxPool->Insert( pNewStyle );
432 if(
mnFamily == SfxStyleFamily::Page )
434 throw IllegalAccessException();
436 return Reference<XInterface>(
467 OSL_FAIL(
"###unexpected!" );
468 return Reference<XPropertySetInfo>();
473 OSL_FAIL(
"###unexpected!" );
478 if ( PropertyName !=
"DisplayName" )
480 throw UnknownPropertyException(
"unknown property: " + PropertyName,
static_cast<OWeakObject *
>(
this) );
496 OSL_FAIL(
"###unexpected!" );
501 OSL_FAIL(
"###unexpected!" );
506 OSL_FAIL(
"###unexpected!" );
511 OSL_FAIL(
"###unexpected!" );
SdStyleFamily(rtl::Reference< SfxStyleSheetPool > xPool, SfxStyleFamily nFamily)
creates the style family for the given SfxStyleFamily
rtl::Reference< SfxStyleSheetPool > mxPool
virtual sal_Int32 SAL_CALL getCount() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual OUString SAL_CALL getImplementationName() override
virtual ~SdStyleFamily() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
SdStyleSheet * GetSheetByName(const OUString &rName)
virtual void SAL_CALL setName(const OUString &aName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
std::unique_ptr< SdStyleFamilyImpl > mpImpl
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual sal_Bool SAL_CALL hasElements() override
void throwIfDisposed() const
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual OUString SAL_CALL getName() override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
SdStyleSheet * GetValidNewSheet(const css::uno::Any &rElement)
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual void SAL_CALL dispose() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removeByName(const OUString &Name) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
OUString const & GetApiName() const
static OUString GetFamilyString(SfxStyleFamily eFamily)
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true) override
static rtl::Reference< SdStyleSheet > CreateEmptyUserStyle(SfxStyleSheetBasePool &rPool, SfxStyleFamily eFamily)
void SetApiName(const OUString &rApiName)
css::uno::Type const & get()
#define DBG_ASSERT(sCon, aError)
constexpr OUStringLiteral SD_LT_SEPARATOR
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString SdResId(TranslateId aId)
std::map< OUString, rtl::Reference< SdStyleSheet > > PresStyleMap
PresStyleMap & getStyleSheets()
unotools::WeakReference< SdPage > mxMasterPage
rtl::Reference< SfxStyleSheetPool > mxPool
PresStyleMap maStyleSheets