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:
SearchAttrItemList()74 SearchAttrItemList() {}
75 SearchAttrItemList( const SearchAttrItemList& rList );
76 ~SearchAttrItemList();
77
78 void Put( const SfxItemSet& rSet );
79 SfxItemSet& Get( SfxItemSet& rSet );
80 void Clear();
Count() const81 sal_uInt16 Count() const { return SrchAttrItemList::Count(); }
operator [](sal_uInt16 nPos) const82 SearchAttrItem& operator[](sal_uInt16 nPos) const
83 { return SrchAttrItemList::operator[]( nPos ); }
GetObject(sal_uInt16 nPos) const84 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)
Insert(const SearchAttrItem & rItem)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
GetSearchItemList() const147 const SearchAttrItemList* GetSearchItemList() const
148 { return pSearchList; }
GetReplaceItemList() const149 const SearchAttrItemList* GetReplaceItemList() const
150 { return pReplaceList; }
151
152 inline sal_Bool HasSearchAttributes() const;
153 inline sal_Bool HasReplaceAttributes() const;
154
GetReplaceBtn()155 PushButton& GetReplaceBtn() { return aReplaceBtn; }
156
157 sal_Int32 GetTransliterationFlags() const;
SetDocWin(Window * pDocWin)158 void SetDocWin( Window* pDocWin ) { mpDocWin = pDocWin; }
GetDocWin()159 Window* GetDocWin() { return mpDocWin; }
SetSrchFlag(sal_Bool bSuccess=sal_False)160 void SetSrchFlag( sal_Bool bSuccess = sal_False ) { mbSuccess = bSuccess; }
GetSrchFlag()161 sal_Bool GetSrchFlag() { return mbSuccess; }
162 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
163 GetComponentInterface( sal_Bool bCreate );
164 private:
165 Window* mpDocWin;
166 sal_Bool mbSuccess;
167 FixedText aSearchText;
168 ComboBox aSearchLB;
169 ListBox aSearchTmplLB;
170 FixedInfo aSearchAttrText;
171
172 FixedText aReplaceText;
173 ComboBox aReplaceLB;
174 ListBox aReplaceTmplLB;
175 FixedInfo aReplaceAttrText;
176
177 PushButton aSearchBtn;
178 PushButton aSearchAllBtn;
179 FixedLine aSearchCmdLine;
180 PushButton aReplaceBtn;
181 PushButton aReplaceAllBtn;
182
183 FixedLine aSearchComponentFL;
184 PushButton aSearchComponent1PB;
185 PushButton aSearchComponent2PB;
186
187 CheckBox aMatchCaseCB;
188 CheckBox aWordBtn;
189
190 FixedLine aButtonsFL;
191 MoreButton* pMoreBtn;
192 HelpButton aHelpBtn;
193 CancelButton aCloseBtn;
194
195 FixedLine aOptionsFL;
196 CheckBox aSelectionBtn;
197 CheckBox aBackwardsBtn;
198 CheckBox aRegExpBtn;
199 CheckBox aSimilarityBox;
200 PushButton aSimilarityBtn;
201 CheckBox aLayoutBtn;
202 CheckBox aNotesBtn;
203 CheckBox aJapMatchFullHalfWidthCB;
204 CheckBox aJapOptionsCB;
205 PushButton aJapOptionsBtn;
206
207 PushButton aAttributeBtn;
208 PushButton aFormatBtn;
209 PushButton aNoFormatBtn;
210
211 FixedLine aCalcFL;
212 FixedText aCalcSearchInFT;
213 ListBox aCalcSearchInLB;
214 FixedText aCalcSearchDirFT;
215 RadioButton aRowsBtn;
216 RadioButton aColumnsBtn;
217 CheckBox aAllSheetsCB;
218
219 SfxBindings& rBindings;
220 sal_Bool bWriter;
221 sal_Bool bSearch;
222 sal_Bool bFormat;
223 sal_uInt16 nOptions;
224 FASTBOOL bSet;
225 FASTBOOL bReadOnly;
226 FASTBOOL bConstruct;
227 sal_uIntPtr nModifyFlag;
228 String aStylesStr;
229 String aLayoutStr;
230 LocalizedString aCalcStr;
231
232 SvStringsDtor aSearchStrings;
233 SvStringsDtor aReplaceStrings;
234
235 SearchDlg_Impl* pImpl;
236 SearchAttrItemList* pSearchList;
237 SearchAttrItemList* pReplaceList;
238 SvxSearchItem* pSearchItem;
239
240 SvxSearchController* pSearchController;
241 SvxSearchController* pOptionsController;
242 SvxSearchController* pFamilyController;
243 SvxSearchController* pSearchSetController;
244 SvxSearchController* pReplaceSetController;
245
246 mutable sal_Int32 nTransliterationFlags;
247
248 #ifdef _SVX_SRCHDLG_CXX
249 DECL_LINK( ModifyHdl_Impl, ComboBox* pEdit );
250 DECL_LINK( FlagHdl_Impl, Control* pCtrl );
251 DECL_LINK( CommandHdl_Impl, Button* pBtn );
252 DECL_LINK( TemplateHdl_Impl, Button* );
253 DECL_LINK( FocusHdl_Impl, Control* );
254 DECL_LINK( LoseFocusHdl_Impl, Control* );
255 DECL_LINK( FormatHdl_Impl, Button* );
256 DECL_LINK( NoFormatHdl_Impl, Button* );
257 DECL_LINK( AttributeHdl_Impl, Button* );
258 DECL_LINK( TimeoutHdl_Impl, Timer* );
259
260 void Construct_Impl();
261 void InitControls_Impl();
262 void CalculateDelta_Impl();
263 void Init_Impl( int bHasItemSet );
264 void InitAttrList_Impl( const SfxItemSet* pSSet,
265 const SfxItemSet* pRSet );
266 void Remember_Impl( const String &rStr,sal_Bool bSearch );
267 void PaintAttrText_Impl();
268 String& BuildAttrText_Impl( String& rStr, sal_Bool bSrchFlag ) const;
269
270 void TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool );
271 void EnableControls_Impl( const sal_uInt16 nFlags );
272 void EnableControl_Impl( Control* pCtrl );
273 void SetItem_Impl( const SvxSearchItem* pItem );
274
275 void SetModifyFlag_Impl( const Control* pCtrl );
276 void SaveToModule_Impl();
277
278 void ApplyTransliterationFlags_Impl( sal_Int32 nSettings );
279 #endif
280 };
281
282 #include <sfx2/layout-post.hxx>
283
HasSearchAttributes() const284 inline sal_Bool SvxSearchDialog::HasSearchAttributes() const
285 {
286 int bLen = aSearchAttrText.GetText().Len();
287 return ( aSearchAttrText.IsEnabled() && bLen );
288 }
289
HasReplaceAttributes() const290 inline sal_Bool SvxSearchDialog::HasReplaceAttributes() const
291 {
292 int bLen = aReplaceAttrText.GetText().Len();
293 return ( aReplaceAttrText.IsEnabled() && bLen );
294 }
295
296
297 //////////////////////////////////////////////////////////////////////
298
299
300 #endif // SV_NODIALOG
301 #endif // NO_SVX_SEARCH
302
303
304 #endif
305
306