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_Start,
86 : SL_EndSheet,
87 : SL_NotFound
88 : };
89 :
90 : class SvxSearchDialog;
91 : class SVX_DLLPUBLIC SvxSearchDialogWrapper : public SfxChildWindow
92 : {
93 : VclPtr<SvxSearchDialog> dialog;
94 : public:
95 : SvxSearchDialogWrapper( vcl::Window*pParent, sal_uInt16 nId,
96 : SfxBindings* pBindings, SfxChildWinInfo* pInfo );
97 :
98 : virtual ~SvxSearchDialogWrapper ();
99 0 : SvxSearchDialog *getDialog () { return dialog;}
100 : static void SetSearchLabel(const SearchLabel& rSL);
101 : SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper);
102 : };
103 :
104 : // class SvxSearchDialog -------------------------------------------------
105 : /*
106 : [Description]
107 : In this modeless dialog the attributes for a search are configured
108 : and a search is started from it. Several search types
109 : (search, search all, replace, replace all) are possible.
110 :
111 : [Items]
112 : <SvxSearchItem><SID_ATTR_SEARCH>
113 : */
114 :
115 : class SvxSearchDialog : public SfxModelessDialog
116 : {
117 : friend class SvxSearchController;
118 : friend class SvxSearchDialogWrapper;
119 : friend class SvxJSearchOptionsDialog;
120 :
121 : public:
122 : SvxSearchDialog( vcl::Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind );
123 : virtual ~SvxSearchDialog();
124 : virtual void dispose() SAL_OVERRIDE;
125 :
126 : virtual bool Close() SAL_OVERRIDE;
127 :
128 : // Window
129 : virtual void Activate() SAL_OVERRIDE;
130 :
131 0 : const SearchAttrItemList* GetSearchItemList() const
132 0 : { return pSearchList; }
133 0 : const SearchAttrItemList* GetReplaceItemList() const
134 0 : { return pReplaceList; }
135 :
136 : inline bool HasSearchAttributes() const;
137 : inline bool HasReplaceAttributes() const;
138 :
139 : PushButton& GetReplaceBtn() { return *m_pReplaceBtn; }
140 :
141 : sal_Int32 GetTransliterationFlags() const;
142 :
143 0 : void SetDocWin( vcl::Window* pDocWin ) { mpDocWin = pDocWin; }
144 0 : vcl::Window* GetDocWin() { return mpDocWin; }
145 0 : void SetSrchFlag( bool bSuccess = false ) { mbSuccess = bSuccess; }
146 0 : bool GetSrchFlag() { return mbSuccess; }
147 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
148 : GetComponentInterface( bool bCreate ) SAL_OVERRIDE;
149 :
150 : void SetSaveToModule(bool b);
151 :
152 0 : void SetSearchLabel(const OUString& rStr) { m_pSearchLabel->SetText(rStr); }
153 :
154 : private:
155 : VclPtr<vcl::Window> mpDocWin;
156 : bool mbSuccess;
157 :
158 : VclPtr<VclFrame> m_pSearchFrame;
159 : VclPtr<ComboBox> m_pSearchLB;
160 : VclPtr<ListBox> m_pSearchTmplLB;
161 : VclPtr<FixedText> m_pSearchAttrText;
162 : VclPtr<FixedText> m_pSearchLabel;
163 :
164 : VclPtr<VclFrame> m_pReplaceFrame;
165 : VclPtr<ComboBox> m_pReplaceLB;
166 : VclPtr<ListBox> m_pReplaceTmplLB;
167 : VclPtr<FixedText> m_pReplaceAttrText;
168 :
169 : VclPtr<PushButton> m_pSearchBtn;
170 : VclPtr<PushButton> m_pSearchAllBtn;
171 : VclPtr<PushButton> m_pReplaceBtn;
172 : VclPtr<PushButton> m_pReplaceAllBtn;
173 :
174 : VclPtr<VclFrame> m_pComponentFrame;
175 : VclPtr<PushButton> m_pSearchComponent1PB;
176 : VclPtr<PushButton> m_pSearchComponent2PB;
177 :
178 : VclPtr<CheckBox> m_pMatchCaseCB;
179 : VclPtr<CheckBox> m_pWordBtn;
180 :
181 : VclPtr<PushButton> m_pCloseBtn;
182 : VclPtr<CheckBox> m_pIgnoreDiacritics;
183 : VclPtr<CheckBox> m_pIgnoreKashida;
184 : VclPtr<CheckBox> m_pSelectionBtn;
185 : VclPtr<CheckBox> m_pBackwardsBtn;
186 : VclPtr<CheckBox> m_pRegExpBtn;
187 : VclPtr<CheckBox> m_pSimilarityBox;
188 : VclPtr<PushButton> m_pSimilarityBtn;
189 : VclPtr<CheckBox> m_pLayoutBtn;
190 : VclPtr<CheckBox> m_pNotesBtn;
191 : VclPtr<CheckBox> m_pJapMatchFullHalfWidthCB;
192 : VclPtr<CheckBox> m_pJapOptionsCB;
193 : VclPtr<PushButton> m_pJapOptionsBtn;
194 :
195 : VclPtr<PushButton> m_pAttributeBtn;
196 : VclPtr<PushButton> m_pFormatBtn;
197 : VclPtr<PushButton> m_pNoFormatBtn;
198 :
199 : VclPtr<VclContainer> m_pCalcGrid;
200 : VclPtr<FixedText> m_pCalcSearchInFT;
201 : VclPtr<ListBox> m_pCalcSearchInLB;
202 : VclPtr<FixedText> m_pCalcSearchDirFT;
203 : VclPtr<RadioButton> m_pRowsBtn;
204 : VclPtr<RadioButton> m_pColumnsBtn;
205 : VclPtr<CheckBox> m_pAllSheetsCB;
206 :
207 : SfxBindings& rBindings;
208 : bool bWriter;
209 : bool bSearch;
210 : bool bFormat;
211 : SearchOptionFlags nOptions;
212 : bool bSet;
213 : bool bReadOnly;
214 : bool bConstruct;
215 : sal_uIntPtr nModifyFlag;
216 : OUString aStylesStr;
217 : OUString aLayoutStr;
218 : OUString aLayoutWriterStr;
219 : OUString aLayoutCalcStr;
220 : OUString aCalcStr;
221 :
222 : std::vector<OUString> aSearchStrings;
223 : std::vector<OUString> aReplaceStrings;
224 :
225 : SearchDlg_Impl* pImpl;
226 : SearchAttrItemList* pSearchList;
227 : SearchAttrItemList* pReplaceList;
228 : SvxSearchItem* pSearchItem;
229 :
230 : SvxSearchController* pSearchController;
231 : SvxSearchController* pOptionsController;
232 : SvxSearchController* pFamilyController;
233 : SvxSearchController* pSearchSetController;
234 : SvxSearchController* pReplaceSetController;
235 :
236 : mutable sal_Int32 nTransliterationFlags;
237 :
238 : DECL_LINK( ModifyHdl_Impl, ComboBox* pEdit );
239 : DECL_LINK( FlagHdl_Impl, Control* pCtrl );
240 : DECL_LINK( CommandHdl_Impl, Button* pBtn );
241 : DECL_LINK(TemplateHdl_Impl, void *);
242 : DECL_LINK( FocusHdl_Impl, Control* );
243 : DECL_LINK(LoseFocusHdl_Impl, void *);
244 : DECL_LINK(FormatHdl_Impl, void *);
245 : DECL_LINK(NoFormatHdl_Impl, void *);
246 : DECL_LINK(AttributeHdl_Impl, void *);
247 : DECL_LINK_TYPED( TimeoutHdl_Impl, Timer*, void );
248 :
249 : void Construct_Impl();
250 : void InitControls_Impl();
251 : void ShowOptionalControls_Impl();
252 : void Init_Impl( bool bHasItemSet );
253 : void InitAttrList_Impl( const SfxItemSet* pSSet,
254 : const SfxItemSet* pRSet );
255 : void Remember_Impl( const OUString &rStr, bool bSearch );
256 : void PaintAttrText_Impl();
257 : OUString& BuildAttrText_Impl( OUString& rStr, bool bSrchFlag ) const;
258 :
259 : void TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool );
260 : void EnableControls_Impl( const SearchOptionFlags nFlags );
261 : void EnableControl_Impl( Control* pCtrl );
262 : void SetItem_Impl( const SvxSearchItem* pItem );
263 :
264 : void SetModifyFlag_Impl( const Control* pCtrl );
265 : void SaveToModule_Impl();
266 :
267 : void ApplyTransliterationFlags_Impl( sal_Int32 nSettings );
268 : };
269 :
270 : inline bool SvxSearchDialog::HasSearchAttributes() const
271 : {
272 : bool bLen = !m_pSearchAttrText->GetText().isEmpty();
273 : return ( m_pSearchAttrText->IsEnabled() && bLen );
274 : }
275 :
276 : inline bool SvxSearchDialog::HasReplaceAttributes() const
277 : {
278 : bool bLen = !m_pReplaceAttrText->GetText().isEmpty();
279 : return ( m_pReplaceAttrText->IsEnabled() && bLen );
280 : }
281 :
282 : #endif
283 :
284 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|