[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Jun 18 05:57:26 PDT 2015
vcl/unx/gtk3/app/gtk3gtkinst.cxx | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
New commits:
commit a26d21acb34d6e35a12cf8afa3cc64701f384687
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jun 18 13:56:29 2015 +0100
gtk3: implement isDataFlavorSupported
Change-Id: Ia381d26a1c6a8f22aafef924215bc64b3c3473c6
diff --git a/vcl/unx/gtk3/app/gtk3gtkinst.cxx b/vcl/unx/gtk3/app/gtk3gtkinst.cxx
index cb26b26..0b5ea9f 100644
--- a/vcl/unx/gtk3/app/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/app/gtk3gtkinst.cxx
@@ -77,6 +77,19 @@ namespace
// PIXMAP
{ "PIXMAP", "image/bmp" }
};
+
+ class DataFlavorEq : public std::unary_function<const css::datatransfer::DataFlavor&, bool>
+ {
+ private:
+ const css::datatransfer::DataFlavor& m_rData;
+ public:
+ explicit DataFlavorEq(const css::datatransfer::DataFlavor& rData) : m_rData(rData) {}
+ bool operator() (const css::datatransfer::DataFlavor& rData) const
+ {
+ return rData.MimeType == m_rData.MimeType &&
+ rData.DataType == m_rData.DataType;
+ }
+ };
}
class GtkTransferable : public ::cppu::WeakImplHelper1 <
@@ -131,12 +144,12 @@ public:
return aRet;
}
- virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( )
- throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+ std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector()
{
+ std::vector<css::datatransfer::DataFlavor> aVector;
+
GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
- std::vector<css::datatransfer::DataFlavor> aVector;
GdkAtom *targets;
gint n_targets;
if (gtk_clipboard_wait_for_targets(clipboard, &targets, &n_targets))
@@ -195,16 +208,22 @@ public:
}
}
- return comphelper::containerToSequence(aVector);
+ return aVector;
+ }
+
+ virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors()
+ throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+ {
+ return comphelper::containerToSequence(getTransferDataFlavorsAsVector());
}
- virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor )
+ virtual sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor)
throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE
{
- fprintf(stderr, "TODO isDataFlavorSupported\n");
+ const std::vector<css::datatransfer::DataFlavor> aAll =
+ getTransferDataFlavorsAsVector();
- (void)aFlavor;
- return false;
+ return std::find_if(aAll.begin(), aAll.end(), DataFlavorEq(rFlavor)) != aAll.end();
}
};
More information about the Libreoffice-commits
mailing list