Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SVX_NUMPAGES_HXX
20 : #define _SVX_NUMPAGES_HXX
21 :
22 : #include <vector>
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 :
25 : #include <sfx2/tabdlg.hxx>
26 : #include <vcl/group.hxx>
27 : #include <vcl/fixed.hxx>
28 : #include <vcl/menubtn.hxx>
29 : #include <vcl/lstbox.hxx>
30 : #include <vcl/edit.hxx>
31 : #include <vcl/field.hxx>
32 : #include <editeng/numdef.hxx>
33 : #include <svtools/ctrlbox.hxx>
34 :
35 : // -----------------------------------------------------------------------
36 : class SvxNumRule;
37 : class SvxBmpNumValueSet;
38 : class SvxNumValueSet;
39 : class SvxBrushItem;
40 :
41 0 : class SvxNumberingPreview : public Window
42 : {
43 : const SvxNumRule* pActNum;
44 : Font aStdFont;
45 : long nPageWidth;
46 : const String* pOutlineNames;
47 : sal_Bool bPosition;
48 : sal_uInt16 nActLevel;
49 :
50 : protected:
51 : virtual void Paint( const Rectangle& rRect );
52 :
53 : public:
54 : SvxNumberingPreview(Window* pParent, WinBits nWinBits = WB_BORDER);
55 :
56 0 : void SetNumRule(const SvxNumRule* pNum)
57 0 : {pActNum = pNum; Invalidate();};
58 : void SetPageWidth(long nPgWidth)
59 : {nPageWidth = nPgWidth;}
60 : void SetOutlineNames(const String* pNames)
61 : {pOutlineNames = pNames;}
62 0 : void SetPositionMode()
63 0 : { bPosition = sal_True;}
64 0 : void SetLevel(sal_uInt16 nSet) {nActLevel = nSet;}
65 :
66 : };
67 :
68 : //------------------------------------------------
69 :
70 0 : struct SvxNumSettings_Impl
71 : {
72 : short nNumberType;
73 : short nParentNumbering;
74 : OUString sPrefix;
75 : OUString sSuffix;
76 : OUString sBulletChar;
77 : OUString sBulletFont;
78 0 : SvxNumSettings_Impl() :
79 : nNumberType(0),
80 0 : nParentNumbering(0)
81 0 : {}
82 : };
83 :
84 : typedef boost::ptr_vector<SvxNumSettings_Impl> SvxNumSettingsArr_Impl;
85 :
86 :
87 : //------------------------------------------------
88 : class SvxSingleNumPickTabPage : public SfxTabPage
89 : {
90 : using TabPage::ActivatePage;
91 : using TabPage::DeactivatePage;
92 :
93 : SvxNumValueSet* m_pExamplesVS;
94 : SvxNumSettingsArr_Impl aNumSettingsArr;
95 : SvxNumRule* pActNum;
96 : SvxNumRule* pSaveNum;
97 : sal_uInt16 nActNumLvl;
98 : sal_Bool bModified : 1;
99 : sal_Bool bPreset : 1;
100 :
101 : String sNumCharFmtName;
102 : sal_uInt16 nNumItemId;
103 :
104 : protected:
105 : DECL_LINK(NumSelectHdl_Impl, void *);
106 : DECL_LINK(DoubleClickHdl_Impl, void *);
107 :
108 : public:
109 : SvxSingleNumPickTabPage(Window* pParent,
110 : const SfxItemSet& rSet);
111 : ~SvxSingleNumPickTabPage();
112 :
113 : static SfxTabPage* Create( Window* pParent,
114 : const SfxItemSet& rAttrSet);
115 :
116 : virtual void ActivatePage(const SfxItemSet& rSet);
117 : virtual int DeactivatePage(SfxItemSet *pSet);
118 : virtual sal_Bool FillItemSet( SfxItemSet& rSet );
119 : virtual void Reset( const SfxItemSet& rSet );
120 :
121 : void SetNumCharFmtName(const String& rName){sNumCharFmtName = rName;}
122 : };
123 :
124 :
125 : //------------------------------------------------
126 :
127 : class SvxBulletPickTabPage : public SfxTabPage
128 : {
129 : using TabPage::ActivatePage;
130 : using TabPage::DeactivatePage;
131 :
132 : SvxNumValueSet* m_pExamplesVS;
133 : SvxNumRule* pActNum;
134 : SvxNumRule* pSaveNum;
135 : sal_uInt16 nActNumLvl;
136 : sal_Bool bModified : 1;
137 : sal_Bool bPreset : 1;
138 : sal_uInt16 nNumItemId;
139 :
140 : String sBulletCharFmtName;
141 : protected:
142 : DECL_LINK(NumSelectHdl_Impl, void *);
143 : DECL_LINK(DoubleClickHdl_Impl, void *);
144 : public:
145 : SvxBulletPickTabPage(Window* pParent,
146 : const SfxItemSet& rSet);
147 : ~SvxBulletPickTabPage();
148 :
149 : static SfxTabPage* Create( Window* pParent,
150 : const SfxItemSet& rAttrSet);
151 :
152 : virtual void ActivatePage(const SfxItemSet& rSet);
153 : virtual int DeactivatePage(SfxItemSet *pSet);
154 : virtual sal_Bool FillItemSet( SfxItemSet& rSet );
155 : virtual void Reset( const SfxItemSet& rSet );
156 :
157 0 : void SetCharFmtName(const String& rName){sBulletCharFmtName = rName;}
158 : virtual void PageCreated(SfxAllItemSet aSet);
159 : };
160 :
161 : #define NUM_VALUSET_COUNT 16
162 :
163 : /// TabPage for complete numeration
164 : class SvxNumPickTabPage : public SfxTabPage
165 : {
166 : using TabPage::ActivatePage;
167 : using TabPage::DeactivatePage;
168 :
169 : SvxNumValueSet* m_pExamplesVS;
170 : String sNumCharFmtName;
171 : String sBulletCharFmtName;
172 :
173 : SvxNumSettingsArr_Impl aNumSettingsArrays[NUM_VALUSET_COUNT]; // is initialized with the five formats
174 :
175 : SvxNumRule* pActNum;
176 : SvxNumRule* pSaveNum;
177 : sal_uInt16 nActNumLvl;
178 : sal_uInt16 nNumItemId;
179 : sal_Bool bModified : 1;
180 : sal_Bool bPreset : 1;
181 :
182 :
183 : protected:
184 : DECL_LINK(NumSelectHdl_Impl, void *);
185 : DECL_LINK(DoubleClickHdl_Impl, void *);
186 :
187 : public:
188 : SvxNumPickTabPage(Window* pParent,
189 : const SfxItemSet& rSet);
190 : ~SvxNumPickTabPage();
191 :
192 : static SfxTabPage* Create( Window* pParent,
193 : const SfxItemSet& rAttrSet);
194 :
195 : virtual void ActivatePage(const SfxItemSet& rSet);
196 : virtual int DeactivatePage(SfxItemSet *pSet);
197 : virtual sal_Bool FillItemSet( SfxItemSet& rSet );
198 : virtual void Reset( const SfxItemSet& rSet );
199 :
200 0 : void SetCharFmtNames(const String& rCharName, const String& rBulName)
201 0 : { sNumCharFmtName = rCharName;
202 0 : sBulletCharFmtName = rBulName;}
203 : virtual void PageCreated(SfxAllItemSet aSet);
204 : };
205 :
206 :
207 : //------------------------------------------------
208 : class SvxBitmapPickTabPage : public SfxTabPage
209 : {
210 : using TabPage::ActivatePage;
211 : using TabPage::DeactivatePage;
212 :
213 : FixedText* m_pErrorText;
214 : SvxBmpNumValueSet* m_pExamplesVS;
215 : CheckBox* m_pLinkedCB;
216 :
217 : std::vector<String> aGrfNames;
218 : String sNumCharFmtName;
219 :
220 : SvxNumRule* pActNum;
221 : SvxNumRule* pSaveNum;
222 : sal_uInt16 nActNumLvl;
223 : sal_uInt16 nNumItemId;
224 : SfxMapUnit eCoreUnit;
225 : sal_Bool bModified : 1;
226 : sal_Bool bPreset : 1;
227 :
228 : protected:
229 : DECL_LINK(NumSelectHdl_Impl, void *);
230 : DECL_LINK(DoubleClickHdl_Impl, void *);
231 : DECL_LINK(LinkBmpHdl_Impl, void *);
232 :
233 : public:
234 : SvxBitmapPickTabPage(Window* pParent,
235 : const SfxItemSet& rSet);
236 : ~SvxBitmapPickTabPage();
237 :
238 : static SfxTabPage* Create( Window* pParent,
239 : const SfxItemSet& rAttrSet);
240 :
241 : virtual void ActivatePage(const SfxItemSet& rSet);
242 : virtual int DeactivatePage(SfxItemSet *pSet);
243 : virtual sal_Bool FillItemSet( SfxItemSet& rSet );
244 : virtual void Reset( const SfxItemSet& rSet );
245 :
246 : void SetNumCharFmtName(const String& rName){sNumCharFmtName = rName;}
247 : };
248 :
249 : //------------------------------------------------
250 : class SvxNumOptionsTabPage : public SfxTabPage
251 : {
252 : using TabPage::ActivatePage;
253 : using TabPage::DeactivatePage;
254 :
255 : ListBox* m_pLevelLB;
256 :
257 : ListBox* m_pFmtLB;
258 :
259 : FixedText* m_pSeparatorFT;
260 : FixedText* m_pPrefixFT;
261 : Edit* m_pPrefixED;
262 : FixedText* m_pSuffixFT;
263 : Edit* m_pSuffixED;
264 : FixedText* m_pCharFmtFT;
265 : ListBox* m_pCharFmtLB;
266 : FixedText* m_pBulColorFT;
267 : ColorListBox* m_pBulColLB;
268 : FixedText* m_pBulRelSizeFT;
269 : MetricField* m_pBulRelSizeMF;
270 : FixedText* m_pAllLevelFT;
271 : NumericField* m_pAllLevelNF;
272 : FixedText* m_pStartFT;
273 : NumericField* m_pStartED;
274 : FixedText* m_pBulletFT;
275 : PushButton* m_pBulletPB;
276 : FixedText* m_pAlignFT;
277 : ListBox* m_pAlignLB;
278 : FixedText* m_pBitmapFT;
279 : MenuButton* m_pBitmapMB;
280 : sal_uInt16 m_nGalleryId;
281 : FixedText* m_pWidthFT;
282 : MetricField* m_pWidthMF;
283 : FixedText* m_pHeightFT;
284 : MetricField* m_pHeightMF;
285 : CheckBox* m_pRatioCB;
286 : FixedText* m_pOrientFT;
287 : ListBox* m_pOrientLB;
288 :
289 : VclContainer* m_pAllLevelsFrame;
290 : CheckBox* m_pSameLevelCB;
291 :
292 : SvxNumberingPreview* m_pPreviewWIN;
293 :
294 : OUString m_sNumCharFmtName;
295 : OUString m_sBulletCharFmtName;
296 :
297 : Timer aInvalidateTimer;
298 :
299 : SvxNumRule* pActNum;
300 : SvxNumRule* pSaveNum;
301 :
302 : Size aInitSize[SVX_MAX_NUM];
303 :
304 : sal_Bool bLastWidthModified : 1;
305 : sal_Bool bModified : 1;
306 : sal_Bool bPreset : 1;
307 : sal_Bool bAutomaticCharStyles: 1;
308 : sal_Bool bHTMLMode : 1;
309 : sal_Bool bMenuButtonInitialized : 1;
310 :
311 : std::vector<String> aGrfNames;
312 : Font aActBulletFont;
313 :
314 : sal_uInt8 nBullet;
315 : sal_uInt16 nActNumLvl;
316 : sal_uInt16 nNumItemId;
317 : SfxMapUnit eCoreUnit;
318 :
319 : void InitControls();
320 : /** To switch between the numbering type
321 : 0 - Number;
322 : 1 - Bullet;
323 : 2 - Bitmap; */
324 : void SwitchNumberType( sal_uInt8 nType, sal_Bool bBmp = sal_False );
325 : void CheckForStartValue_Impl(sal_uInt16 nNumberingType);
326 :
327 : DECL_LINK( NumberTypeSelectHdl_Impl, ListBox * );
328 : DECL_LINK( LevelHdl_Impl, ListBox * );
329 : DECL_LINK(PopupActivateHdl_Impl, void *);
330 : DECL_LINK( GraphicHdl_Impl, MenuButton * );
331 : DECL_LINK(BulletHdl_Impl, void *);
332 : DECL_LINK( SizeHdl_Impl, MetricField * );
333 : DECL_LINK( RatioHdl_Impl, CheckBox * );
334 : DECL_LINK(CharFmtHdl_Impl, void *);
335 : DECL_LINK( EditModifyHdl_Impl, Edit * );
336 : DECL_LINK( AllLevelHdl_Impl, NumericField * );
337 : DECL_LINK( OrientHdl_Impl, ListBox * );
338 : DECL_LINK( SameLevelHdl_Impl, CheckBox * );
339 : DECL_LINK( BulColorHdl_Impl, ColorListBox* );
340 : DECL_LINK( BulRelSizeHdl_Impl, MetricField *);
341 : DECL_LINK(PreviewInvalidateHdl_Impl, void *);
342 :
343 : DECL_STATIC_LINK( SvxNumOptionsTabPage, GraphicArrivedHdl_Impl, SvxBrushItem* );
344 :
345 : public:
346 : SvxNumOptionsTabPage(Window* pParent,
347 : const SfxItemSet& rSet);
348 : ~SvxNumOptionsTabPage();
349 :
350 : static SfxTabPage* Create( Window* pParent,
351 : const SfxItemSet& rAttrSet);
352 :
353 : virtual void ActivatePage(const SfxItemSet& rSet);
354 : virtual int DeactivatePage(SfxItemSet *pSet);
355 : virtual sal_Bool FillItemSet( SfxItemSet& rSet );
356 : virtual void Reset( const SfxItemSet& rSet );
357 :
358 0 : void SetCharFmts(const OUString& rNumName, const OUString& rBulletName)
359 : {
360 0 : m_sNumCharFmtName = rNumName;
361 0 : m_sBulletCharFmtName = rBulletName;
362 0 : }
363 : void SetMetric(FieldUnit eSet);
364 :
365 0 : ListBox& GetCharFmtListBox() {return *m_pCharFmtLB;}
366 : void SetModified(sal_Bool bRepaint = sal_True);
367 : virtual void PageCreated(SfxAllItemSet aSet);
368 :
369 : /** Get the numberings provided by the i18n framework (CTL, Asian, ...) and
370 : add them to the listbox. Extended numbering schemes present in the
371 : resource and already in the listbox but not offered by the i18n
372 : framework per configuration are removed.
373 :
374 : @param nDoNotRemove
375 : A value that shall not be removed, i.e. the ugly 0x88
376 : (SVX_NUM_BITMAP|0x80)
377 : Pass ::std::numeric_limits<sal_uInt16>::max() if there is no such
378 : restriction.
379 : */
380 : static void GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove );
381 : };
382 :
383 : //------------------------------------------------
384 : class SvxNumPositionTabPage : public SfxTabPage
385 : {
386 : using TabPage::ActivatePage;
387 : using TabPage::DeactivatePage;
388 :
389 : ListBox* m_pLevelLB;
390 :
391 : // former set of controls shown for numbering rules containing list level
392 : // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
393 : FixedText* m_pDistBorderFT;
394 : MetricField* m_pDistBorderMF;
395 : CheckBox* m_pRelativeCB;
396 : FixedText* m_pIndentFT;
397 : MetricField* m_pIndentMF;
398 : FixedText* m_pDistNumFT;
399 : MetricField* m_pDistNumMF;
400 : FixedText* m_pAlignFT;
401 : ListBox* m_pAlignLB;
402 :
403 : // new set of controls shown for numbering rules containing list level
404 : // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_ALIGNMENT
405 : FixedText* m_pLabelFollowedByFT;
406 : ListBox* m_pLabelFollowedByLB;
407 : FixedText* m_pListtabFT;
408 : MetricField* m_pListtabMF;
409 : FixedText* m_pAlign2FT;
410 : ListBox* m_pAlign2LB;
411 : FixedText* m_pAlignedAtFT;
412 : MetricField* m_pAlignedAtMF;
413 : FixedText* m_pIndentAtFT;
414 : MetricField* m_pIndentAtMF;
415 :
416 : PushButton* m_pStandardPB;
417 :
418 : SvxNumberingPreview* m_pPreviewWIN;
419 :
420 : SvxNumRule* pActNum;
421 : SvxNumRule* pSaveNum;
422 :
423 : sal_uInt16 nActNumLvl;
424 : sal_uInt16 nNumItemId;
425 : SfxMapUnit eCoreUnit;
426 :
427 : sal_Bool bModified : 1;
428 : sal_Bool bPreset : 1;
429 : sal_Bool bInInintControl : 1; // workaround for Modify-error, is said to be correctet from 391 on
430 : bool bLabelAlignmentPosAndSpaceModeActive;
431 :
432 : void InitControls();
433 :
434 : DECL_LINK( LevelHdl_Impl, ListBox * );
435 : DECL_LINK(EditModifyHdl_Impl, void *);
436 : DECL_LINK( DistanceHdl_Impl, MetricField * );
437 : DECL_LINK( RelativeHdl_Impl, CheckBox * );
438 : DECL_LINK(StandardHdl_Impl, void *);
439 :
440 : void InitPosAndSpaceMode();
441 : void ShowControlsDependingOnPosAndSpaceMode();
442 :
443 : DECL_LINK(LabelFollowedByHdl_Impl, void *);
444 : DECL_LINK( ListtabPosHdl_Impl, MetricField* );
445 : DECL_LINK( AlignAtHdl_Impl, MetricField* );
446 : DECL_LINK( IndentAtHdl_Impl, MetricField* );
447 :
448 : public:
449 : SvxNumPositionTabPage(Window* pParent,
450 : const SfxItemSet& rSet);
451 : ~SvxNumPositionTabPage();
452 :
453 : virtual void ActivatePage(const SfxItemSet& rSet);
454 : virtual int DeactivatePage(SfxItemSet *pSet);
455 : virtual sal_Bool FillItemSet( SfxItemSet& rSet );
456 : virtual void Reset( const SfxItemSet& rSet );
457 :
458 : static SfxTabPage* Create( Window* pParent,
459 : const SfxItemSet& rAttrSet);
460 :
461 : void SetMetric(FieldUnit eSet);
462 : void SetModified(sal_Bool bRepaint = sal_True);
463 : virtual void PageCreated(SfxAllItemSet aSet);
464 : };
465 :
466 : #endif
467 :
468 :
469 :
470 :
471 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|