21 #include <ooo/vba/word/WdFindWrap.hpp>
22 #include <ooo/vba/word/WdReplace.hpp>
23 #include <com/sun/star/frame/XModel.hpp>
24 #include <com/sun/star/text/XTextRangeCompare.hpp>
30 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 ) :
31 SwVbaFind_BASE( rParent, rContext ),
mxModel( xModel ), mxTextRange( xTextRange ), mbReplace(
false ), mnReplaceType( word::WdReplace::wdReplaceOne ), mnWrap( word::WdFindWrap::wdFindStop )
45 uno::Reference< text::XTextRangeCompare > xTRC(
mxTextRange->getText(), uno::UNO_QUERY_THROW );
46 return xTRC->compareRegionStarts(
mxTextRange, xCurrentRange ) >= 0 && xTRC->compareRegionEnds(
mxTextRange, xCurrentRange ) <= 0;
51 uno::Reference< text::XTextRangeCompare > xTRC(
mxTextRange->getText(), uno::UNO_QUERY_THROW );
52 return xTRC->compareRegionStarts(
mxTextRange, xCurrentRange ) == 0 && xTRC->compareRegionEnds(
mxTextRange, xCurrentRange ) == 0;
72 uno::Reference< text::XTextRange > xFoundOne;
73 if( !
mxTVC->getString().isEmpty() )
86 xFoundOne.set(
mxReplaceable->findNext( xFoundOne, uno::Reference< util::XSearchDescriptor >(
mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
88 else if( xFoundOne.is() && !
InRange( xFoundOne ) )
98 if( !xFoundOne.is() && (
getWrap() == word::WdFindWrap::wdFindContinue ||
getWrap() == word::WdFindWrap::wdFindAsk ) )
102 mxTVC->gotoStart(
false);
107 mxTVC->gotoEnd(
false );
125 case word::WdReplace::wdReplaceNone:
130 case word::WdReplace::wdReplaceOne:
140 case word::WdReplace::wdReplaceAll:
142 uno::Reference< container::XIndexAccess > xIndexAccess =
mxReplaceable->findAll( uno::Reference< util::XSearchDescriptor >(
mxPropertyReplace, uno::UNO_QUERY_THROW ) );
143 if( xIndexAccess->getCount() > 0 )
145 for( sal_Int32
i = 0;
i < xIndexAccess->getCount();
i++ )
147 uno::Reference< text::XTextRange > xTextRange( xIndexAccess->getByIndex(
i ), uno::UNO_QUERY_THROW );
148 if(
mnWrap == word::WdFindWrap::wdFindContinue ||
mnWrap == word::WdFindWrap::wdFindAsk ||
InRange( xTextRange ) )
190 throw uno::RuntimeException(
"Not implemented" );
195 bool bBackward =
false;
202 bool bBackward = !_forward;
295 throw uno::RuntimeException(
"Not implemented" );
300 throw uno::RuntimeException(
"Not implemented" );
304 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& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& )
317 MatchCase >>= bValue;
323 MatchWholeWord >>= bValue;
329 MatchWildcards >>= bValue;
335 MatchSoundsLike >>= bValue;
341 MatchAllWordForms >>= bValue;
353 sal_Int32 nWrapType = 0;
367 ReplaceWith >>= sValue;
386 uno::Sequence< beans::PropertyValue > aSearchAttribs;
396 uno::Sequence< OUString >
virtual sal_Bool SAL_CALL Execute(const css::uno::Any &FindText, const css::uno::Any &MatchCase, const css::uno::Any &MatchWholeWord, const css::uno::Any &MatchWildcards, const css::uno::Any &MatchSoundsLike, const css::uno::Any &MatchAllWordForms, const css::uno::Any &Forward, const css::uno::Any &Wrap, const css::uno::Any &Format, const css::uno::Any &ReplaceWith, const css::uno::Any &Replace, const css::uno::Any &MatchKashida, const css::uno::Any &MatchDiacritics, const css::uno::Any &MatchAlefHamza, const css::uno::Any &MatchControl, const css::uno::Any &MatchPrefix, const css::uno::Any &MatchSuffix, const css::uno::Any &MatchPhrase, const css::uno::Any &IgnoreSpace, const css::uno::Any &IgnorePunct) override
virtual sal_Bool SAL_CALL getMatchWholeWord() override
css::uno::Reference< css::text::XTextViewCursor > mxTVC
virtual sal_Bool SAL_CALL getMatchWildcards() override
virtual OUString getServiceImplName() override
bool InEqualRange(const css::uno::Reference< css::text::XTextRange > &xCurrentRange)
css::uno::Reference< css::frame::XModel2 > mxModel
virtual sal_Bool SAL_CALL getForward() override
virtual void SAL_CALL setReplacement(const css::uno::Any &_replacement) override
Sequence< OUString > aServiceNames
css::uno::Reference< css::frame::XModel > mxModel
virtual void SAL_CALL ClearFormatting() override
virtual ::sal_Int32 SAL_CALL getWrap() override
css::uno::Reference< css::util::XReplaceable > mxReplaceable
OUString GetReplaceWith()
uno::Reference< text::XTextViewCursor > getXTextViewCursor(const uno::Reference< frame::XModel > &xModel)
virtual void SAL_CALL setMatchWholeWord(sal_Bool _matchwholeword) override
virtual sal_Bool SAL_CALL getMatchCase() override
virtual void SAL_CALL setWrap(::sal_Int32 _wrap) override
css::uno::Reference< css::text::XTextRange > mxTextRange
css::uno::Reference< css::util::XPropertyReplace > mxPropertyReplace
virtual void SAL_CALL setMatchAllWordForms(sal_Bool _matchallwordforms) override
virtual void SAL_CALL setMatchWildcards(sal_Bool _matchwildcards) override
css::uno::Reference< css::text::XTextRange > FindOneElement()
virtual ~SwVbaFind() override
virtual css::uno::Any SAL_CALL getStyle() override
virtual sal_Bool SAL_CALL getMatchSoundsLike() override
css::uno::Reference< css::view::XSelectionSupplier > mxSelSupp
virtual void SAL_CALL setFormat(sal_Bool _format) override
virtual css::uno::Sequence< OUString > getServiceNames() override
SwVbaFind(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::text::XTextRange > &xTextRange)
virtual void SAL_CALL setStyle(const css::uno::Any &_style) override
virtual OUString SAL_CALL getText() override
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual sal_Bool SAL_CALL getFormat() override
virtual void SAL_CALL setForward(sal_Bool _forward) override
virtual void SAL_CALL setText(const OUString &_text) override
virtual css::uno::Any SAL_CALL getReplacement() override
virtual sal_Bool SAL_CALL getMatchAllWordForms() override
void SetReplaceWith(const OUString &rText)
void SetReplace(sal_Int32 type)
bool InRange(const css::uno::Reference< css::text::XTextRange > &xCurrentRange)
virtual void SAL_CALL setMatchSoundsLike(sal_Bool _matchsoundslike) override
virtual void SAL_CALL setMatchCase(sal_Bool _matchcase) override
bool m_bDetectedRangeSegmentation false