X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcommon%2Ftextprocessing.cpp;h=2a6159109870d8df225813a6692a01bf616b523b;hb=5e38e618bf727f602379725148dd8e2a1d9132d1;hp=ba4f7d9cf79d134d9a51e74efe5331697306fc9b;hpb=45729fca56479bd9158486e0cda0c4a94b4dd1dc;p=xestiaab%2F.git diff --git a/source/common/textprocessing.cpp b/source/common/textprocessing.cpp index ba4f7d9..2a61591 100644 --- a/source/common/textprocessing.cpp +++ b/source/common/textprocessing.cpp @@ -1,3 +1,21 @@ +// textprocessing.cpp - Text processing subroutines. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see + #include #include #include @@ -8,6 +26,8 @@ void EscapeString(wxString *ReceivedString, bool StripQuotes) { + // Escape a string that contains escapable characters. + ReceivedString->Replace(wxT("\\"), wxT("\\\\"), TRUE); ReceivedString->Replace(wxT(","), wxT("\\,"), TRUE); ReceivedString->Replace(wxT(";"), wxT("\\;"), TRUE); @@ -25,6 +45,8 @@ void EscapeString(wxString *ReceivedString, bool StripQuotes) void GetEscapeString(wxTextCtrl *TextCtrl, wxString *ProcessString, bool StripQuotes) { + // Get an escaped string from a wxTextCtrl. + *ProcessString = TextCtrl->GetValue(); EscapeString(ProcessString, StripQuotes); @@ -33,6 +55,8 @@ void GetEscapeString(wxTextCtrl *TextCtrl, wxString *ProcessString, bool StripQu void GetEscapeString(wxComboBox *ComboCtrl, wxString *ProcessString, bool StripQuotes) { + // Get an escaped string from a wxComboBox. + *ProcessString = ComboCtrl->GetValue(); EscapeString(ProcessString, StripQuotes); @@ -41,6 +65,8 @@ void GetEscapeString(wxComboBox *ComboCtrl, wxString *ProcessString, bool StripQ void GetEscapeString(wxChoice *ChoiceCtrl, wxString *ProcessString, bool StripQuotes) { + // Get an escaped string from a wxChoice. + *ProcessString = ChoiceCtrl->GetString(ChoiceCtrl->GetSelection()); EscapeString(ProcessString, StripQuotes); @@ -49,6 +75,8 @@ void GetEscapeString(wxChoice *ChoiceCtrl, wxString *ProcessString, bool StripQu void CaptureString(wxString *ProcessString, bool StripQuotes) { + // Capture a string for processing. + ProcessString->Replace(wxT("\\n"), wxT("\n"), TRUE); ProcessString->Replace(wxT("\\;"), wxT(";"), TRUE); ProcessString->Replace(wxT("\\,"), wxT(","), TRUE); @@ -62,9 +90,24 @@ void CaptureString(wxString *ProcessString, bool StripQuotes) } +void ResetUnusedString(wxString *ProcessString) +{ + + // Reset an unused string. + + ProcessString->Replace(wxT("\\\\"), wxT("\\"), TRUE); + ProcessString->Replace(wxT("\\n"), wxT("\n"), TRUE); + ProcessString->Replace(wxT("\\;"), wxT(";"), TRUE); + ProcessString->Replace(wxT("\\,"), wxT(","), TRUE); + +} + void ConvertToHTML(wxString *ProcessString) { + // Convert string into text that can be used with a + // wxHTMLWindow. + ProcessString->Replace(wxT("&"), wxT("&"), TRUE); ProcessString->Replace(wxT("<"), wxT("<"), TRUE); ProcessString->Replace(wxT(">"), wxT(">"), TRUE); @@ -73,33 +116,105 @@ void ConvertToHTML(wxString *ProcessString) } void DeleteMapDataProcess(int IndexNum, std::map* MapData){ + + // Delete map data (for map). + MapData->erase(IndexNum); + } void DeleteMapDataProcess(int IndexNum, std::map* MapData){ + + // Delete map data (for map). + MapData->erase(IndexNum); + } void DeleteMapDataProcess(int IndexNum, std::map* MapData){ + + // Delete map data (for map). + MapData->erase(IndexNum); + } void DeleteMapDataProcess(int IndexNum, std::map* MapData){ + + // Delete map data (for map). + MapData->erase(IndexNum); + } -/* -template -void DeleteMapData(ArgMap* ArgMapPtr, Args*... ArgsList){ +bool MapDataExists(int *ItemIndex, std::map *MapPtr){ - //DeleteMapDataProcess(ArgMapPtr); - - DeleteMapData(ArgsList...); + // Check if map data exists (for map). + + if (MapPtr->find(*ItemIndex) == MapPtr->end()){ + + return FALSE; + + } else { + + return TRUE; + + } } -*/ -/* -void test(int* x) { + +bool MapDataExists(int *ItemIndex, std::map *MapPtr){ + + // Check if map data exists (for map). + + if (MapPtr->find(*ItemIndex) == MapPtr->end()){ + + return FALSE; + + } else { + + return TRUE; + + } } -*/ \ No newline at end of file + +wxString OutputText(wxString *TextInput){ + + wxString OutputTextData; + wxString OutputLine; + int CharSeek = 0; + int LineSeek = 0; + int MaxLineSeek = 77; + + for (CharSeek = 0; CharSeek < TextInput->size(); CharSeek++){ + + LineSeek++; + + if (LineSeek == MaxLineSeek){ + + if (TextInput->substr(CharSeek, 1) != "\n"){ + OutputLine += TextInput->substr(CharSeek, 1); + } + OutputLine += "\n"; + OutputTextData += OutputLine; + OutputLine = " "; + LineSeek = 0; + MaxLineSeek = 76; + continue; + + } + + OutputLine += TextInput->substr(CharSeek, 1); + + } + + if (OutputLine != " " && OutputLine != " \n"){ + + OutputTextData += OutputLine; + + } + + return OutputTextData; + +} \ No newline at end of file