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>
22 #include <com/sun/star/text/RelOrientation.hpp>
24 #include <numpages.hxx>
25 #include <numpages.hrc>
26 #include <dialmgr.hxx>
27 #include <tools/mapunit.hxx>
28 #include <i18nlangtag/mslangid.hxx>
30 #include <editeng/numitem.hxx>
31 #include <svl/eitem.hxx>
32 #include <vcl/layout.hxx>
33 #include <vcl/svapp.hxx>
34 #include <svx/gallery.hxx>
35 #include <svl/urihelper.hxx>
36 #include <editeng/brushitem.hxx>
37 #include <svl/intitem.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <vcl/graph.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/settings.hxx>
42 #include <vcl/builderfactory.hxx>
43 #include "cuicharmap.hxx"
44 #include <editeng/flstitem.hxx>
45 #include <svx/dlgutil.hxx>
46 #include <svx/xtable.hxx>
47 #include <svx/drawitem.hxx>
48 #include <svx/numvset.hxx>
49 #include <sfx2/htmlmode.hxx>
50 #include <unotools/pathoptions.hxx>
51 #include <svtools/ctrltool.hxx>
52 #include <editeng/unolingu.hxx>
53 #include <com/sun/star/style/NumberingType.hpp>
54 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
55 #include <com/sun/star/container/XIndexAccess.hpp>
56 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
57 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
58 #include <com/sun/star/text/XNumberingFormatter.hpp>
59 #include <com/sun/star/beans/PropertyValue.hpp>
60 #include <comphelper/processfactory.hxx>
61 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
62 #include <svx/dialmgr.hxx>
63 #include <svx/dialogs.hrc>
67 #include "sfx2/opengrf.hxx"
70 #include <sfx2/request.hxx>
71 #include <svl/aeitem.hxx>
72 #include <svl/stritem.hxx>
73 #include <svl/slstitm.hxx>
74 #include <boost/scoped_ptr.hpp>
75 #include <sfx2/filedlghelper.hxx>
76 #include "svx/gallery1.hxx"
77 #include "svx/galtheme.hxx"
78 #include <unotools/ucbstreamhelper.hxx>
79 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
80 #include <rtl/ustring.h>
81 #include <comphelper/string.hxx>
82 #include <vcl/cvtgrf.hxx>
83 #include <vcl/graphicfilter.hxx>
86 using namespace css::uno
;
87 using namespace css::beans
;
88 using namespace css::lang
;
89 using namespace css::i18n
;
90 using namespace css::text
;
91 using namespace css::container
;
92 using namespace css::style
;
94 #define NUM_PAGETYPE_BULLET 0
95 #define NUM_PAGETYPE_SINGLENUM 1
96 #define NUM_PAGETYPE_NUM 2
98 #define SHOW_NUMBERING 0
100 #define SHOW_BITMAP 2
102 #define MAX_BMP_WIDTH 16
103 #define MAX_BMP_HEIGHT 16
104 #define SEARCHPATH_DELIMITER ((sal_Unicode)';')
105 #define SEARCHFILENAME_DELIMITER ((sal_Unicode)'/')
107 static bool bLastRelative
= false;
108 static const sal_Char cNumberingType
[] = "NumberingType";
109 static const sal_Char cParentNumbering
[] = "ParentNumbering";
110 static const sal_Char cPrefix
[] = "Prefix";
111 static const sal_Char cSuffix
[] = "Suffix";
112 static const sal_Char cBulletChar
[] = "BulletChar";
113 static const sal_Char cBulletFontName
[] = "BulletFontName";
115 static Reference
<XDefaultNumberingProvider
> lcl_GetNumberingProvider()
117 Reference
<XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
118 Reference
<XDefaultNumberingProvider
> xRet
= text::DefaultNumberingProvider::create(xContext
);
122 static SvxNumSettings_Impl
* lcl_CreateNumSettingsPtr(const Sequence
<PropertyValue
>& rLevelProps
)
124 const PropertyValue
* pValues
= rLevelProps
.getConstArray();
125 SvxNumSettings_Impl
* pNew
= new SvxNumSettings_Impl
;
126 for(sal_Int32 j
= 0; j
< rLevelProps
.getLength(); j
++)
128 if ( pValues
[j
].Name
== cNumberingType
)
129 pValues
[j
].Value
>>= pNew
->nNumberType
;
130 else if ( pValues
[j
].Name
== cPrefix
)
131 pValues
[j
].Value
>>= pNew
->sPrefix
;
132 else if ( pValues
[j
].Name
== cSuffix
)
133 pValues
[j
].Value
>>= pNew
->sSuffix
;
134 else if ( pValues
[j
].Name
== cParentNumbering
)
135 pValues
[j
].Value
>>= pNew
->nParentNumbering
;
136 else if ( pValues
[j
].Name
== cBulletChar
)
137 pValues
[j
].Value
>>= pNew
->sBulletChar
;
138 else if ( pValues
[j
].Name
== cBulletFontName
)
139 pValues
[j
].Value
>>= pNew
->sBulletFont
;
144 // the selection of bullets from the StarSymbol
145 static const sal_Unicode aBulletTypes
[] =
157 // Is one of the masked formats set?
158 static bool lcl_IsNumFmtSet(SvxNumRule
* pNum
, sal_uInt16 nLevelMask
)
161 sal_uInt16 nMask
= 1;
162 for( sal_uInt16 i
= 0; i
< SVX_MAX_NUM
&& !bRet
; i
++ )
164 if(nLevelMask
& nMask
)
165 bRet
|= 0 != pNum
->Get( i
);
171 static vcl::Font
& lcl_GetDefaultBulletFont()
173 static bool bInit
= false;
174 static vcl::Font
aDefBulletFont( OUString("StarSymbol"),
175 OUString(), Size( 0, 14 ) );
178 aDefBulletFont
.SetCharSet( RTL_TEXTENCODING_SYMBOL
);
179 aDefBulletFont
.SetFamily( FAMILY_DONTKNOW
);
180 aDefBulletFont
.SetPitch( PITCH_DONTKNOW
);
181 aDefBulletFont
.SetWeight( WEIGHT_DONTKNOW
);
182 aDefBulletFont
.SetTransparent( true );
185 return aDefBulletFont
;
188 SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(vcl::Window
* pParent
,
189 const SfxItemSet
& rSet
)
190 : SfxTabPage(pParent
, "PickNumberingPage", "cui/ui/picknumberingpage.ui", &rSet
)
193 , nActNumLvl(SAL_MAX_UINT16
)
196 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
198 SetExchangeSupport();
199 get(m_pExamplesVS
, "valueset");
200 m_pExamplesVS
->init(NUM_PAGETYPE_SINGLENUM
);
201 m_pExamplesVS
->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage
, NumSelectHdl_Impl
));
202 m_pExamplesVS
->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage
, DoubleClickHdl_Impl
));
204 Reference
<XDefaultNumberingProvider
> xDefNum
= lcl_GetNumberingProvider();
207 Sequence
< Sequence
< PropertyValue
> > aNumberings
;
208 const Locale
& rLocale
= Application::GetSettings().GetLanguageTag().getLocale();
212 xDefNum
->getDefaultContinuousNumberingLevels( rLocale
);
215 sal_Int32 nLength
= aNumberings
.getLength() > NUM_VALUSET_COUNT
? NUM_VALUSET_COUNT
:aNumberings
.getLength();
217 const Sequence
<PropertyValue
>* pValuesArr
= aNumberings
.getConstArray();
218 for(sal_Int32 i
= 0; i
< nLength
; i
++)
220 SvxNumSettings_Impl
* pNew
= lcl_CreateNumSettingsPtr(pValuesArr
[i
]);
221 aNumSettingsArr
.push_back(pNew
);
224 catch(const Exception
&)
227 Reference
<XNumberingFormatter
> xFormat(xDefNum
, UNO_QUERY
);
228 m_pExamplesVS
->SetNumberingSettings(aNumberings
, xFormat
, rLocale
);
232 SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
237 void SvxSingleNumPickTabPage::dispose()
243 m_pExamplesVS
.clear();
244 SfxTabPage::dispose();
247 VclPtr
<SfxTabPage
> SvxSingleNumPickTabPage::Create( vcl::Window
* pParent
,
248 const SfxItemSet
* rAttrSet
)
250 return VclPtr
<SvxSingleNumPickTabPage
>::Create(pParent
, *rAttrSet
);
253 bool SvxSingleNumPickTabPage::FillItemSet( SfxItemSet
* rSet
)
255 if( (bPreset
|| bModified
) && pSaveNum
)
257 *pSaveNum
= *pActNum
;
258 rSet
->Put(SvxNumBulletItem( *pSaveNum
), nNumItemId
);
259 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
265 void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
267 const SfxPoolItem
* pItem
;
269 bool bIsPreset
= false;
270 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
273 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
274 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
275 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
276 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
278 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
281 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
283 if(pActNum
&& *pSaveNum
!= *pActNum
)
285 *pActNum
= *pSaveNum
;
286 m_pExamplesVS
->SetNoSelection();
289 if(pActNum
&& (!lcl_IsNumFmtSet(pActNum
, nActNumLvl
) || bIsPreset
))
291 m_pExamplesVS
->SelectItem(1);
292 NumSelectHdl_Impl(m_pExamplesVS
);
295 bPreset
|= bIsPreset
;
300 SfxTabPage::sfxpg
SvxSingleNumPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
307 void SvxSingleNumPickTabPage::Reset( const SfxItemSet
* rSet
)
309 const SfxPoolItem
* pItem
;
311 // in Draw the item exists as WhichId, in Writer only as SlotId
312 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
313 if(eState
!= SfxItemState::SET
)
315 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
316 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
318 if( eState
!= SfxItemState::SET
)
320 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
, true ) );
321 eState
= SfxItemState::SET
;
324 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
326 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
329 pActNum
= new SvxNumRule(*pSaveNum
);
330 else if(*pSaveNum
!= *pActNum
)
331 *pActNum
= *pSaveNum
;
334 IMPL_LINK_NOARG(SvxSingleNumPickTabPage
, NumSelectHdl_Impl
)
340 sal_uInt16 nIdx
= m_pExamplesVS
->GetSelectItemId() - 1;
341 DBG_ASSERT(aNumSettingsArr
.size() > nIdx
, "wrong index");
342 if(aNumSettingsArr
.size() <= nIdx
)
344 SvxNumSettings_Impl
* _pSet
= &aNumSettingsArr
[nIdx
];
345 sal_Int16 eNewType
= _pSet
->nNumberType
;
346 const sal_Unicode cLocalPrefix
= !_pSet
->sPrefix
.isEmpty() ? _pSet
->sPrefix
[0] : 0;
347 const sal_Unicode cLocalSuffix
= !_pSet
->sSuffix
.isEmpty() ? _pSet
->sSuffix
[0] : 0;
349 sal_uInt16 nMask
= 1;
350 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
352 if(nActNumLvl
& nMask
)
354 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
355 aFmt
.SetNumberingType(eNewType
);
357 if(cLocalPrefix
== ' ')
358 aFmt
.SetPrefix( aEmptyStr
);
360 aFmt
.SetPrefix(_pSet
->sPrefix
);
361 if(cLocalSuffix
== ' ')
362 aFmt
.SetSuffix( aEmptyStr
);
364 aFmt
.SetSuffix(_pSet
->sSuffix
);
365 aFmt
.SetCharFormatName(sNumCharFmtName
);
366 // #62069# // #92724#
367 aFmt
.SetBulletRelSize(100);
368 pActNum
->SetLevel(i
, aFmt
);
376 IMPL_LINK_NOARG(SvxSingleNumPickTabPage
, DoubleClickHdl_Impl
)
378 NumSelectHdl_Impl(m_pExamplesVS
);
379 PushButton
& rOk
= GetTabDialog()->GetOKButton();
380 rOk
.GetClickHdl().Call(&rOk
);
385 SvxBulletPickTabPage::SvxBulletPickTabPage(vcl::Window
* pParent
,
386 const SfxItemSet
& rSet
)
387 : SfxTabPage(pParent
, "PickBulletPage", "cui/ui/pickbulletpage.ui", &rSet
)
390 , nActNumLvl(SAL_MAX_UINT16
)
393 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
395 SetExchangeSupport();
396 get(m_pExamplesVS
, "valueset");
397 m_pExamplesVS
->init(NUM_PAGETYPE_BULLET
),
398 m_pExamplesVS
->SetSelectHdl(LINK(this, SvxBulletPickTabPage
, NumSelectHdl_Impl
));
399 m_pExamplesVS
->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage
, DoubleClickHdl_Impl
));
402 SvxBulletPickTabPage::~SvxBulletPickTabPage()
407 void SvxBulletPickTabPage::dispose()
413 m_pExamplesVS
.clear();
414 SfxTabPage::dispose();
417 VclPtr
<SfxTabPage
> SvxBulletPickTabPage::Create( vcl::Window
* pParent
,
418 const SfxItemSet
* rAttrSet
)
420 return VclPtr
<SvxBulletPickTabPage
>::Create(pParent
, *rAttrSet
);
423 bool SvxBulletPickTabPage::FillItemSet( SfxItemSet
* rSet
)
425 if( (bPreset
|| bModified
) && pActNum
)
427 *pSaveNum
= *pActNum
;
428 rSet
->Put(SvxNumBulletItem( *pSaveNum
), nNumItemId
);
429 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
434 void SvxBulletPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
436 const SfxPoolItem
* pItem
;
438 bool bIsPreset
= false;
439 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
442 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
443 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
444 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
445 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
447 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
450 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
452 if(pActNum
&& *pSaveNum
!= *pActNum
)
454 *pActNum
= *pSaveNum
;
455 m_pExamplesVS
->SetNoSelection();
458 if(pActNum
&& (!lcl_IsNumFmtSet(pActNum
, nActNumLvl
) || bIsPreset
))
460 m_pExamplesVS
->SelectItem(1);
461 NumSelectHdl_Impl(m_pExamplesVS
);
464 bPreset
|= bIsPreset
;
468 SfxTabPage::sfxpg
SvxBulletPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
475 void SvxBulletPickTabPage::Reset( const SfxItemSet
* rSet
)
477 const SfxPoolItem
* pItem
;
478 // in Draw the item exists as WhichId, in Writer only as SlotId
479 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
480 if(eState
!= SfxItemState::SET
)
482 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
483 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
485 if( eState
!= SfxItemState::SET
)
487 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
, true ) );
488 eState
= SfxItemState::SET
;
492 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
494 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
497 pActNum
= new SvxNumRule(*pSaveNum
);
498 else if(*pSaveNum
!= *pActNum
)
499 *pActNum
= *pSaveNum
;
502 IMPL_LINK_NOARG(SvxBulletPickTabPage
, NumSelectHdl_Impl
)
508 sal_Unicode cChar
= aBulletTypes
[m_pExamplesVS
->GetSelectItemId() - 1];
509 vcl::Font
& rActBulletFont
= lcl_GetDefaultBulletFont();
511 sal_uInt16 nMask
= 1;
512 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
514 if(nActNumLvl
& nMask
)
516 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
517 aFmt
.SetNumberingType( SVX_NUM_CHAR_SPECIAL
);
518 // #i93908# clear suffix for bullet lists
519 aFmt
.SetPrefix( OUString() );
520 aFmt
.SetSuffix( OUString() );
521 aFmt
.SetBulletFont(&rActBulletFont
);
522 aFmt
.SetBulletChar(cChar
);
523 aFmt
.SetCharFormatName(sBulletCharFormatName
);
524 // #62069# // #92724#
525 aFmt
.SetBulletRelSize(45);
526 pActNum
->SetLevel(i
, aFmt
);
536 IMPL_LINK_NOARG(SvxBulletPickTabPage
, DoubleClickHdl_Impl
)
538 NumSelectHdl_Impl(m_pExamplesVS
);
539 PushButton
& rOk
= GetTabDialog()->GetOKButton();
540 rOk
.GetClickHdl().Call(&rOk
);
545 void SvxBulletPickTabPage::PageCreated(const SfxAllItemSet
& aSet
)
548 SFX_ITEMSET_ARG (&aSet
,pBulletCharFmt
,SfxStringItem
,SID_BULLET_CHAR_FMT
,false);
551 SetCharFormatName( pBulletCharFmt
->GetValue());
557 SvxNumPickTabPage::SvxNumPickTabPage(vcl::Window
* pParent
,
558 const SfxItemSet
& rSet
)
559 : SfxTabPage(pParent
, "PickOutlinePage", "cui/ui/pickoutlinepage.ui", &rSet
)
562 , nActNumLvl(SAL_MAX_UINT16
)
563 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
567 SetExchangeSupport();
569 get(m_pExamplesVS
, "valueset");
570 m_pExamplesVS
->init(NUM_PAGETYPE_NUM
);
571 m_pExamplesVS
->SetSelectHdl(LINK(this, SvxNumPickTabPage
, NumSelectHdl_Impl
));
572 m_pExamplesVS
->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage
, DoubleClickHdl_Impl
));
574 Reference
<XDefaultNumberingProvider
> xDefNum
= lcl_GetNumberingProvider();
577 Sequence
<Reference
<XIndexAccess
> > aOutlineAccess
;
578 const Locale
& rLocale
= Application::GetSettings().GetLanguageTag().getLocale();
581 aOutlineAccess
= xDefNum
->getDefaultOutlineNumberings( rLocale
);
583 for(sal_Int32 nItem
= 0;
584 nItem
< aOutlineAccess
.getLength() && nItem
< NUM_VALUSET_COUNT
;
587 SvxNumSettingsArr_Impl
& rItemArr
= aNumSettingsArrays
[ nItem
];
589 Reference
<XIndexAccess
> xLevel
= aOutlineAccess
.getConstArray()[nItem
];
590 for(sal_Int32 nLevel
= 0; nLevel
< xLevel
->getCount() && nLevel
< 5; nLevel
++)
592 Any aValueAny
= xLevel
->getByIndex(nLevel
);
593 Sequence
<PropertyValue
> aLevelProps
;
594 aValueAny
>>= aLevelProps
;
595 SvxNumSettings_Impl
* pNew
= lcl_CreateNumSettingsPtr(aLevelProps
);
596 rItemArr
.push_back( pNew
);
600 catch(const Exception
&)
603 Reference
<XNumberingFormatter
> xFormat(xDefNum
, UNO_QUERY
);
604 m_pExamplesVS
->SetOutlineNumberingSettings(aOutlineAccess
, xFormat
, rLocale
);
608 SvxNumPickTabPage::~SvxNumPickTabPage()
613 void SvxNumPickTabPage::dispose()
619 m_pExamplesVS
.clear();
620 SfxTabPage::dispose();
623 VclPtr
<SfxTabPage
> SvxNumPickTabPage::Create( vcl::Window
* pParent
,
624 const SfxItemSet
* rAttrSet
)
626 return VclPtr
<SvxNumPickTabPage
>::Create(pParent
, *rAttrSet
);
629 bool SvxNumPickTabPage::FillItemSet( SfxItemSet
* rSet
)
631 if( (bPreset
|| bModified
) && pActNum
)
633 *pSaveNum
= *pActNum
;
634 rSet
->Put(SvxNumBulletItem( *pSaveNum
), nNumItemId
);
635 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
640 void SvxNumPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
642 const SfxPoolItem
* pItem
;
644 bool bIsPreset
= false;
645 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
648 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
649 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
650 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
651 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
653 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
656 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
658 if(pActNum
&& *pSaveNum
!= *pActNum
)
660 *pActNum
= *pSaveNum
;
661 m_pExamplesVS
->SetNoSelection();
664 if(pActNum
&& (!lcl_IsNumFmtSet(pActNum
, nActNumLvl
) || bIsPreset
))
666 m_pExamplesVS
->SelectItem(1);
667 NumSelectHdl_Impl(m_pExamplesVS
);
670 bPreset
|= bIsPreset
;
674 SfxTabPage::sfxpg
SvxNumPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
681 void SvxNumPickTabPage::Reset( const SfxItemSet
* rSet
)
683 const SfxPoolItem
* pItem
;
684 // in Draw the item exists as WhichId, in Writer only as SlotId
685 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
686 if(eState
!= SfxItemState::SET
)
688 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
689 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
691 if( eState
!= SfxItemState::SET
)
693 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
, true ) );
694 eState
= SfxItemState::SET
;
698 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
700 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
703 pActNum
= new SvxNumRule(*pSaveNum
);
704 else if(*pSaveNum
!= *pActNum
)
705 *pActNum
= *pSaveNum
;
709 // all levels are changed here
710 IMPL_LINK_NOARG(SvxNumPickTabPage
, NumSelectHdl_Impl
)
717 const FontList
* pList
= 0;
719 SvxNumSettingsArr_Impl
& rItemArr
= aNumSettingsArrays
[m_pExamplesVS
->GetSelectItemId() - 1];
721 vcl::Font
& rActBulletFont
= lcl_GetDefaultBulletFont();
722 SvxNumSettings_Impl
* pLevelSettings
= 0;
723 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
725 if(rItemArr
.size() > i
)
726 pLevelSettings
= &rItemArr
[i
];
729 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
730 aFmt
.SetNumberingType( pLevelSettings
->nNumberType
);
731 sal_uInt16 nUpperLevelOrChar
= (sal_uInt16
)pLevelSettings
->nParentNumbering
;
732 if(aFmt
.GetNumberingType() == SVX_NUM_CHAR_SPECIAL
)
734 // #i93908# clear suffix for bullet lists
735 aFmt
.SetPrefix(OUString());
736 aFmt
.SetSuffix(OUString());
737 if( !pLevelSettings
->sBulletFont
.isEmpty() &&
738 pLevelSettings
->sBulletFont
.compareTo(
739 rActBulletFont
.GetName()))
741 //search for the font
744 SfxObjectShell
* pCurDocShell
= SfxObjectShell::Current();
745 const SvxFontListItem
* pFontListItem
=
746 static_cast<const SvxFontListItem
*>( pCurDocShell
747 ->GetItem( SID_ATTR_CHAR_FONTLIST
));
748 pList
= pFontListItem
? pFontListItem
->GetFontList() : 0;
750 if(pList
&& pList
->IsAvailable( pLevelSettings
->sBulletFont
) )
752 vcl::FontInfo aInfo
= pList
->Get(
753 pLevelSettings
->sBulletFont
,WEIGHT_NORMAL
, ITALIC_NONE
);
754 vcl::Font
aFont(aInfo
);
755 aFmt
.SetBulletFont(&aFont
);
759 //if it cannot be found then create a new one
760 vcl::Font
aCreateFont( pLevelSettings
->sBulletFont
,
761 OUString(), Size( 0, 14 ) );
762 aCreateFont
.SetCharSet( RTL_TEXTENCODING_DONTKNOW
);
763 aCreateFont
.SetFamily( FAMILY_DONTKNOW
);
764 aCreateFont
.SetPitch( PITCH_DONTKNOW
);
765 aCreateFont
.SetWeight( WEIGHT_DONTKNOW
);
766 aCreateFont
.SetTransparent( true );
767 aFmt
.SetBulletFont( &aCreateFont
);
771 aFmt
.SetBulletFont( &rActBulletFont
);
773 aFmt
.SetBulletChar( !pLevelSettings
->sBulletChar
.isEmpty()
774 ? pLevelSettings
->sBulletChar
[0]
776 aFmt
.SetCharFormatName( sBulletCharFormatName
);
777 // #62069# // #92724#
778 aFmt
.SetBulletRelSize(45);
782 aFmt
.SetIncludeUpperLevels(sal::static_int_cast
< sal_uInt8
>(0 != nUpperLevelOrChar
? pActNum
->GetLevelCount() : 0));
783 aFmt
.SetCharFormatName(sNumCharFmtName
);
784 // #62069# // #92724#
785 aFmt
.SetBulletRelSize(100);
787 aFmt
.SetPrefix(pLevelSettings
->sPrefix
);
788 aFmt
.SetSuffix(pLevelSettings
->sSuffix
);
790 pActNum
->SetLevel(i
, aFmt
);
796 IMPL_LINK_NOARG(SvxNumPickTabPage
, DoubleClickHdl_Impl
)
798 NumSelectHdl_Impl(m_pExamplesVS
);
799 PushButton
& rOk
= GetTabDialog()->GetOKButton();
800 rOk
.GetClickHdl().Call(&rOk
);
804 void SvxNumPickTabPage::PageCreated(const SfxAllItemSet
& aSet
)
806 SFX_ITEMSET_ARG (&aSet
,pNumCharFmt
,SfxStringItem
,SID_NUM_CHAR_FMT
,false);
807 SFX_ITEMSET_ARG (&aSet
,pBulletCharFmt
,SfxStringItem
,SID_BULLET_CHAR_FMT
,false);
810 if (pNumCharFmt
&&pBulletCharFmt
)
811 SetCharFormatNames( pNumCharFmt
->GetValue(),pBulletCharFmt
->GetValue());
814 SvxBitmapPickTabPage::SvxBitmapPickTabPage(vcl::Window
* pParent
,
815 const SfxItemSet
& rSet
)
816 : SfxTabPage(pParent
, "PickGraphicPage", "cui/ui/pickgraphicpage.ui", &rSet
)
819 , nActNumLvl(SAL_MAX_UINT16
)
820 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
824 SetExchangeSupport();
825 get(m_pErrorText
, "errorft");
826 get(m_pExamplesVS
, "valueset");
827 get(m_pBtBrowseFile
, "browseBtn");
829 m_pExamplesVS
->SetSelectHdl(LINK(this, SvxBitmapPickTabPage
, NumSelectHdl_Impl
));
830 m_pExamplesVS
->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage
, DoubleClickHdl_Impl
));
831 m_pBtBrowseFile
->SetClickHdl(LINK(this, SvxBitmapPickTabPage
, ClickAddBrowseHdl_Impl
));
833 eCoreUnit
= rSet
.GetPool()->GetMetric(rSet
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
835 // determine graphic name
836 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, aGrfNames
);
839 for(std::vector
<OUString
>::iterator it
= aGrfNames
.begin(); it
!= aGrfNames
.end(); ++it
, ++i
)
841 m_pExamplesVS
->InsertItem( i
+ 1, i
);
843 INetURLObject
aObj(*it
);
844 if(aObj
.GetProtocol() == INetProtocol::File
)
845 *it
= aObj
.PathToFileName();
847 m_pExamplesVS
->SetItemText( i
+ 1, *it
);
850 if(aGrfNames
.empty())
852 m_pErrorText
->Show();
856 m_pExamplesVS
->Show();
857 m_pExamplesVS
->SetFormat();
858 m_pExamplesVS
->Invalidate();
862 SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
867 void SvxBitmapPickTabPage::dispose()
873 m_pBtBrowseFile
.clear();
874 m_pErrorText
.clear();
875 m_pExamplesVS
.clear();
876 SfxTabPage::dispose();
879 VclPtr
<SfxTabPage
> SvxBitmapPickTabPage::Create( vcl::Window
* pParent
,
880 const SfxItemSet
* rAttrSet
)
882 return VclPtr
<SvxBitmapPickTabPage
>::Create(pParent
, *rAttrSet
);
885 void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet
& rSet
)
887 const SfxPoolItem
* pItem
;
889 bool bIsPreset
= false;
890 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
893 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
894 bIsPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
895 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
896 nActNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
898 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
901 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
903 if(pActNum
&& *pSaveNum
!= *pActNum
)
905 *pActNum
= *pSaveNum
;
906 m_pExamplesVS
->SetNoSelection();
909 if(!aGrfNames
.empty() &&
910 (pActNum
&& (!lcl_IsNumFmtSet(pActNum
, nActNumLvl
) || bIsPreset
)))
912 m_pExamplesVS
->SelectItem(1);
913 NumSelectHdl_Impl(m_pExamplesVS
);
916 bPreset
|= bIsPreset
;
920 SfxTabPage::sfxpg
SvxBitmapPickTabPage::DeactivatePage(SfxItemSet
*_pSet
)
927 bool SvxBitmapPickTabPage::FillItemSet( SfxItemSet
* rSet
)
929 if ( aGrfNames
.empty() )
933 if( (bPreset
|| bModified
) && pActNum
)
935 *pSaveNum
= *pActNum
;
936 rSet
->Put(SvxNumBulletItem( *pSaveNum
), nNumItemId
);
937 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, bPreset
));
943 void SvxBitmapPickTabPage::Reset( const SfxItemSet
* rSet
)
945 const SfxPoolItem
* pItem
;
946 // in Draw the item exists as WhichId, in Writer only as SlotId
947 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
948 if(eState
!= SfxItemState::SET
)
950 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
951 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
953 if( eState
!= SfxItemState::SET
)
955 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
, true ) );
956 eState
= SfxItemState::SET
;
960 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
962 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
965 pActNum
= new SvxNumRule(*pSaveNum
);
966 else if(*pSaveNum
!= *pActNum
)
967 *pActNum
= *pSaveNum
;
970 IMPL_LINK_NOARG(SvxBitmapPickTabPage
, NumSelectHdl_Impl
)
976 sal_uInt16 nIdx
= m_pExamplesVS
->GetSelectItemId() - 1;
978 sal_uInt16 nMask
= 1;
980 sal_uInt16 nSetNumberingType
= SVX_NUM_BITMAP
;
981 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
983 if(nActNumLvl
& nMask
)
985 SvxNumberFormat
aFmt(pActNum
->GetLevel(i
));
986 aFmt
.SetNumberingType(nSetNumberingType
);
987 aFmt
.SetPrefix( aEmptyStr
);
988 aFmt
.SetSuffix( aEmptyStr
);
989 aFmt
.SetCharFormatName( sNumCharFmtName
);
992 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, nIdx
, &aGraphic
))
994 Size aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
995 sal_Int16 eOrient
= text::VertOrientation::LINE_CENTER
;
996 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)eCoreUnit
);
997 SvxBrushItem
aBrush(aGraphic
, GPOS_AREA
, SID_ATTR_BRUSH
);
998 aFmt
.SetGraphicBrush( &aBrush
, &aSize
, &eOrient
);
1000 else if(aGrfNames
.size() > nIdx
)
1001 aFmt
.SetGraphic( aGrfNames
[nIdx
] );
1002 pActNum
->SetLevel(i
, aFmt
);
1011 IMPL_LINK_NOARG(SvxBitmapPickTabPage
, DoubleClickHdl_Impl
)
1013 NumSelectHdl_Impl(m_pExamplesVS
);
1014 PushButton
& rOk
= GetTabDialog()->GetOKButton();
1015 rOk
.GetClickHdl().Call(&rOk
);
1019 IMPL_LINK_NOARG(SvxBitmapPickTabPage
, ClickAddBrowseHdl_Impl
)
1022 sfx2::FileDialogHelper
aFileDialog(0, 0);
1023 aFileDialog
.SetTitle(CUI_RES(RID_SVXSTR_ADD_IMAGE
));
1024 if ( aFileDialog
.Execute() != ERRCODE_NONE
)
1027 OUString aPath
= SvtPathOptions().GetGalleryPath();
1028 OUString aPathToken
= aPath
.getToken( 1 , SEARCHPATH_DELIMITER
);
1030 OUString aUserImageURL
= aFileDialog
.GetPath();
1032 sal_Int32 nSub
= comphelper::string::getTokenCount( aUserImageURL
, '/');
1033 OUString aFileName
= aUserImageURL
.getToken( nSub
-1 , SEARCHFILENAME_DELIMITER
);
1035 OUString aUserGalleryURL
= aPathToken
+ "/" + aFileName
;
1036 INetURLObject
aURL( aUserImageURL
);
1037 DBG_ASSERT( aURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
1039 GraphicDescriptor
aDescriptor(aURL
);
1040 if (aDescriptor
.Detect())
1042 uno::Reference
< lang::XMultiServiceFactory
> xFactory
= ::comphelper::getProcessServiceFactory();
1043 uno::Reference
<ucb::XSimpleFileAccess3
> xSimpleFileAccess(
1044 ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory
) ) );
1045 if ( xSimpleFileAccess
->exists( aUserImageURL
))
1047 xSimpleFileAccess
->copy( aUserImageURL
, aUserGalleryURL
);
1048 INetURLObject
gURL( aUserGalleryURL
);
1049 boost::scoped_ptr
<SvStream
> pIn(::utl::UcbStreamHelper::CreateStream(
1050 gURL
.GetMainURL( INetURLObject::NO_DECODE
), StreamMode::READ
));
1054 GraphicConverter::Import( *pIn
, aGraphic
);
1056 BitmapEx aBitmap
= aGraphic
.GetBitmapEx();
1057 long nPixelX
= (long)(aBitmap
.GetSizePixel().Width());
1058 long nPixelY
= (long)(aBitmap
.GetSizePixel().Height());
1059 double ratio
= nPixelY
/(double)nPixelX
;
1063 nPixelY
= (long) (nPixelX
*ratio
);
1068 nPixelX
= (long) (nPixelY
/ratio
);
1071 aBitmap
.Scale( Size( nPixelX
, nPixelY
), BmpScaleFlag::Fast
);
1072 Graphic
aScaledGraphic( aBitmap
);
1073 GraphicFilter
& rFilter
= GraphicFilter::GetGraphicFilter();
1075 Sequence
< PropertyValue
> aFilterData( 2 );
1076 aFilterData
[ 0 ].Name
= "Compression";
1077 aFilterData
[ 0 ].Value
<<= (sal_Int32
) -1 ;
1078 aFilterData
[ 1 ].Name
= "Quality";
1079 aFilterData
[ 1 ].Value
<<= (sal_Int32
) 1;
1081 sal_uInt16 nFilterFormat
= rFilter
.GetExportFormatNumberForShortName( gURL
.GetFileExtension() );
1082 rFilter
.ExportGraphic( aScaledGraphic
, gURL
, nFilterFormat
, &aFilterData
);
1083 GalleryExplorer::InsertURL( GALLERY_THEME_BULLETS
, aUserGalleryURL
);
1085 aGrfNames
.push_back(aUserGalleryURL
);
1087 for(std::vector
<OUString
>::iterator it
= aGrfNames
.begin(); it
!= aGrfNames
.end(); ++it
, ++i
)
1089 m_pExamplesVS
->InsertItem( i
+ 1, i
);
1090 INetURLObject
aObj(*it
);
1091 if(aObj
.GetProtocol() == INetProtocol::File
)
1092 *it
= aObj
.PathToFileName();
1093 m_pExamplesVS
->SetItemText( i
+ 1, *it
);
1096 if(aGrfNames
.empty())
1098 m_pErrorText
->Show();
1102 m_pExamplesVS
->Show();
1103 m_pExamplesVS
->SetFormat();
1114 void SvxNumOptionsTabPage::GetI18nNumbering( ListBox
& rFmtLB
, sal_uInt16 nDoNotRemove
)
1117 Reference
<XDefaultNumberingProvider
> xDefNum
= lcl_GetNumberingProvider();
1118 Reference
<XNumberingTypeInfo
> xInfo(xDefNum
, UNO_QUERY
);
1120 // Extended numbering schemes present in the resource but not offered by
1121 // the i18n framework per configuration must be removed from the listbox.
1122 // Do not remove a special entry matching nDoNotRemove.
1123 const sal_uInt16 nDontRemove
= SAL_MAX_UINT16
;
1124 ::std::vector
< sal_uInt16
> aRemove( rFmtLB
.GetEntryCount(), nDontRemove
);
1125 for (size_t i
=0; i
<aRemove
.size(); ++i
)
1127 sal_uInt16 nEntryData
= (sal_uInt16
)reinterpret_cast<sal_uLong
>(rFmtLB
.GetEntryData(
1128 sal::static_int_cast
< sal_Int32
>(i
)));
1129 if (nEntryData
> NumberingType::CHARS_LOWER_LETTER_N
&& nEntryData
!= nDoNotRemove
)
1130 aRemove
[i
] = nEntryData
;
1134 Sequence
<sal_Int16
> aTypes
= xInfo
->getSupportedNumberingTypes( );
1135 const sal_Int16
* pTypes
= aTypes
.getConstArray();
1136 for(sal_Int32 nType
= 0; nType
< aTypes
.getLength(); nType
++)
1138 sal_Int16 nCurrent
= pTypes
[nType
];
1139 if(nCurrent
> NumberingType::CHARS_LOWER_LETTER_N
)
1141 bool bInsert
= true;
1142 for(sal_Int32 nEntry
= 0; nEntry
< rFmtLB
.GetEntryCount(); nEntry
++)
1144 sal_uInt16 nEntryData
= (sal_uInt16
)reinterpret_cast<sal_uLong
>(rFmtLB
.GetEntryData(nEntry
));
1145 if(nEntryData
== (sal_uInt16
) nCurrent
)
1148 aRemove
[nEntry
] = nDontRemove
;
1154 OUString aIdent
= xInfo
->getNumberingIdentifier( nCurrent
);
1155 sal_Int32 nPos
= rFmtLB
.InsertEntry(aIdent
);
1156 rFmtLB
.SetEntryData(nPos
, reinterpret_cast<void*>((sal_uLong
)nCurrent
));
1161 for (size_t i
=0; i
<aRemove
.size(); ++i
)
1163 if (aRemove
[i
] != nDontRemove
)
1165 sal_Int32 nPos
= rFmtLB
.GetEntryPos( reinterpret_cast<void*>((sal_uLong
)aRemove
[i
]));
1166 rFmtLB
.RemoveEntry( nPos
);
1171 // tabpage numbering options
1172 SvxNumOptionsTabPage::SvxNumOptionsTabPage(vcl::Window
* pParent
,
1173 const SfxItemSet
& rSet
)
1174 : SfxTabPage(pParent
, "NumberingOptionsPage", "cui/ui/numberingoptionspage.ui", &rSet
)
1177 , bLastWidthModified(false)
1180 , bAutomaticCharStyles(true)
1182 , bMenuButtonInitialized(false)
1184 , nActNumLvl(SAL_MAX_UINT16
)
1185 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
1187 get(m_pLevelLB
, "levellb");
1188 get(m_pFmtLB
, "numfmtlb");
1190 get(m_pSeparatorFT
, "separator");
1191 get(m_pPrefixFT
, "prefixft");
1192 get(m_pPrefixED
, "prefix");
1193 get(m_pSuffixFT
, "suffixft");
1194 get(m_pSuffixED
, "suffix");
1196 get(m_pCharFmtFT
, "charstyleft");
1197 get(m_pCharFmtLB
, "charstyle");
1199 get(m_pBulColorFT
, "colorft");
1200 get(m_pBulColLB
, "color");
1202 get(m_pBulRelSizeFT
, "relsizeft");
1203 get(m_pBulRelSizeMF
, "relsize");
1205 get(m_pAllLevelFT
, "sublevelsft");
1206 get(m_pAllLevelNF
, "sublevels");
1208 get(m_pStartFT
, "startatft");
1209 get(m_pStartED
, "startat");
1211 get(m_pBulletFT
, "bulletft");
1212 get(m_pBulletPB
, "bullet");
1214 get(m_pAlignFT
, "numalignft");
1215 get(m_pAlignLB
, "numalign");
1217 get(m_pBitmapFT
, "bitmapft");
1218 get(m_pBitmapMB
, "bitmap");
1220 get(m_pWidthFT
, "widthft");
1221 get(m_pWidthMF
, "widthmf");
1222 get(m_pHeightFT
, "heightft");
1223 get(m_pHeightMF
, "heightmf");
1225 get(m_pRatioCB
, "keepratio");
1227 get(m_pOrientFT
, "orientft");
1228 get(m_pOrientLB
, "orientlb");
1230 get(m_pAllLevelsFrame
, "levelsframe");
1231 get(m_pSameLevelCB
, "allsame");
1233 get(m_pPreviewWIN
, "preview");
1235 m_pPreviewWIN
->SetBackground(Wallpaper(Color(COL_TRANSPARENT
)));
1236 SetExchangeSupport();
1237 aActBulletFont
= lcl_GetDefaultBulletFont();
1239 m_pBulletPB
->SetClickHdl(LINK(this, SvxNumOptionsTabPage
, BulletHdl_Impl
));
1240 m_pFmtLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, NumberTypeSelectHdl_Impl
));
1241 m_pBitmapMB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, GraphicHdl_Impl
));
1242 m_pLevelLB
->EnableMultiSelection(true);
1243 m_pLevelLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, LevelHdl_Impl
));
1244 m_pCharFmtLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, CharFmtHdl_Impl
));
1245 m_pWidthMF
->SetModifyHdl(LINK(this, SvxNumOptionsTabPage
, SizeHdl_Impl
));
1246 m_pHeightMF
->SetModifyHdl(LINK(this, SvxNumOptionsTabPage
, SizeHdl_Impl
));
1247 m_pRatioCB
->SetClickHdl(LINK(this, SvxNumOptionsTabPage
, RatioHdl_Impl
));
1248 m_pStartED
->SetModifyHdl(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1249 m_pPrefixED
->SetModifyHdl(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1250 m_pSuffixED
->SetModifyHdl(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1251 m_pAllLevelNF
->SetModifyHdl(LINK(this,SvxNumOptionsTabPage
, AllLevelHdl_Impl
));
1252 m_pOrientLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, OrientHdl_Impl
));
1253 m_pSameLevelCB
->SetClickHdl(LINK(this, SvxNumOptionsTabPage
, SameLevelHdl_Impl
));
1254 m_pBulRelSizeMF
->SetModifyHdl(LINK(this,SvxNumOptionsTabPage
, BulRelSizeHdl_Impl
));
1255 m_pBulColLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, BulColorHdl_Impl
));
1256 aInvalidateTimer
.SetTimeoutHdl(LINK(this, SvxNumOptionsTabPage
, PreviewInvalidateHdl_Impl
));
1257 aInvalidateTimer
.SetTimeout(50);
1259 Menu
*pBitmapMenu
= m_pBitmapMB
->GetPopupMenu();
1261 pBitmapMenu
->SetHighlightHdl(LINK(this, SvxNumOptionsTabPage
, PopupActivateHdl_Impl
));
1262 m_nGalleryId
= pBitmapMenu
->GetItemId("gallery");
1263 assert(m_nGalleryId
!= MENU_ITEM_NOTFOUND
);
1264 PopupMenu
* pPopup
= new PopupMenu
;
1265 pBitmapMenu
->SetPopupMenu(m_nGalleryId
, pPopup
);
1267 eCoreUnit
= rSet
.GetPool()->GetMetric(rSet
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
1269 // Get advanced numbering types from the component.
1270 // Watch out for the ugly 0x88/*SVX_NUM_BITMAP|0x80*/ to not remove that.
1271 GetI18nNumbering( *m_pFmtLB
, (SVX_NUM_BITMAP
| 0x80));
1274 SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
1279 void SvxNumOptionsTabPage::dispose()
1283 delete m_pBitmapMB
->GetPopupMenu()->GetPopupMenu(m_nGalleryId
);
1291 m_pSeparatorFT
.clear();
1292 m_pPrefixFT
.clear();
1293 m_pPrefixED
.clear();
1294 m_pSuffixFT
.clear();
1295 m_pSuffixED
.clear();
1296 m_pCharFmtFT
.clear();
1297 m_pCharFmtLB
.clear();
1298 m_pBulColorFT
.clear();
1299 m_pBulColLB
.clear();
1300 m_pBulRelSizeFT
.clear();
1301 m_pBulRelSizeMF
.clear();
1302 m_pAllLevelFT
.clear();
1303 m_pAllLevelNF
.clear();
1306 m_pBulletFT
.clear();
1307 m_pBulletPB
.clear();
1310 m_pBitmapFT
.clear();
1311 m_pBitmapMB
.clear();
1314 m_pHeightFT
.clear();
1315 m_pHeightMF
.clear();
1317 m_pOrientFT
.clear();
1318 m_pOrientLB
.clear();
1319 m_pAllLevelsFrame
.clear();
1320 m_pSameLevelCB
.clear();
1321 m_pPreviewWIN
.clear();
1322 SfxTabPage::dispose();
1325 void SvxNumOptionsTabPage::SetMetric(FieldUnit eMetric
)
1327 if(eMetric
== FUNIT_MM
)
1329 m_pWidthMF
->SetDecimalDigits(1);
1330 m_pHeightMF
->SetDecimalDigits(1);
1332 m_pWidthMF
->SetUnit( eMetric
);
1333 m_pHeightMF
->SetUnit( eMetric
);
1336 VclPtr
<SfxTabPage
> SvxNumOptionsTabPage::Create( vcl::Window
* pParent
,
1337 const SfxItemSet
* rAttrSet
)
1339 return VclPtr
<SvxNumOptionsTabPage
>::Create(pParent
, *rAttrSet
);
1342 void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet
& rSet
)
1344 const SfxPoolItem
* pItem
;
1345 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
1346 sal_uInt16 nTmpNumLvl
= SAL_MAX_UINT16
;
1349 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
1350 bPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1351 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
1352 nTmpNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1354 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
1357 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
1360 bModified
= (!pActNum
->Get( 0 ) || bPreset
);
1361 if(*pActNum
!= *pSaveNum
||
1362 nActNumLvl
!= nTmpNumLvl
)
1364 *pActNum
= *pSaveNum
;
1365 nActNumLvl
= nTmpNumLvl
;
1366 sal_uInt16 nMask
= 1;
1367 m_pLevelLB
->SetUpdateMode(false);
1368 m_pLevelLB
->SetNoSelection();
1370 m_pLevelLB
->SelectEntryPos( 0, true);
1372 m_pLevelLB
->SelectEntryPos( pActNum
->GetLevelCount(), nActNumLvl
== SAL_MAX_UINT16
);
1373 if(nActNumLvl
!= SAL_MAX_UINT16
)
1374 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1376 if(nActNumLvl
& nMask
)
1377 m_pLevelLB
->SelectEntryPos( i
, true);
1380 m_pLevelLB
->SetUpdateMode(true);
1387 SfxTabPage::sfxpg
SvxNumOptionsTabPage::DeactivatePage(SfxItemSet
* _pSet
)
1394 bool SvxNumOptionsTabPage::FillItemSet( SfxItemSet
* rSet
)
1396 rSet
->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL
, nActNumLvl
));
1397 if(bModified
&& pActNum
)
1399 *pSaveNum
= *pActNum
;
1400 rSet
->Put(SvxNumBulletItem( *pSaveNum
), nNumItemId
);
1401 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, false));
1406 void SvxNumOptionsTabPage::Reset( const SfxItemSet
* rSet
)
1408 const SfxPoolItem
* pItem
;
1409 // in Draw the item exists as WhichId, in Writer only as SlotId
1410 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
1411 if(eState
!= SfxItemState::SET
)
1413 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
1414 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
1416 if( eState
!= SfxItemState::SET
)
1418 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
, true ) );
1419 eState
= SfxItemState::SET
;
1423 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
1425 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
1428 if(!m_pLevelLB
->GetEntryCount())
1430 for(sal_uInt16 i
= 1; i
<= pSaveNum
->GetLevelCount(); i
++)
1431 m_pLevelLB
->InsertEntry( OUString::number(i
));
1432 if(pSaveNum
->GetLevelCount() > 1)
1434 OUString
sEntry( "1 - " );
1435 sEntry
+= OUString::number( pSaveNum
->GetLevelCount() );
1436 m_pLevelLB
->InsertEntry(sEntry
);
1437 m_pLevelLB
->SelectEntry(sEntry
);
1440 m_pLevelLB
->SelectEntryPos(0);
1443 m_pLevelLB
->SelectEntryPos(m_pLevelLB
->GetEntryCount() - 1);
1445 sal_uInt16 nMask
= 1;
1446 m_pLevelLB
->SetUpdateMode(false);
1447 m_pLevelLB
->SetNoSelection();
1448 if(nActNumLvl
== SAL_MAX_UINT16
&& !bModified
)
1450 m_pLevelLB
->SelectEntryPos( 0, true);
1452 else if (nActNumLvl
== SAL_MAX_UINT16
)
1454 m_pLevelLB
->SelectEntryPos( pSaveNum
->GetLevelCount(), true);
1457 for(sal_uInt16 i
= 0; i
< pSaveNum
->GetLevelCount(); i
++)
1459 if(nActNumLvl
& nMask
)
1460 m_pLevelLB
->SelectEntryPos( i
, true);
1463 m_pLevelLB
->SetUpdateMode(true);
1466 pActNum
= new SvxNumRule(*pSaveNum
);
1467 else if(*pSaveNum
!= *pActNum
)
1468 *pActNum
= *pSaveNum
;
1469 m_pPreviewWIN
->SetNumRule(pActNum
);
1470 m_pSameLevelCB
->Check(pActNum
->IsContinuousNumbering());
1472 // fill ColorListBox as needed
1473 if ( pActNum
->IsFeatureSupported( SvxNumRuleFlags::BULLET_COLOR
) )
1475 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
1476 DBG_ASSERT( pDocSh
, "DocShell not found!" );
1477 XColorListRef pColorTable
;
1480 pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
1482 pColorTable
= static_cast<const SvxColorListItem
*>(pItem
)->GetColorList();
1485 if ( !pColorTable
.is() )
1486 pColorTable
= XColorList::CreateStdColorList();
1488 m_pBulColLB
->InsertEntry( Color( COL_AUTO
), SVX_RESSTR( RID_SVXSTR_AUTOMATIC
));
1490 for ( long i
= 0; i
< pColorTable
->Count(); i
++ )
1492 XColorEntry
* pEntry
= pColorTable
->GetColor(i
);
1493 m_pBulColLB
->InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
1497 SfxObjectShell
* pShell
;
1498 if ( SfxItemState::SET
== rSet
->GetItemState( SID_HTML_MODE
, false, &pItem
)
1499 || ( 0 != ( pShell
= SfxObjectShell::Current()) &&
1500 0 != ( pItem
= pShell
->GetItem( SID_HTML_MODE
) ) ) )
1502 sal_uInt16 nHtmlMode
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1503 bHTMLMode
= 0 != (nHtmlMode
&HTMLMODE_ON
);
1506 bool bCharFmt
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE
);
1507 m_pCharFmtFT
->Show(bCharFmt
);
1508 m_pCharFmtLB
->Show(bCharFmt
);
1510 bool bContinuous
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
);
1512 bool bAllLevel
= bContinuous
&& !bHTMLMode
;
1513 m_pAllLevelFT
->Show(bAllLevel
);
1514 m_pAllLevelNF
->Show(bAllLevel
);
1516 m_pAllLevelsFrame
->Show(bContinuous
);
1518 // again misusage: in Draw there is numeration only until the bitmap
1519 // without SVX_NUM_NUMBER_NONE
1520 //remove types that are unsupported by Draw/Impress
1523 sal_Int32 nFmtCount
= m_pFmtLB
->GetEntryCount();
1524 for(sal_Int32 i
= nFmtCount
; i
; i
--)
1526 sal_uInt16 nEntryData
= (sal_uInt16
)reinterpret_cast<sal_uLong
>(m_pFmtLB
->GetEntryData(i
- 1));
1527 if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
1528 ((SVX_NUM_BITMAP
|LINK_TOKEN
) == nEntryData
))
1529 m_pFmtLB
->RemoveEntry(i
- 1);
1532 //one must be enabled
1533 if(!pActNum
->IsFeatureSupported(SvxNumRuleFlags::ENABLE_LINKED_BMP
))
1535 sal_IntPtr nData
= SVX_NUM_BITMAP
|LINK_TOKEN
;
1536 sal_Int32 nPos
= m_pFmtLB
->GetEntryPos(reinterpret_cast<void*>(nData
));
1537 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
1538 m_pFmtLB
->RemoveEntry(nPos
);
1540 else if(!pActNum
->IsFeatureSupported(SvxNumRuleFlags::ENABLE_EMBEDDED_BMP
))
1542 sal_IntPtr nData
= SVX_NUM_BITMAP
;
1543 sal_Int32 nPos
= m_pFmtLB
->GetEntryPos(reinterpret_cast<void*>(nData
));
1544 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
1545 m_pFmtLB
->RemoveEntry(nPos
);
1547 if(pActNum
->IsFeatureSupported(SvxNumRuleFlags::SYMBOL_ALIGNMENT
))
1551 m_pAlignLB
->SetSelectHdl(LINK(this, SvxNumOptionsTabPage
, EditModifyHdl_Impl
));
1559 // MegaHack: because of a not-fixable 'design mistake/error' in Impress
1560 // delete all kinds of numeric enumerations
1561 if(pActNum
->IsFeatureSupported(SvxNumRuleFlags::NO_NUMBERS
))
1563 sal_Int32 nFmtCount
= m_pFmtLB
->GetEntryCount();
1564 for(sal_Int32 i
= nFmtCount
; i
; i
--)
1566 sal_uInt16 nEntryData
= (sal_uInt16
)reinterpret_cast<sal_uLong
>(m_pFmtLB
->GetEntryData(i
- 1));
1567 if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData
<= SVX_NUM_NUMBER_NONE
)
1568 m_pFmtLB
->RemoveEntry(i
- 1);
1577 void SvxNumOptionsTabPage::InitControls()
1579 bool bShowBullet
= true;
1580 bool bShowBitmap
= true;
1581 bool bSameType
= true;
1582 bool bSameStart
= true;
1583 bool bSamePrefix
= true;
1584 bool bSameSuffix
= true;
1585 bool bAllLevel
= true;
1586 bool bSameCharFmt
= true;
1587 bool bSameVOrient
= true;
1588 bool bSameSize
= true;
1589 bool bSameBulColor
= true;
1590 bool bSameBulRelSize
= true;
1591 bool bSameAdjust
= true;
1593 const SvxNumberFormat
* aNumFmtArr
[SVX_MAX_NUM
];
1594 OUString sFirstCharFmt
;
1595 sal_Int16 eFirstOrient
= text::VertOrientation::NONE
;
1596 Size
aFirstSize(0,0);
1597 sal_uInt16 nMask
= 1;
1598 sal_uInt16 nLvl
= SAL_MAX_UINT16
;
1599 sal_uInt16 nHighestLevel
= 0;
1602 bool bBullColor
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR
);
1603 bool bBullRelSize
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE
);
1604 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1606 if(nActNumLvl
& nMask
)
1608 aNumFmtArr
[i
] = &pActNum
->GetLevel(i
);
1609 bShowBullet
&= aNumFmtArr
[i
]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL
;
1610 bShowBitmap
&= (aNumFmtArr
[i
]->GetNumberingType()&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
;
1611 if(SAL_MAX_UINT16
== nLvl
)
1614 sFirstCharFmt
= aNumFmtArr
[i
]->GetCharFormatName();
1615 eFirstOrient
= aNumFmtArr
[i
]->GetVertOrient();
1617 aFirstSize
= aNumFmtArr
[i
]->GetGraphicSize();
1621 bSameType
&= aNumFmtArr
[i
]->GetNumberingType() == aNumFmtArr
[nLvl
]->GetNumberingType();
1622 bSameStart
= aNumFmtArr
[i
]->GetStart() == aNumFmtArr
[nLvl
]->GetStart();
1624 bSamePrefix
= aNumFmtArr
[i
]->GetPrefix() == aNumFmtArr
[nLvl
]->GetPrefix();
1625 bSameSuffix
= aNumFmtArr
[i
]->GetSuffix() == aNumFmtArr
[nLvl
]->GetSuffix();
1626 bAllLevel
&= aNumFmtArr
[i
]->GetIncludeUpperLevels() == aNumFmtArr
[nLvl
]->GetIncludeUpperLevels();
1627 bSameCharFmt
&= sFirstCharFmt
== aNumFmtArr
[i
]->GetCharFormatName();
1628 bSameVOrient
&= eFirstOrient
== aNumFmtArr
[i
]->GetVertOrient();
1629 if(bShowBitmap
&& bSameSize
)
1630 bSameSize
&= aNumFmtArr
[i
]->GetGraphicSize() == aFirstSize
;
1631 bSameBulColor
&= aNumFmtArr
[i
]->GetBulletColor() == aNumFmtArr
[nLvl
]->GetBulletColor();
1632 bSameBulRelSize
&= aNumFmtArr
[i
]->GetBulletRelSize() == aNumFmtArr
[nLvl
]->GetBulletRelSize();
1633 bSameAdjust
&= aNumFmtArr
[i
]->GetNumAdjust() == aNumFmtArr
[nLvl
]->GetNumAdjust();
1642 SwitchNumberType(bShowBullet
? 1 : bShowBitmap
? 2 : 0);
1644 sal_uInt16 nNumberingType
;
1645 if (nLvl
!= SAL_MAX_UINT16
)
1646 nNumberingType
= aNumFmtArr
[nLvl
]->GetNumberingType();
1649 nNumberingType
= SVX_NUM_NUMBER_NONE
;
1651 bSameAdjust
= false;
1652 bSameBulRelSize
= false;
1653 bSameBulColor
= false;
1655 bSamePrefix
= false;
1656 bSameSuffix
= false;
1659 CheckForStartValue_Impl(nNumberingType
);
1663 if(!bSameVOrient
|| eFirstOrient
== text::VertOrientation::NONE
)
1664 m_pOrientLB
->SetNoSelection();
1666 m_pOrientLB
->SelectEntryPos(
1667 sal::static_int_cast
< sal_Int32
>(eFirstOrient
- 1));
1668 // no text::VertOrientation::NONE
1672 SetMetricValue(*m_pHeightMF
, aFirstSize
.Height(), eCoreUnit
);
1673 SetMetricValue(*m_pWidthMF
, aFirstSize
.Width(), eCoreUnit
);
1677 m_pHeightMF
->SetText(aEmptyStr
);
1678 m_pWidthMF
->SetText(aEmptyStr
);
1684 sal_uInt16 nLBData
= nNumberingType
;
1685 m_pFmtLB
->SelectEntryPos(m_pFmtLB
->GetEntryPos( reinterpret_cast<void*>(sal::static_int_cast
<sal_uIntPtr
>( nLBData
) )));
1688 m_pFmtLB
->SetNoSelection();
1690 m_pAllLevelNF
->Enable(nHighestLevel
> 0 && !m_pSameLevelCB
->IsChecked());
1691 m_pAllLevelNF
->SetMax(nHighestLevel
+ 1);
1694 m_pAllLevelNF
->SetValue(aNumFmtArr
[nLvl
]->GetIncludeUpperLevels());
1698 m_pAllLevelNF
->SetText(aEmptyStr
);
1702 sal_Int32 nPos
= 1; // centered
1703 if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_LEFT
)
1705 else if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_RIGHT
)
1707 m_pAlignLB
->SelectEntryPos(nPos
);
1711 m_pAlignLB
->SetNoSelection();
1717 m_pBulRelSizeMF
->SetValue(aNumFmtArr
[nLvl
]->GetBulletRelSize());
1719 m_pBulRelSizeMF
->SetText(aEmptyStr
);
1724 m_pBulColLB
->SelectEntry(aNumFmtArr
[nLvl
]->GetBulletColor());
1726 m_pBulColLB
->SetNoSelection();
1730 case SHOW_NUMBERING
:
1733 m_pStartED
->SetValue(aNumFmtArr
[nLvl
]->GetStart());
1736 m_pStartED
->SetText(aEmptyStr
);
1745 m_pPrefixED
->SetText(aNumFmtArr
[nLvl
]->GetPrefix());
1747 m_pPrefixED
->SetText(aEmptyStr
);
1749 m_pSuffixED
->SetText(aNumFmtArr
[nLvl
]->GetSuffix());
1751 m_pSuffixED
->SetText(aEmptyStr
);
1755 if(!sFirstCharFmt
.isEmpty())
1756 m_pCharFmtLB
->SelectEntry(sFirstCharFmt
);
1758 m_pCharFmtLB
->SelectEntryPos( 0 );
1761 m_pCharFmtLB
->SetNoSelection();
1763 m_pPreviewWIN
->SetLevel(nActNumLvl
);
1764 m_pPreviewWIN
->Invalidate();
1767 // 0 - Number; 1 - Bullet; 2 - Bitmap
1768 void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType
, bool )
1770 if(nBullet
== nType
)
1773 bool bBullet
= (nType
== SHOW_BULLET
);
1774 bool bBitmap
= (nType
== SHOW_BITMAP
);
1775 bool bEnableBitmap
= (nType
== SHOW_BITMAP
);
1776 bool bNumeric
= !(bBitmap
||bBullet
);
1777 m_pSeparatorFT
->Show(bNumeric
);
1778 m_pPrefixFT
->Show(bNumeric
);
1779 m_pPrefixED
->Show(bNumeric
);
1780 m_pSuffixFT
->Show(bNumeric
);
1781 m_pSuffixED
->Show(bNumeric
);
1783 bool bCharFmt
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE
);
1784 m_pCharFmtFT
->Show(!bBitmap
&& bCharFmt
);
1785 m_pCharFmtLB
->Show(!bBitmap
&& bCharFmt
);
1787 // this is rather misusage, as there is no own flag
1788 // for complete numeration
1789 bool bAllLevelFeature
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
);
1790 bool bAllLevel
= bNumeric
&& bAllLevelFeature
&& !bHTMLMode
;
1791 m_pAllLevelFT
->Show(bAllLevel
);
1792 m_pAllLevelNF
->Show(bAllLevel
);
1794 m_pStartFT
->Show(!(bBullet
||bBitmap
));
1795 m_pStartED
->Show(!(bBullet
||bBitmap
));
1797 m_pBulletFT
->Show(bBullet
);
1798 m_pBulletPB
->Show(bBullet
);
1799 bool bBullColor
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR
);
1800 m_pBulColorFT
->Show(!bBitmap
&& bBullColor
);
1801 m_pBulColLB
->Show(!bBitmap
&& bBullColor
);
1802 bool bBullResSize
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE
);
1803 m_pBulRelSizeFT
->Show(!bBitmap
&& bBullResSize
);
1804 m_pBulRelSizeMF
->Show(!bBitmap
&& bBullResSize
);
1806 m_pBitmapFT
->Show(bBitmap
);
1807 m_pBitmapMB
->Show(bBitmap
);
1809 m_pWidthFT
->Show(bBitmap
);
1810 m_pWidthMF
->Show(bBitmap
);
1811 m_pHeightFT
->Show(bBitmap
);
1812 m_pHeightMF
->Show(bBitmap
);
1813 m_pRatioCB
->Show(bBitmap
);
1815 m_pOrientFT
->Show(bBitmap
&& bAllLevelFeature
);
1816 m_pOrientLB
->Show(bBitmap
&& bAllLevelFeature
);
1818 m_pWidthFT
->Enable(bEnableBitmap
);
1819 m_pWidthMF
->Enable(bEnableBitmap
);
1820 m_pHeightFT
->Enable(bEnableBitmap
);
1821 m_pHeightMF
->Enable(bEnableBitmap
);
1822 m_pRatioCB
->Enable(bEnableBitmap
);
1823 m_pOrientFT
->Enable(bEnableBitmap
);
1824 m_pOrientLB
->Enable(bEnableBitmap
);
1827 IMPL_LINK( SvxNumOptionsTabPage
, LevelHdl_Impl
, ListBox
*, pBox
)
1829 sal_uInt16 nSaveNumLvl
= nActNumLvl
;
1831 if(pBox
->IsEntryPosSelected( pActNum
->GetLevelCount() ) &&
1832 (pBox
->GetSelectEntryCount() == 1 || nSaveNumLvl
!= 0xffff))
1834 nActNumLvl
= 0xFFFF;
1835 pBox
->SetUpdateMode(false);
1836 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
1837 pBox
->SelectEntryPos( i
, false );
1838 pBox
->SetUpdateMode(true);
1840 else if(pBox
->GetSelectEntryCount())
1842 sal_uInt16 nMask
= 1;
1843 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
1845 if(pBox
->IsEntryPosSelected( i
))
1846 nActNumLvl
|= nMask
;
1849 pBox
->SelectEntryPos( pActNum
->GetLevelCount(), false );
1853 nActNumLvl
= nSaveNumLvl
;
1854 sal_uInt16 nMask
= 1;
1855 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
1857 if(nActNumLvl
& nMask
)
1859 pBox
->SelectEntryPos(i
);
1869 IMPL_LINK_NOARG_TYPED(SvxNumOptionsTabPage
, PreviewInvalidateHdl_Impl
, Timer
*, void)
1871 m_pPreviewWIN
->Invalidate();
1874 IMPL_LINK( SvxNumOptionsTabPage
, AllLevelHdl_Impl
, NumericField
*, pBox
)
1876 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1878 sal_uInt16 nMask
= 1;
1879 for(sal_uInt16 e
= 0; e
< pActNum
->GetLevelCount(); e
++)
1881 if(nActNumLvl
& nMask
)
1883 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(e
));
1884 aNumFmt
.SetIncludeUpperLevels((sal_uInt8
) std::min(pBox
->GetValue(), sal_Int64(e
+ 1)) );
1885 pActNum
->SetLevel(e
, aNumFmt
);
1894 IMPL_LINK( SvxNumOptionsTabPage
, NumberTypeSelectHdl_Impl
, ListBox
*, pBox
)
1896 OUString sSelectStyle
;
1897 bool bShowOrient
= false;
1900 sal_uInt16 nMask
= 1;
1901 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1903 if(nActNumLvl
& nMask
)
1905 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1906 // PAGEDESC does not exist
1907 sal_uInt16 nNumType
= (sal_uInt16
)reinterpret_cast<sal_uLong
>(pBox
->GetSelectEntryData());
1908 aNumFmt
.SetNumberingType((sal_Int16
)nNumType
);
1909 sal_uInt16 nNumberingType
= aNumFmt
.GetNumberingType();
1910 if(SVX_NUM_BITMAP
== (nNumberingType
&(~LINK_TOKEN
)))
1912 bBmp
|= 0 != aNumFmt
.GetBrush();
1913 aNumFmt
.SetIncludeUpperLevels( sal_False
);
1914 aNumFmt
.SetSuffix( aEmptyStr
);
1915 aNumFmt
.SetPrefix( aEmptyStr
);
1917 aNumFmt
.SetGraphic(aEmptyStr
);
1918 pActNum
->SetLevel(i
, aNumFmt
);
1919 SwitchNumberType(SHOW_BITMAP
, bBmp
);
1922 else if( SVX_NUM_CHAR_SPECIAL
== nNumberingType
)
1924 aNumFmt
.SetIncludeUpperLevels( sal_False
);
1925 aNumFmt
.SetSuffix( aEmptyStr
);
1926 aNumFmt
.SetPrefix( aEmptyStr
);
1927 if( !aNumFmt
.GetBulletFont() )
1928 aNumFmt
.SetBulletFont(&aActBulletFont
);
1929 if( !aNumFmt
.GetBulletChar() )
1930 aNumFmt
.SetBulletChar( SVX_DEF_BULLET
);
1931 pActNum
->SetLevel(i
, aNumFmt
);
1932 SwitchNumberType(SHOW_BULLET
);
1933 // allocation of the drawing pattern is automatic
1934 if(bAutomaticCharStyles
)
1936 sSelectStyle
= m_sBulletCharFormatName
;
1941 aNumFmt
.SetPrefix( m_pPrefixED
->GetText() );
1942 aNumFmt
.SetSuffix( m_pSuffixED
->GetText() );
1943 SwitchNumberType(SHOW_NUMBERING
);
1944 pActNum
->SetLevel(i
, aNumFmt
);
1945 CheckForStartValue_Impl(nNumberingType
);
1947 // allocation of the drawing pattern is automatic
1948 if(bAutomaticCharStyles
)
1950 sSelectStyle
= m_sNumCharFmtName
;
1956 bool bAllLevelFeature
= pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
);
1957 if(bShowOrient
&& bAllLevelFeature
)
1959 m_pOrientFT
->Show();
1960 m_pOrientLB
->Show();
1964 m_pOrientFT
->Hide();
1965 m_pOrientLB
->Hide();
1968 if(!sSelectStyle
.isEmpty())
1970 m_pCharFmtLB
->SelectEntry(sSelectStyle
);
1971 CharFmtHdl_Impl(m_pCharFmtLB
);
1972 bAutomaticCharStyles
= true;
1977 void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType
)
1979 bool bIsNull
= m_pStartED
->GetValue() == 0;
1980 bool bNoZeroAllowed
= nNumberingType
< SVX_NUM_ARABIC
||
1981 SVX_NUM_CHARS_UPPER_LETTER_N
== nNumberingType
||
1982 SVX_NUM_CHARS_LOWER_LETTER_N
== nNumberingType
;
1983 m_pStartED
->SetMin(bNoZeroAllowed
? 1 : 0);
1984 if(bIsNull
&& bNoZeroAllowed
)
1985 m_pStartED
->GetModifyHdl().Call(m_pStartED
);
1988 IMPL_LINK( SvxNumOptionsTabPage
, OrientHdl_Impl
, ListBox
*, pBox
)
1990 sal_Int32 nPos
= pBox
->GetSelectEntryPos();
1991 nPos
++; // no VERT_NONE
1993 sal_uInt16 nMask
= 1;
1994 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
1996 if(nActNumLvl
& nMask
)
1998 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
1999 if(SVX_NUM_BITMAP
== (aNumFmt
.GetNumberingType()&(~LINK_TOKEN
)))
2001 const SvxBrushItem
* pBrushItem
= aNumFmt
.GetBrush();
2002 const Size
& rSize
= aNumFmt
.GetGraphicSize();
2003 sal_Int16 eOrient
= (sal_Int16
)nPos
;
2004 aNumFmt
.SetGraphicBrush( pBrushItem
, &rSize
, &eOrient
);
2005 pActNum
->SetLevel(i
, aNumFmt
);
2015 IMPL_LINK( SvxNumOptionsTabPage
, SameLevelHdl_Impl
, CheckBox
*, pBox
)
2017 bool bSet
= pBox
->IsChecked();
2018 pActNum
->SetContinuousNumbering(bSet
);
2019 bool bRepaint
= false;
2020 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2022 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2023 if(aNumFmt
.GetNumberingType() != SVX_NUM_NUMBER_NONE
)
2029 SetModified(bRepaint
);
2034 IMPL_LINK( SvxNumOptionsTabPage
, BulColorHdl_Impl
, ColorListBox
*, pBox
)
2036 Color nSetColor
= pBox
->GetSelectEntryColor();
2038 sal_uInt16 nMask
= 1;
2039 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2041 if(nActNumLvl
& nMask
)
2043 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2044 aNumFmt
.SetBulletColor(nSetColor
);
2045 pActNum
->SetLevel(i
, aNumFmt
);
2053 IMPL_LINK( SvxNumOptionsTabPage
, BulRelSizeHdl_Impl
, MetricField
*, pField
)
2055 sal_uInt16 nRelSize
= (sal_uInt16
)pField
->GetValue();
2057 sal_uInt16 nMask
= 1;
2058 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2060 if(nActNumLvl
& nMask
)
2062 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2063 aNumFmt
.SetBulletRelSize(nRelSize
);
2064 pActNum
->SetLevel(i
, aNumFmt
);
2072 IMPL_LINK_TYPED( SvxNumOptionsTabPage
, GraphicHdl_Impl
, MenuButton
*, pButton
, void )
2074 sal_uInt16 nItemId
= pButton
->GetCurItemId();
2078 SvxOpenGraphicDialog
aGrfDlg( CUI_RES(RID_SVXSTR_EDIT_GRAPHIC
) );
2080 if(MN_GALLERY_ENTRY
<= nItemId
)
2082 sal_uInt16 idx
= nItemId
- MN_GALLERY_ENTRY
;
2083 if (idx
< aGrfNames
.size())
2085 aGrfName
= aGrfNames
[idx
];
2087 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, idx
, &aGraphic
))
2089 aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
2096 aGrfDlg
.EnableLink( false );
2097 aGrfDlg
.AsLink( false );
2098 if ( !aGrfDlg
.Execute() )
2100 // memorize selected filter
2101 aGrfName
= aGrfDlg
.GetPath();
2104 if( !aGrfDlg
.GetGraphic(aGraphic
) )
2106 aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
2113 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)eCoreUnit
);
2115 sal_uInt16 nMask
= 1;
2116 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2118 if(nActNumLvl
& nMask
)
2120 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2121 aNumFmt
.SetCharFormatName(m_sNumCharFmtName
);
2122 aNumFmt
.SetGraphic(aGrfName
);
2124 // set size for a later comparison
2125 const SvxBrushItem
* pBrushItem
= aNumFmt
.GetBrush();
2126 // initiate asynchronous loading
2127 sal_Int16 eOrient
= aNumFmt
.GetVertOrient();
2128 aNumFmt
.SetGraphicBrush( pBrushItem
, &aSize
, &eOrient
);
2129 aInitSize
[i
] = aNumFmt
.GetGraphicSize();
2131 pActNum
->SetLevel(i
, aNumFmt
);
2135 m_pRatioCB
->Enable();
2136 m_pWidthFT
->Enable();
2137 m_pHeightFT
->Enable();
2138 m_pWidthMF
->Enable();
2139 m_pHeightMF
->Enable();
2140 SetMetricValue(*m_pWidthMF
, aSize
.Width(), eCoreUnit
);
2141 SetMetricValue(*m_pHeightMF
, aSize
.Height(), eCoreUnit
);
2142 m_pOrientFT
->Enable();
2143 m_pOrientLB
->Enable();
2145 //needed due to asynchronous loading of graphics in the SvxBrushItem
2146 aInvalidateTimer
.Start();
2150 IMPL_LINK_NOARG_TYPED(SvxNumOptionsTabPage
, PopupActivateHdl_Impl
, Menu
*, bool)
2152 if(!bMenuButtonInitialized
)
2154 bMenuButtonInitialized
= true;
2156 PopupMenu
* pMenu
= m_pBitmapMB
->GetPopupMenu();
2157 PopupMenu
* pPopup
= pMenu
->GetPopupMenu(m_nGalleryId
);
2159 if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, aGrfNames
))
2162 GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS
);
2166 std::vector
<OUString
>::const_iterator it
= aGrfNames
.begin();
2167 for(size_t i
= 0; it
!= aGrfNames
.end(); ++it
, ++i
)
2170 INetURLObject
aObj(sGrfName
);
2171 if(aObj
.GetProtocol() == INetProtocol::File
)
2172 sGrfName
= aObj
.PathToFileName();
2174 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, i
, &aGraphic
))
2176 Bitmap
aBitmap(aGraphic
.GetBitmap());
2177 Size
aSize(aBitmap
.GetSizePixel());
2178 if(aSize
.Width() > MAX_BMP_WIDTH
||
2179 aSize
.Height() > MAX_BMP_HEIGHT
)
2181 bool bWidth
= aSize
.Width() > aSize
.Height();
2182 double nScale
= bWidth
?
2183 (double)MAX_BMP_WIDTH
/ (double)aSize
.Width():
2184 (double)MAX_BMP_HEIGHT
/ (double)aSize
.Height();
2185 aBitmap
.Scale(nScale
, nScale
);
2187 Image
aImage(aBitmap
);
2189 pPopup
->InsertItem(MN_GALLERY_ENTRY
+ i
, sGrfName
, aImage
);
2195 MN_GALLERY_ENTRY
+ i
, sGrfName
, aImage
);
2198 GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS
);
2205 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, BulletHdl_Impl
)
2207 VclPtrInstance
< SvxCharacterMap
> pMap( this, true );
2209 sal_uInt16 nMask
= 1;
2210 const vcl::Font
* pFmtFont
= 0;
2211 bool bSameBullet
= true;
2212 sal_Unicode cBullet
= 0;
2214 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2216 if(nActNumLvl
& nMask
)
2218 const SvxNumberFormat
& rCurFmt
= pActNum
->GetLevel(i
);
2221 cBullet
= rCurFmt
.GetBulletChar();
2223 else if(rCurFmt
.GetBulletChar() != cBullet
)
2225 bSameBullet
= false;
2229 pFmtFont
= rCurFmt
.GetBulletFont();
2237 pMap
->SetCharFont(*pFmtFont
);
2239 pMap
->SetCharFont(aActBulletFont
);
2241 pMap
->SetChar( cBullet
);
2242 if(pMap
->Execute() == RET_OK
)
2244 // change Font Numrules
2245 aActBulletFont
= pMap
->GetCharFont();
2247 sal_uInt16 _nMask
= 1;
2248 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2250 if(nActNumLvl
& _nMask
)
2252 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2253 aNumFmt
.SetBulletFont(&aActBulletFont
); ;
2254 aNumFmt
.SetBulletChar( (sal_Unicode
) pMap
->GetChar() );
2255 pActNum
->SetLevel(i
, aNumFmt
);
2265 IMPL_LINK( SvxNumOptionsTabPage
, SizeHdl_Impl
, MetricField
*, pField
)
2267 bool bWidth
= pField
== m_pWidthMF
;
2268 bLastWidthModified
= bWidth
;
2269 bool bRatio
= m_pRatioCB
->IsChecked();
2270 long nWidthVal
= static_cast<long>(m_pWidthMF
->Denormalize(m_pWidthMF
->GetValue(FUNIT_100TH_MM
)));
2271 long nHeightVal
= static_cast<long>(m_pHeightMF
->Denormalize(m_pHeightMF
->GetValue(FUNIT_100TH_MM
)));
2272 nWidthVal
= OutputDevice::LogicToLogic( nWidthVal
,
2273 MAP_100TH_MM
, (MapUnit
)eCoreUnit
);
2274 nHeightVal
= OutputDevice::LogicToLogic( nHeightVal
,
2275 MAP_100TH_MM
, (MapUnit
)eCoreUnit
);
2278 bool bRepaint
= false;
2279 sal_uInt16 nMask
= 1;
2280 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2282 if(nActNumLvl
& nMask
)
2284 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2285 if(SVX_NUM_BITMAP
== (aNumFmt
.GetNumberingType()&(~LINK_TOKEN
)))
2287 Size
aSize(aNumFmt
.GetGraphicSize() );
2288 Size
aSaveSize(aSize
);
2290 if (aInitSize
[i
].Height())
2291 fSizeRatio
= (double)aInitSize
[i
].Width() / (double)aInitSize
[i
].Height();
2293 fSizeRatio
= (double)1;
2297 long nDelta
= nWidthVal
- aInitSize
[i
].Width();
2298 aSize
.Width() = nWidthVal
;
2301 aSize
.Height() = aInitSize
[i
].Height() + (long)((double)nDelta
/ fSizeRatio
);
2302 m_pHeightMF
->SetUserValue(m_pHeightMF
->Normalize(
2303 OutputDevice::LogicToLogic( aSize
.Height(), (MapUnit
)eCoreUnit
, MAP_100TH_MM
)),
2309 long nDelta
= nHeightVal
- aInitSize
[i
].Height();
2310 aSize
.Height() = nHeightVal
;
2313 aSize
.Width() = aInitSize
[i
].Width() + (long)((double)nDelta
* fSizeRatio
);
2314 m_pWidthMF
->SetUserValue(m_pWidthMF
->Normalize(
2315 OutputDevice::LogicToLogic( aSize
.Width(), (MapUnit
)eCoreUnit
, MAP_100TH_MM
)),
2319 const SvxBrushItem
* pBrushItem
= aNumFmt
.GetBrush();
2320 sal_Int16 eOrient
= aNumFmt
.GetVertOrient();
2321 if(aSize
!= aSaveSize
)
2323 aNumFmt
.SetGraphicBrush( pBrushItem
, &aSize
, &eOrient
);
2324 pActNum
->SetLevel(i
, aNumFmt
);
2329 SetModified(bRepaint
);
2333 IMPL_LINK( SvxNumOptionsTabPage
, RatioHdl_Impl
, CheckBox
*, pBox
)
2335 if (pBox
->IsChecked())
2337 if (bLastWidthModified
)
2338 SizeHdl_Impl(m_pWidthMF
);
2340 SizeHdl_Impl(m_pHeightMF
);
2345 IMPL_LINK_NOARG(SvxNumOptionsTabPage
, CharFmtHdl_Impl
)
2347 bAutomaticCharStyles
= false;
2348 sal_Int32 nEntryPos
= m_pCharFmtLB
->GetSelectEntryPos();
2349 OUString sEntry
= m_pCharFmtLB
->GetSelectEntry();
2350 sal_uInt16 nMask
= 1;
2352 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2354 if(nActNumLvl
& nMask
)
2356 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2357 if( 0 == nEntryPos
)
2358 aNumFmt
.SetCharFormatName(aEmptyStr
);
2361 if(SVX_NUM_BITMAP
!= (aNumFmt
.GetNumberingType()&(~LINK_TOKEN
)))
2362 aNumFmt
.SetCharFormatName(sEntry
);
2364 pActNum
->SetLevel(i
, aNumFmt
);
2373 IMPL_LINK( SvxNumOptionsTabPage
, EditModifyHdl_Impl
, Edit
*, pEdit
)
2375 bool bPrefix
= pEdit
== m_pPrefixED
;
2376 bool bSuffix
= pEdit
== m_pSuffixED
;
2377 bool bStart
= pEdit
== m_pStartED
;
2378 sal_uInt16 nMask
= 1;
2379 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2381 if(nActNumLvl
& nMask
)
2383 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
2385 aNumFmt
.SetPrefix( m_pPrefixED
->GetText() );
2387 aNumFmt
.SetSuffix( m_pSuffixED
->GetText() );
2389 aNumFmt
.SetStart( (sal_uInt16
)m_pStartED
->GetValue() );
2392 sal_Int32 nPos
= m_pAlignLB
->GetSelectEntryPos();
2393 SvxAdjust eAdjust
= SVX_ADJUST_CENTER
;
2395 eAdjust
= SVX_ADJUST_LEFT
;
2397 eAdjust
= SVX_ADJUST_RIGHT
;
2398 aNumFmt
.SetNumAdjust( eAdjust
);
2400 pActNum
->SetLevel(i
, aNumFmt
);
2409 static sal_uInt16
lcl_DrawGraphic(VirtualDevice
* pVDev
, const SvxNumberFormat
&rFmt
, sal_uInt16 nXStart
,
2410 sal_uInt16 nYStart
, sal_uInt16 nDivision
)
2412 const SvxBrushItem
* pBrushItem
= rFmt
.GetBrush();
2413 sal_uInt16 nRet
= 0;
2416 const Graphic
* pGrf
= pBrushItem
->GetGraphic();
2419 Size
aGSize( rFmt
.GetGraphicSize() );
2420 aGSize
.Width() /= nDivision
;
2421 nRet
= (sal_uInt16
)aGSize
.Width();
2422 aGSize
.Height() /= nDivision
;
2423 pGrf
->Draw( pVDev
, Point(nXStart
,nYStart
),
2424 pVDev
->PixelToLogic( aGSize
) );
2431 static sal_uInt16
lcl_DrawBullet(VirtualDevice
* pVDev
,
2432 const SvxNumberFormat
& rFmt
, sal_uInt16 nXStart
,
2433 sal_uInt16 nYStart
, const Size
& rSize
)
2435 vcl::Font
aTmpFont(pVDev
->GetFont());
2437 // via Uno it's possible that no font has been set!
2438 vcl::Font
aFont(rFmt
.GetBulletFont() ? *rFmt
.GetBulletFont() : aTmpFont
);
2439 Size
aTmpSize(rSize
);
2440 aTmpSize
.Width() *= rFmt
.GetBulletRelSize();
2441 aTmpSize
.Width() /= 100 ;
2442 aTmpSize
.Height() *= rFmt
.GetBulletRelSize();
2443 aTmpSize
.Height() /= 100 ;
2444 // in case of a height of zero it is drawed in original height
2445 if(!aTmpSize
.Height())
2446 aTmpSize
.Height() = 1;
2447 aFont
.SetSize(aTmpSize
);
2448 aFont
.SetTransparent(true);
2449 Color aBulletColor
= rFmt
.GetBulletColor();
2450 if(aBulletColor
.GetColor() == COL_AUTO
)
2451 aBulletColor
= Color(pVDev
->GetFillColor().IsDark() ? COL_WHITE
: COL_BLACK
);
2452 else if(aBulletColor
== pVDev
->GetFillColor())
2453 aBulletColor
.Invert();
2454 aFont
.SetColor(aBulletColor
);
2455 pVDev
->SetFont( aFont
);
2456 OUString
aText(rFmt
.GetBulletChar());
2458 nY
-= ((aTmpSize
.Height() - rSize
.Height())/ 2);
2459 pVDev
->DrawText( Point(nXStart
, nY
), aText
);
2460 sal_uInt16 nRet
= (sal_uInt16
)pVDev
->GetTextWidth(aText
);
2462 pVDev
->SetFont(aTmpFont
);
2466 SvxNumberingPreview::SvxNumberingPreview(vcl::Window
* pParent
, WinBits nWinBits
)
2467 : Window(pParent
, nWinBits
)
2472 , nActLevel(SAL_MAX_UINT16
)
2474 SetBorderStyle(WindowBorderStyle::MONO
);
2477 VCL_BUILDER_FACTORY_ARGS(SvxNumberingPreview
, WB_BORDER
)
2479 // paint preview of numeration
2480 void SvxNumberingPreview::Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& /*rRect*/)
2482 Size
aSize(rRenderContext
.PixelToLogic(GetOutputSizePixel()));
2484 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
2485 const Color aBackColor
= rStyleSettings
.GetFieldColor();
2486 const Color aTextColor
= rStyleSettings
.GetFieldTextColor();
2488 ScopedVclPtrInstance
<VirtualDevice
> pVDev(rRenderContext
);
2489 pVDev
->EnableRTL(rRenderContext
.IsRTLEnabled());
2490 pVDev
->SetMapMode(rRenderContext
.GetMapMode());
2491 pVDev
->SetOutputSize(aSize
);
2493 Color
aLineColor(COL_LIGHTGRAY
);
2494 if (aLineColor
== aBackColor
)
2495 aLineColor
.Invert();
2496 pVDev
->SetLineColor(aLineColor
);
2497 pVDev
->SetFillColor(aBackColor
);
2501 sal_uInt16 nWidthRelation
;
2504 nWidthRelation
= sal_uInt16 (nPageWidth
/ aSize
.Width());
2506 nWidthRelation
= nWidthRelation
* 2 / 3;
2508 nWidthRelation
= nWidthRelation
/ 4;
2511 nWidthRelation
= 30; // chapter dialog
2514 sal_uInt16 nXStep
= sal::static_int_cast
<sal_uInt16
>(aSize
.Width() / (3 * pActNum
->GetLevelCount()));
2515 if (pActNum
->GetLevelCount() < 10)
2517 sal_uInt16 nYStart
= 4;
2518 // the whole height mustn't be used for a single level
2519 sal_uInt16 nYStep
= sal::static_int_cast
<sal_uInt16
>((aSize
.Height() - 6)/ (pActNum
->GetLevelCount() > 1 ? pActNum
->GetLevelCount() : 5));
2521 aStdFont
= OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS
, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne
);
2522 aStdFont
.SetColor(aTextColor
);
2523 aStdFont
.SetFillColor(aBackColor
);
2525 sal_uInt16 nFontHeight
= nYStep
* 6 / 10;
2527 nFontHeight
= nYStep
* 15 / 10;
2528 aStdFont
.SetSize(Size( 0, nFontHeight
));
2530 SvxNodeNum
aNum(sal_uInt8(0));
2531 sal_uInt16 nPreNum
= pActNum
->GetLevel(0).GetStart();
2535 sal_uInt16 nLineHeight
= nFontHeight
* 8 / 7;
2536 sal_uInt8 nStart
= 0;
2537 while (!(nActLevel
& (1<<nStart
)))
2543 sal_uInt8 nEnd
= std::min(sal_uInt8(nStart
+ 3), sal_uInt8(pActNum
->GetLevelCount()));
2544 for (sal_uInt8 nLevel
= nStart
; nLevel
< nEnd
; ++nLevel
)
2546 const SvxNumberFormat
&rFmt
= pActNum
->GetLevel(nLevel
);
2547 aNum
.GetLevelVal()[nLevel
] = rFmt
.GetStart();
2549 sal_uInt16
nXStart( 0 );
2550 short nTextOffset( 0 );
2551 sal_uInt16
nNumberXPos( 0 );
2552 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2554 nXStart
= rFmt
.GetAbsLSpace() / nWidthRelation
;
2555 nTextOffset
= rFmt
.GetCharTextDistance() / nWidthRelation
;
2556 nNumberXPos
= nXStart
;
2557 sal_uInt16 nFirstLineOffset
= (-rFmt
.GetFirstLineOffset()) / nWidthRelation
;
2559 if (nFirstLineOffset
<= nNumberXPos
)
2560 nNumberXPos
= nNumberXPos
- nFirstLineOffset
;
2563 // in draw this is valid
2564 if (nTextOffset
< 0)
2565 nNumberXPos
= nNumberXPos
+ nTextOffset
;
2567 else if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2569 const long nTmpNumberXPos((rFmt
.GetIndentAt() + rFmt
.GetFirstLineIndent() ) / nWidthRelation
);
2570 if (nTmpNumberXPos
< 0)
2576 nNumberXPos
= static_cast<sal_uInt16
>(nTmpNumberXPos
);
2580 sal_uInt16 nBulletWidth
= 0;
2581 if (SVX_NUM_BITMAP
== (rFmt
.GetNumberingType() &(~LINK_TOKEN
)))
2583 nBulletWidth
= rFmt
.IsShowSymbol() ? lcl_DrawGraphic(pVDev
.get(), rFmt
, nNumberXPos
, nYStart
, nWidthRelation
) : 0;
2585 else if (SVX_NUM_CHAR_SPECIAL
== rFmt
.GetNumberingType())
2587 nBulletWidth
= rFmt
.IsShowSymbol() ? lcl_DrawBullet(pVDev
.get(), rFmt
, nNumberXPos
, nYStart
, aStdFont
.GetSize()) : 0;
2591 pVDev
->SetFont(aStdFont
);
2592 aNum
.SetLevel(nLevel
);
2593 if (pActNum
->IsContinuousNumbering())
2594 aNum
.GetLevelVal()[nLevel
] = nPreNum
;
2595 OUString
aText(pActNum
->MakeNumString( aNum
));
2596 vcl::Font aSaveFont
= pVDev
->GetFont();
2597 vcl::Font
aColorFont(aSaveFont
);
2598 Color aTmpBulletColor
= rFmt
.GetBulletColor();
2599 if (aTmpBulletColor
.GetColor() == COL_AUTO
)
2600 aTmpBulletColor
= Color(aBackColor
.IsDark() ? COL_WHITE
: COL_BLACK
);
2601 else if (aTmpBulletColor
== aBackColor
)
2602 aTmpBulletColor
.Invert();
2603 aColorFont
.SetColor(aTmpBulletColor
);
2604 pVDev
->SetFont(aColorFont
);
2605 pVDev
->DrawText(Point(nNumberXPos
, nYStart
), aText
);
2606 pVDev
->SetFont(aSaveFont
);
2607 nBulletWidth
= sal_uInt16(pVDev
->GetTextWidth(aText
));
2610 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
&&
2611 rFmt
.GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
2613 pVDev
->SetFont(aStdFont
);
2614 OUString
aText(' ');
2615 pVDev
->DrawText( Point(nNumberXPos
, nYStart
), aText
);
2616 nBulletWidth
= nBulletWidth
+ (sal_uInt16
)pVDev
->GetTextWidth(aText
);
2619 sal_uInt16
nTextXPos( 0 );
2620 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2622 nTextXPos
= nXStart
;
2623 if (nTextOffset
< 0)
2624 nTextXPos
= nTextXPos
+ nTextOffset
;
2625 if (nNumberXPos
+ nBulletWidth
+ nTextOffset
> nTextXPos
)
2626 nTextXPos
= nNumberXPos
+ nBulletWidth
+ nTextOffset
;
2628 else if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2630 switch (rFmt
.GetLabelFollowedBy())
2632 case SvxNumberFormat::LISTTAB
:
2634 nTextXPos
= static_cast<sal_uInt16
>(rFmt
.GetListtabPos() / nWidthRelation
);
2635 if (nTextXPos
< nNumberXPos
+ nBulletWidth
)
2637 nTextXPos
= nNumberXPos
+ nBulletWidth
;
2641 case SvxNumberFormat::SPACE
:
2642 case SvxNumberFormat::NOTHING
:
2644 nTextXPos
= nNumberXPos
+ nBulletWidth
;
2649 nXStart
= static_cast<sal_uInt16
>(rFmt
.GetIndentAt() / nWidthRelation
);
2652 Rectangle
aRect1(Point(nTextXPos
, nYStart
+ nFontHeight
/ 2), Size(aSize
.Width() / 2, 2));
2653 pVDev
->SetFillColor(aBackColor
);
2654 pVDev
->DrawRect(aRect1
);
2656 Rectangle
aRect2(Point(nXStart
, nYStart
+ nLineHeight
+ nFontHeight
/ 2 ), Size(aSize
.Width() / 2, 2));
2657 pVDev
->DrawRect(aRect2
);
2658 nYStart
+= 2 * nLineHeight
;
2663 //#i5153# painting gray or black rectangles as 'normal' numbering text
2664 OUString
sMsg("Preview");
2665 long nWidth
= pVDev
->GetTextWidth(sMsg
);
2666 long nTextHeight
= pVDev
->GetTextHeight();
2667 long nRectHeight
= nTextHeight
* 2 / 3;
2668 long nTopOffset
= nTextHeight
- nRectHeight
;
2669 Color
aBlackColor(COL_BLACK
);
2670 if (aBlackColor
== aBackColor
)
2671 aBlackColor
.Invert();
2673 for (sal_uInt8 nLevel
= 0; nLevel
< pActNum
->GetLevelCount(); ++nLevel
, nYStart
= nYStart
+ nYStep
)
2675 const SvxNumberFormat
&rFmt
= pActNum
->GetLevel(nLevel
);
2676 aNum
.GetLevelVal()[ nLevel
] = rFmt
.GetStart();
2677 sal_uInt16
nXStart( 0 );
2679 if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2681 nXStart
= rFmt
.GetAbsLSpace() / nWidthRelation
;
2683 else if (rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2685 const long nTmpXStart((rFmt
.GetIndentAt() + rFmt
.GetFirstLineIndent() ) / nWidthRelation
);
2692 nXStart
= static_cast<sal_uInt16
>(nTmpXStart
);
2697 sal_uInt16 nTextOffset
= 2 * nXStep
;
2698 if (SVX_NUM_BITMAP
== (rFmt
.GetNumberingType()&(~LINK_TOKEN
)))
2700 if (rFmt
.IsShowSymbol())
2702 nTextOffset
= lcl_DrawGraphic(pVDev
.get(), rFmt
, nXStart
, nYStart
, nWidthRelation
);
2703 nTextOffset
= nTextOffset
+ nXStep
;
2706 else if (SVX_NUM_CHAR_SPECIAL
== rFmt
.GetNumberingType())
2708 if (rFmt
.IsShowSymbol())
2710 nTextOffset
= lcl_DrawBullet(pVDev
.get(), rFmt
, nXStart
, nYStart
, aStdFont
.GetSize());
2711 nTextOffset
= nTextOffset
+ nXStep
;
2716 vcl::Font
aColorFont(aStdFont
);
2717 Color aTmpBulletColor
= rFmt
.GetBulletColor();
2718 if (aTmpBulletColor
.GetColor() == COL_AUTO
)
2719 aTmpBulletColor
= Color(aBackColor
.IsDark() ? COL_WHITE
: COL_BLACK
);
2720 else if (aTmpBulletColor
== aBackColor
)
2721 aTmpBulletColor
.Invert();
2722 aColorFont
.SetColor(aTmpBulletColor
);
2723 pVDev
->SetFont(aColorFont
);
2724 aNum
.SetLevel( nLevel
);
2725 if (pActNum
->IsContinuousNumbering())
2726 aNum
.GetLevelVal()[nLevel
] = nPreNum
;
2727 OUString
aText(pActNum
->MakeNumString(aNum
));
2728 pVDev
->DrawText(Point(nXStart
, nYStart
), aText
);
2729 pVDev
->SetFont(aStdFont
);
2730 nTextOffset
= (sal_uInt16
)pVDev
->GetTextWidth(aText
);
2731 nTextOffset
= nTextOffset
+ nXStep
;
2736 //#i5153# outline numberings still use the style names as text
2737 pVDev
->SetFont(aStdFont
);
2738 sMsg
= pOutlineNames
[nLevel
];
2739 pVDev
->DrawText(Point(nXStart
+ nTextOffset
, nYStart
), sMsg
);
2743 //#i5153# the selected rectangle(s) should be black
2744 if (0 != (nActLevel
& (1<<nLevel
)))
2746 pVDev
->SetFillColor( aBlackColor
);
2747 pVDev
->SetLineColor( aBlackColor
);
2751 //#i5153# unselected levels are gray
2752 pVDev
->SetFillColor( aLineColor
);
2753 pVDev
->SetLineColor( aLineColor
);
2755 Rectangle
aRect1(Point(nXStart
+ nTextOffset
, nYStart
+ nTopOffset
), Size(nWidth
, nRectHeight
));
2756 pVDev
->DrawRect(aRect1
);
2761 rRenderContext
.DrawOutDev(Point(), aSize
, Point(), aSize
, *pVDev
);
2764 //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate
2765 //dialog to this one, except with a different preview window impl.
2766 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
2768 SvxNumPositionTabPage::SvxNumPositionTabPage(vcl::Window
* pParent
,
2769 const SfxItemSet
& rSet
)
2770 : SfxTabPage(pParent
, "NumberingPositionPage", "cui/ui/numberingpositionpage.ui", &rSet
)
2773 , nActNumLvl(SAL_MAX_UINT16
)
2774 , nNumItemId(SID_ATTR_NUMBERING_RULE
)
2777 , bInInintControl(false)
2778 , bLabelAlignmentPosAndSpaceModeActive(false)
2780 SetExchangeSupport();
2782 get(m_pLevelLB
, "levellb");
2783 get(m_pDistBorderFT
, "indent");
2784 get(m_pDistBorderMF
, "indentmf");
2785 get(m_pRelativeCB
, "relative");
2786 get(m_pIndentFT
, "numberingwidth");
2787 get(m_pIndentMF
, "numberingwidthmf");
2788 get(m_pDistNumFT
, "numdist");
2789 get(m_pDistNumMF
, "numdistmf");
2790 get(m_pAlignFT
, "numalign");
2791 get(m_pAlignLB
, "numalignlb");
2793 get(m_pLabelFollowedByFT
, "numfollowedby");
2794 get(m_pLabelFollowedByLB
, "numfollowedbylb");
2795 get(m_pListtabFT
, "at");
2796 get(m_pListtabMF
, "atmf");
2797 get(m_pAlign2FT
, "num2align");
2798 get(m_pAlign2LB
, "num2alignlb");
2799 get(m_pAlignedAtFT
, "alignedat");
2800 get(m_pAlignedAtMF
, "alignedatmf");
2801 get(m_pIndentAtFT
, "indentat");
2802 get(m_pIndentAtMF
, "indentatmf");
2804 get(m_pStandardPB
, "standard");
2805 get(m_pPreviewWIN
, "preview");
2807 m_pPreviewWIN
->SetBackground(Wallpaper(Color(COL_TRANSPARENT
)));
2809 m_pRelativeCB
->Check();
2810 m_pAlignLB
->SetSelectHdl(LINK(this, SvxNumPositionTabPage
, EditModifyHdl_Impl
));
2811 m_pAlign2LB
->SetSelectHdl(LINK(this, SvxNumPositionTabPage
, EditModifyHdl_Impl
));
2812 for ( sal_Int32 i
= 0; i
< m_pAlignLB
->GetEntryCount(); ++i
)
2814 m_pAlign2LB
->InsertEntry( m_pAlignLB
->GetEntry( i
) );
2816 m_pAlign2LB
->SetDropDownLineCount( m_pAlign2LB
->GetEntryCount() );
2818 Link
<> aLk
= LINK(this, SvxNumPositionTabPage
, DistanceHdl_Impl
);
2820 m_pDistBorderMF
->SetUpHdl(aLk
);
2821 m_pDistBorderMF
->SetDownHdl(aLk
);
2822 m_pDistBorderMF
->SetLoseFocusHdl(aLk
);
2824 m_pDistNumMF
->SetUpHdl(aLk
);
2825 m_pDistNumMF
->SetDownHdl(aLk
);
2826 m_pDistNumMF
->SetLoseFocusHdl(aLk
);
2828 m_pIndentMF
->SetUpHdl(aLk
);
2829 m_pIndentMF
->SetDownHdl(aLk
);
2830 m_pIndentMF
->SetLoseFocusHdl(aLk
);
2832 m_pLabelFollowedByLB
->SetDropDownLineCount( m_pLabelFollowedByLB
->GetEntryCount() );
2833 m_pLabelFollowedByLB
->SetSelectHdl( LINK(this, SvxNumPositionTabPage
, LabelFollowedByHdl_Impl
) );
2835 aLk
= LINK(this, SvxNumPositionTabPage
, ListtabPosHdl_Impl
);
2836 m_pListtabMF
->SetUpHdl(aLk
);
2837 m_pListtabMF
->SetDownHdl(aLk
);
2838 m_pListtabMF
->SetLoseFocusHdl(aLk
);
2840 aLk
= LINK(this, SvxNumPositionTabPage
, AlignAtHdl_Impl
);
2841 m_pAlignedAtMF
->SetUpHdl(aLk
);
2842 m_pAlignedAtMF
->SetDownHdl(aLk
);
2843 m_pAlignedAtMF
->SetLoseFocusHdl(aLk
);
2845 aLk
= LINK(this, SvxNumPositionTabPage
, IndentAtHdl_Impl
);
2846 m_pIndentAtMF
->SetUpHdl(aLk
);
2847 m_pIndentAtMF
->SetDownHdl(aLk
);
2848 m_pIndentAtMF
->SetLoseFocusHdl(aLk
);
2850 m_pLevelLB
->EnableMultiSelection(true);
2851 m_pLevelLB
->SetSelectHdl(LINK(this, SvxNumPositionTabPage
, LevelHdl_Impl
));
2852 m_pRelativeCB
->SetClickHdl(LINK(this, SvxNumPositionTabPage
, RelativeHdl_Impl
));
2853 m_pStandardPB
->SetClickHdl(LINK(this, SvxNumPositionTabPage
, StandardHdl_Impl
));
2856 m_pRelativeCB
->Check(bLastRelative
);
2857 m_pPreviewWIN
->SetPositionMode();
2858 eCoreUnit
= rSet
.GetPool()->GetMetric(rSet
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
2861 SvxNumPositionTabPage::~SvxNumPositionTabPage()
2866 void SvxNumPositionTabPage::dispose()
2873 m_pDistBorderFT
.clear();
2874 m_pDistBorderMF
.clear();
2875 m_pRelativeCB
.clear();
2876 m_pIndentFT
.clear();
2877 m_pIndentMF
.clear();
2878 m_pDistNumFT
.clear();
2879 m_pDistNumMF
.clear();
2882 m_pLabelFollowedByFT
.clear();
2883 m_pLabelFollowedByLB
.clear();
2884 m_pListtabFT
.clear();
2885 m_pListtabMF
.clear();
2886 m_pAlign2FT
.clear();
2887 m_pAlign2LB
.clear();
2888 m_pAlignedAtFT
.clear();
2889 m_pAlignedAtMF
.clear();
2890 m_pIndentAtFT
.clear();
2891 m_pIndentAtMF
.clear();
2892 m_pStandardPB
.clear();
2893 m_pPreviewWIN
.clear();
2894 SfxTabPage::dispose();
2897 /*-------------------------------------------------------*/
2899 #if OSL_DEBUG_LEVEL > 1
2900 void lcl_PrintDebugOutput(FixedText
& rFixed
, const SvxNumberFormat
& rNumFmt
)
2902 OUString
const sHash( " # " );
2903 if ( rNumFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
2905 OUString
sDebugText( OUString::number( convertTwipToMm100(rNumFmt
.GetAbsLSpace() ) ) );
2906 sDebugText
+= sHash
;
2907 sDebugText
+= OUString::number( convertTwipToMm100(rNumFmt
.GetCharTextDistance() ) );
2908 sDebugText
+= sHash
;
2909 sDebugText
+= OUString::number( convertTwipToMm100(rNumFmt
.GetFirstLineOffset() ) );
2910 rFixed
.SetText(sDebugText
);
2912 else if ( rNumFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2914 OUString
sDebugText( OUString::number( convertTwipToMm100(rNumFmt
.GetListtabPos() ) ) );
2915 sDebugText
+= sHash
;
2916 sDebugText
+= OUString::number( convertTwipToMm100(rNumFmt
.GetFirstLineIndent() ) );
2917 sDebugText
+= sHash
;
2918 sDebugText
+= OUString::number( convertTwipToMm100(rNumFmt
.GetIndentAt() ) );
2919 rFixed
.SetText(sDebugText
);
2925 void SvxNumPositionTabPage::InitControls()
2927 bInInintControl
= true;
2928 const bool bRelative
= !bLabelAlignmentPosAndSpaceModeActive
&&
2929 m_pRelativeCB
->IsEnabled() && m_pRelativeCB
->IsChecked();
2930 const bool bSingleSelection
= m_pLevelLB
->GetSelectEntryCount() == 1 &&
2931 SAL_MAX_UINT16
!= nActNumLvl
;
2933 m_pDistBorderMF
->Enable( !bLabelAlignmentPosAndSpaceModeActive
&&
2934 ( bSingleSelection
|| bRelative
) );
2935 m_pDistBorderFT
->Enable( !bLabelAlignmentPosAndSpaceModeActive
&&
2936 ( bSingleSelection
|| bRelative
) );
2938 bool bSetDistEmpty
= false;
2939 bool bSameDistBorderNum
= !bLabelAlignmentPosAndSpaceModeActive
;
2940 bool bSameDist
= !bLabelAlignmentPosAndSpaceModeActive
;
2941 bool bSameIndent
= !bLabelAlignmentPosAndSpaceModeActive
;
2942 bool bSameAdjust
= true;
2944 bool bSameLabelFollowedBy
= bLabelAlignmentPosAndSpaceModeActive
;
2945 bool bSameListtab
= bLabelAlignmentPosAndSpaceModeActive
;
2946 bool bSameAlignAt
= bLabelAlignmentPosAndSpaceModeActive
;
2947 bool bSameIndentAt
= bLabelAlignmentPosAndSpaceModeActive
;
2949 const SvxNumberFormat
* aNumFmtArr
[SVX_MAX_NUM
];
2950 sal_uInt16 nMask
= 1;
2951 sal_uInt16 nLvl
= SAL_MAX_UINT16
;
2952 long nFirstBorderTextRelative
= -1;
2953 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
2955 aNumFmtArr
[i
] = &pActNum
->GetLevel(i
);
2956 if(nActNumLvl
& nMask
)
2958 if(SAL_MAX_UINT16
== nLvl
)
2963 bSameAdjust
&= aNumFmtArr
[i
]->GetNumAdjust() == aNumFmtArr
[nLvl
]->GetNumAdjust();
2964 if ( !bLabelAlignmentPosAndSpaceModeActive
)
2968 if(nFirstBorderTextRelative
== -1)
2969 nFirstBorderTextRelative
=
2970 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
2971 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
2973 bSameDistBorderNum
&= nFirstBorderTextRelative
==
2974 (aNumFmtArr
[i
]->GetAbsLSpace() + aNumFmtArr
[i
]->GetFirstLineOffset() -
2975 aNumFmtArr
[i
- 1]->GetAbsLSpace() + aNumFmtArr
[i
- 1]->GetFirstLineOffset());
2978 bSameDistBorderNum
&=
2979 aNumFmtArr
[i
]->GetAbsLSpace() - aNumFmtArr
[i
]->GetFirstLineOffset() ==
2980 aNumFmtArr
[i
- 1]->GetAbsLSpace() - aNumFmtArr
[i
- 1]->GetFirstLineOffset();
2982 bSameDist
&= aNumFmtArr
[i
]->GetCharTextDistance() == aNumFmtArr
[nLvl
]->GetCharTextDistance();
2983 bSameIndent
&= aNumFmtArr
[i
]->GetFirstLineOffset() == aNumFmtArr
[nLvl
]->GetFirstLineOffset();
2987 bSameLabelFollowedBy
&=
2988 aNumFmtArr
[i
]->GetLabelFollowedBy() == aNumFmtArr
[nLvl
]->GetLabelFollowedBy();
2990 aNumFmtArr
[i
]->GetListtabPos() == aNumFmtArr
[nLvl
]->GetListtabPos();
2992 ( ( aNumFmtArr
[i
]->GetIndentAt() + aNumFmtArr
[i
]->GetFirstLineIndent() )
2993 == ( aNumFmtArr
[nLvl
]->GetIndentAt() + aNumFmtArr
[nLvl
]->GetFirstLineIndent() ) );
2995 aNumFmtArr
[i
]->GetIndentAt() == aNumFmtArr
[nLvl
]->GetIndentAt();
3002 if (SVX_MAX_NUM
<= nLvl
)
3004 OSL_ENSURE(false, "cannot happen.");
3008 if(bSameDistBorderNum
)
3010 long nDistBorderNum
;
3013 nDistBorderNum
= (long)aNumFmtArr
[nLvl
]->GetAbsLSpace()+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
3015 nDistBorderNum
-= (long)aNumFmtArr
[nLvl
- 1]->GetAbsLSpace()+ aNumFmtArr
[nLvl
- 1]->GetFirstLineOffset();
3019 nDistBorderNum
= (long)aNumFmtArr
[nLvl
]->GetAbsLSpace()+ aNumFmtArr
[nLvl
]->GetFirstLineOffset();
3021 SetMetricValue(*m_pDistBorderMF
, nDistBorderNum
, eCoreUnit
);
3024 bSetDistEmpty
= true;
3026 const OUString aEmptyStr
;
3028 SetMetricValue(*m_pDistNumMF
, aNumFmtArr
[nLvl
]->GetCharTextDistance(), eCoreUnit
);
3030 m_pDistNumMF
->SetText(aEmptyStr
);
3032 SetMetricValue(*m_pIndentMF
, - aNumFmtArr
[nLvl
]->GetFirstLineOffset(), eCoreUnit
);
3034 m_pIndentMF
->SetText(aEmptyStr
);
3038 sal_Int32 nPos
= 1; // centered
3039 if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_LEFT
)
3041 else if(aNumFmtArr
[nLvl
]->GetNumAdjust() == SVX_ADJUST_RIGHT
)
3043 m_pAlignLB
->SelectEntryPos(nPos
);
3044 m_pAlign2LB
->SelectEntryPos( nPos
);
3048 m_pAlignLB
->SetNoSelection();
3049 m_pAlign2LB
->SetNoSelection();
3052 if ( bSameLabelFollowedBy
)
3054 sal_Int32 nPos
= 0; // LISTTAB
3055 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::SPACE
)
3059 else if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING
)
3063 m_pLabelFollowedByLB
->SelectEntryPos( nPos
);
3067 m_pLabelFollowedByLB
->SetNoSelection();
3070 if ( aNumFmtArr
[nLvl
]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB
)
3072 m_pListtabFT
->Enable( true );
3073 m_pListtabMF
->Enable( true );
3076 SetMetricValue(*m_pListtabMF
, aNumFmtArr
[nLvl
]->GetListtabPos(), eCoreUnit
);
3080 m_pListtabMF
->SetText(aEmptyStr
);
3085 m_pListtabFT
->Enable( false );
3086 m_pListtabMF
->Enable( false );
3087 m_pListtabMF
->SetText(aEmptyStr
);
3092 SetMetricValue(*m_pAlignedAtMF
,
3093 aNumFmtArr
[nLvl
]->GetIndentAt() + aNumFmtArr
[nLvl
]->GetFirstLineIndent(),
3098 m_pAlignedAtMF
->SetText(aEmptyStr
);
3101 if ( bSameIndentAt
)
3103 SetMetricValue(*m_pIndentAtMF
, aNumFmtArr
[nLvl
]->GetIndentAt(), eCoreUnit
);
3107 m_pIndentAtMF
->SetText(aEmptyStr
);
3110 if ( bSetDistEmpty
)
3111 m_pDistBorderMF
->SetText(aEmptyStr
);
3113 bInInintControl
= false;
3116 void SvxNumPositionTabPage::ActivatePage(const SfxItemSet
& rSet
)
3118 const SfxPoolItem
* pItem
;
3119 sal_uInt16 nTmpNumLvl
= SAL_MAX_UINT16
;
3120 const SfxItemSet
* pExampleSet
= GetTabDialog()->GetExampleSet();
3123 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_NUM_PRESET
, false, &pItem
))
3124 bPreset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
3125 if(SfxItemState::SET
== pExampleSet
->GetItemState(SID_PARAM_CUR_NUM_LEVEL
, false, &pItem
))
3126 nTmpNumLvl
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
3128 if(SfxItemState::SET
== rSet
.GetItemState(nNumItemId
, false, &pItem
))
3131 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
3133 bModified
= (!pActNum
->Get( 0 ) || bPreset
);
3134 if(*pSaveNum
!= *pActNum
||
3135 nActNumLvl
!= nTmpNumLvl
)
3137 *pActNum
= *pSaveNum
;
3138 nActNumLvl
= nTmpNumLvl
;
3139 sal_uInt16 nMask
= 1;
3140 m_pLevelLB
->SetUpdateMode(false);
3141 m_pLevelLB
->SetNoSelection();
3143 m_pLevelLB
->SelectEntryPos( 0, true);
3145 m_pLevelLB
->SelectEntryPos( pActNum
->GetLevelCount(), nActNumLvl
== SAL_MAX_UINT16
);
3146 if(nActNumLvl
!= SAL_MAX_UINT16
)
3147 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3149 if(nActNumLvl
& nMask
)
3150 m_pLevelLB
->SelectEntryPos( i
, true);
3153 m_pRelativeCB
->Enable(nActNumLvl
!= 1);
3154 m_pLevelLB
->SetUpdateMode(true);
3156 InitPosAndSpaceMode();
3157 ShowControlsDependingOnPosAndSpaceMode();
3161 m_pPreviewWIN
->SetLevel(nActNumLvl
);
3162 m_pPreviewWIN
->Invalidate();
3165 SfxTabPage::sfxpg
SvxNumPositionTabPage::DeactivatePage(SfxItemSet
*_pSet
)
3169 if(m_pDistBorderMF
->IsEnabled())
3170 DistanceHdl_Impl(m_pDistBorderMF
);
3171 DistanceHdl_Impl(m_pIndentMF
);
3177 bool SvxNumPositionTabPage::FillItemSet( SfxItemSet
* rSet
)
3179 rSet
->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL
, nActNumLvl
));
3181 if(bModified
&& pActNum
)
3183 *pSaveNum
= *pActNum
;
3184 rSet
->Put(SvxNumBulletItem( *pSaveNum
), nNumItemId
);
3185 rSet
->Put(SfxBoolItem(SID_PARAM_NUM_PRESET
, false));
3190 void SvxNumPositionTabPage::Reset( const SfxItemSet
* rSet
)
3192 const SfxPoolItem
* pItem
;
3193 // in Draw the item exists as WhichId, in Writer only as SlotId
3194 SfxItemState eState
= rSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
3195 if(eState
!= SfxItemState::SET
)
3197 nNumItemId
= rSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
3198 eState
= rSet
->GetItemState(nNumItemId
, false, &pItem
);
3200 if( eState
!= SfxItemState::SET
)
3202 pItem
= &static_cast< const SvxNumBulletItem
& >( rSet
->Get( nNumItemId
, true ) );
3203 eState
= SfxItemState::SET
;
3207 DBG_ASSERT(eState
== SfxItemState::SET
, "no item found!");
3209 pSaveNum
= new SvxNumRule(*static_cast<const SvxNumBulletItem
*>(pItem
)->GetNumRule());
3212 if(!m_pLevelLB
->GetEntryCount())
3214 for(sal_uInt16 i
= 1; i
<= pSaveNum
->GetLevelCount(); i
++)
3215 m_pLevelLB
->InsertEntry( OUString::number(i
) );
3216 if(pSaveNum
->GetLevelCount() > 1)
3218 OUString
sEntry( "1 - " );
3219 sEntry
+= OUString::number( pSaveNum
->GetLevelCount() );
3220 m_pLevelLB
->InsertEntry(sEntry
);
3221 m_pLevelLB
->SelectEntry(sEntry
);
3224 m_pLevelLB
->SelectEntryPos(0);
3227 m_pLevelLB
->SelectEntryPos(m_pLevelLB
->GetEntryCount() - 1);
3228 sal_uInt16 nMask
= 1;
3229 m_pLevelLB
->SetUpdateMode(false);
3230 m_pLevelLB
->SetNoSelection();
3231 if(nActNumLvl
== SAL_MAX_UINT16
&& !bModified
)
3233 m_pLevelLB
->SelectEntryPos( 0, true);
3235 else if (nActNumLvl
== SAL_MAX_UINT16
)
3237 m_pLevelLB
->SelectEntryPos( pSaveNum
->GetLevelCount(), true);
3241 for(sal_uInt16 i
= 0; i
< pSaveNum
->GetLevelCount(); i
++)
3243 if(nActNumLvl
& nMask
)
3244 m_pLevelLB
->SelectEntryPos( i
, true);
3248 m_pLevelLB
->SetUpdateMode(true);
3251 pActNum
= new SvxNumRule(*pSaveNum
);
3252 else if(*pSaveNum
!= *pActNum
)
3253 *pActNum
= *pSaveNum
;
3254 m_pPreviewWIN
->SetNumRule(pActNum
);
3256 InitPosAndSpaceMode();
3257 ShowControlsDependingOnPosAndSpaceMode();
3263 void SvxNumPositionTabPage::InitPosAndSpaceMode()
3268 "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
3272 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode
=
3273 SvxNumberFormat::LABEL_ALIGNMENT
;
3274 sal_uInt16 nMask
= 1;
3275 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3277 if(nActNumLvl
& nMask
)
3279 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3280 ePosAndSpaceMode
= aNumFmt
.GetPositionAndSpaceMode();
3281 if ( ePosAndSpaceMode
== SvxNumberFormat::LABEL_ALIGNMENT
)
3289 bLabelAlignmentPosAndSpaceModeActive
=
3290 ePosAndSpaceMode
== SvxNumberFormat::LABEL_ALIGNMENT
;
3293 void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
3295 m_pDistBorderFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3296 m_pDistBorderMF
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3297 m_pRelativeCB
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3298 m_pIndentFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3299 m_pIndentMF
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3300 m_pDistNumFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
&&
3301 pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
) );
3302 m_pDistNumMF
->Show( !bLabelAlignmentPosAndSpaceModeActive
&&
3303 pActNum
->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS
));
3304 m_pAlignFT
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3305 m_pAlignLB
->Show( !bLabelAlignmentPosAndSpaceModeActive
);
3307 m_pLabelFollowedByFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3308 m_pLabelFollowedByLB
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3309 m_pListtabFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3310 m_pListtabMF
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3311 m_pAlign2FT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3312 m_pAlign2LB
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3313 m_pAlignedAtFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3314 m_pAlignedAtMF
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3315 m_pIndentAtFT
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3316 m_pIndentAtMF
->Show( bLabelAlignmentPosAndSpaceModeActive
);
3319 VclPtr
<SfxTabPage
> SvxNumPositionTabPage::Create( vcl::Window
* pParent
,
3320 const SfxItemSet
* rAttrSet
)
3322 return VclPtr
<SvxNumPositionTabPage
>::Create(pParent
, *rAttrSet
);
3325 void SvxNumPositionTabPage::SetMetric(FieldUnit eMetric
)
3327 if(eMetric
== FUNIT_MM
)
3329 m_pDistBorderMF
->SetDecimalDigits(1);
3330 m_pDistNumMF
->SetDecimalDigits(1);
3331 m_pIndentMF
->SetDecimalDigits(1);
3332 m_pListtabMF
->SetDecimalDigits(1);
3333 m_pAlignedAtMF
->SetDecimalDigits(1);
3334 m_pIndentAtMF
->SetDecimalDigits(1);
3336 m_pDistBorderMF
->SetUnit( eMetric
);
3337 m_pDistNumMF
->SetUnit( eMetric
);
3338 m_pIndentMF
->SetUnit( eMetric
);
3339 m_pListtabMF
->SetUnit( eMetric
);
3340 m_pAlignedAtMF
->SetUnit( eMetric
);
3341 m_pIndentAtMF
->SetUnit( eMetric
);
3344 IMPL_LINK_NOARG(SvxNumPositionTabPage
, EditModifyHdl_Impl
)
3346 sal_uInt16 nMask
= 1;
3347 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3349 if(nActNumLvl
& nMask
)
3351 SvxNumberFormat
aNumFmt(pActNum
->GetLevel(i
));
3353 const sal_Int32 nPos
= m_pAlignLB
->IsVisible()
3354 ? m_pAlignLB
->GetSelectEntryPos()
3355 : m_pAlign2LB
->GetSelectEntryPos();
3356 SvxAdjust eAdjust
= SVX_ADJUST_CENTER
;
3358 eAdjust
= SVX_ADJUST_LEFT
;
3360 eAdjust
= SVX_ADJUST_RIGHT
;
3361 aNumFmt
.SetNumAdjust( eAdjust
);
3362 pActNum
->SetLevel(i
, aNumFmt
);
3370 IMPL_LINK( SvxNumPositionTabPage
, LevelHdl_Impl
, ListBox
*, pBox
)
3372 sal_uInt16 nSaveNumLvl
= nActNumLvl
;
3374 if(pBox
->IsEntryPosSelected( pActNum
->GetLevelCount() ) &&
3375 (pBox
->GetSelectEntryCount() == 1 || nSaveNumLvl
!= 0xffff))
3377 nActNumLvl
= 0xFFFF;
3378 pBox
->SetUpdateMode(false);
3379 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
3380 pBox
->SelectEntryPos( i
, false );
3381 pBox
->SetUpdateMode(true);
3383 else if(pBox
->GetSelectEntryCount())
3385 sal_uInt16 nMask
= 1;
3386 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
3388 if(pBox
->IsEntryPosSelected( i
))
3389 nActNumLvl
|= nMask
;
3392 pBox
->SelectEntryPos( pActNum
->GetLevelCount(), false );
3396 nActNumLvl
= nSaveNumLvl
;
3397 sal_uInt16 nMask
= 1;
3398 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++ )
3400 if(nActNumLvl
& nMask
)
3402 pBox
->SelectEntryPos(i
);
3408 m_pRelativeCB
->Enable(nActNumLvl
!= 1);
3410 InitPosAndSpaceMode();
3411 ShowControlsDependingOnPosAndSpaceMode();
3416 IMPL_LINK( SvxNumPositionTabPage
, DistanceHdl_Impl
, MetricField
*, pFld
)
3420 long nValue
= GetCoreValue(*pFld
, eCoreUnit
);
3421 sal_uInt16 nMask
= 1;
3422 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3424 if(nActNumLvl
& nMask
)
3426 SvxNumberFormat
aNumFmt( pActNum
->GetLevel( i
) );
3427 if (pFld
== m_pDistBorderMF
)
3430 if(m_pRelativeCB
->IsChecked())
3434 long nTmp
= aNumFmt
.GetFirstLineOffset();
3435 aNumFmt
.SetAbsLSpace( sal_uInt16(nValue
- nTmp
));
3439 long nTmp
= pActNum
->GetLevel( i
- 1 ).GetAbsLSpace() +
3440 pActNum
->GetLevel( i
- 1 ).GetFirstLineOffset() -
3441 pActNum
->GetLevel( i
).GetFirstLineOffset();
3443 aNumFmt
.SetAbsLSpace( sal_uInt16(nValue
+ nTmp
));
3448 aNumFmt
.SetAbsLSpace( (short)nValue
- aNumFmt
.GetFirstLineOffset());
3451 else if (pFld
== m_pDistNumMF
)
3453 aNumFmt
.SetCharTextDistance( (short)nValue
);
3455 else if (pFld
== m_pIndentMF
)
3457 // together with the FirstLineOffset the AbsLSpace must be changed, too
3458 long nDiff
= nValue
+ aNumFmt
.GetFirstLineOffset();
3459 long nAbsLSpace
= aNumFmt
.GetAbsLSpace();
3460 aNumFmt
.SetAbsLSpace(sal_uInt16(nAbsLSpace
+ nDiff
));
3461 aNumFmt
.SetFirstLineOffset( -(short)nValue
);
3464 pActNum
->SetLevel( i
, aNumFmt
);
3470 if(!m_pDistBorderMF
->IsEnabled())
3473 m_pDistBorderMF
->SetText(aEmptyStr
);
3479 IMPL_LINK( SvxNumPositionTabPage
, RelativeHdl_Impl
, CheckBox
*, pBox
)
3481 bool bOn
= pBox
->IsChecked();
3482 bool bSingleSelection
= m_pLevelLB
->GetSelectEntryCount() == 1 && SAL_MAX_UINT16
!= nActNumLvl
;
3483 bool bSetValue
= false;
3485 if(bOn
|| bSingleSelection
)
3487 sal_uInt16 nMask
= 1;
3490 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3492 if(nActNumLvl
& nMask
)
3494 const SvxNumberFormat
&rNumFmt
= pActNum
->GetLevel(i
);
3497 nValue
= rNumFmt
.GetAbsLSpace() + rNumFmt
.GetFirstLineOffset();
3499 nValue
-= (pActNum
->GetLevel(i
- 1).GetAbsLSpace() + pActNum
->GetLevel(i
- 1).GetFirstLineOffset());
3502 bSetValue
= nValue
==
3503 (rNumFmt
.GetAbsLSpace() + rNumFmt
.GetFirstLineOffset()) -
3504 (pActNum
->GetLevel(i
- 1).GetAbsLSpace() + pActNum
->GetLevel(i
- 1).GetFirstLineOffset());
3513 SetMetricValue(*m_pDistBorderMF
, nValue
, eCoreUnit
);
3515 m_pDistBorderMF
->SetText(aEmptyStr
);
3516 m_pDistBorderMF
->Enable(bOn
|| bSingleSelection
);
3517 m_pDistBorderFT
->Enable(bOn
|| bSingleSelection
);
3518 bLastRelative
= bOn
;
3522 IMPL_LINK_NOARG(SvxNumPositionTabPage
, LabelFollowedByHdl_Impl
)
3524 // determine value to be set at the chosen list levels
3525 SvxNumberFormat::LabelFollowedBy eLabelFollowedBy
= SvxNumberFormat::LISTTAB
;
3527 const sal_Int32 nPos
= m_pLabelFollowedByLB
->GetSelectEntryPos();
3530 eLabelFollowedBy
= SvxNumberFormat::SPACE
;
3532 else if ( nPos
== 2 )
3534 eLabelFollowedBy
= SvxNumberFormat::NOTHING
;
3538 // set value at the chosen list levels
3539 bool bSameListtabPos
= true;
3540 sal_uInt16 nFirstLvl
= SAL_MAX_UINT16
;
3541 sal_uInt16 nMask
= 1;
3542 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3544 if ( nActNumLvl
& nMask
)
3546 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3547 aNumFmt
.SetLabelFollowedBy( eLabelFollowedBy
);
3548 pActNum
->SetLevel( i
, aNumFmt
);
3550 if ( nFirstLvl
== SAL_MAX_UINT16
)
3556 bSameListtabPos
&= aNumFmt
.GetListtabPos() ==
3557 pActNum
->GetLevel( nFirstLvl
).GetListtabPos();
3563 // enable/disable metric field for list tab stop position depending on
3564 // selected item following the list label.
3565 m_pListtabFT
->Enable( eLabelFollowedBy
== SvxNumberFormat::LISTTAB
);
3566 m_pListtabMF
->Enable( eLabelFollowedBy
== SvxNumberFormat::LISTTAB
);
3567 if ( bSameListtabPos
&& eLabelFollowedBy
== SvxNumberFormat::LISTTAB
)
3569 SetMetricValue(*m_pListtabMF
, pActNum
->GetLevel( nFirstLvl
).GetListtabPos(), eCoreUnit
);
3573 m_pListtabMF
->SetText( OUString() );
3581 IMPL_LINK( SvxNumPositionTabPage
, ListtabPosHdl_Impl
, MetricField
*, pFld
)
3583 // determine value to be set at the chosen list levels
3584 const long nValue
= GetCoreValue( *pFld
, eCoreUnit
);
3586 // set value at the chosen list levels
3587 sal_uInt16 nMask
= 1;
3588 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3590 if ( nActNumLvl
& nMask
)
3592 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3593 aNumFmt
.SetListtabPos( nValue
);
3594 pActNum
->SetLevel( i
, aNumFmt
);
3604 IMPL_LINK( SvxNumPositionTabPage
, AlignAtHdl_Impl
, MetricField
*, pFld
)
3606 // determine value to be set at the chosen list levels
3607 const long nValue
= GetCoreValue( *pFld
, eCoreUnit
);
3609 // set value at the chosen list levels
3610 sal_uInt16 nMask
= 1;
3611 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3613 if ( nActNumLvl
& nMask
)
3615 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3616 const long nFirstLineIndent
= nValue
- aNumFmt
.GetIndentAt();
3617 aNumFmt
.SetFirstLineIndent( nFirstLineIndent
);
3618 pActNum
->SetLevel( i
, aNumFmt
);
3628 IMPL_LINK( SvxNumPositionTabPage
, IndentAtHdl_Impl
, MetricField
*, pFld
)
3630 // determine value to be set at the chosen list levels
3631 const long nValue
= GetCoreValue( *pFld
, eCoreUnit
);
3633 // set value at the chosen list levels
3634 sal_uInt16 nMask
= 1;
3635 for( sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); ++i
)
3637 if ( nActNumLvl
& nMask
)
3639 SvxNumberFormat
aNumFmt( pActNum
->GetLevel(i
) );
3640 const long nAlignedAt
= aNumFmt
.GetIndentAt() +
3641 aNumFmt
.GetFirstLineIndent();
3642 aNumFmt
.SetIndentAt( nValue
);
3643 const long nNewFirstLineIndent
= nAlignedAt
- nValue
;
3644 aNumFmt
.SetFirstLineIndent( nNewFirstLineIndent
);
3645 pActNum
->SetLevel( i
, aNumFmt
);
3655 IMPL_LINK_NOARG(SvxNumPositionTabPage
, StandardHdl_Impl
)
3657 sal_uInt16 nMask
= 1;
3658 SvxNumRule
aTmpNumRule( pActNum
->GetFeatureFlags(),
3659 pActNum
->GetLevelCount(),
3660 pActNum
->IsContinuousNumbering(),
3661 SvxNumRuleType::NUMBERING
,
3662 pActNum
->GetLevel( 0 ).GetPositionAndSpaceMode() );
3663 for(sal_uInt16 i
= 0; i
< pActNum
->GetLevelCount(); i
++)
3665 if(nActNumLvl
& nMask
)
3667 SvxNumberFormat
aNumFmt( pActNum
->GetLevel( i
) );
3668 SvxNumberFormat
aTempFmt(aTmpNumRule
.GetLevel( i
));
3669 aNumFmt
.SetPositionAndSpaceMode( aTempFmt
.GetPositionAndSpaceMode() );
3670 if ( aTempFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
)
3672 aNumFmt
.SetAbsLSpace( aTempFmt
.GetAbsLSpace() );
3673 aNumFmt
.SetCharTextDistance( aTempFmt
.GetCharTextDistance() );
3674 aNumFmt
.SetFirstLineOffset( aTempFmt
.GetFirstLineOffset() );
3676 else if ( aTempFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
3678 aNumFmt
.SetNumAdjust( aTempFmt
.GetNumAdjust() );
3679 aNumFmt
.SetLabelFollowedBy( aTempFmt
.GetLabelFollowedBy() );
3680 aNumFmt
.SetListtabPos( aTempFmt
.GetListtabPos() );
3681 aNumFmt
.SetFirstLineIndent( aTempFmt
.GetFirstLineIndent() );
3682 aNumFmt
.SetIndentAt( aTempFmt
.GetIndentAt() );
3685 pActNum
->SetLevel( i
, aNumFmt
);
3695 void SvxNumPositionTabPage::SetModified(bool bRepaint
)
3700 m_pPreviewWIN
->SetLevel(nActNumLvl
);
3701 m_pPreviewWIN
->Invalidate();
3705 void SvxNumOptionsTabPage::SetModified(bool bRepaint
)
3710 m_pPreviewWIN
->SetLevel(nActNumLvl
);
3711 m_pPreviewWIN
->Invalidate();
3715 void SvxNumOptionsTabPage::PageCreated(const SfxAllItemSet
& aSet
)
3717 SFX_ITEMSET_ARG (&aSet
,pListItem
,SfxStringListItem
,SID_CHAR_FMT_LIST_BOX
,false);
3718 SFX_ITEMSET_ARG (&aSet
,pNumCharFmt
,SfxStringItem
,SID_NUM_CHAR_FMT
,false);
3719 SFX_ITEMSET_ARG (&aSet
,pBulletCharFmt
,SfxStringItem
,SID_BULLET_CHAR_FMT
,false);
3720 SFX_ITEMSET_ARG (&aSet
,pMetricItem
,SfxAllEnumItem
,SID_METRIC_ITEM
,false);
3722 if (pNumCharFmt
&&pBulletCharFmt
)
3723 SetCharFmts( pNumCharFmt
->GetValue(),pBulletCharFmt
->GetValue());
3727 ListBox
& myCharFmtLB
= GetCharFmtListBox();
3728 const std::vector
<OUString
> &aList
= pListItem
->GetList();
3729 sal_uInt32 nCount
= aList
.size();;
3730 for(sal_uInt32 i
= 0; i
< nCount
; i
++)
3731 myCharFmtLB
.InsertEntry(aList
[i
]);
3734 SetMetric(static_cast<FieldUnit
>(pMetricItem
->GetValue()));
3737 void SvxNumPositionTabPage::PageCreated(const SfxAllItemSet
& aSet
)
3739 SFX_ITEMSET_ARG (&aSet
,pMetricItem
,SfxAllEnumItem
,SID_METRIC_ITEM
,false);
3742 SetMetric(static_cast<FieldUnit
>(pMetricItem
->GetValue()));
3745 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */