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