-char *wxClipboard::GetClipboardData(char *format, long *length, long time)
-{
- if (clipOwner) {
- if (clipOwner->formats.Member(format))
- return clipOwner->GetData(format, length);
- else
- return NULL;
- } else if (cbString) {
- if (!strcmp(format, "TEXT"))
- return copystring(cbString);
- else
- return NULL;
- } else {
- if (wxOpenClipboard()) {
- receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
- length);
- wxCloseClipboard();
- } else
- receivedString = NULL;
-
- return receivedString;
+ for (size_t i = 0; i < data.GetFormatCount(); i++)
+ {
+ wxDataFormat format( array[i] );
+
+ wxLogTrace( TRACE_CLIPBOARD,
+ wxT("wxClipboard::GetData: requested format: %s"),
+ format.GetId().c_str() );
+
+ /* is data supported by clipboard ? */
+
+ /* store requested format to be asked for by callbacks */
+ m_targetRequested = format;
+
+ wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") );
+
+ m_formatSupported = FALSE;
+
+ /* perform query. this will set m_formatSupported to
+ TRUE if m_targetRequested is supported.
+ also, we have to wait for the "answer" from the
+ clipboard owner which is an asynchronous process.
+ therefore we set m_waiting = TRUE here and wait
+ until the callback "targets_selection_received"
+ sets it to FALSE */
+
+ m_waiting = TRUE;
+
+#if 0
+ gtk_selection_convert( m_targetsWidget,
+ m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY
+ : g_clipboardAtom,
+ g_targetsAtom,
+ (guint32) GDK_CURRENT_TIME );
+
+ while (m_waiting) gtk_main_iteration();
+#endif
+
+ if (!m_formatSupported) continue;
+
+ /* store pointer to data object to be filled up by callbacks */
+ m_receivedData = &data;
+
+ /* store requested format to be asked for by callbacks */
+ m_targetRequested = format;
+
+ wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") );
+
+ /* start query */
+ m_formatSupported = FALSE;
+
+ /* ask for clipboard contents. this will set
+ m_formatSupported to TRUE if m_targetRequested
+ is supported.
+ also, we have to wait for the "answer" from the
+ clipboard owner which is an asynchronous process.
+ therefore we set m_waiting = TRUE here and wait
+ until the callback "targets_selection_received"
+ sets it to FALSE */
+
+ m_waiting = TRUE;
+
+ wxLogTrace( TRACE_CLIPBOARD,
+ wxT("wxClipboard::GetData: format found, start convert") );
+
+#if 0
+ gtk_selection_convert( m_clipboardWidget,
+ m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY
+ : g_clipboardAtom,
+ m_targetRequested,
+ (guint32) GDK_CURRENT_TIME );
+
+ while (m_waiting) gtk_main_iteration();
+#endif
+
+ /* this is a true error as we checked for the presence of such data before */
+ wxCHECK_MSG( m_formatSupported, FALSE, wxT("error retrieving data from clipboard") );
+
+ /* return success */
+ delete[] array;
+ return TRUE;