Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

Commit

Permalink
BUGFIX (#65): Raporter3's template encoding issue
Browse files Browse the repository at this point in the history
+ parameter lists (.xpl) are now always saved in UTF-8 encoding.

+ name field in template create/edit window is filtered and allows only
alphanumeric characters.

+ template filenames are transliterated to remove any diacritics.

+ added .gitignore for 'iks-server'.
  • Loading branch information
Tomasz Pieczerak committed Jun 25, 2014
1 parent d861ef5 commit 1f270e5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions iks/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iks-server
5 changes: 1 addition & 4 deletions wx/common/parlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,8 @@ bool szParList::SaveFile(wxString path, bool showErrors)
}
}
}
#ifdef MINGW32
int ret = xmlSaveFormatFileEnc(SC::S2A(path.c_str()).c_str(), xml, "CP1250", 1);
#else

int ret = xmlSaveFormatFileEnc(SC::S2A(path.c_str()).c_str(), xml, "UTF-8", 1);
#endif
if (ret == -1) {
if (showErrors) {
wxLogError(wxString::Format(_("Error saving document %s\nError %d: %s"),
Expand Down
2 changes: 1 addition & 1 deletion wx/raporter3/pl/raporter3.po
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ msgid "Raporter - help"
msgstr "Raporter - pomoc"

#: raporteredit.cc:62
msgid "Tile"
msgid "Title"
msgstr "Tytu³"

#: raporteredit.cc:65
Expand Down
4 changes: 2 additions & 2 deletions wx/raporter3/raporteredit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ szRaporterEdit::szRaporterEdit(TSzarpConfig *_ipk,

wxBoxSizer *top_sizer = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer *desc_sizer = new wxStaticBoxSizer(
new wxStaticBox(this, wxID_ANY, _("Tile")),
new wxStaticBox(this, wxID_ANY, _("Title")),
wxVERTICAL);

desc_sizer->Add(m_title = new wxTextCtrl(this, ID_T_TITLE, _("User report"),
wxDefaultPosition, wxDefaultSize, 0,
wxTextValidator(wxFILTER_NONE, &g_data.m_report_name)),
wxTextValidator(wxFILTER_ALPHANUMERIC, &g_data.m_report_name)),
0, wxEXPAND | wxALL, 8);

wxStaticBoxSizer *rcont_sizer = new wxStaticBoxSizer(
Expand Down
31 changes: 23 additions & 8 deletions wx/raporter3/userreports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ bool UserReports::CheckFile(wxString filename)
if (parlist.GetConfigName().Cmp(m_config) != 0) {
return false;
}
if (parlist.GetExtraRootProp(SZ_REPORTS_NS_URI, _T("title")).Cmp(filename) != 0) {
if (wxString(SC::S2A(
parlist.GetExtraRootProp(SZ_REPORTS_NS_URI, _T("title")).wc_str()
).c_str(),
wxConvUTF8
).Cmp(filename) != 0)
{
return false;
}
return true;
Expand All @@ -58,28 +63,31 @@ bool UserReports::CheckFile(wxString filename)
wxString UserReports::SaveTemplate(wxString name, szParList parlist)
{
wxString err;
wxString cname(SC::S2A(name.wc_str()).c_str(), wxConvUTF8);

err = CreateDir();
if (!err.IsEmpty()) {
return err;
}
parlist.AddNs(_T("rap"), SZ_REPORTS_NS_URI);
parlist.SetExtraRootProp(SZ_REPORTS_NS_URI, _T("title"), name);
wxFileName path = wxFileName(m_dir.GetFullPath(), name + _T(".xpl"));
wxFileName path = wxFileName(m_dir.GetFullPath(), cname + _T(".xpl"));
if (!parlist.SaveFile(path.GetFullPath().c_str())) {
return wxString(_("Error saving file: ")) + path.GetFullPath();
}
if (m_list.Index(name) == wxNOT_FOUND) {
m_list.Add(name);
if (m_list.Index(cname) == wxNOT_FOUND) {
m_list.Add(cname);
}
return wxEmptyString;
}

void UserReports::RemoveTemplate(wxString name)
{
int i = m_list.Index(name);
wxString cname(SC::S2A(name.wc_str()).c_str(), wxConvUTF8);
int i = m_list.Index(cname);
assert (i != wxNOT_FOUND);
m_list.RemoveAt(i);
wxFileName path = wxFileName(m_dir.GetFullPath(), name + _T(".xpl"));
wxFileName path = wxFileName(m_dir.GetFullPath(), cname + _T(".xpl"));
wxRemoveFile(path.GetFullPath());
}

Expand Down Expand Up @@ -108,15 +116,22 @@ void UserReports::RefreshList(wxString config)

wxString UserReports::GetTemplatePath(wxString name)
{
return m_dir.GetFullPath() + wxFileName::GetPathSeparator() + name + _T(".xpl");
wxString cname(SC::S2A(name.wc_str()).c_str(), wxConvUTF8);
return m_dir.GetFullPath() + wxFileName::GetPathSeparator() + cname + _T(".xpl");
}

bool UserReports::FindTemplate(wxString name, wxString& config)
{
szParList parlist;
if (parlist.LoadFile(GetTemplatePath(name), false) <= 0)
return false;
if (parlist.GetExtraRootProp(SZ_REPORTS_NS_URI, _T("title")).Cmp(name) != 0) {

if (wxString(SC::S2A(
parlist.GetExtraRootProp(SZ_REPORTS_NS_URI, _T("title")).wc_str()
).c_str(),
wxConvUTF8
).Cmp(name) != 0)
{
return false;
}

Expand Down

0 comments on commit 1f270e5

Please sign in to comment.