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_SRCHDLG_HXX
20 : #define _SVX_SRCHDLG_HXX
21 :
22 : #include <svtools/stdctrl.hxx>
23 : #include <vcl/combobox.hxx>
24 : #include <vcl/edit.hxx>
25 : #include <vcl/button.hxx>
26 : #include <vcl/layout.hxx>
27 : #include <vcl/lstbox.hxx>
28 : #include <vcl/group.hxx>
29 : #include <vcl/fixed.hxx>
30 : #include <vcl/dialog.hxx>
31 : #include <sfx2/childwin.hxx>
32 : #include <sfx2/basedlgs.hxx>
33 : #include <svtools/svmedit.hxx>
34 : #include <svl/srchdefs.hxx>
35 : #include "svx/svxdllapi.h"
36 : #include <vector>
37 :
38 : class SvxSearchItem;
39 : class MoreButton;
40 : class SfxStyleSheetBasePool;
41 : class SvxJSearchOptionsPage;
42 : class SvxSearchController;
43 :
44 : struct SearchDlg_Impl;
45 :
46 : #ifndef NO_SVX_SEARCH
47 :
48 : // struct SearchAttrItem -------------------------------------------------
49 :
50 : struct SearchAttrItem
51 : {
52 : sal_uInt16 nSlot;
53 : SfxPoolItem* pItem;
54 : };
55 :
56 : // class SearchAttrItemList ----------------------------------------------
57 :
58 : typedef std::vector<SearchAttrItem> SrchAttrItemList;
59 :
60 : class SVX_DLLPUBLIC SearchAttrItemList : private SrchAttrItemList
61 : {
62 : public:
63 0 : SearchAttrItemList() {}
64 : SearchAttrItemList( const SearchAttrItemList& rList );
65 : ~SearchAttrItemList();
66 :
67 : void Put( const SfxItemSet& rSet );
68 : SfxItemSet& Get( SfxItemSet& rSet );
69 : void Clear();
70 0 : sal_uInt16 Count() const { return SrchAttrItemList::size(); }
71 0 : SearchAttrItem& operator[](sal_uInt16 nPos)
72 0 : { return SrchAttrItemList::operator[]( nPos ); }
73 0 : SearchAttrItem& GetObject( sal_uInt16 nPos )
74 0 : { return SrchAttrItemList::operator[]( nPos ); }
75 :
76 : // the pointer to the item is not being copied, so don't delete
77 0 : void Insert( const SearchAttrItem& rItem )
78 0 : { SrchAttrItemList::push_back( rItem ); }
79 : // deletes the pointer to the items
80 : void Remove(size_t nPos, size_t nLen = 1);
81 : };
82 :
83 : #ifndef SV_NODIALOG
84 :
85 : // class SvxSearchDialogWrapper ------------------------------------------
86 :
87 : class SvxSearchDialog;
88 : class SVX_DLLPUBLIC SvxSearchDialogWrapper : public SfxChildWindow
89 : {
90 : SvxSearchDialog *dialog;
91 : public:
92 : SvxSearchDialogWrapper( Window*pParent, sal_uInt16 nId,
93 : SfxBindings* pBindings, SfxChildWinInfo* pInfo );
94 :
95 : ~SvxSearchDialogWrapper ();
96 : SvxSearchDialog *getDialog ();
97 : SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper);
98 : };
99 :
100 : // class SvxSearchDialog -------------------------------------------------
101 :
102 : /*
103 : {k:\svx\prototyp\dialog\svx/srchdlg.hxx}
104 :
105 : [Description]
106 : In this modeless dialog the attributes for a search are configured
107 : and a search is started from it. Several search types
108 : (search, search all, replace, replace all) are possible.
109 :
110 : [Items]
111 : <SvxSearchItem><SID_ATTR_SEARCH>
112 : */
113 :
114 : class SvxSearchDialog : public SfxModelessDialog
115 : {
116 : friend class SvxSearchController;
117 : friend class SvxSearchDialogWrapper;
118 : friend class SvxJSearchOptionsDialog;
119 :
120 : public:
121 : SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind );
122 : ~SvxSearchDialog();
123 :
124 : virtual sal_Bool Close();
125 :
126 : // Window
127 : virtual void Activate();
128 :
129 0 : const SearchAttrItemList* GetSearchItemList() const
130 0 : { return pSearchList; }
131 0 : const SearchAttrItemList* GetReplaceItemList() const
132 0 : { return pReplaceList; }
133 :
134 : inline sal_Bool HasSearchAttributes() const;
135 : inline sal_Bool HasReplaceAttributes() const;
136 :
137 : PushButton& GetReplaceBtn() { return *m_pReplaceBtn; }
138 :
139 : sal_Int32 GetTransliterationFlags() const;
140 :
141 : void SetSaveToModule(bool b);
142 :
143 : private:
144 : VclFrame* m_pSearchFrame;
145 : ComboBox* m_pSearchLB;
146 : ListBox* m_pSearchTmplLB;
147 : FixedText* m_pSearchAttrText;
148 :
149 : VclFrame* m_pReplaceFrame;
150 : ComboBox* m_pReplaceLB;
151 : ListBox* m_pReplaceTmplLB;
152 : FixedText* m_pReplaceAttrText;
153 :
154 : PushButton* m_pSearchBtn;
155 : PushButton* m_pSearchAllBtn;
156 : PushButton* m_pReplaceBtn;
157 : PushButton* m_pReplaceAllBtn;
158 :
159 : VclFrame* m_pComponentFrame;
160 : PushButton* m_pSearchComponent1PB;
161 : PushButton* m_pSearchComponent2PB;
162 :
163 : CheckBox* m_pMatchCaseCB;
164 : CheckBox* m_pWordBtn;
165 :
166 : PushButton* m_pCloseBtn;
167 : CheckBox* m_pIgnoreDiacritics;
168 : CheckBox* m_pSelectionBtn;
169 : CheckBox* m_pBackwardsBtn;
170 : CheckBox* m_pRegExpBtn;
171 : CheckBox* m_pSimilarityBox;
172 : PushButton* m_pSimilarityBtn;
173 : CheckBox* m_pLayoutBtn;
174 : CheckBox* m_pNotesBtn;
175 : CheckBox* m_pJapMatchFullHalfWidthCB;
176 : CheckBox* m_pJapOptionsCB;
177 : PushButton* m_pJapOptionsBtn;
178 :
179 : PushButton* m_pAttributeBtn;
180 : PushButton* m_pFormatBtn;
181 : PushButton* m_pNoFormatBtn;
182 :
183 : VclContainer* m_pCalcGrid;
184 : FixedText* m_pCalcSearchInFT;
185 : ListBox* m_pCalcSearchInLB;
186 : FixedText* m_pCalcSearchDirFT;
187 : RadioButton* m_pRowsBtn;
188 : RadioButton* m_pColumnsBtn;
189 : CheckBox* m_pAllSheetsCB;
190 :
191 : SfxBindings& rBindings;
192 : sal_Bool bWriter;
193 : sal_Bool bSearch;
194 : sal_Bool bFormat;
195 : sal_uInt16 nOptions;
196 : bool bSet;
197 : bool bReadOnly;
198 : bool bConstruct;
199 : sal_uIntPtr nModifyFlag;
200 : String aStylesStr;
201 : String aLayoutStr;
202 : String aLayoutWriterStr;
203 : String aLayoutCalcStr;
204 : String aCalcStr;
205 :
206 : std::vector<OUString> aSearchStrings;
207 : std::vector<OUString> aReplaceStrings;
208 :
209 : SearchDlg_Impl* pImpl;
210 : SearchAttrItemList* pSearchList;
211 : SearchAttrItemList* pReplaceList;
212 : SvxSearchItem* pSearchItem;
213 :
214 : SvxSearchController* pSearchController;
215 : SvxSearchController* pOptionsController;
216 : SvxSearchController* pFamilyController;
217 : SvxSearchController* pSearchSetController;
218 : SvxSearchController* pReplaceSetController;
219 :
220 : mutable sal_Int32 nTransliterationFlags;
221 :
222 : DECL_LINK( ModifyHdl_Impl, ComboBox* pEdit );
223 : DECL_LINK( FlagHdl_Impl, Control* pCtrl );
224 : DECL_LINK( CommandHdl_Impl, Button* pBtn );
225 : DECL_LINK(TemplateHdl_Impl, void *);
226 : DECL_LINK( FocusHdl_Impl, Control* );
227 : DECL_LINK(LoseFocusHdl_Impl, void *);
228 : DECL_LINK(FormatHdl_Impl, void *);
229 : DECL_LINK(NoFormatHdl_Impl, void *);
230 : DECL_LINK(AttributeHdl_Impl, void *);
231 : DECL_LINK( TimeoutHdl_Impl, Timer* );
232 :
233 : void Construct_Impl();
234 : void InitControls_Impl();
235 : void ShowOptionalControls_Impl();
236 : void Init_Impl( int bHasItemSet );
237 : void InitAttrList_Impl( const SfxItemSet* pSSet,
238 : const SfxItemSet* pRSet );
239 : void Remember_Impl( const String &rStr,sal_Bool bSearch );
240 : void PaintAttrText_Impl();
241 : String& BuildAttrText_Impl( String& rStr, sal_Bool bSrchFlag ) const;
242 :
243 : void TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool );
244 : void EnableControls_Impl( const sal_uInt16 nFlags );
245 : void EnableControl_Impl( Control* pCtrl );
246 : void SetItem_Impl( const SvxSearchItem* pItem );
247 :
248 : void SetModifyFlag_Impl( const Control* pCtrl );
249 : void SaveToModule_Impl();
250 :
251 : void ApplyTransliterationFlags_Impl( sal_Int32 nSettings );
252 : };
253 :
254 : inline sal_Bool SvxSearchDialog::HasSearchAttributes() const
255 : {
256 : sal_Bool bLen = !m_pSearchAttrText->GetText().isEmpty();
257 : return ( m_pSearchAttrText->IsEnabled() && bLen );
258 : }
259 :
260 : inline sal_Bool SvxSearchDialog::HasReplaceAttributes() const
261 : {
262 : sal_Bool bLen = !m_pReplaceAttrText->GetText().isEmpty();
263 : return ( m_pReplaceAttrText->IsEnabled() && bLen );
264 : }
265 :
266 :
267 : //////////////////////////////////////////////////////////////////////
268 :
269 :
270 : #endif // SV_NODIALOG
271 : #endif // NO_SVX_SEARCH
272 :
273 :
274 : #endif
275 :
276 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|