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