63 #include <unoprnms.hxx>
69 #include <strings.hrc>
71 #include <unoevent.hxx>
75 #include <com/sun/star/frame/XModel.hpp>
76 #include <com/sun/star/io/IOException.hpp>
77 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
78 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
79 #include <com/sun/star/beans/PropertyAttribute.hpp>
80 #include <com/sun/star/beans/NamedValue.hpp>
81 #include <com/sun/star/drawing/BitmapMode.hpp>
82 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
83 #include <com/sun/star/lang/IllegalArgumentException.hpp>
84 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
85 #include <com/sun/star/document/XEventsSupplier.hpp>
86 #include <com/sun/star/io/XInputStream.hpp>
128 class SwStyleProperties_Impl;
130 struct StyleFamilyEntry
132 using GetCountOrName_t = std::function<sal_Int32 (const SwDoc&, OUString*, sal_Int32)>;
134 using TranslateIndex_t = std::function<sal_uInt16(const sal_uInt16)>;
136 sal_uInt16 m_nPropMapType;
137 uno::Reference<beans::XPropertySetInfo> m_xPSInfo;
140 const char* m_pResId;
141 GetCountOrName_t m_fGetCountOrName;
142 CreateStyle_t m_fCreateStyle;
143 TranslateIndex_t m_fTranslateIndex;
144 StyleFamilyEntry(
SfxStyleFamily eFamily, sal_uInt16 nPropMapType,
SwGetPoolIdFromName aPoolId, OUString
const& sName,
const char* pResId, GetCountOrName_t
const & fGetCountOrName, CreateStyle_t
const & fCreateStyle, TranslateIndex_t
const & fTranslateIndex)
146 , m_nPropMapType(nPropMapType)
147 , m_xPSInfo(
aSwMapProvider.GetPropertySet(nPropMapType)->getPropertySetInfo())
151 , m_fGetCountOrName(fGetCountOrName)
152 , m_fCreateStyle(fCreateStyle)
153 , m_fTranslateIndex(fTranslateIndex)
156 const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
158 #define nPoolChrNormalRange (RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN)
159 #define nPoolChrHtmlRange (RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN)
160 #define nPoolCollTextRange ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN)
161 #define nPoolCollListsRange ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN)
162 #define nPoolCollExtraRange ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN)
163 #define nPoolCollRegisterRange ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN)
164 #define nPoolCollDocRange ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN)
165 #define nPoolCollHtmlRange ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN)
166 #define nPoolFrameRange ( RES_POOLFRM_END - RES_POOLFRM_BEGIN)
167 #define nPoolPageRange ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN)
168 #define nPoolNumRange ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN)
169 #define nPoolCollListsStackedStart ( nPoolCollTextRange)
170 #define nPoolCollExtraStackedStart ( nPoolCollListsStackedStart + nPoolCollListsRange)
171 #define nPoolCollRegisterStackedStart ( nPoolCollExtraStackedStart + nPoolCollExtraRange)
172 #define nPoolCollDocStackedStart ( nPoolCollRegisterStackedStart + nPoolCollRegisterRange)
173 #define nPoolCollHtmlStackedStart ( nPoolCollDocStackedStart + nPoolCollDocRange)
174 using paragraphstyle_t = std::remove_const<decltype(style::ParagraphStyleCategory::TEXT)>::type;
175 using collectionbits_t = sal_uInt16;
176 struct ParagraphStyleCategoryEntry
178 paragraphstyle_t m_eCategory;
180 collectionbits_t m_nCollectionBits;
181 ParagraphStyleCategoryEntry(paragraphstyle_t eCategory,
SfxStyleSearchBits nSwStyleBits, collectionbits_t nCollectionBits)
182 : m_eCategory(eCategory)
183 , m_nSwStyleBits(nSwStyleBits)
184 , m_nCollectionBits(nCollectionBits)
187 const std::vector<ParagraphStyleCategoryEntry>* our_pParagraphStyleCategoryEntries;
197 class XStyleFamily :
public cppu::WeakImplHelper
199 container::XNameContainer,
201 container::XIndexAccess,
206 const StyleFamilyEntry& m_rEntry;
210 SwXStyle* FindStyle(std::u16string_view rStyleName)
const;
211 sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32)
212 {
return m_rEntry.m_fGetCountOrName(*m_pDocShell->
GetDoc(), pString,
nIndex); };
216 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
217 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
218 assert(pEntry != pEntries->end());
223 : m_rEntry(InitEntry(eFamily))
224 , m_pBasePool(pDocShell->GetStyleSheetPool())
225 , m_pDocShell(pDocShell)
232 virtual sal_Int32 SAL_CALL getCount()
override
235 return GetCountOrName(
nullptr);
237 virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
override;
240 virtual uno::Type SAL_CALL getElementType( )
override
242 virtual sal_Bool SAL_CALL hasElements( )
override
245 throw uno::RuntimeException();
250 virtual uno::Any SAL_CALL getByName(
const OUString& Name)
override;
251 virtual uno::Sequence< OUString > SAL_CALL getElementNames()
override;
252 virtual sal_Bool SAL_CALL hasByName(
const OUString& Name)
override;
255 virtual void SAL_CALL insertByName(
const OUString& Name,
const uno::Any& Element)
override;
256 virtual void SAL_CALL replaceByName(
const OUString& Name,
const uno::Any& Element)
override;
257 virtual void SAL_CALL removeByName(
const OUString& Name)
override;
260 virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override
263 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
265 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
266 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
267 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
268 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
269 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
270 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
271 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
272 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
277 if(rHint.
GetId() == SfxHintId::Dying)
279 m_pBasePool =
nullptr;
280 m_pDocShell =
nullptr;
287 {
return {
"XStyleFamily"}; };
291 {
return {
"com.sun.star.style.StyleFamily" }; }
299 class SwStyleBase_Impl;
300 class SwXStyle :
public cppu::WeakImplHelper
303 css::beans::XPropertySet,
304 css::beans::XMultiPropertySet,
305 css::lang::XServiceInfo,
306 css::lang::XUnoTunnel,
307 css::beans::XPropertyState,
308 css::beans::XMultiPropertyStates
314 OUString m_sStyleName;
315 const StyleFamilyEntry& m_rEntry;
316 bool m_bIsDescriptor;
317 bool m_bIsConditional;
318 OUString m_sParentStyleName;
322 std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl;
323 css::uno::Reference<css::container::XNameAccess> m_xStyleFamily;
324 css::uno::Reference<css::beans::XPropertySet> m_xStyleData;
328 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
330 void PrepareStyleBase(SwStyleBase_Impl& rBase);
339 virtual ~SwXStyle()
override;
342 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
345 virtual sal_Int64 SAL_CALL getSomething(
const css::uno::Sequence< sal_Int8 >& aIdentifier )
override;
348 virtual OUString SAL_CALL getName()
override;
349 virtual void SAL_CALL setName(
const OUString& Name_)
override;
352 virtual sal_Bool SAL_CALL isUserDefined()
override;
353 virtual sal_Bool SAL_CALL isInUse()
override;
354 virtual OUString SAL_CALL getParentStyle()
override;
355 virtual void SAL_CALL setParentStyle(
const OUString& aParentStyle)
override;
358 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override;
359 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
360 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
361 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
362 { OSL_FAIL(
"not implemented"); };
363 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
364 { OSL_FAIL(
"not implemented"); };
365 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
366 { OSL_FAIL(
"not implemented"); };
367 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
368 { OSL_FAIL(
"not implemented"); };
371 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
372 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
373 virtual void SAL_CALL addPropertiesChangeListener(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
375 virtual void SAL_CALL removePropertiesChangeListener(
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
377 virtual void SAL_CALL firePropertiesChangeEvent(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
381 virtual css::beans::PropertyState SAL_CALL getPropertyState(
const OUString& PropertyName )
override;
382 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(
const css::uno::Sequence< OUString >& aPropertyName )
override;
383 virtual void SAL_CALL setPropertyToDefault(
const OUString& PropertyName )
override;
384 virtual css::uno::Any SAL_CALL getPropertyDefault(
const OUString& aPropertyName )
override;
387 virtual void SAL_CALL setAllPropertiesToDefault( )
override;
388 virtual void SAL_CALL setPropertiesToDefault(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
389 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
393 {
return {
"SwXStyle"}; };
402 const OUString& GetStyleName()
const {
return m_sStyleName;}
405 bool IsDescriptor()
const {
return m_bIsDescriptor;}
406 bool IsConditional()
const {
return m_bIsConditional;}
407 const OUString& GetParentStyleName()
const {
return m_sParentStyleName;}
410 m_bIsDescriptor =
false; m_pDoc = pDc;
414 SwDoc* GetDoc()
const {
return m_pDoc; }
416 void ApplyDescriptorProperties();
417 void SetStyleName(
const OUString& rSet){ m_sStyleName = rSet;}
428 ,
public css::document::XEventsSupplier
434 const OUString& rStyleName) :
436 explicit SwXFrameStyle(
SwDoc *pDoc);
438 virtual void SAL_CALL acquire( ) throw()
override {SwXStyle::acquire();}
439 virtual void SAL_CALL release( ) throw()
override {SwXStyle::release();}
441 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( )
override;
442 virtual css::uno::Any SAL_CALL
queryInterface(
const css::uno::Type& aType )
override;
443 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( )
override;
446 virtual void SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
override;
448 virtual css::document::XEventsSupplier& GetEventsSupplier()
override
456 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
457 css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames );
463 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
464 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
466 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
467 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
472 using sw::XStyleFamily;
475 {
return {
"SwXStyleFamilies"}; }
483 {
return {
"com.sun.star.style.StyleFamilies" }; }
487 m_pDocShell(&rDocShell)
497 throw uno::RuntimeException();
499 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
500 [&Name] (
const StyleFamilyEntry& e) {
return e.m_sName == Name; });
501 if(pEntry == pEntries->end())
502 throw container::NoSuchElementException();
509 uno::Sequence<OUString> aNames(pEntries->size());
510 std::transform(pEntries->begin(), pEntries->end(),
511 aNames.begin(), [] (
const StyleFamilyEntry& e) {
return e.m_sName; });
518 return std::any_of(pEntries->begin(), pEntries->end(),
519 [&Name] (
const StyleFamilyEntry& e) {
return e.m_sName == Name; });
531 if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(pEntries->size()))
532 throw lang::IndexOutOfBoundsException();
534 throw uno::RuntimeException();
535 auto eFamily = (*pEntries)[nIndex].m_eFamily;
536 assert(eFamily != SfxStyleFamily::All);
539 rxFamily =
new XStyleFamily(m_pDocShell, eFamily);
540 return uno::makeAny(rxFamily);
552 const uno::Sequence< beans::PropertyValue >& aOptions)
555 if(!
IsValid() || rURL.isEmpty())
556 throw uno::RuntimeException();
563 for(
const auto& rProperty: aOptions)
567 bValue = rProperty.Value.get<
bool>();
579 else if(rProperty.Name ==
"InputStream")
582 if (!(rProperty.Value >>= xInputStream))
583 throw IllegalArgumentException(
"Parameter 'InputStream' could not be converted to "
584 "type 'com::sun::star::io::XInputStream'",
593 throw io::IOException();
599 uno::Sequence< beans::PropertyValue >
aSeq(5);
600 beans::PropertyValue* pArray = aSeq.getArray();
611 SfxItemSet const& rSet, std::u16string_view rPropName,
bool const bFooter,
615 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
616 false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
617 if (SfxItemState::SET != eState &&
621 (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
622 false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
624 return SfxItemState::SET == eState;
627 template<enum SfxStyleFamily>
631 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Char>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
636 for(
auto pFormat : *rDoc.GetCharFormats())
638 if(pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat())
645 if(rDoc.GetDfltCharFormat() == pFormat)
646 *pString =
SwResId(STR_POOLCHR_STANDARD);
648 *pString = pFormat->GetName();
653 return nCount + nBaseCount;
657 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Para>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
662 for(
auto pColl : *rDoc.GetTextFormatColls())
664 if(pColl->IsDefault())
670 *pString = pColl->GetName();
675 return nCount + nBaseCount;
679 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Frame>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
683 for(
const auto pFormat : *rDoc.GetFrameFormats())
685 if(pFormat->IsDefault() || pFormat->IsAuto())
691 *pString = pFormat->GetName();
700 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Page>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
704 const size_t nArrLen = rDoc.GetPageDescCnt();
705 for(
size_t i = 0;
i < nArrLen; ++
i)
722 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Pseudo>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
726 for(
const auto pRule : rDoc.GetNumRuleTable())
728 if(pRule->IsAutoRule())
734 *pString = pRule->GetName();
743 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Table>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
745 if (!rDoc.HasTableStyles())
748 const auto pAutoFormats = &rDoc.GetTableStyles();
749 const sal_Int32
nCount = pAutoFormats->size();
751 *pString = pAutoFormats->operator[](
nIndex).GetName();
757 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Cell>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
759 const auto& rAutoFormats = rDoc.GetTableStyles();
761 const sal_Int32 nUsedCellStylesCount = rAutoFormats.size() * rTableTemplateMap.size();
762 const sal_Int32
nCount = nUsedCellStylesCount + rDoc.GetCellStyles().size();
765 if (nUsedCellStylesCount >
nIndex)
767 const sal_Int32 nAutoFormat =
nIndex / rTableTemplateMap.size();
768 const sal_Int32 nBoxFormat = rTableTemplateMap[
nIndex % rTableTemplateMap.size()];
774 *pString = rDoc.GetCellStyles()[
nIndex-nUsedCellStylesCount].GetName();
779 template<SfxStyleFamily eFamily>
781 {
return pBasePool ?
new SwXStyle(pBasePool, eFamily, pDocShell->
GetDoc(), sStyleName) :
new SwXStyle(pDocShell->
GetDoc(), eFamily,
false); };
785 {
return pBasePool ?
new SwXStyle(pBasePool, SfxStyleFamily::Para, pDocShell->GetDoc(), sStyleName) :
new SwXStyle(pDocShell->GetDoc(), SfxStyleFamily::Para,
false); };
788 {
return pBasePool ?
new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), sStyleName) :
new SwXFrameStyle(pDocShell->GetDoc()); };
792 {
return pBasePool ?
new SwXPageStyle(*pBasePool, pDocShell, sStyleName) :
new SwXPageStyle(pDocShell); };
799 uno::Reference< css::style::XStyle> lcl_CreateStyle<SfxStyleFamily::Cell>(SfxStyleSheetBasePool* ,
SwDocShell* pDocShell,
const OUString& sStyleName)
805 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
806 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
807 return pEntry == pEntries->end() ?
nullptr : pEntry->m_fCreateStyle(
nullptr, rDoc.
GetDocShell(),
"");
812 {
return new SwXStyle(&rDoc, SfxStyleFamily::Para,
true); };
814 template<enum SfxStyleFamily>
818 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Char>(
const sal_uInt16
nIndex)
825 throw lang::IndexOutOfBoundsException();
829 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Para>(
const sal_uInt16
nIndex)
844 throw lang::IndexOutOfBoundsException();
848 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Table>(
const sal_uInt16
nIndex)
854 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Cell>(
const sal_uInt16
nIndex)
859 template<sal_uInt16 nRangeBegin, sal_uInt16 nRangeSize>
862 if(nIndex < nRangeSize)
863 return nIndex + nRangeBegin;
864 throw lang::IndexOutOfBoundsException();
867 uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
871 throw lang::IndexOutOfBoundsException();
873 throw uno::RuntimeException();
879 if (sStyleName.isEmpty())
880 GetCountOrName(&sStyleName, nIndex);
881 if(sStyleName.isEmpty())
882 throw lang::IndexOutOfBoundsException();
883 return getByName(sStyleName);
886 uno::Any XStyleFamily::getByName(
const OUString& rName)
892 throw uno::RuntimeException();
895 throw container::NoSuchElementException();
896 uno::Reference<style::XStyle> xStyle = FindStyle(sStyleName);
898 xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SfxStyleFamily::Frame ? pBase->
GetName() : sStyleName);
899 return uno::makeAny(xStyle);
902 uno::Sequence<OUString> XStyleFamily::getElementNames()
906 throw uno::RuntimeException();
907 std::vector<OUString> vRet;
908 std::unique_ptr<SfxStyleSheetIterator> pIt = m_pBasePool->
CreateIterator(m_rEntry.m_eFamily);
913 vRet.push_back(sName);
918 sal_Bool XStyleFamily::hasByName(
const OUString& rName)
922 throw uno::RuntimeException();
926 return nullptr != pBase;
929 void XStyleFamily::insertByName(
const OUString& rName,
const uno::Any& rElement)
933 throw uno::RuntimeException();
938 if(pBase || pUINameBase)
939 throw container::ElementExistException();
940 if(rElement.getValueType().getTypeClass() != uno::TypeClass_INTERFACE)
941 throw lang::IllegalArgumentException();
945 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
948 throw lang::IllegalArgumentException();
950 pNewStyle->setName(sStyleName);
952 pNewStyle->SetPhysical();
957 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
960 throw lang::IllegalArgumentException();
962 pNewStyle->setName(sStyleName);
964 pNewStyle->SetPhysical();
968 uno::Reference<lang::XUnoTunnel> xStyleTunnel = rElement.get<uno::Reference<lang::XUnoTunnel>>();
969 SwXStyle* pNewStyle =
nullptr;
970 if(xStyleTunnel.is())
972 pNewStyle =
reinterpret_cast< SwXStyle *
>(
973 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
976 if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_rEntry.m_eFamily)
977 throw lang::IllegalArgumentException();
980 if(m_rEntry.m_eFamily == SfxStyleFamily::Para && !pNewStyle->IsConditional())
981 nMask &= ~SfxStyleSearchBits::SwCondColl;
982 m_pBasePool->
Make(sStyleName, m_rEntry.m_eFamily, nMask);
983 pNewStyle->SetDoc(m_pDocShell->
GetDoc(), m_pBasePool);
984 pNewStyle->SetStyleName(sStyleName);
985 const OUString sParentStyleName(pNewStyle->GetParentStyleName());
986 if (!sParentStyleName.isEmpty())
989 if(pParentBase && pParentBase->
GetFamily() == m_rEntry.m_eFamily &&
990 pParentBase->
GetPool() == m_pBasePool)
991 m_pBasePool->
SetParent(m_rEntry.m_eFamily, sStyleName, sParentStyleName);
994 pNewStyle->ApplyDescriptorProperties();
998 void XStyleFamily::replaceByName(
const OUString& rName,
const uno::Any& rElement)
1002 throw uno::RuntimeException();
1003 OUString sStyleName;
1008 throw container::NoSuchElementException();
1014 if (pBoxAutoFormat && sParent.isEmpty())
1016 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1018 if (!pStyleToReplaceWith)
1019 throw lang::IllegalArgumentException();
1021 pStyleToReplaceWith->setName(sStyleName);
1022 *pBoxAutoFormat = *pStyleToReplaceWith->GetBoxFormat();
1023 pStyleToReplaceWith->SetPhysical();
1030 if (pTableAutoFormat)
1032 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1034 if (!pStyleToReplaceWith)
1035 throw lang::IllegalArgumentException();
1037 pStyleToReplaceWith->setName(sStyleName);
1038 *pTableAutoFormat = *pStyleToReplaceWith->GetTableFormat();
1039 pStyleToReplaceWith->SetPhysical();
1045 throw lang::IllegalArgumentException();
1047 uno::Reference<style::XStyle> xStyle = FindStyle(pBase->
GetName());
1050 SwXStyle* pStyle = comphelper::getUnoTunnelImplementation<SwXStyle>(xStyle);
1052 pStyle->Invalidate();
1054 m_pBasePool->
Remove(pBase);
1055 insertByName(rName, rElement);
1059 void XStyleFamily::removeByName(
const OUString& rName)
1063 throw uno::RuntimeException();
1068 throw container::NoSuchElementException();
1080 m_pBasePool->
Remove(pBase);
1083 uno::Any SAL_CALL XStyleFamily::getPropertyValue(
const OUString& sPropertyName )
1085 if(sPropertyName !=
"DisplayName")
1086 throw beans::UnknownPropertyException(
"unknown property: " + sPropertyName, static_cast<OWeakObject *>(
this) );
1088 return uno::makeAny(
SwResId(m_rEntry.m_pResId));
1092 SwXStyle* XStyleFamily::FindStyle(std::u16string_view rStyleName)
const
1095 for(
size_t i = 0;
i < nLCount; ++
i)
1098 SwXStyle* pTempStyle =
dynamic_cast<SwXStyle*
>(pListener);
1099 if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.m_eFamily && pTempStyle->GetStyleName() == rStyleName)
1107 if(!our_pStyleFamilyEntries)
1109 our_pStyleFamilyEntries =
new std::vector<StyleFamilyEntry>{
1110 { SfxStyleFamily::Char,
PROPERTY_MAP_CHAR_STYLE,
SwGetPoolIdFromName::ChrFmt,
"CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SfxStyleFamily::Char>, &lcl_CreateStyle<SfxStyleFamily::Char>, &lcl_TranslateIndex<SfxStyleFamily::Char> },
1111 { SfxStyleFamily::Para,
PROPERTY_MAP_PARA_STYLE,
SwGetPoolIdFromName::TxtColl,
"ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SfxStyleFamily::Para>, &lcl_CreateStyle<SfxStyleFamily::Para>, &lcl_TranslateIndex<SfxStyleFamily::Para> },
1112 { SfxStyleFamily::Page,
PROPERTY_MAP_PAGE_STYLE,
SwGetPoolIdFromName::PageDesc,
"PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SfxStyleFamily::Page>, &lcl_CreateStyle<SfxStyleFamily::Page>, &lcl_TranslateIndexRange<RES_POOLPAGE_BEGIN, nPoolPageRange> },
1113 { SfxStyleFamily::Frame,
PROPERTY_MAP_FRAME_STYLE,
SwGetPoolIdFromName::FrmFmt,
"FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SfxStyleFamily::Frame>, &lcl_CreateStyle<SfxStyleFamily::Frame>, &lcl_TranslateIndexRange<RES_POOLFRM_BEGIN, nPoolFrameRange> },
1114 { SfxStyleFamily::Pseudo,
PROPERTY_MAP_NUM_STYLE,
SwGetPoolIdFromName::NumRule,
"NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SfxStyleFamily::Pseudo>, &lcl_CreateStyle<SfxStyleFamily::Pseudo>, &lcl_TranslateIndexRange<RES_POOLNUMRULE_BEGIN, nPoolNumRange> },
1119 return our_pStyleFamilyEntries;
1124 if(!our_pParagraphStyleCategoryEntries)
1126 our_pParagraphStyleCategoryEntries =
new std::vector<ParagraphStyleCategoryEntry>{
1127 { style::ParagraphStyleCategory::TEXT, SfxStyleSearchBits::SwText,
COLL_TEXT_BITS },
1128 { style::ParagraphStyleCategory::CHAPTER, SfxStyleSearchBits::SwChapter,
COLL_DOC_BITS },
1129 { style::ParagraphStyleCategory::LIST, SfxStyleSearchBits::SwList,
COLL_LISTS_BITS },
1130 { style::ParagraphStyleCategory::INDEX, SfxStyleSearchBits::SwIndex,
COLL_REGISTER_BITS },
1131 { style::ParagraphStyleCategory::EXTRA, SfxStyleSearchBits::SwExtra,
COLL_EXTRA_BITS },
1132 { style::ParagraphStyleCategory::HTML, SfxStyleSearchBits::SwHtml,
COLL_HTML_BITS }
1135 return our_pParagraphStyleCategoryEntries;
1140 class SwStyleProperties_Impl
1143 std::map<OUString, uno::Any> m_vPropertyValues;
1146 : aPropertyEntries(rMap.getPropertyEntries())
1149 bool AllowsKey(
const OUString& rName)
1151 return std::any_of(aPropertyEntries.begin(), aPropertyEntries.end(),
1154 bool SetProperty(
const OUString& rName,
const uno::Any& rValue)
1156 if(!AllowsKey(rName))
1158 m_vPropertyValues[rName] = rValue;
1163 if(!AllowsKey(rName))
1168 pAny = &m_vPropertyValues[rName];
1171 bool ClearProperty(
const OUString& rName )
1173 if(!AllowsKey(rName))
1175 m_vPropertyValues[rName] =
uno::Any();
1178 void ClearAllProperties( )
1179 { m_vPropertyValues.clear(); }
1180 void Apply(SwXStyle& rStyle)
1182 for(
const auto& rPropertyPair : m_vPropertyValues)
1184 if(rPropertyPair.second.hasValue())
1185 rStyle.setPropertyValue(rPropertyPair.first, rPropertyPair.second);
1188 static void GetProperty(
const OUString &rPropertyName,
const uno::Reference < beans::XPropertySet > &rxPropertySet,
uno::Any& rAny )
1190 rAny = rxPropertySet->getPropertyValue( rPropertyName );
1199 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
1200 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
1201 if(pEntry != pEntries->end())
1202 return pEntry->m_aPoolId;
1203 SAL_WARN(
"sw.uno",
"someone asking for all styles in unostyle.cxx!" );
1209 class theSwXStyleUnoTunnelId :
public rtl::Static<UnoTunnelIdInit, theSwXStyleUnoTunnelId> {};
1212 const uno::Sequence<sal_Int8>& SwXStyle::getUnoTunnelId()
1217 sal_Int64 SAL_CALL SwXStyle::getSomething(
const uno::Sequence<sal_Int8>& rId)
1219 if(isUnoTunnelId<SwXStyle>(rId))
1221 return sal::static_int_cast<sal_Int64>(
reinterpret_cast<sal_IntPtr
>(
this));
1227 uno::Sequence< OUString > SwXStyle::getSupportedServiceNames()
1230 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
1233 if(m_bIsConditional)
1236 else if(SfxStyleFamily::Char == m_rEntry.m_eFamily)
1238 else if(SfxStyleFamily::Page == m_rEntry.m_eFamily)
1240 uno::Sequence< OUString > aRet(nCount);
1241 OUString* pArray = aRet.getArray();
1242 pArray[0] =
"com.sun.star.style.Style";
1243 switch(m_rEntry.m_eFamily)
1245 case SfxStyleFamily::Char:
1246 pArray[1] =
"com.sun.star.style.CharacterStyle";
1247 pArray[2] =
"com.sun.star.style.CharacterProperties";
1248 pArray[3] =
"com.sun.star.style.CharacterPropertiesAsian";
1249 pArray[4] =
"com.sun.star.style.CharacterPropertiesComplex";
1251 case SfxStyleFamily::Page:
1252 pArray[1] =
"com.sun.star.style.PageStyle";
1253 pArray[2] =
"com.sun.star.style.PageProperties";
1255 case SfxStyleFamily::Para:
1256 pArray[1] =
"com.sun.star.style.ParagraphStyle";
1257 pArray[2] =
"com.sun.star.style.ParagraphProperties";
1258 pArray[3] =
"com.sun.star.style.ParagraphPropertiesAsian";
1259 pArray[4] =
"com.sun.star.style.ParagraphPropertiesComplex";
1260 if(m_bIsConditional)
1261 pArray[5] =
"com.sun.star.style.ConditionalParagraphStyle";
1273 if(eFamily != SfxStyleFamily::Para && eFamily != SfxStyleFamily::Page)
1275 auto aResult(rxStyleFamily->getByName(
"Standard"));
1276 if(!aResult.has<return_t>())
1278 return aResult.get<return_t>();
1284 if(rEntry.m_eFamily != SfxStyleFamily::Char
1285 && rEntry.m_eFamily != SfxStyleFamily::Para
1286 && rEntry.m_eFamily != SfxStyleFamily::Page)
1289 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(
xModel, uno::UNO_QUERY);
1290 auto xFamilies = xFamilySupplier->getStyleFamilies();
1291 auto aResult(xFamilies->getByName(rEntry.m_sName));
1292 if(!aResult.has<return_t>())
1294 return aResult.get<return_t>();
1299 if(!pBasePool || eFamily != SfxStyleFamily::Para)
1302 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?" );
1314 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
1315 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
1316 assert(pEntry != pEntries->end());
1323 , m_bIsDescriptor(true)
1324 , m_bIsConditional(bConditional)
1325 , m_pBasePool(nullptr)
1329 assert(!m_bIsConditional || m_rEntry.m_eFamily == SfxStyleFamily::Para);
1332 m_pPropertiesImpl = std::make_unique<SwStyleProperties_Impl>(
1336 SwXStyle::SwXStyle(SfxStyleSheetBasePool* pPool,
SfxStyleFamily eFamily,
SwDoc* pDoc,
const OUString& rStyleName)
1338 , m_sStyleName(rStyleName)
1340 , m_bIsDescriptor(false)
1342 , m_pBasePool(pPool)
1345 SwXStyle::~SwXStyle()
1350 m_pPropertiesImpl.reset();
1356 if(rHint.
GetId() == SfxHintId::Dying)
1359 m_xStyleData.clear();
1360 m_xStyleFamily.clear();
1364 OUString SwXStyle::getName()
1368 return m_sStyleName;
1370 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1372 throw uno::RuntimeException();
1378 void SwXStyle::setName(
const OUString& rName)
1383 m_sStyleName = rName;
1387 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1389 throw uno::RuntimeException();
1391 if(!xTmp->SetName(rName))
1392 throw uno::RuntimeException();
1393 m_sStyleName = rName;
1400 throw uno::RuntimeException();
1410 throw uno::RuntimeException();
1411 SfxStyleSheetBase* pBase = m_pBasePool->
Find(m_sStyleName, m_rEntry.m_eFamily, SfxStyleSearchBits::Used);
1412 return pBase && pBase->
IsUsed();
1415 OUString SwXStyle::getParentStyle()
1420 if(!m_bIsDescriptor)
1421 throw uno::RuntimeException();
1422 return m_sParentStyleName;
1432 void SwXStyle::setParentStyle(
const OUString& rParentStyle)
1435 OUString sParentStyle;
1439 if(!m_bIsDescriptor)
1440 throw uno::RuntimeException();
1441 m_sParentStyleName = sParentStyle;
1444 const auto aAny = m_xStyleFamily->getByName(sParentStyle);
1445 m_xStyleData = aAny.get<decltype(m_xStyleData)>();
1453 throw uno::RuntimeException();
1456 xBase->GetItemSet();
1457 if(xBase->GetParent() != sParentStyle)
1459 if(!xBase->SetParent(sParentStyle))
1460 throw uno::RuntimeException();
1464 uno::Reference<beans::XPropertySetInfo> SwXStyle::getPropertySetInfo()
1466 if(m_bIsConditional)
1468 assert(m_rEntry.m_eFamily == SfxStyleFamily::Para);
1469 static uno::Reference<beans::XPropertySetInfo> xCondParaRef;
1471 return xCondParaRef;
1473 return m_rEntry.m_xPSInfo;
1476 void SwXStyle::ApplyDescriptorProperties()
1478 m_bIsDescriptor =
false;
1479 m_xStyleData.clear();
1480 m_xStyleFamily.clear();
1481 m_pPropertiesImpl->Apply(*
this);
1486 class SwStyleBase_Impl
1493 std::unique_ptr<SfxItemSet> m_pMyItemSet;
1494 OUString m_rStyleName;
1497 SwStyleBase_Impl(
SwDoc& rSwDoc,
const OUString& rName,
const SwAttrSet* pParentStyle)
1499 , m_pOldPageDesc(nullptr)
1500 , m_pItemSet(nullptr)
1501 , m_rStyleName(rName)
1502 , m_pParentStyle(pParentStyle)
1515 bool HasItemSet()
const
1517 return m_xNewBase.is();
1525 m_pMyItemSet.reset(
new SfxItemSet(m_xNewBase->GetItemSet()));
1526 m_pItemSet = m_pMyItemSet.get();
1529 if(!m_pItemSet->
GetParent() && m_pParentStyle)
1538 struct ItemSetOverrider
1540 SwStyleBase_Impl& m_rStyleBase;
1542 ItemSetOverrider(SwStyleBase_Impl& rStyleBase,
SfxItemSet* pTemp)
1543 : m_rStyleBase(rStyleBase)
1544 , m_pOldSet(m_rStyleBase.m_pItemSet)
1545 { m_rStyleBase.m_pItemSet = pTemp; }
1547 { m_rStyleBase.m_pItemSet = m_pOldSet; };
1554 STR_POOLPAGE_STANDARD,
1558 STR_POOLPAGE_ENVELOPE,
1559 STR_POOLPAGE_REGISTER,
1561 STR_POOLPAGE_FOOTNOTE,
1562 STR_POOLPAGE_ENDNOTE,
1563 STR_POOLPAGE_LANDSCAPE
1567 const SwPageDesc* SwStyleBase_Impl::GetOldPageDesc()
1573 m_pOldPageDesc = pd;
1587 return m_pOldPageDesc;
1595 if(!(rEntry.
nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
1600 && o_aValue.has<sal_Int32>()
1601 && o_aValue.get<sal_Int32>() < 0)
1608 if(eMapUnit != MapUnit::Map100thMM)
1616 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1618 aSet.SetParent(&rStyleSet);
1619 rPropSet.setPropertyValue(rEntry, rValue, aSet);
1620 rStyleSet.
Put(aSet);
1625 bool bHidden =
false;
1626 if(rValue >>= bHidden)
1629 o_rStyleBase.getNewBase()->GetItemSet();
1630 o_rStyleBase.getNewBase()->SetHidden(bHidden);
1632 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1637 o_rStyleBase.getNewBase()->GetItemSet();
1638 o_rStyleBase.getNewBase()->SetGrabBagItem(rValue);
1639 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1646 if(MID_NAME == nMemberId)
1649 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1650 if(!aValue.has<OUString>())
1651 throw lang::IllegalArgumentException();
1654 else if(MID_BITMAP == nMemberId)
1656 if(sal_uInt16(XATTR_FILLBITMAP) == rEntry.nWID)
1659 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1661 aXFillBitmapItem.PutValue(aValue, nMemberId);
1662 rStyleSet.
Put(aXFillBitmapItem);
1666 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1671 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1673 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
1677 aChangedBrushItem->PutValue(aValue, nMemberId);
1682 if(*aChangedBrushItem == *aOriginalBrushItem && (MID_GRAPHIC_TRANSPARENT != nMemberId || !aValue.has<
bool>() || !aValue.get<
bool>()))
1688 void SwXStyle::SetPropertyValue<OWN_ATTR_FILLBMP_MODE>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1690 drawing::BitmapMode
eMode;
1691 if(!(rValue >>= eMode))
1693 if(!rValue.has<sal_Int32>())
1694 throw lang::IllegalArgumentException();
1695 eMode =
static_cast<drawing::BitmapMode
>(rValue.get<sal_Int32>());
1697 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1702 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAPER_BIN)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1704 if(!rValue.has<OUString>())
1705 throw lang::IllegalArgumentException();
1706 SfxPrinter* pPrinter = m_pDoc->getIDocumentDeviceAccess().getPrinter(
true);
1707 OUString sValue(rValue.get<OUString>());
1708 using printeridx_t = decltype(pPrinter->GetPaperBinCount());
1709 printeridx_t nBin = std::numeric_limits<printeridx_t>::max();
1710 if(sValue ==
"[From printer settings]")
1711 nBin = std::numeric_limits<printeridx_t>::max()-1;
1714 for(sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount();
i < nEnd; ++
i)
1716 if (sValue == pPrinter->GetPaperBinName(i))
1723 if(nBin == std::numeric_limits<printeridx_t>::max())
1724 throw lang::IllegalArgumentException();
1725 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1727 aSet.SetParent(&rStyleSet);
1728 rPropSet.setPropertyValue(rEntry, uno::makeAny(static_cast<sal_Int8>(nBin == std::numeric_limits<printeridx_t>::max()-1 ? -1 : nBin)), aSet);
1729 rStyleSet.
Put(aSet);
1732 void SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1734 if(!rValue.has<uno::Reference<container::XIndexReplace>>() || !rValue.has<uno::Reference<lang::XUnoTunnel>>())
1735 throw lang::IllegalArgumentException();
1736 auto xNumberTunnel(rValue.get<uno::Reference<lang::XUnoTunnel>>());
1743 const SwNumFormat* pFormat = aSetRule.GetNumFormat(i);
1748 if(!rCharName.isEmpty()
1752 auto pCharFormatIt(std::find_if(m_pDoc->GetCharFormats()->begin(), m_pDoc->GetCharFormats()->end(),
1753 [&rCharName] (
SwCharFormat* pF) {
return pF->GetName() == rCharName; }));
1754 if(pCharFormatIt != m_pDoc->GetCharFormats()->end())
1755 aFormat.SetCharFormat(*pCharFormatIt);
1756 else if(m_pBasePool)
1758 auto pBase(m_pBasePool->
Find(rCharName, SfxStyleFamily::Char));
1760 pBase = &m_pBasePool->
Make(rCharName, SfxStyleFamily::Char);
1761 aFormat.SetCharFormat(static_cast<SwDocStyleSheet*>(pBase)->GetCharFormat());
1764 aFormat.SetCharFormat(
nullptr);
1768 if(!rBulletName.isEmpty()
1772 const auto pFontListItem(static_cast<const SvxFontListItem*>(m_pDoc->GetDocShell()->GetItem(SID_ATTR_CHAR_FONTLIST)));
1773 const auto pList(pFontListItem->GetFontList());
1774 FontMetric aFontInfo(pList->Get(rBulletName, WEIGHT_NORMAL, ITALIC_NONE));
1776 aFormat.SetBulletFont(&aFont);
1778 aSetRule.Set(i, &aFormat);
1780 o_rStyleBase.getNewBase()->SetNumRule(aSetRule);
1783 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_OUTLINELEVEL)>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1785 if(!rValue.has<sal_Int16>())
1787 const auto nLevel(rValue.get<sal_Int16>());
1788 if(0 <= nLevel && nLevel <= MAXLEVEL)
1789 o_rStyleBase.getNewBase()->GetCollection()->SetAttrOutlineLevel(nLevel);
1792 void SwXStyle::SetPropertyValue<FN_UNO_FOLLOW_STYLE>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1794 if(!rValue.has<OUString>())
1796 const auto sValue(rValue.get<OUString>());
1799 o_rStyleBase.getNewBase()->SetFollow(aString);
1802 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAGEDESC)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1806 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1809 if(!rValue.has<OUString>())
1810 throw lang::IllegalArgumentException();
1812 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1813 std::unique_ptr<SwFormatPageDesc> pNewDesc;
1816 pNewDesc.reset(
new SwFormatPageDesc(*static_cast<const SwFormatPageDesc*>(pItem)));
1819 const auto sValue(rValue.get<OUString>());
1822 if(pNewDesc->GetPageDesc() && pNewDesc->GetPageDesc()->GetName() == sDescName)
1824 if(sDescName.isEmpty())
1833 throw lang::IllegalArgumentException();
1834 pNewDesc->RegisterToPageDesc(*pPageDesc);
1835 rStyleSet.
Put(*pNewDesc);
1839 void SwXStyle::SetPropertyValue<sal_uInt16(RES_TEXT_VERT_ADJUST)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1841 if(m_rEntry.m_eFamily != SfxStyleFamily::Page)
1843 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1846 if(!m_pDoc || !rValue.has<drawing::TextVerticalAdjust>() || !o_rStyleBase.GetOldPageDesc())
1848 SwPageDesc* pPageDesc = m_pDoc->FindPageDesc(o_rStyleBase.GetOldPageDesc()->GetName());
1853 void SwXStyle::SetPropertyValue<FN_UNO_IS_AUTO_UPDATE>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1855 if(!rValue.has<
bool>())
1856 throw lang::IllegalArgumentException();
1857 const bool bAuto(rValue.get<
bool>());
1858 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
1859 o_rStyleBase.getNewBase()->GetCollection()->SetAutoUpdateFormat(bAuto);
1860 else if(SfxStyleFamily::Frame == m_rEntry.m_eFamily)
1861 o_rStyleBase.getNewBase()->GetFrameFormat()->SetAutoUpdateFormat(bAuto);
1864 void SwXStyle::SetPropertyValue<FN_UNO_PARA_STYLE_CONDITIONS>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1867 using expectedarg_t = uno::Sequence<beans::NamedValue>;
1868 if(!rValue.has<expectedarg_t>() || !m_pBasePool)
1869 throw lang::IllegalArgumentException();
1871 const auto aNamedValues = rValue.get<expectedarg_t>();
1872 for(
const auto& rNamedValue : aNamedValues)
1874 if(!rNamedValue.Value.has<OUString>())
1875 throw lang::IllegalArgumentException();
1877 const OUString sValue(rNamedValue.Value.get<OUString>());
1879 OUString aStyleName;
1885 throw lang::IllegalArgumentException();
1886 bool bStyleFound =
false;
1887 for(
auto pBase = m_pBasePool->
First(SfxStyleFamily::Para); pBase; pBase = m_pBasePool->
Next())
1889 bStyleFound = pBase->
GetName() == aStyleName;
1894 throw lang::IllegalArgumentException();
1895 aCondItem.
SetStyle(&aStyleName, nIdx);
1897 o_rStyleBase.GetItemSet().Put(aCondItem);
1900 void SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1902 if(!o_rStyleBase.getNewBase()->IsUserDefined() || !rValue.has<paragraphstyle_t>())
1903 throw lang::IllegalArgumentException();
1904 static std::unique_ptr<std::map<paragraphstyle_t, SfxStyleSearchBits>> pUnoToCore;
1907 pUnoToCore.reset(
new std::map<paragraphstyle_t, SfxStyleSearchBits>);
1909 std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
1910 [] (
const ParagraphStyleCategoryEntry& rEntry) {
return std::pair<paragraphstyle_t, SfxStyleSearchBits>(rEntry.m_eCategory, rEntry.m_nSwStyleBits); });
1912 const auto pUnoToCoreIt(pUnoToCore->find(rValue.get<paragraphstyle_t>()));
1913 if(pUnoToCoreIt == pUnoToCore->end())
1914 throw lang::IllegalArgumentException();
1915 o_rStyleBase.getNewBase()->SetMask( pUnoToCoreIt->second|SfxStyleSearchBits::UserDefined );
1918 void SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1923 aReg.
SetWhich(SID_SWREGISTER_MODE);
1924 o_rStyleBase.GetItemSet().Put(aReg);
1927 o_rStyleBase.GetItemSet().Put(
SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
1930 void SwXStyle::SetPropertyValue<sal_uInt16(RES_TXTATR_CJK_RUBY)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1934 if(!rValue.has<OUString>())
1935 throw lang::IllegalArgumentException();
1936 const auto sValue(rValue.get<OUString>());
1937 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1938 std::unique_ptr<SwFormatRuby> pRuby;
1941 pRuby.reset(
new SwFormatRuby(*static_cast<const SwFormatRuby*>(pItem)));
1946 pRuby->SetCharFormatName(sValue);
1947 pRuby->SetCharFormatId(0);
1948 if(!sValue.isEmpty())
1951 pRuby->SetCharFormatId(nId);
1953 rStyleSet.
Put(*pRuby);
1954 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1957 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_DROP)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1961 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1964 if(!rValue.has<OUString>())
1965 throw lang::IllegalArgumentException();
1966 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1967 std::unique_ptr<SwFormatDrop> pDrop;
1970 pDrop.reset(
new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem)));
1973 const auto sValue(rValue.get<OUString>());
1976 auto pStyle(static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)));
1978 if(!pStyle || pStyle->GetCharFormat() == m_pDoc->GetDfltCharFormat() )
1980 throw lang::IllegalArgumentException();
1982 pDrop->SetCharFormat(pStyle->GetCharFormat());
1983 rStyleSet.
Put(*pDrop);
1986 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_NUMRULE)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1990 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1992 if(SfxStyleFamily::Para == m_rEntry.m_eFamily &&
1993 o_rStyleBase.getNewBase().is() && o_rStyleBase.getNewBase()->GetCollection() &&
1995 o_rStyleBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle())
1997 OUString sNewNumberingRuleName;
1998 aValue >>= sNewNumberingRuleName;
1999 if(sNewNumberingRuleName.isEmpty() || sNewNumberingRuleName != m_pDoc->GetOutlineNumRule()->GetName())
2000 o_rStyleBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2004 void SwXStyle::SetStyleProperty(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& rBase)
2006 using propertytype_t = decltype(rEntry.
nWID);
2007 using coresetter_t = std::function<void(SwXStyle&, const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, const uno::Any&, SwStyleBase_Impl&)>;
2008 static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
2011 pUnoToCore.reset(
new std::map<propertytype_t, coresetter_t> {
2013 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_HIDDEN>) },
2022 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>) },
2029 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>) },
2030 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>) },
2036 const auto pUnoToCoreIt(pUnoToCore->find(rEntry.
nWID));
2037 if(pUnoToCoreIt != pUnoToCore->end())
2038 pUnoToCoreIt->second(*
this, rEntry, rPropSet, rValue, rBase);
2045 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, rBase);
2049 void SwXStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2052 throw uno::RuntimeException();
2053 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2056 if(rPropertyNames.getLength() != rValues.getLength())
2057 throw lang::IllegalArgumentException();
2059 SwStyleBase_Impl aBaseImpl(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTextFormatColl()->GetAttrSet());
2063 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2065 throw uno::RuntimeException();
2066 aBaseImpl.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2068 if(!aBaseImpl.getNewBase().is() && !m_bIsDescriptor)
2069 throw uno::RuntimeException();
2071 const OUString* pNames = rPropertyNames.getConstArray();
2073 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2075 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(pNames[nProp]);
2077 throw beans::UnknownPropertyException(
"Unknown property: " + pNames[nProp], static_cast<cppu::OWeakObject*>(
this));
2078 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2079 throw beans::PropertyVetoException (
"Property is read-only: " + pNames[nProp], static_cast<cppu::OWeakObject*>(
this));
2080 if(aBaseImpl.getNewBase().is())
2081 SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl);
2082 else if(!m_pPropertiesImpl->SetProperty(pNames[nProp], pValues[nProp]))
2083 throw lang::IllegalArgumentException();
2086 if(aBaseImpl.HasItemSet())
2087 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
2090 void SwXStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2096 SetPropertyValues_Impl( rPropertyNames, rValues );
2098 catch (
const beans::UnknownPropertyException &rException)
2102 lang::WrappedTargetException aWExc;
2103 aWExc.TargetException <<= rException;
2115 void SwXStyle::PrepareStyleBase(SwStyleBase_Impl& rBase)
2119 throw uno::RuntimeException();
2120 if(!rBase.getNewBase().is())
2121 rBase.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2125 uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase);
2127 uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2131 return uno::makeAny(
false);
2134 if( bPhys && SfxStyleFamily::Char == GetFamily() &&
2138 return uno::makeAny<bool>(bPhys);
2141 uno::Any SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2145 return uno::makeAny(
false);
2147 return uno::makeAny(xBase->IsHidden());
2150 uno::Any SwXStyle::GetStyleProperty<FN_UNO_STYLE_INTEROP_GRAB_BAG>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2157 xBase->GetGrabBagItem(aRet);
2161 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAPER_BIN)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2163 PrepareStyleBase(rBase);
2166 rPropSet.getPropertyValue(rEntry, rSet, aValue);
2169 return uno::makeAny<OUString>(
"[From printer settings]");
2170 SfxPrinter* pPrinter = GetDoc()->getIDocumentDeviceAccess().getPrinter(
false);
2173 return uno::makeAny(pPrinter->GetPaperBinName(nBin));
2176 uno::Any SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2178 PrepareStyleBase(rBase);
2179 const SwNumRule* pRule = rBase.getNewBase()->GetNumRule();
2180 assert(pRule &&
"Where is the NumRule?");
2181 uno::Reference<container::XIndexReplace> xRules(
new SwXNumberingRules(*pRule, GetDoc()));
2182 return uno::makeAny<uno::Reference<container::XIndexReplace>>(xRules);
2185 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PARATR_OUTLINELEVEL)>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2187 PrepareStyleBase(rBase);
2188 SAL_WARN_IF(SfxStyleFamily::Para != GetFamily(),
"sw.uno",
"only paras");
2189 return uno::makeAny<sal_Int16>(rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel());
2192 uno::Any SwXStyle::GetStyleProperty<FN_UNO_FOLLOW_STYLE>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2194 PrepareStyleBase(rBase);
2197 return uno::makeAny(aString);
2200 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAGEDESC)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2202 PrepareStyleBase(rBase);
2204 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2207 if(SfxItemState::SET != rBase.GetItemSet().GetItemState(
RES_PAGEDESC,
true, &pItem))
2214 return uno::makeAny(aString);
2217 uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_AUTO_UPDATE>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2219 PrepareStyleBase(rBase);
2222 case SfxStyleFamily::Para :
return uno::makeAny<bool>(rBase.getNewBase()->GetCollection()->IsAutoUpdateFormat());
2223 case SfxStyleFamily::Frame:
return uno::makeAny<bool>(rBase.getNewBase()->GetFrameFormat()->IsAutoUpdateFormat());
2228 uno::Any SwXStyle::GetStyleProperty<FN_UNO_DISPLAY_NAME>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2230 PrepareStyleBase(rBase);
2231 return uno::makeAny(rBase.getNewBase()->GetName());
2234 uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2236 PrepareStyleBase(rBase);
2239 sal_uInt16 nIndex = 0;
2240 for(
auto& rNV : aSeq)
2243 rNV.Value <<= OUString();
2249 beans::NamedValue* pSeq = aSeq.getArray();
2258 pSeq[
n].Value <<= aStyleName;
2261 return uno::makeAny(aSeq);
2264 uno::Any SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2266 PrepareStyleBase(rBase);
2267 static std::unique_ptr<std::map<collectionbits_t, paragraphstyle_t>> pUnoToCore;
2270 pUnoToCore.reset(
new std::map<collectionbits_t, paragraphstyle_t>);
2272 std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
2273 [] (
const ParagraphStyleCategoryEntry& rEntry) {
return std::pair<collectionbits_t, paragraphstyle_t>(rEntry.m_nCollectionBits, rEntry.m_eCategory); });
2275 const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFormatId();
2277 if(pUnoToCoreIt == pUnoToCore->end())
2278 return uno::makeAny<sal_Int16>(-1);
2279 return uno::makeAny(pUnoToCoreIt->second);
2282 uno::Any SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2284 PrepareStyleBase(rBase);
2285 const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc();
2287 return uno::makeAny(OUString());
2290 return uno::makeAny(OUString());
2293 return uno::makeAny(aName);
2296 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_BACKGROUND)>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2298 PrepareStyleBase(rBase);
2302 if(!aOriginalBrushItem->QueryValue(aResult, rEntry.nMemberId))
2303 SAL_WARN(
"sw.uno",
"error getting attribute from RES_BACKGROUND.");
2307 uno::Any SwXStyle::GetStyleProperty<OWN_ATTR_FILLBMP_MODE>(
const SfxItemPropertySimpleEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2309 PrepareStyleBase(rBase);
2311 if (rSet.
Get(XATTR_FILLBMP_TILE).GetValue())
2312 return uno::makeAny(drawing::BitmapMode_REPEAT);
2313 if (rSet.
Get(XATTR_FILLBMP_STRETCH).GetValue())
2314 return uno::makeAny(drawing::BitmapMode_STRETCH);
2315 return uno::makeAny(drawing::BitmapMode_NO_REPEAT);
2318 uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2320 PrepareStyleBase(rBase);
2323 rPropSet.getPropertyValue(rEntry, rSet, aResult);
2327 aResult <<= static_cast<sal_Int16>(aResult.get<sal_Int32>());
2329 if(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM && GetDoc())
2331 const SfxItemPool& rPool = GetDoc()->GetAttrPool();
2333 bool bAllowedConvert(
true);
2336 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
2337 bAllowedConvert = !aResult.has<sal_Int32>() || aResult.get<sal_Int32>() > 0;
2338 if(eMapUnit != MapUnit::Map100thMM && bAllowedConvert)
2344 uno::Any SwXStyle::GetStyleProperty_Impl(
const SfxItemPropertySimpleEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2346 using propertytype_t = decltype(rEntry.
nWID);
2347 using coresetter_t = std::function<uno::Any(SwXStyle&, const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, SwStyleBase_Impl&)>;
2348 static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
2351 pUnoToCore.reset(
new std::map<propertytype_t, coresetter_t> {
2353 {
FN_UNO_IS_PHYSICAL, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>) },
2354 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>) },
2357 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>) },
2364 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>) },
2365 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>) },
2370 const auto pUnoToCoreIt(pUnoToCore->find(rEntry.
nWID));
2371 if(pUnoToCoreIt != pUnoToCore->end())
2372 return pUnoToCoreIt->second(*
this, rEntry, rPropSet, rBase);
2373 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2376 uno::Any SwXStyle::GetPropertyValue_Impl(
const SfxItemPropertySet* pPropSet, SwStyleBase_Impl& rBase,
const OUString& rPropertyName)
2379 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(rPropertyName);
2381 throw beans::UnknownPropertyException(
"Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(
this));
2383 return GetStyleProperty_Impl(*pEntry, *pPropSet, rBase);
2385 m_pPropertiesImpl->GetProperty(rPropertyName, pAny);
2389 switch(m_rEntry.m_eFamily)
2391 case SfxStyleFamily::Pseudo:
2392 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2394 case SfxStyleFamily::Para:
2395 case SfxStyleFamily::Page:
2396 SwStyleProperties_Impl::GetProperty(rPropertyName, m_xStyleData, aValue);
2398 case SfxStyleFamily::Char:
2399 case SfxStyleFamily::Frame:
2402 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2404 if(m_rEntry.m_eFamily == SfxStyleFamily::Char)
2405 pFormat = m_pDoc->GetDfltCharFormat();
2407 pFormat = m_pDoc->GetDfltFrameFormat();
2419 uno::Any SwXStyle::getPropertyValue(
const OUString& rPropertyName)
2423 throw uno::RuntimeException();
2424 if(!m_pBasePool && !m_bIsDescriptor)
2425 throw uno::RuntimeException();
2426 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2428 SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet());
2429 return GetPropertyValue_Impl(pPropSet, aBase, rPropertyName);
2432 uno::Sequence<uno::Any> SwXStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
2436 throw uno::RuntimeException();
2437 if(!m_pBasePool && !m_bIsDescriptor)
2438 throw uno::RuntimeException();
2439 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2441 SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet());
2442 uno::Sequence<uno::Any> aValues(rPropertyNames.getLength());
2446 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2447 aValues[nProp] = GetPropertyValue_Impl(pPropSet, aBase, rPropertyNames[nProp]);
2449 catch(beans::UnknownPropertyException&)
2452 throw css::lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
2453 static_cast < cppu::OWeakObject * > (
this ), anyEx );
2455 catch(lang::WrappedTargetException&)
2458 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
2459 static_cast < cppu::OWeakObject * > (
this ), anyEx );
2464 void SwXStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
2467 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
2468 const uno::Sequence<uno::Any> aValues(&rValue, 1);
2469 SetPropertyValues_Impl(aProperties, aValues);
2472 beans::PropertyState SwXStyle::getPropertyState(
const OUString& rPropertyName)
2475 uno::Sequence<OUString> aNames{rPropertyName};
2476 uno::Sequence<beans::PropertyState> aStates = getPropertyStates(aNames);
2477 return aStates.getConstArray()[0];
2484 if(eFamily != SfxStyleFamily::Page)
2486 const bool isFooter = rPropertyName.startsWith(
"Footer");
2492 return &pSetItem->GetItemSet();
2494 uno::Sequence<beans::PropertyState> SwXStyle::getPropertyStates(
const uno::Sequence<OUString>& rPropertyNames)
2497 uno::Sequence<beans::PropertyState> aRet(rPropertyNames.getLength());
2498 beans::PropertyState* pStates = aRet.getArray();
2501 throw uno::RuntimeException();
2504 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2506 throw uno::RuntimeException();
2508 const OUString* pNames = rPropertyNames.getConstArray();
2510 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2514 const SfxItemSet& rSet = xStyle->GetItemSet();
2516 for(sal_Int32 i = 0;
i < rPropertyNames.getLength(); ++
i)
2518 const OUString sPropName = pNames[
i];
2519 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(sPropName);
2522 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast<cppu::OWeakObject*>(
this));
2527 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2534 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2537 switch(pEntry->
nWID)
2541 if(SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_STRETCH,
false)
2542 || SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_TILE,
false))
2544 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2548 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2560 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2564 pStates[
i] = beans::PropertyState_DEFAULT_VALUE;
2572 if(SfxStyleFamily::Page == m_rEntry.m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->
nWID && beans::PropertyState_DIRECT_VALUE == pStates[i])
2580 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2589 void SwXStyle::setPropertyToDefault(
const OUString& rPropertyName)
2591 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2592 setPropertiesToDefault(aSequence);
2601 case SfxStyleFamily::Char:
return xStyle->GetCharFormat();
2602 case SfxStyleFamily::Para:
return xStyle->GetCollection();
2603 case SfxStyleFamily::Frame:
return xStyle->GetFrameFormat();
2604 case SfxStyleFamily::Page:
2616 void SAL_CALL SwXStyle::setPropertiesToDefault(
const uno::Sequence<OUString>& aPropertyNames)
2623 if(!m_bIsDescriptor)
2625 for(
const auto& rName : aPropertyNames)
2626 m_pPropertiesImpl->ClearProperty(rName);
2629 const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2632 for(
const auto& rName : aPropertyNames)
2634 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(rName);
2636 throw beans::UnknownPropertyException(
"Unknown property: " + rName, static_cast<cppu::OWeakObject*>(
this));
2638 throw uno::RuntimeException(
"Cannot reset: " + rName, static_cast<cppu::OWeakObject*>(
this));
2639 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2640 throw uno::RuntimeException(
"setPropertiesToDefault: property is read-only: " + rName, static_cast<cppu::OWeakObject*>(
this));
2643 static_cast<SwTextFormatColl*
>(pTargetFormat)->DeleteAssignmentToListLevelOfOutlineStyle();
2652 aSet.SetParent(&pTargetFormat->
GetAttrSet());
2654 aSet.ClearItem(XATTR_FILLBMP_STRETCH);
2655 aSet.ClearItem(XATTR_FILLBMP_TILE);
2662 void SAL_CALL SwXStyle::setAllPropertiesToDefault()
2667 if(!m_bIsDescriptor)
2668 throw uno::RuntimeException();
2669 m_pPropertiesImpl->ClearAllProperties();
2674 throw uno::RuntimeException();
2675 if(SfxStyleFamily::Page == m_rEntry.m_eFamily)
2677 size_t nPgDscPos(0);
2678 SwPageDesc* pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName(), &nPgDscPos);
2687 SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos);
2695 aUL.SetUpper(static_cast<sal_uInt16>(nSize));
2696 aUL.SetLower(static_cast<sal_uInt16>(nSize));
2697 pPageFormat->SetFormatAttr(aLR);
2698 pPageFormat->SetFormatAttr(aUL);
2700 std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>(
SwFrameSize::Fixed));
2704 if(m_pDoc->getIDocumentDeviceAccess().getPrinter(
false))
2707 static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(
false))));
2708 aFrameSz->SetSize(aPhysSize);
2723 SwTwips nTmp = aFrameSz->GetHeight();
2724 aFrameSz->SetHeight(aFrameSz->GetWidth());
2725 aFrameSz->SetWidth(nTmp);
2728 pPageFormat->SetFormatAttr(*aFrameSz);
2729 m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos));
2732 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
2734 if(xStyle->GetCollection())
2735 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2743 uno::Sequence<uno::Any> SAL_CALL SwXStyle::getPropertyDefaults(
const uno::Sequence<OUString>& aPropertyNames)
2746 sal_Int32 nCount = aPropertyNames.getLength();
2747 uno::Sequence<uno::Any> aRet(nCount);
2752 throw uno::RuntimeException();
2754 const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2759 for(sal_Int32 i = 0; i < nCount; ++i)
2761 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(aPropertyNames[i]);
2764 throw beans::UnknownPropertyException(
"Unknown property: " + aPropertyNames[i], static_cast < cppu::OWeakObject * >(
this));
2783 uno::Any SwXStyle::getPropertyDefault(
const OUString& rPropertyName)
2785 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2786 return getPropertyDefaults(aSequence)[0];
2791 if((rHint.
GetId() == SfxHintId::Dying) || (rHint.
GetId() == SfxHintId::StyleSheetErased))
2793 m_pBasePool =
nullptr;
2796 else if(rHint.
GetId() == SfxHintId::StyleSheetChanged)
2798 SfxStyleSheetBasePool& rBP =
static_cast<SfxStyleSheetBasePool&
>(rBC);
2808 void SwXStyle::Invalidate()
2810 m_sStyleName.clear();
2811 m_pBasePool =
nullptr;
2813 m_xStyleData.clear();
2814 m_xStyleFamily.clear();
2817 SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
SwDocShell* pDocSh,
const OUString& rStyleName)
2821 SwXPageStyle::SwXPageStyle(
SwDocShell* pDocSh)
2825 void SwXStyle::PutItemToSet(
const SvxSetItem* pSetItem,
const SfxItemPropertySet& rPropSet,
const SfxItemPropertySimpleEntry& rEntry,
const uno::Any& rVal, SwStyleBase_Impl& rBaseImpl)
2828 const std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2829 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2832 rSetSet.SetParent(&m_pDoc->GetDfltFrameFormat()->GetAttrSet());
2837 SwStyleBase_Impl::ItemSetOverrider o(rBaseImpl, &rSetSet);
2838 SetStyleProperty(rEntry, rPropSet, rVal, rBaseImpl);
2842 rSetSet.SetParent(
nullptr);
2845 rBaseImpl.GetItemSet().Put(*pNewSetItem);
2848 void SwXPageStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2851 throw uno::RuntimeException();
2853 if(rPropertyNames.getLength() != rValues.getLength())
2854 throw lang::IllegalArgumentException();
2858 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2862 throw uno::RuntimeException();
2863 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2864 if(!m_pPropertiesImpl->SetProperty(rPropertyNames[nProp], rValues[nProp]))
2865 throw lang::IllegalArgumentException();
2870 throw uno::RuntimeException();
2871 aBaseImpl.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2872 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2874 const OUString& rPropName = rPropertyNames[nProp];
2875 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(rPropName);
2878 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
2879 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2880 throw beans::PropertyVetoException(
"Property is read-only: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
2882 const bool bHeader(rPropName.startsWith(
"Header"));
2883 const bool bFooter(rPropName.startsWith(
"Footer"));
2885 if(bHeader || bFooter || bFirstIsShared)
2887 switch(pEntry->
nWID)
2889 case SID_ATTR_PAGE_ON:
2895 case SID_ATTR_PAGE_DYNAMIC:
2896 case SID_ATTR_PAGE_SHARED:
2897 case SID_ATTR_PAGE_SHARED_FIRST:
2898 case SID_ATTR_PAGE_SIZE:
2905 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2907 if (pEntry->
nWID == SID_ATTR_PAGE_SHARED_FIRST)
2910 if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(
2911 bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
2912 false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)))
2914 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2918 else if(pEntry->
nWID == SID_ATTR_PAGE_ON && rValues[nProp].get<
bool>())
2921 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
2927 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER,
2928 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE,
2929 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED,
2930 SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST>{});
2933 aTempSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2935 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_ON,
true));
2939 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED,
true));
2940 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST,
true));
2941 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_DYNAMIC,
true));
2943 SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet);
2944 aBaseImpl.GetItemSet().Put(aNewSetItem);
2974 if(SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)))
2977 std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2978 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2981 rSetSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2986 SwStyleBase_Impl::ItemSetOverrider o(aBaseImpl, &rSetSet);
2987 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
2991 rSetSet.SetParent(
nullptr);
2994 aBaseImpl.GetItemSet().Put(*pNewSetItem);
3001 switch(pEntry->
nWID)
3003 case SID_ATTR_PAGE_DYNAMIC:
3004 case SID_ATTR_PAGE_SHARED:
3005 case SID_ATTR_PAGE_SHARED_FIRST:
3006 case SID_ATTR_PAGE_ON:
3009 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
3018 throw lang::IllegalArgumentException();
3022 std::unique_ptr<SfxPoolItem> pNewFootnoteItem(rItem.
Clone());
3023 if(!pNewFootnoteItem->PutValue(rValues[nProp], pEntry->
nMemberId))
3024 throw lang::IllegalArgumentException();
3025 aBaseImpl.GetItemSet().Put(std::move(pNewFootnoteItem));
3030 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
3036 if(aBaseImpl.HasItemSet())
3040 if (undoGuard.UndoWasEnabled())
3043 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3046 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
3050 void SwXPageStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
3057 SetPropertyValues_Impl(rPropertyNames, rValues);
3059 catch (
const beans::UnknownPropertyException &rException)
3063 lang::WrappedTargetException aWExc;
3064 aWExc.TargetException <<= rException;
3075 if(SfxItemState::SET != rSet.
GetItemState(nRes,
true, &pItem))
3080 if(!pHeadFootFormat)
3085 uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames)
3088 throw uno::RuntimeException();
3090 sal_Int32
nLength = rPropertyNames.getLength();
3091 uno::Sequence<uno::Any> aRet (nLength);
3095 throw uno::RuntimeException();
3096 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
3099 m_pPropertiesImpl->GetProperty(rPropertyNames[nProp], pAny);
3101 SwStyleProperties_Impl::GetProperty(rPropertyNames[nProp], m_xStyleData, aRet[nProp]);
3103 aRet[nProp] = *pAny;
3109 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
3112 throw uno::RuntimeException();
3113 for(sal_Int32 nProp = 0; nProp < nLength; ++nProp)
3115 const OUString& rPropName = rPropertyNames[nProp];
3116 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(rPropName);
3119 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > (
this ) );
3120 const bool bHeader(rPropName.startsWith(
"Header"));
3121 const bool bFooter(rPropName.startsWith(
"Footer"));
3123 if(bHeader || bFooter || bFirstIsShared)
3125 switch(pEntry->
nWID)
3127 case SID_ATTR_PAGE_ON:
3133 case SID_ATTR_PAGE_DYNAMIC:
3134 case SID_ATTR_PAGE_SHARED:
3135 case SID_ATTR_PAGE_SHARED_FIRST:
3136 case SID_ATTR_PAGE_SIZE:
3141 const SfxItemSet& rSet = xStyle->GetItemSet();
3147 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3149 SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast< SfxItemSet& >(rSetSet));
3150 aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3153 else if(pEntry->
nWID == SID_ATTR_PAGE_ON)
3156 aRet[nProp] <<=
false;
3185 const SfxItemSet& rSet = xStyle->GetItemSet();
3187 if(SfxItemState::SET == rSet.
GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)))
3190 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3192 SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast<SfxItemSet&>(rSetSet));
3193 aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3201 switch(pEntry->
nWID)
3204 case SID_ATTR_PAGE_DYNAMIC:
3205 case SID_ATTR_PAGE_SHARED:
3206 case SID_ATTR_PAGE_SHARED_FIRST:
3207 case SID_ATTR_PAGE_ON:
3209 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > (
this ) );
3221 sal_uInt16 nRes = 0;
3222 switch(pEntry->
nWID)
3235 const SwPageDesc* pDesc = aBase.GetOldPageDesc();
3244 if(bLeft && !bShare)
3245 pFrameFormat = &pDesc->
GetLeft();
3246 else if(bFirst && !bShareFirst)
3256 aRet[nProp] <<= xRet;
3262 const SfxItemSet& rSet = xStyle->GetItemSet();
3268 aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3274 uno::Sequence<uno::Any> SwXPageStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
3277 uno::Sequence<uno::Any> aValues;
3282 aValues = GetPropertyValues_Impl(rPropertyNames);
3284 catch(beans::UnknownPropertyException &)
3287 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
3288 static_cast < cppu::OWeakObject * > (
this ), anyEx );
3290 catch(lang::WrappedTargetException &)
3293 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
3294 static_cast < cppu::OWeakObject * > (
this ), anyEx );
3300 uno::Any SwXPageStyle::getPropertyValue(
const OUString& rPropertyName)
3303 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3304 return GetPropertyValues_Impl(aProperties)[0];
3307 void SwXPageStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
3310 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3311 const uno::Sequence<uno::Any> aValues(&rValue, 1);
3312 SetPropertyValues_Impl(aProperties, aValues);
3315 SwXFrameStyle::SwXFrameStyle(
SwDoc *pDoc)
3319 void SwXFrameStyle::SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
3321 assert(eAtr >= RES_FRMATR_BEGIN && eAtr < RES_FRMATR_END);
3326 SfxItemSet& rStyleSet = xStyle->GetItemSet();
3329 xStyle->SetItemSet(aSet);
3334 assert(eAtr >= RES_FRMATR_BEGIN && eAtr < RES_FRMATR_END);
3339 return &xStyle->GetItemSet().Get(eAtr);
3342 uno::Sequence<uno::Type> SwXFrameStyle::getTypes()
3346 SwXStyle::getTypes()
3353 return uno::makeAny(uno::Reference<XEventsSupplier>(
this));
3354 return SwXStyle::queryInterface(rType);
3357 uno::Reference<container::XNameReplace> SwXFrameStyle::getEvents()
3363 #define AUTOSTYLE_FAMILY_COUNT 3
3374 std::vector<std::shared_ptr<SfxItemSet>>::iterator
aIter;
3380 std::shared_ptr<SfxItemSet>
const &
nextElement() {
return *(aIter++); }
3404 throw lang::IndexOutOfBoundsException();
3406 throw uno::RuntimeException();
3408 uno::Reference< style::XAutoStyleFamily > aRef;
3455 if(Name ==
"CharacterStyles")
3457 else if(Name ==
"RubyStyles")
3459 else if(Name ==
"ParagraphStyles")
3462 throw container::NoSuchElementException();
3469 OUString* pNames = aNames.getArray();
3470 pNames[0] =
"CharacterStyles";
3471 pNames[1] =
"RubyStyles";
3472 pNames[2] =
"ParagraphStyles";
3478 if( Name ==
"CharacterStyles" ||
3479 Name ==
"RubyStyles" ||
3480 Name ==
"ParagraphStyles" )
3487 m_pDocShell( pDocSh ), m_eFamily(nFamily)
3499 if(rHint.
GetId() == SfxHintId::Dying)
3500 m_pDocShell =
nullptr;
3504 const uno::Sequence< beans::PropertyValue >& Values )
3508 throw uno::RuntimeException();
3511 const sal_uInt16* pRange =
nullptr;
3512 const SfxItemPropertySet* pPropSet =
nullptr;
3537 throw uno::RuntimeException();
3542 if(!bTakeCareOfDrawingLayerFillStyle)
3544 for(
const beans::PropertyValue& rValue : Values )
3550 catch (
const beans::UnknownPropertyException &)
3552 OSL_FAIL(
"Unknown property" );
3554 catch (
const lang::IllegalArgumentException &)
3556 OSL_FAIL(
"Illegal argument" );
3572 for(
const beans::PropertyValue& rValue : Values )
3574 const OUString& rPropName = rValue.Name;
3576 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(rPropName);
3580 SAL_WARN(
"sw.core",
"SwXAutoStyleFamily::insertStyle: Unknown property: " << rPropName);
3588 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
3598 if(aValue >>= nValue)
3609 if(eMapUnit != MapUnit::Map100thMM)
3616 switch(pEntry->
nWID)
3632 if(!(aValue >>= aTempName))
3634 throw lang::IllegalArgumentException();
3647 aXFillBitmapItem.
PutValue(aValue, nMemberId);
3648 aSet.Put(aXFillBitmapItem);
3658 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
3660 aChangedBrushItem->PutValue(aValue, nMemberId);
3662 if(*aChangedBrushItem != *aOriginalBrushItem)
3672 drawing::BitmapMode eMode;
3674 if(!(aValue >>= eMode))
3676 sal_Int32 nMode = 0;
3678 if(!(aValue >>= nMode))
3680 throw lang::IllegalArgumentException();
3683 eMode =
static_cast<drawing::BitmapMode
>(nMode);
3701 catch (
const beans::UnknownPropertyException &)
3703 OSL_FAIL(
"Unknown property" );
3705 catch (
const lang::IllegalArgumentException &)
3707 OSL_FAIL(
"Illegal argument" );
3713 aSet.SetParent(
nullptr);
3732 throw uno::RuntimeException();
3733 return uno::Reference< container::XEnumeration >
3748 : rDoc( rInitDoc ), eFamily( eFam )
3753 std::set< std::pair< sal_uInt16, text::RubyAdjust > > aRubyMap;
3757 std::vector<const SwFormatRuby*> vRubyItems;
3760 auto pRubyItem =
dynamic_cast<const SwFormatRuby*
>(pItem);
3761 if ( pRubyItem && pRubyItem->GetTextRuby() )
3762 vRubyItems.push_back(pRubyItem);
3766 std::pair< sal_uInt16, text::RubyAdjust > aPair( pRubyItem->GetPosition(), pRubyItem->GetAdjustment() );
3767 if ( aRubyMap.insert( aPair ).second )
3770 pItemSet->Put( *pRubyItem );
3777 rDoc.GetIStyleAccess().getAllStyles(
mAutoStyles, eFamily );
3796 if(rHint.
GetId() == SfxHintId::Dying)
3803 throw uno::RuntimeException();
3804 return m_pImpl->hasMoreElements();
3810 throw uno::RuntimeException();
3812 if(
m_pImpl->hasMoreElements() )
3814 std::shared_ptr<SfxItemSet> pNextSet =
m_pImpl->nextElement();
3816 pNextSet,
m_pImpl->getFamily());
3817 aRet <<= xAutoStyle;
3831 std::shared_ptr<SfxItemSet>
const & pInitSet,
3847 if(rHint.
GetId() == SfxHintId::Dying)
3853 uno::Reference< beans::XPropertySetInfo > xRet;
3858 static uno::Reference< beans::XPropertySetInfo > xCharRef;
3868 static uno::Reference< beans::XPropertySetInfo > xRubyRef;
3879 static uno::Reference< beans::XPropertySetInfo > xParaRef;
3903 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3908 const uno::Reference< beans::XPropertyChangeListener >& )
3913 const uno::Reference< beans::XPropertyChangeListener >& )
3918 const uno::Reference< beans::XVetoableChangeListener >& )
3923 const uno::Reference< beans::XVetoableChangeListener >& )
3928 const uno::Sequence< OUString >& ,
3929 const uno::Sequence< uno::Any >& )
3934 const uno::Sequence< OUString > & rPropertyNames )
3938 throw uno::RuntimeException();
3953 const OUString* pNames = rPropertyNames.getConstArray();
3955 const sal_Int32 nLen(rPropertyNames.getLength());
3956 uno::Sequence< uno::Any > aRet( nLen );
3957 uno::Any* pValues = aRet.getArray();
3960 for( sal_Int32 i = 0; i < nLen; ++i )
3962 const OUString sPropName = pNames[i];
3963 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(sPropName);
3966 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > (
this ) );
3978 else if(bTakeCareOfDrawingLayerFillStyle)
3981 switch(pEntry->
nWID)
3987 if(!aOriginalBrushItem->QueryValue(aTarget, pEntry->
nMemberId))
3989 OSL_ENSURE(
false,
"Error getting attribute from RES_BACKGROUND (!)");
3999 aTarget <<= drawing::BitmapMode_REPEAT;
4003 aTarget <<= drawing::BitmapMode_STRETCH;
4007 aTarget <<= drawing::BitmapMode_NO_REPEAT;
4021 if(bTakeCareOfDrawingLayerFillStyle)
4027 if (aTarget >>= nValue)
4029 aTarget <<= static_cast<sal_Int16>(nValue);
4034 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
4044 if(aTarget >>= nValue)
4055 if(eMapUnit != MapUnit::Map100thMM)
4064 pValues[i] = aTarget;
4071 const uno::Sequence< OUString >& rPropertyNames )
4074 uno::Sequence< uno::Any > aValues;
4081 catch (beans::UnknownPropertyException &)
4084 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught", static_cast < cppu::OWeakObject * > (
this ), exc );
4086 catch (lang::WrappedTargetException &)
4089 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught", static_cast < cppu::OWeakObject * > (
this ), exc );
4096 const uno::Sequence< OUString >& ,
4097 const uno::Reference< beans::XPropertiesChangeListener >& )
4102 const uno::Reference< beans::XPropertiesChangeListener >& )
4107 const uno::Sequence< OUString >& ,
4108 const uno::Reference< beans::XPropertiesChangeListener >& )
4116 uno::Sequence< OUString > aNames { rPropertyName };
4118 return aStates.getConstArray()[0];
4127 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4132 const uno::Sequence< OUString >& rPropertyNames )
4136 throw uno::RuntimeException();
4140 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4141 beans::PropertyState* pStates = aRet.getArray();
4142 const OUString* pNames = rPropertyNames.getConstArray();
4157 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4159 const OUString sPropName = pNames[i];
4160 const SfxItemPropertySimpleEntry* pEntry = rMap.
getByName(sPropName);
4163 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > (
this ) );
4168 if(bTakeCareOfDrawingLayerFillStyle)
4171 switch(pEntry->
nWID)
4178 pStates[i] = beans::PropertyState_DIRECT_VALUE;
4182 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
4193 pStates[i] = beans::PropertyState_DIRECT_VALUE;
4197 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
4220 const uno::Sequence< OUString >& )
4225 const uno::Sequence< OUString >& )
4227 uno::Sequence< uno::Any > aRet(0);
4234 throw uno::RuntimeException();
4236 std::vector< beans::PropertyValue > aPropertyVector;
4256 const sal_uInt16 nWID = pItem->Which();
4260 for(
const auto& rProp : aPropVector )
4262 if ( rProp.nWID == nWID )
4264 beans::PropertyValue aPropertyValue;
4265 aPropertyValue.Name = rProp.sName;
4266 pItem->QueryValue( aPropertyValue.Value, rProp.nMemberId );
4267 aPropertyVector.push_back( aPropertyValue );
4272 const sal_Int32 nCount = aPropertyVector.size();
4273 uno::Sequence< beans::PropertyValue > aRet( nCount );
4274 beans::PropertyValue* pProps = aRet.getArray();
4276 for (
int i = 0; i < nCount; ++i, pProps++ )
4278 *pProps = aPropertyVector[i];
4285 m_pDocShell(pDocShell), m_pTableAutoFormat(pTableAutoFormat), m_bPhysical(true)
4291 m_pDocShell(pDocShell), m_pTableAutoFormat_Impl(new
SwTableAutoFormat(rTableAutoFormatName)), m_bPhysical(false)
4300 uno::Reference<style::XStyle> xTextTableStyle;
4302 if (pAutoFormat && pAutoFormat->
GetName() == rTableAutoFormatName)
4304 xTextTableStyle.set(pAutoFormat->
GetXObject(), uno::UNO_QUERY);
4305 if (!xTextTableStyle.is())
4313 if (!xTextTableStyle.is())
4316 SAL_INFO(
"sw.uno",
"creating SwXTextTableStyle for non existing SwTableAutoFormat");
4319 return xTextTableStyle;
4325 assert(aTableTemplateMap.size() ==
STYLE_COUNT &&
"can not map SwTableAutoFormat to a SwXTextTableStyle");
4329 uno::Reference<style::XStyle> xCellStyle(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4330 if (!xCellStyle.is())
4372 for(
size_t i=0; i < nStyles; ++i)
4375 if (pAutoFormat->
GetName() == sName)
4390 if (pTableAutoFormat)
4395 for (
size_t i=0; i<aTableTemplateMap.size(); ++i)
4398 uno::Reference<style::XStyle> xCellStyle(pOldBoxFormat->
GetXObject(), uno::UNO_QUERY);
4399 if (!xCellStyle.is())
4411 SAL_WARN(
"sw.uno",
"setting style physical, but SwTableAutoFormat in document not found");
4414 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextTableStyle");
4438 if (!pFormat->
GetInfo(aGetHt))
4481 SAL_WARN(
"sw.uno",
"not implemented");
4487 bool bIsRow =
false;
4500 throw css::beans::UnknownPropertyException(rPropertyName);
4502 return uno::makeAny(bIsRow ? OUString(
"row") : OUString(
"column"));
4507 SAL_WARN(
"sw.uno",
"not implemented");
4512 SAL_WARN(
"sw.uno",
"not implemented");
4517 SAL_WARN(
"sw.uno",
"not implemented");
4522 SAL_WARN(
"sw.uno",
"not implemented");
4530 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4531 if(iter == rMap.end())
4532 throw css::container::NoSuchElementException();
4547 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4548 return iter != rMap.end();
4554 SAL_WARN(
"sw.uno",
"not implemented");
4561 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4562 if(iter == rMap.end())
4563 throw container::NoSuchElementException();
4564 const sal_Int32 nCellStyle = iter->second;
4566 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
4568 throw lang::IllegalArgumentException();
4571 if (!pStyleToReplaceWith)
4572 throw lang::IllegalArgumentException();
4576 throw lang::IllegalArgumentException();
4579 const sal_Int32 nBoxFormat = rTableTemplateMap[nCellStyle];
4594 SAL_WARN(
"sw.uno",
"not implemented");
4611 return {
"SwXTextTableStyle"};
4621 return {
"com.sun.star.style.Style"};
4626 m_pDocShell(pDocShell),
4627 m_pBoxAutoFormat(pBoxAutoFormat),
4628 m_sParentStyle(sParentStyle),
4633 m_pDocShell(pDocShell),
4651 SAL_INFO(
"sw.uno",
"trying to call SwXTextCellStyle::SetBoxFormat on non physical style");
4667 SAL_WARN(
"sw.uno",
"setting style physical, but SwBoxAutoFormat in document not found");
4670 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextCellStyle");
4680 if (sName.isEmpty())
4684 if (!pBoxAutoFormat)
4686 sal_Int32 nSeparatorIndex, nTemplateIndex;
4687 OUString sParentName, sCellSubName;
4689 nSeparatorIndex = sName.lastIndexOf(
'.');
4690 if (0 >= nSeparatorIndex)
4693 sParentName = sName.copy(0, nSeparatorIndex);
4694 sCellSubName = sName.copy(nSeparatorIndex+1);
4695 nTemplateIndex = sCellSubName.toInt32()-1;
4696 if (0 > nTemplateIndex)
4705 if (!pTableAutoFormat)
4709 *pParentName = sParentName;
4710 sal_uInt32 nBoxIndex = rTableTemplateMap[nTemplateIndex];
4711 pBoxAutoFormat = &pTableAutoFormat->
GetBoxFormat(nBoxIndex);
4714 return pBoxAutoFormat;
4719 uno::Reference<style::XStyle> xTextCellStyle;
4721 if (!sName.isEmpty())
4723 OUString sParentName;
4731 pBoxFormat = &aDefaultBoxFormat;
4734 xTextCellStyle.set(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4735 if (!xTextCellStyle.is())
4737 xTextCellStyle.set(
new SwXTextCellStyle(pDocShell, pBoxFormat, sParentName));
4744 return xTextCellStyle;
4761 uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(m_pDocShell->
GetModel(), uno::UNO_QUERY);
4762 if (!xFamiliesSupplier.is())
4765 uno::Reference<container::XNameAccess> xFamilies = xFamiliesSupplier->getStyleFamilies();
4766 if (!xFamilies.is())
4769 uno::Reference<container::XNameAccess> xTableStyles;
4770 xFamilies->getByName(
"TableStyles") >>= xTableStyles;
4771 if (!xTableStyles.is())
4774 uno::Reference<style::XStyle> xStyle;
4779 return xStyle->isInUse();
4792 SAL_INFO(
"sw.uno",
"Changing SwXTextCellStyle parent");
4812 OUString sParentStyle;
4846 switch(pEntry->
nWID)
4879 if (aValue >>= nKey)
4909 bool bValue =
false; aValue >>= bValue;
4910 rShadowedItem.SetValue(bValue);
4917 bool bValue =
false; aValue >>= bValue;
4918 rContourItem.SetValue(bValue);