xref: /aoo41x/main/svx/inc/svx/srchdlg.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SVX_SRCHDLG_HXX
28 #define _SVX_SRCHDLG_HXX
29 
30 // include ---------------------------------------------------------------
31 
32 
33 #include <svtools/stdctrl.hxx>
34 #include <vcl/combobox.hxx>
35 #include <vcl/edit.hxx>
36 #include <vcl/lstbox.hxx>
37 #include <vcl/button.hxx>
38 #include <vcl/group.hxx>
39 #include <vcl/fixed.hxx>
40 #include <vcl/dialog.hxx>
41 #include <sfx2/childwin.hxx>
42 #include <sfx2/basedlgs.hxx>
43 #include <svl/svarray.hxx>
44 #define _SVSTDARR_STRINGSDTOR
45 #include <svl/svstdarr.hxx>
46 #include <svtools/svmedit.hxx>
47 #include <svl/srchdefs.hxx>
48 #include "svx/svxdllapi.h"
49 
50 
51 // forward ---------------------------------------------------------------
52 
53 class SvxSearchItem;
54 class MoreButton;
55 class SfxStyleSheetBasePool;
56 class SvxJSearchOptionsPage;
57 class SvxSearchController;
58 
59 struct SearchDlg_Impl;
60 
61 #ifndef NO_SVX_SEARCH
62 
63 // struct SearchAttrItem -------------------------------------------------
64 
65 struct SearchAttrItem
66 {
67 	sal_uInt16 			nSlot;
68 	SfxPoolItem* 	pItem;
69 };
70 
71 // class SearchAttrItemList ----------------------------------------------
72 
73 SV_DECL_VARARR_VISIBILITY(SrchAttrItemList, SearchAttrItem, 8, 8, SVX_DLLPUBLIC)
74 
75 class SVX_DLLPUBLIC SearchAttrItemList : private SrchAttrItemList
76 {
77 public:
78 	SearchAttrItemList() {}
79 	SearchAttrItemList( const SearchAttrItemList& rList );
80 	~SearchAttrItemList();
81 
82 	void            Put( const SfxItemSet& rSet );
83 	SfxItemSet&     Get( SfxItemSet& rSet );
84 	void            Clear();
85 	sal_uInt16          Count() const { return SrchAttrItemList::Count(); }
86 	SearchAttrItem& operator[](sal_uInt16 nPos) const
87 						{ return SrchAttrItemList::operator[]( nPos ); }
88 	SearchAttrItem& GetObject( sal_uInt16 nPos ) const
89 						{ return SrchAttrItemList::GetObject( nPos ); }
90 
91 	// der Pointer auf das Item wird nicht kopiert!!! (also nicht l"oschen)
92 	void Insert( const SearchAttrItem& rItem )
93 		{ SrchAttrItemList::Insert( rItem, SrchAttrItemList::Count() ); }
94 	// l"oscht die Pointer auf die Items
95 	void Remove( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
96 };
97 
98 #ifndef SV_NODIALOG
99 
100 // class SvxSearchDialogWrapper ------------------------------------------
101 
102 #include <sfx2/layout.hxx>
103 #include <sfx2/layout-pre.hxx>
104 
105 class SvxSearchDialog;
106 class SVX_DLLPUBLIC SvxSearchDialogWrapper : public SfxChildWindow
107 {
108     SvxSearchDialog *dialog;
109 public:
110 	SvxSearchDialogWrapper( Window*pParent, sal_uInt16 nId,
111 							SfxBindings* pBindings, SfxChildWinInfo* pInfo );
112 
113     ~SvxSearchDialogWrapper ();
114     SvxSearchDialog *getDialog ();
115 	SFX_DECL_CHILDWINDOW(SvxSearchDialogWrapper);
116 };
117 
118 // class SvxSearchDialog -------------------------------------------------
119 
120 /*
121 	{k:\svx\prototyp\dialog\svx/srchdlg.hxx}
122 
123 	[Beschreibung]
124 	In diesem Modeless-Dialog werden die Attribute einer Suche eingestellt
125 	und damit eine Suche gestartet. Es sind mehrere Sucharten
126 	( Suchen, Alle suchen, Ersetzen, Alle ersetzen ) m"oglich.
127 
128 	[Items]
129 	<SvxSearchItem><SID_ATTR_SEARCH>
130 */
131 
132 class SvxSearchDialog : public SfxModelessDialog
133 {
134 friend class SvxSearchController;
135 friend class SvxSearchDialogWrapper;
136 friend class SvxJSearchOptionsDialog;
137 
138 public:
139 	SvxSearchDialog( Window* pParent, SfxBindings& rBind );
140 	SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind );
141 	~SvxSearchDialog();
142 
143 	virtual sal_Bool    Close();
144 
145 	// Window
146 	virtual void	Activate();
147 
148 	void            GetSearchItems( SfxItemSet& rSet );
149 	void            GetReplaceItems( SfxItemSet& rSet );
150 
151 	const SearchAttrItemList*   GetSearchItemList() const
152 									{ return pSearchList; }
153 	const SearchAttrItemList*   GetReplaceItemList() const
154 									{ return pReplaceList; }
155 
156 	inline sal_Bool 	HasSearchAttributes() const;
157 	inline sal_Bool 	HasReplaceAttributes() const;
158 
159 	PushButton&     GetReplaceBtn() { return aReplaceBtn; }
160 
161 	sal_Int32			GetTransliterationFlags() const;
162 
163 private:
164 	FixedText       aSearchText;
165 	ComboBox        aSearchLB;
166 	ListBox         aSearchTmplLB;
167 	FixedInfo       aSearchAttrText;
168 
169 	FixedText       aReplaceText;
170 	ComboBox        aReplaceLB;
171 	ListBox         aReplaceTmplLB;
172 	FixedInfo       aReplaceAttrText;
173 
174     PushButton      aSearchBtn;
175 	PushButton      aSearchAllBtn;
176     FixedLine       aSearchCmdLine;
177     PushButton      aReplaceBtn;
178 	PushButton      aReplaceAllBtn;
179 
180     FixedLine       aSearchComponentFL;
181     PushButton      aSearchComponent1PB;
182     PushButton      aSearchComponent2PB;
183 
184     CheckBox        aMatchCaseCB;
185     CheckBox        aWordBtn;
186 
187     FixedLine       aButtonsFL;
188     MoreButton*     pMoreBtn;
189     HelpButton      aHelpBtn;
190     CancelButton    aCloseBtn;
191 
192     FixedLine       aOptionsFL;
193     CheckBox        aSelectionBtn;
194     CheckBox        aBackwardsBtn;
195     CheckBox        aRegExpBtn;
196     CheckBox        aSimilarityBox;
197     PushButton      aSimilarityBtn;
198     CheckBox        aLayoutBtn;
199     CheckBox        aNotesBtn;
200     CheckBox        aJapMatchFullHalfWidthCB;
201     CheckBox        aJapOptionsCB;
202     PushButton      aJapOptionsBtn;
203 
204     PushButton      aAttributeBtn;
205 	PushButton      aFormatBtn;
206 	PushButton      aNoFormatBtn;
207 
208     FixedLine       aCalcFL;
209     FixedText       aCalcSearchInFT;
210     ListBox         aCalcSearchInLB;
211     FixedText       aCalcSearchDirFT;
212 	RadioButton     aRowsBtn;
213 	RadioButton     aColumnsBtn;
214     CheckBox        aAllSheetsCB;
215 
216 	SfxBindings&    rBindings;
217 	sal_Bool            bWriter;
218 	sal_Bool            bSearch;
219 	sal_Bool            bFormat;
220 	sal_uInt16          nOptions;
221 	FASTBOOL		bSet;
222 	FASTBOOL		bReadOnly;
223 	FASTBOOL		bConstruct;
224 	sal_uIntPtr			nModifyFlag;
225 	String          aStylesStr;
226 	String			aLayoutStr;
227 	LocalizedString aCalcStr;
228 
229 	SvStringsDtor   aSearchStrings;
230 	SvStringsDtor   aReplaceStrings;
231 
232 	SearchDlg_Impl*			pImpl;
233 	SearchAttrItemList*     pSearchList;
234 	SearchAttrItemList*     pReplaceList;
235 	SvxSearchItem*          pSearchItem;
236 
237 	SvxSearchController*    pSearchController;
238 	SvxSearchController*    pOptionsController;
239 	SvxSearchController*    pFamilyController;
240 	SvxSearchController*    pSearchSetController;
241 	SvxSearchController*    pReplaceSetController;
242 
243 	mutable sal_Int32			nTransliterationFlags;
244 
245 #ifdef _SVX_SRCHDLG_CXX
246 	DECL_LINK( ModifyHdl_Impl, ComboBox* pEdit );
247     DECL_LINK( FlagHdl_Impl, Control* pCtrl );
248 	DECL_LINK( CommandHdl_Impl, Button* pBtn );
249 	DECL_LINK( TemplateHdl_Impl, Button* );
250 	DECL_LINK( FocusHdl_Impl, Control* );
251 	DECL_LINK( LoseFocusHdl_Impl, Control* );
252 	DECL_LINK( FormatHdl_Impl, Button* );
253 	DECL_LINK( NoFormatHdl_Impl, Button* );
254 	DECL_LINK( AttributeHdl_Impl, Button* );
255 	DECL_LINK( TimeoutHdl_Impl, Timer* );
256 
257 	void			Construct_Impl();
258 	void            InitControls_Impl();
259     void            CalculateDelta_Impl();
260 	void            Init_Impl( int bHasItemSet );
261 	void            InitAttrList_Impl( const SfxItemSet* pSSet,
262 									   const SfxItemSet* pRSet );
263 	void            Remember_Impl( const String &rStr,sal_Bool bSearch );
264 	void            PaintAttrText_Impl();
265 	String&         BuildAttrText_Impl( String& rStr, sal_Bool bSrchFlag ) const;
266 
267 	void            TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool );
268 	void            EnableControls_Impl( const sal_uInt16 nFlags );
269 	void            EnableControl_Impl( Control* pCtrl );
270 	void            SetItem_Impl( const SvxSearchItem* pItem );
271 
272 	void			SetModifyFlag_Impl( const Control* pCtrl );
273 	void			SaveToModule_Impl();
274 
275 	void			ApplyTransliterationFlags_Impl( sal_Int32 nSettings );
276 #endif
277 };
278 
279 #include <sfx2/layout-post.hxx>
280 
281 inline sal_Bool SvxSearchDialog::HasSearchAttributes() const
282 {
283 	int bLen = aSearchAttrText.GetText().Len();
284 	return ( aSearchAttrText.IsEnabled() && bLen );
285 }
286 
287 inline sal_Bool SvxSearchDialog::HasReplaceAttributes() const
288 {
289 	int bLen = aReplaceAttrText.GetText().Len();
290 	return ( aReplaceAttrText.IsEnabled() && bLen );
291 }
292 
293 
294 //////////////////////////////////////////////////////////////////////
295 
296 
297 #endif  // SV_NODIALOG
298 #endif  // NO_SVX_SEARCH
299 
300 
301 #endif
302 
303