Updated for 1.2.0.3

This commit is contained in:
Gerald Schmidt 2009-01-17 22:52:54 +00:00
parent 5601d58552
commit 0d77b3b0c7
28 changed files with 293 additions and 169 deletions

View File

@ -18,13 +18,21 @@
*/
#include <memory>
#include "wraplibxml.h"
#include "catalogresolver.h"
std::string CatalogResolver::lookupPublicId (
const std::string& publicId,
const std::string& catalogPath )
CatalogResolver::CatalogResolver( const std::string& catalogPath )
{
std::auto_ptr<WrapLibxml> libxml ( new WrapLibxml ( false, catalogPath ) );
return libxml->lookupPublicId ( publicId );
wl = new WrapLibxml ( false, catalogPath );
}
CatalogResolver::~CatalogResolver()
{
delete wl;
}
std::string CatalogResolver::lookupPublicId (
const std::string& publicId)
{
//std::auto_ptr<WrapLibxml> libxml ( new WrapLibxml ( false, catalogPath ) );
return wl->lookupPublicId ( publicId );
}

View File

@ -21,13 +21,17 @@
#define CATALOG_RESOLVER_H
#include <string>
#include "wraplibxml.h"
class CatalogResolver
{
public:
static std::string lookupPublicId (
const std::string& publicId,
const std::string& catalogPath );
CatalogResolver( const std::string& catalogPath );
~CatalogResolver();
std::string lookupPublicId (
const std::string& publicId);
private:
WrapLibxml *wl;
};
#endif

View File

@ -77,7 +77,7 @@ bool GetWord::isWordCharacter ( char *s, size_t *bytes )
unsigned char *us = ( unsigned char * ) s;
if (
*us < 65 ||
( *us < 65 && *us != 45 ) ||
( *us > 90 && *us < 97 ) ||
( *us > 123 && *us < 128 )
)

View File

@ -29,6 +29,10 @@ HouseStyle::HouseStyle (
const std::string& filterDirectoryParameter,
const std::string& filterFileParameter,
const std::string& pathSeparatorParameter,
#ifdef __WXMSW__
const std::string& aspellDataPathParameter,
const std::string& aspellDictPathParameter,
#endif
int contextRangeParameter ) :
type ( typeParameter ),
buffer ( bufferParameter ),
@ -37,11 +41,16 @@ HouseStyle::HouseStyle (
filterDirectory ( filterDirectoryParameter ),
filterFile ( filterFileParameter ),
pathSeparator ( pathSeparatorParameter ),
#ifdef __WXMSW__
aspellDataPath ( aspellDataPathParameter ),
aspellDictPath ( aspellDictPathParameter ),
#endif
contextRange ( contextRangeParameter ),
ruleVector ( new std::vector<boost::shared_ptr<Rule> > ),
dictionary ( new StringSet<char> ),
passiveDictionary ( new StringSet<char> )
{}
{
}
HouseStyle::~HouseStyle()
{}
@ -199,7 +208,13 @@ bool HouseStyle::createReport()
WrapAspell *spellcheck = NULL;
try {
if (type == HS_TYPE_SPELL)
spellcheck = new WrapAspell( ruleFile );
spellcheck = new WrapAspell(
ruleFile, // carries lang information
#ifdef __WXMSW__
aspellDataPath,
aspellDictPath
#endif
);
}
catch (...)
{
@ -294,7 +309,7 @@ bool HouseStyle::createReport()
*/
}
}
delete spellcheck; // ok if NULL
delete spellcheck;
return true;
}

View File

@ -31,7 +31,6 @@
#include "xmlrulereader.h"
#include "housestylereader.h"
#include "xmlfilterreader.h"
//#include "spellcheck.h"
#include "wrapaspell.h"
#include "casehandler.h"
@ -51,6 +50,10 @@ class HouseStyle
const std::string& filterDirectoryParameter,
const std::string& filterFileParameter,
const std::string& pathSeparatorParameter,
#ifdef __WXMSW__
const std::string& aspellDataPathParameter,
const std::string& aspellDictPathParameter,
#endif
int contextRangeParameter );
~HouseStyle();
bool createReport();
@ -59,13 +62,18 @@ class HouseStyle
private:
int type;
std::string
buffer,
ruleDirectory,
ruleFile,
filterDirectory,
filterFile,
pathSeparator,
error;
buffer,
ruleDirectory,
ruleFile,
filterDirectory,
filterFile,
pathSeparator,
error,
#ifdef __WXMSW__
aspellDataPath,
aspellDictPath
#endif
;
int contextRange;
boost::shared_ptr<std::vector<boost::shared_ptr<Rule> > > ruleVector;
std::map<std::string, std::map<std::string, std::set<std::string> > >

View File

