diff --git a/src/exportdialog.cpp b/src/exportdialog.cpp index 86d8277..29c23b0 100755 --- a/src/exportdialog.cpp +++ b/src/exportdialog.cpp @@ -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 ) { } diff --git a/src/exportdialog.h b/src/exportdialog.h index bb6f201..f6adc45 100755 --- a/src/exportdialog.h +++ b/src/exportdialog.h @@ -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, diff --git a/src/wrapdaisy.cpp b/src/wrapdaisy.cpp index 3009fa8..c8c1147 100755 --- a/src/wrapdaisy.cpp +++ b/src/wrapdaisy.cpp @@ -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; } diff --git a/src/wrapdaisy.h b/src/wrapdaisy.h index be37f88..556fd30 100755 --- a/src/wrapdaisy.h +++ b/src/wrapdaisy.h @@ -20,6 +20,7 @@ public: bool suppressOptional, bool epub, bool rtf, + bool doc, bool fullDaisy, bool mp3Album ); wxString getLastError(); diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index f742899..2c9274c 100755 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -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; diff --git a/src/xmlcopyeditor.h b/src/xmlcopyeditor.h index 156ff62..967ed07 100755 --- a/src/xmlcopyeditor.h +++ b/src/xmlcopyeditor.h @@ -444,7 +444,13 @@ class MyFrame : public wxFrame findRegex, commandSync, exportQuiet, - exportMp3Album; + exportMp3Album, + exportSuppressOptional, + exportHtml, + exportEpub, + exportRtf, + exportDoc, + exportFullDaisy; wxBitmap newBitmap, new16Bitmap, openBitmap, diff --git a/src/xsl/openlearn2daisyhtml/heading.xsl b/src/xsl/openlearn2daisyhtml/heading.xsl index 46e8bf0..e4ac40a 100644 --- a/src/xsl/openlearn2daisyhtml/heading.xsl +++ b/src/xsl/openlearn2daisyhtml/heading.xsl @@ -51,11 +51,11 @@ - -

- -

-
+ +

+ +

+
@@ -66,9 +66,7 @@

- - Question - + Question

@@ -76,9 +74,7 @@

- - Answer - + Answer

@@ -86,9 +82,7 @@

- - Discussion - + Discussion

diff --git a/src/xsl/openlearn2daisyhtml/inline.xsl b/src/xsl/openlearn2daisyhtml/inline.xsl index c2291d7..7f13dc1 100644 --- a/src/xsl/openlearn2daisyhtml/inline.xsl +++ b/src/xsl/openlearn2daisyhtml/inline.xsl @@ -129,14 +129,6 @@
- - - - - - - - diff --git a/src/xsl/openlearn2daisyhtml/object.xsl b/src/xsl/openlearn2daisyhtml/object.xsl index bc38c7c..2f9e6db 100644 --- a/src/xsl/openlearn2daisyhtml/object.xsl +++ b/src/xsl/openlearn2daisyhtml/object.xsl @@ -112,12 +112,19 @@ + + + + + figure description follows + no alternative text @@ -133,7 +140,9 @@ - + + +

End of figure @@ -152,12 +161,19 @@ + + + + + equation description follows + no alternative text @@ -176,7 +192,9 @@ - + + + End of equation @@ -402,9 +420,9 @@


- Side note +

Side note

- End of side note +

End of side note