Kaydet (Commit) c43ffd3d authored tarafından Jürgen Schmidt's avatar Jürgen Schmidt Kaydeden (comit) Caolán McNamara

Resolves: #i121734# extend XTextMarkup to support ranges

Patch by: Kai Labusch
Review by: arielch, jsc
(cherry picked from commit de751733)

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
üst 79b231f7
......@@ -22,6 +22,7 @@
#include <com/sun/star/container/XStringKeyMap.idl>
#include <com/sun/star/text/TextMarkupType.idl>
#include <com/sun/star/text/XTextRange.idl>
module com { module sun { module star { module text {
......@@ -61,11 +62,17 @@ interface XTextMarkup
@param xMarkupInfoContainer
contains additional information about the markup.
*/
void commitTextMarkup( [in] long nType,
void commitStringMarkup( [in] long nType,
[in] string aIdentifier,
[in] long nStart,
[in] long nLength,
[in] com::sun::star::container::XStringKeyMap xMarkupInfoContainer );
void commitTextRangeMarkup( [in] long nType,
[in] string aIdentifier,
[in] com::sun::star::text::XTextRange xRange,
[in] com::sun::star::container::XStringKeyMap xMarkupInfoContainer );
};
}; }; }; };
......
......@@ -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);
......
......@@ -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);
......
......@@ -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:
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment