diff options
author | Jürgen Schmidt <jsc@apache.org> | 2013-03-20 14:14:46 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-23 11:55:26 +0100 |
commit | 1959113eac6bb23310883c974ac40cba6f222493 (patch) | |
tree | 5474214954797653cb230be53dd01ed553e39d88 /svx | |
parent | 403bfea10fb8ef5c4596d6a137aa22cc5b895ccf (diff) |
Resolves: #i121730# add optional interface XRangeBasedSmartTagRecognizer
for SmartTags
Patch by: Kai Labusch
Review by: arielch, jsc
(cherry picked from commit a64c066b02924371f486688df01b6881bcd0da8b)
Conflicts:
offapi/com/sun/star/smarttags/XSmartTagRecognizer.idl
offapi/com/sun/star/smarttags/makefile.mk
svx/inc/svx/SmartTagMgr.hxx
svx/source/smarttags/SmartTagMgr.cxx
sw/source/core/txtnode/txtedt.cxx
Change-Id: I11f528b2c1a068d0b1db1e76c2f889c0632ab972
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/smarttags/SmartTagMgr.cxx | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/svx/source/smarttags/SmartTagMgr.cxx b/svx/source/smarttags/SmartTagMgr.cxx index ebd67334e16e..218406ca8138 100644 --- a/svx/source/smarttags/SmartTagMgr.cxx +++ b/svx/source/smarttags/SmartTagMgr.cxx @@ -24,6 +24,7 @@ #include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <com/sun/star/smarttags/XSmartTagRecognizer.hpp> +#include <com/sun/star/smarttags/XRangeBasedSmartTagRecognizer.hpp> #include <com/sun/star/smarttags/XSmartTagAction.hpp> #include <com/sun/star/deployment/ExtensionManager.hpp> #include <com/sun/star/text/XTextMarkup.hpp> @@ -44,6 +45,8 @@ #include <comphelper/processfactory.hxx> #include <rtl/ustring.hxx> +#include <com/sun/star/text/XTextRange.hpp> + using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::i18n; @@ -86,7 +89,7 @@ void SmartTagMgr::CreateBreakIterator() const /** Dispatches the recognize call to all installed smart tag recognizers */ -void SmartTagMgr::Recognize( const OUString& rText, +void SmartTagMgr::RecognizeString( const OUString& rText, const Reference< text::XTextMarkup > xMarkup, const Reference< frame::XController > xController, const lang::Locale& rLocale, @@ -118,6 +121,39 @@ void SmartTagMgr::Recognize( const OUString& rText, } } +void SmartTagMgr::RecognizeTextRange(const Reference< text::XTextRange> xRange, + const Reference< text::XTextMarkup > xMarkup, + const Reference< frame::XController > xController) const +{ + for ( sal_uInt32 i = 0; i < maRecognizerList.size(); i++ ) + { + Reference < smarttags::XSmartTagRecognizer > xRecognizer = maRecognizerList[i]; + + Reference< smarttags::XRangeBasedSmartTagRecognizer > xRangeBasedRecognizer = Reference< smarttags::XRangeBasedSmartTagRecognizer >( xRecognizer, UNO_QUERY); + + if (!xRangeBasedRecognizer.is()) continue; + + // if all smart tag types supported by this recognizer have been + // disabled, we do not have to call the recognizer: + bool bCallRecognizer = false; + const sal_uInt32 nSmartTagCount = xRecognizer->getSmartTagCount(); + for ( sal_uInt32 j = 0; j < nSmartTagCount && !bCallRecognizer; ++j ) + { + const rtl::OUString aSmartTagName = xRecognizer->getSmartTagName(j); + if ( IsSmartTagTypeEnabled( aSmartTagName ) ) + bCallRecognizer = true; + } + + if ( bCallRecognizer ) + { + xRangeBasedRecognizer->recognizeTextRange( xRange, + smarttags::SmartTagRecognizerMode_PARAGRAPH, + xMarkup, maApplicationName, xController); + } + } + +} + typedef std::multimap < OUString, ActionReference >::const_iterator SmartTagMapIter; void SmartTagMgr::GetActionSequences( Sequence < OUString >& rSmartTagTypes, |