You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by js...@apache.org on 2013/03/20 16:14:46 UTC
svn commit: r1458875 - in /openoffice/trunk/main:
offapi/com/sun/star/smarttags/ svx/inc/svx/ svx/source/smarttags/
sw/source/core/txtnode/
Author: jsc
Date: Wed Mar 20 15:14:46 2013
New Revision: 1458875
URL: http://svn.apache.org/r1458875
Log:
#121730# add new optional interface XRangeBasedSmartTagRecognizer for SmartTags
Patch by: Kai Labusch
Review by: arielch, jsc
Added:
openoffice/trunk/main/offapi/com/sun/star/smarttags/XRangeBasedSmartTagRecognizer.idl
Modified:
openoffice/trunk/main/offapi/com/sun/star/smarttags/XSmartTagRecognizer.idl
openoffice/trunk/main/offapi/com/sun/star/smarttags/makefile.mk
openoffice/trunk/main/svx/inc/svx/SmartTagMgr.hxx
openoffice/trunk/main/svx/source/smarttags/SmartTagMgr.cxx
openoffice/trunk/main/sw/source/core/txtnode/txtedt.cxx
Added: openoffice/trunk/main/offapi/com/sun/star/smarttags/XRangeBasedSmartTagRecognizer.idl
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/offapi/com/sun/star/smarttags/XRangeBasedSmartTagRecognizer.idl?rev=1458875&view=auto
==============================================================================
--- openoffice/trunk/main/offapi/com/sun/star/smarttags/XRangeBasedSmartTagRecognizer.idl (added)
+++ openoffice/trunk/main/offapi/com/sun/star/smarttags/XRangeBasedSmartTagRecognizer.idl Wed Mar 20 15:14:46 2013
@@ -0,0 +1,101 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef __com_sun_star_smarttags_XRangeBasedSmartTagRecognizer_idl__
+#define __com_sun_star_smarttags_XRangeBasedSmartTagRecognizer_idl__
+
+#ifndef __com_sun_star_uno_XInitialization_idl__
+#include <com/sun/star/lang/XInitialization.idl>
+#endif
+
+#ifndef __com_sun_star_lang_Locale_idl__
+#include <com/sun/star/lang/Locale.idl>
+#endif
+
+#ifndef __com_sun_star_smarttags_SmartTagRecognizerMode_idl__
+#include <com/sun/star/smarttags/SmartTagRecognizerMode.idl>
+#endif
+
+#ifndef __com_sun_star_text_XTextMarkup_idl__
+#include <com/sun/star/text/XTextMarkup.idl>
+#endif
+
+#ifndef __com_sun_star_frame_XController_idl__
+#include <com/sun/star/frame/XController.idl>
+#endif
+
+#ifndef __com_sun_star_lang_IndexOutOfBoundsException_idl__
+#include <com/sun/star/lang/IndexOutOfBoundsException.idl>
+#endif
+
+#ifndef __com_sun_star_text_XTextRange_idl__
+#include <com/sun/star/text/XTextRange.idl>
+#endif
+
+
+//=============================================================================
+
+module com { module sun { module star { module smarttags {
+
+//=============================================================================
+
+/**
+ provides access to a range based smart tag recognizer.
+ */
+
+interface XRangeBasedSmartTagRecognizer: com::sun::star::lang::XInitialization
+{
+
+ //-------------------------------------------------------------------------
+ /** recognizes smart tags.
+
+ @param xRange
+ The text that should be scanned by the recognizer.
+
+ @param eDataType
+ This value indicates the type of the passed text.
+
+ @param aLocale
+ Is used to indicate the language of the passed text.
+
+ @param xTextMarkup
+ This object is used to submit any recognized smart tags
+ to the calling application.
+
+ @param aApplicationName
+ A string containing the name of the calling application.
+
+ @param xController
+ The current controller of the document.
+ */
+
+ void recognizeTextRange( [in] com::sun::star::text::XTextRange xRange,
+ [in] SmartTagRecognizerMode eDataType,
+ [in] com::sun::star::text::XTextMarkup xTextMarkup,
+ [in] string aApplicationName,
+ [in] com::sun::star::frame::XController xController);
+};
+
+}; }; }; };
+
+#endif
Modified: openoffice/trunk/main/offapi/com/sun/star/smarttags/XSmartTagRecognizer.idl
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/offapi/com/sun/star/smarttags/XSmartTagRecognizer.idl?rev=1458875&r1=1458874&r2=1458875&view=diff
==============================================================================
--- openoffice/trunk/main/offapi/com/sun/star/smarttags/XSmartTagRecognizer.idl (original)
+++ openoffice/trunk/main/offapi/com/sun/star/smarttags/XSmartTagRecognizer.idl Wed Mar 20 15:14:46 2013
@@ -52,6 +52,11 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.idl>
#endif
+#ifndef __com_sun_star_text_XTextRange_idl__
+#include <com/sun/star/text/XTextRange.idl>
+#endif
+
+
//=============================================================================
module com { module sun { module star { module smarttags {
@@ -178,7 +183,6 @@ interface XSmartTagRecognizer: com::sun:
[in] com::sun::star::frame::XController xController,
[in] com::sun::star::i18n::XBreakIterator xTokenizer );
-
//-------------------------------------------------------------------------
/** indicates whether there is a property page for a smart tag type.
Modified: openoffice/trunk/main/offapi/com/sun/star/smarttags/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/offapi/com/sun/star/smarttags/makefile.mk?rev=1458875&r1=1458874&r2=1458875&view=diff
==============================================================================
--- openoffice/trunk/main/offapi/com/sun/star/smarttags/makefile.mk (original)
+++ openoffice/trunk/main/offapi/com/sun/star/smarttags/makefile.mk Wed Mar 20 15:14:46 2013
@@ -37,6 +37,7 @@ IDLFILES=\
SmartTagAction.idl\
SmartTagRecognizer.idl\
SmartTagRecognizerMode.idl\
+ XRangeBasedSmartTagRecognizer.idl\
XSmartTagAction.idl\
XSmartTagRecognizer.idl
Modified: openoffice/trunk/main/svx/inc/svx/SmartTagMgr.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/SmartTagMgr.hxx?rev=1458875&r1=1458874&r2=1458875&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/SmartTagMgr.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/SmartTagMgr.hxx Wed Mar 20 15:14:46 2013
@@ -46,6 +46,7 @@ namespace com { namespace sun { namespac
namespace com { namespace sun { namespace star { namespace text {
class XTextMarkup;
+ class XTextRange;
} } } }
namespace com { namespace sun { namespace star { namespace i18n {
@@ -155,12 +156,17 @@ public:
The length of the text to be scanned.
*/
- void Recognize( const rtl::OUString& rText,
+ void RecognizeString( const rtl::OUString& rText,
const com::sun::star::uno::Reference< com::sun::star::text::XTextMarkup > xMarkup,
const com::sun::star::uno::Reference< com::sun::star::frame::XController > xController,
const com::sun::star::lang::Locale& rLocale,
sal_uInt32 nStart, sal_uInt32 nLen ) const;
+ void RecognizeTextRange(const com::sun::star::uno::Reference< com::sun::star::text::XTextRange> xRange,
+ const com::sun::star::uno::Reference< com::sun::star::text::XTextMarkup > xMarkup,
+ const com::sun::star::uno::Reference< com::sun::star::frame::XController > xController) const;
+
+
/** Returns all action references associated with a given list of smart tag types
@param rSmartTagTypes
Modified: openoffice/trunk/main/svx/source/smarttags/SmartTagMgr.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/smarttags/SmartTagMgr.cxx?rev=1458875&r1=1458874&r2=1458875&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/smarttags/SmartTagMgr.cxx (original)
+++ openoffice/trunk/main/svx/source/smarttags/SmartTagMgr.cxx Wed Mar 20 15:14:46 2013
@@ -30,6 +30,7 @@
#include <vos/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>
@@ -50,6 +51,8 @@
#include <rtl/ustring.hxx>
#include <tools/string.hxx>
+#include <com/sun/star/text/XTextRange.hpp>
+
using namespace com::sun::star;
using namespace com::sun::star::uno;
@@ -100,7 +103,7 @@ void SmartTagMgr::CreateBreakIterator()
/** Dispatches the recognize call to all installed smart tag recognizers
*/
-void SmartTagMgr::Recognize( const rtl::OUString& rText,
+void SmartTagMgr::RecognizeString( const rtl::OUString& rText,
const Reference< text::XTextMarkup > xMarkup,
const Reference< frame::XController > xController,
const lang::Locale& rLocale,
@@ -132,6 +135,40 @@ void SmartTagMgr::Recognize( const rtl::
}
}
+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 < rtl::OUString, ActionReference >::const_iterator SmartTagMapIter;
void SmartTagMgr::GetActionSequences( Sequence < rtl::OUString >& rSmartTagTypes,
Modified: openoffice/trunk/main/sw/source/core/txtnode/txtedt.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/txtnode/txtedt.cxx?rev=1458875&r1=1458874&r2=1458875&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/txtnode/txtedt.cxx (original)
+++ openoffice/trunk/main/sw/source/core/txtnode/txtedt.cxx Wed Mar 20 15:14:46 2013
@@ -88,6 +88,7 @@
#include <vector>
+#include <unotextrange.hxx>
using rtl::OUString;
using namespace ::com::sun::star;
@@ -1352,7 +1353,14 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNo
Reference< ::com::sun::star::frame::XController > xController = pNode->GetDoc()->GetDocShell()->GetController();
- xub_StrLen nLangBegin = nBegin;
+ SwPosition start(*pNode, nBegin);
+ SwPosition end (*pNode, nEnd);
+ Reference< ::com::sun::star::text::XTextRange > xRange = SwXTextRange::CreateXTextRange(*pNode->GetDoc(), start, &end);
+
+ rSmartTagMgr.RecognizeTextRange(xRange, xTextMarkup, xController);
+
+
+ xub_StrLen nLangBegin = nBegin;
xub_StrLen nLangEnd = nEnd;
// smart tag recognization has to be done for each language portion:
@@ -1367,7 +1375,7 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNo
const sal_uInt32 nExpandBegin = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nLangBegin );
const sal_uInt32 nExpandEnd = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nLangEnd );
- rSmartTagMgr.Recognize( aExpandText, xTextMarkup, xController, aLocale, nExpandBegin, nExpandEnd - nExpandBegin );
+ rSmartTagMgr.RecognizeString(aExpandText, xTextMarkup, xController, aLocale, nExpandBegin, nExpandEnd - nExpandBegin );
nLangBegin = nLangEnd;
}