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 <com/sun/star/text/HoriOrientation.hpp>
21 #include <com/sun/star/text/VertOrientation.hpp>
23 #include <numpages.hxx>
24 #include <dialmgr.hxx>
25 #include <tools/mapunit.hxx>
26 #include <i18nlangtag/languagetag.hxx>
27 #include <i18nlangtag/mslangid.hxx>
28 #include <editeng/numitem.hxx>
29 #include <svl/eitem.hxx>
30 #include <vcl/svapp.hxx>
31 #include <svx/colorbox.hxx>
32 #include <svx/strarray.hxx>
33 #include <svx/gallery.hxx>
34 #include <editeng/brushitem.hxx>
35 #include <svl/intitem.hxx>
36 #include <sfx2/objsh.hxx>
37 #include <vcl/graph.hxx>
38 #include <vcl/settings.hxx>
39 #include <cui/cuicharmap.hxx>
40 #include <editeng/flstitem.hxx>
41 #include <svx/numvset.hxx>
42 #include <sfx2/htmlmode.hxx>
43 #include <unotools/pathoptions.hxx>
44 #include <svtools/ctrltool.hxx>
45 #include <svtools/unitconv.hxx>
46 #include <com/sun/star/style/NumberingType.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/container/XIndexAccess.hpp>
49 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
50 #include <com/sun/star/text/XNumberingFormatter.hpp>
51 #include <com/sun/star/beans/PropertyValue.hpp>
52 #include <comphelper/processfactory.hxx>
53 #include <svx/svxids.hrc>
58 #include <sfx2/opengrf.hxx>
60 #include <strings.hrc>
61 #include <svl/aeitem.hxx>
62 #include <svl/stritem.hxx>
63 #include <svl/slstitm.hxx>
64 #include <sfx2/filedlghelper.hxx>
65 #include <unotools/ucbstreamhelper.hxx>
66 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
67 #include <sal/log.hxx>
68 #include <vcl/cvtgrf.hxx>
69 #include <vcl/graphicfilter.hxx>
70 #include <svx/SvxNumOptionsTabPageHelper.hxx>
71 #include <tools/urlobj.hxx>
72 #include <osl/diagnose.h>
75 using namespace css::uno
;
76 using namespace css::beans
;
77 using namespace css::lang
;
78 using namespace css::i18n
;
79 using namespace css::text
;
80 using namespace css::container
;
81 using namespace css::style
;
83 #define SHOW_NUMBERING 0
87 #define MAX_BMP_WIDTH 16
88 #define MAX_BMP_HEIGHT 16
89 #define SEARCHPATH_DELIMITER u';'
90 #define SEARCHFILENAME_DELIMITER u'/'
92 static bool bLastRelative
= false;
94 static SvxNumSettings_Impl
* lcl_CreateNumSettingsPtr(const Sequence
<PropertyValue
>& rLevelProps
)
96 const PropertyValue
* pValues
= rLevelProps
.getConstArray();
97 SvxNumSettings_Impl
* pNew
= new SvxNumSettings_Impl
;
98 for(sal_Int32 j
= 0; j
< rLevelProps
.getLength(); j
++)
100 if ( pValues
[j
].Name
== "NumberingType" )
103 if (pValues
[j
].Value
>>= nTmp
)
104 pNew
->nNumberType
= static_cast<SvxNumType
>(nTmp
);
106 else if ( pValues
[j
].Name
== "Prefix" )
107 pValues
[j
].Value
>>= pNew
->sPrefix
;
108 else if ( pValues
[j
].Name
== "Suffix" )
109 pValues
[j
].Value
>>= pNew
->sSuffix
;
110 else if ( pValues
[j
].Name
== "ParentNumbering" )
111 pValues
[j
].Value
>>= pNew
->nParentNumbering
;
112 else if ( pValues
[j
].Name
== "BulletChar" )
113 pValues
[j
].Value
>>= pNew
->sBulletChar
;
114 else if ( pValues
[j
].Name
== "BulletFontName" )
115 pValues
[j
].Value
>>= pNew
->sBulletFont
;
120 // the selection of bullets from the OpenSymbol
121 static const sal_Unicode aBulletTypes
[] =
133 // Is one of the masked formats set?
134 static bool lcl_IsNumFmtSet(SvxNumRule
const * pNum
, sal_uInt16 nLevelMask
)
137 sal_uInt16 nMask
= 1;
138 for( sal_uInt16 i
= 0; i
< SVX_MAX_NUM
&& !bRet
; i
++ )
140 if(nLevelMask
& nMask
)
141 bRet
|= nullptr != pNum
->Get( i
);
147 static const vcl::Font
& lcl_GetDefaultBulletFont()
149 static vcl::Font aDefBulletFont
= [&]()
151 vcl::Font
tmp("OpenSymbol", "", Size(0, 14));
152 tmp
.SetCharSet( RTL_TEXTENCODING_SYMBOL
);
153 tmp
.SetFamily( FAMILY_DONTKNOW
);
154 tmp
.SetPitch( PITCH_DONTKNOW
);
155 tmp
.SetWeight( WEIGHT_DONTKNOW
);
156 tmp
.SetTransparent( true );
159 return aDefBulletFont
;
162 SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
163 : SfxTabPage(pPage
, pController
, "cui/ui/picknumberingpage.ui", "PickNumberingPage", &rSet
)
164 , nActNumLvl(SAL_MAX_UINT16
)
167 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
168 , m_xExamplesVS(new NumValueSet(nullptr))
169 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder
, "valueset", *m_xExamplesVS
))
171 SetExchangeSupport();
172 m_xExamplesVS
->init(NumberingPageType::SINGLENUM
);
173 m_xExamplesVS
->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage
, NumSelectHdl_Impl
));
174 m_xExamplesVS
->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage
, DoubleClickHdl_Impl
));
176 Reference
<XDefaultNumberingProvider
> xDefNum
= SvxNumOptionsTabPageHelper::GetNumberingProvider();
179 Sequence
< Sequence
< PropertyValue
> > aNumberings
;
180 const Locale
& rLocale
= Application::GetSettings().GetLanguageTag().getLocale();
184 xDefNum
->getDefaultContinuousNumberingLevels( rLocale
);
187 sal_Int32 nLength
= std::min
<sal_Int32
>(aNumberings
.getLength(), NUM_VALUSET_COUNT
);
189 const Sequence
<PropertyValue
>* pValuesArr
= aNumberings
.getConstArray();
190 for(sal_Int32 i
= 0; i
< nLength
; i
++)
192 SvxNumSettings_Impl
* pNew
= lcl_CreateNumSettingsPtr(pValuesArr
[i
]);
193 aNumSettingsArr
.push_back(std::unique_ptr
<SvxNumSettings_Impl
>(pNew
));
196 catch(const Exception
&)
199 Reference
<XNumberingFormatter
> xFormat(xDefNum
, UNO_QUERY
);
200 m_xExamplesVS
->SetNumberingSettings(aNumberings
, xFormat
, rLocale
);
204 SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
206 m_xExamplesVSWin
.reset();
207 m_xExamplesVS
.reset();
210 std::unique_ptr
<SfxTabPage
> SvxSingleNumPickTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
211 const SfxItemSet
* rAttrSet
)
213 return std::make_unique
<SvxSingleNumPickTabPage
>(pPage
, pController
, *rAttrSet
);
216 bool SvxSingleNumPickTabPage::FillItemSet( SfxItemSet
* rSet
)
218 if( (bPreset
|| bModified
) && pSaveNum
)
220 *pSaveNum
= *pActNum
;
221 rSet
->Put(SvxNumBulletItem( *pSaveNum
, nNumItemId
));
222 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
228 void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
230 const SfxPoolItem
* pItem
;
232 bool bIsPreset
= false;
233 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
236 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
237 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
238 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
239 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
241 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
243 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
245 if(pActNum
&& *pSaveNum
!= *pActNum
)
247 *pActNum
= *pSaveNum
;
248 m_xExamplesVS
->SetNoSelection();
251 if(pActNum
&& (!lcl_IsNumFmtSet(pActNum
.get(), nActNumLvl
) || bIsPreset
))
253 m_xExamplesVS
->SelectItem(1);
254 NumSelectHdl_Impl(m_xExamplesVS
.get());
257 bPreset
|= bIsPreset
;
262 DeactivateRC
SvxSingleNumPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
266 return DeactivateRC::LeavePage
;
269 void SvxSingleNumPickTabPage::Reset( const SfxItemSet
* rSet
)
271 const SfxPoolItem
* pItem
;
273 // in Draw the item exists as WhichId, in Writer only as SlotId
274 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
275 if(eState
!= SfxItemState::SET
)
277 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
278 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
280 if( eState
!= SfxItemState::SET
)
282 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
) );
283 eState
= SfxItemState::SET
;
286 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
287 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
290 pActNum
.reset( new SvxNumRule(*pSaveNum
) );
291 else if(*pSaveNum
!= *pActNum
)
292 *pActNum
= *pSaveNum
;
295 IMPL_LINK_NOARG(SvxSingleNumPickTabPage
, NumSelectHdl_Impl
, SvtValueSet
*, void)
301 sal_uInt16 nIdx
= m_xExamplesVS
->GetSelectedItemId() - 1;
302 DBG_ASSERT(aNumSettingsArr
.size() > nIdx
, "wrong index");
303 if(aNumSettingsArr
.size() <= nIdx
)
305 SvxNumSettings_Impl
* _pSet
= aNumSettingsArr
[nIdx
].get();
306 SvxNumType eNewType
= _pSet
->nNumberType
;
307 const sal_Unicode cLocalPrefix
= !_pSet
->sPrefix
.isEmpty() ? _pSet
->sPrefix
[0] : 0;
308 const sal_Unicode cLocalSuffix
= !_pSet
->sSuffix
.isEmpty() ? _pSet
->sSuffix
[0] : 0;
310 sal_uInt16 nMask
= 1;
311 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
313 if(nActNumLvl
& nMask
)
315 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
316 aFmt
.SetNumberingType(eNewType
);
317 if(cLocalPrefix
== ' ')
318 aFmt
.SetPrefix( "" );
320 aFmt
.SetPrefix(_pSet
->sPrefix
);
321 if(cLocalSuffix
== ' ')
322 aFmt
.SetSuffix( "" );
324 aFmt
.SetSuffix(_pSet
->sSuffix
);
325 aFmt
.SetCharFormatName("");
326 aFmt
.SetBulletRelSize(100);
327 pActNum
->SetLevel(i
, aFmt
);
334 IMPL_LINK_NOARG(SvxSingleNumPickTabPage
, DoubleClickHdl_Impl
, SvtValueSet
*, void)
336 NumSelectHdl_Impl(m_xExamplesVS
.get());
337 weld::Button
& rOk
= GetDialogController()->GetOKButton();
341 SvxBulletPickTabPage::SvxBulletPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
342 : SfxTabPage(pPage
, pController
, "cui/ui/pickbulletpage.ui", "PickBulletPage", &rSet
)
343 , nActNumLvl(SAL_MAX_UINT16
)
346 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
347 , m_xExamplesVS(new NumValueSet(nullptr))
348 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder
, "valueset", *m_xExamplesVS
))
350 SetExchangeSupport();
351 m_xExamplesVS
->init(NumberingPageType::BULLET
);
352 m_xExamplesVS
->SetSelectHdl(LINK(this, SvxBulletPickTabPage
, NumSelectHdl_Impl
));
353 m_xExamplesVS
->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage
, DoubleClickHdl_Impl
));
356 SvxBulletPickTabPage::~SvxBulletPickTabPage()
358 m_xExamplesVSWin
.reset();
359 m_xExamplesVS
.reset();
362 std::unique_ptr
<SfxTabPage
> SvxBulletPickTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
363 const SfxItemSet
* rAttrSet
)
365 return std::make_unique
<SvxBulletPickTabPage
>(pPage
, pController
, *rAttrSet
);
368 bool SvxBulletPickTabPage::FillItemSet( SfxItemSet
* rSet
)
370 if( (bPreset
|| bModified
) && pActNum
)
372 *pSaveNum
= *pActNum
;
373 rSet
->Put(SvxNumBulletItem( *pSaveNum
, nNumItemId
));
374 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
379 void SvxBulletPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
381 const SfxPoolItem
* pItem
;
383 bool bIsPreset
= false;
384 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
387 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
388 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
389 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
390 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
392 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
394 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
396 if(pActNum
&& *pSaveNum
!= *pActNum
)
398 *pActNum
= *pSaveNum
;
399 m_xExamplesVS
->SetNoSelection();
402 if(pActNum
&& (!lcl_IsNumFmtSet(pActNum
.get(), nActNumLvl
) || bIsPreset
))
404 m_xExamplesVS
->SelectItem(1);
405 NumSelectHdl_Impl(m_xExamplesVS
.get());
408 bPreset
|= bIsPreset
;
412 DeactivateRC
SvxBulletPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
416 return DeactivateRC::LeavePage
;
419 void SvxBulletPickTabPage::Reset( const SfxItemSet
* rSet
)
421 const SfxPoolItem
* pItem
;
422 // in Draw the item exists as WhichId, in Writer only as SlotId
423 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
424 if(eState
!= SfxItemState::SET
)
426 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
427 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
429 if( eState
!= SfxItemState::SET
)
431 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
) );
432 eState
= SfxItemState::SET
;
436 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
437 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
440 pActNum
.reset( new SvxNumRule(*pSaveNum
) );
441 else if(*pSaveNum
!= *pActNum
)
442 *pActNum
= *pSaveNum
;
445 IMPL_LINK_NOARG(SvxBulletPickTabPage
, NumSelectHdl_Impl
, SvtValueSet
*, void)
451 sal_Unicode cChar
= aBulletTypes
[m_xExamplesVS
->GetSelectedItemId() - 1];
452 const vcl::Font
& rActBulletFont
= lcl_GetDefaultBulletFont();
454 sal_uInt16 nMask
= 1;
455 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
457 if(nActNumLvl
& nMask
)
459 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
460 aFmt
.SetNumberingType( SVX_NUM_CHAR_SPECIAL
);
461 // #i93908# clear suffix for bullet lists
462 aFmt
.SetPrefix( OUString() );
463 aFmt
.SetSuffix( OUString() );
464 aFmt
.SetBulletFont(&rActBulletFont
);
465 aFmt
.SetBulletChar(cChar
);
466 aFmt
.SetCharFormatName(sBulletCharFormatName
);
467 aFmt
.SetBulletRelSize(45);
468 pActNum
->SetLevel(i
, aFmt
);
475 IMPL_LINK_NOARG(SvxBulletPickTabPage
, DoubleClickHdl_Impl
, SvtValueSet
*, void)
477 NumSelectHdl_Impl(m_xExamplesVS
.get());
478 weld::Button
& rOk
= GetDialogController()->GetOKButton();
482 void SvxBulletPickTabPage::PageCreated(const SfxAllItemSet
& aSet
)
484 const SfxStringItem
* pBulletCharFmt
= aSet
.GetItem
<SfxStringItem
>(SID_BULLET_CHAR_FMT
, false);
487 sBulletCharFormatName
= pBulletCharFmt
->GetValue();
490 SvxNumPickTabPage::SvxNumPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
491 : SfxTabPage(pPage
, pController
, "cui/ui/pickoutlinepage.ui", "PickOutlinePage", &rSet
)
492 , nActNumLvl(SAL_MAX_UINT16
)
493 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
496 , m_xExamplesVS(new NumValueSet(nullptr))
497 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder
, "valueset", *m_xExamplesVS
))
499 SetExchangeSupport();
501 m_xExamplesVS
->init(NumberingPageType::OUTLINE
);
502 m_xExamplesVS
->SetSelectHdl(LINK(this, SvxNumPickTabPage
, NumSelectHdl_Impl
));
503 m_xExamplesVS
->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage
, DoubleClickHdl_Impl
));
505 Reference
<XDefaultNumberingProvider
> xDefNum
= SvxNumOptionsTabPageHelper::GetNumberingProvider();
508 Sequence
<Reference
<XIndexAccess
> > aOutlineAccess
;
509 const Locale
& rLocale
= Application::GetSettings().GetLanguageTag().getLocale();
512 aOutlineAccess
= xDefNum
->getDefaultOutlineNumberings( rLocale
);
514 for(sal_Int32 nItem
= 0;
515 nItem
< aOutlineAccess
.getLength() && nItem
< NUM_VALUSET_COUNT
;
518 SvxNumSettingsArr_Impl
& rItemArr
= aNumSettingsArrays
[ nItem
];
520 Reference
<XIndexAccess
> xLevel
= aOutlineAccess
.getConstArray()[nItem
];
521 for(sal_Int32 nLevel
= 0; nLevel
< xLevel
->getCount() && nLevel
< 5; nLevel
++)
523 Any aValueAny
= xLevel
->getByIndex(nLevel
);
524 Sequence
<PropertyValue
> aLevelProps
;
525 aValueAny
>>= aLevelProps
;
526 SvxNumSettings_Impl
* pNew
= lcl_CreateNumSettingsPtr(aLevelProps
);
527 rItemArr
.push_back( std::unique_ptr
<SvxNumSettings_Impl
>(pNew
) );
531 catch(const Exception
&)
534 Reference
<XNumberingFormatter
> xFormat(xDefNum
, UNO_QUERY
);
535 m_xExamplesVS
->SetOutlineNumberingSettings(aOutlineAccess
, xFormat
, rLocale
);
539 SvxNumPickTabPage::~SvxNumPickTabPage()
541 m_xExamplesVSWin
.reset();
542 m_xExamplesVS
.reset();
545 std::unique_ptr
<SfxTabPage
> SvxNumPickTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
546 const SfxItemSet
* rAttrSet
)
548 return std::make_unique
<SvxNumPickTabPage
>(pPage
, pController
, *rAttrSet
);
551 bool SvxNumPickTabPage::FillItemSet( SfxItemSet
* rSet
)
553 if( (bPreset
|| bModified
) && pActNum
)
555 *pSaveNum
= *pActNum
;
556 rSet
->Put(SvxNumBulletItem( *pSaveNum
, nNumItemId
));
557 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
562 void SvxNumPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
564 const SfxPoolItem
* pItem
;
566 bool bIsPreset
= false;
567 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
570 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
571 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
572 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
573 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
575 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
577 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
579 if(pActNum
&& *pSaveNum
!= *pActNum
)
581 *pActNum
= *pSaveNum
;
582 m_xExamplesVS
->SetNoSelection();
585 if(pActNum
&& (!lcl_IsNumFmtSet(pActNum
.get(), nActNumLvl
) || bIsPreset
))
587 m_xExamplesVS
->SelectItem(1);
588 NumSelectHdl_Impl(m_xExamplesVS
.get());
591 bPreset
|= bIsPreset
;
595 DeactivateRC
SvxNumPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
599 return DeactivateRC::LeavePage
;
602 void SvxNumPickTabPage::Reset( const SfxItemSet
* rSet
)
604 const SfxPoolItem
* pItem
;
605 // in Draw the item exists as WhichId, in Writer only as SlotId
606 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
607 if(eState
!= SfxItemState::SET
)
609 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
610 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
612 if( eState
!= SfxItemState::SET
)
614 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
) );
615 eState
= SfxItemState::SET
;
619 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
620 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
623 pActNum
.reset( new SvxNumRule(*pSaveNum
) );
624 else if(*pSaveNum
!= *pActNum
)
625 *pActNum
= *pSaveNum
;
629 // all levels are changed here
630 IMPL_LINK_NOARG(SvxNumPickTabPage
, NumSelectHdl_Impl
, SvtValueSet
*, void)
637 const FontList
* pList
= nullptr;
639 SvxNumSettingsArr_Impl
& rItemArr
= aNumSettingsArrays
[m_xExamplesVS
->GetSelectedItemId() - 1];
641 const vcl::Font
& rActBulletFont
= lcl_GetDefaultBulletFont();
642 SvxNumSettings_Impl
* pLevelSettings
= nullptr;
643 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
645 if(rItemArr
.size() > i
)
646 pLevelSettings
= rItemArr
[i
].get();
649 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
650 aFmt
.SetNumberingType( pLevelSettings
->nNumberType
);
651 sal_uInt16 nUpperLevelOrChar
= static_cast<sal_uInt16
>(pLevelSettings
->nParentNumbering
);
652 if(aFmt
.GetNumberingType() == SVX_NUM_CHAR_SPECIAL
)
654 // #i93908# clear suffix for bullet lists
655 aFmt
.SetPrefix(OUString());
656 aFmt
.SetSuffix(OUString());
657 if( !pLevelSettings
->sBulletFont
.isEmpty() &&
658 pLevelSettings
->sBulletFont
!= rActBulletFont
.GetFamilyName())
660 //search for the font
663 SfxObjectShell
* pCurDocShell
= SfxObjectShell::Current();
664 const SvxFontListItem
* pFontListItem
=
665 static_cast<const SvxFontListItem
*>( pCurDocShell
666 ->GetItem( SID_ATTR_CHAR_FONTLIST
));
667 pList
= pFontListItem
? pFontListItem
->GetFontList() : nullptr;
669 if(pList
&& pList
->IsAvailable( pLevelSettings
->sBulletFont
) )
671 FontMetric aFontMetric
= pList
->Get(
672 pLevelSettings
->sBulletFont
,WEIGHT_NORMAL
, ITALIC_NONE
);
673 vcl::Font
aFont(aFontMetric
);
674 aFmt
.SetBulletFont(&aFont
);
678 //if it cannot be found then create a new one
679 vcl::Font
aCreateFont( pLevelSettings
->sBulletFont
,
680 OUString(), Size( 0, 14 ) );
681 aCreateFont
.SetCharSet( RTL_TEXTENCODING_DONTKNOW
);
682 aCreateFont
.SetFamily( FAMILY_DONTKNOW
);
683 aCreateFont
.SetPitch( PITCH_DONTKNOW
);
684 aCreateFont
.SetWeight( WEIGHT_DONTKNOW
);
685 aCreateFont
.SetTransparent( true );
686 aFmt
.SetBulletFont( &aCreateFont
);
690 aFmt
.SetBulletFont( &rActBulletFont
);
692 aFmt
.SetBulletChar( !pLevelSettings
->sBulletChar
.isEmpty()
693 ? pLevelSettings
->sBulletChar
[0]
695 aFmt
.SetCharFormatName( sBulletCharFormatName
);
696 aFmt
.SetBulletRelSize(45);
700 aFmt
.SetIncludeUpperLevels(sal::static_int_cast
< sal_uInt8
>(0 != nUpperLevelOrChar
? pActNum
->GetLevelCount() : 0));
701 aFmt
.SetCharFormatName(sNumCharFmtName
);
702 aFmt
.SetBulletRelSize(100);
704 aFmt
.SetPrefix(pLevelSettings
->sPrefix
);
705 aFmt
.SetSuffix(pLevelSettings
->sSuffix
);
707 pActNum
->SetLevel(i
, aFmt
);
712 IMPL_LINK_NOARG(SvxNumPickTabPage
, DoubleClickHdl_Impl
, SvtValueSet
*, void)
714 NumSelectHdl_Impl(m_xExamplesVS
.get());
715 weld::Button
& rOk
= GetDialogController()->GetOKButton();
719 void SvxNumPickTabPage::PageCreated(const SfxAllItemSet
& aSet
)
721 const SfxStringItem
* pNumCharFmt
= aSet
.GetItem
<SfxStringItem
>(SID_NUM_CHAR_FMT
, false);
722 const SfxStringItem
* pBulletCharFmt
= aSet
.GetItem
<SfxStringItem
>(SID_BULLET_CHAR_FMT
, false);
725 if (pNumCharFmt
&&pBulletCharFmt
)
726 SetCharFormatNames( pNumCharFmt
->GetValue(),pBulletCharFmt
->GetValue());
729 SvxBitmapPickTabPage::SvxBitmapPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
730 : SfxTabPage(pPage
, pController
, "cui/ui/pickgraphicpage.ui", "PickGraphicPage", &rSet
)
731 , nActNumLvl(SAL_MAX_UINT16
)
732 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
735 , m_xErrorText(m_xBuilder
->weld_label("errorft"))
736 , m_xBtBrowseFile(m_xBuilder
->weld_button("browseBtn"))
737 , m_xExamplesVS(new SvxBmpNumValueSet(m_xBuilder
->weld_scrolled_window("valuesetwin")))
738 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder
, "valueset", *m_xExamplesVS
))
740 SetExchangeSupport();
742 m_xExamplesVS
->init();
743 m_xExamplesVS
->SetSelectHdl(LINK(this, SvxBitmapPickTabPage
, NumSelectHdl_Impl
));
744 m_xExamplesVS
->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage
, DoubleClickHdl_Impl
));
745 m_xBtBrowseFile
->connect_clicked(LINK(this, SvxBitmapPickTabPage
, ClickAddBrowseHdl_Impl
));
747 eCoreUnit
= rSet
.GetPool()->GetMetric(rSet
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
749 // determine graphic name
750 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, aGrfNames
);
753 for (auto & grfName
: aGrfNames
)
755 m_xExamplesVS
->InsertItem( i
+ 1, i
);
757 INetURLObject
aObj(grfName
);
758 if(aObj
.GetProtocol() == INetProtocol::File
)
759 grfName
= aObj
.PathToFileName();
761 m_xExamplesVS
->SetItemText( i
+ 1, grfName
);
765 if(aGrfNames
.empty())
767 m_xErrorText
->show();
771 m_xExamplesVS
->Show();
772 m_xExamplesVS
->SetFormat();
773 m_xExamplesVS
->Invalidate();
777 SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
779 m_xExamplesVSWin
.reset();
780 m_xExamplesVS
.reset();
783 std::unique_ptr
<SfxTabPage
> SvxBitmapPickTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
784 const SfxItemSet
* rAttrSet
)
786 return std::make_unique
<SvxBitmapPickTabPage
>(pPage
, pController
, *rAttrSet
);
789 void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
791 const SfxPoolItem
* pItem
;
793 bool bIsPreset
= false;
794 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
797 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
798 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
799 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
800 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
802 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
804 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
806 if(pActNum
&& *pSaveNum
!= *pActNum
)
808 *pActNum
= *pSaveNum
;
809 m_xExamplesVS
->SetNoSelection();
812 if(!aGrfNames
.empty() &&
813 (pActNum
&& (!lcl_IsNumFmtSet(pActNum
.get(), nActNumLvl
) || bIsPreset
)))
815 m_xExamplesVS
->SelectItem(1);
816 NumSelectHdl_Impl(m_xExamplesVS
.get());
819 bPreset
|= bIsPreset
;
823 DeactivateRC
SvxBitmapPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
827 return DeactivateRC::LeavePage
;
830 bool SvxBitmapPickTabPage::FillItemSet( SfxItemSet
* rSet
)
832 if ( aGrfNames
.empty() )
836 if( (bPreset
|| bModified
) && pActNum
)
838 *pSaveNum
= *pActNum
;
839 rSet
->Put(SvxNumBulletItem( *pSaveNum
, nNumItemId
) );
840 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
846 void SvxBitmapPickTabPage::Reset( const SfxItemSet
* rSet
)
848 const SfxPoolItem
* pItem
;
849 // in Draw the item exists as WhichId, in Writer only as SlotId
850 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
851 if(eState
!= SfxItemState::SET
)
853 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
854 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
856 if( eState
!= SfxItemState::SET
)
858 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
) );
859 eState
= SfxItemState::SET
;
863 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
864 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
867 pActNum
.reset( new SvxNumRule(*pSaveNum
) );
868 else if(*pSaveNum
!= *pActNum
)
869 *pActNum
= *pSaveNum
;
872 IMPL_LINK_NOARG(SvxBitmapPickTabPage
, NumSelectHdl_Impl
, SvtValueSet
*, void)
878 sal_uInt16 nIdx
= m_xExamplesVS
->GetSelectedItemId() - 1;
880 sal_uInt16 nMask
= 1;
881 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
883 if(nActNumLvl
& nMask
)
885 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
886 aFmt
.SetNumberingType(SVX_NUM_BITMAP
);
887 aFmt
.SetPrefix( "" );
888 aFmt
.SetSuffix( "" );
889 aFmt
.SetCharFormatName( "" );
892 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, nIdx
, &aGraphic
))
894 Size aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
895 sal_Int16 eOrient
= text::VertOrientation::LINE_CENTER
;
896 aSize
= OutputDevice::LogicToLogic(aSize
, MapMode(MapUnit::Map100thMM
), MapMode(eCoreUnit
));
897 SvxBrushItem
aBrush(aGraphic
, GPOS_AREA
, SID_ATTR_BRUSH
);
898 aFmt
.SetGraphicBrush( &aBrush
, &aSize
, &eOrient
);
900 else if(aGrfNames
.size() > nIdx
)
901 aFmt
.SetGraphic( aGrfNames
[nIdx
] );
902 pActNum
->SetLevel(i
, aFmt
);
909 IMPL_LINK_NOARG(SvxBitmapPickTabPage
, DoubleClickHdl_Impl
, SvtValueSet
*, void)
911 NumSelectHdl_Impl(m_xExamplesVS
.get());
912 weld::Button
& rOk
= GetDialogController()->GetOKButton();
916 IMPL_LINK_NOARG(SvxBitmapPickTabPage
, ClickAddBrowseHdl_Impl
, weld::Button
&, void)
918 sfx2::FileDialogHelper
aFileDialog(0, FileDialogFlags::NONE
, GetFrameWeld());
919 aFileDialog
.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE
));
920 if ( aFileDialog
.Execute() != ERRCODE_NONE
)
923 OUString aPath
= SvtPathOptions().GetGalleryPath();
924 OUString aPathToken
= aPath
.getToken( 1 , SEARCHPATH_DELIMITER
);
926 OUString aUserImageURL
= aFileDialog
.GetPath();
929 const sal_Int32 nPos
{aUserImageURL
.lastIndexOf(SEARCHFILENAME_DELIMITER
)+1};
931 aFileName
= aUserImageURL
;
932 else if (nPos
<aUserImageURL
.getLength())
933 aFileName
= aUserImageURL
.copy(nPos
);
935 OUString aUserGalleryURL
= aPathToken
+ "/" + aFileName
;
936 INetURLObject
aURL( aUserImageURL
);
937 DBG_ASSERT( aURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
939 GraphicDescriptor
aDescriptor(aURL
);
940 if (aDescriptor
.Detect())
942 uno::Reference
< lang::XMultiServiceFactory
> xFactory
= ::comphelper::getProcessServiceFactory();
943 uno::Reference
<ucb::XSimpleFileAccess3
> xSimpleFileAccess(
944 ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory
) ) );
945 if ( xSimpleFileAccess
->exists( aUserImageURL
))
947 xSimpleFileAccess
->copy( aUserImageURL
, aUserGalleryURL
);
948 INetURLObject
gURL( aUserGalleryURL
);
949 std::unique_ptr
<SvStream
> pIn(::utl::UcbStreamHelper::CreateStream(
950 gURL
.GetMainURL( INetURLObject::DecodeMechanism::NONE
), StreamMode::READ
));
954 GraphicConverter::Import( *pIn
, aGraphic
);
956 BitmapEx aBitmap
= aGraphic
.GetBitmapEx();
957 long nPixelX
= aBitmap
.GetSizePixel().Width();
958 long nPixelY
= aBitmap
.GetSizePixel().Height();
959 double ratio
= nPixelY
/static_cast<double>(nPixelX
);
963 nPixelY
= static_cast<long>(nPixelX
*ratio
);
968 nPixelX
= static_cast<long>(nPixelY
/ratio
);
971 aBitmap
.Scale( Size( nPixelX
, nPixelY
), BmpScaleFlag::Fast
);
972 Graphic
aScaledGraphic( aBitmap
);
973 GraphicFilter
& rFilter
= GraphicFilter::GetGraphicFilter();
975 Sequence
< PropertyValue
> aFilterData( 2 );
976 aFilterData
[ 0 ].Name
= "Compression";
977 aFilterData
[ 0 ].Value
<<= sal_Int32(-1) ;
978 aFilterData
[ 1 ].Name
= "Quality";
979 aFilterData
[ 1 ].Value
<<= sal_Int32(1);
981 sal_uInt16 nFilterFormat
= rFilter
.GetExportFormatNumberForShortName( gURL
.GetFileExtension() );
982 rFilter
.ExportGraphic( aScaledGraphic
, gURL
, nFilterFormat
, &aFilterData
);
983 GalleryExplorer::InsertURL( GALLERY_THEME_BULLETS
, aUserGalleryURL
);
985 aGrfNames
.push_back(aUserGalleryURL
);
987 for (auto & grfName
: aGrfNames
)
989 m_xExamplesVS
->InsertItem( i
+ 1, i
);
990 INetURLObject
aObj(grfName
);
991 if(aObj
.GetProtocol() == INetProtocol::File
)
992 grfName
= aObj
.PathToFileName();
993 m_xExamplesVS
->SetItemText( i
+ 1, grfName
);
997 if(aGrfNames
.empty())
999 m_xErrorText
->show();
1003 m_xExamplesVS
->Show();
1004 m_xExamplesVS
->SetFormat();
1013 // tabpage numbering options
1014 SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container
* pPage
, weld::DialogController
* pController
,
1015 const SfxItemSet
& rSet
)
1016 : SfxTabPage(pPage
, pController
, "cui/ui/numberingoptionspage.ui", "NumberingOptionsPage", &rSet
)
1017 , bLastWidthModified(false)
1020 , bAutomaticCharStyles(true)
1024 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
1025 , m_xGrid(m_xBuilder
->weld_widget("grid2"))
1026 , m_xLevelLB(m_xBuilder
->weld_tree_view("levellb"))
1027 , m_xFmtLB(m_xBuilder
->weld_combo_box("numfmtlb"))
1028 , m_xSeparatorFT(m_xBuilder
->weld_label("separator"))
1029 , m_xPrefixFT(m_xBuilder
->weld_label("prefixft"))
1030 , m_xPrefixED(m_xBuilder
->weld_entry("prefix"))
1031 , m_xSuffixFT(m_xBuilder
->weld_label("suffixft"))
1032 , m_xSuffixED(m_xBuilder
->weld_entry("suffix"))
1033 , m_xCharFmtFT(m_xBuilder
->weld_label("charstyleft"))
1034 , m_xCharFmtLB(m_xBuilder
->weld_combo_box("charstyle"))
1035 , m_xBulColorFT(m_xBuilder
->weld_label("colorft"))
1036 , m_xBulColLB(new ColorListBox(m_xBuilder
->weld_menu_button("color"), pController
->getDialog()))
1037 , m_xBulRelSizeFT(m_xBuilder
->weld_label("relsizeft"))
1038 , m_xBulRelSizeMF(m_xBuilder
->weld_metric_spin_button("relsize", FieldUnit::PERCENT
))
1039 , m_xAllLevelFT(m_xBuilder
->weld_label("sublevelsft"))
1040 , m_xAllLevelNF(m_xBuilder
->weld_spin_button("sublevels"))
1041 , m_xStartFT(m_xBuilder
->weld_label("startatft"))
1042 , m_xStartED(m_xBuilder
->weld_spin_button("startat"))
1043 , m_xBulletFT(m_xBuilder
->weld_label("bulletft"))
1044 , m_xBulletPB(m_xBuilder
->weld_button("bullet"))
1045 , m_xBitmapFT(m_xBuilder
->weld_label("bitmapft"))
1046 , m_xBitmapMB(m_xBuilder
->weld_menu_button("bitmap"))
1047 , m_xWidthFT(m_xBuilder
->weld_label("widthft"))
1048 , m_xWidthMF(m_xBuilder
->weld_metric_spin_button("widthmf", FieldUnit::CM
))
1049 , m_xHeightFT(m_xBuilder
->weld_label("heightft"))
1050 , m_xHeightMF(m_xBuilder
->weld_metric_spin_button("heightmf", FieldUnit::CM
))
1051 , m_xRatioCB(m_xBuilder
->weld_check_button("keepratio"))
1052 , m_xOrientFT(m_xBuilder
->weld_label("orientft"))
1053 , m_xOrientLB(m_xBuilder
->weld_combo_box("orientlb"))
1054 , m_xAllLevelsFrame(m_xBuilder
->weld_widget("levelsframe"))
1055 , m_xSameLevelCB(m_xBuilder
->weld_check_button("allsame"))
1056 , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder
, "preview", m_aPreviewWIN
))
1058 m_xBulColLB
->SetSlotId(SID_ATTR_CHAR_COLOR
);
1059 m_xBulRelSizeMF
->set_min(SVX_NUM_REL_SIZE_MIN
, FieldUnit::PERCENT
);
1060 m_xBulRelSizeMF
->set_increments(5, 50, FieldUnit::PERCENT
);
1061 SetExchangeSupport();
1062 aActBulletFont
= lcl_GetDefaultBulletFont();
1064 m_xBulletPB
->connect_clicked(LINK(this, SvxNumOptionsTabPage
, BulletHdl_Impl
));
1065 m_xFmtLB
->connect_changed(LINK(this, SvxNumOptionsTabPage
, NumberTypeSelectHdl_Impl
));
1066 m_xBitmapMB
->connect_selected(LINK(this, SvxNumOptionsTabPage
, GraphicHdl_Impl
));
1067 m_xBitmapMB
->connect_toggled(LINK(this, SvxNumOptionsTabPage
, PopupActivateHdl_Impl
));
1068 m_xLevelLB
->set_selection_mode(SelectionMode::Multiple
);
1069 m_xLevelLB
->connect_changed(LINK(this, SvxNumOptionsTabPage
, LevelHdl_Impl
));
1070 m_xCharFmtLB
->connect_changed(LINK(this, SvxNumOptionsTabPage
, CharFmtHdl_Impl
));
1071 m_xWidthMF
->connect_value_changed(LINK(this, SvxNumOptionsTabPage
, SizeHdl_Impl
));
1072 m_xHeightMF
->connect_value_changed(LINK(this, SvxNumOptionsTabPage
, SizeHdl_Impl
));
1073 m_xRatioCB
->connect_toggled(LINK(this, SvxNumOptionsTabPage
, RatioHdl_Impl
));
1074 m_xStartED
->connect_changed(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1075 m_xPrefixED
->connect_changed(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1076 m_xSuffixED
->connect_changed(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1077 m_xAllLevelNF
->connect_value_changed(LINK(this,SvxNumOptionsTabPage
, AllLevelHdl_Impl
));
1078 m_xOrientLB
->connect_changed(LINK(this, SvxNumOptionsTabPage
, OrientHdl_Impl
));
1079 m_xSameLevelCB
->connect_toggled(LINK(this, SvxNumOptionsTabPage
, SameLevelHdl_Impl
));
1080 m_xBulRelSizeMF
->connect_value_changed(LINK(this,SvxNumOptionsTabPage
, BulRelSizeHdl_Impl
));
1081 m_xBulColLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, BulColorHdl_Impl
));
1082 aInvalidateTimer
.SetInvokeHandler(LINK(this, SvxNumOptionsTabPage
, PreviewInvalidateHdl_Impl
));
1083 aInvalidateTimer
.SetTimeout(50);
1085 eCoreUnit
= rSet
.GetPool()->GetMetric(rSet
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
1087 // Fill ListBox with predefined / translated numbering types.
1088 sal_uInt32 nCount
= SvxNumberingTypeTable::Count();
1089 for (sal_uInt32 i
= 0; i
< nCount
; ++i
)
1091 m_xFmtLB
->append(OUString::number(SvxNumberingTypeTable::GetValue(i
)), SvxNumberingTypeTable::GetString(i
));
1094 // Get advanced numbering types from the component.
1095 // Watch out for the ugly
1096 // 136 == 0x88 == SVX_NUM_BITMAP|0x80 == SVX_NUM_BITMAP|LINK_TOKEN
1097 // to not remove that.
1098 SvxNumOptionsTabPageHelper::GetI18nNumbering( *m_xFmtLB
, (SVX_NUM_BITMAP
| LINK_TOKEN
));
1100 m_xFmtLB
->set_active(0);
1102 m_xCharFmtLB
->set_size_request(m_xCharFmtLB
->get_approximate_digit_width() * 10, -1);
1103 Size
aSize(m_xGrid
->get_preferred_size());
1104 m_xGrid
->set_size_request(aSize
.Width(), -1);
1107 SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
1109 m_xPreviewWIN
.reset();
1110 m_xBulColLB
.reset();
1115 void SvxNumOptionsTabPage::SetMetric(FieldUnit eMetric
)
1117 if(eMetric
== FieldUnit::MM
)
1119 m_xWidthMF
->set_digits(1);
1120 m_xHeightMF
->set_digits(1);
1122 m_xWidthMF
->set_unit(eMetric
);
1123 m_xHeightMF
->set_unit(eMetric
);
1126 std::unique_ptr
<SfxTabPage
> SvxNumOptionsTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
1127 const SfxItemSet
* rAttrSet
)
1129 return std::make_unique
<SvxNumOptionsTabPage
>(pPage
, pController
, *rAttrSet
);
1132 void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet
& rSet
)
1134 const SfxPoolItem
* pItem
;
1135 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
1136 sal_uInt16 nTmpNumLvl
= 1;
1139 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
1140 bPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1141 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
1142 nTmpNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1144 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
1146 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
1149 bModified
= (!pActNum
->Get( 0 ) || bPreset
);
1150 if(*pActNum
!= *pSaveNum
||
1151 nActNumLvl
!= nTmpNumLvl
)
1153 nActNumLvl
= nTmpNumLvl
;
1154 sal_uInt16 nMask
= 1;
1155 if (nActNumLvl
== SAL_MAX_UINT16
)
1156 m_xLevelLB
->select(pActNum
->GetLevelCount());
1157 if(nActNumLvl
!= SAL_MAX_UINT16
)
1159 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1161 if(nActNumLvl
& nMask
)
1162 m_xLevelLB
->select(i
);
1166 *pActNum
= *pSaveNum
;
1172 DeactivateRC
SvxNumOptionsTabPage::DeactivatePage(SfxItemSet
* _pSet
)
1176 return DeactivateRC::LeavePage
;
1179 bool SvxNumOptionsTabPage::FillItemSet( SfxItemSet
* rSet
)
1181 rSet
->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL
, nActNumLvl
));
1182 if(bModified
&& pActNum
)
1184 *pSaveNum
= *pActNum
;
1185 rSet
->Put(SvxNumBulletItem( *pSaveNum
, nNumItemId
));
1186 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, false));
1191 void SvxNumOptionsTabPage::Reset( const SfxItemSet
* rSet
)
1193 const SfxPoolItem
* pItem
;
1194 // in Draw the item exists as WhichId, in Writer only as SlotId
1195 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
1196 if(eState
!= SfxItemState::SET
)
1198 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
1199 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
1201 if( eState
!= SfxItemState::SET
)
1203 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
) );
1204 eState
= SfxItemState::SET
;
1208 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
1209 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
1212 if (!m_xLevelLB
->n_children())
1214 for(sal_uInt16 i
= 1; i
<= pSaveNum
->GetLevelCount(); i
++)
1215 m_xLevelLB
->append_text(OUString::number(i
));
1216 if(pSaveNum
->GetLevelCount() > 1)
1218 OUString sEntry
= "1 - " + OUString::number( pSaveNum
->GetLevelCount() );
1219 m_xLevelLB
->append_text(sEntry
);
1220 m_xLevelLB
->select_text(sEntry
);
1223 m_xLevelLB
->select(0);
1226 m_xLevelLB
->select(m_xLevelLB
->n_children() - 1);
1228 sal_uInt16 nMask
= 1;
1229 m_xLevelLB
->unselect_all();
1230 if (nActNumLvl
== SAL_MAX_UINT16
)
1232 m_xLevelLB
->select( pSaveNum
->GetLevelCount() );
1236 for(sal_uInt16 i
= 0; i
< pSaveNum
->GetLevelCount(); i
++)
1238 if(nActNumLvl
& nMask
)
1239 m_xLevelLB
->select( i
);
1245 pActNum
.reset( new SvxNumRule(*pSaveNum
) );
1246 else if(*pSaveNum
!= *pActNum
)
1247 *pActNum
= *pSaveNum
;
1248 m_aPreviewWIN
.SetNumRule(pActNum
.get());
1249 m_xSameLevelCB
->set_active(pActNum
->IsContinuousNumbering());
1251 SfxObjectShell
* pShell
;
1252 if ( SfxItemState::SET
== rSet
->GetItemState( SID_HTML_MODE
, false, &pItem
)
1253 || ( nullptr != ( pShell
= SfxObjectShell::Current()) &&
1254 nullptr != ( pItem
= pShell
->GetItem( SID_HTML_MODE
) ) ) )
1256 sal_uInt16 nHtmlMode
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1257 bHTMLMode
= 0 != (nHtmlMode
&HTMLMODE_ON
);
1260 bool bCharFmt
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE
);
1261 m_xCharFmtFT
->set_visible(bCharFmt
);
1262 m_xCharFmtLB
->set_visible(bCharFmt
);
1264 bool bContinuous
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
);
1266 bool bAllLevel
= bContinuous
&& !bHTMLMode
;
1267 m_xAllLevelFT
->set_visible(bAllLevel
);
1268 m_xAllLevelNF
->set_visible(bAllLevel
);
1270 m_xAllLevelsFrame
->set_visible(bContinuous
);
1272 // again misusage: in Draw there is numeration only until the bitmap
1273 // without SVX_NUM_NUMBER_NONE
1274 //remove types that are unsupported by Draw/Impress
1277 sal_Int32 nFmtCount
= m_xFmtLB
->get_count();
1278 for(sal_Int32 i
= nFmtCount
; i
; i
--)
1280 sal_uInt16 nEntryData
= m_xFmtLB
->get_id(i
- 1).toUInt32();
1281 if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
1282 (SVX_NUM_BITMAP
|LINK_TOKEN
) == nEntryData
)
1283 m_xFmtLB
->remove(i
- 1);
1286 //one must be enabled
1287 if(!pActNum
->IsFeatureSupported(SvxNumRuleFlags::ENABLE_LINKED_BMP
))
1289 auto nPos
= m_xFmtLB
->find_id(OUString::number(SVX_NUM_BITMAP
|LINK_TOKEN
));
1291 m_xFmtLB
->remove(nPos
);
1293 else if(!pActNum
->IsFeatureSupported(SvxNumRuleFlags::ENABLE_EMBEDDED_BMP
))
1295 auto nPos
= m_xFmtLB
->find_id(OUString::number(SVX_NUM_BITMAP
));
1297 m_xFmtLB
->remove(nPos
);
1300 // MegaHack: because of a not-fixable 'design mistake/error' in Impress
1301 // delete all kinds of numeric enumerations
1302 if(pActNum
->IsFeatureSupported(SvxNumRuleFlags::NO_NUMBERS
))
1304 sal_Int32 nFmtCount
= m_xFmtLB
->get_count();
1305 for(sal_Int32 i
= nFmtCount
; i
; i
--)
1307 sal_uInt16 nEntryData
= m_xFmtLB
->get_id(i
- 1).toUInt32();
1308 if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData
<= SVX_NUM_NUMBER_NONE
)
1309 m_xFmtLB
->remove(i
- 1);
1317 void SvxNumOptionsTabPage::InitControls()
1319 bool bShowBullet
= true;
1320 bool bShowBitmap
= true;
1321 bool bSameType
= true;
1322 bool bSameStart
= true;
1323 bool bSamePrefix
= true;
1324 bool bSameSuffix
= true;
1325 bool bAllLevel
= true;
1326 bool bSameCharFmt
= true;
1327 bool bSameVOrient
= true;
1328 bool bSameSize
= true;
1329 bool bSameBulColor
= true;
1330 bool bSameBulRelSize
= true;
1332 const SvxNumberFormat
* aNumFmtArr
[SVX_MAX_NUM
];
1333 OUString sFirstCharFmt
;
1334 sal_Int16 eFirstOrient
= text::VertOrientation::NONE
;
1335 Size
aFirstSize(0,0);
1336 sal_uInt16 nMask
= 1;
1337 sal_uInt16 nLvl
= SAL_MAX_UINT16
;
1338 sal_uInt16 nHighestLevel
= 0;
1340 bool bBullColor
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR
);
1341 bool bBullRelSize
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE
);
1342 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1344 if(nActNumLvl
& nMask
)
1346 aNumFmtArr
[i
] = &pActNum
->GetLevel(i
);
1347 bShowBullet
&= aNumFmtArr
[i
]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL
;
1348 bShowBitmap
&= (aNumFmtArr
[i
]->GetNumberingType()&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
;
1349 if(SAL_MAX_UINT16
== nLvl
)
1352 sFirstCharFmt
= aNumFmtArr
[i
]->GetCharFormatName();
1353 eFirstOrient
= aNumFmtArr
[i
]->GetVertOrient();
1355 aFirstSize
= aNumFmtArr
[i
]->GetGraphicSize();
1359 bSameType
&= aNumFmtArr
[i
]->GetNumberingType() == aNumFmtArr
[nLvl
]->GetNumberingType();
1360 bSameStart
= aNumFmtArr
[i
]->GetStart() == aNumFmtArr
[nLvl
]->GetStart();
1362 bSamePrefix
= aNumFmtArr
[i
]->GetPrefix() == aNumFmtArr
[nLvl
]->GetPrefix();
1363 bSameSuffix
= aNumFmtArr
[i
]->GetSuffix() == aNumFmtArr
[nLvl
]->GetSuffix();
1364 bAllLevel
&= aNumFmtArr
[i
]->GetIncludeUpperLevels() == aNumFmtArr
[nLvl
]->GetIncludeUpperLevels();
1365 bSameCharFmt
&= sFirstCharFmt
== aNumFmtArr
[i
]->GetCharFormatName();
1366 bSameVOrient
&= eFirstOrient
== aNumFmtArr
[i
]->GetVertOrient();
1367 if(bShowBitmap
&& bSameSize
)
1368 bSameSize
&= aNumFmtArr
[i
]->GetGraphicSize() == aFirstSize
;
1369 bSameBulColor
&= aNumFmtArr
[i
]->GetBulletColor() == aNumFmtArr
[nLvl
]->GetBulletColor();
1370 bSameBulRelSize
&= aNumFmtArr
[i
]->GetBulletRelSize() == aNumFmtArr
[nLvl
]->GetBulletRelSize();
1375 aNumFmtArr
[i
] = nullptr;
1379 SwitchNumberType(bShowBullet
? 1 : bShowBitmap
? 2 : 0);
1381 sal_uInt16 nNumberingType
;
1382 if (nLvl
!= SAL_MAX_UINT16
)
1383 nNumberingType
= aNumFmtArr
[nLvl
]->GetNumberingType();
1386 nNumberingType
= SVX_NUM_NUMBER_NONE
;
1388 bSameBulRelSize
= false;
1389 bSameBulColor
= false;
1391 bSamePrefix
= false;
1392 bSameSuffix
= false;
1395 CheckForStartValue_Impl(nNumberingType
);
1399 if(!bSameVOrient
|| eFirstOrient
== text::VertOrientation::NONE
)
1400 m_xOrientLB
->set_active(-1);
1402 m_xOrientLB
->set_active(
1403 sal::static_int_cast
< sal_Int32
>(eFirstOrient
- 1));
1404 // no text::VertOrientation::NONE
1408 SetMetricValue(*m_xHeightMF
, aFirstSize
.Height(), eCoreUnit
);
1409 SetMetricValue(*m_xWidthMF
, aFirstSize
.Width(), eCoreUnit
);
1413 m_xHeightMF
->set_text("");
1414 m_xWidthMF
->set_text("");
1420 sal_uInt16 nLBData
= nNumberingType
;
1421 m_xFmtLB
->set_active_id(OUString::number(nLBData
));
1424 m_xFmtLB
->set_active(-1);
1426 m_xAllLevelNF
->set_sensitive(nHighestLevel
> 0 && !m_xSameLevelCB
->get_active());
1427 m_xAllLevelNF
->set_max(nHighestLevel
+ 1);
1430 m_xAllLevelNF
->set_value(aNumFmtArr
[nLvl
]->GetIncludeUpperLevels());
1434 m_xAllLevelNF
->set_text("");
1440 m_xBulRelSizeMF
->set_value(aNumFmtArr
[nLvl
]->GetBulletRelSize(), FieldUnit::PERCENT
);
1442 m_xBulRelSizeMF
->set_text("");
1447 m_xBulColLB
->SelectEntry(aNumFmtArr
[nLvl
]->GetBulletColor());
1449 m_xBulColLB
->SetNoSelection();
1453 case SHOW_NUMBERING
:
1456 m_xStartED
->set_value(aNumFmtArr
[nLvl
]->GetStart());
1459 m_xStartED
->set_text("");
1468 m_xPrefixED
->set_text(aNumFmtArr
[nLvl
]->GetPrefix());
1470 m_xPrefixED
->set_text("");
1472 m_xSuffixED
->set_text(aNumFmtArr
[nLvl
]->GetSuffix());
1474 m_xSuffixED
->set_text("");
1478 if (!sFirstCharFmt
.isEmpty())
1479 m_xCharFmtLB
->set_active_text(sFirstCharFmt
);
1481 m_xCharFmtLB
->set_active(0);
1484 m_xCharFmtLB
->set_active(-1);
1486 m_aPreviewWIN
.SetLevel(nActNumLvl
);
1487 m_aPreviewWIN
.Invalidate();
1490 // 0 - Number; 1 - Bullet; 2 - Bitmap
1491 void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType
)
1493 if(nBullet
== nType
)
1496 bool bBullet
= (nType
== SHOW_BULLET
);
1497 bool bBitmap
= (nType
== SHOW_BITMAP
);
1498 bool bEnableBitmap
= (nType
== SHOW_BITMAP
);
1499 bool bNumeric
= !(bBitmap
||bBullet
);
1500 m_xSeparatorFT
->set_visible(bNumeric
);
1501 m_xPrefixFT
->set_visible(bNumeric
);
1502 m_xPrefixED
->set_visible(bNumeric
);
1503 m_xSuffixFT
->set_visible(bNumeric
);
1504 m_xSuffixED
->set_visible(bNumeric
);
1506 bool bCharFmt
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE
);
1507 m_xCharFmtFT
->set_visible(!bBitmap
&& bCharFmt
);
1508 m_xCharFmtLB
->set_visible(!bBitmap
&& bCharFmt
);
1510 // this is rather misusage, as there is no own flag
1511 // for complete numeration
1512 bool bAllLevelFeature
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
);
1513 bool bAllLevel
= bNumeric
&& bAllLevelFeature
&& !bHTMLMode
;
1514 m_xAllLevelFT
->set_visible(bAllLevel
);
1515 m_xAllLevelNF
->set_visible(bAllLevel
);
1517 m_xStartFT
->set_visible(!(bBullet
||bBitmap
));
1518 m_xStartED
->set_visible(!(bBullet
||bBitmap
));
1520 m_xBulletFT
->set_visible(bBullet
);
1521 m_xBulletPB
->set_visible(bBullet
);
1522 bool bBullColor
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR
);
1523 m_xBulColorFT
->set_visible(!bBitmap
&& bBullColor
);
1524 m_xBulColLB
->set_visible(!bBitmap
&& bBullColor
);
1525 bool bBullResSize
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE
);
1526 m_xBulRelSizeFT
->set_visible(!bBitmap
&& bBullResSize
);
1527 m_xBulRelSizeMF
->set_visible(!bBitmap
&& bBullResSize
);
1529 m_xBitmapFT
->set_visible(bBitmap
);
1530 m_xBitmapMB
->set_visible(bBitmap
);
1532 m_xWidthFT
->set_visible(bBitmap
);
1533 m_xWidthMF
->set_visible(bBitmap
);
1534 m_xHeightFT
->set_visible(bBitmap
);
1535 m_xHeightMF
->set_visible(bBitmap
);
1536 m_xRatioCB
->set_visible(bBitmap
);
1538 m_xOrientFT
->set_visible(bBitmap
&& bAllLevelFeature
);
1539 m_xOrientLB
->set_visible(bBitmap
&& bAllLevelFeature
);
1541 m_xWidthFT
->set_sensitive(bEnableBitmap
);
1542 m_xWidthMF
->set_sensitive(bEnableBitmap
);
1543 m_xHeightFT
->set_sensitive(bEnableBitmap
);
1544 m_xHeightMF
->set_sensitive(bEnableBitmap
);
1545 m_xRatioCB
->set_sensitive(bEnableBitmap
);
1546 m_xOrientFT
->set_sensitive(bEnableBitmap
);
1547 m_xOrientLB
->set_sensitive(bEnableBitmap
);
1550 IMPL_LINK(SvxNumOptionsTabPage
, LevelHdl_Impl
, weld::TreeView
&, rBox
, void)
1552 sal_uInt16 nSaveNumLvl
= nActNumLvl
;
1554 auto aSelectedRows
= rBox
.get_selected_rows();
1555 if (std::find(aSelectedRows
.begin(), aSelectedRows
.end(), pActNum
->GetLevelCount()) != aSelectedRows
.end() &&
1556 (aSelectedRows
.size() == 1 || nSaveNumLvl
!= 0xffff))
1558 nActNumLvl
= 0xFFFF;
1559 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
1562 else if (!aSelectedRows
.empty())
1564 sal_uInt16 nMask
= 1;
1565 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
1567 if (std::find(aSelectedRows
.begin(), aSelectedRows
.end(), i
) != aSelectedRows
.end())
1568 nActNumLvl
|= nMask
;
1571 rBox
.unselect(pActNum
->GetLevelCount());
1575 nActNumLvl
= nSaveNumLvl
;
1576 sal_uInt16 nMask
= 1;
1577 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
1579 if(nActNumLvl
& nMask
)
1590 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, PreviewInvalidateHdl_Impl
, Timer
*, void)
1592 m_aPreviewWIN
.Invalidate();
1595 IMPL_LINK(SvxNumOptionsTabPage
, AllLevelHdl_Impl
, weld::SpinButton
&, rBox
, void)
1597 sal_uInt16 nMask
= 1;
1598 for(sal_uInt16 e
= 0; e
< pActNum
->GetLevelCount(); e
++)
1600 if(nActNumLvl
& nMask
)
1602 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(e
));
1603 aNumFmt
.SetIncludeUpperLevels(static_cast<sal_uInt8
>(std::min(rBox
.get_value(), int(e
+ 1))) );
1604 pActNum
->SetLevel(e
, aNumFmt
);
1611 IMPL_LINK(SvxNumOptionsTabPage
, NumberTypeSelectHdl_Impl
, weld::ComboBox
&, rBox
, void)
1613 OUString sSelectStyle
;
1614 bool bShowOrient
= false;
1616 sal_uInt16 nMask
= 1;
1617 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1619 if(nActNumLvl
& nMask
)
1621 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1622 // PAGEDESC does not exist
1623 SvxNumType nNumType
= static_cast<SvxNumType
>(rBox
.get_active_id().toUInt32());
1624 aNumFmt
.SetNumberingType(nNumType
);
1625 sal_uInt16 nNumberingType
= aNumFmt
.GetNumberingType();
1626 if(SVX_NUM_BITMAP
== (nNumberingType
&(~LINK_TOKEN
)))
1628 bBmp
|= nullptr != aNumFmt
.GetBrush();
1629 aNumFmt
.SetIncludeUpperLevels( 0 );
1630 aNumFmt
.SetSuffix( "" );
1631 aNumFmt
.SetPrefix( "" );
1633 aNumFmt
.SetGraphic("");
1634 pActNum
->SetLevel(i
, aNumFmt
);
1635 SwitchNumberType(SHOW_BITMAP
);
1638 else if( SVX_NUM_CHAR_SPECIAL
== nNumberingType
)
1640 aNumFmt
.SetIncludeUpperLevels( 0 );
1641 aNumFmt
.SetSuffix( "" );
1642 aNumFmt
.SetPrefix( "" );
1643 if( !aNumFmt
.GetBulletFont() )
1644 aNumFmt
.SetBulletFont(&aActBulletFont
);
1645 if( !aNumFmt
.GetBulletChar() )
1646 aNumFmt
.SetBulletChar( SVX_DEF_BULLET
);
1647 pActNum
->SetLevel(i
, aNumFmt
);
1648 SwitchNumberType(SHOW_BULLET
);
1649 // allocation of the drawing pattern is automatic
1650 if(bAutomaticCharStyles
)
1652 sSelectStyle
= m_sBulletCharFormatName
;
1657 aNumFmt
.SetPrefix( m_xPrefixED
->get_text() );
1658 aNumFmt
.SetSuffix( m_xSuffixED
->get_text() );
1659 SwitchNumberType(SHOW_NUMBERING
);
1660 pActNum
->SetLevel(i
, aNumFmt
);
1661 CheckForStartValue_Impl(nNumberingType
);
1663 // allocation of the drawing pattern is automatic
1664 if(bAutomaticCharStyles
)
1666 sSelectStyle
= m_sNumCharFmtName
;
1672 bool bAllLevelFeature
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
);
1673 if(bShowOrient
&& bAllLevelFeature
)
1675 m_xOrientFT
->show();
1676 m_xOrientLB
->show();
1680 m_xOrientFT
->hide();
1681 m_xOrientLB
->hide();
1684 if(!sSelectStyle
.isEmpty())
1686 m_xCharFmtLB
->set_active_text(sSelectStyle
);
1687 CharFmtHdl_Impl(*m_xCharFmtLB
);
1688 bAutomaticCharStyles
= true;
1692 void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType
)
1694 bool bIsNull
= m_xStartED
->get_value() == 0;
1695 bool bNoZeroAllowed
= nNumberingType
< SVX_NUM_ARABIC
||
1696 SVX_NUM_CHARS_UPPER_LETTER_N
== nNumberingType
||
1697 SVX_NUM_CHARS_LOWER_LETTER_N
== nNumberingType
;
1698 m_xStartED
->set_min(bNoZeroAllowed
? 1 : 0);
1699 if (bIsNull
&& bNoZeroAllowed
)
1700 EditModifyHdl_Impl(*m_xStartED
);
1703 IMPL_LINK(SvxNumOptionsTabPage
, OrientHdl_Impl
, weld::ComboBox
&, rBox
, void)
1705 sal_Int32 nPos
= rBox
.get_active();
1706 nPos
++; // no VERT_NONE
1708 sal_uInt16 nMask
= 1;
1709 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1711 if(nActNumLvl
& nMask
)
1713 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1714 if(SVX_NUM_BITMAP
== (aNumFmt
.GetNumberingType()&(~LINK_TOKEN
)))
1716 const SvxBrushItem
* pBrushItem
= aNumFmt
.GetBrush();
1717 const Size
& rSize
= aNumFmt
.GetGraphicSize();
1718 sal_Int16 eOrient
= static_cast<sal_Int16
>(nPos
);
1719 aNumFmt
.SetGraphicBrush( pBrushItem
, &rSize
, &eOrient
);
1720 pActNum
->SetLevel(i
, aNumFmt
);
1728 IMPL_LINK(SvxNumOptionsTabPage
, SameLevelHdl_Impl
, weld::ToggleButton
&, rBox
, void)
1730 bool bSet
= rBox
.get_active();
1731 pActNum
->SetContinuousNumbering(bSet
);
1732 bool bRepaint
= false;
1733 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1735 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1736 if(aNumFmt
.GetNumberingType() != SVX_NUM_NUMBER_NONE
)
1742 SetModified(bRepaint
);
1746 IMPL_LINK(SvxNumOptionsTabPage
, BulColorHdl_Impl
, ColorListBox
&, rColorBox
, void)
1748 Color nSetColor
= rColorBox
.GetSelectEntryColor();
1750 sal_uInt16 nMask
= 1;
1751 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1753 if(nActNumLvl
& nMask
)
1755 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1756 aNumFmt
.SetBulletColor(nSetColor
);
1757 pActNum
->SetLevel(i
, aNumFmt
);
1764 IMPL_LINK(SvxNumOptionsTabPage
, BulRelSizeHdl_Impl
, weld::MetricSpinButton
&, rField
, void)
1766 sal_uInt16 nRelSize
= rField
.get_value(FieldUnit::PERCENT
);
1768 sal_uInt16 nMask
= 1;
1769 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1771 if(nActNumLvl
& nMask
)
1773 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1774 aNumFmt
.SetBulletRelSize(nRelSize
);
1775 pActNum
->SetLevel(i
, aNumFmt
);
1782 IMPL_LINK(SvxNumOptionsTabPage
, GraphicHdl_Impl
, const OString
&, rIdent
, void)
1787 SvxOpenGraphicDialog
aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC
), GetFrameWeld());
1790 if (rIdent
.startsWith("gallery", &sNumber
))
1792 auto idx
= sNumber
.toUInt32();
1793 if (idx
< aGrfNames
.size())
1795 aGrfName
= aGrfNames
[idx
];
1797 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, idx
, &aGraphic
))
1799 aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
1804 else if (rIdent
== "fromfile")
1806 aGrfDlg
.EnableLink( false );
1807 aGrfDlg
.AsLink( false );
1808 if ( !aGrfDlg
.Execute() )
1810 // memorize selected filter
1811 aGrfName
= aGrfDlg
.GetPath();
1814 if( !aGrfDlg
.GetGraphic(aGraphic
) )
1816 aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
1823 aSize
= OutputDevice::LogicToLogic(aSize
, MapMode(MapUnit::Map100thMM
), MapMode(eCoreUnit
));
1825 sal_uInt16 nMask
= 1;
1826 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1828 if(nActNumLvl
& nMask
)
1830 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1831 aNumFmt
.SetCharFormatName(m_sNumCharFmtName
);
1832 aNumFmt
.SetGraphic(aGrfName
);
1834 // set size for a later comparison
1835 const SvxBrushItem
* pBrushItem
= aNumFmt
.GetBrush();
1836 // initiate asynchronous loading
1837 sal_Int16 eOrient
= aNumFmt
.GetVertOrient();
1838 aNumFmt
.SetGraphicBrush( pBrushItem
, &aSize
, &eOrient
);
1839 aInitSize
[i
] = aNumFmt
.GetGraphicSize();
1841 pActNum
->SetLevel(i
, aNumFmt
);
1845 m_xRatioCB
->set_sensitive(true);
1846 m_xWidthFT
->set_sensitive(true);
1847 m_xHeightFT
->set_sensitive(true);
1848 m_xWidthMF
->set_sensitive(true);
1849 m_xHeightMF
->set_sensitive(true);
1850 SetMetricValue(*m_xWidthMF
, aSize
.Width(), eCoreUnit
);
1851 SetMetricValue(*m_xHeightMF
, aSize
.Height(), eCoreUnit
);
1852 m_xOrientFT
->set_sensitive(true);
1853 m_xOrientLB
->set_sensitive(true);
1855 //needed due to asynchronous loading of graphics in the SvxBrushItem
1856 aInvalidateTimer
.Start();
1860 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, PopupActivateHdl_Impl
, weld::ToggleButton
&, void)
1862 if (!m_xGalleryMenu
)
1864 m_xGalleryMenu
= m_xBuilder
->weld_menu("gallerysubmenu");
1865 weld::WaitObject
aWait(GetFrameWeld());
1867 if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, aGrfNames
))
1869 GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS
);
1873 ScopedVclPtrInstance
< VirtualDevice
> pVD
;
1875 for (const auto & grfName
: aGrfNames
)
1878 OUString sItemId
= "gallery" + OUString::number(i
);
1879 INetURLObject
aObj(sGrfName
);
1880 if(aObj
.GetProtocol() == INetProtocol::File
)
1881 sGrfName
= aObj
.PathToFileName();
1882 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, i
, &aGraphic
))
1884 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1885 Size
aSize(aBitmap
.GetSizePixel());
1886 if(aSize
.Width() > MAX_BMP_WIDTH
||
1887 aSize
.Height() > MAX_BMP_HEIGHT
)
1889 bool bWidth
= aSize
.Width() > aSize
.Height();
1890 double nScale
= bWidth
?
1891 double(MAX_BMP_WIDTH
) / static_cast<double>(aSize
.Width()):
1892 double(MAX_BMP_HEIGHT
) / static_cast<double>(aSize
.Height());
1893 aBitmap
.Scale(nScale
, nScale
);
1895 pVD
->SetOutputSizePixel(aBitmap
.GetSizePixel(), false);
1896 pVD
->DrawBitmapEx(Point(), aBitmap
);
1897 m_xGalleryMenu
->append(sItemId
, sGrfName
, *pVD
);
1901 m_xGalleryMenu
->append(sItemId
, sGrfName
);
1905 GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS
);
1910 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, BulletHdl_Impl
, weld::Button
&, void)
1912 SvxCharacterMap
aMap(GetFrameWeld(), nullptr, nullptr);
1914 sal_uInt16 nMask
= 1;
1915 const vcl::Font
* pFmtFont
= nullptr;
1916 bool bSameBullet
= true;
1917 sal_Unicode cBullet
= 0;
1919 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1921 if(nActNumLvl
& nMask
)
1923 const SvxNumberFormat
& rCurFmt
= pActNum
->GetLevel(i
);
1926 cBullet
= rCurFmt
.GetBulletChar();
1928 else if(rCurFmt
.GetBulletChar() != cBullet
)
1930 bSameBullet
= false;
1934 pFmtFont
= rCurFmt
.GetBulletFont();
1942 aMap
.SetCharFont(*pFmtFont
);
1944 aMap
.SetCharFont(aActBulletFont
);
1946 aMap
.SetChar(cBullet
);
1947 if (aMap
.run() == RET_OK
)
1949 // change Font Numrules
1950 aActBulletFont
= aMap
.GetCharFont();
1952 sal_uInt16 _nMask
= 1;
1953 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1955 if(nActNumLvl
& _nMask
)
1957 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1958 aNumFmt
.SetBulletFont(&aActBulletFont
);
1959 aNumFmt
.SetBulletChar( static_cast<sal_Unicode
>(aMap
.GetChar()) );
1960 pActNum
->SetLevel(i
, aNumFmt
);
1969 IMPL_LINK( SvxNumOptionsTabPage
, SizeHdl_Impl
, weld::MetricSpinButton
&, rField
, void)
1971 bool bWidth
= &rField
== m_xWidthMF
.get();
1972 bLastWidthModified
= bWidth
;
1973 bool bRatio
= m_xRatioCB
->get_active();
1974 long nWidthVal
= static_cast<long>(m_xWidthMF
->denormalize(m_xWidthMF
->get_value(FieldUnit::MM_100TH
)));
1975 long nHeightVal
= static_cast<long>(m_xHeightMF
->denormalize(m_xHeightMF
->get_value(FieldUnit::MM_100TH
)));
1976 nWidthVal
= OutputDevice::LogicToLogic( nWidthVal
,
1977 MapUnit::Map100thMM
, eCoreUnit
);
1978 nHeightVal
= OutputDevice::LogicToLogic( nHeightVal
,
1979 MapUnit::Map100thMM
, eCoreUnit
);
1982 bool bRepaint
= false;
1983 sal_uInt16 nMask
= 1;
1984 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1986 if(nActNumLvl
& nMask
)
1988 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1989 if(SVX_NUM_BITMAP
== (aNumFmt
.GetNumberingType()&(~LINK_TOKEN
)))
1991 Size
aSize(aNumFmt
.GetGraphicSize() );
1992 Size
aSaveSize(aSize
);
1994 if (aInitSize
[i
].Height())
1995 fSizeRatio
= static_cast<double>(aInitSize
[i
].Width()) / static_cast<double>(aInitSize
[i
].Height());
1997 fSizeRatio
= double(1);
2001 long nDelta
= nWidthVal
- aInitSize
[i
].Width();
2002 aSize
.setWidth( nWidthVal
);
2005 aSize
.setHeight( aInitSize
[i
].Height() + static_cast<long>(static_cast<double>(nDelta
) / fSizeRatio
) );
2006 m_xHeightMF
->set_value(m_xHeightMF
->normalize(
2007 OutputDevice::LogicToLogic( aSize
.Height(), eCoreUnit
, MapUnit::Map100thMM
)),
2008 FieldUnit::MM_100TH
);
2013 long nDelta
= nHeightVal
- aInitSize
[i
].Height();
2014 aSize
.setHeight( nHeightVal
);
2017 aSize
.setWidth( aInitSize
[i
].Width() + static_cast<long>(static_cast<double>(nDelta
) * fSizeRatio
) );
2018 m_xWidthMF
->set_value(m_xWidthMF
->normalize(
2019 OutputDevice::LogicToLogic( aSize
.Width(), eCoreUnit
, MapUnit::Map100thMM
)),
2020 FieldUnit::MM_100TH
);
2023 const SvxBrushItem
* pBrushItem
= aNumFmt
.GetBrush();
2024 sal_Int16 eOrient
= aNumFmt
.GetVertOrient();
2025 if(aSize
!= aSaveSize
)
2027 aNumFmt
.SetGraphicBrush( pBrushItem
, &aSize
, &eOrient
);
2028 pActNum
->SetLevel(i
, aNumFmt
);
2033 SetModified(bRepaint
);
2036 IMPL_LINK(SvxNumOptionsTabPage
, RatioHdl_Impl
, weld::ToggleButton
&, rBox
, void)
2038 if (rBox
.get_active())
2040 if (bLastWidthModified
)
2041 SizeHdl_Impl(*m_xWidthMF
);
2043 SizeHdl_Impl(*m_xHeightMF
);
2047 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, CharFmtHdl_Impl
, weld::ComboBox
&, void)
2049 bAutomaticCharStyles
= false;
2050 sal_Int32 nEntryPos
= m_xCharFmtLB
->get_active();
2051 OUString sEntry
= m_xCharFmtLB
->get_active_text();
2052 sal_uInt16 nMask
= 1;
2053 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2055 if(nActNumLvl
& nMask
)
2057 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2058 if( 0 == nEntryPos
)
2059 aNumFmt
.SetCharFormatName("");
2062 if(SVX_NUM_BITMAP
!= (aNumFmt
.GetNumberingType()&(~LINK_TOKEN
)))
2063 aNumFmt
.SetCharFormatName(sEntry
);
2065 pActNum
->SetLevel(i
, aNumFmt
);
2072 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, EditListBoxHdl_Impl
, weld::ComboBox
&, void)
2074 EditModifyHdl_Impl(nullptr);
2077 IMPL_LINK(SvxNumOptionsTabPage
, EditModifyHdl_Impl
, weld::Entry
&, rEdit
, void)
2079 EditModifyHdl_Impl(&rEdit
);
2082 void SvxNumOptionsTabPage::EditModifyHdl_Impl(const weld::Entry
* pEdit
)
2084 bool bPrefix
= pEdit
== m_xPrefixED
.get();
2085 bool bSuffix
= pEdit
== m_xSuffixED
.get();
2086 bool bStart
= pEdit
== m_xStartED
.get();
2087 sal_uInt16 nMask
= 1;
2088 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2090 if(nActNumLvl
& nMask
)
2092 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2094 aNumFmt
.SetPrefix(m_xPrefixED
->get_text());
2096 aNumFmt
.SetSuffix(m_xSuffixED
->get_text());
2098 aNumFmt
.SetStart(m_xStartED
->get_value());
2099 pActNum
->SetLevel(i
, aNumFmt
);
2106 static long lcl_DrawGraphic(VirtualDevice
* pVDev
, const SvxNumberFormat
&rFmt
, long nXStart
,
2107 long nYMiddle
, long nDivision
)
2109 const SvxBrushItem
* pBrushItem
= rFmt
.GetBrush();
2113 const Graphic
* pGrf
= pBrushItem
->GetGraphic();
2116 Size
aGSize( rFmt
.GetGraphicSize() );
2117 aGSize
.setWidth( aGSize
.Width() / nDivision
);
2118 nRet
= aGSize
.Width();
2119 aGSize
.setHeight( aGSize
.Height() / nDivision
);
2120 pGrf
->Draw( pVDev
, Point(nXStart
,nYMiddle
- ( aGSize
.Height() / 2) ),
2121 pVDev
->PixelToLogic( aGSize
) );
2128 static long lcl_DrawBullet(VirtualDevice
* pVDev
,
2129 const SvxNumberFormat
& rFmt
, long nXStart
,
2130 long nYStart
, const Size
& rSize
)
2132 vcl::Font
aTmpFont(pVDev
->GetFont());
2134 // via Uno it's possible that no font has been set!
2135 vcl::Font
aFont(rFmt
.GetBulletFont() ? *rFmt
.GetBulletFont() : aTmpFont
);
2136 Size
aTmpSize(rSize
);
2137 aTmpSize
.setWidth( aTmpSize
.Width() * ( rFmt
.GetBulletRelSize()) );
2138 aTmpSize
.setWidth( aTmpSize
.Width() / 100 ) ;
2139 aTmpSize
.setHeight( aTmpSize
.Height() * ( rFmt
.GetBulletRelSize()) );
2140 aTmpSize
.setHeight( aTmpSize
.Height() / 100 ) ;
2141 // in case of a height of zero it is drawn in original height
2142 if(!aTmpSize
.Height())
2143 aTmpSize
.setHeight( 1 );
2144 aFont
.SetFontSize(aTmpSize
);
2145 aFont
.SetTransparent(true);
2146 Color aBulletColor
= rFmt
.GetBulletColor();
2147 if(aBulletColor
== COL_AUTO
)
2148 aBulletColor
= pVDev
->GetFillColor().IsDark() ? COL_WHITE
: COL_BLACK
;
2149 else if(aBulletColor
== pVDev
->GetFillColor())
2150 aBulletColor
.Invert();
2151 aFont
.SetColor(aBulletColor
);
2152 pVDev
->SetFont( aFont
);
2153 OUString
aText(rFmt
.GetBulletChar());
2155 nY
-= ((aTmpSize
.Height() - rSize
.Height())/ 2);
2156 pVDev
->DrawText( Point(nXStart
, nY
), aText
);
2157 long nRet
= pVDev
->GetTextWidth(aText
);
2159 pVDev
->SetFont(aTmpFont
);
2163 SvxNumberingPreview::SvxNumberingPreview()
2166 , nActLevel(SAL_MAX_UINT16
)
2170 // paint preview of numeration
2171 void SvxNumberingPreview::Paint(vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
& /*rRect*/)
2173 Size
aSize(rRenderContext
.PixelToLogic(GetOutputSizePixel()));
2175 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
2176 const Color aBackColor
= rStyleSettings
.GetFieldColor();
2177 const Color aTextColor
= rStyleSettings
.GetFieldTextColor();
2179 ScopedVclPtrInstance
<VirtualDevice
> pVDev(rRenderContext
);
2180 pVDev
->EnableRTL(rRenderContext
.IsRTLEnabled());
2181 pVDev
->SetMapMode(rRenderContext
.GetMapMode());
2182 pVDev
->SetOutputSize(aSize
);
2184 Color
aLineColor(COL_LIGHTGRAY
);
2185 if (aLineColor
== aBackColor
)
2186 aLineColor
.Invert();
2187 pVDev
->SetLineColor(aLineColor
);
2188 pVDev
->SetFillColor(aBackColor
);
2192 long nWidthRelation
= 30; // chapter dialog
2195 long nXStep
= aSize
.Width() / (3 * pActNum
->GetLevelCount());
2196 if (pActNum
->GetLevelCount() < 10)
2199 // the whole height mustn't be used for a single level
2200 long nYStep
= (aSize
.Height() - 6)/ (pActNum
->GetLevelCount() > 1 ? pActNum
->GetLevelCount() : 5);
2202 aStdFont
= OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS
, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne
);
2203 aStdFont
.SetColor(aTextColor
);
2204 aStdFont
.SetFillColor(aBackColor
);
2206 long nFontHeight
= nYStep
* 6 / 10;
2208 nFontHeight
= nYStep
* 15 / 10;
2209 aStdFont
.SetFontSize(Size( 0, nFontHeight
));
2212 sal_uInt16 nPreNum
= pActNum
->GetLevel(0).GetStart();
2216 long nLineHeight
= nFontHeight
* 8 / 7;
2217 sal_uInt8 nStart
= 0;
2218 while (!(nActLevel
& (1<<nStart
)))
2224 sal_uInt8 nEnd
= std::min(sal_uInt8(nStart
+ 3), sal_uInt8(pActNum
->GetLevelCount()));
2225 for (sal_uInt8 nLevel
= nStart
; nLevel
< nEnd
; ++nLevel
)
2227 const SvxNumberFormat
&rFmt
= pActNum
->GetLevel(nLevel
);
2228 aNum
.GetLevelVal()[nLevel
] = rFmt
.GetStart();
2231 short nTextOffset( 0 );
2232 long nNumberXPos( 0 );
2233 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2235 nXStart
= rFmt
.GetAbsLSpace() / nWidthRelation
;
2236 nTextOffset
= rFmt
.GetCharTextDistance() / nWidthRelation
;
2237 nNumberXPos
= nXStart
;
2238 long nFirstLineOffset
= (-rFmt
.GetFirstLineOffset()) / nWidthRelation
;
2240 if (nFirstLineOffset
<= nNumberXPos
)
2241 nNumberXPos
= nNumberXPos
- nFirstLineOffset
;
2244 // in draw this is valid
2245 if (nTextOffset
< 0)
2246 nNumberXPos
= nNumberXPos
+ nTextOffset
;
2248 else if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2250 const long nTmpNumberXPos((rFmt
.GetIndentAt() + rFmt
.GetFirstLineIndent() ) / nWidthRelation
);
2251 if (nTmpNumberXPos
< 0)
2257 nNumberXPos
= nTmpNumberXPos
;
2261 long nBulletWidth
= 0;
2262 if (SVX_NUM_BITMAP
== (rFmt
.GetNumberingType() &(~LINK_TOKEN
)))
2264 long nYMiddle
= nYStart
+ ( nFontHeight
/ 2 );
2265 nBulletWidth
= rFmt
.IsShowSymbol() ? lcl_DrawGraphic(pVDev
.get(), rFmt
, nNumberXPos
, nYMiddle
, nWidthRelation
) : 0;
2267 else if (SVX_NUM_CHAR_SPECIAL
== rFmt
.GetNumberingType())
2269 nBulletWidth
= rFmt
.IsShowSymbol() ? lcl_DrawBullet(pVDev
.get(), rFmt
, nNumberXPos
, nYStart
, aStdFont
.GetFontSize()) : 0;
2273 pVDev
->SetFont(aStdFont
);
2274 aNum
.SetLevel(nLevel
);
2275 if (pActNum
->IsContinuousNumbering())
2276 aNum
.GetLevelVal()[nLevel
] = nPreNum
;
2277 OUString
aText(pActNum
->MakeNumString( aNum
));
2278 vcl::Font aSaveFont
= pVDev
->GetFont();
2279 vcl::Font
aColorFont(aSaveFont
);
2280 Color aTmpBulletColor
= rFmt
.GetBulletColor();
2281 if (aTmpBulletColor
== COL_AUTO
)
2282 aTmpBulletColor
= aBackColor
.IsDark() ? COL_WHITE
: COL_BLACK
;
2283 else if (aTmpBulletColor
== aBackColor
)
2284 aTmpBulletColor
.Invert();
2285 aColorFont
.SetColor(aTmpBulletColor
);
2286 pVDev
->SetFont(aColorFont
);
2287 pVDev
->DrawText(Point(nNumberXPos
, nYStart
), aText
);
2288 pVDev
->SetFont(aSaveFont
);
2289 nBulletWidth
= pVDev
->GetTextWidth(aText
);
2292 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
&&
2293 rFmt
.GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
2295 pVDev
->SetFont(aStdFont
);
2296 OUString
aText(' ');
2297 pVDev
->DrawText( Point(nNumberXPos
, nYStart
), aText
);
2298 nBulletWidth
= nBulletWidth
+ pVDev
->GetTextWidth(aText
);
2301 long nTextXPos( 0 );
2302 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2304 nTextXPos
= nXStart
;
2305 if (nTextOffset
< 0)
2306 nTextXPos
= nTextXPos
+ nTextOffset
;
2307 if (nNumberXPos
+ nBulletWidth
+ nTextOffset
> nTextXPos
)
2308 nTextXPos
= nNumberXPos
+ nBulletWidth
+ nTextOffset
;
2310 else if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2312 switch (rFmt
.GetLabelFollowedBy())
2314 case SvxNumberFormat::LISTTAB
:
2316 nTextXPos
= rFmt
.GetListtabPos() / nWidthRelation
;
2317 if (nTextXPos
< nNumberXPos
+ nBulletWidth
)
2319 nTextXPos
= nNumberXPos
+ nBulletWidth
;
2323 case SvxNumberFormat::SPACE
:
2324 case SvxNumberFormat::NOTHING
:
2325 case SvxNumberFormat::NEWLINE
:
2327 nTextXPos
= nNumberXPos
+ nBulletWidth
;
2332 nXStart
= rFmt
.GetIndentAt() / nWidthRelation
;
2335 ::tools::Rectangle
aRect1(Point(nTextXPos
, nYStart
+ nFontHeight
/ 2), Size(aSize
.Width() / 2, 2));
2336 pVDev
->SetFillColor(aBackColor
);
2337 pVDev
->DrawRect(aRect1
);
2339 ::tools::Rectangle
aRect2(Point(nXStart
, nYStart
+ nLineHeight
+ nFontHeight
/ 2 ), Size(aSize
.Width() / 2, 2));
2340 pVDev
->DrawRect(aRect2
);
2341 nYStart
+= 2 * nLineHeight
;
2346 //#i5153# painting gray or black rectangles as 'normal' numbering text
2347 long nWidth
= pVDev
->GetTextWidth("Preview");
2348 long nTextHeight
= pVDev
->GetTextHeight();
2349 long nRectHeight
= nTextHeight
* 2 / 3;
2350 long nTopOffset
= nTextHeight
- nRectHeight
;
2351 Color
aBlackColor(COL_BLACK
);
2352 if (aBlackColor
== aBackColor
)
2353 aBlackColor
.Invert();
2355 for (sal_uInt16 nLevel
= 0; nLevel
< pActNum
->GetLevelCount(); ++nLevel
, nYStart
= nYStart
+ nYStep
)
2357 const SvxNumberFormat
&rFmt
= pActNum
->GetLevel(nLevel
);
2358 aNum
.GetLevelVal()[ nLevel
] = rFmt
.GetStart();
2360 pVDev
->SetFillColor( aBackColor
);
2362 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2364 nXStart
= rFmt
.GetAbsLSpace() / nWidthRelation
;
2366 else if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2368 const long nTmpXStart((rFmt
.GetIndentAt() + rFmt
.GetFirstLineIndent() ) / nWidthRelation
);
2375 nXStart
= nTmpXStart
;
2380 long nTextOffset
= 2 * nXStep
;
2381 if (SVX_NUM_BITMAP
== (rFmt
.GetNumberingType()&(~LINK_TOKEN
)))
2383 if (rFmt
.IsShowSymbol())
2385 long nYMiddle
= nYStart
+ ( nFontHeight
/ 2 );
2386 nTextOffset
= lcl_DrawGraphic(pVDev
.get(), rFmt
, nXStart
, nYMiddle
, nWidthRelation
);
2387 nTextOffset
= nTextOffset
+ nXStep
;
2390 else if (SVX_NUM_CHAR_SPECIAL
== rFmt
.GetNumberingType())
2392 if (rFmt
.IsShowSymbol())
2394 nTextOffset
= lcl_DrawBullet(pVDev
.get(), rFmt
, nXStart
, nYStart
, aStdFont
.GetFontSize());
2395 nTextOffset
= nTextOffset
+ nXStep
;
2400 vcl::Font
aFont(aStdFont
);
2401 Size
aTmpSize(aStdFont
.GetFontSize());
2402 if(pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE
))
2404 aTmpSize
.setWidth( aTmpSize
.Width() * ( rFmt
.GetBulletRelSize()) );
2405 aTmpSize
.setWidth( aTmpSize
.Width() / 100 ) ;
2406 aTmpSize
.setHeight( aTmpSize
.Height() * ( rFmt
.GetBulletRelSize()) );
2407 aTmpSize
.setHeight( aTmpSize
.Height() / 100 ) ;
2409 if(!aTmpSize
.Height())
2410 aTmpSize
.setHeight( 1 );
2411 aFont
.SetFontSize(aTmpSize
);
2412 Color aTmpBulletColor
= rFmt
.GetBulletColor();
2413 if (aTmpBulletColor
== COL_AUTO
)
2414 aTmpBulletColor
= aBackColor
.IsDark() ? COL_WHITE
: COL_BLACK
;
2415 else if (aTmpBulletColor
== aBackColor
)
2416 aTmpBulletColor
.Invert();
2417 aFont
.SetColor(aTmpBulletColor
);
2418 pVDev
->SetFont(aFont
);
2419 aNum
.SetLevel( nLevel
);
2420 if (pActNum
->IsContinuousNumbering())
2421 aNum
.GetLevelVal()[nLevel
] = nPreNum
;
2422 OUString
aText(pActNum
->MakeNumString(aNum
));
2424 nY
-= (pVDev
->GetTextHeight() - nTextHeight
- pVDev
->GetFontMetric().GetDescent());
2425 pVDev
->DrawText(Point(nXStart
, nY
), aText
);
2426 nTextOffset
= pVDev
->GetTextWidth(aText
);
2427 nTextOffset
= nTextOffset
+ nXStep
;
2429 pVDev
->SetFont(aStdFont
);
2431 //#i5153# the selected rectangle(s) should be black
2432 if (0 != (nActLevel
& (1<<nLevel
)))
2434 pVDev
->SetFillColor( aBlackColor
);
2435 pVDev
->SetLineColor( aBlackColor
);
2439 //#i5153# unselected levels are gray
2440 pVDev
->SetFillColor( aLineColor
);
2441 pVDev
->SetLineColor( aLineColor
);
2443 ::tools::Rectangle
aRect1(Point(nXStart
+ nTextOffset
, nYStart
+ nTopOffset
), Size(nWidth
, nRectHeight
));
2444 pVDev
->DrawRect(aRect1
);
2448 rRenderContext
.DrawOutDev(Point(), aSize
, Point(), aSize
, *pVDev
);
2452 //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate
2453 //dialog to this one, except with a different preview window impl.
2454 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
2456 SvxNumPositionTabPage::SvxNumPositionTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
2457 : SfxTabPage(pPage
, pController
, "cui/ui/numberingpositionpage.ui", "NumberingPositionPage", &rSet
)
2458 , m_pLevelHdlEvent(nullptr)
2460 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
2463 , bInInintControl(false)
2464 , bLabelAlignmentPosAndSpaceModeActive(false)
2465 , m_xLevelLB(m_xBuilder
->weld_tree_view("levellb"))
2466 , m_xDistBorderFT(m_xBuilder
->weld_label("indent"))
2467 , m_xDistBorderMF(m_xBuilder
->weld_metric_spin_button("indentmf", FieldUnit::CM
))
2468 , m_xRelativeCB(m_xBuilder
->weld_check_button("relative"))
2469 , m_xIndentFT(m_xBuilder
->weld_label("numberingwidth"))
2470 , m_xIndentMF(m_xBuilder
->weld_metric_spin_button("numberingwidthmf", FieldUnit::CM
))
2471 , m_xDistNumFT(m_xBuilder
->weld_label("numdist"))
2472 , m_xDistNumMF(m_xBuilder
->weld_metric_spin_button("numdistmf", FieldUnit::CM
))
2473 , m_xAlignFT(m_xBuilder
->weld_label("numalign"))
2474 , m_xAlignLB(m_xBuilder
->weld_combo_box("numalignlb"))
2475 , m_xLabelFollowedByFT(m_xBuilder
->weld_label("numfollowedby"))
2476 , m_xLabelFollowedByLB(m_xBuilder
->weld_combo_box("numfollowedbylb"))
2477 , m_xListtabFT(m_xBuilder
->weld_label("at"))
2478 , m_xListtabMF(m_xBuilder
->weld_metric_spin_button("atmf", FieldUnit::CM
))
2479 , m_xAlign2FT(m_xBuilder
->weld_label("num2align"))
2480 , m_xAlign2LB(m_xBuilder
->weld_combo_box("num2alignlb"))
2481 , m_xAlignedAtFT(m_xBuilder
->weld_label("alignedat"))
2482 , m_xAlignedAtMF(m_xBuilder
->weld_metric_spin_button("alignedatmf", FieldUnit::CM
))
2483 , m_xIndentAtFT(m_xBuilder
->weld_label("indentat"))
2484 , m_xIndentAtMF(m_xBuilder
->weld_metric_spin_button("indentatmf", FieldUnit::CM
))
2485 , m_xStandardPB(m_xBuilder
->weld_button("standard"))
2486 , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder
, "preview", m_aPreviewWIN
))
2488 SetExchangeSupport();
2490 m_xAlignedAtMF
->set_range(0, SAL_MAX_INT32
, FieldUnit::NONE
);
2491 m_xListtabMF
->set_range(0, SAL_MAX_INT32
, FieldUnit::NONE
);
2492 m_xIndentAtMF
->set_range(0, SAL_MAX_INT32
, FieldUnit::NONE
);
2494 m_xRelativeCB
->set_active(true);
2495 m_xAlignLB
->connect_changed(LINK(this, SvxNumPositionTabPage
, EditModifyHdl_Impl
));
2496 m_xAlign2LB
->connect_changed(LINK(this, SvxNumPositionTabPage
, EditModifyHdl_Impl
));
2497 for ( sal_Int32 i
= 0; i
< m_xAlignLB
->get_count(); ++i
)
2499 m_xAlign2LB
->append_text(m_xAlignLB
->get_text(i
));
2502 Link
<weld::MetricSpinButton
&,void> aLk3
= LINK(this, SvxNumPositionTabPage
, DistanceHdl_Impl
);
2503 m_xDistBorderMF
->connect_value_changed(aLk3
);
2504 m_xDistNumMF
->connect_value_changed(aLk3
);
2505 m_xIndentMF
->connect_value_changed(aLk3
);
2507 m_xLabelFollowedByLB
->connect_changed(LINK(this, SvxNumPositionTabPage
, LabelFollowedByHdl_Impl
));
2509 m_xListtabMF
->connect_value_changed(LINK(this, SvxNumPositionTabPage
, ListtabPosHdl_Impl
));
2510 m_xAlignedAtMF
->connect_value_changed(LINK(this, SvxNumPositionTabPage
, AlignAtHdl_Impl
));
2511 m_xIndentAtMF
->connect_value_changed(LINK(this, SvxNumPositionTabPage
, IndentAtHdl_Impl
));
2513 m_xLevelLB
->set_selection_mode(SelectionMode::Multiple
);
2514 m_xLevelLB
->connect_changed(LINK(this, SvxNumPositionTabPage
, LevelHdl_Impl
));
2515 m_xRelativeCB
->connect_toggled(LINK(this, SvxNumPositionTabPage
, RelativeHdl_Impl
));
2516 m_xStandardPB
->connect_clicked(LINK(this, SvxNumPositionTabPage
, StandardHdl_Impl
));
2518 m_xRelativeCB
->set_active(bLastRelative
);
2519 m_aPreviewWIN
.SetPositionMode();
2520 eCoreUnit
= rSet
.GetPool()->GetMetric(rSet
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
2523 SvxNumPositionTabPage::~SvxNumPositionTabPage()
2525 if (m_pLevelHdlEvent
)
2527 Application::RemoveUserEvent(m_pLevelHdlEvent
);
2528 m_pLevelHdlEvent
= nullptr;
2530 m_xPreviewWIN
.reset();
2533 /*-------------------------------------------------------*/
2535 void SvxNumPositionTabPage::InitControls()
2537 bInInintControl
= true;
2538 const bool bRelative
= !bLabelAlignmentPosAndSpaceModeActive
&&
2539 m_xRelativeCB
->get_sensitive() && m_xRelativeCB
->get_active();
2540 const bool bSingleSelection
= m_xLevelLB
->count_selected_rows() == 1 &&
2541 SAL_MAX_UINT16
!= nActNumLvl
;
2543 m_xDistBorderMF
->set_sensitive( !bLabelAlignmentPosAndSpaceModeActive
&&
2544 ( bSingleSelection
|| bRelative
) );
2545 m_xDistBorderFT
->set_sensitive( !bLabelAlignmentPosAndSpaceModeActive
&&
2546 ( bSingleSelection
|| bRelative
) );
2548 bool bSetDistEmpty
= false;
2549 bool bSameDistBorderNum
= !bLabelAlignmentPosAndSpaceModeActive
;
2550 bool bSameDist
= !bLabelAlignmentPosAndSpaceModeActive
;
2551 bool bSameIndent
= !bLabelAlignmentPosAndSpaceModeActive
;
2552 bool bSameAdjust
= true;
2554 bool bSameLabelFollowedBy
= bLabelAlignmentPosAndSpaceModeActive
;
2555 bool bSameListtab
= bLabelAlignmentPosAndSpaceModeActive
;
2556 bool bSameAlignAt
= bLabelAlignmentPosAndSpaceModeActive
;
2557 bool bSameIndentAt
= bLabelAlignmentPosAndSpaceModeActive
;
2559 const SvxNumberFormat
* aNumFmtArr
[SVX_MAX_NUM
];
2560 sal_uInt16 nMask
= 1;
2561 sal_uInt16 nLvl
= SAL_MAX_UINT16
;
2562 long nFirstBorderTextRelative
= -1;
2563 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2565 aNumFmtArr
[i
] = &pActNum
->GetLevel(i
);
2566 if(nActNumLvl
& nMask
)
2568 if(SAL_MAX_UINT16
== nLvl
)
2573 bSameAdjust
&= aNumFmtArr
[i
]->GetNumAdjust() == aNumFmtArr
[nLvl
]->GetNumAdjust();
2574 if ( !bLabelAlignmentPosAndSpaceModeActive
)
2578 if(nFirstBorderTextRelative
== -1)
2579 nFirstBorderTextRelative
=
2580 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
2581 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
2583 bSameDistBorderNum
&= nFirstBorderTextRelative
==
2584 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
2585 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
2588 bSameDistBorderNum
&=
2589 aNumFmtArr
[i
]->GetAbsLSpace() - aNumFmtArr
[i
]->GetFirstLineOffset() ==
2590 aNumFmtArr
[i
- 1]->GetAbsLSpace() - aNumFmtArr
[i
- 1]->GetFirstLineOffset();
2592 bSameDist
&= aNumFmtArr
[i
]->GetCharTextDistance() == aNumFmtArr
[nLvl
]->GetCharTextDistance();
2593 bSameIndent
&= aNumFmtArr
[i
]->GetFirstLineOffset() == aNumFmtArr
[nLvl
]->GetFirstLineOffset();
2597 bSameLabelFollowedBy
&=
2598 aNumFmtArr
[i
]->GetLabelFollowedBy() == aNumFmtArr
[nLvl
]->GetLabelFollowedBy();
2600 aNumFmtArr
[i
]->GetListtabPos() == aNumFmtArr
[nLvl
]->GetListtabPos();
2602 ( ( aNumFmtArr
[i
]->GetIndentAt() + aNumFmtArr
[i
]->GetFirstLineIndent() )
2603 == ( aNumFmtArr
[nLvl
]->GetIndentAt() + aNumFmtArr
[nLvl
]->GetFirstLineIndent() ) );
2605 aNumFmtArr
[i
]->GetIndentAt() == aNumFmtArr
[nLvl
]->GetIndentAt();
2612 if (SVX_MAX_NUM
<= nLvl
)
2614 OSL_ENSURE(false, "cannot happen.");
2618 if(bSameDistBorderNum
)
2620 long nDistBorderNum
;
2623 nDistBorderNum
= static_cast<long>(aNumFmtArr
[nLvl
]->GetAbsLSpace())+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
2625 nDistBorderNum
-= static_cast<long>(aNumFmtArr
[nLvl
- 1]->GetAbsLSpace())+ aNumFmtArr
[nLvl
- 1]->GetFirstLineOffset();
2629 nDistBorderNum
= static_cast<long>(aNumFmtArr
[nLvl
]->GetAbsLSpace())+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
2631 SetMetricValue(*m_xDistBorderMF
, nDistBorderNum
, eCoreUnit
);
2634 bSetDistEmpty
= true;
2637 SetMetricValue(*m_xDistNumMF
, aNumFmtArr
[nLvl
]->GetCharTextDistance(), eCoreUnit
);
2639 m_xDistNumMF
->set_text("");
2641 SetMetricValue(*m_xIndentMF
, - aNumFmtArr
[nLvl
]->GetFirstLineOffset(), eCoreUnit
);
2643 m_xIndentMF
->set_text("");
2647 sal_Int32 nPos
= 1; // centered
2648 if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SvxAdjust::Left
)
2650 else if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SvxAdjust::Right
)
2652 m_xAlignLB
->set_active(nPos
);
2653 m_xAlign2LB
->set_active(nPos
);
2657 m_xAlignLB
->set_active(-1);
2658 m_xAlign2LB
->set_active(-1);
2661 if ( bSameLabelFollowedBy
)
2663 sal_Int32 nPos
= 0; // LISTTAB
2664 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
2668 else if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING
)
2672 else if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::NEWLINE
)
2676 m_xLabelFollowedByLB
->set_active(nPos
);
2680 m_xLabelFollowedByLB
->set_active(-1);
2683 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB
)
2685 m_xListtabFT
->set_sensitive(true);
2686 m_xListtabMF
->set_sensitive(true);
2689 SetMetricValue(*m_xListtabMF
, aNumFmtArr
[nLvl
]->GetListtabPos(), eCoreUnit
);
2693 m_xListtabMF
->set_text("");
2698 m_xListtabFT
->set_sensitive(false);
2699 m_xListtabMF
->set_sensitive(false);
2700 m_xListtabMF
->set_text("");
2705 SetMetricValue(*m_xAlignedAtMF
,
2706 aNumFmtArr
[nLvl
]->GetIndentAt() + aNumFmtArr
[nLvl
]->GetFirstLineIndent(),
2711 m_xAlignedAtMF
->set_text("");
2714 if ( bSameIndentAt
)
2716 SetMetricValue(*m_xIndentAtMF
, aNumFmtArr
[nLvl
]->GetIndentAt(), eCoreUnit
);
2720 m_xIndentAtMF
->set_text("");
2723 if ( bSetDistEmpty
)
2724 m_xDistBorderMF
->set_text("");
2726 bInInintControl
= false;
2729 void SvxNumPositionTabPage::ActivatePage(const SfxItemSet
& rSet
)
2731 const SfxPoolItem
* pItem
;
2732 sal_uInt16 nTmpNumLvl
= 1;
2733 const SfxItemSet
* pExampleSet
= GetDialogExampleSet();
2736 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
2737 bPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
2738 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
2739 nTmpNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
2741 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
2743 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
2745 bModified
= (!pActNum
->Get( 0 ) || bPreset
);
2746 if(*pSaveNum
!= *pActNum
||
2747 nActNumLvl
!= nTmpNumLvl
)
2749 *pActNum
= *pSaveNum
;
2750 nActNumLvl
= nTmpNumLvl
;
2751 sal_uInt16 nMask
= 1;
2752 m_xLevelLB
->unselect_all();
2753 if (nActNumLvl
== SAL_MAX_UINT16
)
2754 m_xLevelLB
->select(pActNum
->GetLevelCount());
2755 if (nActNumLvl
!= SAL_MAX_UINT16
)
2756 for (sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2758 if (nActNumLvl
& nMask
)
2759 m_xLevelLB
->select(i
);
2762 m_xRelativeCB
->set_sensitive(nActNumLvl
!= 1);
2764 InitPosAndSpaceMode();
2765 ShowControlsDependingOnPosAndSpaceMode();
2769 m_aPreviewWIN
.SetLevel(nActNumLvl
);
2770 m_aPreviewWIN
.Invalidate();
2773 DeactivateRC
SvxNumPositionTabPage::DeactivatePage(SfxItemSet
*_pSet
)
2777 if (m_xDistBorderMF
->get_sensitive())
2778 DistanceHdl_Impl(*m_xDistBorderMF
);
2779 DistanceHdl_Impl(*m_xIndentMF
);
2782 return DeactivateRC::LeavePage
;
2785 bool SvxNumPositionTabPage::FillItemSet( SfxItemSet
* rSet
)
2787 rSet
->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL
, nActNumLvl
));
2789 if(bModified
&& pActNum
)
2791 *pSaveNum
= *pActNum
;
2792 rSet
->Put(SvxNumBulletItem( *pSaveNum
, nNumItemId
));
2793 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, false));
2798 void SvxNumPositionTabPage::Reset( const SfxItemSet
* rSet
)
2800 const SfxPoolItem
* pItem
;
2801 // in Draw the item exists as WhichId, in Writer only as SlotId
2802 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
2803 if(eState
!= SfxItemState::SET
)
2805 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
2806 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
2808 if( eState
!= SfxItemState::SET
)
2810 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
) );
2811 eState
= SfxItemState::SET
;
2815 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
2816 pSaveNum
.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule()) );
2819 if (!m_xLevelLB
->count_selected_rows())
2821 for(sal_uInt16 i
= 1; i
<= pSaveNum
->GetLevelCount(); i
++)
2822 m_xLevelLB
->append_text(OUString::number(i
));
2823 if(pSaveNum
->GetLevelCount() > 1)
2825 OUString sEntry
= "1 - " + OUString::number( pSaveNum
->GetLevelCount() );
2826 m_xLevelLB
->append_text(sEntry
);
2827 m_xLevelLB
->select_text(sEntry
);
2830 m_xLevelLB
->select(0);
2833 m_xLevelLB
->select(m_xLevelLB
->count_selected_rows() - 1);
2834 sal_uInt16 nMask
= 1;
2835 m_xLevelLB
->unselect_all();
2836 if (nActNumLvl
== SAL_MAX_UINT16
)
2838 m_xLevelLB
->select(pSaveNum
->GetLevelCount());
2842 for(sal_uInt16 i
= 0; i
< pSaveNum
->GetLevelCount(); i
++)
2844 if(nActNumLvl
& nMask
)
2845 m_xLevelLB
->select(i
);
2851 pActNum
.reset( new SvxNumRule(*pSaveNum
) );
2852 else if(*pSaveNum
!= *pActNum
)
2853 *pActNum
= *pSaveNum
;
2854 m_aPreviewWIN
.SetNumRule(pActNum
.get());
2856 InitPosAndSpaceMode();
2857 ShowControlsDependingOnPosAndSpaceMode();
2863 void SvxNumPositionTabPage::InitPosAndSpaceMode()
2865 if ( pActNum
== nullptr )
2867 SAL_WARN( "cui.tabpages",
2868 "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
2872 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode
=
2873 SvxNumberFormat::LABEL_ALIGNMENT
;
2874 sal_uInt16 nMask
= 1;
2875 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
2877 if(nActNumLvl
& nMask
)
2879 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
2880 ePosAndSpaceMode
= aNumFmt
.GetPositionAndSpaceMode();
2881 if ( ePosAndSpaceMode
== SvxNumberFormat::LABEL_ALIGNMENT
)
2889 bLabelAlignmentPosAndSpaceModeActive
=
2890 ePosAndSpaceMode
== SvxNumberFormat::LABEL_ALIGNMENT
;
2893 void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
2895 m_xDistBorderFT
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2896 m_xDistBorderMF
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2897 m_xRelativeCB
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2898 m_xIndentFT
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2899 m_xIndentMF
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2900 m_xDistNumFT
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
&&
2901 pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
) );
2902 m_xDistNumMF
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
&&
2903 pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
));
2904 m_xAlignFT
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2905 m_xAlignLB
->set_visible( !bLabelAlignmentPosAndSpaceModeActive
);
2907 m_xLabelFollowedByFT
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2908 m_xLabelFollowedByLB
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2909 m_xListtabFT
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2910 m_xListtabMF
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2911 m_xAlign2FT
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2912 m_xAlign2LB
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2913 m_xAlignedAtFT
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2914 m_xAlignedAtMF
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2915 m_xIndentAtFT
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2916 m_xIndentAtMF
->set_visible( bLabelAlignmentPosAndSpaceModeActive
);
2919 std::unique_ptr
<SfxTabPage
> SvxNumPositionTabPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
,
2920 const SfxItemSet
* rAttrSet
)
2922 return std::make_unique
<SvxNumPositionTabPage
>(pPage
, pController
, *rAttrSet
);
2925 void SvxNumPositionTabPage::SetMetric(FieldUnit eMetric
)
2927 if (eMetric
== FieldUnit::MM
)
2929 m_xDistBorderMF
->set_digits(1);
2930 m_xDistNumMF
->set_digits(1);
2931 m_xIndentMF
->set_digits(1);
2932 m_xListtabMF
->set_digits(1);
2933 m_xAlignedAtMF
->set_digits(1);
2934 m_xIndentAtMF
->set_digits(1);
2936 m_xDistBorderMF
->set_unit(eMetric
);
2937 m_xDistNumMF
->set_unit(eMetric
);
2938 m_xIndentMF
->set_unit(eMetric
);
2939 m_xListtabMF
->set_unit(eMetric
);
2940 m_xAlignedAtMF
->set_unit(eMetric
);
2941 m_xIndentAtMF
->set_unit(eMetric
);
2944 IMPL_LINK_NOARG(SvxNumPositionTabPage
, EditModifyHdl_Impl
, weld::ComboBox
&, void)
2946 sal_uInt16 nMask
= 1;
2947 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2949 if(nActNumLvl
& nMask
)
2951 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2953 const sal_Int32 nPos
= m_xAlignLB
->get_visible()
2954 ? m_xAlignLB
->get_active()
2955 : m_xAlign2LB
->get_active();
2956 SvxAdjust eAdjust
= SvxAdjust::Center
;
2958 eAdjust
= SvxAdjust::Left
;
2960 eAdjust
= SvxAdjust::Right
;
2961 aNumFmt
.SetNumAdjust( eAdjust
);
2962 pActNum
->SetLevel(i
, aNumFmt
);
2969 IMPL_LINK_NOARG(SvxNumPositionTabPage
, LevelHdl_Impl
, weld::TreeView
&, void)
2971 if (m_pLevelHdlEvent
)
2973 // tdf#127120 multiselection may be implemented by deselect follow by select so
2974 // fire off the handler to happen on next event loop and only process the
2976 m_pLevelHdlEvent
= Application::PostUserEvent(LINK(this, SvxNumPositionTabPage
, LevelHdl
));
2979 IMPL_LINK_NOARG(SvxNumPositionTabPage
, LevelHdl
, void*, void)
2981 m_pLevelHdlEvent
= nullptr;
2983 sal_uInt16 nSaveNumLvl
= nActNumLvl
;
2985 std::vector
<int> aSelectedRows
= m_xLevelLB
->get_selected_rows();
2986 if (std::find(aSelectedRows
.begin(), aSelectedRows
.end(), pActNum
->GetLevelCount()) != aSelectedRows
.end() &&
2987 (aSelectedRows
.size() == 1 || nSaveNumLvl
!= 0xffff))
2989 nActNumLvl
= 0xFFFF;
2990 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
2991 m_xLevelLB
->unselect(i
);
2993 else if (!aSelectedRows
.empty())
2995 sal_uInt16 nMask
= 1;
2996 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
2998 if (std::find(aSelectedRows
.begin(), aSelectedRows
.end(), i
) != aSelectedRows
.end())
2999 nActNumLvl
|= nMask
;
3002 m_xLevelLB
->unselect(pActNum
->GetLevelCount());
3006 nActNumLvl
= nSaveNumLvl
;
3007 sal_uInt16 nMask
= 1;
3008 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
3010 if(nActNumLvl
& nMask
)
3012 m_xLevelLB
->select(i
);
3018 m_xRelativeCB
->set_sensitive(nActNumLvl
!= 1);
3020 InitPosAndSpaceMode();
3021 ShowControlsDependingOnPosAndSpaceMode();
3025 IMPL_LINK(SvxNumPositionTabPage
, DistanceHdl_Impl
, weld::MetricSpinButton
&, rFld
, void)
3029 long nValue
= GetCoreValue(rFld
, eCoreUnit
);
3030 sal_uInt16 nMask
= 1;
3031 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3033 if(nActNumLvl
& nMask
)
3035 SvxNumberFormat
aNumFmt( pActNum
->GetLevel( i
) );
3036 if (&rFld
== m_xDistBorderMF
.get())
3039 if (m_xRelativeCB
->get_active())
3043 auto const nTmp
= aNumFmt
.GetFirstLineOffset();
3044 aNumFmt
.SetAbsLSpace( nValue
- nTmp
);
3048 long nTmp
= pActNum
->GetLevel( i
- 1 ).GetAbsLSpace() +
3049 pActNum
->GetLevel( i
- 1 ).GetFirstLineOffset() -
3050 pActNum
->GetLevel( i
).GetFirstLineOffset();
3052 aNumFmt
.SetAbsLSpace( nValue
+ nTmp
);
3057 aNumFmt
.SetAbsLSpace( nValue
- aNumFmt
.GetFirstLineOffset());
3060 else if (&rFld
== m_xDistNumMF
.get())
3062 aNumFmt
.SetCharTextDistance( static_cast<short>(nValue
) );
3064 else if (&rFld
== m_xIndentMF
.get())
3066 // together with the FirstLineOffset the AbsLSpace must be changed, too
3067 long nDiff
= nValue
+ aNumFmt
.GetFirstLineOffset();
3068 auto const nAbsLSpace
= aNumFmt
.GetAbsLSpace();
3069 aNumFmt
.SetAbsLSpace(nAbsLSpace
+ nDiff
);
3070 aNumFmt
.SetFirstLineOffset( -nValue
);
3073 pActNum
->SetLevel( i
, aNumFmt
);
3079 if (!m_xDistBorderMF
->get_sensitive())
3081 m_xDistBorderMF
->set_text("");
3085 IMPL_LINK(SvxNumPositionTabPage
, RelativeHdl_Impl
, weld::ToggleButton
&, rBox
, void)
3087 bool bOn
= rBox
.get_active();
3088 bool bSingleSelection
= m_xLevelLB
->count_selected_rows() == 1 && SAL_MAX_UINT16
!= nActNumLvl
;
3089 bool bSetValue
= false;
3091 if(bOn
|| bSingleSelection
)
3093 sal_uInt16 nMask
= 1;
3096 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3098 if(nActNumLvl
& nMask
)
3100 const SvxNumberFormat
&rNumFmt
= pActNum
->GetLevel(i
);
3103 nValue
= rNumFmt
.GetAbsLSpace() + rNumFmt
.GetFirstLineOffset();
3105 nValue
-= (pActNum
->GetLevel(i
- 1).GetAbsLSpace() + pActNum
->GetLevel(i
- 1).GetFirstLineOffset());
3108 bSetValue
= nValue
==
3109 (rNumFmt
.GetAbsLSpace() + rNumFmt
.GetFirstLineOffset()) -
3110 (pActNum
->GetLevel(i
- 1).GetAbsLSpace() + pActNum
->GetLevel(i
- 1).GetFirstLineOffset());
3118 SetMetricValue(*m_xDistBorderMF
, nValue
, eCoreUnit
);
3120 m_xDistBorderMF
->set_text("");
3121 m_xDistBorderMF
->set_sensitive(bOn
|| bSingleSelection
);
3122 m_xDistBorderFT
->set_sensitive(bOn
|| bSingleSelection
);
3123 bLastRelative
= bOn
;
3126 IMPL_LINK_NOARG(SvxNumPositionTabPage
, LabelFollowedByHdl_Impl
, weld::ComboBox
&, void)
3128 // determine value to be set at the chosen list levels
3129 SvxNumberFormat::LabelFollowedBy eLabelFollowedBy
= SvxNumberFormat::LISTTAB
;
3131 const auto nPos
= m_xLabelFollowedByLB
->get_active();
3134 eLabelFollowedBy
= SvxNumberFormat::SPACE
;
3136 else if ( nPos
== 2 )
3138 eLabelFollowedBy
= SvxNumberFormat::NOTHING
;
3140 else if ( nPos
== 3 )
3142 eLabelFollowedBy
= SvxNumberFormat::NEWLINE
;
3146 // set value at the chosen list levels
3147 bool bSameListtabPos
= true;
3148 sal_uInt16 nFirstLvl
= SAL_MAX_UINT16
;
3149 sal_uInt16 nMask
= 1;
3150 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3152 if ( nActNumLvl
& nMask
)
3154 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3155 aNumFmt
.SetLabelFollowedBy( eLabelFollowedBy
);
3156 pActNum
->SetLevel( i
, aNumFmt
);
3158 if ( nFirstLvl
== SAL_MAX_UINT16
)
3164 bSameListtabPos
&= aNumFmt
.GetListtabPos() ==
3165 pActNum
->GetLevel( nFirstLvl
).GetListtabPos();
3171 // enable/disable metric field for list tab stop position depending on
3172 // selected item following the list label.
3173 m_xListtabFT
->set_sensitive( eLabelFollowedBy
== SvxNumberFormat::LISTTAB
);
3174 m_xListtabMF
->set_sensitive( eLabelFollowedBy
== SvxNumberFormat::LISTTAB
);
3175 if ( bSameListtabPos
&& eLabelFollowedBy
== SvxNumberFormat::LISTTAB
)
3177 SetMetricValue(*m_xListtabMF
, pActNum
->GetLevel( nFirstLvl
).GetListtabPos(), eCoreUnit
);
3181 m_xListtabMF
->set_text(OUString());
3187 IMPL_LINK(SvxNumPositionTabPage
, ListtabPosHdl_Impl
, weld::MetricSpinButton
&, rFld
, void)
3189 // determine value to be set at the chosen list levels
3190 const long nValue
= GetCoreValue(rFld
, eCoreUnit
);
3192 // set value at the chosen list levels
3193 sal_uInt16 nMask
= 1;
3194 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3196 if ( nActNumLvl
& nMask
)
3198 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3199 aNumFmt
.SetListtabPos( nValue
);
3200 pActNum
->SetLevel( i
, aNumFmt
);
3208 IMPL_LINK(SvxNumPositionTabPage
, AlignAtHdl_Impl
, weld::MetricSpinButton
&, rFld
, void)
3210 // determine value to be set at the chosen list levels
3211 const long nValue
= GetCoreValue(rFld
, eCoreUnit
);
3213 // set value at the chosen list levels
3214 sal_uInt16 nMask
= 1;
3215 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3217 if ( nActNumLvl
& nMask
)
3219 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3220 const long nFirstLineIndent
= nValue
- aNumFmt
.GetIndentAt();
3221 aNumFmt
.SetFirstLineIndent( nFirstLineIndent
);
3222 pActNum
->SetLevel( i
, aNumFmt
);
3230 IMPL_LINK(SvxNumPositionTabPage
, IndentAtHdl_Impl
, weld::MetricSpinButton
&, rFld
, void)
3232 // determine value to be set at the chosen list levels
3233 const long nValue
= GetCoreValue(rFld
, eCoreUnit
);
3235 // set value at the chosen list levels
3236 sal_uInt16 nMask
= 1;
3237 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3239 if ( nActNumLvl
& nMask
)
3241 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3242 const long nAlignedAt
= aNumFmt
.GetIndentAt() +
3243 aNumFmt
.GetFirstLineIndent();
3244 aNumFmt
.SetIndentAt( nValue
);
3245 const long nNewFirstLineIndent
= nAlignedAt
- nValue
;
3246 aNumFmt
.SetFirstLineIndent( nNewFirstLineIndent
);
3247 pActNum
->SetLevel( i
, aNumFmt
);
3255 IMPL_LINK_NOARG(SvxNumPositionTabPage
, StandardHdl_Impl
, weld::Button
&, void)
3257 sal_uInt16 nMask
= 1;
3258 SvxNumRule
aTmpNumRule( pActNum
->GetFeatureFlags(),
3259 pActNum
->GetLevelCount(),
3260 pActNum
->IsContinuousNumbering(),
3261 SvxNumRuleType::NUMBERING
,
3262 pActNum
->GetLevel( 0 ).GetPositionAndSpaceMode() );
3263 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3265 if(nActNumLvl
& nMask
)
3267 SvxNumberFormat
aNumFmt( pActNum
->GetLevel( i
) );
3268 const SvxNumberFormat
& aTempFmt(aTmpNumRule
.GetLevel( i
));
3269 aNumFmt
.SetPositionAndSpaceMode( aTempFmt
.GetPositionAndSpaceMode() );
3270 if ( aTempFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
3272 aNumFmt
.SetAbsLSpace( aTempFmt
.GetAbsLSpace() );
3273 aNumFmt
.SetCharTextDistance( aTempFmt
.GetCharTextDistance() );
3274 aNumFmt
.SetFirstLineOffset( aTempFmt
.GetFirstLineOffset() );
3276 else if ( aTempFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
3278 aNumFmt
.SetNumAdjust( aTempFmt
.GetNumAdjust() );
3279 aNumFmt
.SetLabelFollowedBy( aTempFmt
.GetLabelFollowedBy() );
3280 aNumFmt
.SetListtabPos( aTempFmt
.GetListtabPos() );
3281 aNumFmt
.SetFirstLineIndent( aTempFmt
.GetFirstLineIndent() );
3282 aNumFmt
.SetIndentAt( aTempFmt
.GetIndentAt() );
3285 pActNum
->SetLevel( i
, aNumFmt
);
3294 void SvxNumPositionTabPage::SetModified()
3297 m_aPreviewWIN
.SetLevel(nActNumLvl
);
3298 m_aPreviewWIN
.Invalidate();
3301 void SvxNumOptionsTabPage::SetModified(bool bRepaint
)
3306 m_aPreviewWIN
.SetLevel(nActNumLvl
);
3307 m_aPreviewWIN
.Invalidate();
3311 void SvxNumOptionsTabPage::PageCreated(const SfxAllItemSet
& aSet
)
3313 const SfxStringListItem
* pListItem
= aSet
.GetItem
<SfxStringListItem
>(SID_CHAR_FMT_LIST_BOX
, false);
3314 const SfxStringItem
* pNumCharFmt
= aSet
.GetItem
<SfxStringItem
>(SID_NUM_CHAR_FMT
, false);
3315 const SfxStringItem
* pBulletCharFmt
= aSet
.GetItem
<SfxStringItem
>(SID_BULLET_CHAR_FMT
, false);
3316 const SfxUInt16Item
* pMetricItem
= aSet
.GetItem
<SfxUInt16Item
>(SID_METRIC_ITEM
, false);
3318 if (pNumCharFmt
&&pBulletCharFmt
)
3319 SetCharFmts( pNumCharFmt
->GetValue(),pBulletCharFmt
->GetValue());
3323 const std::vector
<OUString
> &aList
= pListItem
->GetList();
3324 sal_uInt32 nCount
= aList
.size();
3325 for(sal_uInt32 i
= 0; i
< nCount
; i
++)
3326 m_xCharFmtLB
->append_text(aList
[i
]);
3329 SetMetric(static_cast<FieldUnit
>(pMetricItem
->GetValue()));
3332 void SvxNumPositionTabPage::PageCreated(const SfxAllItemSet
& aSet
)
3334 const SfxUInt16Item
* pMetricItem
= aSet
.GetItem
<SfxUInt16Item
>(SID_METRIC_ITEM
, false);
3337 SetMetric(static_cast<FieldUnit
>(pMetricItem
->GetValue()));
3340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */