summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-05-27 09:05:55 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-05-27 09:32:44 +0200
commitae59502b20b52aaf34f8f4d89e354f28a7dbe453 (patch)
tree1709083c2b959ff83b983b8f71670d45f9c3772c
parentf8ef170acf5bc01820c986428c7bec419e6884b6 (diff)
SwXShape: return the right XText implementaation in the TextBox case
Change-Id: Iac31bd4b3b1918f857feff9045df473e9b1d3d2b
-rw-r--r--sw/inc/textboxhelper.hxx4
-rw-r--r--sw/source/core/doc/textboxhelper.cxx23
-rw-r--r--sw/source/core/unocore/unodraw.cxx2
3 files changed, 20 insertions, 9 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 0c992dc87493..f7750b388148 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -28,8 +28,8 @@ public:
static void create(SwFrmFmt* pShape);
/// Destroy a TextBox for a shape.
static void destroy(SwFrmFmt* pShape);
- /// Get XTextAppend of a shape's TextBox, if there is any.
- static css::uno::Any getXTextAppend(SwFrmFmt* pShape, const css::uno::Type& rType);
+ /// Get interface of a shape's TextBox, if there is any.
+ static css::uno::Any queryInterface(SwFrmFmt* pShape, const css::uno::Type& rType);
/// Sync property of TextBox with the one of the shape.
static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const OUString& rPropertyName, const css::uno::Any& rValue);
/// If we have an associated TextFrame, then return that.
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index faadb5f3f9e8..85b18b989ffa 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -103,18 +103,29 @@ SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape)
return pRet;
}
-uno::Any SwTextBoxHelper::getXTextAppend(SwFrmFmt* pShape, const uno::Type& rType)
+template < typename T >
+void lcl_queryInterface(SwFrmFmt* pShape, uno::Any& rAny)
+{
+ if (SwFrmFmt* pFmt = SwTextBoxHelper::findTextBox(pShape))
+ {
+ uno::Reference<T> xInterface(static_cast<cppu::OWeakObject*>(SwXFrames::GetObject(*pFmt, FLYCNTTYPE_FRM)), uno::UNO_QUERY);
+ rAny <<= xInterface;
+ }
+}
+
+uno::Any SwTextBoxHelper::queryInterface(SwFrmFmt* pShape, const uno::Type& rType)
{
uno::Any aRet;
if (rType == cppu::UnoType<css::text::XTextAppend>::get())
{
- if (SwFrmFmt* pFmt = findTextBox(pShape))
- {
- uno::Reference<text::XTextAppend> xTextAppend(static_cast<cppu::OWeakObject*>(SwXFrames::GetObject(*pFmt, FLYCNTTYPE_FRM)), uno::UNO_QUERY);
- aRet <<= xTextAppend;
- }
+ lcl_queryInterface<text::XTextAppend>(pShape, aRet);
}
+ else if (rType == cppu::UnoType<css::text::XText>::get())
+ {
+ lcl_queryInterface<text::XText>(pShape, aRet);
+ }
+
return aRet;
}
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index e506cd202c64..b01ae9cb38ff 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -975,7 +975,7 @@ SwXShape::~SwXShape()
uno::Any SwXShape::queryInterface( const uno::Type& aType ) throw( uno::RuntimeException, std::exception )
{
- uno::Any aRet = SwTextBoxHelper::getXTextAppend(GetFrmFmt(), aType);
+ uno::Any aRet = SwTextBoxHelper::queryInterface(GetFrmFmt(), aType);
if (aRet.hasValue())
return aRet;