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