1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir #include "vbafind.hxx" 24cdf0e10cSrcweir #include <vbahelper/vbahelper.hxx> 25cdf0e10cSrcweir #include <tools/diagnose_ex.h> 26cdf0e10cSrcweir #include "vbareplacement.hxx" 27cdf0e10cSrcweir #include <ooo/vba/word/WdFindWrap.hpp> 28cdf0e10cSrcweir #include <ooo/vba/word/WdReplace.hpp> 29cdf0e10cSrcweir #include <com/sun/star/text/XTextRangeCompare.hpp> 30cdf0e10cSrcweir #include "wordvbahelper.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir using namespace ::ooo::vba; 33cdf0e10cSrcweir using namespace ::com::sun::star; 34cdf0e10cSrcweir 35cdf0e10cSrcweir SwVbaFind::SwVbaFind( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) : 36cdf0e10cSrcweir SwVbaFind_BASE( rParent, rContext ), mxModel( xModel ), mxTextRange( xTextRange ), mbReplace( sal_False ), mnReplaceType( word::WdReplace::wdReplaceOne ), mnWrap( word::WdFindWrap::wdFindStop ) 37cdf0e10cSrcweir { 38cdf0e10cSrcweir mxReplaceable.set( mxModel, uno::UNO_QUERY_THROW ); 39cdf0e10cSrcweir mxPropertyReplace.set( mxReplaceable->createReplaceDescriptor(), uno::UNO_QUERY_THROW ); 40cdf0e10cSrcweir mxTVC = word::getXTextViewCursor( mxModel ); 41cdf0e10cSrcweir mxSelSupp.set( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); 42cdf0e10cSrcweir } 43cdf0e10cSrcweir 44cdf0e10cSrcweir SwVbaFind::~SwVbaFind() 45cdf0e10cSrcweir { 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48cdf0e10cSrcweir sal_Bool SwVbaFind::InRange( const uno::Reference< text::XTextRange >& xCurrentRange ) throw ( uno::RuntimeException ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir uno::Reference< text::XTextRangeCompare > xTRC( mxTextRange->getText(), uno::UNO_QUERY_THROW ); 51cdf0e10cSrcweir if( xTRC->compareRegionStarts( mxTextRange, xCurrentRange ) >= 0 && xTRC->compareRegionEnds( mxTextRange, xCurrentRange ) <= 0 ) 52cdf0e10cSrcweir return sal_True; 53cdf0e10cSrcweir return sal_False; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir sal_Bool SwVbaFind::InEqualRange( const uno::Reference< text::XTextRange >& xCurrentRange ) throw ( uno::RuntimeException ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir uno::Reference< text::XTextRangeCompare > xTRC( mxTextRange->getText(), uno::UNO_QUERY_THROW ); 59cdf0e10cSrcweir if( xTRC->compareRegionStarts( mxTextRange, xCurrentRange ) == 0 && xTRC->compareRegionEnds( mxTextRange, xCurrentRange ) == 0 ) 60cdf0e10cSrcweir return sal_True; 61cdf0e10cSrcweir return sal_False; 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir void SwVbaFind::SetReplaceWith( const rtl::OUString& rText ) throw (uno::RuntimeException) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir mxPropertyReplace->setReplaceString( rText ); 67cdf0e10cSrcweir mbReplace = sal_True; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir rtl::OUString SwVbaFind::GetReplaceWith() throw (uno::RuntimeException) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir return mxPropertyReplace->getReplaceString(); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir void SwVbaFind::SetReplace( sal_Int32 type ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir mnReplaceType = type; 77cdf0e10cSrcweir mbReplace = sal_True; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir #ifdef TOMORROW 80cdf0e10cSrcweir rtl::OUString SwVbaFind::ReplaceWildcards( const rtl::OUString& /*rText*/ ) throw ( uno::RuntimeException ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir // TODO: 83cdf0e10cSrcweir return rtl::OUString(); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir #endif 86cdf0e10cSrcweir uno::Reference< text::XTextRange > SwVbaFind::FindOneElement() throw ( uno::RuntimeException ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir uno::Reference< text::XTextRange > xFoundOne; 89cdf0e10cSrcweir if( mxTVC->getString().getLength() > 0 ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir if( getForward() ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir xFoundOne.set( mxReplaceable->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir else 96cdf0e10cSrcweir { 97cdf0e10cSrcweir xFoundOne.set( mxReplaceable->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir if( xFoundOne.is() && InEqualRange( xFoundOne ) ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir xFoundOne.set( mxReplaceable->findNext( xFoundOne, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir else if( xFoundOne.is() && !InRange( xFoundOne ) ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir xFoundOne = uno::Reference< text::XTextRange >(); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir } 109cdf0e10cSrcweir else 110cdf0e10cSrcweir { 111cdf0e10cSrcweir xFoundOne.set( mxReplaceable->findNext( mxTextRange, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir if( !xFoundOne.is() && ( getWrap() == word::WdFindWrap::wdFindContinue || getWrap() == word::WdFindWrap::wdFindAsk ) ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir if( getForward() ) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir mxTVC->gotoStart(sal_False); 119cdf0e10cSrcweir xFoundOne.set( mxReplaceable->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir else 122cdf0e10cSrcweir { 123cdf0e10cSrcweir mxTVC->gotoEnd( sal_False ); 124cdf0e10cSrcweir xFoundOne.set( mxReplaceable->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); 125cdf0e10cSrcweir 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir return xFoundOne; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir sal_Bool SwVbaFind::SearchReplace() throw (uno::RuntimeException) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir sal_Bool result = sal_False; 134cdf0e10cSrcweir 135cdf0e10cSrcweir // TODO: map wildcards in area to OOo wildcards 136cdf0e10cSrcweir 137cdf0e10cSrcweir if( mbReplace ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir switch( mnReplaceType ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir case word::WdReplace::wdReplaceNone: 142cdf0e10cSrcweir { 143cdf0e10cSrcweir result = sal_True; 144cdf0e10cSrcweir break; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir case word::WdReplace::wdReplaceOne: 147cdf0e10cSrcweir { 148cdf0e10cSrcweir uno::Reference< text::XTextRange > xFindOne = FindOneElement(); 149cdf0e10cSrcweir if( xFindOne.is() ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir xFindOne->setString( GetReplaceWith() ); 152cdf0e10cSrcweir result = mxSelSupp->select( uno::makeAny( xFindOne ) ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir case word::WdReplace::wdReplaceAll: 157cdf0e10cSrcweir { 158cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xIndexAccess = mxReplaceable->findAll( uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ); 159cdf0e10cSrcweir if( xIndexAccess->getCount() > 0 ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir for( sal_Int32 i = 0; i < xIndexAccess->getCount(); i++ ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir uno::Reference< text::XTextRange > xTextRange( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW ); 164cdf0e10cSrcweir if( mnWrap == word::WdFindWrap::wdFindContinue || mnWrap == word::WdFindWrap::wdFindAsk || InRange( xTextRange ) ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir xTextRange->setString( GetReplaceWith() ); 167cdf0e10cSrcweir result = sal_True; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir } 171cdf0e10cSrcweir break; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir default: 174cdf0e10cSrcweir { 175cdf0e10cSrcweir result = sal_False; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } 178cdf0e10cSrcweir } 179cdf0e10cSrcweir else 180cdf0e10cSrcweir { 181cdf0e10cSrcweir uno::Reference< text::XTextRange > xFindOne = FindOneElement(); 182cdf0e10cSrcweir if( xFindOne.is() ) 183cdf0e10cSrcweir result = mxSelSupp->select( uno::makeAny( xFindOne ) ); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir return result; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir ::rtl::OUString SAL_CALL SwVbaFind::getText() throw (uno::RuntimeException) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir return mxPropertyReplace->getSearchString(); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir void SAL_CALL SwVbaFind::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir mxPropertyReplace->setSearchString( _text ); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir uno::Any SAL_CALL SwVbaFind::getReplacement() throw (uno::RuntimeException) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir return uno::makeAny( uno::Reference< word::XReplacement >( new SwVbaReplacement( this, mxContext, mxPropertyReplace ) ) ); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir void SAL_CALL SwVbaFind::setReplacement( const uno::Any& /*_replacement */ ) throw (uno::RuntimeException) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getForward() throw (uno::RuntimeException) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir sal_Bool bBackward = sal_False; 212cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchBackwards") ) ) >>= bBackward; 213cdf0e10cSrcweir return !bBackward; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir void SAL_CALL SwVbaFind::setForward( ::sal_Bool _forward ) throw (uno::RuntimeException) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir sal_Bool bBackward = !_forward; 219cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchBackwards") ), uno::makeAny( bBackward ) ); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir ::sal_Int32 SAL_CALL SwVbaFind::getWrap() throw (uno::RuntimeException) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir // seems not supported in Writer 225cdf0e10cSrcweir return mnWrap; 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir void SAL_CALL SwVbaFind::setWrap( ::sal_Int32 _wrap ) throw (uno::RuntimeException) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir // seems not supported in Writer 231cdf0e10cSrcweir mnWrap = _wrap; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getFormat() throw (uno::RuntimeException) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir return mxPropertyReplace->getValueSearch(); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir void SAL_CALL SwVbaFind::setFormat( ::sal_Bool _format ) throw (uno::RuntimeException) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir mxPropertyReplace->setValueSearch( _format ); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getMatchCase() throw (uno::RuntimeException) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir sal_Bool value = sal_False; 247cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchCaseSensitive") ) ) >>= value; 248cdf0e10cSrcweir return value; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir void SAL_CALL SwVbaFind::setMatchCase( ::sal_Bool _matchcase ) throw (uno::RuntimeException) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchCaseSensitive") ), uno::makeAny( _matchcase ) ); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getMatchWholeWord() throw (uno::RuntimeException) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir sal_Bool value = sal_False; 259cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchWords") ) ) >>= value; 260cdf0e10cSrcweir return value; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir void SAL_CALL SwVbaFind::setMatchWholeWord( ::sal_Bool _matchwholeword ) throw (uno::RuntimeException) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchWords") ), uno::makeAny( _matchwholeword ) ); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getMatchWildcards() throw (uno::RuntimeException) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir sal_Bool value = sal_False; 271cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchRegularExpression") ) ) >>= value; 272cdf0e10cSrcweir return value; 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir void SAL_CALL SwVbaFind::setMatchWildcards( ::sal_Bool _matchwildcards ) throw (uno::RuntimeException) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchRegularExpression") ), uno::makeAny( _matchwildcards ) ); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getMatchSoundsLike() throw (uno::RuntimeException) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir sal_Bool value = sal_False; 283cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ) ) >>= value; 284cdf0e10cSrcweir return value; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir void SAL_CALL SwVbaFind::setMatchSoundsLike( ::sal_Bool _matchsoundslike ) throw (uno::RuntimeException) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir // seems not accurate 290cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ), uno::makeAny( _matchsoundslike ) ); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir ::sal_Bool SAL_CALL SwVbaFind::getMatchAllWordForms() throw (uno::RuntimeException) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir sal_Bool value = sal_False; 296cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ) ) >>= value; 297cdf0e10cSrcweir if( value ) 298cdf0e10cSrcweir mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRelax") ) ) >>= value; 299cdf0e10cSrcweir return value; 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir void SAL_CALL SwVbaFind::setMatchAllWordForms( ::sal_Bool _matchallwordforms ) throw (uno::RuntimeException) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir // seems not accurate 305cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ), uno::makeAny( _matchallwordforms ) ); 306cdf0e10cSrcweir mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRelax") ), uno::makeAny( _matchallwordforms ) ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir uno::Any SAL_CALL SwVbaFind::getStyle() throw (uno::RuntimeException) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir void SAL_CALL SwVbaFind::setStyle( const uno::Any& /*_style */ ) throw (uno::RuntimeException) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir sal_Bool SAL_CALL 320cdf0e10cSrcweir SwVbaFind::Execute( const uno::Any& FindText, const uno::Any& MatchCase, const uno::Any& MatchWholeWord, const uno::Any& MatchWildcards, const uno::Any& MatchSoundsLike, const uno::Any& MatchAllWordForms, const uno::Any& Forward, const uno::Any& Wrap, const uno::Any& Format, const uno::Any& ReplaceWith, const uno::Any& Replace, const uno::Any& /*MatchKashida*/, const uno::Any& /*MatchDiacritics*/, const uno::Any& /*MatchAlefHamza*/, const uno::Any& /*MatchControl*/, const uno::Any& /*MatchPrefix*/, const uno::Any& /*MatchSuffix*/, const uno::Any& /*MatchPhrase*/, const uno::Any& /*IgnoreSpace*/, const uno::Any& /*IgnorePunct*/ ) throw (uno::RuntimeException) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir sal_Bool result = sal_False; 323cdf0e10cSrcweir if( FindText.hasValue() ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir rtl::OUString sText; 326cdf0e10cSrcweir FindText >>= sText; 327cdf0e10cSrcweir setText( sText ); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir sal_Bool bValue = sal_False; 331cdf0e10cSrcweir if( MatchCase.hasValue() ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir MatchCase >>= bValue; 334cdf0e10cSrcweir setMatchCase( bValue ); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir if( MatchWholeWord.hasValue() ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir MatchWholeWord >>= bValue; 340cdf0e10cSrcweir setMatchWholeWord( bValue ); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir if( MatchWildcards.hasValue() ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir MatchWildcards >>= bValue; 346cdf0e10cSrcweir setMatchWildcards( bValue ); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir if( MatchSoundsLike.hasValue() ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir MatchSoundsLike >>= bValue; 352cdf0e10cSrcweir setMatchSoundsLike( bValue ); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir if( MatchAllWordForms.hasValue() ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir MatchAllWordForms >>= bValue; 358cdf0e10cSrcweir setMatchAllWordForms( bValue ); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir if( Forward.hasValue() ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir Forward >>= bValue; 364cdf0e10cSrcweir setForward( bValue ); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir if( Wrap.hasValue() ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir sal_Int32 nWrapType = 0; 370cdf0e10cSrcweir Wrap >>= nWrapType; 371cdf0e10cSrcweir setWrap( nWrapType ); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir if( Format.hasValue() ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir Format >>= bValue; 377cdf0e10cSrcweir setFormat( bValue ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir if( ReplaceWith.hasValue() ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir rtl::OUString sValue; 383cdf0e10cSrcweir ReplaceWith >>= sValue; 384cdf0e10cSrcweir SetReplaceWith( sValue ); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir if( Replace.hasValue() ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir sal_Int32 nValue(0); 390cdf0e10cSrcweir Replace >>= nValue; 391cdf0e10cSrcweir SetReplace( nValue ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir result = SearchReplace(); 395cdf0e10cSrcweir 396cdf0e10cSrcweir return result; 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir void SAL_CALL 400cdf0e10cSrcweir SwVbaFind::ClearFormatting( ) throw (uno::RuntimeException) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aSearchAttribs; 403cdf0e10cSrcweir mxPropertyReplace->setSearchAttributes( aSearchAttribs ); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir rtl::OUString& 407cdf0e10cSrcweir SwVbaFind::getServiceImplName() 408cdf0e10cSrcweir { 409cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFind") ); 410cdf0e10cSrcweir return sImplName; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir uno::Sequence< rtl::OUString > 414cdf0e10cSrcweir SwVbaFind::getServiceNames() 415cdf0e10cSrcweir { 416cdf0e10cSrcweir static uno::Sequence< rtl::OUString > aServiceNames; 417cdf0e10cSrcweir if ( aServiceNames.getLength() == 0 ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir aServiceNames.realloc( 1 ); 420cdf0e10cSrcweir aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Find" ) ); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir return aServiceNames; 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425