diff --git a/ctl/ctlSQLBox.cpp b/ctl/ctlSQLBox.cpp
index 78562b0..0825539 100644
--- a/ctl/ctlSQLBox.cpp
+++ b/ctl/ctlSQLBox.cpp
@@ -1293,66 +1293,70 @@ void ctlSQLBox::OnMarginClick(wxStyledTextEvent &event)
event.Skip();
}
+wxString ctlSQLBox::TextToHtml(int start, int end) {
+ wxColor frColor[40];
+ wxString str;
+ wxColour frc = settings->GetSQLBoxColourForeground();
+ wxString selText = GetTextRange(start,end);
+ if (settings->GetSQLBoxUseSystemForeground())
+ {
+ frc = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ }
+
+ for (int i = 0; i < 34; ++i)
+ {
+ frColor[i] = StyleGetForeground(i);
+ if (i > 0 && i < 12)
+ //StyleSetForeground(i, settings->GetSQLBoxColour(i));
+ frColor[i] = StyleGetForeground(i);
+ else
+ frColor[i] = frc;
+
+ //StyleSetBackground(i, bgColor);
+ //StyleSetFont(i, fntSQLBox);
+ }
+ //
+ int endp = end;
+ int startp = start;
+ wxString prevColor = wxEmptyString;
+ wxString tColor;
+ wxFont fntSQLBox = settings->GetSQLFont();
+ wxString fontName = fntSQLBox.GetFaceName();
+ wxString sz;
+ sz.Printf("%d", fntSQLBox.GetPixelSize().GetHeight());
+
+ str = wxT("
");
+ int k = 0;
+ int l = 1;
+ while (startp < endp) {
+ int st = GetStyleAt(startp);
+ if (st < 34) tColor = frColor[st].GetAsString(wxC2S_HTML_SYNTAX);
+ if (prevColor != tColor) {
+ str = str + wxT("");
+ prevColor = tColor;
+ }
+ //str.append(str[k].GetValue());
+ l = 1;
+ if (!selText[k].IsAscii()) l++;
+ int s = 0;
+ char c = selText[k].GetValue();
+ if (c == '\r') { startp = startp + l; k++; continue; };
+ if (c == '\n') { str += wxT("
"); startp = startp + l; k++; continue; };
+ if (c == 9) s = 5;
+ if (c == 32) s = 1;
+ if (s > 0) for (int tt = 0; tt < s; tt++) str += wxT(" ");
+ else str += selText[k];
+ startp = startp + l; k++;
+ }
+ str = str + wxT("
");
+ return str;
+}
void ctlSQLBox::Copy() {
wxString selText = GetSelectedText();
if (!selText.IsEmpty())
{
- wxColor frColor[40];
wxString str;
- wxColour frc = settings->GetSQLBoxColourForeground();
- if (settings->GetSQLBoxUseSystemForeground())
- {
- frc = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
- }
-
- for (int i = 0; i < 34; ++ i )
- {
- frColor[i]=StyleGetForeground(i);
- if (i > 0 && i < 12)
- //StyleSetForeground(i, settings->GetSQLBoxColour(i));
- frColor[i]=StyleGetForeground(i);
- else
- frColor[i]=frc;
-
- //StyleSetBackground(i, bgColor);
- //StyleSetFont(i, fntSQLBox);
- }
- //
- int endp=GetSelectionEnd();
- int startp=GetSelectionStart();
- wxString prevColor=wxEmptyString;
- wxString tColor;
- wxFont fntSQLBox = settings->GetSQLFont();
- wxString fontName = fntSQLBox.GetFaceName();
- wxString sz;
- sz.Printf("%d",fntSQLBox.GetPixelSize().GetHeight() );
-
- str=wxT("
");
- int k=0;
- int l=1;
- while (startp");
- prevColor=tColor;
- }
- //str.append(str[k].GetValue());
- l=1;
- if (!selText[k].IsAscii()) l++;
- int s=0;
- char c = selText[k].GetValue();
- if (c == '\r') { startp = startp + l; k++; continue; };
- if (c == '\n') { str += wxT("
"); startp = startp + l; k++; continue; };
- if (c==9) s=5;
- if (c==32) s=1;
- if (s>0) for (int tt=0;tt
");
-
-
+ str = TextToHtml(GetSelectionStart(), GetSelectionEnd());
if (wxTheClipboard->Open())
{
diff --git a/ctl/ctlSQLGrid.cpp b/ctl/ctlSQLGrid.cpp
index 1822c05..4a9a398 100644
--- a/ctl/ctlSQLGrid.cpp
+++ b/ctl/ctlSQLGrid.cpp
@@ -21,6 +21,7 @@
#include "frm/frmExport.h"
#include
#include "ctl/ctlSQLResult.h"
+#include "utils/misc.h"
#define EXTRAEXTENT_HEIGHT 6
#define EXTRAEXTENT_WIDTH 6
@@ -390,6 +391,72 @@ void selMerge::setArrayColumns(int row, wxArrayInt& columns) {
columns.Add(k);
}
};
+int ctlSQLGrid::CopyTableToHtml(wxString htmlquery) {
+ wxString htm = ""
+ ""
+ "\n"
+ "";
+
+ htm += htmlquery;
+ htm += "
";
+// AppendColumnHeader(str, cols);
+ htm += head;
+ for (int i = 0; i < numRows; i++)
+ {
+ if (GetRowSize(i) == 0) continue;
+ htm+= "\n";
+ htm += wxString::Format("%d | ",i+1);
+ for (int c = 0; c < cols.Count(); c++) {
+ wxString text = GetCellValue(i, cols[c]);
+ htm += wxString::Format("%s | ", c, escapeHtml(text,true));
+ }
+ htm += "
\n";
+ //wxString cname = GetColumnName(cols[c]);
+
+ }
+ htm += "
";
+ }
+ else {
+ htm += ""+ htmlquery+"";
+ }
+ if (wxTheClipboard->Open())
+ {
+ wxDataObjectComposite* dataobj = new wxDataObjectComposite();
+ dataobj->Add(new wxTextDataObject(htm));
+ dataobj->Add(new wxHTMLDataObject(htm));
+ wxTheClipboard->SetData(dataobj);
+ wxTheClipboard->Close();
+ }
+ return 0;
+}
int ctlSQLGrid::Copy(int gensql)
{
wxString str,tmp,linedelim="";
diff --git a/frm/frmLog.cpp b/frm/frmLog.cpp
index bc044b5..48e2680 100644
--- a/frm/frmLog.cpp
+++ b/frm/frmLog.cpp
@@ -24,6 +24,7 @@
#include "utils/csvfiles.h"
#include "log/StorageModel.h"
#include "utils/utffile.h"
+#include "utils/misc.h"
#include
#ifdef WIN32
@@ -113,13 +114,6 @@ void frmLog::OnChangeSmart(wxCommandEvent& event) {
my_view->ModUserFilter("", "ChangeFilter", listUserFilter, contentFilter);
}
}
-wxString escapeHtml(wxString text) {
- text.Replace("&", "&");
- text.Replace("<", "<");
- text.Replace(">", ">");
- text.Replace("\n", "¶
");
- return text;
-}
void frmLog::OnSendMail(wxCommandEvent& event) {
//wxMessageBox("send mail");
wxDataViewItem item;
@@ -163,8 +157,8 @@ void frmLog::OnSendMail(wxCommandEvent& event) {
wxString r;
for (int i = 0; i < a.Count(); i++) {
templat = l;
- le = escapeHtml(a[i++]);
- r = escapeHtml(a[i]);
+ le = escapeHtml(a[i++],false);
+ r = escapeHtml(a[i],false);
int co = templat.Replace("$1", le);
co += templat.Replace("$2", r);
html.Append(templat);
diff --git a/frm/frmQuery.cpp b/frm/frmQuery.cpp
index 7b73a75..b87d572 100644
--- a/frm/frmQuery.cpp
+++ b/frm/frmQuery.cpp
@@ -122,6 +122,7 @@ BEGIN_EVENT_TABLE(frmQuery, pgFrame)
EVT_MENU(MNU_COPY_INSERT, frmQuery::OnCopy_Insert)
EVT_MENU(MNU_COPY_INLIST, frmQuery::OnCopy_InList)
EVT_MENU(MNU_COPY_WHERELIST, frmQuery::OnCopy_WhereList)
+ EVT_MENU(MNU_COPY_TABLEHTML, frmQuery::OnCopy_TableToHtml)
EVT_MENU(MNU_CLEAR_FILTER, frmQuery::OnClear_Filter)
EVT_MENU(MNU_CHECK_COLUMN_DATE, frmQuery::OnCheck_Column_Date)
EVT_MENU(MNU_COPY_LISTCOLTYPE, frmQuery::OnCopy_NameTypeCols)
@@ -1695,10 +1696,14 @@ void frmQuery::OnCopy(wxCommandEvent &ev)
{
wxWindow *wnd = currentControl();
- if (wnd == sqlQuery)
+ if (wnd == sqlQuery) {
sqlQuery->Copy();
- else if (wnd == msgResult)
+ SetStatusText("Select query copy.", STATUSPOS_MSGS);
+ }
+ else if (wnd == msgResult) {
msgResult->Copy();
+ SetStatusText("select msgResult copy.", STATUSPOS_MSGS);
+ }
else if (wnd == msgHistory)
msgHistory->Copy();
else if (wnd == scratchPad)
@@ -1712,6 +1717,7 @@ void frmQuery::OnCopy(wxCommandEvent &ev)
if (obj == sqlResult)
{
sqlResult->Copy(0);
+ SetStatusText("Result query copy.", STATUSPOS_MSGS);
break;
}
obj = obj->GetParent();
@@ -2182,6 +2188,7 @@ void frmQuery::OnLabelRightClick(wxGridEvent &event)
xmenu->Append(MNU_COPY_LISTCOLTYPE, _("List columns header"), _("Copy list columns header"));
xmenu->Append(MNU_COPY_INLIST, _("IN list format copy"), _("Copy In list format."));
xmenu->Append(MNU_COPY_WHERELIST, _("WHERE list format copy"), _("Copy where list format."));
+ xmenu->Append(MNU_COPY_TABLEHTML, _("Copy table html format"), _("Copy table html format."));
xmenu->AppendSeparator();
xmenu->Append(MNU_AUTOCOLSPLOT, _("Draw plot LY(bar) or LXY or XYYY..."), _("Draw plot LY(bar) LXY or XYYY..."));
xmenu->Append(MNU_SUMMARY_COL, _("Summary"), _("Summary selected cells."));
@@ -2190,6 +2197,7 @@ void frmQuery::OnLabelRightClick(wxGridEvent &event)
bool selcol = sqlResult->GetSelectedCols().GetCount() > 0;
xmenu->Enable(MNU_CHECK_COLUMN_DATE, selcol);
xmenu->Enable(MNU_COPY_LISTCOLTYPE, selcol);
+ xmenu->Enable(MNU_COPY_TABLEHTML, selcol);
xmenu->Enable(MNU_AUTOCOLSPLOT, sqlResult->IsSelection());
xmenu->Enable(MNU_SUMMARY_COL, sqlResult->IsSelection());
xmenu->Enable(MNU_COPY_INLIST, sqlResult->IsSelection());
@@ -2239,6 +2247,23 @@ void frmQuery::OnCopy_WhereList(wxCommandEvent& ev)
SetStatusText(s, STATUSPOS_MSGS);
}
}
+void frmQuery::OnCopy_TableToHtml(wxCommandEvent& ev)
+{
+ // if (currentControl() == sqlResult)
+ {
+ wxString s = wxT("Table html format copy buffer.");
+ wxString q = sqlResult->sqlquerytext;
+ if (q.IsEmpty()) return;
+ ctlSQLBox *box = new ctlSQLBox(sqlNotebook, CTL_SQLQUERY, wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE | wxTE_RICH2);
+ box->SetText(q);
+ box->Colourise(0, box->GetTextLength());
+ wxString html = box->TextToHtml(0, box->GetTextLength());
+ delete box;
+ sqlResult->CopyTableToHtml(html);
+
+ SetStatusText(s, STATUSPOS_MSGS);
+ }
+}
void frmQuery::OnCellLeftDClick(wxGridEvent &event)
{
int row=event.GetRow();
diff --git a/include/ctl/ctlSQLBox.h b/include/ctl/ctlSQLBox.h
index 94c9ef7..94c61c4 100644
--- a/include/ctl/ctlSQLBox.h
+++ b/include/ctl/ctlSQLBox.h
@@ -51,6 +51,7 @@ public:
void Create(wxWindow *parent, wxWindowID id = -1, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0);
void HighlightBrace(int lb, int rb);
void SetDatabase(pgConn *db);
+ wxString TextToHtml(int start, int end);
void Copy();
void OnKeyDown(wxKeyEvent &event);
void OnAutoComplete(wxCommandEvent &event);
diff --git a/include/ctl/ctlSQLGrid.h b/include/ctl/ctlSQLGrid.h
index 249185c..299a2a7 100644
--- a/include/ctl/ctlSQLGrid.h
+++ b/include/ctl/ctlSQLGrid.h
@@ -30,6 +30,7 @@ public:
{
return false;
}
+ int CopyTableToHtml(wxString htmlquery);
int Copy(int gensql);
virtual bool CheckRowPresent(int row)
diff --git a/include/frm/frmQuery.h b/include/frm/frmQuery.h
index 3283e7a..62f23b0 100644
--- a/include/frm/frmQuery.h
+++ b/include/frm/frmQuery.h
@@ -217,6 +217,7 @@ private:
void OnCopy_Insert(wxCommandEvent &event);
void OnCopy_InList(wxCommandEvent& event);
void OnCopy_WhereList(wxCommandEvent& event);
+ void OnCopy_TableToHtml(wxCommandEvent& ev);
void OnClear_Filter(wxCommandEvent &event);
void OnCopy_NameTypeCols(wxCommandEvent& ev);
void OnCheck_Column_Date(wxCommandEvent& ev);
diff --git a/include/frm/menu.h b/include/frm/menu.h
index bb1b093..d4491c8 100644
--- a/include/frm/menu.h
+++ b/include/frm/menu.h
@@ -80,6 +80,7 @@ enum
MNU_COPY_INLIST,
MNU_COPY_LISTCOLTYPE,
MNU_COPY_WHERELIST,
+ MNU_COPY_TABLEHTML,
MNU_CLEAR_FILTER,
MNU_CHECK_COLUMN_DATE,
MNU_AUTOCOLSPLOT,
diff --git a/include/utils/misc.h b/include/utils/misc.h
index d3d8926..fcf881a 100644
--- a/include/utils/misc.h
+++ b/include/utils/misc.h
@@ -100,6 +100,7 @@ extern sysSettings *settings;
// Conversions
wxString BoolToStr(bool value); // english; used for config values
wxString DateToAnsiStr(const wxDateTime &datetime);
+wxString escapeHtml(wxString text, bool pre);
bool StrToBool(const wxString &value); // english
long StrToLong(const wxString &value);
diff --git a/utils/misc.cpp b/utils/misc.cpp
index 66b5276..f7d1e59 100644
--- a/utils/misc.cpp
+++ b/utils/misc.cpp
@@ -85,6 +85,13 @@ wxString BoolToStr(bool value)
return value ? wxT("true") : wxT("false");
}
+wxString escapeHtml(wxString text, bool pre) {
+ text.Replace("&", "&");
+ text.Replace("<", "<");
+ text.Replace(">", ">");
+ if (!pre) text.Replace("\n", "¶
");
+ return text;
+}
bool StrToBool(const wxString &value)
diff --git a/x64/Release_(3.0)/pgAdmin3.exe b/x64/Release_(3.0)/pgAdmin3.exe
index 8bb55dc..23e9631 100644
Binary files a/x64/Release_(3.0)/pgAdmin3.exe and b/x64/Release_(3.0)/pgAdmin3.exe differ