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