diff --git a/src/cell.h b/src/cell.h index 18ba9269..f9e61cf8 100755 --- a/src/cell.h +++ b/src/cell.h @@ -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()) { @@ -219,13 +219,13 @@ struct Cell { str.Append(L""); } 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) { diff --git a/src/document.h b/src/document.h index e5b35410..84ea368a 100755 --- a/src/document.h +++ b/src/document.h @@ -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; } @@ -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); @@ -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); @@ -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( diff --git a/src/grid.h b/src/grid.h index 95189c7d..708df548 100755 --- a/src/grid.h +++ b/src/grid.h @@ -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; @@ -618,7 +619,7 @@ struct Grid { font_size).wc_str()); foreachcellinsel(c, s) { if (x == s.x) Formatter(r, format, indent, L"\n", L"\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"\n", L"\n", L""); }