1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/editids.hrc>
21 #include <swtypes.hxx>
23 #include <hintids.hxx>
24 #include <strings.hrc>
25 #include <poolfmt.hxx>
28 #include <unosett.hxx>
29 #include <unoprnms.hxx>
30 #include <ftninfo.hxx>
32 #include <pagedesc.hxx>
33 #include <IDocumentStylePoolAccess.hxx>
34 #include <charfmt.hxx>
35 #include <lineinfo.hxx>
38 #include <docstyle.hxx>
39 #include <editeng/brushitem.hxx>
40 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
41 #include <com/sun/star/text/FootnoteNumbering.hpp>
42 #include <com/sun/star/text/HoriOrientation.hpp>
43 #include <com/sun/star/style/LineNumberPosition.hpp>
44 #include <com/sun/star/awt/FontDescriptor.hpp>
45 #include <com/sun/star/awt/XBitmap.hpp>
46 #include <com/sun/star/graphic/XGraphic.hpp>
47 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <o3tl/any.hxx>
49 #include <o3tl/enumarray.hxx>
50 #include <tools/UnitConversion.hxx>
51 #include <vcl/font.hxx>
52 #include <editeng/flstitem.hxx>
53 #include <vcl/metric.hxx>
54 #include <vcl/graph.hxx>
55 #include <vcl/GraphicLoader.hxx>
56 #include <sfx2/docfile.hxx>
57 #include <svtools/ctrltool.hxx>
58 #include <vcl/svapp.hxx>
59 #include <editeng/unofdesc.hxx>
60 #include <fmtornt.hxx>
61 #include <SwStyleNameMapper.hxx>
62 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
63 #include <com/sun/star/text/LabelFollow.hpp>
64 #include <numrule.hxx>
65 #include <comphelper/servicehelper.hxx>
66 #include <comphelper/sequence.hxx>
67 #include <cppuhelper/supportsservice.hxx>
68 #include <comphelper/propertyvalue.hxx>
69 #include <svl/itemprop.hxx>
70 #include <svl/listener.hxx>
72 #include <sal/log.hxx>
74 using namespace ::com::sun::star
;
75 using namespace ::com::sun::star::uno
;
76 using namespace ::com::sun::star::lang
;
77 using namespace ::com::sun::star::beans
;
78 using namespace ::com::sun::star::text
;
79 using namespace ::com::sun::star::style
;
84 SvtBroadcaster
& GetPageDescNotifier(SwDoc
* pDoc
)
86 return pDoc
->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD
)->GetNotifier();
92 #define WID_NUMBERING_TYPE 2
93 #define WID_START_AT 3
94 #define WID_FOOTNOTE_COUNTING 4
95 #define WID_PARAGRAPH_STYLE 5
96 #define WID_PAGE_STYLE 6
97 #define WID_CHARACTER_STYLE 7
98 #define WID_POSITION_END_OF_DOC 8
99 #define WID_END_NOTICE 9
100 #define WID_BEGIN_NOTICE 10
101 #define WID_ANCHOR_CHARACTER_STYLE 11
102 #define WID_NUM_ON 12
103 #define WID_SEPARATOR_INTERVAL 13
104 #define WID_NUMBER_POSITION 14
105 #define WID_DISTANCE 15
106 #define WID_INTERVAL 16
107 #define WID_SEPARATOR_TEXT 17
108 #define WID_COUNT_EMPTY_LINES 18
109 #define WID_COUNT_LINES_IN_FRAMES 19
110 #define WID_RESTART_AT_EACH_PAGE 20
113 static const SfxItemPropertySet
* GetFootnoteSet()
115 static const SfxItemPropertyMapEntry aFootnoteMap_Impl
[] =
117 { UNO_NAME_ANCHOR_CHAR_STYLE_NAME
,WID_ANCHOR_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
118 { UNO_NAME_BEGIN_NOTICE
, WID_BEGIN_NOTICE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
119 { UNO_NAME_CHAR_STYLE_NAME
, WID_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
120 { UNO_NAME_END_NOTICE
, WID_END_NOTICE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
121 { UNO_NAME_FOOTNOTE_COUNTING
, WID_FOOTNOTE_COUNTING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
122 { UNO_NAME_NUMBERING_TYPE
, WID_NUMBERING_TYPE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
123 { UNO_NAME_PAGE_STYLE_NAME
, WID_PAGE_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
124 { UNO_NAME_PARA_STYLE_NAME
, WID_PARAGRAPH_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
125 { UNO_NAME_POSITION_END_OF_DOC
, WID_POSITION_END_OF_DOC
,cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
126 { UNO_NAME_PREFIX
, WID_PREFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
127 { UNO_NAME_START_AT
, WID_START_AT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
128 { UNO_NAME_SUFFIX
, WID_SUFFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
130 static const SfxItemPropertySet
aFootnoteSet_Impl(aFootnoteMap_Impl
);
131 return &aFootnoteSet_Impl
;
134 static const SfxItemPropertySet
* GetEndnoteSet()
136 static const SfxItemPropertyMapEntry aEndnoteMap_Impl
[] =
138 { UNO_NAME_ANCHOR_CHAR_STYLE_NAME
,WID_ANCHOR_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
139 { UNO_NAME_CHAR_STYLE_NAME
, WID_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
140 { UNO_NAME_NUMBERING_TYPE
, WID_NUMBERING_TYPE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
141 { UNO_NAME_PAGE_STYLE_NAME
, WID_PAGE_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
142 { UNO_NAME_PARA_STYLE_NAME
, WID_PARAGRAPH_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
143 { UNO_NAME_PREFIX
, WID_PREFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
144 { UNO_NAME_START_AT
, WID_START_AT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
145 { UNO_NAME_SUFFIX
, WID_SUFFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
147 static const SfxItemPropertySet
aEndnoteSet_Impl(aEndnoteMap_Impl
);
148 return &aEndnoteSet_Impl
;
151 static const SfxItemPropertySet
* GetNumberingRulesSet()
153 static const SfxItemPropertyMapEntry aNumberingRulesMap_Impl
[] =
155 { UNO_NAME_IS_ABSOLUTE_MARGINS
, WID_IS_ABS_MARGINS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
156 { UNO_NAME_IS_AUTOMATIC
, WID_IS_AUTOMATIC
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
157 { UNO_NAME_IS_CONTINUOUS_NUMBERING
, WID_CONTINUOUS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
158 { UNO_NAME_NAME
, WID_RULE_NAME
, ::cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0},
159 { UNO_NAME_NUMBERING_IS_OUTLINE
, WID_IS_OUTLINE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
160 { UNO_NAME_DEFAULT_LIST_ID
, WID_DEFAULT_LIST_ID
, ::cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0},
162 static const SfxItemPropertySet
aNumberingRulesSet_Impl( aNumberingRulesMap_Impl
);
163 return &aNumberingRulesSet_Impl
;
166 static const SfxItemPropertySet
* GetLineNumberingSet()
168 static const SfxItemPropertyMapEntry aLineNumberingMap_Impl
[] =
170 { UNO_NAME_CHAR_STYLE_NAME
, WID_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
171 { UNO_NAME_COUNT_EMPTY_LINES
, WID_COUNT_EMPTY_LINES
, cppu::UnoType
<bool>::get(),PROPERTY_NONE
, 0},
172 { UNO_NAME_COUNT_LINES_IN_FRAMES
, WID_COUNT_LINES_IN_FRAMES
, cppu::UnoType
<bool>::get(),PROPERTY_NONE
, 0},
173 { UNO_NAME_DISTANCE
, WID_DISTANCE
, ::cppu::UnoType
<sal_Int32
>::get(),PROPERTY_NONE
, 0},
174 { UNO_NAME_IS_ON
, WID_NUM_ON
, cppu::UnoType
<bool>::get() , PROPERTY_NONE
, 0},
175 { UNO_NAME_INTERVAL
, WID_INTERVAL
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
176 { UNO_NAME_SEPARATOR_TEXT
, WID_SEPARATOR_TEXT
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
177 { UNO_NAME_NUMBER_POSITION
, WID_NUMBER_POSITION
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
178 { UNO_NAME_NUMBERING_TYPE
, WID_NUMBERING_TYPE
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
179 { UNO_NAME_RESTART_AT_EACH_PAGE
, WID_RESTART_AT_EACH_PAGE
, cppu::UnoType
<bool>::get() , PROPERTY_NONE
, 0},
180 { UNO_NAME_SEPARATOR_INTERVAL
, WID_SEPARATOR_INTERVAL
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
182 static const SfxItemPropertySet
aLineNumberingSet_Impl(aLineNumberingMap_Impl
);
183 return &aLineNumberingSet_Impl
;
186 static SwCharFormat
* lcl_getCharFormat(SwDoc
* pDoc
, const uno::Any
& aValue
)
188 SwCharFormat
* pRet
= nullptr;
191 OUString sCharFormat
;
192 SwStyleNameMapper::FillUIName(uTmp
, sCharFormat
, SwGetPoolIdFromName::ChrFmt
);
193 if (sCharFormat
!= SwResId(STR_POOLCHR_STANDARD
))
195 pRet
= pDoc
->FindCharFormatByName( sCharFormat
);
199 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName(sCharFormat
, SwGetPoolIdFromName::ChrFmt
);
201 pRet
= pDoc
->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId
);
206 static SwTextFormatColl
* lcl_GetParaStyle(SwDoc
* pDoc
, const uno::Any
& aValue
)
211 SwStyleNameMapper::FillUIName(uTmp
, sParaStyle
, SwGetPoolIdFromName::TxtColl
);
212 SwTextFormatColl
* pRet
= pDoc
->FindTextFormatCollByName( sParaStyle
);
215 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName( sParaStyle
, SwGetPoolIdFromName::TxtColl
);
216 if( USHRT_MAX
!= nId
)
217 pRet
= pDoc
->getIDocumentStylePoolAccess().GetTextCollFromPool( nId
);
222 static SwPageDesc
* lcl_GetPageDesc(SwDoc
* pDoc
, const uno::Any
& aValue
)
227 SwStyleNameMapper::FillUIName(uTmp
, sPageDesc
, SwGetPoolIdFromName::PageDesc
);
228 SwPageDesc
* pRet
= pDoc
->FindPageDesc( sPageDesc
);
231 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName(sPageDesc
, SwGetPoolIdFromName::PageDesc
);
233 pRet
= pDoc
->getIDocumentStylePoolAccess().GetPageDescFromPool( nId
);
239 const o3tl::enumarray
<SvxAdjust
, sal_Int16
> aSvxToUnoAdjust
241 text::HoriOrientation::LEFT
, //3
242 text::HoriOrientation::RIGHT
, //1
244 text::HoriOrientation::CENTER
, //2
249 OUString
SwXFootnoteProperties::getImplementationName()
251 return "SwXFootnoteProperties";
254 sal_Bool
SwXFootnoteProperties::supportsService(const OUString
& rServiceName
)
256 return cppu::supportsService(this, rServiceName
);
259 Sequence
< OUString
> SwXFootnoteProperties::getSupportedServiceNames()
261 Sequence
<OUString
> aRet
{ "com.sun.star.text.FootnoteSettings" };
265 SwXFootnoteProperties::SwXFootnoteProperties(SwDoc
* pDc
) :
267 m_pPropertySet(GetFootnoteSet())
271 SwXFootnoteProperties::~SwXFootnoteProperties()
276 uno::Reference
< beans::XPropertySetInfo
> SwXFootnoteProperties::getPropertySetInfo()
278 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
282 void SwXFootnoteProperties::setPropertyValue(const OUString
& rPropertyName
, const uno::Any
& aValue
)
284 SolarMutexGuard aGuard
;
286 throw uno::RuntimeException();
288 const SfxItemPropertyMapEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
290 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
292 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
293 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
294 SwFootnoteInfo
aFootnoteInfo(m_pDoc
->GetFootnoteInfo());
301 aFootnoteInfo
.SetPrefix(uTmp
);
308 aFootnoteInfo
.SetSuffix(uTmp
);
311 case WID_NUMBERING_TYPE
:
316 (nTmp
<= SVX_NUM_ARABIC
||
317 nTmp
> SVX_NUM_BITMAP
)))
318 throw lang::IllegalArgumentException();
320 aFootnoteInfo
.m_aFormat
.SetNumberingType(static_cast<SvxNumType
>(nTmp
));
328 aFootnoteInfo
.m_nFootnoteOffset
= nTmp
;
331 case WID_FOOTNOTE_COUNTING
:
337 case FootnoteNumbering::PER_PAGE
:
338 aFootnoteInfo
.m_eNum
= FTNNUM_PAGE
;
340 case FootnoteNumbering::PER_CHAPTER
:
341 aFootnoteInfo
.m_eNum
= FTNNUM_CHAPTER
;
343 case FootnoteNumbering::PER_DOCUMENT
:
344 aFootnoteInfo
.m_eNum
= FTNNUM_DOC
;
349 case WID_PARAGRAPH_STYLE
:
351 SwTextFormatColl
* pColl
= lcl_GetParaStyle(m_pDoc
, aValue
);
353 aFootnoteInfo
.SetFootnoteTextColl(*pColl
);
358 SwPageDesc
* pDesc
= lcl_GetPageDesc(m_pDoc
, aValue
);
360 aFootnoteInfo
.ChgPageDesc( pDesc
);
363 case WID_ANCHOR_CHARACTER_STYLE
:
364 case WID_CHARACTER_STYLE
:
366 SwCharFormat
* pFormat
= lcl_getCharFormat(m_pDoc
, aValue
);
369 if(pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
)
370 aFootnoteInfo
.SetAnchorCharFormat(pFormat
);
372 aFootnoteInfo
.SetCharFormat(pFormat
);
376 case WID_POSITION_END_OF_DOC
:
378 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
379 aFootnoteInfo
.m_ePos
= bVal
? FTNPOS_CHAPTER
: FTNPOS_PAGE
;
386 aFootnoteInfo
.m_aQuoVadis
= uTmp
;
389 case WID_BEGIN_NOTICE
:
393 aFootnoteInfo
.m_aErgoSum
= uTmp
;
397 m_pDoc
->SetFootnoteInfo(aFootnoteInfo
);
402 uno::Any
SwXFootnoteProperties::getPropertyValue(const OUString
& rPropertyName
)
404 SolarMutexGuard aGuard
;
407 throw uno::RuntimeException();
409 const SfxItemPropertyMapEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
411 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
413 const SwFootnoteInfo
& rFootnoteInfo
= m_pDoc
->GetFootnoteInfo();
418 aRet
<<= rFootnoteInfo
.GetPrefix();
423 aRet
<<= rFootnoteInfo
.GetSuffix();
426 case WID_NUMBERING_TYPE
:
428 aRet
<<= static_cast<sal_Int16
>(rFootnoteInfo
.m_aFormat
.GetNumberingType());
432 aRet
<<= static_cast<sal_Int16
>(rFootnoteInfo
.m_nFootnoteOffset
);
434 case WID_FOOTNOTE_COUNTING
:
437 switch(rFootnoteInfo
.m_eNum
)
440 nRet
= FootnoteNumbering::PER_PAGE
;
443 nRet
= FootnoteNumbering::PER_CHAPTER
;
446 nRet
= FootnoteNumbering::PER_DOCUMENT
;
452 case WID_PARAGRAPH_STYLE
:
454 SwTextFormatColl
* pColl
= rFootnoteInfo
.GetFootnoteTextColl();
457 aString
= pColl
->GetName();
458 SwStyleNameMapper::FillProgName(aString
, aString
, SwGetPoolIdFromName::TxtColl
);
462 case WID_PAGE_STYLE
:
465 if( rFootnoteInfo
.KnowsPageDesc() )
467 SwStyleNameMapper::FillProgName(
468 rFootnoteInfo
.GetPageDesc( *m_pDoc
)->GetName(),
470 SwGetPoolIdFromName::PageDesc
);
475 case WID_ANCHOR_CHARACTER_STYLE
:
476 case WID_CHARACTER_STYLE
:
479 const SwCharFormat
* pCharFormat
= rFootnoteInfo
.GetCurrentCharFormat(pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
);
482 SwStyleNameMapper::FillProgName(
483 pCharFormat
->GetName(),
485 SwGetPoolIdFromName::ChrFmt
);
490 case WID_POSITION_END_OF_DOC
:
491 aRet
<<= FTNPOS_CHAPTER
== rFootnoteInfo
.m_ePos
;
493 case WID_END_NOTICE
:
494 aRet
<<= rFootnoteInfo
.m_aQuoVadis
;
496 case WID_BEGIN_NOTICE
:
497 aRet
<<= rFootnoteInfo
.m_aErgoSum
;
505 void SwXFootnoteProperties::addPropertyChangeListener(
506 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
508 OSL_FAIL("not implemented");
511 void SwXFootnoteProperties::removePropertyChangeListener(
512 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
514 OSL_FAIL("not implemented");
517 void SwXFootnoteProperties::addVetoableChangeListener(
518 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
520 OSL_FAIL("not implemented");
523 void SwXFootnoteProperties::removeVetoableChangeListener(
524 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
526 OSL_FAIL("not implemented");
529 OUString
SwXEndnoteProperties::getImplementationName()
531 return "SwXEndnoteProperties";
534 sal_Bool
SwXEndnoteProperties::supportsService(const OUString
& rServiceName
)
536 return cppu::supportsService(this, rServiceName
);
539 Sequence
< OUString
> SwXEndnoteProperties::getSupportedServiceNames()
541 Sequence
<OUString
> aRet
{ "com.sun.star.text.FootnoteSettings" };
545 SwXEndnoteProperties::SwXEndnoteProperties(SwDoc
* pDc
) :
547 m_pPropertySet(GetEndnoteSet())
551 SwXEndnoteProperties::~SwXEndnoteProperties()
555 uno::Reference
< beans::XPropertySetInfo
> SwXEndnoteProperties::getPropertySetInfo()
557 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
561 void SwXEndnoteProperties::setPropertyValue(const OUString
& rPropertyName
, const uno::Any
& aValue
)
563 SolarMutexGuard aGuard
;
567 const SfxItemPropertyMapEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
569 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
571 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
572 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
573 SwEndNoteInfo
aEndInfo(m_pDoc
->GetEndNoteInfo());
580 aEndInfo
.SetPrefix(uTmp
);
587 aEndInfo
.SetSuffix(uTmp
);
590 case WID_NUMBERING_TYPE
:
594 aEndInfo
.m_aFormat
.SetNumberingType(static_cast<SvxNumType
>(nTmp
));
601 aEndInfo
.m_nFootnoteOffset
= nTmp
;
604 case WID_PARAGRAPH_STYLE
:
606 SwTextFormatColl
* pColl
= lcl_GetParaStyle(m_pDoc
, aValue
);
608 aEndInfo
.SetFootnoteTextColl(*pColl
);
611 case WID_PAGE_STYLE
:
613 SwPageDesc
* pDesc
= lcl_GetPageDesc(m_pDoc
, aValue
);
615 aEndInfo
.ChgPageDesc( pDesc
);
618 case WID_ANCHOR_CHARACTER_STYLE
:
619 case WID_CHARACTER_STYLE
:
621 SwCharFormat
* pFormat
= lcl_getCharFormat(m_pDoc
, aValue
);
624 if(pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
)
625 aEndInfo
.SetAnchorCharFormat(pFormat
);
627 aEndInfo
.SetCharFormat(pFormat
);
632 m_pDoc
->SetEndNoteInfo(aEndInfo
);
635 uno::Any
SwXEndnoteProperties::getPropertyValue(const OUString
& rPropertyName
)
637 SolarMutexGuard aGuard
;
641 const SfxItemPropertyMapEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
643 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
645 const SwEndNoteInfo
& rEndInfo
= m_pDoc
->GetEndNoteInfo();
649 aRet
<<= rEndInfo
.GetPrefix();
652 aRet
<<= rEndInfo
.GetSuffix();
654 case WID_NUMBERING_TYPE
:
655 aRet
<<= static_cast<sal_Int16
>(rEndInfo
.m_aFormat
.GetNumberingType());
658 aRet
<<= static_cast<sal_Int16
>(rEndInfo
.m_nFootnoteOffset
);
660 case WID_PARAGRAPH_STYLE
:
662 SwTextFormatColl
* pColl
= rEndInfo
.GetFootnoteTextColl();
665 aString
= pColl
->GetName();
666 SwStyleNameMapper::FillProgName(
669 SwGetPoolIdFromName::TxtColl
);
674 case WID_PAGE_STYLE
:
677 if( rEndInfo
.KnowsPageDesc() )
679 SwStyleNameMapper::FillProgName(
680 rEndInfo
.GetPageDesc( *m_pDoc
)->GetName(),
682 SwGetPoolIdFromName::PageDesc
);
687 case WID_ANCHOR_CHARACTER_STYLE
:
688 case WID_CHARACTER_STYLE
:
691 const SwCharFormat
* pCharFormat
= rEndInfo
.GetCurrentCharFormat( pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
);
694 SwStyleNameMapper::FillProgName(
695 pCharFormat
->GetName(),
697 SwGetPoolIdFromName::ChrFmt
);
708 void SwXEndnoteProperties::addPropertyChangeListener(
709 const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
711 OSL_FAIL("not implemented");
714 void SwXEndnoteProperties::removePropertyChangeListener(const OUString
& /*PropertyName*/,
715 const uno:: Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
717 OSL_FAIL("not implemented");
720 void SwXEndnoteProperties::addVetoableChangeListener(const OUString
& /*PropertyName*/,
721 const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
723 OSL_FAIL("not implemented");
726 void SwXEndnoteProperties::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
728 OSL_FAIL("not implemented");
731 OUString
SwXLineNumberingProperties::getImplementationName()
733 return "SwXLineNumberingProperties";
736 sal_Bool
SwXLineNumberingProperties::supportsService(const OUString
& rServiceName
)
738 return cppu::supportsService(this, rServiceName
);
741 Sequence
< OUString
> SwXLineNumberingProperties::getSupportedServiceNames()
743 Sequence
<OUString
> aRet
{ "com.sun.star.text.LineNumberingProperties" };
747 SwXLineNumberingProperties::SwXLineNumberingProperties(SwDoc
* pDc
) :
749 m_pPropertySet(GetLineNumberingSet())
753 SwXLineNumberingProperties::~SwXLineNumberingProperties()
757 uno::Reference
< beans::XPropertySetInfo
> SwXLineNumberingProperties::getPropertySetInfo()
759 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
763 void SwXLineNumberingProperties::setPropertyValue(
764 const OUString
& rPropertyName
, const Any
& aValue
)
766 SolarMutexGuard aGuard
;
768 throw uno::RuntimeException();
770 const SfxItemPropertyMapEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
772 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
774 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
775 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
776 SwLineNumberInfo
aFontMetric(m_pDoc
->GetLineNumberInfo());
781 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
782 aFontMetric
.SetPaintLineNumbers(bVal
);
785 case WID_CHARACTER_STYLE
:
787 SwCharFormat
* pFormat
= lcl_getCharFormat(m_pDoc
, aValue
);
789 aFontMetric
.SetCharFormat(pFormat
);
792 case WID_NUMBERING_TYPE
:
794 SvxNumberType
aNumType(aFontMetric
.GetNumType());
797 aNumType
.SetNumberingType(static_cast<SvxNumType
>(nTmp
));
798 aFontMetric
.SetNumType(aNumType
);
801 case WID_NUMBER_POSITION
:
807 case style::LineNumberPosition::LEFT
:
808 aFontMetric
.SetPos(LINENUMBER_POS_LEFT
);
810 case style::LineNumberPosition::RIGHT
:
811 aFontMetric
.SetPos(LINENUMBER_POS_RIGHT
);
813 case style::LineNumberPosition::INSIDE
:
814 aFontMetric
.SetPos(LINENUMBER_POS_INSIDE
);
816 case style::LineNumberPosition::OUTSIDE
:
817 aFontMetric
.SetPos(LINENUMBER_POS_OUTSIDE
);
826 sal_Int32 nTmp
= o3tl::toTwips(nVal
, o3tl::Length::mm100
);
827 if (nTmp
> SAL_MAX_UINT16
)
828 nTmp
= SAL_MAX_UINT16
;
829 aFontMetric
.SetPosFromLeft(nTmp
);
837 aFontMetric
.SetCountBy(nTmp
);
840 case WID_SEPARATOR_TEXT
:
844 aFontMetric
.SetDivider(uTmp
);
847 case WID_SEPARATOR_INTERVAL
:
852 aFontMetric
.SetDividerCountBy(nTmp
);
855 case WID_COUNT_EMPTY_LINES
:
857 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
858 aFontMetric
.SetCountBlankLines(bVal
);
861 case WID_COUNT_LINES_IN_FRAMES
:
863 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
864 aFontMetric
.SetCountInFlys(bVal
);
867 case WID_RESTART_AT_EACH_PAGE
:
869 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
870 aFontMetric
.SetRestartEachPage(bVal
);
874 m_pDoc
->SetLineNumberInfo(aFontMetric
);
877 Any
SwXLineNumberingProperties::getPropertyValue(const OUString
& rPropertyName
)
879 SolarMutexGuard aGuard
;
882 throw uno::RuntimeException();
884 const SfxItemPropertyMapEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
886 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
888 const SwLineNumberInfo
& rInfo
= m_pDoc
->GetLineNumberInfo();
892 aRet
<<= rInfo
.IsPaintLineNumbers();
894 case WID_CHARACTER_STYLE
:
897 // return empty string if no char format is set
898 // otherwise it would be created here
899 if(rInfo
.HasCharFormat())
901 SwStyleNameMapper::FillProgName(
902 rInfo
.GetCharFormat(m_pDoc
->getIDocumentStylePoolAccess())->GetName(),
904 SwGetPoolIdFromName::ChrFmt
);
909 case WID_NUMBERING_TYPE
:
910 aRet
<<= static_cast<sal_Int16
>(rInfo
.GetNumType().GetNumberingType());
912 case WID_NUMBER_POSITION
:
915 switch(rInfo
.GetPos())
917 case LINENUMBER_POS_LEFT
:
918 nRet
= style::LineNumberPosition::LEFT
;
920 case LINENUMBER_POS_RIGHT
:
921 nRet
= style::LineNumberPosition::RIGHT
;
923 case LINENUMBER_POS_INSIDE
:
924 nRet
= style::LineNumberPosition::INSIDE
;
926 case LINENUMBER_POS_OUTSIDE
:
927 nRet
= style::LineNumberPosition::OUTSIDE
;
935 sal_uInt32 nPos
= rInfo
.GetPosFromLeft();
936 if(USHRT_MAX
== nPos
)
938 aRet
<<= static_cast < sal_Int32
>(convertTwipToMm100(nPos
));
942 aRet
<<= static_cast<sal_Int16
>(rInfo
.GetCountBy());
944 case WID_SEPARATOR_TEXT
:
945 aRet
<<= rInfo
.GetDivider();
947 case WID_SEPARATOR_INTERVAL
:
948 aRet
<<= static_cast<sal_Int16
>(rInfo
.GetDividerCountBy());
950 case WID_COUNT_EMPTY_LINES
:
951 aRet
<<= rInfo
.IsCountBlankLines();
953 case WID_COUNT_LINES_IN_FRAMES
:
954 aRet
<<= rInfo
.IsCountInFlys();
956 case WID_RESTART_AT_EACH_PAGE
:
957 aRet
<<= rInfo
.IsRestartEachPage();
963 void SwXLineNumberingProperties::addPropertyChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
965 OSL_FAIL("not implemented");
968 void SwXLineNumberingProperties::removePropertyChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
970 OSL_FAIL("not implemented");
973 void SwXLineNumberingProperties::addVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
975 OSL_FAIL("not implemented");
978 void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
980 OSL_FAIL("not implemented");
983 constexpr OUStringLiteral aInvalidStyle
= u
"__XXX___invalid";
985 class SwXNumberingRules::Impl
988 SwXNumberingRules
& m_rParent
;
989 virtual void Notify(const SfxHint
&) override
;
991 explicit Impl(SwXNumberingRules
& rParent
) : m_rParent(rParent
) {}
994 bool SwXNumberingRules::isInvalidStyle(std::u16string_view rName
)
996 return rName
== aInvalidStyle
;
999 OUString
SwXNumberingRules::getImplementationName()
1001 return "SwXNumberingRules";
1004 sal_Bool
SwXNumberingRules::supportsService(const OUString
& rServiceName
)
1006 return cppu::supportsService(this, rServiceName
);
1009 Sequence
< OUString
> SwXNumberingRules::getSupportedServiceNames()
1011 Sequence
<OUString
> aRet
{ "com.sun.star.text.NumberingRules" };
1015 SwXNumberingRules::SwXNumberingRules(const SwNumRule
& rRule
, SwDoc
* doc
) :
1016 m_pImpl(new SwXNumberingRules::Impl(*this)),
1018 m_pDocShell(nullptr),
1019 m_pNumRule(new SwNumRule(rRule
)),
1020 m_pPropertySet(GetNumberingRulesSet()),
1021 m_bOwnNumRuleCreated(true)
1023 // first organize the document - it is dependent on the set character formats
1024 // if no format is set, it should work as well
1025 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
1027 SwNumFormat
rFormat(m_pNumRule
->Get(i
));
1028 SwCharFormat
* pCharFormat
= rFormat
.GetCharFormat();
1031 m_pDoc
= pCharFormat
->GetDoc();
1036 m_pImpl
->StartListening(GetPageDescNotifier(m_pDoc
));
1037 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
1039 m_sNewCharStyleNames
[i
] = aInvalidStyle
;
1040 m_sNewBulletFontNames
[i
] = aInvalidStyle
;
1044 SwXNumberingRules::SwXNumberingRules(SwDocShell
& rDocSh
) :
1045 m_pImpl(new SwXNumberingRules::Impl(*this)),
1047 m_pDocShell(&rDocSh
),
1048 m_pNumRule(nullptr),
1049 m_pPropertySet(GetNumberingRulesSet()),
1050 m_bOwnNumRuleCreated(false)
1052 m_pImpl
->StartListening(GetPageDescNotifier(m_pDocShell
->GetDoc()));
1055 SwXNumberingRules::SwXNumberingRules(SwDoc
& rDoc
) :
1056 m_pImpl(new SwXNumberingRules::Impl(*this)),
1058 m_pDocShell(nullptr),
1059 m_pNumRule(nullptr),
1060 m_pPropertySet(GetNumberingRulesSet()),
1061 m_bOwnNumRuleCreated(false)
1063 m_pImpl
->StartListening(GetPageDescNotifier(&rDoc
));
1064 m_sCreatedNumRuleName
= rDoc
.GetUniqueNumRuleName();
1065 rDoc
.MakeNumRule( m_sCreatedNumRuleName
, nullptr, false,
1067 numfunc::GetDefaultPositionAndSpaceMode() );
1070 SwXNumberingRules::~SwXNumberingRules()
1072 SolarMutexGuard aGuard
;
1073 if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
1074 m_pDoc
->DelNumRule( m_sCreatedNumRuleName
);
1075 if( m_bOwnNumRuleCreated
)
1079 void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex
, const uno::Any
& rElement
)
1081 SolarMutexGuard aGuard
;
1082 if(nIndex
< 0 || MAXLEVEL
<= nIndex
)
1083 throw lang::IndexOutOfBoundsException();
1085 auto rProperties
= o3tl::tryAccess
<uno::Sequence
<beans::PropertyValue
>>(
1088 throw lang::IllegalArgumentException();
1089 SwNumRule
* pRule
= nullptr;
1091 SwXNumberingRules::SetNumberingRuleByIndex( *m_pNumRule
,
1092 *rProperties
, nIndex
);
1093 else if(m_pDocShell
)
1095 // #i87650# - correction of cws warnings:
1096 SwNumRule
aNumRule( *(m_pDocShell
->GetDoc()->GetOutlineNumRule()) );
1097 SwXNumberingRules::SetNumberingRuleByIndex( aNumRule
,
1098 *rProperties
, nIndex
);
1099 // set character format if needed
1100 // this code appears to be dead - except when a style is assigned for BITMAP numbering?
1101 const SwCharFormats
* pFormats
= m_pDocShell
->GetDoc()->GetCharFormats();
1102 const size_t nChCount
= pFormats
->size();
1103 for(sal_uInt16 i
= 0; i
< MAXLEVEL
;i
++)
1105 SwNumFormat
aFormat(aNumRule
.Get( i
));
1106 if (!m_sNewCharStyleNames
[i
].isEmpty() &&
1107 (!aFormat
.GetCharFormat() || aFormat
.GetCharFormat()->GetName()!= m_sNewCharStyleNames
[i
]))
1109 SwCharFormat
* pCharFormat
= nullptr;
1110 for(size_t j
= 0; j
< nChCount
; ++j
)
1112 SwCharFormat
* pTmp
= (*pFormats
)[j
];
1113 if(pTmp
->GetName() == m_sNewCharStyleNames
[i
])
1121 SfxStyleSheetBase
* pBase
;
1122 pBase
= m_pDocShell
->GetStyleSheetPool()->Find(m_sNewCharStyleNames
[i
],
1123 SfxStyleFamily::Char
);
1125 pBase
= &m_pDocShell
->GetStyleSheetPool()->Make(m_sNewCharStyleNames
[i
], SfxStyleFamily::Char
);
1126 pCharFormat
= static_cast<SwDocStyleSheet
*>(pBase
)->GetCharFormat();
1129 aFormat
.SetCharFormat( pCharFormat
);
1130 aNumRule
.Set( i
, aFormat
);
1133 m_pDocShell
->GetDoc()->SetOutlineNumRule( aNumRule
);
1135 else if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty() &&
1136 nullptr != (pRule
= m_pDoc
->FindNumRulePtr( m_sCreatedNumRuleName
)))
1138 SwXNumberingRules::SetNumberingRuleByIndex( *pRule
,
1139 *rProperties
, nIndex
);
1141 pRule
->Validate(*m_pDoc
);
1144 throw uno::RuntimeException();
1147 sal_Int32
SwXNumberingRules::getCount()
1152 uno::Any
SwXNumberingRules::getByIndex(sal_Int32 nIndex
)
1154 SolarMutexGuard aGuard
;
1155 if(nIndex
< 0 || MAXLEVEL
<= nIndex
)
1156 throw lang::IndexOutOfBoundsException();
1159 const SwNumRule
* pRule
= m_pNumRule
;
1160 if(!pRule
&& m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
1161 pRule
= m_pDoc
->FindNumRulePtr( m_sCreatedNumRuleName
);
1164 uno::Sequence
<beans::PropertyValue
> aRet
= GetNumberingRuleByIndex(
1169 else if(m_pDocShell
)
1171 uno::Sequence
<beans::PropertyValue
> aRet
= GetNumberingRuleByIndex(
1172 *m_pDocShell
->GetDoc()->GetOutlineNumRule(), nIndex
);
1176 throw uno::RuntimeException();
1180 uno::Type
SwXNumberingRules::getElementType()
1182 return cppu::UnoType
<uno::Sequence
<beans::PropertyValue
>>::get();
1185 sal_Bool
SwXNumberingRules::hasElements()
1190 const TranslateId STR_POOLCOLL_HEADLINE_ARY
[]
1192 STR_POOLCOLL_HEADLINE1
,
1193 STR_POOLCOLL_HEADLINE2
,
1194 STR_POOLCOLL_HEADLINE3
,
1195 STR_POOLCOLL_HEADLINE4
,
1196 STR_POOLCOLL_HEADLINE5
,
1197 STR_POOLCOLL_HEADLINE6
,
1198 STR_POOLCOLL_HEADLINE7
,
1199 STR_POOLCOLL_HEADLINE8
,
1200 STR_POOLCOLL_HEADLINE9
,
1201 STR_POOLCOLL_HEADLINE10
1204 uno::Sequence
<beans::PropertyValue
> SwXNumberingRules::GetNumberingRuleByIndex(
1205 const SwNumRule
& rNumRule
, sal_Int32 nIndex
) const
1207 SolarMutexGuard aGuard
;
1208 OSL_ENSURE( 0 <= nIndex
&& nIndex
< MAXLEVEL
, "index out of range" );
1210 const SwNumFormat
& rFormat
= rNumRule
.Get( o3tl::narrowing
<sal_uInt16
>(nIndex
) );
1212 SwCharFormat
* pCharFormat
= rFormat
.GetCharFormat();
1213 OUString CharStyleName
;
1215 CharStyleName
= pCharFormat
->GetName();
1217 // Whether or not a style is present: the array entry overwrites this string
1218 if (!m_sNewCharStyleNames
[nIndex
].isEmpty() &&
1219 !SwXNumberingRules::isInvalidStyle(m_sNewCharStyleNames
[nIndex
]))
1221 CharStyleName
= m_sNewCharStyleNames
[nIndex
];
1225 if (m_pDocShell
) // -> Chapter Numbering
1228 OUString
sValue(SwResId(STR_POOLCOLL_HEADLINE_ARY
[nIndex
]));
1229 const SwTextFormatColls
* pColls
= m_pDocShell
->GetDoc()->GetTextFormatColls();
1230 const size_t nCount
= pColls
->size();
1231 for(size_t i
= 0; i
< nCount
; ++i
)
1233 SwTextFormatColl
&rTextColl
= *pColls
->operator[](i
);
1234 if(rTextColl
.IsDefault())
1237 const sal_Int16 nOutLevel
= rTextColl
.IsAssignedToListLevelOfOutlineStyle()
1238 ? static_cast<sal_Int16
>(rTextColl
.GetAssignedOutlineStyleLevel())
1240 if ( nOutLevel
== nIndex
)
1242 sValue
= rTextColl
.GetName();
1243 break; // the style for the level in question has been found
1245 else if( sValue
==rTextColl
.GetName() )
1247 // if the default for the level is existing, but its
1248 // level is different, then it cannot be the default.
1252 SwStyleNameMapper::FillProgName(sValue
, aUString
, SwGetPoolIdFromName::TxtColl
);
1256 if (m_pDoc
!= nullptr) {
1257 auto const sh
= m_pDoc
->GetPersist();
1258 if (sh
!= nullptr && sh
->HasName()) {
1259 referer
= sh
->GetMedium()->GetName();
1262 return GetPropertiesForNumFormat(
1263 rFormat
, CharStyleName
, m_pDocShell
? & aUString
: nullptr, referer
);
1267 uno::Sequence
<beans::PropertyValue
> SwXNumberingRules::GetPropertiesForNumFormat(
1268 const SwNumFormat
& rFormat
, OUString
const& rCharFormatName
,
1269 OUString
const*const pHeadingStyleName
, OUString
const & referer
)
1271 bool bChapterNum
= pHeadingStyleName
!= nullptr;
1273 std::vector
<PropertyValue
> aPropertyValues
;
1274 aPropertyValues
.reserve(32);
1275 //fill all properties into the array
1278 SvxAdjust eAdj
= rFormat
.GetNumAdjust();
1279 sal_Int16 nINT16
= aSvxToUnoAdjust
[eAdj
];
1280 aPropertyValues
.push_back(comphelper::makePropertyValue("Adjust", nINT16
));
1283 nINT16
= rFormat
.GetIncludeUpperLevels();
1284 aPropertyValues
.push_back(comphelper::makePropertyValue("ParentNumbering", nINT16
));
1287 OUString aUString
= rFormat
.GetPrefix();
1288 aPropertyValues
.push_back(comphelper::makePropertyValue("Prefix", aUString
));
1291 aUString
= rFormat
.GetSuffix();
1292 aPropertyValues
.push_back(comphelper::makePropertyValue("Suffix", aUString
));
1295 if (rFormat
.HasListFormat())
1297 aPropertyValues
.push_back(comphelper::makePropertyValue("ListFormat", rFormat
.GetListFormat()));
1302 SwStyleNameMapper::FillProgName( rCharFormatName
, aUString
, SwGetPoolIdFromName::ChrFmt
);
1303 aPropertyValues
.push_back(comphelper::makePropertyValue("CharStyleName", aUString
));
1306 nINT16
= rFormat
.GetStart();
1307 aPropertyValues
.push_back(comphelper::makePropertyValue("StartWith", nINT16
));
1309 if ( rFormat
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
1312 sal_Int32 nINT32
= convertTwipToMm100(rFormat
.GetAbsLSpace());
1313 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_LEFT_MARGIN
, nINT32
));
1316 nINT32
= convertTwipToMm100(rFormat
.GetCharTextDistance());
1317 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_SYMBOL_TEXT_DISTANCE
, nINT32
));
1320 nINT32
= convertTwipToMm100(rFormat
.GetFirstLineOffset());
1321 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_FIRST_LINE_OFFSET
, nINT32
));
1324 // PositionAndSpaceMode
1325 nINT16
= PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
;
1326 if ( rFormat
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
1328 nINT16
= PositionAndSpaceMode::LABEL_ALIGNMENT
;
1330 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_POSITION_AND_SPACE_MODE
, nINT16
));
1332 if ( rFormat
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
1335 nINT16
= LabelFollow::LISTTAB
;
1336 if ( rFormat
.GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
1338 nINT16
= LabelFollow::SPACE
;
1340 else if ( rFormat
.GetLabelFollowedBy() == SvxNumberFormat::NOTHING
)
1342 nINT16
= LabelFollow::NOTHING
;
1344 else if ( rFormat
.GetLabelFollowedBy() == SvxNumberFormat::NEWLINE
)
1346 nINT16
= LabelFollow::NEWLINE
;
1348 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_LABEL_FOLLOWED_BY
, nINT16
));
1350 // ListtabStopPosition
1351 sal_Int32 nINT32
= convertTwipToMm100(rFormat
.GetListtabPos());
1352 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_LISTTAB_STOP_POSITION
, nINT32
));
1355 nINT32
= convertTwipToMm100(rFormat
.GetFirstLineIndent());
1356 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_FIRST_LINE_INDENT
, nINT32
));
1359 nINT32
= convertTwipToMm100(rFormat
.GetIndentAt());
1360 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_INDENT_AT
, nINT32
));
1364 nINT16
= rFormat
.GetNumberingType();
1365 aPropertyValues
.push_back(comphelper::makePropertyValue("NumberingType", nINT16
));
1369 if(SVX_NUM_CHAR_SPECIAL
== rFormat
.GetNumberingType())
1371 sal_UCS4 cBullet
= rFormat
.GetBulletChar();
1375 aPropertyValues
.push_back(comphelper::makePropertyValue("BulletId", nINT16
));
1377 std::optional
<vcl::Font
> pFont
= rFormat
.GetBulletFont();
1380 aUString
= OUString(&cBullet
, 1);
1381 aPropertyValues
.push_back(comphelper::makePropertyValue("BulletChar", aUString
));
1384 aUString
= pFont
? pFont
->GetStyleName() : OUString();
1385 aPropertyValues
.push_back(comphelper::makePropertyValue("BulletFontName", aUString
));
1390 awt::FontDescriptor aDesc
;
1391 SvxUnoFontDescriptor::ConvertFromFont( *pFont
, aDesc
);
1392 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_BULLET_FONT
, aDesc
));
1395 if (SVX_NUM_BITMAP
== rFormat
.GetNumberingType())
1397 const SvxBrushItem
* pBrush
= rFormat
.GetBrush();
1398 const Graphic
* pGraphic
= pBrush
? pBrush
->GetGraphic(referer
) : nullptr;
1402 uno::Reference
<awt::XBitmap
> xBitmap(pGraphic
->GetXGraphic(), uno::UNO_QUERY
);
1403 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_BITMAP
, xBitmap
));
1406 Size aSize
= rFormat
.GetGraphicSize();
1408 // adjust conversion due to type mismatch between <Size> and <awt::Size>
1409 awt::Size
aAwtSize(convertTwipToMm100(aSize
.Width()), convertTwipToMm100(aSize
.Height()));
1410 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_SIZE
, aAwtSize
));
1412 const SwFormatVertOrient
* pOrient
= rFormat
.GetGraphicOrientation();
1416 pOrient
->QueryValue(any
);
1417 aPropertyValues
.emplace_back(
1418 UNO_NAME_VERT_ORIENT
, -1, any
, PropertyState_DIRECT_VALUE
);
1424 aUString
= *pHeadingStyleName
;
1425 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_HEADING_STYLE_NAME
, aUString
));
1428 return ::comphelper::containerToSequence(aPropertyValues
);
1431 void SwXNumberingRules::SetNumberingRuleByIndex(
1432 SwNumRule
& rNumRule
,
1433 const uno::Sequence
<beans::PropertyValue
>& rProperties
, sal_Int32 nIndex
)
1435 SolarMutexGuard aGuard
;
1436 OSL_ENSURE( 0 <= nIndex
&& nIndex
< MAXLEVEL
, "index out of range" );
1438 SwNumFormat
aFormat(rNumRule
.Get( o3tl::narrowing
<sal_uInt16
>(nIndex
) ));
1440 OUString sHeadingStyleName
;
1441 OUString sParagraphStyleName
;
1443 SetPropertiesToNumFormat(aFormat
, m_sNewCharStyleNames
[nIndex
],
1444 &m_sNewBulletFontNames
[nIndex
],
1445 &sHeadingStyleName
, &sParagraphStyleName
,
1446 m_pDoc
, m_pDocShell
, rProperties
);
1449 if (m_pDoc
&& !sParagraphStyleName
.isEmpty())
1451 const SwTextFormatColls
* pColls
= m_pDoc
->GetTextFormatColls();
1452 const size_t nCount
= pColls
->size();
1453 for (size_t k
= 0; k
< nCount
; ++k
)
1455 SwTextFormatColl
&rTextColl
= *((*pColls
)[k
]);
1456 if (rTextColl
.GetName() == sParagraphStyleName
)
1457 rTextColl
.SetFormatAttr( SwNumRuleItem( rNumRule
.GetName()));
1461 if (!sHeadingStyleName
.isEmpty())
1463 assert(m_pDocShell
);
1464 const SwTextFormatColls
* pColls
= m_pDocShell
->GetDoc()->GetTextFormatColls();
1465 const size_t nCount
= pColls
->size();
1466 for (size_t k
= 0; k
< nCount
; ++k
)
1468 SwTextFormatColl
&rTextColl
= *((*pColls
)[k
]);
1469 if (rTextColl
.IsDefault())
1471 if (rTextColl
.IsAssignedToListLevelOfOutlineStyle() &&
1472 rTextColl
.GetAssignedOutlineStyleLevel() == nIndex
&&
1473 rTextColl
.GetName() != sHeadingStyleName
)
1475 rTextColl
.DeleteAssignmentToListLevelOfOutlineStyle();
1477 else if (rTextColl
.GetName() == sHeadingStyleName
)
1479 rTextColl
.AssignToListLevelOfOutlineStyle( nIndex
);
1484 rNumRule
.Set(o3tl::narrowing
<sal_uInt16
>(nIndex
), aFormat
);
1487 void SwXNumberingRules::SetPropertiesToNumFormat(
1488 SwNumFormat
& aFormat
,
1489 OUString
& rCharStyleName
, OUString
*const pBulletFontName
,
1490 OUString
*const pHeadingStyleName
,
1491 OUString
*const pParagraphStyleName
,
1493 SwDocShell
*const pDocShell
,
1494 const uno::Sequence
<beans::PropertyValue
>& rProperties
)
1496 assert(pDoc
== nullptr || pDocShell
== nullptr); // can't be both ordinary and chapter numbering
1498 bool bWrongArg
= false;
1499 std::unique_ptr
<SvxBrushItem
> pSetBrush
;
1500 std::unique_ptr
<Size
> pSetSize
;
1501 std::unique_ptr
<SwFormatVertOrient
> pSetVOrient
;
1502 bool bCharStyleNameSet
= false;
1504 for (const beans::PropertyValue
& rProp
: rProperties
)
1506 if (rProp
.Name
== UNO_NAME_ADJUST
)
1508 sal_Int16 nValue
= text::HoriOrientation::NONE
;
1509 rProp
.Value
>>= nValue
;
1511 case text::HoriOrientation::RIGHT
:
1512 aFormat
.SetNumAdjust(SvxAdjust::Right
);
1514 case text::HoriOrientation::CENTER
:
1515 aFormat
.SetNumAdjust(SvxAdjust::Center
);
1517 case text::HoriOrientation::LEFT
:
1518 aFormat
.SetNumAdjust(SvxAdjust::Left
);
1525 else if (rProp
.Name
== UNO_NAME_PARENT_NUMBERING
)
1528 rProp
.Value
>>= nSet
;
1529 if(nSet
>= 0 && MAXLEVEL
>= nSet
)
1530 aFormat
.SetIncludeUpperLevels( static_cast< sal_uInt8
>(nSet
) );
1532 else if (rProp
.Name
== UNO_NAME_PREFIX
)
1535 rProp
.Value
>>= uTmp
;
1536 aFormat
.SetPrefix(uTmp
);
1538 else if (rProp
.Name
== UNO_NAME_SUFFIX
)
1541 rProp
.Value
>>= uTmp
;
1542 aFormat
.SetSuffix(uTmp
);
1544 else if (rProp
.Name
== UNO_NAME_CHAR_STYLE_NAME
)
1546 bCharStyleNameSet
= true;
1548 rProp
.Value
>>= uTmp
;
1549 OUString sCharFormatName
;
1550 SwStyleNameMapper::FillUIName( uTmp
, sCharFormatName
, SwGetPoolIdFromName::ChrFmt
);
1551 SwDoc
*const pLocalDoc
= pDocShell
? pDocShell
->GetDoc() : pDoc
;
1552 if (sCharFormatName
.isEmpty())
1554 rCharStyleName
.clear();
1555 aFormat
.SetCharFormat(nullptr);
1556 aFormat
.SetCharFormatName("");
1560 SwCharFormat
* pCharFormat
= nullptr;
1561 if (!sCharFormatName
.isEmpty())
1563 pCharFormat
= pLocalDoc
->FindCharFormatByName(sCharFormatName
);
1567 SfxStyleSheetBase
* pBase
;
1568 SfxStyleSheetBasePool
* pPool
= pLocalDoc
->GetDocShell()->GetStyleSheetPool();
1569 pBase
= pPool
->Find(sCharFormatName
, SfxStyleFamily::Char
);
1571 pBase
= &pPool
->Make(sCharFormatName
, SfxStyleFamily::Char
);
1572 pCharFormat
= static_cast<SwDocStyleSheet
*>(pBase
)->GetCharFormat();
1575 aFormat
.SetCharFormat( pCharFormat
);
1577 // If the character format has been found its name should not be in the
1578 // char style names array
1579 rCharStyleName
.clear();
1582 rCharStyleName
= sCharFormatName
;
1584 else if (rProp
.Name
== UNO_NAME_START_WITH
)
1587 rProp
.Value
>>= nVal
;
1588 aFormat
.SetStart(nVal
);
1590 else if (rProp
.Name
== UNO_NAME_LEFT_MARGIN
)
1592 sal_Int32 nValue
= 0;
1593 rProp
.Value
>>= nValue
;
1594 // #i23727# nValue can be negative
1595 aFormat
.SetAbsLSpace(o3tl::toTwips(nValue
, o3tl::Length::mm100
));
1597 else if (rProp
.Name
== UNO_NAME_SYMBOL_TEXT_DISTANCE
)
1599 sal_Int32 nValue
= 0;
1600 rProp
.Value
>>= nValue
;
1602 aFormat
.SetCharTextDistance(o3tl::toTwips(nValue
, o3tl::Length::mm100
));
1606 else if (rProp
.Name
== UNO_NAME_FIRST_LINE_OFFSET
)
1608 sal_Int32 nValue
= 0;
1609 rProp
.Value
>>= nValue
;
1610 // #i23727# nValue can be positive
1611 nValue
= o3tl::toTwips(nValue
, o3tl::Length::mm100
);
1612 aFormat
.SetFirstLineOffset(nValue
);
1614 else if (rProp
.Name
== UNO_NAME_POSITION_AND_SPACE_MODE
)
1616 sal_Int16 nValue
= 0;
1617 rProp
.Value
>>= nValue
;
1620 aFormat
.SetPositionAndSpaceMode( SvxNumberFormat::LABEL_WIDTH_AND_POSITION
);
1622 else if ( nValue
== 1 )
1624 aFormat
.SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT
);
1631 else if (rProp
.Name
== UNO_NAME_LABEL_FOLLOWED_BY
)
1633 sal_Int16 nValue
= 0;
1634 rProp
.Value
>>= nValue
;
1635 if ( nValue
== LabelFollow::LISTTAB
)
1637 aFormat
.SetLabelFollowedBy( SvxNumberFormat::LISTTAB
);
1639 else if ( nValue
== LabelFollow::SPACE
)
1641 aFormat
.SetLabelFollowedBy( SvxNumberFormat::SPACE
);
1643 else if ( nValue
== LabelFollow::NOTHING
)
1645 aFormat
.SetLabelFollowedBy( SvxNumberFormat::NOTHING
);
1647 else if ( nValue
== LabelFollow::NEWLINE
)
1649 aFormat
.SetLabelFollowedBy( SvxNumberFormat::NEWLINE
);
1656 else if (rProp
.Name
== UNO_NAME_LISTTAB_STOP_POSITION
)
1658 sal_Int32 nValue
= 0;
1659 rProp
.Value
>>= nValue
;
1660 nValue
= o3tl::toTwips(nValue
, o3tl::Length::mm100
);
1663 aFormat
.SetListtabPos( nValue
);
1670 else if (rProp
.Name
== UNO_NAME_FIRST_LINE_INDENT
)
1672 sal_Int32 nValue
= 0;
1673 rProp
.Value
>>= nValue
;
1674 nValue
= o3tl::toTwips(nValue
, o3tl::Length::mm100
);
1675 aFormat
.SetFirstLineIndent( nValue
);
1677 else if (rProp
.Name
== UNO_NAME_INDENT_AT
)
1679 sal_Int32 nValue
= 0;
1680 rProp
.Value
>>= nValue
;
1681 nValue
= o3tl::toTwips(nValue
, o3tl::Length::mm100
);
1682 aFormat
.SetIndentAt( nValue
);
1684 else if (rProp
.Name
== UNO_NAME_NUMBERING_TYPE
)
1687 rProp
.Value
>>= nSet
;
1689 aFormat
.SetNumberingType(static_cast<SvxNumType
>(nSet
));
1693 else if (rProp
.Name
== UNO_NAME_PARAGRAPH_STYLE_NAME
)
1695 if (pParagraphStyleName
)
1698 rProp
.Value
>>= uTmp
;
1699 OUString sStyleName
;
1700 SwStyleNameMapper::FillUIName(uTmp
, sStyleName
, SwGetPoolIdFromName::TxtColl
);
1701 *pParagraphStyleName
= sStyleName
;
1704 else if (rProp
.Name
== UNO_NAME_BULLET_ID
)
1707 if( rProp
.Value
>>= nSet
)
1708 aFormat
.SetBulletChar(nSet
);
1712 else if (rProp
.Name
== UNO_NAME_BULLET_FONT
)
1714 awt::FontDescriptor desc
;
1715 if (rProp
.Value
>>= desc
)
1718 // do not accept "empty" font
1719 if (!desc
.Name
.isEmpty())
1722 SvxUnoFontDescriptor::ConvertToFont(desc
, aFont
);
1723 aFormat
.SetBulletFont(&aFont
);
1729 else if (rProp
.Name
== UNO_NAME_BULLET_FONT_NAME
)
1731 OUString sBulletFontName
;
1732 rProp
.Value
>>= sBulletFontName
;
1733 SwDocShell
*const pLclDocShell
= pDocShell
? pDocShell
: pDoc
? pDoc
->GetDocShell() : nullptr;
1734 if (!sBulletFontName
.isEmpty() && pLclDocShell
)
1736 const SvxFontListItem
* pFontListItem
=
1737 static_cast<const SvxFontListItem
* >(pLclDocShell
1738 ->GetItem( SID_ATTR_CHAR_FONTLIST
));
1739 const FontList
* pList
= pFontListItem
->GetFontList();
1740 FontMetric aFontMetric
= pList
->Get(
1741 sBulletFontName
, WEIGHT_NORMAL
, ITALIC_NONE
);
1742 vcl::Font
aFont(aFontMetric
);
1743 aFormat
.SetBulletFont(&aFont
);
1745 else if (pBulletFontName
)
1746 *pBulletFontName
= sBulletFontName
;
1748 else if (rProp
.Name
== UNO_NAME_BULLET_CHAR
)
1751 rProp
.Value
>>= aChar
;
1752 if (aChar
.isEmpty())
1754 // If w:lvlText's value is null - set bullet char to zero
1755 aFormat
.SetBulletChar(u
'\0');
1759 sal_Int32 nIndexUtf16
= 0;
1760 sal_UCS4 cBullet
= aChar
.iterateCodePoints(&nIndexUtf16
);
1761 if (aChar
.getLength() == nIndexUtf16
)
1762 aFormat
.SetBulletChar(cBullet
);
1767 else if (rProp
.Name
== UNO_NAME_GRAPHIC
)
1769 uno::Reference
<graphic::XGraphic
> xGraphic
;
1770 if (rProp
.Value
>>= xGraphic
)
1774 const SvxBrushItem
* pOrigBrush
= aFormat
.GetBrush();
1776 pSetBrush
.reset(new SvxBrushItem(*pOrigBrush
));
1778 pSetBrush
.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA
, RES_BACKGROUND
));
1780 Graphic
aGraphic(xGraphic
);
1781 pSetBrush
->SetGraphic(aGraphic
);
1786 else if (rProp
.Name
== UNO_NAME_GRAPHIC_BITMAP
)
1788 uno::Reference
<awt::XBitmap
> xBitmap
;
1789 if (rProp
.Value
>>= xBitmap
)
1793 const SvxBrushItem
* pOrigBrush
= aFormat
.GetBrush();
1795 pSetBrush
.reset(new SvxBrushItem(*pOrigBrush
));
1797 pSetBrush
.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA
, RES_BACKGROUND
));
1800 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1801 Graphic
aGraphic(xGraphic
);
1802 pSetBrush
->SetGraphic(aGraphic
);
1807 else if (rProp
.Name
== UNO_NAME_GRAPHIC_SIZE
)
1810 pSetSize
.reset(new Size
);
1812 if (rProp
.Value
>>= size
)
1814 pSetSize
->setWidth(o3tl::toTwips(size
.Width
, o3tl::Length::mm100
));
1815 pSetSize
->setHeight(o3tl::toTwips(size
.Height
, o3tl::Length::mm100
));
1820 else if (rProp
.Name
== UNO_NAME_VERT_ORIENT
)
1824 if(aFormat
.GetGraphicOrientation())
1825 pSetVOrient
.reset(aFormat
.GetGraphicOrientation()->Clone());
1827 pSetVOrient
.reset(new SwFormatVertOrient
);
1829 pSetVOrient
->PutValue(rProp
.Value
, MID_VERTORIENT_ORIENT
);
1831 else if (rProp
.Name
== UNO_NAME_HEADING_STYLE_NAME
1832 && pDocShell
) // only on chapter numbering
1834 if (pHeadingStyleName
)
1837 rProp
.Value
>>= uTmp
;
1838 OUString sStyleName
;
1839 SwStyleNameMapper::FillUIName(uTmp
, sStyleName
, SwGetPoolIdFromName::TxtColl
);
1840 *pHeadingStyleName
= sStyleName
;
1843 else if (rProp
.Name
== UNO_NAME_BULLET_REL_SIZE
)
1845 // BulletRelSize - unsupported - only available in Impress
1847 else if (rProp
.Name
== UNO_NAME_BULLET_COLOR
)
1849 // BulletColor - ignored too
1851 else if (rProp
.Name
== UNO_NAME_GRAPHIC_URL
)
1854 if (rProp
.Value
>>= aURL
)
1858 const SvxBrushItem
* pOrigBrush
= aFormat
.GetBrush();
1860 pSetBrush
.reset(new SvxBrushItem(*pOrigBrush
));
1862 pSetBrush
.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA
, RES_BACKGROUND
));
1865 Graphic aGraphic
= vcl::graphic::loadFromURL(aURL
);
1866 if (!aGraphic
.IsNone())
1867 pSetBrush
->SetGraphic(aGraphic
);
1872 else if (rProp
.Name
== UNO_NAME_LIST_FORMAT
)
1875 rProp
.Value
>>= uTmp
;
1876 aFormat
.SetListFormat(uTmp
);
1880 // Invalid property name
1881 SAL_WARN("sw.uno", "Unknown/incorrect property " << rProp
.Name
<< ", failing");
1882 throw uno::RuntimeException("Unknown/incorrect property " + rProp
.Name
);
1885 if(!bWrongArg
&& (pSetBrush
|| pSetSize
|| pSetVOrient
))
1887 if(!pSetBrush
&& aFormat
.GetBrush())
1888 pSetBrush
.reset(new SvxBrushItem(*aFormat
.GetBrush()));
1892 if(!pSetVOrient
&& aFormat
.GetGraphicOrientation())
1893 pSetVOrient
.reset( new SwFormatVertOrient(*aFormat
.GetGraphicOrientation()) );
1897 pSetSize
.reset(new Size(aFormat
.GetGraphicSize()));
1898 if(!pSetSize
->Width() || !pSetSize
->Height())
1900 const Graphic
* pGraphic
= pSetBrush
->GetGraphic();
1902 *pSetSize
= ::GetGraphicSizeTwip(*pGraphic
, nullptr);
1905 sal_Int16 eOrient
= pSetVOrient
?
1906 pSetVOrient
->GetVertOrient() : text::VertOrientation::NONE
;
1907 aFormat
.SetGraphicBrush( pSetBrush
.get(), pSetSize
.get(), text::VertOrientation::NONE
== eOrient
? nullptr : &eOrient
);
1910 if ((!bCharStyleNameSet
|| rCharStyleName
.isEmpty())
1911 && aFormat
.GetNumberingType() == NumberingType::BITMAP
1912 && !aFormat
.GetCharFormat()
1913 && !SwXNumberingRules::isInvalidStyle(rCharStyleName
))
1916 SwStyleNameMapper::FillProgName(RES_POOLCHR_BULLET_LEVEL
, tmp
);
1917 rCharStyleName
= tmp
;
1921 throw lang::IllegalArgumentException();
1924 uno::Reference
< XPropertySetInfo
> SwXNumberingRules::getPropertySetInfo()
1926 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
1930 void SwXNumberingRules::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
1932 SolarMutexGuard aGuard
;
1933 std::unique_ptr
<SwNumRule
> pDocRule
;
1934 SwNumRule
* pCreatedRule
= nullptr;
1939 pDocRule
.reset(new SwNumRule(*m_pDocShell
->GetDoc()->GetOutlineNumRule()));
1941 else if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
1943 pCreatedRule
= m_pDoc
->FindNumRulePtr(m_sCreatedNumRuleName
);
1947 if(!m_pNumRule
&& !pDocRule
&& !pCreatedRule
)
1948 throw RuntimeException();
1950 if(rPropertyName
== UNO_NAME_IS_AUTOMATIC
)
1952 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
1954 pDocRule
? pDocRule
->SetAutoRule(bVal
) : m_pNumRule
->SetAutoRule(bVal
);
1956 else if(rPropertyName
== UNO_NAME_IS_CONTINUOUS_NUMBERING
)
1958 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
1959 pDocRule
? pDocRule
->SetContinusNum(bVal
) :
1960 pCreatedRule
? pCreatedRule
->SetContinusNum(bVal
) : m_pNumRule
->SetContinusNum(bVal
);
1962 else if(rPropertyName
== UNO_NAME_NAME
)
1964 throw IllegalArgumentException();
1966 else if(rPropertyName
== UNO_NAME_IS_ABSOLUTE_MARGINS
)
1968 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
1969 pDocRule
? pDocRule
->SetAbsSpaces(bVal
) :
1970 pCreatedRule
? pCreatedRule
->SetAbsSpaces(bVal
) : m_pNumRule
->SetAbsSpaces(bVal
);
1972 else if(rPropertyName
== UNO_NAME_NUMBERING_IS_OUTLINE
)
1974 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
1975 SwNumRuleType eNumRuleType
= bVal
? OUTLINE_RULE
: NUM_RULE
;
1976 pDocRule
? pDocRule
->SetRuleType(eNumRuleType
) :
1977 pCreatedRule
? pCreatedRule
->SetRuleType(eNumRuleType
) : m_pNumRule
->SetRuleType(eNumRuleType
);
1979 else if(rPropertyName
== UNO_NAME_DEFAULT_LIST_ID
)
1981 throw IllegalArgumentException();
1984 throw UnknownPropertyException(rPropertyName
);
1988 assert(m_pDocShell
);
1989 m_pDocShell
->GetDoc()->SetOutlineNumRule(*pDocRule
);
1992 else if(pCreatedRule
)
1994 pCreatedRule
->Validate(*m_pDoc
);
1998 Any
SwXNumberingRules::getPropertyValue( const OUString
& rPropertyName
)
2001 const SwNumRule
* pRule
= m_pNumRule
;
2002 if(!pRule
&& m_pDocShell
)
2003 pRule
= m_pDocShell
->GetDoc()->GetOutlineNumRule();
2004 else if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
2005 pRule
= m_pDoc
->FindNumRulePtr( m_sCreatedNumRuleName
);
2007 throw RuntimeException();
2009 if(rPropertyName
== UNO_NAME_IS_AUTOMATIC
)
2011 aRet
<<= pRule
->IsAutoRule();
2013 else if(rPropertyName
== UNO_NAME_IS_CONTINUOUS_NUMBERING
)
2015 aRet
<<= pRule
->IsContinusNum();
2017 else if(rPropertyName
== UNO_NAME_NAME
)
2018 aRet
<<= pRule
->GetName();
2019 else if(rPropertyName
== UNO_NAME_IS_ABSOLUTE_MARGINS
)
2021 aRet
<<= pRule
->IsAbsSpaces();
2023 else if(rPropertyName
== UNO_NAME_NUMBERING_IS_OUTLINE
)
2025 aRet
<<= pRule
->IsOutlineRule();
2027 else if(rPropertyName
== UNO_NAME_DEFAULT_LIST_ID
)
2029 OSL_ENSURE( !pRule
->GetDefaultListId().isEmpty(),
2030 "<SwXNumberingRules::getPropertyValue(..)> - no default list id found. Serious defect." );
2031 aRet
<<= pRule
->GetDefaultListId();
2034 throw UnknownPropertyException(rPropertyName
);
2038 void SwXNumberingRules::addPropertyChangeListener(
2039 const OUString
& /*rPropertyName*/, const uno::Reference
< XPropertyChangeListener
>& /*xListener*/ )
2043 void SwXNumberingRules::removePropertyChangeListener(
2044 const OUString
& /*rPropertyName*/, const uno::Reference
< XPropertyChangeListener
>& /*xListener*/ )
2048 void SwXNumberingRules::addVetoableChangeListener(
2049 const OUString
& /*rPropertyName*/, const uno::Reference
< XVetoableChangeListener
>& /*xListener*/ )
2053 void SwXNumberingRules::removeVetoableChangeListener(
2054 const OUString
& /*rPropertyName*/, const uno::Reference
< XVetoableChangeListener
>& /*xListener*/ )
2058 OUString
SwXNumberingRules::getName()
2063 SwStyleNameMapper::FillProgName(m_pNumRule
->GetName(), aString
, SwGetPoolIdFromName::NumRule
);
2066 // consider chapter numbering <SwXNumberingRules>
2070 SwStyleNameMapper::FillProgName( m_pDocShell
->GetDoc()->GetOutlineNumRule()->GetName(),
2071 aString
, SwGetPoolIdFromName::NumRule
);
2074 return m_sCreatedNumRuleName
;
2077 void SwXNumberingRules::setName(const OUString
& /*rName*/)
2079 RuntimeException aExcept
;
2080 aExcept
.Message
= "readonly";
2084 void SwXNumberingRules::Impl::Notify(const SfxHint
& rHint
)
2086 if(rHint
.GetId() == SfxHintId::Dying
)
2088 if(m_rParent
.m_bOwnNumRuleCreated
)
2089 delete m_rParent
.m_pNumRule
;
2090 m_rParent
.m_pNumRule
= nullptr;
2091 m_rParent
.m_pDoc
= nullptr;
2095 OUString
SwXChapterNumbering::getImplementationName()
2097 return "SwXChapterNumbering";
2100 sal_Bool
SwXChapterNumbering::supportsService(const OUString
& rServiceName
)
2102 return cppu::supportsService(this, rServiceName
);
2105 Sequence
< OUString
> SwXChapterNumbering::getSupportedServiceNames()
2107 return { "com.sun.star.text.ChapterNumbering", "com.sun.star.text.NumberingRules" };
2110 SwXChapterNumbering::SwXChapterNumbering(SwDocShell
& rDocSh
) :
2111 SwXNumberingRules(rDocSh
)
2115 SwXChapterNumbering::~SwXChapterNumbering()
2119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */