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>
127 class SwStyleProperties_Impl;
129 struct StyleFamilyEntry
131 using GetCountOrName_t = std::function<sal_Int32 (const SwDoc&, OUString*, sal_Int32)>;
133 using TranslateIndex_t = std::function<sal_uInt16(const sal_uInt16)>;
135 sal_uInt16 m_nPropMapType;
136 uno::Reference<beans::XPropertySetInfo> m_xPSInfo;
139 const char* m_pResId;
140 GetCountOrName_t m_fGetCountOrName;
141 CreateStyle_t m_fCreateStyle;
142 TranslateIndex_t m_fTranslateIndex;
143 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)
145 , m_nPropMapType(nPropMapType)
146 , m_xPSInfo(
aSwMapProvider.GetPropertySet(nPropMapType)->getPropertySetInfo())
150 , m_fGetCountOrName(fGetCountOrName)
151 , m_fCreateStyle(fCreateStyle)
152 , m_fTranslateIndex(fTranslateIndex)
155 const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
157 #define nPoolChrNormalRange (RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN)
158 #define nPoolChrHtmlRange (RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN)
159 #define nPoolCollTextRange ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN)
160 #define nPoolCollListsRange ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN)
161 #define nPoolCollExtraRange ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN)
162 #define nPoolCollRegisterRange ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN)
163 #define nPoolCollDocRange ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN)
164 #define nPoolCollHtmlRange ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN)
165 #define nPoolFrameRange ( RES_POOLFRM_END - RES_POOLFRM_BEGIN)
166 #define nPoolPageRange ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN)
167 #define nPoolNumRange ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN)
168 #define nPoolCollListsStackedStart ( nPoolCollTextRange)
169 #define nPoolCollExtraStackedStart ( nPoolCollListsStackedStart + nPoolCollListsRange)
170 #define nPoolCollRegisterStackedStart ( nPoolCollExtraStackedStart + nPoolCollExtraRange)
171 #define nPoolCollDocStackedStart ( nPoolCollRegisterStackedStart + nPoolCollRegisterRange)
172 #define nPoolCollHtmlStackedStart ( nPoolCollDocStackedStart + nPoolCollDocRange)
173 using paragraphstyle_t = std::remove_const<decltype(style::ParagraphStyleCategory::TEXT)>::type;
174 using collectionbits_t = sal_uInt16;
175 struct ParagraphStyleCategoryEntry
177 paragraphstyle_t m_eCategory;
179 collectionbits_t m_nCollectionBits;
180 ParagraphStyleCategoryEntry(paragraphstyle_t eCategory,
SfxStyleSearchBits nSwStyleBits, collectionbits_t nCollectionBits)
181 : m_eCategory(eCategory)
182 , m_nSwStyleBits(nSwStyleBits)
183 , m_nCollectionBits(nCollectionBits)
186 const std::vector<ParagraphStyleCategoryEntry>* our_pParagraphStyleCategoryEntries;
196 class XStyleFamily :
public cppu::WeakImplHelper
198 container::XNameContainer,
200 container::XIndexAccess,
205 const StyleFamilyEntry& m_rEntry;
209 SwXStyle* FindStyle(std::u16string_view rStyleName)
const;
210 sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32)
211 {
return m_rEntry.m_fGetCountOrName(*m_pDocShell->
GetDoc(), pString,
nIndex); };
215 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
216 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
217 assert(pEntry != pEntries->end());
222 : m_rEntry(InitEntry(eFamily))
223 , m_pBasePool(pDocShell->GetStyleSheetPool())
224 , m_pDocShell(pDocShell)
231 virtual sal_Int32 SAL_CALL getCount()
override
234 return GetCountOrName(
nullptr);
236 virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
override;
239 virtual uno::Type SAL_CALL getElementType( )
override
241 virtual sal_Bool SAL_CALL hasElements( )
override
244 throw uno::RuntimeException();
249 virtual uno::Any SAL_CALL getByName(
const OUString& Name)
override;
250 virtual uno::Sequence< OUString > SAL_CALL getElementNames()
override;
251 virtual sal_Bool SAL_CALL hasByName(
const OUString& Name)
override;
254 virtual void SAL_CALL insertByName(
const OUString& Name,
const uno::Any& Element)
override;
255 virtual void SAL_CALL replaceByName(
const OUString& Name,
const uno::Any& Element)
override;
256 virtual void SAL_CALL removeByName(
const OUString& Name)
override;
259 virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override
262 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
264 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
265 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
266 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const uno::Reference<beans::XPropertyChangeListener>&)
override
267 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
268 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
269 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
270 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const uno::Reference<beans::XVetoableChangeListener>&)
override
271 {
SAL_WARN(
"sw.uno",
"###unexpected!"); };
276 if(rHint.
GetId() == SfxHintId::Dying)
278 m_pBasePool =
nullptr;
279 m_pDocShell =
nullptr;
286 {
return {
"XStyleFamily"}; };
290 {
return {
"com.sun.star.style.StyleFamily" }; }
298 class SwStyleBase_Impl;
299 class SwXStyle :
public cppu::WeakImplHelper
302 css::beans::XPropertySet,
303 css::beans::XMultiPropertySet,
304 css::lang::XServiceInfo,
305 css::lang::XUnoTunnel,
306 css::beans::XPropertyState,
307 css::beans::XMultiPropertyStates
313 OUString m_sStyleName;
314 const StyleFamilyEntry& m_rEntry;
315 bool m_bIsDescriptor;
316 bool m_bIsConditional;
317 OUString m_sParentStyleName;
321 std::unique_ptr<SwStyleProperties_Impl> m_pPropertiesImpl;
322 css::uno::Reference<css::container::XNameAccess> m_xStyleFamily;
323 css::uno::Reference<css::beans::XPropertySet> m_xStyleData;
327 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
329 void PrepareStyleBase(SwStyleBase_Impl& rBase);
338 virtual ~SwXStyle()
override;
341 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
344 virtual sal_Int64 SAL_CALL getSomething(
const css::uno::Sequence< sal_Int8 >& aIdentifier )
override;
347 virtual OUString SAL_CALL getName()
override;
348 virtual void SAL_CALL setName(
const OUString& Name_)
override;
351 virtual sal_Bool SAL_CALL isUserDefined()
override;
352 virtual sal_Bool SAL_CALL isInUse()
override;
353 virtual OUString SAL_CALL getParentStyle()
override;
354 virtual void SAL_CALL setParentStyle(
const OUString& aParentStyle)
override;
357 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
override;
358 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
359 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
360 virtual void SAL_CALL addPropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
361 { OSL_FAIL(
"not implemented"); };
362 virtual void SAL_CALL removePropertyChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XPropertyChangeListener >& )
override
363 { OSL_FAIL(
"not implemented"); };
364 virtual void SAL_CALL addVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
365 { OSL_FAIL(
"not implemented"); };
366 virtual void SAL_CALL removeVetoableChangeListener(
const OUString&,
const css::uno::Reference< css::beans::XVetoableChangeListener >& )
override
367 { OSL_FAIL(
"not implemented"); };
370 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
371 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
372 virtual void SAL_CALL addPropertiesChangeListener(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
374 virtual void SAL_CALL removePropertiesChangeListener(
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
376 virtual void SAL_CALL firePropertiesChangeEvent(
const css::uno::Sequence< OUString >&,
const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
override
380 virtual css::beans::PropertyState SAL_CALL getPropertyState(
const OUString& PropertyName )
override;
381 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(
const css::uno::Sequence< OUString >& aPropertyName )
override;
382 virtual void SAL_CALL setPropertyToDefault(
const OUString& PropertyName )
override;
383 virtual css::uno::Any SAL_CALL getPropertyDefault(
const OUString& aPropertyName )
override;
386 virtual void SAL_CALL setAllPropertiesToDefault( )
override;
387 virtual void SAL_CALL setPropertiesToDefault(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
388 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
392 {
return {
"SwXStyle"}; };
401 const OUString& GetStyleName()
const {
return m_sStyleName;}
404 bool IsDescriptor()
const {
return m_bIsDescriptor;}
405 bool IsConditional()
const {
return m_bIsConditional;}
406 const OUString& GetParentStyleName()
const {
return m_sParentStyleName;}
409 m_bIsDescriptor =
false; m_pDoc = pDc;
413 SwDoc* GetDoc()
const {
return m_pDoc; }
415 void ApplyDescriptorProperties();
416 void SetStyleName(
const OUString& rSet){ m_sStyleName = rSet;}
427 ,
public css::document::XEventsSupplier
433 const OUString& rStyleName) :
435 explicit SwXFrameStyle(
SwDoc *pDoc);
437 virtual void SAL_CALL acquire( ) throw()
override {SwXStyle::acquire();}
438 virtual void SAL_CALL release( ) throw()
override {SwXStyle::release();}
440 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( )
override;
441 virtual css::uno::Any SAL_CALL
queryInterface(
const css::uno::Type& aType )
override;
442 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( )
override;
445 virtual void SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
override;
447 virtual css::document::XEventsSupplier& GetEventsSupplier()
override
455 void SetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues );
456 css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(
const css::uno::Sequence< OUString >& aPropertyNames );
462 virtual void SAL_CALL
setPropertyValue(
const OUString& aPropertyName,
const css::uno::Any& aValue )
override;
463 virtual css::uno::Any SAL_CALL
getPropertyValue(
const OUString& PropertyName )
override;
465 virtual void SAL_CALL setPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames,
const css::uno::Sequence< css::uno::Any >& aValues )
override;
466 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
const css::uno::Sequence< OUString >& aPropertyNames )
override;
471 using sw::XStyleFamily;
474 {
return {
"SwXStyleFamilies"}; }
482 {
return {
"com.sun.star.style.StyleFamilies" }; }
486 m_pDocShell(&rDocShell)
496 throw uno::RuntimeException();
498 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
499 [&Name] (
const StyleFamilyEntry& e) {
return e.m_sName == Name; });
500 if(pEntry == pEntries->end())
501 throw container::NoSuchElementException();
508 uno::Sequence<OUString> aNames(pEntries->size());
509 std::transform(pEntries->begin(), pEntries->end(),
510 aNames.begin(), [] (
const StyleFamilyEntry& e) {
return e.m_sName; });
517 return std::any_of(pEntries->begin(), pEntries->end(),
518 [&Name] (
const StyleFamilyEntry& e) {
return e.m_sName == Name; });
530 if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(pEntries->size()))
531 throw lang::IndexOutOfBoundsException();
533 throw uno::RuntimeException();
534 auto eFamily = (*pEntries)[nIndex].m_eFamily;
535 assert(eFamily != SfxStyleFamily::All);
538 rxFamily =
new XStyleFamily(m_pDocShell, eFamily);
539 return uno::makeAny(rxFamily);
551 const uno::Sequence< beans::PropertyValue >& aOptions)
554 if(!
IsValid() || rURL.isEmpty())
555 throw uno::RuntimeException();
562 for(
const auto& rProperty: aOptions)
566 bValue = rProperty.Value.get<
bool>();
578 else if(rProperty.Name ==
"InputStream")
581 if (!(rProperty.Value >>= xInputStream))
582 throw IllegalArgumentException(
"Parameter 'InputStream' could not be converted to "
583 "type 'com::sun::star::io::XInputStream'",
592 throw io::IOException();
598 uno::Sequence< beans::PropertyValue >
aSeq(5);
599 beans::PropertyValue* pArray = aSeq.getArray();
610 SfxItemSet const& rSet, std::u16string_view rPropName,
bool const bFooter,
614 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
615 false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
616 if (SfxItemState::SET != eState &&
620 (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
621 false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
623 return SfxItemState::SET == eState;
626 template<enum SfxStyleFamily>
630 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Char>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
635 for(
auto pFormat : *rDoc.GetCharFormats())
637 if(pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat())
644 if(rDoc.GetDfltCharFormat() == pFormat)
645 *pString =
SwResId(STR_POOLCHR_STANDARD);
647 *pString = pFormat->GetName();
652 return nCount + nBaseCount;
656 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Para>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
661 for(
auto pColl : *rDoc.GetTextFormatColls())
663 if(pColl->IsDefault())
669 *pString = pColl->GetName();
674 return nCount + nBaseCount;
678 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Frame>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
682 for(
const auto pFormat : *rDoc.GetFrameFormats())
684 if(pFormat->IsDefault() || pFormat->IsAuto())
690 *pString = pFormat->GetName();
699 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Page>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
703 const size_t nArrLen = rDoc.GetPageDescCnt();
704 for(
size_t i = 0;
i < nArrLen; ++
i)
721 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Pseudo>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
725 for(
const auto pRule : rDoc.GetNumRuleTable())
727 if(pRule->IsAutoRule())
733 *pString = pRule->GetName();
742 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Table>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
744 if (!rDoc.HasTableStyles())
747 const auto pAutoFormats = &rDoc.GetTableStyles();
748 const sal_Int32
nCount = pAutoFormats->size();
750 *pString = pAutoFormats->operator[](
nIndex).GetName();
756 sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Cell>(
const SwDoc& rDoc, OUString* pString, sal_Int32
nIndex)
758 const auto& rAutoFormats = rDoc.GetTableStyles();
760 const sal_Int32 nUsedCellStylesCount = rAutoFormats.size() * rTableTemplateMap.size();
761 const sal_Int32
nCount = nUsedCellStylesCount + rDoc.GetCellStyles().size();
764 if (nUsedCellStylesCount >
nIndex)
766 const sal_Int32 nAutoFormat =
nIndex / rTableTemplateMap.size();
767 const sal_Int32 nBoxFormat = rTableTemplateMap[
nIndex % rTableTemplateMap.size()];
773 *pString = rDoc.GetCellStyles()[
nIndex-nUsedCellStylesCount].GetName();
778 template<SfxStyleFamily eFamily>
780 {
return pBasePool ?
new SwXStyle(pBasePool, eFamily, pDocShell->
GetDoc(), sStyleName) :
new SwXStyle(pDocShell->
GetDoc(), eFamily,
false); };
784 {
return pBasePool ?
new SwXStyle(pBasePool, SfxStyleFamily::Para, pDocShell->GetDoc(), sStyleName) :
new SwXStyle(pDocShell->GetDoc(), SfxStyleFamily::Para,
false); };
787 {
return pBasePool ?
new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), sStyleName) :
new SwXFrameStyle(pDocShell->GetDoc()); };
791 {
return pBasePool ?
new SwXPageStyle(*pBasePool, pDocShell, sStyleName) :
new SwXPageStyle(pDocShell); };
798 uno::Reference< css::style::XStyle> lcl_CreateStyle<SfxStyleFamily::Cell>(SfxStyleSheetBasePool* ,
SwDocShell* pDocShell,
const OUString& sStyleName)
804 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
805 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
806 return pEntry == pEntries->end() ?
nullptr : pEntry->m_fCreateStyle(
nullptr, rDoc.
GetDocShell(),
"");
811 {
return new SwXStyle(&rDoc, SfxStyleFamily::Para,
true); };
813 template<enum SfxStyleFamily>
817 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Char>(
const sal_uInt16
nIndex)
824 throw lang::IndexOutOfBoundsException();
828 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Para>(
const sal_uInt16
nIndex)
843 throw lang::IndexOutOfBoundsException();
847 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Table>(
const sal_uInt16
nIndex)
853 sal_uInt16 lcl_TranslateIndex<SfxStyleFamily::Cell>(
const sal_uInt16
nIndex)
858 template<sal_uInt16 nRangeBegin, sal_uInt16 nRangeSize>
861 if(nIndex < nRangeSize)
862 return nIndex + nRangeBegin;
863 throw lang::IndexOutOfBoundsException();
866 uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
870 throw lang::IndexOutOfBoundsException();
872 throw uno::RuntimeException();
878 if (sStyleName.isEmpty())
879 GetCountOrName(&sStyleName, nIndex);
880 if(sStyleName.isEmpty())
881 throw lang::IndexOutOfBoundsException();
882 return getByName(sStyleName);
885 uno::Any XStyleFamily::getByName(
const OUString& rName)
891 throw uno::RuntimeException();
894 throw container::NoSuchElementException();
895 uno::Reference<style::XStyle> xStyle = FindStyle(sStyleName);
897 xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SfxStyleFamily::Frame ? pBase->
GetName() : sStyleName);
898 return uno::makeAny(xStyle);
901 uno::Sequence<OUString> XStyleFamily::getElementNames()
905 throw uno::RuntimeException();
906 std::vector<OUString> vRet;
907 std::unique_ptr<SfxStyleSheetIterator> pIt = m_pBasePool->
CreateIterator(m_rEntry.m_eFamily);
912 vRet.push_back(sName);
917 sal_Bool XStyleFamily::hasByName(
const OUString& rName)
921 throw uno::RuntimeException();
925 return nullptr != pBase;
928 void XStyleFamily::insertByName(
const OUString& rName,
const uno::Any& rElement)
932 throw uno::RuntimeException();
937 if(pBase || pUINameBase)
938 throw container::ElementExistException();
939 if(rElement.getValueType().getTypeClass() != uno::TypeClass_INTERFACE)
940 throw lang::IllegalArgumentException();
944 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
947 throw lang::IllegalArgumentException();
949 pNewStyle->setName(sStyleName);
951 pNewStyle->SetPhysical();
956 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
959 throw lang::IllegalArgumentException();
961 pNewStyle->setName(sStyleName);
963 pNewStyle->SetPhysical();
967 uno::Reference<lang::XUnoTunnel> xStyleTunnel = rElement.get<uno::Reference<lang::XUnoTunnel>>();
968 SwXStyle* pNewStyle =
nullptr;
969 if(xStyleTunnel.is())
971 pNewStyle =
reinterpret_cast< SwXStyle *
>(
972 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
975 if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_rEntry.m_eFamily)
976 throw lang::IllegalArgumentException();
979 if(m_rEntry.m_eFamily == SfxStyleFamily::Para && !pNewStyle->IsConditional())
980 nMask &= ~SfxStyleSearchBits::SwCondColl;
981 m_pBasePool->
Make(sStyleName, m_rEntry.m_eFamily, nMask);
982 pNewStyle->SetDoc(m_pDocShell->
GetDoc(), m_pBasePool);
983 pNewStyle->SetStyleName(sStyleName);
984 const OUString sParentStyleName(pNewStyle->GetParentStyleName());
985 if (!sParentStyleName.isEmpty())
988 if(pParentBase && pParentBase->
GetFamily() == m_rEntry.m_eFamily &&
989 pParentBase->
GetPool() == m_pBasePool)
990 m_pBasePool->
SetParent(m_rEntry.m_eFamily, sStyleName, sParentStyleName);
993 pNewStyle->ApplyDescriptorProperties();
997 void XStyleFamily::replaceByName(
const OUString& rName,
const uno::Any& rElement)
1001 throw uno::RuntimeException();
1002 OUString sStyleName;
1007 throw container::NoSuchElementException();
1013 if (pBoxAutoFormat && sParent.isEmpty())
1015 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1017 if (!pStyleToReplaceWith)
1018 throw lang::IllegalArgumentException();
1020 pStyleToReplaceWith->setName(sStyleName);
1021 *pBoxAutoFormat = *pStyleToReplaceWith->GetBoxFormat();
1022 pStyleToReplaceWith->SetPhysical();
1029 if (pTableAutoFormat)
1031 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
1033 if (!pStyleToReplaceWith)
1034 throw lang::IllegalArgumentException();
1036 pStyleToReplaceWith->setName(sStyleName);
1037 *pTableAutoFormat = *pStyleToReplaceWith->GetTableFormat();
1038 pStyleToReplaceWith->SetPhysical();
1044 throw lang::IllegalArgumentException();
1046 uno::Reference<style::XStyle> xStyle = FindStyle(pBase->
GetName());
1049 SwXStyle* pStyle = comphelper::getUnoTunnelImplementation<SwXStyle>(xStyle);
1051 pStyle->Invalidate();
1053 m_pBasePool->
Remove(pBase);
1054 insertByName(rName, rElement);
1058 void XStyleFamily::removeByName(
const OUString& rName)
1062 throw uno::RuntimeException();
1067 throw container::NoSuchElementException();
1079 m_pBasePool->
Remove(pBase);
1082 uno::Any SAL_CALL XStyleFamily::getPropertyValue(
const OUString& sPropertyName )
1084 if(sPropertyName !=
"DisplayName")
1085 throw beans::UnknownPropertyException(
"unknown property: " + sPropertyName, static_cast<OWeakObject *>(
this) );
1087 return uno::makeAny(
SwResId(m_rEntry.m_pResId));
1091 SwXStyle* XStyleFamily::FindStyle(std::u16string_view rStyleName)
const
1094 for(
size_t i = 0;
i < nLCount; ++
i)
1097 SwXStyle* pTempStyle =
dynamic_cast<SwXStyle*
>(pListener);
1098 if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.m_eFamily && pTempStyle->GetStyleName() == rStyleName)
1106 if(!our_pStyleFamilyEntries)
1108 our_pStyleFamilyEntries =
new std::vector<StyleFamilyEntry>{
1109 { 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> },
1110 { 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> },
1111 { 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> },
1112 { 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> },
1113 { 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> },
1118 return our_pStyleFamilyEntries;
1123 if(!our_pParagraphStyleCategoryEntries)
1125 our_pParagraphStyleCategoryEntries =
new std::vector<ParagraphStyleCategoryEntry>{
1126 { style::ParagraphStyleCategory::TEXT, SfxStyleSearchBits::SwText,
COLL_TEXT_BITS },
1127 { style::ParagraphStyleCategory::CHAPTER, SfxStyleSearchBits::SwChapter,
COLL_DOC_BITS },
1128 { style::ParagraphStyleCategory::LIST, SfxStyleSearchBits::SwList,
COLL_LISTS_BITS },
1129 { style::ParagraphStyleCategory::INDEX, SfxStyleSearchBits::SwIndex,
COLL_REGISTER_BITS },
1130 { style::ParagraphStyleCategory::EXTRA, SfxStyleSearchBits::SwExtra,
COLL_EXTRA_BITS },
1131 { style::ParagraphStyleCategory::HTML, SfxStyleSearchBits::SwHtml,
COLL_HTML_BITS }
1134 return our_pParagraphStyleCategoryEntries;
1139 class SwStyleProperties_Impl
1142 std::map<OUString, uno::Any> m_vPropertyValues;
1148 bool AllowsKey(std::u16string_view rName)
1152 bool SetProperty(
const OUString& rName,
const uno::Any& rValue)
1154 if(!AllowsKey(rName))
1156 m_vPropertyValues[rName] = rValue;
1161 if(!AllowsKey(rName))
1166 pAny = &m_vPropertyValues[rName];
1169 bool ClearProperty(
const OUString& rName )
1171 if(!AllowsKey(rName))
1173 m_vPropertyValues[rName] =
uno::Any();
1176 void ClearAllProperties( )
1177 { m_vPropertyValues.clear(); }
1178 void Apply(SwXStyle& rStyle)
1180 for(
const auto& rPropertyPair : m_vPropertyValues)
1182 if(rPropertyPair.second.hasValue())
1183 rStyle.setPropertyValue(rPropertyPair.first, rPropertyPair.second);
1186 static void GetProperty(
const OUString &rPropertyName,
const uno::Reference < beans::XPropertySet > &rxPropertySet,
uno::Any& rAny )
1188 rAny = rxPropertySet->getPropertyValue( rPropertyName );
1197 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
1198 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
1199 if(pEntry != pEntries->end())
1200 return pEntry->m_aPoolId;
1201 SAL_WARN(
"sw.uno",
"someone asking for all styles in unostyle.cxx!" );
1209 const uno::Sequence<sal_Int8>& SwXStyle::getUnoTunnelId()
1212 return theSwXStyleUnoTunnelId.
getSeq();
1215 sal_Int64 SAL_CALL SwXStyle::getSomething(
const uno::Sequence<sal_Int8>& rId)
1217 if(isUnoTunnelId<SwXStyle>(rId))
1219 return sal::static_int_cast<sal_Int64>(
reinterpret_cast<sal_IntPtr
>(
this));
1225 uno::Sequence< OUString > SwXStyle::getSupportedServiceNames()
1228 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
1231 if(m_bIsConditional)
1234 else if(SfxStyleFamily::Char == m_rEntry.m_eFamily)
1236 else if(SfxStyleFamily::Page == m_rEntry.m_eFamily)
1238 uno::Sequence< OUString > aRet(nCount);
1239 OUString* pArray = aRet.getArray();
1240 pArray[0] =
"com.sun.star.style.Style";
1241 switch(m_rEntry.m_eFamily)
1243 case SfxStyleFamily::Char:
1244 pArray[1] =
"com.sun.star.style.CharacterStyle";
1245 pArray[2] =
"com.sun.star.style.CharacterProperties";
1246 pArray[3] =
"com.sun.star.style.CharacterPropertiesAsian";
1247 pArray[4] =
"com.sun.star.style.CharacterPropertiesComplex";
1249 case SfxStyleFamily::Page:
1250 pArray[1] =
"com.sun.star.style.PageStyle";
1251 pArray[2] =
"com.sun.star.style.PageProperties";
1253 case SfxStyleFamily::Para:
1254 pArray[1] =
"com.sun.star.style.ParagraphStyle";
1255 pArray[2] =
"com.sun.star.style.ParagraphProperties";
1256 pArray[3] =
"com.sun.star.style.ParagraphPropertiesAsian";
1257 pArray[4] =
"com.sun.star.style.ParagraphPropertiesComplex";
1258 if(m_bIsConditional)
1259 pArray[5] =
"com.sun.star.style.ConditionalParagraphStyle";
1271 if(eFamily != SfxStyleFamily::Para && eFamily != SfxStyleFamily::Page)
1273 auto aResult(rxStyleFamily->getByName(
"Standard"));
1274 if(!aResult.has<return_t>())
1276 return aResult.get<return_t>();
1282 if(rEntry.m_eFamily != SfxStyleFamily::Char
1283 && rEntry.m_eFamily != SfxStyleFamily::Para
1284 && rEntry.m_eFamily != SfxStyleFamily::Page)
1287 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(
xModel, uno::UNO_QUERY);
1288 auto xFamilies = xFamilySupplier->getStyleFamilies();
1289 auto aResult(xFamilies->getByName(rEntry.m_sName));
1290 if(!aResult.has<return_t>())
1292 return aResult.get<return_t>();
1297 if(!pBasePool || eFamily != SfxStyleFamily::Para)
1300 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?" );
1312 const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
1313 [eFamily] (
const StyleFamilyEntry& e) {
return e.m_eFamily == eFamily; });
1314 assert(pEntry != pEntries->end());
1321 , m_bIsDescriptor(true)
1322 , m_bIsConditional(bConditional)
1323 , m_pBasePool(nullptr)
1327 assert(!m_bIsConditional || m_rEntry.m_eFamily == SfxStyleFamily::Para);
1330 m_pPropertiesImpl = std::make_unique<SwStyleProperties_Impl>(
1334 SwXStyle::SwXStyle(SfxStyleSheetBasePool* pPool,
SfxStyleFamily eFamily,
SwDoc* pDoc,
const OUString& rStyleName)
1336 , m_sStyleName(rStyleName)
1338 , m_bIsDescriptor(false)
1340 , m_pBasePool(pPool)
1343 SwXStyle::~SwXStyle()
1348 m_pPropertiesImpl.reset();
1354 if(rHint.
GetId() == SfxHintId::Dying)
1357 m_xStyleData.clear();
1358 m_xStyleFamily.clear();
1362 OUString SwXStyle::getName()
1366 return m_sStyleName;
1368 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1370 throw uno::RuntimeException();
1376 void SwXStyle::setName(
const OUString& rName)
1381 m_sStyleName = rName;
1385 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
1387 throw uno::RuntimeException();
1389 if(!xTmp->SetName(rName))
1390 throw uno::RuntimeException();
1391 m_sStyleName = rName;
1398 throw uno::RuntimeException();
1408 throw uno::RuntimeException();
1409 SfxStyleSheetBase* pBase = m_pBasePool->
Find(m_sStyleName, m_rEntry.m_eFamily, SfxStyleSearchBits::Used);
1410 return pBase && pBase->
IsUsed();
1413 OUString SwXStyle::getParentStyle()
1418 if(!m_bIsDescriptor)
1419 throw uno::RuntimeException();
1420 return m_sParentStyleName;
1430 void SwXStyle::setParentStyle(
const OUString& rParentStyle)
1433 OUString sParentStyle;
1437 if(!m_bIsDescriptor)
1438 throw uno::RuntimeException();
1439 m_sParentStyleName = sParentStyle;
1442 const auto aAny = m_xStyleFamily->getByName(sParentStyle);
1443 m_xStyleData = aAny.get<decltype(m_xStyleData)>();
1451 throw uno::RuntimeException();
1454 xBase->GetItemSet();
1455 if(xBase->GetParent() != sParentStyle)
1457 if(!xBase->SetParent(sParentStyle))
1458 throw uno::RuntimeException();
1462 uno::Reference<beans::XPropertySetInfo> SwXStyle::getPropertySetInfo()
1464 if(m_bIsConditional)
1466 assert(m_rEntry.m_eFamily == SfxStyleFamily::Para);
1467 static uno::Reference<beans::XPropertySetInfo> xCondParaRef;
1469 return xCondParaRef;
1471 return m_rEntry.m_xPSInfo;
1474 void SwXStyle::ApplyDescriptorProperties()
1476 m_bIsDescriptor =
false;
1477 m_xStyleData.clear();
1478 m_xStyleFamily.clear();
1479 m_pPropertiesImpl->Apply(*
this);
1484 class SwStyleBase_Impl
1491 std::unique_ptr<SfxItemSet> m_pMyItemSet;
1492 OUString m_rStyleName;
1495 SwStyleBase_Impl(
SwDoc& rSwDoc,
const OUString& rName,
const SwAttrSet* pParentStyle)
1497 , m_pOldPageDesc(nullptr)
1498 , m_pItemSet(nullptr)
1499 , m_rStyleName(rName)
1500 , m_pParentStyle(pParentStyle)
1513 bool HasItemSet()
const
1515 return m_xNewBase.is();
1523 m_pMyItemSet.reset(
new SfxItemSet(m_xNewBase->GetItemSet()));
1524 m_pItemSet = m_pMyItemSet.get();
1527 if(!m_pItemSet->
GetParent() && m_pParentStyle)
1536 struct ItemSetOverrider
1538 SwStyleBase_Impl& m_rStyleBase;
1540 ItemSetOverrider(SwStyleBase_Impl& rStyleBase,
SfxItemSet* pTemp)
1541 : m_rStyleBase(rStyleBase)
1542 , m_pOldSet(m_rStyleBase.m_pItemSet)
1543 { m_rStyleBase.m_pItemSet = pTemp; }
1545 { m_rStyleBase.m_pItemSet = m_pOldSet; };
1552 STR_POOLPAGE_STANDARD,
1556 STR_POOLPAGE_ENVELOPE,
1557 STR_POOLPAGE_REGISTER,
1559 STR_POOLPAGE_FOOTNOTE,
1560 STR_POOLPAGE_ENDNOTE,
1561 STR_POOLPAGE_LANDSCAPE
1565 const SwPageDesc* SwStyleBase_Impl::GetOldPageDesc()
1571 m_pOldPageDesc = pd;
1585 return m_pOldPageDesc;
1593 if(!(rEntry.
nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
1598 && o_aValue.has<sal_Int32>()
1599 && o_aValue.get<sal_Int32>() < 0)
1606 if(eMapUnit != MapUnit::Map100thMM)
1614 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1616 aSet.SetParent(&rStyleSet);
1617 rPropSet.setPropertyValue(rEntry, rValue, aSet);
1618 rStyleSet.
Put(aSet);
1623 bool bHidden =
false;
1624 if(rValue >>= bHidden)
1627 o_rStyleBase.getNewBase()->GetItemSet();
1628 o_rStyleBase.getNewBase()->SetHidden(bHidden);
1630 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1635 o_rStyleBase.getNewBase()->GetItemSet();
1636 o_rStyleBase.getNewBase()->SetGrabBagItem(rValue);
1637 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1644 if(MID_NAME == nMemberId)
1647 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1648 if(!aValue.has<OUString>())
1649 throw lang::IllegalArgumentException();
1652 else if(MID_BITMAP == nMemberId)
1654 if(sal_uInt16(XATTR_FILLBITMAP) == rEntry.nWID)
1657 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1659 aXFillBitmapItem.PutValue(aValue, nMemberId);
1660 rStyleSet.
Put(aXFillBitmapItem);
1664 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1669 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1671 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
1675 aChangedBrushItem->PutValue(aValue, nMemberId);
1680 if(*aChangedBrushItem == *aOriginalBrushItem && (MID_GRAPHIC_TRANSPARENT != nMemberId || !aValue.has<
bool>() || !aValue.get<
bool>()))
1686 void SwXStyle::SetPropertyValue<OWN_ATTR_FILLBMP_MODE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1688 drawing::BitmapMode
eMode;
1689 if(!(rValue >>= eMode))
1691 if(!rValue.has<sal_Int32>())
1692 throw lang::IllegalArgumentException();
1693 eMode =
static_cast<drawing::BitmapMode
>(rValue.get<sal_Int32>());
1695 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1700 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAPER_BIN)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1702 if(!rValue.has<OUString>())
1703 throw lang::IllegalArgumentException();
1704 SfxPrinter* pPrinter = m_pDoc->getIDocumentDeviceAccess().getPrinter(
true);
1705 OUString sValue(rValue.get<OUString>());
1706 using printeridx_t = decltype(pPrinter->GetPaperBinCount());
1707 printeridx_t nBin = std::numeric_limits<printeridx_t>::max();
1708 if(sValue ==
"[From printer settings]")
1709 nBin = std::numeric_limits<printeridx_t>::max()-1;
1712 for(sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount();
i < nEnd; ++
i)
1714 if (sValue == pPrinter->GetPaperBinName(i))
1721 if(nBin == std::numeric_limits<printeridx_t>::max())
1722 throw lang::IllegalArgumentException();
1723 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1725 aSet.SetParent(&rStyleSet);
1726 rPropSet.setPropertyValue(rEntry, uno::makeAny(static_cast<sal_Int8>(nBin == std::numeric_limits<printeridx_t>::max()-1 ? -1 : nBin)), aSet);
1727 rStyleSet.
Put(aSet);
1730 void SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1732 if(!rValue.has<uno::Reference<container::XIndexReplace>>() || !rValue.has<uno::Reference<lang::XUnoTunnel>>())
1733 throw lang::IllegalArgumentException();
1734 auto xNumberTunnel(rValue.get<uno::Reference<lang::XUnoTunnel>>());
1741 const SwNumFormat* pFormat = aSetRule.GetNumFormat(i);
1746 if(!rCharName.isEmpty()
1750 auto pCharFormatIt(std::find_if(m_pDoc->GetCharFormats()->begin(), m_pDoc->GetCharFormats()->end(),
1751 [&rCharName] (
SwCharFormat* pF) {
return pF->GetName() == rCharName; }));
1752 if(pCharFormatIt != m_pDoc->GetCharFormats()->end())
1753 aFormat.SetCharFormat(*pCharFormatIt);
1754 else if(m_pBasePool)
1756 auto pBase(m_pBasePool->
Find(rCharName, SfxStyleFamily::Char));
1758 pBase = &m_pBasePool->
Make(rCharName, SfxStyleFamily::Char);
1759 aFormat.SetCharFormat(static_cast<SwDocStyleSheet*>(pBase)->GetCharFormat());
1762 aFormat.SetCharFormat(
nullptr);
1766 if(!rBulletName.isEmpty()
1770 const auto pFontListItem(static_cast<const SvxFontListItem*>(m_pDoc->GetDocShell()->GetItem(SID_ATTR_CHAR_FONTLIST)));
1771 const auto pList(pFontListItem->GetFontList());
1772 FontMetric aFontInfo(pList->Get(rBulletName, WEIGHT_NORMAL, ITALIC_NONE));
1774 aFormat.SetBulletFont(&aFont);
1776 aSetRule.Set(i, &aFormat);
1778 o_rStyleBase.getNewBase()->SetNumRule(aSetRule);
1781 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_OUTLINELEVEL)>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1783 if(!rValue.has<sal_Int16>())
1785 const auto nLevel(rValue.get<sal_Int16>());
1786 if(0 <= nLevel && nLevel <= MAXLEVEL)
1787 o_rStyleBase.getNewBase()->GetCollection()->SetAttrOutlineLevel(nLevel);
1790 void SwXStyle::SetPropertyValue<FN_UNO_FOLLOW_STYLE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1792 if(!rValue.has<OUString>())
1794 const auto sValue(rValue.get<OUString>());
1797 o_rStyleBase.getNewBase()->SetFollow(aString);
1800 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PAGEDESC)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1804 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1807 if(!rValue.has<OUString>())
1808 throw lang::IllegalArgumentException();
1810 SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
1811 std::unique_ptr<SwFormatPageDesc> pNewDesc;
1814 pNewDesc.reset(
new SwFormatPageDesc(*static_cast<const SwFormatPageDesc*>(pItem)));
1817 const auto sValue(rValue.get<OUString>());
1820 if(pNewDesc->GetPageDesc() && pNewDesc->GetPageDesc()->GetName() == sDescName)
1822 if(sDescName.isEmpty())
1831 throw lang::IllegalArgumentException();
1832 pNewDesc->RegisterToPageDesc(*pPageDesc);
1833 rStyleSet.
Put(*pNewDesc);
1837 void SwXStyle::SetPropertyValue<sal_uInt16(RES_TEXT_VERT_ADJUST)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1839 if(m_rEntry.m_eFamily != SfxStyleFamily::Page)
1841 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1844 if(!m_pDoc || !rValue.has<drawing::TextVerticalAdjust>() || !o_rStyleBase.GetOldPageDesc())
1846 SwPageDesc* pPageDesc = m_pDoc->FindPageDesc(o_rStyleBase.GetOldPageDesc()->GetName());
1851 void SwXStyle::SetPropertyValue<FN_UNO_IS_AUTO_UPDATE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1853 if(!rValue.has<
bool>())
1854 throw lang::IllegalArgumentException();
1855 const bool bAuto(rValue.get<
bool>());
1856 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
1857 o_rStyleBase.getNewBase()->GetCollection()->SetAutoUpdateFormat(bAuto);
1858 else if(SfxStyleFamily::Frame == m_rEntry.m_eFamily)
1859 o_rStyleBase.getNewBase()->GetFrameFormat()->SetAutoUpdateFormat(bAuto);
1862 void SwXStyle::SetPropertyValue<FN_UNO_PARA_STYLE_CONDITIONS>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1865 using expectedarg_t = uno::Sequence<beans::NamedValue>;
1866 if(!rValue.has<expectedarg_t>() || !m_pBasePool)
1867 throw lang::IllegalArgumentException();
1869 const auto aNamedValues = rValue.get<expectedarg_t>();
1870 for(
const auto& rNamedValue : aNamedValues)
1872 if(!rNamedValue.Value.has<OUString>())
1873 throw lang::IllegalArgumentException();
1875 const OUString sValue(rNamedValue.Value.get<OUString>());
1877 OUString aStyleName;
1883 throw lang::IllegalArgumentException();
1884 bool bStyleFound =
false;
1885 for(
auto pBase = m_pBasePool->
First(SfxStyleFamily::Para); pBase; pBase = m_pBasePool->
Next())
1887 bStyleFound = pBase->
GetName() == aStyleName;
1892 throw lang::IllegalArgumentException();
1893 aCondItem.
SetStyle(&aStyleName, nIdx);
1895 o_rStyleBase.GetItemSet().Put(aCondItem);
1898 void SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1900 if(!o_rStyleBase.getNewBase()->IsUserDefined() || !rValue.has<paragraphstyle_t>())
1901 throw lang::IllegalArgumentException();
1902 static std::unique_ptr<std::map<paragraphstyle_t, SfxStyleSearchBits>> pUnoToCore;
1905 pUnoToCore.reset(
new std::map<paragraphstyle_t, SfxStyleSearchBits>);
1907 std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
1908 [] (
const ParagraphStyleCategoryEntry& rEntry) {
return std::pair<paragraphstyle_t, SfxStyleSearchBits>(rEntry.m_eCategory, rEntry.m_nSwStyleBits); });
1910 const auto pUnoToCoreIt(pUnoToCore->find(rValue.get<paragraphstyle_t>()));
1911 if(pUnoToCoreIt == pUnoToCore->end())
1912 throw lang::IllegalArgumentException();
1913 o_rStyleBase.getNewBase()->SetMask( pUnoToCoreIt->second|SfxStyleSearchBits::UserDefined );
1916 void SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1921 aReg.
SetWhich(SID_SWREGISTER_MODE);
1922 o_rStyleBase.GetItemSet().Put(aReg);
1925 o_rStyleBase.GetItemSet().Put(
SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
1928 void SwXStyle::SetPropertyValue<sal_uInt16(RES_TXTATR_CJK_RUBY)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1932 if(!rValue.has<OUString>())
1933 throw lang::IllegalArgumentException();
1934 const auto sValue(rValue.get<OUString>());
1935 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1936 std::unique_ptr<SwFormatRuby> pRuby;
1939 pRuby.reset(
new SwFormatRuby(*static_cast<const SwFormatRuby*>(pItem)));
1944 pRuby->SetCharFormatName(sValue);
1945 pRuby->SetCharFormatId(0);
1946 if(!sValue.isEmpty())
1949 pRuby->SetCharFormatId(nId);
1951 rStyleSet.
Put(*pRuby);
1952 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1955 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_DROP)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1959 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, rValue, o_rStyleBase);
1962 if(!rValue.has<OUString>())
1963 throw lang::IllegalArgumentException();
1964 SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet());
1965 std::unique_ptr<SwFormatDrop> pDrop;
1968 pDrop.reset(
new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem)));
1971 const auto sValue(rValue.get<OUString>());
1974 auto pStyle(static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)));
1976 if(!pStyle || pStyle->GetCharFormat() == m_pDoc->GetDfltCharFormat() )
1978 throw lang::IllegalArgumentException();
1980 pDrop->SetCharFormat(pStyle->GetCharFormat());
1981 rStyleSet.
Put(*pDrop);
1984 void SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_NUMRULE)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
1988 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, o_rStyleBase);
1990 if(SfxStyleFamily::Para == m_rEntry.m_eFamily &&
1991 o_rStyleBase.getNewBase().is() && o_rStyleBase.getNewBase()->GetCollection() &&
1993 o_rStyleBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle())
1995 OUString sNewNumberingRuleName;
1996 aValue >>= sNewNumberingRuleName;
1997 if(sNewNumberingRuleName.isEmpty() || sNewNumberingRuleName != m_pDoc->GetOutlineNumRule()->GetName())
1998 o_rStyleBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2002 void SwXStyle::SetStyleProperty(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet,
const uno::Any& rValue, SwStyleBase_Impl& rBase)
2004 using propertytype_t = decltype(rEntry.
nWID);
2005 using coresetter_t = std::function<void(SwXStyle&, const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, const uno::Any&, SwStyleBase_Impl&)>;
2006 static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
2009 pUnoToCore.reset(
new std::map<propertytype_t, coresetter_t> {
2011 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_HIDDEN>) },
2020 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>) },
2027 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>) },
2028 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>) },
2034 const auto pUnoToCoreIt(pUnoToCore->find(rEntry.
nWID));
2035 if(pUnoToCoreIt != pUnoToCore->end())
2036 pUnoToCoreIt->second(*
this, rEntry, rPropSet, rValue, rBase);
2043 SetPropertyValue<HINT_BEGIN>(rEntry, rPropSet, aValue, rBase);
2047 void SwXStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2050 throw uno::RuntimeException();
2051 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2054 if(rPropertyNames.getLength() != rValues.getLength())
2055 throw lang::IllegalArgumentException();
2057 SwStyleBase_Impl aBaseImpl(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTextFormatColl()->GetAttrSet());
2061 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2063 throw uno::RuntimeException();
2064 aBaseImpl.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2066 if(!aBaseImpl.getNewBase().is() && !m_bIsDescriptor)
2067 throw uno::RuntimeException();
2069 const OUString* pNames = rPropertyNames.getConstArray();
2071 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2073 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(pNames[nProp]);
2075 throw beans::UnknownPropertyException(
"Unknown property: " + pNames[nProp], static_cast<cppu::OWeakObject*>(
this));
2076 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2077 throw beans::PropertyVetoException (
"Property is read-only: " + pNames[nProp], static_cast<cppu::OWeakObject*>(
this));
2078 if(aBaseImpl.getNewBase().is())
2079 SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl);
2080 else if(!m_pPropertiesImpl->SetProperty(pNames[nProp], pValues[nProp]))
2081 throw lang::IllegalArgumentException();
2084 if(aBaseImpl.HasItemSet())
2085 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
2088 void SwXStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2094 SetPropertyValues_Impl( rPropertyNames, rValues );
2096 catch (
const beans::UnknownPropertyException &rException)
2100 lang::WrappedTargetException aWExc;
2101 aWExc.TargetException <<= rException;
2113 void SwXStyle::PrepareStyleBase(SwStyleBase_Impl& rBase)
2117 throw uno::RuntimeException();
2118 if(!rBase.getNewBase().is())
2119 rBase.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2123 uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase);
2125 uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2129 return uno::makeAny(
false);
2132 if( bPhys && SfxStyleFamily::Char == GetFamily() &&
2136 return uno::makeAny<bool>(bPhys);
2139 uno::Any SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2143 return uno::makeAny(
false);
2145 return uno::makeAny(xBase->IsHidden());
2148 uno::Any SwXStyle::GetStyleProperty<FN_UNO_STYLE_INTEROP_GRAB_BAG>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl&)
2155 xBase->GetGrabBagItem(aRet);
2159 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAPER_BIN)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2161 PrepareStyleBase(rBase);
2164 rPropSet.getPropertyValue(rEntry, rSet, aValue);
2167 return uno::makeAny<OUString>(
"[From printer settings]");
2168 SfxPrinter* pPrinter = GetDoc()->getIDocumentDeviceAccess().getPrinter(
false);
2171 return uno::makeAny(pPrinter->GetPaperBinName(nBin));
2174 uno::Any SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2176 PrepareStyleBase(rBase);
2177 const SwNumRule* pRule = rBase.getNewBase()->GetNumRule();
2178 assert(pRule &&
"Where is the NumRule?");
2179 uno::Reference<container::XIndexReplace> xRules(
new SwXNumberingRules(*pRule, GetDoc()));
2180 return uno::makeAny<uno::Reference<container::XIndexReplace>>(xRules);
2183 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PARATR_OUTLINELEVEL)>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2185 PrepareStyleBase(rBase);
2186 SAL_WARN_IF(SfxStyleFamily::Para != GetFamily(),
"sw.uno",
"only paras");
2187 return uno::makeAny<sal_Int16>(rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel());
2190 uno::Any SwXStyle::GetStyleProperty<FN_UNO_FOLLOW_STYLE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2192 PrepareStyleBase(rBase);
2195 return uno::makeAny(aString);
2198 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_PAGEDESC)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2200 PrepareStyleBase(rBase);
2202 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2205 if(SfxItemState::SET != rBase.GetItemSet().GetItemState(
RES_PAGEDESC,
true, &pItem))
2212 return uno::makeAny(aString);
2215 uno::Any SwXStyle::GetStyleProperty<FN_UNO_IS_AUTO_UPDATE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2217 PrepareStyleBase(rBase);
2220 case SfxStyleFamily::Para :
return uno::makeAny<bool>(rBase.getNewBase()->GetCollection()->IsAutoUpdateFormat());
2221 case SfxStyleFamily::Frame:
return uno::makeAny<bool>(rBase.getNewBase()->GetFrameFormat()->IsAutoUpdateFormat());
2226 uno::Any SwXStyle::GetStyleProperty<FN_UNO_DISPLAY_NAME>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2228 PrepareStyleBase(rBase);
2229 return uno::makeAny(rBase.getNewBase()->GetName());
2232 uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2234 PrepareStyleBase(rBase);
2237 sal_uInt16 nIndex = 0;
2238 for(
auto& rNV : aSeq)
2241 rNV.Value <<= OUString();
2247 beans::NamedValue* pSeq = aSeq.getArray();
2256 pSeq[
n].Value <<= aStyleName;
2259 return uno::makeAny(aSeq);
2262 uno::Any SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2264 PrepareStyleBase(rBase);
2265 static std::unique_ptr<std::map<collectionbits_t, paragraphstyle_t>> pUnoToCore;
2268 pUnoToCore.reset(
new std::map<collectionbits_t, paragraphstyle_t>);
2270 std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
2271 [] (
const ParagraphStyleCategoryEntry& rEntry) {
return std::pair<collectionbits_t, paragraphstyle_t>(rEntry.m_nCollectionBits, rEntry.m_eCategory); });
2273 const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFormatId();
2275 if(pUnoToCoreIt == pUnoToCore->end())
2276 return uno::makeAny<sal_Int16>(-1);
2277 return uno::makeAny(pUnoToCoreIt->second);
2280 uno::Any SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2282 PrepareStyleBase(rBase);
2283 const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc();
2285 return uno::makeAny(OUString());
2288 return uno::makeAny(OUString());
2291 return uno::makeAny(aName);
2294 uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_BACKGROUND)>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2296 PrepareStyleBase(rBase);
2300 if(!aOriginalBrushItem->QueryValue(aResult, rEntry.nMemberId))
2301 SAL_WARN(
"sw.uno",
"error getting attribute from RES_BACKGROUND.");
2305 uno::Any SwXStyle::GetStyleProperty<OWN_ATTR_FILLBMP_MODE>(
const SfxItemPropertyMapEntry&,
const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
2307 PrepareStyleBase(rBase);
2309 if (rSet.
Get(XATTR_FILLBMP_TILE).GetValue())
2310 return uno::makeAny(drawing::BitmapMode_REPEAT);
2311 if (rSet.
Get(XATTR_FILLBMP_STRETCH).GetValue())
2312 return uno::makeAny(drawing::BitmapMode_STRETCH);
2313 return uno::makeAny(drawing::BitmapMode_NO_REPEAT);
2316 uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2318 PrepareStyleBase(rBase);
2321 rPropSet.getPropertyValue(rEntry, rSet, aResult);
2325 aResult <<= static_cast<sal_Int16>(aResult.get<sal_Int32>());
2327 if(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM && GetDoc())
2329 const SfxItemPool& rPool = GetDoc()->GetAttrPool();
2331 bool bAllowedConvert(
true);
2334 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
2335 bAllowedConvert = !aResult.has<sal_Int32>() || aResult.get<sal_Int32>() > 0;
2336 if(eMapUnit != MapUnit::Map100thMM && bAllowedConvert)
2342 uno::Any SwXStyle::GetStyleProperty_Impl(
const SfxItemPropertyMapEntry& rEntry,
const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
2344 using propertytype_t = decltype(rEntry.
nWID);
2345 using coresetter_t = std::function<uno::Any(SwXStyle&, const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, SwStyleBase_Impl&)>;
2346 static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
2349 pUnoToCore.reset(
new std::map<propertytype_t, coresetter_t> {
2351 {
FN_UNO_IS_PHYSICAL, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>) },
2352 {
FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>) },
2355 {
FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_NUM_RULES>) },
2362 {
FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>) },
2363 { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>) },
2368 const auto pUnoToCoreIt(pUnoToCore->find(rEntry.
nWID));
2369 if(pUnoToCoreIt != pUnoToCore->end())
2370 return pUnoToCoreIt->second(*
this, rEntry, rPropSet, rBase);
2371 return GetStyleProperty<HINT_BEGIN>(rEntry, rPropSet, rBase);
2374 uno::Any SwXStyle::GetPropertyValue_Impl(
const SfxItemPropertySet* pPropSet, SwStyleBase_Impl& rBase,
const OUString& rPropertyName)
2377 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropertyName);
2379 throw beans::UnknownPropertyException(
"Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(
this));
2381 return GetStyleProperty_Impl(*pEntry, *pPropSet, rBase);
2383 m_pPropertiesImpl->GetProperty(rPropertyName, pAny);
2387 switch(m_rEntry.m_eFamily)
2389 case SfxStyleFamily::Pseudo:
2390 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2392 case SfxStyleFamily::Para:
2393 case SfxStyleFamily::Page:
2394 SwStyleProperties_Impl::GetProperty(rPropertyName, m_xStyleData, aValue);
2396 case SfxStyleFamily::Char:
2397 case SfxStyleFamily::Frame:
2400 throw uno::RuntimeException(
"No default value for: " + rPropertyName);
2402 if(m_rEntry.m_eFamily == SfxStyleFamily::Char)
2403 pFormat = m_pDoc->GetDfltCharFormat();
2405 pFormat = m_pDoc->GetDfltFrameFormat();
2417 uno::Any SwXStyle::getPropertyValue(
const OUString& rPropertyName)
2421 throw uno::RuntimeException();
2422 if(!m_pBasePool && !m_bIsDescriptor)
2423 throw uno::RuntimeException();
2424 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2426 SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet());
2427 return GetPropertyValue_Impl(pPropSet, aBase, rPropertyName);
2430 uno::Sequence<uno::Any> SwXStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
2434 throw uno::RuntimeException();
2435 if(!m_pBasePool && !m_bIsDescriptor)
2436 throw uno::RuntimeException();
2437 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2439 SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet());
2440 uno::Sequence<uno::Any> aValues(rPropertyNames.getLength());
2444 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2445 aValues[nProp] = GetPropertyValue_Impl(pPropSet, aBase, rPropertyNames[nProp]);
2447 catch(beans::UnknownPropertyException&)
2450 throw css::lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
2451 static_cast < cppu::OWeakObject * > (
this ), anyEx );
2453 catch(lang::WrappedTargetException&)
2456 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
2457 static_cast < cppu::OWeakObject * > (
this ), anyEx );
2462 void SwXStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
2465 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
2466 const uno::Sequence<uno::Any> aValues(&rValue, 1);
2467 SetPropertyValues_Impl(aProperties, aValues);
2470 beans::PropertyState SwXStyle::getPropertyState(
const OUString& rPropertyName)
2473 uno::Sequence<OUString> aNames{rPropertyName};
2474 uno::Sequence<beans::PropertyState> aStates = getPropertyStates(aNames);
2475 return aStates.getConstArray()[0];
2482 if(eFamily != SfxStyleFamily::Page)
2484 const bool isFooter = rPropertyName.startsWith(
"Footer");
2490 return &pSetItem->GetItemSet();
2492 uno::Sequence<beans::PropertyState> SwXStyle::getPropertyStates(
const uno::Sequence<OUString>& rPropertyNames)
2495 uno::Sequence<beans::PropertyState> aRet(rPropertyNames.getLength());
2496 beans::PropertyState* pStates = aRet.getArray();
2499 throw uno::RuntimeException();
2502 SAL_WARN_IF(!pBase,
"sw.uno",
"where is the style?");
2504 throw uno::RuntimeException();
2506 const OUString* pNames = rPropertyNames.getConstArray();
2508 sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2512 const SfxItemSet& rSet = xStyle->GetItemSet();
2514 for(sal_Int32 i = 0;
i < rPropertyNames.getLength(); ++
i)
2516 const OUString sPropName = pNames[
i];
2517 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(sPropName);
2520 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast<cppu::OWeakObject*>(
this));
2525 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2532 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2535 switch(pEntry->
nWID)
2539 if(SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_STRETCH,
false)
2540 || SfxItemState::SET == pSourceSet->
GetItemState(XATTR_FILLBMP_TILE,
false))
2542 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2546 pStates[
i] = beans::PropertyState_AMBIGUOUS_VALUE;
2558 pStates[
i] = beans::PropertyState_DIRECT_VALUE;
2562 pStates[
i] = beans::PropertyState_DEFAULT_VALUE;
2570 if(SfxStyleFamily::Page == m_rEntry.m_eFamily && SID_ATTR_PAGE_SIZE == pEntry->
nWID && beans::PropertyState_DIRECT_VALUE == pStates[i])
2578 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2587 void SwXStyle::setPropertyToDefault(
const OUString& rPropertyName)
2589 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2590 setPropertiesToDefault(aSequence);
2599 case SfxStyleFamily::Char:
return xStyle->GetCharFormat();
2600 case SfxStyleFamily::Para:
return xStyle->GetCollection();
2601 case SfxStyleFamily::Frame:
return xStyle->GetFrameFormat();
2602 case SfxStyleFamily::Page:
2614 void SAL_CALL SwXStyle::setPropertiesToDefault(
const uno::Sequence<OUString>& aPropertyNames)
2621 if(!m_bIsDescriptor)
2623 for(
const auto& rName : aPropertyNames)
2624 m_pPropertiesImpl->ClearProperty(rName);
2627 const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2630 for(
const auto& rName : aPropertyNames)
2632 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rName);
2634 throw beans::UnknownPropertyException(
"Unknown property: " + rName, static_cast<cppu::OWeakObject*>(
this));
2636 throw uno::RuntimeException(
"Cannot reset: " + rName, static_cast<cppu::OWeakObject*>(
this));
2637 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2638 throw uno::RuntimeException(
"setPropertiesToDefault: property is read-only: " + rName, static_cast<cppu::OWeakObject*>(
this));
2641 static_cast<SwTextFormatColl*
>(pTargetFormat)->DeleteAssignmentToListLevelOfOutlineStyle();
2650 aSet.SetParent(&pTargetFormat->
GetAttrSet());
2652 aSet.ClearItem(XATTR_FILLBMP_STRETCH);
2653 aSet.ClearItem(XATTR_FILLBMP_TILE);
2660 void SAL_CALL SwXStyle::setAllPropertiesToDefault()
2665 if(!m_bIsDescriptor)
2666 throw uno::RuntimeException();
2667 m_pPropertiesImpl->ClearAllProperties();
2672 throw uno::RuntimeException();
2673 if(SfxStyleFamily::Page == m_rEntry.m_eFamily)
2675 size_t nPgDscPos(0);
2676 SwPageDesc* pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName(), &nPgDscPos);
2685 SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos);
2688 pPageFormat->SetPageFormatToDefault();
2690 std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>(
SwFrameSize::Fixed));
2694 if(m_pDoc->getIDocumentDeviceAccess().getPrinter(
false))
2697 static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(
false))));
2698 aFrameSz->SetSize(aPhysSize);
2713 SwTwips nTmp = aFrameSz->GetHeight();
2714 aFrameSz->SetHeight(aFrameSz->GetWidth());
2715 aFrameSz->SetWidth(nTmp);
2718 pPageFormat->SetFormatAttr(*aFrameSz);
2719 m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos));
2722 if(SfxStyleFamily::Para == m_rEntry.m_eFamily)
2724 if(xStyle->GetCollection())
2725 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2733 uno::Sequence<uno::Any> SAL_CALL SwXStyle::getPropertyDefaults(
const uno::Sequence<OUString>& aPropertyNames)
2736 sal_Int32 nCount = aPropertyNames.getLength();
2737 uno::Sequence<uno::Any> aRet(nCount);
2742 throw uno::RuntimeException();
2744 const sal_Int8 nPropSetId = m_bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
2749 for(sal_Int32 i = 0; i < nCount; ++i)
2751 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(aPropertyNames[i]);
2754 throw beans::UnknownPropertyException(
"Unknown property: " + aPropertyNames[i], static_cast < cppu::OWeakObject * >(
this));
2773 uno::Any SwXStyle::getPropertyDefault(
const OUString& rPropertyName)
2775 const uno::Sequence<OUString> aSequence(&rPropertyName, 1);
2776 return getPropertyDefaults(aSequence)[0];
2781 if((rHint.
GetId() == SfxHintId::Dying) || (rHint.
GetId() == SfxHintId::StyleSheetErased))
2783 m_pBasePool =
nullptr;
2786 else if(rHint.
GetId() == SfxHintId::StyleSheetChanged)
2788 SfxStyleSheetBasePool& rBP =
static_cast<SfxStyleSheetBasePool&
>(rBC);
2798 void SwXStyle::Invalidate()
2800 m_sStyleName.clear();
2801 m_pBasePool =
nullptr;
2803 m_xStyleData.clear();
2804 m_xStyleFamily.clear();
2807 SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
SwDocShell* pDocSh,
const OUString& rStyleName)
2811 SwXPageStyle::SwXPageStyle(
SwDocShell* pDocSh)
2815 void SwXStyle::PutItemToSet(
const SvxSetItem* pSetItem,
const SfxItemPropertySet& rPropSet,
const SfxItemPropertyMapEntry& rEntry,
const uno::Any& rVal, SwStyleBase_Impl& rBaseImpl)
2818 const std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2819 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2822 rSetSet.SetParent(&m_pDoc->GetDfltFrameFormat()->GetAttrSet());
2827 SwStyleBase_Impl::ItemSetOverrider o(rBaseImpl, &rSetSet);
2828 SetStyleProperty(rEntry, rPropSet, rVal, rBaseImpl);
2832 rSetSet.SetParent(
nullptr);
2835 rBaseImpl.GetItemSet().Put(*pNewSetItem);
2838 void SwXPageStyle::SetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
2841 throw uno::RuntimeException();
2843 if(rPropertyNames.getLength() != rValues.getLength())
2844 throw lang::IllegalArgumentException();
2848 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2852 throw uno::RuntimeException();
2853 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2854 if(!m_pPropertiesImpl->SetProperty(rPropertyNames[nProp], rValues[nProp]))
2855 throw lang::IllegalArgumentException();
2860 throw uno::RuntimeException();
2861 aBaseImpl.setNewBase(
new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
2862 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
2864 const OUString& rPropName = rPropertyNames[nProp];
2865 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropName);
2868 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
2869 if(pEntry->
nFlags & beans::PropertyAttribute::READONLY)
2870 throw beans::PropertyVetoException(
"Property is read-only: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
2872 const bool bHeader(rPropName.startsWith(
"Header"));
2873 const bool bFooter(rPropName.startsWith(
"Footer"));
2875 if(bHeader || bFooter || bFirstIsShared)
2877 switch(pEntry->
nWID)
2879 case SID_ATTR_PAGE_ON:
2885 case SID_ATTR_PAGE_DYNAMIC:
2886 case SID_ATTR_PAGE_SHARED:
2887 case SID_ATTR_PAGE_SHARED_FIRST:
2888 case SID_ATTR_PAGE_SIZE:
2895 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2897 if (pEntry->
nWID == SID_ATTR_PAGE_SHARED_FIRST)
2900 if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(
2901 bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
2902 false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)))
2904 PutItemToSet(pSetItem, *pPropSet, *pEntry, rValues[nProp], aBaseImpl);
2908 else if(pEntry->
nWID == SID_ATTR_PAGE_ON && rValues[nProp].get<
bool>())
2911 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
2917 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER,
2918 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE,
2919 SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED,
2920 SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST>{});
2923 aTempSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2925 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_ON,
true));
2929 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED,
true));
2930 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST,
true));
2931 aTempSet.Put(
SfxBoolItem(SID_ATTR_PAGE_DYNAMIC,
true));
2933 SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet);
2934 aBaseImpl.GetItemSet().Put(aNewSetItem);
2964 if(SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)))
2967 std::unique_ptr<SvxSetItem> pNewSetItem(pSetItem->
Clone());
2968 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2971 rSetSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2976 SwStyleBase_Impl::ItemSetOverrider o(aBaseImpl, &rSetSet);
2977 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
2981 rSetSet.SetParent(
nullptr);
2984 aBaseImpl.GetItemSet().Put(*pNewSetItem);
2991 switch(pEntry->
nWID)
2993 case SID_ATTR_PAGE_DYNAMIC:
2994 case SID_ATTR_PAGE_SHARED:
2995 case SID_ATTR_PAGE_SHARED_FIRST:
2996 case SID_ATTR_PAGE_ON:
2999 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast<cppu::OWeakObject*>(
this));
3008 throw lang::IllegalArgumentException();
3012 std::unique_ptr<SfxPoolItem> pNewFootnoteItem(rItem.
Clone());
3013 if(!pNewFootnoteItem->PutValue(rValues[nProp], pEntry->
nMemberId))
3014 throw lang::IllegalArgumentException();
3015 aBaseImpl.GetItemSet().Put(std::move(pNewFootnoteItem));
3020 SetStyleProperty(*pEntry, *pPropSet, rValues[nProp], aBaseImpl);
3026 if(aBaseImpl.HasItemSet())
3030 if (undoGuard.UndoWasEnabled())
3033 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3036 aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
3040 void SwXPageStyle::setPropertyValues(
const uno::Sequence<OUString>& rPropertyNames,
const uno::Sequence<uno::Any>& rValues)
3047 SetPropertyValues_Impl(rPropertyNames, rValues);
3049 catch (
const beans::UnknownPropertyException &rException)
3053 lang::WrappedTargetException aWExc;
3054 aWExc.TargetException <<= rException;
3065 if(SfxItemState::SET != rSet.
GetItemState(nRes,
true, &pItem))
3070 if(!pHeadFootFormat)
3075 uno::Sequence<uno::Any> SwXPageStyle::GetPropertyValues_Impl(
const uno::Sequence<OUString>& rPropertyNames)
3078 throw uno::RuntimeException();
3080 sal_Int32
nLength = rPropertyNames.getLength();
3081 uno::Sequence<uno::Any> aRet (nLength);
3085 throw uno::RuntimeException();
3086 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp)
3089 m_pPropertiesImpl->GetProperty(rPropertyNames[nProp], pAny);
3091 SwStyleProperties_Impl::GetProperty(rPropertyNames[nProp], m_xStyleData, aRet[nProp]);
3093 aRet[nProp] = *pAny;
3099 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrameFormat()->GetAttrSet());
3102 throw uno::RuntimeException();
3103 for(sal_Int32 nProp = 0; nProp < nLength; ++nProp)
3105 const OUString& rPropName = rPropertyNames[nProp];
3106 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropName);
3109 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > (
this ) );
3110 const bool bHeader(rPropName.startsWith(
"Header"));
3111 const bool bFooter(rPropName.startsWith(
"Footer"));
3113 if(bHeader || bFooter || bFirstIsShared)
3115 switch(pEntry->
nWID)
3117 case SID_ATTR_PAGE_ON:
3123 case SID_ATTR_PAGE_DYNAMIC:
3124 case SID_ATTR_PAGE_SHARED:
3125 case SID_ATTR_PAGE_SHARED_FIRST:
3126 case SID_ATTR_PAGE_SIZE:
3131 const SfxItemSet& rSet = xStyle->GetItemSet();
3137 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3139 SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast< SfxItemSet& >(rSetSet));
3140 aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3143 else if(pEntry->
nWID == SID_ATTR_PAGE_ON)
3146 aRet[nProp] <<=
false;
3175 const SfxItemSet& rSet = xStyle->GetItemSet();
3177 if(SfxItemState::SET == rSet.
GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
false, reinterpret_cast<const SfxPoolItem**>(&pSetItem)))
3180 const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3182 SwStyleBase_Impl::ItemSetOverrider o(aBase, &const_cast<SfxItemSet&>(rSetSet));
3183 aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3191 switch(pEntry->
nWID)
3194 case SID_ATTR_PAGE_DYNAMIC:
3195 case SID_ATTR_PAGE_SHARED:
3196 case SID_ATTR_PAGE_SHARED_FIRST:
3197 case SID_ATTR_PAGE_ON:
3199 throw beans::UnknownPropertyException(
"Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > (
this ) );
3211 sal_uInt16 nRes = 0;
3212 switch(pEntry->
nWID)
3225 const SwPageDesc* pDesc = aBase.GetOldPageDesc();
3234 if(bLeft && !bShare)
3235 pFrameFormat = &pDesc->
GetLeft();
3236 else if(bFirst && !bShareFirst)
3246 aRet[nProp] <<= xRet;
3252 const SfxItemSet& rSet = xStyle->GetItemSet();
3258 aRet[nProp] = GetStyleProperty_Impl(*pEntry, *pPropSet, aBase);
3264 uno::Sequence<uno::Any> SwXPageStyle::getPropertyValues(
const uno::Sequence<OUString>& rPropertyNames)
3267 uno::Sequence<uno::Any> aValues;
3272 aValues = GetPropertyValues_Impl(rPropertyNames);
3274 catch(beans::UnknownPropertyException &)
3277 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught",
3278 static_cast < cppu::OWeakObject * > (
this ), anyEx );
3280 catch(lang::WrappedTargetException &)
3283 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught",
3284 static_cast < cppu::OWeakObject * > (
this ), anyEx );
3290 uno::Any SwXPageStyle::getPropertyValue(
const OUString& rPropertyName)
3293 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3294 return GetPropertyValues_Impl(aProperties)[0];
3297 void SwXPageStyle::setPropertyValue(
const OUString& rPropertyName,
const uno::Any& rValue)
3300 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3301 const uno::Sequence<uno::Any> aValues(&rValue, 1);
3307 if ((bIsFooter || bIsHeader) && rValue ==
uno::Any(
true))
3310 for (
size_t i = 0; i < GetDoc()->GetPageDescCnt(); i++)
3312 auto pPageDesc = &GetDoc()->GetPageDesc(i);
3314 if (pPageDesc->
GetName() == GetStyleName())
3317 if (bIsHeader && pLeftHeader)
3324 if (bIsFooter && pLeftFooter)
3334 SetPropertyValues_Impl(aProperties, aValues);
3337 SwXFrameStyle::SwXFrameStyle(
SwDoc *pDoc)
3341 void SwXFrameStyle::SetItem(sal_uInt16 eAtr,
const SfxPoolItem& rItem)
3343 assert(eAtr >= RES_FRMATR_BEGIN && eAtr < RES_FRMATR_END);
3348 SfxItemSet& rStyleSet = xStyle->GetItemSet();
3351 xStyle->SetItemSet(aSet);
3356 assert(eAtr >= RES_FRMATR_BEGIN && eAtr < RES_FRMATR_END);
3361 return &xStyle->GetItemSet().Get(eAtr);
3364 uno::Sequence<uno::Type> SwXFrameStyle::getTypes()
3368 SwXStyle::getTypes()
3375 return uno::makeAny(uno::Reference<XEventsSupplier>(
this));
3376 return SwXStyle::queryInterface(rType);
3379 uno::Reference<container::XNameReplace> SwXFrameStyle::getEvents()
3385 #define AUTOSTYLE_FAMILY_COUNT 3
3396 std::vector<std::shared_ptr<SfxItemSet>>::iterator
aIter;
3402 std::shared_ptr<SfxItemSet>
const &
nextElement() {
return *(aIter++); }
3426 throw lang::IndexOutOfBoundsException();
3428 throw uno::RuntimeException();
3430 uno::Reference< style::XAutoStyleFamily > aRef;
3477 if(Name ==
"CharacterStyles")
3479 else if(Name ==
"RubyStyles")
3481 else if(Name ==
"ParagraphStyles")
3484 throw container::NoSuchElementException();
3491 OUString* pNames = aNames.getArray();
3492 pNames[0] =
"CharacterStyles";
3493 pNames[1] =
"RubyStyles";
3494 pNames[2] =
"ParagraphStyles";
3500 if( Name ==
"CharacterStyles" ||
3501 Name ==
"RubyStyles" ||
3502 Name ==
"ParagraphStyles" )
3509 m_pDocShell( pDocSh ), m_eFamily(nFamily)
3521 if(rHint.
GetId() == SfxHintId::Dying)
3522 m_pDocShell =
nullptr;
3526 const uno::Sequence< beans::PropertyValue >& Values )
3530 throw uno::RuntimeException();
3533 const sal_uInt16* pRange =
nullptr;
3534 const SfxItemPropertySet* pPropSet =
nullptr;
3559 throw uno::RuntimeException();
3564 if(!bTakeCareOfDrawingLayerFillStyle)
3566 for(
const beans::PropertyValue& rValue : Values )
3572 catch (
const beans::UnknownPropertyException &)
3574 OSL_FAIL(
"Unknown property" );
3576 catch (
const lang::IllegalArgumentException &)
3578 OSL_FAIL(
"Illegal argument" );
3594 for(
const beans::PropertyValue& rValue : Values )
3596 const OUString& rPropName = rValue.Name;
3598 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(rPropName);
3602 SAL_WARN(
"sw.core",
"SwXAutoStyleFamily::insertStyle: Unknown property: " << rPropName);
3610 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
3620 if(aValue >>= nValue)
3631 if(eMapUnit != MapUnit::Map100thMM)
3638 switch(pEntry->
nWID)
3654 if(!(aValue >>= aTempName))
3656 throw lang::IllegalArgumentException();
3669 aXFillBitmapItem.
PutValue(aValue, nMemberId);
3670 aSet.Put(aXFillBitmapItem);
3680 std::unique_ptr<SvxBrushItem> aChangedBrushItem(aOriginalBrushItem->Clone());
3682 aChangedBrushItem->PutValue(aValue, nMemberId);
3684 if(*aChangedBrushItem != *aOriginalBrushItem)
3694 drawing::BitmapMode eMode;
3696 if(!(aValue >>= eMode))
3698 sal_Int32 nMode = 0;
3700 if(!(aValue >>= nMode))
3702 throw lang::IllegalArgumentException();
3705 eMode =
static_cast<drawing::BitmapMode
>(nMode);
3723 catch (
const beans::UnknownPropertyException &)
3725 OSL_FAIL(
"Unknown property" );
3727 catch (
const lang::IllegalArgumentException &)
3729 OSL_FAIL(
"Illegal argument" );
3735 aSet.SetParent(
nullptr);
3754 throw uno::RuntimeException();
3755 return uno::Reference< container::XEnumeration >
3770 : rDoc( rInitDoc ), eFamily( eFam )
3775 std::set< std::pair< sal_uInt16, text::RubyAdjust > > aRubyMap;
3779 std::vector<const SwFormatRuby*> vRubyItems;
3782 auto pRubyItem =
dynamic_cast<const SwFormatRuby*
>(pItem);
3783 if ( pRubyItem && pRubyItem->GetTextRuby() )
3784 vRubyItems.push_back(pRubyItem);
3788 std::pair< sal_uInt16, text::RubyAdjust > aPair( pRubyItem->GetPosition(), pRubyItem->GetAdjustment() );
3789 if ( aRubyMap.insert( aPair ).second )
3792 pItemSet->Put( *pRubyItem );
3799 rDoc.GetIStyleAccess().getAllStyles(
mAutoStyles, eFamily );
3818 if(rHint.
GetId() == SfxHintId::Dying)
3825 throw uno::RuntimeException();
3826 return m_pImpl->hasMoreElements();
3832 throw uno::RuntimeException();
3834 if(
m_pImpl->hasMoreElements() )
3836 std::shared_ptr<SfxItemSet> pNextSet =
m_pImpl->nextElement();
3838 pNextSet,
m_pImpl->getFamily());
3839 aRet <<= xAutoStyle;
3853 std::shared_ptr<SfxItemSet>
const & pInitSet,
3869 if(rHint.
GetId() == SfxHintId::Dying)
3875 uno::Reference< beans::XPropertySetInfo > xRet;
3880 static uno::Reference< beans::XPropertySetInfo > xCharRef;
3890 static uno::Reference< beans::XPropertySetInfo > xRubyRef;
3901 static uno::Reference< beans::XPropertySetInfo > xParaRef;
3925 const uno::Sequence<OUString>
aProperties(&rPropertyName, 1);
3930 const uno::Reference< beans::XPropertyChangeListener >& )
3935 const uno::Reference< beans::XPropertyChangeListener >& )
3940 const uno::Reference< beans::XVetoableChangeListener >& )
3945 const uno::Reference< beans::XVetoableChangeListener >& )
3950 const uno::Sequence< OUString >& ,
3951 const uno::Sequence< uno::Any >& )
3956 const uno::Sequence< OUString > & rPropertyNames )
3960 throw uno::RuntimeException();
3975 const OUString* pNames = rPropertyNames.getConstArray();
3977 const sal_Int32 nLen(rPropertyNames.getLength());
3978 uno::Sequence< uno::Any > aRet( nLen );
3979 uno::Any* pValues = aRet.getArray();
3982 for( sal_Int32 i = 0; i < nLen; ++i )
3984 const OUString sPropName = pNames[i];
3985 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(sPropName);
3988 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > (
this ) );
4000 else if(bTakeCareOfDrawingLayerFillStyle)
4003 switch(pEntry->
nWID)
4009 if(!aOriginalBrushItem->QueryValue(aTarget, pEntry->
nMemberId))
4011 OSL_ENSURE(
false,
"Error getting attribute from RES_BACKGROUND (!)");
4021 aTarget <<= drawing::BitmapMode_REPEAT;
4025 aTarget <<= drawing::BitmapMode_STRETCH;
4029 aTarget <<= drawing::BitmapMode_NO_REPEAT;
4043 if(bTakeCareOfDrawingLayerFillStyle)
4049 if (aTarget >>= nValue)
4051 aTarget <<= static_cast<sal_Int16>(nValue);
4056 if(pEntry->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
4066 if(aTarget >>= nValue)
4077 if(eMapUnit != MapUnit::Map100thMM)
4086 pValues[i] = aTarget;
4093 const uno::Sequence< OUString >& rPropertyNames )
4096 uno::Sequence< uno::Any > aValues;
4103 catch (beans::UnknownPropertyException &)
4106 throw lang::WrappedTargetRuntimeException(
"Unknown property exception caught", static_cast < cppu::OWeakObject * > (
this ), exc );
4108 catch (lang::WrappedTargetException &)
4111 throw lang::WrappedTargetRuntimeException(
"WrappedTargetException caught", static_cast < cppu::OWeakObject * > (
this ), exc );
4118 const uno::Sequence< OUString >& ,
4119 const uno::Reference< beans::XPropertiesChangeListener >& )
4124 const uno::Reference< beans::XPropertiesChangeListener >& )
4129 const uno::Sequence< OUString >& ,
4130 const uno::Reference< beans::XPropertiesChangeListener >& )
4138 uno::Sequence< OUString > aNames { rPropertyName };
4140 return aStates.getConstArray()[0];
4149 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4154 const uno::Sequence< OUString >& rPropertyNames )
4158 throw uno::RuntimeException();
4162 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4163 beans::PropertyState* pStates = aRet.getArray();
4164 const OUString* pNames = rPropertyNames.getConstArray();
4179 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4181 const OUString sPropName = pNames[i];
4182 const SfxItemPropertyMapEntry* pEntry = rMap.
getByName(sPropName);
4185 throw beans::UnknownPropertyException(
"Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > (
this ) );
4190 if(bTakeCareOfDrawingLayerFillStyle)
4193 switch(pEntry->
nWID)
4200 pStates[i] = beans::PropertyState_DIRECT_VALUE;
4204 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
4215 pStates[i] = beans::PropertyState_DIRECT_VALUE;
4219 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
4242 const uno::Sequence< OUString >& )
4247 const uno::Sequence< OUString >& )
4249 uno::Sequence< uno::Any > aRet(0);
4256 throw uno::RuntimeException();
4258 std::vector< beans::PropertyValue > aPropertyVector;
4277 const sal_uInt16 nWID = pItem->Which();
4283 if ( pEntry->
nWID == nWID )
4285 beans::PropertyValue aPropertyValue;
4286 aPropertyValue.Name = pEntry->
aName;
4287 pItem->QueryValue( aPropertyValue.Value, pEntry->
nMemberId );
4288 aPropertyVector.push_back( aPropertyValue );
4293 const sal_Int32 nCount = aPropertyVector.size();
4294 uno::Sequence< beans::PropertyValue > aRet( nCount );
4295 beans::PropertyValue* pProps = aRet.getArray();
4297 for (
int i = 0; i < nCount; ++i, pProps++ )
4299 *pProps = aPropertyVector[i];
4306 m_pDocShell(pDocShell), m_pTableAutoFormat(pTableAutoFormat), m_bPhysical(true)
4312 m_pDocShell(pDocShell), m_pTableAutoFormat_Impl(new
SwTableAutoFormat(rTableAutoFormatName)), m_bPhysical(false)
4321 uno::Reference<style::XStyle> xTextTableStyle;
4323 if (pAutoFormat && pAutoFormat->
GetName() == rTableAutoFormatName)
4325 xTextTableStyle.set(pAutoFormat->
GetXObject(), uno::UNO_QUERY);
4326 if (!xTextTableStyle.is())
4334 if (!xTextTableStyle.is())
4337 SAL_INFO(
"sw.uno",
"creating SwXTextTableStyle for non existing SwTableAutoFormat");
4340 return xTextTableStyle;
4346 assert(aTableTemplateMap.size() ==
STYLE_COUNT &&
"can not map SwTableAutoFormat to a SwXTextTableStyle");
4350 uno::Reference<style::XStyle> xCellStyle(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4351 if (!xCellStyle.is())
4393 for(
size_t i=0; i < nStyles; ++i)
4396 if (pAutoFormat->
GetName() == sName)
4411 if (pTableAutoFormat)
4416 for (
size_t i=0; i<aTableTemplateMap.size(); ++i)
4419 uno::Reference<style::XStyle> xCellStyle(pOldBoxFormat->
GetXObject(), uno::UNO_QUERY);
4420 if (!xCellStyle.is())
4432 SAL_WARN(
"sw.uno",
"setting style physical, but SwTableAutoFormat in document not found");
4435 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextTableStyle");
4459 if (!pFormat->
GetInfo(aGetHt))
4502 SAL_WARN(
"sw.uno",
"not implemented");
4508 bool bIsRow =
false;
4521 throw css::beans::UnknownPropertyException(rPropertyName);
4523 return uno::makeAny(bIsRow ? OUString(
"row") : OUString(
"column"));
4528 SAL_WARN(
"sw.uno",
"not implemented");
4533 SAL_WARN(
"sw.uno",
"not implemented");
4538 SAL_WARN(
"sw.uno",
"not implemented");
4543 SAL_WARN(
"sw.uno",
"not implemented");
4551 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4552 if(iter == rMap.end())
4553 throw css::container::NoSuchElementException();
4568 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4569 return iter != rMap.end();
4575 SAL_WARN(
"sw.uno",
"not implemented");
4582 CellStyleNameMap::const_iterator iter = rMap.find(rName);
4583 if(iter == rMap.end())
4584 throw container::NoSuchElementException();
4585 const sal_Int32 nCellStyle = iter->second;
4587 uno::Reference<style::XStyle> xStyle = rElement.get<uno::Reference<style::XStyle>>();
4589 throw lang::IllegalArgumentException();
4592 if (!pStyleToReplaceWith)
4593 throw lang::IllegalArgumentException();
4597 throw lang::IllegalArgumentException();
4600 const sal_Int32 nBoxFormat = rTableTemplateMap[nCellStyle];
4615 SAL_WARN(
"sw.uno",
"not implemented");
4632 return {
"SwXTextTableStyle"};
4642 return {
"com.sun.star.style.Style"};
4647 m_pDocShell(pDocShell),
4648 m_pBoxAutoFormat(pBoxAutoFormat),
4649 m_sParentStyle(sParentStyle),
4654 m_pDocShell(pDocShell),
4672 SAL_INFO(
"sw.uno",
"trying to call SwXTextCellStyle::SetBoxFormat on non physical style");
4688 SAL_WARN(
"sw.uno",
"setting style physical, but SwBoxAutoFormat in document not found");
4691 SAL_WARN(
"sw.uno",
"calling SetPhysical on a physical SwXTextCellStyle");
4701 if (sName.isEmpty())
4705 if (!pBoxAutoFormat)
4707 sal_Int32 nSeparatorIndex, nTemplateIndex;
4708 OUString sParentName, sCellSubName;
4710 nSeparatorIndex = sName.lastIndexOf(
'.');
4711 if (0 >= nSeparatorIndex)
4714 sParentName = sName.copy(0, nSeparatorIndex);
4715 sCellSubName = sName.copy(nSeparatorIndex+1);
4716 nTemplateIndex = sCellSubName.toInt32()-1;
4717 if (0 > nTemplateIndex)
4726 if (!pTableAutoFormat)
4730 *pParentName = sParentName;
4731 sal_uInt32 nBoxIndex = rTableTemplateMap[nTemplateIndex];
4732 pBoxAutoFormat = &pTableAutoFormat->
GetBoxFormat(nBoxIndex);
4735 return pBoxAutoFormat;
4740 uno::Reference<style::XStyle> xTextCellStyle;
4742 if (!sName.isEmpty())
4744 OUString sParentName;
4752 pBoxFormat = &aDefaultBoxFormat;
4755 xTextCellStyle.set(pBoxFormat->
GetXObject(), uno::UNO_QUERY);
4756 if (!xTextCellStyle.is())
4758 xTextCellStyle.set(
new SwXTextCellStyle(pDocShell, pBoxFormat, sParentName));
4765 return xTextCellStyle;
4782 uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(m_pDocShell->
GetModel(), uno::UNO_QUERY);
4783 if (!xFamiliesSupplier.is())
4786 uno::Reference<container::XNameAccess> xFamilies = xFamiliesSupplier->getStyleFamilies();
4787 if (!xFamilies.is())
4790 uno::Reference<container::XNameAccess> xTableStyles;
4791 xFamilies->getByName(
"TableStyles") >>= xTableStyles;
4792 if (!xTableStyles.is())
4795 uno::Reference<style::XStyle> xStyle;
4800 return xStyle->isInUse();
4813 SAL_INFO(
"sw.uno",
"Changing SwXTextCellStyle parent");
4833 OUString sParentStyle;
4867 switch(pEntry->
nWID)
4900 if (aValue >>= nKey)
4930 bool bValue =
false; aValue >>= bValue;
4931 rShadowedItem.SetValue(bValue);
4938 bool bValue =
false; aValue >>= bValue;
4939 rContourItem.SetValue(bValue);