[Amis-vcs] SF.net SVN: amis: [2161] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2007-09-24 13:36:52
|
Revision: 2161 http://amis.svn.sourceforge.net/amis/?rev=2161&view=rev Author: marisademeglio Date: 2007-09-24 06:36:52 -0700 (Mon, 24 Sep 2007) Log Message: ----------- fixed a bug in section order playback Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Spine.h branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp branches/amis3/AmisCore/src/dtb/Spine.cpp branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp Modified: branches/amis3/AmisCore/include/dtb/Spine.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Spine.h 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/include/dtb/Spine.h 2007-09-24 13:36:52 UTC (rev 2161) @@ -43,17 +43,17 @@ ~Spine(); //note: removed forced value on bool (skipCheck = false) for python linking - void addFile(ambulant::net::url*, bool); - void addFile(string, bool); + void addFile(const ambulant::net::url*, bool); + //void addFile(string, bool); - bool isFilePresent(ambulant::net::url*); + bool isFilePresent(const ambulant::net::url*); bool isEmpty(); const ambulant::net::url* getNextFile(); const ambulant::net::url* getPreviousFile(); const ambulant::net::url* getFirstFile(); const ambulant::net::url* getLastFile(); - bool goToFile(ambulant::net::url*); + bool goToFile(const ambulant::net::url*); void print(); int getNumberOfSmilFiles(); const ambulant::net::url* getSmilFilePath(unsigned int); Modified: branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h =================================================================== --- branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/include/dtb/nav/NavVisitor.h 2007-09-24 13:36:52 UTC (rev 2161) @@ -54,11 +54,12 @@ public: BuildSpineVisitor() {mpSpine = NULL;} ~BuildSpineVisitor() {} - amis::dtb::Spine* getSpine(NavModel*); + amis::dtb::Spine* getSpine(NavModel*, const ambulant::net::url*); bool preVisit(NavNode*); private: amis::dtb::Spine* mpSpine; + const ambulant::net::url* mpBookDirectory; }; Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -208,7 +208,7 @@ mpMetadata = ncc_file_reader.getMetadata(); mpCustomTests = ncc_file_reader.getCustomTests(); - mpSpine = spine_visitor.getSpine(mpNavModel); + mpSpine = spine_visitor.getSpine(mpNavModel, this->getFileSet()->getBookDirectory()); mUid = getUid(); mpFiles->setAdditionalDataAfterInitialParse(this->mUid, NULL, NULL); Modified: branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/DtbFileSet.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -130,6 +130,7 @@ return &mBookmarksFilepath; } +//these two functions (setSmilFile, getSmilFile) are not used when Ambulant is hooked up //expected: relative file path void amis::dtb::DtbFileSet::setSmilFile(const ambulant::net::url* file) { @@ -140,6 +141,8 @@ { return &mSmilFilepath; } + + //is this an ncc file? bool amis::dtb::DtbFileSet::isNccFile(const ambulant::net::url* filepath) { Modified: branches/amis3/AmisCore/src/dtb/Spine.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Spine.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/Spine.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -95,7 +95,7 @@ //check to see if a file is present in the spine -bool amis::dtb::Spine::isFilePresent(ambulant::net::url* filePath) +bool amis::dtb::Spine::isFilePresent(const ambulant::net::url* filePath) { for (unsigned int i=0; i<mSpineList.size(); i++) { @@ -108,19 +108,20 @@ } //wrapper -void amis::dtb::Spine::addFile(string filePath, bool skipCheck) +/*void amis::dtb::Spine::addFile(string filePath, bool skipCheck) { ambulant::net::url fileurl = ambulant::net::url::from_url(filePath); addFile(&fileurl, skipCheck); -} +}*/ //if the file doesn't already exist, add it to the spine list //skipCheck allows to skip the isFilePresent check for very long lists -void amis::dtb::Spine::addFile(ambulant::net::url* filePath, bool skipCheck) +//filePath should be a full path. +void amis::dtb::Spine::addFile(const ambulant::net::url* filePath, bool skipCheck) { if (filePath->is_empty_path()) return; - if (skipCheck == true) + if (skipCheck) { mSpineList.push_back(filePath->get_document()); } @@ -133,7 +134,6 @@ } } - //print the spine void amis::dtb::Spine::print() { @@ -158,7 +158,7 @@ } //set the spine at this particular file, if exists -bool amis::dtb::Spine::goToFile(ambulant::net::url* filePath) +bool amis::dtb::Spine::goToFile(const ambulant::net::url* filePath) { bool b_found = false; unsigned int i; @@ -167,6 +167,7 @@ if (mSpineList[i].same_document((*filePath))) { b_found = true; + break; } } Modified: branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisCore/src/dtb/nav/NavVisitor.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -29,8 +29,9 @@ /**************************************/ /*BUILD SPINE VISITOR /**************************************/ -amis::dtb::Spine* amis::dtb::nav::BuildSpineVisitor::getSpine(amis::dtb::nav::NavModel* model) +amis::dtb::Spine* amis::dtb::nav::BuildSpineVisitor::getSpine(amis::dtb::nav::NavModel* model, const ambulant::net::url* pBookDirectory) { + mpBookDirectory = pBookDirectory; mpSpine = new amis::dtb::Spine(); model->acceptDepthFirst(this); return mpSpine; @@ -39,7 +40,11 @@ //this gets called each time a node is visited bool amis::dtb::nav::BuildSpineVisitor::preVisit(NavNode* n) { - mpSpine->addFile(n->getContent(), false); + //make a full path out of n->getContent() + ambulant::net::url smil_url = ambulant::net::url::from_url(n->getContent()); + ambulant::net::url full_smil_url = smil_url.join_to_base(*mpBookDirectory); + + mpSpine->addFile(&full_smil_url, false); return true; } Modified: branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisGuiMFC2/include/DtbWithHooks.h 2007-09-24 13:36:52 UTC (rev 2161) @@ -54,7 +54,7 @@ void updateCustomTestStates(bool playAll = false); amis::dtb::Bookmark* addBookmark(); void loadBookmark(int); - amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(ambulant::net::url*); + amis::dtb::smil::SmilMediaGroup* loadSmilFromUrl(const ambulant::net::url*); private: void addToRecentBooks(); Modified: branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisGuiMFC2/src/DtbWithHooks.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -109,18 +109,12 @@ //if we're not using the lastmark or it is unavailable, just load from the beginning if (loadLastmark == false || getBookmarks() == NULL || getBookmarks()->getLastmark() == NULL) - { smilfile = getSpine()->getFirstFile(); - //why this is necessary I forget ... it might not be - this->getFileSet()->setSmilFile(smilfile); - } else - { smilfile = &getBookmarks()->getLastmark()->mUri; - } - assert(smilfile); - amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(smilfile->get_url().c_str())); + loadSmilFromUrl(smilfile); + return NULL; #else smil::SmilMediaGroup* pData = Dtb::startReading(loadLastmark); @@ -149,22 +143,15 @@ void DtbWithHooks::nextSmilDocument() { const ambulant::net::url* filepath = this->getSpine()->getNextFile(); - if (filepath != NULL) - { - ambulant::net::url full_path_to_file = filepath->join_to_base(*getFileSet()->getBookDirectory()); - amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(full_path_to_file.get_url()); - } + if (filepath) + amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_url()); } void DtbWithHooks::previousSmilDocument() { const ambulant::net::url* filepath = this->getSpine()->getPreviousFile(); - if (filepath != NULL) - { - ambulant::net::url full_path_to_file = filepath->join_to_base(*getFileSet()->getBookDirectory()); - amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(full_path_to_file.get_url()); - - } + if (filepath) + amis::gui::MainWndParts::Instance()->mpMmView->ScheduleReplaceDoc(filepath->get_url()); } void DtbWithHooks::loadNavNode(nav::NavNode* pNav) @@ -333,12 +320,16 @@ loadSmilFromUrl(&p_mark->mpStart->mUri); } -amis::dtb::smil::SmilMediaGroup* DtbWithHooks::loadSmilFromUrl(ambulant::net::url* pUri) +amis::dtb::smil::SmilMediaGroup* DtbWithHooks::loadSmilFromUrl(const ambulant::net::url* pUri) { USES_CONVERSION; - + assert(pUri); ambulant::net::url full_path = pUri->join_to_base(*getFileSet()->getBookDirectory()); - amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); - + + //set the spine at this file. this also makes sure that we're going to a file that is in the book. + if (getSpine()->goToFile(&full_path)) + { + amis::gui::MainWndParts::Instance()->mpMmDoc->OnOpenDocument(A2T(full_path.get_url().c_str())); + } return NULL; } \ No newline at end of file Modified: branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-09-24 10:13:39 UTC (rev 2160) +++ branches/amis3/AmisGuiMFC2/src/gui/HtmlView.cpp 2007-09-24 13:36:52 UTC (rev 2161) @@ -20,29 +20,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <algorithm> +#include <string> +#include <cassert> + #include "stdafx.h" -#include "gui/AmisGuiMFC2.h" +#include "gui/AmisGuiMFC2.h" #include "gui/HtmlDoc.h" #include "gui/HtmlView.h" - #include "gui/MainWndParts.h" +#include "gui/MmDoc.h" +#include "gui/TextRenderBrain.h" +#include "DtbWithHooks.h" -#include <algorithm> -#include <string> - #define WITH_HTML_WIDGET #define AM_DBG if (1) -#include <cassert> -#include "gui/MmDoc.h" -#include "gui/TextRenderBrain.h" - typedef amis::gui::CAmisHtmlView HtmlView; using namespace std; using namespace amis::gui; -//#endif // Messages for communicating between worker threads and main (GUI) thread, which // is the only one that should do html-widget calls. @@ -68,29 +67,20 @@ #endif extern CWnd* topView; -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView IMPLEMENT_DYNCREATE(CAmisHtmlView, CHtmlView) BEGIN_MESSAGE_MAP(CAmisHtmlView, CHtmlView) - //{{AFX_MSG_MAP(CAmisHtmlView) ON_WM_CREATE() #ifdef HTML_LOAD_MANUALLY ON_MESSAGE(WM_MY_NAVIGATESTRING, OnNavigateString) #endif ON_MESSAGE(WM_MY_HIGHLIGHTURITARGET, OnHighlightUrlTarget) ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - - //}}AFX_MSG_MAP END_MESSAGE_MAP() -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView construction/destruction - CAmisHtmlView::CAmisHtmlView() { - //mpBrain = NULL; #ifdef HTML_LOAD_AMBULANT_PDTB mpLoaderBridge = NULL; #endif @@ -98,7 +88,6 @@ CAmisHtmlView::CAmisHtmlView(const RECT& rect, CWnd* parent) { - //mpBrain = NULL; #ifdef HTML_LOAD_AMBULANT_PDTB mpLoaderBridge = NULL; #endif @@ -107,7 +96,8 @@ CAmisHtmlView::~CAmisHtmlView() { - if (mpLoaderBridge) { + if (mpLoaderBridge) + { mpLoaderBridge->Release(); mpLoaderBridge = NULL; } @@ -115,28 +105,15 @@ BOOL CAmisHtmlView::PreCreateWindow(CREATESTRUCT& cs) { - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - - return CHtmlView::PreCreateWindow(cs); } -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView drawing - void CAmisHtmlView::OnDraw(CDC* pDC) { CAmisHtmlDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); - - // TODO: add draw code for native data here } -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView diagnostics - #ifdef _DEBUG void CAmisHtmlView::AssertValid() const { @@ -157,17 +134,11 @@ #endif //_DEBUG -///////////////////////////////////////////////////////////////////////////// -// CAmisHtmlView message handlers - int CAmisHtmlView::OnCreate(LPCREATESTRUCT lpCreateStruct) { - if (CHtmlView::OnCreate(lpCreateStruct) == -1) - return -1; + if (CHtmlView::OnCreate(lpCreateStruct) == -1) return -1; MainWndParts::Instance()->mpHtmlView = this; - - this->ModifyStyle(0, WS_CLIPCHILDREN); return 0; } @@ -185,37 +156,31 @@ CHtmlView::OnActivateView(bActivate, pActivateView, pDeactiveView); } +//this signals the completion of a URL load request void CAmisHtmlView::OnDocumentComplete(LPCTSTR lpszURL) { TextRenderBrain::Instance()->webDocumentComplete(); - CHtmlView::OnDocumentComplete(lpszURL); - } BOOL CAmisHtmlView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { // create the view window itself m_pCreateContext = pContext; - if (!CView::Create(lpszClassName, lpszWindowName, - dwStyle, rect, pParentWnd, nID, pContext)) - { + if (!CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext)) return FALSE; - } - RECT rectClient; GetClientRect(&rectClient); // create the control window // AFX_IDW_PANE_FIRST is a safe but arbitrary ID if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, lpszWindowName, - WS_VISIBLE | WS_CHILD , rectClient, this, AFX_IDW_PANE_FIRST)) + WS_VISIBLE | WS_CHILD , rectClient, this, AFX_IDW_PANE_FIRST)) { DestroyWindow(); return FALSE; } - LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown(); HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp); @@ -244,7 +209,6 @@ p_parent->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); } - return CHtmlView::PreTranslateMessage(pMsg); } @@ -255,22 +219,27 @@ BOOL* pbCancel) { USES_CONVERSION; - //AfxMessageBox(lpszURL); + // lpszURL can be either a URL or a filename (sigh) // Guess: if there's a : in the string and it is not in second position // this is a URL. string urlOrFile = T2A(lpszURL); ambulant::net::url thisUrl; string::size_type colonPos = urlOrFile.find(':'); - if (colonPos == string::npos || colonPos == 1) { + if (colonPos == string::npos || colonPos == 1) + { thisUrl = ambulant::net::url::from_filename(urlOrFile, true); - } else if (urlOrFile.substr(0, 5) == "file:") { + } + else if (urlOrFile.substr(0, 5) == "file:") + { // Stupid hack: urlOrFile can be mixed-case. Sigh. ambulant::net::url tmpurl = ambulant::net::url::from_url(urlOrFile); assert(tmpurl.is_local_file()); std::string tmpfile = tmpurl.get_file(); thisUrl = ambulant::net::url::from_filename(tmpfile); - } else { + } + else + { thisUrl = ambulant::net::url::from_url(urlOrFile); } //if this URL is not in our current book directory, don't go there @@ -296,7 +265,7 @@ if (thisUrl.guesstype() == "application/smil") { *pbCancel = TRUE; -// AmisBrain::Instance()->loadSmilContent(thisUrl.get_url()); + amis::dtb::DtbWithHooks::Instance()->loadSmilFromUrl(&thisUrl); } //else it's probably a text-file loading request that we sent ourselves else @@ -304,8 +273,6 @@ CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel); } } - - } LPARAM CAmisHtmlView::OnHighlightUrlTarget(WPARAM wParam, LPARAM lParam) @@ -326,18 +293,23 @@ // Also, we need to inform the PdtbPluggableProtocol about // our datasource factory. This is done with the PdtbBridge // object, which remembers the factory until disposed of. - if (mpLoaderBridge == NULL) { + if (mpLoaderBridge == NULL) + { ambulant::net::datasource_factory *df = MainWndParts::Instance()->mpMmView->getDatasourceFactory(); assert(df); HRESULT hr = CoCreateInstance(CLSID_CPdtbBridge, 0, CLSCTX_INPROC_SERVER, IID_PdtbBridge, (void **)&mpLoaderBridge); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr)) + { mpLoaderBridge->SetDatasourceFactory((DATASOURCEFACTORYPTR)df); } } - } else { - if (mpLoaderBridge) { + } + else + { + if (mpLoaderBridge) + { mpLoaderBridge->Release(); mpLoaderBridge = NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |