summaryrefslogtreecommitdiff
path: root/sd/source/ui
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-06-06 17:45:24 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-06-07 15:42:05 +0200
commit03d33ba9410433d2072364b3afb9dbd6b19c4d0d (patch)
treea0513e810856ea6a45fc8eb31b086e857b9a17fd /sd/source/ui
parent00dfa6dc890dbbc8140fe613599becb5e4c55486 (diff)
lok: re-factor getTextSelection.
Change-Id: I2c27c213ee980e19d6020e9599b2b72115e7f28e Reviewed-on: https://gerrit.libreoffice.org/73626 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sd/source/ui')
-rw-r--r--sd/source/ui/inc/ViewShell.hxx4
-rw-r--r--sd/source/ui/inc/unomodel.hxx4
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx6
-rw-r--r--sd/source/ui/view/viewshel.cxx53
4 files changed, 11 insertions, 56 deletions
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index dea7dfbfea4c..c8fce2036aeb 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -412,8 +412,8 @@ public:
/// Allows adjusting the point or mark of the selection to a document coordinate.
void SetCursorMm100Position(const Point& rPosition, bool bPoint, bool bClearMark);
- /// Gets the currently selected text.
- OString GetTextSelection(const OString& aMimeType, OString& rUsedMimeType);
+ /// Gets the current selectiion
+ css::uno::Reference<css::datatransfer::XTransferable> GetSelectionTransferrable();
/// Allows starting or ending a graphic move or resize action.
void SetGraphicMm100Position(bool bStart, const Point& rPosition);
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index d13109d0667e..2be081b447f1 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -249,8 +249,8 @@ public:
virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override;
/// @see vcl::ITiledRenderable::setTextSelection().
virtual void setTextSelection(int nType, int nX, int nY) override;
- /// @see vcl::ITiledRenderable::getTextSelection().
- virtual OString getTextSelection(const char* pMimeType, OString& rUsedMimeType) override;
+ /// @see vcl::ITiledRenderable::getSelection().
+ virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override;
/// @see vcl::ITiledRenderable::setGraphicSelection().
virtual void setGraphicSelection(int nType, int nX, int nY) override;
/// @see lok::Document::resetSelection().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 237dab1bace1..e6c15f7f1cd0 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2538,15 +2538,15 @@ void SdXImpressDocument::setTextSelection(int nType, int nX, int nY)
}
}
-OString SdXImpressDocument::getTextSelection(const char* pMimeType, OString& rUsedMimeType)
+uno::Reference<datatransfer::XTransferable> SdXImpressDocument::getSelection()
{
SolarMutexGuard aGuard;
DrawViewShell* pViewShell = GetViewShell();
if (!pViewShell)
- return OString();
+ return uno::Reference<datatransfer::XTransferable>();
- return pViewShell->GetTextSelection(pMimeType, rUsedMimeType);
+ return pViewShell->GetSelectionTransferrable();
}
void SdXImpressDocument::setGraphicSelection(int nType, int nX, int nY)
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 8679f069b734..f2c1a5603041 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -524,62 +524,17 @@ void ViewShell::SetCursorMm100Position(const Point& rPosition, bool bPoint, bool
}
}
-OString ViewShell::GetTextSelection(const OString& _aMimeType, OString& rUsedMimeType)
+uno::Reference<datatransfer::XTransferable> ViewShell::GetSelectionTransferrable()
{
SdrView* pSdrView = GetView();
if (!pSdrView)
- return OString();
+ return uno::Reference<datatransfer::XTransferable>();
if (!pSdrView->GetTextEditObject())
- return OString();
+ return uno::Reference<datatransfer::XTransferable>();
EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
- uno::Reference<datatransfer::XTransferable> xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
-
- // Take care of UTF-8 text here.
- bool bConvert = false;
- sal_Int32 nIndex = 0;
- OString aMimeType = _aMimeType;
- if (aMimeType.getToken(0, ';', nIndex) == "text/plain")
- {
- if (aMimeType.getToken(0, ';', nIndex) == "charset=utf-8")
- {
- aMimeType = "text/plain;charset=utf-16";
- bConvert = true;
- }
- }
-
- datatransfer::DataFlavor aFlavor;
- aFlavor.MimeType = OUString::fromUtf8(aMimeType.getStr());
- if (bConvert || aMimeType == "text/plain;charset=utf-16")
- aFlavor.DataType = cppu::UnoType<OUString>::get();
- else
- aFlavor.DataType = cppu::UnoType< uno::Sequence<sal_Int8> >::get();
-
- if (!xTransferable->isDataFlavorSupported(aFlavor))
- return OString();
-
- uno::Any aAny(xTransferable->getTransferData(aFlavor));
-
- OString aRet;
- if (aFlavor.DataType == cppu::UnoType<OUString>::get())
- {
- OUString aString;
- aAny >>= aString;
- if (bConvert)
- aRet = OUStringToOString(aString, RTL_TEXTENCODING_UTF8);
- else
- aRet = OString(reinterpret_cast<const sal_Char *>(aString.getStr()), aString.getLength() * sizeof(sal_Unicode));
- }
- else
- {
- uno::Sequence<sal_Int8> aSequence;
- aAny >>= aSequence;
- aRet = OString(reinterpret_cast<sal_Char*>(aSequence.getArray()), aSequence.getLength());
- }
-
- rUsedMimeType = _aMimeType;
- return aRet;
+ return rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
}
void ViewShell::SetGraphicMm100Position(bool bStart, const Point& rPosition)