update dev300-m58
[ooovba.git] / svx / source / dialog / srchdlg.cxx
blob5981347302d47ce989c69a1ead3bd119d51dda3f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: srchdlg.cxx,v $
10 * $Revision: 1.46 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <vcl/wrkwin.hxx>
36 #include <vcl/morebtn.hxx>
37 #include <vcl/msgbox.hxx>
38 #include <svtools/slstitm.hxx>
39 #include <svtools/itemiter.hxx>
40 #include <svtools/style.hxx>
41 #include <svtools/searchopt.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <sfx2/module.hxx>
45 #include <sfx2/viewsh.hxx>
46 #include <sfx2/basedlgs.hxx>
47 #include <svtools/cjkoptions.hxx>
48 #include <com/sun/star/container/XNameAccess.hpp>
49 #include <com/sun/star/i18n/TransliterationModules.hpp>
50 #include <com/sun/star/frame/XDispatch.hpp>
51 #include <com/sun/star/frame/XDispatchProvider.hpp>
52 #include <com/sun/star/beans/PropertyValue.hpp>
53 #include <com/sun/star/frame/XModuleManager.hpp>
54 #include <comphelper/processfactory.hxx>
55 #include <svtools/itempool.hxx>
57 #include <sfx2/app.hxx>
58 #include <toolkit/unohlp.hxx>
60 #define _SVX_SRCHDLG_CXX
61 #include "srchdlg.hxx"
63 #include <svx/dialogs.hrc>
64 #include <svx/svxitems.hrc>
65 #include "srchdlg.hrc"
68 #define ITEMID_SETITEM 0
70 #include <sfx2/srchitem.hxx>
71 #include <svx/pageitem.hxx>
72 #include "srchctrl.hxx"
73 #include <svx/dialmgr.hxx>
74 #include "dlgutil.hxx"
75 #include <svx/brshitem.hxx>
77 #include <svx/svxdlg.hxx> //CHINA001
79 #include <sfx2/layout-pre.hxx>
81 using namespace com::sun::star::i18n;
82 using namespace com::sun::star;
83 using namespace comphelper;
84 // -----------------------------------------------------------------------
86 #define REMEMBER_SIZE 10
88 #define MODIFY_SEARCH 0x00000001
89 #define MODIFY_REPLACE 0x00000002
90 #define MODIFY_WORD 0x00000004
91 #define MODIFY_EXACT 0x00000008
92 #define MODIFY_BACKWARDS 0x00000010
93 #define MODIFY_SELECTION 0x00000020
94 #define MODIFY_REGEXP 0x00000040
95 #define MODIFY_LAYOUT 0x00000080
96 #define MODIFY_SIMILARITY 0x00000100
97 #define MODIFY_FORMULAS 0x00000200
98 #define MODIFY_VALUES 0x00000400
99 #define MODIFY_CALC_NOTES 0x00000800
100 #define MODIFY_ROWS 0x00001000
101 #define MODIFY_COLUMNS 0x00002000
102 #define MODIFY_ALLTABLES 0x00004000
103 #define MODIFY_NOTES 0x00008000
105 SV_IMPL_VARARR(SrchAttrItemList, SearchAttrItem);
107 //#define NotifyApp( nId )
108 // rBindings.ExecuteSynchron( nId, (const SfxPoolItem**)&pSearchItem, 0L )
110 #define GetCheckBoxValue( rBox ) \
111 rBox.IsEnabled() ? rBox.IsChecked() : FALSE
113 #if ENABLE_LAYOUT
114 #undef SVX_RES
115 #define SVX_RES(x) #x
116 #endif /* ENABLE_LAYOUT */
118 struct SearchDlg_Impl
120 FixedText aSearchFormats;
121 FixedText aReplaceFormats;
123 BOOL bMultiLineEdit : 1,
124 bSaveToModule : 1,
125 bFocusOnSearch : 1,
126 bDeltaCalculated : 1;
127 USHORT* pRanges;
128 Timer aSelectionTimer;
130 uno::Reference< frame::XDispatch > xCommand1Dispatch;
131 uno::Reference< frame::XDispatch > xCommand2Dispatch;
132 util::URL aCommand1URL;
133 util::URL aCommand2URL;
135 #if ENABLE_LAYOUT
136 SearchDlg_Impl( layout::Context* pParent ) :
137 #else /* !ENABLE_LAYOUT */
138 SearchDlg_Impl( Window* pParent ) :
139 #endif /* !ENABLE_LAYOUT */
140 aSearchFormats ( pParent, SVX_RES( FT_SEARCH_FORMATS ) ),
141 aReplaceFormats ( pParent, SVX_RES( FT_REPLACE_FORMATS ) ),
142 bMultiLineEdit ( FALSE ),
143 bSaveToModule ( TRUE ),
144 bFocusOnSearch ( TRUE ),
145 bDeltaCalculated( FALSE ),
146 pRanges ( NULL )
148 aCommand1URL.Complete = aCommand1URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent1");
149 aCommand1URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:");
150 aCommand1URL.Path = rtl::OUString::createFromAscii("SearchViaComponent1");
151 aCommand2URL.Complete = aCommand2URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent2");
152 aCommand2URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:");
153 aCommand2URL.Path = rtl::OUString::createFromAscii("SearchViaComponent2");
155 ~SearchDlg_Impl() { delete[] pRanges; }
158 // -----------------------------------------------------------------------
160 void ListToStrArr_Impl( USHORT nId, SvStringsDtor& rStrLst, ComboBox& rCBox )
162 SfxStringListItem* pSrchItem =
163 (SfxStringListItem*)SFX_APP()->GetItem( nId );
164 List* pLst = pSrchItem ? pSrchItem->GetList() : 0;
166 if ( pLst )
167 for ( USHORT i = 0; i < pLst->Count(); ++i )
169 String* pTmp = new String( *(String*)( pLst->GetObject(i) ) );
170 rStrLst.Insert( pTmp, rStrLst.Count() );
171 rCBox.InsertEntry( *pTmp );
175 // -----------------------------------------------------------------------
177 void StrArrToList_Impl( USHORT nId, const SvStringsDtor& rStrLst )
179 DBG_ASSERT( rStrLst.Count(), "vorher abpruefen!!" );
180 List aLst;
182 for ( USHORT i = 0; i < rStrLst.Count(); ++i )
183 aLst.Insert( rStrLst[ i ], LIST_APPEND );
185 SFX_APP()->PutItem( SfxStringListItem( nId, &aLst ) );
188 // class SearchAttrItemList ----------------------------------------------
190 SearchAttrItemList::SearchAttrItemList( const SearchAttrItemList& rList ) :
192 SrchAttrItemList( (BYTE)rList.Count() )
195 SrchAttrItemList::Insert( &rList, 0 );
196 SearchAttrItem* _pData = (SearchAttrItem*)GetData();
198 for ( USHORT i = Count(); i; --i, ++_pData )
199 if ( !IsInvalidItem( _pData->pItem ) )
200 _pData->pItem = _pData->pItem->Clone();
203 // -----------------------------------------------------------------------
205 SearchAttrItemList::~SearchAttrItemList()
207 Clear();
210 // -----------------------------------------------------------------------
212 void SearchAttrItemList::Put( const SfxItemSet& rSet )
214 if ( !rSet.Count() )
215 return;
217 SfxItemPool* pPool = rSet.GetPool();
218 SfxItemIter aIter( rSet );
219 SearchAttrItem aItem;
220 const SfxPoolItem* pItem = aIter.GetCurItem();
221 USHORT nWhich;
223 while ( TRUE )
225 // nur testen, ob vorhanden ist ?
226 if( IsInvalidItem( pItem ) )
228 nWhich = rSet.GetWhichByPos( aIter.GetCurPos() );
229 aItem.pItem = (SfxPoolItem*)pItem;
231 else
233 nWhich = pItem->Which();
234 aItem.pItem = pItem->Clone();
237 aItem.nSlot = pPool->GetSlotId( nWhich );
238 Insert( aItem );
240 if ( aIter.IsAtEnd() )
241 break;
242 pItem = aIter.NextItem();
246 // -----------------------------------------------------------------------
248 SfxItemSet& SearchAttrItemList::Get( SfxItemSet& rSet )
250 SfxItemPool* pPool = rSet.GetPool();
251 SearchAttrItem* _pData = (SearchAttrItem*)GetData();
253 for ( USHORT i = Count(); i; --i, ++_pData )
254 if ( IsInvalidItem( _pData->pItem ) )
255 rSet.InvalidateItem( pPool->GetWhich( _pData->nSlot ) );
256 else
257 rSet.Put( *_pData->pItem );
258 return rSet;
261 // -----------------------------------------------------------------------
263 void SearchAttrItemList::Clear()
265 SearchAttrItem* _pData = (SearchAttrItem*)GetData();
267 for ( USHORT i = Count(); i; --i, ++_pData )
268 if ( !IsInvalidItem( _pData->pItem ) )
269 delete _pData->pItem;
270 SrchAttrItemList::Remove( 0, Count() );
273 // -----------------------------------------------------------------------
275 // l"oscht die Pointer auf die Items
276 void SearchAttrItemList::Remove( USHORT nPos, USHORT nLen )
278 if ( nPos + nLen > Count() )
279 nLen = Count() - nPos;
280 SearchAttrItem* _pData = (SearchAttrItem*)GetData() + nPos;
282 for ( USHORT n = nLen; n; --n, ++_pData )
283 if ( !IsInvalidItem( _pData->pItem ) )
284 delete _pData->pItem;
286 SrchAttrItemList::Remove( nPos, nLen );
289 /* //CHINA001
290 // class SvxJSearchOptionsDialog -----------------------------------------
292 SvxJSearchOptionsDialog::SvxJSearchOptionsDialog(
293 Window *pParent,
294 const SfxItemSet& rOptionsSet, USHORT nUniqueId, INT32 nInitialFlags ) :
295 SfxSingleTabDialog ( pParent, rOptionsSet, RID_SVXPAGE_JSEARCH_OPTIONS ),
296 nInitialTlFlags( nInitialFlags )
298 pPage = (SvxJSearchOptionsPage *)
299 SvxJSearchOptionsPage::Create( this, rOptionsSet );
300 SetTabPage( pPage ); //! implicitly calls pPage->Reset(...)!
301 pPage->EnableSaveOptions( FALSE );
305 SvxJSearchOptionsDialog::~SvxJSearchOptionsDialog()
307 // pPage will be implicitly destroyed by the
308 // SfxSingleTabDialog destructor
312 void SvxJSearchOptionsDialog::Activate()
314 pPage->SetTransliterationFlags( nInitialTlFlags );
318 INT32 SvxJSearchOptionsDialog::GetTransliterationFlags() const
320 return pPage->GetTransliterationFlags();
324 void SvxJSearchOptionsDialog::SetTransliterationFlags( INT32 nSettings )
326 pPage->SetTransliterationFlags( nSettings );
328 */ //CHINA001
330 #if ENABLE_LAYOUT
331 #undef SfxModelessDialog
332 #define SfxModelessDialog(bindings, child, parent, id) SfxDialog (parent, "find-and-replace.xml", id, bindings, child)
333 #define SVX_RES_PLAIN(x) ResId (x, DIALOG_MGR ())
334 #define THIS_SVX_RES(x) this, #x
335 #else /* !ENABLE_LAYOUT */
336 #define SVX_RES_PLAIN SVX_RES
337 #define THIS_SVX_RES SVX_RES
338 #endif /* !ENABLE_LAYOUT */
340 #undef INI_LIST
341 #define INI_LIST() \
342 aSearchText ( this, SVX_RES( FT_SEARCH ) ), \
343 aSearchLB ( this, SVX_RES( ED_SEARCH ) ), \
344 aSearchTmplLB ( this, SVX_RES( LB_SEARCH ) ), \
345 aSearchAttrText ( this, SVX_RES( FT_SEARCH_ATTR ) ), \
346 aReplaceText ( this, SVX_RES( FT_REPLACE ) ), \
347 aReplaceLB ( this, SVX_RES( ED_REPLACE ) ), \
348 aReplaceTmplLB ( this, SVX_RES( LB_REPLACE ) ), \
349 aReplaceAttrText( this, SVX_RES( FT_REPLACE_ATTR ) ), \
350 aSearchBtn ( this, SVX_RES( BTN_SEARCH ) ), \
351 aSearchAllBtn ( this, SVX_RES( BTN_SEARCH_ALL ) ), \
352 aSearchCmdLine ( this, SVX_RES( FL_SEARCH_COMMAND ) ), \
353 aReplaceBtn ( this, SVX_RES( BTN_REPLACE ) ), \
354 aReplaceAllBtn ( this, SVX_RES( BTN_REPLACE_ALL ) ), \
355 aSearchComponentFL( this, SVX_RES( FL_SEARCH_COMPONENT ) ), \
356 aSearchComponent1PB( this, SVX_RES( BTN_COMPONENT_1 ) ), \
357 aSearchComponent2PB( this, SVX_RES( BTN_COMPONENT_2 ) ), \
358 aMatchCaseCB ( this, SVX_RES( CB_MATCH_CASE ) ), \
359 aWordBtn ( this, SVX_RES( CB_WHOLE_WORDS ) ), \
360 aButtonsFL ( this, SVX_RES( FL_BUTTONS ) ), \
361 pMoreBtn ( new MoreButton( this, SVX_RES( BTN_MORE ) ) ), \
362 aHelpBtn ( this, SVX_RES( BTN_HELP ) ), \
363 aCloseBtn ( this, SVX_RES( BTN_CLOSE ) ), \
364 aOptionsFL ( this, SVX_RES( FL_OPTIONS ) ), \
365 aSelectionBtn ( this, SVX_RES( CB_SELECTIONS ) ), \
366 aBackwardsBtn ( this, SVX_RES( CB_BACKWARDS ) ), \
367 aRegExpBtn ( this, SVX_RES( CB_REGEXP ) ), \
368 aSimilarityBox ( this, SVX_RES( CB_SIMILARITY) ), \
369 aSimilarityBtn ( this, SVX_RES( PB_SIMILARITY) ), \
370 aLayoutBtn ( this, SVX_RES( CB_LAYOUTS ) ), \
371 aNotesBtn ( this, SVX_RES( CB_NOTES ) ), \
372 aJapMatchFullHalfWidthCB( this, SVX_RES( CB_JAP_MATCH_FULL_HALF_WIDTH ) ),\
373 aJapOptionsCB ( this, SVX_RES( CB_JAP_SOUNDS_LIKE ) ), \
374 aJapOptionsBtn ( this, SVX_RES( PB_JAP_OPTIONS ) ), \
375 aAttributeBtn ( this, SVX_RES( BTN_ATTRIBUTE ) ), \
376 aFormatBtn ( this, SVX_RES( BTN_FORMAT ) ), \
377 aNoFormatBtn ( this, SVX_RES( BTN_NOFORMAT ) ), \
378 aCalcFL ( this, SVX_RES( FL_CALC ) ), \
379 aCalcSearchInFT ( this, SVX_RES( FT_CALC_SEARCHIN ) ), \
380 aCalcSearchInLB ( this, SVX_RES( LB_CALC_SEARCHIN ) ), \
381 aCalcSearchDirFT( this, SVX_RES( FT_CALC_SEARCHDIR ) ), \
382 aRowsBtn ( this, SVX_RES( RB_CALC_ROWS ) ), \
383 aColumnsBtn ( this, SVX_RES( RB_CALC_COLUMNS ) ), \
384 aAllSheetsCB ( this, SVX_RES( CB_ALL_SHEETS ) ), \
385 rBindings ( rBind ), \
386 bWriter ( FALSE ), \
387 bSearch ( TRUE ), \
388 bFormat ( FALSE ), \
389 nOptions ( USHRT_MAX ), \
390 bSet ( FALSE ), \
391 bReadOnly ( FALSE ), \
392 bConstruct ( TRUE ), \
393 nModifyFlag ( 0 ), \
394 aCalcStr ( THIS_SVX_RES( STR_WORDCALC ) ), \
395 pImpl ( NULL ), \
396 pSearchList ( NULL ), \
397 pReplaceList ( new SearchAttrItemList ), \
398 pSearchItem ( NULL ), \
399 pSearchController ( NULL ), \
400 pOptionsController ( NULL ), \
401 pFamilyController ( NULL ), \
402 pSearchSetController ( NULL ), \
403 pReplaceSetController ( NULL ), \
404 nTransliterationFlags ( 0x00000000 )
406 // class SvxSearchDialog -------------------------------------------------
408 SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxBindings& rBind ) :
410 SfxModelessDialog( &rBind, NULL, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
412 INI_LIST()
415 Construct_Impl();
418 // -----------------------------------------------------------------------
420 SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind ) :
422 SfxModelessDialog( &rBind, pChildWin, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
424 INI_LIST()
427 Construct_Impl();
430 #undef INI_LIST
431 #if ENABLE_LAYOUT
432 #undef SVX_RES
433 #define SVX_RES(x) ResId (x, DIALOG_MGR ())
434 #endif
436 // -----------------------------------------------------------------------
438 SvxSearchDialog::~SvxSearchDialog()
440 Hide();
442 rBindings.EnterRegistrations();
443 delete pSearchController;
444 delete pOptionsController;
445 delete pFamilyController;
446 delete pSearchSetController;
447 delete pReplaceSetController;
448 rBindings.LeaveRegistrations();
450 delete pSearchItem;
451 delete pImpl;
452 delete pSearchList;
453 delete pReplaceList;
454 delete pMoreBtn;
457 #if ENABLE_LAYOUT
458 #undef Window
459 #define Window layout::Window
460 #endif /* ENABLE_LAYOUT */
462 void lcl_MoveDown( Window& rWindow, sal_Int32 nOffset )
464 Point aPos(rWindow.GetPosPixel());
465 aPos.Y() += nOffset;
466 rWindow.SetPosPixel(aPos);
469 void SvxSearchDialog::Construct_Impl()
471 #if ENABLE_LAYOUT
472 SetHelpId (SID_SEARCH_DLG);
473 #endif /* ENABLE_LAYOUT */
475 // temporary to avoid incompatibility
476 pImpl = new SearchDlg_Impl( this );
477 #if !ENABLE_LAYOUT
478 pImpl->aSelectionTimer.SetTimeout( 500 );
479 pImpl->aSelectionTimer.SetTimeoutHdl(
480 LINK( this, SvxSearchDialog, TimeoutHdl_Impl ) );
481 #endif /* !ENABLE_LAYOUT */
482 EnableControls_Impl( 0 );
484 // alten Text des aWordBtn's merken
485 aCalcStr += sal_Unicode('#');
486 aCalcStr += aWordBtn.GetText();
488 aLayoutStr = SVX_RESSTR( RID_SVXSTR_SEARCH_STYLES );
489 aStylesStr = aLayoutBtn.GetText();
491 // gemerkte Such-Strings von der Applikation holen
492 ListToStrArr_Impl( SID_SEARCHDLG_SEARCHSTRINGS,
493 aSearchStrings, aSearchLB );
494 ListToStrArr_Impl( SID_SEARCHDLG_REPLACESTRINGS,
495 aReplaceStrings, aReplaceLB );
497 pMoreBtn->SetMoreText( String( SVX_RES( STR_MORE_BTN ) ) );
498 pMoreBtn->SetLessText( String( SVX_RES( STR_LESS_BTN ) ) );
500 FreeResource();
501 InitControls_Impl();
503 // Attribut-Sets nur einmal im Ctor() besorgen
504 const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
505 const SvxSetItem* pSrchSetItem =
506 (const SvxSetItem*) rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
508 if ( pSrchSetItem )
509 InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
511 const SvxSetItem* pReplSetItem =
512 (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
514 if ( pReplSetItem )
515 InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
517 // Controller erzeugen und gleich aktualisieren
518 rBindings.EnterRegistrations();
519 pSearchController =
520 new SvxSearchController( SID_SEARCH_ITEM, rBindings, *this );
521 pOptionsController =
522 new SvxSearchController( SID_SEARCH_OPTIONS, rBindings, *this );
523 rBindings.LeaveRegistrations();
524 rBindings.GetDispatcher()->Execute( FID_SEARCH_ON, SFX_CALLMODE_SLOT, ppArgs );
525 pImpl->aSelectionTimer.Start();
528 SvtCJKOptions aCJKOptions;
529 if(!aCJKOptions.IsJapaneseFindEnabled())
531 aJapOptionsCB.Check( FALSE );
532 aJapOptionsCB.Hide();
533 aJapOptionsBtn.Hide();
535 if(!aCJKOptions.IsCJKFontEnabled())
537 aJapMatchFullHalfWidthCB.Hide();
539 //component extension - show component search buttons if the commands
540 // vnd.sun.star::SearchViaComponent1 and 2 are supported
541 const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
542 const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
543 rtl::OUString sTarget = rtl::OUString::createFromAscii("_self");
545 bool bSearchComponent1 = false;
546 bool bSearchComponent2 = false;
547 if(xDispatchProv.is() &&
548 (pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0)).is())
550 bSearchComponent1 = true;
552 if(xDispatchProv.is() &&
553 (pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0)).is())
555 bSearchComponent2 = true;
558 if( bSearchComponent1 || bSearchComponent2 )
560 //get the labels of the FixedLine and the buttons
561 // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchGroupLabel
562 // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchCommandLabel1
563 // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchCommandLabel2
566 uno::Reference< lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
567 uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(xMgr->createInstance(
568 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider"))),
569 uno::UNO_QUERY);
570 uno::Sequence< uno::Any > aArgs(1);
571 ::rtl::OUString sPath(RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/SearchOptions/"));
572 aArgs[0] <<= sPath;
574 uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
575 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess")),
576 aArgs);
577 uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
578 if(xDirectAccess.is())
580 ::rtl::OUString sTemp;
581 ::rtl::OUString sProperty(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchGroupLabel"));
582 uno::Any aRet = xDirectAccess->getByName(sProperty);
583 aRet >>= sTemp;
584 aSearchComponentFL.SetText( sTemp );
585 aRet = xDirectAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchCommandLabel1")));
586 aRet >>= sTemp;
587 aSearchComponent1PB.SetText( sTemp );
588 aRet = xDirectAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchCommandLabel2")));
589 aRet >>= sTemp;
590 aSearchComponent2PB.SetText( sTemp );
593 catch(uno::Exception&){}
595 if(aSearchComponent1PB.GetText().Len() && bSearchComponent1 )
597 aSearchComponentFL.Show();
598 aSearchComponent1PB.Show();
600 if( aSearchComponent2PB.GetText().Len() )
602 if(!aSearchComponent1PB.IsVisible())
604 aSearchComponent2PB.SetPosPixel(aSearchComponent1PB.GetPosPixel());
606 aSearchComponentFL.Show();
607 aSearchComponent2PB.Show();
609 if( aSearchComponentFL.IsVisible() && aSearchComponent1PB.IsVisible() )
612 //dialog must be resized
613 Size aDlgSize(GetSizePixel());
614 sal_Int32 nOffset = aSearchCmdLine.GetPosPixel().Y() - aSearchAllBtn.GetPosPixel().Y()
615 - aButtonsFL.GetPosPixel().Y() + aSearchComponent2PB.GetPosPixel().Y();
617 aDlgSize.Height() += nOffset;
618 Window* aWindows[] =
620 &aOptionsFL,
621 &aSelectionBtn,
622 &aBackwardsBtn,
623 &aRegExpBtn,
624 &aSimilarityBox,
625 &aSimilarityBtn,
626 &aLayoutBtn,
627 &aNotesBtn,
628 &aJapMatchFullHalfWidthCB,
629 &aJapOptionsCB,
630 &aJapOptionsBtn,
631 &aAttributeBtn,
632 &aFormatBtn,
633 &aNoFormatBtn,
634 &aCalcFL,
635 &aCalcSearchInFT,
636 &aCalcSearchInLB,
637 &aCalcSearchDirFT,
638 &aRowsBtn,
639 &aColumnsBtn,
640 &aAllSheetsCB,
641 &aButtonsFL,
642 &aHelpBtn,
643 &aCloseBtn,
644 pMoreBtn,
647 sal_Int32 nWindow = 0;
650 lcl_MoveDown( *aWindows[nWindow], nOffset );
652 while(aWindows[++nWindow]);
654 SetSizePixel(aDlgSize);
659 // -----------------------------------------------------------------------
661 BOOL SvxSearchDialog::Close()
663 // remember strings speichern
664 if ( aSearchStrings.Count() )
665 StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
667 if ( aReplaceStrings.Count() )
668 StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
670 // save settings to configuration
671 SvtSearchOptions aOpt;
672 aOpt.SetWholeWordsOnly ( aWordBtn .IsChecked() );
673 aOpt.SetBackwards ( aBackwardsBtn .IsChecked() );
674 aOpt.SetUseRegularExpression ( aRegExpBtn .IsChecked() );
675 //aOpt.SetMatchCase ( aMatchCaseCB .IsChecked() );
676 aOpt.SetSearchForStyles ( aLayoutBtn .IsChecked() );
677 aOpt.SetSimilaritySearch ( aSimilarityBox .IsChecked() );
678 //aOpt.SetMatchFullHalfWidthForms ( !aJapMatchFullHalfWidthCB.IsChecked() );
679 aOpt.SetUseAsianOptions ( aJapOptionsCB .IsChecked() );
680 aOpt.SetNotes ( aNotesBtn .IsChecked() );
682 const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
683 rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SFX_CALLMODE_SLOT, ppArgs );
684 rBindings.Execute( SID_SEARCH_DLG );
686 return TRUE;
689 // -----------------------------------------------------------------------
691 INT32 SvxSearchDialog::GetTransliterationFlags() const
693 if (!aMatchCaseCB.IsChecked())
694 nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
695 else
696 nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE;
697 if ( !aJapMatchFullHalfWidthCB.IsChecked())
698 nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH;
699 else
700 nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH;
701 return nTransliterationFlags;
704 void SvxSearchDialog::SetSaveToModule(bool b)
706 pImpl->bSaveToModule = b;
709 // -----------------------------------------------------------------------
711 void SvxSearchDialog::ApplyTransliterationFlags_Impl( INT32 nSettings )
713 nTransliterationFlags = nSettings;
714 BOOL bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
715 aMatchCaseCB .Check(!bVal );
716 bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
717 aJapMatchFullHalfWidthCB.Check( !bVal );
720 // -----------------------------------------------------------------------
722 void SvxSearchDialog::Activate()
724 // apply possible transliteration changes of the SvxSearchItem member
725 DBG_ASSERT( pSearchItem, "SearchItem missing" );
726 if (pSearchItem)
728 aMatchCaseCB .Check( pSearchItem->GetExact() );
729 aJapMatchFullHalfWidthCB.Check( !pSearchItem->IsMatchFullHalfWidthForms() );
733 // -----------------------------------------------------------------------
735 void SvxSearchDialog::InitControls_Impl()
737 // CaseSensitives AutoComplete
738 aSearchLB.EnableAutocomplete( TRUE, TRUE );
739 aSearchLB.Show();
740 aReplaceLB.EnableAutocomplete( TRUE, TRUE );
741 aReplaceLB.Show();
743 aFormatBtn.Disable();
744 aAttributeBtn.Disable();
746 aSearchLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
747 aReplaceLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
749 Link aLink = LINK( this, SvxSearchDialog, FocusHdl_Impl );
750 aSearchLB.SetGetFocusHdl( aLink );
751 pImpl->aSearchFormats.SetGetFocusHdl( aLink );
753 aReplaceLB.SetGetFocusHdl( aLink );
754 pImpl->aReplaceFormats.SetGetFocusHdl( aLink );
756 aLink = LINK( this, SvxSearchDialog, LoseFocusHdl_Impl );
757 aSearchLB.SetLoseFocusHdl( aLink );
758 aReplaceLB.SetLoseFocusHdl( aLink );
760 aSearchTmplLB.SetLoseFocusHdl( aLink );
761 aReplaceTmplLB.SetLoseFocusHdl( aLink );
763 aLink = LINK( this, SvxSearchDialog, CommandHdl_Impl );
764 aSearchBtn.SetClickHdl( aLink );
765 aSearchAllBtn.SetClickHdl( aLink );
766 aReplaceBtn.SetClickHdl( aLink );
767 aReplaceAllBtn.SetClickHdl( aLink );
768 aCloseBtn.SetClickHdl( aLink );
769 aSimilarityBtn.SetClickHdl( aLink );
770 aJapOptionsBtn.SetClickHdl( aLink );
771 aSearchComponent1PB.SetClickHdl( aLink );
772 aSearchComponent2PB.SetClickHdl( aLink );
774 aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
775 aWordBtn.SetClickHdl( aLink );
776 aSelectionBtn.SetClickHdl( aLink );
777 aMatchCaseCB.SetClickHdl( aLink );
778 aRegExpBtn.SetClickHdl( aLink );
779 aBackwardsBtn.SetClickHdl( aLink );
780 aNotesBtn.SetClickHdl( aLink );
781 aSimilarityBox.SetClickHdl( aLink );
782 aJapOptionsCB.SetClickHdl( aLink );
783 aJapMatchFullHalfWidthCB.SetClickHdl( aLink );
785 aLayoutBtn.SetClickHdl( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
786 aFormatBtn.SetClickHdl( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
787 aNoFormatBtn.SetClickHdl(
788 LINK( this, SvxSearchDialog, NoFormatHdl_Impl ) );
789 aAttributeBtn.SetClickHdl(
790 LINK( this, SvxSearchDialog, AttributeHdl_Impl ) );
792 // check if buttontext is to wide
793 long nTxtW = Max( pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetMoreText() ),
794 pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetLessText() ) );
795 nTxtW += ( pMoreBtn->GetTextHeight() * 2 ); // add image size + offset
796 long nBtnW = pMoreBtn->GetSizePixel().Width();
797 if ( nTxtW > nBtnW )
799 // broaden the button
800 const long nMinDelta = 10;
801 long nDelta = Max( nTxtW - nBtnW, nMinDelta );
802 Size aNewSize = pMoreBtn->GetSizePixel();
803 aNewSize.Width() += nDelta;
804 pMoreBtn->SetSizePixel( aNewSize );
808 // -----------------------------------------------------------------------
810 void SvxSearchDialog::CalculateDelta_Impl()
812 DBG_ASSERT( pSearchItem, "no search item" );
814 bool bDrawApp = false;
815 bool bCalcApp = false;
816 bool bWriterApp = false;
817 bool bImpressApp = false;
818 const uno::Reference< frame::XFrame > xFrame = rBindings.GetActiveFrame();
819 uno::Reference< frame::XModuleManager > xModuleManager(
820 ::comphelper::getProcessServiceFactory()->createInstance(
821 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), uno::UNO_QUERY );
822 if ( xModuleManager.is() )
826 ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame );
827 bCalcApp = aModuleIdentifier.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" );
828 bDrawApp = aModuleIdentifier.equalsAscii( "com.sun.star.drawing.DrawingDocument" );
829 bImpressApp = aModuleIdentifier.equalsAscii( "com.sun.star.presentation.PresentationDocument" );
830 bWriterApp = aModuleIdentifier.equalsAscii( "com.sun.star.text.TextDocument" );
832 catch ( uno::Exception& )
837 if ( pImpl->bDeltaCalculated )
838 return;
839 else
840 pImpl->bDeltaCalculated = TRUE;
842 ULONG nDelta = 187, nOffset = 0;
843 SvtCJKOptions aCJKOptions;
845 pMoreBtn->AddWindow( &aOptionsFL );
846 if ( !bDrawApp )
847 pMoreBtn->AddWindow( &aLayoutBtn );
848 if ( bWriterApp )
849 pMoreBtn->AddWindow( &aNotesBtn );
850 else
852 aNotesBtn.Hide();
853 nOffset = !bDrawApp ? 13 : 0;
855 pMoreBtn->AddWindow( &aBackwardsBtn );
856 if ( !bDrawApp )
857 pMoreBtn->AddWindow( &aRegExpBtn );
858 pMoreBtn->AddWindow( &aSimilarityBox );
859 pMoreBtn->AddWindow( &aSimilarityBtn );
860 pMoreBtn->AddWindow( &aSelectionBtn );
862 if ( aCJKOptions.IsCJKFontEnabled() )
863 pMoreBtn->AddWindow( &aJapMatchFullHalfWidthCB );
864 else
865 nOffset += 13;
866 if ( aCJKOptions.IsJapaneseFindEnabled() )
868 pMoreBtn->AddWindow( &aJapOptionsCB );
869 pMoreBtn->AddWindow( &aJapOptionsBtn );
871 else
872 nOffset += 17;
874 if ( bWriter )
876 pMoreBtn->AddWindow( &aAttributeBtn );
877 pMoreBtn->AddWindow( &aFormatBtn );
878 pMoreBtn->AddWindow( &aNoFormatBtn );
881 if ( bDrawApp )
883 // Draw App: "Regular expressions" and "Search for Styles" check boxes are hidden
884 // so align the other buttons
885 const long nAppFontHeight = 13; // checkbox height + space between in APPFONT
886 long nH = LogicToPixel( Size( 0, nAppFontHeight ), MAP_APPFONT ).Height();
888 Point aNewPos = aSimilarityBox.GetPosPixel();
889 aNewPos.Y() -= nH;
890 aSimilarityBox.SetPosPixel( aNewPos );
891 aNewPos = aSimilarityBtn.GetPosPixel();
892 aNewPos.Y() -= nH;
893 aSimilarityBtn.SetPosPixel( aNewPos );
894 nH *= 3;
895 nOffset += ( 3 * nAppFontHeight );
896 if ( aCJKOptions.IsCJKFontEnabled() )
898 aNewPos = aJapMatchFullHalfWidthCB.GetPosPixel();
899 aNewPos.Y() -= nH;
900 aJapMatchFullHalfWidthCB.SetPosPixel( aNewPos );
902 if ( aCJKOptions.IsJapaneseFindEnabled() )
904 aNewPos = aJapOptionsCB.GetPosPixel();
905 aNewPos.Y() -= nH;
906 aJapOptionsCB.SetPosPixel( aNewPos );
907 aNewPos = aJapOptionsBtn.GetPosPixel();
908 aNewPos.Y() -= nH;
909 aJapOptionsBtn.SetPosPixel( aNewPos );
913 if ( bCalcApp || bImpressApp )
915 Window* pWins[] =
917 &aCalcFL, &aCalcSearchInFT, &aCalcSearchInLB, &aCalcSearchDirFT,
918 &aRowsBtn, &aColumnsBtn, &aAllSheetsCB, &aJapMatchFullHalfWidthCB,
919 &aJapOptionsCB, &aJapOptionsBtn
921 Window** pCurrent = pWins;
922 sal_uInt32 i = 0;
923 const sal_uInt32 nCalcCtrlCount = 7;
924 if ( nOffset > 0 )
926 long nH = LogicToPixel( Size( 0, nOffset ), MAP_APPFONT ).Height();
927 for ( i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent )
929 if ( ( bCalcApp && i < nCalcCtrlCount )
930 || ( i == nCalcCtrlCount && aCJKOptions.IsCJKFontEnabled() )
931 || ( i > nCalcCtrlCount && aCJKOptions.IsJapaneseFindEnabled() ) )
933 Point aNewPos = (*pCurrent)->GetPosPixel();
934 aNewPos.Y() -= nH;
935 (*pCurrent)->SetPosPixel( aNewPos );
940 if ( bCalcApp)
942 pCurrent = pWins;
943 for ( i = 0; i < nCalcCtrlCount; ++i, ++pCurrent )
944 pMoreBtn->AddWindow( *pCurrent );
946 else
947 nOffset += 64;
949 else
950 nOffset += 64;
952 pMoreBtn->SetDelta( nDelta - nOffset );
953 pMoreBtn->Show();
954 pMoreBtn->Enable();
957 #if ENABLE_LAYOUT
958 #undef Window
959 #define Window ::Window
960 #endif /* ENABLE_LAYOUT */
962 // -----------------------------------------------------------------------
964 namespace {
966 class ToggleSaveToModule
968 public:
969 ToggleSaveToModule(SvxSearchDialog& rDialog, bool bValue) :
970 mrDialog(rDialog), mbValue(bValue)
972 mrDialog.SetSaveToModule(mbValue);
975 ~ToggleSaveToModule()
977 mrDialog.SetSaveToModule(!mbValue);
979 private:
980 SvxSearchDialog& mrDialog;
981 bool mbValue;
986 void SvxSearchDialog::Init_Impl( int bSearchPattern )
988 DBG_ASSERT( pSearchItem, "SearchItem == 0" );
990 // We don't want to save any intermediate state to the module while the
991 // dialog is being initialized.
992 ToggleSaveToModule aNoModuleSave(*this, false);
994 bWriter = ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_WRITER );
996 pImpl->bMultiLineEdit = FALSE;
998 if ( !pImpl->bMultiLineEdit )
1000 pImpl->aSearchFormats.Hide();
1001 aSearchAttrText.Show();
1002 pImpl->aReplaceFormats.Hide();
1003 aReplaceAttrText.Show();
1005 else
1007 String aText = aSearchAttrText.GetText();
1008 aSearchAttrText.Hide();
1010 if ( aText.Len() )
1011 pImpl->aSearchFormats.SetText( aText );
1012 pImpl->aSearchFormats.Show();
1013 aText = aReplaceAttrText.GetText();
1014 aReplaceAttrText.Hide();
1016 if ( aText.Len() )
1017 pImpl->aReplaceFormats.SetText( aText );
1018 pImpl->aReplaceFormats.Show();
1021 if ( ( nModifyFlag & MODIFY_WORD ) == 0 )
1022 aWordBtn.Check( pSearchItem->GetWordOnly() );
1023 if ( ( nModifyFlag & MODIFY_EXACT ) == 0 )
1024 aMatchCaseCB.Check( pSearchItem->GetExact() );
1025 if ( ( nModifyFlag & MODIFY_BACKWARDS ) == 0 )
1026 aBackwardsBtn.Check( pSearchItem->GetBackward() );
1027 if ( ( nModifyFlag & MODIFY_NOTES ) == 0 )
1028 aNotesBtn.Check( pSearchItem->GetNotes() );
1029 if ( ( nModifyFlag & MODIFY_SELECTION ) == 0 )
1030 aSelectionBtn.Check( pSearchItem->GetSelection() );
1031 if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 )
1032 aRegExpBtn.Check( pSearchItem->GetRegExp() );
1033 if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 )
1034 aLayoutBtn.Check( pSearchItem->GetPattern() );
1035 if (aNotesBtn.IsChecked())
1036 aLayoutBtn.Disable();
1037 aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
1038 if( aJapOptionsCB.IsVisible() )
1039 aJapOptionsCB.Check( pSearchItem->IsUseAsianOptions() );
1040 ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
1042 CalculateDelta_Impl();
1044 FASTBOOL bDraw = FALSE;
1045 if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
1047 Link aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
1048 aCalcSearchInLB.SetSelectHdl( aLink );
1049 aRowsBtn.SetClickHdl( aLink );
1050 aColumnsBtn.SetClickHdl( aLink );
1051 aAllSheetsCB.SetClickHdl( aLink );
1053 switch ( pSearchItem->GetCellType() )
1055 case SVX_SEARCHIN_FORMULA:
1056 if ( ( nModifyFlag & MODIFY_FORMULAS ) == 0 )
1057 aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_FORMULA );
1058 break;
1060 case SVX_SEARCHIN_VALUE:
1061 if ( ( nModifyFlag & MODIFY_VALUES ) == 0 )
1062 aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_VALUE );
1063 break;
1065 case SVX_SEARCHIN_NOTE:
1066 if ( ( nModifyFlag & MODIFY_CALC_NOTES ) == 0 )
1067 aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_NOTE );
1068 break;
1070 aWordBtn.SetText( aCalcStr.GetToken( 0, '#' ) );
1072 if ( pSearchItem->GetRowDirection() &&
1073 ( nModifyFlag & MODIFY_ROWS ) == 0 )
1074 aRowsBtn.Check();
1075 else if ( !pSearchItem->GetRowDirection() &&
1076 ( nModifyFlag & MODIFY_COLUMNS ) == 0 )
1077 aColumnsBtn.Check();
1079 if ( ( nModifyFlag & MODIFY_ALLTABLES ) == 0 )
1080 aAllSheetsCB.Check( pSearchItem->IsAllTables() );
1082 // nur im Writer Suche nach Formatierung
1083 aFormatBtn.Hide();
1084 aNoFormatBtn.Hide();
1085 aAttributeBtn.Hide();
1087 else
1089 aWordBtn.SetText( aCalcStr.GetToken( 1, '#' ) );
1091 if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_DRAW )
1093 aRegExpBtn.Hide();
1094 aLayoutBtn.Hide();
1096 // nur im Writer Suche nach Formatierung
1097 aFormatBtn.Hide();
1098 aNoFormatBtn.Hide();
1099 aAttributeBtn.Hide();
1100 bDraw = TRUE;
1102 else
1104 if ( !pSearchList )
1106 // Attribut-Sets besorgen, wenn noch nicht geschehen
1107 const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
1108 const SvxSetItem* pSrchSetItem =
1109 (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
1111 if ( pSrchSetItem )
1112 InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
1114 const SvxSetItem* pReplSetItem =
1115 (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
1117 if ( pReplSetItem )
1118 InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
1121 aFormatBtn.Show();
1122 aNoFormatBtn.Show();
1123 aAttributeBtn.Show();
1126 // pMoreBtn->SetState( FALSE );
1127 // pMoreBtn->Hide();
1130 if ( 0 && !bDraw ) //!!!!!
1132 aRegExpBtn.Show();
1133 aLayoutBtn.Show();
1136 // "Ahnlichkeitssuche?
1137 if ( ( nModifyFlag & MODIFY_SIMILARITY ) == 0 )
1138 aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
1139 bSet = TRUE;
1141 FlagHdl_Impl( &aSimilarityBox );
1142 FlagHdl_Impl( &aJapOptionsCB );
1144 FASTBOOL bDisableSearch = FALSE;
1145 SfxViewShell* pViewShell = SfxViewShell::Current();
1147 if ( pViewShell )
1149 BOOL bText = !bSearchPattern;
1151 if ( pViewShell->HasSelection( bText ) )
1152 EnableControl_Impl( &aSelectionBtn );
1153 else
1155 aSelectionBtn.Check( FALSE );
1156 aSelectionBtn.Disable();
1160 // Patternsuche und es wurden keine AttrSets "ubergeben
1161 if ( bSearchPattern )
1163 SfxObjectShell* pShell = SfxObjectShell::Current();
1165 if ( pShell && pShell->GetStyleSheetPool() )
1167 // Vorlagen beschaffen
1168 aSearchTmplLB .Clear();
1169 aReplaceTmplLB.Clear();
1170 SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
1171 pStylePool->SetSearchMask( pSearchItem->GetFamily(),
1172 SFXSTYLEBIT_ALL );
1173 SfxStyleSheetBase* pBase = pStylePool->First();
1175 while ( pBase )
1177 if ( pBase->IsUsed() )
1178 aSearchTmplLB.InsertEntry( pBase->GetName() );
1179 aReplaceTmplLB.InsertEntry( pBase->GetName() );
1180 pBase = pStylePool->Next();
1182 aSearchTmplLB.SelectEntry( pSearchItem->GetSearchString() );
1183 aReplaceTmplLB.SelectEntry( pSearchItem->GetReplaceString() );
1186 aSearchTmplLB.Show();
1188 if ( bConstruct )
1189 // nur nach dem Erzeugen den Fokus grappen
1190 aSearchTmplLB.GrabFocus();
1191 aReplaceTmplLB.Show();
1192 aSearchLB.Hide();
1193 aReplaceLB.Hide();
1195 aWordBtn.Disable();
1196 aRegExpBtn.Disable();
1197 aMatchCaseCB.Disable();
1199 bDisableSearch = !aSearchTmplLB.GetEntryCount();
1201 else
1203 FASTBOOL bSetSearch = ( ( nModifyFlag & MODIFY_SEARCH ) == 0 );
1204 FASTBOOL bSetReplace = ( ( nModifyFlag & MODIFY_REPLACE ) == 0 );
1206 if ( pSearchItem->GetSearchString().Len() && bSetSearch )
1207 aSearchLB.SetText( pSearchItem->GetSearchString() );
1208 else if ( aSearchStrings.Count() )
1210 FASTBOOL bAttributes =
1211 ( ( pSearchList && pSearchList->Count() ) ||
1212 ( pReplaceList && pReplaceList->Count() ) );
1214 if ( bSetSearch && !bAttributes )
1215 aSearchLB.SetText( *aSearchStrings[ 0 ] );
1217 String aReplaceTxt = pSearchItem->GetReplaceString();
1219 if ( aReplaceStrings.Count() )
1220 aReplaceTxt = *aReplaceStrings[ 0 ];
1222 if ( bSetReplace && !bAttributes )
1223 aReplaceLB.SetText( aReplaceTxt );
1225 aSearchLB.Show();
1227 if ( bConstruct )
1228 // nur nach dem Erzeugen den Fokus grappen
1229 aSearchLB.GrabFocus();
1230 aReplaceLB.Show();
1231 aSearchTmplLB.Hide();
1232 aReplaceTmplLB.Hide();
1234 EnableControl_Impl( &aRegExpBtn );
1235 EnableControl_Impl( &aMatchCaseCB );
1237 if ( aRegExpBtn.IsChecked() )
1238 aWordBtn.Disable();
1239 else
1240 EnableControl_Impl( &aWordBtn );
1242 String aSrchAttrTxt;
1244 if ( pImpl->bMultiLineEdit )
1245 aSrchAttrTxt = pImpl->aSearchFormats.GetText();
1246 else
1247 aSrchAttrTxt = aSearchAttrText.GetText();
1249 bDisableSearch = !aSearchLB.GetText().Len() && !aSrchAttrTxt.Len();
1251 FocusHdl_Impl( &aSearchLB );
1253 if ( bDisableSearch )
1255 aSearchBtn.Disable();
1256 aSearchAllBtn.Disable();
1257 aReplaceBtn.Disable();
1258 aReplaceAllBtn.Disable();
1259 aSearchComponentFL.Enable(sal_False);
1260 aSearchComponent1PB.Enable(sal_False);
1261 aSearchComponent2PB.Enable(sal_False);
1263 else
1265 EnableControl_Impl( &aSearchBtn );
1266 EnableControl_Impl( &aReplaceBtn );
1267 if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
1269 EnableControl_Impl( &aSearchAllBtn );
1270 EnableControl_Impl( &aReplaceAllBtn );
1272 if (bWriter && pSearchItem->GetNotes())
1274 aSearchAllBtn.Disable();
1275 aReplaceAllBtn.Disable();
1279 if ( ( !pImpl->bMultiLineEdit && aSearchAttrText.GetText().Len() ) ||
1280 ( pImpl->bMultiLineEdit && pImpl->aSearchFormats.GetText().Len() ) )
1281 EnableControl_Impl( &aNoFormatBtn );
1282 else
1283 aNoFormatBtn.Disable();
1285 if ( !pSearchList )
1287 aAttributeBtn.Disable();
1288 aFormatBtn.Disable();
1291 if ( aLayoutBtn.IsChecked() )
1293 pImpl->bSaveToModule = FALSE;
1294 TemplateHdl_Impl( &aLayoutBtn );
1295 pImpl->bSaveToModule = TRUE;
1299 // -----------------------------------------------------------------------
1301 void SvxSearchDialog::InitAttrList_Impl( const SfxItemSet* pSSet,
1302 const SfxItemSet* pRSet )
1304 if ( !pSSet && !pRSet )
1305 return;
1307 if ( !pImpl->pRanges && pSSet )
1309 sal_sSize nCnt = 0;
1310 const USHORT* pPtr = pSSet->GetRanges();
1311 const USHORT* pTmp = pPtr;
1313 while( *pPtr )
1315 nCnt += ( *(pPtr+1) - *pPtr ) + 1;
1316 pPtr += 2;
1318 nCnt = pPtr - pTmp + 1;
1319 pImpl->pRanges = new USHORT[nCnt];
1320 memcpy( pImpl->pRanges, pTmp, sizeof(USHORT) * nCnt );
1323 // sorge daf"ur, das die Texte der Attribute richtig stehen
1324 String aDesc;
1326 if ( pSSet )
1328 delete pSearchList;
1329 pSearchList = new SearchAttrItemList;
1331 if ( pSSet->Count() )
1333 pSearchList->Put( *pSSet );
1335 if ( !pImpl->bMultiLineEdit )
1336 aSearchAttrText.SetText( BuildAttrText_Impl( aDesc, TRUE ) );
1337 else
1338 pImpl->aSearchFormats.SetText( BuildAttrText_Impl( aDesc, TRUE ) );
1340 if ( aDesc.Len() )
1341 bFormat |= TRUE;
1345 if ( pRSet )
1347 delete pReplaceList;
1348 pReplaceList = new SearchAttrItemList;
1350 if ( pRSet->Count() )
1352 pReplaceList->Put( *pRSet );
1354 if ( !pImpl->bMultiLineEdit )
1355 aReplaceAttrText.SetText( BuildAttrText_Impl( aDesc, FALSE ) );
1356 else
1357 pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( aDesc, FALSE ) );
1359 if ( aDesc.Len() )
1360 bFormat |= TRUE;
1365 // -----------------------------------------------------------------------
1367 IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, Control *, pCtrl )
1369 if ( pCtrl && !bSet )
1370 SetModifyFlag_Impl( pCtrl );
1371 else
1372 bSet = FALSE;
1374 if ( pCtrl == &aSimilarityBox )
1376 BOOL bIsChecked = aSimilarityBox.IsChecked();
1378 if ( bIsChecked )
1380 aSimilarityBtn.Enable();
1381 aRegExpBtn.Check( FALSE );
1382 aRegExpBtn.Disable();
1383 EnableControl_Impl( &aWordBtn );
1385 if ( aLayoutBtn.IsChecked() )
1387 EnableControl_Impl( &aMatchCaseCB );
1388 aLayoutBtn.Check( FALSE );
1390 aRegExpBtn.Disable();
1391 aLayoutBtn.Disable();
1392 aFormatBtn.Disable();
1393 aNoFormatBtn.Disable();
1394 aAttributeBtn.Disable();
1396 else
1398 EnableControl_Impl( &aRegExpBtn );
1399 if (!aNotesBtn.IsChecked())
1400 EnableControl_Impl( &aLayoutBtn );
1401 EnableControl_Impl( &aFormatBtn );
1402 EnableControl_Impl( &aAttributeBtn );
1403 aSimilarityBtn.Disable();
1405 pSearchItem->SetLevenshtein( bIsChecked );
1407 else
1408 if ( pCtrl == &aNotesBtn)
1410 if (aNotesBtn.IsChecked())
1412 aLayoutBtn.Disable();
1413 aSearchAllBtn.Disable();
1414 aReplaceAllBtn.Disable();
1416 else
1418 EnableControl_Impl( &aLayoutBtn );
1419 ModifyHdl_Impl( &aSearchLB );
1422 else
1424 if ( aLayoutBtn.IsChecked() && !bFormat )
1426 aWordBtn.Check( FALSE );
1427 aWordBtn.Disable();
1428 aRegExpBtn.Check( FALSE );
1429 aRegExpBtn.Disable();
1430 aMatchCaseCB.Check( FALSE );
1431 aMatchCaseCB.Disable();
1432 aNotesBtn.Disable();
1434 if ( aSearchTmplLB.GetEntryCount() )
1436 EnableControl_Impl( &aSearchBtn );
1437 EnableControl_Impl( &aSearchAllBtn );
1438 EnableControl_Impl( &aReplaceBtn );
1439 EnableControl_Impl( &aReplaceAllBtn );
1442 else
1444 EnableControl_Impl( &aRegExpBtn );
1445 EnableControl_Impl( &aMatchCaseCB );
1446 EnableControl_Impl( &aNotesBtn );
1448 if ( aRegExpBtn.IsChecked() )
1450 aWordBtn.Check( FALSE );
1451 aWordBtn.Disable();
1452 aSimilarityBox.Disable();
1453 aSimilarityBtn.Disable();
1455 else
1457 EnableControl_Impl( &aWordBtn );
1458 EnableControl_Impl( &aSimilarityBox );
1461 // Such-String vorhanden? dann Buttons enablen
1462 bSet = TRUE;
1463 ModifyHdl_Impl( &aSearchLB );
1467 if ( &aAllSheetsCB == pCtrl )
1469 if ( aAllSheetsCB.IsChecked() )
1470 aSearchAllBtn.Disable();
1471 else
1473 bSet = TRUE;
1474 ModifyHdl_Impl( &aSearchLB );
1478 if ( &aJapOptionsCB == pCtrl )
1480 BOOL bEnableJapOpt = aJapOptionsCB.IsChecked();
1481 aMatchCaseCB .Enable(!bEnableJapOpt );
1482 aJapMatchFullHalfWidthCB.Enable(!bEnableJapOpt );
1483 aJapOptionsBtn .Enable( bEnableJapOpt );
1486 if ( pImpl->bSaveToModule )
1487 SaveToModule_Impl();
1488 return 0;
1491 // -----------------------------------------------------------------------
1493 IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn )
1495 FASTBOOL bInclusive = ( aLayoutBtn.GetText() == aLayoutStr );
1497 if ( ( pBtn == &aSearchBtn ) ||
1498 ( pBtn == &aSearchAllBtn ) ||
1499 ( pBtn == &aReplaceBtn ) ||
1500 ( pBtn == &aReplaceAllBtn ) )
1502 if ( aLayoutBtn.IsChecked() && !bInclusive )
1504 pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
1505 pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
1507 else
1509 pSearchItem->SetSearchString ( aSearchLB.GetText() );
1510 pSearchItem->SetReplaceString( aReplaceLB.GetText() );
1512 if ( pBtn == &aReplaceBtn )
1513 Remember_Impl( aReplaceLB.GetText(), FALSE );
1514 else
1516 Remember_Impl( aSearchLB.GetText(), TRUE );
1518 if ( pBtn == &aReplaceAllBtn )
1519 Remember_Impl( aReplaceLB.GetText(), FALSE );
1523 pSearchItem->SetRegExp( FALSE );
1524 pSearchItem->SetLevenshtein( FALSE );
1525 if (GetCheckBoxValue( aRegExpBtn ))
1526 pSearchItem->SetRegExp( TRUE );
1527 else if (GetCheckBoxValue( aSimilarityBox ))
1528 pSearchItem->SetLevenshtein( TRUE );
1530 pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
1531 pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
1532 pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
1533 pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
1534 pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
1536 pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
1537 INT32 nFlags = GetTransliterationFlags();
1538 if( !pSearchItem->IsUseAsianOptions())
1539 nFlags &= (TransliterationModules_IGNORE_CASE |
1540 TransliterationModules_IGNORE_WIDTH );
1541 pSearchItem->SetTransliterationFlags( nFlags );
1543 if ( !bWriter )
1545 if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
1546 pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
1548 pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
1549 pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
1552 if ( pBtn == &aSearchBtn )
1553 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
1554 else if ( pBtn == &aSearchAllBtn )
1555 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
1556 else if ( pBtn == &aReplaceBtn )
1557 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE );
1558 else if ( pBtn == &aReplaceAllBtn )
1559 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
1561 // wenn nach Vorlagen gesucht wird, dann Format-Listen l"oschen
1562 if ( !bFormat && pSearchItem->GetPattern() )
1564 if ( pSearchList )
1565 pSearchList->Clear();
1567 if ( pReplaceList )
1568 pReplaceList->Clear();
1570 nModifyFlag = 0;
1571 const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
1572 rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs, 0L );
1574 else if ( pBtn == &aCloseBtn )
1576 if ( !aLayoutBtn.IsChecked() || bInclusive )
1578 String aStr( aSearchLB.GetText() );
1580 if ( aStr.Len() )
1581 Remember_Impl( aStr, TRUE );
1582 aStr = aReplaceLB.GetText();
1584 if ( aStr.Len() )
1585 Remember_Impl( aStr, FALSE );
1587 SaveToModule_Impl();
1588 Close();
1590 else if ( pBtn == &aSimilarityBtn )
1592 //CHINA001 SvxSearchSimilarityDialog* pDlg =
1593 //CHINA001 new SvxSearchSimilarityDialog( this,
1594 //CHINA001 pSearchItem->IsLEVRelaxed(),
1595 //CHINA001 pSearchItem->GetLEVOther(),
1596 //CHINA001 pSearchItem->GetLEVShorter(),
1597 //CHINA001 pSearchItem->GetLEVLonger() );
1598 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1599 if(pFact)
1601 AbstractSvxSearchSimilarityDialog* pDlg = pFact->CreateSvxSearchSimilarityDialog( LAYOUT_THIS_WINDOW (this),
1602 pSearchItem->IsLEVRelaxed(),
1603 pSearchItem->GetLEVOther(),
1604 pSearchItem->GetLEVShorter(),
1605 pSearchItem->GetLEVLonger() );
1606 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
1607 if ( pDlg && pDlg->Execute() == RET_OK )
1609 pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
1610 pSearchItem->SetLEVOther( pDlg->GetOther() );
1611 pSearchItem->SetLEVShorter( pDlg->GetShorter() );
1612 pSearchItem->SetLEVLonger( pDlg->GetLonger() );
1613 SaveToModule_Impl();
1615 delete pDlg;
1618 else if ( pBtn == &aJapOptionsBtn )
1620 SfxItemSet aSet( SFX_APP()->GetPool() );
1621 pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
1622 //CHINA001 SvxJSearchOptionsDialog aDlg( this, aSet, RID_SVXPAGE_JSEARCH_OPTIONS,
1623 //CHINA001 pSearchItem->GetTransliterationFlags() );
1624 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1625 if(pFact)
1627 AbstractSvxJSearchOptionsDialog* aDlg = pFact->CreateSvxJSearchOptionsDialog( LAYOUT_THIS_WINDOW (this), aSet, RID_SVXPAGE_JSEARCH_OPTIONS, pSearchItem->GetTransliterationFlags(), RID_SVXPAGE_JSEARCH_OPTIONS );
1628 DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
1629 int nRet = aDlg->Execute(); //CHINA001 int nRet = aDlg.Execute();
1630 if (RET_OK == nRet) //! true only if FillItemSet of SvxJSearchOptionsPage returns true
1632 INT32 nFlags = aDlg->GetTransliterationFlags(); //CHINA001 INT32 nFlags = aDlg.GetTransliterationFlags();
1633 pSearchItem->SetTransliterationFlags( nFlags );
1634 ApplyTransliterationFlags_Impl( nFlags );
1636 delete aDlg; //add for CHINA001
1639 else if(pBtn == &aSearchComponent1PB || pBtn == &aSearchComponent2PB )
1641 uno::Sequence < beans::PropertyValue > aArgs(2);
1642 beans::PropertyValue* pArgs = aArgs.getArray();
1643 pArgs[0].Name = ::rtl::OUString::createFromAscii("SearchString");
1644 pArgs[0].Value <<= ::rtl::OUString(aSearchLB.GetText());
1645 pArgs[1].Name = ::rtl::OUString::createFromAscii("ParentWindow");
1646 pArgs[1].Value <<= VCLUnoHelper::GetInterface( LAYOUT_THIS_WINDOW (this) );
1647 if(pBtn == &aSearchComponent1PB)
1649 if ( pImpl->xCommand1Dispatch.is() )
1650 pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1652 else
1654 if ( pImpl->xCommand2Dispatch.is() )
1655 pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1659 return 0;
1662 // -----------------------------------------------------------------------
1664 IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, ComboBox *, pEd )
1666 if ( !bSet )
1667 SetModifyFlag_Impl( pEd );
1668 else
1669 bSet = FALSE;
1671 // Calc allows searching for empty cells.
1672 bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC);
1674 if ( pEd == &aSearchLB || pEd == &aReplaceLB )
1676 xub_StrLen nSrchTxtLen = aSearchLB.GetText().Len();
1677 xub_StrLen nReplTxtLen = 0;
1678 if (bAllowEmptySearch)
1679 nReplTxtLen = aReplaceLB.GetText().Len();
1680 xub_StrLen nAttrTxtLen = 0;
1682 if ( !pImpl->bMultiLineEdit )
1683 nAttrTxtLen = aSearchAttrText.GetText().Len();
1684 else
1685 nAttrTxtLen = pImpl->aSearchFormats.GetText().Len();
1687 if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
1689 EnableControl_Impl( &aSearchBtn );
1690 EnableControl_Impl( &aReplaceBtn );
1691 if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
1693 EnableControl_Impl( &aSearchAllBtn );
1694 EnableControl_Impl( &aReplaceAllBtn );
1697 else
1699 aSearchComponentFL.Enable(sal_False);
1700 aSearchComponent1PB.Enable(sal_False);
1701 aSearchComponent2PB.Enable(sal_False);
1702 aSearchBtn.Disable();
1703 aSearchAllBtn.Disable();
1704 aReplaceBtn.Disable();
1705 aReplaceAllBtn.Disable();
1708 return 0;
1711 // -----------------------------------------------------------------------
1713 IMPL_LINK( SvxSearchDialog, TemplateHdl_Impl, Button *, EMPTYARG )
1715 if ( pImpl->bSaveToModule )
1716 SaveToModule_Impl();
1718 if ( bFormat )
1719 return 0;
1720 String sDesc;
1722 if ( aLayoutBtn.IsChecked() )
1724 if ( !pFamilyController )
1726 USHORT nId = 0;
1728 // Vorlagen-Controller enablen
1729 switch ( pSearchItem->GetFamily() )
1731 case SFX_STYLE_FAMILY_CHAR:
1732 nId = SID_STYLE_FAMILY1; break;
1734 case SFX_STYLE_FAMILY_PARA:
1735 nId = SID_STYLE_FAMILY2; break;
1737 case SFX_STYLE_FAMILY_FRAME:
1738 nId = SID_STYLE_FAMILY3; break;
1740 case SFX_STYLE_FAMILY_PAGE:
1741 nId = SID_STYLE_FAMILY4; break;
1743 case SFX_STYLE_FAMILY_ALL:
1744 break;
1746 default:
1747 DBG_ERROR( "StyleSheetFamily wurde geaendert?" );
1750 rBindings.EnterRegistrations();
1751 pFamilyController =
1752 new SvxSearchController( nId, rBindings, *this );
1753 rBindings.LeaveRegistrations();
1754 aSearchTmplLB.Clear();
1755 aReplaceTmplLB.Clear();
1757 aSearchTmplLB.Show();
1758 aReplaceTmplLB.Show();
1759 aSearchLB.Hide();
1760 aReplaceLB.Hide();
1762 if ( !pImpl->bMultiLineEdit )
1764 aSearchAttrText.SetText( sDesc );
1765 aReplaceAttrText.SetText( sDesc );
1767 else
1769 pImpl->aSearchFormats.SetText( sDesc );
1770 pImpl->aReplaceFormats.SetText( sDesc );
1773 aFormatBtn.Disable();
1774 aNoFormatBtn.Disable();
1775 aAttributeBtn.Disable();
1776 aSimilarityBox.Disable();
1777 aSimilarityBtn.Disable();
1779 else
1781 // Vorlagen-Controller disablen
1782 rBindings.EnterRegistrations();
1783 DELETEZ( pFamilyController );
1784 rBindings.LeaveRegistrations();
1786 aSearchLB.Show();
1787 aReplaceLB.Show();
1788 aSearchTmplLB.Hide();
1789 aReplaceTmplLB.Hide();
1791 if ( !pImpl->bMultiLineEdit )
1793 aSearchAttrText.SetText( BuildAttrText_Impl( sDesc, TRUE ) );
1794 aReplaceAttrText.SetText( BuildAttrText_Impl( sDesc, FALSE ) );
1796 else
1798 pImpl->aSearchFormats.SetText( BuildAttrText_Impl( sDesc, TRUE ) );
1799 pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( sDesc, FALSE ) );
1802 EnableControl_Impl( &aFormatBtn );
1803 EnableControl_Impl( &aAttributeBtn );
1804 EnableControl_Impl( &aSimilarityBox );
1806 FocusHdl_Impl( bSearch ? &aSearchLB : &aReplaceLB );
1808 bSet = TRUE;
1809 pImpl->bSaveToModule = FALSE;
1810 FlagHdl_Impl( &aLayoutBtn );
1811 pImpl->bSaveToModule = TRUE;
1812 return 0;
1815 // -----------------------------------------------------------------------
1817 void SvxSearchDialog::Remember_Impl( const String &rStr,BOOL _bSearch )
1819 if ( !rStr.Len() )
1820 return;
1822 SvStringsDtor* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
1823 ComboBox* pListBox = _bSearch ? &aSearchLB : &aReplaceLB;
1825 // identische Strings ignorieren
1826 for ( USHORT i = 0; i < pArr->Count(); ++i )
1828 if ( COMPARE_EQUAL == (*pArr)[i]->CompareTo( rStr ) )
1829 return;
1832 // bei maximaler Belegung "altesten Eintrag l"oschen (ListBox und Array)
1833 String* pInsStr;
1835 if ( pArr->Count() >= REMEMBER_SIZE )
1837 pInsStr = (*pArr)[REMEMBER_SIZE - 1];
1838 pListBox->RemoveEntry( USHORT(REMEMBER_SIZE - 1) );
1839 pArr->Remove( REMEMBER_SIZE - 1 );
1840 *pInsStr = rStr;
1842 else
1843 pInsStr = new String( rStr );
1845 pArr->Insert( pInsStr, 0 );
1846 pListBox->InsertEntry( *pInsStr, 0 );
1849 // -----------------------------------------------------------------------
1851 void SvxSearchDialog::TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool )
1853 // SetUpdateMode( FALSE );
1854 String aOldSrch( aSearchTmplLB .GetSelectEntry() );
1855 String aOldRepl( aReplaceTmplLB.GetSelectEntry() );
1856 aSearchTmplLB .Clear();
1857 aReplaceTmplLB.Clear();
1858 rPool.SetSearchMask( pSearchItem->GetFamily(), SFXSTYLEBIT_ALL );
1859 aSearchTmplLB.SetUpdateMode( FALSE );
1860 aReplaceTmplLB.SetUpdateMode( FALSE );
1861 SfxStyleSheetBase* pBase = rPool.First();
1863 while ( pBase )
1865 if ( pBase->IsUsed() )
1866 aSearchTmplLB.InsertEntry( pBase->GetName() );
1867 aReplaceTmplLB.InsertEntry( pBase->GetName() );
1868 pBase = rPool.Next();
1870 aSearchTmplLB.SetUpdateMode( TRUE );
1871 aReplaceTmplLB.SetUpdateMode( TRUE );
1872 aSearchTmplLB.SelectEntryPos(0);
1874 if ( aOldSrch.Len() )
1875 aSearchTmplLB .SelectEntry( aOldSrch );
1876 aReplaceTmplLB.SelectEntryPos(0);
1878 if ( aOldRepl.Len() )
1879 aReplaceTmplLB.SelectEntry( aOldRepl );
1881 if ( aSearchTmplLB.GetEntryCount() )
1883 EnableControl_Impl( &aSearchBtn );
1884 EnableControl_Impl( &aSearchAllBtn );
1885 EnableControl_Impl( &aReplaceBtn );
1886 EnableControl_Impl( &aReplaceAllBtn );
1888 // FlagHdl_Impl(0);
1889 // SetUpdateMode( TRUE );
1892 // -----------------------------------------------------------------------
1894 void SvxSearchDialog::EnableControls_Impl( const USHORT nFlags )
1896 if ( nFlags == nOptions )
1897 return;
1898 else
1899 nOptions = nFlags;
1901 if ( !nOptions )
1903 if ( IsVisible() )
1905 Hide();
1906 return;
1909 else if ( !IsVisible() )
1910 Show();
1911 FASTBOOL bNoSearch = TRUE;
1913 sal_Bool bEnableSearch = ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0;
1914 aSearchBtn.Enable(bEnableSearch);
1916 if( bEnableSearch )
1917 bNoSearch = FALSE;
1920 if ( ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
1922 aSearchAllBtn.Enable();
1923 bNoSearch = FALSE;
1925 else
1926 aSearchAllBtn.Disable();
1927 if ( ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
1929 aReplaceBtn.Enable();
1930 aReplaceText.Enable();
1931 aReplaceLB.Enable();
1932 aReplaceTmplLB.Enable();
1933 bNoSearch = FALSE;
1935 else
1937 aReplaceBtn.Disable();
1938 aReplaceText.Disable();
1939 aReplaceLB.Disable();
1940 aReplaceTmplLB.Disable();
1942 if ( ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
1944 aReplaceAllBtn.Enable();
1945 bNoSearch = FALSE;
1947 else
1948 aReplaceAllBtn.Disable();
1949 aSearchComponentFL.Enable(!bNoSearch);
1950 aSearchComponent1PB.Enable(!bNoSearch);
1951 aSearchComponent2PB.Enable(!bNoSearch);
1952 aSearchBtn.Enable( !bNoSearch );
1953 aSearchText.Enable( !bNoSearch );
1954 aSearchLB.Enable( !bNoSearch );
1956 if ( ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
1957 aWordBtn.Enable();
1958 else
1959 aWordBtn.Disable();
1960 if ( ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
1961 aBackwardsBtn.Enable();
1962 else
1963 aBackwardsBtn.Disable();
1964 //!if ( ( SEARCH_OPTIONS_NOTES & nOptions ) != 0 )
1965 aNotesBtn.Enable();
1966 //!else
1967 //! aNotesBtn.Disable();
1968 if ( ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0 )
1969 aRegExpBtn.Enable();
1970 else
1971 aRegExpBtn.Disable();
1972 if ( ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
1973 aMatchCaseCB.Enable();
1974 else
1975 aMatchCaseCB.Disable();
1976 if ( ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
1977 aSelectionBtn.Enable();
1978 else
1979 aSelectionBtn.Disable();
1980 if ( ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
1981 aLayoutBtn.Enable();
1982 else
1983 aLayoutBtn.Disable();
1984 if ( ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
1986 aAttributeBtn.Enable();
1987 aFormatBtn.Enable();
1988 aNoFormatBtn.Enable();
1990 else
1992 aAttributeBtn.Disable();
1993 aFormatBtn.Disable();
1994 aNoFormatBtn.Disable();
1997 if ( ( SEARCH_OPTIONS_MORE & nOptions ) != 0 &&
1998 pSearchItem && pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
1999 pMoreBtn->Enable();
2000 else
2002 pMoreBtn->SetState( FALSE );
2003 pMoreBtn->Disable();
2006 if ( ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
2008 aSimilarityBox.Enable();
2009 aSimilarityBtn.Enable();
2011 else
2013 aSimilarityBox.Disable();
2014 aSimilarityBtn.Disable();
2017 if ( pSearchItem )
2018 Init_Impl( pSearchItem->GetPattern() &&
2019 ( !pSearchList || !pSearchList->Count() ) );
2022 // -----------------------------------------------------------------------
2024 void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
2026 if ( &aSearchBtn == pCtrl && ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0 )
2028 aSearchComponentFL.Enable();
2029 aSearchComponent1PB.Enable();
2030 aSearchComponent2PB.Enable();
2031 aSearchBtn.Enable();
2032 return;
2034 if ( &aSearchAllBtn == pCtrl &&
2035 ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
2037 aSearchAllBtn.Enable( ( bWriter || !aAllSheetsCB.IsChecked() ) );
2038 return;
2040 if ( &aReplaceBtn == pCtrl && ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
2042 aReplaceBtn.Enable();
2043 return;
2045 if ( &aReplaceAllBtn == pCtrl &&
2046 ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
2048 aReplaceAllBtn.Enable();
2049 return;
2051 if ( &aWordBtn == pCtrl && ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
2053 aWordBtn.Enable();
2054 return;
2056 if ( &aBackwardsBtn == pCtrl && ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
2058 aBackwardsBtn.Enable();
2059 return;
2061 if ( &aNotesBtn == pCtrl /*! && ( SEARCH_OPTIONS_NOTES & nOptions ) != 0 */ )
2063 aNotesBtn.Enable();
2064 return;
2066 if ( &aRegExpBtn == pCtrl && ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0
2067 && !aSimilarityBox.IsChecked())
2069 aRegExpBtn.Enable();
2070 return;
2072 if ( &aMatchCaseCB == pCtrl && ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
2074 if (!aJapOptionsCB.IsChecked())
2075 aMatchCaseCB.Enable();
2076 return;
2078 if ( &aSelectionBtn == pCtrl && ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
2080 aSelectionBtn.Enable();
2081 return;
2083 if ( &aLayoutBtn == pCtrl && ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
2085 aLayoutBtn.Enable();
2086 return;
2088 if ( &aAttributeBtn == pCtrl
2089 && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0
2090 && pSearchList )
2092 aAttributeBtn.Enable( pImpl->bFocusOnSearch );
2094 if ( &aFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
2096 aFormatBtn.Enable();
2097 return;
2099 if ( &aNoFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
2101 aNoFormatBtn.Enable();
2102 return;
2104 if ( &aSimilarityBox == pCtrl &&
2105 ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
2107 aSimilarityBox.Enable();
2109 if ( aSimilarityBox.IsChecked() )
2110 aSimilarityBtn.Enable();
2114 // -----------------------------------------------------------------------
2116 void SvxSearchDialog::SetItem_Impl( const SvxSearchItem* pItem )
2118 if ( pItem )
2120 delete pSearchItem;
2121 pSearchItem = (SvxSearchItem*)pItem->Clone();
2122 Init_Impl( pSearchItem->GetPattern() &&
2123 ( !pSearchList || !pSearchList->Count() ) );
2127 // -----------------------------------------------------------------------
2129 IMPL_LINK( SvxSearchDialog, FocusHdl_Impl, Control *, pCtrl )
2131 xub_StrLen nTxtLen;
2133 if ( !pImpl->bMultiLineEdit )
2134 nTxtLen = aSearchAttrText.GetText().Len();
2135 else
2136 nTxtLen = pImpl->aSearchFormats.GetText().Len();
2138 if ( pCtrl == &aSearchLB || pCtrl == &pImpl->aSearchFormats )
2140 if ( pCtrl->HasChildPathFocus() )
2141 pImpl->bFocusOnSearch = TRUE;
2142 pCtrl = &aSearchLB;
2143 bSearch = TRUE;
2145 if( nTxtLen )
2146 EnableControl_Impl( &aNoFormatBtn );
2147 else
2148 aNoFormatBtn.Disable();
2149 EnableControl_Impl( &aAttributeBtn );
2151 else
2153 pImpl->bFocusOnSearch = FALSE;
2154 pCtrl = &aReplaceLB;
2155 bSearch = FALSE;
2157 if ( ( !pImpl->bMultiLineEdit && aReplaceAttrText.GetText().Len() ) ||
2158 ( pImpl->bMultiLineEdit && pImpl->aReplaceFormats.GetText().Len() ) )
2159 EnableControl_Impl( &aNoFormatBtn );
2160 else
2161 aNoFormatBtn.Disable();
2162 aAttributeBtn.Disable();
2164 bSet = TRUE;
2166 aSearchLB.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
2168 ModifyHdl_Impl( (ComboBox*)pCtrl );
2170 aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aStylesStr );
2171 return 0;
2174 // -----------------------------------------------------------------------
2176 IMPL_LINK( SvxSearchDialog, LoseFocusHdl_Impl, Control *, EMPTYARG )
2178 SaveToModule_Impl();
2179 return 0;
2182 // -----------------------------------------------------------------------
2184 IMPL_LINK( SvxSearchDialog, FormatHdl_Impl, Button *, EMPTYARG )
2186 SfxObjectShell* pSh = SfxObjectShell::Current();
2188 DBG_ASSERT( pSh, "no DocShell" );
2190 if ( !pSh || !pImpl->pRanges )
2191 return 0;
2193 sal_sSize nCnt = 0;
2194 const USHORT* pPtr = pImpl->pRanges;
2195 const USHORT* pTmp = pPtr;
2197 while( *pTmp )
2198 pTmp++;
2199 nCnt = pTmp - pPtr + 7;
2200 USHORT* pWhRanges = new USHORT[nCnt];
2201 USHORT nPos = 0;
2203 while( *pPtr )
2205 pWhRanges[nPos++] = *pPtr++;
2208 pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
2209 pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
2211 USHORT nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
2212 pWhRanges[nPos++] = nBrushWhich;
2213 pWhRanges[nPos++] = nBrushWhich;
2214 pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
2215 pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
2216 pWhRanges[nPos] = 0;
2217 SfxItemPool& rPool = pSh->GetPool();
2218 SfxItemSet aSet( rPool, pWhRanges );
2219 String aTxt;
2221 aSet.InvalidateAllItems();
2222 aSet.Put(SvxBrushItem(nBrushWhich));
2223 aSet.Put(SfxUInt16Item(SID_PARA_BACKGRND_DESTINATION, PARA_DEST_CHAR));
2225 if ( bSearch )
2227 aTxt = SVX_RESSTR( RID_SVXSTR_SEARCH );
2228 pSearchList->Get( aSet );
2230 else
2232 aTxt = SVX_RESSTR( RID_SVXSTR_REPLACE );
2233 pReplaceList->Get( aSet );
2235 aSet.DisableItem(SID_ATTR_PARA_MODEL);
2236 aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK));
2237 aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP));
2239 //CHINA001 SvxSearchFormatDialog* pDlg = new SvxSearchFormatDialog( this, aSet );
2240 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2241 if(pFact)
2243 SfxAbstractTabDialog* pDlg = pFact->CreateTabItemDialog( LAYOUT_THIS_WINDOW (this), aSet, RID_SVXDLG_SEARCHFORMAT );
2244 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
2245 aTxt.Insert( pDlg->GetText(), 0 );
2246 pDlg->SetText( aTxt );
2248 if ( pDlg->Execute() == RET_OK )
2250 DBG_ASSERT( pDlg->GetOutputItemSet(), "invalid Output-Set" );
2251 SfxItemSet aOutSet( *pDlg->GetOutputItemSet() );
2253 SearchAttrItemList* pList = bSearch ? pSearchList : pReplaceList;
2255 SearchAttrItem* pAItem;
2256 const SfxPoolItem* pItem;
2257 for( USHORT n = 0; n < pList->Count(); ++n )
2258 if( !IsInvalidItem( (pAItem = &pList->GetObject(n))->pItem ) &&
2259 SFX_ITEM_SET == aOutSet.GetItemState(
2260 pAItem->pItem->Which(), FALSE, &pItem ) )
2262 delete pAItem->pItem;
2263 pAItem->pItem = pItem->Clone();
2264 aOutSet.ClearItem( pAItem->pItem->Which() );
2267 if( aOutSet.Count() )
2268 pList->Put( aOutSet );
2270 PaintAttrText_Impl(); // AttributText in GroupBox setzen
2272 delete pDlg;
2274 delete[] pWhRanges;
2275 return 0;
2278 // -----------------------------------------------------------------------
2280 IMPL_LINK( SvxSearchDialog, NoFormatHdl_Impl, Button *, EMPTYARG )
2282 aLayoutBtn.SetText( aStylesStr );
2283 bFormat = FALSE;
2284 aLayoutBtn.Check( FALSE );
2286 if ( bSearch )
2288 if ( !pImpl->bMultiLineEdit )
2289 aSearchAttrText.SetText( String() );
2290 else
2291 pImpl->aSearchFormats.SetText( String() );
2292 pSearchList->Clear();
2294 else
2296 if ( !pImpl->bMultiLineEdit )
2297 aReplaceAttrText.SetText( String() );
2298 else
2299 pImpl->aReplaceFormats.SetText( String() );
2300 pReplaceList->Clear();
2302 pImpl->bSaveToModule = FALSE;
2303 TemplateHdl_Impl( &aLayoutBtn );
2304 pImpl->bSaveToModule = TRUE;
2305 aNoFormatBtn.Disable();
2306 return 0;
2309 // -----------------------------------------------------------------------
2311 IMPL_LINK( SvxSearchDialog, AttributeHdl_Impl, Button *, EMPTYARG )
2313 if ( !pSearchList || !pImpl->pRanges )
2314 return 0;
2316 //CHINA001 SvxSearchAttributeDialog* pDlg = new SvxSearchAttributeDialog( this, *pSearchList, pImpl->pRanges );
2317 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2318 if(pFact)
2320 VclAbstractDialog* pDlg = pFact->CreateSvxSearchAttributeDialog( LAYOUT_THIS_WINDOW (this), *pSearchList, pImpl->pRanges, RID_SVXDLG_SEARCHATTR );
2321 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
2322 pDlg->Execute();
2323 delete pDlg;
2325 PaintAttrText_Impl();
2326 return 0;
2329 // -----------------------------------------------------------------------
2331 IMPL_LINK( SvxSearchDialog, TimeoutHdl_Impl, Timer *, pTimer )
2333 SfxViewShell* pViewShell = SfxViewShell::Current();
2335 if ( pViewShell )
2337 if ( pViewShell->HasSelection( aSearchLB.IsVisible() ) )
2338 EnableControl_Impl( &aSelectionBtn );
2339 else
2341 aSelectionBtn.Check( FALSE );
2342 aSelectionBtn.Disable();
2346 pTimer->Start();
2347 return 0;
2350 // -----------------------------------------------------------------------
2352 void SvxSearchDialog::GetSearchItems( SfxItemSet& rSet )
2354 xub_StrLen nLen;
2356 if ( !pImpl->bMultiLineEdit )
2357 nLen = aSearchAttrText.GetText().Len();
2358 else
2359 nLen = pImpl->aSearchFormats.GetText().Len();
2361 if ( nLen && pSearchList )
2362 pSearchList->Get( rSet );
2365 // -----------------------------------------------------------------------
2367 void SvxSearchDialog::GetReplaceItems( SfxItemSet& rSet )
2369 xub_StrLen nLen;
2371 if ( !pImpl->bMultiLineEdit )
2372 nLen = aReplaceAttrText.GetText().Len();
2373 else
2374 nLen = pImpl->aReplaceFormats.GetText().Len();
2376 if ( nLen && pReplaceList )
2377 pReplaceList->Get( rSet );
2380 // -----------------------------------------------------------------------
2382 String& SvxSearchDialog::BuildAttrText_Impl( String& rStr,
2383 BOOL bSrchFlag ) const
2385 if ( rStr.Len() )
2386 rStr.Erase();
2388 SfxObjectShell* pSh = SfxObjectShell::Current();
2389 DBG_ASSERT( pSh, "no DocShell" );
2391 if ( !pSh )
2392 return rStr;
2394 SfxItemPool& rPool = pSh->GetPool();
2395 SearchAttrItemList* pList = bSrchFlag ? pSearchList : pReplaceList;
2397 if ( !pList )
2398 return rStr;
2400 // Metrik abfragen
2401 SfxMapUnit eMapUnit = SFX_MAPUNIT_CM;
2402 FieldUnit eFieldUnit = GetModuleFieldUnit();
2404 switch ( eFieldUnit )
2406 case FUNIT_MM: eMapUnit = SFX_MAPUNIT_MM; break;
2407 case FUNIT_CM:
2408 case FUNIT_M:
2409 case FUNIT_KM: eMapUnit = SFX_MAPUNIT_CM; break;
2410 case FUNIT_TWIP: eMapUnit = SFX_MAPUNIT_TWIP; break;
2411 case FUNIT_POINT:
2412 case FUNIT_PICA: eMapUnit = SFX_MAPUNIT_POINT; break;
2413 case FUNIT_INCH:
2414 case FUNIT_FOOT:
2415 case FUNIT_MILE: eMapUnit = SFX_MAPUNIT_INCH; break;
2416 case FUNIT_100TH_MM: eMapUnit = SFX_MAPUNIT_100TH_MM; break;
2417 default: ;//prevent warning
2420 for ( USHORT i = 0; i < pList->Count(); ++i )
2422 const SearchAttrItem& rItem = pList->GetObject(i);
2424 if ( rStr.Len() )
2425 rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
2427 if ( !IsInvalidItem( rItem.pItem ) )
2429 String aStr;
2430 rPool.GetPresentation( *rItem.pItem,
2431 SFX_ITEM_PRESENTATION_COMPLETE,
2432 eMapUnit, aStr );
2433 rStr += aStr;
2435 else
2437 //Sonderbehandlung fuer Zeichenhintergrund
2438 USHORT nId = rItem.nSlot == SID_ATTR_BRUSH_CHAR ?
2439 RID_SVXITEMS_BRUSH_CHAR :
2440 rItem.nSlot - SID_SVX_START + RID_ATTR_BEGIN;
2441 rStr += SVX_RESSTR( nId );
2444 return rStr;
2447 // -----------------------------------------------------------------------
2449 void SvxSearchDialog::PaintAttrText_Impl()
2451 String aDesc;
2452 BuildAttrText_Impl( aDesc, bSearch );
2454 if ( !bFormat && aDesc.Len() )
2455 bFormat = TRUE;
2457 if ( bSearch )
2459 if ( !pImpl->bMultiLineEdit )
2460 aSearchAttrText.SetText( aDesc );
2461 else
2462 pImpl->aSearchFormats.SetText( aDesc );
2463 FocusHdl_Impl( &aSearchLB );
2465 else
2467 if ( !pImpl->bMultiLineEdit )
2468 aReplaceAttrText.SetText( aDesc );
2469 else
2470 pImpl->aReplaceFormats.SetText( aDesc );
2471 FocusHdl_Impl( &aReplaceLB );
2475 // -----------------------------------------------------------------------
2477 void SvxSearchDialog::SetModifyFlag_Impl( const Control* pCtrl )
2479 if ( &aSearchLB == (ComboBox*)pCtrl )
2480 nModifyFlag |= MODIFY_SEARCH;
2481 else if ( &aReplaceLB == (ComboBox*)pCtrl )
2482 nModifyFlag |= MODIFY_REPLACE;
2483 else if ( &aWordBtn == (CheckBox*)pCtrl )
2484 nModifyFlag |= MODIFY_WORD;
2485 else if ( &aMatchCaseCB == (CheckBox*)pCtrl )
2486 nModifyFlag |= MODIFY_EXACT;
2487 else if ( &aBackwardsBtn == (CheckBox*)pCtrl )
2488 nModifyFlag |= MODIFY_BACKWARDS;
2489 else if ( &aNotesBtn == (CheckBox*)pCtrl )
2490 nModifyFlag |= MODIFY_NOTES;
2491 else if ( &aSelectionBtn == (CheckBox*)pCtrl )
2492 nModifyFlag |= MODIFY_SELECTION;
2493 else if ( &aRegExpBtn == (CheckBox*)pCtrl )
2494 nModifyFlag |= MODIFY_REGEXP;
2495 else if ( &aLayoutBtn == (CheckBox*)pCtrl )
2496 nModifyFlag |= MODIFY_LAYOUT;
2497 else if ( &aSimilarityBox == (CheckBox*)pCtrl )
2498 nModifyFlag |= MODIFY_SIMILARITY;
2499 else if ( &aCalcSearchInLB == (ListBox*)pCtrl )
2501 nModifyFlag |= MODIFY_FORMULAS;
2502 nModifyFlag |= MODIFY_VALUES;
2503 nModifyFlag |= MODIFY_CALC_NOTES;
2505 else if ( &aRowsBtn == (RadioButton*)pCtrl )
2506 nModifyFlag |= MODIFY_ROWS;
2507 else if ( &aColumnsBtn == (RadioButton*)pCtrl )
2508 nModifyFlag |= MODIFY_COLUMNS;
2509 else if ( &aAllSheetsCB == (CheckBox*)pCtrl )
2510 nModifyFlag |= MODIFY_ALLTABLES;
2513 // -----------------------------------------------------------------------
2515 void SvxSearchDialog::SaveToModule_Impl()
2517 if ( !pSearchItem )
2518 return;
2520 if ( aLayoutBtn.IsChecked() )
2522 pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
2523 pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
2525 else
2527 pSearchItem->SetSearchString ( aSearchLB.GetText() );
2528 pSearchItem->SetReplaceString( aReplaceLB.GetText() );
2529 Remember_Impl( aSearchLB.GetText(), TRUE );
2532 pSearchItem->SetRegExp( FALSE );
2533 pSearchItem->SetLevenshtein( FALSE );
2534 if (GetCheckBoxValue( aRegExpBtn ))
2535 pSearchItem->SetRegExp( TRUE );
2536 else if (GetCheckBoxValue( aSimilarityBox ))
2537 pSearchItem->SetLevenshtein( TRUE );
2539 pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
2540 pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
2541 pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
2542 pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
2543 pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
2545 pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
2546 INT32 nFlags = GetTransliterationFlags();
2547 if( !pSearchItem->IsUseAsianOptions())
2548 nFlags &= (TransliterationModules_IGNORE_CASE |
2549 TransliterationModules_IGNORE_WIDTH );
2550 pSearchItem->SetTransliterationFlags( nFlags );
2552 if ( !bWriter )
2554 if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
2555 pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
2557 pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
2558 pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
2561 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
2562 nModifyFlag = 0;
2563 const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
2564 rBindings.GetDispatcher()->Execute( SID_SEARCH_ITEM, SFX_CALLMODE_SLOT, ppArgs );
2567 // class SvxSearchDialogWrapper ------------------------------------------
2569 SFX_IMPL_CHILDWINDOW(SvxSearchDialogWrapper, SID_SEARCH_DLG);
2571 // -----------------------------------------------------------------------
2573 SvxSearchDialogWrapper::SvxSearchDialogWrapper( Window* _pParent, USHORT nId,
2574 SfxBindings* pBindings,
2575 SfxChildWinInfo* pInfo )
2576 : SfxChildWindow( _pParent, nId )
2577 , dialog (new SvxSearchDialog (_pParent, this, *pBindings))
2579 pWindow = LAYOUT_THIS_WINDOW (dialog);
2580 dialog->Initialize( pInfo );
2582 pBindings->Update( SID_SEARCH_ITEM );
2583 pBindings->Update( SID_SEARCH_OPTIONS );
2584 pBindings->Update( SID_SEARCH_SEARCHSET );
2585 pBindings->Update( SID_SEARCH_REPLACESET );
2586 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
2587 dialog->bConstruct = FALSE;
2590 SvxSearchDialogWrapper::~SvxSearchDialogWrapper ()
2592 #if ENABLE_LAYOUT
2593 delete dialog;
2594 pWindow = 0;
2595 #endif /* ENABLE_LAYOUT */
2598 SvxSearchDialog *SvxSearchDialogWrapper::getDialog ()
2600 return dialog;
2603 // -----------------------------------------------------------------------
2605 SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
2607 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
2608 aInfo.bVisible = sal_False;
2609 return aInfo;