summaryrefslogtreecommitdiff
path: root/sd/source/ui/view/viewshel.cxx
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/view/viewshel.cxx
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/view/viewshel.cxx')
-rw-r--r--sd/source/ui/view/viewshel.cxx53
1 files changed, 4 insertions, 49 deletions
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)