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 INCLUDED_SVX_SRCHDLG_HXX
20 : #define INCLUDED_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 SfxStyleSheetBasePool;
40 : class SvxJSearchOptionsPage;
41 : class SvxSearchController;
42 :
43 : struct SearchDlg_Impl;
44 :
45 : struct SearchAttrItem
46 : {
47 : sal_uInt16 nSlot;
48 : SfxPoolItem* pItem;
49 : };
50 :
51 : // class SearchAttrItemList ----------------------------------------------
52 :
53 : typedef std::vector<SearchAttrItem> SrchAttrItemList;
54 :
55 : class SVX_DLLPUBLIC SearchAttrItemList : private SrchAttrItemList
56 : {
57 : public:
58 0 : SearchAttrItemList() {}
59 : SearchAttrItemList( const SearchAttrItemList& rList );
60 : ~SearchAttrItemList();
61 :
62 : void Put( const SfxItemSet& rSet );
63 : SfxItemSet& Get( SfxItemSet& rSet );
64 : void Clear();
65 0 : sal_uInt16 Count() const { return SrchAttrItemList::size(); }
66 0 : SearchAttrItem& operator[](sal_uInt16 nPos)
67 0 : { return SrchAttrItemList::operator[]( nPos ); }
68 0 : SearchAttrItem& GetObject( sal_uInt16 nPos )
69 0 : { return SrchAttrItemList::operator[]( nPos ); }
70 :
71 : // the pointer to the item is not being copied, so don't delete
72 0 : void Insert( const SearchAttrItem& rItem )
73 0 : { SrchAttrItemList::push_back( rItem ); }
74 : // deletes the pointer to the items
75 : void Remove(size_t nPos, size_t nLen = 1);
76 : };
77 :
78 :
79 : // class SvxSearchDialogWrapper ------------------------------------------
80 :
81 : enum SearchLabel
82 : {
83 : SL_Empty,
84 : SL_End,
85 : SL_EndSheet,
86 : SL_NotFound
87 : };
88 :
89 : class SvxSearchDialog;
90 : class SVX_DLLPUBLIC SvxSearchDialogWrapper : public SfxChildWindow
91 : {
92 : SvxSearchDialog *dialog;
93 : public:
94 : SvxSearchDialogWrapper( Window*pParent, sal_uInt16 nId,
95 : SfxBindings* pBindings, SfxChildWinInfo* pInfo );
96 :
97 : virtual ~SvxSearchDialogWrapper ();
98 : SvxSearchDialog *getDialog ();
99 : static void SetSearchLabel(const SearchLabel& rSL);
100 : SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper);
101 : };
102 :
103 : // class SvxSearchDialog -------------------------------------------------
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 : virtual ~SvxSearchDialog();
123 :
124 : virtual bool Close() SAL_OVERRIDE;
125 :
126 : // Window
127 : virtual void Activate() SAL_OVERRIDE;
128 :
129 0 : const SearchAttrItemList* GetSearchItemList() const
130 0 : { return pSearchList; }
131 0 : const SearchAttrItemList* GetReplaceItemList() const
132 0 : { return pReplaceList; }
133 :
134 : inline bool HasSearchAttributes() const;
135 : inline bool HasReplaceAttributes() const;
136 :
137 : PushButton& GetReplaceBtn() { return *m_pReplaceBtn; }
138 :
139 : sal_Int32 GetTransliterationFlags() const;
140 :
141 0 : void SetDocWin( Window* pDocWin ) { mpDocWin = pDocWin; }
142 0 : Window* GetDocWin() { return mpDocWin; }
143 0 : void SetSrchFlag( bool bSuccess = false ) { mbSuccess = bSuccess; }
144 0 : bool GetSrchFlag() { return mbSuccess; }
145 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
146 : GetComponentInterface( sal_Bool bCreate ) SAL_OVERRIDE;
147 :
148 : void SetSaveToModule(bool b);
149 :
150 0 : void SetSearchLabel(const OUString& rStr) { m_pSearchLabel->SetText(rStr); }
151 :
152 : private:
153 : Window* mpDocWin;
154 : bool mbSuccess;
155 :
156 : VclFrame* m_pSearchFrame;
157 : ComboBox* m_pSearchLB;
158 : ListBox* m_pSearchTmplLB;
159 : FixedText* m_pSearchAttrText;
160 : FixedText* m_pSearchLabel;
161 :
162 : VclFrame* m_pReplaceFrame;
163 : ComboBox* m_pReplaceLB;
164 : ListBox* m_pReplaceTmplLB;
165 : FixedText* m_pReplaceAttrText;
166 :
167 : PushButton* m_pSearchBtn;
168 : PushButton* m_pSearchAllBtn;
169 : PushButton* m_pReplaceBtn;
170 : PushButton* m_pReplaceAllBtn;
171 :
172 : VclFrame* m_pComponentFrame;
173 : PushButton* m_pSearchComponent1PB;
174 : PushButton* m_pSearchComponent2PB;
175 :
176 : CheckBox* m_pMatchCaseCB;
177 : CheckBox* m_pWordBtn;
178 :
179 : PushButton* m_pCloseBtn;
180 : CheckBox* m_pIgnoreDiacritics;
181 : CheckBox* m_pIgnoreKashida;
182 : CheckBox* m_pSelectionBtn;
183 : CheckBox* m_pBackwardsBtn;
184 : CheckBox* m_pRegExpBtn;
185 : CheckBox* m_pSimilarityBox;
186 : PushButton* m_pSimilarityBtn;
187 : CheckBox* m_pLayoutBtn;
188 : CheckBox* m_pNotesBtn;
189 : CheckBox* m_pJapMatchFullHalfWidthCB;
190 : CheckBox* m_pJapOptionsCB;
191 : PushButton* m_pJapOptionsBtn;
192 :
193 : PushButton* m_pAttributeBtn;
194 : PushButton* m_pFormatBtn;
195 : PushButton* m_pNoFormatBtn;
196 :
197 : VclContainer* m_pCalcGrid;
198 : FixedText* m_pCalcSearchInFT;
199 : ListBox* m_pCalcSearchInLB;
200 : FixedText* m_pCalcSearchDirFT;
201 : RadioButton* m_pRowsBtn;
202 : RadioButton* m_pColumnsBtn;
203 : CheckBox* m_pAllSheetsCB;
204 :
205 : SfxBindings& rBindings;
206 : bool bWriter;
207 : bool bSearch;
208 : bool bFormat;
209 : sal_uInt16 nOptions;
210 : bool bSet;
211 : bool bReadOnly;
212 : bool bConstruct;
213 : sal_uIntPtr nModifyFlag;
214 : OUString aStylesStr;
215 : OUString aLayoutStr;
216 : OUString aLayoutWriterStr;
217 : OUString aLayoutCalcStr;
218 : OUString aCalcStr;
219 :
220 : std::vector<OUString> aSearchStrings;
221 : std::vector<OUString> aReplaceStrings;
222 :
223 : SearchDlg_Impl* pImpl;
224 : SearchAttrItemList* pSearchList;
225 : SearchAttrItemList* pReplaceList;
226 : SvxSearchItem* pSearchItem;
227 :
228 : SvxSearchController* pSearchController;
229 : SvxSearchController* pOptionsController;
230 : SvxSearchController* pFamilyController;
231 : SvxSearchController* pSearchSetController;
232 : SvxSearchController* pReplaceSetController;
233 :
234 : mutable sal_Int32 nTransliterationFlags;
235 :
236 : DECL_LINK( ModifyHdl_Impl, ComboBox* pEdit );
237 : DECL_LINK( FlagHdl_Impl, Control* pCtrl );
238 : DECL_LINK( CommandHdl_Impl, Button* pBtn );
239 : DECL_LINK(TemplateHdl_Impl, void *);
240 : DECL_LINK( FocusHdl_Impl, Control* );
241 : DECL_LINK(LoseFocusHdl_Impl, void *);
242 : DECL_LINK(FormatHdl_Impl, void *);
243 : DECL_LINK(NoFormatHdl_Impl, void *);
244 : DECL_LINK(AttributeHdl_Impl, void *);
245 : DECL_LINK( TimeoutHdl_Impl, Timer* );
246 :
247 : void Construct_Impl();
248 : void InitControls_Impl();
249 : void ShowOptionalControls_Impl();
250 : void Init_Impl( bool bHasItemSet );
251 : void InitAttrList_Impl( const SfxItemSet* pSSet,
252 : const SfxItemSet* pRSet );
253 : void Remember_Impl( const OUString &rStr, bool bSearch );
254 : void PaintAttrText_Impl();
255 : OUString& BuildAttrText_Impl( OUString& rStr, bool bSrchFlag ) const;
256 :
257 : void TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool );
258 : void EnableControls_Impl( const sal_uInt16 nFlags );
259 : void EnableControl_Impl( Control* pCtrl );
260 : void SetItem_Impl( const SvxSearchItem* pItem );
261 :
262 : void SetModifyFlag_Impl( const Control* pCtrl );
263 : void SaveToModule_Impl();
264 :
265 : void ApplyTransliterationFlags_Impl( sal_Int32 nSettings );
266 : };
267 :
268 : inline bool SvxSearchDialog::HasSearchAttributes() const
269 : {
270 : bool bLen = !m_pSearchAttrText->GetText().isEmpty();
271 : return ( m_pSearchAttrText->IsEnabled() && bLen );
272 : }
273 :
274 : inline bool SvxSearchDialog::HasReplaceAttributes() const
275 : {
276 : bool bLen = !m_pReplaceAttrText->GetText().isEmpty();
277 : return ( m_pReplaceAttrText->IsEnabled() && bLen );
278 : }
279 :
280 : #endif
281 :
282 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|