Skip to content

Commit

Permalink
Same behavior for clipboard as for Drag and Drop operation (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiolo authored Sep 7, 2023
1 parent cc6d65d commit 8d4073d
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,19 @@ struct Document {
Refresh();
}

auto CopyEntireCells(wxString &s) {
sys->clipboardcopy = s;
wxString html = selected.g->ConvertToText(selected, 0, A_EXPHTMLT, this);
auto htmlobj =
#ifdef __WXGTK__
new wxCustomDataObject(wxDF_HTML);
htmlobj->SetData(html.Len(), html);
#else
new wxHTMLDataObject(html);
#endif
return htmlobj;
}

void Copy(int mode) {
Cell *c = selected.GetCell();
sys->clipboardcopy = wxEmptyString;
Expand All @@ -425,20 +438,12 @@ struct Document {
dragdata.Add(new wxBitmapDataObject(bm));
}
} else {
wxString s, html;
s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this);
html = selected.g->ConvertToText(selected, 0, A_EXPHTMLT, this);
if (!selected.TextEdit()) sys->clipboardcopy = s;

wxString s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this);
dragdata.Add(new wxTextDataObject(s));
auto *htmlobj =
#ifdef __WXGTK__
new wxCustomDataObject(wxDF_HTML);
htmlobj->SetData(html.Len(), html);
#else
new wxHTMLDataObject(html);
#endif
dragdata.Add(htmlobj);
if (!selected.TextEdit()) {
auto htmlobj = CopyEntireCells(s);
dragdata.Add(htmlobj);
}
}
wxDropSource dragsource(dragdata, sw);
dragsource.DoDragDrop(true);
Expand Down Expand Up @@ -474,15 +479,7 @@ struct Document {
wxString s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this);
clipboarddata->Add(new wxTextDataObject(s));
if (!selected.TextEdit()) {
sys->clipboardcopy = s;
wxString html = selected.g->ConvertToText(selected, 0, A_EXPHTMLT, this);
auto *htmlobj =
#ifdef __WXGTK__
new wxCustomDataObject(wxDF_HTML);
htmlobj->SetData(html.Len(), html);
#else
new wxHTMLDataObject(html);
#endif
auto htmlobj = CopyEntireCells(s);
clipboarddata->Add(htmlobj);
}
if (wxTheClipboard->Open()) {
Expand Down

0 comments on commit 8d4073d

Please sign in to comment.