1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_SRCHDLG_HXX
20 #define INCLUDED_SVX_SRCHDLG_HXX
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>
39 class SfxStyleSheetBasePool
;
40 class SvxJSearchOptionsPage
;
41 class SvxSearchController
;
43 struct SearchDlg_Impl
;
51 // class SearchAttrItemList ----------------------------------------------
53 typedef std::vector
<SearchAttrItem
> SrchAttrItemList
;
55 class SVX_DLLPUBLIC SearchAttrItemList
: private SrchAttrItemList
58 SearchAttrItemList() {}
59 SearchAttrItemList( const SearchAttrItemList
& rList
);
60 ~SearchAttrItemList();
62 void Put( const SfxItemSet
& rSet
);
63 SfxItemSet
& Get( SfxItemSet
& rSet
);
65 sal_uInt16
Count() const { return SrchAttrItemList::size(); }
66 SearchAttrItem
& operator[](sal_uInt16 nPos
)
67 { return SrchAttrItemList::operator[]( nPos
); }
68 SearchAttrItem
& GetObject( sal_uInt16 nPos
)
69 { return SrchAttrItemList::operator[]( nPos
); }
71 // the pointer to the item is not being copied, so don't delete
72 void Insert( const SearchAttrItem
& rItem
)
73 { SrchAttrItemList::push_back( rItem
); }
74 // deletes the pointer to the items
75 void Remove(size_t nPos
, size_t nLen
= 1);
79 // class SvxSearchDialogWrapper ------------------------------------------
90 class SvxSearchDialog
;
91 class SVX_DLLPUBLIC SvxSearchDialogWrapper
: public SfxChildWindow
93 VclPtr
<SvxSearchDialog
> dialog
;
95 SvxSearchDialogWrapper( vcl::Window
*pParent
, sal_uInt16 nId
,
96 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
);
98 virtual ~SvxSearchDialogWrapper ();
99 SvxSearchDialog
*getDialog () { return dialog
;}
100 static void SetSearchLabel(const SearchLabel
& rSL
);
101 SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper
);
104 // class SvxSearchDialog -------------------------------------------------
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.
112 <SvxSearchItem><SID_ATTR_SEARCH>
115 class SvxSearchDialog
: public SfxModelessDialog
117 friend class SvxSearchController
;
118 friend class SvxSearchDialogWrapper
;
119 friend class SvxJSearchOptionsDialog
;
122 SvxSearchDialog( vcl::Window
* pParent
, SfxChildWindow
* pChildWin
, SfxBindings
& rBind
);
123 virtual ~SvxSearchDialog();
124 virtual void dispose() SAL_OVERRIDE
;
126 virtual bool Close() SAL_OVERRIDE
;
129 virtual void Activate() SAL_OVERRIDE
;
131 const SearchAttrItemList
* GetSearchItemList() const
132 { return pSearchList
; }
133 const SearchAttrItemList
* GetReplaceItemList() const
134 { return pReplaceList
; }
136 inline bool HasSearchAttributes() const;
137 inline bool HasReplaceAttributes() const;
139 PushButton
& GetReplaceBtn() { return *m_pReplaceBtn
; }
141 sal_Int32
GetTransliterationFlags() const;
143 void SetDocWin( vcl::Window
* pDocWin
) { mpDocWin
= pDocWin
; }
144 vcl::Window
* GetDocWin() { return mpDocWin
; }
145 void SetSrchFlag( bool bSuccess
= false ) { mbSuccess
= bSuccess
; }
146 bool GetSrchFlag() { return mbSuccess
; }
147 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>
148 GetComponentInterface( bool bCreate
) SAL_OVERRIDE
;
150 void SetSaveToModule(bool b
);
152 void SetSearchLabel(const OUString
& rStr
) { m_pSearchLabel
->SetText(rStr
); }
155 VclPtr
<vcl::Window
> mpDocWin
;
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
;
164 VclPtr
<VclFrame
> m_pReplaceFrame
;
165 VclPtr
<ComboBox
> m_pReplaceLB
;
166 VclPtr
<ListBox
> m_pReplaceTmplLB
;
167 VclPtr
<FixedText
> m_pReplaceAttrText
;
169 VclPtr
<PushButton
> m_pSearchBtn
;
170 VclPtr
<PushButton
> m_pSearchAllBtn
;
171 VclPtr
<PushButton
> m_pReplaceBtn
;
172 VclPtr
<PushButton
> m_pReplaceAllBtn
;
174 VclPtr
<VclFrame
> m_pComponentFrame
;
175 VclPtr
<PushButton
> m_pSearchComponent1PB
;
176 VclPtr
<PushButton
> m_pSearchComponent2PB
;
178 VclPtr
<CheckBox
> m_pMatchCaseCB
;
179 VclPtr
<CheckBox
> m_pWordBtn
;
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
;
195 VclPtr
<PushButton
> m_pAttributeBtn
;
196 VclPtr
<PushButton
> m_pFormatBtn
;
197 VclPtr
<PushButton
> m_pNoFormatBtn
;
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
;
207 SfxBindings
& rBindings
;
211 SearchOptionFlags nOptions
;
215 sal_uIntPtr nModifyFlag
;
218 OUString aLayoutWriterStr
;
219 OUString aLayoutCalcStr
;
222 std::vector
<OUString
> aSearchStrings
;
223 std::vector
<OUString
> aReplaceStrings
;
225 SearchDlg_Impl
* pImpl
;
226 SearchAttrItemList
* pSearchList
;
227 SearchAttrItemList
* pReplaceList
;
228 SvxSearchItem
* pSearchItem
;
230 SvxSearchController
* pSearchController
;
231 SvxSearchController
* pOptionsController
;
232 SvxSearchController
* pFamilyController
;
233 SvxSearchController
* pSearchSetController
;
234 SvxSearchController
* pReplaceSetController
;
236 mutable sal_Int32 nTransliterationFlags
;
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 );
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;
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
);
264 void SetModifyFlag_Impl( const Control
* pCtrl
);
265 void SaveToModule_Impl();
267 void ApplyTransliterationFlags_Impl( sal_Int32 nSettings
);
270 inline bool SvxSearchDialog::HasSearchAttributes() const
272 bool bLen
= !m_pSearchAttrText
->GetText().isEmpty();
273 return ( m_pSearchAttrText
->IsEnabled() && bLen
);
276 inline bool SvxSearchDialog::HasReplaceAttributes() const
278 bool bLen
= !m_pReplaceAttrText
->GetText().isEmpty();
279 return ( m_pReplaceAttrText
->IsEnabled() && bLen
);
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */