Updated for 1.2.0.6
This commit is contained in:
parent
41a1e77b0e
commit
ed7abc9dd5
|
@ -0,0 +1,4 @@
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
#define ASPELL_DATA_PATH "C:\\Program Files\\XML Copy Editor\\aspell\\data"
|
||||||
|
#define ASPELL_DICT_PATH "C:\\Program Files\\XML Copy Editor\\aspell\\dict"
|
||||||
|
#endif
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#include "catalogresolverthread.h"
|
||||||
|
#include "wraplibxml.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
wxCriticalSection catalogResolverCriticalSection;
|
||||||
|
|
||||||
|
CatalogResolverThread::CatalogResolverThread (
|
||||||
|
std::string *publicId,
|
||||||
|
std::string *systemId,
|
||||||
|
bool *finished,
|
||||||
|
const std::string& catalogPath ) : wxThread()//( wxTHREAD_JOINABLE )
|
||||||
|
{
|
||||||
|
myPublicIdPtr = publicId;
|
||||||
|
mySystemIdPtr = systemId;
|
||||||
|
myFinishedPtr = finished;
|
||||||
|
myCatalogPath = catalogPath;
|
||||||
|
|
||||||
|
*myFinishedPtr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *CatalogResolverThread::Entry()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker locker ( catalogResolverCriticalSection );
|
||||||
|
|
||||||
|
std::auto_ptr<WrapLibxml> libxml ( new WrapLibxml ( false, myCatalogPath ) );
|
||||||
|
*mySystemIdPtr = libxml->lookupPublicId ( *myPublicIdPtr );
|
||||||
|
}
|
||||||
|
Exit();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CatalogResolverThread::OnExit()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker locker ( catalogResolverCriticalSection );
|
||||||
|
*myFinishedPtr = true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef CATALOG_RESOLVER_THREAD_H
|
||||||
|
#define CATALOG_RESOLVER_THREAD_H
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <string>
|
||||||
|
#include <wx/thread.h>
|
||||||
|
|
||||||
|
class CatalogResolverThread : public wxThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CatalogResolverThread ( std::string *publicId, std::string *systemId, bool *finished, const std::string& catalogPath );
|
||||||
|
virtual void *Entry();
|
||||||
|
virtual void OnExit();
|
||||||
|
private:
|
||||||
|
std::string *myPublicIdPtr, *mySystemIdPtr;
|
||||||
|
std::string myCatalogPath;
|
||||||
|
bool *myFinishedPtr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,225 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <wx/hyperlink.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include "exportdialog.h"
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE ( ExportDialog, wxDialog )
|
||||||
|
EVT_BUTTON ( wxID_OK, ExportDialog::OnOk )
|
||||||
|
EVT_HELP ( wxID_OK, ExportDialog::OnContextHelp )
|
||||||
|
EVT_HELP ( wxID_CANCEL, ExportDialog::OnContextHelp )
|
||||||
|
EVT_HELP ( ID_URL, ExportDialog::OnContextHelp )
|
||||||
|
EVT_HELP ( ID_FOLDER, ExportDialog::OnContextHelp )
|
||||||
|
EVT_HELP ( ID_QUIET, ExportDialog::OnContextHelp )
|
||||||
|
EVT_HELP ( ID_MP3, ExportDialog::OnContextHelp )
|
||||||
|
EVT_UPDATE_UI ( wxID_OK, ExportDialog::OnUpdateOk )
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
ExportDialog::ExportDialog (
|
||||||
|
wxWindow *parent,
|
||||||
|
const wxString& urlParameter,
|
||||||
|
const wxString& folderParameter,
|
||||||
|
bool quietParameter,
|
||||||
|
bool suppressOptionalParameter,
|
||||||
|
bool epubParameter,
|
||||||
|
bool rtfParameter,
|
||||||
|
bool docParameter,
|
||||||
|
bool fullDaisyParameter,
|
||||||
|
bool mp3AlbumParameter,
|
||||||
|
bool downloadLinkParameter) :
|
||||||
|
wxDialog(),
|
||||||
|
url ( urlParameter ),
|
||||||
|
folder ( folderParameter ),
|
||||||
|
quiet ( quietParameter ),
|
||||||
|
suppressOptional ( suppressOptionalParameter ),
|
||||||
|
epub ( epubParameter ),
|
||||||
|
rtf ( rtfParameter ),
|
||||||
|
doc ( docParameter ),
|
||||||
|
fullDaisy ( fullDaisyParameter ),
|
||||||
|
mp3Album ( mp3AlbumParameter ),
|
||||||
|
downloadLink ( downloadLinkParameter )
|
||||||
|
{
|
||||||
|
SetExtraStyle ( wxDIALOG_EX_CONTEXTHELP );
|
||||||
|
Create (
|
||||||
|
parent,
|
||||||
|
wxID_ANY,
|
||||||
|
wxString ( _ ( "Export DAISY" ) ),
|
||||||
|
wxDefaultPosition,
|
||||||
|
wxSize ( 250, -1 ),
|
||||||
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
|
||||||
|
|
||||||
|
wxBoxSizer *dialogSizer = new wxBoxSizer ( wxVERTICAL );
|
||||||
|
|
||||||
|
wxString labelText = _ ( "&Stylesheet for conversion to canonical XHTML:" );
|
||||||
|
// pad with whitespace
|
||||||
|
labelText += _T(" ");
|
||||||
|
wxStaticText *urlLabel =
|
||||||
|
new wxStaticText ( this, wxID_ANY, labelText);
|
||||||
|
urlCtrl = new wxFilePickerCtrl ( this, ID_URL, url );
|
||||||
|
|
||||||
|
#ifndef __WXMSW__
|
||||||
|
urlCtrl->SetPath ( url );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxStaticText *folderLabel =
|
||||||
|
new wxStaticText ( this, wxID_ANY, _ ( "&Output folder:" ) );
|
||||||
|
dirPicker = new wxDirPickerCtrl (
|
||||||
|
this,
|
||||||
|
ID_FOLDER,
|
||||||
|
folder,
|
||||||
|
_T("Select a folder"),
|
||||||
|
wxDefaultPosition,
|
||||||
|
wxSize ( 300, urlCtrl->GetSize().GetHeight() )
|
||||||
|
);
|
||||||
|
|
||||||
|
wxStaticBoxSizer *prodnoteSizer = new wxStaticBoxSizer ( wxVERTICAL, this, _T("Production notes") );
|
||||||
|
quietCheckbox = new wxCheckBox ( this, ID_QUIET, _ ( "&De-emphasize production notes" ) );
|
||||||
|
quietCheckbox->SetValue ( quiet );
|
||||||
|
suppressOptionalCheckbox = new wxCheckBox ( this, ID_SUPPRESS_OPTIONAL, _ ( "&Suppress optional production notes" ) );
|
||||||
|
suppressOptionalCheckbox->SetValue ( suppressOptional );
|
||||||
|
|
||||||
|
wxStaticBoxSizer *outputSizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Outputs") );
|
||||||
|
fullDaisyCheckbox = new wxCheckBox ( this, ID_FULL_DAISY, _ ( "&Full DAISY 3.0 Talking Book" ) );
|
||||||
|
fullDaisyCheckbox->SetValue ( fullDaisy );
|
||||||
|
epubCheckbox = new wxCheckBox ( this, ID_EPUB, _ ( "&EPUB ebook" ) );
|
||||||
|
epubCheckbox->SetValue ( epub );
|
||||||
|
rtfCheckbox = new wxCheckBox ( this, ID_EPUB, _ ( "&RTF document" ) );
|
||||||
|
rtfCheckbox->SetValue ( rtf );
|
||||||
|
docCheckbox = new wxCheckBox ( this, ID_DOC, _ ( "&Word document" ) );
|
||||||
|
docCheckbox->SetValue ( rtf );
|
||||||
|
mp3AlbumCheckbox = new wxCheckBox ( this, ID_MP3, _ ( "&MP3 album" ) );
|
||||||
|
mp3AlbumCheckbox->SetValue ( mp3Album );
|
||||||
|
|
||||||
|
dialogSizer->Add ( urlLabel, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
dialogSizer->Add ( urlCtrl, 0, wxALL | wxALIGN_LEFT | wxEXPAND, 5 );
|
||||||
|
dialogSizer->Add ( folderLabel, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
dialogSizer->Add ( dirPicker, 0, wxALL | wxALIGN_LEFT | wxEXPAND, 5 );
|
||||||
|
prodnoteSizer->Add ( quietCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
prodnoteSizer->Add ( suppressOptionalCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
outputSizer->Add ( rtfCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
outputSizer->Add ( docCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
outputSizer->Add ( epubCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
outputSizer->Add ( fullDaisyCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
outputSizer->Add ( mp3AlbumCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
dialogSizer->Add ( prodnoteSizer, 0, wxTOP | wxLEFT | wxALIGN_LEFT | wxEXPAND, 5 );
|
||||||
|
dialogSizer->Add ( outputSizer, 0, wxTOP | wxLEFT | wxALIGN_LEFT | wxEXPAND, 5 );
|
||||||
|
|
||||||
|
if ( downloadLink )
|
||||||
|
{
|
||||||
|
wxHyperlinkCtrl *downloadCtrl = new wxHyperlinkCtrl (
|
||||||
|
this,
|
||||||
|
wxID_ANY,
|
||||||
|
_ ( "Download DAISY extension" ),
|
||||||
|
_T ( "http://xml-copy-editor.sourceforge.net" ) );
|
||||||
|
dialogSizer->AddSpacer ( 5 );
|
||||||
|
dialogSizer->Add ( downloadCtrl, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogSizer->AddSpacer ( 5 );
|
||||||
|
dialogSizer->Add (
|
||||||
|
CreateButtonSizer ( wxOK | wxCANCEL ), 0, wxTOP | wxBOTTOM | wxALIGN_RIGHT, 5 );
|
||||||
|
this->SetSizer ( dialogSizer );
|
||||||
|
dialogSizer->SetSizeHints ( this );
|
||||||
|
urlCtrl->SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExportDialog::~ExportDialog()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void ExportDialog::OnOk ( wxCommandEvent& e )
|
||||||
|
{
|
||||||
|
std::string urlUtf8, urlParamsUtf8;
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
url = urlCtrl->GetTextCtrlValue();
|
||||||
|
#else
|
||||||
|
url = urlCtrl->GetPath();
|
||||||
|
#endif
|
||||||
|
folder = dirPicker->GetPath();
|
||||||
|
quiet = quietCheckbox->IsChecked();
|
||||||
|
mp3Album = mp3AlbumCheckbox->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 (
|
||||||
|
this,
|
||||||
|
_ ( "Provides a space for you to enter or select a stylesheet for conversion to canonical XHTML" ) );
|
||||||
|
if ( id == ID_FOLDER )
|
||||||
|
tw = new wxTipWindow (
|
||||||
|
this,
|
||||||
|
_ ( "Provides a space for you to enter or select the output folder" ) );
|
||||||
|
else if ( id == wxID_OK )
|
||||||
|
tw = new wxTipWindow (
|
||||||
|
this,
|
||||||
|
_ ( "Starts the export" ) );
|
||||||
|
else if ( id == wxID_CANCEL )
|
||||||
|
tw = new wxTipWindow (
|
||||||
|
this,
|
||||||
|
_ ( "Closes the dialog box without exporting the file" ) );
|
||||||
|
else
|
||||||
|
{ }
|
||||||
|
e.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::OnUpdateOk ( wxUpdateUIEvent& e )
|
||||||
|
{
|
||||||
|
bool enable = true;
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
if ( urlCtrl->GetTextCtrlValue().empty() ||
|
||||||
|
#else
|
||||||
|
if ( urlCtrl->GetPath().empty() ||
|
||||||
|
#endif
|
||||||
|
dirPicker->GetPath().empty() ||
|
||||||
|
downloadLink )
|
||||||
|
enable = false;
|
||||||
|
e.Enable ( enable );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString ExportDialog::getUrlString()
|
||||||
|
{
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString ExportDialog::getFolderString()
|
||||||
|
{
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ExportDialog::getQuiet()
|
||||||
|
{
|
||||||
|
return quiet;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ExportDialog::getMp3Album()
|
||||||
|
{
|
||||||
|
return mp3Album;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportDialog::OnFolderBrowse ( wxCommandEvent& e )
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXPORT_DIALOG_H
|
||||||
|
#define EXPORT_DIALOG_H
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/tipwin.h>
|
||||||
|
#include <wx/filepicker.h>
|
||||||
|
|
||||||
|
class ExportDialog : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ExportDialog (
|
||||||
|
wxWindow *parent,
|
||||||
|
const wxString& urlParameter,
|
||||||
|
const wxString& folderParameter,
|
||||||
|
bool quiet = true,
|
||||||
|
bool suppressOptional = true,
|
||||||
|
bool epub = true,
|
||||||
|
bool rtf = true,
|
||||||
|
bool doc = true,
|
||||||
|
bool fullDaisy = true,
|
||||||
|
bool mp3Album = true,
|
||||||
|
bool downloadLink = false );
|
||||||
|
~ExportDialog();
|
||||||
|
void OnOk ( wxCommandEvent& e );
|
||||||
|
void OnContextHelp ( wxHelpEvent& e );
|
||||||
|
void OnUpdateOk ( wxUpdateUIEvent& e );
|
||||||
|
void OnFolderBrowse ( wxCommandEvent& e );
|
||||||
|
wxString getUrlString();
|
||||||
|
wxString getFolderString();
|
||||||
|
bool getQuiet();
|
||||||
|
bool getMp3Album();
|
||||||
|
enum constants
|
||||||
|
{
|
||||||
|
ID_URL,
|
||||||
|
ID_FOLDER,
|
||||||
|
ID_QUIET,
|
||||||
|
ID_SUPPRESS_OPTIONAL,
|
||||||
|
ID_FULL_DAISY,
|
||||||
|
ID_MP3,
|
||||||
|
ID_EPUB,
|
||||||
|
ID_RTF,
|
||||||
|
ID_DOC
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxStaticText *urlLabel, *folderLabel;
|
||||||
|
wxString url, folder;
|
||||||
|
wxCheckBox *quietCheckbox,
|
||||||
|
*suppressOptionalCheckbox,
|
||||||
|
*epubCheckbox,
|
||||||
|
*rtfCheckbox,
|
||||||
|
*docCheckbox,
|
||||||
|
*fullDaisyCheckbox,
|
||||||
|
*mp3AlbumCheckbox;
|
||||||
|
wxFilePickerCtrl *urlCtrl;
|
||||||
|
wxDirPickerCtrl *dirPicker;
|
||||||
|
bool quiet, suppressOptional, epub, rtf, doc, fullDaisy, mp3Album, downloadLink;
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,156 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <expat.h>
|
||||||
|
#include <cstring>
|
||||||
|
#include "wrapregex.h"
|
||||||
|
#include "mp3album.h"
|
||||||
|
|
||||||
|
Mp3Album::Mp3Album() : d ( new Mp3AlbumData() )
|
||||||
|
{
|
||||||
|
XML_SetUserData ( p, d.get() );
|
||||||
|
XML_SetElementHandler ( p, start, end );
|
||||||
|
XML_SetCharacterDataHandler ( p, characterdata );
|
||||||
|
|
||||||
|
d->trackNo = 0;
|
||||||
|
d->armed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mp3Album::~Mp3Album()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void XMLCALL Mp3Album::start ( void *data,
|
||||||
|
const XML_Char *el,
|
||||||
|
const XML_Char **attr )
|
||||||
|
{
|
||||||
|
Mp3AlbumData *ad;
|
||||||
|
ad = ( Mp3AlbumData * ) data;
|
||||||
|
|
||||||
|
std::string value;
|
||||||
|
char noArray[5];
|
||||||
|
int currentNo;
|
||||||
|
|
||||||
|
for ( ; *attr; attr += 2 )
|
||||||
|
{
|
||||||
|
|
||||||
|
if (
|
||||||
|
!strcmp ( *attr, "smilref" ) &&
|
||||||
|
!strncmp ( * ( attr + 1 ), "speechgen", 9 ) )
|
||||||
|
{
|
||||||
|
memcpy ( noArray, ( * ( attr + 1 ) ) + 9, 4 );
|
||||||
|
noArray[4] = '\0';
|
||||||
|
currentNo = atoi ( noArray );
|
||||||
|
if ( currentNo > ad->trackNo )
|
||||||
|
{
|
||||||
|
ad->trackNoString = noArray;
|
||||||
|
ad->trackNo = currentNo;
|
||||||
|
ad->armed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL Mp3Album::end ( void *data, const XML_Char *el )
|
||||||
|
{
|
||||||
|
Mp3AlbumData *ad;
|
||||||
|
ad = ( Mp3AlbumData * ) data;
|
||||||
|
|
||||||
|
if ( ad->armed )
|
||||||
|
{
|
||||||
|
ad->armed = false;
|
||||||
|
|
||||||
|
bool abbrev = false;
|
||||||
|
if ( ad->buffer.size() > 22 )
|
||||||
|
{
|
||||||
|
ad->buffer.erase ( 18 );
|
||||||
|
abbrev = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int replacements;
|
||||||
|
|
||||||
|
// no trailing whitespace
|
||||||
|
std::string pattern = "\\s+$";
|
||||||
|
WrapRegex re ( pattern, false );
|
||||||
|
ad->buffer = re.replaceGlobal ( ad->buffer, &replacements );
|
||||||
|
|
||||||
|
// no contiguous whitespace
|
||||||
|
std::string pattern2 = "\\s\\s+";
|
||||||
|
std::string replace2 = " ";
|
||||||
|
WrapRegex re2 ( pattern2, false, replace2 );
|
||||||
|
ad->buffer = re.replaceGlobal ( ad->buffer, &replacements );
|
||||||
|
|
||||||
|
// alphanumeric only
|
||||||
|
std::string pattern3 = "[;\\.\\[\\],!^&*()]";
|
||||||
|
WrapRegex re3 ( pattern3, false );
|
||||||
|
ad->buffer = re3.replaceGlobal ( ad->buffer, &replacements );
|
||||||
|
|
||||||
|
if ( abbrev )
|
||||||
|
ad->buffer.append ( "..." );
|
||||||
|
|
||||||
|
if ( ad->trackNo == 1 )
|
||||||
|
ad->albumTitle = ad->buffer;
|
||||||
|
|
||||||
|
if ( abbrev )
|
||||||
|
ad->buffer.append ( " " );
|
||||||
|
|
||||||
|
|
||||||
|
std::string source;
|
||||||
|
source.append ( "speechgen" );
|
||||||
|
source.append ( ad->trackNoString );
|
||||||
|
source.append ( ".mp3" );
|
||||||
|
|
||||||
|
std::stringstream destinationStream;
|
||||||
|
|
||||||
|
destinationStream << ad->trackNo << " - " << ad->buffer.c_str();
|
||||||
|
ad->buffer.clear();
|
||||||
|
|
||||||
|
ad->fileNameVector.push_back ( std::make_pair ( source, destinationStream.str()) );
|
||||||
|
}
|
||||||
|
if ( !ad->armed || ad->buffer.empty() )
|
||||||
|
{
|
||||||
|
ad->armed = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL Mp3Album::characterdata (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *s,
|
||||||
|
int len )
|
||||||
|
{
|
||||||
|
Mp3AlbumData *ad;
|
||||||
|
ad = ( Mp3AlbumData * ) data;
|
||||||
|
|
||||||
|
if ( ad->armed )
|
||||||
|
ad->buffer.append ( s, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mp3Album::getFileNameVector ( std::vector<std::pair<std::string, std::string> >& v )
|
||||||
|
{
|
||||||
|
v = d->fileNameVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Mp3Album::getAlbumTitle()
|
||||||
|
{
|
||||||
|
return d->albumTitle;
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MP3_ALBUM_H
|
||||||
|
#define MP3_ALBUM_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <expat.h>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
#include "wrapexpat.h"
|
||||||
|
|
||||||
|
struct Mp3AlbumData : public ParserData
|
||||||
|
{
|
||||||
|
std::string albumTitle, trackNoString, buffer;
|
||||||
|
std::vector<std::pair<std::string, std::string> > fileNameVector;
|
||||||
|
int trackNo;
|
||||||
|
bool armed;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Mp3Album : public WrapExpat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Mp3Album();
|
||||||
|
virtual ~Mp3Album();
|
||||||
|
void getFileNameVector ( std::vector<std::pair<std::string, std::string> >& v );
|
||||||
|
std::string getAlbumTitle();
|
||||||
|
private:
|
||||||
|
std::auto_ptr<Mp3AlbumData> d;
|
||||||
|
static void XMLCALL start ( void *data, const XML_Char *el, const XML_Char **attr );
|
||||||
|
static void XMLCALL end ( void *data, const XML_Char *el );
|
||||||
|
static void XMLCALL characterdata ( void *data, const XML_Char *s, int len );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,418 @@
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/progdlg.h>
|
||||||
|
#include "wrapdaisy.h"
|
||||||
|
#include "wraptempfilename.h"
|
||||||
|
#include "wraplibxml.h"
|
||||||
|
#include "xmlprodnote.h"
|
||||||
|
#include "mp3album.h"
|
||||||
|
#include "binaryfile.h"
|
||||||
|
|
||||||
|
WrapDaisy::WrapDaisy ( const wxString& daisyDirParameter ) :
|
||||||
|
daisyDir ( daisyDirParameter)
|
||||||
|
{
|
||||||
|
albumCover = daisyDir + _T("cover.jpg");
|
||||||
|
|
||||||
|
memoryCwd = wxFileName::GetCwd();
|
||||||
|
daisyCwd = daisyDir +
|
||||||
|
_T("pipeline-20090410") +
|
||||||
|
wxFileName::GetPathSeparator();
|
||||||
|
wxFileName::SetCwd ( daisyCwd );
|
||||||
|
|
||||||
|
std::string systemCmd = "cd ";
|
||||||
|
systemCmd += daisyCwd.mb_str ( wxConvUTF8 );
|
||||||
|
system ( systemCmd.c_str() );
|
||||||
|
|
||||||
|
classPath = _T("\"pipeline.jar\";\".\"");
|
||||||
|
commandLineUI = _T("org.daisy.pipeline.ui.CommandLineUI");
|
||||||
|
|
||||||
|
baseCmd = _T("java -classpath ") +
|
||||||
|
classPath +
|
||||||
|
_T( " " ) +
|
||||||
|
commandLineUI +
|
||||||
|
_T(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapDaisy::~WrapDaisy()
|
||||||
|
{
|
||||||
|
wxFileName::SetCwd ( memoryCwd );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WrapDaisy::run (
|
||||||
|
wxString& fileIn,
|
||||||
|
wxString& stylesheet,
|
||||||
|
wxString& folder,
|
||||||
|
bool quiet,
|
||||||
|
bool suppressOptional,
|
||||||
|
bool epub,
|
||||||
|
bool rtf,
|
||||||
|
bool fullDaisy,
|
||||||
|
bool mp3Album )
|
||||||
|
{
|
||||||
|
fileIn.Replace ( _T("\\"), _T("/") );
|
||||||
|
stylesheet.Replace ( _T("\\"), _T("/") );
|
||||||
|
|
||||||
|
std::auto_ptr<wxProgressDialog> pd ( new wxProgressDialog (
|
||||||
|
_ ( "Export in progress" ),
|
||||||
|
_ ( "Initializing..." ),
|
||||||
|
100,
|
||||||
|
NULL,
|
||||||
|
wxPD_SMOOTH | wxPD_CAN_ABORT ) );
|
||||||
|
|
||||||
|
// #1: convert to canonical XHTML
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 20, _T("Preparing canonical XHTML...") ) )
|
||||||
|
{
|
||||||
|
error = _T( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapTempFileName canonicalFile;
|
||||||
|
WrapTempFileName dtbFile ( wxEmptyString, _T(".xml"));
|
||||||
|
WrapLibxml wrapLibxml;
|
||||||
|
std::string stdStylesheet, stdFileIn;
|
||||||
|
stdStylesheet = stylesheet.mb_str ( wxConvUTF8 );
|
||||||
|
stdFileIn = fileIn.mb_str ( wxConvUTF8 );
|
||||||
|
|
||||||
|
bool success = wrapLibxml.xslt ( stdStylesheet, stdFileIn );
|
||||||
|
|
||||||
|
if ( !success )
|
||||||
|
{
|
||||||
|
std::string stdError = wrapLibxml.getLastError();
|
||||||
|
error = wxString ( stdError.c_str(), wxConvUTF8, stdError.size() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string output = wrapLibxml.getOutput();
|
||||||
|
|
||||||
|
if ( output.empty() )
|
||||||
|
{
|
||||||
|
error = _ ("Empty XHTML file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( quiet )
|
||||||
|
{
|
||||||
|
// #1.5: apply quiet setting if req'd
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 20, _("De-emphasizing production notes...") ) )
|
||||||
|
{
|
||||||
|
error = _ ( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto_ptr<XmlProdnote> xp ( new XmlProdnote() );
|
||||||
|
if ( !xp->parse ( output.c_str() ) )
|
||||||
|
{
|
||||||
|
std::string stdError = xp->getLastError();
|
||||||
|
error = wxString ( stdError.c_str(), wxConvUTF8, stdError.size() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
output = xp->getBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ofstream canonicalStream ( canonicalFile.name().c_str() );
|
||||||
|
if ( !canonicalStream )
|
||||||
|
{
|
||||||
|
error = _T( "Cannot write canonical XHTML file" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
canonicalStream << output.c_str() << std::endl;
|
||||||
|
canonicalStream.close();
|
||||||
|
|
||||||
|
// #2: convert to DTBook
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 40, _T("Preparing DTBook...") ) )
|
||||||
|
{
|
||||||
|
error = _T ( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString xhtml2dtbookScript;
|
||||||
|
|
||||||
|
xhtml2dtbookScript += _T("scripts");
|
||||||
|
xhtml2dtbookScript += wxFileName::GetPathSeparator();
|
||||||
|
xhtml2dtbookScript += _T("create_distribute");
|
||||||
|
xhtml2dtbookScript += wxFileName::GetPathSeparator();
|
||||||
|
xhtml2dtbookScript += _T("dtbook");
|
||||||
|
xhtml2dtbookScript += wxFileName::GetPathSeparator();
|
||||||
|
xhtml2dtbookScript += _T("Xhtml2Dtbook.taskScript");
|
||||||
|
|
||||||
|
wxString cmd = baseCmd +
|
||||||
|
xhtml2dtbookScript +
|
||||||
|
_T(" --inputFile=") +
|
||||||
|
canonicalFile.wideName() + _T(" --outputFile=") +
|
||||||
|
dtbFile.wideName();
|
||||||
|
|
||||||
|
wxArrayString out, err;
|
||||||
|
|
||||||
|
int result = wxExecute ( cmd, out, err );
|
||||||
|
|
||||||
|
int count = err.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += err.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*count = out.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += out.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
if ( !error.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// #2.5: create EPUB version
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 50, _T("Transforming to EPUB ebook...") ) )
|
||||||
|
{
|
||||||
|
error = _T ( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString epubScript;
|
||||||
|
|
||||||
|
epubScript += _T("scripts");
|
||||||
|
epubScript += wxFileName::GetPathSeparator();
|
||||||
|
epubScript += _T("create_distribute");
|
||||||
|
epubScript += wxFileName::GetPathSeparator();
|
||||||
|
epubScript += _T("epub");
|
||||||
|
epubScript += wxFileName::GetPathSeparator();
|
||||||
|
epubScript += _T("OPSCreator.taskScript");
|
||||||
|
|
||||||
|
cmd = baseCmd +
|
||||||
|
_T("\"") + epubScript + _T("\" --input=\"") +
|
||||||
|
canonicalFile.wideName() + _T("\" --output=\"") +
|
||||||
|
folder + wxFileName::GetPathSeparator() + _T("ebook.epub\"");
|
||||||
|
|
||||||
|
result = wxExecute ( cmd, out, err );
|
||||||
|
|
||||||
|
count = err.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += err.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
count = out.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += out.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( !error.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// #2.9: convert to RTF
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 50, _T("Transforming to RTF...") ) )
|
||||||
|
{
|
||||||
|
error = _T ( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString rtfScript;
|
||||||
|
|
||||||
|
rtfScript += _T("scripts");
|
||||||
|
rtfScript += wxFileName::GetPathSeparator();
|
||||||
|
rtfScript += _T("create_distribute");
|
||||||
|
rtfScript += wxFileName::GetPathSeparator();
|
||||||
|
rtfScript += _T("text");
|
||||||
|
rtfScript += wxFileName::GetPathSeparator();
|
||||||
|
rtfScript += _T("DtbookToRtf.taskScript");
|
||||||
|
|
||||||
|
cmd = baseCmd +
|
||||||
|
_T("\"") + rtfScript + _T("\" --input=\"") +
|
||||||
|
canonicalFile.wideName() + _T("\" --output=\"") +
|
||||||
|
folder + wxFileName::GetPathSeparator() + _T("document.rtf\" --inclToc=\"true\" --inclPagenum=\"false\"");
|
||||||
|
|
||||||
|
result = wxExecute ( cmd, out, err );
|
||||||
|
|
||||||
|
count = err.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += err.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
count = out.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += out.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**/
|
||||||
|
|
||||||
|
if ( !error.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// #3: convert to full DAISY book
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 60, _T("Preparing DAISY book...") ) )
|
||||||
|
{
|
||||||
|
error = _T ( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString narratorScript;
|
||||||
|
|
||||||
|
narratorScript += _T("scripts");
|
||||||
|
narratorScript += wxFileName::GetPathSeparator();
|
||||||
|
narratorScript += _T("create_distribute");
|
||||||
|
narratorScript += wxFileName::GetPathSeparator();
|
||||||
|
narratorScript += _T("dtb");
|
||||||
|
narratorScript += wxFileName::GetPathSeparator();
|
||||||
|
narratorScript += _T("Narrator-DtbookToDaisy.taskScript");
|
||||||
|
|
||||||
|
cmd = baseCmd +
|
||||||
|
_T("\"") + narratorScript + _T("\" --input=") +
|
||||||
|
dtbFile.wideName() + _T(" --outputPath=") +
|
||||||
|
_T("\"") +
|
||||||
|
folder +
|
||||||
|
_T("\"");
|
||||||
|
|
||||||
|
result = wxExecute ( cmd, out, err );
|
||||||
|
|
||||||
|
count = err.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += err.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
count = out.GetCount();
|
||||||
|
if ( count )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
error += out.Item ( i );
|
||||||
|
error += _T(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( !error.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// #4: create MP3 album
|
||||||
|
pd->ProcessPendingEvents();
|
||||||
|
if ( !pd->Update ( 80, _T("Preparing MP3 album...") ) )
|
||||||
|
{
|
||||||
|
error = _T ( "Cancelled" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//rename mp3 files in //z3986/
|
||||||
|
wxFileName fn ( dtbFile.wideName() );
|
||||||
|
wxString folderWithSmilFile, fileWithSmilAttribs;
|
||||||
|
folderWithSmilFile =
|
||||||
|
folder + wxFileName::GetPathSeparator() +
|
||||||
|
_T("z3986") + wxFileName::GetPathSeparator();
|
||||||
|
fileWithSmilAttribs = folderWithSmilFile + fn.GetFullName();
|
||||||
|
|
||||||
|
std::string file = ( const char *) fileWithSmilAttribs.mb_str ( wxConvUTF8 );
|
||||||
|
|
||||||
|
auto_ptr<Mp3Album> ma ( new Mp3Album() );
|
||||||
|
|
||||||
|
BinaryFile *binaryfile;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
binaryfile = new BinaryFile ( file.c_str() );
|
||||||
|
}
|
||||||
|
catch ( ... )
|
||||||
|
{
|
||||||
|
error.Printf ( _ ( "Cannot open %s" ), file.c_str() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !ma->parse ( binaryfile->getData(), binaryfile->getDataLen() ) )
|
||||||
|
{
|
||||||
|
std::string stdError = ma->getLastError();
|
||||||
|
error = wxString ( stdError.c_str(), wxConvUTF8, stdError.size() );
|
||||||
|
delete binaryfile;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete binaryfile;
|
||||||
|
|
||||||
|
wxString albumDir = folder;
|
||||||
|
albumDir += wxFileName::GetPathSeparator();
|
||||||
|
|
||||||
|
std::string albumTitle = ma->getAlbumTitle();
|
||||||
|
wxString wideAlbumTitle = wxString ( albumTitle.c_str(), wxConvUTF8, albumTitle.size() );
|
||||||
|
albumDir += wideAlbumTitle;
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
albumDir.Replace ( _T("."), wxEmptyString );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxFileName dir ( albumDir );
|
||||||
|
bool dirExists = dir.DirExists();
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
if ( !wxMkDir ( albumDir ) && !dirExists )
|
||||||
|
#else
|
||||||
|
if ( !wxMkDir ( (const char *) albumDir.mb_str( wxConvUTF8 ), 0 ) && !dirExists )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
error = _ ("Cannot create MP3 album folder ") + albumDir;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, std::string> > v;
|
||||||
|
ma->getFileNameVector ( v );
|
||||||
|
size_t vectorSize = v.size();
|
||||||
|
wxString sourcePath, destPath, wideSourceFile, wideDestFile;
|
||||||
|
std::string sourceFile, destFile;
|
||||||
|
for ( size_t i = 0; i < vectorSize; i++ )
|
||||||
|
{
|
||||||
|
sourceFile = v[i].first;
|
||||||
|
destFile = v[i].second;
|
||||||
|
|
||||||
|
wideSourceFile = wxString ( sourceFile.c_str(), wxConvUTF8, sourceFile.size() );
|
||||||
|
wideDestFile = wxString ( destFile.c_str(), wxConvUTF8, destFile.size() );
|
||||||
|
|
||||||
|
sourcePath = folderWithSmilFile + wideSourceFile;
|
||||||
|
destPath = albumDir + wxFileName::GetPathSeparator() +
|
||||||
|
wideDestFile + _T(".mp3");
|
||||||
|
wxCopyFile ( sourcePath, destPath, true );
|
||||||
|
}
|
||||||
|
wxString destAlbumCover = albumDir +
|
||||||
|
wxFileName::GetPathSeparator() +
|
||||||
|
_T("cover.jpg");
|
||||||
|
wxCopyFile ( albumCover, destAlbumCover, true );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString WrapDaisy::getLastError()
|
||||||
|
{
|
||||||
|
return error;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef WRAPDAISY_H
|
||||||
|
#define WRAPDAISY_H
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
class WrapDaisy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WrapDaisy ( const wxString& daisyDir );
|
||||||
|
~WrapDaisy();
|
||||||
|
bool run (
|
||||||
|
wxString& fileIn,
|
||||||
|
wxString& stylesheet,
|
||||||
|
wxString& folder,
|
||||||
|
bool quiet,
|
||||||
|
bool suppressOptional,
|
||||||
|
bool epub,
|
||||||
|
bool rtf,
|
||||||
|
bool fullDaisy,
|
||||||
|
bool mp3Album );
|
||||||
|
wxString getLastError();
|
||||||
|
private:
|
||||||
|
wxString daisyDir, classPath, commandLineUI, baseCmd, error,
|
||||||
|
memoryCwd, daisyCwd, albumCover;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <expat.h>
|
||||||
|
#include <cstring>
|
||||||
|
#include "xmlprodnote.h"
|
||||||
|
|
||||||
|
XmlProdnote::XmlProdnote (
|
||||||
|
bool parseDeclaration,
|
||||||
|
bool expandInternalEntities,
|
||||||
|
size_t size ) :
|
||||||
|
d ( new ProdnoteData() )
|
||||||
|
{
|
||||||
|
d->buffer.reserve ( size );
|
||||||
|
XML_SetUserData ( p, d.get() );
|
||||||
|
|
||||||
|
// parse declaration?
|
||||||
|
if ( parseDeclaration )
|
||||||
|
XML_SetXmlDeclHandler ( p, xmldeclhandler );
|
||||||
|
|
||||||
|
// internal entities
|
||||||
|
if ( expandInternalEntities )
|
||||||
|
XML_SetDefaultHandlerExpand ( p, defaulthandler );
|
||||||
|
else
|
||||||
|
XML_SetDefaultHandler ( p, defaulthandler );
|
||||||
|
|
||||||
|
XML_SetElementHandler ( p, start, end );
|
||||||
|
d->level = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlProdnote::~XmlProdnote()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void XMLCALL XmlProdnote::xmldeclhandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *version,
|
||||||
|
const XML_Char *encoding,
|
||||||
|
int standalone )
|
||||||
|
{
|
||||||
|
ProdnoteData *d;
|
||||||
|
d = ( ProdnoteData * ) data;
|
||||||
|
|
||||||
|
d->encoding = ( encoding ) ? encoding : "UTF-8";
|
||||||
|
|
||||||
|
d->buffer.append ( "<?xml version=\"" );
|
||||||
|
d->buffer.append ( version );
|
||||||
|
d->buffer.append ( "\" encoding=\"" );
|
||||||
|
d->buffer.append ( d->encoding );
|
||||||
|
d->buffer.append ( "\"" );
|
||||||
|
|
||||||
|
if ( standalone != -1 )
|
||||||
|
{
|
||||||
|
d->buffer.append ( " standalone=\"" );
|
||||||
|
d->buffer.append ( ( standalone == 1 ) ? "yes" : "no" );
|
||||||
|
d->buffer.append ( "\"" );
|
||||||
|
}
|
||||||
|
d->buffer.append ( "?>" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlProdnote::defaulthandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *s,
|
||||||
|
int len )
|
||||||
|
{
|
||||||
|
ProdnoteData *d;
|
||||||
|
d = ( ProdnoteData * ) data;
|
||||||
|
d->buffer.append ( s, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlProdnote::start ( void *data,
|
||||||
|
const XML_Char *el,
|
||||||
|
const XML_Char **attr )
|
||||||
|
{
|
||||||
|
ProdnoteData *pd;
|
||||||
|
pd = ( ProdnoteData * ) data;
|
||||||
|
|
||||||
|
pd->level += 1;
|
||||||
|
|
||||||
|
bool skip = false;
|
||||||
|
|
||||||
|
std::string tag;
|
||||||
|
tag += "<";
|
||||||
|
tag += el;
|
||||||
|
|
||||||
|
for ( ; *attr; attr += 2 )
|
||||||
|
{
|
||||||
|
tag += " ";
|
||||||
|
tag += *attr;
|
||||||
|
tag += "=\"";
|
||||||
|
tag += *(attr + 1);
|
||||||
|
tag += "\"";
|
||||||
|
if ( !strcmp ( el, "span" ) && !strcmp (*attr, "class") )
|
||||||
|
{
|
||||||
|
if ( !strcmp ( *(attr + 1), "optional-prodnote" ) ||
|
||||||
|
!strcmp ( *(attr + 1), "required-prodnote" ) )
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
|
pd->level = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tag += ">";
|
||||||
|
|
||||||
|
if ( skip )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pd->buffer += tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlProdnote::end ( void *data, const XML_Char *el )
|
||||||
|
{
|
||||||
|
ProdnoteData *pd;
|
||||||
|
pd = ( ProdnoteData * ) data;
|
||||||
|
|
||||||
|
pd->level -= 1;
|
||||||
|
|
||||||
|
if ( !(pd->level) && !strcmp ( el, "span" ) )
|
||||||
|
{
|
||||||
|
pd->level = 100;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pd->buffer += "</";
|
||||||
|
pd->buffer += el;
|
||||||
|
pd->buffer += ">";
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XML_PRODNOTE_H
|
||||||
|
#define XML_PRODNOTE_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <expat.h>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include "wrapexpat.h"
|
||||||
|
|
||||||
|
struct ProdnoteData : public ParserData
|
||||||
|
{
|
||||||
|
int level;
|
||||||
|
std::string encoding, buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class XmlProdnote : public WrapExpat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XmlProdnote (
|
||||||
|
bool parseDeclaration = false,
|
||||||
|
bool expandInternalEntities = true,
|
||||||
|
size_t size = BUFSIZ
|
||||||
|
);
|
||||||
|
virtual ~XmlProdnote();
|
||||||
|
std::string getBuffer()
|
||||||
|
{
|
||||||
|
return d->buffer;
|
||||||
|
}
|
||||||
|
std::string getEncoding()
|
||||||
|
{
|
||||||
|
return d->encoding;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::auto_ptr<ProdnoteData> d;
|
||||||
|
std::string encoding, element, attribute;
|
||||||
|
static void XMLCALL xmldeclhandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *version,
|
||||||
|
const XML_Char *encoding,
|
||||||
|
int standalone );
|
||||||
|
static void XMLCALL defaulthandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *s,
|
||||||
|
int len );
|
||||||
|
static void XMLCALL start ( void *data, const XML_Char *el, const XML_Char **attr );
|
||||||
|
static void XMLCALL end ( void *data, const XML_Char *el );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <expat.h>
|
||||||
|
#include "xmlschemaparser.h"
|
||||||
|
|
||||||
|
XmlSchemaParser::XmlSchemaParser ( PromptGeneratorData *data, bool nameSpaceAware ) :
|
||||||
|
WrapExpat ( nameSpaceAware ), d ( new SchemaParserData )
|
||||||
|
{
|
||||||
|
d->promptData = data;
|
||||||
|
d->setState ( STATE_UNKNOWN );
|
||||||
|
XML_SetUserData ( p, d.get() );
|
||||||
|
XML_SetElementHandler ( p, starthandler, endhandler );
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlSchemaParser::~XmlSchemaParser()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void XMLCALL XmlSchemaParser::starthandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *el,
|
||||||
|
const XML_Char **attr )
|
||||||
|
{
|
||||||
|
SchemaParserData *d;
|
||||||
|
d = ( SchemaParserData * ) data;
|
||||||
|
if ( !strcmp ( el, "http://www.w3.org/2001/XMLSchema:complexType" ) )
|
||||||
|
{
|
||||||
|
d->setState ( STATE_COMPLEX_TYPE );
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( *attr )
|
||||||
|
{
|
||||||
|
attr += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLCALL XmlSchemaParser::endhandler ( void *data, const XML_Char *el )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XML_SCHEMA_PARSER_H
|
||||||
|
#define XML_SCHEMA_PARSER_H
|
||||||
|
|
||||||
|
#include <expat.h>
|
||||||
|
#include <string>
|
||||||
|
#include "wrapexpat.h"
|
||||||
|
#include "xmlpromptgenerator.h"
|
||||||
|
|
||||||
|
struct SchemaParserData : public ParserData
|
||||||
|
{
|
||||||
|
PromptGeneratorData *promptData;
|
||||||
|
std::map<std::string, std::set<std::string> > referenceMap;
|
||||||
|
std::string currentElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
class XmlSchemaParser : public WrapExpat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XmlSchemaParser ( PromptGeneratorData *data, bool nameSpaceAware );
|
||||||
|
virtual ~XmlSchemaParser();
|
||||||
|
enum {
|
||||||
|
STATE_UNKNOWN,
|
||||||
|
STATE_ROOT,
|
||||||
|
STATE_ELEMENT,
|
||||||
|
STATE_SIMPLE_TYPE,
|
||||||
|
STATE_COMPLEX_TYPE,
|
||||||
|
STATE_SEQUENCE,
|
||||||
|
STATE_CHOICE
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
std::auto_ptr<SchemaParserData> d;
|
||||||
|
static void XMLCALL starthandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *el,
|
||||||
|
const XML_Char **attr );
|
||||||
|
static void XMLCALL endhandler (
|
||||||
|
void *data,
|
||||||
|
const XML_Char *el );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue