Preserve the original EOL
This commit is contained in:
parent
b3ed8c5d69
commit
b4661d535c
|
@ -13,22 +13,24 @@ pixmapdir = /usr/share/pixmaps
|
||||||
applicationsdir = /usr/share/applications
|
applicationsdir = /usr/share/applications
|
||||||
|
|
||||||
# the application source, library search path, and link libraries
|
# the application source, library search path, and link libraries
|
||||||
xmlcopyeditor_SOURCES = xmlcopyeditor.cpp associatedialog.cpp casehandler.cpp \
|
xmlcopyeditor_SOURCES = aboutdialog.cpp associatedialog.cpp binaryfile.cpp \
|
||||||
contexthandler.cpp dtd2schema.cpp globalreplacedialog.cpp housestyle.cpp \
|
casehandler.cpp catalogresolver.cpp commandpanel.cpp \
|
||||||
housestylereader.cpp myhtmlpane.cpp nocasecompare.cpp readfile.cpp \
|
contexthandler.cpp dtd2schema.cpp exportdialog.cpp \
|
||||||
replace.cpp styledialog.cpp threadreaper.cpp wraplibxml.cpp \
|
findreplacepanel.cpp getword.cpp globalreplacedialog.cpp \
|
||||||
wrapregex.cpp wraptempfilename.cpp xmlassociatedtd.cpp xmlassociatexsd.cpp \
|
housestyle.cpp housestylereader.cpp housestylewriter.cpp \
|
||||||
xmlassociatexsl.cpp xmlctrl.cpp xmldoc.cpp xmlencodinghandler.cpp \
|
insertpanel.cpp locationpanel.cpp mp3album.cpp myhtmlpane.cpp \
|
||||||
xmlfilterreader.cpp xmlpromptgenerator.cpp xmlrulereader.cpp \
|
myipc.cpp mynotebook.cpp mypropertysheet.cpp nocasecompare.cpp \
|
||||||
xmlschemalocator.cpp xmlutf8reader.cpp xsllocator.cpp \
|
pathresolver.cpp readfile.cpp replace.cpp rule.cpp styledialog.cpp \
|
||||||
wrapexpat.cpp mypropertysheet.cpp rule.cpp housestylewriter.cpp myipc.cpp \
|
threadreaper.cpp validationthread.cpp wrapaspell.cpp wrapdaisy.cpp \
|
||||||
aboutdialog.cpp pathresolver.cpp mynotebook.cpp insertpanel.cpp \
|
wrapexpat.cpp wraplibxml.cpp wrapregex.cpp wraptempfilename.cpp \
|
||||||
xmlwordcount.cpp getword.cpp locationpanel.cpp catalogresolver.cpp \
|
wrapxerces.cpp xercescatalogresolver.cpp xmlassociatedtd.cpp \
|
||||||
xmlparseschemans.cpp xmlshallowvalidator.cpp wrapxerces.cpp \
|
xmlassociatexsd.cpp xmlassociatexsl.cpp xmlcopyeditor.cpp \
|
||||||
findreplacepanel.cpp commandpanel.cpp xercescatalogresolver.cpp \
|
xmlcopyimg.cpp xmlctrl.cpp xmldoc.cpp xmlencodinghandler.cpp \
|
||||||
binaryfile.cpp xmlencodingspy.cpp wrapaspell.cpp validationthread.cpp \
|
xmlencodingspy.cpp xmlfilterreader.cpp xmlparseschemans.cpp \
|
||||||
wrapdaisy.cpp exportdialog.cpp mp3album.cpp xmlprodnote.cpp \
|
xmlprodnote.cpp xmlpromptgenerator.cpp xmlrulereader.cpp \
|
||||||
xmlsuppressprodnote.cpp xmlcopyimg.cpp xmlschemagenerator.cpp \
|
xmlschemagenerator.cpp xmlschemalocator.cpp xmlshallowvalidator.cpp \
|
||||||
|
xmlsuppressprodnote.cpp xmltextinfo.cpp xmlutf8reader.cpp \
|
||||||
|
xmlwordcount.cpp xsllocator.cpp \
|
||||||
xmlcopyeditor.spec xmlcopyeditor.png custom.xpm
|
xmlcopyeditor.spec xmlcopyeditor.png custom.xpm
|
||||||
|
|
||||||
xmlcopyeditor_LDADD = $(WX_LIBS) \
|
xmlcopyeditor_LDADD = $(WX_LIBS) \
|
||||||
|
|
|
@ -50,35 +50,35 @@ CONFIG_CLEAN_VPATH_FILES =
|
||||||
am__installdirs = "$(DESTDIR)$(bindir)" \
|
am__installdirs = "$(DESTDIR)$(bindir)" \
|
||||||
"$(DESTDIR)$(xmlcopyeditordir)" "$(DESTDIR)$(pixmapdir)"
|
"$(DESTDIR)$(xmlcopyeditordir)" "$(DESTDIR)$(pixmapdir)"
|
||||||
PROGRAMS = $(bin_PROGRAMS)
|
PROGRAMS = $(bin_PROGRAMS)
|
||||||
am_xmlcopyeditor_OBJECTS = xmlcopyeditor.$(OBJEXT) \
|
am_xmlcopyeditor_OBJECTS = aboutdialog.$(OBJEXT) \
|
||||||
associatedialog.$(OBJEXT) casehandler.$(OBJEXT) \
|
associatedialog.$(OBJEXT) binaryfile.$(OBJEXT) \
|
||||||
contexthandler.$(OBJEXT) dtd2schema.$(OBJEXT) \
|
casehandler.$(OBJEXT) catalogresolver.$(OBJEXT) \
|
||||||
|
commandpanel.$(OBJEXT) contexthandler.$(OBJEXT) \
|
||||||
|
dtd2schema.$(OBJEXT) exportdialog.$(OBJEXT) \
|
||||||
|
findreplacepanel.$(OBJEXT) getword.$(OBJEXT) \
|
||||||
globalreplacedialog.$(OBJEXT) housestyle.$(OBJEXT) \
|
globalreplacedialog.$(OBJEXT) housestyle.$(OBJEXT) \
|
||||||
housestylereader.$(OBJEXT) myhtmlpane.$(OBJEXT) \
|
housestylereader.$(OBJEXT) housestylewriter.$(OBJEXT) \
|
||||||
nocasecompare.$(OBJEXT) readfile.$(OBJEXT) replace.$(OBJEXT) \
|
insertpanel.$(OBJEXT) locationpanel.$(OBJEXT) \
|
||||||
|
mp3album.$(OBJEXT) myhtmlpane.$(OBJEXT) myipc.$(OBJEXT) \
|
||||||
|
mynotebook.$(OBJEXT) mypropertysheet.$(OBJEXT) \
|
||||||
|
nocasecompare.$(OBJEXT) pathresolver.$(OBJEXT) \
|
||||||
|
readfile.$(OBJEXT) replace.$(OBJEXT) rule.$(OBJEXT) \
|
||||||
styledialog.$(OBJEXT) threadreaper.$(OBJEXT) \
|
styledialog.$(OBJEXT) threadreaper.$(OBJEXT) \
|
||||||
wraplibxml.$(OBJEXT) wrapregex.$(OBJEXT) \
|
validationthread.$(OBJEXT) wrapaspell.$(OBJEXT) \
|
||||||
wraptempfilename.$(OBJEXT) xmlassociatedtd.$(OBJEXT) \
|
wrapdaisy.$(OBJEXT) wrapexpat.$(OBJEXT) wraplibxml.$(OBJEXT) \
|
||||||
xmlassociatexsd.$(OBJEXT) xmlassociatexsl.$(OBJEXT) \
|
wrapregex.$(OBJEXT) wraptempfilename.$(OBJEXT) \
|
||||||
xmlctrl.$(OBJEXT) xmldoc.$(OBJEXT) \
|
wrapxerces.$(OBJEXT) xercescatalogresolver.$(OBJEXT) \
|
||||||
xmlencodinghandler.$(OBJEXT) xmlfilterreader.$(OBJEXT) \
|
xmlassociatedtd.$(OBJEXT) xmlassociatexsd.$(OBJEXT) \
|
||||||
xmlpromptgenerator.$(OBJEXT) xmlrulereader.$(OBJEXT) \
|
xmlassociatexsl.$(OBJEXT) xmlcopyeditor.$(OBJEXT) \
|
||||||
xmlschemalocator.$(OBJEXT) xmlutf8reader.$(OBJEXT) \
|
xmlcopyimg.$(OBJEXT) xmlctrl.$(OBJEXT) xmldoc.$(OBJEXT) \
|
||||||
xsllocator.$(OBJEXT) wrapexpat.$(OBJEXT) \
|
xmlencodinghandler.$(OBJEXT) xmlencodingspy.$(OBJEXT) \
|
||||||
mypropertysheet.$(OBJEXT) rule.$(OBJEXT) \
|
xmlfilterreader.$(OBJEXT) xmlparseschemans.$(OBJEXT) \
|
||||||
housestylewriter.$(OBJEXT) myipc.$(OBJEXT) \
|
xmlprodnote.$(OBJEXT) xmlpromptgenerator.$(OBJEXT) \
|
||||||
aboutdialog.$(OBJEXT) pathresolver.$(OBJEXT) \
|
xmlrulereader.$(OBJEXT) xmlschemagenerator.$(OBJEXT) \
|
||||||
mynotebook.$(OBJEXT) insertpanel.$(OBJEXT) \
|
xmlschemalocator.$(OBJEXT) xmlshallowvalidator.$(OBJEXT) \
|
||||||
xmlwordcount.$(OBJEXT) getword.$(OBJEXT) \
|
xmlsuppressprodnote.$(OBJEXT) xmltextinfo.$(OBJEXT) \
|
||||||
locationpanel.$(OBJEXT) catalogresolver.$(OBJEXT) \
|
xmlutf8reader.$(OBJEXT) xmlwordcount.$(OBJEXT) \
|
||||||
xmlparseschemans.$(OBJEXT) xmlshallowvalidator.$(OBJEXT) \
|
xsllocator.$(OBJEXT)
|
||||||
wrapxerces.$(OBJEXT) findreplacepanel.$(OBJEXT) \
|
|
||||||
commandpanel.$(OBJEXT) xercescatalogresolver.$(OBJEXT) \
|
|
||||||
binaryfile.$(OBJEXT) xmlencodingspy.$(OBJEXT) \
|
|
||||||
wrapaspell.$(OBJEXT) validationthread.$(OBJEXT) \
|
|
||||||
wrapdaisy.$(OBJEXT) exportdialog.$(OBJEXT) mp3album.$(OBJEXT) \
|
|
||||||
xmlprodnote.$(OBJEXT) xmlsuppressprodnote.$(OBJEXT) \
|
|
||||||
xmlcopyimg.$(OBJEXT) xmlschemagenerator.$(OBJEXT)
|
|
||||||
xmlcopyeditor_OBJECTS = $(am_xmlcopyeditor_OBJECTS)
|
xmlcopyeditor_OBJECTS = $(am_xmlcopyeditor_OBJECTS)
|
||||||
am__DEPENDENCIES_1 =
|
am__DEPENDENCIES_1 =
|
||||||
xmlcopyeditor_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
xmlcopyeditor_DEPENDENCIES = $(am__DEPENDENCIES_1) \
|
||||||
|
@ -287,22 +287,24 @@ pixmapdir = /usr/share/pixmaps
|
||||||
applicationsdir = /usr/share/applications
|
applicationsdir = /usr/share/applications
|
||||||
|
|
||||||
# the application source, library search path, and link libraries
|
# the application source, library search path, and link libraries
|
||||||
xmlcopyeditor_SOURCES = xmlcopyeditor.cpp associatedialog.cpp casehandler.cpp \
|
xmlcopyeditor_SOURCES = aboutdialog.cpp associatedialog.cpp binaryfile.cpp \
|
||||||
contexthandler.cpp dtd2schema.cpp globalreplacedialog.cpp housestyle.cpp \
|
casehandler.cpp catalogresolver.cpp commandpanel.cpp \
|
||||||
housestylereader.cpp myhtmlpane.cpp nocasecompare.cpp readfile.cpp \
|
contexthandler.cpp dtd2schema.cpp exportdialog.cpp \
|
||||||
replace.cpp styledialog.cpp threadreaper.cpp wraplibxml.cpp \
|
findreplacepanel.cpp getword.cpp globalreplacedialog.cpp \
|
||||||
wrapregex.cpp wraptempfilename.cpp xmlassociatedtd.cpp xmlassociatexsd.cpp \
|
housestyle.cpp housestylereader.cpp housestylewriter.cpp \
|
||||||
xmlassociatexsl.cpp xmlctrl.cpp xmldoc.cpp xmlencodinghandler.cpp \
|
insertpanel.cpp locationpanel.cpp mp3album.cpp myhtmlpane.cpp \
|
||||||
xmlfilterreader.cpp xmlpromptgenerator.cpp xmlrulereader.cpp \
|
myipc.cpp mynotebook.cpp mypropertysheet.cpp nocasecompare.cpp \
|
||||||
xmlschemalocator.cpp xmlutf8reader.cpp xsllocator.cpp \
|
pathresolver.cpp readfile.cpp replace.cpp rule.cpp styledialog.cpp \
|
||||||
wrapexpat.cpp mypropertysheet.cpp rule.cpp housestylewriter.cpp myipc.cpp \
|
threadreaper.cpp validationthread.cpp wrapaspell.cpp wrapdaisy.cpp \
|
||||||
aboutdialog.cpp pathresolver.cpp mynotebook.cpp insertpanel.cpp \
|
wrapexpat.cpp wraplibxml.cpp wrapregex.cpp wraptempfilename.cpp \
|
||||||
xmlwordcount.cpp getword.cpp locationpanel.cpp catalogresolver.cpp \
|
wrapxerces.cpp xercescatalogresolver.cpp xmlassociatedtd.cpp \
|
||||||
xmlparseschemans.cpp xmlshallowvalidator.cpp wrapxerces.cpp \
|
xmlassociatexsd.cpp xmlassociatexsl.cpp xmlcopyeditor.cpp \
|
||||||
findreplacepanel.cpp commandpanel.cpp xercescatalogresolver.cpp \
|
xmlcopyimg.cpp xmlctrl.cpp xmldoc.cpp xmlencodinghandler.cpp \
|
||||||
binaryfile.cpp xmlencodingspy.cpp wrapaspell.cpp validationthread.cpp \
|
xmlencodingspy.cpp xmlfilterreader.cpp xmlparseschemans.cpp \
|
||||||
wrapdaisy.cpp exportdialog.cpp mp3album.cpp xmlprodnote.cpp \
|
xmlprodnote.cpp xmlpromptgenerator.cpp xmlrulereader.cpp \
|
||||||
xmlsuppressprodnote.cpp xmlcopyimg.cpp xmlschemagenerator.cpp \
|
xmlschemagenerator.cpp xmlschemalocator.cpp xmlshallowvalidator.cpp \
|
||||||
|
xmlsuppressprodnote.cpp xmltextinfo.cpp xmlutf8reader.cpp \
|
||||||
|
xmlwordcount.cpp xsllocator.cpp \
|
||||||
xmlcopyeditor.spec xmlcopyeditor.png custom.xpm
|
xmlcopyeditor.spec xmlcopyeditor.png custom.xpm
|
||||||
|
|
||||||
xmlcopyeditor_LDADD = $(WX_LIBS) \
|
xmlcopyeditor_LDADD = $(WX_LIBS) \
|
||||||
|
@ -499,6 +501,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlschemalocator.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlschemalocator.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlshallowvalidator.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlshallowvalidator.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlsuppressprodnote.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlsuppressprodnote.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmltextinfo.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlutf8reader.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlutf8reader.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlwordcount.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmlwordcount.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsllocator.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsllocator.Po@am__quote@
|
||||||
|
|
|
@ -25,12 +25,14 @@
|
||||||
#include "xmlassociatedtd.h"
|
#include "xmlassociatedtd.h"
|
||||||
|
|
||||||
XmlAssociateDtd::XmlAssociateDtd (
|
XmlAssociateDtd::XmlAssociateDtd (
|
||||||
const wxString &path,
|
const XmlTextInfo &info,
|
||||||
const wxString &publicID,
|
const wxString &path,
|
||||||
const char *encoding,
|
const wxString &publicID,
|
||||||
size_t size )
|
const char *encoding,
|
||||||
: WrapExpat ( encoding )
|
size_t size )
|
||||||
, d ( new DtdData() )
|
: WrapExpat ( encoding )
|
||||||
|
, d ( new DtdData() )
|
||||||
|
, mInfo ( info )
|
||||||
{
|
{
|
||||||
d->buffer.reserve ( size );
|
d->buffer.reserve ( size );
|
||||||
d->path = path;
|
d->path = path;
|
||||||
|
@ -67,7 +69,7 @@ void XMLCALL XmlAssociateDtd::start ( void *data,
|
||||||
if ( !d->associated )
|
if ( !d->associated )
|
||||||
{
|
{
|
||||||
associate ( d, el );
|
associate ( d, el );
|
||||||
d->buffer += "\n";
|
d->buffer += pThis->mInfo.mEOL.utf8_str();
|
||||||
d->associated = true;
|
d->associated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "wrapexpat.h"
|
#include "xmltextinfo.h"
|
||||||
|
|
||||||
struct DtdData : public ParserData
|
struct DtdData : public ParserData
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,7 @@ class XmlAssociateDtd : public WrapExpat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XmlAssociateDtd (
|
XmlAssociateDtd (
|
||||||
|
const XmlTextInfo &info,
|
||||||
const wxString &path = wxEmptyString,
|
const wxString &path = wxEmptyString,
|
||||||
const wxString &publicID = wxEmptyString,
|
const wxString &publicID = wxEmptyString,
|
||||||
const char *encoding = NULL,
|
const char *encoding = NULL,
|
||||||
|
@ -48,7 +49,7 @@ class XmlAssociateDtd : public WrapExpat
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::auto_ptr<DtdData> d;
|
std::auto_ptr<DtdData> d;
|
||||||
std::string encoding;
|
const XmlTextInfo &mInfo;
|
||||||
static void XMLCALL start (
|
static void XMLCALL start (
|
||||||
void *data,
|
void *data,
|
||||||
const XML_Char *el,
|
const XML_Char *el,
|
||||||
|
|
|
@ -25,11 +25,13 @@
|
||||||
#include "xmlassociatexsl.h"
|
#include "xmlassociatexsl.h"
|
||||||
|
|
||||||
XmlAssociateXsl::XmlAssociateXsl (
|
XmlAssociateXsl::XmlAssociateXsl (
|
||||||
|
const XmlTextInfo &info,
|
||||||
const wxString &path,
|
const wxString &path,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
size_t size )
|
size_t size )
|
||||||
: WrapExpat ( encoding )
|
: WrapExpat ( encoding )
|
||||||
, d ( new XslData() )
|
, d ( new XslData() )
|
||||||
|
, mInfo ( info )
|
||||||
{
|
{
|
||||||
d->buffer.reserve ( size );
|
d->buffer.reserve ( size );
|
||||||
d->path = path;
|
d->path = path;
|
||||||
|
@ -64,7 +66,8 @@ void XMLCALL XmlAssociateXsl::start ( void *data,
|
||||||
{
|
{
|
||||||
d->buffer += "<?xml-stylesheet type=\"text/xsl\" href=\"";
|
d->buffer += "<?xml-stylesheet type=\"text/xsl\" href=\"";
|
||||||
d->buffer += d->path.utf8_str(); // TODO: Apply the encoding of the parser
|
d->buffer += d->path.utf8_str(); // TODO: Apply the encoding of the parser
|
||||||
d->buffer += "\"?>\n";
|
d->buffer += "\"?>";
|
||||||
|
d->buffer += pThis->mInfo.mEOL.utf8_str();
|
||||||
d->associated = true;
|
d->associated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "wrapexpat.h"
|
#include "xmltextinfo.h"
|
||||||
|
|
||||||
struct XslData : public ParserData
|
struct XslData : public ParserData
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ class XmlAssociateXsl : public WrapExpat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XmlAssociateXsl (
|
XmlAssociateXsl (
|
||||||
|
const XmlTextInfo &info,
|
||||||
const wxString &path = wxEmptyString,
|
const wxString &path = wxEmptyString,
|
||||||
const char *encoding = NULL,
|
const char *encoding = NULL,
|
||||||
size_t size = BUFSIZ );
|
size_t size = BUFSIZ );
|
||||||
|
@ -48,7 +49,7 @@ class XmlAssociateXsl : public WrapExpat
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::auto_ptr<XslData> d;
|
std::auto_ptr<XslData> d;
|
||||||
std::string encoding;
|
const XmlTextInfo &mInfo;
|
||||||
static void XMLCALL start (
|
static void XMLCALL start (
|
||||||
void *data,
|
void *data,
|
||||||
const XML_Char *el,
|
const XML_Char *el,
|
||||||
|
|
|
@ -5739,6 +5739,9 @@ void MyFrame::OnAssociate ( wxCommandEvent& event )
|
||||||
if ( ( doc = getActiveDocument() ) == NULL )
|
if ( ( doc = getActiveDocument() ) == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
XmlTextInfo info ( doc->getFullFileName() );
|
||||||
|
info.parse ( doc->myGetTextRaw() );
|
||||||
|
|
||||||
wxString title, label, type, extension, path, defaulturl, defaultaux;
|
wxString title, label, type, extension, path, defaulturl, defaultaux;
|
||||||
wxString auxiliaryLabel;
|
wxString auxiliaryLabel;
|
||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
|
@ -5748,24 +5751,26 @@ void MyFrame::OnAssociate ( wxCommandEvent& event )
|
||||||
type = _ ( "Public DTD" );
|
type = _ ( "Public DTD" );
|
||||||
extension = _T ( "*.dtd" );
|
extension = _T ( "*.dtd" );
|
||||||
defaulturl = lastDtdPublic;
|
defaulturl = lastDtdPublic;
|
||||||
defaultaux = lastDtdPublicAux;
|
defaultaux = info.mDtdFile.empty()
|
||||||
|
? lastDtdPublicAux : info.mDtdFile;
|
||||||
break;
|
break;
|
||||||
case ID_ASSOCIATE_DTD_SYSTEM:
|
case ID_ASSOCIATE_DTD_SYSTEM:
|
||||||
type = _ ( "System DTD" );
|
type = _ ( "System DTD" );
|
||||||
extension = _T ( "*.dtd" );
|
extension = _T ( "*.dtd" );
|
||||||
defaulturl = lastDtdSystem;
|
defaulturl = info.mDtdFile.empty() ? lastDtdSystem : info.mDtdFile;
|
||||||
defaultaux = _T ( "" );
|
defaultaux = _T ( "" );
|
||||||
break;
|
break;
|
||||||
case ID_ASSOCIATE_W3C_SCHEMA:
|
case ID_ASSOCIATE_W3C_SCHEMA:
|
||||||
type = _ ( "XML Schema" );
|
type = _ ( "XML Schema" );
|
||||||
extension = _T ( "*.xsd" );
|
extension = _T ( "*.xsd" );
|
||||||
defaulturl = lastSchema;
|
defaulturl = info.mXsdFile.empty() ? lastSchema : info.mXsdFile;
|
||||||
defaultaux = _T ( "" );
|
defaultaux = _T ( "" );
|
||||||
break;
|
break;
|
||||||
case ID_ASSOCIATE_XSL:
|
case ID_ASSOCIATE_XSL:
|
||||||
type = _ ( "XSLT stylesheet" );
|
type = _ ( "XSLT stylesheet" );
|
||||||
extension = _T ( "*.xsl;*.xslt" );
|
extension = _T ( "*.xsl;*.xslt" );
|
||||||
defaulturl = lastXslStylesheet;
|
defaulturl = info.mXslFile.empty()
|
||||||
|
? lastXslStylesheet : info.mXslFile;
|
||||||
defaultaux = _T ( "" );
|
defaultaux = _T ( "" );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -5856,14 +5861,14 @@ void MyFrame::OnAssociate ( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
else if ( id == ID_ASSOCIATE_DTD_SYSTEM || id == ID_ASSOCIATE_DTD_PUBLIC )
|
else if ( id == ID_ASSOCIATE_DTD_SYSTEM || id == ID_ASSOCIATE_DTD_PUBLIC )
|
||||||
{
|
{
|
||||||
XmlAssociateDtd parser ( path, aux, "UTF-8" );
|
XmlAssociateDtd parser ( info, path, aux, "UTF-8" );
|
||||||
if ( !parser.parse ( utf8Buffer ) )
|
if ( !parser.parse ( utf8Buffer ) )
|
||||||
return;
|
return;
|
||||||
modifiedBuffer = parser.getBuffer();
|
modifiedBuffer = parser.getBuffer();
|
||||||
}
|
}
|
||||||
else if ( id == ID_ASSOCIATE_XSL )
|
else if ( id == ID_ASSOCIATE_XSL )
|
||||||
{
|
{
|
||||||
XmlAssociateXsl parser( path, "UTF-8" );
|
XmlAssociateXsl parser( info, path, "UTF-8" );
|
||||||
if ( !parser.parse ( utf8Buffer ) )
|
if ( !parser.parse ( utf8Buffer ) )
|
||||||
return;
|
return;
|
||||||
modifiedBuffer = parser.getBuffer();
|
modifiedBuffer = parser.getBuffer();
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 Zane U. Ji.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "xmltextinfo.h"
|
||||||
|
|
||||||
|
XmlTextInfo::XmlTextInfo
|
||||||
|
( const wxString &path
|
||||||
|
, const char *encoding /*= NULL*/
|
||||||
|
)
|
||||||
|
: WrapExpat ( encoding )
|
||||||
|
{
|
||||||
|
XML_SetUserData ( p, this );
|
||||||
|
XML_SetBase ( p, path.utf8_str() );
|
||||||
|
XML_SetDoctypeDeclHandler ( p, startdoctypehandler, NULL );
|
||||||
|
XML_SetProcessingInstructionHandler ( p, processinghandler );
|
||||||
|
XML_SetElementHandler ( p, start, NULL );
|
||||||
|
XML_SetDefaultHandlerExpand ( p, defaulthandler );
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlTextInfo::~XmlTextInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlTextInfo::startdoctypehandler
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *doctypeName
|
||||||
|
, const XML_Char *sysid
|
||||||
|
, const XML_Char *pubid
|
||||||
|
, int has_internal_subset
|
||||||
|
)
|
||||||
|
{
|
||||||
|
XmlTextInfo *pThis = (XmlTextInfo *)data;
|
||||||
|
|
||||||
|
pThis->mDocTypeName = wxString::FromUTF8 ( doctypeName );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlTextInfo::processinghandler
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *target
|
||||||
|
, const XML_Char *datastring
|
||||||
|
)
|
||||||
|
{
|
||||||
|
XmlTextInfo *pThis = (XmlTextInfo *)data;
|
||||||
|
|
||||||
|
if ( strcmp ( target, "xml-stylesheet" ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
char *href = strstr ( ( char * ) datastring, "href" );
|
||||||
|
if ( !href )
|
||||||
|
return;
|
||||||
|
href += strlen ( "href" );
|
||||||
|
|
||||||
|
char ch = '"'; // Is '' or "" used?
|
||||||
|
char *start = strchr ( href, ch);
|
||||||
|
char *p = strchr ( href, '\'');
|
||||||
|
if ( start == NULL
|
||||||
|
|| ( p != NULL && start > p ) )
|
||||||
|
{
|
||||||
|
start = p;
|
||||||
|
ch = '\'';
|
||||||
|
}
|
||||||
|
if ( !start++ )
|
||||||
|
return;
|
||||||
|
while ( isspace ( *start ) )
|
||||||
|
start++;
|
||||||
|
|
||||||
|
char *end = strchr ( start, ch);
|
||||||
|
if ( !end )
|
||||||
|
return;
|
||||||
|
while ( isspace ( end[-1] ) )
|
||||||
|
end--;
|
||||||
|
|
||||||
|
pThis->mXslFile = wxString::FromUTF8 ( start, end - start );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlTextInfo::start
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *el
|
||||||
|
, const XML_Char **attr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
XmlTextInfo *pThis = (XmlTextInfo *)data;
|
||||||
|
|
||||||
|
for ( ; *attr; attr += 2 )
|
||||||
|
{
|
||||||
|
if ( strstr ( *attr, ":noNamespaceSchemaLocation" ) )
|
||||||
|
{
|
||||||
|
pThis->mXsdFile = wxString::FromUTF8 ( attr[1] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( strstr ( *attr, ":schemaLocation" ) )
|
||||||
|
{ // TODO: Support multiple schemas
|
||||||
|
std::string str ( attr[1] );
|
||||||
|
char *p = strtok ( ( char * ) str.c_str(), " \t\r\n" );
|
||||||
|
if ( !p )
|
||||||
|
continue;
|
||||||
|
p = strtok ( NULL, " \t\r\n" );
|
||||||
|
if ( !p )
|
||||||
|
continue;
|
||||||
|
pThis->mXsdFile = wxString::FromUTF8 ( p );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pThis->mDocTypeName = wxString::FromUTF8 ( el );
|
||||||
|
|
||||||
|
XML_SetElementHandler ( pThis->p, NULL, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlTextInfo::defaulthandler
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *s
|
||||||
|
, int len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
XmlTextInfo *pThis = (XmlTextInfo *)data;
|
||||||
|
const char *p = s;
|
||||||
|
const char *end = s + len;
|
||||||
|
while ( p < end && *p != '\r' )
|
||||||
|
p++;
|
||||||
|
if ( p < end )
|
||||||
|
{
|
||||||
|
if ( p + 1 < end && p[1] == '\n' )
|
||||||
|
pThis->mEOL = _T ( "\r\n" );
|
||||||
|
else
|
||||||
|
pThis->mEOL = _T ( "\n" );
|
||||||
|
XML_SetDefaultHandlerExpand ( pThis->p, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = s;
|
||||||
|
while ( p < end && *p != '\r')
|
||||||
|
p++;
|
||||||
|
if ( p < end )
|
||||||
|
{
|
||||||
|
pThis->mEOL = _T ( "\n" );
|
||||||
|
XML_SetDefaultHandlerExpand ( pThis->p, NULL );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 Zane U. Ji.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMLASSOCIATEINFO_H_
|
||||||
|
#define XMLASSOCIATEINFO_H_
|
||||||
|
|
||||||
|
#include "wrapexpat.h"
|
||||||
|
|
||||||
|
class XmlTextInfo : public WrapExpat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XmlTextInfo
|
||||||
|
( const wxString &path
|
||||||
|
, const char *encoding = NULL
|
||||||
|
);
|
||||||
|
virtual ~XmlTextInfo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void XMLCALL startdoctypehandler
|
||||||
|
( void *userData
|
||||||
|
, const XML_Char *doctypeName
|
||||||
|
, const XML_Char *sysid
|
||||||
|
, const XML_Char *pubid
|
||||||
|
, int has_internal_subset
|
||||||
|
);
|
||||||
|
static void XMLCALL processinghandler
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *target
|
||||||
|
, const XML_Char *datastring
|
||||||
|
);
|
||||||
|
static void XMLCALL start
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *el
|
||||||
|
, const XML_Char **attr
|
||||||
|
);
|
||||||
|
static void XMLCALL defaulthandler
|
||||||
|
( void *data
|
||||||
|
, const XML_Char *s
|
||||||
|
, int len
|
||||||
|
);
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxString mDocTypeName;
|
||||||
|
wxString mDtdFile, mXsdFile, mXslFile;
|
||||||
|
wxString mEOL;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* XMLASSOCIATEINFO_H_ */
|
Loading…
Reference in New Issue