66 #include <unoprnms.hxx>
72 #include <strings.hrc>
74 #include <unoevent.hxx>
78 #include <com/sun/star/frame/XModel.hpp>
79 #include <com/sun/star/io/IOException.hpp>
80 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
81 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
82 #include <com/sun/star/beans/PropertyAttribute.hpp>
83 #include <com/sun/star/beans/NamedValue.hpp>
84 #include <com/sun/star/drawing/BitmapMode.hpp>
85 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
86 #include <com/sun/star/lang/IllegalArgumentException.hpp>
87 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
88 #include <com/sun/star/document/XEventsSupplier.hpp>
89 #include <com/sun/star/io/XInputStream.hpp>
116 #include <uiitems.hxx>
121 #include <string_view>
132 class SwStyleProperties_Impl;
134 struct StyleFamilyEntry
136 using GetCountOrName_t = std::function<sal_Int32 (const SwDoc&, OUString*, sal_Int32)>;
138 using TranslateIndex_t = std::function<sal_uInt16(const sal_uInt16)>;
140 sal_uInt16 m_nPropMapType;
141 uno::Reference<beans::XPropertySetInfo> m_xPSInfo;
145 GetCountOrName_t m_fGetCountOrName;
146 CreateStyle_t m_fCreateStyle;
147 TranslateIndex_t m_fTranslateIndex;
148 StyleFamilyEntry(
SfxStyleFamily eFamily, sal_uInt16 nPropMapType,
SwGetPoolIdFromName aPoolId, OUString
const& sName,
TranslateId pResId, GetCountOrName_t
const & fGetCountOrName, CreateStyle_t
const & fCreateStyle, TranslateIndex_t
const & fTranslateIndex)
150 , m_nPropMapType(nPropMapType)
151 , m_xPSInfo(
aSwMapProvider.GetPropertySet(nPropMapType)->getPropertySetInfo())
155 , m_fGetCountOrName(fGetCountOrName)
156 , m_fCreateStyle(fCreateStyle)
157 , m_fTranslateIndex(fTranslateIndex)
160 const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
162 #define nPoolChrNormalRange (RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN)
163 #define nPoolChrHtmlRange (RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN)
164 #define nPoolCollTextRange ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN)
165 #define nPoolCollListsRange ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN)
166 #define nPoolCollExtraRange ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN)
167 #define nPoolCollRegisterRange ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN)
168 #define nPoolCollDocRange ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN)
169 #define nPoolCollHtmlRange ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN)
170 #define nPoolFrameRange ( RES_POOLFRM_END - RES_POOLFRM_BEGIN)
171 #define nPoolPageRange ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN)
172 #define nPoolNumRange ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN)
173 #define nPoolCollListsStackedStart ( nPoolCollTextRange)
174 #define nPoolCollExtraStackedStart ( nPoolCollListsStackedStart + nPoolCollListsRange)
175 #define nPoolCollRegisterStackedStart ( nPoolCollExtraStackedStart + nPoolCollExtraRange)
176 #define nPoolCollDocStackedStart ( nPoolCollRegisterStackedStart + nPoolCollRegisterRange)
177 #define nPoolCollHtmlStackedStart ( nPoolCollDocStackedStart + nPoolCollDocRange)
178 using paragraphstyle_t = std::remove_const<decltype(style::ParagraphStyleCategory::TEXT)>::type;
179 using collectionbits_t = sal_uInt16;
180 struct ParagraphStyleCategoryEntry
182 paragraphstyle_t m_eCategory;
184 collectionbits_t m_nCollectionBits;
185 ParagraphStyleCategoryEntry(paragraphstyle_t eCategory,
SfxStyleSearchBits nSwStyleBits, collectionbits_t nCollectionBits)
186 : m_eCategory(eCategory)
187 , m_nSwStyleBits(nSwStyleBits)
188 , m_nCollectionBits(nCollectionBits)
191 const std::vector<ParagraphStyleCategoryEntry>* our_pParagraphStyleCategoryEntries;
201 class XStyleFamily :
public cppu::WeakImplHelper
203 container::XNameContainer,
205 container::XIndexAccess,
210 const StyleFamilyEntry& m_rEntry;
214 SwXStyle* FindStyle(std::u16string_view rStyleName)
const;
215 sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32)
216 {
return m_rEntry.m_fGetCountOrName(*m_pDocShell->
GetDoc(), pString,
nIndex); };
220 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
221 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
222 assert(pEntry != pEntries->end());
227 : m_rEntry(InitEntry(eFamily))
228 , m_pBasePool(pDocShell->GetStyleSheetPool())
229 , m_pDocShell(pDocShell)
236 virtual sal_Int32 SAL_CALL getCount()
override
239 return GetCountOrName(
nullptr);
241 virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
override;
244 virtual uno::Type SAL_CALL getElementType( )
override
246 virtual sal_Bool SAL_CALL hasElements( )
override
249 throw uno::RuntimeException();
254 virtual uno::Any SAL_CALL getByName(
const OUString& Name)
override;
255 virtual uno::Sequence< OUString > SAL_CALL getElementNames()
override;
256 virtual sal_Bool SAL_CALL hasByName(
const OUString& Name)
override;
259 virtual void SAL_CALL insertByName(
const OUString& Name,
const uno::Any& Element)
override;
260 virtual void SAL_CALL replaceByName(
const OUString& Name,
const uno::Any& Element)
override;
261 virtual void SAL_CALL removeByName(
const OUString& Name)
override;
264 virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override
267 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
269 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
270 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
271 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
272 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
273 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
274 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
275 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
276 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
281 if(rHint.
GetId() == SfxHintId::Dying)
283 m_pBasePool =
nullptr;
284 m_pDocShell =
nullptr;
291 {
return {
"XStyleFamily"}; };
295 {
return {
"com.sun.star.style.StyleFamily" }; }
303 class SwStyleBase_Impl;
304 class SwXStyle :
public cppu::WeakImplHelper
307 css::beans::XPropertySet,
308 css::beans::XMultiPropertySet,
309 css::lang::XServiceInfo,
310 css::lang::XUnoTunnel,
311 css::beans::XPropertyState,
312 css::beans::XMultiPropertyStates
318 OUString m_sStyleName;
319 const StyleFamilyEntry& m_rEntry;
320 bool m_bIsDescriptor;
321 bool m_bIsConditional;
322 OUString m_sParentStyleName;
326 std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl;
327 css::uno::Reference<css::container::XNameAccess> m_xStyleFamily;
328 css::uno::Reference<css::beans::XPropertySet> m_xStyleData;
332 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
334 void PrepareStyleBase(SwStyleBase_Impl& rBase);
343 virtual ~SwXStyle()
override;
346 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
349 virtual sal_Int64 SAL_CALL getSomething(
const css::uno::Sequence< sal_Int8 >& aIdentifier )
override;
352 virtual OUString SAL_CALL getName()
override;
353 virtual void SAL_CALL setName(
const OUString& Name_)
override;
356 virtual sal_Bool SAL_CALL isUserDefined()
override;
357 virtual sal_Bool SAL_CALL isInUse()
override;
358 virtual OUString SAL_CALL getParentStyle()
override;
359 virtual void SAL_CALL setParentStyle(
const OUString& aParentStyle)
override;
362 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override;
363 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
364 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
365 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
366 { OSL_FAIL(
"not implemented"); };
367 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
368 { OSL_FAIL(
"not implemented"); };
369 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
370 { OSL_FAIL(
"not implemented"); };
371 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
372 { OSL_FAIL(
"not implemented"); };
375 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
376 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
377 virtual void SAL_CALL addPropertiesChangeListener(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
379 virtual void SAL_CALL removePropertiesChangeListener(
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
381 virtual void SAL_CALL firePropertiesChangeEvent(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
385 virtual css::beans::PropertyState SAL_CALL getPropertyState(
const OUString& PropertyName )
override;
386 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(
const css::uno::Sequence< OUString >& aPropertyName )
override;
387 virtual void SAL_CALL setPropertyToDefault(
const OUString& PropertyName )
override;
388 virtual css::uno::Any SAL_CALL getPropertyDefault(
const OUString& aPropertyName )
override;
391 virtual void SAL_CALL setAllPropertiesToDefault( )
override;
392 virtual void SAL_CALL setPropertiesToDefault(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
393 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
397 {
return {
"SwXStyle"}; };
406 const OUString& GetStyleName()
const {
return m_sStyleName;}
409 bool IsDescriptor()
const {
return m_bIsDescriptor;}
410 bool IsConditional()
const {
return m_bIsConditional;}
411 const OUString& GetParentStyleName()
const {
return m_sParentStyleName;}
414 m_bIsDescriptor =
false; m_pDoc = pDc;
418 SwDoc* GetDoc()
const {
return m_pDoc; }
420 void ApplyDescriptorProperties();
421 void SetStyleName(
const OUString& rSet){ m_sStyleName = rSet;}
432 ,
public css::document::XEventsSupplier
438 const OUString& rStyleName) :
440 explicit SwXFrameStyle(
SwDoc *pDoc);
442 virtual void SAL_CALL acquire( ) noexcept
override {SwXStyle::acquire();}
443 virtual void SAL_CALL release( ) noexcept
override {SwXStyle::release();}
445 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( )
override;
446 virtual css::uno::Any SAL_CALL
queryInterface(
const css::uno::Type& aType )
override;
447 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( )
override;
450 virtual void SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
override;
452 virtual css::document::XEventsSupplier& GetEventsSupplier()
override
460 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
461 css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames );
467 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
468 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
470 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
471 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
476 using sw::XStyleFamily;
479 {
return {
"SwXStyleFamilies"}; }
487 {
return {
"com.sun.star.style.StyleFamilies" }; }
491 m_pDocShell(&rDocShell)
501 throw uno::RuntimeException();
503 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
504 [&Name] (
const StyleFamilyEntry& e) {
return e.m_sName == Name; });
505 if(pEntry == pEntries->end())
506 throw container::NoSuchElementException();
513 uno::Sequence<OUString> aNames(pEntries->size());
514 std::transform(pEntries->begin(), pEntries->end(),
515 aNames.getArray(), [] (
const StyleFamilyEntry& e) {
return e.m_sName; });
522 return std::any_of(pEntries->begin(), pEntries->end(),
523 [&Name] (
const StyleFamilyEntry& e) {
return e.m_sName == Name; });
535 if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(pEntries->size()))
536 throw lang::IndexOutOfBoundsException();
538 throw uno::RuntimeException();
539 auto eFamily = (*pEntries)[nIndex].m_eFamily;
540 assert(eFamily != SfxStyleFamily::All);
543 rxFamily =
new XStyleFamily(m_pDocShell, eFamily);
556 const uno::Sequence< beans::PropertyValue >& aOptions)
559 if(!
IsValid() || rURL.isEmpty())
560 throw uno::RuntimeException();
567 for(
const auto& rProperty: aOptions)
571 bValue = rProperty.Value.get<
bool>();
583 else if(rProperty.Name ==
"InputStream")
586 if (!(rProperty.Value >>= xInputStream))
587 throw IllegalArgumentException(
"Parameter 'InputStream' could not be converted to "
588 "type 'com::sun::star::io::XInputStream'",
597 throw io::IOException();
614 SfxItemSet const& rSet, std::u16string_view rPropName,
bool const bFooter,
618 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
624 (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
630 template<enum SfxStyleFamily>
634 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Char>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
639 for(
auto pFormat : *rDoc.GetCharFormats())
641 if(pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat())
648 if(rDoc.GetDfltCharFormat() == pFormat)
649 *pString =
SwResId(STR_POOLCHR_STANDARD);
651 *pString = pFormat->GetName();
656 return nCount + nBaseCount;
660 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Para>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
665 for(
auto pColl : *rDoc.GetTextFormatColls())
667 if(pColl->IsDefault())
673 *pString = pColl->GetName();
678 return nCount + nBaseCount;
682 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Frame>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
686 for(
const auto pFormat : *rDoc.GetFrameFormats())
688 if(pFormat->IsDefault() || pFormat->IsAuto())
694 *pString = pFormat->GetName();
703 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Page>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
707 const size_t nArrLen = rDoc.GetPageDescCnt();
708 for(
size_t i = 0;
i < nArrLen; ++
i)
725 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Pseudo>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
729 for(
const auto pRule : rDoc.GetNumRuleTable())
731 if(pRule->IsAutoRule())
737 *pString = pRule->GetName();
746 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Table>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
748 if (!rDoc.HasTableStyles())
751 const auto pAutoFormats = &rDoc.GetTableStyles();
752 const sal_Int32
nCount = pAutoFormats->size();
760 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Cell>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
762 const auto& rAutoFormats = rDoc.GetTableStyles();
764 const sal_Int32 nUsedCellStylesCount = rAutoFormats.size() * rTableTemplateMap.size();
765 const sal_Int32
nCount = nUsedCellStylesCount + rDoc.GetCellStyles().size();
768 if (nUsedCellStylesCount >
nIndex)
770 const sal_Int32 nAutoFormat =
nIndex / rTableTemplateMap.size();
771 const sal_Int32 nBoxFormat = rTableTemplateMap[
nIndex % rTableTemplateMap.size()];
777 *pString = rDoc.GetCellStyles()[
nIndex-nUsedCellStylesCount].GetName();
782 template<SfxStyleFamily eFamily>
784 {
return pBasePool ?
new SwXStyle(pBasePool, eFamily, pDocShell->
GetDoc(), sStyleName) :
new SwXStyle(pDocShell->
GetDoc(), eFamily,
false); };
788 {
return pBasePool ?
new SwXStyle(pBasePool, SfxStyleFamily::Para, pDocShell->GetDoc(), sStyleName) :
new SwXStyle(pDocShell->GetDoc(), SfxStyleFamily::Para,
false); };
791 {
return pBasePool ?
new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), sStyleName) :
new SwXFrameStyle(pDocShell->GetDoc()); };
795 {
return pBasePool ?
new SwXPageStyle(*pBasePool, pDocShell, sStyleName) :
new SwXPageStyle(pDocShell); };
802 uno::Reference< css::style::XStyle> lcl_CreateStyle<SfxStyleFamily::Cell>(SfxStyleSheetBasePool* ,
SwDocShell* pDocShell,
const OUString& sStyleName)
808 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
809 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
810 return pEntry == pEntries->end() ?
nullptr : pEntry->m_fCreateStyle(
nullptr, rDoc.
GetDocShell(),
"");
815 {
return new SwXStyle(&rDoc, SfxStyleFamily::Para,
true); };
817 template<enum SfxStyleFamily>
821 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Char>(
const sal_uInt16
nIndex)
828 throw lang::IndexOutOfBoundsException();
832 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Para>(
const sal_uInt16
nIndex)
847 throw lang::IndexOutOfBoundsException();
851 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Table>(
const sal_uInt16
nIndex)
857 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Cell>(
const sal_uInt16
nIndex)
862 template<sal_uInt16 nRangeBegin, sal_uInt16 nRangeSize>
865 if(nIndex < nRangeSize)
866 return nIndex + nRangeBegin;
867 throw lang::IndexOutOfBoundsException();
870 uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
874 throw lang::IndexOutOfBoundsException();
876 throw uno::RuntimeException();
882 if (sStyleName.isEmpty())
883 GetCountOrName(&sStyleName, nIndex);
884 if(sStyleName.isEmpty())
885 throw lang::IndexOutOfBoundsException();
886 return getByName(sStyleName);
889 uno::Any XStyleFamily::getByName(
const OUString& rName)
895 throw uno::RuntimeException();
898 throw container::NoSuchElementException(rName);
899 uno::Reference<style::XStyle> xStyle = FindStyle(sStyleName);
901 xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SfxStyleFamily::Frame ? pBase->
GetName() : sStyleName);
905 uno::Sequence<OUString> XStyleFamily::getElementNames()
909 throw uno::RuntimeException();
910 std::vector<OUString> vRet;
911 std::unique_ptr<SfxStyleSheetIterator> pIt = m_pBasePool->
CreateIterator(m_rEntry.m_eFamily);
916 vRet.push_back(sName);
921 sal_Bool XStyleFamily::hasByName(
const OUString& rName)
925 throw uno::RuntimeException();
929 return nullptr != pBase;
932 void XStyleFamily::insertByName(
const OUString& rName,
const uno::Any& rElement)
936 throw uno::RuntimeException();
941 if(pBase || pUINameBase)
942 throw container::ElementExistException();
943 if(rElement.getValueType().getTypeClass() != uno::TypeClass_INTERFACE)
944 throw lang::IllegalArgumentException();
948 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
951 throw lang::IllegalArgumentException();
953 pNewStyle->setName(sStyleName);
955 pNewStyle->SetPhysical();
960 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
963 throw lang::IllegalArgumentException();
965 pNewStyle->setName(sStyleName);
967 pNewStyle->SetPhysical();
971 uno::Reference<lang::XUnoTunnel> xStyleTunnel = rElement.get<uno::Reference<lang::XUnoTunnel>>();
972 SwXStyle* pNewStyle = comphelper::getFromUnoTunnel<SwXStyle>(xStyleTunnel);
973 if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_rEntry.m_eFamily)
974 throw lang::IllegalArgumentException();
977 if(m_rEntry.m_eFamily == SfxStyleFamily::Para && !pNewStyle->IsConditional())
978 nMask &= ~SfxStyleSearchBits::SwCondColl;
979 m_pBasePool->
Make(sStyleName, m_rEntry.m_eFamily, nMask);
980 pNewStyle->SetDoc(m_pDocShell->
GetDoc(), m_pBasePool);
981 pNewStyle->SetStyleName(sStyleName);
982 const OUString sParentStyleName(pNewStyle->GetParentStyleName());
983 if (!sParentStyleName.isEmpty())
986 if(pParentBase && pParentBase->
GetFamily() == m_rEntry.m_eFamily &&
987 pParentBase->
GetPool() == m_pBasePool)
988 m_pBasePool->
SetParent(m_rEntry.m_eFamily, sStyleName, sParentStyleName);
991 pNewStyle->ApplyDescriptorProperties();
995 void XStyleFamily::replaceByName(
const OUString& rName,
const uno::Any& rElement)
999 throw uno::RuntimeException();
1000 OUString sStyleName;
1005 throw container::NoSuchElementException();
1011 if (pBoxAutoFormat && sParent.isEmpty())
1013 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1015 if (!pStyleToReplaceWith)
1016 throw lang::IllegalArgumentException();
1018 pStyleToReplaceWith->setName(sStyleName);
1019 *pBoxAutoFormat = *pStyleToReplaceWith->GetBoxFormat();
1020 pStyleToReplaceWith->SetPhysical();
1027 if (pTableAutoFormat)
1029 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1031 if (!pStyleToReplaceWith)
1032 throw lang::IllegalArgumentException();
1034 pStyleToReplaceWith->setName(sStyleName);
1035 *pTableAutoFormat = *pStyleToReplaceWith->GetTableFormat();
1036 pStyleToReplaceWith->SetPhysical();
1042 throw lang::IllegalArgumentException();
1044 uno::Reference<style::XStyle> xStyle = FindStyle(pBase->
GetName());
1047 SwXStyle* pStyle = comphelper::getFromUnoTunnel<SwXStyle>(xStyle);
1049 pStyle->Invalidate();
1051 m_pBasePool->
Remove(pBase);
1052 insertByName(rName, rElement);
1056 void XStyleFamily::removeByName(
const OUString& rName)
1060 throw uno::RuntimeException();
1065 throw container::NoSuchElementException();
1077 m_pBasePool->
Remove(pBase);
1080 uno::Any SAL_CALL XStyleFamily::getPropertyValue(
const OUString& sPropertyName )
1082 if(sPropertyName !=
"DisplayName")
1083 throw beans::UnknownPropertyException(
"unknown property: " + sPropertyName, static_cast<OWeakObject *>(
this) );
1089 SwXStyle* XStyleFamily::FindStyle(std::u16string_view rStyleName)
const
1092 for(
size_t i = 0;
i < nLCount; ++
i)
1095 SwXStyle* pTempStyle =
dynamic_cast<SwXStyle*
>(pListener);
1096 if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.m_eFamily && pTempStyle->GetStyleName() == rStyleName)
1104 if(!our_pStyleFamilyEntries)
1106 our_pStyleFamilyEntries =
new std::vector<StyleFamilyEntry>{
1107 { 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> },
1108 { 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> },
1109 { 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> },
1110 { 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> },
1111 { 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> },
1116 return our_pStyleFamilyEntries;
1121 if(!our_pParagraphStyleCategoryEntries)
1123 our_pParagraphStyleCategoryEntries =
new std::vector<ParagraphStyleCategoryEntry>{
1124 { style::ParagraphStyleCategory::TEXT, SfxStyleSearchBits::SwText,
COLL_TEXT_BITS },
1125 { style::ParagraphStyleCategory::CHAPTER, SfxStyleSearchBits::SwChapter,
COLL_DOC_BITS },
1126 { style::ParagraphStyleCategory::LIST, SfxStyleSearchBits::SwList,
COLL_LISTS_BITS },
1127 { style::ParagraphStyleCategory::INDEX, SfxStyleSearchBits::SwIndex,
COLL_REGISTER_BITS },
1128 { style::ParagraphStyleCategory::EXTRA, SfxStyleSearchBits::SwExtra,
COLL_EXTRA_BITS },
1129 { style::ParagraphStyleCategory::HTML, SfxStyleSearchBits::SwHtml,
COLL_HTML_BITS }
1132 return our_pParagraphStyleCategoryEntries;
1137 class SwStyleProperties_Impl
1140 std::map<OUString, uno::Any> m_vPropertyValues;
1146 bool AllowsKey(std::u16string_view rName)
1150 bool SetProperty(
const OUString& rName,
const uno::Any& rValue)
1152 if(!AllowsKey(rName))
1154 m_vPropertyValues[rName] = rValue;
1159 if(!AllowsKey(rName))
1164 pAny = &m_vPropertyValues[rName];
1167 bool ClearProperty(
const OUString& rName )
1169 if(!AllowsKey(rName))
1171 m_vPropertyValues[rName] =
uno::Any();
1174 void ClearAllProperties( )
1175 { m_vPropertyValues.clear(); }
1176 void Apply(SwXStyle& rStyle)
1178 for(
const auto& rPropertyPair : m_vPropertyValues)
1180 if(rPropertyPair.second.hasValue())
1181 rStyle.setPropertyValue(rPropertyPair.first, rPropertyPair.second);
1184 static void GetProperty(
const OUString &rPropertyName,
const uno::Reference < beans::XPropertySet > &rxPropertySet,
uno::Any& rAny )
1186 rAny = rxPropertySet->getPropertyValue( rPropertyName );
1195 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
1196 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
1197 if(pEntry != pEntries->end())
1198 return pEntry->m_aPoolId;
1199 SAL_WARN(
"sw.uno",
"someone asking for all styles in unostyle.cxx!" );
1207 const uno::Sequence<sal_Int8>& SwXStyle::getUnoTunnelId()
1210 return theSwXStyleUnoTunnelId.
getSeq();
1213 sal_Int64 SAL_CALL SwXStyle::getSomething(
const uno::Sequence<sal_Int8>& rId)
1219 uno::Sequence< OUString > SwXStyle::getSupportedServiceNames()
1222 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
1225 if(m_bIsConditional)
1228 else if(SfxStyleFamily::Char == m_rEntry.m_eFamily)
1230 else if(SfxStyleFamily::Page == m_rEntry.m_eFamily)
1232 uno::Sequence< OUString > aRet(nCount);
1233 OUString* pArray = aRet.getArray();
1234 pArray[0] =
"com.sun.star.style.Style";
1235 switch(m_rEntry.m_eFamily)
1237 case SfxStyleFamily::Char:
1238 pArray[1] =
"com.sun.star.style.CharacterStyle";
1239 pArray[2] =
"com.sun.star.style.CharacterProperties";
1240 pArray[3] =
"com.sun.star.style.CharacterPropertiesAsian";
1241 pArray[4] =
"com.sun.star.style.CharacterPropertiesComplex";
1243 case SfxStyleFamily::Page:
1244 pArray[1] =
"com.sun.star.style.PageStyle";
1245 pArray[2] =
"com.sun.star.style.PageProperties";
1247 case SfxStyleFamily::Para:
1248 pArray[1] =
"com.sun.star.style.ParagraphStyle";
1249 pArray[2] =
"com.sun.star.style.ParagraphProperties";
1250 pArray[3] =
"com.sun.star.style.ParagraphPropertiesAsian";
1251 pArray[4] =
"com.sun.star.style.ParagraphPropertiesComplex";
1252 if(m_bIsConditional)
1253 pArray[5] =
"com.sun.star.style.ConditionalParagraphStyle";
1265 if(eFamily != SfxStyleFamily::Para && eFamily != SfxStyleFamily::Page)
1267 auto aResult(rxStyleFamily->getByName(
"Standard"));
1268 if(!aResult.has<return_t>())
1270 return aResult.get<return_t>();
1276 if(rEntry.m_eFamily != SfxStyleFamily::Char
1277 && rEntry.m_eFamily != SfxStyleFamily::Para
1278 && rEntry.m_eFamily != SfxStyleFamily::Page)
1281 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(
xModel, uno::UNO_QUERY);
1282 auto xFamilies = xFamilySupplier->getStyleFamilies();
1283 auto aResult(xFamilies->getByName(rEntry.m_sName));
1284 if(!aResult.has<return_t>())
1286 return aResult.get<return_t>();
1291 if(!pBasePool || eFamily != SfxStyleFamily::Para)
1294 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?" );
1298 if(nId != USHRT_MAX)
1306 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
1307 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
1308 assert(pEntry != pEntries->end());
1315 , m_bIsDescriptor(true)
1316 , m_bIsConditional(bConditional)
1317 , m_pBasePool(nullptr)
1321 assert(!m_bIsConditional || m_rEntry.m_eFamily == SfxStyleFamily::Para);
1324 m_pPropertiesImpl = std::make_unique<SwStyleProperties_Impl>(
1328 SwXStyle::SwXStyle(SfxStyleSheetBasePool* pPool,
SfxStyleFamily eFamily,
SwDoc* pDoc,
const OUString& rStyleName)
1330 , m_sStyleName(rStyleName)
1332 , m_bIsDescriptor(
false)
1334 , m_pBasePool(pPool)
1337 SwXStyle::~SwXStyle()
1342 m_pPropertiesImpl.reset();
1348 if(rHint.
GetId() == SfxHintId::Dying)
1351 m_xStyleData.clear();
1352 m_xStyleFamily.clear();
1356 OUString SwXStyle::getName()
1360 return m_sStyleName;
1362 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1364 throw uno::RuntimeException();
1370 void SwXStyle::setName(
const OUString& rName)
1375 m_sStyleName = rName;
1379 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1381 throw uno::RuntimeException();
1383 if(!xTmp->SetName(rName))
1384 throw uno::RuntimeException();
1385 m_sStyleName = rName;
1392 throw uno::RuntimeException();
1402 throw uno::RuntimeException();
1403 SfxStyleSheetBase* pBase = m_pBasePool->
Find(m_sStyleName, m_rEntry.m_eFamily, SfxStyleSearchBits::Used);
1404 return pBase && pBase->
IsUsed();
1407 OUString SwXStyle::getParentStyle()
1412 if(!m_bIsDescriptor)
1413 throw uno::RuntimeException();
1414 return m_sParentStyleName;
1424 void SwXStyle::setParentStyle(
const OUString& rParentStyle)
1427 OUString sParentStyle;
1431 if(!m_bIsDescriptor)
1432 throw uno::RuntimeException();
1433 m_sParentStyleName = sParentStyle;
1436 const auto aAny = m_xStyleFamily->getByName(sParentStyle);
1437 m_xStyleData = aAny.get<decltype(m_xStyleData)>();
1445 throw uno::RuntimeException();
1448 xBase->GetItemSet();
1449 if(xBase->GetParent() != sParentStyle)
1451 if(!xBase->SetParent(sParentStyle))
1452 throw uno::RuntimeException();
1456 uno::Reference<beans::XPropertySetInfo> SwXStyle::getPropertySetInfo()
1458 if(m_bIsConditional)
1460 assert(m_rEntry.m_eFamily == SfxStyleFamily::Para);
1461 static uno::Reference<beans::XPropertySetInfo> xCondParaRef;
1463 return xCondParaRef;
1465 return m_rEntry.m_xPSInfo;
1468 void SwXStyle::ApplyDescriptorProperties()
1470 m_bIsDescriptor =
false;
1471 m_xStyleData.clear();
1472 m_xStyleFamily.clear();
1473 m_pPropertiesImpl->Apply(*
this);
1478 class SwStyleBase_Impl
1485 std::unique_ptr<SfxItemSet> m_pMyItemSet;
1486 OUString m_rStyleName;
1489 SwStyleBase_Impl(
SwDoc& rSwDoc,
const OUString& rName,
const SwAttrSet* pParentStyle)
1491 , m_pOldPageDesc(nullptr)
1492 , m_pItemSet(nullptr)
1493 , m_rStyleName(rName)
1494 , m_pParentStyle(pParentStyle)
1507 bool HasItemSet()
const
1509 return m_xNewBase.is();
1514 assert(m_xNewBase.is());
1517 m_pMyItemSet.reset(
new SfxItemSet(m_xNewBase->GetItemSet()));
1518 m_pItemSet = m_pMyItemSet.get();
1521 if(!m_pItemSet->
GetParent() && m_pParentStyle)
1530 struct ItemSetOverrider
1532 SwStyleBase_Impl& m_rStyleBase;
1534 ItemSetOverrider(SwStyleBase_Impl& rStyleBase,
SfxItemSet* pTemp)
1535 : m_rStyleBase(rStyleBase)
1536 , m_pOldSet(m_rStyleBase.m_pItemSet)
1537 { m_rStyleBase.m_pItemSet = pTemp; }
1539 { m_rStyleBase.m_pItemSet = m_pOldSet; };
1546 STR_POOLPAGE_STANDARD,
1550 STR_POOLPAGE_ENVELOPE,
1551 STR_POOLPAGE_REGISTER,
1553 STR_POOLPAGE_FOOTNOTE,
1554 STR_POOLPAGE_ENDNOTE,
1555 STR_POOLPAGE_LANDSCAPE
1559 const SwPageDesc* SwStyleBase_Impl::GetOldPageDesc()
1565 m_pOldPageDesc = pd;
1579 return m_pOldPageDesc;
1587 if(!(rEntry.
nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
1592 && o_aValue.has<sal_Int32>()
1593 && o_aValue.get<sal_Int32>() < 0)
1600 if(eMapUnit != MapUnit::Map100thMM)
1608 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1611 rPropSet.setPropertyValue(rEntry, rValue, aSet);
1612 rStyleSet.
Put(aSet);
1617 bool bHidden =
false;
1618 if(rValue >>= bHidden)
1621 o_rStyleBase.getNewBase()->GetItemSet();
1622 o_rStyleBase.getNewBase()->SetHidden(bHidden);
1624 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1629 o_rStyleBase.getNewBase()->GetItemSet();
1630 o_rStyleBase.getNewBase()->SetGrabBagItem(rValue);
1631 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1638 if(MID_NAME == nMemberId)
1641 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1642 if(!aValue.has<OUString>())
1643 throw lang::IllegalArgumentException();
1646 else if(MID_BITMAP == nMemberId)
1648 if(sal_uInt16(XATTR_FILLBITMAP) == rEntry.nWID)
1651 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1653 aXFillBitmapItem.PutValue(aValue, nMemberId);
1654 rStyleSet.
Put(aXFillBitmapItem);
1658 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1663 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1665 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
1669 aChangedBrushItem->PutValue(aValue, nMemberId);
1674 if(*aChangedBrushItem == *aOriginalBrushItem && (MID_GRAPHIC_TRANSPARENT != nMemberId || !aValue.has<
bool>() || !aValue.get<
bool>()))
1680 void SwXStyle::SetPropertyValue<OWN_ATTR_FILLBMP_MODE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1682 drawing::BitmapMode
eMode;
1683 if(!(rValue >>= eMode))
1685 if(!rValue.has<sal_Int32>())
1686 throw lang::IllegalArgumentException();
1687 eMode =
static_cast<drawing::BitmapMode
>(rValue.get<sal_Int32>());
1689 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1694 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAPER_BIN)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1696 if(!rValue.has<OUString>())
1697 throw lang::IllegalArgumentException();
1698 SfxPrinter* pPrinter = m_pDoc->getIDocumentDeviceAccess().getPrinter(
true);
1699 OUString sValue(rValue.get<OUString>());
1700 using printeridx_t = decltype(pPrinter->GetPaperBinCount());
1701 printeridx_t nBin = std::numeric_limits<printeridx_t>::max();
1702 if(sValue ==
"[From printer settings]")
1703 nBin = std::numeric_limits<printeridx_t>::max()-1;
1706 for(sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount();
i < nEnd; ++
i)
1708 if (sValue == pPrinter->GetPaperBinName(i))
1715 if(nBin == std::numeric_limits<printeridx_t>::max())
1716 throw lang::IllegalArgumentException();
1717 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1720 rPropSet.setPropertyValue(rEntry,
uno::Any(static_cast<sal_Int8>(nBin == std::numeric_limits<printeridx_t>::max()-1 ? -1 : nBin)), aSet);
1721 rStyleSet.
Put(aSet);
1724 void SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1726 if(!rValue.has<uno::Reference<container::XIndexReplace>>() || !rValue.has<uno::Reference<lang::XUnoTunnel>>())
1727 throw lang::IllegalArgumentException();
1728 auto xNumberTunnel(rValue.get<uno::Reference<lang::XUnoTunnel>>());
1729 SwXNumberingRules* pSwXRules = comphelper::getFromUnoTunnel<SwXNumberingRules>(xNumberTunnel);
1735 const SwNumFormat* pFormat = aSetRule.GetNumFormat(i);
1740 if(!rCharName.isEmpty()
1744 auto pCharFormatIt(std::find_if(m_pDoc->GetCharFormats()->begin(), m_pDoc->GetCharFormats()->end(),
1745 [&rCharName] (
SwCharFormat* pF) {
return pF->GetName() == rCharName; }));
1746 if(pCharFormatIt != m_pDoc->GetCharFormats()->end())
1747 aFormat.SetCharFormat(*pCharFormatIt);
1748 else if(m_pBasePool)
1750 auto pBase(m_pBasePool->
Find(rCharName, SfxStyleFamily::Char));
1752 pBase = &m_pBasePool->
Make(rCharName, SfxStyleFamily::Char);
1753 aFormat.SetCharFormat(static_cast<SwDocStyleSheet*>(pBase)->GetCharFormat());
1756 aFormat.SetCharFormat(
nullptr);
1760 if(!rBulletName.isEmpty()
1764 const auto pFontListItem(static_cast<const SvxFontListItem*>(m_pDoc->GetDocShell()->GetItem(SID_ATTR_CHAR_FONTLIST)));
1765 const auto pList(pFontListItem->GetFontList());
1766 FontMetric aFontInfo(pList->Get(rBulletName, WEIGHT_NORMAL, ITALIC_NONE));
1768 aFormat.SetBulletFont(&aFont);
1770 aSetRule.Set(i, &aFormat);
1772 o_rStyleBase.getNewBase()->SetNumRule(aSetRule);
1775 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_OUTLINELEVEL)>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1777 if(!rValue.has<sal_Int16>())
1779 const auto nLevel(rValue.get<sal_Int16>());
1780 if(0 <= nLevel && nLevel <= MAXLEVEL)
1781 o_rStyleBase.getNewBase()->GetCollection()->SetAttrOutlineLevel(nLevel);
1784 void SwXStyle::SetPropertyValue<FN_UNO_FOLLOW_STYLE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1786 if(!rValue.has<OUString>())
1788 const auto sValue(rValue.get<OUString>());
1791 o_rStyleBase.getNewBase()->SetFollow(aString);
1795 void SwXStyle::SetPropertyValue<FN_UNO_LINK_STYLE>(
const SfxItemPropertyMapEntry&,
1796 const SfxItemPropertySet&,
1798 SwStyleBase_Impl& o_rStyleBase)
1800 if (!rValue.has<OUString>())
1802 const auto sValue(rValue.get<OUString>());
1805 o_rStyleBase.getNewBase()->SetLink(aString);
1809 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAGEDESC)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1813 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1816 if(!rValue.has<OUString>())
1817 throw lang::IllegalArgumentException();
1819 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1820 std::unique_ptr<SwFormatPageDesc> pNewDesc;
1825 const auto sValue(rValue.get<OUString>());
1828 if(pNewDesc->GetPageDesc() && pNewDesc->GetPageDesc()->GetName() == sDescName)
1830 if(sDescName.isEmpty())
1839 throw lang::IllegalArgumentException();
1840 pNewDesc->RegisterToPageDesc(*pPageDesc);
1841 rStyleSet.
Put(*pNewDesc);
1845 void SwXStyle::SetPropertyValue<sal_uInt16(RES_TEXT_VERT_ADJUST)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1847 if(m_rEntry.m_eFamily != SfxStyleFamily::Page)
1849 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1852 if(!m_pDoc || !rValue.has<drawing::TextVerticalAdjust>() || !o_rStyleBase.GetOldPageDesc())
1854 SwPageDesc* pPageDesc = m_pDoc->FindPageDesc(o_rStyleBase.GetOldPageDesc()->GetName());
1859 void SwXStyle::SetPropertyValue<FN_UNO_IS_AUTO_UPDATE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1861 if(!rValue.has<
bool>())
1862 throw lang::IllegalArgumentException();
1863 const bool bAuto(rValue.get<
bool>());
1864 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
1865 o_rStyleBase.getNewBase()->GetCollection()->SetAutoUpdateFormat(bAuto);
1866 else if(SfxStyleFamily::Frame == m_rEntry.m_eFamily)
1867 o_rStyleBase.getNewBase()->GetFrameFormat()->SetAutoUpdateFormat(bAuto);
1870 void SwXStyle::SetPropertyValue<FN_UNO_PARA_STYLE_CONDITIONS>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1873 using expectedarg_t = uno::Sequence<beans::NamedValue>;
1874 if(!rValue.has<expectedarg_t>() || !m_pBasePool)
1875 throw lang::IllegalArgumentException();
1877 const auto aNamedValues = rValue.get<expectedarg_t>();
1878 for(
const auto& rNamedValue : aNamedValues)
1880 if(!rNamedValue.Value.has<OUString>())
1881 throw lang::IllegalArgumentException();
1883 const OUString sValue(rNamedValue.Value.get<OUString>());
1885 OUString aStyleName;
1891 throw lang::IllegalArgumentException();
1892 bool bStyleFound =
false;
1893 for(
auto pBase = m_pBasePool->
First(SfxStyleFamily::Para); pBase; pBase = m_pBasePool->
Next())
1895 bStyleFound = pBase->
GetName() == aStyleName;
1900 throw lang::IllegalArgumentException();
1901 aCondItem.
SetStyle(&aStyleName, nIdx);
1903 o_rStyleBase.GetItemSet().Put(aCondItem);
1906 void SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1908 if(!o_rStyleBase.getNewBase()->IsUserDefined() || !rValue.has<paragraphstyle_t>())
1909 throw lang::IllegalArgumentException();
1910 static std::optional<std::map<paragraphstyle_t, SfxStyleSearchBits>> pUnoToCore;
1913 pUnoToCore.emplace();
1915 std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
1916 [] (
const ParagraphStyleCategoryEntry& rEntry) {
return std::pair<paragraphstyle_t, SfxStyleSearchBits>(rEntry.m_eCategory, rEntry.m_nSwStyleBits); });
1918 const auto pUnoToCoreIt(pUnoToCore->find(rValue.get<paragraphstyle_t>()));
1919 if(pUnoToCoreIt == pUnoToCore->end())
1920 throw lang::IllegalArgumentException();
1921 o_rStyleBase.getNewBase()->SetMask( pUnoToCoreIt->second|SfxStyleSearchBits::UserDefined );
1924 void SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1929 aReg.
SetWhich(SID_SWREGISTER_MODE);
1930 o_rStyleBase.GetItemSet().Put(aReg);
1933 o_rStyleBase.GetItemSet().Put(
SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
1936 void SwXStyle::SetPropertyValue<sal_uInt16(RES_TXTATR_CJK_RUBY)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1940 if(!rValue.has<OUString>())
1941 throw lang::IllegalArgumentException();
1942 const auto sValue(rValue.get<OUString>());
1943 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1944 std::unique_ptr<SwFormatRuby> pRuby;
1951 pRuby->SetCharFormatName(sValue);
1952 pRuby->SetCharFormatId(0);
1953 if(!sValue.isEmpty())
1956 pRuby->SetCharFormatId(nId);
1958 rStyleSet.
Put(*pRuby);
1959 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1962 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_DROP)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1966 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1969 if(!rValue.has<OUString>())
1970 throw lang::IllegalArgumentException();
1971 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1972 std::unique_ptr<SwFormatDrop> pDrop;
1977 const auto sValue(rValue.get<OUString>());
1980 auto pStyle(static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)));
1982 if(!pStyle || pStyle->GetCharFormat() == m_pDoc->GetDfltCharFormat() )
1984 throw lang::IllegalArgumentException();
1986 pDrop->SetCharFormat(pStyle->GetCharFormat());
1987 rStyleSet.
Put(*pDrop);
1990 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_NUMRULE)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1994 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1996 if(SfxStyleFamily::Para == m_rEntry.m_eFamily &&
1997 o_rStyleBase.getNewBase().is() && o_rStyleBase.getNewBase()->GetCollection() &&
1999 o_rStyleBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle())
2001 OUString sNewNumberingRuleName;
2002 aValue >>= sNewNumberingRuleName;
2003 if(sNewNumberingRuleName.isEmpty() || sNewNumberingRuleName != m_pDoc->GetOutlineNumRule()->GetName())
2004 o_rStyleBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2008 void SwXStyle::SetStyleProperty(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& rBase)
2010 using propertytype_t = decltype(rEntry.
nWID);
2011 using coresetter_t = std::function<void(SwXStyle&, const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, const uno::Any&, SwStyleBase_Impl&)>;
2012 static std::optional<std::map<propertytype_t, coresetter_t>> pUnoToCore;
2015 pUnoToCore = std::map<propertytype_t, coresetter_t> {
2017 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_HIDDEN>) },
2026 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>) },
2029 {
FN_UNO_LINK_STYLE, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_LINK_STYLE>) },
2034 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>) },
2035 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>) },
2041 const auto pUnoToCoreIt(pUnoToCore->find(rEntry.
nWID));
2042 if(pUnoToCoreIt != pUnoToCore->end())
2043 pUnoToCoreIt->second(*
this, rEntry, rPropSet, rValue, rBase);
2050 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, rBase);
2054 void SwXStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2057 throw uno::RuntimeException();
2058 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2061 if(rPropertyNames.getLength() != rValues.getLength())
2062 throw lang::IllegalArgumentException();
2064 SwStyleBase_Impl aBaseImpl(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTextFormatColl()->GetAttrSet());
2068 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2070 throw uno::RuntimeException();
2071 aBaseImpl.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2073 if(!aBaseImpl.getNewBase().is() && !m_bIsDescriptor)
2074 throw uno::RuntimeException();
2076 const OUString* pNames = rPropertyNames.getConstArray();
2078 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2080 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(pNames[nProp]);
2082 throw beans::UnknownPropertyException(
"Unknown property: " + pNames[nProp], static_cast<cppu::OWeakObject*>(
this));
2083 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2084 throw beans::PropertyVetoException (
"Property is read-only: " + pNames[nProp], static_cast<cppu::OWeakObject*>(
this));
2085 if(aBaseImpl.getNewBase().is())
2086 SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl);
2087 else if(!m_pPropertiesImpl->SetProperty(pNames[nProp], pValues[nProp]))
2088 throw lang::IllegalArgumentException();
2091 if(aBaseImpl.HasItemSet())
2092 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
2095 void SwXStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2101 SetPropertyValues_Impl( rPropertyNames, rValues );
2103 catch (
const beans::UnknownPropertyException &rException)
2107 lang::WrappedTargetException aWExc;
2108 aWExc.TargetException <<= rException;
2120 void SwXStyle::PrepareStyleBase(SwStyleBase_Impl& rBase)
2124 throw uno::RuntimeException();
2125 if(!rBase.getNewBase().is())
2126 rBase.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2130 uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase);
2132 uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2139 if( bPhys && SfxStyleFamily::Char == GetFamily() &&
2146 uno::Any SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2152 return uno::Any(xBase->IsHidden());
2155 uno::Any SwXStyle::GetStyleProperty<FN_UNO_STYLE_INTEROP_GRAB_BAG>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2162 xBase->GetGrabBagItem(aRet);
2166 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAPER_BIN)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2168 PrepareStyleBase(rBase);
2171 rPropSet.getPropertyValue(rEntry, rSet, aValue);
2174 return uno::Any(OUString(
"[From printer settings]"));
2175 SfxPrinter* pPrinter = GetDoc()->getIDocumentDeviceAccess().getPrinter(
false);
2178 return uno::Any(pPrinter->GetPaperBinName(nBin));
2181 uno::Any SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2183 PrepareStyleBase(rBase);
2184 const SwNumRule* pRule = rBase.getNewBase()->GetNumRule();
2185 assert(pRule &&
"Where is the NumRule?");
2186 uno::Reference<container::XIndexReplace> xRules(
new SwXNumberingRules(*pRule, GetDoc()));
2190 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PARATR_OUTLINELEVEL)>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2192 PrepareStyleBase(rBase);
2193 SAL_WARN_IF(SfxStyleFamily::Para != GetFamily(),
"sw.uno",
"only paras");
2194 return uno::Any(sal_Int16(rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel()));
2197 uno::Any SwXStyle::GetStyleProperty<FN_UNO_FOLLOW_STYLE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2199 PrepareStyleBase(rBase);
2206 uno::Any SwXStyle::GetStyleProperty<FN_UNO_LINK_STYLE>(
const SfxItemPropertyMapEntry&,
2207 const SfxItemPropertySet&,
2208 SwStyleBase_Impl& rBase)
2210 PrepareStyleBase(rBase);
2218 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAGEDESC)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2220 PrepareStyleBase(rBase);
2222 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2236 uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_AUTO_UPDATE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2238 PrepareStyleBase(rBase);
2241 case SfxStyleFamily::Para :
return uno::Any(rBase.getNewBase()->GetCollection()->IsAutoUpdateFormat());
2242 case SfxStyleFamily::Frame:
return uno::Any(rBase.getNewBase()->GetFrameFormat()->IsAutoUpdateFormat());
2247 uno::Any SwXStyle::GetStyleProperty<FN_UNO_DISPLAY_NAME>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2249 PrepareStyleBase(rBase);
2250 return uno::Any(rBase.getNewBase()->GetName());
2253 uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2255 PrepareStyleBase(rBase);
2258 sal_uInt16 nIndex = 0;
2259 for(
auto& rNV : asNonConstRange(aSeq))
2262 rNV.Value <<= OUString();
2268 beans::NamedValue* pSeq =
aSeq.getArray();
2277 pSeq[
n].Value <<= aStyleName;
2283 uno::Any SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2285 PrepareStyleBase(rBase);
2286 static std::optional<std::map<collectionbits_t, paragraphstyle_t>> pUnoToCore;
2289 pUnoToCore.emplace();
2291 std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
2292 [] (
const ParagraphStyleCategoryEntry& rEntry) {
return std::pair<collectionbits_t, paragraphstyle_t>(rEntry.m_nCollectionBits, rEntry.m_eCategory); });
2294 const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFormatId();
2296 if(pUnoToCoreIt == pUnoToCore->end())
2298 return uno::Any(pUnoToCoreIt->second);
2301 uno::Any SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2303 PrepareStyleBase(rBase);
2304 const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc();
2315 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_BACKGROUND)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2317 PrepareStyleBase(rBase);
2321 if(!aOriginalBrushItem->QueryValue(aResult, rEntry.nMemberId))
2322 SAL_WARN(
"sw.uno",
"error getting attribute from RES_BACKGROUND.");
2326 uno::Any SwXStyle::GetStyleProperty<OWN_ATTR_FILLBMP_MODE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2328 PrepareStyleBase(rBase);
2330 if (rSet.
Get(XATTR_FILLBMP_TILE).GetValue())
2331 return uno::Any(drawing::BitmapMode_REPEAT);
2332 if (rSet.
Get(XATTR_FILLBMP_STRETCH).GetValue())
2333 return uno::Any(drawing::BitmapMode_STRETCH);
2334 return uno::Any(drawing::BitmapMode_NO_REPEAT);
2337 uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2339 PrepareStyleBase(rBase);
2342 rPropSet.getPropertyValue(rEntry, rSet, aResult);
2346 aResult <<= static_cast<sal_Int16>(aResult.get<sal_Int32>());
2348 if(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM && GetDoc())
2350 const SfxItemPool& rPool = GetDoc()->GetAttrPool();
2352 bool bAllowedConvert(
true);
2355 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
2356 bAllowedConvert = !aResult.has<sal_Int32>() || aResult.get<sal_Int32>() > 0;
2357 if(eMapUnit != MapUnit::Map100thMM && bAllowedConvert)
2363 uno::Any SwXStyle::GetStyleProperty_Impl(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2365 using propertytype_t = decltype(rEntry.
nWID);
2366 using coresetter_t = std::function<uno::Any(SwXStyle&, const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, SwStyleBase_Impl&)>;
2367 static std::optional<std::map<propertytype_t, coresetter_t>> pUnoToCore;
2370 pUnoToCore = std::map<propertytype_t, coresetter_t> {
2372 {
FN_UNO_IS_PHYSICAL, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>) },
2373 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>) },
2376 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>) },
2379 {
FN_UNO_LINK_STYLE, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_LINK_STYLE>) },
2384 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>) },
2385 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>) },
2390 const auto pUnoToCoreIt(pUnoToCore->find(rEntry.
nWID));
2391 if(pUnoToCoreIt != pUnoToCore->end())
2392 return pUnoToCoreIt->second(*
this, rEntry, rPropSet, rBase);
2393 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2396 uno::Any SwXStyle::GetPropertyValue_Impl(
const SfxItemPropertySet* pPropSet, SwStyleBase_Impl& rBase,
const OUString& rPropertyName)
2399 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropertyName);
2401 throw beans::UnknownPropertyException(
"Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(
this));
2403 return GetStyleProperty_Impl(*pEntry, *pPropSet, rBase);
2405 m_pPropertiesImpl->GetProperty(rPropertyName, pAny);
2409 switch(m_rEntry.m_eFamily)
2411 case SfxStyleFamily::Pseudo:
2412 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2414 case SfxStyleFamily::Para:
2415 case SfxStyleFamily::Page:
2416 SwStyleProperties_Impl::GetProperty(rPropertyName, m_xStyleData, aValue);
2418 case SfxStyleFamily::Char:
2419 case SfxStyleFamily::Frame:
2422 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2424 if(m_rEntry.m_eFamily == SfxStyleFamily::Char)
2425 pFormat = m_pDoc->GetDfltCharFormat();
2427 pFormat = m_pDoc->GetDfltFrameFormat();
2439 uno::Any SwXStyle::getPropertyValue(
const OUString& rPropertyName)
2443 throw uno::RuntimeException();
2444 if(!m_pBasePool && !m_bIsDescriptor)
2445 throw uno::RuntimeException();
2446 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2448 SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet());
2449 return GetPropertyValue_Impl(pPropSet, aBase, rPropertyName);
2452 uno::Sequence<uno::Any> SwXStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
2456 throw uno::RuntimeException();
2457 if(!m_pBasePool && !m_bIsDescriptor)
2458 throw uno::RuntimeException();
2459 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2461 SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet());
2462 uno::Sequence<uno::Any> aValues(rPropertyNames.getLength());
2463 auto aValuesRange = asNonConstRange(aValues);
2467 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2468 aValuesRange[nProp] = GetPropertyValue_Impl(pPropSet, aBase, rPropertyNames[nProp]);
2470 catch(beans::UnknownPropertyException&)
2473 throw css::lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
2474 static_cast < cppu::OWeakObject * > (
this ), anyEx );
2476 catch(lang::WrappedTargetException&)
2479 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
2480 static_cast < cppu::OWeakObject * > (
this ), anyEx );
2485 void SwXStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
2488 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
2489 const uno::Sequence<uno::Any> aValues(&rValue, 1);
2490 SetPropertyValues_Impl(aProperties, aValues);
2493 beans::PropertyState SwXStyle::getPropertyState(
const OUString& rPropertyName)
2496 uno::Sequence<OUString> aNames{rPropertyName};
2497 uno::Sequence<beans::PropertyState> aStates = getPropertyStates(aNames);
2498 return aStates.getConstArray()[0];
2505 if(eFamily != SfxStyleFamily::Page)
2513 return &pSetItem->GetItemSet();
2515 uno::Sequence<beans::PropertyState> SwXStyle::getPropertyStates(
const uno::Sequence<OUString>& rPropertyNames)
2518 uno::Sequence<beans::PropertyState> aRet(rPropertyNames.getLength());
2519 beans::PropertyState* pStates = aRet.getArray();
2522 throw uno::RuntimeException();
2525 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2527 throw uno::RuntimeException();
2529 const OUString* pNames = rPropertyNames.getConstArray();
2531 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2535 const SfxItemSet& rSet = xStyle->GetItemSet();
2537 for(sal_Int32 i = 0;
i < rPropertyNames.getLength(); ++
i)
2539 const OUString sPropName = pNames[
i];
2540 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(sPropName);
2543 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast<cppu::OWeakObject*>(
this));
2549 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2556 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2559 switch(pEntry->
nWID)
2563 if(SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_STRETCH,
false)
2564 || SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_TILE,
false))
2566 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2570 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2582 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2586 pStates[
i] = beans::PropertyState_DEFAULT_VALUE;
2594 if(SfxStyleFamily::Page == m_rEntry.m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->
nWID && beans::PropertyState_DIRECT_VALUE == pStates[i])
2602 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2611 void SwXStyle::setPropertyToDefault(
const OUString& rPropertyName)
2613 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2614 setPropertiesToDefault(aSequence);
2623 case SfxStyleFamily::Char:
return xStyle->GetCharFormat();
2624 case SfxStyleFamily::Para:
return xStyle->GetCollection();
2625 case SfxStyleFamily::Frame:
return xStyle->GetFrameFormat();
2626 case SfxStyleFamily::Page:
2638 void SAL_CALL SwXStyle::setPropertiesToDefault(
const uno::Sequence<OUString>& aPropertyNames)
2645 if(!m_bIsDescriptor)
2647 for(
const auto& rName : aPropertyNames)
2648 m_pPropertiesImpl->ClearProperty(rName);
2651 const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2654 for(
const auto& rName : aPropertyNames)
2656 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rName);
2658 throw beans::UnknownPropertyException(
"Unknown property: " + rName, static_cast<cppu::OWeakObject*>(
this));
2661 throw uno::RuntimeException(
"Cannot reset: " + rName, static_cast<cppu::OWeakObject*>(
this));
2662 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2663 throw uno::RuntimeException(
"setPropertiesToDefault: property is read-only: " + rName, static_cast<cppu::OWeakObject*>(
this));
2666 static_cast<SwTextFormatColl*
>(pTargetFormat)->DeleteAssignmentToListLevelOfOutlineStyle();
2677 aSet.ClearItem(XATTR_FILLBMP_STRETCH);
2678 aSet.ClearItem(XATTR_FILLBMP_TILE);
2685 void SAL_CALL SwXStyle::setAllPropertiesToDefault()
2690 if(!m_bIsDescriptor)
2691 throw uno::RuntimeException();
2692 m_pPropertiesImpl->ClearAllProperties();
2697 throw uno::RuntimeException();
2698 if(SfxStyleFamily::Page == m_rEntry.m_eFamily)
2700 size_t nPgDscPos(0);
2701 SwPageDesc* pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName(), &nPgDscPos);
2710 SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos);
2713 pPageFormat->SetPageFormatToDefault();
2715 std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>(
SwFrameSize::Fixed));
2719 if(m_pDoc->getIDocumentDeviceAccess().getPrinter(
false))
2722 static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(
false))));
2723 aFrameSz->SetSize(aPhysSize);
2738 SwTwips nTmp = aFrameSz->GetHeight();
2739 aFrameSz->SetHeight(aFrameSz->GetWidth());
2740 aFrameSz->SetWidth(nTmp);
2743 pPageFormat->SetFormatAttr(*aFrameSz);
2744 m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos));
2747 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
2749 if(xStyle->GetCollection())
2750 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2758 uno::Sequence<uno::Any> SAL_CALL SwXStyle::getPropertyDefaults(
const uno::Sequence<OUString>& aPropertyNames)
2761 sal_Int32 nCount = aPropertyNames.getLength();
2762 uno::Sequence<uno::Any> aRet(nCount);
2765 auto pRet = aRet.getArray();
2768 throw uno::RuntimeException();
2770 const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2775 for(sal_Int32 i = 0; i < nCount; ++i)
2777 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(aPropertyNames[i]);
2780 throw beans::UnknownPropertyException(
"Unknown property: " + aPropertyNames[i], static_cast < cppu::OWeakObject * >(
this));
2799 uno::Any SwXStyle::getPropertyDefault(
const OUString& rPropertyName)
2801 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2802 return getPropertyDefaults(aSequence)[0];
2807 if((rHint.
GetId() == SfxHintId::Dying) || (rHint.
GetId() == SfxHintId::StyleSheetErased))
2809 m_pBasePool =
nullptr;
2812 else if(rHint.
GetId() == SfxHintId::StyleSheetChanged)
2814 SfxStyleSheetBasePool& rBP =
static_cast<SfxStyleSheetBasePool&
>(rBC);
2824 void SwXStyle::Invalidate()
2826 m_sStyleName.clear();
2827 m_pBasePool =
nullptr;
2829 m_xStyleData.clear();
2830 m_xStyleFamily.clear();
2833 SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
SwDocShell* pDocSh,
const OUString& rStyleName)
2837 SwXPageStyle::SwXPageStyle(
SwDocShell* pDocSh)
2841 void SwXStyle::PutItemToSet(
const SvxSetItem* pSetItem,
const SfxItemPropertySet& rPropSet,
const SfxItemPropertyMapEntry& rEntry,
const uno::Any& rVal, SwStyleBase_Impl& rBaseImpl)
2844 const std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2845 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2848 rSetSet.
SetParent(&m_pDoc->GetDfltFrameFormat()->GetAttrSet());
2853 SwStyleBase_Impl::ItemSetOverrider o(rBaseImpl, &rSetSet);
2854 SetStyleProperty(rEntry, rPropSet, rVal, rBaseImpl);
2858 rSetSet.SetParent(
nullptr);
2861 rBaseImpl.GetItemSet().Put(*pNewSetItem);
2864 void SwXPageStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2867 throw uno::RuntimeException();
2869 if(rPropertyNames.getLength() != rValues.getLength())
2870 throw lang::IllegalArgumentException();
2874 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2878 throw uno::RuntimeException();
2879 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2880 if(!m_pPropertiesImpl->SetProperty(rPropertyNames[nProp], rValues[nProp]))
2881 throw lang::IllegalArgumentException();
2886 throw uno::RuntimeException();
2887 aBaseImpl.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2888 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2890 const OUString& rPropName = rPropertyNames[nProp];
2891 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropName);
2894 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
2895 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2896 throw beans::PropertyVetoException(
"Property is read-only: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
2898 const bool bHeader(rPropName.startsWith(
"Header"));
2899 const bool bFooter(rPropName.startsWith(
"Footer"));
2901 if(bHeader || bFooter || bFirstIsShared)
2903 switch(pEntry->
nWID)
2905 case SID_ATTR_PAGE_ON:
2911 case SID_ATTR_PAGE_DYNAMIC:
2912 case SID_ATTR_PAGE_SHARED:
2913 case SID_ATTR_PAGE_SHARED_FIRST:
2914 case SID_ATTR_PAGE_SIZE:
2921 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2923 if (pEntry->
nWID == SID_ATTR_PAGE_SHARED_FIRST)
2926 pSetItem = aBaseImpl.GetItemSet().GetItemIfSet(
2927 bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
2931 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2935 else if(pEntry->
nWID == SID_ATTR_PAGE_ON && rValues[nProp].get<
bool>())
2944 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER,
2945 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE,
2946 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED,
2947 SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST>
2948 aTempSet(*aBaseImpl.GetItemSet().GetPool());
2951 aTempSet.
SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2953 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_ON,
true));
2955 aTempSet.Put(
SvxSizeItem(SID_ATTR_PAGE_SIZE,
Size(constTwips_5mm, constTwips_5mm)));
2958 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED,
true));
2959 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST,
true));
2960 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_DYNAMIC,
true));
2962 SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet);
2963 aBaseImpl.GetItemSet().Put(aNewSetItem);
2992 aBaseImpl.GetItemSet().GetItemIfSet(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false);
2997 std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2998 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
3001 rSetSet.
SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
3006 SwStyleBase_Impl::ItemSetOverrider o(aBaseImpl, &rSetSet);
3007 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
3011 rSetSet.SetParent(
nullptr);
3014 aBaseImpl.GetItemSet().Put(*pNewSetItem);
3021 switch(pEntry->
nWID)
3023 case SID_ATTR_PAGE_DYNAMIC:
3024 case SID_ATTR_PAGE_SHARED:
3025 case SID_ATTR_PAGE_SHARED_FIRST:
3026 case SID_ATTR_PAGE_ON:
3029 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
3038 throw lang::IllegalArgumentException();
3042 std::unique_ptr<SfxPoolItem> pNewFootnoteItem(rItem.
Clone());
3043 if(!pNewFootnoteItem->PutValue(rValues[nProp], pEntry->
nMemberId))
3044 throw lang::IllegalArgumentException();
3045 aBaseImpl.GetItemSet().Put(std::move(pNewFootnoteItem));
3050 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
3056 if(aBaseImpl.HasItemSet())
3060 if (undoGuard.UndoWasEnabled())
3063 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3066 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
3070 void SwXPageStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
3077 SetPropertyValues_Impl(rPropertyNames, rValues);
3079 catch (
const beans::UnknownPropertyException &rException)
3083 lang::WrappedTargetException aWExc;
3084 aWExc.TargetException <<= rException;
3095 if(SfxItemState::SET != rSet.
GetItemState(nRes,
true, &pItem))
3100 if(!pHeadFootFormat)
3105 uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames)
3108 throw uno::RuntimeException();
3110 sal_Int32
nLength = rPropertyNames.getLength();
3111 uno::Sequence<uno::Any> aRet (nLength);
3112 auto aRetRange = asNonConstRange(aRet);
3116 throw uno::RuntimeException();
3117 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
3120 m_pPropertiesImpl->GetProperty(rPropertyNames[nProp], pAny);
3122 SwStyleProperties_Impl::GetProperty(rPropertyNames[nProp], m_xStyleData, aRetRange[nProp]);
3124 aRetRange[nProp] = *pAny;
3130 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
3133 throw uno::RuntimeException();
3134 for(sal_Int32 nProp = 0; nProp < nLength; ++nProp)
3136 const OUString& rPropName = rPropertyNames[nProp];
3137 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropName);
3140 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > (
this ) );
3141 const bool bHeader(rPropName.startsWith(
"Header"));
3142 const bool bFooter(rPropName.startsWith(
"Footer"));
3144 if(bHeader || bFooter || bFirstIsShared)
3146 switch(pEntry->
nWID)
3148 case SID_ATTR_PAGE_ON:
3154 case SID_ATTR_PAGE_DYNAMIC:
3155 case SID_ATTR_PAGE_SHARED:
3156 case SID_ATTR_PAGE_SHARED_FIRST:
3157 case SID_ATTR_PAGE_SIZE:
3162 const SfxItemSet& rSet = xStyle->GetItemSet();
3168 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3170 SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast< SfxItemSet& >(rSetSet));
3171 aRetRange[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3174 else if(pEntry->
nWID == SID_ATTR_PAGE_ON)
3177 aRetRange[nProp] <<=
false;
3206 const SfxItemSet& rSet = xStyle->GetItemSet();
3208 rSet.
GetItemIfSet(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false);
3212 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3214 SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast<SfxItemSet&>(rSetSet));
3215 aRetRange[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3223 switch(pEntry->
nWID)
3226 case SID_ATTR_PAGE_DYNAMIC:
3227 case SID_ATTR_PAGE_SHARED:
3228 case SID_ATTR_PAGE_SHARED_FIRST:
3229 case SID_ATTR_PAGE_ON:
3231 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > (
this ) );
3243 sal_uInt16 nRes = 0;
3244 switch(pEntry->
nWID)
3257 const SwPageDesc* pDesc = aBase.GetOldPageDesc();
3266 if(bLeft && !bShare)
3267 pFrameFormat = &pDesc->
GetLeft();
3268 else if(bFirst && !bShareFirst)
3278 aRetRange[nProp] <<= xRet;
3284 const SfxItemSet& rSet = xStyle->GetItemSet();
3290 aRetRange[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3296 uno::Sequence<uno::Any> SwXPageStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
3299 uno::Sequence<uno::Any> aValues;
3304 aValues = GetPropertyValues_Impl(rPropertyNames);
3306 catch(beans::UnknownPropertyException &)
3309 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
3310 static_cast < cppu::OWeakObject * > (
this ), anyEx );
3312 catch(lang::WrappedTargetException &)
3315 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
3316 static_cast < cppu::OWeakObject * > (
this ), anyEx );
3322 uno::Any SwXPageStyle::getPropertyValue(
const OUString& rPropertyName)
3325 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3326 return GetPropertyValues_Impl(aProperties)[0];
3329 void SwXPageStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
3332 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3333 const uno::Sequence<uno::Any> aValues(&rValue, 1);
3339 if ((bIsFooter || bIsHeader) && rValue ==
uno::Any(
true))
3342 for (
size_t i = 0; i < GetDoc()->GetPageDescCnt(); i++)
3344 auto pPageDesc = &GetDoc()->GetPageDesc(i);
3346 if (pPageDesc->
GetName() == GetStyleName())
3349 if (bIsHeader && pLeftHeader)
3356 if (bIsFooter && pLeftFooter)
3366 SetPropertyValues_Impl(aProperties, aValues);
3369 SwXFrameStyle::SwXFrameStyle(
SwDoc *pDoc)
3373 void SwXFrameStyle::SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
3375 assert(eAtr >= RES_FRMATR_BEGIN && eAtr < RES_FRMATR_END);
3380 SfxItemSet& rStyleSet = xStyle->GetItemSet();
3383 xStyle->SetItemSet(aSet);
3388 assert(eAtr >= RES_FRMATR_BEGIN && eAtr < RES_FRMATR_END);
3393 return &xStyle->GetItemSet().Get(eAtr);
3396 uno::Sequence<uno::Type> SwXFrameStyle::getTypes()
3400 SwXStyle::getTypes()
3407 return uno::Any(uno::Reference<XEventsSupplier>(
this));
3408 return SwXStyle::queryInterface(rType);
3411 uno::Reference<container::XNameReplace> SwXFrameStyle::getEvents()
3417 #define AUTOSTYLE_FAMILY_COUNT 3
3428 std::vector<std::shared_ptr<SfxItemSet>>::iterator
m_aIter;
3434 std::shared_ptr<SfxItemSet>
const &
nextElement() {
return *(m_aIter++); }
3458 throw lang::IndexOutOfBoundsException();
3460 throw uno::RuntimeException();
3462 uno::Reference< style::XAutoStyleFamily > aRef;
3509 if(Name ==
"CharacterStyles")
3511 else if(Name ==
"RubyStyles")
3513 else if(Name ==
"ParagraphStyles")
3516 throw container::NoSuchElementException();
3523 OUString* pNames = aNames.getArray();
3524 pNames[0] =
"CharacterStyles";
3525 pNames[1] =
"RubyStyles";
3526 pNames[2] =
"ParagraphStyles";
3532 if( Name ==
"CharacterStyles" ||
3533 Name ==
"RubyStyles" ||
3534 Name ==
"ParagraphStyles" )
3541 m_pDocShell( pDocSh ), m_eFamily(nFamily)
3553 if(rHint.
GetId() == SfxHintId::Dying)
3554 m_pDocShell =
nullptr;
3558 const uno::Sequence< beans::PropertyValue >& Values )
3562 throw uno::RuntimeException();
3566 const SfxItemPropertySet* pPropSet =
nullptr;
3591 throw uno::RuntimeException();
3596 if(!bTakeCareOfDrawingLayerFillStyle)
3598 for(
const beans::PropertyValue& rValue : Values )
3604 catch (
const beans::UnknownPropertyException &)
3606 OSL_FAIL(
"Unknown property" );
3608 catch (
const lang::IllegalArgumentException &)
3610 OSL_FAIL(
"Illegal argument" );
3626 for(
const beans::PropertyValue& rValue : Values )
3628 const OUString& rPropName = rValue.Name;
3630 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropName);
3634 SAL_WARN(
"sw.core",
"SwXAutoStyleFamily::insertStyle: Unknown property: " << rPropName);
3642 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
3652 if(aValue >>= nValue)
3663 if(eMapUnit != MapUnit::Map100thMM)
3670 switch(pEntry->
nWID)
3686 if(!(aValue >>= aTempName))
3688 throw lang::IllegalArgumentException();
3701 aXFillBitmapItem.
PutValue(aValue, nMemberId);
3702 aSet.Put(aXFillBitmapItem);
3712 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
3714 aChangedBrushItem->PutValue(aValue, nMemberId);
3716 if(*aChangedBrushItem != *aOriginalBrushItem)
3726 drawing::BitmapMode eMode;
3728 if(!(aValue >>= eMode))
3730 sal_Int32 nMode = 0;
3732 if(!(aValue >>= nMode))
3734 throw lang::IllegalArgumentException();
3737 eMode =
static_cast<drawing::BitmapMode
>(nMode);
3755 catch (
const beans::UnknownPropertyException &)
3757 OSL_FAIL(
"Unknown property" );
3759 catch (
const lang::IllegalArgumentException &)
3761 OSL_FAIL(
"Illegal argument" );
3767 aSet.SetParent(
nullptr);
3786 throw uno::RuntimeException();
3787 return uno::Reference< container::XEnumeration >
3802 : m_rDoc( rInitDoc ), m_eFamily( eFam )
3807 std::set< std::pair< sal_uInt16, text::RubyAdjust > > aRubyMap;
3811 std::vector<const SwFormatRuby*> vRubyItems;
3814 auto pRubyItem =
dynamic_cast<const SwFormatRuby*
>(pItem);
3815 if ( pRubyItem && pRubyItem->GetTextRuby() )
3816 vRubyItems.push_back(pRubyItem);
3820 std::pair< sal_uInt16, text::RubyAdjust > aPair( pRubyItem->GetPosition(), pRubyItem->GetAdjustment() );
3821 if ( aRubyMap.insert( aPair ).second )
3823 auto pItemSet = std::make_shared<SfxItemSetFixed<RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY>>( rAttrPool );
3824 pItemSet->Put( *pRubyItem );
3850 if(rHint.
GetId() == SfxHintId::Dying)
3857 throw uno::RuntimeException();
3858 return m_pImpl->hasMoreElements();
3864 throw uno::RuntimeException();
3866 if(
m_pImpl->hasMoreElements() )
3868 std::shared_ptr<SfxItemSet> pNextSet =
m_pImpl->nextElement();
3870 pNextSet,
m_pImpl->getFamily());
3871 aRet <<= xAutoStyle;
3885 std::shared_ptr<SfxItemSet>
const & pInitSet,
3901 if(rHint.
GetId() == SfxHintId::Dying)
3907 uno::Reference< beans::XPropertySetInfo > xRet;
3912 static uno::Reference< beans::XPropertySetInfo > xCharRef;
3922 static uno::Reference< beans::XPropertySetInfo > xRubyRef;
3933 static uno::Reference< beans::XPropertySetInfo > xParaRef;
3957 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3962 const uno::Reference< beans::XPropertyChangeListener >& )
3967 const uno::Reference< beans::XPropertyChangeListener >& )
3972 const uno::Reference< beans::XVetoableChangeListener >& )
3977 const uno::Reference< beans::XVetoableChangeListener >& )
3982 const uno::Sequence< OUString >& ,
3983 const uno::Sequence< uno::Any >& )
3988 const uno::Sequence< OUString > & rPropertyNames )
3992 throw uno::RuntimeException();
4007 const OUString* pNames = rPropertyNames.getConstArray();
4009 const sal_Int32 nLen(rPropertyNames.getLength());
4010 uno::Sequence< uno::Any > aRet( nLen );
4011 uno::Any* pValues = aRet.getArray();
4014 for( sal_Int32 i = 0; i < nLen; ++i )
4016 const OUString sPropName = pNames[i];
4017 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(sPropName);
4020 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > (
this ) );
4032 else if(bTakeCareOfDrawingLayerFillStyle)
4035 switch(pEntry->
nWID)
4041 if(!aOriginalBrushItem->QueryValue(aTarget, pEntry->
nMemberId))
4043 OSL_ENSURE(
false,
"Error getting attribute from RES_BACKGROUND (!)");
4053 aTarget <<= drawing::BitmapMode_REPEAT;
4057 aTarget <<= drawing::BitmapMode_STRETCH;
4061 aTarget <<= drawing::BitmapMode_NO_REPEAT;
4075 if(bTakeCareOfDrawingLayerFillStyle)
4081 if (aTarget >>= nValue)
4083 aTarget <<= static_cast<sal_Int16>(nValue);
4088 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
4098 if(aTarget >>= nValue)
4109 if(eMapUnit != MapUnit::Map100thMM)
4118 pValues[i] = aTarget;
4125 const uno::Sequence< OUString >& rPropertyNames )
4128 uno::Sequence< uno::Any > aValues;
4135 catch (beans::UnknownPropertyException &)
4138 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught", static_cast < cppu::OWeakObject * > (
this ), exc );
4140 catch (lang::WrappedTargetException &)
4143 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught", static_cast < cppu::OWeakObject * > (
this ), exc );
4150 const uno::Sequence< OUString >& ,
4151 const uno::Reference< beans::XPropertiesChangeListener >& )
4156 const uno::Reference< beans::XPropertiesChangeListener >& )
4161 const uno::Sequence< OUString >& ,
4162 const uno::Reference< beans::XPropertiesChangeListener >& )
4170 uno::Sequence< OUString > aNames { rPropertyName };
4172 return aStates.getConstArray()[0];
4181 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4186 const uno::Sequence< OUString >& rPropertyNames )
4190 throw uno::RuntimeException();
4194 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4195 beans::PropertyState* pStates = aRet.getArray();
4196 const OUString* pNames = rPropertyNames.getConstArray();
4211 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4213 const OUString sPropName = pNames[i];
4214 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(sPropName);
4217 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > (
this ) );
4222 if(bTakeCareOfDrawingLayerFillStyle)
4225 switch(pEntry->
nWID)
4232 pStates[i] = beans::PropertyState_DIRECT_VALUE;
4236 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
4247 pStates[i] = beans::PropertyState_DIRECT_VALUE;
4251 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
4274 const uno::Sequence< OUString >& )
4279 const uno::Sequence< OUString >& )
4287 throw uno::RuntimeException();
4289 std::vector< beans::PropertyValue > aPropertyVector;
4308 const sal_uInt16 nWID = pItem->Which();
4314 if ( pEntry->
nWID == nWID )
4316 beans::PropertyValue aPropertyValue;
4317 aPropertyValue.Name = pEntry->
aName;
4318 pItem->QueryValue( aPropertyValue.Value, pEntry->
nMemberId );
4319 aPropertyVector.push_back( aPropertyValue );
4324 const sal_Int32 nCount = aPropertyVector.size();
4325 uno::Sequence< beans::PropertyValue > aRet( nCount );
4326 beans::PropertyValue* pProps = aRet.getArray();
4328 for (
int i = 0; i < nCount; ++i, pProps++ )
4330 *pProps = aPropertyVector[i];
4337 m_pDocShell(pDocShell), m_pTableAutoFormat(pTableAutoFormat), m_bPhysical(true)
4343 m_pDocShell(pDocShell), m_pTableAutoFormat_Impl(new
SwTableAutoFormat(rTableAutoFormatName)), m_bPhysical(
false)
4352 uno::Reference<style::XStyle> xTextTableStyle;
4354 if (pAutoFormat && pAutoFormat->
GetName() == rTableAutoFormatName)
4356 xTextTableStyle.set(pAutoFormat->
GetXObject(), uno::UNO_QUERY);
4357 if (!xTextTableStyle.is())
4365 if (!xTextTableStyle.is())
4368 SAL_INFO(
"sw.uno",
"creating SwXTextTableStyle for non existing SwTableAutoFormat");
4371 return xTextTableStyle;
4377 assert(aTableTemplateMap.size() ==
STYLE_COUNT &&
"can not map SwTableAutoFormat to a SwXTextTableStyle");
4381 uno::Reference<style::XStyle> xCellStyle(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4382 if (!xCellStyle.is())
4424 for(
size_t i=0; i < nStyles; ++i)
4427 if (pAutoFormat->
GetName() == sName)
4442 if (pTableAutoFormat)
4447 for (
size_t i=0; i<aTableTemplateMap.size(); ++i)
4450 uno::Reference<style::XStyle> xCellStyle(pOldBoxFormat->
GetXObject(), uno::UNO_QUERY);
4451 if (!xCellStyle.is())
4463 SAL_WARN(
"sw.uno",
"setting style physical, but SwTableAutoFormat in document not found");
4466 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextTableStyle");
4490 if (!pFormat->
GetInfo(aGetHt))
4533 SAL_WARN(
"sw.uno",
"not implemented");
4539 bool bIsRow =
false;
4552 throw css::beans::UnknownPropertyException(rPropertyName);
4554 return uno::Any(bIsRow ? OUString(
"row") : OUString(
"column"));
4559 SAL_WARN(
"sw.uno",
"not implemented");
4564 SAL_WARN(
"sw.uno",
"not implemented");
4569 SAL_WARN(
"sw.uno",
"not implemented");
4574 SAL_WARN(
"sw.uno",
"not implemented");
4582 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4583 if(iter == rMap.end())
4584 throw css::container::NoSuchElementException();
4599 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4600 return iter != rMap.end();
4606 SAL_WARN(
"sw.uno",
"not implemented");
4613 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4614 if(iter == rMap.end())
4615 throw container::NoSuchElementException();
4616 const sal_Int32 nCellStyle = iter->second;
4618 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
4620 throw lang::IllegalArgumentException();
4623 if (!pStyleToReplaceWith)
4624 throw lang::IllegalArgumentException();
4628 throw lang::IllegalArgumentException();
4631 const sal_Int32 nBoxFormat = rTableTemplateMap[nCellStyle];
4646 SAL_WARN(
"sw.uno",
"not implemented");
4663 return {
"SwXTextTableStyle"};
4673 return {
"com.sun.star.style.Style"};
4678 m_pDocShell(pDocShell),
4679 m_pBoxAutoFormat(pBoxAutoFormat),
4680 m_sParentStyle(sParentStyle),
4685 m_pDocShell(pDocShell),
4703 SAL_INFO(
"sw.uno",
"trying to call SwXTextCellStyle::SetBoxFormat on non physical style");
4719 SAL_WARN(
"sw.uno",
"setting style physical, but SwBoxAutoFormat in document not found");
4722 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextCellStyle");
4736 if (!pBoxAutoFormat)
4738 sal_Int32 nTemplateIndex;
4739 OUString sParentName;
4740 std::u16string_view sCellSubName;
4742 size_t nSeparatorIndex = sName.rfind(
'.');
4743 if (nSeparatorIndex == std::u16string_view::npos)
4746 sParentName = sName.substr(0, nSeparatorIndex);
4747 sCellSubName = sName.substr(nSeparatorIndex+1);
4749 if (0 > nTemplateIndex)
4758 if (!pTableAutoFormat)
4762 *pParentName = sParentName;
4763 sal_uInt32 nBoxIndex = rTableTemplateMap[nTemplateIndex];
4764 pBoxAutoFormat = &pTableAutoFormat->
GetBoxFormat(nBoxIndex);
4767 return pBoxAutoFormat;
4772 uno::Reference<style::XStyle> xTextCellStyle;
4774 if (!sName.isEmpty())
4776 OUString sParentName;
4784 pBoxFormat = &aDefaultBoxFormat;
4787 xTextCellStyle.set(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4788 if (!xTextCellStyle.is())
4790 xTextCellStyle.set(
new SwXTextCellStyle(pDocShell, pBoxFormat, sParentName));
4797 return xTextCellStyle;
4814 uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(m_pDocShell->
GetModel(), uno::UNO_QUERY);
4815 if (!xFamiliesSupplier.is())
4818 uno::Reference<container::XNameAccess> xFamilies = xFamiliesSupplier->getStyleFamilies();
4819 if (!xFamilies.is())
4822 uno::Reference<container::XNameAccess> xTableStyles;
4823 xFamilies->getByName(
"TableStyles") >>= xTableStyles;
4824 if (!xTableStyles.is())
4827 uno::Reference<style::XStyle> xStyle;
4832 return xStyle->isInUse();
4845 SAL_INFO(
"sw.uno",
"Changing SwXTextCellStyle parent");
4865 OUString sParentStyle;
4899 switch(pEntry->
nWID)
4932 if (aValue >>= nKey)
4962 bool bValue =
false; aValue >>= bValue;
4963 rShadowedItem.SetValue(bValue);
4970 bool bValue =
false; aValue >>= bValue;
4971 rContourItem.SetValue(bValue);
4992 rFontHeightItem.
PutValue(aValue, pEntry->