Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not copy folded grids to clipboard #591

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct Cell {
bool IsParentOf(const Cell *c) { return c->parent == this || (c->parent && IsParentOf(c->parent)); }

uint SwapColor(uint c) { return ((c & 0xFF) << 16) | (c & 0xFF00) | ((c & 0xFF0000) >> 16); }
wxString ToText(int indent, const Selection &s, int format, Document *doc, bool inheritstyle) {
wxString ToText(int indent, const Selection &s, int format, Document *doc, bool inheritstyle, bool includefolded) {
wxString str = text.ToText(indent, s, format);
if ((format == A_EXPHTMLT || format == A_EXPHTMLTI) && ((text.stylebits & STYLE_UNDERLINE) || (text.stylebits & STYLE_STRIKETHRU))
&& this != doc->curdrawroot && !str.IsEmpty()) {
Expand All @@ -219,13 +219,13 @@ struct Cell {
str.Append(L"</span>");
}
if (format == A_EXPCSV) {
if (grid) return grid->ToText(indent, s, format, doc, inheritstyle);
if (grid) return grid->ToText(indent, s, format, doc, inheritstyle, includefolded);
str.Replace(L"\"", L"\"\"");
return L"\"" + str + L"\"";
}
if (s.cursor != s.cursorend) return str;
str.Append(L"\n");
if (grid) str.Append(grid->ToText(indent, s, format, doc, inheritstyle));
if (grid) str.Append(grid->ToText(indent, s, format, doc, inheritstyle, includefolded));
if (format == A_EXPXML) {
str.Prepend(L">");
if (text.relsize) {
Expand Down
8 changes: 4 additions & 4 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ struct Document {

auto CopyEntireCells(wxString &s, int k) {
sys->clipboardcopy = s;
wxString html = selected.g->ConvertToText(selected, 0, k == A_COPYWI ? A_EXPHTMLTI : A_EXPHTMLT, this, false);
wxString html = selected.g->ConvertToText(selected, 0, k == A_COPYWI ? A_EXPHTMLTI : A_EXPHTMLT, this, false, false);
auto htmlobj = new wxHTMLDataObject(html);
return htmlobj;
}
Expand All @@ -432,7 +432,7 @@ struct Document {
dragdata.Add(new wxBitmapDataObject(bm));
}
} else {
wxString s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this, false);
wxString s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this, false, false);
dragdata.Add(new wxTextDataObject(s));
if (!selected.TextEdit()) {
auto htmlobj = CopyEntireCells(s, A_COPY);
Expand Down Expand Up @@ -471,7 +471,7 @@ struct Document {
}
} else {
wxDataObjectComposite *clipboarddata = new wxDataObjectComposite();
wxString s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this, false);
wxString s = selected.g->ConvertToText(selected, 0, A_EXPTEXT, this, false, false);
clipboarddata->Add(new wxTextDataObject(s));
if (!selected.TextEdit()) {
auto htmlobj = CopyEntireCells(s, k);
Expand Down Expand Up @@ -843,7 +843,7 @@ struct Document {
return _(L"Error writing to file!");
}
wxTextOutputStream dos(fos);
wxString content = root->ToText(0, Selection(), k, this, true);
wxString content = root->ToText(0, Selection(), k, this, true, true);
switch (k) {
case A_EXPXML:
dos.WriteString(
Expand Down
9 changes: 5 additions & 4 deletions src/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,12 @@ struct Grid {
}
}

wxString ToText(int indent, const Selection &s, int format, Document *doc, bool inheritstyle) {
return ConvertToText(SelectAll(), indent + 2, format, doc, inheritstyle);
wxString ToText(int indent, const Selection &s, int format, Document *doc, bool inheritstyle, bool includefolded) {
return ConvertToText(SelectAll(), indent + 2, format, doc, inheritstyle, includefolded);
};

wxString ConvertToText(const Selection &s, int indent, int format, Document *doc, bool inheritstyle) {
wxString ConvertToText(const Selection &s, int indent, int format, Document *doc, bool inheritstyle, bool includefolded) {
if (!includefolded && folded) return wxEmptyString;
wxString r;
const int root_grid_spacing = 2; // Can't be adjusted in editor, so use a default.
const int font_size = 14 - indent / 2;
Expand All @@ -618,7 +619,7 @@ struct Grid {
font_size).wc_str());
foreachcellinsel(c, s) {
if (x == s.x) Formatter(r, format, indent, L"<row>\n", L"<tr>\n", L"");
r.Append(c->ToText(indent, s, format, doc, inheritstyle));
r.Append(c->ToText(indent, s, format, doc, inheritstyle, includefolded));
if (format == A_EXPCSV) r.Append(x == s.x + s.xs - 1 ? '\n' : ',');
if (x == s.x + s.xs - 1) Formatter(r, format, indent, L"</row>\n", L"</tr>\n", L"");
}
Expand Down