void CFindDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFindDlg) DDX_Control(pDX, IDC_FIND_WHAT, m_ctlFindText); DDX_Check(pDX, IDC_MATCH_CASE, m_bMatchCase); DDX_Radio(pDX, IDC_FIND_UP, m_bForwards); DDX_Check(pDX, IDC_REGEXP, m_bRegexp); DDX_CBString(pDX, IDC_FIND_WHAT, m_strFindText); //}}AFX_DATA_MAP if(pDX->m_bSaveAndValidate) { if (m_strFindText.IsEmpty ()) { ::TMessageBox("You must specify something to search for."); DDX_Text(pDX, IDC_FIND_WHAT, m_strFindText); pDX->Fail(); } // compile regular expression to check it if (m_bRegexp) { if (!CheckRegularExpression (m_strFindText, 0)) { // failed check DDX_Text(pDX, IDC_FIND_WHAT, m_strFindText); pDX->Fail(); } } // end of checking regular expression } // end of saving and validating }
void CMultiLineTriggerDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMultiLineTriggerDlg) DDX_Control(pDX, IDC_TRIGGER_TEXT, m_ctlTriggerText); DDX_Text(pDX, IDC_TRIGGER_TEXT, m_strTriggerText); DDX_Check(pDX, IDC_MATCH_CASE, m_bMatchCase); //}}AFX_DATA_MAP if(pDX->m_bSaveAndValidate) { // can't make an empty trigger if (m_strTriggerText.IsEmpty ()) { ::TMessageBox("The trigger match text cannot be empty.", MB_ICONSTOP); DDX_Text(pDX, IDC_TRIGGER_TEXT, m_strTriggerText); pDX->Fail(); } // end of text being blank int iCount = 1; const char * p; for (p = m_strTriggerText; *p; p++) if (*p == '\n') iCount++; if (iCount < 1) { ::TMessageBox("Multi-line triggers must match at least 2 lines.", MB_ICONSTOP); DDX_Text(pDX, IDC_TRIGGER_TEXT, m_strTriggerText); pDX->Fail(); } // end of text being blank if (iCount > MAX_RECENT_LINES) { ::UMessageBox( TFormat ("Multi-line triggers can match a maximum of %i lines.", MAX_RECENT_LINES), MB_ICONSTOP); DDX_Text(pDX, IDC_TRIGGER_TEXT, m_strTriggerText); pDX->Fail(); } // end of text being blank CString strText = ::Replace (m_strTriggerText, ENDLINE, "\\n"); // check they haven't put crap into the regular expression if (!CheckRegularExpression (strText, PCRE_MULTILINE)) { // failed check DDX_Text(pDX, IDC_TRIGGER_TEXT, m_strTriggerText); pDX->Fail(); } } // end of save and validate else FixFont (m_font, m_ctlTriggerText, "Courier New", 9, FW_NORMAL, DEFAULT_CHARSET); }
void CAliasDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); if(!pDX->m_bSaveAndValidate) { if (m_current_alias && m_current_alias->bIncluded) m_strIncluded = "(included)"; else m_strIncluded.Empty (); } //{{AFX_DATA_MAP(CAliasDlg) DDX_Control(pDX, IDC_SEND_TO, m_ctlSendTo); DDX_Control(pDX, IDC_VARIABLE, m_ctlVariable); DDX_Control(pDX, IDC_REGEXP, m_ctlRegexp); DDX_Control(pDX, IDC_ALIAS_CONTENTS, m_ctlAliasContents); DDX_Control(pDX, IDC_ALIAS_NAME, m_ctlAliasName); DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents); DDX_Text(pDX, IDC_ALIAS_NAME, m_name); DDX_Text(pDX, IDC_ALIAS_LABEL, m_strLabel); DDX_Check(pDX, IDC_ENABLED, m_bEnabled); DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure); DDX_Check(pDX, IDC_IGNORE_CASE, m_bIgnoreCase); DDX_Check(pDX, IDC_EXPAND_VARIABLES, m_bExpandVariables); DDX_Check(pDX, IDC_OMIT_FROM_LOG, m_bOmitFromLogFile); DDX_Check(pDX, IDC_REGEXP, m_bRegexp); DDX_Check(pDX, IDC_OMIT_FROM_OUTPUT, m_bOmitFromOutput); DDX_Check(pDX, IDC_ALIAS_MENU, m_bMenu); DDX_Check(pDX, IDC_TEMPORARY_ALIAS, m_bTemporary); DDX_Text(pDX, IDC_GROUP, m_strGroup); DDX_Text(pDX, IDC_VARIABLE, m_strVariable); DDX_CBIndex(pDX, IDC_SEND_TO, m_iSendTo); DDX_Check(pDX, IDC_KEEP_EVALUATING, m_bKeepEvaluating); DDX_Text(pDX, IDC_SEQUENCE, m_iSequence); DDV_MinMaxInt(pDX, m_iSequence, 0, 10000); DDX_Check(pDX, IDC_ECHO_ALIAS, m_bEchoAlias); DDX_Check(pDX, IDC_OMIT_FROM_COMMAND_HISTORY, m_bOmitFromCommandHistory); DDX_Text(pDX, IDC_INCLUDED, m_strIncluded); DDX_Text(pDX, IDC_REGEXP_ERROR, m_strRegexpError); DDX_Check(pDX, IDC_ONE_SHOT, m_bOneShot); //}}AFX_DATA_MAP if(pDX->m_bSaveAndValidate) { POSITION pos; CAlias * alias_item; m_strLabel.TrimLeft (); m_strLabel.TrimRight (); m_strProcedure.TrimLeft (); m_strProcedure.TrimRight (); m_strGroup.TrimLeft (); m_strGroup.TrimRight (); m_strVariable.TrimLeft (); m_strVariable.TrimRight (); if (m_name.IsEmpty ()) { ::TMessageBox("The alias cannot be blank."); DDX_Text(pDX, IDC_ALIAS_NAME, m_name); pDX->Fail(); } // end of alias being blank // check for foolishly using ** in a non-regular expression if (m_name.Find ("**") != -1 && !m_bRegexp) { CCreditsDlg dlg; dlg.m_iResourceID = IDR_MULTIPLE_ASTERISKS; dlg.m_strTitle = "Warning"; dlg.DoModal (); DDX_Text(pDX, IDC_ALIAS_NAME, m_name); pDX->Fail(); } int iInvalidPos = m_name.FindOneOf ("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"); if (iInvalidPos != -1) { char c = m_name [iInvalidPos]; ::UMessageBox(TFormat ( "The alias 'match' text contains an invalid non-printable character (hex %02X) at position %i.", c, iInvalidPos + 1), MB_ICONSTOP); DDX_Text(pDX, IDC_ALIAS_NAME, m_name); pDX->Fail(); } // end of alias match having weird characters in it // we allow carriage-return, linefeed, tab here iInvalidPos = m_contents.FindOneOf ("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F"); if (iInvalidPos != -1) { char c = m_contents [iInvalidPos]; ::UMessageBox(TFormat ( "The alias 'send' text contains an invalid non-printable character (hex %02X) at position %i.", c, iInvalidPos + 1), MB_ICONSTOP); DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents); pDX->Fail(); } // end of alias send having weird characters in it // compile regular expression to check it if (m_bRegexp) { if (!CheckRegularExpression (m_name, (m_bIgnoreCase ? 0 : PCRE_CASELESS) | (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0) #if ALIASES_USE_UTF8 | (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0) #endif // ALIASES_USE_UTF8 )) { // failed check DDX_Text(pDX, IDC_ALIAS_NAME, m_name); pDX->Fail(); } } // end of checking regular expression CString strAliasName; for (pos = m_pAliasMap->GetStartPosition (); pos; ) { m_pAliasMap->GetNextAssoc (pos, strAliasName, alias_item); // don't compare against itself if (alias_item == m_current_alias) continue; /* bool bDuplicate = false; // if either one is case-insensitive, compare insensitive if ((alias_item->bIgnoreCase || m_bIgnoreCase) && alias_item->name.CompareNoCase (m_name) == 0) bDuplicate = true; // if both are case-sensitive, compare exactly else if (alias_item->name == m_name) bDuplicate = true; // we won't consider it a match if they send to different places if (alias_item->iSendTo != m_iSendTo) bDuplicate = false; if (bDuplicate) { ::TMessageBox("This alias is already in the list of aliases."); DDX_Text(pDX, IDC_ALIAS_NAME, m_name); pDX->Fail(); } */ // now check the label for duplicates if (!m_strLabel.IsEmpty ()) // we can have duplicate blank names if (m_strLabel.CompareNoCase (alias_item->strLabel) == 0) { CString strMsg; strMsg = TFormat ("The alias label \"%s\" is already in the list of aliases.", (LPCTSTR) m_strLabel); ::UMessageBox(strMsg); DDX_Text(pDX, IDC_ALIAS_LABEL, m_strLabel); pDX->Fail(); } } // end of checking each alias if (!m_strLabel.IsEmpty ()) // we can have blank labels { // check label is valid if (CheckLabel (m_strLabel)) { ::TMessageBox("The label must start with a letter and consist of letters" ", numbers or the underscore character."); DDX_Text(pDX, IDC_ALIAS_LABEL, m_strLabel); pDX->Fail(); } } // end of having non-blank label if (m_strVariable.IsEmpty ()) // we can have blank variables { if (m_iSendTo == eSendToVariable) { ::TMessageBox("When sending to a variable you must specify a variable name. ", MB_ICONSTOP); DDX_Text(pDX, IDC_VARIABLE, m_strVariable); pDX->Fail(); } } else { // check variable name is valid if (CheckLabel (m_strVariable)) { ::TMessageBox("The variable name must start with a letter and consist of letters" ", numbers or the underscore character."); DDX_Text(pDX, IDC_VARIABLE, m_strVariable); pDX->Fail(); } } // end of having non-blank variable // check for speed walking OK, unless they are substituting if (!m_bExpandVariables || m_contents.Find ('@') == -1) if (m_iSendTo == eSendToSpeedwalk && m_contents.Find ('%') == -1) { CString strResult = m_pDoc->DoEvaluateSpeedwalk (m_contents); if (!strResult.IsEmpty ()) { if (strResult [0] == '*') // error in speedwalk string? { ::UMessageBox (strResult.Mid (1)); DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents); pDX->Fail(); } // end of error message } // end of non-empty speedwalk } // end of speed walking wanted if(m_contents.IsEmpty () && m_strProcedure.IsEmpty ()) { ::TMessageBox("The alias contents cannot be blank unless you specify a script subroutine."); DDX_Text(pDX, IDC_ALIAS_CONTENTS, m_contents); pDX->Fail(); } // end of contents being blank if (!m_strProcedure.IsEmpty ()) // blank procedure is OK { // check procedure is valid if (CheckLabel (m_strProcedure, true)) { ::TMessageBox("The script subroutine name must start with a letter and consist of letters" ", numbers or the underscore character."); DDX_Text(pDX, IDC_SCRIPT_NAME, m_strProcedure); pDX->Fail(); } } // end of having non-blank procedure } // end of saving and validating else if (App.m_bFixedFontForEditing) { FixFont (m_font, m_ctlAliasName, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET); FixFont (m_font2, m_ctlAliasContents, App.m_strFixedPitchFont, App.m_iFixedPitchFontSize, FW_NORMAL, DEFAULT_CHARSET); } }