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>
34SwVbaFind::SwVbaFind(
const uno::Reference< ooo::vba::XHelperInterface >& rParent,
const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< frame::XModel > xModel ) :
35 SwVbaFind_BASE( rParent, rContext ),
mxModel(
std::move(
xModel) ), mbReplace( false ), mnReplaceType( word::WdReplace::wdReplaceOne ), mnWrap( word::WdFindWrap::wdFindStop )
48 const uno::Reference< uno::XComponentContext >& rContext,
49 const uno::Reference< frame::XModel >& xModel,
50 const uno::Reference< text::XTextRange >& xTextRange)
62 xFind->mxTextRange = xTextRange;
70 uno::Reference< text::XTextRangeCompare > xTRC(
mxTextRange->getText(), uno::UNO_QUERY_THROW );
71 return xTRC->compareRegionStarts(
mxTextRange, xCurrentRange ) >= 0 && xTRC->compareRegionEnds(
mxTextRange, xCurrentRange ) <= 0;
76 uno::Reference< text::XTextRangeCompare > xTRC(
mxTextRange->getText(), uno::UNO_QUERY_THROW );
77 return xTRC->compareRegionStarts(
mxTextRange, xCurrentRange ) == 0 && xTRC->compareRegionEnds(
mxTextRange, xCurrentRange ) == 0;
97 uno::Reference< text::XTextRange > xFoundOne;
98 if( !
mxTVC->getString().isEmpty() )
111 xFoundOne.set(
mxReplaceable->findNext( xFoundOne, uno::Reference< util::XSearchDescriptor >(
mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY );
113 else if( xFoundOne.is() && !
InRange( xFoundOne ) )
123 if( !xFoundOne.is() && (
getWrap() == word::WdFindWrap::wdFindContinue ||
getWrap() == word::WdFindWrap::wdFindAsk ) )
127 mxTVC->gotoStart(
false);
132 mxTVC->gotoEnd(
false );
150 case word::WdReplace::wdReplaceNone:
155 case word::WdReplace::wdReplaceOne:
165 case word::WdReplace::wdReplaceAll:
167 uno::Reference< container::XIndexAccess > xIndexAccess =
mxReplaceable->findAll( uno::Reference< util::XSearchDescriptor >(
mxPropertyReplace, uno::UNO_QUERY_THROW ) );
168 if( xIndexAccess->getCount() > 0 )
170 for( sal_Int32
i = 0;
i < xIndexAccess->getCount();
i++ )
172 uno::Reference< text::XTextRange > xTextRange( xIndexAccess->getByIndex(
i ), uno::UNO_QUERY_THROW );
173 if(
mnWrap == word::WdFindWrap::wdFindContinue ||
mnWrap == word::WdFindWrap::wdFindAsk ||
InRange( xTextRange ) )
215 throw uno::RuntimeException(
"Not implemented" );
220 bool bBackward =
false;
227 bool bBackward = !_forward;
320 throw uno::RuntimeException(
"Not implemented" );
325 throw uno::RuntimeException(
"Not implemented" );
329SwVbaFind::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& )
354 MatchWildcards >>= bValue;
360 MatchSoundsLike >>= bValue;
366 MatchAllWordForms >>= bValue;
378 sal_Int32 nWrapType = 0;
392 ReplaceWith >>= sValue;
411 uno::Sequence< beans::PropertyValue > aSearchAttribs;
421uno::Sequence< OUString >
css::uno::Reference< css::frame::XModel2 > mxModel
css::uno::Reference< css::uno::XComponentContext > mxContext
SwDoc * GetDoc()
returns Doc. But be careful!
const css::uno::Reference< ooo::vba::word::XFind > & getVbaFind() const
void setVbaFind(const css::uno::Reference< ooo::vba::word::XFind > &xFind)
virtual sal_Bool SAL_CALL getFormat() override
virtual void SAL_CALL setMatchCase(sal_Bool _matchcase) override
virtual void SAL_CALL setMatchWholeWord(sal_Bool _matchwholeword) override
virtual void SAL_CALL setMatchAllWordForms(sal_Bool _matchallwordforms) override
virtual OUString getServiceImplName() override
virtual sal_Bool SAL_CALL getMatchSoundsLike() override
static css::uno::Reference< ooo::vba::word::XFind > GetOrCreateFind(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< com::sun::star::uno::XComponentContext > &rContext, const css::uno::Reference< com::sun::star::frame::XModel > &xModel, const css::uno::Reference< css::text::XTextRange > &xTextRange)
void SetReplaceWith(const OUString &rText)
virtual css::uno::Any SAL_CALL getStyle() override
css::uno::Reference< css::text::XTextViewCursor > mxTVC
virtual void SAL_CALL setFormat(sal_Bool _format) override
css::uno::Reference< css::text::XTextRange > mxTextRange
virtual sal_Bool SAL_CALL getMatchAllWordForms() override
virtual void SAL_CALL setText(const OUString &_text) override
SwVbaFind(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, css::uno::Reference< css::frame::XModel > xModel)
virtual OUString SAL_CALL getText() override
virtual ::sal_Int32 SAL_CALL getWrap() override
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
css::uno::Reference< css::frame::XModel > mxModel
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual sal_Bool SAL_CALL getMatchWholeWord() override
css::uno::Reference< css::util::XReplaceable > mxReplaceable
virtual void SAL_CALL setWrap(::sal_Int32 _wrap) override
bool InRange(const css::uno::Reference< css::text::XTextRange > &xCurrentRange)
void SetReplace(sal_Int32 type)
virtual void SAL_CALL setForward(sal_Bool _forward) override
virtual void SAL_CALL setReplacement(const css::uno::Any &_replacement) override
virtual css::uno::Any SAL_CALL getReplacement() override
virtual sal_Bool SAL_CALL getMatchWildcards() override
css::uno::Reference< css::text::XTextRange > FindOneElement()
virtual ~SwVbaFind() override
virtual void SAL_CALL setStyle(const css::uno::Any &_style) override
virtual sal_Bool SAL_CALL getForward() override
virtual void SAL_CALL setMatchWildcards(sal_Bool _matchwildcards) override
virtual void SAL_CALL ClearFormatting() override
virtual void SAL_CALL setMatchSoundsLike(sal_Bool _matchsoundslike) override
css::uno::Reference< css::util::XPropertyReplace > mxPropertyReplace
bool InEqualRange(const css::uno::Reference< css::text::XTextRange > &xCurrentRange)
virtual sal_Bool SAL_CALL getMatchCase() override
css::uno::Reference< css::view::XSelectionSupplier > mxSelSupp
OUString GetReplaceWith()
Sequence< OUString > aServiceNames
uno::Reference< text::XTextViewCursor > getXTextViewCursor(const uno::Reference< frame::XModel > &xModel)
SwDocShell * getDocShell(const uno::Reference< frame::XModel > &xModel)
Reference< XModel > xModel