@ -70,6 +70,7 @@ bool MyServerConnection::OnPoke (
else
{
frame->openFile ( ( wxString& ) item );
//frame->addToFileQueue ( ( wxString& ) item ); // prevent event loop problems
}
frame->Raise();
return true;

View File

@ -20,6 +20,8 @@
#ifndef MY_IPC_H
#define MY_IPC_H
//#define wxUSE_DDE_FOR_IPC 0
#include <wx/wx.h>
#include <wx/ipc.h>

View File

@ -57,6 +57,10 @@ StyleDialog::StyleDialog (
const wxString& browserParameter,
const wxString& ruleSetPresetParameter,
const wxString& filterPresetParameter,
#ifdef __WXMSW__
const std::string& aspellDataPathParameter,
const std::string& aspellDictPathParameter,
#endif
int typeParameter,
bool readOnlyParameter,
wxPoint position,
@ -75,6 +79,10 @@ StyleDialog::StyleDialog (
browser ( browserParameter ),
ruleSetPreset ( ruleSetPresetParameter ),
filterPreset ( filterPresetParameter ),
#ifdef __WXMSW__
aspellDataPath ( aspellDataPathParameter ),
aspellDictPath ( aspellDictPathParameter ),
#endif
type(typeParameter),
readOnly ( readOnlyParameter )
{
@ -235,8 +243,8 @@ StyleDialog::StyleDialog (
config = new_aspell_config();
#ifdef __WXMSW__
aspell_config_replace ( config, "data-dir", ASPELL_DATA_PATH );
aspell_config_replace ( config, "dict-dir", ASPELL_DICT_PATH );
aspell_config_replace ( config, "data-dir", aspellDataPath.c_str() ); //ASPELL_DATA_PATH );
aspell_config_replace ( config, "dict-dir", aspellDictPath.c_str() ); //ASPELL_DICT_PATH );
#endif
dlist = get_aspell_dict_info_list( config );
@ -428,6 +436,10 @@ void StyleDialog::OnReport ( wxCommandEvent& event )
filterDirectoryUtf8,
filterUtf8,
pathSeparatorUtf8,
#ifdef __WXMSW__
aspellDataPath,
aspellDictPath,
#endif
5 ) );
status->SetStatusText ( _ ( "Checking document..." ) );
@ -589,6 +601,9 @@ void StyleDialog::OnStyleWebReport ( wxCommandEvent& event )
std::ofstream ofs ( tempNameUtf8.c_str() );
if ( !ofs )
return;
WrapExpat we;
ofs << XHTML_START;
ofs << "<body><h2>";
ofs << fileName.mb_str ( wxConvUTF8 );
@ -606,15 +621,15 @@ void StyleDialog::OnStyleWebReport ( wxCommandEvent& event )
ofs << ++matchCount;
ofs << "</td>";
ofs << "<td align=\"right\">";
ofs << it->prelog;
ofs << we.xmliseTextNode ( it->prelog );
ofs << "</td><td align=\"center\"><font color=\"red\"><b>";
ofs << it->match;
ofs << we.xmliseTextNode ( it->match );
ofs << "</b></font></td><td align=\"left\">";
ofs << it->postlog;
ofs << we.xmliseTextNode ( it->postlog );
ofs << "</td><td><font color=\"green\"><b>";
ofs << it->replace;
ofs << we.xmliseTextNode ( it->replace );
ofs << "</b></font></td><td>";
ofs << it->report;
ofs << we.xmliseTextNode ( it->report );
ofs << "</td></tr>";
}
ofs << "</table></body>";

View File

@ -73,6 +73,10 @@ class StyleDialog : public wxDialog
const wxString& browserParameter,
const wxString& ruleSetPresetParameter,
const wxString& filterPresetParameter,
#ifdef __WXMSW__
const std::string& aspellDataPath,
const std::string& aspellDictPath,
#endif
int type = ID_TYPE_STYLE,
bool readOnlyParameter = false,
wxPoint position = wxDefaultPosition,
@ -115,7 +119,7 @@ class StyleDialog : public wxDialog
wxComboBox *ruleSetCombo, *filterCombo;
wxListCtrl *table;
wxStatusBar *status;
std::string bufferUtf8;
std::string bufferUtf8, aspellDataPath, aspellDictPath;
std::set<wxString> tempFiles;
wxString fileName, ruleSetDirectory, filterDirectory, browser;
wxString ruleSetPreset, filterPreset;

View File

@ -8,6 +8,8 @@
ValidationThread::ValidationThread (
const char *buffer,
const char *system,
const char *catalogPath,
const char *catalogUtilityPath,
bool *finished,
bool *success,
bool *release,
@ -21,6 +23,8 @@ ValidationThread::ValidationThread (
myBuffer = buffer;
mySystem = system;
myCatalogPath = catalogPath;
myCatalogUtilityPath = catalogUtilityPath;
myFinishedPtr = finished;
mySuccessPtr = success;
myReleasePtr = release;
@ -30,7 +34,9 @@ ValidationThread::ValidationThread (
void *ValidationThread::Entry()
{
std::auto_ptr<WrapXerces> validator ( new WrapXerces() );
std::auto_ptr<WrapXerces> validator ( new WrapXerces(
myCatalogPath,
myCatalogUtilityPath ) );
{
//wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection );
@ -45,8 +51,6 @@ void *ValidationThread::Entry()
myBuffer.c_str(),
mySystem.c_str(),
myBuffer.size() );
{
//wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection );
if ( *myReleasePtr || TestDestroy() )

View File

@ -8,11 +8,19 @@
class ValidationThread : public wxThread
{
public:
ValidationThread ( const char *buffer, const char *system, bool *finished, bool *success, bool *release, std::pair<int, int> *position, std::string *message );
ValidationThread (
const char *buffer,
const char *system,
const char *catalogPath,
const char *catalogUtilityPath,
bool *finished,
bool *success,
bool *release, std::pair<int, int> *position,
std::string *message );
virtual void *Entry();
virtual void OnExit();
private:
std::string myBuffer, mySystem;
std::string myBuffer, mySystem, myCatalogPath, myCatalogUtilityPath;
bool *myFinishedPtr, *mySuccessPtr, *myReleasePtr;
std::pair<int, int> *myPositionPtr;
std::string *myMessagePtr;

View File

@ -29,13 +29,20 @@
#include "aspellpaths.h"
#endif
WrapAspell::WrapAspell ( std::string lang )
WrapAspell::WrapAspell (
std::string lang
#ifdef __WXMSW__
,
const std::string& aspellDataPathParameter,
const std::string& aspellDictPathParameter
#endif
)
{
spell_config = new_aspell_config();
#ifdef __WXMSW__
aspell_config_replace ( spell_config, "data-dir", ASPELL_DATA_PATH );
aspell_config_replace ( spell_config, "dict-dir", ASPELL_DICT_PATH );
aspell_config_replace ( spell_config, "data-dir", aspellDataPathParameter.c_str() );//ASPELL_DATA_PATH );
aspell_config_replace ( spell_config, "dict-dir", aspellDictPathParameter.c_str() );//ASPELL_DICT_PATH );
#endif
aspell_config_replace ( spell_config, "lang", lang.c_str() );
@ -101,4 +108,3 @@ bool WrapAspell::checkWord ( char *s, size_t len )
{
return aspell_speller_check ( spell_checker, s, len );
}

View File

@ -28,7 +28,13 @@
class WrapAspell
{
public:
WrapAspell ( std::string lang = "en_US" );
WrapAspell (
std::string lang,// = "en_US",
#ifdef __WXMSW__
const std::string& aspellDataPathParameter,
const std::string& aspellDictPath
#endif
);
~WrapAspell();
inline bool checkWord ( std::string &s );
void checkString (
@ -36,6 +42,7 @@ class WrapAspell
std::vector<ContextMatch> &v,
int contextRange );
std::string getSuggestion ( std::string &s );
std::string getVersion();
private:
AspellConfig *spell_config;
AspellSpeller *spell_checker;

View File

@ -18,7 +18,7 @@
*/
#include "wrapexpat.h"
#include "expat.h"
//#include "expat.h"
#include <stdexcept>
#include <iostream>
#include <sstream>

View File

@ -533,7 +533,18 @@ std::string WrapLibxml::lookupPublicId ( const std::string& id )
char *s = ( char * ) xmlCatalogResolvePublic ( ( const xmlChar * ) id.c_str() );
if ( !s )
return ret;
char *original, *it;
original = s;
it = strstr ( s, "file://" );
if ( it )
{
s = it + 6;
}
ret = s;
free ( s );
free ( original );
return ret;
}

View File

@ -31,7 +31,7 @@
using namespace xercesc;
WrapXerces::WrapXerces()
WrapXerces::WrapXerces( std::string catalogPath, std::string catalogUtilityPath )
{
try
{
@ -42,11 +42,13 @@ WrapXerces::WrapXerces()
throw std::runtime_error ( "Cannot initialize Xerces" );
}
errorPosition = std::make_pair ( 1, 1 );
catalogResolver = new XercesCatalogResolver( catalogPath, catalogUtilityPath );
}
WrapXerces::~WrapXerces()
{
XMLPlatformUtils::Terminate();
delete catalogResolver;
XMLPlatformUtils::Terminate();
}
bool WrapXerces::validate ( const std::string& fileName )
@ -61,11 +63,15 @@ bool WrapXerces::validate ( const std::string& fileName )
parser->setFeature ( XMLUni::fgXercesValidationErrorAsFatal, true );
parser->setFeature ( XMLUni::fgXercesLoadExternalDTD, true );
DefaultHandler handler;
MySAX2Handler mySAX2Handler;
parser->setContentHandler ( &handler );
parser->setErrorHandler ( &mySAX2Handler );
parser->setEntityResolver ( &handler );
//DefaultHandler handler;
//parser->setEntityResolver ( &handler );
parser->setEntityResolver ( catalogResolver );
try
{
@ -112,7 +118,7 @@ bool WrapXerces::validateMemory (
parser->setFeature ( XMLUni::fgSAX2CoreValidation, true );
parser->setFeature ( XMLUni::fgXercesDynamic, true );
parser->setFeature ( XMLUni::fgXercesSchema, true );
parser->setFeature ( XMLUni::fgXercesSchemaFullChecking, true );
//parser->setFeature ( XMLUni::fgXercesSchemaFullChecking, true );
parser->setFeature ( XMLUni::fgXercesValidationErrorAsFatal, true );
parser->setFeature ( XMLUni::fgXercesLoadExternalDTD, true );
@ -120,7 +126,8 @@ bool WrapXerces::validateMemory (
MySAX2Handler mySAX2Handler;
parser->setContentHandler ( &handler );
parser->setErrorHandler ( &mySAX2Handler );
parser->setEntityResolver ( &handler );
//parser->setEntityResolver ( &handler );
parser->setEntityResolver ( catalogResolver );
XMLByte* xmlBuffer = (XMLByte*) buffer;
MemBufInputSource source (

View File

@ -25,19 +25,22 @@
#include <utility>
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include "xercescatalogresolver.h"
using namespace xercesc;
class WrapXerces
{
public:
WrapXerces();
WrapXerces( std::string catalogPath = "",
std::string catalogUtilityPath = "" );
~WrapXerces();
bool validate ( const std::string& fileName );
bool validateMemory ( const char *buffer, const char *system, unsigned len );
std::string getLastError();
std::pair<int, int> getErrorPosition();
private:
XercesCatalogResolver *catalogResolver;
std::string lastError;
std::pair<int, int> errorPosition;
};

View File

@ -158,10 +158,10 @@ BEGIN_EVENT_TABLE ( MyFrame, wxFrame )
EVT_UPDATE_UI ( wxID_CLOSE, MyFrame::OnUpdateDocRange )
EVT_UPDATE_UI ( wxID_SAVEAS, MyFrame::OnUpdateDocRange )
EVT_UPDATE_UI ( wxID_CLOSE_ALL, MyFrame::OnUpdateCloseAll )
// EVT_UPDATE_UI_RANGE ( ID_SPLIT_TAB_TOP, ID_SPLIT_TAB_LEFT, MyFrame::OnUpdateCloseAll )
EVT_UPDATE_UI ( wxID_REVERT, MyFrame::OnUpdateSaveUndo )
EVT_UPDATE_UI_RANGE ( ID_SPLIT_TAB_TOP, ID_SPLIT_TAB_LEFT, MyFrame::OnUpdateCloseAll )
EVT_UPDATE_UI ( wxID_REVERT, MyFrame::OnUpdateUndo )
EVT_UPDATE_UI ( wxID_SAVE, MyFrame::OnUpdateDocRange ) // always allow save if doc present
EVT_UPDATE_UI ( wxID_UNDO, MyFrame::OnUpdateSaveUndo )
EVT_UPDATE_UI ( wxID_UNDO, MyFrame::OnUpdateUndo )
EVT_UPDATE_UI ( wxID_REDO, MyFrame::OnUpdateRedo )
EVT_UPDATE_UI ( wxID_PASTE, MyFrame::OnUpdatePaste )
EVT_UPDATE_UI ( wxID_CUT, MyFrame::OnUpdateCutCopy )
@ -174,18 +174,18 @@ BEGIN_EVENT_TABLE ( MyFrame, wxFrame )
EVT_UPDATE_UI ( ID_RELOAD, MyFrame::OnUpdateReload )
EVT_IDLE ( MyFrame::OnIdle )
EVT_AUINOTEBOOK_PAGE_CLOSE ( wxID_ANY, MyFrame::OnPageClosing )
#ifdef __WXMSW__
#ifdef __WXMSW__
EVT_DROP_FILES ( MyFrame::OnDropFiles )
#endif
#endif
END_EVENT_TABLE()
IMPLEMENT_APP ( MyApp)
MyApp::MyApp() : checker ( NULL ), server ( NULL ), connection ( NULL ),
#ifdef __WXMSW__
config ( new wxConfig ( _T ( "SourceForge Project\\XML Copy Editor" ) ) )
config ( new wxFileConfig ( _T ( ".xmlcopyeditor" ) ) )//( _T ( "SourceForge Project\\XML Copy Editor" ) ) )
#else
config ( new wxConfig ( _T ( "xmlcopyeditor" ) ) )
config ( new wxFileConfig ( _T ( "xmlcopyeditor" ) ) )
#endif
{
lang = 0;
@ -315,7 +315,7 @@ bool MyApp::OnInit()
if ( singleInstanceCheck )
{
checker = new wxSingleInstanceChecker ( name );
checker = new wxSingleInstanceChecker ( name );
while ( checker->IsAnotherRunning() )
{
// attempt calling server
@ -336,7 +336,8 @@ bool MyApp::OnInit()
{
argument = ( wxString ) this->argv[i];
argument = PathResolver::run ( argument );
connection->Poke ( argument, whatBuffer );
if ( ! connection->Poke ( argument, whatBuffer ) )
break;
}
}
else
@ -529,7 +530,7 @@ void MyApp::HandleEvent ( wxEvtHandler *handler, wxEventFunction func, wxEvent&
MyFrame::MyFrame (
const wxString& title,
wxConfig *configParameter,
wxFileConfig *configParameter,
wxLocale& locale,
bool singleInstanceCheckParameter,
int langParameter ) :
@ -981,8 +982,8 @@ MyFrame::~MyFrame()
config->Write ( _T ( "protectTags" ), protectTags );
config->Write ( _T ( "visibilityState" ), visibilityState );
config->Write ( _T ( "browserCommand" ), browserCommand );
config->Write ( _T ( "layout" ), layout );
config->Write ( _T ( "showLocationPane" ), manager.GetPane ( locationPanel ).IsShown() );
// config->Write ( _T ( "layout" ), layout ); // omit while unused
config->Write ( _T ( "showLocationPane" ), manager.GetPane ( locationPanel ).IsShown() );
config->Write ( _T ( "showInsertChildPane" ), manager.GetPane ( insertChildPanel ).IsShown() );
config->Write ( _T ( "showInsertSiblingPane" ), manager.GetPane ( insertSiblingPanel ).IsShown() );
config->Write ( _T ( "showInsertEntityPane" ), manager.GetPane ( insertEntityPanel ).IsShown() );
@ -1451,22 +1452,13 @@ void MyFrame::OnPaste ( wxCommandEvent& event )
wxTextDataObject data;
wxTheClipboard->GetData ( data );
wxString buffer = data.GetText();
wxTheClipboard->Close();
xmliseWideTextNode ( buffer );
doc->adjustCursor();
doc->AddText ( buffer );
}
else
doc->Paste();
/*
XmlDoc *doc;
doc = getActiveDocument();
if (doc && protectTags)
doc->adjustCursor();
doc->setValidationRequired(true);
event.Skip(); // new
*/
}
void MyFrame::OnIdle ( wxIdleEvent& event )
@ -1475,6 +1467,15 @@ void MyFrame::OnIdle ( wxIdleEvent& event )
if ( !status )
return;
/*
// IPC handling: take one file from fileQueue at a time
if ( !fileQueue.empty() )
{
openFile ( * ( fileQueue.begin() ) );
fileQueue.erase( fileQueue.begin() );
}
*/
// update attributes hidden field even if no document loaded
wxString currentHiddenStatus = status->GetStatusText ( STATUS_HIDDEN );
if ( visibilityState == HIDE_ATTRIBUTES )
@ -1557,7 +1558,7 @@ void MyFrame::OnIdle ( wxIdleEvent& event )
if ( frameTitle != docTitle )
SetTitle ( docTitle );
// update modified field
// update modified field
if ( !mainBook )
return;
int index = mainBook->GetSelection();
@ -1799,6 +1800,7 @@ void MyFrame::OnPasteNewDocument ( wxCommandEvent& event )
buffer.Append ( _T ( "</root>\n" ) );
newDocument ( buffer );
wxTheClipboard->Close();
}
void MyFrame::OnDialogFind ( wxFindDialogEvent& event )
@ -2278,7 +2280,6 @@ void MyFrame::OnSplitTab ( wxCommandEvent& event )
direction = wxAUI_NB_RIGHT;
switch ( id )
{
/*
ID_SPLIT_TAB_TOP:
direction = wxAUI_NB_TOP;
break;
@ -2291,7 +2292,6 @@ void MyFrame::OnSplitTab ( wxCommandEvent& event )
ID_SPLIT_TAB_LEFT:
direction = wxAUI_NB_LEFT;
break;
*/
default:
direction = wxAUI_NB_RIGHT;
break;
@ -2726,6 +2726,7 @@ void MyFrame::newDocument ( const std::string& s, const std::string& path, bool
s.c_str(), // modified
s.size(), // new
catalogPath,
catalogUtilityPath,
path,
auxPath );
mainBook->AddPage ( ( wxWindow * ) doc, documentLabel, true );
@ -3040,6 +3041,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
finalBuffer,
finalBufferLen,
catalogPath,
catalogUtilityPath,
( const char * ) fileName.mb_str ( wxConvLocal ),
auxPath );
#ifdef __WXMSW__
@ -3114,7 +3116,8 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
if ( !largeFile && ( properties.validateAsYouType && doc->getGrammarFound() ) )
{
statusProgress ( _T ( "Validating document..." ) );
doc->backgroundValidate ( finalBuffer, doc->getFullFileName().mb_str(wxConvUTF8), finalBufferLen );
//doc->backgroundValidate ( finalBuffer, doc->getFullFileName().mb_str(wxConvUTF8), finalBufferLen );
doc->backgroundValidate();
statusProgress ( wxEmptyString );
}
@ -3262,9 +3265,13 @@ void MyFrame::OnSpelling ( wxCommandEvent& event )
ruleSetDir,
filterDir,
browserCommand,
( type == ID_TYPE_SPELL ) ? dictionaryPreset : ruleSetPreset,
( type == ID_TYPE_SPELL ) ? dictionaryPreset : ruleSetPreset,
filterPreset,
type,
#ifdef __WXMSW__
aspellDataPath,
aspellDictPath,
#endif
type,
( success ) ? false : true,
stylePosition,
styleSize ) );
@ -3511,7 +3518,7 @@ void MyFrame::OnUpdateFindAgain ( wxUpdateUIEvent& event )
event.Enable ( true );
}
void MyFrame::OnUpdateSaveUndo ( wxUpdateUIEvent& event )
void MyFrame::OnUpdateUndo ( wxUpdateUIEvent& event )
{
XmlDoc *doc;
if ( ( doc = getActiveDocument() ) == NULL )
@ -3519,8 +3526,11 @@ void MyFrame::OnUpdateSaveUndo ( wxUpdateUIEvent& event )
event.Enable ( false );
return;
}
//event.Enable((doc->CanUndo()) ? true : false);
#ifdef __WXMSW__
event.Enable((doc->CanUndo()) ? true : false);
#else
event.Enable ( ( doc->GetModify() ) ? true : false );
#endif
}
void MyFrame::OnUpdateRedo ( wxUpdateUIEvent& event )
@ -3760,6 +3770,7 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
// branch: if no XML Schema found, use LibXML DTD parser instead
// so the catalog is read - switch when Xerces-C implements
// XMLCatalogResolver
#ifdef __WXMSW__
{
std::string rawBuffer, schemaLocation;
getRawText ( doc, rawBuffer );
@ -3771,6 +3782,7 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
return;
}
}
#endif
wxString fileName;
std::string tempFileNameLocal;
@ -3800,7 +3812,9 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
std::string error;
wxString wideError;
std::auto_ptr<WrapXerces> validator ( new WrapXerces() );
std::auto_ptr<WrapXerces> validator (
new WrapXerces( catalogPath, catalogUtilityPath )
);
std::string fileNameLocal = ( const char * ) fileName.mb_str ( wxConvLocal );
if ( !validator->validate ( fileNameLocal ) )
{
@ -3813,11 +3827,10 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
int cursorPos =
doc->PositionFromLine ( posPair.first - 1 );
doc->SetSelection ( cursorPos, cursorPos );
doc->setErrorIndicator ( posPair.first - 1, 0 ); //posPair.second );
doc->setErrorIndicator ( posPair.first - 1, 0 );
}
else
documentOk ( _ ( "valid" ) );
//#endif
}
void MyFrame::OnXPath ( wxCommandEvent& event )
@ -4605,7 +4618,7 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
finalBuffer = iconvBuffer; // iconvBuffer will be incremented by iconv
size_t nconv;
#ifdef __WXMSW_
#ifdef __WXMSW__
const char *
#else
char *
@ -4748,7 +4761,8 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
if ( properties.validateAsYouType && isXml )
{
doc->clearErrorIndicators();
doc->backgroundValidate ( utf8Buffer.c_str(), doc->getFullFileName().mb_str(wxConvUTF8), utf8Buffer.size() );
//doc->backgroundValidate ( utf8Buffer.c_str(), doc->getFullFileName().mb_str(wxConvUTF8), utf8Buffer.size() );
doc->backgroundValidate();
}
if ( !unlimitedUndo )
@ -4950,13 +4964,13 @@ wxMenuBar *MyFrame::getMenuBar()
break;
}
/* WAIT FOR AUI LIBRARY TO SUPPORT THIS - currently always splits left
/* WAIT FOR AUI LIBRARY TO SUPPORT THIS - currently always splits left
wxMenu *splitTabMenu = new wxMenu;
splitTabMenu->Append ( ID_SPLIT_TAB_TOP, _ ( "&Top" ), _ ( "Top" ));
splitTabMenu->Append ( ID_SPLIT_TAB_RIGHT, _ ( "&Right" ), _ ( "Right" ));
splitTabMenu->Append ( ID_SPLIT_TAB_BOTTOM, _ ( "&Bottom" ), _ ( "Bottom" ));
splitTabMenu->Append ( ID_SPLIT_TAB_LEFT, _ ( "&Left" ), _ ( "Left" ));
*/
*/
viewMenu = new wxMenu; // use class-wide data member
viewMenu->Append ( ID_PREVIOUS_DOCUMENT, _ ( "&Previous Document\tCtrl+PgUp" ), _ ( "Previous Document" ) );
@ -5333,11 +5347,7 @@ wxToolBar *MyFrame::getToolBar()
wxTB_HORIZONTAL |
wxTB_DOCKABLE );
int w, h;
//#ifdef __WXMSW__
w = saveBitmap.GetWidth(), h = saveBitmap.GetHeight();
//#else
// w = h = 24;
//#endif
toolBar->SetToolBitmapSize ( wxSize ( w, h ) );
toolBar->AddTool (
@ -5623,6 +5633,8 @@ void MyFrame::updatePaths()
applicationDir + wxFileName::GetPathSeparator() + _T ( "catalog" ) +
wxFileName::GetPathSeparator() + _T ( "catalog" );
catalogPath = wideCatalogPath.mb_str ( wxConvLocal );
wxString wideCatalogUtilityPath = applicationDir + wxFileName::GetPathSeparator() + _T ( "xmlcatalog" );
catalogUtilityPath = wideCatalogUtilityPath.mb_str ( wxConvLocal );
wxString wideXslDtdPath =
applicationDir + wxFileName::GetPathSeparator() + _T ( "dtd" ) +
wxFileName::GetPathSeparator() + _T ( "xslt10.dtd" );
@ -5643,6 +5655,12 @@ void MyFrame::updatePaths()
applicationDir + wxFileName::GetPathSeparator() + _T ( "dtd" ) +
wxFileName::GetPathSeparator() + _T ( "xliff.dtd" );
xliffDtdPath = wideXliffDtdPath.mb_str ( wxConvLocal );
wxString wideAspellDataPath = applicationDir + wxFileName::GetPathSeparator() +
_T ( "aspell" ) + wxFileName::GetPathSeparator() + _T ( "data" );
aspellDataPath = wideAspellDataPath.mb_str ( wxConvLocal );
wxString wideAspellDictPath = applicationDir + wxFileName::GetPathSeparator() +
_T ( "aspell" ) + wxFileName::GetPathSeparator() + _T ( "dict" );
aspellDictPath = wideAspellDictPath.mb_str ( wxConvLocal );
}
void MyFrame::OnAssociate ( wxCommandEvent& event )
@ -6018,3 +6036,7 @@ void MyFrame::setStrictScrolling ( bool b )
( b ) ? 10 : 0 );
}
void MyFrame::addToFileQueue ( wxString& fileName )
{
fileQueue.push_back ( fileName );
}

View File

@ -41,6 +41,7 @@
#include <wx/snglinst.h>
#include <wx/ipc.h>
#include <wx/intl.h>
#include <wx/fileconf.h>
#include <utility>
#include <string>
#include <set>
@ -184,7 +185,7 @@ class MyApp : public wxApp
MyClientConnection *connection;
bool singleInstanceCheck;
int lang;
std::auto_ptr<wxConfig> config;
std::auto_ptr<wxFileConfig> config;
};
// forward declarations
@ -203,7 +204,7 @@ class MyFrame : public wxFrame
public:
MyFrame (
const wxString& title,
wxConfig *configParameter,
wxFileConfig *configParameter,
wxLocale& locale,
bool singleInstanceCheck,
int langParameter );
@ -266,7 +267,7 @@ class MyFrame : public wxFrame
void OnIdle ( wxIdleEvent& event );
void OnUpdateClosePane ( wxUpdateUIEvent& event );
void OnUpdateCloseAll ( wxUpdateUIEvent& event );
void OnUpdateSaveUndo ( wxUpdateUIEvent& event );
void OnUpdateUndo ( wxUpdateUIEvent& event );
void OnUpdatePreviousDocument ( wxUpdateUIEvent& event );
void OnUpdateSavedOnly ( wxUpdateUIEvent& event );
void OnUpdateNextDocument ( wxUpdateUIEvent& event );
@ -337,10 +338,11 @@ class MyFrame : public wxFrame
bool isOpen ( const wxString& fileName );
bool activateTab ( const wxString& fileName );
void reloadTab();
void addToFileQueue ( wxString& fileName );
private:
wxAuiManager manager;
wxConfig *config; // owned by MyApp
wxLocale& myLocale;
wxFileConfig *config; // owned by MyApp
wxLocale& myLocale;
bool singleInstanceCheck;
int lang, lastPos;
wxLogNull logTarget;
@ -365,15 +367,15 @@ class MyFrame : public wxFrame
MyNotebook *mainBook;
MyHtmlPane *htmlReport;
std::string catalogPath, xslDtdPath, rssDtdPath, lzxDtdPath, xtmDtdPath,
xliffDtdPath;
std::string catalogPath, catalogUtilityPath, xslDtdPath, rssDtdPath, lzxDtdPath, xtmDtdPath,
xliffDtdPath, aspellDataPath, aspellDictPath;
std::pair<int, int> controlCoordinates;
std::map<std::string, std::map<std::string, std::set<std::string> > >
promptMap;
std::map<int, wxString> validationPresetMap;
std::set<wxString> openFileSet;
std::set<wxString> openLargeFileSet;
std::vector<wxString> tempFileVector;
std::vector<wxString> tempFileVector, fileQueue;
int documentCount,
framePosX,
framePosY,
@ -385,33 +387,33 @@ class MyFrame : public wxFrame
wxPoint stylePosition, aboutPosition;
wxSize styleSize;
wxString applicationDir,
ruleSetPreset,
dictionaryPreset,
filterPreset,
ruleSetDir,
filterDir,
binDir,
templateDir,
helpDir,
rngDir,
htmlDir,
pngDir,
xpathExpression,
lastDtdPublic,
lastDtdSystem,
lastSchema,
lastSchemaNamespace,
lastXslStylesheet,
lastSchemaNamespaceAux,
lastRelaxNGSchema,
lastDtdPublicAux,
openTabsOnClose,
browserCommand,
layout,
defaultLayout,
lastParent,
lastGrandparent,
commandString;
ruleSetPreset,
dictionaryPreset,
filterPreset,
ruleSetDir,
filterDir,
binDir,
templateDir,
helpDir,
rngDir,
htmlDir,
pngDir,
xpathExpression,
lastDtdPublic,
lastDtdSystem,
lastSchema,
lastSchemaNamespace,
lastXslStylesheet,
lastSchemaNamespaceAux,
lastRelaxNGSchema,
lastDtdPublicAux,
openTabsOnClose,
browserCommand,
layout,
defaultLayout,
lastParent,
lastGrandparent,
commandString;
bool globalReplaceAllDocuments,
toolbarVisible,
protectTags,

View File

@ -1,22 +1,3 @@
/*
* Copyright 2005-2007 Gerald Schmidt.
*
* This file is part of Xml Copy Editor.
*
* Xml Copy Editor 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 2 of the License.
*
* Xml Copy Editor 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 Xml Copy Editor; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
/* DO NOT EDIT ! */

View File

@ -41,5 +41,5 @@
"License along with this program; if not, write to the Free\n"\
"Software Foundation, Inc., 59 Temple Place, Suite 330,\n"\
"Boston, MA 02111-1307 USA.")
#define ABOUT_VERSION _T("1.2.0")
#define ABOUT_VERSION _T("1.2.0.3")
#define XMLCE_VAR _T("XMLCE_VAR")

View File

@ -21,7 +21,7 @@
#include "xmlpromptgenerator.h"
#include "xmlshallowvalidator.h"
#include "xmlencodinghandler.h"
#include "wrapxerces.h"
//#include "wrapxerces.h"
#include "xmlcopyeditor.h" // needed to enable validation-as-you-type alerts
#include <utility>
#include <memory>
@ -53,6 +53,7 @@ XmlCtrl::XmlCtrl (
const char *buffer, // could be NULL
size_t bufferLen,
const std::string& catalogPathParameter,
const std::string& catalogUtilityPathParameter,
const std::string& basePathParameter,
const std::string& auxPathParameter,
const wxPoint& position,
@ -62,6 +63,7 @@ XmlCtrl::XmlCtrl (
protectTags ( protectTagsParameter ),
visibilityState ( visibilityStateParameter ),
catalogPath ( catalogPathParameter ),
catalogUtilityPath ( catalogUtilityPathParameter ),
basePath ( basePathParameter ),
auxPath ( auxPathParameter )
{
@ -142,7 +144,6 @@ XmlCtrl::~XmlCtrl()
}
delete validationReleasePtr;
}
@ -244,7 +245,7 @@ void XmlCtrl::handleBackspace ( wxKeyEvent& event )
if ( canMoveLeftAt ( GetCurrentPos() ) )
{
event.Skip();
DeleteBack();//event.Skip();
return;
}
@ -269,13 +270,13 @@ void XmlCtrl::handleBackspace ( wxKeyEvent& event )
if ( *protectTags )
adjustSelection();
else
event.Skip();
DeleteBack();//event.Skip();
return;
}
if ( !properties.deleteWholeTag )
{
if ( ! ( *protectTags ) )
event.Skip();
DeleteBack();//event.Skip();
return;
}
// delete tag to left of caret
@ -352,7 +353,11 @@ void XmlCtrl::handleDelete ( wxKeyEvent& event )
end = GetSelectionEnd();
startLine = LineFromPosition ( start );
endLine = LineFromPosition ( end );
if ( startLine != endLine )
// add test so range unindentation only happens when caret is flush with left margin
int column = GetColumn ( GetCurrentPos() );
if ( startLine != endLine && !column)
{
if ( startLine > endLine )
{
@ -398,13 +403,13 @@ void XmlCtrl::handleDelete ( wxKeyEvent& event )
if ( *protectTags )
adjustSelection();
else
event.Skip();
DeleteBack();//event.Skip();
return;
}
if ( !properties.deleteWholeTag )
{
if ( ! ( *protectTags ) )
event.Skip();
DeleteBack();//event.Skip();
return;
}
@ -414,7 +419,7 @@ void XmlCtrl::handleDelete ( wxKeyEvent& event )
{
if ( limitPos > ( currentPos + BUFSIZ ) )
{
event.Skip();
DeleteBack();//event.Skip();
return;
}
}
@ -445,7 +450,7 @@ void XmlCtrl::handleDelete ( wxKeyEvent& event )
break;
else if ( GetCharAt ( limitPos ) == '\n' || limitPos > ( currentPos + BUFSIZ ) )
{
event.Skip();
DeleteBack();//event.Skip();
return;
}
}
@ -1434,12 +1439,12 @@ void XmlCtrl::setColorScheme ( int scheme )
StyleSetBackground ( wxSTC_STYLE_DEFAULT, *wxWHITE );
StyleClearAll();
baseBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 70 );
alternateBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 90 );
baseBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 75 );
alternateBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 95 );
SetCaretLineBackground ( baseBackground );
SetCaretForeground ( *wxBLACK );
SetSelBackground ( true, wxTheColourDatabase->Find ( _T ( "LIGHT GREY" ) ) );
SetSelBackground ( true, LightColour ( wxTheColourDatabase->Find ( _T ( "YELLOW" ) ), 20));//wxTheColourDatabase->Find ( _T ( "LIGHT GREY" ) ) );
if ( type == FILE_TYPE_CSS )
{
@ -1501,12 +1506,12 @@ void XmlCtrl::setColorScheme ( int scheme )
StyleSetBackground ( wxSTC_STYLE_DEFAULT, *wxWHITE );
StyleClearAll();
baseBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "YELLOW" ) ), 20 );
alternateBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "YELLOW" ) ), 60 );
baseBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 75 );
alternateBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 95 );
SetCaretLineBackground ( baseBackground );
SetCaretForeground ( *wxBLACK );
SetSelBackground ( true, wxTheColourDatabase->Find ( _T ( "LIGHT GREY" ) ) );
SetSelBackground ( true, LightColour ( wxTheColourDatabase->Find ( _T ( "YELLOW" ) ), 20) );//wxTheColourDatabase->Find ( _T ( "LIGHT GREY" ) ) );
if ( type == FILE_TYPE_CSS )
{
@ -1688,8 +1693,8 @@ void XmlCtrl::setColorScheme ( int scheme )
}
break;
case COLOR_SCHEME_NONE:
baseBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "YELLOW" ) ), 20 );
alternateBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "YELLOW" ) ), 60 );
baseBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 75 );
alternateBackground = LightColour ( wxTheColourDatabase->Find ( _T ( "CYAN" ) ), 95 );
SetCaretLineBackground ( baseBackground );
SetSelBackground ( true, wxTheColourDatabase->Find ( _T ( "LIGHT GREY" ) ) );
@ -2033,6 +2038,8 @@ bool XmlCtrl::backgroundValidate()
return true;
std::string bufferUtf8 = myGetTextRaw();
XmlEncodingHandler::setUtf8( bufferUtf8, true );
return backgroundValidate (
bufferUtf8.c_str(),
@ -2043,7 +2050,7 @@ bool XmlCtrl::backgroundValidate()
bool XmlCtrl::backgroundValidate (
const char *buffer,
const char *system,
size_t bufferLen
size_t bufferLen
)
{
if ( !validationRequired )
@ -2061,6 +2068,8 @@ bool XmlCtrl::backgroundValidate (
validationThread = new ValidationThread(
buffer,
system,
catalogPath.c_str(),
catalogUtilityPath.c_str(),
&validationFinished,
&validationSuccess,
validationReleasePtr,

View File

@ -102,6 +102,7 @@ class XmlCtrl: public wxStyledTextCtrl
const char *buffer = NULL,
size_t bufferLen = 0,
const std::string& catalogPath = "",
const std::string& catalogUtilityPath = "",
const std::string& basePath = "",
const std::string& auxPath = "",
const wxPoint &position = wxDefaultPosition,
@ -168,7 +169,7 @@ class XmlCtrl: public wxStyledTextCtrl
std::map<std::string, std::set<std::string> > elementMap;
std::set<std::string> entitySet;
std::map<std::string, std::string> elementStructureMap;
std::string catalogPath, basePath, auxPath;
std::string catalogPath, catalogUtilityPath, basePath, auxPath;
XmlCtrlProperties properties;
wxString getLastAttributeName ( int pos );
int getAttributeStartPos ( int pos );

View File

@ -31,6 +31,7 @@ XmlDoc::XmlDoc (
const char *buffer,
size_t bufferLen,
const std::string& catalogPath,
const std::string& catalogUtilityPath,
const std::string& basePath,
const std::string& auxPath,
const wxPoint &position,
@ -46,6 +47,7 @@ XmlDoc::XmlDoc (
buffer,
bufferLen, // new
catalogPath,
catalogUtilityPath,
basePath,
auxPath,
position,

View File

@ -39,6 +39,7 @@ class XmlDoc : public XmlCtrl
const char *buffer = NULL,
size_t bufferLen = 0,
const std::string& catalogPath = "",
const std::string& catalogUtilityPath = "",
const std::string& basePath = "",
const std::string& auxPath = "",
const wxPoint& position = wxDefaultPosition,

View File

@ -128,3 +128,4 @@ XmlEncodingHandler::getEncodingValueLimits ( const std::string& utf8 )
return make_pair ( -1, -1 );
return make_pair ( start - buffer, end - start );
}

View File

@ -26,6 +26,8 @@
#include "replace.h"
#include "getword.h"
#include "pathresolver.h"
#undef XMLCALL
#include "catalogresolver.h"
// Xerces-C req'd for Schema parsing
@ -39,6 +41,7 @@
#include <xercesc/validators/schema/SchemaValidator.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
//#include "wrapxerces.h"
using namespace xercesc;
@ -84,7 +87,7 @@ void XMLCALL XmlPromptGenerator::starthandler (
if (d->isRootElement)
{
d->rootElement = el;
handleSchema ( d, el, attr );
handleSchema ( d, el, attr ); // experimental: schema has been pre-parsed
d->isRootElement = false;
if ( ! (d->elementMap.empty() ) )//if ( d->elementMap.size() == 1) // must be 1 for success
{
@ -304,7 +307,8 @@ int XMLCALL XmlPromptGenerator::externalentityrefhandler (
if ( publicId )
stdPublicId = publicId;
std::string stdSystemId = CatalogResolver::lookupPublicId ( stdPublicId, d->catalogPath );
CatalogResolver cr ( d->catalogPath );
std::string stdSystemId = cr.lookupPublicId ( stdPublicId );
if ( !stdSystemId.empty() )
{
@ -312,6 +316,7 @@ int XMLCALL XmlPromptGenerator::externalentityrefhandler (
Replace::run ( stdSystemId, "%20", " ", false );
#ifdef __WXMSW__
Replace::run ( stdSystemId, "//C:/", "C:\\", false );
Replace::run ( stdSystemId, "/C:/", "C:\\", false );
Replace::run ( stdSystemId, "/", "\\", false );
#endif
@ -523,6 +528,3 @@ void XmlPromptGenerator::handleSchema (
delete parser;
XMLPlatformUtils::Terminate();
}

View File

@ -20,7 +20,7 @@
#ifndef XML_PROMPT_GENERATOR_H
#define XML_PROMPT_GENERATOR_H
#include <expat.h>
//#include <expat.h>
#include <map>
#include <set>
#include <memory>