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