67#include <unoprnms.hxx>
75#include <unoevent.hxx>
79#include <com/sun/star/frame/XModel.hpp>
80#include <com/sun/star/io/IOException.hpp>
81#include <com/sun/star/style/ParagraphStyleCategory.hpp>
82#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
83#include <com/sun/star/beans/PropertyAttribute.hpp>
84#include <com/sun/star/beans/NamedValue.hpp>
85#include <com/sun/star/drawing/BitmapMode.hpp>
86#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
87#include <com/sun/star/lang/IllegalArgumentException.hpp>
88#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
89#include <com/sun/star/document/XEventsSupplier.hpp>
90#include <com/sun/star/io/XInputStream.hpp>
117#include <uiitems.hxx>
122#include <string_view>
126using namespace css::io;
127using namespace css::lang;
128using namespace css::uno;
133 #define nPoolChrNormalRange (RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN)
134 #define nPoolChrHtmlRange (RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN)
135 #define nPoolCollTextRange ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN)
136 #define nPoolCollListsRange ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN)
137 #define nPoolCollExtraRange ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN)
138 #define nPoolCollRegisterRange ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN)
139 #define nPoolCollDocRange ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN)
140 #define nPoolCollHtmlRange ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN)
141 #define nPoolFrameRange ( RES_POOLFRM_END - RES_POOLFRM_BEGIN)
142 #define nPoolPageRange ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN)
143 #define nPoolNumRange ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN)
144 #define nPoolCollListsStackedStart ( nPoolCollTextRange)
145 #define nPoolCollExtraStackedStart ( nPoolCollListsStackedStart + nPoolCollListsRange)
146 #define nPoolCollRegisterStackedStart ( nPoolCollExtraStackedStart + nPoolCollExtraRange)
147 #define nPoolCollDocStackedStart ( nPoolCollRegisterStackedStart + nPoolCollRegisterRange)
148 #define nPoolCollHtmlStackedStart ( nPoolCollDocStackedStart + nPoolCollDocRange)
149 using paragraphstyle_t = std::remove_const<
decltype(style::ParagraphStyleCategory::TEXT)>::type;
150 using collectionbits_t = sal_uInt16;
151 struct ParagraphStyleCategoryEntry
153 paragraphstyle_t m_eCategory;
155 collectionbits_t m_nCollectionBits;
156 constexpr ParagraphStyleCategoryEntry(paragraphstyle_t eCategory,
SfxStyleSearchBits nSwStyleBits, collectionbits_t nCollectionBits)
157 : m_eCategory(eCategory)
158 , m_nSwStyleBits(nSwStyleBits)
159 , m_nCollectionBits(nCollectionBits)
163constexpr ParagraphStyleCategoryEntry sParagraphStyleCategoryEntries[]
165 { style::ParagraphStyleCategory::TEXT, SfxStyleSearchBits::SwText,
COLL_TEXT_BITS },
166 { style::ParagraphStyleCategory::CHAPTER, SfxStyleSearchBits::SwChapter,
COLL_DOC_BITS },
167 { style::ParagraphStyleCategory::LIST, SfxStyleSearchBits::SwList,
COLL_LISTS_BITS },
168 { style::ParagraphStyleCategory::INDEX, SfxStyleSearchBits::SwIndex,
COLL_REGISTER_BITS },
169 { style::ParagraphStyleCategory::EXTRA, SfxStyleSearchBits::SwExtra,
COLL_EXTRA_BITS },
170 { style::ParagraphStyleCategory::HTML, SfxStyleSearchBits::SwHtml,
COLL_HTML_BITS }
173class StyleFamilyEntry
178 return StyleFamilyEntry(f, nPropMapType, aPoolId, sName, pResId, GetCountOrName<f>, CreateStyle<f>, TranslateIndex<f>);
182 sal_uInt16 propMapType()
const {
return m_nPropMapType; }
183 const uno::Reference<beans::XPropertySetInfo>& xPSInfo()
const {
return m_xPSInfo; }
186 const TranslateId& resId()
const {
return m_pResId; }
188 sal_Int32 getCountOrName(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
const {
return m_fGetCountOrName(rDoc, pString, nIndex); }
189 css::uno::Reference<css::style::XStyle> createStyle(
SfxStyleSheetBasePool* pBasePool,
SwDocShell* pDocShell,
const OUString& sStyleName)
const {
return m_fCreateStyle(pBasePool, pDocShell, sStyleName); }
190 sal_uInt16 translateIndex(
const sal_uInt16 nIndex)
const {
return m_fTranslateIndex(nIndex); }
193 using GetCountOrName_t = sal_Int32 (*)(
const SwDoc&, OUString*, sal_Int32);
195 using TranslateIndex_t = sal_uInt16(*)(
const sal_uInt16);
197 sal_uInt16 m_nPropMapType;
198 uno::Reference<beans::XPropertySetInfo> m_xPSInfo;
202 GetCountOrName_t m_fGetCountOrName;
203 CreateStyle_t m_fCreateStyle;
204 TranslateIndex_t m_fTranslateIndex;
205 StyleFamilyEntry(
SfxStyleFamily eFamily, sal_uInt16 nPropMapType,
SwGetPoolIdFromName aPoolId, OUString sName,
TranslateId pResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle, TranslateIndex_t fTranslateIndex)
207 , m_nPropMapType(nPropMapType)
208 , m_xPSInfo(
aSwMapProvider.GetPropertySet(nPropMapType)->getPropertySetInfo())
212 , m_fGetCountOrName(fGetCountOrName)
213 , m_fCreateStyle(fCreateStyle)
214 , m_fTranslateIndex(fTranslateIndex)
216 template<SfxStyleFamily>
static inline sal_Int32 GetCountOrName(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex);
217 template<SfxStyleFamily>
static inline css::uno::Reference<css::style::XStyle> CreateStyle(
SfxStyleSheetBasePool* pBasePool,
SwDocShell* pDocShell,
const OUString& sStyleName);
218 template<SfxStyleFamily>
static inline sal_uInt16 TranslateIndex(
const sal_uInt16 nIndex) {
return nIndex; }
222sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Char>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
237 *pString =
SwResId(STR_POOLCHR_STANDARD);
239 *pString = pFormat->GetName();
244 return nCount + nBaseCount;
248sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Para>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
255 if(pColl->IsDefault())
261 *pString = pColl->GetName();
266 return nCount + nBaseCount;
270sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Frame>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
276 if(pFormat->IsDefault() || pFormat->IsAuto())
282 *pString = pFormat->GetName();
291sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Page>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
296 for(
size_t i = 0;
i < nArrLen; ++
i)
313sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Pseudo>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
319 if(pRule->IsAutoRule())
325 *pString = pRule->GetName();
334sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Table>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
340 const sal_Int32
nCount = pAutoFormats->size();
341 if (0 <= nIndex && nIndex < nCount)
348sal_Int32 StyleFamilyEntry::GetCountOrName<SfxStyleFamily::Cell>(
const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
352 const sal_Int32 nUsedCellStylesCount = rAutoFormats.size() * rTableTemplateMap.size();
354 if (0 <= nIndex && nIndex < nCount)
356 if (nUsedCellStylesCount > nIndex)
358 const sal_Int32 nAutoFormat =
nIndex / rTableTemplateMap.size();
359 const sal_Int32 nBoxFormat = rTableTemplateMap[
nIndex % rTableTemplateMap.size()];
371sal_uInt16 StyleFamilyEntry::TranslateIndex<SfxStyleFamily::Char>(
const sal_uInt16 nIndex)
378 throw lang::IndexOutOfBoundsException();
382sal_uInt16 StyleFamilyEntry::TranslateIndex<SfxStyleFamily::Para>(
const sal_uInt16 nIndex)
397 throw lang::IndexOutOfBoundsException();
401sal_uInt16 StyleFamilyEntry::TranslateIndex<SfxStyleFamily::Page>(
const sal_uInt16 nIndex)
405 throw lang::IndexOutOfBoundsException();
409sal_uInt16 StyleFamilyEntry::TranslateIndex<SfxStyleFamily::Frame>(
const sal_uInt16 nIndex)
413 throw lang::IndexOutOfBoundsException();
417sal_uInt16 StyleFamilyEntry::TranslateIndex<SfxStyleFamily::Pseudo>(
const sal_uInt16 nIndex)
421 throw lang::IndexOutOfBoundsException();
424const std::vector<StyleFamilyEntry>& lcl_GetStyleFamilyEntries()
426 static const std::vector<StyleFamilyEntry> our_pStyleFamilyEntries{
435 return our_pStyleFamilyEntries;
438class SwStyleBase_Impl
445 std::unique_ptr<SfxItemSet> m_pMyItemSet;
446 OUString m_rStyleName;
449 SwStyleBase_Impl(
SwDoc& rSwDoc, OUString aName,
const SwAttrSet* pParentStyle)
451 , m_pOldPageDesc(nullptr)
452 , m_pItemSet(nullptr)
454 , m_pParentStyle(pParentStyle)
467 bool HasItemSet()
const
469 return m_xNewBase.is();
474 assert(m_xNewBase.is());
477 m_pMyItemSet.reset(
new SfxItemSet(m_xNewBase->GetItemSet()));
478 m_pItemSet = m_pMyItemSet.get();
481 if(!m_pItemSet->
GetParent() && m_pParentStyle)
490 struct ItemSetOverrider
492 SwStyleBase_Impl& m_rStyleBase;
494 ItemSetOverrider(SwStyleBase_Impl& rStyleBase,
SfxItemSet* pTemp)
495 : m_rStyleBase(rStyleBase)
496 , m_pOldSet(m_rStyleBase.m_pItemSet)
497 { m_rStyleBase.m_pItemSet = pTemp; }
499 { m_rStyleBase.m_pItemSet = m_pOldSet; };
503class SwStyleProperties_Impl;
504class SwXStyle :
public cppu::WeakImplHelper
507 css::beans::XPropertySet,
508 css::beans::XMultiPropertySet,
509 css::lang::XServiceInfo,
510 css::lang::XUnoTunnel,
511 css::beans::XPropertyState,
512 css::beans::XMultiPropertyStates
518 OUString m_sStyleName;
519 const StyleFamilyEntry& m_rEntry;
520 bool m_bIsDescriptor;
521 bool m_bIsConditional;
522 OUString m_sParentStyleName;
526 std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl;
527 css::uno::Reference<css::container::XNameAccess> m_xStyleFamily;
528 css::uno::Reference<css::beans::XPropertySet> m_xStyleData;
532 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
534 void PrepareStyleBase(SwStyleBase_Impl& rBase);
543 virtual ~SwXStyle()
override;
546 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
549 virtual sal_Int64 SAL_CALL getSomething(
const css::uno::Sequence< sal_Int8 >& aIdentifier )
override;
552 virtual OUString SAL_CALL getName()
override;
553 virtual void SAL_CALL setName(
const OUString& Name_)
override;
556 virtual sal_Bool SAL_CALL isUserDefined()
override;
557 virtual sal_Bool SAL_CALL isInUse()
override;
558 virtual OUString SAL_CALL getParentStyle()
override;
559 virtual void SAL_CALL setParentStyle(
const OUString& aParentStyle)
override;
562 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override;
563 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
564 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
565 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
566 { OSL_FAIL(
"not implemented"); };
567 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
568 { OSL_FAIL(
"not implemented"); };
569 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
570 { OSL_FAIL(
"not implemented"); };
571 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
572 { OSL_FAIL(
"not implemented"); };
575 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
576 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
577 virtual void SAL_CALL addPropertiesChangeListener(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
579 virtual void SAL_CALL removePropertiesChangeListener(
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
581 virtual void SAL_CALL firePropertiesChangeEvent(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
585 virtual css::beans::PropertyState SAL_CALL getPropertyState(
const OUString& PropertyName )
override;
586 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(
const css::uno::Sequence< OUString >& aPropertyName )
override;
587 virtual void SAL_CALL setPropertyToDefault(
const OUString& PropertyName )
override;
588 virtual css::uno::Any SAL_CALL getPropertyDefault(
const OUString& aPropertyName )
override;
591 virtual void SAL_CALL setAllPropertiesToDefault( )
override;
592 virtual void SAL_CALL setPropertiesToDefault(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
593 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
597 {
return {
"SwXStyle"}; };
606 const OUString& GetStyleName()
const {
return m_sStyleName;}
609 bool IsDescriptor()
const {
return m_bIsDescriptor;}
610 bool IsConditional()
const {
return m_bIsConditional;}
611 const OUString& GetParentStyleName()
const {
return m_sParentStyleName;}
614 m_bIsDescriptor =
false; m_pDoc = pDc;
618 SwDoc* GetDoc()
const {
return m_pDoc; }
620 void ApplyDescriptorProperties();
621 void SetStyleName(
const OUString& rSet){ m_sStyleName =
rSet;}
630typedef cppu::ImplInheritanceHelper< SwXStyle, css::document::XEventsSupplier> SwXFrameStyle_Base;
632 :
public SwXFrameStyle_Base
638 const OUString& rStyleName) :
640 explicit SwXFrameStyle(
SwDoc *pDoc);
642 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( )
override;
655 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
656 css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames );
662 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
663 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
665 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
666 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
669class SwStyleProperties_Impl
672 std::map<OUString, uno::Any> m_vPropertyValues;
678 bool AllowsKey(std::u16string_view rName)
682 bool SetProperty(
const OUString& rName,
const uno::Any& rValue)
684 if(!AllowsKey(rName))
686 m_vPropertyValues[rName] = rValue;
691 if(!AllowsKey(rName))
696 pAny = &m_vPropertyValues[rName];
699 bool ClearProperty(
const OUString& rName )
701 if(!AllowsKey(rName))
703 m_vPropertyValues[rName] =
uno::Any();
706 void ClearAllProperties( )
707 { m_vPropertyValues.clear(); }
708 void Apply(SwXStyle& rStyle)
710 for(
const auto& rPropertyPair : m_vPropertyValues)
712 if(rPropertyPair.second.hasValue())
713 rStyle.setPropertyValue(rPropertyPair.first, rPropertyPair.second);
718template<SfxStyleFamily eFamily>
719css::uno::Reference<css::style::XStyle> StyleFamilyEntry::CreateStyle(
SfxStyleSheetBasePool* pBasePool,
SwDocShell* pDocShell,
const OUString& sStyleName)
721 return pBasePool ?
new SwXStyle(pBasePool, eFamily, pDocShell->
GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), eFamily, false);
725css::uno::Reference<css::style::XStyle> StyleFamilyEntry::CreateStyle<SfxStyleFamily::Frame>(
SfxStyleSheetBasePool* pBasePool,
SwDocShell* pDocShell,
const OUString& sStyleName)
727 return pBasePool ?
new SwXFrameStyle(*pBasePool, pDocShell->
GetDoc(), sStyleName) : new SwXFrameStyle(pDocShell->GetDoc());
731css::uno::Reference<css::style::XStyle> StyleFamilyEntry::CreateStyle<SfxStyleFamily::Page>(
SfxStyleSheetBasePool* pBasePool,
SwDocShell* pDocShell,
const OUString& sStyleName)
733 return pBasePool ?
new SwXPageStyle(*pBasePool, pDocShell, sStyleName) : new SwXPageStyle(pDocShell);
737css::uno::Reference<css::style::XStyle> StyleFamilyEntry::CreateStyle<SfxStyleFamily::Table>(
SfxStyleSheetBasePool* ,
SwDocShell* pDocShell,
const OUString& sStyleName)
743css::uno::Reference<css::style::XStyle> StyleFamilyEntry::CreateStyle<SfxStyleFamily::Cell>(
SfxStyleSheetBasePool* ,
SwDocShell* pDocShell,
const OUString& sStyleName)
748class XStyleFamily :
public cppu::WeakImplHelper
750 container::XNameContainer,
752 container::XIndexAccess,
757 const StyleFamilyEntry& m_rEntry;
761 SwXStyle* FindStyle(std::u16string_view rStyleName)
const;
762 sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32)
763 {
return m_rEntry.getCountOrName(*m_pDocShell->
GetDoc(), pString, nIndex); };
766 auto& entries = lcl_GetStyleFamilyEntries();
767 const auto pEntry = std::find_if(entries.begin(), entries.end(),
768 [eFamily] (
const StyleFamilyEntry& e) { return e.family() == eFamily; });
769 assert(pEntry != entries.end());
774 : m_rEntry(InitEntry(eFamily))
775 , m_pBasePool(pDocShell->GetStyleSheetPool())
776 , m_pDocShell(pDocShell)
783 virtual sal_Int32 SAL_CALL getCount()
override
786 return GetCountOrName(
nullptr);
788 virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
override;
791 virtual uno::Type SAL_CALL getElementType( )
override
793 virtual sal_Bool SAL_CALL hasElements( )
override
796 throw uno::RuntimeException();
801 virtual uno::Any SAL_CALL getByName(
const OUString& Name)
override;
802 virtual uno::Sequence< OUString > SAL_CALL getElementNames()
override;
803 virtual sal_Bool SAL_CALL hasByName(
const OUString& Name)
override;
806 virtual void SAL_CALL insertByName(
const OUString& Name,
const uno::Any& Element)
override;
807 virtual void SAL_CALL replaceByName(
const OUString& Name,
const uno::Any& Element)
override;
808 virtual void SAL_CALL removeByName(
const OUString& Name)
override;
811 virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override
814 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
816 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
817 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
818 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
819 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
820 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
821 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
822 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
823 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
828 if(rHint.
GetId() == SfxHintId::Dying)
830 m_pBasePool =
nullptr;
831 m_pDocShell =
nullptr;
838 {
return {
"XStyleFamily"}; };
842 {
return {
"com.sun.star.style.StyleFamily" }; }
847 {
return {
"SwXStyleFamilies"}; }
855 {
return {
"com.sun.star.style.StyleFamilies" }; }
859 m_pDocShell(&rDocShell)
869 throw uno::RuntimeException();
870 auto& entries(lcl_GetStyleFamilyEntries());
871 const auto pEntry = std::find_if(entries.begin(), entries.end(),
872 [&
Name] (
const StyleFamilyEntry& e) { return e.name() == Name; });
873 if(pEntry == entries.end())
874 throw container::NoSuchElementException();
880 auto& entries(lcl_GetStyleFamilyEntries());
881 uno::Sequence<OUString> aNames(entries.size());
882 std::transform(entries.begin(), entries.end(),
883 aNames.getArray(), [] (
const StyleFamilyEntry& e) { return e.name(); });
889 auto& entries(lcl_GetStyleFamilyEntries());
890 return std::any_of(entries.begin(), entries.end(),
891 [&
Name] (
const StyleFamilyEntry& e) { return e.name() == Name; });
896 return lcl_GetStyleFamilyEntries().size();
901 auto& entries(lcl_GetStyleFamilyEntries());
904 throw lang::IndexOutOfBoundsException();
906 throw uno::RuntimeException();
907 auto eFamily = entries[
nIndex].family();
908 assert(eFamily != SfxStyleFamily::All);
924 const uno::Sequence< beans::PropertyValue >& aOptions)
927 if(!
IsValid() || rURL.isEmpty())
928 throw uno::RuntimeException();
935 for(
const auto& rProperty: aOptions)
939 bValue = rProperty.Value.get<
bool>();
951 else if(rProperty.Name ==
"InputStream")
953 Reference<XInputStream> xInputStream;
954 if (!(rProperty.Value >>= xInputStream))
955 throw IllegalArgumentException(
"Parameter 'InputStream' could not be converted to "
956 "type 'com::sun::star::io::XInputStream'",
965 throw io::IOException();
981 SfxItemSet const& rSet, std::u16string_view rPropName,
bool const bFooter,
985 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
991 (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
999 auto& entries(lcl_GetStyleFamilyEntries());
1000 const auto pEntry = std::find_if(entries.begin(), entries.end(),
1001 [eFamily] (
const StyleFamilyEntry& e) { return e.family() == eFamily; });
1002 return pEntry == entries.end() ? nullptr : pEntry->createStyle(
nullptr, rDoc.
GetDocShell(),
"");
1007 {
return new SwXStyle(&rDoc, SfxStyleFamily::Para,
true); };
1009uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
1013 throw lang::IndexOutOfBoundsException();
1015 throw uno::RuntimeException();
1016 OUString sStyleName;
1021 if (sStyleName.isEmpty())
1022 GetCountOrName(&sStyleName, nIndex);
1023 if(sStyleName.isEmpty())
1024 throw lang::IndexOutOfBoundsException();
1025 return getByName(sStyleName);
1028uno::Any XStyleFamily::getByName(
const OUString& rName)
1031 OUString sStyleName;
1034 throw uno::RuntimeException();
1037 throw container::NoSuchElementException(rName);
1038 uno::Reference<style::XStyle> xStyle = FindStyle(sStyleName);
1040 xStyle = m_rEntry.createStyle(m_pBasePool, m_pDocShell, m_rEntry.family() == SfxStyleFamily::Frame ? pBase->
GetName() : sStyleName);
1044uno::Sequence<OUString> XStyleFamily::getElementNames()
1048 throw uno::RuntimeException();
1049 std::vector<OUString> vRet;
1050 std::unique_ptr<SfxStyleSheetIterator> pIt = m_pBasePool->
CreateIterator(m_rEntry.family());
1055 vRet.push_back(sName);
1060sal_Bool XStyleFamily::hasByName(
const OUString& rName)
1064 throw uno::RuntimeException();
1065 OUString sStyleName;
1068 return nullptr != pBase;
1071void XStyleFamily::insertByName(
const OUString& rName,
const uno::Any& rElement)
1075 throw uno::RuntimeException();
1076 OUString sStyleName;
1080 if(pBase || pUINameBase)
1081 throw container::ElementExistException();
1082 if(rElement.getValueType().getTypeClass() != uno::TypeClass_INTERFACE)
1083 throw lang::IllegalArgumentException();
1087 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1090 throw lang::IllegalArgumentException();
1092 pNewStyle->setName(sStyleName);
1094 pNewStyle->SetPhysical();
1099 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1102 throw lang::IllegalArgumentException();
1104 pNewStyle->setName(sStyleName);
1106 pNewStyle->SetPhysical();
1110 uno::Reference<lang::XUnoTunnel> xStyleTunnel = rElement.get<uno::Reference<lang::XUnoTunnel>>();
1111 SwXStyle* pNewStyle = comphelper::getFromUnoTunnel<SwXStyle>(xStyleTunnel);
1112 if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_rEntry.family())
1113 throw lang::IllegalArgumentException();
1116 if(m_rEntry.family() == SfxStyleFamily::Para && !pNewStyle->IsConditional())
1118 m_pBasePool->
Make(sStyleName, m_rEntry.family(), nMask);
1119 pNewStyle->SetDoc(m_pDocShell->
GetDoc(), m_pBasePool);
1120 pNewStyle->SetStyleName(sStyleName);
1121 const OUString sParentStyleName(pNewStyle->GetParentStyleName());
1122 if (!sParentStyleName.isEmpty())
1125 if(pParentBase && pParentBase->
GetFamily() == m_rEntry.family() &&
1126 pParentBase->
GetPool() == m_pBasePool)
1127 m_pBasePool->
SetParent(m_rEntry.family(), sStyleName, sParentStyleName);
1130 pNewStyle->ApplyDescriptorProperties();
1134void XStyleFamily::replaceByName(
const OUString& rName,
const uno::Any& rElement)
1138 throw uno::RuntimeException();
1139 OUString sStyleName;
1144 throw container::NoSuchElementException();
1150 if (pBoxAutoFormat && sParent.isEmpty())
1152 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1154 if (!pStyleToReplaceWith)
1155 throw lang::IllegalArgumentException();
1157 pStyleToReplaceWith->setName(sStyleName);
1158 *pBoxAutoFormat = *pStyleToReplaceWith->GetBoxFormat();
1159 pStyleToReplaceWith->SetPhysical();
1166 if (pTableAutoFormat)
1168 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1170 if (!pStyleToReplaceWith)
1171 throw lang::IllegalArgumentException();
1173 pStyleToReplaceWith->setName(sStyleName);
1174 *pTableAutoFormat = *pStyleToReplaceWith->GetTableFormat();
1175 pStyleToReplaceWith->SetPhysical();
1181 throw lang::IllegalArgumentException();
1183 uno::Reference<style::XStyle> xStyle = FindStyle(pBase->
GetName());
1186 SwXStyle* pStyle = comphelper::getFromUnoTunnel<SwXStyle>(xStyle);
1188 pStyle->Invalidate();
1190 m_pBasePool->
Remove(pBase);
1191 insertByName(rName, rElement);
1195void XStyleFamily::removeByName(
const OUString& rName)
1199 throw uno::RuntimeException();
1204 throw container::NoSuchElementException();
1216 m_pBasePool->
Remove(pBase);
1219uno::Any SAL_CALL XStyleFamily::getPropertyValue(
const OUString& sPropertyName )
1221 if(sPropertyName !=
"DisplayName")
1222 throw beans::UnknownPropertyException(
"unknown property: " + sPropertyName,
static_cast<OWeakObject *
>(
this) );
1228SwXStyle* XStyleFamily::FindStyle(std::u16string_view rStyleName)
const
1231 for(
size_t i = 0;
i < nLCount; ++
i)
1234 SwXStyle* pTempStyle =
dynamic_cast<SwXStyle*
>(pListener);
1235 if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.family() && pTempStyle->GetStyleName() == rStyleName)
1243 auto& entries(lcl_GetStyleFamilyEntries());
1244 const auto pEntry = std::find_if(entries.begin(), entries.end(),
1245 [eFamily] (
const StyleFamilyEntry& e) { return e.family() == eFamily; });
1246 if(pEntry != entries.end())
1247 return pEntry->poolId();
1248 SAL_WARN(
"sw.uno",
"someone asking for all styles in unostyle.cxx!" );
1252const uno::Sequence<sal_Int8>& SwXStyle::getUnoTunnelId()
1255 return theSwXStyleUnoTunnelId.
getSeq();
1258sal_Int64 SAL_CALL SwXStyle::getSomething(
const uno::Sequence<sal_Int8>& rId)
1264uno::Sequence< OUString > SwXStyle::getSupportedServiceNames()
1267 if(SfxStyleFamily::Para == m_rEntry.family())
1270 if(m_bIsConditional)
1273 else if(SfxStyleFamily::Char == m_rEntry.family())
1275 else if(SfxStyleFamily::Page == m_rEntry.family())
1277 uno::Sequence< OUString > aRet(nCount);
1278 OUString* pArray = aRet.getArray();
1279 pArray[0] =
"com.sun.star.style.Style";
1280 switch(m_rEntry.family())
1282 case SfxStyleFamily::Char:
1283 pArray[1] =
"com.sun.star.style.CharacterStyle";
1284 pArray[2] =
"com.sun.star.style.CharacterProperties";
1285 pArray[3] =
"com.sun.star.style.CharacterPropertiesAsian";
1286 pArray[4] =
"com.sun.star.style.CharacterPropertiesComplex";
1288 case SfxStyleFamily::Page:
1289 pArray[1] =
"com.sun.star.style.PageStyle";
1290 pArray[2] =
"com.sun.star.style.PageProperties";
1292 case SfxStyleFamily::Para:
1293 pArray[1] =
"com.sun.star.style.ParagraphStyle";
1294 pArray[2] =
"com.sun.star.style.ParagraphProperties";
1295 pArray[3] =
"com.sun.star.style.ParagraphPropertiesAsian";
1296 pArray[4] =
"com.sun.star.style.ParagraphPropertiesComplex";
1297 if(m_bIsConditional)
1298 pArray[5] =
"com.sun.star.style.ConditionalParagraphStyle";
1310 if(eFamily != SfxStyleFamily::Para && eFamily != SfxStyleFamily::Page)
1312 auto aResult(rxStyleFamily->getByName(
"Standard"));
1313 if(!aResult.has<return_t>())
1315 return aResult.get<return_t>();
1321 if(rEntry.family() != SfxStyleFamily::Char
1322 && rEntry.family() != SfxStyleFamily::Para
1323 && rEntry.family() != SfxStyleFamily::Page)
1326 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(
xModel, uno::UNO_QUERY);
1327 auto xFamilies = xFamilySupplier->getStyleFamilies();
1328 auto aResult(xFamilies->getByName(rEntry.name()));
1329 if(!aResult.has<return_t>())
1331 return aResult.get<return_t>();
1336 if(!pBasePool || eFamily != SfxStyleFamily::Para)
1339 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?" );
1343 if(
nId != USHRT_MAX)
1350 auto& entries = lcl_GetStyleFamilyEntries();
1351 const auto pEntry = std::find_if(entries.begin(), entries.end(),
1352 [eFamily] (
const StyleFamilyEntry& e) { return e.family() == eFamily; });
1353 assert(pEntry != entries.end());
1360 , m_bIsDescriptor(true)
1361 , m_bIsConditional(bConditional)
1362 , m_pBasePool(nullptr)
1366 assert(!m_bIsConditional || m_rEntry.family() == SfxStyleFamily::Para);
1369 m_pPropertiesImpl = std::make_unique<SwStyleProperties_Impl>(
1375 , m_sStyleName(rStyleName)
1377 , m_bIsDescriptor(false)
1379 , m_pBasePool(pPool)
1382SwXStyle::~SwXStyle()
1387 m_pPropertiesImpl.reset();
1393 if(rHint.
GetId() == SfxHintId::Dying)
1396 m_xStyleData.clear();
1397 m_xStyleFamily.clear();
1401OUString SwXStyle::getName()
1405 return m_sStyleName;
1407 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1409 throw uno::RuntimeException();
1415void SwXStyle::setName(
const OUString& rName)
1420 m_sStyleName = rName;
1424 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1426 throw uno::RuntimeException();
1428 if(!xTmp->SetName(rName))
1429 throw uno::RuntimeException();
1430 m_sStyleName = rName;
1437 throw uno::RuntimeException();
1447 throw uno::RuntimeException();
1448 SfxStyleSheetBase* pBase = m_pBasePool->
Find(m_sStyleName, m_rEntry.family(), SfxStyleSearchBits::Used);
1449 return pBase && pBase->
IsUsed();
1452OUString SwXStyle::getParentStyle()
1457 if(!m_bIsDescriptor)
1458 throw uno::RuntimeException();
1459 return m_sParentStyleName;
1469void SwXStyle::setParentStyle(
const OUString& rParentStyle)
1472 OUString sParentStyle;
1476 if(!m_bIsDescriptor)
1477 throw uno::RuntimeException();
1478 m_sParentStyleName = sParentStyle;
1481 const auto aAny = m_xStyleFamily->getByName(sParentStyle);
1482 m_xStyleData = aAny.get<
decltype(m_xStyleData)>();
1490 throw uno::RuntimeException();
1493 xBase->GetItemSet();
1494 if(xBase->GetParent() != sParentStyle)
1496 if(!xBase->SetParent(sParentStyle))
1497 throw uno::RuntimeException();
1501uno::Reference<beans::XPropertySetInfo> SwXStyle::getPropertySetInfo()
1503 if(m_bIsConditional)
1505 assert(m_rEntry.family() == SfxStyleFamily::Para);
1507 return xCondParaRef;
1509 return m_rEntry.xPSInfo();
1512void SwXStyle::ApplyDescriptorProperties()
1514 m_bIsDescriptor =
false;
1515 m_xStyleData.clear();
1516 m_xStyleFamily.clear();
1517 m_pPropertiesImpl->Apply(*
this);
1524 STR_POOLPAGE_STANDARD,
1528 STR_POOLPAGE_ENVELOPE,
1529 STR_POOLPAGE_REGISTER,
1531 STR_POOLPAGE_FOOTNOTE,
1532 STR_POOLPAGE_ENDNOTE,
1533 STR_POOLPAGE_LANDSCAPE
1537const SwPageDesc* SwStyleBase_Impl::GetOldPageDesc()
1543 m_pOldPageDesc = pd;
1557 return m_pOldPageDesc;
1565 if(!(rEntry.
nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
1570 && o_aValue.has<sal_Int32>()
1571 && o_aValue.get<sal_Int32>() < 0)
1578 if(eMapUnit != MapUnit::Map100thMM)
1586 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1588 aSet.SetParent(&rStyleSet);
1590 rStyleSet.
Put(aSet);
1595 bool bHidden =
false;
1596 if(rValue >>= bHidden)
1599 o_rStyleBase.getNewBase()->GetItemSet();
1600 o_rStyleBase.getNewBase()->SetHidden(bHidden);
1602 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1607 o_rStyleBase.getNewBase()->GetItemSet();
1608 o_rStyleBase.getNewBase()->SetGrabBagItem(rValue);
1609 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1616 if(MID_NAME == nMemberId)
1619 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1620 if(!aValue.has<OUString>())
1621 throw lang::IllegalArgumentException();
1624 else if(MID_BITMAP == nMemberId)
1626 if(sal_uInt16(XATTR_FILLBITMAP) == rEntry.
nWID)
1629 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1631 aXFillBitmapItem.PutValue(aValue, nMemberId);
1632 rStyleSet.
Put(aXFillBitmapItem);
1636 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1641 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1643 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
1647 aChangedBrushItem->PutValue(aValue, nMemberId);
1652 if(*aChangedBrushItem == *aOriginalBrushItem && (MID_GRAPHIC_TRANSPARENT != nMemberId || !aValue.has<
bool>() || !aValue.get<
bool>()))
1660 drawing::BitmapMode
eMode;
1661 if(!(rValue >>= eMode))
1663 if(!rValue.has<sal_Int32>())
1664 throw lang::IllegalArgumentException();
1665 eMode =
static_cast<drawing::BitmapMode
>(rValue.get<sal_Int32>());
1667 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1674 if(!rValue.has<OUString>())
1675 throw lang::IllegalArgumentException();
1677 OUString sValue(rValue.get<OUString>());
1678 using printeridx_t =
decltype(pPrinter->GetPaperBinCount());
1679 printeridx_t nBin = std::numeric_limits<printeridx_t>::max();
1680 if(sValue ==
"[From printer settings]")
1681 nBin = std::numeric_limits<printeridx_t>::max()-1;
1684 for(sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; ++i)
1686 if (sValue == pPrinter->GetPaperBinName(i))
1693 if(nBin == std::numeric_limits<printeridx_t>::max())
1694 throw lang::IllegalArgumentException();
1695 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1697 aSet.SetParent(&rStyleSet);
1699 rStyleSet.
Put(aSet);
1704 auto xNumberTunnel(rValue.get<uno::Reference<container::XIndexReplace>>());
1706 throw lang::IllegalArgumentException();
1713 const SwNumFormat* pFormat = aSetRule.GetNumFormat(i);
1718 if(!rCharName.isEmpty()
1723 [&rCharName] (
SwCharFormat* pF) { return pF->GetName() == rCharName; }));
1725 aFormat.SetCharFormat(*pCharFormatIt);
1726 else if(m_pBasePool)
1728 auto pBase(m_pBasePool->
Find(rCharName, SfxStyleFamily::Char));
1730 pBase = &m_pBasePool->
Make(rCharName, SfxStyleFamily::Char);
1731 aFormat.SetCharFormat(
static_cast<SwDocStyleSheet*
>(pBase)->GetCharFormat());
1734 aFormat.SetCharFormat(
nullptr);
1738 if(!rBulletName.isEmpty()
1743 const auto pList(pFontListItem->GetFontList());
1744 FontMetric aFontInfo(pList->Get(rBulletName, WEIGHT_NORMAL, ITALIC_NONE));
1746 aFormat.SetBulletFont(&aFont);
1748 aSetRule.Set(i, &aFormat);
1750 o_rStyleBase.getNewBase()->SetNumRule(aSetRule);
1755 if(!rValue.has<sal_Int16>())
1757 const auto nLevel(rValue.get<sal_Int16>());
1758 if(0 <= nLevel && nLevel <=
MAXLEVEL)
1759 o_rStyleBase.getNewBase()->GetCollection()->SetAttrOutlineLevel(nLevel);
1764 if(!rValue.has<OUString>())
1766 const auto sValue(rValue.get<OUString>());
1769 o_rStyleBase.getNewBase()->SetFollow(aString);
1776 SwStyleBase_Impl& o_rStyleBase)
1778 if (!rValue.has<OUString>())
1780 const auto sValue(rValue.get<OUString>());
1783 o_rStyleBase.getNewBase()->SetLink(aString);
1791 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1794 if(!rValue.has<OUString>())
1795 throw lang::IllegalArgumentException();
1797 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1798 std::unique_ptr<SwFormatPageDesc> pNewDesc;
1803 const auto sValue(rValue.get<OUString>());
1806 if(pNewDesc->GetPageDesc() && pNewDesc->GetPageDesc()->GetName() == sDescName)
1808 if(sDescName.isEmpty())
1817 throw lang::IllegalArgumentException();
1818 pNewDesc->RegisterToPageDesc(*pPageDesc);
1819 rStyleSet.
Put(std::move(pNewDesc));
1825 if(m_rEntry.family() != SfxStyleFamily::Page)
1827 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1830 if(!m_pDoc || !rValue.has<drawing::TextVerticalAdjust>() || !o_rStyleBase.GetOldPageDesc())
1839 if(!rValue.has<
bool>())
1840 throw lang::IllegalArgumentException();
1841 const bool bAuto(rValue.get<
bool>());
1842 if(SfxStyleFamily::Para == m_rEntry.family())
1843 o_rStyleBase.getNewBase()->GetCollection()->SetAutoUpdateOnDirectFormat(bAuto);
1844 else if(SfxStyleFamily::Frame == m_rEntry.family())
1845 o_rStyleBase.getNewBase()->GetFrameFormat()->SetAutoUpdateOnDirectFormat(bAuto);
1851 using expectedarg_t = uno::Sequence<beans::NamedValue>;
1852 if(!rValue.has<expectedarg_t>() || !m_pBasePool)
1853 throw lang::IllegalArgumentException();
1855 const auto aNamedValues = rValue.get<expectedarg_t>();
1856 for(
const auto& rNamedValue : aNamedValues)
1858 if(!rNamedValue.Value.has<OUString>())
1859 throw lang::IllegalArgumentException();
1861 const OUString sValue(rNamedValue.Value.get<OUString>());
1863 OUString aStyleName;
1869 throw lang::IllegalArgumentException();
1870 bool bStyleFound =
false;
1871 for(
auto pBase = m_pBasePool->
First(SfxStyleFamily::Para); pBase; pBase = m_pBasePool->
Next())
1873 bStyleFound = pBase->
GetName() == aStyleName;
1878 throw lang::IllegalArgumentException();
1879 aCondItem.
SetStyle(&aStyleName, nIdx);
1881 o_rStyleBase.GetItemSet().Put(aCondItem);
1886 if(!o_rStyleBase.getNewBase()->IsUserDefined() || !rValue.has<paragraphstyle_t>())
1887 throw lang::IllegalArgumentException();
1888 static const std::map<paragraphstyle_t, SfxStyleSearchBits> aUnoToCore = []{
1889 std::map<paragraphstyle_t, SfxStyleSearchBits>
map;
1890 std::transform(std::begin(sParagraphStyleCategoryEntries), std::end(sParagraphStyleCategoryEntries), std::inserter(map,
map.end()),
1891 [] (
const ParagraphStyleCategoryEntry& rEntry) { return std::make_pair(rEntry.m_eCategory, rEntry.m_nSwStyleBits); });
1894 const auto pUnoToCoreIt(aUnoToCore.find(rValue.get<paragraphstyle_t>()));
1895 if (pUnoToCoreIt == aUnoToCore.end())
1896 throw lang::IllegalArgumentException();
1897 o_rStyleBase.getNewBase()->SetMask( pUnoToCoreIt->second|SfxStyleSearchBits::UserDefined );
1905 aReg.SetWhich(SID_SWREGISTER_MODE);
1906 o_rStyleBase.GetItemSet().Put(aReg);
1909 o_rStyleBase.GetItemSet().Put(
SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
1916 if(!rValue.has<OUString>())
1917 throw lang::IllegalArgumentException();
1918 const auto sValue(rValue.get<OUString>());
1919 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1920 std::unique_ptr<SwFormatRuby> pRuby;
1927 pRuby->SetCharFormatName(sValue);
1928 pRuby->SetCharFormatId(0);
1929 if(!sValue.isEmpty())
1932 pRuby->SetCharFormatId(nId);
1934 rStyleSet.
Put(std::move(pRuby));
1935 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1942 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1945 if(!rValue.has<OUString>())
1946 throw lang::IllegalArgumentException();
1947 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1948 std::unique_ptr<SwFormatDrop> pDrop;
1953 const auto sValue(rValue.get<OUString>());
1960 throw lang::IllegalArgumentException();
1962 pDrop->SetCharFormat(pStyle->GetCharFormat());
1963 rStyleSet.
Put(std::move(pDrop));
1970 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1972 if(SfxStyleFamily::Para == m_rEntry.family() &&
1973 o_rStyleBase.getNewBase().is() && o_rStyleBase.getNewBase()->GetCollection() &&
1975 o_rStyleBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle())
1977 OUString sNewNumberingRuleName;
1978 aValue >>= sNewNumberingRuleName;
1980 o_rStyleBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
1986 using propertytype_t =
decltype(rEntry.
nWID);
1988 static const std::map<propertytype_t, coresetter_t> aUnoToCore{
1990 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_HIDDEN>) },
1999 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>) },
2002 {
FN_UNO_LINK_STYLE, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_LINK_STYLE>) },
2007 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>) },
2008 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>) },
2013 const auto pUnoToCoreIt(aUnoToCore.find(rEntry.
nWID));
2014 if(pUnoToCoreIt != aUnoToCore.end())
2015 pUnoToCoreIt->second(*
this, rEntry, rPropSet, rValue, rBase);
2022 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, rBase);
2026void SwXStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2029 throw uno::RuntimeException();
2033 if(rPropertyNames.getLength() != rValues.getLength())
2034 throw lang::IllegalArgumentException();
2036 SwStyleBase_Impl aBaseImpl(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTextFormatColl()->GetAttrSet());
2040 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2042 throw uno::RuntimeException();
2045 if(!aBaseImpl.getNewBase().is() && !m_bIsDescriptor)
2046 throw uno::RuntimeException();
2048 const OUString* pNames = rPropertyNames.getConstArray();
2050 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2054 throw beans::UnknownPropertyException(
"Unknown property: " + pNames[nProp],
static_cast<cppu::OWeakObject*
>(
this));
2055 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2056 throw beans::PropertyVetoException (
"Property is read-only: " + pNames[nProp],
static_cast<cppu::OWeakObject*
>(
this));
2057 if(aBaseImpl.getNewBase().is())
2058 SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl);
2059 else if(!m_pPropertiesImpl->SetProperty(pNames[nProp], pValues[nProp]))
2060 throw lang::IllegalArgumentException();
2063 if(aBaseImpl.HasItemSet())
2064 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
2067void SwXStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2073 SetPropertyValues_Impl( rPropertyNames, rValues );
2075 catch (
const beans::UnknownPropertyException &rException)
2079 lang::WrappedTargetException aWExc;
2080 aWExc.TargetException <<= rException;
2092void SwXStyle::PrepareStyleBase(SwStyleBase_Impl& rBase)
2096 throw uno::RuntimeException();
2097 if(!rBase.getNewBase().is())
2111 if( bPhys && SfxStyleFamily::Char == GetFamily() &&
2124 return uno::Any(xBase->IsHidden());
2134 xBase->GetGrabBagItem(aRet);
2140 PrepareStyleBase(rBase);
2146 return uno::Any(OUString(
"[From printer settings]"));
2147 SfxPrinter* pPrinter = GetDoc()->getIDocumentDeviceAccess().getPrinter(
false);
2150 return uno::Any(pPrinter->GetPaperBinName(nBin));
2155 PrepareStyleBase(rBase);
2156 const SwNumRule* pRule = rBase.getNewBase()->GetNumRule();
2157 assert(pRule &&
"Where is the NumRule?");
2158 uno::Reference<container::XIndexReplace> xRules(
new SwXNumberingRules(*pRule, GetDoc()));
2164 PrepareStyleBase(rBase);
2165 SAL_WARN_IF(SfxStyleFamily::Para != GetFamily(),
"sw.uno",
"only paras");
2166 return uno::Any(sal_Int16(rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel()));
2171 PrepareStyleBase(rBase);
2180 SwStyleBase_Impl& rBase)
2182 PrepareStyleBase(rBase);
2192 PrepareStyleBase(rBase);
2194 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2210 PrepareStyleBase(rBase);
2213 case SfxStyleFamily::Para :
return uno::Any(rBase.getNewBase()->GetCollection()->IsAutoUpdateOnDirectFormat());
2214 case SfxStyleFamily::Frame:
return uno::Any(rBase.getNewBase()->GetFrameFormat()->IsAutoUpdateOnDirectFormat());
2221 PrepareStyleBase(rBase);
2222 return uno::Any(rBase.getNewBase()->GetName());
2227 PrepareStyleBase(rBase);
2231 for(
auto& rNV : asNonConstRange(aSeq))
2234 rNV.Value <<= OUString();
2240 beans::NamedValue* pSeq =
aSeq.getArray();
2249 pSeq[
n].Value <<= aStyleName;
2257 PrepareStyleBase(rBase);
2258 static const std::map<collectionbits_t, paragraphstyle_t> aUnoToCore = []{
2259 std::map<collectionbits_t, paragraphstyle_t>
map;
2260 std::transform(std::begin(sParagraphStyleCategoryEntries), std::end(sParagraphStyleCategoryEntries), std::inserter(map,
map.end()),
2261 [] (
const ParagraphStyleCategoryEntry& rEntry) { return std::make_pair(rEntry.m_nCollectionBits, rEntry.m_eCategory); });
2264 const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFormatId();
2266 if(pUnoToCoreIt == aUnoToCore.end())
2268 return uno::Any(pUnoToCoreIt->second);
2273 PrepareStyleBase(rBase);
2274 const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc();
2287 PrepareStyleBase(rBase);
2291 if(!aOriginalBrushItem->QueryValue(aResult, rEntry.
nMemberId))
2292 SAL_WARN(
"sw.uno",
"error getting attribute from RES_BACKGROUND.");
2298 PrepareStyleBase(rBase);
2300 if (
rSet.
Get(XATTR_FILLBMP_TILE).GetValue())
2301 return uno::Any(drawing::BitmapMode_REPEAT);
2302 if (
rSet.
Get(XATTR_FILLBMP_STRETCH).GetValue())
2303 return uno::Any(drawing::BitmapMode_STRETCH);
2304 return uno::Any(drawing::BitmapMode_NO_REPEAT);
2309 PrepareStyleBase(rBase);
2316 aResult <<= static_cast<sal_Int16>(aResult.get<sal_Int32>());
2318 if(rEntry.
nMoreFlags & PropertyMoreFlags::METRIC_ITEM && GetDoc())
2320 const SfxItemPool& rPool = GetDoc()->GetAttrPool();
2322 bool bAllowedConvert(
true);
2325 if(XATTR_FILLBMP_SIZEX == rEntry.
nWID || XATTR_FILLBMP_SIZEY == rEntry.
nWID)
2326 bAllowedConvert = !aResult.has<sal_Int32>() || aResult.get<sal_Int32>() > 0;
2327 if(eMapUnit != MapUnit::Map100thMM && bAllowedConvert)
2335 using propertytype_t =
decltype(rEntry.
nWID);
2337 static const std::map<propertytype_t, coresetter_t> aUnoToCore{
2339 {
FN_UNO_IS_PHYSICAL, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>) },
2340 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>) },
2343 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>) },
2346 {
FN_UNO_LINK_STYLE, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_LINK_STYLE>) },
2351 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>) },
2352 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>) },
2356 const auto pUnoToCoreIt(aUnoToCore.find(rEntry.
nWID));
2357 if(pUnoToCoreIt != aUnoToCore.end())
2358 return pUnoToCoreIt->second(*
this, rEntry, rPropSet, rBase);
2359 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2362uno::Any SwXStyle::GetPropertyValue_Impl(
const SfxItemPropertySet* pPropSet, SwStyleBase_Impl& rBase,
const OUString& rPropertyName)
2367 throw beans::UnknownPropertyException(
"Unknown property: " + rPropertyName,
static_cast<cppu::OWeakObject*
>(
this));
2369 return GetStyleProperty_Impl(*pEntry, *pPropSet, rBase);
2371 m_pPropertiesImpl->GetProperty(rPropertyName, pAny);
2375 switch(m_rEntry.family())
2377 case SfxStyleFamily::Pseudo:
2378 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2380 case SfxStyleFamily::Para:
2381 case SfxStyleFamily::Page:
2382 aValue = m_xStyleData->getPropertyValue(rPropertyName);
2384 case SfxStyleFamily::Char:
2385 case SfxStyleFamily::Frame:
2388 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2390 if(m_rEntry.family() == SfxStyleFamily::Char)
2405uno::Any SwXStyle::getPropertyValue(
const OUString& rPropertyName)
2409 throw uno::RuntimeException();
2410 if(!m_pBasePool && !m_bIsDescriptor)
2411 throw uno::RuntimeException();
2415 return GetPropertyValue_Impl(pPropSet, aBase, rPropertyName);
2418uno::Sequence<uno::Any> SwXStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
2422 throw uno::RuntimeException();
2423 if(!m_pBasePool && !m_bIsDescriptor)
2424 throw uno::RuntimeException();
2428 uno::Sequence<uno::Any> aValues(rPropertyNames.getLength());
2429 auto aValuesRange = asNonConstRange(aValues);
2433 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2434 aValuesRange[nProp] = GetPropertyValue_Impl(pPropSet, aBase, rPropertyNames[nProp]);
2436 catch(beans::UnknownPropertyException&)
2439 throw css::lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
2442 catch(lang::WrappedTargetException&)
2445 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
2451void SwXStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
2454 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
2455 const uno::Sequence<uno::Any> aValues(&rValue, 1);
2456 SetPropertyValues_Impl(aProperties, aValues);
2459beans::PropertyState SwXStyle::getPropertyState(
const OUString& rPropertyName)
2462 uno::Sequence<OUString> aNames{rPropertyName};
2463 uno::Sequence<beans::PropertyState> aStates = getPropertyStates(aNames);
2464 return aStates.getConstArray()[0];
2471 if(eFamily != SfxStyleFamily::Page)
2479 return &pSetItem->GetItemSet();
2481uno::Sequence<beans::PropertyState> SwXStyle::getPropertyStates(
const uno::Sequence<OUString>& rPropertyNames)
2484 uno::Sequence<beans::PropertyState> aRet(rPropertyNames.getLength());
2485 beans::PropertyState* pStates = aRet.getArray();
2488 throw uno::RuntimeException();
2491 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2493 throw uno::RuntimeException();
2495 const OUString* pNames = rPropertyNames.getConstArray();
2503 for(sal_Int32 i = 0;
i < rPropertyNames.getLength(); ++
i)
2505 const OUString sPropName = pNames[
i];
2509 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName,
static_cast<cppu::OWeakObject*
>(
this));
2515 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2522 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2525 switch(pEntry->
nWID)
2529 if(SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_STRETCH,
false)
2530 || SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_TILE,
false))
2532 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2536 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2548 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2552 pStates[
i] = beans::PropertyState_DEFAULT_VALUE;
2560 if(SfxStyleFamily::Page == m_rEntry.family() && SID_ATTR_PAGE_SIZE == pEntry->
nWID && beans::PropertyState_DIRECT_VALUE == pStates[i])
2565 if((LONG_MAX == rSize.
GetSize().
Width() && (MID_SIZE_WIDTH == nMemberId || MID_SIZE_SIZE == nMemberId)) ||
2566 (LONG_MAX == rSize.
GetSize().
Height() && MID_SIZE_HEIGHT == nMemberId))
2568 pStates[
i] = beans::PropertyState_DEFAULT_VALUE;
2577void SwXStyle::setPropertyToDefault(
const OUString& rPropertyName)
2579 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2580 setPropertiesToDefault(aSequence);
2589 case SfxStyleFamily::Char:
return xStyle->GetCharFormat();
2590 case SfxStyleFamily::Para:
return xStyle->GetCollection();
2591 case SfxStyleFamily::Frame:
return xStyle->GetFrameFormat();
2592 case SfxStyleFamily::Page:
2604void SAL_CALL SwXStyle::setPropertiesToDefault(
const uno::Sequence<OUString>& aPropertyNames)
2611 if(!m_bIsDescriptor)
2613 for(
const auto& rName : aPropertyNames)
2614 m_pPropertiesImpl->ClearProperty(rName);
2620 for(
const auto& rName : aPropertyNames)
2624 throw beans::UnknownPropertyException(
"Unknown property: " + rName,
static_cast<cppu::OWeakObject*
>(
this));
2627 throw uno::RuntimeException(
"Cannot reset: " + rName,
static_cast<cppu::OWeakObject*
>(
this));
2628 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2629 throw uno::RuntimeException(
"setPropertiesToDefault: property is read-only: " + rName,
static_cast<cppu::OWeakObject*
>(
this));
2632 static_cast<SwTextFormatColl*
>(pTargetFormat)->DeleteAssignmentToListLevelOfOutlineStyle();
2641 aSet.SetParent(&pTargetFormat->
GetAttrSet());
2643 aSet.ClearItem(XATTR_FILLBMP_STRETCH);
2644 aSet.ClearItem(XATTR_FILLBMP_TILE);
2651void SAL_CALL SwXStyle::setAllPropertiesToDefault()
2656 if(!m_bIsDescriptor)
2657 throw uno::RuntimeException();
2658 m_pPropertiesImpl->ClearAllProperties();
2663 throw uno::RuntimeException();
2664 if(SfxStyleFamily::Page == m_rEntry.family())
2666 size_t nPgDscPos(0);
2679 pPageFormat->SetPageFormatToDefault();
2681 std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>(
SwFrameSize::Fixed));
2689 aFrameSz->SetSize(aPhysSize);
2704 SwTwips nTmp = aFrameSz->GetHeight();
2705 aFrameSz->SetHeight(aFrameSz->GetWidth());
2706 aFrameSz->SetWidth(nTmp);
2709 pPageFormat->SetFormatAttr(*aFrameSz);
2713 if(SfxStyleFamily::Para == m_rEntry.family())
2715 if(xStyle->GetCollection())
2716 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2724uno::Sequence<uno::Any> SAL_CALL SwXStyle::getPropertyDefaults(
const uno::Sequence<OUString>& aPropertyNames)
2727 sal_Int32
nCount = aPropertyNames.getLength();
2728 uno::Sequence<uno::Any> aRet(nCount);
2731 auto pRet = aRet.getArray();
2734 throw uno::RuntimeException();
2741 for(sal_Int32 i = 0;
i <
nCount; ++
i)
2746 throw beans::UnknownPropertyException(
"Unknown property: " + aPropertyNames[i],
static_cast < cppu::OWeakObject *
>(
this));
2765uno::Any SwXStyle::getPropertyDefault(
const OUString& rPropertyName)
2767 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2768 return getPropertyDefaults(aSequence)[0];
2773 if((rHint.
GetId() == SfxHintId::Dying) || (rHint.
GetId() == SfxHintId::StyleSheetErased))
2775 m_pBasePool =
nullptr;
2778 else if(rHint.
GetId() == SfxHintId::StyleSheetChanged)
2790void SwXStyle::Invalidate()
2792 m_sStyleName.clear();
2793 m_pBasePool =
nullptr;
2795 m_xStyleData.clear();
2796 m_xStyleFamily.clear();
2803SwXPageStyle::SwXPageStyle(
SwDocShell* pDocSh)
2810 std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2811 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2819 SwStyleBase_Impl::ItemSetOverrider o(rBaseImpl, &rSetSet);
2820 SetStyleProperty(rEntry, rPropSet, rVal, rBaseImpl);
2827 rBaseImpl.GetItemSet().Put(std::move(pNewSetItem));
2830void SwXPageStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2833 throw uno::RuntimeException();
2835 if(rPropertyNames.getLength() != rValues.getLength())
2836 throw lang::IllegalArgumentException();
2840 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2844 throw uno::RuntimeException();
2845 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2846 if(!m_pPropertiesImpl->SetProperty(rPropertyNames[nProp], rValues[nProp]))
2847 throw lang::IllegalArgumentException();
2852 throw uno::RuntimeException();
2854 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2856 const OUString& rPropName = rPropertyNames[nProp];
2860 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName,
static_cast<cppu::OWeakObject*
>(
this));
2861 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2862 throw beans::PropertyVetoException(
"Property is read-only: " + rPropName,
static_cast<cppu::OWeakObject*
>(
this));
2864 const bool bHeader(rPropName.startsWith(
"Header"));
2865 const bool bFooter(rPropName.startsWith(
"Footer"));
2867 if(bHeader || bFooter || bFirstIsShared)
2869 switch(pEntry->
nWID)
2871 case SID_ATTR_PAGE_ON:
2877 case SID_ATTR_PAGE_DYNAMIC:
2878 case SID_ATTR_PAGE_SHARED:
2879 case SID_ATTR_PAGE_SHARED_FIRST:
2880 case SID_ATTR_PAGE_SIZE:
2887 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2889 if (pEntry->
nWID == SID_ATTR_PAGE_SHARED_FIRST)
2892 pSetItem = aBaseImpl.GetItemSet().GetItemIfSet(
2893 bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
2897 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2901 else if(pEntry->
nWID == SID_ATTR_PAGE_ON && rValues[nProp].get<
bool>())
2910 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER,
2911 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE,
2912 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED,
2913 SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST>
2914 aTempSet(*aBaseImpl.GetItemSet().GetPool());
2917 aTempSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2919 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_ON,
true));
2924 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED,
true));
2925 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST,
true));
2926 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_DYNAMIC,
true));
2928 SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet);
2929 aBaseImpl.GetItemSet().Put(aNewSetItem);
2958 aBaseImpl.GetItemSet().GetItemIfSet(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false);
2963 std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2964 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2967 rSetSet.
SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2972 SwStyleBase_Impl::ItemSetOverrider o(aBaseImpl, &rSetSet);
2973 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
2980 aBaseImpl.GetItemSet().Put(std::move(pNewSetItem));
2987 switch(pEntry->
nWID)
2989 case SID_ATTR_PAGE_DYNAMIC:
2990 case SID_ATTR_PAGE_SHARED:
2991 case SID_ATTR_PAGE_SHARED_FIRST:
2992 case SID_ATTR_PAGE_ON:
2995 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName,
static_cast<cppu::OWeakObject*
>(
this));
3004 throw lang::IllegalArgumentException();
3008 std::unique_ptr<SfxPoolItem> pNewFootnoteItem(rItem.
Clone());
3009 if(!pNewFootnoteItem->PutValue(rValues[nProp], pEntry->
nMemberId))
3010 throw lang::IllegalArgumentException();
3011 aBaseImpl.GetItemSet().Put(std::move(pNewFootnoteItem));
3016 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
3022 if(aBaseImpl.HasItemSet())
3026 if (undoGuard.UndoWasEnabled())
3029 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3032 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
3036void SwXPageStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
3043 SetPropertyValues_Impl(rPropertyNames, rValues);
3045 catch (
const beans::UnknownPropertyException &rException)
3049 lang::WrappedTargetException aWExc;
3050 aWExc.TargetException <<= rException;
3066 if(!pHeadFootFormat)
3071uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames)
3074 throw uno::RuntimeException();
3076 sal_Int32
nLength = rPropertyNames.getLength();
3077 uno::Sequence<uno::Any> aRet (nLength);
3078 auto aRetRange = asNonConstRange(aRet);
3082 throw uno::RuntimeException();
3083 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
3086 m_pPropertiesImpl->GetProperty(rPropertyNames[nProp], pAny);
3088 aRetRange[nProp] = m_xStyleData->getPropertyValue(rPropertyNames[nProp]);
3090 aRetRange[nProp] = *pAny;
3096 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
3099 throw uno::RuntimeException();
3100 for(sal_Int32 nProp = 0; nProp <
nLength; ++nProp)
3102 const OUString& rPropName = rPropertyNames[nProp];
3106 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName,
static_cast < cppu::OWeakObject *
> (
this ) );
3107 const bool bHeader(rPropName.startsWith(
"Header"));
3108 const bool bFooter(rPropName.startsWith(
"Footer"));
3110 if(bHeader || bFooter || bFirstIsShared)
3112 switch(pEntry->
nWID)
3114 case SID_ATTR_PAGE_ON:
3120 case SID_ATTR_PAGE_DYNAMIC:
3121 case SID_ATTR_PAGE_SHARED:
3122 case SID_ATTR_PAGE_SHARED_FIRST:
3123 case SID_ATTR_PAGE_SIZE:
3134 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3136 SwStyleBase_Impl::ItemSetOverrider o(aBase, &
const_cast< SfxItemSet&
>(rSetSet));
3137 aRetRange[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3140 else if(pEntry->
nWID == SID_ATTR_PAGE_ON)
3143 aRetRange[nProp] <<=
false;
3174 rSet.
GetItemIfSet(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false);
3178 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3180 SwStyleBase_Impl::ItemSetOverrider o(aBase, &
const_cast<SfxItemSet&
>(rSetSet));
3181 aRetRange[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3189 switch(pEntry->
nWID)
3192 case SID_ATTR_PAGE_DYNAMIC:
3193 case SID_ATTR_PAGE_SHARED:
3194 case SID_ATTR_PAGE_SHARED_FIRST:
3195 case SID_ATTR_PAGE_ON:
3197 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName,
static_cast < cppu::OWeakObject *
> (
this ) );
3209 sal_uInt16 nRes = 0;
3210 switch(pEntry->
nWID)
3223 const SwPageDesc* pDesc = aBase.GetOldPageDesc();
3232 if(bLeft && !bShare)
3233 pFrameFormat = &pDesc->
GetLeft();
3234 else if(bFirst && !bShareFirst)
3244 aRetRange[nProp] <<= xRet;
3256 aRetRange[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3262uno::Sequence<uno::Any> SwXPageStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
3265 uno::Sequence<uno::Any> aValues;
3270 aValues = GetPropertyValues_Impl(rPropertyNames);
3272 catch(beans::UnknownPropertyException &)
3275 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
3278 catch(lang::WrappedTargetException &)
3281 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
3288uno::Any SwXPageStyle::getPropertyValue(
const OUString& rPropertyName)
3291 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3292 return GetPropertyValues_Impl(aProperties)[0];
3295void SwXPageStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
3298 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3299 const uno::Sequence<uno::Any> aValues(&rValue, 1);
3305 if ((bIsFooter || bIsHeader) && rValue ==
uno::Any(
true))
3308 for (
size_t i = 0;
i < GetDoc()->GetPageDescCnt();
i++)
3310 auto pPageDesc = &GetDoc()->GetPageDesc(i);
3312 if (pPageDesc->
GetName() == GetStyleName())
3315 if (bIsHeader && pLeftHeader)
3322 if (bIsFooter && pLeftFooter)
3332 SetPropertyValues_Impl(aProperties, aValues);
3335SwXFrameStyle::SwXFrameStyle(
SwDoc *pDoc)
3339void SwXFrameStyle::SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
3346 SfxItemSet& rStyleSet = xStyle->GetItemSet();
3349 xStyle->SetItemSet(aSet);
3359 return &xStyle->GetItemSet().Get(eAtr);
3362uno::Reference<container::XNameReplace> SwXFrameStyle::getEvents()
3368#define AUTOSTYLE_FAMILY_COUNT 3
3379 std::vector<std::shared_ptr<SfxItemSet>>::iterator
m_aIter;
3409 throw lang::IndexOutOfBoundsException();
3411 throw uno::RuntimeException();
3413 uno::Reference< style::XAutoStyleFamily > aRef;
3460 if(
Name ==
"CharacterStyles")
3462 else if(
Name ==
"RubyStyles")
3464 else if(
Name ==
"ParagraphStyles")
3467 throw container::NoSuchElementException();
3474 OUString* pNames = aNames.getArray();
3475 pNames[0] =
"CharacterStyles";
3476 pNames[1] =
"RubyStyles";
3477 pNames[2] =
"ParagraphStyles";
3483 if(
Name ==
"CharacterStyles" ||
3484 Name ==
"RubyStyles" ||
3485 Name ==
"ParagraphStyles" )
3492 m_pDocShell( pDocSh ), m_eFamily(nFamily)
3504 if(rHint.
GetId() == SfxHintId::Dying)
3509 const uno::Sequence< beans::PropertyValue >& Values )
3513 throw uno::RuntimeException();
3542 throw uno::RuntimeException();
3547 if(!bTakeCareOfDrawingLayerFillStyle)
3549 for(
const beans::PropertyValue& rValue :
Values )
3555 catch (
const beans::UnknownPropertyException &)
3557 OSL_FAIL(
"Unknown property" );
3559 catch (
const lang::IllegalArgumentException &)
3561 OSL_FAIL(
"Illegal argument" );
3577 for(
const beans::PropertyValue& rValue :
Values )
3579 const OUString& rPropName = rValue.Name;
3585 SAL_WARN(
"sw.core",
"SwXAutoStyleFamily::insertStyle: Unknown property: " << rPropName);
3593 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
3614 if(eMapUnit != MapUnit::Map100thMM)
3621 switch(pEntry->
nWID)
3637 if(!(aValue >>= aTempName))
3639 throw lang::IllegalArgumentException();
3652 aXFillBitmapItem.
PutValue(aValue, nMemberId);
3653 aSet.
Put(aXFillBitmapItem);
3663 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
3665 aChangedBrushItem->PutValue(aValue, nMemberId);
3667 if(*aChangedBrushItem != *aOriginalBrushItem)
3677 drawing::BitmapMode
eMode;
3679 if(!(aValue >>=
eMode))
3681 sal_Int32 nMode = 0;
3683 if(!(aValue >>= nMode))
3685 throw lang::IllegalArgumentException();
3688 eMode =
static_cast<drawing::BitmapMode
>(nMode);
3706 catch (
const beans::UnknownPropertyException &)
3708 OSL_FAIL(
"Unknown property" );
3710 catch (
const lang::IllegalArgumentException &)
3712 OSL_FAIL(
"Illegal argument" );
3737 throw uno::RuntimeException();
3738 return uno::Reference< container::XEnumeration >
3753:
m_rDoc( rInitDoc ), m_eFamily( eFam )
3758 std::set< std::pair< sal_uInt16, text::RubyAdjust > > aRubyMap;
3762 std::vector<const SwFormatRuby*> vRubyItems;
3765 auto pRubyItem =
dynamic_cast<const SwFormatRuby*
>(pItem);
3766 if ( pRubyItem && pRubyItem->GetTextRuby() )
3767 vRubyItems.push_back(pRubyItem);
3771 std::pair< sal_uInt16, text::RubyAdjust > aPair( pRubyItem->GetPosition(), pRubyItem->GetAdjustment() );
3772 if ( aRubyMap.insert( aPair ).second )
3774 auto pItemSet = std::make_shared<SfxItemSetFixed<RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY>>( rAttrPool );
3775 pItemSet->Put( *pRubyItem );
3801 if(rHint.
GetId() == SfxHintId::Dying)
3808 throw uno::RuntimeException();
3809 return m_pImpl->hasMoreElements();
3815 throw uno::RuntimeException();
3817 if(
m_pImpl->hasMoreElements() )
3819 std::shared_ptr<SfxItemSet> pNextSet =
m_pImpl->nextElement();
3821 pNextSet,
m_pImpl->getFamily());
3822 aRet <<= xAutoStyle;
3836 std::shared_ptr<SfxItemSet> pInitSet,
3838: mpSet(
std::move(pInitSet)),
3852 if(rHint.
GetId() == SfxHintId::Dying)
3858 uno::Reference< beans::XPropertySetInfo > xRet;
3894 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3899 const uno::Reference< beans::XPropertyChangeListener >& )
3904 const uno::Reference< beans::XPropertyChangeListener >& )
3909 const uno::Reference< beans::XVetoableChangeListener >& )
3914 const uno::Reference< beans::XVetoableChangeListener >& )
3919 const uno::Sequence< OUString >& ,
3920 const uno::Sequence< uno::Any >& )
3925 const uno::Sequence< OUString > & rPropertyNames )
3929 throw uno::RuntimeException();
3944 const OUString* pNames = rPropertyNames.getConstArray();
3946 const sal_Int32 nLen(rPropertyNames.getLength());
3947 uno::Sequence< uno::Any > aRet( nLen );
3951 for( sal_Int32
i = 0;
i < nLen; ++
i )
3953 const OUString sPropName = pNames[
i];
3957 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName,
static_cast < cppu::OWeakObject *
> (
this ) );
3969 else if(bTakeCareOfDrawingLayerFillStyle)
3972 switch(pEntry->
nWID)
3978 if(!aOriginalBrushItem->QueryValue(aTarget, pEntry->
nMemberId))
3980 OSL_ENSURE(
false,
"Error getting attribute from RES_BACKGROUND (!)");
3990 aTarget <<= drawing::BitmapMode_REPEAT;
3994 aTarget <<= drawing::BitmapMode_STRETCH;
3998 aTarget <<= drawing::BitmapMode_NO_REPEAT;
4012 if(bTakeCareOfDrawingLayerFillStyle)
4020 aTarget <<= static_cast<sal_Int16>(
nValue);
4025 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
4046 if(eMapUnit != MapUnit::Map100thMM)
4062 const uno::Sequence< OUString >& rPropertyNames )
4065 uno::Sequence< uno::Any > aValues;
4072 catch (beans::UnknownPropertyException &)
4075 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
static_cast < cppu::OWeakObject *
> (
this ), exc );
4077 catch (lang::WrappedTargetException &)
4080 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
static_cast < cppu::OWeakObject *
> (
this ), exc );
4087 const uno::Sequence< OUString >& ,
4088 const uno::Reference< beans::XPropertiesChangeListener >& )
4093 const uno::Reference< beans::XPropertiesChangeListener >& )
4098 const uno::Sequence< OUString >& ,
4099 const uno::Reference< beans::XPropertiesChangeListener >& )
4107 uno::Sequence< OUString > aNames { rPropertyName };
4109 return aStates.getConstArray()[0];
4118 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4123 const uno::Sequence< OUString >& rPropertyNames )
4127 throw uno::RuntimeException();
4131 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4132 beans::PropertyState* pStates = aRet.getArray();
4133 const OUString* pNames = rPropertyNames.getConstArray();
4148 for(sal_Int32
i = 0;
i < rPropertyNames.getLength();
i++)
4150 const OUString sPropName = pNames[
i];
4154 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName,
static_cast < cppu::OWeakObject *
> (
this ) );
4159 if(bTakeCareOfDrawingLayerFillStyle)
4162 switch(pEntry->
nWID)
4169 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
4173 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
4184 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
4188 pStates[
i] = beans::PropertyState_DEFAULT_VALUE;
4211 const uno::Sequence< OUString >& )
4216 const uno::Sequence< OUString >& )
4224 throw uno::RuntimeException();
4226 std::vector< beans::PropertyValue > aPropertyVector;
4245 const sal_uInt16 nWID = pItem->
Which();
4251 if ( pEntry->
nWID == nWID )
4253 beans::PropertyValue aPropertyValue;
4254 aPropertyValue.Name = pEntry->
aName;
4256 aPropertyVector.push_back( aPropertyValue );
4261 const sal_Int32
nCount = aPropertyVector.size();
4262 uno::Sequence< beans::PropertyValue > aRet(
nCount );
4263 beans::PropertyValue* pProps = aRet.getArray();
4265 for (
int i = 0;
i <
nCount; ++
i, pProps++ )
4267 *pProps = aPropertyVector[
i];
4274 m_pDocShell(pDocShell), m_pTableAutoFormat(pTableAutoFormat), m_bPhysical(true)
4280 m_pDocShell(pDocShell), m_pTableAutoFormat_Impl(new
SwTableAutoFormat(rTableAutoFormatName)), m_bPhysical(false)
4289 uno::Reference<style::XStyle> xTextTableStyle;
4291 if (pAutoFormat && pAutoFormat->
GetName() == rTableAutoFormatName)
4293 xTextTableStyle.set(pAutoFormat->
GetXObject(), uno::UNO_QUERY);
4294 if (!xTextTableStyle.is())
4302 if (!xTextTableStyle.is())
4305 SAL_INFO(
"sw.uno",
"creating SwXTextTableStyle for non existing SwTableAutoFormat");
4308 return xTextTableStyle;
4314 assert(aTableTemplateMap.size() ==
STYLE_COUNT &&
"can not map SwTableAutoFormat to a SwXTextTableStyle");
4318 uno::Reference<style::XStyle> xCellStyle(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4319 if (!xCellStyle.is())
4361 for(
size_t i=0;
i < nStyles; ++
i)
4379 if (pTableAutoFormat)
4384 for (
size_t i=0;
i<aTableTemplateMap.size(); ++
i)
4387 uno::Reference<style::XStyle> xCellStyle(pOldBoxFormat->
GetXObject(), uno::UNO_QUERY);
4388 if (!xCellStyle.is())
4400 SAL_WARN(
"sw.uno",
"setting style physical, but SwTableAutoFormat in document not found");
4403 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextTableStyle");
4427 if (!pFormat->GetInfo(aGetHt))
4470 SAL_WARN(
"sw.uno",
"not implemented");
4476 bool bIsRow =
false;
4489 throw css::beans::UnknownPropertyException(rPropertyName);
4491 return uno::Any(bIsRow ? OUString(
"row") : OUString(
"column"));
4496 SAL_WARN(
"sw.uno",
"not implemented");
4501 SAL_WARN(
"sw.uno",
"not implemented");
4506 SAL_WARN(
"sw.uno",
"not implemented");
4511 SAL_WARN(
"sw.uno",
"not implemented");
4519 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4520 if(iter == rMap.end())
4521 throw css::container::NoSuchElementException();
4534 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4535 return iter != rMap.end();
4541 SAL_WARN(
"sw.uno",
"not implemented");
4548 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4549 if(iter == rMap.end())
4550 throw container::NoSuchElementException();
4551 const sal_Int32 nCellStyle = iter->second;
4553 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
4555 throw lang::IllegalArgumentException();
4558 if (!pStyleToReplaceWith)
4559 throw lang::IllegalArgumentException();
4563 throw lang::IllegalArgumentException();
4566 const sal_Int32 nBoxFormat = rTableTemplateMap[nCellStyle];
4581 SAL_WARN(
"sw.uno",
"not implemented");
4598 return {
"SwXTextTableStyle"};
4608 return {
"com.sun.star.style.Style"};
4613 m_pDocShell(pDocShell),
4614 m_pBoxAutoFormat(pBoxAutoFormat),
4615 m_sParentStyle(
std::move(sParentStyle)),
4620 m_pDocShell(pDocShell),
4638 SAL_INFO(
"sw.uno",
"trying to call SwXTextCellStyle::SetBoxFormat on non physical style");
4654 SAL_WARN(
"sw.uno",
"setting style physical, but SwBoxAutoFormat in document not found");
4657 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextCellStyle");
4671 if (!pBoxAutoFormat)
4673 sal_Int32 nTemplateIndex;
4674 OUString sParentName;
4675 std::u16string_view sCellSubName;
4677 size_t nSeparatorIndex =
sName.rfind(
'.');
4678 if (nSeparatorIndex == std::u16string_view::npos)
4681 sParentName =
sName.substr(0, nSeparatorIndex);
4682 sCellSubName =
sName.substr(nSeparatorIndex+1);
4684 if (0 > nTemplateIndex)
4693 if (!pTableAutoFormat)
4697 *pParentName = sParentName;
4698 sal_uInt32 nBoxIndex = rTableTemplateMap[nTemplateIndex];
4699 pBoxAutoFormat = &pTableAutoFormat->
GetBoxFormat(nBoxIndex);
4702 return pBoxAutoFormat;
4707 uno::Reference<style::XStyle> xTextCellStyle;
4709 if (!
sName.isEmpty())
4711 OUString sParentName;
4719 pBoxFormat = &aDefaultBoxFormat;
4722 xTextCellStyle.set(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4723 if (!xTextCellStyle.is())
4725 xTextCellStyle.set(
new SwXTextCellStyle(pDocShell, pBoxFormat, sParentName));
4732 return xTextCellStyle;
4749 uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(
m_pDocShell->
GetModel(), uno::UNO_QUERY);
4750 if (!xFamiliesSupplier.is())
4753 uno::Reference<container::XNameAccess> xFamilies = xFamiliesSupplier->getStyleFamilies();
4754 if (!xFamilies.is())
4757 uno::Reference<container::XNameAccess> xTableStyles;
4758 xFamilies->getByName(
"TableStyles") >>= xTableStyles;
4759 if (!xTableStyles.is())
4762 uno::Reference<style::XStyle> xStyle;
4767 return xStyle->isInUse();
4779 SAL_INFO(
"sw.uno",
"Changing SwXTextCellStyle parent");
4799 OUString sParentStyle;
4833 switch(pEntry->
nWID)
4866 if (aValue >>= nKey)
4896 bool bValue =
false; aValue >>= bValue;
4897 rShadowedItem.SetValue(bValue);
4904 bool bValue =
false; aValue >>= bValue;
4905 rContourItem.SetValue(bValue);
5008 SAL_WARN(
"sw.uno",
"SwXTextCellStyle unknown nWID");
5009 throw css::uno::RuntimeException();
5013 throw css::beans::UnknownPropertyException(rPropertyName);