updated for v. 1.0.3

This commit is contained in:
Gerald Schmidt 2010-04-25 22:24:53 +00:00
parent 635f783128
commit 68b60043a3
9 changed files with 272 additions and 200 deletions

View File

@ -165,6 +165,12 @@ void ExportDialog::OnOk ( wxCommandEvent& e )
folder = dirPicker->GetPath();
quiet = quietCheckbox->IsChecked();
mp3Album = mp3AlbumCheckbox->IsChecked();
suppressOptional = suppressOptionalCheckbox->IsChecked();
html = htmlCheckbox->IsChecked();
epub = epubCheckbox->IsChecked();
rtf = rtfCheckbox->IsChecked();
doc = docCheckbox->IsChecked();
fullDaisy = fullDaisyCheckbox->IsChecked();
urlUtf8 = ( const char * ) url.mb_str ( wxConvUTF8 );
e.Skip();
@ -199,13 +205,6 @@ void ExportDialog::OnContextHelp ( wxHelpEvent& e )
void ExportDialog::OnUpdateOk ( wxUpdateUIEvent& e )
{
bool enable = true;
/*
#ifdef __WXMSW__
if ( urlCtrl->GetTextCtrlValue().empty() ||
#else
if ( urlCtrl->GetPath().empty() ||
#endif
*/
if (
dirPicker->GetPath().empty() ||
downloadLink )
@ -233,6 +232,13 @@ bool ExportDialog::getMp3Album()
return mp3Album;
}
bool ExportDialog::getSuppressOptional() { return suppressOptional; }
bool ExportDialog::getHtml() { return html; }
bool ExportDialog::getEpub() { return epub; }
bool ExportDialog::getRtf() { return rtf; }
bool ExportDialog::getDoc() { return doc; }
bool ExportDialog::getFullDaisy() { return fullDaisy; }
void ExportDialog::OnFolderBrowse ( wxCommandEvent& e )
{
}

View File

