xref: /aoo42x/main/sw/source/ui/uiview/viewsrch.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2*efeef26fSAndrew Rist  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
29cdf0e10cSrcweir #include <hintids.hxx>
30cdf0e10cSrcweir #include <com/sun/star/util/SearchOptions.hpp>
31cdf0e10cSrcweir #include <svl/cjkoptions.hxx>
32cdf0e10cSrcweir #include <svl/ctloptions.hxx>
33cdf0e10cSrcweir #include <svx/pageitem.hxx>
34cdf0e10cSrcweir #include <svl/whiter.hxx>
35cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
36cdf0e10cSrcweir #include <svl/stritem.hxx>
37cdf0e10cSrcweir #include <svtools/txtcmp.hxx>
38cdf0e10cSrcweir #include <svl/itempool.hxx>
39cdf0e10cSrcweir #include <svl/eitem.hxx>
40cdf0e10cSrcweir #include <svl/srchitem.hxx>
41cdf0e10cSrcweir #include <sfx2/request.hxx>
42cdf0e10cSrcweir #include <svx/srchdlg.hxx>
43cdf0e10cSrcweir #include <vcl/msgbox.hxx>
44cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
45cdf0e10cSrcweir #include "editeng/unolingu.hxx"
46cdf0e10cSrcweir #include <swmodule.hxx>
47cdf0e10cSrcweir #include <swwait.hxx>
48cdf0e10cSrcweir #include <workctrl.hxx>
49cdf0e10cSrcweir #include <view.hxx>
50cdf0e10cSrcweir #include <wrtsh.hxx>
51cdf0e10cSrcweir #include <swundo.hxx>               	// fuer Undo-Ids
52cdf0e10cSrcweir #include <uitool.hxx>
53cdf0e10cSrcweir #include <cmdid.h>
54cdf0e10cSrcweir #include <docsh.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <view.hrc>
57cdf0e10cSrcweir #include <SwRewriter.hxx>
58cdf0e10cSrcweir #include <comcore.hrc>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #include "PostItMgr.hxx"
61cdf0e10cSrcweir 
62cdf0e10cSrcweir using namespace com::sun::star;
63cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
64cdf0e10cSrcweir using namespace ::com::sun::star::lang;
65cdf0e10cSrcweir using namespace ::com::sun::star::util;
66cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #define SRCH_ATTR_OFF	0
69cdf0e10cSrcweir #define SRCH_ATTR_ON    1
70cdf0e10cSrcweir #define SRCH_ATTR_SET   2
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /*--------------------------------------------------------------------
73cdf0e10cSrcweir 	Beschreibung:	Search Parameter
74cdf0e10cSrcweir  --------------------------------------------------------------------*/
75cdf0e10cSrcweir 
76cdf0e10cSrcweir struct SwSearchOptions
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	SwDocPositions eStart, eEnd;
79cdf0e10cSrcweir 	sal_Bool bDontWrap;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	SwSearchOptions( SwWrtShell* pSh, sal_Bool bBackward );
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir inline Window* GetParentWindow( SvxSearchDialog* pSrchDlg )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	Window* pWin;
88cdf0e10cSrcweir 	if( pSrchDlg && pSrchDlg->IsVisible() )
89cdf0e10cSrcweir 		pWin = LAYOUT_THIS_WINDOW (pSrchDlg);
90cdf0e10cSrcweir 	else
91cdf0e10cSrcweir 		pWin = 0;
92cdf0e10cSrcweir 	return pWin;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 
96cdf0e10cSrcweir /*-----------------12.04.97 13:04-------------------
97cdf0e10cSrcweir 
98cdf0e10cSrcweir --------------------------------------------------*/
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir void SwView::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
104cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
105cdf0e10cSrcweir 	const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
106cdf0e10cSrcweir 	SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nId);
107cdf0e10cSrcweir     sal_Bool bQuiet = sal_False;
108cdf0e10cSrcweir     if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SEARCH_QUIET, sal_False, &pItem))
109cdf0e10cSrcweir         bQuiet = ((const SfxBoolItem*) pItem)->GetValue();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     sal_Bool bApi = bQuiet | bNoMessage;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
114cdf0e10cSrcweir 	if (nSlot == FN_REPEAT_SEARCH && !pSrchItem)
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		if(bApi)
117cdf0e10cSrcweir 		{
118cdf0e10cSrcweir 			rReq.SetReturnValue(SfxBoolItem(nSlot, sal_False));
119cdf0e10cSrcweir 			nSlot = 0;
120cdf0e10cSrcweir 		}
121cdf0e10cSrcweir 	}
122cdf0e10cSrcweir     if( pWrtShell->IsBlockMode() )
123cdf0e10cSrcweir         pWrtShell->LeaveBlockMode();
124cdf0e10cSrcweir 	switch (nSlot)
125cdf0e10cSrcweir 	{
126cdf0e10cSrcweir 	// erstmal Nichts tun
127cdf0e10cSrcweir 	case SID_SEARCH_ITEM:
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		delete pSrchItem;
130cdf0e10cSrcweir 		pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 	break;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	case FID_SEARCH_ON:
135cdf0e10cSrcweir 		bJustOpened = sal_True;
136cdf0e10cSrcweir 		GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM);
137cdf0e10cSrcweir 		break;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	case FID_SEARCH_OFF:
140cdf0e10cSrcweir 		if(pArgs)
141cdf0e10cSrcweir 		{
142cdf0e10cSrcweir 			// Dialog abmelden
143cdf0e10cSrcweir 			delete pSrchItem;
144cdf0e10cSrcweir 			pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 			DELETEZ( pSrchList );
147cdf0e10cSrcweir 			DELETEZ( pReplList );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 			if ( pWrp )
150cdf0e10cSrcweir 			{
151cdf0e10cSrcweir                 pSrchDlg = static_cast <SvxSearchDialog*> (pWrp->getDialog ());
152cdf0e10cSrcweir 				// die Search / Replace -Items merken wir uns
153cdf0e10cSrcweir 				const SearchAttrItemList* pList = pSrchDlg->GetSearchItemList();
154cdf0e10cSrcweir 				if( pList && pList->Count() )
155cdf0e10cSrcweir 					pSrchList = new SearchAttrItemList( *pList );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 				if( 0 != (pList = pSrchDlg->GetReplaceItemList() ) &&
158cdf0e10cSrcweir 					pList->Count() )
159cdf0e10cSrcweir 					pReplList = new SearchAttrItemList( *pList );
160cdf0e10cSrcweir 			}
161cdf0e10cSrcweir 		}
162cdf0e10cSrcweir 		break;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		case FN_REPEAT_SEARCH:
165cdf0e10cSrcweir 		case FID_SEARCH_NOW:
166cdf0e10cSrcweir         {
167cdf0e10cSrcweir 			{
168cdf0e10cSrcweir 				if(FID_SEARCH_NOW == nSlot && !rReq.IsAPI())
169cdf0e10cSrcweir 					SwView::SetMoveType(NID_SRCH_REP);
170cdf0e10cSrcweir 				if ( pWrp )
171cdf0e10cSrcweir 				{
172cdf0e10cSrcweir                     pSrchDlg = static_cast <SvxSearchDialog*> (pWrp->getDialog ());
173cdf0e10cSrcweir 				}
174cdf0e10cSrcweir 				else
175cdf0e10cSrcweir 					pSrchDlg = 0;
176cdf0e10cSrcweir 			}
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 			if (pSrchDlg)
179cdf0e10cSrcweir 			{
180cdf0e10cSrcweir 				DELETEZ( pSrchList );
181cdf0e10cSrcweir 				DELETEZ( pReplList );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 				const SearchAttrItemList* pList = pSrchDlg->GetSearchItemList();
184cdf0e10cSrcweir 				if( pList && pList->Count() )
185cdf0e10cSrcweir 					pSrchList = new SearchAttrItemList( *pList );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 				if( 0 != (pList = pSrchDlg->GetReplaceItemList() ) &&
188cdf0e10cSrcweir 					pList->Count() )
189cdf0e10cSrcweir 					pReplList = new SearchAttrItemList( *pList );
190cdf0e10cSrcweir 			}
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 			if (nSlot == FN_REPEAT_SEARCH)
193cdf0e10cSrcweir 			{
194cdf0e10cSrcweir 				ASSERT(pSrchItem, "Search-Item fehlt");
195cdf0e10cSrcweir 				if( !pSrchItem )
196cdf0e10cSrcweir                     pSrchItem = new SvxSearchItem(SID_SEARCH_ITEM);
197cdf0e10cSrcweir 			}
198cdf0e10cSrcweir 			else
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir 				// SearchItem aus Request besorgen
201cdf0e10cSrcweir 				ASSERT(pArgs, "Args fehlen");
202cdf0e10cSrcweir                 if ( pArgs )
203cdf0e10cSrcweir                 {
204cdf0e10cSrcweir 				    delete pSrchItem;
205cdf0e10cSrcweir 				    pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
206cdf0e10cSrcweir                 }
207cdf0e10cSrcweir 			}
208cdf0e10cSrcweir 			switch (pSrchItem->GetCommand())
209cdf0e10cSrcweir 			{
210cdf0e10cSrcweir 			case SVX_SEARCHCMD_FIND:
211cdf0e10cSrcweir 			{
212cdf0e10cSrcweir 				sal_Bool bRet = SearchAndWrap(bApi);
213cdf0e10cSrcweir 				if( bRet )
214cdf0e10cSrcweir 					Scroll(pWrtShell->GetCharRect().SVRect());
215cdf0e10cSrcweir 				rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
216cdf0e10cSrcweir 			}
217cdf0e10cSrcweir 			break;
218cdf0e10cSrcweir 			case SVX_SEARCHCMD_FIND_ALL:
219cdf0e10cSrcweir 			{
220cdf0e10cSrcweir 				sal_Bool bRet = SearchAll();
221cdf0e10cSrcweir 				if( !bRet )
222cdf0e10cSrcweir 				{
223cdf0e10cSrcweir 					if( !bApi )
224cdf0e10cSrcweir 					{
225cdf0e10cSrcweir 						Window* pParentWindow = GetParentWindow( pSrchDlg );
226cdf0e10cSrcweir 						InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
227cdf0e10cSrcweir 					}
228cdf0e10cSrcweir 					bFound = sal_False;
229cdf0e10cSrcweir 				}
230cdf0e10cSrcweir 				rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
231cdf0e10cSrcweir 			}
232cdf0e10cSrcweir 			break;
233cdf0e10cSrcweir 			case SVX_SEARCHCMD_REPLACE:
234cdf0e10cSrcweir 				{
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 					// 1) Selektion ersetzen (nicht. wenn nur Attribute ersetzt
237cdf0e10cSrcweir 					//    werden sollen)
238cdf0e10cSrcweir //JP 27.04.95: warum ?
239cdf0e10cSrcweir // 		was ist, wenn man das gefundene nur attributieren will??
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 					sal_uInt16 nCmd = SVX_SEARCHCMD_FIND;
242cdf0e10cSrcweir 					if( pSrchItem->GetReplaceString().Len() ||
243cdf0e10cSrcweir 						!pReplList )
244cdf0e10cSrcweir 					{
245cdf0e10cSrcweir 						// Verhindern, dass - falls der Suchstring im
246cdf0e10cSrcweir 						// Ersetzungsstring enthalten ist - der ersetzte String
247cdf0e10cSrcweir 						// noch einmal gefunden wird.
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 						sal_Bool bBack = pSrchItem->GetBackward();
250cdf0e10cSrcweir 						if (bBack)
251cdf0e10cSrcweir 							pWrtShell->Push();
252cdf0e10cSrcweir                         String aReplace( pSrchItem->GetReplaceString() );
253cdf0e10cSrcweir                         SearchOptions aTmp( pSrchItem->GetSearchOptions() );
254cdf0e10cSrcweir                         String *pBackRef = ReplaceBackReferences( aTmp, pWrtShell->GetCrsr() );
255cdf0e10cSrcweir                         if( pBackRef )
256cdf0e10cSrcweir                             pSrchItem->SetReplaceString( *pBackRef );
257cdf0e10cSrcweir 						Replace();
258cdf0e10cSrcweir                         if( pBackRef )
259cdf0e10cSrcweir                         {
260cdf0e10cSrcweir                             pSrchItem->SetReplaceString( aReplace );
261cdf0e10cSrcweir                             delete pBackRef;
262cdf0e10cSrcweir                         }
263cdf0e10cSrcweir 						if (bBack)
264cdf0e10cSrcweir 						{
265cdf0e10cSrcweir 							pWrtShell->Pop();
266cdf0e10cSrcweir 							pWrtShell->SwapPam();
267cdf0e10cSrcweir 						}
268cdf0e10cSrcweir 					}
269cdf0e10cSrcweir 					else if( pReplList )
270cdf0e10cSrcweir 						nCmd = SVX_SEARCHCMD_REPLACE;
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 					// 2) Weiter suchen (ohne zu ersetzen!)
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 					sal_uInt16 nOldCmd = pSrchItem->GetCommand();
275cdf0e10cSrcweir 					pSrchItem->SetCommand( nCmd );
276cdf0e10cSrcweir 					sal_Bool bRet = SearchAndWrap(bApi);
277cdf0e10cSrcweir 					if( bRet )
278cdf0e10cSrcweir 						Scroll( pWrtShell->GetCharRect().SVRect());
279cdf0e10cSrcweir 					pSrchItem->SetCommand( nOldCmd );
280cdf0e10cSrcweir 					rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
281cdf0e10cSrcweir 				}
282cdf0e10cSrcweir 				break;
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 			case SVX_SEARCHCMD_REPLACE_ALL:
285cdf0e10cSrcweir 				{
286cdf0e10cSrcweir 					SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 					if( !pSrchItem->GetSelection() )
290cdf0e10cSrcweir 					{
291cdf0e10cSrcweir 						// bestehende Selektionen aufheben,
292cdf0e10cSrcweir 						// wenn nicht in selektierten Bereichen gesucht werden soll
293cdf0e10cSrcweir 						(pWrtShell->*pWrtShell->fnKillSel)(0, sal_False);
294cdf0e10cSrcweir 						if( DOCPOS_START == aOpts.eEnd )
295cdf0e10cSrcweir 							pWrtShell->EndDoc();
296cdf0e10cSrcweir 						else
297cdf0e10cSrcweir 							pWrtShell->SttDoc();
298cdf0e10cSrcweir 					}
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 					bExtra = sal_False;
301cdf0e10cSrcweir 					sal_uLong nFound;
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 					{	//Scope for SwWait-Object
304cdf0e10cSrcweir 						SwWait aWait( *GetDocShell(), sal_True );
305cdf0e10cSrcweir 						pWrtShell->StartAllAction();
306cdf0e10cSrcweir 						nFound = FUNC_Search( aOpts );
307cdf0e10cSrcweir 						pWrtShell->EndAllAction();
308cdf0e10cSrcweir 					}
309cdf0e10cSrcweir                     rReq.SetReturnValue(SfxBoolItem(nSlot, nFound != 0 && ULONG_MAX != nFound));
310cdf0e10cSrcweir 					if( !nFound )
311cdf0e10cSrcweir 					{
312cdf0e10cSrcweir 						if( !bApi )
313cdf0e10cSrcweir 						{
314cdf0e10cSrcweir 							Window* pParentWindow = GetParentWindow( pSrchDlg );
315cdf0e10cSrcweir 							InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
316cdf0e10cSrcweir 						}
317cdf0e10cSrcweir 						bFound = sal_False;
318cdf0e10cSrcweir 						return;
319cdf0e10cSrcweir 					}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir                     if( !bApi && ULONG_MAX != nFound)
322cdf0e10cSrcweir 					{
323cdf0e10cSrcweir 						String aText( SW_RES( STR_NB_REPLACED ) );
324cdf0e10cSrcweir 						const xub_StrLen nPos = aText.Search( String::CreateFromAscii("XX") );
325cdf0e10cSrcweir 						aText.Erase( nPos, 2 );
326cdf0e10cSrcweir 						aText.Insert( String::CreateFromInt32( nFound ), nPos );
327cdf0e10cSrcweir 						Window* pParentWindow = GetParentWindow( pSrchDlg );
328cdf0e10cSrcweir 						InfoBox( pParentWindow, aText ).Execute();
329cdf0e10cSrcweir 					}
330cdf0e10cSrcweir 				}
331cdf0e10cSrcweir 				break;
332cdf0e10cSrcweir 			}
333cdf0e10cSrcweir 
334cdf0e10cSrcweir             uno::Reference< frame::XDispatchRecorder > xRecorder =
335cdf0e10cSrcweir                     GetViewFrame()->GetBindings().GetRecorder();
336cdf0e10cSrcweir             //prevent additional dialogs in recorded macros
337cdf0e10cSrcweir             if ( xRecorder.is() )
338cdf0e10cSrcweir                 rReq.AppendItem(SfxBoolItem(SID_SEARCH_QUIET, sal_True));
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 			rReq.Done();
341cdf0e10cSrcweir         }
342cdf0e10cSrcweir         break;
343cdf0e10cSrcweir 		case FID_SEARCH_SEARCHSET:
344cdf0e10cSrcweir 		case FID_SEARCH_REPLACESET:
345cdf0e10cSrcweir 		{
346cdf0e10cSrcweir 			static const sal_uInt16 aNormalAttr[] =
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir /* 0 */			RES_CHRATR_CASEMAP,		RES_CHRATR_CASEMAP,
349cdf0e10cSrcweir /* 2 */			RES_CHRATR_COLOR, 		RES_CHRATR_POSTURE,
350cdf0e10cSrcweir /* 4 */			RES_CHRATR_SHADOWED, 	RES_CHRATR_WORDLINEMODE,
351cdf0e10cSrcweir /* 6 */			RES_CHRATR_BLINK,		RES_CHRATR_BLINK,
352cdf0e10cSrcweir /* 8 */			RES_CHRATR_BACKGROUND,	RES_CHRATR_BACKGROUND,
353cdf0e10cSrcweir /*10 */			RES_CHRATR_ROTATE,		RES_CHRATR_ROTATE,
354cdf0e10cSrcweir /*12 */			RES_CHRATR_SCALEW,		RES_CHRATR_RELIEF,
355cdf0e10cSrcweir // insert position for CJK/CTL attributes!
356cdf0e10cSrcweir /*14 */			RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE,
357cdf0e10cSrcweir /*16 */			RES_PARATR_REGISTER, 	RES_PARATR_REGISTER,
358cdf0e10cSrcweir /*18 */			RES_PARATR_VERTALIGN, 	RES_PARATR_VERTALIGN,
359cdf0e10cSrcweir /*20 */			RES_LR_SPACE, 			RES_UL_SPACE,
360cdf0e10cSrcweir /*22 */			SID_ATTR_PARA_MODEL, 	SID_ATTR_PARA_KEEP,
361cdf0e10cSrcweir /*24 */ 		0
362cdf0e10cSrcweir 			};
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 			static const sal_uInt16 aCJKAttr[] =
365cdf0e10cSrcweir 			{
366cdf0e10cSrcweir 				RES_CHRATR_CJK_FONT,	RES_CHRATR_CJK_WEIGHT,
367cdf0e10cSrcweir 				RES_CHRATR_EMPHASIS_MARK, RES_CHRATR_TWO_LINES,
368cdf0e10cSrcweir 				RES_PARATR_SCRIPTSPACE, RES_PARATR_FORBIDDEN_RULES
369cdf0e10cSrcweir 			};
370cdf0e10cSrcweir 			static const sal_uInt16 aCTLAttr[] =
371cdf0e10cSrcweir 			{
372cdf0e10cSrcweir 				RES_CHRATR_CTL_FONT,	RES_CHRATR_CTL_WEIGHT
373cdf0e10cSrcweir 			};
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 			SvUShorts aArr( 0, 16 );
376cdf0e10cSrcweir 			aArr.Insert(	aNormalAttr,
377cdf0e10cSrcweir 							sizeof( aNormalAttr ) / sizeof( aNormalAttr[0] ),
378cdf0e10cSrcweir 							0 );
379cdf0e10cSrcweir             if( SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
380cdf0e10cSrcweir 				aArr.Insert(	aCTLAttr,
381cdf0e10cSrcweir 								sizeof( aCTLAttr ) / sizeof( aCTLAttr[0] ),
382cdf0e10cSrcweir 								14 );
383cdf0e10cSrcweir 			SvtCJKOptions aCJKOpt;
384cdf0e10cSrcweir 			if( aCJKOpt.IsAnyEnabled() )
385cdf0e10cSrcweir 				aArr.Insert( 	aCJKAttr,
386cdf0e10cSrcweir 								sizeof( aCJKAttr ) / sizeof( aCJKAttr[0] ),
387cdf0e10cSrcweir 								14 );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 			SfxItemSet aSet( pWrtShell->GetAttrPool(), aArr.GetData() );
390cdf0e10cSrcweir 			sal_uInt16 nWhich = SID_SEARCH_SEARCHSET;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 			if ( FID_SEARCH_REPLACESET == nSlot )
393cdf0e10cSrcweir 			{
394cdf0e10cSrcweir 				nWhich = SID_SEARCH_REPLACESET;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 				if ( pReplList )
397cdf0e10cSrcweir 				{
398cdf0e10cSrcweir 					pReplList->Get( aSet );
399cdf0e10cSrcweir 					DELETEZ( pReplList );
400cdf0e10cSrcweir 				}
401cdf0e10cSrcweir 			}
402cdf0e10cSrcweir 			else if ( pSrchList )
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				pSrchList->Get( aSet );
405cdf0e10cSrcweir 				DELETEZ( pSrchList );
406cdf0e10cSrcweir 			}
407cdf0e10cSrcweir 			rReq.SetReturnValue( SvxSetItem( nWhich, aSet ) );
408cdf0e10cSrcweir 		}
409cdf0e10cSrcweir 		break;
410cdf0e10cSrcweir 		default:
411cdf0e10cSrcweir #ifdef DBG_UTIL
412cdf0e10cSrcweir 			if(nSlot)
413cdf0e10cSrcweir 			{
414cdf0e10cSrcweir 				ByteString sStr( "nSlot: " );
415cdf0e10cSrcweir 				sStr += ByteString::CreateFromInt32( nSlot );
416cdf0e10cSrcweir 				sStr += " falscher Dispatcher (viewsrch.cxx)";
417cdf0e10cSrcweir 				DBG_ERROR( sStr.GetBuffer() );
418cdf0e10cSrcweir 			}
419cdf0e10cSrcweir #endif
420cdf0e10cSrcweir 			return;
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 
425cdf0e10cSrcweir sal_Bool SwView::SearchAndWrap(sal_Bool bApi)
426cdf0e10cSrcweir {
427cdf0e10cSrcweir 	SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 		// Startposition der Suche fuer WrapAround merken
430cdf0e10cSrcweir 		// Start- / EndAction wegen vielleicht bestehender Selektionen
431cdf0e10cSrcweir 		// aus 'Suche alle'
432cdf0e10cSrcweir 	pWrtShell->StartAllAction();
433cdf0e10cSrcweir 	pWrtShell->Push();
434cdf0e10cSrcweir 		// falls in selektierten Bereichen gesucht werden soll, duerfen sie
435cdf0e10cSrcweir 		// nicht aufgehoben werden
436cdf0e10cSrcweir 	if (!pSrchItem->GetSelection())
437cdf0e10cSrcweir 		(pWrtShell->*pWrtShell->fnKillSel)(0, sal_False);
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	SwWait *pWait = new SwWait( *GetDocShell(), sal_True );
440cdf0e10cSrcweir 	if( FUNC_Search( aOpts ) )
441cdf0e10cSrcweir 	{
442cdf0e10cSrcweir 		bFound = sal_True;
443cdf0e10cSrcweir 		if(pWrtShell->IsSelFrmMode())
444cdf0e10cSrcweir 		{
445cdf0e10cSrcweir 			pWrtShell->UnSelectFrm();
446cdf0e10cSrcweir 			pWrtShell->LeaveSelFrmMode();
447cdf0e10cSrcweir 		}
448cdf0e10cSrcweir 		pWrtShell->Pop();
449cdf0e10cSrcweir 		pWrtShell->EndAllAction();
450cdf0e10cSrcweir 		delete pWait;
451cdf0e10cSrcweir 		return sal_True;
452cdf0e10cSrcweir 	}
453cdf0e10cSrcweir 	delete pWait, pWait = 0;
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 		// Suchen in den Sonderbereichen, wenn keine
456cdf0e10cSrcweir 		// Suche in Selektionen vorliegt. Bei Suche in Selektionen
457cdf0e10cSrcweir 		// wird ohnehin in diesen Sonderbereichen gesucht
458cdf0e10cSrcweir 	sal_Bool bHasSrchInOther = bExtra;
459cdf0e10cSrcweir 	if (!pSrchItem->GetSelection() && !bExtra )
460cdf0e10cSrcweir 	{
461cdf0e10cSrcweir 		bExtra = sal_True;
462cdf0e10cSrcweir 		if( FUNC_Search( aOpts ) )
463cdf0e10cSrcweir 		{
464cdf0e10cSrcweir 			bFound = sal_True;
465cdf0e10cSrcweir 			pWrtShell->Pop();
466cdf0e10cSrcweir 			pWrtShell->EndAllAction();
467cdf0e10cSrcweir 			return sal_True;
468cdf0e10cSrcweir 		}
469cdf0e10cSrcweir 		bExtra = sal_False;
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 	else
472cdf0e10cSrcweir 		bExtra = !bExtra;
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 	const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
475cdf0e10cSrcweir 	SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nId);
476cdf0e10cSrcweir 	pSrchDlg = pWrp ? static_cast <SvxSearchDialog*> (pWrp->getDialog ()) : 0;
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 		// falls Startposition am Dokumentende / -anfang
479cdf0e10cSrcweir 	if (aOpts.bDontWrap)
480cdf0e10cSrcweir 	{
481cdf0e10cSrcweir 		pWrtShell->EndAllAction();
482cdf0e10cSrcweir 		if( !bApi )
483cdf0e10cSrcweir 		{
484cdf0e10cSrcweir 			Window* pParentWindow = GetParentWindow( pSrchDlg );
485cdf0e10cSrcweir 			InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
486cdf0e10cSrcweir 		}
487cdf0e10cSrcweir 		bFound = sal_False;
488cdf0e10cSrcweir 		pWrtShell->Pop();
489cdf0e10cSrcweir 		return sal_False;
490cdf0e10cSrcweir 	}
491cdf0e10cSrcweir 	pWrtShell->EndAllAction();
492cdf0e10cSrcweir 		// noch mal mit WrapAround versuchen?
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	if( bApi || RET_NO == QueryBox( GetParentWindow( pSrchDlg ),
495cdf0e10cSrcweir 										SW_RES( DOCPOS_START == aOpts.eEnd
496cdf0e10cSrcweir 											? MSG_SEARCH_START
497cdf0e10cSrcweir 											: MSG_SEARCH_END )
498cdf0e10cSrcweir 									).Execute() )
499cdf0e10cSrcweir 	{
500cdf0e10cSrcweir 		bFound = sal_False;
501cdf0e10cSrcweir 		pWrtShell->Pop();
502cdf0e10cSrcweir 		return sal_False;
503cdf0e10cSrcweir 	}
504cdf0e10cSrcweir 	pWrtShell->StartAllAction();
505cdf0e10cSrcweir 	pWrtShell->Pop(sal_False);
506cdf0e10cSrcweir 	pWait = new SwWait( *GetDocShell(), sal_True );
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 	sal_Bool bSrchBkwrd = DOCPOS_START == aOpts.eEnd;
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 	aOpts.eEnd =  bSrchBkwrd ? DOCPOS_START : DOCPOS_END;
511cdf0e10cSrcweir 	aOpts.eStart = bSrchBkwrd ? DOCPOS_END : DOCPOS_START;
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 	if (bHasSrchInOther)
514cdf0e10cSrcweir 	{
515cdf0e10cSrcweir 		pWrtShell->ClearMark();
516cdf0e10cSrcweir 		if (bSrchBkwrd)
517cdf0e10cSrcweir 			pWrtShell->EndDoc();
518cdf0e10cSrcweir 		else
519cdf0e10cSrcweir 			pWrtShell->SttDoc();
520cdf0e10cSrcweir 	}
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 	bFound = 0 != FUNC_Search( aOpts );
523cdf0e10cSrcweir 	pWrtShell->EndAllAction();
524cdf0e10cSrcweir 	delete pWait;
525cdf0e10cSrcweir 	if ( bFound )
526cdf0e10cSrcweir 		return bFound;
527cdf0e10cSrcweir 	if(!bApi)
528cdf0e10cSrcweir 	{
529cdf0e10cSrcweir 		Window* pParentWindow = GetParentWindow( pSrchDlg );
530cdf0e10cSrcweir 		InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
531cdf0e10cSrcweir 	}
532cdf0e10cSrcweir 	return bFound = sal_False;
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 
536cdf0e10cSrcweir sal_Bool SwView::SearchAll(sal_uInt16* pFound)
537cdf0e10cSrcweir {
538cdf0e10cSrcweir 	SwWait aWait( *GetDocShell(), sal_True );
539cdf0e10cSrcweir 	pWrtShell->StartAllAction();
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 	SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 	if (!pSrchItem->GetSelection())
544cdf0e10cSrcweir 	{
545cdf0e10cSrcweir 		// bestehende Selektionen aufheben,
546cdf0e10cSrcweir 		// wenn nicht in selektierten Bereichen gesucht werden soll
547cdf0e10cSrcweir 		(pWrtShell->*pWrtShell->fnKillSel)(0, sal_False);
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 		if( DOCPOS_START == aOpts.eEnd )
550cdf0e10cSrcweir 			pWrtShell->EndDoc();
551cdf0e10cSrcweir 		else
552cdf0e10cSrcweir 			pWrtShell->SttDoc();
553cdf0e10cSrcweir 	}
554cdf0e10cSrcweir 	bExtra = sal_False;
555cdf0e10cSrcweir 	sal_uInt16 nFound = (sal_uInt16)FUNC_Search( aOpts );
556cdf0e10cSrcweir 	if(pFound)
557cdf0e10cSrcweir 		*pFound = nFound;
558cdf0e10cSrcweir 	bFound = 0 != nFound;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 	pWrtShell->EndAllAction();
561cdf0e10cSrcweir 	return bFound;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 
565cdf0e10cSrcweir void SwView::Replace()
566cdf0e10cSrcweir {
567cdf0e10cSrcweir 	SwWait aWait( *GetDocShell(), sal_True );
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 	pWrtShell->StartAllAction();
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 	if( pSrchItem->GetPattern() ) // Vorlagen?
572cdf0e10cSrcweir     {
573cdf0e10cSrcweir         SwRewriter aRewriter;
574cdf0e10cSrcweir         aRewriter.AddRule(UNDO_ARG1, pSrchItem->GetSearchString());
575cdf0e10cSrcweir         aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS));
576cdf0e10cSrcweir         aRewriter.AddRule(UNDO_ARG3, pSrchItem->GetReplaceString());
577cdf0e10cSrcweir 
578cdf0e10cSrcweir         pWrtShell->StartUndo(UNDO_UI_REPLACE_STYLE, &aRewriter); // #111827#
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 		pWrtShell->SetTxtFmtColl( pWrtShell->GetParaStyle(
581cdf0e10cSrcweir 							pSrchItem->GetReplaceString(),
582cdf0e10cSrcweir 							SwWrtShell::GETSTYLE_CREATESOME ));
583cdf0e10cSrcweir 
584cdf0e10cSrcweir         pWrtShell->EndUndo(); // #111827#
585cdf0e10cSrcweir     }
586cdf0e10cSrcweir 	else
587cdf0e10cSrcweir 	{
588cdf0e10cSrcweir         if (GetPostItMgr()->HasActiveSidebarWin())
589cdf0e10cSrcweir 			GetPostItMgr()->Replace(pSrchItem);
590cdf0e10cSrcweir 		sal_Bool bReplaced = pWrtShell->SwEditShell::Replace( pSrchItem->GetReplaceString(),
591cdf0e10cSrcweir 											pSrchItem->GetRegExp());
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 		if( bReplaced && pReplList && pReplList->Count() && pWrtShell->HasSelection() )
594cdf0e10cSrcweir 		{
595cdf0e10cSrcweir 			SfxItemSet aReplSet( pWrtShell->GetAttrPool(),
596cdf0e10cSrcweir 									aTxtFmtCollSetRange );
597cdf0e10cSrcweir 			if( pReplList->Get( aReplSet ).Count() )
598cdf0e10cSrcweir 			{
599cdf0e10cSrcweir 				::SfxToSwPageDescAttr( *pWrtShell, aReplSet );
600cdf0e10cSrcweir 				pWrtShell->SwEditShell::SetAttr( aReplSet );
601cdf0e10cSrcweir 			}
602cdf0e10cSrcweir 		}
603cdf0e10cSrcweir 	}
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	pWrtShell->EndAllAction();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 
610cdf0e10cSrcweir SwSearchOptions::SwSearchOptions( SwWrtShell* pSh, sal_Bool bBackward )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir 	eStart = DOCPOS_CURR;
613cdf0e10cSrcweir 	if( bBackward )
614cdf0e10cSrcweir 	{
615cdf0e10cSrcweir 		eEnd = DOCPOS_START;
616cdf0e10cSrcweir 		bDontWrap = pSh->IsEndOfDoc();
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir 	else
619cdf0e10cSrcweir 	{
620cdf0e10cSrcweir 		eEnd = DOCPOS_END;
621cdf0e10cSrcweir 		bDontWrap = pSh->IsStartOfDoc();
622cdf0e10cSrcweir 	}
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	sal_Bool bDoReplace = pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE ||
628cdf0e10cSrcweir 					  pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 	int eRanges = pSrchItem->GetSelection() ?
631cdf0e10cSrcweir 		FND_IN_SEL : bExtra ? FND_IN_OTHER : FND_IN_BODY;
632cdf0e10cSrcweir 	if (pSrchItem->GetCommand() == SVX_SEARCHCMD_FIND_ALL    ||
633cdf0e10cSrcweir 		pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL)
634cdf0e10cSrcweir 		eRanges |= FND_IN_SELALL;
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 	pWrtShell->SttSelect();
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 	static sal_uInt16 __READONLY_DATA aSearchAttrRange[] = {
639cdf0e10cSrcweir 		RES_FRMATR_BEGIN, RES_FRMATR_END-1,
640cdf0e10cSrcweir 		RES_CHRATR_BEGIN, RES_CHRATR_END-1,
641cdf0e10cSrcweir 		RES_PARATR_BEGIN, RES_PARATR_END-1,
642cdf0e10cSrcweir 		SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
643cdf0e10cSrcweir 		0 };
644cdf0e10cSrcweir 
645cdf0e10cSrcweir 	SfxItemSet aSrchSet( pWrtShell->GetAttrPool(), aSearchAttrRange);
646cdf0e10cSrcweir 	if( pSrchList && pSrchList->Count() )
647cdf0e10cSrcweir 	{
648cdf0e10cSrcweir 		pSrchList->Get( aSrchSet );
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 		/*  -- Seitenumbruch mit Seitenvorlage */
651cdf0e10cSrcweir 		::SfxToSwPageDescAttr( *pWrtShell, aSrchSet );
652cdf0e10cSrcweir 	}
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	SfxItemSet* pReplSet = 0;
655cdf0e10cSrcweir 	if( bDoReplace && pReplList && pReplList->Count() )
656cdf0e10cSrcweir 	{
657cdf0e10cSrcweir 		pReplSet = new SfxItemSet( pWrtShell->GetAttrPool(),
658cdf0e10cSrcweir 										aSearchAttrRange );
659cdf0e10cSrcweir 		pReplList->Get( *pReplSet );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir 		/*  -- Seitenumbruch mit Seitenvorlage */
662cdf0e10cSrcweir 		::SfxToSwPageDescAttr( *pWrtShell, *pReplSet );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 		if( !pReplSet->Count() )		// schade, die Attribute
665cdf0e10cSrcweir 			DELETEZ( pReplSet );		// kennen wir nicht
666cdf0e10cSrcweir 	}
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	//
669cdf0e10cSrcweir 	// build SearchOptions to be used
670cdf0e10cSrcweir 	//
671cdf0e10cSrcweir 	SearchOptions aSearchOpt( pSrchItem->GetSearchOptions() );
672cdf0e10cSrcweir 	aSearchOpt.Locale = SvxCreateLocale( (sal_uInt16)GetAppLanguage() );
673cdf0e10cSrcweir 	if( !bDoReplace )
674cdf0e10cSrcweir 		aSearchOpt.replaceString = aEmptyStr;
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 	sal_uLong nFound;
677cdf0e10cSrcweir 	if( aSrchSet.Count() || ( pReplSet && pReplSet->Count() ))
678cdf0e10cSrcweir 	{
679cdf0e10cSrcweir 		nFound = pWrtShell->SearchAttr(
680cdf0e10cSrcweir 			aSrchSet,
681cdf0e10cSrcweir 			!pSrchItem->GetPattern(),
682cdf0e10cSrcweir 			rOptions.eStart,
683cdf0e10cSrcweir 			rOptions.eEnd,
684cdf0e10cSrcweir 			FindRanges(eRanges),
685cdf0e10cSrcweir 			pSrchItem->GetSearchString().Len() ? &aSearchOpt : 0,
686cdf0e10cSrcweir 			pReplSet );
687cdf0e10cSrcweir 	}
688cdf0e10cSrcweir 	else if( pSrchItem->GetPattern() )
689cdf0e10cSrcweir 	{
690cdf0e10cSrcweir 		// Suchen (und ersetzen) von Vorlagen
691cdf0e10cSrcweir 		const String sRplStr( pSrchItem->GetReplaceString() );
692cdf0e10cSrcweir 		nFound = pWrtShell->SearchTempl( pSrchItem->GetSearchString(),
693cdf0e10cSrcweir 			rOptions.eStart,
694cdf0e10cSrcweir 			rOptions.eEnd,
695cdf0e10cSrcweir 			FindRanges(eRanges),
696cdf0e10cSrcweir 			bDoReplace ? &sRplStr : 0 );
697cdf0e10cSrcweir 	}
698cdf0e10cSrcweir 	else
699cdf0e10cSrcweir 	{
700cdf0e10cSrcweir 		// Normale Suche
701cdf0e10cSrcweir 		nFound = pWrtShell->SearchPattern(aSearchOpt, pSrchItem->GetNotes(),
702cdf0e10cSrcweir 										  rOptions.eStart,
703cdf0e10cSrcweir 										  rOptions.eEnd,
704cdf0e10cSrcweir 										  FindRanges(eRanges),
705cdf0e10cSrcweir 										  bDoReplace );
706cdf0e10cSrcweir 	}
707cdf0e10cSrcweir 	pWrtShell->EndSelect();
708cdf0e10cSrcweir 	return nFound;
709cdf0e10cSrcweir }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir LAYOUT_NS Dialog* SwView::GetSearchDialog()
712cdf0e10cSrcweir {
713cdf0e10cSrcweir 	const sal_uInt16 nId = SvxSearchDialogWrapper::GetChildWindowId();
714cdf0e10cSrcweir 	SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*)SfxViewFrame::Current()->GetChildWindow(nId);
715cdf0e10cSrcweir 	if ( pWrp )
716cdf0e10cSrcweir 		pSrchDlg = pWrp->getDialog ();
717cdf0e10cSrcweir 	else
718cdf0e10cSrcweir 		pSrchDlg = 0;
719cdf0e10cSrcweir 	return pSrchDlg;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
722cdf0e10cSrcweir void SwView::StateSearch(SfxItemSet &rSet)
723cdf0e10cSrcweir {
724cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
725cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	while(nWhich)
728cdf0e10cSrcweir 	{
729cdf0e10cSrcweir 		switch(nWhich)
730cdf0e10cSrcweir 		{
731cdf0e10cSrcweir 			case SID_SEARCH_OPTIONS:
732cdf0e10cSrcweir 			{
733cdf0e10cSrcweir 				sal_uInt16 nOpt = 0xFFFF;
734cdf0e10cSrcweir 				if( GetDocShell()->IsReadOnly() )
735cdf0e10cSrcweir 					nOpt &= ~( SEARCH_OPTIONS_REPLACE |
736cdf0e10cSrcweir 							   SEARCH_OPTIONS_REPLACE_ALL );
737cdf0e10cSrcweir 				rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, nOpt));
738cdf0e10cSrcweir 			}
739cdf0e10cSrcweir 			break;
740cdf0e10cSrcweir 			case SID_SEARCH_ITEM:
741cdf0e10cSrcweir 			{
742cdf0e10cSrcweir 				if ( !pSrchItem )
743cdf0e10cSrcweir 				{
744cdf0e10cSrcweir 					pSrchItem = new SvxSearchItem( SID_SEARCH_ITEM );
745cdf0e10cSrcweir 					pSrchItem->SetFamily(SFX_STYLE_FAMILY_PARA);
746cdf0e10cSrcweir 					pSrchItem->SetSearchString( pWrtShell->GetSelTxt() );
747cdf0e10cSrcweir 				}
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 				if( bJustOpened && pWrtShell->IsSelection() )
750cdf0e10cSrcweir 				{
751cdf0e10cSrcweir 					String aTxt;
752cdf0e10cSrcweir 					if( 1 == pWrtShell->GetCrsrCnt() &&
753cdf0e10cSrcweir 						( aTxt = pWrtShell->SwCrsrShell::GetSelTxt() ).Len() )
754cdf0e10cSrcweir 					{
755cdf0e10cSrcweir 						pSrchItem->SetSearchString( aTxt );
756cdf0e10cSrcweir 						pSrchItem->SetSelection( sal_False );
757cdf0e10cSrcweir 					}
758cdf0e10cSrcweir 					else
759cdf0e10cSrcweir 						pSrchItem->SetSelection( sal_True );
760cdf0e10cSrcweir 				}
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 				bJustOpened = sal_False;
763cdf0e10cSrcweir 				rSet.Put( *pSrchItem );
764cdf0e10cSrcweir 			}
765cdf0e10cSrcweir 			break;
766cdf0e10cSrcweir 
767cdf0e10cSrcweir /*			case SID_SEARCH_REPLACESET:
768cdf0e10cSrcweir 			case SID_SEARCH_SEARCHSET:
769cdf0e10cSrcweir 			{
770cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aSearchAttrRange[] =
771cdf0e10cSrcweir 				{
772cdf0e10cSrcweir 						RES_CHRATR_CASEMAP,		RES_CHRATR_POSTURE,
773cdf0e10cSrcweir 						RES_CHRATR_SHADOWED, 	RES_CHRATR_WORDLINEMODE,
774cdf0e10cSrcweir 						RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE,
775cdf0e10cSrcweir 						RES_LR_SPACE, 			RES_UL_SPACE,
776cdf0e10cSrcweir 						SID_ATTR_PARA_MODEL, 	SID_ATTR_PARA_KEEP,
777cdf0e10cSrcweir 						0
778cdf0e10cSrcweir 				};
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 				SfxItemSet aSet(pWrtShell->GetAttrPool(), aSearchAttrRange );
781cdf0e10cSrcweir 				if( SID_SEARCH_REPLACESET==nWhich )
782cdf0e10cSrcweir 				{
783cdf0e10cSrcweir 					if( pReplList )
784cdf0e10cSrcweir 					{
785cdf0e10cSrcweir 						pReplList->Get( aSet );
786cdf0e10cSrcweir 						DELETEZ( pReplList );
787cdf0e10cSrcweir 					}
788cdf0e10cSrcweir 				}
789cdf0e10cSrcweir 				else if( pSrchList )
790cdf0e10cSrcweir 				{
791cdf0e10cSrcweir 					pSrchList->Get( aSet );
792cdf0e10cSrcweir 					DELETEZ( pSrchList );
793cdf0e10cSrcweir 				}
794cdf0e10cSrcweir 				rSet.Put( SvxSetItem( nWhich, aSet ));
795cdf0e10cSrcweir 			}
796cdf0e10cSrcweir 			break;
797cdf0e10cSrcweir */
798cdf0e10cSrcweir 		}
799cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 
805