1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
29cdf0e10cSrcweir #include <vcl/morebtn.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <svl/slstitm.hxx>
32cdf0e10cSrcweir #include <svl/itemiter.hxx>
33cdf0e10cSrcweir #include <svl/style.hxx>
34cdf0e10cSrcweir #include <unotools/searchopt.hxx>
35cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
36cdf0e10cSrcweir #include <sfx2/objsh.hxx>
37cdf0e10cSrcweir #include <sfx2/module.hxx>
38cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
39cdf0e10cSrcweir #include <sfx2/basedlgs.hxx>
40cdf0e10cSrcweir #include <svl/cjkoptions.hxx>
41cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
42cdf0e10cSrcweir #include <com/sun/star/i18n/TransliterationModules.hpp>
43cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
44cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
45cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
46cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
47cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
48cdf0e10cSrcweir #include <svl/itempool.hxx>
49cdf0e10cSrcweir #include <svl/intitem.hxx>
50cdf0e10cSrcweir
51cdf0e10cSrcweir #include <sfx2/app.hxx>
52cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir #define _SVX_SRCHDLG_CXX
55cdf0e10cSrcweir #include "svx/srchdlg.hxx"
56cdf0e10cSrcweir
57cdf0e10cSrcweir #include <svx/dialogs.hrc>
58cdf0e10cSrcweir #include <svx/svxitems.hrc>
59cdf0e10cSrcweir #include "srchdlg.hrc"
60cdf0e10cSrcweir
61cdf0e10cSrcweir
62cdf0e10cSrcweir #define ITEMID_SETITEM 0
63cdf0e10cSrcweir
64cdf0e10cSrcweir #include <svl/srchitem.hxx>
65cdf0e10cSrcweir #include <svx/pageitem.hxx>
66cdf0e10cSrcweir #include "srchctrl.hxx"
67cdf0e10cSrcweir #include <svx/dialmgr.hxx>
68cdf0e10cSrcweir #include "svx/dlgutil.hxx"
69cdf0e10cSrcweir #include <editeng/brshitem.hxx>
70cdf0e10cSrcweir #include <tools/resary.hxx>
71cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
72cdf0e10cSrcweir
73*9b8096d0SSteve Yin #ifndef _ACCESSIBLESVXFINDREPLACEDIALOG_HXX_
74*9b8096d0SSteve Yin #include <svx/AccessibleSvxFindReplaceDialog.hxx>
75*9b8096d0SSteve Yin #endif
76*9b8096d0SSteve Yin using namespace com::sun::star::uno;
77*9b8096d0SSteve Yin using namespace com::sun::star::accessibility;
78*9b8096d0SSteve Yin
79cdf0e10cSrcweir #include <sfx2/layout-pre.hxx>
80cdf0e10cSrcweir
81cdf0e10cSrcweir using namespace com::sun::star::i18n;
82cdf0e10cSrcweir using namespace com::sun::star;
83cdf0e10cSrcweir using namespace comphelper;
84cdf0e10cSrcweir
85cdf0e10cSrcweir // -----------------------------------------------------------------------
86cdf0e10cSrcweir
87cdf0e10cSrcweir #define REMEMBER_SIZE 10
88cdf0e10cSrcweir
89cdf0e10cSrcweir #define MODIFY_SEARCH 0x00000001
90cdf0e10cSrcweir #define MODIFY_REPLACE 0x00000002
91cdf0e10cSrcweir #define MODIFY_WORD 0x00000004
92cdf0e10cSrcweir #define MODIFY_EXACT 0x00000008
93cdf0e10cSrcweir #define MODIFY_BACKWARDS 0x00000010
94cdf0e10cSrcweir #define MODIFY_SELECTION 0x00000020
95cdf0e10cSrcweir #define MODIFY_REGEXP 0x00000040
96cdf0e10cSrcweir #define MODIFY_LAYOUT 0x00000080
97cdf0e10cSrcweir #define MODIFY_SIMILARITY 0x00000100
98cdf0e10cSrcweir #define MODIFY_FORMULAS 0x00000200
99cdf0e10cSrcweir #define MODIFY_VALUES 0x00000400
100cdf0e10cSrcweir #define MODIFY_CALC_NOTES 0x00000800
101cdf0e10cSrcweir #define MODIFY_ROWS 0x00001000
102cdf0e10cSrcweir #define MODIFY_COLUMNS 0x00002000
103cdf0e10cSrcweir #define MODIFY_ALLTABLES 0x00004000
104cdf0e10cSrcweir #define MODIFY_NOTES 0x00008000
105cdf0e10cSrcweir
106cdf0e10cSrcweir SV_IMPL_VARARR(SrchAttrItemList, SearchAttrItem);
107cdf0e10cSrcweir
108cdf0e10cSrcweir //#define NotifyApp( nId )
109cdf0e10cSrcweir // rBindings.ExecuteSynchron( nId, (const SfxPoolItem**)&pSearchItem, 0L )
110cdf0e10cSrcweir
111cdf0e10cSrcweir #define GetCheckBoxValue( rBox ) \
112cdf0e10cSrcweir rBox.IsEnabled() ? rBox.IsChecked() : sal_False
113cdf0e10cSrcweir
114cdf0e10cSrcweir #if ENABLE_LAYOUT
115cdf0e10cSrcweir #undef SVX_RES
116cdf0e10cSrcweir #define SVX_RES(x) #x
117cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
118cdf0e10cSrcweir
119cdf0e10cSrcweir struct SearchDlg_Impl
120cdf0e10cSrcweir {
121cdf0e10cSrcweir FixedText aSearchFormats;
122cdf0e10cSrcweir FixedText aReplaceFormats;
123cdf0e10cSrcweir
124cdf0e10cSrcweir sal_Bool bMultiLineEdit : 1,
125cdf0e10cSrcweir bSaveToModule : 1,
126cdf0e10cSrcweir bFocusOnSearch : 1,
127cdf0e10cSrcweir bDeltaCalculated : 1;
128cdf0e10cSrcweir sal_uInt16* pRanges;
129cdf0e10cSrcweir Timer aSelectionTimer;
130cdf0e10cSrcweir
131cdf0e10cSrcweir uno::Reference< frame::XDispatch > xCommand1Dispatch;
132cdf0e10cSrcweir uno::Reference< frame::XDispatch > xCommand2Dispatch;
133cdf0e10cSrcweir util::URL aCommand1URL;
134cdf0e10cSrcweir util::URL aCommand2URL;
135cdf0e10cSrcweir
136cdf0e10cSrcweir #if ENABLE_LAYOUT
SearchDlg_ImplSearchDlg_Impl137cdf0e10cSrcweir SearchDlg_Impl( layout::Context* pParent ) :
138cdf0e10cSrcweir #else /* !ENABLE_LAYOUT */
139cdf0e10cSrcweir SearchDlg_Impl( Window* pParent ) :
140cdf0e10cSrcweir #endif /* !ENABLE_LAYOUT */
141cdf0e10cSrcweir aSearchFormats ( pParent, SVX_RES( FT_SEARCH_FORMATS ) ),
142cdf0e10cSrcweir aReplaceFormats ( pParent, SVX_RES( FT_REPLACE_FORMATS ) ),
143cdf0e10cSrcweir bMultiLineEdit ( sal_False ),
144cdf0e10cSrcweir bSaveToModule ( sal_True ),
145cdf0e10cSrcweir bFocusOnSearch ( sal_True ),
146cdf0e10cSrcweir bDeltaCalculated( sal_False ),
147cdf0e10cSrcweir pRanges ( NULL )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir aCommand1URL.Complete = aCommand1URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent1");
150cdf0e10cSrcweir aCommand1URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:");
151cdf0e10cSrcweir aCommand1URL.Path = rtl::OUString::createFromAscii("SearchViaComponent1");
152cdf0e10cSrcweir aCommand2URL.Complete = aCommand2URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent2");
153cdf0e10cSrcweir aCommand2URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:");
154cdf0e10cSrcweir aCommand2URL.Path = rtl::OUString::createFromAscii("SearchViaComponent2");
155cdf0e10cSrcweir }
~SearchDlg_ImplSearchDlg_Impl156cdf0e10cSrcweir ~SearchDlg_Impl() { delete[] pRanges; }
157cdf0e10cSrcweir };
158cdf0e10cSrcweir
159cdf0e10cSrcweir // -----------------------------------------------------------------------
160cdf0e10cSrcweir
ListToStrArr_Impl(sal_uInt16 nId,SvStringsDtor & rStrLst,ComboBox & rCBox)161cdf0e10cSrcweir void ListToStrArr_Impl( sal_uInt16 nId, SvStringsDtor& rStrLst, ComboBox& rCBox )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir SfxStringListItem* pSrchItem =
164cdf0e10cSrcweir (SfxStringListItem*)SFX_APP()->GetItem( nId );
165cdf0e10cSrcweir List* pLst = pSrchItem ? pSrchItem->GetList() : 0;
166cdf0e10cSrcweir
167cdf0e10cSrcweir if ( pLst )
168cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < pLst->Count(); ++i )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir String* pTmp = new String( *(String*)( pLst->GetObject(i) ) );
171cdf0e10cSrcweir rStrLst.Insert( pTmp, rStrLst.Count() );
172cdf0e10cSrcweir rCBox.InsertEntry( *pTmp );
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir // -----------------------------------------------------------------------
177cdf0e10cSrcweir
StrArrToList_Impl(sal_uInt16 nId,const SvStringsDtor & rStrLst)178cdf0e10cSrcweir void StrArrToList_Impl( sal_uInt16 nId, const SvStringsDtor& rStrLst )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir DBG_ASSERT( rStrLst.Count(), "vorher abpruefen!!" );
181cdf0e10cSrcweir List aLst;
182cdf0e10cSrcweir
183cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < rStrLst.Count(); ++i )
184cdf0e10cSrcweir aLst.Insert( rStrLst[ i ], LIST_APPEND );
185cdf0e10cSrcweir
186cdf0e10cSrcweir SFX_APP()->PutItem( SfxStringListItem( nId, &aLst ) );
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
189cdf0e10cSrcweir // class SearchAttrItemList ----------------------------------------------
190cdf0e10cSrcweir
SearchAttrItemList(const SearchAttrItemList & rList)191cdf0e10cSrcweir SearchAttrItemList::SearchAttrItemList( const SearchAttrItemList& rList ) :
192cdf0e10cSrcweir
193cdf0e10cSrcweir SrchAttrItemList( (sal_uInt8)rList.Count() )
194cdf0e10cSrcweir
195cdf0e10cSrcweir {
196cdf0e10cSrcweir SrchAttrItemList::Insert( &rList, 0 );
197cdf0e10cSrcweir SearchAttrItem* _pData = (SearchAttrItem*)GetData();
198cdf0e10cSrcweir
199cdf0e10cSrcweir for ( sal_uInt16 i = Count(); i; --i, ++_pData )
200cdf0e10cSrcweir if ( !IsInvalidItem( _pData->pItem ) )
201cdf0e10cSrcweir _pData->pItem = _pData->pItem->Clone();
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
204cdf0e10cSrcweir // -----------------------------------------------------------------------
205cdf0e10cSrcweir
~SearchAttrItemList()206cdf0e10cSrcweir SearchAttrItemList::~SearchAttrItemList()
207cdf0e10cSrcweir {
208cdf0e10cSrcweir Clear();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir // -----------------------------------------------------------------------
212cdf0e10cSrcweir
Put(const SfxItemSet & rSet)213cdf0e10cSrcweir void SearchAttrItemList::Put( const SfxItemSet& rSet )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir if ( !rSet.Count() )
216cdf0e10cSrcweir return;
217cdf0e10cSrcweir
218cdf0e10cSrcweir SfxItemPool* pPool = rSet.GetPool();
219cdf0e10cSrcweir SfxItemIter aIter( rSet );
220cdf0e10cSrcweir SearchAttrItem aItem;
221cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.GetCurItem();
222cdf0e10cSrcweir sal_uInt16 nWhich;
223cdf0e10cSrcweir
224cdf0e10cSrcweir while ( sal_True )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir // nur testen, ob vorhanden ist ?
227cdf0e10cSrcweir if( IsInvalidItem( pItem ) )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir nWhich = rSet.GetWhichByPos( aIter.GetCurPos() );
230cdf0e10cSrcweir aItem.pItem = (SfxPoolItem*)pItem;
231cdf0e10cSrcweir }
232cdf0e10cSrcweir else
233cdf0e10cSrcweir {
234cdf0e10cSrcweir nWhich = pItem->Which();
235cdf0e10cSrcweir aItem.pItem = pItem->Clone();
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir aItem.nSlot = pPool->GetSlotId( nWhich );
239cdf0e10cSrcweir Insert( aItem );
240cdf0e10cSrcweir
241cdf0e10cSrcweir if ( aIter.IsAtEnd() )
242cdf0e10cSrcweir break;
243cdf0e10cSrcweir pItem = aIter.NextItem();
244cdf0e10cSrcweir }
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir // -----------------------------------------------------------------------
248cdf0e10cSrcweir
Get(SfxItemSet & rSet)249cdf0e10cSrcweir SfxItemSet& SearchAttrItemList::Get( SfxItemSet& rSet )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir SfxItemPool* pPool = rSet.GetPool();
252cdf0e10cSrcweir SearchAttrItem* _pData = (SearchAttrItem*)GetData();
253cdf0e10cSrcweir
254cdf0e10cSrcweir for ( sal_uInt16 i = Count(); i; --i, ++_pData )
255cdf0e10cSrcweir if ( IsInvalidItem( _pData->pItem ) )
256cdf0e10cSrcweir rSet.InvalidateItem( pPool->GetWhich( _pData->nSlot ) );
257cdf0e10cSrcweir else
258cdf0e10cSrcweir rSet.Put( *_pData->pItem );
259cdf0e10cSrcweir return rSet;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir // -----------------------------------------------------------------------
263cdf0e10cSrcweir
Clear()264cdf0e10cSrcweir void SearchAttrItemList::Clear()
265cdf0e10cSrcweir {
266cdf0e10cSrcweir SearchAttrItem* _pData = (SearchAttrItem*)GetData();
267cdf0e10cSrcweir
268cdf0e10cSrcweir for ( sal_uInt16 i = Count(); i; --i, ++_pData )
269cdf0e10cSrcweir if ( !IsInvalidItem( _pData->pItem ) )
270cdf0e10cSrcweir delete _pData->pItem;
271cdf0e10cSrcweir SrchAttrItemList::Remove( 0, Count() );
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir // -----------------------------------------------------------------------
275cdf0e10cSrcweir
276cdf0e10cSrcweir // l"oscht die Pointer auf die Items
Remove(sal_uInt16 nPos,sal_uInt16 nLen)277cdf0e10cSrcweir void SearchAttrItemList::Remove( sal_uInt16 nPos, sal_uInt16 nLen )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir if ( nPos + nLen > Count() )
280cdf0e10cSrcweir nLen = Count() - nPos;
281cdf0e10cSrcweir SearchAttrItem* _pData = (SearchAttrItem*)GetData() + nPos;
282cdf0e10cSrcweir
283cdf0e10cSrcweir for ( sal_uInt16 n = nLen; n; --n, ++_pData )
284cdf0e10cSrcweir if ( !IsInvalidItem( _pData->pItem ) )
285cdf0e10cSrcweir delete _pData->pItem;
286cdf0e10cSrcweir
287cdf0e10cSrcweir SrchAttrItemList::Remove( nPos, nLen );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir #if ENABLE_LAYOUT
291cdf0e10cSrcweir #undef SfxModelessDialog
292cdf0e10cSrcweir #define SfxModelessDialog(bindings, child, parent, id) SfxDialog (parent, "find-and-replace.xml", id, bindings, child)
293cdf0e10cSrcweir #define SVX_RES_PLAIN(x) ResId (x, DIALOG_MGR ())
294cdf0e10cSrcweir #define THIS_SVX_RES(x) this, #x
295cdf0e10cSrcweir #else /* !ENABLE_LAYOUT */
296cdf0e10cSrcweir #define SVX_RES_PLAIN SVX_RES
297cdf0e10cSrcweir #define THIS_SVX_RES SVX_RES
298cdf0e10cSrcweir #endif /* !ENABLE_LAYOUT */
299cdf0e10cSrcweir
300cdf0e10cSrcweir #undef INI_LIST
301cdf0e10cSrcweir #define INI_LIST() \
302*9b8096d0SSteve Yin mpDocWin (NULL), \
303*9b8096d0SSteve Yin mbSuccess (sal_False), \
304cdf0e10cSrcweir aSearchText ( this, SVX_RES( FT_SEARCH ) ), \
305cdf0e10cSrcweir aSearchLB ( this, SVX_RES( ED_SEARCH ) ), \
306cdf0e10cSrcweir aSearchTmplLB ( this, SVX_RES( LB_SEARCH ) ), \
307cdf0e10cSrcweir aSearchAttrText ( this, SVX_RES( FT_SEARCH_ATTR ) ), \
308cdf0e10cSrcweir aReplaceText ( this, SVX_RES( FT_REPLACE ) ), \
309cdf0e10cSrcweir aReplaceLB ( this, SVX_RES( ED_REPLACE ) ), \
310cdf0e10cSrcweir aReplaceTmplLB ( this, SVX_RES( LB_REPLACE ) ), \
311cdf0e10cSrcweir aReplaceAttrText( this, SVX_RES( FT_REPLACE_ATTR ) ), \
312cdf0e10cSrcweir aSearchBtn ( this, SVX_RES( BTN_SEARCH ) ), \
313cdf0e10cSrcweir aSearchAllBtn ( this, SVX_RES( BTN_SEARCH_ALL ) ), \
314cdf0e10cSrcweir aSearchCmdLine ( this, SVX_RES( FL_SEARCH_COMMAND ) ), \
315cdf0e10cSrcweir aReplaceBtn ( this, SVX_RES( BTN_REPLACE ) ), \
316cdf0e10cSrcweir aReplaceAllBtn ( this, SVX_RES( BTN_REPLACE_ALL ) ), \
317cdf0e10cSrcweir aSearchComponentFL( this, SVX_RES( FL_SEARCH_COMPONENT ) ), \
318cdf0e10cSrcweir aSearchComponent1PB( this, SVX_RES( BTN_COMPONENT_1 ) ), \
319cdf0e10cSrcweir aSearchComponent2PB( this, SVX_RES( BTN_COMPONENT_2 ) ), \
320cdf0e10cSrcweir aMatchCaseCB ( this, SVX_RES( CB_MATCH_CASE ) ), \
321cdf0e10cSrcweir aWordBtn ( this, SVX_RES( CB_WHOLE_WORDS ) ), \
322cdf0e10cSrcweir aButtonsFL ( this, SVX_RES( FL_BUTTONS ) ), \
323cdf0e10cSrcweir pMoreBtn ( new MoreButton( this, SVX_RES( BTN_MORE ) ) ), \
324cdf0e10cSrcweir aHelpBtn ( this, SVX_RES( BTN_HELP ) ), \
325cdf0e10cSrcweir aCloseBtn ( this, SVX_RES( BTN_CLOSE ) ), \
326cdf0e10cSrcweir aOptionsFL ( this, SVX_RES( FL_OPTIONS ) ), \
327cdf0e10cSrcweir aSelectionBtn ( this, SVX_RES( CB_SELECTIONS ) ), \
328cdf0e10cSrcweir aBackwardsBtn ( this, SVX_RES( CB_BACKWARDS ) ), \
329cdf0e10cSrcweir aRegExpBtn ( this, SVX_RES( CB_REGEXP ) ), \
330cdf0e10cSrcweir aSimilarityBox ( this, SVX_RES( CB_SIMILARITY) ), \
331cdf0e10cSrcweir aSimilarityBtn ( this, SVX_RES( PB_SIMILARITY) ), \
332cdf0e10cSrcweir aLayoutBtn ( this, SVX_RES( CB_LAYOUTS ) ), \
333cdf0e10cSrcweir aNotesBtn ( this, SVX_RES( CB_NOTES ) ), \
334cdf0e10cSrcweir aJapMatchFullHalfWidthCB( this, SVX_RES( CB_JAP_MATCH_FULL_HALF_WIDTH ) ),\
335cdf0e10cSrcweir aJapOptionsCB ( this, SVX_RES( CB_JAP_SOUNDS_LIKE ) ), \
336cdf0e10cSrcweir aJapOptionsBtn ( this, SVX_RES( PB_JAP_OPTIONS ) ), \
337cdf0e10cSrcweir aAttributeBtn ( this, SVX_RES( BTN_ATTRIBUTE ) ), \
338cdf0e10cSrcweir aFormatBtn ( this, SVX_RES( BTN_FORMAT ) ), \
339cdf0e10cSrcweir aNoFormatBtn ( this, SVX_RES( BTN_NOFORMAT ) ), \
340cdf0e10cSrcweir aCalcFL ( this, SVX_RES( FL_CALC ) ), \
341cdf0e10cSrcweir aCalcSearchInFT ( this, SVX_RES( FT_CALC_SEARCHIN ) ), \
342cdf0e10cSrcweir aCalcSearchInLB ( this, SVX_RES( LB_CALC_SEARCHIN ) ), \
343cdf0e10cSrcweir aCalcSearchDirFT( this, SVX_RES( FT_CALC_SEARCHDIR ) ), \
344cdf0e10cSrcweir aRowsBtn ( this, SVX_RES( RB_CALC_ROWS ) ), \
345cdf0e10cSrcweir aColumnsBtn ( this, SVX_RES( RB_CALC_COLUMNS ) ), \
346cdf0e10cSrcweir aAllSheetsCB ( this, SVX_RES( CB_ALL_SHEETS ) ), \
347cdf0e10cSrcweir rBindings ( rBind ), \
348cdf0e10cSrcweir bWriter ( sal_False ), \
349cdf0e10cSrcweir bSearch ( sal_True ), \
350cdf0e10cSrcweir bFormat ( sal_False ), \
351cdf0e10cSrcweir nOptions ( USHRT_MAX ), \
352cdf0e10cSrcweir bSet ( sal_False ), \
353cdf0e10cSrcweir bReadOnly ( sal_False ), \
354cdf0e10cSrcweir bConstruct ( sal_True ), \
355cdf0e10cSrcweir nModifyFlag ( 0 ), \
356cdf0e10cSrcweir aCalcStr ( THIS_SVX_RES( STR_WORDCALC ) ), \
357cdf0e10cSrcweir pImpl ( NULL ), \
358cdf0e10cSrcweir pSearchList ( NULL ), \
359cdf0e10cSrcweir pReplaceList ( new SearchAttrItemList ), \
360cdf0e10cSrcweir pSearchItem ( NULL ), \
361cdf0e10cSrcweir pSearchController ( NULL ), \
362cdf0e10cSrcweir pOptionsController ( NULL ), \
363cdf0e10cSrcweir pFamilyController ( NULL ), \
364cdf0e10cSrcweir pSearchSetController ( NULL ), \
365cdf0e10cSrcweir pReplaceSetController ( NULL ), \
366cdf0e10cSrcweir nTransliterationFlags ( 0x00000000 )
367cdf0e10cSrcweir
368cdf0e10cSrcweir // class SvxSearchDialog -------------------------------------------------
369cdf0e10cSrcweir
SvxSearchDialog(Window * pParent,SfxBindings & rBind)370cdf0e10cSrcweir SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxBindings& rBind ) :
371cdf0e10cSrcweir
372cdf0e10cSrcweir SfxModelessDialog( &rBind, NULL, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
373cdf0e10cSrcweir
374cdf0e10cSrcweir INI_LIST()
375cdf0e10cSrcweir
376cdf0e10cSrcweir {
377cdf0e10cSrcweir Construct_Impl();
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
380cdf0e10cSrcweir // -----------------------------------------------------------------------
381cdf0e10cSrcweir
SvxSearchDialog(Window * pParent,SfxChildWindow * pChildWin,SfxBindings & rBind)382cdf0e10cSrcweir SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind ) :
383cdf0e10cSrcweir
384cdf0e10cSrcweir SfxModelessDialog( &rBind, pChildWin, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
385cdf0e10cSrcweir
386cdf0e10cSrcweir INI_LIST()
387cdf0e10cSrcweir
388cdf0e10cSrcweir {
389cdf0e10cSrcweir Construct_Impl();
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
392cdf0e10cSrcweir #undef INI_LIST
393cdf0e10cSrcweir #if ENABLE_LAYOUT
394cdf0e10cSrcweir #undef SVX_RES
395cdf0e10cSrcweir #define SVX_RES(x) ResId (x, DIALOG_MGR ())
396cdf0e10cSrcweir #endif
397cdf0e10cSrcweir
398cdf0e10cSrcweir // -----------------------------------------------------------------------
399cdf0e10cSrcweir
~SvxSearchDialog()400cdf0e10cSrcweir SvxSearchDialog::~SvxSearchDialog()
401cdf0e10cSrcweir {
402cdf0e10cSrcweir Hide();
403cdf0e10cSrcweir
404cdf0e10cSrcweir rBindings.EnterRegistrations();
405cdf0e10cSrcweir delete pSearchController;
406cdf0e10cSrcweir delete pOptionsController;
407cdf0e10cSrcweir delete pFamilyController;
408cdf0e10cSrcweir delete pSearchSetController;
409cdf0e10cSrcweir delete pReplaceSetController;
410cdf0e10cSrcweir rBindings.LeaveRegistrations();
411cdf0e10cSrcweir
412cdf0e10cSrcweir delete pSearchItem;
413cdf0e10cSrcweir delete pImpl;
414cdf0e10cSrcweir delete pSearchList;
415cdf0e10cSrcweir delete pReplaceList;
416cdf0e10cSrcweir delete pMoreBtn;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
419cdf0e10cSrcweir #if ENABLE_LAYOUT
420cdf0e10cSrcweir #undef Window
421cdf0e10cSrcweir #define Window layout::Window
422cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
423cdf0e10cSrcweir
lcl_MoveDown(Window & rWindow,sal_Int32 nOffset)424cdf0e10cSrcweir void lcl_MoveDown( Window& rWindow, sal_Int32 nOffset )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir Point aPos(rWindow.GetPosPixel());
427cdf0e10cSrcweir aPos.Y() += nOffset;
428cdf0e10cSrcweir rWindow.SetPosPixel(aPos);
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
Construct_Impl()431cdf0e10cSrcweir void SvxSearchDialog::Construct_Impl()
432cdf0e10cSrcweir {
433cdf0e10cSrcweir #if ENABLE_LAYOUT
434cdf0e10cSrcweir SetHelpId (".uno:SearchDialog");
435cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
436cdf0e10cSrcweir
437cdf0e10cSrcweir // temporary to avoid incompatibility
438cdf0e10cSrcweir pImpl = new SearchDlg_Impl( this );
439cdf0e10cSrcweir #if !ENABLE_LAYOUT
440cdf0e10cSrcweir pImpl->aSelectionTimer.SetTimeout( 500 );
441cdf0e10cSrcweir pImpl->aSelectionTimer.SetTimeoutHdl(
442cdf0e10cSrcweir LINK( this, SvxSearchDialog, TimeoutHdl_Impl ) );
443cdf0e10cSrcweir #endif /* !ENABLE_LAYOUT */
444cdf0e10cSrcweir EnableControls_Impl( 0 );
445cdf0e10cSrcweir
446cdf0e10cSrcweir // alten Text des aWordBtn's merken
447cdf0e10cSrcweir aCalcStr += sal_Unicode('#');
448cdf0e10cSrcweir aCalcStr += aWordBtn.GetText();
449cdf0e10cSrcweir
450cdf0e10cSrcweir aLayoutStr = SVX_RESSTR( RID_SVXSTR_SEARCH_STYLES );
451cdf0e10cSrcweir aStylesStr = aLayoutBtn.GetText();
452cdf0e10cSrcweir
453cdf0e10cSrcweir // gemerkte Such-Strings von der Applikation holen
454cdf0e10cSrcweir ListToStrArr_Impl( SID_SEARCHDLG_SEARCHSTRINGS,
455cdf0e10cSrcweir aSearchStrings, aSearchLB );
456cdf0e10cSrcweir ListToStrArr_Impl( SID_SEARCHDLG_REPLACESTRINGS,
457cdf0e10cSrcweir aReplaceStrings, aReplaceLB );
458cdf0e10cSrcweir
459cdf0e10cSrcweir pMoreBtn->SetMoreText( String( SVX_RES( STR_MORE_BTN ) ) );
460cdf0e10cSrcweir pMoreBtn->SetLessText( String( SVX_RES( STR_LESS_BTN ) ) );
461cdf0e10cSrcweir
462cdf0e10cSrcweir FreeResource();
463cdf0e10cSrcweir InitControls_Impl();
464cdf0e10cSrcweir
465cdf0e10cSrcweir // Attribut-Sets nur einmal im Ctor() besorgen
466cdf0e10cSrcweir const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
467cdf0e10cSrcweir const SvxSetItem* pSrchSetItem =
468cdf0e10cSrcweir (const SvxSetItem*) rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
469cdf0e10cSrcweir
470cdf0e10cSrcweir if ( pSrchSetItem )
471cdf0e10cSrcweir InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
472cdf0e10cSrcweir
473cdf0e10cSrcweir const SvxSetItem* pReplSetItem =
474cdf0e10cSrcweir (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
475cdf0e10cSrcweir
476cdf0e10cSrcweir if ( pReplSetItem )
477cdf0e10cSrcweir InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
478cdf0e10cSrcweir
479cdf0e10cSrcweir // Controller erzeugen und gleich aktualisieren
480cdf0e10cSrcweir rBindings.EnterRegistrations();
481cdf0e10cSrcweir pSearchController =
482cdf0e10cSrcweir new SvxSearchController( SID_SEARCH_ITEM, rBindings, *this );
483cdf0e10cSrcweir pOptionsController =
484cdf0e10cSrcweir new SvxSearchController( SID_SEARCH_OPTIONS, rBindings, *this );
485cdf0e10cSrcweir rBindings.LeaveRegistrations();
486cdf0e10cSrcweir rBindings.GetDispatcher()->Execute( FID_SEARCH_ON, SFX_CALLMODE_SLOT, ppArgs );
487cdf0e10cSrcweir pImpl->aSelectionTimer.Start();
488cdf0e10cSrcweir
489cdf0e10cSrcweir
490cdf0e10cSrcweir SvtCJKOptions aCJKOptions;
491cdf0e10cSrcweir if(!aCJKOptions.IsJapaneseFindEnabled())
492cdf0e10cSrcweir {
493cdf0e10cSrcweir aJapOptionsCB.Check( sal_False );
494cdf0e10cSrcweir aJapOptionsCB.Hide();
495cdf0e10cSrcweir aJapOptionsBtn.Hide();
496cdf0e10cSrcweir }
497cdf0e10cSrcweir if(!aCJKOptions.IsCJKFontEnabled())
498cdf0e10cSrcweir {
499cdf0e10cSrcweir aJapMatchFullHalfWidthCB.Hide();
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
502cdf0e10cSrcweir aSimilarityBtn.SetAccessibleRelationLabeledBy(&aSimilarityBox);
503cdf0e10cSrcweir aSimilarityBtn.SetAccessibleRelationMemberOf(&aOptionsFL);
504cdf0e10cSrcweir aJapOptionsBtn.SetAccessibleRelationLabeledBy(&aJapOptionsCB);
505cdf0e10cSrcweir aJapOptionsBtn.SetAccessibleRelationMemberOf(&aOptionsFL);
506cdf0e10cSrcweir aRowsBtn.SetAccessibleRelationMemberOf(&aCalcSearchDirFT);
507cdf0e10cSrcweir aColumnsBtn.SetAccessibleRelationMemberOf(&aCalcSearchDirFT);
508cdf0e10cSrcweir
509cdf0e10cSrcweir //component extension - show component search buttons if the commands
510cdf0e10cSrcweir // vnd.sun.star::SearchViaComponent1 and 2 are supported
511cdf0e10cSrcweir const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
512cdf0e10cSrcweir const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
513cdf0e10cSrcweir rtl::OUString sTarget = rtl::OUString::createFromAscii("_self");
514cdf0e10cSrcweir
515cdf0e10cSrcweir bool bSearchComponent1 = false;
516cdf0e10cSrcweir bool bSearchComponent2 = false;
517cdf0e10cSrcweir if(xDispatchProv.is() &&
518cdf0e10cSrcweir (pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0)).is())
519cdf0e10cSrcweir {
520cdf0e10cSrcweir bSearchComponent1 = true;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir if(xDispatchProv.is() &&
523cdf0e10cSrcweir (pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0)).is())
524cdf0e10cSrcweir {
525cdf0e10cSrcweir bSearchComponent2 = true;
526cdf0e10cSrcweir }
527cdf0e10cSrcweir
528cdf0e10cSrcweir if( bSearchComponent1 || bSearchComponent2 )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir //get the labels of the FixedLine and the buttons
531cdf0e10cSrcweir // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchGroupLabel
532cdf0e10cSrcweir // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchCommandLabel1
533cdf0e10cSrcweir // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchCommandLabel2
534cdf0e10cSrcweir try
535cdf0e10cSrcweir {
536cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
537cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(xMgr->createInstance(
538cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider"))),
539cdf0e10cSrcweir uno::UNO_QUERY);
540cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs(1);
541cdf0e10cSrcweir ::rtl::OUString sPath(RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/SearchOptions/"));
542cdf0e10cSrcweir aArgs[0] <<= sPath;
543cdf0e10cSrcweir
544cdf0e10cSrcweir uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
545cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess")),
546cdf0e10cSrcweir aArgs);
547cdf0e10cSrcweir uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
548cdf0e10cSrcweir if(xDirectAccess.is())
549cdf0e10cSrcweir {
550cdf0e10cSrcweir ::rtl::OUString sTemp;
551cdf0e10cSrcweir ::rtl::OUString sProperty(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchGroupLabel"));
552cdf0e10cSrcweir uno::Any aRet = xDirectAccess->getByName(sProperty);
553cdf0e10cSrcweir aRet >>= sTemp;
554cdf0e10cSrcweir aSearchComponentFL.SetText( sTemp );
555cdf0e10cSrcweir aRet = xDirectAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchCommandLabel1")));
556cdf0e10cSrcweir aRet >>= sTemp;
557cdf0e10cSrcweir aSearchComponent1PB.SetText( sTemp );
558cdf0e10cSrcweir aRet = xDirectAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchCommandLabel2")));
559cdf0e10cSrcweir aRet >>= sTemp;
560cdf0e10cSrcweir aSearchComponent2PB.SetText( sTemp );
561cdf0e10cSrcweir }
562cdf0e10cSrcweir }
563cdf0e10cSrcweir catch(uno::Exception&){}
564cdf0e10cSrcweir
565cdf0e10cSrcweir if(aSearchComponent1PB.GetText().Len() && bSearchComponent1 )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir aSearchComponentFL.Show();
568cdf0e10cSrcweir aSearchComponent1PB.Show();
569cdf0e10cSrcweir }
570cdf0e10cSrcweir if( aSearchComponent2PB.GetText().Len() )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir if(!aSearchComponent1PB.IsVisible())
573cdf0e10cSrcweir {
574cdf0e10cSrcweir aSearchComponent2PB.SetPosPixel(aSearchComponent1PB.GetPosPixel());
575cdf0e10cSrcweir }
576cdf0e10cSrcweir aSearchComponentFL.Show();
577cdf0e10cSrcweir aSearchComponent2PB.Show();
578cdf0e10cSrcweir }
579cdf0e10cSrcweir if( aSearchComponentFL.IsVisible() && aSearchComponent1PB.IsVisible() )
580cdf0e10cSrcweir {
581cdf0e10cSrcweir
582cdf0e10cSrcweir //dialog must be resized
583cdf0e10cSrcweir Size aDlgSize(GetSizePixel());
584cdf0e10cSrcweir sal_Int32 nOffset = aSearchCmdLine.GetPosPixel().Y() - aSearchAllBtn.GetPosPixel().Y()
585cdf0e10cSrcweir - aButtonsFL.GetPosPixel().Y() + aSearchComponent2PB.GetPosPixel().Y();
586cdf0e10cSrcweir
587cdf0e10cSrcweir aDlgSize.Height() += nOffset;
588cdf0e10cSrcweir Window* aWindows[] =
589cdf0e10cSrcweir {
590cdf0e10cSrcweir &aOptionsFL,
591cdf0e10cSrcweir &aSelectionBtn,
592cdf0e10cSrcweir &aBackwardsBtn,
593cdf0e10cSrcweir &aRegExpBtn,
594cdf0e10cSrcweir &aSimilarityBox,
595cdf0e10cSrcweir &aSimilarityBtn,
596cdf0e10cSrcweir &aLayoutBtn,
597cdf0e10cSrcweir &aNotesBtn,
598cdf0e10cSrcweir &aJapMatchFullHalfWidthCB,
599cdf0e10cSrcweir &aJapOptionsCB,
600cdf0e10cSrcweir &aJapOptionsBtn,
601cdf0e10cSrcweir &aAttributeBtn,
602cdf0e10cSrcweir &aFormatBtn,
603cdf0e10cSrcweir &aNoFormatBtn,
604cdf0e10cSrcweir &aCalcFL,
605cdf0e10cSrcweir &aCalcSearchInFT,
606cdf0e10cSrcweir &aCalcSearchInLB,
607cdf0e10cSrcweir &aCalcSearchDirFT,
608cdf0e10cSrcweir &aRowsBtn,
609cdf0e10cSrcweir &aColumnsBtn,
610cdf0e10cSrcweir &aAllSheetsCB,
611cdf0e10cSrcweir &aButtonsFL,
612cdf0e10cSrcweir &aHelpBtn,
613cdf0e10cSrcweir &aCloseBtn,
614cdf0e10cSrcweir pMoreBtn,
615cdf0e10cSrcweir 0
616cdf0e10cSrcweir };
617cdf0e10cSrcweir sal_Int32 nWindow = 0;
618cdf0e10cSrcweir do
619cdf0e10cSrcweir {
620cdf0e10cSrcweir lcl_MoveDown( *aWindows[nWindow], nOffset );
621cdf0e10cSrcweir }
622cdf0e10cSrcweir while(aWindows[++nWindow]);
623cdf0e10cSrcweir
624cdf0e10cSrcweir SetSizePixel(aDlgSize);
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir }
628cdf0e10cSrcweir
629cdf0e10cSrcweir // -----------------------------------------------------------------------
630cdf0e10cSrcweir
Close()631cdf0e10cSrcweir sal_Bool SvxSearchDialog::Close()
632cdf0e10cSrcweir {
633cdf0e10cSrcweir // remember strings speichern
634cdf0e10cSrcweir if ( aSearchStrings.Count() )
635cdf0e10cSrcweir StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
636cdf0e10cSrcweir
637cdf0e10cSrcweir if ( aReplaceStrings.Count() )
638cdf0e10cSrcweir StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
639cdf0e10cSrcweir
640cdf0e10cSrcweir // save settings to configuration
641cdf0e10cSrcweir SvtSearchOptions aOpt;
642cdf0e10cSrcweir aOpt.SetWholeWordsOnly ( aWordBtn .IsChecked() );
643cdf0e10cSrcweir aOpt.SetBackwards ( aBackwardsBtn .IsChecked() );
644cdf0e10cSrcweir aOpt.SetUseRegularExpression ( aRegExpBtn .IsChecked() );
645cdf0e10cSrcweir //aOpt.SetMatchCase ( aMatchCaseCB .IsChecked() );
646cdf0e10cSrcweir aOpt.SetSearchForStyles ( aLayoutBtn .IsChecked() );
647cdf0e10cSrcweir aOpt.SetSimilaritySearch ( aSimilarityBox .IsChecked() );
648cdf0e10cSrcweir //aOpt.SetMatchFullHalfWidthForms ( !aJapMatchFullHalfWidthCB.IsChecked() );
649cdf0e10cSrcweir aOpt.SetUseAsianOptions ( aJapOptionsCB .IsChecked() );
650cdf0e10cSrcweir aOpt.SetNotes ( aNotesBtn .IsChecked() );
651cdf0e10cSrcweir
652cdf0e10cSrcweir const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
653cdf0e10cSrcweir rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SFX_CALLMODE_SLOT, ppArgs );
654cdf0e10cSrcweir rBindings.Execute( SID_SEARCH_DLG );
655cdf0e10cSrcweir
656cdf0e10cSrcweir return sal_True;
657cdf0e10cSrcweir }
658cdf0e10cSrcweir
659cdf0e10cSrcweir // -----------------------------------------------------------------------
660cdf0e10cSrcweir
GetTransliterationFlags() const661cdf0e10cSrcweir sal_Int32 SvxSearchDialog::GetTransliterationFlags() const
662cdf0e10cSrcweir {
663cdf0e10cSrcweir if (!aMatchCaseCB.IsChecked())
664cdf0e10cSrcweir nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
665cdf0e10cSrcweir else
666cdf0e10cSrcweir nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE;
667cdf0e10cSrcweir if ( !aJapMatchFullHalfWidthCB.IsChecked())
668cdf0e10cSrcweir nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH;
669cdf0e10cSrcweir else
670cdf0e10cSrcweir nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH;
671cdf0e10cSrcweir return nTransliterationFlags;
672cdf0e10cSrcweir }
673cdf0e10cSrcweir
674cdf0e10cSrcweir // -----------------------------------------------------------------------
675cdf0e10cSrcweir
ApplyTransliterationFlags_Impl(sal_Int32 nSettings)676cdf0e10cSrcweir void SvxSearchDialog::ApplyTransliterationFlags_Impl( sal_Int32 nSettings )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir nTransliterationFlags = nSettings;
679cdf0e10cSrcweir sal_Bool bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
680cdf0e10cSrcweir aMatchCaseCB .Check(!bVal );
681cdf0e10cSrcweir bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
682cdf0e10cSrcweir aJapMatchFullHalfWidthCB.Check( !bVal );
683cdf0e10cSrcweir }
684cdf0e10cSrcweir
685cdf0e10cSrcweir // -----------------------------------------------------------------------
686cdf0e10cSrcweir
Activate()687cdf0e10cSrcweir void SvxSearchDialog::Activate()
688cdf0e10cSrcweir {
689cdf0e10cSrcweir // apply possible transliteration changes of the SvxSearchItem member
690cdf0e10cSrcweir DBG_ASSERT( pSearchItem, "SearchItem missing" );
691cdf0e10cSrcweir if (pSearchItem)
692cdf0e10cSrcweir {
693cdf0e10cSrcweir aMatchCaseCB .Check( pSearchItem->GetExact() );
694cdf0e10cSrcweir aJapMatchFullHalfWidthCB.Check( !pSearchItem->IsMatchFullHalfWidthForms() );
695cdf0e10cSrcweir }
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir // -----------------------------------------------------------------------
699cdf0e10cSrcweir
InitControls_Impl()700cdf0e10cSrcweir void SvxSearchDialog::InitControls_Impl()
701cdf0e10cSrcweir {
702cdf0e10cSrcweir // CaseSensitives AutoComplete
703cdf0e10cSrcweir aSearchLB.EnableAutocomplete( sal_True, sal_True );
704cdf0e10cSrcweir aSearchLB.Show();
705cdf0e10cSrcweir aReplaceLB.EnableAutocomplete( sal_True, sal_True );
706cdf0e10cSrcweir aReplaceLB.Show();
707cdf0e10cSrcweir
708cdf0e10cSrcweir aFormatBtn.Disable();
709cdf0e10cSrcweir aAttributeBtn.Disable();
710cdf0e10cSrcweir
711cdf0e10cSrcweir aSearchLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
712cdf0e10cSrcweir aReplaceLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
713cdf0e10cSrcweir
714cdf0e10cSrcweir Link aLink = LINK( this, SvxSearchDialog, FocusHdl_Impl );
715cdf0e10cSrcweir aSearchLB.SetGetFocusHdl( aLink );
716cdf0e10cSrcweir pImpl->aSearchFormats.SetGetFocusHdl( aLink );
717cdf0e10cSrcweir
718cdf0e10cSrcweir aReplaceLB.SetGetFocusHdl( aLink );
719cdf0e10cSrcweir pImpl->aReplaceFormats.SetGetFocusHdl( aLink );
720cdf0e10cSrcweir
721cdf0e10cSrcweir aLink = LINK( this, SvxSearchDialog, LoseFocusHdl_Impl );
722cdf0e10cSrcweir aSearchLB.SetLoseFocusHdl( aLink );
723cdf0e10cSrcweir aReplaceLB.SetLoseFocusHdl( aLink );
724cdf0e10cSrcweir
725cdf0e10cSrcweir aSearchTmplLB.SetLoseFocusHdl( aLink );
726cdf0e10cSrcweir aReplaceTmplLB.SetLoseFocusHdl( aLink );
727cdf0e10cSrcweir
728cdf0e10cSrcweir aLink = LINK( this, SvxSearchDialog, CommandHdl_Impl );
729cdf0e10cSrcweir aSearchBtn.SetClickHdl( aLink );
730cdf0e10cSrcweir aSearchAllBtn.SetClickHdl( aLink );
731cdf0e10cSrcweir aReplaceBtn.SetClickHdl( aLink );
732cdf0e10cSrcweir aReplaceAllBtn.SetClickHdl( aLink );
733cdf0e10cSrcweir aCloseBtn.SetClickHdl( aLink );
734cdf0e10cSrcweir aSimilarityBtn.SetClickHdl( aLink );
735cdf0e10cSrcweir aJapOptionsBtn.SetClickHdl( aLink );
736cdf0e10cSrcweir aSearchComponent1PB.SetClickHdl( aLink );
737cdf0e10cSrcweir aSearchComponent2PB.SetClickHdl( aLink );
738cdf0e10cSrcweir
739cdf0e10cSrcweir aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
740cdf0e10cSrcweir aWordBtn.SetClickHdl( aLink );
741cdf0e10cSrcweir aSelectionBtn.SetClickHdl( aLink );
742cdf0e10cSrcweir aMatchCaseCB.SetClickHdl( aLink );
743cdf0e10cSrcweir aRegExpBtn.SetClickHdl( aLink );
744cdf0e10cSrcweir aBackwardsBtn.SetClickHdl( aLink );
745cdf0e10cSrcweir aNotesBtn.SetClickHdl( aLink );
746cdf0e10cSrcweir aSimilarityBox.SetClickHdl( aLink );
747cdf0e10cSrcweir aJapOptionsCB.SetClickHdl( aLink );
748cdf0e10cSrcweir aJapMatchFullHalfWidthCB.SetClickHdl( aLink );
749cdf0e10cSrcweir
750cdf0e10cSrcweir aLayoutBtn.SetClickHdl( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
751cdf0e10cSrcweir aFormatBtn.SetClickHdl( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
752cdf0e10cSrcweir aNoFormatBtn.SetClickHdl(
753cdf0e10cSrcweir LINK( this, SvxSearchDialog, NoFormatHdl_Impl ) );
754cdf0e10cSrcweir aAttributeBtn.SetClickHdl(
755cdf0e10cSrcweir LINK( this, SvxSearchDialog, AttributeHdl_Impl ) );
756cdf0e10cSrcweir
757cdf0e10cSrcweir // check if buttontext is to wide
758cdf0e10cSrcweir long nTxtW = Max( pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetMoreText() ),
759cdf0e10cSrcweir pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetLessText() ) );
760cdf0e10cSrcweir nTxtW += ( pMoreBtn->GetTextHeight() * 2 ); // add image size + offset
761cdf0e10cSrcweir long nBtnW = pMoreBtn->GetSizePixel().Width();
762cdf0e10cSrcweir if ( nTxtW > nBtnW )
763cdf0e10cSrcweir {
764cdf0e10cSrcweir // broaden the button
765cdf0e10cSrcweir const long nMinDelta = 10;
766cdf0e10cSrcweir long nDelta = Max( nTxtW - nBtnW, nMinDelta );
767cdf0e10cSrcweir Size aNewSize = pMoreBtn->GetSizePixel();
768cdf0e10cSrcweir aNewSize.Width() += nDelta;
769cdf0e10cSrcweir pMoreBtn->SetSizePixel( aNewSize );
770cdf0e10cSrcweir }
771cdf0e10cSrcweir }
772cdf0e10cSrcweir
773cdf0e10cSrcweir // -----------------------------------------------------------------------
774cdf0e10cSrcweir
CalculateDelta_Impl()775cdf0e10cSrcweir void SvxSearchDialog::CalculateDelta_Impl()
776cdf0e10cSrcweir {
777cdf0e10cSrcweir DBG_ASSERT( pSearchItem, "no search item" );
778cdf0e10cSrcweir
779cdf0e10cSrcweir bool bDrawApp = false;
780cdf0e10cSrcweir bool bCalcApp = false;
781cdf0e10cSrcweir bool bWriterApp = false;
782cdf0e10cSrcweir bool bImpressApp = false;
783cdf0e10cSrcweir const uno::Reference< frame::XFrame > xFrame = rBindings.GetActiveFrame();
784cdf0e10cSrcweir uno::Reference< frame::XModuleManager > xModuleManager(
785cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance(
786cdf0e10cSrcweir DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), uno::UNO_QUERY );
787cdf0e10cSrcweir if ( xModuleManager.is() )
788cdf0e10cSrcweir {
789cdf0e10cSrcweir try
790cdf0e10cSrcweir {
791cdf0e10cSrcweir ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame );
792cdf0e10cSrcweir bCalcApp = aModuleIdentifier.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" );
793cdf0e10cSrcweir bDrawApp = aModuleIdentifier.equalsAscii( "com.sun.star.drawing.DrawingDocument" );
794cdf0e10cSrcweir bImpressApp = aModuleIdentifier.equalsAscii( "com.sun.star.presentation.PresentationDocument" );
795cdf0e10cSrcweir bWriterApp = aModuleIdentifier.equalsAscii( "com.sun.star.text.TextDocument" );
796cdf0e10cSrcweir }
797cdf0e10cSrcweir catch ( uno::Exception& )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir }
800cdf0e10cSrcweir }
801cdf0e10cSrcweir
802cdf0e10cSrcweir if ( pImpl->bDeltaCalculated )
803cdf0e10cSrcweir return;
804cdf0e10cSrcweir else
805cdf0e10cSrcweir pImpl->bDeltaCalculated = sal_True;
806cdf0e10cSrcweir
807cdf0e10cSrcweir sal_uIntPtr nDelta = 187, nOffset = 0;
808cdf0e10cSrcweir SvtCJKOptions aCJKOptions;
809cdf0e10cSrcweir
810cdf0e10cSrcweir pMoreBtn->AddWindow( &aOptionsFL );
811cdf0e10cSrcweir if ( !bDrawApp )
812cdf0e10cSrcweir pMoreBtn->AddWindow( &aLayoutBtn );
813cdf0e10cSrcweir if ( bWriterApp )
814cdf0e10cSrcweir pMoreBtn->AddWindow( &aNotesBtn );
815cdf0e10cSrcweir else
816cdf0e10cSrcweir {
817cdf0e10cSrcweir aNotesBtn.Hide();
818cdf0e10cSrcweir nOffset = !bDrawApp ? 13 : 0;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir pMoreBtn->AddWindow( &aBackwardsBtn );
821cdf0e10cSrcweir if ( !bDrawApp )
822cdf0e10cSrcweir pMoreBtn->AddWindow( &aRegExpBtn );
823cdf0e10cSrcweir pMoreBtn->AddWindow( &aSimilarityBox );
824cdf0e10cSrcweir pMoreBtn->AddWindow( &aSimilarityBtn );
825cdf0e10cSrcweir pMoreBtn->AddWindow( &aSelectionBtn );
826cdf0e10cSrcweir
827cdf0e10cSrcweir if ( aCJKOptions.IsCJKFontEnabled() )
828cdf0e10cSrcweir pMoreBtn->AddWindow( &aJapMatchFullHalfWidthCB );
829cdf0e10cSrcweir else
830cdf0e10cSrcweir nOffset += 13;
831cdf0e10cSrcweir if ( aCJKOptions.IsJapaneseFindEnabled() )
832cdf0e10cSrcweir {
833cdf0e10cSrcweir pMoreBtn->AddWindow( &aJapOptionsCB );
834cdf0e10cSrcweir pMoreBtn->AddWindow( &aJapOptionsBtn );
835cdf0e10cSrcweir }
836cdf0e10cSrcweir else
837cdf0e10cSrcweir nOffset += 17;
838cdf0e10cSrcweir
839cdf0e10cSrcweir if ( bWriter )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir pMoreBtn->AddWindow( &aAttributeBtn );
842cdf0e10cSrcweir pMoreBtn->AddWindow( &aFormatBtn );
843cdf0e10cSrcweir pMoreBtn->AddWindow( &aNoFormatBtn );
844cdf0e10cSrcweir }
845cdf0e10cSrcweir
846cdf0e10cSrcweir if (bDrawApp || bImpressApp)
847cdf0e10cSrcweir {
848cdf0e10cSrcweir // "Find All" button is hidden--align "Find" vertically to the
849cdf0e10cSrcweir // search listbox
850cdf0e10cSrcweir Point aNewPt(aSearchBtn.GetPosPixel());
851cdf0e10cSrcweir const Size aBtnSz(aSearchBtn.GetSizePixel());
852cdf0e10cSrcweir const Size aLBSz(aSearchLB.GetSizePixel());
853cdf0e10cSrcweir const int nOff((aLBSz.Height() - aBtnSz.Height()) / 2);
854cdf0e10cSrcweir aNewPt.Y() = aSearchLB.GetPosPixel().Y() + nOff;
855cdf0e10cSrcweir aSearchBtn.SetPosPixel(aNewPt);
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir if ( bDrawApp )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir // Draw App: "Regular expressions" and "Search for Styles" check boxes are hidden
861cdf0e10cSrcweir // so align the other buttons
862cdf0e10cSrcweir const long nAppFontHeight = 13; // checkbox height + space between in APPFONT
863cdf0e10cSrcweir long nH = LogicToPixel( Size( 0, nAppFontHeight ), MAP_APPFONT ).Height();
864cdf0e10cSrcweir
865cdf0e10cSrcweir Point aNewPos = aSimilarityBox.GetPosPixel();
866cdf0e10cSrcweir aNewPos.Y() -= nH;
867cdf0e10cSrcweir aSimilarityBox.SetPosPixel( aNewPos );
868cdf0e10cSrcweir aNewPos = aSimilarityBtn.GetPosPixel();
869cdf0e10cSrcweir aNewPos.Y() -= nH;
870cdf0e10cSrcweir aSimilarityBtn.SetPosPixel( aNewPos );
871cdf0e10cSrcweir nH *= 3;
872cdf0e10cSrcweir nOffset += ( 3 * nAppFontHeight );
873cdf0e10cSrcweir if ( aCJKOptions.IsCJKFontEnabled() )
874cdf0e10cSrcweir {
875cdf0e10cSrcweir aNewPos = aJapMatchFullHalfWidthCB.GetPosPixel();
876cdf0e10cSrcweir aNewPos.Y() -= nH;
877cdf0e10cSrcweir aJapMatchFullHalfWidthCB.SetPosPixel( aNewPos );
878cdf0e10cSrcweir }
879cdf0e10cSrcweir if ( aCJKOptions.IsJapaneseFindEnabled() )
880cdf0e10cSrcweir {
881cdf0e10cSrcweir aNewPos = aJapOptionsCB.GetPosPixel();
882cdf0e10cSrcweir aNewPos.Y() -= nH;
883cdf0e10cSrcweir aJapOptionsCB.SetPosPixel( aNewPos );
884cdf0e10cSrcweir aNewPos = aJapOptionsBtn.GetPosPixel();
885cdf0e10cSrcweir aNewPos.Y() -= nH;
886cdf0e10cSrcweir aJapOptionsBtn.SetPosPixel( aNewPos );
887cdf0e10cSrcweir }
888cdf0e10cSrcweir }
889cdf0e10cSrcweir
890cdf0e10cSrcweir if ( bCalcApp || bImpressApp )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir Window* pWins[] =
893cdf0e10cSrcweir {
894cdf0e10cSrcweir &aCalcFL, &aCalcSearchInFT, &aCalcSearchInLB, &aCalcSearchDirFT,
895cdf0e10cSrcweir &aRowsBtn, &aColumnsBtn, &aAllSheetsCB, &aJapMatchFullHalfWidthCB,
896cdf0e10cSrcweir &aJapOptionsCB, &aJapOptionsBtn
897cdf0e10cSrcweir };
898cdf0e10cSrcweir Window** pCurrent = pWins;
899cdf0e10cSrcweir sal_uInt32 i = 0;
900cdf0e10cSrcweir const sal_uInt32 nCalcCtrlCount = 7;
901cdf0e10cSrcweir if ( nOffset > 0 )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir long nH = LogicToPixel( Size( 0, nOffset ), MAP_APPFONT ).Height();
904cdf0e10cSrcweir for ( i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir if ( ( bCalcApp && i < nCalcCtrlCount )
907cdf0e10cSrcweir || ( i == nCalcCtrlCount && aCJKOptions.IsCJKFontEnabled() )
908cdf0e10cSrcweir || ( i > nCalcCtrlCount && aCJKOptions.IsJapaneseFindEnabled() ) )
909cdf0e10cSrcweir {
910cdf0e10cSrcweir Point aNewPos = (*pCurrent)->GetPosPixel();
911cdf0e10cSrcweir aNewPos.Y() -= nH;
912cdf0e10cSrcweir (*pCurrent)->SetPosPixel( aNewPos );
913cdf0e10cSrcweir }
914cdf0e10cSrcweir }
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
917cdf0e10cSrcweir if ( bCalcApp)
918cdf0e10cSrcweir {
919cdf0e10cSrcweir pCurrent = pWins;
920cdf0e10cSrcweir for ( i = 0; i < nCalcCtrlCount; ++i, ++pCurrent )
921cdf0e10cSrcweir pMoreBtn->AddWindow( *pCurrent );
922cdf0e10cSrcweir }
923cdf0e10cSrcweir else
924cdf0e10cSrcweir nOffset += 64;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir else
927cdf0e10cSrcweir nOffset += 64;
928cdf0e10cSrcweir
929cdf0e10cSrcweir pMoreBtn->SetDelta( nDelta - nOffset );
930cdf0e10cSrcweir pMoreBtn->Show();
931cdf0e10cSrcweir pMoreBtn->Enable();
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
934cdf0e10cSrcweir #if ENABLE_LAYOUT
935cdf0e10cSrcweir #undef Window
936cdf0e10cSrcweir #define Window ::Window
937cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
938cdf0e10cSrcweir
939cdf0e10cSrcweir // -----------------------------------------------------------------------
940cdf0e10cSrcweir
Init_Impl(int bSearchPattern)941cdf0e10cSrcweir void SvxSearchDialog::Init_Impl( int bSearchPattern )
942cdf0e10cSrcweir {
943cdf0e10cSrcweir DBG_ASSERT( pSearchItem, "SearchItem == 0" );
944cdf0e10cSrcweir bWriter = ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_WRITER );
945cdf0e10cSrcweir
946cdf0e10cSrcweir pImpl->bMultiLineEdit = sal_False;
947cdf0e10cSrcweir
948cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
949cdf0e10cSrcweir {
950cdf0e10cSrcweir pImpl->aSearchFormats.Hide();
951cdf0e10cSrcweir aSearchAttrText.Show();
952cdf0e10cSrcweir pImpl->aReplaceFormats.Hide();
953cdf0e10cSrcweir aReplaceAttrText.Show();
954cdf0e10cSrcweir }
955cdf0e10cSrcweir else
956cdf0e10cSrcweir {
957cdf0e10cSrcweir String aText = aSearchAttrText.GetText();
958cdf0e10cSrcweir aSearchAttrText.Hide();
959cdf0e10cSrcweir
960cdf0e10cSrcweir if ( aText.Len() )
961cdf0e10cSrcweir pImpl->aSearchFormats.SetText( aText );
962cdf0e10cSrcweir pImpl->aSearchFormats.Show();
963cdf0e10cSrcweir aText = aReplaceAttrText.GetText();
964cdf0e10cSrcweir aReplaceAttrText.Hide();
965cdf0e10cSrcweir
966cdf0e10cSrcweir if ( aText.Len() )
967cdf0e10cSrcweir pImpl->aReplaceFormats.SetText( aText );
968cdf0e10cSrcweir pImpl->aReplaceFormats.Show();
969cdf0e10cSrcweir }
970cdf0e10cSrcweir
971cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_WORD ) == 0 )
972cdf0e10cSrcweir aWordBtn.Check( pSearchItem->GetWordOnly() );
973cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_EXACT ) == 0 )
974cdf0e10cSrcweir aMatchCaseCB.Check( pSearchItem->GetExact() );
975cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_BACKWARDS ) == 0 )
976cdf0e10cSrcweir aBackwardsBtn.Check( pSearchItem->GetBackward() );
977cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_NOTES ) == 0 )
978cdf0e10cSrcweir aNotesBtn.Check( pSearchItem->GetNotes() );
979cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_SELECTION ) == 0 )
980cdf0e10cSrcweir aSelectionBtn.Check( pSearchItem->GetSelection() );
981cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 )
982cdf0e10cSrcweir aRegExpBtn.Check( pSearchItem->GetRegExp() );
983cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 )
984cdf0e10cSrcweir aLayoutBtn.Check( pSearchItem->GetPattern() );
985cdf0e10cSrcweir if (aNotesBtn.IsChecked())
986cdf0e10cSrcweir aLayoutBtn.Disable();
987cdf0e10cSrcweir aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
988cdf0e10cSrcweir if( aJapOptionsCB.IsVisible() )
989cdf0e10cSrcweir aJapOptionsCB.Check( pSearchItem->IsUseAsianOptions() );
990cdf0e10cSrcweir ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
991cdf0e10cSrcweir
992cdf0e10cSrcweir CalculateDelta_Impl();
993cdf0e10cSrcweir
994cdf0e10cSrcweir bool bDraw = sal_False;
995cdf0e10cSrcweir if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir Link aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
998cdf0e10cSrcweir aCalcSearchInLB.SetSelectHdl( aLink );
999cdf0e10cSrcweir aRowsBtn.SetClickHdl( aLink );
1000cdf0e10cSrcweir aColumnsBtn.SetClickHdl( aLink );
1001cdf0e10cSrcweir aAllSheetsCB.SetClickHdl( aLink );
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir switch ( pSearchItem->GetCellType() )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir case SVX_SEARCHIN_FORMULA:
1006cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_FORMULAS ) == 0 )
1007cdf0e10cSrcweir aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_FORMULA );
1008cdf0e10cSrcweir break;
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir case SVX_SEARCHIN_VALUE:
1011cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_VALUES ) == 0 )
1012cdf0e10cSrcweir aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_VALUE );
1013cdf0e10cSrcweir break;
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir case SVX_SEARCHIN_NOTE:
1016cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_CALC_NOTES ) == 0 )
1017cdf0e10cSrcweir aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_NOTE );
1018cdf0e10cSrcweir break;
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir aWordBtn.SetText( aCalcStr.GetToken( 0, '#' ) );
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir if ( pSearchItem->GetRowDirection() &&
1023cdf0e10cSrcweir ( nModifyFlag & MODIFY_ROWS ) == 0 )
1024cdf0e10cSrcweir aRowsBtn.Check();
1025cdf0e10cSrcweir else if ( !pSearchItem->GetRowDirection() &&
1026cdf0e10cSrcweir ( nModifyFlag & MODIFY_COLUMNS ) == 0 )
1027cdf0e10cSrcweir aColumnsBtn.Check();
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_ALLTABLES ) == 0 )
1030cdf0e10cSrcweir aAllSheetsCB.Check( pSearchItem->IsAllTables() );
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir // nur im Writer Suche nach Formatierung
1033cdf0e10cSrcweir aFormatBtn.Hide();
1034cdf0e10cSrcweir aNoFormatBtn.Hide();
1035cdf0e10cSrcweir aAttributeBtn.Hide();
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir else
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir aWordBtn.SetText( aCalcStr.GetToken( 1, '#' ) );
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_DRAW )
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir aSearchAllBtn.Hide();
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir aRegExpBtn.Hide();
1046cdf0e10cSrcweir aLayoutBtn.Hide();
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir // nur im Writer Suche nach Formatierung
1049cdf0e10cSrcweir aFormatBtn.Hide();
1050cdf0e10cSrcweir aNoFormatBtn.Hide();
1051cdf0e10cSrcweir aAttributeBtn.Hide();
1052cdf0e10cSrcweir bDraw = sal_True;
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir else
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir if ( !pSearchList )
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir // Attribut-Sets besorgen, wenn noch nicht geschehen
1059cdf0e10cSrcweir const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
1060cdf0e10cSrcweir const SvxSetItem* pSrchSetItem =
1061cdf0e10cSrcweir (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir if ( pSrchSetItem )
1064cdf0e10cSrcweir InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
1065cdf0e10cSrcweir
1066cdf0e10cSrcweir const SvxSetItem* pReplSetItem =
1067cdf0e10cSrcweir (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir if ( pReplSetItem )
1070cdf0e10cSrcweir InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir /*
1073cdf0e10cSrcweir aFormatBtn.Show();
1074cdf0e10cSrcweir aNoFormatBtn.Show();
1075cdf0e10cSrcweir aAttributeBtn.Show();
1076cdf0e10cSrcweir */
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir // pMoreBtn->SetState( sal_False );
1079cdf0e10cSrcweir // pMoreBtn->Hide();
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir if ( 0 && !bDraw ) //!!!!!
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir aRegExpBtn.Show();
1085cdf0e10cSrcweir aLayoutBtn.Show();
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir // "Ahnlichkeitssuche?
1089cdf0e10cSrcweir if ( ( nModifyFlag & MODIFY_SIMILARITY ) == 0 )
1090cdf0e10cSrcweir aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
1091cdf0e10cSrcweir bSet = sal_True;
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir pImpl->bSaveToModule = sal_False;
1094cdf0e10cSrcweir FlagHdl_Impl( &aSimilarityBox );
1095cdf0e10cSrcweir FlagHdl_Impl( &aJapOptionsCB );
1096cdf0e10cSrcweir pImpl->bSaveToModule = sal_True;
1097cdf0e10cSrcweir
1098cdf0e10cSrcweir bool bDisableSearch = sal_False;
1099cdf0e10cSrcweir SfxViewShell* pViewShell = SfxViewShell::Current();
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir if ( pViewShell )
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir sal_Bool bText = !bSearchPattern;
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir if ( pViewShell->HasSelection( bText ) )
1106cdf0e10cSrcweir EnableControl_Impl( &aSelectionBtn );
1107cdf0e10cSrcweir else
1108cdf0e10cSrcweir {
1109cdf0e10cSrcweir aSelectionBtn.Check( sal_False );
1110cdf0e10cSrcweir aSelectionBtn.Disable();
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir // Patternsuche und es wurden keine AttrSets "ubergeben
1115cdf0e10cSrcweir if ( bSearchPattern )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir SfxObjectShell* pShell = SfxObjectShell::Current();
1118cdf0e10cSrcweir
1119cdf0e10cSrcweir if ( pShell && pShell->GetStyleSheetPool() )
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir // Vorlagen beschaffen
1122cdf0e10cSrcweir aSearchTmplLB .Clear();
1123cdf0e10cSrcweir aReplaceTmplLB.Clear();
1124cdf0e10cSrcweir SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
1125cdf0e10cSrcweir pStylePool->SetSearchMask( pSearchItem->GetFamily(),
1126cdf0e10cSrcweir SFXSTYLEBIT_ALL );
1127cdf0e10cSrcweir SfxStyleSheetBase* pBase = pStylePool->First();
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir while ( pBase )
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir if ( pBase->IsUsed() )
1132cdf0e10cSrcweir aSearchTmplLB.InsertEntry( pBase->GetName() );
1133cdf0e10cSrcweir aReplaceTmplLB.InsertEntry( pBase->GetName() );
1134cdf0e10cSrcweir pBase = pStylePool->Next();
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir aSearchTmplLB.SelectEntry( pSearchItem->GetSearchString() );
1137cdf0e10cSrcweir aReplaceTmplLB.SelectEntry( pSearchItem->GetReplaceString() );
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir aSearchTmplLB.Show();
1141cdf0e10cSrcweir
1142cdf0e10cSrcweir if ( bConstruct )
1143cdf0e10cSrcweir // nur nach dem Erzeugen den Fokus grappen
1144cdf0e10cSrcweir aSearchTmplLB.GrabFocus();
1145cdf0e10cSrcweir aReplaceTmplLB.Show();
1146cdf0e10cSrcweir aSearchLB.Hide();
1147cdf0e10cSrcweir aReplaceLB.Hide();
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir aWordBtn.Disable();
1150cdf0e10cSrcweir aRegExpBtn.Disable();
1151cdf0e10cSrcweir aMatchCaseCB.Disable();
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir bDisableSearch = !aSearchTmplLB.GetEntryCount();
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir else
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir bool bSetSearch = ( ( nModifyFlag & MODIFY_SEARCH ) == 0 );
1158cdf0e10cSrcweir bool bSetReplace = ( ( nModifyFlag & MODIFY_REPLACE ) == 0 );
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir if ( pSearchItem->GetSearchString().Len() && bSetSearch )
1161cdf0e10cSrcweir aSearchLB.SetText( pSearchItem->GetSearchString() );
1162cdf0e10cSrcweir else if ( aSearchStrings.Count() )
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir bool bAttributes =
1165cdf0e10cSrcweir ( ( pSearchList && pSearchList->Count() ) ||
1166cdf0e10cSrcweir ( pReplaceList && pReplaceList->Count() ) );
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir if ( bSetSearch && !bAttributes )
1169cdf0e10cSrcweir aSearchLB.SetText( *aSearchStrings[ 0 ] );
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir String aReplaceTxt = pSearchItem->GetReplaceString();
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir if ( aReplaceStrings.Count() )
1174cdf0e10cSrcweir aReplaceTxt = *aReplaceStrings[ 0 ];
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir if ( bSetReplace && !bAttributes )
1177cdf0e10cSrcweir aReplaceLB.SetText( aReplaceTxt );
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir aSearchLB.Show();
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir if ( bConstruct )
1182cdf0e10cSrcweir // nur nach dem Erzeugen den Fokus grappen
1183cdf0e10cSrcweir aSearchLB.GrabFocus();
1184cdf0e10cSrcweir aReplaceLB.Show();
1185cdf0e10cSrcweir aSearchTmplLB.Hide();
1186cdf0e10cSrcweir aReplaceTmplLB.Hide();
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir EnableControl_Impl( &aRegExpBtn );
1189cdf0e10cSrcweir EnableControl_Impl( &aMatchCaseCB );
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir if ( aRegExpBtn.IsChecked() )
1192cdf0e10cSrcweir aWordBtn.Disable();
1193cdf0e10cSrcweir else
1194cdf0e10cSrcweir EnableControl_Impl( &aWordBtn );
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir String aSrchAttrTxt;
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir if ( pImpl->bMultiLineEdit )
1199cdf0e10cSrcweir aSrchAttrTxt = pImpl->aSearchFormats.GetText();
1200cdf0e10cSrcweir else
1201cdf0e10cSrcweir aSrchAttrTxt = aSearchAttrText.GetText();
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir bDisableSearch = !aSearchLB.GetText().Len() && !aSrchAttrTxt.Len();
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir FocusHdl_Impl( &aSearchLB );
1206cdf0e10cSrcweir
1207cdf0e10cSrcweir if ( bDisableSearch )
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir aSearchBtn.Disable();
1210cdf0e10cSrcweir aSearchAllBtn.Disable();
1211cdf0e10cSrcweir aReplaceBtn.Disable();
1212cdf0e10cSrcweir aReplaceAllBtn.Disable();
1213cdf0e10cSrcweir aSearchComponentFL.Enable(sal_False);
1214cdf0e10cSrcweir aSearchComponent1PB.Enable(sal_False);
1215cdf0e10cSrcweir aSearchComponent2PB.Enable(sal_False);
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir else
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir EnableControl_Impl( &aSearchBtn );
1220cdf0e10cSrcweir EnableControl_Impl( &aReplaceBtn );
1221cdf0e10cSrcweir if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir EnableControl_Impl( &aSearchAllBtn );
1224cdf0e10cSrcweir EnableControl_Impl( &aReplaceAllBtn );
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir if (bWriter && pSearchItem->GetNotes())
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir aSearchAllBtn.Disable();
1229cdf0e10cSrcweir aReplaceAllBtn.Disable();
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir if ( ( !pImpl->bMultiLineEdit && aSearchAttrText.GetText().Len() ) ||
1234cdf0e10cSrcweir ( pImpl->bMultiLineEdit && pImpl->aSearchFormats.GetText().Len() ) )
1235cdf0e10cSrcweir EnableControl_Impl( &aNoFormatBtn );
1236cdf0e10cSrcweir else
1237cdf0e10cSrcweir aNoFormatBtn.Disable();
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir if ( !pSearchList )
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir aAttributeBtn.Disable();
1242cdf0e10cSrcweir aFormatBtn.Disable();
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir if ( aLayoutBtn.IsChecked() )
1246cdf0e10cSrcweir {
1247cdf0e10cSrcweir pImpl->bSaveToModule = sal_False;
1248cdf0e10cSrcweir TemplateHdl_Impl( &aLayoutBtn );
1249cdf0e10cSrcweir pImpl->bSaveToModule = sal_True;
1250cdf0e10cSrcweir }
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir // -----------------------------------------------------------------------
1254cdf0e10cSrcweir
InitAttrList_Impl(const SfxItemSet * pSSet,const SfxItemSet * pRSet)1255cdf0e10cSrcweir void SvxSearchDialog::InitAttrList_Impl( const SfxItemSet* pSSet,
1256cdf0e10cSrcweir const SfxItemSet* pRSet )
1257cdf0e10cSrcweir {
1258cdf0e10cSrcweir if ( !pSSet && !pRSet )
1259cdf0e10cSrcweir return;
1260cdf0e10cSrcweir
1261cdf0e10cSrcweir if ( !pImpl->pRanges && pSSet )
1262cdf0e10cSrcweir {
1263cdf0e10cSrcweir sal_sSize nCnt = 0;
1264cdf0e10cSrcweir const sal_uInt16* pPtr = pSSet->GetRanges();
1265cdf0e10cSrcweir const sal_uInt16* pTmp = pPtr;
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir while( *pPtr )
1268cdf0e10cSrcweir {
1269cdf0e10cSrcweir nCnt += ( *(pPtr+1) - *pPtr ) + 1;
1270cdf0e10cSrcweir pPtr += 2;
1271cdf0e10cSrcweir }
1272cdf0e10cSrcweir nCnt = pPtr - pTmp + 1;
1273cdf0e10cSrcweir pImpl->pRanges = new sal_uInt16[nCnt];
1274cdf0e10cSrcweir memcpy( pImpl->pRanges, pTmp, sizeof(sal_uInt16) * nCnt );
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir // sorge daf"ur, das die Texte der Attribute richtig stehen
1278cdf0e10cSrcweir String aDesc;
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir if ( pSSet )
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir delete pSearchList;
1283cdf0e10cSrcweir pSearchList = new SearchAttrItemList;
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir if ( pSSet->Count() )
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir pSearchList->Put( *pSSet );
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
1290cdf0e10cSrcweir aSearchAttrText.SetText( BuildAttrText_Impl( aDesc, sal_True ) );
1291cdf0e10cSrcweir else
1292cdf0e10cSrcweir pImpl->aSearchFormats.SetText( BuildAttrText_Impl( aDesc, sal_True ) );
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir if ( aDesc.Len() )
1295cdf0e10cSrcweir bFormat |= sal_True;
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir if ( pRSet )
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir delete pReplaceList;
1302cdf0e10cSrcweir pReplaceList = new SearchAttrItemList;
1303cdf0e10cSrcweir
1304cdf0e10cSrcweir if ( pRSet->Count() )
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir pReplaceList->Put( *pRSet );
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
1309cdf0e10cSrcweir aReplaceAttrText.SetText( BuildAttrText_Impl( aDesc, sal_False ) );
1310cdf0e10cSrcweir else
1311cdf0e10cSrcweir pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( aDesc, sal_False ) );
1312cdf0e10cSrcweir
1313cdf0e10cSrcweir if ( aDesc.Len() )
1314cdf0e10cSrcweir bFormat |= sal_True;
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir
1319cdf0e10cSrcweir // -----------------------------------------------------------------------
1320cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,FlagHdl_Impl,Control *,pCtrl)1321cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, Control *, pCtrl )
1322cdf0e10cSrcweir {
1323cdf0e10cSrcweir if ( pCtrl && !bSet )
1324cdf0e10cSrcweir SetModifyFlag_Impl( pCtrl );
1325cdf0e10cSrcweir else
1326cdf0e10cSrcweir bSet = sal_False;
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir if ( pCtrl == &aSimilarityBox )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir sal_Bool bIsChecked = aSimilarityBox.IsChecked();
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir if ( bIsChecked )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir aSimilarityBtn.Enable();
1335cdf0e10cSrcweir aRegExpBtn.Check( sal_False );
1336cdf0e10cSrcweir aRegExpBtn.Disable();
1337cdf0e10cSrcweir EnableControl_Impl( &aWordBtn );
1338cdf0e10cSrcweir
1339cdf0e10cSrcweir if ( aLayoutBtn.IsChecked() )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir EnableControl_Impl( &aMatchCaseCB );
1342cdf0e10cSrcweir aLayoutBtn.Check( sal_False );
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir aRegExpBtn.Disable();
1345cdf0e10cSrcweir aLayoutBtn.Disable();
1346cdf0e10cSrcweir aFormatBtn.Disable();
1347cdf0e10cSrcweir aNoFormatBtn.Disable();
1348cdf0e10cSrcweir aAttributeBtn.Disable();
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir else
1351cdf0e10cSrcweir {
1352cdf0e10cSrcweir EnableControl_Impl( &aRegExpBtn );
1353cdf0e10cSrcweir if (!aNotesBtn.IsChecked())
1354cdf0e10cSrcweir EnableControl_Impl( &aLayoutBtn );
1355cdf0e10cSrcweir EnableControl_Impl( &aFormatBtn );
1356cdf0e10cSrcweir EnableControl_Impl( &aAttributeBtn );
1357cdf0e10cSrcweir aSimilarityBtn.Disable();
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir pSearchItem->SetLevenshtein( bIsChecked );
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir else
1362cdf0e10cSrcweir if ( pCtrl == &aNotesBtn)
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir if (aNotesBtn.IsChecked())
1365cdf0e10cSrcweir {
1366cdf0e10cSrcweir aLayoutBtn.Disable();
1367cdf0e10cSrcweir aSearchAllBtn.Disable();
1368cdf0e10cSrcweir aReplaceAllBtn.Disable();
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir else
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir EnableControl_Impl( &aLayoutBtn );
1373cdf0e10cSrcweir ModifyHdl_Impl( &aSearchLB );
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir }
1376cdf0e10cSrcweir else
1377cdf0e10cSrcweir {
1378cdf0e10cSrcweir if ( aLayoutBtn.IsChecked() && !bFormat )
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir aWordBtn.Check( sal_False );
1381cdf0e10cSrcweir aWordBtn.Disable();
1382cdf0e10cSrcweir aRegExpBtn.Check( sal_False );
1383cdf0e10cSrcweir aRegExpBtn.Disable();
1384cdf0e10cSrcweir aMatchCaseCB.Check( sal_False );
1385cdf0e10cSrcweir aMatchCaseCB.Disable();
1386cdf0e10cSrcweir aNotesBtn.Disable();
1387cdf0e10cSrcweir
1388cdf0e10cSrcweir if ( aSearchTmplLB.GetEntryCount() )
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir EnableControl_Impl( &aSearchBtn );
1391cdf0e10cSrcweir EnableControl_Impl( &aSearchAllBtn );
1392cdf0e10cSrcweir EnableControl_Impl( &aReplaceBtn );
1393cdf0e10cSrcweir EnableControl_Impl( &aReplaceAllBtn );
1394cdf0e10cSrcweir }
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir else
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir EnableControl_Impl( &aRegExpBtn );
1399cdf0e10cSrcweir EnableControl_Impl( &aMatchCaseCB );
1400cdf0e10cSrcweir EnableControl_Impl( &aNotesBtn );
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir if ( aRegExpBtn.IsChecked() )
1403cdf0e10cSrcweir {
1404cdf0e10cSrcweir aWordBtn.Check( sal_False );
1405cdf0e10cSrcweir aWordBtn.Disable();
1406cdf0e10cSrcweir aSimilarityBox.Disable();
1407cdf0e10cSrcweir aSimilarityBtn.Disable();
1408cdf0e10cSrcweir }
1409cdf0e10cSrcweir else
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir EnableControl_Impl( &aWordBtn );
1412cdf0e10cSrcweir EnableControl_Impl( &aSimilarityBox );
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir
1415cdf0e10cSrcweir // Such-String vorhanden? dann Buttons enablen
1416cdf0e10cSrcweir bSet = sal_True;
1417cdf0e10cSrcweir ModifyHdl_Impl( &aSearchLB );
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir }
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir if ( &aAllSheetsCB == pCtrl )
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir if ( aAllSheetsCB.IsChecked() )
1424cdf0e10cSrcweir aSearchAllBtn.Disable();
1425cdf0e10cSrcweir else
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir bSet = sal_True;
1428cdf0e10cSrcweir ModifyHdl_Impl( &aSearchLB );
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir
1432cdf0e10cSrcweir if ( &aJapOptionsCB == pCtrl )
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir sal_Bool bEnableJapOpt = aJapOptionsCB.IsChecked();
1435cdf0e10cSrcweir aMatchCaseCB .Enable(!bEnableJapOpt );
1436cdf0e10cSrcweir aJapMatchFullHalfWidthCB.Enable(!bEnableJapOpt );
1437cdf0e10cSrcweir aJapOptionsBtn .Enable( bEnableJapOpt );
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir
1440cdf0e10cSrcweir if ( pImpl->bSaveToModule )
1441cdf0e10cSrcweir SaveToModule_Impl();
1442cdf0e10cSrcweir return 0;
1443cdf0e10cSrcweir }
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir // -----------------------------------------------------------------------
1446cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,CommandHdl_Impl,Button *,pBtn)1447cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir bool bInclusive = ( aLayoutBtn.GetText() == aLayoutStr );
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir if ( ( pBtn == &aSearchBtn ) ||
1452cdf0e10cSrcweir ( pBtn == &aSearchAllBtn ) ||
1453cdf0e10cSrcweir ( pBtn == &aReplaceBtn ) ||
1454cdf0e10cSrcweir ( pBtn == &aReplaceAllBtn ) )
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir if ( aLayoutBtn.IsChecked() && !bInclusive )
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
1459cdf0e10cSrcweir pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
1460cdf0e10cSrcweir }
1461cdf0e10cSrcweir else
1462cdf0e10cSrcweir {
1463cdf0e10cSrcweir pSearchItem->SetSearchString ( aSearchLB.GetText() );
1464cdf0e10cSrcweir pSearchItem->SetReplaceString( aReplaceLB.GetText() );
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir if ( pBtn == &aReplaceBtn )
1467cdf0e10cSrcweir Remember_Impl( aReplaceLB.GetText(), sal_False );
1468cdf0e10cSrcweir else
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir Remember_Impl( aSearchLB.GetText(), sal_True );
1471cdf0e10cSrcweir
1472cdf0e10cSrcweir if ( pBtn == &aReplaceAllBtn )
1473cdf0e10cSrcweir Remember_Impl( aReplaceLB.GetText(), sal_False );
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir }
1476cdf0e10cSrcweir
1477cdf0e10cSrcweir pSearchItem->SetRegExp( sal_False );
1478cdf0e10cSrcweir pSearchItem->SetLevenshtein( sal_False );
1479cdf0e10cSrcweir if (GetCheckBoxValue( aRegExpBtn ))
1480cdf0e10cSrcweir pSearchItem->SetRegExp( sal_True );
1481cdf0e10cSrcweir else if (GetCheckBoxValue( aSimilarityBox ))
1482cdf0e10cSrcweir pSearchItem->SetLevenshtein( sal_True );
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
1485cdf0e10cSrcweir pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
1486cdf0e10cSrcweir pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
1487cdf0e10cSrcweir pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
1488cdf0e10cSrcweir pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
1489cdf0e10cSrcweir
1490cdf0e10cSrcweir pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
1491cdf0e10cSrcweir sal_Int32 nFlags = GetTransliterationFlags();
1492cdf0e10cSrcweir if( !pSearchItem->IsUseAsianOptions())
1493cdf0e10cSrcweir nFlags &= (TransliterationModules_IGNORE_CASE |
1494cdf0e10cSrcweir TransliterationModules_IGNORE_WIDTH );
1495cdf0e10cSrcweir pSearchItem->SetTransliterationFlags( nFlags );
1496cdf0e10cSrcweir
1497cdf0e10cSrcweir if ( !bWriter )
1498cdf0e10cSrcweir {
1499cdf0e10cSrcweir if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
1500cdf0e10cSrcweir pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
1501cdf0e10cSrcweir
1502cdf0e10cSrcweir pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
1503cdf0e10cSrcweir pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
1504cdf0e10cSrcweir }
1505cdf0e10cSrcweir
1506cdf0e10cSrcweir if ( pBtn == &aSearchBtn )
1507cdf0e10cSrcweir pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
1508cdf0e10cSrcweir else if ( pBtn == &aSearchAllBtn )
1509cdf0e10cSrcweir pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
1510cdf0e10cSrcweir else if ( pBtn == &aReplaceBtn )
1511cdf0e10cSrcweir pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE );
1512cdf0e10cSrcweir else if ( pBtn == &aReplaceAllBtn )
1513cdf0e10cSrcweir pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
1514cdf0e10cSrcweir
1515cdf0e10cSrcweir // wenn nach Vorlagen gesucht wird, dann Format-Listen l"oschen
1516cdf0e10cSrcweir if ( !bFormat && pSearchItem->GetPattern() )
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir if ( pSearchList )
1519cdf0e10cSrcweir pSearchList->Clear();
1520cdf0e10cSrcweir
1521cdf0e10cSrcweir if ( pReplaceList )
1522cdf0e10cSrcweir pReplaceList->Clear();
1523cdf0e10cSrcweir }
1524cdf0e10cSrcweir nModifyFlag = 0;
1525cdf0e10cSrcweir const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
1526cdf0e10cSrcweir rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs, 0L );
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir else if ( pBtn == &aCloseBtn )
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir if ( !aLayoutBtn.IsChecked() || bInclusive )
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir String aStr( aSearchLB.GetText() );
1533cdf0e10cSrcweir
1534cdf0e10cSrcweir if ( aStr.Len() )
1535cdf0e10cSrcweir Remember_Impl( aStr, sal_True );
1536cdf0e10cSrcweir aStr = aReplaceLB.GetText();
1537cdf0e10cSrcweir
1538cdf0e10cSrcweir if ( aStr.Len() )
1539cdf0e10cSrcweir Remember_Impl( aStr, sal_False );
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir SaveToModule_Impl();
1542cdf0e10cSrcweir Close();
1543cdf0e10cSrcweir }
1544cdf0e10cSrcweir else if ( pBtn == &aSimilarityBtn )
1545cdf0e10cSrcweir {
1546cdf0e10cSrcweir //CHINA001 SvxSearchSimilarityDialog* pDlg =
1547cdf0e10cSrcweir //CHINA001 new SvxSearchSimilarityDialog( this,
1548cdf0e10cSrcweir //CHINA001 pSearchItem->IsLEVRelaxed(),
1549cdf0e10cSrcweir //CHINA001 pSearchItem->GetLEVOther(),
1550cdf0e10cSrcweir //CHINA001 pSearchItem->GetLEVShorter(),
1551cdf0e10cSrcweir //CHINA001 pSearchItem->GetLEVLonger() );
1552cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1553cdf0e10cSrcweir if(pFact)
1554cdf0e10cSrcweir {
1555cdf0e10cSrcweir AbstractSvxSearchSimilarityDialog* pDlg = pFact->CreateSvxSearchSimilarityDialog( LAYOUT_THIS_WINDOW (this),
1556cdf0e10cSrcweir pSearchItem->IsLEVRelaxed(),
1557cdf0e10cSrcweir pSearchItem->GetLEVOther(),
1558cdf0e10cSrcweir pSearchItem->GetLEVShorter(),
1559cdf0e10cSrcweir pSearchItem->GetLEVLonger() );
1560cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
1561cdf0e10cSrcweir if ( pDlg && pDlg->Execute() == RET_OK )
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
1564cdf0e10cSrcweir pSearchItem->SetLEVOther( pDlg->GetOther() );
1565cdf0e10cSrcweir pSearchItem->SetLEVShorter( pDlg->GetShorter() );
1566cdf0e10cSrcweir pSearchItem->SetLEVLonger( pDlg->GetLonger() );
1567cdf0e10cSrcweir SaveToModule_Impl();
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir delete pDlg;
1570cdf0e10cSrcweir }
1571cdf0e10cSrcweir }
1572cdf0e10cSrcweir else if ( pBtn == &aJapOptionsBtn )
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir SfxItemSet aSet( SFX_APP()->GetPool() );
1575cdf0e10cSrcweir pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
1576cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1577cdf0e10cSrcweir if(pFact)
1578cdf0e10cSrcweir {
1579cdf0e10cSrcweir AbstractSvxJSearchOptionsDialog* aDlg = pFact->CreateSvxJSearchOptionsDialog( LAYOUT_THIS_WINDOW (this), aSet,
1580cdf0e10cSrcweir pSearchItem->GetTransliterationFlags() );
1581cdf0e10cSrcweir DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
1582cdf0e10cSrcweir int nRet = aDlg->Execute(); //CHINA001 int nRet = aDlg.Execute();
1583cdf0e10cSrcweir if (RET_OK == nRet) //! true only if FillItemSet of SvxJSearchOptionsPage returns true
1584cdf0e10cSrcweir {
1585cdf0e10cSrcweir sal_Int32 nFlags = aDlg->GetTransliterationFlags(); //CHINA001 sal_Int32 nFlags = aDlg.GetTransliterationFlags();
1586cdf0e10cSrcweir pSearchItem->SetTransliterationFlags( nFlags );
1587cdf0e10cSrcweir ApplyTransliterationFlags_Impl( nFlags );
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir delete aDlg; //add for CHINA001
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir else if(pBtn == &aSearchComponent1PB || pBtn == &aSearchComponent2PB )
1593cdf0e10cSrcweir {
1594cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aArgs(2);
1595cdf0e10cSrcweir beans::PropertyValue* pArgs = aArgs.getArray();
1596cdf0e10cSrcweir pArgs[0].Name = ::rtl::OUString::createFromAscii("SearchString");
1597cdf0e10cSrcweir pArgs[0].Value <<= ::rtl::OUString(aSearchLB.GetText());
1598cdf0e10cSrcweir pArgs[1].Name = ::rtl::OUString::createFromAscii("ParentWindow");
1599cdf0e10cSrcweir pArgs[1].Value <<= VCLUnoHelper::GetInterface( LAYOUT_THIS_WINDOW (this) );
1600cdf0e10cSrcweir if(pBtn == &aSearchComponent1PB)
1601cdf0e10cSrcweir {
1602cdf0e10cSrcweir if ( pImpl->xCommand1Dispatch.is() )
1603cdf0e10cSrcweir pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1604cdf0e10cSrcweir }
1605cdf0e10cSrcweir else
1606cdf0e10cSrcweir {
1607cdf0e10cSrcweir if ( pImpl->xCommand2Dispatch.is() )
1608cdf0e10cSrcweir pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1609cdf0e10cSrcweir }
1610cdf0e10cSrcweir }
1611cdf0e10cSrcweir
1612cdf0e10cSrcweir return 0;
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir
1615cdf0e10cSrcweir // -----------------------------------------------------------------------
1616cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,ModifyHdl_Impl,ComboBox *,pEd)1617cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, ComboBox *, pEd )
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir if ( !bSet )
1620cdf0e10cSrcweir SetModifyFlag_Impl( pEd );
1621cdf0e10cSrcweir else
1622cdf0e10cSrcweir bSet = sal_False;
1623cdf0e10cSrcweir
1624cdf0e10cSrcweir if ( pEd == &aSearchLB || pEd == &aReplaceLB )
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir xub_StrLen nLBTxtLen = aSearchLB.GetText().Len(), nTxtLen;
1627cdf0e10cSrcweir
1628cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
1629cdf0e10cSrcweir nTxtLen = aSearchAttrText.GetText().Len();
1630cdf0e10cSrcweir else
1631cdf0e10cSrcweir nTxtLen = pImpl->aSearchFormats.GetText().Len();
1632cdf0e10cSrcweir
1633cdf0e10cSrcweir if ( nLBTxtLen || nTxtLen )
1634cdf0e10cSrcweir {
1635cdf0e10cSrcweir EnableControl_Impl( &aSearchBtn );
1636cdf0e10cSrcweir EnableControl_Impl( &aReplaceBtn );
1637cdf0e10cSrcweir if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir EnableControl_Impl( &aSearchAllBtn );
1640cdf0e10cSrcweir EnableControl_Impl( &aReplaceAllBtn );
1641cdf0e10cSrcweir }
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir else
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir aSearchComponentFL.Enable(sal_False);
1646cdf0e10cSrcweir aSearchComponent1PB.Enable(sal_False);
1647cdf0e10cSrcweir aSearchComponent2PB.Enable(sal_False);
1648cdf0e10cSrcweir aSearchBtn.Disable();
1649cdf0e10cSrcweir aSearchAllBtn.Disable();
1650cdf0e10cSrcweir aReplaceBtn.Disable();
1651cdf0e10cSrcweir aReplaceAllBtn.Disable();
1652cdf0e10cSrcweir }
1653cdf0e10cSrcweir }
1654cdf0e10cSrcweir return 0;
1655cdf0e10cSrcweir }
1656cdf0e10cSrcweir
1657cdf0e10cSrcweir // -----------------------------------------------------------------------
1658cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,TemplateHdl_Impl,Button *,EMPTYARG)1659cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, TemplateHdl_Impl, Button *, EMPTYARG )
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir if ( pImpl->bSaveToModule )
1662cdf0e10cSrcweir SaveToModule_Impl();
1663cdf0e10cSrcweir
1664cdf0e10cSrcweir if ( bFormat )
1665cdf0e10cSrcweir return 0;
1666cdf0e10cSrcweir String sDesc;
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir if ( aLayoutBtn.IsChecked() )
1669cdf0e10cSrcweir {
1670cdf0e10cSrcweir if ( !pFamilyController )
1671cdf0e10cSrcweir {
1672cdf0e10cSrcweir sal_uInt16 nId = 0;
1673cdf0e10cSrcweir
1674cdf0e10cSrcweir // Vorlagen-Controller enablen
1675cdf0e10cSrcweir switch ( pSearchItem->GetFamily() )
1676cdf0e10cSrcweir {
1677cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
1678cdf0e10cSrcweir nId = SID_STYLE_FAMILY1; break;
1679cdf0e10cSrcweir
1680cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
1681cdf0e10cSrcweir nId = SID_STYLE_FAMILY2; break;
1682cdf0e10cSrcweir
1683cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
1684cdf0e10cSrcweir nId = SID_STYLE_FAMILY3; break;
1685cdf0e10cSrcweir
1686cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
1687cdf0e10cSrcweir nId = SID_STYLE_FAMILY4; break;
1688cdf0e10cSrcweir
1689cdf0e10cSrcweir case SFX_STYLE_FAMILY_ALL:
1690cdf0e10cSrcweir break;
1691cdf0e10cSrcweir
1692cdf0e10cSrcweir default:
1693cdf0e10cSrcweir DBG_ERROR( "StyleSheetFamily wurde geaendert?" );
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir rBindings.EnterRegistrations();
1697cdf0e10cSrcweir pFamilyController =
1698cdf0e10cSrcweir new SvxSearchController( nId, rBindings, *this );
1699cdf0e10cSrcweir rBindings.LeaveRegistrations();
1700cdf0e10cSrcweir aSearchTmplLB.Clear();
1701cdf0e10cSrcweir aReplaceTmplLB.Clear();
1702cdf0e10cSrcweir
1703cdf0e10cSrcweir aSearchTmplLB.Show();
1704cdf0e10cSrcweir aReplaceTmplLB.Show();
1705cdf0e10cSrcweir aSearchLB.Hide();
1706cdf0e10cSrcweir aReplaceLB.Hide();
1707cdf0e10cSrcweir
1708cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir aSearchAttrText.SetText( sDesc );
1711cdf0e10cSrcweir aReplaceAttrText.SetText( sDesc );
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir else
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir pImpl->aSearchFormats.SetText( sDesc );
1716cdf0e10cSrcweir pImpl->aReplaceFormats.SetText( sDesc );
1717cdf0e10cSrcweir }
1718cdf0e10cSrcweir }
1719cdf0e10cSrcweir aFormatBtn.Disable();
1720cdf0e10cSrcweir aNoFormatBtn.Disable();
1721cdf0e10cSrcweir aAttributeBtn.Disable();
1722cdf0e10cSrcweir aSimilarityBox.Disable();
1723cdf0e10cSrcweir aSimilarityBtn.Disable();
1724cdf0e10cSrcweir }
1725cdf0e10cSrcweir else
1726cdf0e10cSrcweir {
1727cdf0e10cSrcweir // Vorlagen-Controller disablen
1728cdf0e10cSrcweir rBindings.EnterRegistrations();
1729cdf0e10cSrcweir DELETEZ( pFamilyController );
1730cdf0e10cSrcweir rBindings.LeaveRegistrations();
1731cdf0e10cSrcweir
1732cdf0e10cSrcweir aSearchLB.Show();
1733cdf0e10cSrcweir aReplaceLB.Show();
1734cdf0e10cSrcweir aSearchTmplLB.Hide();
1735cdf0e10cSrcweir aReplaceTmplLB.Hide();
1736cdf0e10cSrcweir
1737cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
1738cdf0e10cSrcweir {
1739cdf0e10cSrcweir aSearchAttrText.SetText( BuildAttrText_Impl( sDesc, sal_True ) );
1740cdf0e10cSrcweir aReplaceAttrText.SetText( BuildAttrText_Impl( sDesc, sal_False ) );
1741cdf0e10cSrcweir }
1742cdf0e10cSrcweir else
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir pImpl->aSearchFormats.SetText( BuildAttrText_Impl( sDesc, sal_True ) );
1745cdf0e10cSrcweir pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( sDesc, sal_False ) );
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir
1748cdf0e10cSrcweir EnableControl_Impl( &aFormatBtn );
1749cdf0e10cSrcweir EnableControl_Impl( &aAttributeBtn );
1750cdf0e10cSrcweir EnableControl_Impl( &aSimilarityBox );
1751cdf0e10cSrcweir
1752cdf0e10cSrcweir FocusHdl_Impl( bSearch ? &aSearchLB : &aReplaceLB );
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir bSet = sal_True;
1755cdf0e10cSrcweir pImpl->bSaveToModule = sal_False;
1756cdf0e10cSrcweir FlagHdl_Impl( &aLayoutBtn );
1757cdf0e10cSrcweir pImpl->bSaveToModule = sal_True;
1758cdf0e10cSrcweir return 0;
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir
1761cdf0e10cSrcweir // -----------------------------------------------------------------------
1762cdf0e10cSrcweir
Remember_Impl(const String & rStr,sal_Bool _bSearch)1763cdf0e10cSrcweir void SvxSearchDialog::Remember_Impl( const String &rStr,sal_Bool _bSearch )
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir if ( !rStr.Len() )
1766cdf0e10cSrcweir return;
1767cdf0e10cSrcweir
1768cdf0e10cSrcweir SvStringsDtor* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
1769cdf0e10cSrcweir ComboBox* pListBox = _bSearch ? &aSearchLB : &aReplaceLB;
1770cdf0e10cSrcweir
1771cdf0e10cSrcweir // identische Strings ignorieren
1772cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < pArr->Count(); ++i )
1773cdf0e10cSrcweir {
1774cdf0e10cSrcweir if ( COMPARE_EQUAL == (*pArr)[i]->CompareTo( rStr ) )
1775cdf0e10cSrcweir return;
1776cdf0e10cSrcweir }
1777cdf0e10cSrcweir
1778cdf0e10cSrcweir // bei maximaler Belegung "altesten Eintrag l"oschen (ListBox und Array)
1779cdf0e10cSrcweir String* pInsStr;
1780cdf0e10cSrcweir
1781cdf0e10cSrcweir if ( pArr->Count() >= REMEMBER_SIZE )
1782cdf0e10cSrcweir {
1783cdf0e10cSrcweir pInsStr = (*pArr)[REMEMBER_SIZE - 1];
1784cdf0e10cSrcweir pListBox->RemoveEntry( sal_uInt16(REMEMBER_SIZE - 1) );
1785cdf0e10cSrcweir pArr->Remove( REMEMBER_SIZE - 1 );
1786cdf0e10cSrcweir *pInsStr = rStr;
1787cdf0e10cSrcweir }
1788cdf0e10cSrcweir else
1789cdf0e10cSrcweir pInsStr = new String( rStr );
1790cdf0e10cSrcweir
1791cdf0e10cSrcweir pArr->Insert( pInsStr, 0 );
1792cdf0e10cSrcweir pListBox->InsertEntry( *pInsStr, 0 );
1793cdf0e10cSrcweir }
1794cdf0e10cSrcweir
1795cdf0e10cSrcweir // -----------------------------------------------------------------------
1796cdf0e10cSrcweir
TemplatesChanged_Impl(SfxStyleSheetBasePool & rPool)1797cdf0e10cSrcweir void SvxSearchDialog::TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool )
1798cdf0e10cSrcweir {
1799cdf0e10cSrcweir // SetUpdateMode( sal_False );
1800cdf0e10cSrcweir String aOldSrch( aSearchTmplLB .GetSelectEntry() );
1801cdf0e10cSrcweir String aOldRepl( aReplaceTmplLB.GetSelectEntry() );
1802cdf0e10cSrcweir aSearchTmplLB .Clear();
1803cdf0e10cSrcweir aReplaceTmplLB.Clear();
1804cdf0e10cSrcweir rPool.SetSearchMask( pSearchItem->GetFamily(), SFXSTYLEBIT_ALL );
1805cdf0e10cSrcweir aSearchTmplLB.SetUpdateMode( sal_False );
1806cdf0e10cSrcweir aReplaceTmplLB.SetUpdateMode( sal_False );
1807cdf0e10cSrcweir SfxStyleSheetBase* pBase = rPool.First();
1808cdf0e10cSrcweir
1809cdf0e10cSrcweir while ( pBase )
1810cdf0e10cSrcweir {
1811cdf0e10cSrcweir if ( pBase->IsUsed() )
1812cdf0e10cSrcweir aSearchTmplLB.InsertEntry( pBase->GetName() );
1813cdf0e10cSrcweir aReplaceTmplLB.InsertEntry( pBase->GetName() );
1814cdf0e10cSrcweir pBase = rPool.Next();
1815cdf0e10cSrcweir }
1816cdf0e10cSrcweir aSearchTmplLB.SetUpdateMode( sal_True );
1817cdf0e10cSrcweir aReplaceTmplLB.SetUpdateMode( sal_True );
1818cdf0e10cSrcweir aSearchTmplLB.SelectEntryPos(0);
1819cdf0e10cSrcweir
1820cdf0e10cSrcweir if ( aOldSrch.Len() )
1821cdf0e10cSrcweir aSearchTmplLB .SelectEntry( aOldSrch );
1822cdf0e10cSrcweir aReplaceTmplLB.SelectEntryPos(0);
1823cdf0e10cSrcweir
1824cdf0e10cSrcweir if ( aOldRepl.Len() )
1825cdf0e10cSrcweir aReplaceTmplLB.SelectEntry( aOldRepl );
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir if ( aSearchTmplLB.GetEntryCount() )
1828cdf0e10cSrcweir {
1829cdf0e10cSrcweir EnableControl_Impl( &aSearchBtn );
1830cdf0e10cSrcweir EnableControl_Impl( &aSearchAllBtn );
1831cdf0e10cSrcweir EnableControl_Impl( &aReplaceBtn );
1832cdf0e10cSrcweir EnableControl_Impl( &aReplaceAllBtn );
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir // FlagHdl_Impl(0);
1835cdf0e10cSrcweir // SetUpdateMode( sal_True );
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir
1838cdf0e10cSrcweir // -----------------------------------------------------------------------
1839cdf0e10cSrcweir
EnableControls_Impl(const sal_uInt16 nFlags)1840cdf0e10cSrcweir void SvxSearchDialog::EnableControls_Impl( const sal_uInt16 nFlags )
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir if ( nFlags == nOptions )
1843cdf0e10cSrcweir return;
1844cdf0e10cSrcweir else
1845cdf0e10cSrcweir nOptions = nFlags;
1846cdf0e10cSrcweir
1847cdf0e10cSrcweir if ( !nOptions )
1848cdf0e10cSrcweir {
1849cdf0e10cSrcweir if ( IsVisible() )
1850cdf0e10cSrcweir {
1851cdf0e10cSrcweir Hide();
1852cdf0e10cSrcweir return;
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir }
1855cdf0e10cSrcweir else if ( !IsVisible() )
1856cdf0e10cSrcweir Show();
1857cdf0e10cSrcweir bool bNoSearch = sal_True;
1858cdf0e10cSrcweir
1859cdf0e10cSrcweir sal_Bool bEnableSearch = ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0;
1860cdf0e10cSrcweir aSearchBtn.Enable(bEnableSearch);
1861cdf0e10cSrcweir
1862cdf0e10cSrcweir if( bEnableSearch )
1863cdf0e10cSrcweir bNoSearch = sal_False;
1864cdf0e10cSrcweir
1865cdf0e10cSrcweir
1866cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
1867cdf0e10cSrcweir {
1868cdf0e10cSrcweir aSearchAllBtn.Enable();
1869cdf0e10cSrcweir bNoSearch = sal_False;
1870cdf0e10cSrcweir }
1871cdf0e10cSrcweir else
1872cdf0e10cSrcweir aSearchAllBtn.Disable();
1873cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
1874cdf0e10cSrcweir {
1875cdf0e10cSrcweir aReplaceBtn.Enable();
1876cdf0e10cSrcweir aReplaceText.Enable();
1877cdf0e10cSrcweir aReplaceLB.Enable();
1878cdf0e10cSrcweir aReplaceTmplLB.Enable();
1879cdf0e10cSrcweir bNoSearch = sal_False;
1880cdf0e10cSrcweir }
1881cdf0e10cSrcweir else
1882cdf0e10cSrcweir {
1883cdf0e10cSrcweir aReplaceBtn.Disable();
1884cdf0e10cSrcweir aReplaceText.Disable();
1885cdf0e10cSrcweir aReplaceLB.Disable();
1886cdf0e10cSrcweir aReplaceTmplLB.Disable();
1887cdf0e10cSrcweir }
1888cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir aReplaceAllBtn.Enable();
1891cdf0e10cSrcweir bNoSearch = sal_False;
1892cdf0e10cSrcweir }
1893cdf0e10cSrcweir else
1894cdf0e10cSrcweir aReplaceAllBtn.Disable();
1895cdf0e10cSrcweir aSearchComponentFL.Enable(!bNoSearch);
1896cdf0e10cSrcweir aSearchComponent1PB.Enable(!bNoSearch);
1897cdf0e10cSrcweir aSearchComponent2PB.Enable(!bNoSearch);
1898cdf0e10cSrcweir aSearchBtn.Enable( !bNoSearch );
1899cdf0e10cSrcweir aSearchText.Enable( !bNoSearch );
1900cdf0e10cSrcweir aSearchLB.Enable( !bNoSearch );
1901cdf0e10cSrcweir
1902cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
1903cdf0e10cSrcweir aWordBtn.Enable();
1904cdf0e10cSrcweir else
1905cdf0e10cSrcweir aWordBtn.Disable();
1906cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
1907cdf0e10cSrcweir aBackwardsBtn.Enable();
1908cdf0e10cSrcweir else
1909cdf0e10cSrcweir aBackwardsBtn.Disable();
1910cdf0e10cSrcweir //!if ( ( SEARCH_OPTIONS_NOTES & nOptions ) != 0 )
1911cdf0e10cSrcweir aNotesBtn.Enable();
1912cdf0e10cSrcweir //!else
1913cdf0e10cSrcweir //! aNotesBtn.Disable();
1914cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0 )
1915cdf0e10cSrcweir aRegExpBtn.Enable();
1916cdf0e10cSrcweir else
1917cdf0e10cSrcweir aRegExpBtn.Disable();
1918cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
1919cdf0e10cSrcweir aMatchCaseCB.Enable();
1920cdf0e10cSrcweir else
1921cdf0e10cSrcweir aMatchCaseCB.Disable();
1922cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
1923cdf0e10cSrcweir aSelectionBtn.Enable();
1924cdf0e10cSrcweir else
1925cdf0e10cSrcweir aSelectionBtn.Disable();
1926cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
1927cdf0e10cSrcweir aLayoutBtn.Enable();
1928cdf0e10cSrcweir else
1929cdf0e10cSrcweir aLayoutBtn.Disable();
1930cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
1931cdf0e10cSrcweir {
1932cdf0e10cSrcweir aAttributeBtn.Enable();
1933cdf0e10cSrcweir aFormatBtn.Enable();
1934cdf0e10cSrcweir aNoFormatBtn.Enable();
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir else
1937cdf0e10cSrcweir {
1938cdf0e10cSrcweir aAttributeBtn.Disable();
1939cdf0e10cSrcweir aFormatBtn.Disable();
1940cdf0e10cSrcweir aNoFormatBtn.Disable();
1941cdf0e10cSrcweir }
1942cdf0e10cSrcweir /*
1943cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_MORE & nOptions ) != 0 &&
1944cdf0e10cSrcweir pSearchItem && pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
1945cdf0e10cSrcweir pMoreBtn->Enable();
1946cdf0e10cSrcweir else
1947cdf0e10cSrcweir {
1948cdf0e10cSrcweir pMoreBtn->SetState( sal_False );
1949cdf0e10cSrcweir pMoreBtn->Disable();
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir */
1952cdf0e10cSrcweir if ( ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir aSimilarityBox.Enable();
1955cdf0e10cSrcweir aSimilarityBtn.Enable();
1956cdf0e10cSrcweir }
1957cdf0e10cSrcweir else
1958cdf0e10cSrcweir {
1959cdf0e10cSrcweir aSimilarityBox.Disable();
1960cdf0e10cSrcweir aSimilarityBtn.Disable();
1961cdf0e10cSrcweir }
1962cdf0e10cSrcweir
1963cdf0e10cSrcweir if ( pSearchItem )
1964cdf0e10cSrcweir Init_Impl( pSearchItem->GetPattern() &&
1965cdf0e10cSrcweir ( !pSearchList || !pSearchList->Count() ) );
1966cdf0e10cSrcweir }
1967cdf0e10cSrcweir
1968cdf0e10cSrcweir // -----------------------------------------------------------------------
1969cdf0e10cSrcweir
EnableControl_Impl(Control * pCtrl)1970cdf0e10cSrcweir void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir if ( &aSearchBtn == pCtrl && ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0 )
1973cdf0e10cSrcweir {
1974cdf0e10cSrcweir aSearchComponentFL.Enable();
1975cdf0e10cSrcweir aSearchComponent1PB.Enable();
1976cdf0e10cSrcweir aSearchComponent2PB.Enable();
1977cdf0e10cSrcweir aSearchBtn.Enable();
1978cdf0e10cSrcweir return;
1979cdf0e10cSrcweir }
1980cdf0e10cSrcweir if ( &aSearchAllBtn == pCtrl &&
1981cdf0e10cSrcweir ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
1982cdf0e10cSrcweir {
1983cdf0e10cSrcweir aSearchAllBtn.Enable( ( bWriter || !aAllSheetsCB.IsChecked() ) );
1984cdf0e10cSrcweir return;
1985cdf0e10cSrcweir }
1986cdf0e10cSrcweir if ( &aReplaceBtn == pCtrl && ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
1987cdf0e10cSrcweir {
1988cdf0e10cSrcweir aReplaceBtn.Enable();
1989cdf0e10cSrcweir return;
1990cdf0e10cSrcweir }
1991cdf0e10cSrcweir if ( &aReplaceAllBtn == pCtrl &&
1992cdf0e10cSrcweir ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
1993cdf0e10cSrcweir {
1994cdf0e10cSrcweir aReplaceAllBtn.Enable();
1995cdf0e10cSrcweir return;
1996cdf0e10cSrcweir }
1997cdf0e10cSrcweir if ( &aWordBtn == pCtrl && ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
1998cdf0e10cSrcweir {
1999cdf0e10cSrcweir aWordBtn.Enable();
2000cdf0e10cSrcweir return;
2001cdf0e10cSrcweir }
2002cdf0e10cSrcweir if ( &aBackwardsBtn == pCtrl && ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
2003cdf0e10cSrcweir {
2004cdf0e10cSrcweir aBackwardsBtn.Enable();
2005cdf0e10cSrcweir return;
2006cdf0e10cSrcweir }
2007cdf0e10cSrcweir if ( &aNotesBtn == pCtrl /*! && ( SEARCH_OPTIONS_NOTES & nOptions ) != 0 */ )
2008cdf0e10cSrcweir {
2009cdf0e10cSrcweir aNotesBtn.Enable();
2010cdf0e10cSrcweir return;
2011cdf0e10cSrcweir }
2012cdf0e10cSrcweir if ( &aRegExpBtn == pCtrl && ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0
2013cdf0e10cSrcweir && !aSimilarityBox.IsChecked())
2014cdf0e10cSrcweir {
2015cdf0e10cSrcweir aRegExpBtn.Enable();
2016cdf0e10cSrcweir return;
2017cdf0e10cSrcweir }
2018cdf0e10cSrcweir if ( &aMatchCaseCB == pCtrl && ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
2019cdf0e10cSrcweir {
2020cdf0e10cSrcweir if (!aJapOptionsCB.IsChecked())
2021cdf0e10cSrcweir aMatchCaseCB.Enable();
2022cdf0e10cSrcweir return;
2023cdf0e10cSrcweir }
2024cdf0e10cSrcweir if ( &aSelectionBtn == pCtrl && ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
2025cdf0e10cSrcweir {
2026cdf0e10cSrcweir aSelectionBtn.Enable();
2027cdf0e10cSrcweir return;
2028cdf0e10cSrcweir }
2029cdf0e10cSrcweir if ( &aLayoutBtn == pCtrl && ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
2030cdf0e10cSrcweir {
2031cdf0e10cSrcweir aLayoutBtn.Enable();
2032cdf0e10cSrcweir return;
2033cdf0e10cSrcweir }
2034cdf0e10cSrcweir if ( &aAttributeBtn == pCtrl
2035cdf0e10cSrcweir && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0
2036cdf0e10cSrcweir && pSearchList )
2037cdf0e10cSrcweir {
2038cdf0e10cSrcweir aAttributeBtn.Enable( pImpl->bFocusOnSearch );
2039cdf0e10cSrcweir }
2040cdf0e10cSrcweir if ( &aFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
2041cdf0e10cSrcweir {
2042cdf0e10cSrcweir aFormatBtn.Enable();
2043cdf0e10cSrcweir return;
2044cdf0e10cSrcweir }
2045cdf0e10cSrcweir if ( &aNoFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
2046cdf0e10cSrcweir {
2047cdf0e10cSrcweir aNoFormatBtn.Enable();
2048cdf0e10cSrcweir return;
2049cdf0e10cSrcweir }
2050cdf0e10cSrcweir if ( &aSimilarityBox == pCtrl &&
2051cdf0e10cSrcweir ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
2052cdf0e10cSrcweir {
2053cdf0e10cSrcweir aSimilarityBox.Enable();
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir if ( aSimilarityBox.IsChecked() )
2056cdf0e10cSrcweir aSimilarityBtn.Enable();
2057cdf0e10cSrcweir }
2058cdf0e10cSrcweir }
2059cdf0e10cSrcweir
2060cdf0e10cSrcweir // -----------------------------------------------------------------------
2061cdf0e10cSrcweir
SetItem_Impl(const SvxSearchItem * pItem)2062cdf0e10cSrcweir void SvxSearchDialog::SetItem_Impl( const SvxSearchItem* pItem )
2063cdf0e10cSrcweir {
2064cdf0e10cSrcweir if ( pItem )
2065cdf0e10cSrcweir {
2066cdf0e10cSrcweir delete pSearchItem;
2067cdf0e10cSrcweir pSearchItem = (SvxSearchItem*)pItem->Clone();
2068cdf0e10cSrcweir Init_Impl( pSearchItem->GetPattern() &&
2069cdf0e10cSrcweir ( !pSearchList || !pSearchList->Count() ) );
2070cdf0e10cSrcweir }
2071cdf0e10cSrcweir }
2072cdf0e10cSrcweir
2073cdf0e10cSrcweir // -----------------------------------------------------------------------
2074cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,FocusHdl_Impl,Control *,pCtrl)2075cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, FocusHdl_Impl, Control *, pCtrl )
2076cdf0e10cSrcweir {
2077cdf0e10cSrcweir xub_StrLen nTxtLen;
2078cdf0e10cSrcweir
2079cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2080cdf0e10cSrcweir nTxtLen = aSearchAttrText.GetText().Len();
2081cdf0e10cSrcweir else
2082cdf0e10cSrcweir nTxtLen = pImpl->aSearchFormats.GetText().Len();
2083cdf0e10cSrcweir
2084cdf0e10cSrcweir if ( pCtrl == &aSearchLB || pCtrl == &pImpl->aSearchFormats )
2085cdf0e10cSrcweir {
2086cdf0e10cSrcweir if ( pCtrl->HasChildPathFocus() )
2087cdf0e10cSrcweir pImpl->bFocusOnSearch = sal_True;
2088cdf0e10cSrcweir pCtrl = &aSearchLB;
2089cdf0e10cSrcweir bSearch = sal_True;
2090cdf0e10cSrcweir
2091cdf0e10cSrcweir if( nTxtLen )
2092cdf0e10cSrcweir EnableControl_Impl( &aNoFormatBtn );
2093cdf0e10cSrcweir else
2094cdf0e10cSrcweir aNoFormatBtn.Disable();
2095cdf0e10cSrcweir EnableControl_Impl( &aAttributeBtn );
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir else
2098cdf0e10cSrcweir {
2099cdf0e10cSrcweir pImpl->bFocusOnSearch = sal_False;
2100cdf0e10cSrcweir pCtrl = &aReplaceLB;
2101cdf0e10cSrcweir bSearch = sal_False;
2102cdf0e10cSrcweir
2103cdf0e10cSrcweir if ( ( !pImpl->bMultiLineEdit && aReplaceAttrText.GetText().Len() ) ||
2104cdf0e10cSrcweir ( pImpl->bMultiLineEdit && pImpl->aReplaceFormats.GetText().Len() ) )
2105cdf0e10cSrcweir EnableControl_Impl( &aNoFormatBtn );
2106cdf0e10cSrcweir else
2107cdf0e10cSrcweir aNoFormatBtn.Disable();
2108cdf0e10cSrcweir aAttributeBtn.Disable();
2109cdf0e10cSrcweir }
2110cdf0e10cSrcweir bSet = sal_True;
2111cdf0e10cSrcweir
2112cdf0e10cSrcweir aSearchLB.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
2113cdf0e10cSrcweir
2114cdf0e10cSrcweir ModifyHdl_Impl( (ComboBox*)pCtrl );
2115cdf0e10cSrcweir
2116cdf0e10cSrcweir aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aStylesStr );
2117cdf0e10cSrcweir return 0;
2118cdf0e10cSrcweir }
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir // -----------------------------------------------------------------------
2121cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,LoseFocusHdl_Impl,Control *,EMPTYARG)2122cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, LoseFocusHdl_Impl, Control *, EMPTYARG )
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir SaveToModule_Impl();
2125cdf0e10cSrcweir return 0;
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir // -----------------------------------------------------------------------
2129cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,FormatHdl_Impl,Button *,EMPTYARG)2130cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, FormatHdl_Impl, Button *, EMPTYARG )
2131cdf0e10cSrcweir {
2132cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::Current();
2133cdf0e10cSrcweir
2134cdf0e10cSrcweir DBG_ASSERT( pSh, "no DocShell" );
2135cdf0e10cSrcweir
2136cdf0e10cSrcweir if ( !pSh || !pImpl->pRanges )
2137cdf0e10cSrcweir return 0;
2138cdf0e10cSrcweir
2139cdf0e10cSrcweir sal_sSize nCnt = 0;
2140cdf0e10cSrcweir const sal_uInt16* pPtr = pImpl->pRanges;
2141cdf0e10cSrcweir const sal_uInt16* pTmp = pPtr;
2142cdf0e10cSrcweir
2143cdf0e10cSrcweir while( *pTmp )
2144cdf0e10cSrcweir pTmp++;
2145cdf0e10cSrcweir nCnt = pTmp - pPtr + 7;
2146cdf0e10cSrcweir sal_uInt16* pWhRanges = new sal_uInt16[nCnt];
2147cdf0e10cSrcweir sal_uInt16 nPos = 0;
2148cdf0e10cSrcweir
2149cdf0e10cSrcweir while( *pPtr )
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir pWhRanges[nPos++] = *pPtr++;
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir
2154cdf0e10cSrcweir pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
2155cdf0e10cSrcweir pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
2156cdf0e10cSrcweir
2157cdf0e10cSrcweir sal_uInt16 nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
2158cdf0e10cSrcweir pWhRanges[nPos++] = nBrushWhich;
2159cdf0e10cSrcweir pWhRanges[nPos++] = nBrushWhich;
2160cdf0e10cSrcweir pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
2161cdf0e10cSrcweir pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
2162cdf0e10cSrcweir pWhRanges[nPos] = 0;
2163cdf0e10cSrcweir SfxItemPool& rPool = pSh->GetPool();
2164cdf0e10cSrcweir SfxItemSet aSet( rPool, pWhRanges );
2165cdf0e10cSrcweir String aTxt;
2166cdf0e10cSrcweir
2167cdf0e10cSrcweir aSet.InvalidateAllItems();
2168cdf0e10cSrcweir aSet.Put(SvxBrushItem(nBrushWhich));
2169cdf0e10cSrcweir aSet.Put(SfxUInt16Item(SID_PARA_BACKGRND_DESTINATION, PARA_DEST_CHAR));
2170cdf0e10cSrcweir
2171cdf0e10cSrcweir if ( bSearch )
2172cdf0e10cSrcweir {
2173cdf0e10cSrcweir aTxt = SVX_RESSTR( RID_SVXSTR_SEARCH );
2174cdf0e10cSrcweir pSearchList->Get( aSet );
2175cdf0e10cSrcweir }
2176cdf0e10cSrcweir else
2177cdf0e10cSrcweir {
2178cdf0e10cSrcweir aTxt = SVX_RESSTR( RID_SVXSTR_REPLACE );
2179cdf0e10cSrcweir pReplaceList->Get( aSet );
2180cdf0e10cSrcweir }
2181cdf0e10cSrcweir aSet.DisableItem(SID_ATTR_PARA_MODEL);
2182cdf0e10cSrcweir aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK));
2183cdf0e10cSrcweir aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP));
2184cdf0e10cSrcweir
2185cdf0e10cSrcweir //CHINA001 SvxSearchFormatDialog* pDlg = new SvxSearchFormatDialog( this, aSet );
2186cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2187cdf0e10cSrcweir if(pFact)
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateTabItemDialog( LAYOUT_THIS_WINDOW (this), aSet, RID_SVXDLG_SEARCHFORMAT );
2190cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
2191cdf0e10cSrcweir aTxt.Insert( pDlg->GetText(), 0 );
2192cdf0e10cSrcweir pDlg->SetText( aTxt );
2193cdf0e10cSrcweir
2194cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK )
2195cdf0e10cSrcweir {
2196cdf0e10cSrcweir DBG_ASSERT( pDlg->GetOutputItemSet(), "invalid Output-Set" );
2197cdf0e10cSrcweir SfxItemSet aOutSet( *pDlg->GetOutputItemSet() );
2198cdf0e10cSrcweir
2199cdf0e10cSrcweir SearchAttrItemList* pList = bSearch ? pSearchList : pReplaceList;
2200cdf0e10cSrcweir
2201cdf0e10cSrcweir SearchAttrItem* pAItem;
2202cdf0e10cSrcweir const SfxPoolItem* pItem;
2203cdf0e10cSrcweir for( sal_uInt16 n = 0; n < pList->Count(); ++n )
2204cdf0e10cSrcweir if( !IsInvalidItem( (pAItem = &pList->GetObject(n))->pItem ) &&
2205cdf0e10cSrcweir SFX_ITEM_SET == aOutSet.GetItemState(
2206cdf0e10cSrcweir pAItem->pItem->Which(), sal_False, &pItem ) )
2207cdf0e10cSrcweir {
2208cdf0e10cSrcweir delete pAItem->pItem;
2209cdf0e10cSrcweir pAItem->pItem = pItem->Clone();
2210cdf0e10cSrcweir aOutSet.ClearItem( pAItem->pItem->Which() );
2211cdf0e10cSrcweir }
2212cdf0e10cSrcweir
2213cdf0e10cSrcweir if( aOutSet.Count() )
2214cdf0e10cSrcweir pList->Put( aOutSet );
2215cdf0e10cSrcweir
2216cdf0e10cSrcweir PaintAttrText_Impl(); // AttributText in GroupBox setzen
2217cdf0e10cSrcweir }
2218cdf0e10cSrcweir delete pDlg;
2219cdf0e10cSrcweir }
2220cdf0e10cSrcweir delete[] pWhRanges;
2221cdf0e10cSrcweir return 0;
2222cdf0e10cSrcweir }
2223cdf0e10cSrcweir
2224cdf0e10cSrcweir // -----------------------------------------------------------------------
2225cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,NoFormatHdl_Impl,Button *,EMPTYARG)2226cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, NoFormatHdl_Impl, Button *, EMPTYARG )
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir aLayoutBtn.SetText( aStylesStr );
2229cdf0e10cSrcweir bFormat = sal_False;
2230cdf0e10cSrcweir aLayoutBtn.Check( sal_False );
2231cdf0e10cSrcweir
2232cdf0e10cSrcweir if ( bSearch )
2233cdf0e10cSrcweir {
2234cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2235cdf0e10cSrcweir aSearchAttrText.SetText( String() );
2236cdf0e10cSrcweir else
2237cdf0e10cSrcweir pImpl->aSearchFormats.SetText( String() );
2238cdf0e10cSrcweir pSearchList->Clear();
2239cdf0e10cSrcweir }
2240cdf0e10cSrcweir else
2241cdf0e10cSrcweir {
2242cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2243cdf0e10cSrcweir aReplaceAttrText.SetText( String() );
2244cdf0e10cSrcweir else
2245cdf0e10cSrcweir pImpl->aReplaceFormats.SetText( String() );
2246cdf0e10cSrcweir pReplaceList->Clear();
2247cdf0e10cSrcweir }
2248cdf0e10cSrcweir pImpl->bSaveToModule = sal_False;
2249cdf0e10cSrcweir TemplateHdl_Impl( &aLayoutBtn );
2250cdf0e10cSrcweir pImpl->bSaveToModule = sal_True;
2251cdf0e10cSrcweir aNoFormatBtn.Disable();
2252cdf0e10cSrcweir return 0;
2253cdf0e10cSrcweir }
2254cdf0e10cSrcweir
2255cdf0e10cSrcweir // -----------------------------------------------------------------------
2256cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,AttributeHdl_Impl,Button *,EMPTYARG)2257cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, AttributeHdl_Impl, Button *, EMPTYARG )
2258cdf0e10cSrcweir {
2259cdf0e10cSrcweir if ( !pSearchList || !pImpl->pRanges )
2260cdf0e10cSrcweir return 0;
2261cdf0e10cSrcweir
2262cdf0e10cSrcweir //CHINA001 SvxSearchAttributeDialog* pDlg = new SvxSearchAttributeDialog( this, *pSearchList, pImpl->pRanges );
2263cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2264cdf0e10cSrcweir if(pFact)
2265cdf0e10cSrcweir {
2266cdf0e10cSrcweir VclAbstractDialog* pDlg = pFact->CreateSvxSearchAttributeDialog( LAYOUT_THIS_WINDOW (this), *pSearchList, pImpl->pRanges );
2267cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
2268cdf0e10cSrcweir pDlg->Execute();
2269cdf0e10cSrcweir delete pDlg;
2270cdf0e10cSrcweir }
2271cdf0e10cSrcweir PaintAttrText_Impl();
2272cdf0e10cSrcweir return 0;
2273cdf0e10cSrcweir }
2274cdf0e10cSrcweir
2275cdf0e10cSrcweir // -----------------------------------------------------------------------
2276cdf0e10cSrcweir
IMPL_LINK(SvxSearchDialog,TimeoutHdl_Impl,Timer *,pTimer)2277cdf0e10cSrcweir IMPL_LINK( SvxSearchDialog, TimeoutHdl_Impl, Timer *, pTimer )
2278cdf0e10cSrcweir {
2279cdf0e10cSrcweir SfxViewShell* pViewShell = SfxViewShell::Current();
2280cdf0e10cSrcweir
2281cdf0e10cSrcweir if ( pViewShell )
2282cdf0e10cSrcweir {
2283cdf0e10cSrcweir if ( pViewShell->HasSelection( aSearchLB.IsVisible() ) )
2284cdf0e10cSrcweir EnableControl_Impl( &aSelectionBtn );
2285cdf0e10cSrcweir else
2286cdf0e10cSrcweir {
2287cdf0e10cSrcweir aSelectionBtn.Check( sal_False );
2288cdf0e10cSrcweir aSelectionBtn.Disable();
2289cdf0e10cSrcweir }
2290cdf0e10cSrcweir }
2291cdf0e10cSrcweir
2292cdf0e10cSrcweir pTimer->Start();
2293cdf0e10cSrcweir return 0;
2294cdf0e10cSrcweir }
2295cdf0e10cSrcweir
2296cdf0e10cSrcweir // -----------------------------------------------------------------------
2297cdf0e10cSrcweir
GetSearchItems(SfxItemSet & rSet)2298cdf0e10cSrcweir void SvxSearchDialog::GetSearchItems( SfxItemSet& rSet )
2299cdf0e10cSrcweir {
2300cdf0e10cSrcweir xub_StrLen nLen;
2301cdf0e10cSrcweir
2302cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2303cdf0e10cSrcweir nLen = aSearchAttrText.GetText().Len();
2304cdf0e10cSrcweir else
2305cdf0e10cSrcweir nLen = pImpl->aSearchFormats.GetText().Len();
2306cdf0e10cSrcweir
2307cdf0e10cSrcweir if ( nLen && pSearchList )
2308cdf0e10cSrcweir pSearchList->Get( rSet );
2309cdf0e10cSrcweir }
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir // -----------------------------------------------------------------------
2312cdf0e10cSrcweir
GetReplaceItems(SfxItemSet & rSet)2313cdf0e10cSrcweir void SvxSearchDialog::GetReplaceItems( SfxItemSet& rSet )
2314cdf0e10cSrcweir {
2315cdf0e10cSrcweir xub_StrLen nLen;
2316cdf0e10cSrcweir
2317cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2318cdf0e10cSrcweir nLen = aReplaceAttrText.GetText().Len();
2319cdf0e10cSrcweir else
2320cdf0e10cSrcweir nLen = pImpl->aReplaceFormats.GetText().Len();
2321cdf0e10cSrcweir
2322cdf0e10cSrcweir if ( nLen && pReplaceList )
2323cdf0e10cSrcweir pReplaceList->Get( rSet );
2324cdf0e10cSrcweir }
2325cdf0e10cSrcweir
2326cdf0e10cSrcweir // -----------------------------------------------------------------------
2327cdf0e10cSrcweir
BuildAttrText_Impl(String & rStr,sal_Bool bSrchFlag) const2328cdf0e10cSrcweir String& SvxSearchDialog::BuildAttrText_Impl( String& rStr,
2329cdf0e10cSrcweir sal_Bool bSrchFlag ) const
2330cdf0e10cSrcweir {
2331cdf0e10cSrcweir if ( rStr.Len() )
2332cdf0e10cSrcweir rStr.Erase();
2333cdf0e10cSrcweir
2334cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::Current();
2335cdf0e10cSrcweir DBG_ASSERT( pSh, "no DocShell" );
2336cdf0e10cSrcweir
2337cdf0e10cSrcweir if ( !pSh )
2338cdf0e10cSrcweir return rStr;
2339cdf0e10cSrcweir
2340cdf0e10cSrcweir SfxItemPool& rPool = pSh->GetPool();
2341cdf0e10cSrcweir SearchAttrItemList* pList = bSrchFlag ? pSearchList : pReplaceList;
2342cdf0e10cSrcweir
2343cdf0e10cSrcweir if ( !pList )
2344cdf0e10cSrcweir return rStr;
2345cdf0e10cSrcweir
2346cdf0e10cSrcweir // Metrik abfragen
2347cdf0e10cSrcweir SfxMapUnit eMapUnit = SFX_MAPUNIT_CM;
2348cdf0e10cSrcweir FieldUnit eFieldUnit = pSh->GetModule()->GetFieldUnit();
2349cdf0e10cSrcweir switch ( eFieldUnit )
2350cdf0e10cSrcweir {
2351cdf0e10cSrcweir case FUNIT_MM: eMapUnit = SFX_MAPUNIT_MM; break;
2352cdf0e10cSrcweir case FUNIT_CM:
2353cdf0e10cSrcweir case FUNIT_M:
2354cdf0e10cSrcweir case FUNIT_KM: eMapUnit = SFX_MAPUNIT_CM; break;
2355cdf0e10cSrcweir case FUNIT_TWIP: eMapUnit = SFX_MAPUNIT_TWIP; break;
2356cdf0e10cSrcweir case FUNIT_POINT:
2357cdf0e10cSrcweir case FUNIT_PICA: eMapUnit = SFX_MAPUNIT_POINT; break;
2358cdf0e10cSrcweir case FUNIT_INCH:
2359cdf0e10cSrcweir case FUNIT_FOOT:
2360cdf0e10cSrcweir case FUNIT_MILE: eMapUnit = SFX_MAPUNIT_INCH; break;
2361cdf0e10cSrcweir case FUNIT_100TH_MM: eMapUnit = SFX_MAPUNIT_100TH_MM; break;
2362cdf0e10cSrcweir default: ;//prevent warning
2363cdf0e10cSrcweir }
2364cdf0e10cSrcweir
2365cdf0e10cSrcweir ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
2366cdf0e10cSrcweir
2367cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < pList->Count(); ++i )
2368cdf0e10cSrcweir {
2369cdf0e10cSrcweir const SearchAttrItem& rItem = pList->GetObject(i);
2370cdf0e10cSrcweir
2371cdf0e10cSrcweir if ( rStr.Len() )
2372cdf0e10cSrcweir rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
2373cdf0e10cSrcweir
2374cdf0e10cSrcweir if ( !IsInvalidItem( rItem.pItem ) )
2375cdf0e10cSrcweir {
2376cdf0e10cSrcweir String aStr;
2377cdf0e10cSrcweir rPool.GetPresentation( *rItem.pItem,
2378cdf0e10cSrcweir SFX_ITEM_PRESENTATION_COMPLETE,
2379cdf0e10cSrcweir eMapUnit, aStr );
2380cdf0e10cSrcweir rStr += aStr;
2381cdf0e10cSrcweir }
2382cdf0e10cSrcweir else if ( rItem.nSlot == SID_ATTR_BRUSH_CHAR )
2383cdf0e10cSrcweir {
2384cdf0e10cSrcweir //Sonderbehandlung fuer Zeichenhintergrund
2385cdf0e10cSrcweir rStr += SVX_RESSTR( RID_SVXITEMS_BRUSH_CHAR );
2386cdf0e10cSrcweir }
2387cdf0e10cSrcweir else
2388cdf0e10cSrcweir {
2389cdf0e10cSrcweir sal_uInt32 nId = aAttrNames.FindIndex( rItem.nSlot );
2390cdf0e10cSrcweir if ( RESARRAY_INDEX_NOTFOUND != nId )
2391cdf0e10cSrcweir rStr += aAttrNames.GetString( nId );
2392cdf0e10cSrcweir }
2393cdf0e10cSrcweir }
2394cdf0e10cSrcweir return rStr;
2395cdf0e10cSrcweir }
2396cdf0e10cSrcweir
2397cdf0e10cSrcweir // -----------------------------------------------------------------------
2398cdf0e10cSrcweir
PaintAttrText_Impl()2399cdf0e10cSrcweir void SvxSearchDialog::PaintAttrText_Impl()
2400cdf0e10cSrcweir {
2401cdf0e10cSrcweir String aDesc;
2402cdf0e10cSrcweir BuildAttrText_Impl( aDesc, bSearch );
2403cdf0e10cSrcweir
2404cdf0e10cSrcweir if ( !bFormat && aDesc.Len() )
2405cdf0e10cSrcweir bFormat = sal_True;
2406cdf0e10cSrcweir
2407cdf0e10cSrcweir if ( bSearch )
2408cdf0e10cSrcweir {
2409cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2410cdf0e10cSrcweir aSearchAttrText.SetText( aDesc );
2411cdf0e10cSrcweir else
2412cdf0e10cSrcweir pImpl->aSearchFormats.SetText( aDesc );
2413cdf0e10cSrcweir FocusHdl_Impl( &aSearchLB );
2414cdf0e10cSrcweir }
2415cdf0e10cSrcweir else
2416cdf0e10cSrcweir {
2417cdf0e10cSrcweir if ( !pImpl->bMultiLineEdit )
2418cdf0e10cSrcweir aReplaceAttrText.SetText( aDesc );
2419cdf0e10cSrcweir else
2420cdf0e10cSrcweir pImpl->aReplaceFormats.SetText( aDesc );
2421cdf0e10cSrcweir FocusHdl_Impl( &aReplaceLB );
2422cdf0e10cSrcweir }
2423cdf0e10cSrcweir }
2424cdf0e10cSrcweir
2425cdf0e10cSrcweir // -----------------------------------------------------------------------
2426cdf0e10cSrcweir
SetModifyFlag_Impl(const Control * pCtrl)2427cdf0e10cSrcweir void SvxSearchDialog::SetModifyFlag_Impl( const Control* pCtrl )
2428cdf0e10cSrcweir {
2429cdf0e10cSrcweir if ( &aSearchLB == (ComboBox*)pCtrl )
2430cdf0e10cSrcweir nModifyFlag |= MODIFY_SEARCH;
2431cdf0e10cSrcweir else if ( &aReplaceLB == (ComboBox*)pCtrl )
2432cdf0e10cSrcweir nModifyFlag |= MODIFY_REPLACE;
2433cdf0e10cSrcweir else if ( &aWordBtn == (CheckBox*)pCtrl )
2434cdf0e10cSrcweir nModifyFlag |= MODIFY_WORD;
2435cdf0e10cSrcweir else if ( &aMatchCaseCB == (CheckBox*)pCtrl )
2436cdf0e10cSrcweir nModifyFlag |= MODIFY_EXACT;
2437cdf0e10cSrcweir else if ( &aBackwardsBtn == (CheckBox*)pCtrl )
2438cdf0e10cSrcweir nModifyFlag |= MODIFY_BACKWARDS;
2439cdf0e10cSrcweir else if ( &aNotesBtn == (CheckBox*)pCtrl )
2440cdf0e10cSrcweir nModifyFlag |= MODIFY_NOTES;
2441cdf0e10cSrcweir else if ( &aSelectionBtn == (CheckBox*)pCtrl )
2442cdf0e10cSrcweir nModifyFlag |= MODIFY_SELECTION;
2443cdf0e10cSrcweir else if ( &aRegExpBtn == (CheckBox*)pCtrl )
2444cdf0e10cSrcweir nModifyFlag |= MODIFY_REGEXP;
2445cdf0e10cSrcweir else if ( &aLayoutBtn == (CheckBox*)pCtrl )
2446cdf0e10cSrcweir nModifyFlag |= MODIFY_LAYOUT;
2447cdf0e10cSrcweir else if ( &aSimilarityBox == (CheckBox*)pCtrl )
2448cdf0e10cSrcweir nModifyFlag |= MODIFY_SIMILARITY;
2449cdf0e10cSrcweir else if ( &aCalcSearchInLB == (ListBox*)pCtrl )
2450cdf0e10cSrcweir {
2451cdf0e10cSrcweir nModifyFlag |= MODIFY_FORMULAS;
2452cdf0e10cSrcweir nModifyFlag |= MODIFY_VALUES;
2453cdf0e10cSrcweir nModifyFlag |= MODIFY_CALC_NOTES;
2454cdf0e10cSrcweir }
2455cdf0e10cSrcweir else if ( &aRowsBtn == (RadioButton*)pCtrl )
2456cdf0e10cSrcweir nModifyFlag |= MODIFY_ROWS;
2457cdf0e10cSrcweir else if ( &aColumnsBtn == (RadioButton*)pCtrl )
2458cdf0e10cSrcweir nModifyFlag |= MODIFY_COLUMNS;
2459cdf0e10cSrcweir else if ( &aAllSheetsCB == (CheckBox*)pCtrl )
2460cdf0e10cSrcweir nModifyFlag |= MODIFY_ALLTABLES;
2461cdf0e10cSrcweir }
2462cdf0e10cSrcweir
2463cdf0e10cSrcweir // -----------------------------------------------------------------------
2464cdf0e10cSrcweir
SaveToModule_Impl()2465cdf0e10cSrcweir void SvxSearchDialog::SaveToModule_Impl()
2466cdf0e10cSrcweir {
2467cdf0e10cSrcweir if ( !pSearchItem )
2468cdf0e10cSrcweir return;
2469cdf0e10cSrcweir
2470cdf0e10cSrcweir if ( aLayoutBtn.IsChecked() )
2471cdf0e10cSrcweir {
2472cdf0e10cSrcweir pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
2473cdf0e10cSrcweir pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
2474cdf0e10cSrcweir }
2475cdf0e10cSrcweir else
2476cdf0e10cSrcweir {
2477cdf0e10cSrcweir pSearchItem->SetSearchString ( aSearchLB.GetText() );
2478cdf0e10cSrcweir pSearchItem->SetReplaceString( aReplaceLB.GetText() );
2479cdf0e10cSrcweir Remember_Impl( aSearchLB.GetText(), sal_True );
2480cdf0e10cSrcweir }
2481cdf0e10cSrcweir
2482cdf0e10cSrcweir pSearchItem->SetRegExp( sal_False );
2483cdf0e10cSrcweir pSearchItem->SetLevenshtein( sal_False );
2484cdf0e10cSrcweir if (GetCheckBoxValue( aRegExpBtn ))
2485cdf0e10cSrcweir pSearchItem->SetRegExp( sal_True );
2486cdf0e10cSrcweir else if (GetCheckBoxValue( aSimilarityBox ))
2487cdf0e10cSrcweir pSearchItem->SetLevenshtein( sal_True );
2488cdf0e10cSrcweir
2489cdf0e10cSrcweir pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
2490cdf0e10cSrcweir pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
2491cdf0e10cSrcweir pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
2492cdf0e10cSrcweir pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
2493cdf0e10cSrcweir pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
2494cdf0e10cSrcweir
2495cdf0e10cSrcweir pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
2496cdf0e10cSrcweir sal_Int32 nFlags = GetTransliterationFlags();
2497cdf0e10cSrcweir if( !pSearchItem->IsUseAsianOptions())
2498cdf0e10cSrcweir nFlags &= (TransliterationModules_IGNORE_CASE |
2499cdf0e10cSrcweir TransliterationModules_IGNORE_WIDTH );
2500cdf0e10cSrcweir pSearchItem->SetTransliterationFlags( nFlags );
2501cdf0e10cSrcweir
2502cdf0e10cSrcweir if ( !bWriter )
2503cdf0e10cSrcweir {
2504cdf0e10cSrcweir if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
2505cdf0e10cSrcweir pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
2506cdf0e10cSrcweir
2507cdf0e10cSrcweir pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
2508cdf0e10cSrcweir pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
2509cdf0e10cSrcweir }
2510cdf0e10cSrcweir
2511cdf0e10cSrcweir pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
2512cdf0e10cSrcweir nModifyFlag = 0;
2513cdf0e10cSrcweir const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
2514cdf0e10cSrcweir rBindings.GetDispatcher()->Execute( SID_SEARCH_ITEM, SFX_CALLMODE_SLOT, ppArgs );
2515cdf0e10cSrcweir }
2516cdf0e10cSrcweir
2517*9b8096d0SSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
GetComponentInterface(sal_Bool bCreate)2518*9b8096d0SSteve Yin SvxSearchDialog::GetComponentInterface( sal_Bool bCreate )
2519*9b8096d0SSteve Yin {
2520*9b8096d0SSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer
2521*9b8096d0SSteve Yin (Window::GetComponentInterface(false));
2522*9b8096d0SSteve Yin if ( !xPeer.is() && bCreate )
2523*9b8096d0SSteve Yin {
2524*9b8096d0SSteve Yin ::com::sun::star::awt::XWindowPeer* mxPeer = new VCLXSvxFindReplaceDialog(this);
2525*9b8096d0SSteve Yin SetComponentInterface(mxPeer);
2526*9b8096d0SSteve Yin return mxPeer;
2527*9b8096d0SSteve Yin }
2528*9b8096d0SSteve Yin else
2529*9b8096d0SSteve Yin return xPeer;
2530*9b8096d0SSteve Yin }
2531*9b8096d0SSteve Yin
2532cdf0e10cSrcweir // class SvxSearchDialogWrapper ------------------------------------------
2533cdf0e10cSrcweir
2534cdf0e10cSrcweir SFX_IMPL_CHILDWINDOW(SvxSearchDialogWrapper, SID_SEARCH_DLG);
2535cdf0e10cSrcweir
2536cdf0e10cSrcweir // -----------------------------------------------------------------------
2537cdf0e10cSrcweir
SvxSearchDialogWrapper(Window * _pParent,sal_uInt16 nId,SfxBindings * pBindings,SfxChildWinInfo * pInfo)2538cdf0e10cSrcweir SvxSearchDialogWrapper::SvxSearchDialogWrapper( Window* _pParent, sal_uInt16 nId,
2539cdf0e10cSrcweir SfxBindings* pBindings,
2540cdf0e10cSrcweir SfxChildWinInfo* pInfo )
2541cdf0e10cSrcweir : SfxChildWindow( _pParent, nId )
2542cdf0e10cSrcweir , dialog (new SvxSearchDialog (_pParent, this, *pBindings))
2543cdf0e10cSrcweir {
2544cdf0e10cSrcweir pWindow = LAYOUT_THIS_WINDOW (dialog);
2545cdf0e10cSrcweir dialog->Initialize( pInfo );
2546cdf0e10cSrcweir
2547cdf0e10cSrcweir pBindings->Update( SID_SEARCH_ITEM );
2548cdf0e10cSrcweir pBindings->Update( SID_SEARCH_OPTIONS );
2549cdf0e10cSrcweir pBindings->Update( SID_SEARCH_SEARCHSET );
2550cdf0e10cSrcweir pBindings->Update( SID_SEARCH_REPLACESET );
2551cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_NOALIGNMENT;
2552cdf0e10cSrcweir dialog->bConstruct = sal_False;
2553cdf0e10cSrcweir }
2554cdf0e10cSrcweir
~SvxSearchDialogWrapper()2555cdf0e10cSrcweir SvxSearchDialogWrapper::~SvxSearchDialogWrapper ()
2556cdf0e10cSrcweir {
2557cdf0e10cSrcweir #if ENABLE_LAYOUT
2558cdf0e10cSrcweir delete dialog;
2559cdf0e10cSrcweir pWindow = 0;
2560cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
2561cdf0e10cSrcweir }
2562cdf0e10cSrcweir
getDialog()2563cdf0e10cSrcweir SvxSearchDialog *SvxSearchDialogWrapper::getDialog ()
2564cdf0e10cSrcweir {
2565cdf0e10cSrcweir return dialog;
2566cdf0e10cSrcweir }
2567cdf0e10cSrcweir
2568cdf0e10cSrcweir // -----------------------------------------------------------------------
2569cdf0e10cSrcweir
GetInfo() const2570cdf0e10cSrcweir SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
2571cdf0e10cSrcweir {
2572cdf0e10cSrcweir SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
2573cdf0e10cSrcweir aInfo.bVisible = sal_False;
2574cdf0e10cSrcweir return aInfo;
2575cdf0e10cSrcweir }
2576cdf0e10cSrcweir
2577