@ -49,6 +49,13 @@ class ExportDialog : public wxDialog
wxString getFolderString();
bool getQuiet();
bool getMp3Album();
bool getSuppressOptional();
bool getHtml();
bool getEpub();
bool getRtf();
bool getDoc();
bool getFullDaisy();
enum constants
{
ID_URL,

View File

@ -66,6 +66,7 @@ bool WrapDaisy::run (
bool suppressOptional,
bool epub,
bool rtf,
bool doc,
bool fullDaisy,
bool mp3Album )
{
@ -348,176 +349,185 @@ bool WrapDaisy::run (
while (wxTheApp->Pending())
wxTheApp->Dispatch();
if ( !pd->Update ( 50, _T("Preparing ePub...") ) )
if ( epub )
{
error = _T ( "Cancelled" );
return false;
}
wxString epubScript;
if ( !pd->Update ( 50, _T("Preparing ePub...") ) )
{
error = _T ( "Cancelled" );
return false;
}
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 + //canonicalFile.wideName() +
_T("\" --output=\"") +
folder + wxFileName::GetPathSeparator() + _T("ebook.epub\"");
wxString epubScript;
result = wxExecute ( cmd, out, err );
count = err.GetCount();
if ( count )
{
for ( int i = 0; i < count; i++ )
{
error += err.Item ( i );
error += _T(" ");
}
}
epubScript += _T("scripts");
epubScript += wxFileName::GetPathSeparator();
epubScript += _T("create_distribute");
epubScript += wxFileName::GetPathSeparator();
epubScript += _T("epub");
epubScript += wxFileName::GetPathSeparator();
epubScript += _T("OPSCreator.taskScript");
/*
count = out.GetCount();
if ( count )
{
for ( int i = 0; i < count; i++ )
cmd = baseCmd +
_T("\"") + epubScript + _T("\" --input=\"") +
canonicalFile + //canonicalFile.wideName() +
_T("\" --output=\"") +
folder + wxFileName::GetPathSeparator() + _T("ebook.epub\"");
result = wxExecute ( cmd, out, err );
count = err.GetCount();
if ( count )
{
error += out.Item ( i );
error += _T(" ");
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;
}
*/
if ( !error.empty() )
return false;
// #2.9: convert to RTF
pd->ProcessPendingEvents();
while (wxTheApp->Pending())
wxTheApp->Dispatch();
if ( !pd->Update ( 60, _T("Preparing RTF...") ) )
if ( rtf || doc )
{
error = _T ( "Cancelled" );
return false;
}
wxString rtfScript;
pd->ProcessPendingEvents();
while (wxTheApp->Pending())
wxTheApp->Dispatch();
rtfScript += _T("scripts");
rtfScript += wxFileName::GetPathSeparator();
rtfScript += _T("create_distribute");
rtfScript += wxFileName::GetPathSeparator();
rtfScript += _T("text");
rtfScript += wxFileName::GetPathSeparator();
rtfScript += _T("DtbookToRtf.taskScript");
wxString rtfFile, tempRtfFile, docFile, tempDocFile;
rtfFile = folder + wxFileName::GetPathSeparator() + _T("document.rtf");
tempRtfFile = folder + wxFileName::GetPathSeparator() + _T("html") +
wxFileName::GetPathSeparator() + _T("document.rtf");
docFile = rtfFile;
tempDocFile = tempRtfFile;
docFile.Replace ( _T(".rtf"), _T(".doc") );
tempDocFile.Replace ( _T(".rtf"), _T(".doc") );
if ( !pd->Update ( 60, _T("Preparing RTF...") ) )
{
error = _T ( "Cancelled" );
return false;
}
cmd = baseCmd +
_T("\"") + rtfScript + _T("\" --input=\"") +
dtbFilePath + //dtbFile.wideName() +
_T("\" --output=\"") + rtfFile +
_T("\" --inclTOC=\"true\" --inclPagenum=\"false\"");
wxString rtfScript;
result = wxExecute ( cmd, out, err );
count = err.GetCount();
if ( count )
{
for ( int i = 0; i < count; i++ )
rtfScript += _T("scripts");
rtfScript += wxFileName::GetPathSeparator();
rtfScript += _T("create_distribute");
rtfScript += wxFileName::GetPathSeparator();
rtfScript += _T("text");
rtfScript += wxFileName::GetPathSeparator();
rtfScript += _T("DtbookToRtf.taskScript");
wxString rtfFile, tempRtfFile, docFile, tempDocFile;
rtfFile = folder + wxFileName::GetPathSeparator() + _T("document.rtf");
tempRtfFile = folder + wxFileName::GetPathSeparator() + _T("html") +
wxFileName::GetPathSeparator() + _T("document.rtf");
docFile = rtfFile;
tempDocFile = tempRtfFile;
docFile.Replace ( _T(".rtf"), _T(".doc") );
tempDocFile.Replace ( _T(".rtf"), _T(".doc") );
cmd = baseCmd +
_T("\"") + rtfScript + _T("\" --input=\"") +
dtbFilePath + //dtbFile.wideName() +
_T("\" --output=\"") + rtfFile +
_T("\" --inclTOC=\"true\" --inclPagenum=\"false\"");
result = wxExecute ( cmd, out, err );
count = err.GetCount();
if ( count )
{
error += err.Item ( i );
error += _T(" ");
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.5: convert to binary Word
// (Win only; otherwise create copy with *.doc extension)
pd->ProcessPendingEvents();
while (wxTheApp->Pending())
wxTheApp->Dispatch();
if ( !pd->Update ( 60, _T("Preparing Word document...") ) )
{
error = _T ( "Cancelled" );
return false;
}
//wxString docFile = rtfFile;
//docFile.Replace ( _T(".rtf"), _T(".doc") );
#ifdef __WXMSW__
wxAutomationObject wordObject, documentObject;
if ( wordObject.CreateInstance ( _T("Word.Application") ) )
{
wxVariant openParams[2];
openParams[0] = rtfFile;//tempRtfFile
openParams[1] = false;
wordObject.CallMethod(_("documents.open"), 2, openParams);
if (!wordObject.GetObject(documentObject, _("ActiveDocument")))
{
error = _("Cannot open ") + rtfFile;//tempRtfFile;
return false;
}
wxVariant saveAsParams[2];
saveAsParams[0] = docFile;//tempDocFile;//
saveAsParams[1] = (long)0; //wdFormatDocument
if ( !documentObject.CallMethod(_("SaveAs"), 2, saveAsParams) )
{
//error = _("Cannot save ") + docFile;
//return false;
}
documentObject.CallMethod(_("Close"), 0, NULL );
wordObject.CallMethod(_T("Quit"), 0, NULL );
}
#else
//wxCopyFile ( tempRtfFile, tempDocFile );
wxCopyFile ( rtfFile, docFile );
#endif
//wxCopyFile ( tempRtfFile, rtfFile );
//wxCopyFile ( tempDocFile, docFile );
//wxRemoveFile ( tempRtfFile );
//wxRemoveFile ( tempDocFile );
}
/*
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.5: convert to binary Word
// (Win only; otherwise create copy with *.doc extension)
pd->ProcessPendingEvents();
while (wxTheApp->Pending())
wxTheApp->Dispatch();
if ( !pd->Update ( 60, _T("Preparing Word document...") ) )
{
error = _T ( "Cancelled" );
return false;
}
//wxString docFile = rtfFile;
//docFile.Replace ( _T(".rtf"), _T(".doc") );
#ifdef __WXMSW__
wxAutomationObject wordObject, documentObject;
if ( wordObject.CreateInstance ( _T("Word.Application") ) )
{
wxVariant openParams[2];
openParams[0] = rtfFile;//tempRtfFile
openParams[1] = false;
wordObject.CallMethod(_("documents.open"), 2, openParams);
if (!wordObject.GetObject(documentObject, _("ActiveDocument")))
{
error = _("Cannot open ") + rtfFile;//tempRtfFile;
return false;
}
wxVariant saveAsParams[2];
saveAsParams[0] = docFile;//tempDocFile;//
saveAsParams[1] = (long)0; //wdFormatDocument
if ( !documentObject.CallMethod(_("SaveAs"), 2, saveAsParams) )
{
//error = _("Cannot save ") + docFile;
//return false;
}
documentObject.CallMethod(_("Close"), 0, NULL );
wordObject.CallMethod(_T("Quit"), 0, NULL );
}
#else
//wxCopyFile ( tempRtfFile, tempDocFile );
wxCopyFile ( rtfFile, docFile );
#endif
//wxCopyFile ( tempRtfFile, rtfFile );
//wxCopyFile ( tempDocFile, docFile );
//wxRemoveFile ( tempRtfFile );
//wxRemoveFile ( tempDocFile );
// #3: convert to full DAISY book
pd->ProcessPendingEvents();
while (wxTheApp->Pending())
wxTheApp->Dispatch();
if ( !fullDaisy )
return true; // no full DAISY, no audio
if ( !pd->Update ( 70, _T("Preparing DAISY books...") ) )
{
error = _T ( "Cancelled" );
@ -569,6 +579,9 @@ bool WrapDaisy::run (
if ( !error.empty() )
return false;
if ( !mp3Album )
return true;
// #4: create MP3 album
pd->ProcessPendingEvents();
while (wxTheApp->Pending())
@ -651,19 +664,19 @@ bool WrapDaisy::run (
while (wxTheApp->Pending())
wxTheApp->Dispatch();
/*
if ( !pd->Update ( 90, _T("Updating playlists...") ) )
{
error = _T ( "Cancelled" );
return false;
}
/*
//rename mp3 playlists
albumDir += wxFileName::GetPathSeparator();
PlayListRenamer plr;
std::string stdAlbumDir = ( const char *) albumDir.mb_str ( wxConvUTF8 );
plr.run ( stdAlbumDir );
*/
//albumDir += wxFileName::GetPathSeparator();
//PlayListRenamer plr;
//std::string stdAlbumDir = ( const char *) albumDir.mb_str ( wxConvUTF8 );
//plr.run ( stdAlbumDir );
//rename mp3 files in //z3986/
wxFileName fn ( dtbFilePath );
@ -741,6 +754,7 @@ bool WrapDaisy::run (
wxFileName::GetPathSeparator() +
_T("cover.jpg");
wxCopyFile ( albumCover, destAlbumCover, true );
*/
return true;
}

View File

@ -20,6 +20,7 @@ public:
bool suppressOptional,
bool epub,
bool rtf,
bool doc,
bool fullDaisy,
bool mp3Album );
wxString getLastError();

View File

@ -617,12 +617,23 @@ MyFrame::MyFrame (
lastXslStylesheet.Replace ( _T ( " " ), _T ( "%20" ), true );
lastRelaxNGSchema.Replace ( _T ( " " ), _T ( "%20" ), true );
exportQuiet =
config->Read ( _T ( "exportQuiet" ), (long)false );
config->Read ( _T ( "exportQuiet" ), (long)true );
exportMp3Album =
config->Read ( _T ( "exportMp3Album" ), (long)false );
config->Read ( _T ( "exportMp3Album" ), (long)true );
exportSuppressOptional =
config->Read ( _T ( "exportSuppressOptional" ), (long)true );
exportHtml =
config->Read ( _T ( "exportHtml" ), (long)true );
exportEpub =
config->Read ( _T ( "exportEpub" ), (long)true );
exportRtf =
config->Read ( _T ( "exportRtf" ), (long)true );
exportDoc =
config->Read ( _T ( "exportDoc" ), (long)true );
exportFullDaisy =
config->Read ( _T ( "exportFullDaisy" ), (long)true );
applicationDir =
config->Read ( _T ( "applicationDir" ), wxEmptyString );
@ -751,7 +762,8 @@ MyFrame::MyFrame (
exportStylesheet = exportFolder = wxEmptyString;
exportQuiet = exportMp3Album = false;
exportQuiet = exportMp3Album = exportSuppressOptional = exportHtml =
exportEpub = exportRtf = exportDoc = exportFullDaisy = true;
}
largeFileProperties.completion = false;
@ -1020,6 +1032,12 @@ MyFrame::~MyFrame()
config->Write ( _T ( "exportFolder" ), exportFolder );
config->Write ( _T ( "exportQuiet" ), exportQuiet );
config->Write ( _T ( "exportMp3Album" ), exportMp3Album );
config->Write ( _T ( "exportSuppressOptional" ), exportSuppressOptional );
config->Write ( _T ( "exportHtml" ), exportHtml );
config->Write ( _T ( "exportEpub" ), exportEpub );
config->Write ( _T ( "exportRtf" ), exportRtf );
config->Write ( _T ( "exportDoc" ), exportDoc );
config->Write ( _T ( "exportFullDaisy" ), exportFullDaisy );
GetPosition ( &framePosX, &framePosY );
config->Write ( _T ( "framePosX" ), framePosX );
@ -2067,12 +2085,12 @@ void MyFrame::OnExport ( wxCommandEvent& event )
exportStylesheet,
exportFolder,
exportQuiet,
true, //suppressOptional
true, //html
true, //epub
true, //rtf
true, //doc
true, //fullDaisy
exportSuppressOptional,
exportHtml,
exportEpub,
exportRtf,
exportDoc,
exportFullDaisy,
exportMp3Album,
downloadLink ) );
int ret = ed->ShowModal();
@ -2084,6 +2102,12 @@ void MyFrame::OnExport ( wxCommandEvent& event )
exportFolder = ed->getFolderString();
exportQuiet = ed->getQuiet();
exportMp3Album = ed->getMp3Album();
exportSuppressOptional = ed->getSuppressOptional();
exportHtml = ed->getHtml();
exportEpub = ed->getEpub();
exportRtf = ed->getRtf();
exportDoc = ed->getDoc();
exportFullDaisy = ed->getFullDaisy();
std::string rawBufferUtf8;
getRawText ( doc, rawBufferUtf8 );
@ -2104,7 +2128,17 @@ void MyFrame::OnExport ( wxCommandEvent& event )
wxString tempFile= tempFileName.wideName();
WrapDaisy wd ( this, daisyDir, doc->getFullFileName() );
if ( !wd.run ( tempFile, exportStylesheet, exportFolder, exportQuiet, exportMp3Album, true, true, true, true ) )
if ( !wd.run (
tempFile,
exportStylesheet,
exportFolder,
exportQuiet,
exportSuppressOptional,
exportEpub,
exportRtf,
exportDoc,
exportFullDaisy,
exportMp3Album ) )
{
messagePane ( _ ("[b]DAISY export stopped[/b]: ") + wd.getLastError(), CONST_STOP );
return;

View File

@ -444,7 +444,13 @@ class MyFrame : public wxFrame
findRegex,
commandSync,
exportQuiet,
exportMp3Album;
exportMp3Album,
exportSuppressOptional,
exportHtml,
exportEpub,
exportRtf,
exportDoc,
exportFullDaisy;
wxBitmap newBitmap,
new16Bitmap,
openBitmap,

View File

@ -51,11 +51,11 @@
<xsl:call-template name="apply-templates-lang"/>
</h3>
</xsl:when>
<xsl:otherwise>
<h2>
<xsl:call-template name="apply-templates-lang"/>
</h2>
</xsl:otherwise>
<xsl:otherwise>
<h2>
<xsl:call-template name="apply-templates-lang"/>
</h2>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="SubSubHeading">
@ -66,9 +66,7 @@
<xsl:template match="Question">
<xsl:if test="count(Heading) = '0'">
<p>
<span class="optional-prodnote">
<strong>Question</strong>
</span>
<span class="optional-prodnote">Question</span>
</p>
</xsl:if>
<xsl:call-template name="apply-templates-lang"/>
@ -76,9 +74,7 @@
<xsl:template match="Answer">
<xsl:if test="count(Heading) = '0'">
<p>
<span class="optional-prodnote">
<strong>Answer</strong>
</span>
<span class="optional-prodnote">Answer</span>
</p>
</xsl:if>
<xsl:call-template name="apply-templates-lang"/>
@ -86,9 +82,7 @@
<xsl:template match="Discussion">
<xsl:if test="count(Heading) = '0'">
<p>
<span class="optional-prodnote">
<strong>Discussion</strong>
</span>
<span class="optional-prodnote">Discussion</span>
</p>
</xsl:if>
<xsl:call-template name="apply-templates-lang"/>

View File

@ -129,14 +129,6 @@
</xsl:template>
<xsl:template
match="InlineChemistry/Description | InlineChemistry/Alternative"/>
<xsl:template match="AuthorComment">
<!-- omit -->
<xsl:apply-templates/>

View File

@ -112,12 +112,19 @@
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:choose>
<xsl:when
test="count(./Description/*) = 0 and string-length(./Description) &lt; 1024">
<xsl:value-of select="./Description"/>
</xsl:when>
<xsl:when test="string-length(./Image/@alt) &gt; 0">
<xsl:value-of select="./Image/@alt"/>
</xsl:when>
<xsl:when test="string-length(Alternative) &gt; 0">
<xsl:value-of select="Alternative"/>
</xsl:when>
<xsl:when test="count(./Description/*) &gt; 0">
<xsl:text>figure description follows</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>no alternative text</xsl:text>
</xsl:otherwise>
@ -133,7 +140,9 @@
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="Caption"/>
<xsl:apply-templates select="Description"/>
<xsl:if test="count(./Description/*) &gt; 0 or string-length(./Description) &gt; 1024">
<xsl:apply-templates select="Description"/>
</xsl:if>
<xsl:apply-templates select="SourceReference"/>
<p>
<span class="optional-prodnote">End of figure</span>
@ -152,12 +161,19 @@
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:choose>
<xsl:when
test="count(./Description/*) = 0 and string-length(./Description) &lt; 1024">
<xsl:value-of select="./Description"/>
</xsl:when>
<xsl:when test="string-length(./Image/@alt) &gt; 0">
<xsl:value-of select="./Image/@alt"/>
</xsl:when>
<xsl:when test="string-length(Alternative) &gt; 0">
<xsl:value-of select="Alternative"/>
</xsl:when>
<xsl:when test="count(./Description/*) &gt; 0">
<xsl:text>equation description follows</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>no alternative text</xsl:text>
</xsl:otherwise>
@ -176,7 +192,9 @@
<xsl:apply-templates select="TeX"/>
<xsl:apply-templates select="MathML"/>
<xsl:apply-templates select="Caption"/>
<xsl:apply-templates select="Description"/>
<xsl:if test="count(./Description/*) &gt; 0 or string-length(./Description) &gt; 1024">
<xsl:apply-templates select="Description"/>
</xsl:if>
<xsl:apply-templates select="SourceReference"/>
<span class="optional-prodnote">End of equation</span>
</xsl:template>
@ -402,9 +420,9 @@
</xsl:template>
<xsl:template match="SideNote">
<hr/>
<span class="optional-prodnote">Side note</span>
<p><span class="optional-prodnote">Side note</span></p>
<xsl:apply-templates/>
<span class="optional-prodnote">End of side note</span>
<p><span class="optional-prodnote">End of side note</span></p>
<hr/>
</xsl:template>
<xsl:template match="footnote">