summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/unomodel.cxx51
-rw-r--r--basctl/source/basicide/unomodel.hxx3
2 files changed, 54 insertions, 0 deletions
diff --git a/basctl/source/basicide/unomodel.cxx b/basctl/source/basicide/unomodel.cxx
index 5d3946b426c6..180bf3d17fa7 100644
--- a/basctl/source/basicide/unomodel.cxx
+++ b/basctl/source/basicide/unomodel.cxx
@@ -19,6 +19,7 @@
#include "basdoc.hxx"
+#include <basidesh.hxx>
#include <iderdll.hxx>
#include <com/sun/star/io/IOException.hpp>
#include <comphelper/sequence.hxx>
@@ -29,6 +30,41 @@
#include "unomodel.hxx"
+
+namespace {
+
+// Implements XEnumeration to hold a single selected portion of text
+// This will actually only hold a single string value
+class SelectionEnumeration : public ::cppu::WeakImplHelper<css::container::XEnumeration>
+{
+private:
+ OUString m_sText;
+ bool m_bHasElements;
+
+public:
+ explicit SelectionEnumeration(OUString& sSelectedText)
+ : m_sText(sSelectedText)
+ , m_bHasElements(true) {}
+
+ virtual sal_Bool SAL_CALL hasMoreElements() override
+ {
+ return m_bHasElements;
+ }
+
+ virtual css::uno::Any SAL_CALL nextElement() override
+ {
+ if (m_bHasElements)
+ {
+ m_bHasElements = false;
+ return css::uno::Any(m_sText);
+ }
+
+ throw css::container::NoSuchElementException();
+ }
+};
+
+} // End of unnamed namespace
+
namespace basctl
{
@@ -114,6 +150,21 @@ void SIDEModel::notImplemented()
throw io::IOException("Can't store IDE model" );
}
+// XModel
+css::uno::Reference< css::uno::XInterface > SAL_CALL SIDEModel::getCurrentSelection()
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<container::XEnumeration> xEnum;
+ Shell* pShell = GetShell();
+
+ if (pShell)
+ {
+ OUString sText = GetShell()->GetSelectionText(false);
+ xEnum = new SelectionEnumeration(sText);
+ }
+ return xEnum;
+}
+
} // namespace basctl
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
diff --git a/basctl/source/basicide/unomodel.hxx b/basctl/source/basicide/unomodel.hxx
index b47873005699..9b0289032660 100644
--- a/basctl/source/basicide/unomodel.hxx
+++ b/basctl/source/basicide/unomodel.hxx
@@ -53,6 +53,9 @@ public:
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override;
virtual void SAL_CALL storeToURL( const OUString& sURL,
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override;
+
+ // XModel
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection() override;
};
} // namespace basctl