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 .
24 #include <sfx2/tabdlg.hxx>
25 #include <editeng/numdef.hxx>
26 #include <editeng/svxenum.hxx>
27 #include <svtools/ctrlbox.hxx>
28 #include <vcl/customweld.hxx>
29 #include <vcl/timer.hxx>
30 #include <cui/numberingpreview.hxx>
32 #define MN_GALLERY_ENTRY 100
37 class SvxBmpNumValueSet
;
41 struct SvxNumSettings_Impl
43 SvxNumType nNumberType
;
44 short nParentNumbering
;
49 SvxNumSettings_Impl() :
50 nNumberType(SVX_NUM_CHARS_UPPER_LETTER
),
55 typedef std::vector
<std::unique_ptr
<SvxNumSettings_Impl
> > SvxNumSettingsArr_Impl
;
58 class SvxSingleNumPickTabPage final
: public SfxTabPage
60 SvxNumSettingsArr_Impl aNumSettingsArr
;
61 std::unique_ptr
<SvxNumRule
> pActNum
;
62 std::unique_ptr
<SvxNumRule
> pSaveNum
;
63 sal_uInt16 nActNumLvl
;
66 TypedWhichId
<SvxNumBulletItem
> nNumItemId
;
68 std::unique_ptr
<SvxNumValueSet
> m_xExamplesVS
;
69 std::unique_ptr
<weld::CustomWeld
> m_xExamplesVSWin
;
71 DECL_LINK(NumSelectHdl_Impl
, ValueSet
*, void);
72 DECL_LINK(DoubleClickHdl_Impl
, ValueSet
*, void);
75 SvxSingleNumPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
76 virtual ~SvxSingleNumPickTabPage() override
;
78 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
79 const SfxItemSet
* rAttrSet
);
81 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
82 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
83 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
84 virtual void Reset( const SfxItemSet
* rSet
) override
;
87 class SvxBulletPickTabPage final
: public SfxTabPage
89 std::unique_ptr
<SvxNumRule
> pActNum
;
90 std::unique_ptr
<SvxNumRule
> pSaveNum
;
91 sal_uInt16 nActNumLvl
;
94 TypedWhichId
<SvxNumBulletItem
> nNumItemId
;
96 OUString sBulletCharFormatName
;
98 std::unique_ptr
<SvxNumValueSet
> m_xExamplesVS
;
99 std::unique_ptr
<weld::CustomWeld
> m_xExamplesVSWin
;
101 DECL_LINK(NumSelectHdl_Impl
, ValueSet
*, void);
102 DECL_LINK(DoubleClickHdl_Impl
, ValueSet
*, void);
104 SvxBulletPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
105 virtual ~SvxBulletPickTabPage() override
;
107 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
108 const SfxItemSet
* rAttrSet
);
110 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
111 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
112 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
113 virtual void Reset( const SfxItemSet
* rSet
) override
;
115 virtual void PageCreated(const SfxAllItemSet
& aSet
) override
;
118 #define NUM_VALUSET_COUNT 16
120 /// TabPage for complete numeration
121 class SvxNumPickTabPage final
: public SfxTabPage
123 OUString sNumCharFmtName
;
124 OUString sBulletCharFormatName
;
126 SvxNumSettingsArr_Impl aNumSettingsArrays
[NUM_VALUSET_COUNT
]; // is initialized with the five formats
128 std::unique_ptr
<SvxNumRule
> pActNum
;
129 std::unique_ptr
<SvxNumRule
> pSaveNum
;
130 sal_uInt16 nActNumLvl
;
131 TypedWhichId
<SvxNumBulletItem
> nNumItemId
;
135 std::unique_ptr
<SvxNumValueSet
> m_xExamplesVS
;
136 std::unique_ptr
<weld::CustomWeld
> m_xExamplesVSWin
;
138 DECL_LINK(NumSelectHdl_Impl
, ValueSet
*, void);
139 DECL_LINK(DoubleClickHdl_Impl
, ValueSet
*, void);
142 SvxNumPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
143 virtual ~SvxNumPickTabPage() override
;
145 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
146 const SfxItemSet
* rAttrSet
);
148 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
149 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
150 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
151 virtual void Reset( const SfxItemSet
* rSet
) override
;
153 void SetCharFormatNames(const OUString
& rCharName
, const OUString
& rBulName
)
154 { sNumCharFmtName
= rCharName
;
155 sBulletCharFormatName
= rBulName
;}
156 virtual void PageCreated(const SfxAllItemSet
& aSet
) override
;
159 class SvxBitmapPickTabPage final
: public SfxTabPage
161 std::vector
<OUString
> aGrfNames
;
163 std::unique_ptr
<SvxNumRule
> pActNum
;
164 std::unique_ptr
<SvxNumRule
> pSaveNum
;
165 sal_uInt16 nActNumLvl
;
166 TypedWhichId
<SvxNumBulletItem
> nNumItemId
;
171 std::unique_ptr
<weld::Label
> m_xErrorText
;
172 std::unique_ptr
<weld::Button
> m_xBtBrowseFile
;
173 std::unique_ptr
<SvxBmpNumValueSet
> m_xExamplesVS
;
174 std::unique_ptr
<weld::CustomWeld
> m_xExamplesVSWin
;
176 DECL_LINK(NumSelectHdl_Impl
, ValueSet
*, void);
177 DECL_LINK(DoubleClickHdl_Impl
, ValueSet
*, void);
178 DECL_LINK(ClickAddBrowseHdl_Impl
, weld::Button
&, void);
181 SvxBitmapPickTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
182 virtual ~SvxBitmapPickTabPage() override
;
184 static std::unique_ptr
<SfxTabPage
> Create(weld::Container
* pPage
, weld::DialogController
* pController
,
185 const SfxItemSet
* rAttrSet
);
187 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
188 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
189 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
190 virtual void Reset( const SfxItemSet
* rSet
) override
;
193 class SvxNumOptionsTabPage
: public SfxTabPage
195 OUString m_sNumCharFmtName
;
196 OUString m_sBulletCharFormatName
;
198 Timer aInvalidateTimer
;
200 std::unique_ptr
<SvxNumRule
> pActNum
;
201 std::unique_ptr
<SvxNumRule
> pSaveNum
;
203 Size aInitSize
[SVX_MAX_NUM
];
205 ImplSVEvent
* m_pLevelHdlEvent
;
207 bool bLastWidthModified
: 1;
210 bool bAutomaticCharStyles
: 1;
213 std::vector
<OUString
> aGrfNames
;
214 vcl::Font aActBulletFont
;
217 sal_uInt16 nActNumLvl
;
218 TypedWhichId
<SvxNumBulletItem
> nNumItemId
;
221 SvxNumberingPreview m_aPreviewWIN
;
222 std::unique_ptr
<weld::Widget
> m_xGrid
;
223 std::unique_ptr
<weld::TreeView
> m_xLevelLB
;
224 std::unique_ptr
<weld::ComboBox
> m_xFmtLB
;
225 std::unique_ptr
<weld::Label
> m_xSeparatorFT
;
226 std::unique_ptr
<weld::Label
> m_xPrefixFT
;
227 std::unique_ptr
<weld::Entry
> m_xPrefixED
;
228 std::unique_ptr
<weld::Label
> m_xSuffixFT
;
229 std::unique_ptr
<weld::Entry
> m_xSuffixED
;
230 std::unique_ptr
<weld::Label
> m_xCharFmtFT
;
231 std::unique_ptr
<weld::ComboBox
> m_xCharFmtLB
;
232 std::unique_ptr
<weld::Label
> m_xBulColorFT
;
233 std::unique_ptr
<ColorListBox
> m_xBulColLB
;
234 std::unique_ptr
<weld::Label
> m_xBulRelSizeFT
;
235 std::unique_ptr
<weld::MetricSpinButton
> m_xBulRelSizeMF
;
236 std::unique_ptr
<weld::Label
> m_xAllLevelFT
;
237 std::unique_ptr
<weld::SpinButton
> m_xAllLevelNF
;
238 std::unique_ptr
<weld::Label
> m_xStartFT
;
239 std::unique_ptr
<weld::SpinButton
> m_xStartED
;
240 std::unique_ptr
<weld::Label
> m_xBulletFT
;
241 std::unique_ptr
<weld::Button
> m_xBulletPB
;
242 std::unique_ptr
<weld::Label
> m_xBitmapFT
;
243 std::unique_ptr
<weld::MenuButton
> m_xBitmapMB
;
244 std::unique_ptr
<weld::Label
> m_xWidthFT
;
245 std::unique_ptr
<weld::MetricSpinButton
> m_xWidthMF
;
246 std::unique_ptr
<weld::Label
> m_xHeightFT
;
247 std::unique_ptr
<weld::MetricSpinButton
> m_xHeightMF
;
248 std::unique_ptr
<weld::CheckButton
> m_xRatioCB
;
249 std::unique_ptr
<weld::Label
> m_xOrientFT
;
250 std::unique_ptr
<weld::ComboBox
> m_xOrientLB
;
251 std::unique_ptr
<weld::Widget
> m_xAllLevelsFrame
;
252 std::unique_ptr
<weld::Menu
> m_xGalleryMenu
;
253 std::unique_ptr
<weld::CheckButton
> m_xSameLevelCB
;
254 std::unique_ptr
<weld::CustomWeld
> m_xPreviewWIN
;
257 /** To switch between the numbering type
261 void SwitchNumberType( sal_uInt8 nType
);
262 void CheckForStartValue_Impl(sal_uInt16 nNumberingType
);
264 DECL_LINK(NumberTypeSelectHdl_Impl
, weld::ComboBox
&, void);
265 DECL_LINK(LevelHdl_Impl
, weld::TreeView
&, void);
266 DECL_LINK(LevelHdl
, void *, void);
267 DECL_LINK(PopupActivateHdl_Impl
, weld::Toggleable
&, void);
268 DECL_LINK(GraphicHdl_Impl
, const OUString
&, void);
269 DECL_LINK(BulletHdl_Impl
, weld::Button
&, void);
270 DECL_LINK(SizeHdl_Impl
, weld::MetricSpinButton
&, void);
271 DECL_LINK(RatioHdl_Impl
, weld::Toggleable
&, void);
272 DECL_LINK(CharFmtHdl_Impl
, weld::ComboBox
&, void);
273 DECL_LINK(EditModifyHdl_Impl
, weld::Entry
&, void);
274 DECL_LINK(SpinModifyHdl_Impl
, weld::SpinButton
&, void);
275 DECL_LINK(AllLevelHdl_Impl
, weld::SpinButton
&, void);
276 DECL_LINK(OrientHdl_Impl
, weld::ComboBox
&, void);
277 DECL_LINK(SameLevelHdl_Impl
, weld::Toggleable
&, void);
278 DECL_LINK(BulColorHdl_Impl
, ColorListBox
&, void);
279 DECL_LINK(BulRelSizeHdl_Impl
, weld::MetricSpinButton
&, void);
280 DECL_LINK(PreviewInvalidateHdl_Impl
, Timer
*, void);
281 void EditModifyHdl_Impl(const weld::Entry
*);
284 SvxNumOptionsTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
285 virtual ~SvxNumOptionsTabPage() override
;
287 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
288 const SfxItemSet
* rAttrSet
);
290 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
291 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
292 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
293 virtual void Reset( const SfxItemSet
* rSet
) override
;
295 void SetCharFmts(const OUString
& rNumName
, const OUString
& rBulletName
)
297 m_sNumCharFmtName
= rNumName
;
298 m_sBulletCharFormatName
= rBulletName
;
300 void SetMetric(FieldUnit eSet
);
302 void SetModified(bool bRepaint
= true);
303 virtual void PageCreated(const SfxAllItemSet
& aSet
) override
;
307 class SvxNumPositionTabPage
: public SfxTabPage
309 std::unique_ptr
<SvxNumRule
> pActNum
;
310 std::unique_ptr
<SvxNumRule
> pSaveNum
;
312 ImplSVEvent
* m_pLevelHdlEvent
;
313 sal_uInt16 nActNumLvl
;
314 TypedWhichId
<SvxNumBulletItem
> nNumItemId
;
319 bool bInInintControl
: 1; // workaround for Modify-error, is said to be corrected from 391 on
320 bool bLabelAlignmentPosAndSpaceModeActive
;
322 SvxNumberingPreview m_aPreviewWIN
;
323 std::unique_ptr
<weld::TreeView
> m_xLevelLB
;
324 // former set of controls shown for numbering rules containing list level
325 // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
326 std::unique_ptr
<weld::Label
> m_xDistBorderFT
;
327 std::unique_ptr
<weld::MetricSpinButton
> m_xDistBorderMF
;
328 std::unique_ptr
<weld::CheckButton
> m_xRelativeCB
;
329 std::unique_ptr
<weld::Label
> m_xIndentFT
;
330 std::unique_ptr
<weld::MetricSpinButton
> m_xIndentMF
;
331 std::unique_ptr
<weld::Label
> m_xDistNumFT
;
332 std::unique_ptr
<weld::MetricSpinButton
> m_xDistNumMF
;
333 std::unique_ptr
<weld::Label
> m_xAlignFT
;
334 std::unique_ptr
<weld::ComboBox
> m_xAlignLB
;
335 // new set of controls shown for numbering rules containing list level
336 // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_ALIGNMENT
337 std::unique_ptr
<weld::Label
> m_xLabelFollowedByFT
;
338 std::unique_ptr
<weld::ComboBox
> m_xLabelFollowedByLB
;
339 std::unique_ptr
<weld::Label
> m_xListtabFT
;
340 std::unique_ptr
<weld::MetricSpinButton
> m_xListtabMF
;
341 std::unique_ptr
<weld::Label
>m_xAlign2FT
;
342 std::unique_ptr
<weld::ComboBox
> m_xAlign2LB
;
343 std::unique_ptr
<weld::Label
> m_xAlignedAtFT
;
344 std::unique_ptr
<weld::MetricSpinButton
> m_xAlignedAtMF
;
345 std::unique_ptr
<weld::Label
> m_xIndentAtFT
;
346 std::unique_ptr
<weld::MetricSpinButton
> m_xIndentAtMF
;
347 std::unique_ptr
<weld::Button
> m_xStandardPB
;
348 std::unique_ptr
<weld::CustomWeld
> m_xPreviewWIN
;
352 DECL_LINK(LevelHdl_Impl
, weld::TreeView
&, void);
353 DECL_LINK(LevelHdl
, void *, void);
354 DECL_LINK(EditModifyHdl_Impl
, weld::ComboBox
&, void);
355 DECL_LINK(DistanceHdl_Impl
, weld::MetricSpinButton
&, void);
356 DECL_LINK(RelativeHdl_Impl
, weld::Toggleable
&, void);
357 DECL_LINK(StandardHdl_Impl
, weld::Button
&, void);
359 void InitPosAndSpaceMode();
360 void ShowControlsDependingOnPosAndSpaceMode();
362 DECL_LINK(LabelFollowedByHdl_Impl
, weld::ComboBox
&, void);
363 DECL_LINK(ListtabPosHdl_Impl
, weld::MetricSpinButton
&, void);
364 DECL_LINK(AlignAtHdl_Impl
, weld::MetricSpinButton
&, void);
365 DECL_LINK(IndentAtHdl_Impl
, weld::MetricSpinButton
&, void);
368 SvxNumPositionTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
369 virtual ~SvxNumPositionTabPage() override
;
371 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
372 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
373 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
374 virtual void Reset( const SfxItemSet
* rSet
) override
;
376 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
377 const SfxItemSet
* rAttrSet
);
379 void SetMetric(FieldUnit eSet
);
381 virtual void PageCreated(const SfxAllItemSet
& aSet
) override
;
384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */