From 977b867e72fe5c836d5af43ac087c943afc463f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 16 Jul 2004 17:19:17 +0000 Subject: [PATCH] added wxHtmlWindow::ToText git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28261 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/html/htmlwin.h | 7 ++++++- src/html/htmlwin.cpp | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index c455fdde06..2560670927 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -253,13 +253,18 @@ protected: #if wxUSE_CLIPBOARD // Convert selection to text: - wxString SelectionToText(); + wxString SelectionToText() { return DoSelectionToText(m_selection); } + + // Converts current page to text: + wxString ToText(); // Automatic scrolling during selection: void StopAutoScrolling(); #endif // wxUSE_CLIPBOARD protected: + wxString DoSelectionToText(wxHtmlSelection *sel); + // This is pointer to the first cell in parsed data. (Note: the first cell // is usually top one = all other cells are sub-cells of this one) wxHtmlContainerCell *m_Cell; diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index 8e988da39e..85a1662126 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -728,19 +728,19 @@ bool wxHtmlWindow::IsSelectionEnabled() const #if wxUSE_CLIPBOARD -wxString wxHtmlWindow::SelectionToText() +wxString wxHtmlWindow::DoSelectionToText(wxHtmlSelection *sel) { - if ( !m_selection ) + if ( !sel ) return wxEmptyString; wxClientDC dc(this); - const wxHtmlCell *end = m_selection->GetToCell(); + const wxHtmlCell *end = sel->GetToCell(); wxString text; - wxHtmlTerminalCellsInterator i(m_selection->GetFromCell(), end); + wxHtmlTerminalCellsInterator i(sel->GetFromCell(), end); if ( i ) { - text << i->ConvertToText(m_selection); + text << i->ConvertToText(sel); ++i; } const wxHtmlCell *prev = *i; @@ -748,13 +748,25 @@ wxString wxHtmlWindow::SelectionToText() { if ( prev->GetParent() != i->GetParent() ) text << _T('\n'); - text << i->ConvertToText(*i == end ? m_selection : NULL); + text << i->ConvertToText(*i == end ? sel : NULL); prev = *i; ++i; } return text; } +wxString wxHtmlWindow::ToText() +{ + if (m_Cell) + { + wxHtmlSelection sel; + sel.Set(m_Cell->GetFirstTerminal(), m_Cell->GetLastTerminal()); + return DoSelectionToText(&sel); + } + else + return wxEmptyString; +} + #endif // wxUSE_CLIPBOARD bool wxHtmlWindow::CopySelection(ClipboardType t) -- 2.45.2