xref: /trunk/main/sw/source/ui/inc/swuicnttab.hxx (revision 1d2dbeb0)
1  /**************************************************************
2   *
3   * Licensed to the Apache Software Foundation (ASF) under one
4   * or more contributor license agreements.  See the NOTICE file
5   * distributed with this work for additional information
6   * regarding copyright ownership.  The ASF licenses this file
7   * to you under the Apache License, Version 2.0 (the
8   * "License"); you may not use this file except in compliance
9   * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   *
20   *************************************************************/
21  
22  
23  #ifndef _SWUI_CNTTAB_HXX
24  #define _SWUI_CNTTAB_HXX
25  
26  #include <svx/stddlg.hxx>
27  
28  #ifndef _BUTTON_HXX //autogen
29  #include <vcl/button.hxx>
30  #endif
31  
32  #ifndef _EDIT_HXX //autogen
33  #include <vcl/edit.hxx>
34  #endif
35  
36  #ifndef _FIXED_HXX //autogen
37  #include <vcl/fixed.hxx>
38  #endif
39  
40  #ifndef _FIELD_HXX //autogen
41  #include <vcl/field.hxx>
42  #endif
43  #include <vcl/lstbox.hxx>
44  #include <sfx2/tabdlg.hxx>
45  
46  #include "tox.hxx"
47  #include <tools/list.hxx>
48  #include <toxmgr.hxx>
49  #include <svx/checklbx.hxx>
50  #include <tools/resary.hxx>
51  #include <svtools/svtreebx.hxx>
52  #include <vcl/menubtn.hxx>
53  #include <svx/langbox.hxx>
54  #include <cnttab.hxx>
55  class SwWrtShell;
56  class SwTOXMgr;
57  namespace com{namespace sun{namespace star{
58      namespace text{
59          class XTextSection;
60          class XDocumentIndex;
61      }
62  }}}
63  
64  //-----------------------------------------------------------------------------
65  struct SwIndexSections_Impl
66  {
67      com::sun::star::uno::Reference< com::sun::star::text::XTextSection >    xContainerSection;
68      com::sun::star::uno::Reference< com::sun::star::text::XDocumentIndex >    xDocumentIndex;
69  };
70  
71  //-----------------------------------------------------------------------------
72  class SwOneExampleFrame;
73  struct SwIndexSections_Impl;
74  
75  class SwMultiTOXTabDialog : public SfxTabDialog
76  {
77  	Window					aExampleContainerWIN;
78      Window                  aExampleWIN;
79  	CheckBox				aShowExampleCB;
80  	SwTOXMgr*				pMgr;
81  	SwWrtShell& 			rSh;
82  
83  	SwOneExampleFrame*		pExampleFrame;
84  
85  	SwTOXDescription** 		pDescArr; //
86  	SwForm**				pFormArr; //
87  	SwIndexSections_Impl**	pxIndexSectionsArr;
88  
89  	SwTOXBase* 				pParamTOXBase;
90  
91  	CurTOXType				eCurrentTOXType;
92  
93  	String					sUserDefinedIndex;
94  	sal_uInt16 					nTypeCount;
95  	sal_uInt16					nInitialTOXType;
96  
97  	sal_Bool					bEditTOX;
98  	sal_Bool					bExampleCreated;
99  	sal_Bool					bGlobalFlag;
100  
101  	virtual short		Ok();
102  	SwTOXDescription* 	CreateTOXDescFromTOXBase(const SwTOXBase*pCurTOX);
103  
104  	DECL_LINK(CreateExample_Hdl, void* );
105  	DECL_LINK(ShowPreviewHdl, CheckBox*);
106  
107  public:
108  	SwMultiTOXTabDialog(Window* pParent, const SfxItemSet& rSet,
109  						SwWrtShell &rShell,
110  						SwTOXBase* pCurTOX, sal_uInt16 nToxType = USHRT_MAX,
111  						sal_Bool bGlobal = sal_False);
112  	~SwMultiTOXTabDialog();
113  
114  	virtual void		PageCreated( sal_uInt16 nId, SfxTabPage &rPage );
115  
116  	SwForm*				GetForm(CurTOXType eType);
117  
118  	CurTOXType			GetCurrentTOXType() const { return eCurrentTOXType;}
119  	void				SetCurrentTOXType(CurTOXType	eSet)
120  								{
121  									eCurrentTOXType = eSet;
122  								}
123  
124  	void				UpdateExample();
125  	sal_Bool				IsTOXEditMode() const { return bEditTOX;}
126  
127  	SwWrtShell& 		GetWrtShell() {return rSh;}
128  
129  	SwTOXDescription&	GetTOXDescription(CurTOXType eTOXTypes);
130  	void				CreateOrUpdateExample(
131                              TOXTypes nTOXIndex, sal_uInt16 nPage = 0, sal_uInt16 nCurLevel = USHRT_MAX);
132  
133  	static sal_Bool	IsNoNum(SwWrtShell& rSh, const String& rName);
134  };
135  /* -----------------14.07.99 12:17-------------------
136  
137   --------------------------------------------------*/
138  class IndexEntryRessource;
139  class IndexEntrySupplierWrapper;
140  
141  class SwTOXSelectTabPage : public SfxTabPage
142  {
143      FixedLine       aTypeTitleFL;
144  	FixedText		aTitleFT;
145  	Edit			aTitleED;
146  	FixedText		aTypeFT;
147  	ListBox			aTypeLB;
148  	CheckBox		aReadOnlyCB;
149  
150      FixedLine       aAreaFL;
151      FixedText       aAreaFT;
152      ListBox         aAreaLB;
153  	FixedText		aLevelFT;	//content, user
154  	NumericField	aLevelNF;   //content, user
155  
156  	//content
157      FixedLine       aCreateFromFL;  // content, user, illustration
158  	CheckBox		aFromHeadingsCB;
159  //	PushButton		aChapterDlgPB;	//#outline level,removed by zhaojianwei
160  	CheckBox		aAddStylesCB;
161  	PushButton		aAddStylesPB;
162      Point           aAddStylesPosDef;
163      Point           aAddStylesPosUser;
164  	//user
165  	CheckBox		aFromTablesCB;
166  	CheckBox		aFromFramesCB;
167  	CheckBox		aFromGraphicsCB;
168  	CheckBox		aFromOLECB;
169  	CheckBox		aLevelFromChapterCB;
170  
171  	//illustration + table
172  	RadioButton		aFromCaptionsRB;
173  	RadioButton     aFromObjectNamesRB;
174  
175  	//illustration and tables
176  	FixedText		aCaptionSequenceFT;
177  	ListBox			aCaptionSequenceLB;
178  	FixedText		aDisplayTypeFT;
179  	ListBox			aDisplayTypeLB;
180  
181  	//all but illustration and table
182  	CheckBox		aTOXMarksCB;
183  
184  	//
185  
186  	//index only
187  	FixedLine       aIdxOptionsFL;
188  	CheckBox		aCollectSameCB;
189  	CheckBox		aUseFFCB;
190  	CheckBox		aUseDashCB;
191  	CheckBox		aCaseSensitiveCB;
192  	CheckBox		aInitialCapsCB;
193  	CheckBox		aKeyAsEntryCB;
194  	CheckBox		aFromFileCB;
195  	MenuButton		aAutoMarkPB;
196  
197  	// object only
198  	SwOLENames		aFromNames;
199  	SvxCheckListBox	aFromObjCLB;
200      FixedLine       aFromObjFL;
201  
202  	CheckBox		aSequenceCB;
203  	FixedText		aBracketFT;
204  	ListBox			aBracketLB;
205      FixedLine       aAuthorityFormatFL;
206  
207      //all
208      FixedLine       aSortOptionsFL;
209      FixedText       aLanguageFT;
210      SvxLanguageBox  aLanguageLB;
211      FixedText       aSortAlgorithmFT;
212      ListBox         aSortAlgorithmLB;
213  
214      IndexEntryRessource* pIndexRes;
215  
216      Point           aCBLeftPos1;
217  	Point 			aCBLeftPos2;
218  	Point 			aCBLeftPos3;
219  
220  	String			aStyleArr[MAXLEVEL];
221  	String 			sAutoMarkURL;
222  	String 			sAutoMarkType;
223  	String 			sAddStyleUser;
224  	String 			sAddStyleContent;
225  
226      const IndexEntrySupplierWrapper* pIndexEntryWrapper;
227  
228  	sal_Bool 			bFirstCall;
229  
230  	DECL_LINK(TOXTypeHdl, 	ListBox* );
231  	DECL_LINK(TOXAreaHdl, 	ListBox* );
232  //	DECL_LINK(ChapterHdl, 	PushButton* ); //#outline level,removed by zhaojianwei
233  	DECL_LINK(AddStylesHdl, PushButton* );
234  	DECL_LINK(MenuEnableHdl, Menu*);
235  	DECL_LINK(MenuExecuteHdl, Menu*);
236      DECL_LINK(LanguageHdl, ListBox*);
237  
238  	DECL_LINK(CheckBoxHdl, 	CheckBox*	);
239  	DECL_LINK(RadioButtonHdl, RadioButton* );
240  	DECL_LINK(ModifyHdl, void*);
241  
242    	void	ApplyTOXDescription();
243  	void 	FillTOXDescription();
244  
245      using SfxTabPage::ActivatePage;
246      using SfxTabPage::DeactivatePage;
247  
248  public:
249  	SwTOXSelectTabPage(Window* pParent, const SfxItemSet& rAttrSet);
250  	~SwTOXSelectTabPage();
251  
252  	virtual sal_Bool		FillItemSet( SfxItemSet& );
253  	virtual void		Reset( const SfxItemSet& );
254  
255      virtual void		ActivatePage( const SfxItemSet& );
256  	virtual int			DeactivatePage( SfxItemSet* pSet = 0 );
257  
258  	static SfxTabPage*	Create( Window* pParent,
259  								const SfxItemSet& rAttrSet);
260  
261  	void				SelectType(TOXTypes eSet); 	//preset TOXType, GlobalDoc
262  	void				SetWrtShell(SwWrtShell& rSh);
263  };
264  /* -----------------16.06.99 08:33-------------------
265  
266   --------------------------------------------------*/
267  
268  DECLARE_LIST(TOXControlList, Control*)
269  
270  class SwTOXEdit;
271  class SwTOXButton;
272  class SwTOXEntryTabPage;
273  
274  class SwTokenWindow : public Window
275  {
276  	ImageButton 	aLeftScrollWin;
277  	Window			aCtrlParentWin;
278  	ImageButton 	aRightScrollWin;
279  	TOXControlList 	aControlList;
280  	SwForm* 		pForm;
281  	sal_uInt16 			nLevel;
282  	sal_Bool			bValid;
283  	String 			aButtonTexts[TOKEN_END]; // Text of the buttons
284  	String 			aButtonHelpTexts[TOKEN_END]; // QuickHelpText of the buttons
285  	String 			sCharStyle;
286  	Link			aButtonSelectedHdl;
287  	Control*		pActiveCtrl;
288  	Link			aModifyHdl;
289  
290  	SwTOXEntryTabPage*	m_pParent;
291  
292  	DECL_LINK(EditResize, Edit*);
293  	DECL_LINK(NextItemHdl, SwTOXEdit* );
294  	DECL_LINK(TbxFocusHdl, SwTOXEdit* );
295  	DECL_LINK(NextItemBtnHdl, SwTOXButton* );
296  	DECL_LINK(TbxFocusBtnHdl, SwTOXButton* );
297  	DECL_LINK(ScrollHdl, ImageButton* );
298  
299  	void	SetActiveControl(Control* pSet);
300  
301  	Control*	InsertItem(const String& rText, const SwFormToken& aToken);
302  	void		AdjustPositions();
303  	void 		AdjustScrolling();
304  	void 		MoveControls(long nOffset);
305  
306  public:
307  	SwTokenWindow(SwTOXEntryTabPage* pParent, const ResId& rResId);
308  	~SwTokenWindow();
309  
310  	void		SetForm(SwForm& rForm, sal_uInt16 nLevel);
311  	sal_uInt16 		GetLastLevel()const {return nLevel;};
312  
313  	sal_Bool		IsValid() const {return bValid;}
314  
315  	void		SetInvalid() {bValid = sal_False;}
316  
317  	String		GetPattern() const;
318  
319  	void		SetButtonSelectedHdl(const Link& rLink)
320  				{ aButtonSelectedHdl = rLink;}
321  
322  	void		SetModifyHdl(const Link& rLink){aModifyHdl = rLink;}
323  
324  	Control*	GetActiveControl()
325  					{ return pActiveCtrl;}
326  
327  	void		InsertAtSelection(const String& rText, const SwFormToken& aToken);
328  	void		RemoveControl(SwTOXButton* pDel, sal_Bool bInternalCall = sal_False);
329  
330  	sal_Bool 		Contains(FormTokenType) const;
331  
332  	sal_Bool		DetermineLinkStart();
333  
334  	//helper for pattern buttons and edits
335  	sal_Bool 		CreateQuickHelp(Control* pCtrl,
336  					const SwFormToken& rToken, const HelpEvent& );
337  
338  	virtual void		Resize();
339      virtual void        GetFocus();
340  };
341  /* -----------------------------23.12.99 14:16--------------------------------
342  
343   ---------------------------------------------------------------------------*/
344  class SwTOXEntryTabPage;
345  class SwIdxTreeListBox : public SvTreeListBox
346  {
347  	SwTOXEntryTabPage* pParent;
348  
349  	virtual void    RequestHelp( const HelpEvent& rHEvt );
350  public:
351  	SwIdxTreeListBox(SwTOXEntryTabPage* pPar, const ResId& rResId);
352  };
353  
354  /* -----------------16.06.99 12:49-------------------
355  
356   --------------------------------------------------*/
357  class SwTOXEntryTabPage : public SfxTabPage
358  {
359      FixedText           aLevelFT;
360      SwIdxTreeListBox    aLevelLB;
361  
362  	FixedLine       aEntryFL;
363      FixedText       aTokenFT;
364      SwTokenWindow   aTokenWIN;
365  	PushButton		aAllLevelsPB;
366  
367  	PushButton		aEntryNoPB;
368  	PushButton		aEntryPB;
369  	PushButton 		aTabPB;
370  	PushButton		aChapterInfoPB;
371  	PushButton		aPageNoPB;
372  	PushButton		aHyperLinkPB;
373  
374  	ListBox			aAuthFieldsLB;
375  	PushButton 		aAuthInsertPB;
376  	PushButton 		aAuthRemovePB;
377  
378  	FixedText		aCharStyleFT;
379  	ListBox			aCharStyleLB;		// character style of the current token
380  	PushButton		aEditStylePB;
381  
382  	FixedText		aChapterEntryFT;
383  	ListBox			aChapterEntryLB;	// type of chapter info
384  
385  	FixedText		aNumberFormatFT;
386  	ListBox			aNumberFormatLB;    //!< format for numbering (E#)
387  
388  	FixedText		aEntryOutlineLevelFT;    //!< Fixed text, for i53420
389  	NumericField	aEntryOutlineLevelNF;   //!< level to evaluate outline level to, for i53420
390  	FixedText		aFillCharFT;
391  	ComboBox		aFillCharCB;		// fill char for tab stop
392  	FixedText		aTabPosFT;
393  	MetricField		aTabPosMF;			// tab stop position
394  	CheckBox		aAutoRightCB;
395  	FixedLine       aFormatFL;
396  
397  	CheckBox		aRelToStyleCB;		// position relative to the right margin of the para style
398  	FixedText		aMainEntryStyleFT;
399  	ListBox 		aMainEntryStyleLB;	// character style of main entries in indexes
400  	CheckBox		aAlphaDelimCB;
401  	CheckBox		aCommaSeparatedCB;
402  
403  	RadioButton		aSortDocPosRB;
404  	RadioButton		aSortContentRB;
405      FixedLine       aSortingFL;
406  
407  	FixedText			aFirstKeyFT;
408  	ListBox				aFirstKeyLB;
409  	ImageRadioButton    aFirstSortUpRB;
410  	ImageRadioButton    aFirstSortDownRB;
411  
412  	FixedText			aSecondKeyFT;
413  	ListBox				aSecondKeyLB;
414  	ImageRadioButton    aSecondSortUpRB;
415  	ImageRadioButton    aSecondSortDownRB;
416  
417  	FixedText 			aThirdKeyFT;
418  	ListBox 			aThirdKeyLB;
419  	ImageRadioButton    aThirdSortUpRB;
420  	ImageRadioButton    aThirdSortDownRB;
421  
422      FixedLine       aSortKeyFL;
423  
424  	String 			sDelimStr;
425  	String 			sLevelStr;
426  	String			sAuthTypeStr;
427  
428  	String 			sNoCharStyle;
429  	String 			sNoCharSortKey;
430  	Point 			aButtonPositions[5];
431      SwForm*         m_pCurrentForm;
432  
433  	Point 			aRelToStylePos;
434  	Point 			aRelToStyleIdxPos;
435      Size            aLevelFLSize;
436  
437  	CurTOXType  	aLastTOXType;
438  	sal_Bool 			bInLevelHdl;
439  
440      Point           aChapterEntryFTPosition; //!< holds position of ChapterEntryFT control,
441                                               //to be used in moving the element among different tokens
442      Point           aEntryOutlineLevelFTPosition;//!< holds position ofrEntryOutlineLevelFT control
443      sal_Int32       nBiasToEntryPoint;
444  
445  	DECL_LINK(StyleSelectHdl, ListBox*);
446  	DECL_LINK(EditStyleHdl, PushButton*);
447  	DECL_LINK(InsertTokenHdl, PushButton*);
448  	DECL_LINK(LevelHdl, SvTreeListBox*);
449  	DECL_LINK(AutoRightHdl, CheckBox*);
450  	DECL_LINK(TokenSelectedHdl, SwFormToken*);
451  	DECL_LINK(TabPosHdl, MetricField*);
452  	DECL_LINK(FillCharHdl, ComboBox*);
453  	DECL_LINK(RemoveInsertAuthHdl, PushButton*);
454  	DECL_LINK(SortKeyHdl, RadioButton*);
455  	DECL_LINK(ChapterInfoHdl, ListBox*);
456  	DECL_LINK(ChapterInfoOutlineHdl, NumericField*);
457      DECL_LINK(NumberFormatHdl, ListBox*);
458  
459  	DECL_LINK(AllLevelsHdl, PushButton*);
460  
461  	void 			EnableButtons();
462  	void			WriteBackLevel();
463  	void			UpdateDescriptor();
464  	DECL_LINK(ModifyHdl, void*);
465  
466      using SfxTabPage::ActivatePage;
467      using SfxTabPage::DeactivatePage;
468  
469  public:
470  	SwTOXEntryTabPage(Window* pParent, const SfxItemSet& rAttrSet);
471  	~SwTOXEntryTabPage();
472  
473  	virtual sal_Bool		FillItemSet( SfxItemSet& );
474  	virtual void		Reset( const SfxItemSet& );
475      virtual void		ActivatePage( const SfxItemSet& );
476  	virtual int			DeactivatePage( SfxItemSet* pSet = 0 );
477  
478  	static SfxTabPage*	Create( Window* pParent,
479  								const SfxItemSet& rAttrSet);
480  	void				SetWrtShell(SwWrtShell& rSh);
481  
482  	String 				GetLevelHelp(sal_uInt16 nLevel) const;
483  
484  	void 				PreTokenButtonRemoved(const SwFormToken& rToken);
485  };
486  /* -----------------05.07.99 13:00-------------------
487  
488   --------------------------------------------------*/
489  class SwTOXStylesTabPage : public SfxTabPage
490  {
491      FixedLine       aFormatFL;
492  	FixedText		aLevelFT2;
493  	ListBox 		aLevelLB;
494      ImageButton     aAssignBT;
495  	FixedText		aTemplateFT;
496  	ListBox 		aParaLayLB;
497  	PushButton		aStdBT;
498  	PushButton 		aEditStyleBT;
499  
500      SwForm*         m_pCurrentForm;
501  //	void			UpdatePattern();
502  
503  	DECL_LINK( EditStyleHdl, Button *);
504  	DECL_LINK( StdHdl, Button * );
505  	DECL_LINK( EnableSelectHdl, ListBox * );
506  	DECL_LINK( DoubleClickHdl, Button * );
507  	DECL_LINK( AssignHdl, Button * );
508  	DECL_LINK( ModifyHdl, void*);
509  
510  	SwForm&		GetForm()
511  		{
512  			SwMultiTOXTabDialog* pDlg = (SwMultiTOXTabDialog*)GetTabDialog();
513  			return *pDlg->GetForm(pDlg->GetCurrentTOXType());
514  		}
515  
516      using SfxTabPage::ActivatePage;
517      using SfxTabPage::DeactivatePage;
518  
519  public:
520  	SwTOXStylesTabPage(Window* pParent, const SfxItemSet& rAttrSet);
521  	~SwTOXStylesTabPage();
522  
523  	virtual sal_Bool		FillItemSet( SfxItemSet& );
524  	virtual void		Reset( const SfxItemSet& );
525  
526      virtual void		ActivatePage( const SfxItemSet& );
527  	virtual int			DeactivatePage( SfxItemSet* pSet = 0 );
528  
529  	static SfxTabPage*	Create( Window* pParent,
530  								const SfxItemSet& rAttrSet);
531  
532  };
533  
534  #endif // _SWUI_CNTTAB_HXX
535  
536