summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJürgen Schmidt <jsc@apache.org>2013-03-20 14:19:45 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-23 11:55:27 +0100
commitc43ffd3d44060c0801138e33a9dfc917133b7c21 (patch)
tree7ab3f484b29143d863950db09ce58d1f5c432753 /sw
parent79b231f7a032c7e04b74fa019e18a5d7e3b5f4f3 (diff)
Resolves: #i121734# extend XTextMarkup to support ranges
Patch by: Kai Labusch Review by: arielch, jsc (cherry picked from commit de75173372c022c3004643d8978f76662261130b) Conflicts: offapi/com/sun/star/text/XTextMarkup.idl sw/inc/unoflatpara.hxx sw/inc/unotextmarkup.hxx sw/source/core/unocore/unoflatpara.cxx Change-Id: I2cfa15f08a893feb8880dc729b76cff3d29ce4eb
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/inc/unoflatpara.hxx11
-rw-r--r--sw/source/core/inc/unotextmarkup.hxx12
-rw-r--r--sw/source/core/unocore/unoflatpara.cxx14
-rw-r--r--sw/source/core/unocore/unotextmarkup.cxx56
4 files changed, 88 insertions, 5 deletions
diff --git a/sw/source/core/inc/unoflatpara.hxx b/sw/source/core/inc/unoflatpara.hxx
index ff499abe71aa..31927517aa09 100644
--- a/sw/source/core/inc/unoflatpara.hxx
+++ b/sw/source/core/inc/unoflatpara.hxx
@@ -34,6 +34,10 @@ namespace com { namespace sun { namespace star { namespace container {
class XStringKeyMap;
} } } }
+namespace com { namespace sun { namespace star { namespace text {
+ class XTextRange;
+} } } }
+
class SwTxtNode;
class SwDoc;
@@ -62,7 +66,12 @@ public:
// text::XTextMarkup:
virtual css::uno::Reference< css::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() throw (css::uno::RuntimeException);
- virtual void SAL_CALL commitTextMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength,
+ const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange> & xRange,
+ const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (css::uno::RuntimeException);
// text::XFlatParagraph:
virtual OUString SAL_CALL getText() throw (css::uno::RuntimeException);
diff --git a/sw/source/core/inc/unotextmarkup.hxx b/sw/source/core/inc/unotextmarkup.hxx
index 8a5b3c7eb362..1ceb4131933b 100644
--- a/sw/source/core/inc/unotextmarkup.hxx
+++ b/sw/source/core/inc/unotextmarkup.hxx
@@ -33,6 +33,11 @@ namespace com { namespace sun { namespace star { namespace container {
class XStringKeyMap;
} } } }
+namespace com { namespace sun { namespace star { namespace text {
+ class XTextRange;
+} } } }
+
+
class SwTxtNode;
class SfxPoolItem;
@@ -52,7 +57,12 @@ public:
// ::com::sun::star::text::XTextMarkup:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > SAL_CALL getMarkupInfoContainer() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL commitTextMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > & xMarkupInfoContainer) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL commitStringMarkup(::sal_Int32 nType, const OUString & aIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > & xMarkupInfoContainer) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange> & xRange,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XStringKeyMap > & xMarkupInfoContainer) throw (::com::sun::star::uno::RuntimeException);
// ::com::sun::star::text::XMultiTextMarkup:
virtual void SAL_CALL commitMultiTextMarkup( const ::com::sun::star::uno::Sequence< ::com::sun::star::text::TextMarkupDescriptor >& aMarkups ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index 2c3696a1bf77..c1c2b92446a2 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -44,6 +44,9 @@
#include <viewopt.hxx>
#include <comphelper/servicehelper.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
using namespace ::com::sun::star;
namespace SwUnoCursorHelper {
@@ -119,10 +122,17 @@ css::uno::Reference< css::container::XStringKeyMap > SAL_CALL SwXFlatParagraph::
return SwXTextMarkup::getMarkupInfoContainer();
}
-void SAL_CALL SwXFlatParagraph::commitTextMarkup(::sal_Int32 nType, const OUString & rIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, const css::uno::Reference< css::container::XStringKeyMap > & rxMarkupInfoContainer) throw (css::uno::RuntimeException)
+void SAL_CALL SwXFlatParagraph::commitTextRangeMarkup(::sal_Int32 nType, const OUString & aIdentifier, const uno::Reference< text::XTextRange> & xRange,
+ const css::uno::Reference< css::container::XStringKeyMap > & xMarkupInfoContainer) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SwXTextMarkup::commitTextRangeMarkup( nType, aIdentifier, xRange, xMarkupInfoContainer );
+}
+
+void SAL_CALL SwXFlatParagraph::commitStringMarkup(::sal_Int32 nType, const OUString & rIdentifier, ::sal_Int32 nStart, ::sal_Int32 nLength, const css::uno::Reference< css::container::XStringKeyMap > & rxMarkupInfoContainer) throw (css::uno::RuntimeException)
{
SolarMutexGuard aGuard;
- SwXTextMarkup::commitTextMarkup( nType, rIdentifier, nStart, nLength, rxMarkupInfoContainer );
+ SwXTextMarkup::commitStringMarkup( nType, rIdentifier, nStart, nLength, rxMarkupInfoContainer );
}
// text::XFlatParagraph:
diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx
index 72ffaa762759..8976a65784b0 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -30,6 +30,15 @@
#include <IGrammarContact.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <pam.hxx>
+
+#include <unotextrange.hxx>
+#include <unotextcursor.hxx>
+
+
using namespace ::com::sun::star;
/*
@@ -55,7 +64,52 @@ uno::Reference< container::XStringKeyMap > SAL_CALL SwXTextMarkup::getMarkupInfo
return xProp;
}
-void SAL_CALL SwXTextMarkup::commitTextMarkup(
+void SAL_CALL SwXTextMarkup::commitTextRangeMarkup(::sal_Int32 nType, const ::rtl::OUString & aIdentifier, const uno::Reference< text::XTextRange> & xRange,
+ const uno::Reference< container::XStringKeyMap > & xMarkupInfoContainer) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
+
+ if(!xRangeTunnel.is()) return;
+
+ SwXTextRange* pRange = 0;
+ OTextCursorHelper* pCursor = 0;
+
+ if(xRangeTunnel.is())
+ {
+ pRange = reinterpret_cast<SwXTextRange*>( sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething(SwXTextRange::getUnoTunnelId())));
+ pCursor = reinterpret_cast<OTextCursorHelper*>( sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething(OTextCursorHelper::getUnoTunnelId())));
+ }
+
+ if (pRange)
+ {
+ SwDoc* pDoc = reinterpret_cast<SwDoc*>(pRange->GetDoc());
+
+ if (!pDoc) return;
+
+ SwUnoInternalPaM aPam(*pDoc);
+
+ ::sw::XTextRangeToSwPaM(aPam, xRange);
+
+ SwPosition* startPos = aPam.Start();
+ SwPosition* endPos = aPam.End();
+
+ commitStringMarkup (nType, aIdentifier, startPos->nContent.GetIndex(), endPos->nContent.GetIndex() - startPos->nContent.GetIndex(), xMarkupInfoContainer);
+ }
+ else if (pCursor)
+ {
+ SwPaM aPam(*pCursor->GetPaM());
+
+ SwPosition* startPos = aPam.Start();
+ SwPosition* endPos = aPam.End();
+
+ commitStringMarkup (nType, aIdentifier, startPos->nContent.GetIndex(), endPos->nContent.GetIndex() - startPos->nContent.GetIndex(), xMarkupInfoContainer);
+ }
+}
+
+
+void SAL_CALL SwXTextMarkup::commitStringMarkup(
::sal_Int32 nType,
const OUString & rIdentifier,
::sal_Int32 nStart,