Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
6552767a
Kaydet (Commit)
6552767a
authored
Eki 22, 2015
tarafından
Miklos Vajna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
LOK: add Document::paste()
Change-Id: I34998229e7f5cac4c62c859861783be3c161f9bf
üst
981a9748
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
199 additions
and
0 deletions
+199
-0
Library_sofficeapp.mk
desktop/Library_sofficeapp.mk
+2
-0
init.cxx
desktop/source/lib/init.cxx
+38
-0
lokclipboard.cxx
desktop/source/lib/lokclipboard.cxx
+83
-0
lokclipboard.hxx
desktop/source/lib/lokclipboard.hxx
+58
-0
LibreOfficeKit.h
include/LibreOfficeKit/LibreOfficeKit.h
+6
-0
LibreOfficeKit.hxx
include/LibreOfficeKit/LibreOfficeKit.hxx
+12
-0
No files found.
desktop/Library_sofficeapp.mk
Dosyayı görüntüle @
6552767a
...
...
@@ -122,6 +122,7 @@ ifneq ($(filter $(OS),ANDROID IOS MACOSX),)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/init \
desktop/source/lib/lokinteractionhandler \
desktop/source/lib/lokclipboard \
$(if $(filter $(OS),ANDROID), \
desktop/source/lib/lokandroid) \
))
...
...
@@ -130,6 +131,7 @@ ifeq ($(USING_X11),TRUE)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/init \
desktop/source/lib/lokinteractionhandler \
desktop/source/lib/lokclipboard \
))
endif
endif
...
...
desktop/source/lib/init.cxx
Dosyayı görüntüle @
6552767a
...
...
@@ -44,6 +44,7 @@
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <editeng/fontitem.hxx>
#include <editeng/flstitem.hxx>
...
...
@@ -79,6 +80,7 @@
#include "../../inc/lib/init.hxx"
#include "lokinteractionhandler.hxx"
#include <lokclipboard.hxx>
using
namespace
css
;
using
namespace
vcl
;
...
...
@@ -247,6 +249,10 @@ static void doc_setTextSelection (LibreOfficeKitDocument* pThis,
static
char
*
doc_getTextSelection
(
LibreOfficeKitDocument
*
pThis
,
const
char
*
pMimeType
,
char
**
pUsedMimeType
);
static
bool
doc_paste
(
LibreOfficeKitDocument
*
pThis
,
const
char
*
pMimeType
,
const
char
*
pData
,
size_t
nSize
);
static
void
doc_setGraphicSelection
(
LibreOfficeKitDocument
*
pThis
,
int
nType
,
int
nX
,
...
...
@@ -287,6 +293,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass
->
postUnoCommand
=
doc_postUnoCommand
;
m_pDocumentClass
->
setTextSelection
=
doc_setTextSelection
;
m_pDocumentClass
->
getTextSelection
=
doc_getTextSelection
;
m_pDocumentClass
->
paste
=
doc_paste
;
m_pDocumentClass
->
setGraphicSelection
=
doc_setGraphicSelection
;
m_pDocumentClass
->
resetSelection
=
doc_resetSelection
;
m_pDocumentClass
->
getCommandValues
=
doc_getCommandValues
;
...
...
@@ -990,6 +997,37 @@ static char* doc_getTextSelection(LibreOfficeKitDocument* pThis, const char* pMi
return
pMemory
;
}
static
bool
doc_paste
(
LibreOfficeKitDocument
*
pThis
,
const
char
*
pMimeType
,
const
char
*
pData
,
size_t
nSize
)
{
ITiledRenderable
*
pDoc
=
getTiledRenderable
(
pThis
);
if
(
!
pDoc
)
{
gImpl
->
maLastExceptionMsg
=
"Document doesn't support tiled rendering"
;
return
false
;
}
uno
::
Reference
<
datatransfer
::
XTransferable
>
xTransferable
(
new
LOKTransferable
(
pMimeType
,
pData
,
nSize
));
uno
::
Reference
<
datatransfer
::
clipboard
::
XClipboard
>
xClipboard
(
new
LOKClipboard
());
xClipboard
->
setContents
(
xTransferable
,
uno
::
Reference
<
datatransfer
::
clipboard
::
XClipboardOwner
>
());
vcl
::
Window
*
pWindow
=
pDoc
->
getWindow
();
if
(
!
pWindow
)
{
gImpl
->
maLastExceptionMsg
=
"Document did not provide a window"
;
return
false
;
}
pWindow
->
SetClipboard
(
xClipboard
);
OUString
aCommand
(
".uno:Paste"
);
uno
::
Sequence
<
beans
::
PropertyValue
>
aPropertyValues
;
if
(
!
comphelper
::
dispatchCommand
(
aCommand
,
aPropertyValues
))
{
gImpl
->
maLastExceptionMsg
=
"Failed to dispatch the .uno: command"
;
return
false
;
}
return
true
;
}
static
void
doc_setGraphicSelection
(
LibreOfficeKitDocument
*
pThis
,
int
nType
,
int
nX
,
int
nY
)
{
ITiledRenderable
*
pDoc
=
getTiledRenderable
(
pThis
);
...
...
desktop/source/lib/lokclipboard.cxx
0 → 100644
Dosyayı görüntüle @
6552767a
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <lokclipboard.hxx>
#include <comphelper/sequence.hxx>
using
namespace
com
::
sun
::
star
;
uno
::
Reference
<
datatransfer
::
XTransferable
>
SAL_CALL
LOKClipboard
::
getContents
()
throw
(
uno
::
RuntimeException
,
std
::
exception
)
{
return
m_xTransferable
;
}
void
SAL_CALL
LOKClipboard
::
setContents
(
const
uno
::
Reference
<
datatransfer
::
XTransferable
>&
xTransferable
,
const
uno
::
Reference
<
datatransfer
::
clipboard
::
XClipboardOwner
>&
/*xClipboardOwner*/
)
throw
(
uno
::
RuntimeException
,
std
::
exception
)
{
m_xTransferable
=
xTransferable
;
}
OUString
SAL_CALL
LOKClipboard
::
getName
()
throw
(
uno
::
RuntimeException
,
std
::
exception
)
{
return
OUString
();
}
LOKTransferable
::
LOKTransferable
(
const
char
*
pMimeType
,
const
char
*
pData
,
size_t
nSize
)
:
m_aMimeType
(
pMimeType
),
m_aText
(
pData
,
nSize
)
{
}
uno
::
Any
SAL_CALL
LOKTransferable
::
getTransferData
(
const
datatransfer
::
DataFlavor
&
rFlavor
)
throw
(
datatransfer
::
UnsupportedFlavorException
,
io
::
IOException
,
uno
::
RuntimeException
,
std
::
exception
)
{
uno
::
Any
aRet
;
if
(
m_aMimeType
==
"text/plain;charset=utf-8"
&&
rFlavor
.
MimeType
==
"text/plain;charset=utf-16"
)
aRet
<<=
OStringToOUString
(
m_aText
,
RTL_TEXTENCODING_UTF8
);
return
aRet
;
}
std
::
vector
<
datatransfer
::
DataFlavor
>
LOKTransferable
::
getTransferDataFlavorsAsVector
()
{
std
::
vector
<
datatransfer
::
DataFlavor
>
aRet
;
datatransfer
::
DataFlavor
aFlavor
;
aFlavor
.
MimeType
=
OUString
::
fromUtf8
(
m_aMimeType
.
getStr
());
aFlavor
.
DataType
=
cppu
::
UnoType
<
uno
::
Sequence
<
sal_Int8
>
>::
get
();
sal_Int32
nIndex
(
0
);
if
(
m_aMimeType
.
getToken
(
0
,
';'
,
nIndex
)
==
"text/plain"
)
{
if
(
m_aMimeType
.
getToken
(
0
,
';'
,
nIndex
)
!=
"charset=utf-16"
)
aFlavor
.
MimeType
=
"text/plain;charset=utf-16"
;
aFlavor
.
DataType
=
cppu
::
UnoType
<
OUString
>::
get
();
}
aRet
.
push_back
(
aFlavor
);
return
aRet
;
}
uno
::
Sequence
<
datatransfer
::
DataFlavor
>
SAL_CALL
LOKTransferable
::
getTransferDataFlavors
()
throw
(
uno
::
RuntimeException
,
std
::
exception
)
{
return
comphelper
::
containerToSequence
(
getTransferDataFlavorsAsVector
());
}
sal_Bool
SAL_CALL
LOKTransferable
::
isDataFlavorSupported
(
const
datatransfer
::
DataFlavor
&
rFlavor
)
throw
(
uno
::
RuntimeException
,
std
::
exception
)
{
const
std
::
vector
<
datatransfer
::
DataFlavor
>
aFlavors
=
getTransferDataFlavorsAsVector
();
return
std
::
find_if
(
aFlavors
.
begin
(),
aFlavors
.
end
(),
[
&
rFlavor
](
const
datatransfer
::
DataFlavor
&
i
)
{
return
i
.
MimeType
==
rFlavor
.
MimeType
&&
i
.
DataType
==
rFlavor
.
DataType
;
})
!=
aFlavors
.
end
();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
desktop/source/lib/lokclipboard.hxx
0 → 100644
Dosyayı görüntüle @
6552767a
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX
#define INCLUDED_DESKTOP_SOURCE_LIB_LOKCLIPBOARD_HXX
#include <vector>
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
/// A clipboard implementation for LibreOfficeKit.
class
LOKClipboard
:
public
cppu
::
WeakImplHelper
<
css
::
datatransfer
::
clipboard
::
XClipboard
>
{
css
::
uno
::
Reference
<
css
::
datatransfer
::
XTransferable
>
m_xTransferable
;
public
:
virtual
css
::
uno
::
Reference
<
css
::
datatransfer
::
XTransferable
>
SAL_CALL
getContents
()
throw
(
css
::
uno
::
RuntimeException
,
std
::
exception
)
override
;
virtual
void
SAL_CALL
setContents
(
const
css
::
uno
::
Reference
<
css
::
datatransfer
::
XTransferable
>&
xTransferable
,
const
css
::
uno
::
Reference
<
css
::
datatransfer
::
clipboard
::
XClipboardOwner
>&
xClipboardOwner
)
throw
(
css
::
uno
::
RuntimeException
,
std
::
exception
)
override
;
virtual
OUString
SAL_CALL
getName
()
throw
(
css
::
uno
::
RuntimeException
,
std
::
exception
)
override
;
};
/// Represents the contents of LOKClipboard.
class
LOKTransferable
:
public
cppu
::
WeakImplHelper
<
css
::
datatransfer
::
XTransferable
>
{
OString
m_aMimeType
;
OString
m_aText
;
/// Provides a list of flavors, used by getTransferDataFlavors() and isDataFlavorSupported().
std
::
vector
<
css
::
datatransfer
::
DataFlavor
>
getTransferDataFlavorsAsVector
();
public
:
LOKTransferable
(
const
char
*
pMimeType
,
const
char
*
pData
,
size_t
nSize
);
virtual
css
::
uno
::
Any
SAL_CALL
getTransferData
(
const
css
::
datatransfer
::
DataFlavor
&
rFlavor
)
throw
(
css
::
datatransfer
::
UnsupportedFlavorException
,
css
::
io
::
IOException
,
css
::
uno
::
RuntimeException
,
std
::
exception
)
override
;
virtual
css
::
uno
::
Sequence
<
css
::
datatransfer
::
DataFlavor
>
SAL_CALL
getTransferDataFlavors
()
throw
(
css
::
uno
::
RuntimeException
,
std
::
exception
)
override
;
virtual
sal_Bool
SAL_CALL
isDataFlavorSupported
(
const
css
::
datatransfer
::
DataFlavor
&
rFlavor
)
throw
(
css
::
uno
::
RuntimeException
,
std
::
exception
)
override
;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
include/LibreOfficeKit/LibreOfficeKit.h
Dosyayı görüntüle @
6552767a
...
...
@@ -157,6 +157,12 @@ struct _LibreOfficeKitDocumentClass
const
char
*
pMimeType
,
char
**
pUsedMimeType
);
/// @see lok::Document::paste().
bool
(
*
paste
)
(
LibreOfficeKitDocument
*
pThis
,
const
char
*
pMimeType
,
const
char
*
pData
,
size_t
nSize
);
/// @see lok::Document::setGraphicSelection
void
(
*
setGraphicSelection
)
(
LibreOfficeKitDocument
*
pThis
,
int
nType
,
...
...
include/LibreOfficeKit/LibreOfficeKit.hxx
Dosyayı görüntüle @
6552767a
...
...
@@ -246,6 +246,18 @@ public:
return
mpDoc
->
pClass
->
getTextSelection
(
mpDoc
,
pMimeType
,
pUsedMimeType
);
}
/**
* Pastes content at the current cursor position.
*
* @param pMimeType format of pData, for example text/plain;charset=utf-8.
* @param pData the actual data to be pasted.
* @return if the supplied data was pasted successfully.
*/
inline
bool
paste
(
const
char
*
pMimeType
,
const
char
*
pData
,
size_t
nSize
)
{
return
mpDoc
->
pClass
->
paste
(
mpDoc
,
pMimeType
,
pData
,
nSize
);
}
/**
* Adjusts the graphic selection.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment