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 <svx/svxids.hrc>
21 #include <editeng/memberids.h>
22 #include <swtypes.hxx>
25 #include <hintids.hxx>
26 #include <strings.hrc>
27 #include <poolfmt.hxx>
30 #include <unostyle.hxx>
31 #include <unosett.hxx>
32 #include <unoprnms.hxx>
33 #include <ftninfo.hxx>
35 #include <pagedesc.hxx>
36 #include <IDocumentStylePoolAccess.hxx>
37 #include <charfmt.hxx>
38 #include <lineinfo.hxx>
41 #include <docstyle.hxx>
42 #include <fmtclds.hxx>
43 #include <editeng/brushitem.hxx>
44 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
45 #include <com/sun/star/text/XFootnotesSettingsSupplier.hpp>
46 #include <com/sun/star/text/XFootnote.hpp>
47 #include <com/sun/star/text/XFootnotesSupplier.hpp>
48 #include <com/sun/star/text/XEndnotesSupplier.hpp>
49 #include <com/sun/star/text/XEndnotesSettingsSupplier.hpp>
50 #include <com/sun/star/text/FootnoteNumbering.hpp>
51 #include <com/sun/star/text/HoriOrientation.hpp>
52 #include <com/sun/star/style/LineNumberPosition.hpp>
53 #include <com/sun/star/awt/FontDescriptor.hpp>
54 #include <com/sun/star/awt/XBitmap.hpp>
55 #include <com/sun/star/graphic/XGraphic.hpp>
56 #include <com/sun/star/beans/PropertyAttribute.hpp>
57 #include <com/sun/star/style/VerticalAlignment.hpp>
58 #include <o3tl/any.hxx>
59 #include <o3tl/enumarray.hxx>
60 #include <vcl/font.hxx>
61 #include <editeng/flstitem.hxx>
62 #include <vcl/metric.hxx>
63 #include <vcl/graph.hxx>
64 #include <vcl/GraphicLoader.hxx>
65 #include <sfx2/docfile.hxx>
66 #include <svtools/ctrltool.hxx>
67 #include <vcl/svapp.hxx>
68 #include <editeng/unofdesc.hxx>
69 #include <fmtornt.hxx>
70 #include <SwStyleNameMapper.hxx>
71 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
72 #include <com/sun/star/text/LabelFollow.hpp>
73 #include <numrule.hxx>
74 #include <comphelper/servicehelper.hxx>
75 #include <comphelper/sequence.hxx>
76 #include <cppuhelper/supportsservice.hxx>
77 #include <comphelper/propertyvalue.hxx>
78 #include <svl/itemprop.hxx>
79 #include <svl/listener.hxx>
81 #include <sal/log.hxx>
84 using namespace ::com::sun::star
;
85 using namespace ::com::sun::star::uno
;
86 using namespace ::com::sun::star::lang
;
87 using namespace ::com::sun::star::beans
;
88 using namespace ::com::sun::star::text
;
89 using namespace ::com::sun::star::style
;
94 SvtBroadcaster
& GetPageDescNotifier(SwDoc
* pDoc
)
96 return pDoc
->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD
)->GetNotifier();
99 // Constants for the css::text::ColumnSeparatorStyle
100 #define API_COL_LINE_NONE 0
101 #define API_COL_LINE_SOLID 1
102 #define API_COL_LINE_DOTTED 2
103 #define API_COL_LINE_DASHED 3
107 #define WID_NUMBERING_TYPE 2
108 #define WID_START_AT 3
109 #define WID_FOOTNOTE_COUNTING 4
110 #define WID_PARAGRAPH_STYLE 5
111 #define WID_PAGE_STYLE 6
112 #define WID_CHARACTER_STYLE 7
113 #define WID_POSITION_END_OF_DOC 8
114 #define WID_END_NOTICE 9
115 #define WID_BEGIN_NOTICE 10
116 #define WID_ANCHOR_CHARACTER_STYLE 11
118 static const SfxItemPropertySet
* GetFootnoteSet()
120 static const SfxItemPropertyMapEntry aFootnoteMap_Impl
[] =
122 { OUString(UNO_NAME_ANCHOR_CHAR_STYLE_NAME
),WID_ANCHOR_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
123 { OUString(UNO_NAME_BEGIN_NOTICE
), WID_BEGIN_NOTICE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
124 { OUString(UNO_NAME_CHAR_STYLE_NAME
), WID_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
125 { OUString(UNO_NAME_END_NOTICE
), WID_END_NOTICE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
126 { OUString(UNO_NAME_FOOTNOTE_COUNTING
), WID_FOOTNOTE_COUNTING
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
127 { OUString(UNO_NAME_NUMBERING_TYPE
), WID_NUMBERING_TYPE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
128 { OUString(UNO_NAME_PAGE_STYLE_NAME
), WID_PAGE_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
129 { OUString(UNO_NAME_PARA_STYLE_NAME
), WID_PARAGRAPH_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
130 { OUString(UNO_NAME_POSITION_END_OF_DOC
), WID_POSITION_END_OF_DOC
,cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
131 { OUString(UNO_NAME_PREFIX
), WID_PREFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
132 { OUString(UNO_NAME_START_AT
), WID_START_AT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
133 { OUString(UNO_NAME_SUFFIX
), WID_SUFFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
134 { OUString(), 0, css::uno::Type(), 0, 0 }
136 static const SfxItemPropertySet
aFootnoteSet_Impl(aFootnoteMap_Impl
);
137 return &aFootnoteSet_Impl
;
140 static const SfxItemPropertySet
* GetEndnoteSet()
142 static const SfxItemPropertyMapEntry aEndnoteMap_Impl
[] =
144 { OUString(UNO_NAME_ANCHOR_CHAR_STYLE_NAME
),WID_ANCHOR_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
145 { OUString(UNO_NAME_CHAR_STYLE_NAME
), WID_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
146 { OUString(UNO_NAME_NUMBERING_TYPE
), WID_NUMBERING_TYPE
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
147 { OUString(UNO_NAME_PAGE_STYLE_NAME
), WID_PAGE_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
148 { OUString(UNO_NAME_PARA_STYLE_NAME
), WID_PARAGRAPH_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
149 { OUString(UNO_NAME_PREFIX
), WID_PREFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
150 { OUString(UNO_NAME_START_AT
), WID_START_AT
, ::cppu::UnoType
<sal_Int16
>::get(), PROPERTY_NONE
, 0},
151 { OUString(UNO_NAME_SUFFIX
), WID_SUFFIX
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
152 { OUString(), 0, css::uno::Type(), 0, 0 }
154 static const SfxItemPropertySet
aEndnoteSet_Impl(aEndnoteMap_Impl
);
155 return &aEndnoteSet_Impl
;
158 static const SfxItemPropertySet
* GetNumberingRulesSet()
160 static const SfxItemPropertyMapEntry aNumberingRulesMap_Impl
[] =
162 { OUString(UNO_NAME_IS_ABSOLUTE_MARGINS
), WID_IS_ABS_MARGINS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
163 { OUString(UNO_NAME_IS_AUTOMATIC
), WID_IS_AUTOMATIC
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
164 { OUString(UNO_NAME_IS_CONTINUOUS_NUMBERING
), WID_CONTINUOUS
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
165 { OUString(UNO_NAME_NAME
), WID_RULE_NAME
, ::cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0},
166 { OUString(UNO_NAME_NUMBERING_IS_OUTLINE
), WID_IS_OUTLINE
, cppu::UnoType
<bool>::get(), PROPERTY_NONE
, 0},
167 { OUString(UNO_NAME_DEFAULT_LIST_ID
), WID_DEFAULT_LIST_ID
, ::cppu::UnoType
<OUString
>::get(), PropertyAttribute::READONLY
, 0},
168 { OUString(), 0, css::uno::Type(), 0, 0 }
170 static const SfxItemPropertySet
aNumberingRulesSet_Impl( aNumberingRulesMap_Impl
);
171 return &aNumberingRulesSet_Impl
;
175 #define WID_SEPARATOR_INTERVAL 1
176 #define WID_NUMBERING_TYPE 2
177 #define WID_NUMBER_POSITION 3
178 #define WID_DISTANCE 4
179 #define WID_INTERVAL 5
180 #define WID_SEPARATOR_TEXT 6
181 #define WID_COUNT_EMPTY_LINES 8
182 #define WID_COUNT_LINES_IN_FRAMES 9
183 #define WID_RESTART_AT_EACH_PAGE 10
185 static const SfxItemPropertySet
* GetLineNumberingSet()
187 static const SfxItemPropertyMapEntry aLineNumberingMap_Impl
[] =
189 { OUString(UNO_NAME_CHAR_STYLE_NAME
), WID_CHARACTER_STYLE
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
190 { OUString(UNO_NAME_COUNT_EMPTY_LINES
), WID_COUNT_EMPTY_LINES
, cppu::UnoType
<bool>::get(),PROPERTY_NONE
, 0},
191 { OUString(UNO_NAME_COUNT_LINES_IN_FRAMES
), WID_COUNT_LINES_IN_FRAMES
, cppu::UnoType
<bool>::get(),PROPERTY_NONE
, 0},
192 { OUString(UNO_NAME_DISTANCE
), WID_DISTANCE
, ::cppu::UnoType
<sal_Int32
>::get(),PROPERTY_NONE
, 0},
193 { OUString(UNO_NAME_IS_ON
), WID_NUM_ON
, cppu::UnoType
<bool>::get() , PROPERTY_NONE
, 0},
194 { OUString(UNO_NAME_INTERVAL
), WID_INTERVAL
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
195 { OUString(UNO_NAME_SEPARATOR_TEXT
), WID_SEPARATOR_TEXT
, ::cppu::UnoType
<OUString
>::get(), PROPERTY_NONE
, 0},
196 { OUString(UNO_NAME_NUMBER_POSITION
), WID_NUMBER_POSITION
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
197 { OUString(UNO_NAME_NUMBERING_TYPE
), WID_NUMBERING_TYPE
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
198 { OUString(UNO_NAME_RESTART_AT_EACH_PAGE
), WID_RESTART_AT_EACH_PAGE
, cppu::UnoType
<bool>::get() , PROPERTY_NONE
, 0},
199 { OUString(UNO_NAME_SEPARATOR_INTERVAL
), WID_SEPARATOR_INTERVAL
, ::cppu::UnoType
<sal_Int16
>::get(),PROPERTY_NONE
, 0},
200 { OUString(), 0, css::uno::Type(), 0, 0 }
202 static const SfxItemPropertySet
aLineNumberingSet_Impl(aLineNumberingMap_Impl
);
203 return &aLineNumberingSet_Impl
;
206 static SwCharFormat
* lcl_getCharFormat(SwDoc
* pDoc
, const uno::Any
& aValue
)
208 SwCharFormat
* pRet
= nullptr;
211 OUString sCharFormat
;
212 SwStyleNameMapper::FillUIName(uTmp
, sCharFormat
, SwGetPoolIdFromName::ChrFmt
);
213 if (sCharFormat
!= SwResId(STR_POOLCOLL_STANDARD
))
215 pRet
= pDoc
->FindCharFormatByName( sCharFormat
);
219 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName(sCharFormat
, SwGetPoolIdFromName::ChrFmt
);
221 pRet
= pDoc
->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId
);
226 static SwTextFormatColl
* lcl_GetParaStyle(SwDoc
* pDoc
, const uno::Any
& aValue
)
231 SwStyleNameMapper::FillUIName(uTmp
, sParaStyle
, SwGetPoolIdFromName::TxtColl
);
232 SwTextFormatColl
* pRet
= pDoc
->FindTextFormatCollByName( sParaStyle
);
235 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName( sParaStyle
, SwGetPoolIdFromName::TxtColl
);
236 if( USHRT_MAX
!= nId
)
237 pRet
= pDoc
->getIDocumentStylePoolAccess().GetTextCollFromPool( nId
);
242 static SwPageDesc
* lcl_GetPageDesc(SwDoc
* pDoc
, const uno::Any
& aValue
)
247 SwStyleNameMapper::FillUIName(uTmp
, sPageDesc
, SwGetPoolIdFromName::PageDesc
);
248 SwPageDesc
* pRet
= pDoc
->FindPageDesc( sPageDesc
);
251 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName(sPageDesc
, SwGetPoolIdFromName::PageDesc
);
253 pRet
= pDoc
->getIDocumentStylePoolAccess().GetPageDescFromPool( nId
);
259 const o3tl::enumarray
<SvxAdjust
, unsigned short> aSvxToUnoAdjust
261 text::HoriOrientation::LEFT
, //3
262 text::HoriOrientation::RIGHT
, //1
264 text::HoriOrientation::CENTER
, //2
269 const unsigned short aUnoToSvxAdjust
[] =
272 static_cast<unsigned short>(SvxAdjust::Right
), // 1
273 static_cast<unsigned short>(SvxAdjust::Center
), // 3
274 static_cast<unsigned short>(SvxAdjust::Left
), // 0
279 OUString
SwXFootnoteProperties::getImplementationName()
281 return "SwXFootnoteProperties";
284 sal_Bool
SwXFootnoteProperties::supportsService(const OUString
& rServiceName
)
286 return cppu::supportsService(this, rServiceName
);
289 Sequence
< OUString
> SwXFootnoteProperties::getSupportedServiceNames()
291 Sequence
<OUString
> aRet
{ "com.sun.star.text.FootnoteSettings" };
295 SwXFootnoteProperties::SwXFootnoteProperties(SwDoc
* pDc
) :
297 m_pPropertySet(GetFootnoteSet())
301 SwXFootnoteProperties::~SwXFootnoteProperties()
306 uno::Reference
< beans::XPropertySetInfo
> SwXFootnoteProperties::getPropertySetInfo()
308 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
312 void SwXFootnoteProperties::setPropertyValue(const OUString
& rPropertyName
, const uno::Any
& aValue
)
314 SolarMutexGuard aGuard
;
316 throw uno::RuntimeException();
318 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
320 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
322 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
323 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
324 SwFootnoteInfo
aFootnoteInfo(m_pDoc
->GetFootnoteInfo());
331 aFootnoteInfo
.SetPrefix(uTmp
);
338 aFootnoteInfo
.SetSuffix(uTmp
);
341 case WID_NUMBERING_TYPE
:
346 (nTmp
<= SVX_NUM_ARABIC
||
347 nTmp
> SVX_NUM_BITMAP
)))
348 throw lang::IllegalArgumentException();
350 aFootnoteInfo
.aFormat
.SetNumberingType(static_cast<SvxNumType
>(nTmp
));
358 aFootnoteInfo
.nFootnoteOffset
= nTmp
;
361 case WID_FOOTNOTE_COUNTING
:
367 case FootnoteNumbering::PER_PAGE
:
368 aFootnoteInfo
.eNum
= FTNNUM_PAGE
;
370 case FootnoteNumbering::PER_CHAPTER
:
371 aFootnoteInfo
.eNum
= FTNNUM_CHAPTER
;
373 case FootnoteNumbering::PER_DOCUMENT
:
374 aFootnoteInfo
.eNum
= FTNNUM_DOC
;
379 case WID_PARAGRAPH_STYLE
:
381 SwTextFormatColl
* pColl
= lcl_GetParaStyle(m_pDoc
, aValue
);
383 aFootnoteInfo
.SetFootnoteTextColl(*pColl
);
388 SwPageDesc
* pDesc
= lcl_GetPageDesc(m_pDoc
, aValue
);
390 aFootnoteInfo
.ChgPageDesc( pDesc
);
393 case WID_ANCHOR_CHARACTER_STYLE
:
394 case WID_CHARACTER_STYLE
:
396 SwCharFormat
* pFormat
= lcl_getCharFormat(m_pDoc
, aValue
);
399 if(pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
)
400 aFootnoteInfo
.SetAnchorCharFormat(pFormat
);
402 aFootnoteInfo
.SetCharFormat(pFormat
);
406 case WID_POSITION_END_OF_DOC
:
408 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
409 aFootnoteInfo
.ePos
= bVal
? FTNPOS_CHAPTER
: FTNPOS_PAGE
;
416 aFootnoteInfo
.aQuoVadis
= uTmp
;
419 case WID_BEGIN_NOTICE
:
423 aFootnoteInfo
.aErgoSum
= uTmp
;
427 m_pDoc
->SetFootnoteInfo(aFootnoteInfo
);
432 uno::Any
SwXFootnoteProperties::getPropertyValue(const OUString
& rPropertyName
)
434 SolarMutexGuard aGuard
;
437 throw uno::RuntimeException();
439 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
441 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
443 const SwFootnoteInfo
& rFootnoteInfo
= m_pDoc
->GetFootnoteInfo();
448 aRet
<<= rFootnoteInfo
.GetPrefix();
453 aRet
<<= rFootnoteInfo
.GetSuffix();
456 case WID_NUMBERING_TYPE
:
458 aRet
<<= static_cast<sal_Int16
>(rFootnoteInfo
.aFormat
.GetNumberingType());
462 aRet
<<= static_cast<sal_Int16
>(rFootnoteInfo
.nFootnoteOffset
);
464 case WID_FOOTNOTE_COUNTING
:
467 switch(rFootnoteInfo
.eNum
)
470 nRet
= FootnoteNumbering::PER_PAGE
;
473 nRet
= FootnoteNumbering::PER_CHAPTER
;
476 nRet
= FootnoteNumbering::PER_DOCUMENT
;
482 case WID_PARAGRAPH_STYLE
:
484 SwTextFormatColl
* pColl
= rFootnoteInfo
.GetFootnoteTextColl();
487 aString
= pColl
->GetName();
488 SwStyleNameMapper::FillProgName(aString
, aString
, SwGetPoolIdFromName::TxtColl
);
492 case WID_PAGE_STYLE
:
495 if( rFootnoteInfo
.KnowsPageDesc() )
497 SwStyleNameMapper::FillProgName(
498 rFootnoteInfo
.GetPageDesc( *m_pDoc
)->GetName(),
500 SwGetPoolIdFromName::PageDesc
);
505 case WID_ANCHOR_CHARACTER_STYLE
:
506 case WID_CHARACTER_STYLE
:
509 const SwCharFormat
* pCharFormat
= rFootnoteInfo
.GetCurrentCharFormat(pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
);
512 SwStyleNameMapper::FillProgName(
513 pCharFormat
->GetName(),
515 SwGetPoolIdFromName::ChrFmt
);
520 case WID_POSITION_END_OF_DOC
:
521 aRet
<<= FTNPOS_CHAPTER
== rFootnoteInfo
.ePos
;
523 case WID_END_NOTICE
:
524 aRet
<<= rFootnoteInfo
.aQuoVadis
;
526 case WID_BEGIN_NOTICE
:
527 aRet
<<= rFootnoteInfo
.aErgoSum
;
535 void SwXFootnoteProperties::addPropertyChangeListener(
536 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
538 OSL_FAIL("not implemented");
541 void SwXFootnoteProperties::removePropertyChangeListener(
542 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
544 OSL_FAIL("not implemented");
547 void SwXFootnoteProperties::addVetoableChangeListener(
548 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
550 OSL_FAIL("not implemented");
553 void SwXFootnoteProperties::removeVetoableChangeListener(
554 const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
556 OSL_FAIL("not implemented");
559 OUString
SwXEndnoteProperties::getImplementationName()
561 return "SwXEndnoteProperties";
564 sal_Bool
SwXEndnoteProperties::supportsService(const OUString
& rServiceName
)
566 return cppu::supportsService(this, rServiceName
);
569 Sequence
< OUString
> SwXEndnoteProperties::getSupportedServiceNames()
571 Sequence
<OUString
> aRet
{ "com.sun.star.text.FootnoteSettings" };
575 SwXEndnoteProperties::SwXEndnoteProperties(SwDoc
* pDc
) :
577 m_pPropertySet(GetEndnoteSet())
581 SwXEndnoteProperties::~SwXEndnoteProperties()
585 uno::Reference
< beans::XPropertySetInfo
> SwXEndnoteProperties::getPropertySetInfo()
587 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
591 void SwXEndnoteProperties::setPropertyValue(const OUString
& rPropertyName
, const uno::Any
& aValue
)
593 SolarMutexGuard aGuard
;
596 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
598 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
600 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
601 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
602 SwEndNoteInfo
aEndInfo(m_pDoc
->GetEndNoteInfo());
609 aEndInfo
.SetPrefix(uTmp
);
616 aEndInfo
.SetSuffix(uTmp
);
619 case WID_NUMBERING_TYPE
:
623 aEndInfo
.aFormat
.SetNumberingType(static_cast<SvxNumType
>(nTmp
));
630 aEndInfo
.nFootnoteOffset
= nTmp
;
633 case WID_PARAGRAPH_STYLE
:
635 SwTextFormatColl
* pColl
= lcl_GetParaStyle(m_pDoc
, aValue
);
637 aEndInfo
.SetFootnoteTextColl(*pColl
);
640 case WID_PAGE_STYLE
:
642 SwPageDesc
* pDesc
= lcl_GetPageDesc(m_pDoc
, aValue
);
644 aEndInfo
.ChgPageDesc( pDesc
);
647 case WID_ANCHOR_CHARACTER_STYLE
:
648 case WID_CHARACTER_STYLE
:
650 SwCharFormat
* pFormat
= lcl_getCharFormat(m_pDoc
, aValue
);
653 if(pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
)
654 aEndInfo
.SetAnchorCharFormat(pFormat
);
656 aEndInfo
.SetCharFormat(pFormat
);
661 m_pDoc
->SetEndNoteInfo(aEndInfo
);
666 uno::Any
SwXEndnoteProperties::getPropertyValue(const OUString
& rPropertyName
)
668 SolarMutexGuard aGuard
;
672 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
674 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
676 const SwEndNoteInfo
& rEndInfo
= m_pDoc
->GetEndNoteInfo();
680 aRet
<<= rEndInfo
.GetPrefix();
683 aRet
<<= rEndInfo
.GetSuffix();
685 case WID_NUMBERING_TYPE
:
686 aRet
<<= static_cast<sal_Int16
>(rEndInfo
.aFormat
.GetNumberingType());
689 aRet
<<= static_cast<sal_Int16
>(rEndInfo
.nFootnoteOffset
);
691 case WID_PARAGRAPH_STYLE
:
693 SwTextFormatColl
* pColl
= rEndInfo
.GetFootnoteTextColl();
696 aString
= pColl
->GetName();
697 SwStyleNameMapper::FillProgName(
700 SwGetPoolIdFromName::TxtColl
);
705 case WID_PAGE_STYLE
:
708 if( rEndInfo
.KnowsPageDesc() )
710 SwStyleNameMapper::FillProgName(
711 rEndInfo
.GetPageDesc( *m_pDoc
)->GetName(),
713 SwGetPoolIdFromName::PageDesc
);
718 case WID_ANCHOR_CHARACTER_STYLE
:
719 case WID_CHARACTER_STYLE
:
722 const SwCharFormat
* pCharFormat
= rEndInfo
.GetCurrentCharFormat( pEntry
->nWID
== WID_ANCHOR_CHARACTER_STYLE
);
725 SwStyleNameMapper::FillProgName(
726 pCharFormat
->GetName(),
728 SwGetPoolIdFromName::ChrFmt
);
739 void SwXEndnoteProperties::addPropertyChangeListener(
740 const OUString
& /*PropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
742 OSL_FAIL("not implemented");
745 void SwXEndnoteProperties::removePropertyChangeListener(const OUString
& /*PropertyName*/,
746 const uno:: Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
748 OSL_FAIL("not implemented");
751 void SwXEndnoteProperties::addVetoableChangeListener(const OUString
& /*PropertyName*/,
752 const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
754 OSL_FAIL("not implemented");
757 void SwXEndnoteProperties::removeVetoableChangeListener(const OUString
& /*PropertyName*/, const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
759 OSL_FAIL("not implemented");
762 OUString
SwXLineNumberingProperties::getImplementationName()
764 return "SwXLineNumberingProperties";
767 sal_Bool
SwXLineNumberingProperties::supportsService(const OUString
& rServiceName
)
769 return cppu::supportsService(this, rServiceName
);
772 Sequence
< OUString
> SwXLineNumberingProperties::getSupportedServiceNames()
774 Sequence
<OUString
> aRet
{ "com.sun.star.text.LineNumberingProperties" };
778 SwXLineNumberingProperties::SwXLineNumberingProperties(SwDoc
* pDc
) :
780 m_pPropertySet(GetLineNumberingSet())
784 SwXLineNumberingProperties::~SwXLineNumberingProperties()
788 uno::Reference
< beans::XPropertySetInfo
> SwXLineNumberingProperties::getPropertySetInfo()
790 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
794 void SwXLineNumberingProperties::setPropertyValue(
795 const OUString
& rPropertyName
, const Any
& aValue
)
797 SolarMutexGuard aGuard
;
799 throw uno::RuntimeException();
801 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
803 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
805 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
806 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
807 SwLineNumberInfo
aFontMetric(m_pDoc
->GetLineNumberInfo());
812 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
813 aFontMetric
.SetPaintLineNumbers(bVal
);
816 case WID_CHARACTER_STYLE
:
818 SwCharFormat
* pFormat
= lcl_getCharFormat(m_pDoc
, aValue
);
820 aFontMetric
.SetCharFormat(pFormat
);
823 case WID_NUMBERING_TYPE
:
825 SvxNumberType
aNumType(aFontMetric
.GetNumType());
828 aNumType
.SetNumberingType(static_cast<SvxNumType
>(nTmp
));
829 aFontMetric
.SetNumType(aNumType
);
832 case WID_NUMBER_POSITION
:
838 case style::LineNumberPosition::LEFT
:
839 aFontMetric
.SetPos(LINENUMBER_POS_LEFT
);
841 case style::LineNumberPosition::RIGHT
:
842 aFontMetric
.SetPos(LINENUMBER_POS_RIGHT
);
844 case style::LineNumberPosition::INSIDE
:
845 aFontMetric
.SetPos(LINENUMBER_POS_INSIDE
);
847 case style::LineNumberPosition::OUTSIDE
:
848 aFontMetric
.SetPos(LINENUMBER_POS_OUTSIDE
);
857 sal_Int32 nTmp
= convertMm100ToTwip(nVal
);
858 if (nTmp
> SAL_MAX_UINT16
)
859 nTmp
= SAL_MAX_UINT16
;
860 aFontMetric
.SetPosFromLeft( static_cast< sal_uInt16
>(nTmp
) );
868 aFontMetric
.SetCountBy(nTmp
);
871 case WID_SEPARATOR_TEXT
:
875 aFontMetric
.SetDivider(uTmp
);
878 case WID_SEPARATOR_INTERVAL
:
883 aFontMetric
.SetDividerCountBy(nTmp
);
886 case WID_COUNT_EMPTY_LINES
:
888 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
889 aFontMetric
.SetCountBlankLines(bVal
);
892 case WID_COUNT_LINES_IN_FRAMES
:
894 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
895 aFontMetric
.SetCountInFlys(bVal
);
898 case WID_RESTART_AT_EACH_PAGE
:
900 bool bVal
= *o3tl::doAccess
<bool>(aValue
);
901 aFontMetric
.SetRestartEachPage(bVal
);
905 m_pDoc
->SetLineNumberInfo(aFontMetric
);
908 Any
SwXLineNumberingProperties::getPropertyValue(const OUString
& rPropertyName
)
910 SolarMutexGuard aGuard
;
913 throw uno::RuntimeException();
915 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropertySet
->getPropertyMap().getByName( rPropertyName
);
917 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
919 const SwLineNumberInfo
& rInfo
= m_pDoc
->GetLineNumberInfo();
923 aRet
<<= rInfo
.IsPaintLineNumbers();
925 case WID_CHARACTER_STYLE
:
928 // return empty string if no char format is set
929 // otherwise it would be created here
930 if(rInfo
.HasCharFormat())
932 SwStyleNameMapper::FillProgName(
933 rInfo
.GetCharFormat(m_pDoc
->getIDocumentStylePoolAccess())->GetName(),
935 SwGetPoolIdFromName::ChrFmt
);
940 case WID_NUMBERING_TYPE
:
941 aRet
<<= static_cast<sal_Int16
>(rInfo
.GetNumType().GetNumberingType());
943 case WID_NUMBER_POSITION
:
946 switch(rInfo
.GetPos())
948 case LINENUMBER_POS_LEFT
:
949 nRet
= style::LineNumberPosition::LEFT
;
951 case LINENUMBER_POS_RIGHT
:
952 nRet
= style::LineNumberPosition::RIGHT
;
954 case LINENUMBER_POS_INSIDE
:
955 nRet
= style::LineNumberPosition::INSIDE
;
957 case LINENUMBER_POS_OUTSIDE
:
958 nRet
= style::LineNumberPosition::OUTSIDE
;
966 sal_uInt32 nPos
= rInfo
.GetPosFromLeft();
967 if(USHRT_MAX
== nPos
)
969 aRet
<<= static_cast < sal_Int32
>(convertTwipToMm100(nPos
));
973 aRet
<<= static_cast<sal_Int16
>(rInfo
.GetCountBy());
975 case WID_SEPARATOR_TEXT
:
976 aRet
<<= rInfo
.GetDivider();
978 case WID_SEPARATOR_INTERVAL
:
979 aRet
<<= static_cast<sal_Int16
>(rInfo
.GetDividerCountBy());
981 case WID_COUNT_EMPTY_LINES
:
982 aRet
<<= rInfo
.IsCountBlankLines();
984 case WID_COUNT_LINES_IN_FRAMES
:
985 aRet
<<= rInfo
.IsCountInFlys();
987 case WID_RESTART_AT_EACH_PAGE
:
988 aRet
<<= rInfo
.IsRestartEachPage();
994 void SwXLineNumberingProperties::addPropertyChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
996 OSL_FAIL("not implemented");
999 void SwXLineNumberingProperties::removePropertyChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
1001 OSL_FAIL("not implemented");
1004 void SwXLineNumberingProperties::addVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
1006 OSL_FAIL("not implemented");
1009 void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno:: Reference
< beans::XVetoableChangeListener
> & /*xListener*/)
1011 OSL_FAIL("not implemented");
1014 static const char aInvalidStyle
[] = "__XXX___invalid";
1016 class SwXNumberingRules::Impl
1017 : public SvtListener
1019 SwXNumberingRules
& m_rParent
;
1020 virtual void Notify(const SfxHint
&) override
;
1022 explicit Impl(SwXNumberingRules
& rParent
) : m_rParent(rParent
) {}
1025 bool SwXNumberingRules::isInvalidStyle(const OUString
&rName
)
1027 return rName
== aInvalidStyle
;
1032 class theSwXNumberingRulesUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSwXNumberingRulesUnoTunnelId
> {};
1035 const uno::Sequence
< sal_Int8
> & SwXNumberingRules::getUnoTunnelId()
1037 return theSwXNumberingRulesUnoTunnelId::get().getSeq();
1040 // return implementation specific data
1041 sal_Int64
SwXNumberingRules::getSomething( const uno::Sequence
< sal_Int8
> & rId
)
1043 if( isUnoTunnelId
<SwXNumberingRules
>(rId
) )
1045 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
1050 OUString
SwXNumberingRules::getImplementationName()
1052 return "SwXNumberingRules";
1055 sal_Bool
SwXNumberingRules::supportsService(const OUString
& rServiceName
)
1057 return cppu::supportsService(this, rServiceName
);
1060 Sequence
< OUString
> SwXNumberingRules::getSupportedServiceNames()
1062 Sequence
<OUString
> aRet
{ "com.sun.star.text.NumberingRules" };
1066 SwXNumberingRules::SwXNumberingRules(const SwNumRule
& rRule
, SwDoc
* doc
) :
1067 m_pImpl(new SwXNumberingRules::Impl(*this)),
1069 m_pDocShell(nullptr),
1070 m_pNumRule(new SwNumRule(rRule
)),
1071 m_pPropertySet(GetNumberingRulesSet()),
1072 m_bOwnNumRuleCreated(true)
1074 // first organize the document - it is dependent on the set character formats
1075 // if no format is set, it should work as well
1076 for( sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
1078 SwNumFormat
rFormat(m_pNumRule
->Get(i
));
1079 SwCharFormat
* pCharFormat
= rFormat
.GetCharFormat();
1082 m_pDoc
= pCharFormat
->GetDoc();
1087 m_pImpl
->StartListening(GetPageDescNotifier(m_pDoc
));
1088 for(sal_uInt16 i
= 0; i
< MAXLEVEL
; ++i
)
1090 m_sNewCharStyleNames
[i
] = aInvalidStyle
;
1091 m_sNewBulletFontNames
[i
] = aInvalidStyle
;
1095 SwXNumberingRules::SwXNumberingRules(SwDocShell
& rDocSh
) :
1096 m_pImpl(new SwXNumberingRules::Impl(*this)),
1098 m_pDocShell(&rDocSh
),
1099 m_pNumRule(nullptr),
1100 m_pPropertySet(GetNumberingRulesSet()),
1101 m_bOwnNumRuleCreated(false)
1103 m_pImpl
->StartListening(GetPageDescNotifier(m_pDocShell
->GetDoc()));
1106 SwXNumberingRules::SwXNumberingRules(SwDoc
& rDoc
) :
1107 m_pImpl(new SwXNumberingRules::Impl(*this)),
1109 m_pDocShell(nullptr),
1110 m_pNumRule(nullptr),
1111 m_pPropertySet(GetNumberingRulesSet()),
1112 m_bOwnNumRuleCreated(false)
1114 m_pImpl
->StartListening(GetPageDescNotifier(&rDoc
));
1115 m_sCreatedNumRuleName
= rDoc
.GetUniqueNumRuleName();
1116 rDoc
.MakeNumRule( m_sCreatedNumRuleName
, nullptr, false,
1118 numfunc::GetDefaultPositionAndSpaceMode() );
1121 SwXNumberingRules::~SwXNumberingRules()
1123 SolarMutexGuard aGuard
;
1124 if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
1125 m_pDoc
->DelNumRule( m_sCreatedNumRuleName
);
1126 if( m_bOwnNumRuleCreated
)
1130 void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex
, const uno::Any
& rElement
)
1132 SolarMutexGuard aGuard
;
1133 if(nIndex
< 0 || MAXLEVEL
<= nIndex
)
1134 throw lang::IndexOutOfBoundsException();
1136 auto rProperties
= o3tl::tryAccess
<uno::Sequence
<beans::PropertyValue
>>(
1139 throw lang::IllegalArgumentException();
1140 SwNumRule
* pRule
= nullptr;
1142 SwXNumberingRules::SetNumberingRuleByIndex( *m_pNumRule
,
1143 *rProperties
, nIndex
);
1144 else if(m_pDocShell
)
1146 // #i87650# - correction of cws warnings:
1147 SwNumRule
aNumRule( *(m_pDocShell
->GetDoc()->GetOutlineNumRule()) );
1148 SwXNumberingRules::SetNumberingRuleByIndex( aNumRule
,
1149 *rProperties
, nIndex
);
1150 // set character format if needed
1151 const SwCharFormats
* pFormats
= m_pDocShell
->GetDoc()->GetCharFormats();
1152 const size_t nChCount
= pFormats
->size();
1153 for(sal_uInt16 i
= 0; i
< MAXLEVEL
;i
++)
1155 SwNumFormat
aFormat(aNumRule
.Get( i
));
1156 if (!m_sNewCharStyleNames
[i
].isEmpty() &&
1157 m_sNewCharStyleNames
[i
] != UNO_NAME_CHARACTER_FORMAT_NONE
&&
1158 (!aFormat
.GetCharFormat() || aFormat
.GetCharFormat()->GetName()!= m_sNewCharStyleNames
[i
]))
1160 SwCharFormat
* pCharFormat
= nullptr;
1161 for(size_t j
= 0; j
< nChCount
; ++j
)
1163 SwCharFormat
* pTmp
= (*pFormats
)[j
];
1164 if(pTmp
->GetName() == m_sNewCharStyleNames
[i
])
1172 SfxStyleSheetBase
* pBase
;
1173 pBase
= m_pDocShell
->GetStyleSheetPool()->Find(m_sNewCharStyleNames
[i
],
1174 SfxStyleFamily::Char
);
1176 pBase
= &m_pDocShell
->GetStyleSheetPool()->Make(m_sNewCharStyleNames
[i
], SfxStyleFamily::Char
);
1177 pCharFormat
= static_cast<SwDocStyleSheet
*>(pBase
)->GetCharFormat();
1180 aFormat
.SetCharFormat( pCharFormat
);
1181 aNumRule
.Set( i
, aFormat
);
1184 m_pDocShell
->GetDoc()->SetOutlineNumRule( aNumRule
);
1186 else if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty() &&
1187 nullptr != (pRule
= m_pDoc
->FindNumRulePtr( m_sCreatedNumRuleName
)))
1189 SwXNumberingRules::SetNumberingRuleByIndex( *pRule
,
1190 *rProperties
, nIndex
);
1195 throw uno::RuntimeException();
1198 sal_Int32
SwXNumberingRules::getCount()
1203 uno::Any
SwXNumberingRules::getByIndex(sal_Int32 nIndex
)
1205 SolarMutexGuard aGuard
;
1206 if(nIndex
< 0 || MAXLEVEL
<= nIndex
)
1207 throw lang::IndexOutOfBoundsException();
1210 const SwNumRule
* pRule
= m_pNumRule
;
1211 if(!pRule
&& m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
1212 pRule
= m_pDoc
->FindNumRulePtr( m_sCreatedNumRuleName
);
1215 uno::Sequence
<beans::PropertyValue
> aRet
= GetNumberingRuleByIndex(
1220 else if(m_pDocShell
)
1222 uno::Sequence
<beans::PropertyValue
> aRet
= GetNumberingRuleByIndex(
1223 *m_pDocShell
->GetDoc()->GetOutlineNumRule(), nIndex
);
1227 throw uno::RuntimeException();
1231 uno::Type
SwXNumberingRules::getElementType()
1233 return cppu::UnoType
<uno::Sequence
<beans::PropertyValue
>>::get();
1236 sal_Bool
SwXNumberingRules::hasElements()
1241 static const char* STR_POOLCOLL_HEADLINE_ARY
[]
1243 STR_POOLCOLL_HEADLINE1
,
1244 STR_POOLCOLL_HEADLINE2
,
1245 STR_POOLCOLL_HEADLINE3
,
1246 STR_POOLCOLL_HEADLINE4
,
1247 STR_POOLCOLL_HEADLINE5
,
1248 STR_POOLCOLL_HEADLINE6
,
1249 STR_POOLCOLL_HEADLINE7
,
1250 STR_POOLCOLL_HEADLINE8
,
1251 STR_POOLCOLL_HEADLINE9
,
1252 STR_POOLCOLL_HEADLINE10
1255 uno::Sequence
<beans::PropertyValue
> SwXNumberingRules::GetNumberingRuleByIndex(
1256 const SwNumRule
& rNumRule
, sal_Int32 nIndex
) const
1258 SolarMutexGuard aGuard
;
1259 OSL_ENSURE( 0 <= nIndex
&& nIndex
< MAXLEVEL
, "index out of range" );
1261 const SwNumFormat
& rFormat
= rNumRule
.Get( static_cast<sal_uInt16
>(nIndex
) );
1263 SwCharFormat
* pCharFormat
= rFormat
.GetCharFormat();
1264 OUString CharStyleName
;
1266 CharStyleName
= pCharFormat
->GetName();
1268 // Whether or not a style is present: the array entry overwrites this string
1269 if (!m_sNewCharStyleNames
[nIndex
].isEmpty() &&
1270 !SwXNumberingRules::isInvalidStyle(m_sNewCharStyleNames
[nIndex
]))
1272 CharStyleName
= m_sNewCharStyleNames
[nIndex
];
1276 if (m_pDocShell
) // -> Chapter Numbering
1279 OUString
sValue(SwResId(STR_POOLCOLL_HEADLINE_ARY
[nIndex
]));
1280 const SwTextFormatColls
* pColls
= m_pDocShell
->GetDoc()->GetTextFormatColls();
1281 const size_t nCount
= pColls
->size();
1282 for(size_t i
= 0; i
< nCount
; ++i
)
1284 SwTextFormatColl
&rTextColl
= *pColls
->operator[](i
);
1285 if(rTextColl
.IsDefault())
1288 const sal_Int16 nOutLevel
= rTextColl
.IsAssignedToListLevelOfOutlineStyle()
1289 ? static_cast<sal_Int16
>(rTextColl
.GetAssignedOutlineStyleLevel())
1291 if ( nOutLevel
== nIndex
)
1293 sValue
= rTextColl
.GetName();
1294 break; // the style for the level in question has been found
1296 else if( sValue
==rTextColl
.GetName() )
1298 // if the default for the level is existing, but its
1299 // level is different, then it cannot be the default.
1303 SwStyleNameMapper::FillProgName(sValue
, aUString
, SwGetPoolIdFromName::TxtColl
);
1307 if (m_pDoc
!= nullptr) {
1308 auto const sh
= m_pDoc
->GetPersist();
1309 if (sh
!= nullptr && sh
->HasName()) {
1310 referer
= sh
->GetMedium()->GetName();
1313 return GetPropertiesForNumFormat(
1314 rFormat
, CharStyleName
, m_pDocShell
? & aUString
: nullptr, referer
);
1318 uno::Sequence
<beans::PropertyValue
> SwXNumberingRules::GetPropertiesForNumFormat(
1319 const SwNumFormat
& rFormat
, OUString
const& rCharFormatName
,
1320 OUString
const*const pHeadingStyleName
, OUString
const & referer
)
1322 bool bChapterNum
= pHeadingStyleName
!= nullptr;
1324 std::vector
<PropertyValue
> aPropertyValues
;
1325 aPropertyValues
.reserve(32);
1326 //fill all properties into the array
1329 SvxAdjust eAdj
= rFormat
.GetNumAdjust();
1330 sal_Int16 nINT16
= aSvxToUnoAdjust
[eAdj
];
1331 aPropertyValues
.push_back(comphelper::makePropertyValue("Adjust", nINT16
));
1334 nINT16
= rFormat
.GetIncludeUpperLevels();
1335 aPropertyValues
.push_back(comphelper::makePropertyValue("ParentNumbering", nINT16
));
1338 OUString aUString
= rFormat
.GetPrefix();
1339 aPropertyValues
.push_back(comphelper::makePropertyValue("Prefix", aUString
));
1342 aUString
= rFormat
.GetSuffix();
1343 aPropertyValues
.push_back(comphelper::makePropertyValue("Suffix", aUString
));
1346 aUString
= rFormat
.GetListFormat();
1347 aPropertyValues
.push_back(comphelper::makePropertyValue("ListFormat", aUString
));
1352 SwStyleNameMapper::FillProgName( rCharFormatName
, aUString
, SwGetPoolIdFromName::ChrFmt
);
1353 aPropertyValues
.push_back(comphelper::makePropertyValue("CharStyleName", aUString
));
1356 nINT16
= rFormat
.GetStart();
1357 aPropertyValues
.push_back(comphelper::makePropertyValue("StartWith", nINT16
));
1359 if ( rFormat
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
1362 sal_Int32 nINT32
= convertTwipToMm100(rFormat
.GetAbsLSpace());
1363 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_LEFT_MARGIN
, nINT32
));
1366 nINT32
= convertTwipToMm100(rFormat
.GetCharTextDistance());
1367 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_SYMBOL_TEXT_DISTANCE
, nINT32
));
1370 nINT32
= convertTwipToMm100(rFormat
.GetFirstLineOffset());
1371 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_FIRST_LINE_OFFSET
, nINT32
));
1374 // PositionAndSpaceMode
1375 nINT16
= PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION
;
1376 if ( rFormat
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
1378 nINT16
= PositionAndSpaceMode::LABEL_ALIGNMENT
;
1380 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_POSITION_AND_SPACE_MODE
, nINT16
));
1382 if ( rFormat
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
1385 nINT16
= LabelFollow::LISTTAB
;
1386 if ( rFormat
.GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
1388 nINT16
= LabelFollow::SPACE
;
1390 else if ( rFormat
.GetLabelFollowedBy() == SvxNumberFormat::NOTHING
)
1392 nINT16
= LabelFollow::NOTHING
;
1394 else if ( rFormat
.GetLabelFollowedBy() == SvxNumberFormat::NEWLINE
)
1396 nINT16
= LabelFollow::NEWLINE
;
1398 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_LABEL_FOLLOWED_BY
, nINT16
));
1400 // ListtabStopPosition
1401 sal_Int32 nINT32
= convertTwipToMm100(rFormat
.GetListtabPos());
1402 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_LISTTAB_STOP_POSITION
, nINT32
));
1405 nINT32
= convertTwipToMm100(rFormat
.GetFirstLineIndent());
1406 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_FIRST_LINE_INDENT
, nINT32
));
1409 nINT32
= convertTwipToMm100(rFormat
.GetIndentAt());
1410 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_INDENT_AT
, nINT32
));
1414 nINT16
= rFormat
.GetNumberingType();
1415 aPropertyValues
.push_back(comphelper::makePropertyValue("NumberingType", nINT16
));
1419 if(SVX_NUM_CHAR_SPECIAL
== rFormat
.GetNumberingType())
1422 nINT16
= rFormat
.GetBulletChar();
1423 aPropertyValues
.push_back(comphelper::makePropertyValue("BulletId", nINT16
));
1425 const vcl::Font
* pFont
= rFormat
.GetBulletFont();
1428 aUString
= OUString(rFormat
.GetBulletChar());
1429 aPropertyValues
.push_back(comphelper::makePropertyValue("BulletChar", aUString
));
1432 aUString
= pFont
? pFont
->GetStyleName() : OUString();
1433 aPropertyValues
.push_back(comphelper::makePropertyValue("BulletFontName", aUString
));
1438 awt::FontDescriptor aDesc
;
1439 SvxUnoFontDescriptor::ConvertFromFont( *pFont
, aDesc
);
1440 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_BULLET_FONT
, aDesc
));
1443 if (SVX_NUM_BITMAP
== rFormat
.GetNumberingType())
1445 const SvxBrushItem
* pBrush
= rFormat
.GetBrush();
1446 const Graphic
* pGraphic
= pBrush
? pBrush
->GetGraphic(referer
) : nullptr;
1450 uno::Reference
<awt::XBitmap
> xBitmap(pGraphic
->GetXGraphic(), uno::UNO_QUERY
);
1451 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_BITMAP
, xBitmap
));
1454 Size aSize
= rFormat
.GetGraphicSize();
1456 // adjust conversion due to type mismatch between <Size> and <awt::Size>
1457 awt::Size
aAwtSize(convertTwipToMm100(aSize
.Width()), convertTwipToMm100(aSize
.Height()));
1458 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_GRAPHIC_SIZE
, aAwtSize
));
1460 const SwFormatVertOrient
* pOrient
= rFormat
.GetGraphicOrientation();
1464 pOrient
->QueryValue(any
);
1465 aPropertyValues
.emplace_back(
1466 UNO_NAME_VERT_ORIENT
, -1, any
, PropertyState_DIRECT_VALUE
);
1472 aUString
= *pHeadingStyleName
;
1473 aPropertyValues
.push_back(comphelper::makePropertyValue(UNO_NAME_HEADING_STYLE_NAME
, aUString
));
1476 return ::comphelper::containerToSequence(aPropertyValues
);
1479 void SwXNumberingRules::SetNumberingRuleByIndex(
1480 SwNumRule
& rNumRule
,
1481 const uno::Sequence
<beans::PropertyValue
>& rProperties
, sal_Int32 nIndex
)
1483 SolarMutexGuard aGuard
;
1484 OSL_ENSURE( 0 <= nIndex
&& nIndex
< MAXLEVEL
, "index out of range" );
1486 SwNumFormat
aFormat(rNumRule
.Get( static_cast<sal_uInt16
>(nIndex
) ));
1488 OUString sHeadingStyleName
;
1489 OUString sParagraphStyleName
;
1491 SetPropertiesToNumFormat(aFormat
, m_sNewCharStyleNames
[nIndex
],
1492 &m_sNewBulletFontNames
[nIndex
],
1493 &sHeadingStyleName
, &sParagraphStyleName
,
1494 m_pDoc
, rProperties
);
1497 if (m_pDoc
&& !sParagraphStyleName
.isEmpty())
1499 const SwTextFormatColls
* pColls
= m_pDoc
->GetTextFormatColls();
1500 const size_t nCount
= pColls
->size();
1501 for (size_t k
= 0; k
< nCount
; ++k
)
1503 SwTextFormatColl
&rTextColl
= *((*pColls
)[k
]);
1504 if (rTextColl
.GetName() == sParagraphStyleName
)
1505 rTextColl
.SetFormatAttr( SwNumRuleItem( rNumRule
.GetName()));
1509 if (!sHeadingStyleName
.isEmpty())
1511 assert(m_pDocShell
);
1512 const SwTextFormatColls
* pColls
= m_pDocShell
->GetDoc()->GetTextFormatColls();
1513 const size_t nCount
= pColls
->size();
1514 for (size_t k
= 0; k
< nCount
; ++k
)
1516 SwTextFormatColl
&rTextColl
= *((*pColls
)[k
]);
1517 if (rTextColl
.IsDefault())
1519 if (rTextColl
.IsAssignedToListLevelOfOutlineStyle() &&
1520 rTextColl
.GetAssignedOutlineStyleLevel() == nIndex
&&
1521 rTextColl
.GetName() != sHeadingStyleName
)
1523 rTextColl
.DeleteAssignmentToListLevelOfOutlineStyle();
1525 else if (rTextColl
.GetName() == sHeadingStyleName
)
1527 rTextColl
.AssignToListLevelOfOutlineStyle( nIndex
);
1532 rNumRule
.Set(static_cast<sal_uInt16
>(nIndex
), aFormat
);
1535 void SwXNumberingRules::SetPropertiesToNumFormat(
1536 SwNumFormat
& aFormat
,
1537 OUString
& rCharStyleName
, OUString
*const pBulletFontName
,
1538 OUString
*const pHeadingStyleName
,
1539 OUString
*const pParagraphStyleName
,
1541 const uno::Sequence
<beans::PropertyValue
>& rProperties
)
1543 bool bWrongArg
= false;
1544 std::unique_ptr
<SvxBrushItem
> pSetBrush
;
1545 std::unique_ptr
<Size
> pSetSize
;
1546 std::unique_ptr
<SwFormatVertOrient
> pSetVOrient
;
1547 bool bCharStyleNameSet
= false;
1549 for (const beans::PropertyValue
& rProp
: rProperties
)
1551 if (rProp
.Name
== UNO_NAME_ADJUST
)
1553 sal_Int16 nValue
= text::HoriOrientation::NONE
;
1554 rProp
.Value
>>= nValue
;
1555 if (nValue
> text::HoriOrientation::NONE
&&
1556 nValue
<= text::HoriOrientation::LEFT
&&
1557 USHRT_MAX
!= aUnoToSvxAdjust
[nValue
])
1559 aFormat
.SetNumAdjust(static_cast<SvxAdjust
>(aUnoToSvxAdjust
[nValue
]));
1564 else if (rProp
.Name
== UNO_NAME_PARENT_NUMBERING
)
1567 rProp
.Value
>>= nSet
;
1568 if(nSet
>= 0 && MAXLEVEL
>= nSet
)
1569 aFormat
.SetIncludeUpperLevels( static_cast< sal_uInt8
>(nSet
) );
1571 else if (rProp
.Name
== UNO_NAME_PREFIX
)
1574 rProp
.Value
>>= uTmp
;
1575 aFormat
.SetPrefix(uTmp
);
1577 else if (rProp
.Name
== UNO_NAME_SUFFIX
)
1580 rProp
.Value
>>= uTmp
;
1581 aFormat
.SetSuffix(uTmp
);
1583 else if (rProp
.Name
== UNO_NAME_CHAR_STYLE_NAME
)
1585 bCharStyleNameSet
= true;
1587 rProp
.Value
>>= uTmp
;
1588 OUString sCharFormatName
;
1589 SwStyleNameMapper::FillUIName( uTmp
, sCharFormatName
, SwGetPoolIdFromName::ChrFmt
);
1590 if (sCharFormatName
== UNO_NAME_CHARACTER_FORMAT_NONE
)
1592 rCharStyleName
= aInvalidStyle
;
1593 aFormat
.SetCharFormat(nullptr);
1597 const SwCharFormats
* pFormats
= pDoc
->GetCharFormats();
1598 const size_t nChCount
= pFormats
->size();
1600 SwCharFormat
* pCharFormat
= nullptr;
1601 if (!sCharFormatName
.isEmpty())
1603 for(size_t j
= 0; j
< nChCount
; ++j
)
1605 SwCharFormat
* pTmp
= (*pFormats
)[j
];
1606 if(pTmp
->GetName() == sCharFormatName
)
1615 SfxStyleSheetBase
* pBase
;
1616 SfxStyleSheetBasePool
* pPool
= pDoc
->GetDocShell()->GetStyleSheetPool();
1617 pBase
= pPool
->Find(sCharFormatName
, SfxStyleFamily::Char
);
1619 pBase
= &pPool
->Make(sCharFormatName
, SfxStyleFamily::Char
);
1620 pCharFormat
= static_cast<SwDocStyleSheet
*>(pBase
)->GetCharFormat();
1623 aFormat
.SetCharFormat( pCharFormat
);
1625 // If the character format has been found its name should not be in the
1626 // char style names array
1627 rCharStyleName
.clear();
1630 rCharStyleName
= sCharFormatName
;
1632 else if (rProp
.Name
== UNO_NAME_START_WITH
)
1635 rProp
.Value
>>= nVal
;
1636 aFormat
.SetStart(nVal
);
1638 else if (rProp
.Name
== UNO_NAME_LEFT_MARGIN
)
1640 sal_Int32 nValue
= 0;
1641 rProp
.Value
>>= nValue
;
1642 // #i23727# nValue can be negative
1643 aFormat
.SetAbsLSpace(convertMm100ToTwip(nValue
));
1645 else if (rProp
.Name
== UNO_NAME_SYMBOL_TEXT_DISTANCE
)
1647 sal_Int32 nValue
= 0;
1648 rProp
.Value
>>= nValue
;
1650 aFormat
.SetCharTextDistance(static_cast<short>(convertMm100ToTwip(nValue
)));
1654 else if (rProp
.Name
== UNO_NAME_FIRST_LINE_OFFSET
)
1656 sal_Int32 nValue
= 0;
1657 rProp
.Value
>>= nValue
;
1658 // #i23727# nValue can be positive
1659 nValue
= convertMm100ToTwip(nValue
);
1660 aFormat
.SetFirstLineOffset(nValue
);
1662 else if (rProp
.Name
== UNO_NAME_POSITION_AND_SPACE_MODE
)
1664 sal_Int16 nValue
= 0;
1665 rProp
.Value
>>= nValue
;
1668 aFormat
.SetPositionAndSpaceMode( SvxNumberFormat::LABEL_WIDTH_AND_POSITION
);
1670 else if ( nValue
== 1 )
1672 aFormat
.SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT
);
1679 else if (rProp
.Name
== UNO_NAME_LABEL_FOLLOWED_BY
)
1681 sal_Int16 nValue
= 0;
1682 rProp
.Value
>>= nValue
;
1683 if ( nValue
== LabelFollow::LISTTAB
)
1685 aFormat
.SetLabelFollowedBy( SvxNumberFormat::LISTTAB
);
1687 else if ( nValue
== LabelFollow::SPACE
)
1689 aFormat
.SetLabelFollowedBy( SvxNumberFormat::SPACE
);
1691 else if ( nValue
== LabelFollow::NOTHING
)
1693 aFormat
.SetLabelFollowedBy( SvxNumberFormat::NOTHING
);
1695 else if ( nValue
== LabelFollow::NEWLINE
)
1697 aFormat
.SetLabelFollowedBy( SvxNumberFormat::NEWLINE
);
1704 else if (rProp
.Name
== UNO_NAME_LISTTAB_STOP_POSITION
)
1706 sal_Int32 nValue
= 0;
1707 rProp
.Value
>>= nValue
;
1708 nValue
= convertMm100ToTwip(nValue
);
1711 aFormat
.SetListtabPos( nValue
);
1718 else if (rProp
.Name
== UNO_NAME_FIRST_LINE_INDENT
)
1720 sal_Int32 nValue
= 0;
1721 rProp
.Value
>>= nValue
;
1722 nValue
= convertMm100ToTwip(nValue
);
1723 aFormat
.SetFirstLineIndent( nValue
);
1725 else if (rProp
.Name
== UNO_NAME_INDENT_AT
)
1727 sal_Int32 nValue
= 0;
1728 rProp
.Value
>>= nValue
;
1729 nValue
= convertMm100ToTwip(nValue
);
1730 aFormat
.SetIndentAt( nValue
);
1732 else if (rProp
.Name
== UNO_NAME_NUMBERING_TYPE
)
1735 rProp
.Value
>>= nSet
;
1737 aFormat
.SetNumberingType(static_cast<SvxNumType
>(nSet
));
1741 else if (rProp
.Name
== UNO_NAME_PARAGRAPH_STYLE_NAME
)
1743 if (pParagraphStyleName
)
1746 rProp
.Value
>>= uTmp
;
1747 OUString sStyleName
;
1748 SwStyleNameMapper::FillUIName(uTmp
, sStyleName
, SwGetPoolIdFromName::TxtColl
);
1749 *pParagraphStyleName
= sStyleName
;
1752 else if (rProp
.Name
== UNO_NAME_BULLET_ID
)
1755 if( rProp
.Value
>>= nSet
)
1756 aFormat
.SetBulletChar(nSet
);
1760 else if (rProp
.Name
== UNO_NAME_BULLET_FONT
)
1762 awt::FontDescriptor desc
;
1763 if (rProp
.Value
>>= desc
)
1766 // do not accept "empty" font
1767 if (!desc
.Name
.isEmpty())
1770 SvxUnoFontDescriptor::ConvertToFont(desc
, aFont
);
1771 aFormat
.SetBulletFont(&aFont
);
1777 else if (rProp
.Name
== UNO_NAME_BULLET_FONT_NAME
)
1779 OUString sBulletFontName
;
1780 rProp
.Value
>>= sBulletFontName
;
1781 SwDocShell
* pLclDocShell
= pDoc
->GetDocShell();
1782 if( !sBulletFontName
.isEmpty() && pLclDocShell
)
1784 const SvxFontListItem
* pFontListItem
=
1785 static_cast<const SvxFontListItem
* >(pLclDocShell
1786 ->GetItem( SID_ATTR_CHAR_FONTLIST
));
1787 const FontList
* pList
= pFontListItem
->GetFontList();
1788 FontMetric aFontMetric
= pList
->Get(
1789 sBulletFontName
, WEIGHT_NORMAL
, ITALIC_NONE
);
1790 vcl::Font
aFont(aFontMetric
);
1791 aFormat
.SetBulletFont(&aFont
);
1793 else if (pBulletFontName
)
1794 *pBulletFontName
= sBulletFontName
;
1796 else if (rProp
.Name
== UNO_NAME_BULLET_CHAR
)
1799 rProp
.Value
>>= aChar
;
1800 if(aChar
.getLength() == 1)
1802 aFormat
.SetBulletChar(aChar
.toChar());
1804 else if(aChar
.isEmpty())
1806 // If w:lvlText's value is null - set bullet char to zero
1807 aFormat
.SetBulletChar(u
'\0');
1814 else if (rProp
.Name
== UNO_NAME_GRAPHIC
)
1816 uno::Reference
<graphic::XGraphic
> xGraphic
;
1817 if (rProp
.Value
>>= xGraphic
)
1821 const SvxBrushItem
* pOrigBrush
= aFormat
.GetBrush();
1823 pSetBrush
.reset(new SvxBrushItem(*pOrigBrush
));
1825 pSetBrush
.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA
, RES_BACKGROUND
));
1827 Graphic
aGraphic(xGraphic
);
1828 pSetBrush
->SetGraphic(aGraphic
);
1833 else if (rProp
.Name
== UNO_NAME_GRAPHIC_BITMAP
)
1835 uno::Reference
<awt::XBitmap
> xBitmap
;
1836 if (rProp
.Value
>>= xBitmap
)
1840 const SvxBrushItem
* pOrigBrush
= aFormat
.GetBrush();
1842 pSetBrush
.reset(new SvxBrushItem(*pOrigBrush
));
1844 pSetBrush
.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA
, RES_BACKGROUND
));
1847 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1848 Graphic
aGraphic(xGraphic
);
1849 pSetBrush
->SetGraphic(aGraphic
);
1854 else if (rProp
.Name
== UNO_NAME_GRAPHIC_SIZE
)
1857 pSetSize
.reset(new Size
);
1859 if (rProp
.Value
>>= size
)
1861 size
.Width
= convertMm100ToTwip(size
.Width
);
1862 size
.Height
= convertMm100ToTwip(size
.Height
);
1863 pSetSize
->setWidth( size
.Width
);
1864 pSetSize
->setHeight( size
.Height
);
1869 else if (rProp
.Name
== UNO_NAME_VERT_ORIENT
)
1873 if(aFormat
.GetGraphicOrientation())
1874 pSetVOrient
.reset( static_cast<SwFormatVertOrient
*>(aFormat
.GetGraphicOrientation()->Clone()) );
1876 pSetVOrient
.reset(new SwFormatVertOrient
);
1878 pSetVOrient
->PutValue(rProp
.Value
, MID_VERTORIENT_ORIENT
);
1880 else if (rProp
.Name
== UNO_NAME_HEADING_STYLE_NAME
)
1882 if (pHeadingStyleName
)
1885 rProp
.Value
>>= uTmp
;
1886 OUString sStyleName
;
1887 SwStyleNameMapper::FillUIName(uTmp
, sStyleName
, SwGetPoolIdFromName::TxtColl
);
1888 *pHeadingStyleName
= sStyleName
;
1891 else if (rProp
.Name
== UNO_NAME_BULLET_REL_SIZE
)
1893 // BulletRelSize - unsupported - only available in Impress
1895 else if (rProp
.Name
== UNO_NAME_BULLET_COLOR
)
1897 // BulletColor - ignored too
1899 else if (rProp
.Name
== UNO_NAME_GRAPHIC_URL
)
1902 if (rProp
.Value
>>= aURL
)
1906 const SvxBrushItem
* pOrigBrush
= aFormat
.GetBrush();
1908 pSetBrush
.reset(new SvxBrushItem(*pOrigBrush
));
1910 pSetBrush
.reset(new SvxBrushItem(OUString(), OUString(), GPOS_AREA
, RES_BACKGROUND
));
1913 Graphic aGraphic
= vcl::graphic::loadFromURL(aURL
);
1914 if (!aGraphic
.IsNone())
1915 pSetBrush
->SetGraphic(aGraphic
);
1920 else if (rProp
.Name
== UNO_NAME_LIST_FORMAT
)
1923 rProp
.Value
>>= uTmp
;
1924 aFormat
.SetListFormat(uTmp
);
1928 // Invalid property name
1929 SAL_WARN("sw.uno", "Unknown/incorrect property " << rProp
.Name
<< ", failing");
1930 throw uno::RuntimeException("Unknown/incorrect property " + rProp
.Name
);
1933 if(!bWrongArg
&& (pSetBrush
|| pSetSize
|| pSetVOrient
))
1935 if(!pSetBrush
&& aFormat
.GetBrush())
1936 pSetBrush
.reset(new SvxBrushItem(*aFormat
.GetBrush()));
1940 if(!pSetVOrient
&& aFormat
.GetGraphicOrientation())
1941 pSetVOrient
.reset( new SwFormatVertOrient(*aFormat
.GetGraphicOrientation()) );
1945 pSetSize
.reset(new Size(aFormat
.GetGraphicSize()));
1946 if(!pSetSize
->Width() || !pSetSize
->Height())
1948 const Graphic
* pGraphic
= pSetBrush
->GetGraphic();
1950 *pSetSize
= ::GetGraphicSizeTwip(*pGraphic
, nullptr);
1953 sal_Int16 eOrient
= pSetVOrient
?
1954 pSetVOrient
->GetVertOrient() : text::VertOrientation::NONE
;
1955 aFormat
.SetGraphicBrush( pSetBrush
.get(), pSetSize
.get(), text::VertOrientation::NONE
== eOrient
? nullptr : &eOrient
);
1958 if ((!bCharStyleNameSet
|| rCharStyleName
.isEmpty())
1959 && aFormat
.GetNumberingType() == NumberingType::BITMAP
1960 && !aFormat
.GetCharFormat()
1961 && !SwXNumberingRules::isInvalidStyle(rCharStyleName
))
1964 SwStyleNameMapper::FillProgName(RES_POOLCHR_BUL_LEVEL
, tmp
);
1965 rCharStyleName
= tmp
;
1969 throw lang::IllegalArgumentException();
1972 uno::Reference
< XPropertySetInfo
> SwXNumberingRules::getPropertySetInfo()
1974 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropertySet
->getPropertySetInfo();
1978 void SwXNumberingRules::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
1980 SolarMutexGuard aGuard
;
1981 std::unique_ptr
<SwNumRule
> pDocRule
;
1982 SwNumRule
* pCreatedRule
= nullptr;
1987 pDocRule
.reset(new SwNumRule(*m_pDocShell
->GetDoc()->GetOutlineNumRule()));
1989 else if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
1991 pCreatedRule
= m_pDoc
->FindNumRulePtr(m_sCreatedNumRuleName
);
1995 if(!m_pNumRule
&& !pDocRule
&& !pCreatedRule
)
1996 throw RuntimeException();
1998 if(rPropertyName
== UNO_NAME_IS_AUTOMATIC
)
2000 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
2002 pDocRule
? pDocRule
->SetAutoRule(bVal
) : m_pNumRule
->SetAutoRule(bVal
);
2004 else if(rPropertyName
== UNO_NAME_IS_CONTINUOUS_NUMBERING
)
2006 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
2007 pDocRule
? pDocRule
->SetContinusNum(bVal
) :
2008 pCreatedRule
? pCreatedRule
->SetContinusNum(bVal
) : m_pNumRule
->SetContinusNum(bVal
);
2010 else if(rPropertyName
== UNO_NAME_NAME
)
2012 throw IllegalArgumentException();
2014 else if(rPropertyName
== UNO_NAME_IS_ABSOLUTE_MARGINS
)
2016 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
2017 pDocRule
? pDocRule
->SetAbsSpaces(bVal
) :
2018 pCreatedRule
? pCreatedRule
->SetAbsSpaces(bVal
) : m_pNumRule
->SetAbsSpaces(bVal
);
2020 else if(rPropertyName
== UNO_NAME_NUMBERING_IS_OUTLINE
)
2022 bool bVal
= *o3tl::doAccess
<bool>(rValue
);
2023 SwNumRuleType eNumRuleType
= bVal
? OUTLINE_RULE
: NUM_RULE
;
2024 pDocRule
? pDocRule
->SetRuleType(eNumRuleType
) :
2025 pCreatedRule
? pCreatedRule
->SetRuleType(eNumRuleType
) : m_pNumRule
->SetRuleType(eNumRuleType
);
2027 else if(rPropertyName
== UNO_NAME_DEFAULT_LIST_ID
)
2029 throw IllegalArgumentException();
2032 throw UnknownPropertyException(rPropertyName
);
2036 assert(m_pDocShell
);
2037 m_pDocShell
->GetDoc()->SetOutlineNumRule(*pDocRule
);
2040 else if(pCreatedRule
)
2042 pCreatedRule
->Validate();
2046 Any
SwXNumberingRules::getPropertyValue( const OUString
& rPropertyName
)
2049 const SwNumRule
* pRule
= m_pNumRule
;
2050 if(!pRule
&& m_pDocShell
)
2051 pRule
= m_pDocShell
->GetDoc()->GetOutlineNumRule();
2052 else if(m_pDoc
&& !m_sCreatedNumRuleName
.isEmpty())
2053 pRule
= m_pDoc
->FindNumRulePtr( m_sCreatedNumRuleName
);
2055 throw RuntimeException();
2057 if(rPropertyName
== UNO_NAME_IS_AUTOMATIC
)
2059 aRet
<<= pRule
->IsAutoRule();
2061 else if(rPropertyName
== UNO_NAME_IS_CONTINUOUS_NUMBERING
)
2063 aRet
<<= pRule
->IsContinusNum();
2065 else if(rPropertyName
== UNO_NAME_NAME
)
2066 aRet
<<= pRule
->GetName();
2067 else if(rPropertyName
== UNO_NAME_IS_ABSOLUTE_MARGINS
)
2069 aRet
<<= pRule
->IsAbsSpaces();
2071 else if(rPropertyName
== UNO_NAME_NUMBERING_IS_OUTLINE
)
2073 aRet
<<= pRule
->IsOutlineRule();
2075 else if(rPropertyName
== UNO_NAME_DEFAULT_LIST_ID
)
2077 OSL_ENSURE( !pRule
->GetDefaultListId().isEmpty(),
2078 "<SwXNumberingRules::getPropertyValue(..)> - no default list id found. Serious defect." );
2079 aRet
<<= pRule
->GetDefaultListId();
2082 throw UnknownPropertyException(rPropertyName
);
2086 void SwXNumberingRules::addPropertyChangeListener(
2087 const OUString
& /*rPropertyName*/, const uno::Reference
< XPropertyChangeListener
>& /*xListener*/ )
2091 void SwXNumberingRules::removePropertyChangeListener(
2092 const OUString
& /*rPropertyName*/, const uno::Reference
< XPropertyChangeListener
>& /*xListener*/ )
2096 void SwXNumberingRules::addVetoableChangeListener(
2097 const OUString
& /*rPropertyName*/, const uno::Reference
< XVetoableChangeListener
>& /*xListener*/ )
2101 void SwXNumberingRules::removeVetoableChangeListener(
2102 const OUString
& /*rPropertyName*/, const uno::Reference
< XVetoableChangeListener
>& /*xListener*/ )
2106 OUString
SwXNumberingRules::getName()
2111 SwStyleNameMapper::FillProgName(m_pNumRule
->GetName(), aString
, SwGetPoolIdFromName::NumRule
);
2114 // consider chapter numbering <SwXNumberingRules>
2118 SwStyleNameMapper::FillProgName( m_pDocShell
->GetDoc()->GetOutlineNumRule()->GetName(),
2119 aString
, SwGetPoolIdFromName::NumRule
);
2122 return m_sCreatedNumRuleName
;
2125 void SwXNumberingRules::setName(const OUString
& /*rName*/)
2127 RuntimeException aExcept
;
2128 aExcept
.Message
= "readonly";
2132 void SwXNumberingRules::Impl::Notify(const SfxHint
& rHint
)
2134 if(rHint
.GetId() == SfxHintId::Dying
)
2136 if(m_rParent
.m_bOwnNumRuleCreated
)
2137 delete m_rParent
.m_pNumRule
;
2138 m_rParent
.m_pNumRule
= nullptr;
2139 m_rParent
.m_pDoc
= nullptr;
2143 OUString
SwXChapterNumbering::getImplementationName()
2145 return "SwXChapterNumbering";
2148 sal_Bool
SwXChapterNumbering::supportsService(const OUString
& rServiceName
)
2150 return cppu::supportsService(this, rServiceName
);
2153 Sequence
< OUString
> SwXChapterNumbering::getSupportedServiceNames()
2155 return { "com.sun.star.text.ChapterNumbering", "com.sun.star.text.NumberingRules" };
2158 SwXChapterNumbering::SwXChapterNumbering(SwDocShell
& rDocSh
) :
2159 SwXNumberingRules(rDocSh
)
2163 SwXChapterNumbering::~SwXChapterNumbering()
2167 OUString
SwXTextColumns::getImplementationName()
2169 return "SwXTextColumns";
2172 sal_Bool
SwXTextColumns::supportsService(const OUString
& rServiceName
)
2174 return cppu::supportsService(this, rServiceName
);
2177 Sequence
< OUString
> SwXTextColumns::getSupportedServiceNames()
2179 Sequence
<OUString
> aRet
{ "com.sun.star.text.TextColumns" };
2183 SwXTextColumns::SwXTextColumns() :
2185 m_bIsAutomaticWidth(true),
2187 m_pPropSet(aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_COLUMS
)),
2189 m_nSepLineColor(0), //black
2190 m_nSepLineHeightRelative(100),//full height
2191 m_nSepLineVertAlign(style::VerticalAlignment_MIDDLE
),
2192 m_bSepLineIsOn(false),
2193 m_nSepLineStyle(API_COL_LINE_NONE
) // None
2197 SwXTextColumns::SwXTextColumns(const SwFormatCol
& rFormatCol
) :
2199 m_aTextColumns(rFormatCol
.GetNumCols()),
2200 m_bIsAutomaticWidth(rFormatCol
.IsOrtho()),
2201 m_pPropSet(aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXT_COLUMS
))
2203 const sal_uInt16 nItemGutterWidth
= rFormatCol
.GetGutterWidth();
2204 m_nAutoDistance
= m_bIsAutomaticWidth
?
2205 USHRT_MAX
== nItemGutterWidth
? DEF_GUTTER_WIDTH
: static_cast<sal_Int32
>(nItemGutterWidth
)
2207 m_nAutoDistance
= convertTwipToMm100(m_nAutoDistance
);
2209 TextColumn
* pColumns
= m_aTextColumns
.getArray();
2210 const SwColumns
& rCols
= rFormatCol
.GetColumns();
2211 for(sal_Int32 i
= 0; i
< m_aTextColumns
.getLength(); ++i
)
2213 const SwColumn
* pCol
= &rCols
[i
];
2215 pColumns
[i
].Width
= pCol
->GetWishWidth();
2216 m_nReference
+= pColumns
[i
].Width
;
2217 pColumns
[i
].LeftMargin
= convertTwipToMm100(pCol
->GetLeft ());
2218 pColumns
[i
].RightMargin
= convertTwipToMm100(pCol
->GetRight());
2220 if(!m_aTextColumns
.hasElements())
2221 m_nReference
= USHRT_MAX
;
2223 m_nSepLineWidth
= rFormatCol
.GetLineWidth();
2224 m_nSepLineColor
= rFormatCol
.GetLineColor();
2225 m_nSepLineHeightRelative
= rFormatCol
.GetLineHeight();
2226 m_bSepLineIsOn
= rFormatCol
.GetLineAdj() != COLADJ_NONE
;
2227 sal_Int8 nStyle
= API_COL_LINE_NONE
;
2228 switch (rFormatCol
.GetLineStyle())
2230 case SvxBorderLineStyle::SOLID
: nStyle
= API_COL_LINE_SOLID
; break;
2231 case SvxBorderLineStyle::DOTTED
: nStyle
= API_COL_LINE_DOTTED
; break;
2232 case SvxBorderLineStyle::DASHED
: nStyle
= API_COL_LINE_DASHED
; break;
2235 m_nSepLineStyle
= nStyle
;
2236 switch(rFormatCol
.GetLineAdj())
2238 case COLADJ_TOP
: m_nSepLineVertAlign
= style::VerticalAlignment_TOP
; break;
2239 case COLADJ_BOTTOM
: m_nSepLineVertAlign
= style::VerticalAlignment_BOTTOM
; break;
2241 case COLADJ_NONE
: m_nSepLineVertAlign
= style::VerticalAlignment_MIDDLE
;
2245 SwXTextColumns::~SwXTextColumns()
2249 sal_Int32
SwXTextColumns::getReferenceValue()
2251 SolarMutexGuard aGuard
;
2252 return m_nReference
;
2255 sal_Int16
SwXTextColumns::getColumnCount()
2257 SolarMutexGuard aGuard
;
2258 return static_cast< sal_Int16
>( m_aTextColumns
.getLength() );
2261 void SwXTextColumns::setColumnCount(sal_Int16 nColumns
)
2263 SolarMutexGuard aGuard
;
2265 throw uno::RuntimeException();
2266 m_bIsAutomaticWidth
= true;
2267 m_aTextColumns
.realloc(nColumns
);
2268 TextColumn
* pCols
= m_aTextColumns
.getArray();
2269 m_nReference
= USHRT_MAX
;
2270 sal_Int32 nWidth
= m_nReference
/ nColumns
;
2271 sal_Int32 nDiff
= m_nReference
- nWidth
* nColumns
;
2272 sal_Int32 nDist
= m_nAutoDistance
/ 2;
2273 for(sal_Int16 i
= 0; i
< nColumns
; i
++)
2275 pCols
[i
].Width
= nWidth
;
2276 pCols
[i
].LeftMargin
= i
== 0 ? 0 : nDist
;
2277 pCols
[i
].RightMargin
= i
== nColumns
- 1 ? 0 : nDist
;
2279 pCols
[nColumns
- 1].Width
+= nDiff
;
2282 uno::Sequence
< TextColumn
> SwXTextColumns::getColumns()
2284 SolarMutexGuard aGuard
;
2285 return m_aTextColumns
;
2288 void SwXTextColumns::setColumns(const uno::Sequence
< TextColumn
>& rColumns
)
2290 SolarMutexGuard aGuard
;
2291 sal_Int32 nReferenceTemp
= std::accumulate(rColumns
.begin(), rColumns
.end(), sal_Int32(0),
2292 [](const sal_Int32 nSum
, const TextColumn
& rCol
) { return nSum
+ rCol
.Width
; });
2293 m_bIsAutomaticWidth
= false;
2294 m_nReference
= !nReferenceTemp
? USHRT_MAX
: nReferenceTemp
;
2295 m_aTextColumns
= rColumns
;
2298 uno::Reference
< XPropertySetInfo
> SwXTextColumns::getPropertySetInfo( )
2300 static uno::Reference
< beans::XPropertySetInfo
> aRef
= m_pPropSet
->getPropertySetInfo();
2304 void SwXTextColumns::setPropertyValue( const OUString
& rPropertyName
, const Any
& aValue
)
2306 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName( rPropertyName
);
2308 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2309 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
2310 throw PropertyVetoException("Property is read-only: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2312 switch(pEntry
->nWID
)
2314 case WID_TXTCOL_LINE_WIDTH
:
2319 throw IllegalArgumentException();
2320 m_nSepLineWidth
= convertMm100ToTwip(nTmp
);
2323 case WID_TXTCOL_LINE_COLOR
:
2324 aValue
>>= m_nSepLineColor
;
2326 case WID_TXTCOL_LINE_STYLE
:
2328 aValue
>>= m_nSepLineStyle
;
2331 case WID_TXTCOL_LINE_REL_HGT
:
2336 throw IllegalArgumentException();
2337 m_nSepLineHeightRelative
= nTmp
;
2340 case WID_TXTCOL_LINE_ALIGN
:
2342 style::VerticalAlignment eAlign
;
2343 if(!(aValue
>>= eAlign
) )
2346 if (! ( aValue
>>= nTmp
) )
2347 throw IllegalArgumentException();
2348 m_nSepLineVertAlign
= static_cast<style::VerticalAlignment
>(nTmp
);
2351 m_nSepLineVertAlign
= eAlign
;
2354 case WID_TXTCOL_LINE_IS_ON
:
2355 m_bSepLineIsOn
= *o3tl::doAccess
<bool>(aValue
);
2357 case WID_TXTCOL_AUTO_DISTANCE
:
2361 if(nTmp
< 0 || nTmp
>= m_nReference
)
2362 throw IllegalArgumentException();
2363 m_nAutoDistance
= nTmp
;
2364 sal_Int32 nColumns
= m_aTextColumns
.getLength();
2365 TextColumn
* pCols
= m_aTextColumns
.getArray();
2366 sal_Int32 nDist
= m_nAutoDistance
/ 2;
2367 for(sal_Int32 i
= 0; i
< nColumns
; i
++)
2369 pCols
[i
].LeftMargin
= i
== 0 ? 0 : nDist
;
2370 pCols
[i
].RightMargin
= i
== nColumns
- 1 ? 0 : nDist
;
2377 Any
SwXTextColumns::getPropertyValue( const OUString
& rPropertyName
)
2379 const SfxItemPropertySimpleEntry
* pEntry
= m_pPropSet
->getPropertyMap().getByName( rPropertyName
);
2381 throw UnknownPropertyException("Unknown property: " + rPropertyName
, static_cast < cppu::OWeakObject
* > ( this ) );
2384 switch(pEntry
->nWID
)
2386 case WID_TXTCOL_LINE_WIDTH
:
2387 aRet
<<= static_cast < sal_Int32
>(convertTwipToMm100(m_nSepLineWidth
));
2389 case WID_TXTCOL_LINE_COLOR
:
2390 aRet
<<= m_nSepLineColor
;
2392 case WID_TXTCOL_LINE_STYLE
:
2393 aRet
<<= m_nSepLineStyle
;
2395 case WID_TXTCOL_LINE_REL_HGT
:
2396 aRet
<<= m_nSepLineHeightRelative
;
2398 case WID_TXTCOL_LINE_ALIGN
:
2399 aRet
<<= m_nSepLineVertAlign
;
2401 case WID_TXTCOL_LINE_IS_ON
:
2402 aRet
<<= m_bSepLineIsOn
;
2404 case WID_TXTCOL_IS_AUTOMATIC
:
2405 aRet
<<= m_bIsAutomaticWidth
;
2407 case WID_TXTCOL_AUTO_DISTANCE
:
2408 aRet
<<= m_nAutoDistance
;
2414 void SwXTextColumns::addPropertyChangeListener(
2415 const OUString
& /*rPropertyName*/, const uno::Reference
< XPropertyChangeListener
>& /*xListener*/ )
2419 void SwXTextColumns::removePropertyChangeListener(
2420 const OUString
& /*rPropertyName*/, const uno::Reference
< XPropertyChangeListener
>& /*xListener*/ )
2424 void SwXTextColumns::addVetoableChangeListener(
2425 const OUString
& /*rPropertyName*/, const uno::Reference
< XVetoableChangeListener
>& /*xListener*/ )
2429 void SwXTextColumns::removeVetoableChangeListener(
2430 const OUString
& /*rPropertyName*/, const uno::Reference
< XVetoableChangeListener
>& /*xListener*/ )
2436 class theSwXTextColumnsUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSwXTextColumnsUnoTunnelId
> {};
2439 const uno::Sequence
< sal_Int8
> & SwXTextColumns::getUnoTunnelId()
2441 return theSwXTextColumnsUnoTunnelId::get().getSeq();
2444 sal_Int64 SAL_CALL
SwXTextColumns::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
2446 if( isUnoTunnelId
<SwXTextColumns
>(rId
) )
2448 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
2453 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */