Cleaned up code using CppCheck

This commit is contained in:
Zane U. Ji 2013-11-13 00:30:07 +08:00
parent f73803ab6d
commit 13b5bb6a87
27 changed files with 134 additions and 244 deletions

View File

@ -114,26 +114,25 @@ void AssociateDialog::OnOk ( wxCommandEvent& e )
void AssociateDialog::OnContextHelp ( wxHelpEvent& e )
{
wxTipWindow *tw;
int id = e.GetId();
if ( id == ID_URL )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Provides a space for you to type the path of the file" ) );
else if ( id == ID_BROWSE )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Opens a standard file dialog" ) );
else if ( id == ID_AUX )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Provides a space for you to type additional information" ) );
else if ( id == wxID_CANCEL )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Closes this dialog without making any changes" ) );
else if ( id == wxID_OK )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Selects the file specified" ) );
else

View File

@ -21,12 +21,12 @@
#include "contexthandler.h"
ContextMatch ContextHandler::getContext (
char *s,
const char *s,
int len,
char *origin,
const char *origin,
int context )
{
char *t, *u;
const char *t, *u;
int maxrange = context * 20;
int range = context + 1, i = 0;

View File

@ -41,9 +41,9 @@ class ContextHandler
{
public:
static ContextMatch getContext (
char *s,
const char *s,
int len,
char *origin,
const char *origin,
int context );
};

View File

@ -156,7 +156,6 @@ ExportDialog::~ExportDialog()
void ExportDialog::OnOk ( wxCommandEvent& e )
{
std::string urlUtf8, urlParamsUtf8;
#ifdef __WXMSW__
url = urlCtrl->GetTextCtrlValue();
#else
@ -171,30 +170,27 @@ void ExportDialog::OnOk ( wxCommandEvent& e )
rtf = rtfCheckbox->IsChecked();
doc = docCheckbox->IsChecked();
fullDaisy = fullDaisyCheckbox->IsChecked();
urlUtf8 = ( const char * ) url.mb_str ( wxConvUTF8 );
e.Skip();
}
void ExportDialog::OnContextHelp ( wxHelpEvent& e )
{
wxTipWindow *tw;
int id = e.GetId();
if ( id == ID_URL )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Provides a space for you to enter or select a stylesheet for conversion to canonical XHTML" ) );
if ( id == ID_FOLDER )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Provides a space for you to enter or select the output folder" ) );
else if ( id == wxID_OK )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Starts the export" ) );
else if ( id == wxID_CANCEL )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Closes the dialog box without exporting the file" ) );
else

View File

@ -71,7 +71,6 @@ class ExportDialog : public wxDialog
};
private:
wxStaticText *urlLabel, *folderLabel;
wxString url, folder;
wxCheckBox *quietCheckbox,
*suppressOptionalCheckbox,

View File

@ -138,35 +138,33 @@ void GlobalReplaceDialog::OnOk ( wxCommandEvent& e )
void GlobalReplaceDialog::OnContextHelp ( wxHelpEvent& e )
{
wxTipWindow *tw;
int id = e.GetId();
if ( id == ID_FIND )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Provides a space for you to type the text you want to find" ) );
else if ( id == ID_REPLACE )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Provides a space for you to type the text you want to replace the text you typed in Find what" ) );
else if ( id == ID_MATCHCASE )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Finds only text with lowercase and uppercase letters as specified in Find what" ) );
else if ( id == ID_ALLDOCUMENTS )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Extends the scope to all open documents" ) );
else if ( id == ID_REGEX )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Interprets the text specified in Find what as a regular expression" ) );
else if ( id == wxID_OK )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Finds all instances of the text specified in Find what and replaces them with the text in Replace with" ) );
else if ( id == wxID_CANCEL )
tw = new wxTipWindow (
new wxTipWindow (
this,
_ ( "Closes the dialog box without saving any changes you have made" ) );
else

View File

@ -53,7 +53,6 @@ class GlobalReplaceDialog : public wxDialog
private:
wxTextCtrl *findCtrl, *replaceCtrl;
wxStaticText *findLabel, *replaceLabel;
wxCheckBox *matchCaseBox, *allDocumentsBox, *regexBox;
wxString find, replace;
bool matchCase, allDocuments, regex;

View File

@ -67,10 +67,9 @@ LocationPanel::LocationPanel ( wxWindow *parentWindowParameter, int id ) :
}
void LocationPanel::update (
XmlDoc *docParameter,
XmlDoc *doc,
const wxString& parentParameter )
{
doc = docParameter;
parent = parentParameter;
wxString previous = edit->GetValue();

View File

@ -36,7 +36,6 @@ class LocationPanel : public wxPanel
private:
void indentStructure ( wxString& structure );
MyFrame *parentWindow;
XmlDoc *doc;
wxBoxSizer *sizer;
wxTextCtrl *edit;
wxStyledTextCtrl *structureEdit;

View File

@ -47,7 +47,6 @@ void XMLCALL Mp3Album::start ( void *data,
Mp3AlbumData *ad;
ad = ( Mp3AlbumData * ) data;
std::string value;
char noArray[5];
int currentNo;

View File

@ -32,15 +32,15 @@ MyPropertySheet::MyPropertySheet (
wxWindow *parent,
XmlCtrlProperties& propertiesParameter,
wxString& applicationDirParameter,
bool rememberOpenTabsParameter,
bool libxmlNetAccessParameter,
bool singleInstanceCheckParameter,
bool saveBomParameter,
bool unlimitedUndoParameter,
bool restoreLayoutParameter,
bool expandInternalEntitiesParameter,
bool showFullPathOnFrameParameter,
int lang,
bool &rememberOpenTabsParameter,
bool &libxmlNetAccessParameter,
bool &singleInstanceCheckParameter,
bool &saveBomParameter,
bool &unlimitedUndoParameter,
bool &restoreLayoutParameter,
bool &expandInternalEntitiesParameter,
bool &showFullPathOnFrameParameter,
int &lang,
const std::set<const wxLanguageInfo *> &translations,
wxWindowID id,
wxString title,
@ -51,6 +51,15 @@ MyPropertySheet::MyPropertySheet (
: wxPropertySheetDialog ( parent, id, title, position, size, style )
, properties ( propertiesParameter )
, applicationDir ( applicationDirParameter )
, rememberOpenTabs ( rememberOpenTabsParameter )
, libxmlNetAccess ( libxmlNetAccessParameter )
, singleInstanceCheck ( singleInstanceCheckParameter )
, saveBom ( saveBomParameter )
, unlimitedUndo ( unlimitedUndoParameter )
, restoreLayout ( restoreLayoutParameter )
, expandInternalEntities ( expandInternalEntitiesParameter )
, showFullPathOnFrame ( showFullPathOnFrameParameter )
, lang ( lang )
{
CreateButtons ( wxOK | wxCANCEL );
@ -241,6 +250,15 @@ MyPropertySheet::~MyPropertySheet()
void MyPropertySheet::OnOk ( wxCommandEvent& e )
{
wxString testDir = applicationDirEdit->GetValue();
if ( !wxFileName::DirExists ( testDir ) )
{
wxMessageBox ( _ ( "Cannot access application directory" ), _ ( "Options" ) );
// tbd: show general tab
return;
}
applicationDir = testDir;
properties.completion = completionBox->GetValue();
properties.fold = foldBox->GetValue();
properties.number = numberBox->GetValue();
@ -255,16 +273,6 @@ void MyPropertySheet::OnOk ( wxCommandEvent& e )
properties.font = fontBox->GetStringSelection();
properties.highlightSyntax = highlightSyntaxBox->GetValue();
wxString testDir = applicationDirEdit->GetValue();
if ( !wxFileName::DirExists ( testDir ) )
{
wxMessageBox ( _ ( "Cannot access application directory" ), _ ( "Options" ) );
// tbd: show general tab
return;
}
else
applicationDir = testDir;
singleInstanceCheck = singleInstanceCheckBox->GetValue();
restoreLayout = restoreLayoutBox->GetValue();
rememberOpenTabs = rememberOpenTabsBox->GetValue();
@ -289,58 +297,3 @@ void MyPropertySheet::OnApplicationDirBrowse ( wxCommandEvent& e )
if ( browseDialog->ShowModal() == wxID_OK )
applicationDirEdit->SetValue ( browseDialog->GetPath() );
}
XmlCtrlProperties MyPropertySheet::getProperties()
{
return properties;
}
wxString MyPropertySheet::getApplicationDir()
{
return applicationDir;
}
bool MyPropertySheet::getSingleInstanceCheck()
{
return singleInstanceCheck;
}
bool MyPropertySheet::getRememberOpenTabs()
{
return rememberOpenTabs;
}
bool MyPropertySheet::getLibxmlNetAccess()
{
return libxmlNetAccess;
}
bool MyPropertySheet::getSaveBom()
{
return saveBom;
}
bool MyPropertySheet::getUnlimitedUndo()
{
return unlimitedUndo;
}
int MyPropertySheet::getLang()
{
return lang;
}
bool MyPropertySheet::getRestoreLayout()
{
return restoreLayout;
}
bool MyPropertySheet::getExpandInternalEntities()
{
return expandInternalEntities;
}
bool MyPropertySheet::getShowFullPathOnFrame()
{
return showFullPathOnFrame;
}

View File

@ -38,15 +38,15 @@ class MyPropertySheet : public wxPropertySheetDialog
wxWindow *parent,
XmlCtrlProperties& propertiesParameter,
wxString& applicationDirParameter,
bool rememberOpenTabsParameter,
bool libxmlNetAccess,
bool singleInstanceCheck,
bool saveBom,
bool unlimitedUndo,
bool restoreLayout,
bool expandInternalEntities,
bool showFullPathOnFrame,
int lang,
bool &rememberOpenTabsParameter,
bool &libxmlNetAccess,
bool &singleInstanceCheck,
bool &saveBom,
bool &unlimitedUndo,
bool &restoreLayout,
bool &expandInternalEntities,
bool &showFullPathOnFrame,
int &lang,
const std::set<const wxLanguageInfo *> &translations,
wxWindowID id = wxID_ANY,
wxString title = _T ( "" ),
@ -56,19 +56,8 @@ class MyPropertySheet : public wxPropertySheetDialog
~MyPropertySheet();
void OnOk ( wxCommandEvent& e );
void OnApplicationDirBrowse ( wxCommandEvent& e );
XmlCtrlProperties getProperties();
wxString getApplicationDir();
bool getSingleInstanceCheck();
bool getRememberOpenTabs();
bool getLibxmlNetAccess();
bool getSaveBom();
bool getUnlimitedUndo();
bool getRestoreLayout();
bool getExpandInternalEntities();
bool getShowFullPathOnFrame();
int getLang();
private:
int lang;
int &lang;
wxCheckBox *completionBox,
*currentLineBox,
*foldBox,
@ -91,17 +80,17 @@ class MyPropertySheet : public wxPropertySheetDialog
*insertCloseTagBox;
wxChoice *languageBox, *fontBox;
wxTextCtrl *applicationDirEdit;
XmlCtrlProperties properties;
wxString applicationDir;
bool singleInstanceCheck,
rememberOpenTabs,
libxmlNetAccess,
saveBom,
unlimitedUndo,
restoreLayout,
expandInternalEntities,
showFullPathOnFrame,
insertCloseTag;
XmlCtrlProperties &properties;
wxString &applicationDir;
bool &singleInstanceCheck,
&rememberOpenTabs,
&libxmlNetAccess,
&saveBom,
&unlimitedUndo,
&restoreLayout,
&expandInternalEntities,
&showFullPathOnFrame;
DECLARE_EVENT_TABLE()
};

View File

@ -28,6 +28,7 @@ class ParserData
public:
ParserData()
{
state = 0;
count = 0;
}
~ParserData()

View File

@ -31,7 +31,9 @@ Rule::Rule (
matchCase,
replace,
arrayLength )
{ }
{
adjustCaseAttribute = tentativeAttribute = false;
}
bool Rule::getAdjustCaseAttribute()
{

View File

@ -30,9 +30,10 @@
#ifdef __WXMSW__
#include <mem.h>
#endif
#include <boost/utility.hpp>
template<class T>
class StringSetNode
class StringSetNode : private boost::noncopyable
{
public:
StringSetNode ( T *keyParameter, size_t lenParameter )

View File

@ -103,6 +103,7 @@ StyleDialog::StyleDialog (
position,
size,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ),
indexForContextMenu ( -1 ),
bufferUtf8 ( bufferParameterUtf8 ),
#if !defined(USE_ENCHANT) && defined(__WXMSW__)
aspellDataPath ( aspellDataPathParameter ),

View File

@ -96,6 +96,7 @@ void WrapLibxml::Init ( const wxString &catalogPath ) throw()
WrapLibxml::WrapLibxml ( bool netAccessParameter )
: netAccess ( netAccessParameter )
, errorLine ( 0 )
{
WrapLibxml::Init();
}
@ -117,19 +118,13 @@ bool WrapLibxml::validate ( const std::string& fileName )
return false;
}
bool returnValue = false;
docPtr = xmlCtxtReadFile (
ctxt,
fileName.c_str(),
NULL,
( netAccess ) ? XML_PARSE_DTDVALID : XML_PARSE_DTDVALID | XML_PARSE_NONET );
if ( docPtr == NULL )
;
else if ( ctxt->valid == 0 )
;
else
returnValue = true;
bool returnValue = docPtr != NULL && ctxt->valid != 0;
xmlFreeDoc ( docPtr );
xmlFreeParserCtxt ( ctxt );

View File

@ -33,11 +33,15 @@ WrapRegex::WrapRegex (
const string& replaceParameter,
const int arrayLengthParameter ) :
replace ( replaceParameter ),
arrayLength ( arrayLengthParameter )
arrayLength ( arrayLengthParameter ),
returnValue ( 0 )
{
if ( pattern.empty() || pattern == ".*" )
{
disabled = true;
matchArray = NULL;
patternStructure = NULL;
patternExtraStructure = NULL;
return;
}
disabled = false;
@ -67,17 +71,10 @@ WrapRegex::~WrapRegex()
if ( disabled )
return;
try
{
pcre_free ( patternStructure );
pcre_free ( patternExtraStructure );
delete[] matchArray;
}
catch ( ... )
{
throw runtime_error ( "Wrapregex::~WrapRegex" );
}
}
int WrapRegex::matchPatternGlobal (
string &buffer,
@ -105,7 +102,7 @@ string WrapRegex::replaceGlobal (
if ( disabled )
return buffer;
char *s = ( char * ) buffer.c_str();
const char *s = buffer.c_str();
string output, match;
@ -143,12 +140,12 @@ int WrapRegex::matchPatternGlobal_ (
if ( disabled )
return 0;
char *s, *origin;
const char *s, *origin;
int matchcount;
size_t offset;
ContextMatch match;
s = origin = ( char * ) buffer;
s = origin = buffer;
matchcount = 0;
offset = 0;
@ -193,13 +190,12 @@ int WrapRegex::matchPatternGlobal_ (
return matchcount;
}
string WrapRegex::getInterpolatedString_ ( char *buffer, char *source )
string WrapRegex::getInterpolatedString_ ( const char *buffer, const char *source )
{
if ( disabled )
return "";
char *s, *origin;
s = origin = ( char * ) source;
const char *s = source;
string interpol_string;
@ -213,7 +209,7 @@ string WrapRegex::getInterpolatedString_ ( char *buffer, char *source )
{
if ( isdigit ( * ( s + 1 ) ) )
{
char *number, *it;
const char *number, *it;
number = s + 1;
for ( it = number; *it && isdigit ( * ( it + 1 ) ); ++it )
;
@ -253,7 +249,7 @@ string WrapRegex::getInterpolatedString_ ( char *buffer, char *source )
return interpol_string;
}
string WrapRegex::getSubpattern_ ( char *s, unsigned subpattern )
string WrapRegex::getSubpattern_ ( const char *s, unsigned subpattern )
{
if ( disabled )
return "";
@ -263,6 +259,6 @@ string WrapRegex::getSubpattern_ ( char *s, unsigned subpattern )
if ( ret == PCRE_ERROR_NOSUBSTRING || ret == PCRE_ERROR_NOMEMORY )
return "";
string subString ( sub );
pcre_free ( ( char * ) sub );
pcre_free_substring ( sub );
return subString;
}

View File

@ -24,11 +24,12 @@
#include <string>
#include <vector>
#include <pcre.h>
#include <boost/utility.hpp>
#include "contexthandler.h"
using namespace std;
class WrapRegex
class WrapRegex : private boost::noncopyable
{
public:
WrapRegex (
@ -55,8 +56,9 @@ class WrapRegex
pcre_extra *patternExtraStructure;
int *matchArray;
string getInterpolatedString_ ( char *buffer, char *source );
string getSubpattern_ ( char *buffer, unsigned subpattern );
string getInterpolatedString_ ( const char *buffer,
const char *source );
string getSubpattern_ ( const char *buffer, unsigned subpattern );
int matchPatternGlobal_ (
const char *buffer,
size_t buflen,

View File

@ -25,6 +25,7 @@
#include <wx/buffer.h>
#include <string>
#include <utility>
#include <boost/utility.hpp>
#if !wxCHECK_GCC_VERSION(4,7)
#define XERCES_TMPLSINC
@ -36,7 +37,7 @@
using namespace xercesc;
class WrapXerces
class WrapXerces : private boost::noncopyable
{
public:
static void Init() throw ();

View File

@ -104,7 +104,7 @@ void XMLCALL XmlAssociateXsd::start ( void *data,
!strcmp ( *attr, "xmlns" ) ||
!strcmp ( *attr, "xsi:noNamespaceSchemaLocation" ) ||
!strcmp ( *attr, "xsi:schemaLocation" ) )
;
{}
else
{
d->buffer += " ";

View File

@ -388,7 +388,7 @@ bool MyApp::OnInit()
getAvailableTranslations ( &prefixes, &catalog );
if ( !myLocale.AddCatalog ( catalog ) )
;
{}
#ifndef __WXMSW__
{
@ -862,7 +862,6 @@ MyFrame::MyFrame (
commandString = wxEmptyString;
exportStylesheet = exportFolder = wxEmptyString;
exportQuiet = exportMp3Album = false;
exportQuiet = exportMp3Album = exportSuppressOptional = exportHtml =
exportEpub = exportRtf = exportDoc = exportFullDaisy = true;
@ -894,7 +893,6 @@ MyFrame::MyFrame (
largeFileProperties.indentLines = false;
largeFileProperties.protectHiddenElements = false;
largeFileProperties.toggleLineBackground = false;
largeFileProperties.toggleLineBackground = false;
largeFileProperties.insertCloseTag = false;
largeFileProperties.deleteWholeTag = false;
largeFileProperties.highlightSyntax = false;
@ -1437,7 +1435,8 @@ void MyFrame::OnPageClosing ( wxAuiNotebookEvent& event ) //wxNotebookEvent& eve
{
int selection;
wxString fileName;
if ( ( selection = mainBook->GetSelection() ) != -1 )
selection = mainBook->GetSelection();
if ( selection != -1 )
fileName = doc->getShortFileName();
int answer = wxMessageBox (
@ -1962,10 +1961,9 @@ void MyFrame::OnDialogReplace ( wxFindDialogEvent& event )
if ( !doc->GetSelectedText().IsEmpty() )
{
int regexWidth = 0;
if ( findReplacePanel->getRegex() )
{
regexWidth = doc->ReplaceTargetRE ( event.GetReplaceString() );
doc->ReplaceTargetRE ( event.GetReplaceString() );
}
else
{
@ -2049,7 +2047,7 @@ void MyFrame::OnPrintPreview ( wxCommandEvent &WXUNUSED ( event ) )
wxString htmlBuffer = getHtmlBuffer();
statusProgress ( wxEmptyString );
if ( ! ( htmlPrinting->PreviewText ( htmlBuffer ) ) )
;
{}
}
void MyFrame::OnPrint ( wxCommandEvent &WXUNUSED ( event ) )
@ -2070,7 +2068,7 @@ void MyFrame::OnPrint ( wxCommandEvent &WXUNUSED ( event ) )
wxString htmlBuffer = getHtmlBuffer();
statusProgress ( wxEmptyString );
if ( ! ( htmlPrinting->PrintText ( htmlBuffer ) ) )
;
{}
}
wxString MyFrame::getHtmlBuffer()
@ -2632,18 +2630,7 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
title ) );
if ( mpsd->ShowModal() == wxID_OK )
{
properties = mpsd->getProperties();
applyEditorProperties();
applicationDir = mpsd->getApplicationDir();
rememberOpenTabs = mpsd->getRememberOpenTabs();
libxmlNetAccess = mpsd->getLibxmlNetAccess();
singleInstanceCheck = mpsd->getSingleInstanceCheck();
saveBom = mpsd->getSaveBom();
unlimitedUndo = mpsd->getUnlimitedUndo();
restoreLayout = mpsd->getRestoreLayout();
expandInternalEntities = mpsd->getExpandInternalEntities();
showFullPathOnFrame = mpsd->getShowFullPathOnFrame();
lang = mpsd->getLang();
updatePaths();
}
if ( doc )
@ -2734,8 +2721,7 @@ void MyFrame::OnFindReplace ( wxCommandEvent& WXUNUSED ( event ) )
void MyFrame::OnGlobalReplace ( wxCommandEvent& event )
{
XmlDoc *doc;
if ( ( doc = getActiveDocument() ) == NULL )
if ( getActiveDocument() == NULL )
return;
size_t flags = findData.GetFlags();
@ -3052,7 +3038,6 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
}
wxString wideError;
std::string buffer;
pair<int, int> posPair;
XmlDoc *doc;
@ -3363,7 +3348,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
std::string MyFrame::getApproximateEncoding ( char *docBuffer,
size_t docBufferLen )
{
std::string line, encoding;
std::string line;
char *it;
size_t i;
@ -3573,7 +3558,7 @@ void MyFrame::save()
}
if ( !saveFile ( doc, fileName, true ) )
; // handle messages in saveFile
{} // handle messages in saveFile
}
void MyFrame::OnReload ( wxCommandEvent& event )
@ -3679,13 +3664,7 @@ void MyFrame::OnUpdateReload ( wxUpdateUIEvent& event )
void MyFrame::OnUpdateCutCopy ( wxUpdateUIEvent& event )
{
XmlDoc *doc;
if ( ( doc = getActiveDocument() ) == NULL )
{
event.Enable ( false );
return;
}
event.Enable ( true );
event.Enable ( getActiveDocument() != NULL );
}
void MyFrame::OnUpdateLocationPaneVisible ( wxUpdateUIEvent& event )
@ -3704,30 +3683,17 @@ void MyFrame::OnUpdateSavedOnly ( wxUpdateUIEvent& event )
event.Enable ( false );
return;
}
event.Enable (
( doc->getFullFileName().empty() ) ? false : true );
event.Enable ( !doc->getFullFileName().empty() );
}
void MyFrame::OnUpdateDocRange ( wxUpdateUIEvent& event )
{
XmlDoc *doc;
if ( ( doc = getActiveDocument() ) == NULL )
{
event.Enable ( false );
return;
}
event.Enable ( true );
event.Enable ( getActiveDocument() != NULL );
}
void MyFrame::OnUpdateReplaceRange ( wxUpdateUIEvent& event )
{
XmlDoc *doc;
if ( ( doc = getActiveDocument() ) == NULL ) // || protectTags)
{
event.Enable ( false );
return;
}
event.Enable ( true );
event.Enable ( getActiveDocument() != NULL );
}
void MyFrame::OnUpdateFindAgain ( wxUpdateUIEvent& event )
@ -3768,13 +3734,7 @@ void MyFrame::OnUpdateRedo ( wxUpdateUIEvent& event )
void MyFrame::OnUpdatePaste ( wxUpdateUIEvent& event )
{
XmlDoc *doc;
if ( ( doc = getActiveDocument() ) == NULL )
{
event.Enable ( false );
return;
}
event.Enable ( true );
event.Enable ( getActiveDocument() != NULL );
}
void MyFrame::OnUpdatePreviousDocument ( wxUpdateUIEvent& event )
@ -3992,7 +3952,7 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
// XMLCatalogResolver
#ifdef __WXMSW__
{
std::string rawBuffer, schemaLocation;
std::string rawBuffer;
getRawText ( doc, rawBuffer );
if ( !XmlEncodingHandler::setUtf8 ( rawBuffer ) )
{
@ -4010,7 +3970,6 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
#endif
wxString fileName;
std::string tempFileNameLocal;
fileName = doc->getFullFileName();
WrapTempFileName wtfn ( fileName );

View File

@ -1291,13 +1291,11 @@ bool XmlCtrl::canMoveLeftAt ( int pos )
void XmlCtrl::adjustPosRight()
{
int pos, max;
bool canInsert = false;
pos = GetCurrentPos();
max = GetLength();
for ( ; pos <= max; pos++ )
if ( canInsertAt ( pos ) )
{
canInsert = true;
break;
}
SetSelection ( pos, pos );
@ -1306,7 +1304,6 @@ void XmlCtrl::adjustPosRight()
void XmlCtrl::adjustPosLeft()
{
int pos;
bool canInsert = false;
pos = GetCurrentPos() - 1;
if ( pos < 0 )
{
@ -1316,7 +1313,6 @@ void XmlCtrl::adjustPosLeft()
for ( ; pos > 0; pos-- )
if ( canInsertAt ( pos ) )
{
canInsert = true;
break;
}
SetSelection ( pos, pos );

View File

@ -165,8 +165,8 @@ void XMLCALL XmlPromptGenerator::doctypedeclstarthandler (
const XML_Char *pubid,
int has_internal_subset )
{
PromptGeneratorData *d;
d = ( PromptGeneratorData * ) data;
//PromptGeneratorData *d;
//d = ( PromptGeneratorData * ) data;
}
void XMLCALL XmlPromptGenerator::doctypedeclendhandler ( void *data )

View File

@ -35,6 +35,7 @@ RuleData::RuleData (
passiveDictionary ( passiveDictionaryParameter ),
ruleVector ( ruleVectorParameter )
{
cipher = false;
dictionaryFound = false;
initialiseAttributes();
ruleCount = 0;

View File

@ -252,7 +252,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
{
wxString &schema = data.schema;
if ( data.children.size() == 0 && data.attrMap.size() == 0 )
if ( data.children.empty() && data.attrMap.empty() )
{
if ( !mInlineSimpleType )
{
@ -267,7 +267,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
addIndent ( schema, nIndent++ );
schema << _T("<xs:element name=\"") << data.name << _T("\">") << getEOL();
if ( data.children.size() > 0 )
if ( !data.children.empty() )
{
addIndent ( schema, nIndent++ );
schema << _T("<xs:complexType>") << getEOL();
@ -305,8 +305,8 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
if ( mInlineSimpleType )
{ // Check if it's a simple type
const ElmtData *childElmt = &mElements[*seqItr];
if ( childElmt->children.size() == 0
&& childElmt->attrMap.size() == 0 )
if ( childElmt->children.empty()
&& childElmt->attrMap.empty() )
{
schema << _T("<xs:element name=\"") << *seqItr
<< _T("\" type=\"xs:string\"/>") << getEOL();
@ -338,7 +338,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
schema << _T("</xs:choice>") << getEOL();
}
}
else if ( data.attrMap.size() != 0 )
else if ( !data.attrMap.empty() )
{
addIndent ( schema, nIndent++ );
schema << _T("<xs:complexType>") << getEOL();

View File

@ -32,7 +32,12 @@
struct XmlShallowValidatorData : public ParserData
{
XmlShallowValidatorData()
{}
{
isValid = segmentOnly = false;
depth = maxLine = 0;
p = 0;
overrideFailure = false;
}
std::map<wxString, std::set<wxString> > elementMap;
std::map<wxString, std::map<wxString, std::set<wxString> > >
attributeMap;