[Amis-vcs] SF.net SVN: amis: [2302] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2008-02-01 01:20:07
|
Revision: 2302 http://amis.svn.sourceforge.net/amis/?rev=2302&view=rev Author: marisademeglio Date: 2008-01-31 17:20:08 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Started PublicationSummaryDialog Modified Metadata so that it can support multiple entries for one metadata name (e.g. many dc:creator tags to list many authors) Modified Paths: -------------- branches/amis3/AmisCore/include/dtb/Dtb.h branches/amis3/AmisCore/include/dtb/Metadata.h branches/amis3/AmisCore/include/io/NccFileReader.h branches/amis3/AmisCore/include/io/OpfFileReader.h branches/amis3/AmisCore/src/dtb/Dtb.cpp branches/amis3/AmisCore/src/dtb/Metadata.cpp branches/amis3/AmisCore/src/io/NccFileReader.cpp branches/amis3/AmisCore/src/io/OpfFileReader.cpp branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj branches/amis3/AmisGuiMFC2/resource.h Added Paths: ----------- branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp Modified: branches/amis3/AmisCore/include/dtb/Dtb.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Dtb.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/dtb/Dtb.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -38,7 +38,7 @@ namespace dtb { typedef bool (*ProtectedBookKeyHandlerFunctionPtr)(const ambulant::net::url*, const ambulant::net::url*); - +enum DaisyVersion {UNDEFINED, DAISY_202, ZED_2002, ZED_2005}; class Dtb { public: @@ -73,7 +73,7 @@ void setNewLastmark(ambulant::net::url); ambulant::net::url calculateUriOfData(amis::dtb::smil::SmilMediaGroup*); - int getDaisyVersion(); + amis::dtb::DaisyVersion getDaisyVersion(); bool isProtected(); void setCallbackForPreprocessingBookKey(ProtectedBookKeyHandlerFunctionPtr); @@ -105,7 +105,7 @@ string mLastSearchResult; string mLastSearchedTextFile; amis::util::SearchForFiles* mpFileSearcher; - int mDaisyVersion; + amis::dtb::DaisyVersion mDaisyVersion; bool mbIsProtected; ProtectedBookKeyHandlerFunctionPtr mpCallbackForPreprocessingBookKey; }; Modified: branches/amis3/AmisCore/include/dtb/Metadata.h =================================================================== --- branches/amis3/AmisCore/include/dtb/Metadata.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/dtb/Metadata.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -48,9 +48,9 @@ ~Metadata(); //!get a metadata item - wstring getMetadata(string); + wstring getMetadataContent(string); + MetaItem* getMetadata(string); void addMetadata(MetaItem*); - MetaItem* getLastAdded(); private: void clearVector(); Modified: branches/amis3/AmisCore/include/io/NccFileReader.h =================================================================== --- branches/amis3/AmisCore/include/io/NccFileReader.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/io/NccFileReader.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -72,6 +72,7 @@ bool mbFlag_ProcessMetadataChars; amis::dtb::Metadata* mpMetadata; + amis::dtb::MetaItem* mpCurrentMetaItem; Modified: branches/amis3/AmisCore/include/io/OpfFileReader.h =================================================================== --- branches/amis3/AmisCore/include/io/OpfFileReader.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/include/io/OpfFileReader.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -86,6 +86,8 @@ StdStringList mItemRefs; //the input filename const ambulant::net::url* mpFilename; + //temporary metadata item + amis::dtb::MetaItem* mpCurrentMetaItem; }; } } Modified: branches/amis3/AmisCore/src/dtb/Dtb.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/dtb/Dtb.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -51,7 +51,7 @@ mpCustomTests = NULL; mpFileSearcher = NULL; mUid.erase(); - mDaisyVersion = 0; + mDaisyVersion = UNDEFINED; mpCallbackForPreprocessingBookKey = NULL; } //destructor @@ -99,7 +99,7 @@ mpTextSmilMap = NULL; mpCustomTests = NULL; mUid.erase(); - mDaisyVersion = 0; + mDaisyVersion = UNDEFINED; } amis::MediaGroup* amis::dtb::Dtb::getTitle() @@ -169,7 +169,7 @@ if (DtbFileSet::isNccFile(fileUrl)) { - mDaisyVersion = 2; + mDaisyVersion = DAISY_202; if (!processNcc(mpFiles->getNavFilepath())) { return false; @@ -177,7 +177,8 @@ } else if (DtbFileSet::isOpfFile(fileUrl)) { - mDaisyVersion = 3; + //TODO: differentiate between 2005 and 2002 + mDaisyVersion = ZED_2005; if (!processOpf(mpFiles->getOpfFilepath())) return false; if (!processNcx(mpFiles->getNavFilepath())) return false; @@ -185,7 +186,7 @@ } else { - mDaisyVersion = 0; + mDaisyVersion = UNDEFINED; //TODO: flag not supported return false; } @@ -281,12 +282,12 @@ mUid = getUid(); mpTitle = new amis::MediaGroup(); amis::TextNode* p_title_text = new amis::TextNode(); - p_title_text->setTextString(mpMetadata->getMetadata("dc:title")); + p_title_text->setTextString(mpMetadata->getMetadataContent("dc:title")); mpTitle->setText(p_title_text); mpAuthor = new amis::MediaGroup(); amis::TextNode* p_author_text = new amis::TextNode(); - p_author_text->setTextString(mpMetadata->getMetadata("dc:creator")); + p_author_text->setTextString(mpMetadata->getMetadataContent("dc:creator")); mpAuthor->setText(p_author_text); //TODO: get the audio for the title (author audio not available in Daisy 202) @@ -351,12 +352,12 @@ if (mpMetadata == NULL) return 0; - wstring w_uid = mpMetadata->getMetadata("dc:Identifier"); + wstring w_uid = mpMetadata->getMetadataContent("dc:Identifier"); if (w_uid.size() == 0) - w_uid = mpMetadata->getMetadata("dc:identifier"); + w_uid = mpMetadata->getMetadataContent("dc:identifier"); if (w_uid.size() == 0) - w_uid = mpMetadata->getMetadata("ncc:identifier"); + w_uid = mpMetadata->getMetadataContent("ncc:identifier"); return w_uid; } @@ -639,7 +640,7 @@ return fullpath; } -int amis::dtb::Dtb::getDaisyVersion() +amis::dtb::DaisyVersion amis::dtb::Dtb::getDaisyVersion() { return mDaisyVersion; } @@ -687,9 +688,9 @@ if (!pMetadata) return false; //metadata uses wide strings - std::wstring w_version = pMetadata->getMetadata("prod:pdtb-version"); - std::wstring w_key = pMetadata->getMetadata("prod:pdtb-bookKey"); - std::wstring w_ncc = pMetadata->getMetadata("prod:pdtb-nccFile"); + std::wstring w_version = pMetadata->getMetadataContent("prod:pdtb-version"); + std::wstring w_key = pMetadata->getMetadataContent("prod:pdtb-bookKey"); + std::wstring w_ncc = pMetadata->getMetadataContent("prod:pdtb-nccFile"); #if defined(AMIS_COMPILER_MSVC) std::string s_version = T2A(w_version.c_str()); Modified: branches/amis3/AmisCore/src/dtb/Metadata.cpp =================================================================== --- branches/amis3/AmisCore/src/dtb/Metadata.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/dtb/Metadata.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -24,6 +24,7 @@ #include <string> #include <iostream> +#include <algorithm> #include "util/FilePathTools.h" using namespace std; @@ -38,17 +39,30 @@ clearVector(); } -wstring amis::dtb::Metadata::getMetadata(string metaname) +//This is case-insensitive +amis::dtb::MetaItem* amis::dtb::Metadata::getMetadata(string metaname) { - wstring return_value; for (int i = 0; i<mMetaList.size(); i++) { - if (mMetaList[i]->mName.compare(metaname) == 0) + //convert to lowercase first + std::string name1 = metaname; + std::string name2 = mMetaList[i]->mName; + std::transform(name1.begin(), name1.end(), name1.begin(), (int(*)(int))tolower); + std::transform(name2.begin(), name2.end(), name2.begin(), (int(*)(int))tolower); + + if (name1.compare(name2) == 0) { - return_value.assign(mMetaList[i]->mContent); - break; + return mMetaList[i]; } } + return NULL; +} + +wstring amis::dtb::Metadata::getMetadataContent(string metaname) +{ + wstring return_value; + MetaItem* p_item = getMetadata(metaname); + if (p_item != NULL) return_value = p_item->mContent; return return_value; } @@ -57,14 +71,6 @@ mMetaList.push_back(pNewItem); } -amis::dtb::MetaItem* amis::dtb::Metadata::getLastAdded() -{ - if (mMetaList.size() > 0) - return mMetaList.back(); - else - return NULL; -} - //delete all metaitem objects in the list of metadata void amis::dtb::Metadata::clearVector() { Modified: branches/amis3/AmisCore/src/io/NccFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/NccFileReader.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/io/NccFileReader.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -31,6 +31,7 @@ amis::io::NccFileReader::NccFileReader() { mpMetadata = NULL; + mpCurrentMetaItem = NULL; } amis::io::NccFileReader::~NccFileReader() @@ -112,19 +113,30 @@ const XMLCh* const localname, const XMLCh* const qname) { - //local variable char* element_name = XMLString::transcode(qname); - - if (strcmp(element_name, "a") == 0) - { - mbFlag_GetChars = false; - } - string tmpstr; tmpstr.assign(element_name); - if (tmpstr.substr(0, 3).compare("dc:") == 0) + if (tmpstr.substr(0, 3).compare("dc:") == 0 || tmpstr.compare("meta") == 0) + { + if (mbFlag_ProcessMetadataChars == true && mpCurrentMetaItem != NULL) + { + //if the meta item has content already, add to it + //this is because some metadata names might appear more than once, like several authors + //we don't need to provide atomic navigation for each, so just list them like "A, B, C, ..." + if (mpCurrentMetaItem->mContent.size() > 0) + { + mpCurrentMetaItem->mContent.append(L", "); + mpCurrentMetaItem->mContent.append(mTempChars); + } + else + { + mpCurrentMetaItem->mContent.assign(mTempChars); + } + } mbFlag_ProcessMetadataChars = false; - + } + + if (strcmp(element_name, "a") == 0) mbFlag_GetChars = false; XMLString::release(&element_name); } @@ -133,14 +145,9 @@ if (mbFlag_GetChars == true) { mTempChars.append((wchar_t*)chars); - - if (mbFlag_ProcessMetadataChars == true) + //process metadata characters at endElement because the value of mContent might need to be appended + if (mbFlag_ProcessMetadataChars == false) { - if (mpMetadata->getLastAdded() != NULL) - mpMetadata->getLastAdded()->mContent.assign(mTempChars); - } - else - { amis::MediaGroup* p_media_label; if (mListType == 0) @@ -345,25 +352,35 @@ void amis::io::NccFileReader::processMetadata(string tagname, const Attributes* pAttrs) { - amis::dtb::MetaItem* p_meta_item = new amis::dtb::MetaItem(); + amis::dtb::MetaItem* p_meta_item = NULL; //it's a dublin core if (tagname.substr(0, 3).compare("dc:") == 0) { - p_meta_item->mName.assign(tagname); mbFlag_GetChars = true; mbFlag_ProcessMetadataChars = true; + //account for dc:creator already existing - we might just append content to it + if (tagname == "dc:creator" && mpMetadata->getMetadata("dc:creator") != NULL) + { + p_meta_item = mpMetadata->getMetadata("dc:creator"); + } + else + { + p_meta_item = new amis::dtb::MetaItem(); + p_meta_item->mName.assign(tagname); + } } //it's just a plain "meta" else { + p_meta_item = new amis::dtb::MetaItem(); mbFlag_GetChars = false; string meta_name = SimpleAttrs::get("name", pAttrs); wstring meta_content = SimpleAttrs::getw("content", pAttrs); p_meta_item->mName.assign(meta_name); p_meta_item->mContent = meta_content; } - + mpCurrentMetaItem = p_meta_item; mpMetadata->addMetadata(p_meta_item); } Modified: branches/amis3/AmisCore/src/io/OpfFileReader.cpp =================================================================== --- branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisCore/src/io/OpfFileReader.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -124,7 +124,7 @@ mTextFilename = temp.join_to_base(*mpFilename); } //add the smil files to the manifest list - //text/sml hack for bookshare books + //the media type "text/sml" is used in bookshare books else if ((media_type == "application/smil" || media_type == "text/sml") && id.size() > 0) { string filename = SimpleAttrs::get("href", &attributes); @@ -141,21 +141,34 @@ else if (node_name.compare("meta") == 0 || node_name.substr(0, 3).compare("dc:") == 0) { - amis::dtb::MetaItem* p_meta = new amis::dtb::MetaItem(); - + amis::dtb::MetaItem* p_meta_item = NULL; + //just a plain "meta" tag with all data in attributes if (node_name.compare("meta") == 0) { - p_meta->mName.assign(SimpleAttrs::get("name", &attributes)); + mbFlag_GetChars = false; + p_meta_item = new amis::dtb::MetaItem(); + string meta_name = SimpleAttrs::get("name", &attributes); + wstring meta_content = SimpleAttrs::getw("content", &attributes); + p_meta_item->mName.assign(meta_name); + p_meta_item->mContent = meta_content; } + //it's a dublin core (with character data) else { - p_meta->mName.assign(node_name); + mbFlag_GetChars = true; + if (node_name == "dc:Creator" && mpMetadata->getMetadata("dc:creator") != NULL) + { + p_meta_item = mpMetadata->getMetadata("dc:creator"); + } + else + { + p_meta_item = new amis::dtb::MetaItem(); + p_meta_item->mName.assign(node_name); + } } - - mpMetadata->addMetadata(p_meta); - + mpCurrentMetaItem = p_meta_item; + mpMetadata->addMetadata(p_meta_item); mTempChars.erase(); - mbFlag_GetChars = true; } } @@ -170,9 +183,17 @@ XMLString::release(&element_name); if (node_name.substr(0, 3).compare("dc:") == 0 || - node_name.compare("meta") == 0) + node_name.compare("meta") == 0 && mpCurrentMetaItem != NULL) { - mbFlag_GetChars = false; + if (mpCurrentMetaItem->mContent.size() > 0) + { + mpCurrentMetaItem->mContent.append(L", "); + mpCurrentMetaItem->mContent.append(mTempChars); + } + else + { + mpCurrentMetaItem->mContent.assign(mTempChars); + } } else if (node_name.compare("manifest") == 0) { @@ -186,13 +207,7 @@ void amis::io::OpfFileReader::characters(const XMLCh *const chars, const unsigned int length) { - if (mbFlag_GetChars == true) - { - mTempChars.append((wchar_t*)chars); - - if (mpMetadata->getLastAdded() != NULL) - mpMetadata->getLastAdded()->mContent.assign(mTempChars); - } + if (mbFlag_GetChars == true) mTempChars.append((wchar_t*)chars); } void amis::io::OpfFileReader::sortSpine() Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.aps =================================================================== (Binary files differ) Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.rc 2008-02-01 01:20:08 UTC (rev 2302) @@ -120,7 +120,7 @@ BOTTOMMARGIN, 90 END - IDD_PUBLICATIONINFO, DIALOG + IDD_PUBLICATIONSUMMARY, DIALOG BEGIN LEFTMARGIN, 6 RIGHTMARGIN, 393 @@ -222,10 +222,7 @@ POPUP "&Info" BEGIN MENUITEM "&Reading Options...", ID_MENU_INFO_SKIP - MENUITEM SEPARATOR - MENUITEM "&Full Summary", ID_MENU_INFO_SUMMARY - MENUITEM "&Current Position", ID_MENU_INFO_CURRENTPOSITION - MENUITEM "&Navigation Options", ID_MENU_INFO_NAVOPTIONS + MENUITEM "&Publication Summary", ID_PUBLICATION_SUMMARY END POPUP "&Help" BEGIN @@ -340,7 +337,7 @@ DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP END -IDD_PUBLICATIONINFO DIALOGEX 0, 0, 400, 278 +IDD_PUBLICATIONSUMMARY DIALOGEX 0, 0, 400, 278 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Publication Summary" FONT 8, "MS Sans Serif", 0, 0, 0x0 Modified: branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj =================================================================== --- branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisGuiMFC2/AmisGuiMFC2.vcproj 2008-02-01 01:20:08 UTC (rev 2302) @@ -227,6 +227,9 @@ RelativePath=".\include\gui\dialogs\PreferencesDialog.h"> </File> <File + RelativePath=".\include\gui\dialogs\PublicationSummaryDialog.h"> + </File> + <File RelativePath=".\include\gui\dialogs\SearchForBooksDialog.h"> </File> <File @@ -521,6 +524,9 @@ RelativePath=".\src\gui\dialogs\PreferencesDialog.cpp"> </File> <File + RelativePath=".\src\gui\dialogs\PublicationSummaryDialog.cpp"> + </File> + <File RelativePath=".\src\gui\dialogs\SearchForBooksDialog.cpp"> </File> <File Added: branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h (rev 0) +++ branches/amis3/AmisGuiMFC2/include/gui/dialogs/PublicationSummaryDialog.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -0,0 +1,72 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2008 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef PUBLICATIONSUMMARY_H +#define PUBLICATIONSUMMARY_H + +#include "gui/dialogs/AmisDialogBase.h" +#include "../resource.h" +#include "AmisCore.h" +#include "Media.h" + +namespace amis +{ +namespace gui +{ +namespace dialogs +{ +class PublicationSummaryDialog : public AmisDialogBase +{ +public: + PublicationSummaryDialog(CWnd* pParent = NULL); + ~PublicationSummaryDialog(); + virtual BOOL PreTranslateMessage(MSG*); + enum { IDD = IDD_PUBLICATIONSUMMARY }; + //call this first + void setBook(amis::dtb::Dtb*); + +protected: + virtual BOOL OnInitDialog(); + afx_msg void OnPaint(); + virtual void DoDataExchange(CDataExchange*); + DECLARE_MESSAGE_MAP() + +private: + amis::dtb::Dtb* mpBook; + amis::MediaGroup* mpTitle; + wstring mCreator; + string mCurrentPage; + int mTotalPages; + wstring mCurrentTimestamp; + string mTimeRemaining; + amis::MediaGroup* mpSectionName; + int mNumSubsections; + int mNumPages; + wstring mTotalTime; + wstring mPublisher; + wstring mDescription; + wstring mDate; + wstring mFormat; +}; +} +} +} +#endif Modified: branches/amis3/AmisGuiMFC2/resource.h =================================================================== --- branches/amis3/AmisGuiMFC2/resource.h 2008-01-30 20:01:56 UTC (rev 2301) +++ branches/amis3/AmisGuiMFC2/resource.h 2008-02-01 01:20:08 UTC (rev 2302) @@ -28,6 +28,7 @@ #define IDD_CDSEARCH 181 #define IDD_FULLSUMMARY 182 #define IDD_PUBLICATIONINFO 182 +#define IDD_PUBLICATIONSUMMARY 182 #define IDI_LANGICON 185 #define IDD_PROPPAGE3 185 #define IDB_BOOKSHELFMAG 186 @@ -50,7 +51,6 @@ #define IDC_LIST_PAGE 1015 #define IDC_TTSVOICE 1020 #define IDC_TTSVOICES 1020 -#define IDC_TTSVOICES2 1021 #define IDC_BTN_RESETCOLORS 1028 #define IDC_STARTSEARCH 1030 #define IDC_BTN_TEXTFG 1030 @@ -151,6 +151,7 @@ #define ID_MENU_PLAYPAUSE 32865 #define ID_MENU_FILE_OPENFROMURL 32870 #define ID_MENU_FILE_CLOSE 32871 +#define ID_PUBLICATION_SUMMARY 32875 #define IDS_NOSKIP 61245 #define IDS_SELFOLDER_TITLE 61258 #define IDS_SELFOLDER_INSTR 61259 @@ -165,7 +166,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 192 -#define _APS_NEXT_COMMAND_VALUE 32875 +#define _APS_NEXT_COMMAND_VALUE 32876 #define _APS_NEXT_CONTROL_VALUE 1098 #define _APS_NEXT_SYMED_VALUE 141 #endif Added: branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp (rev 0) +++ branches/amis3/AmisGuiMFC2/src/gui/dialogs/PublicationSummaryDialog.cpp 2008-02-01 01:20:08 UTC (rev 2302) @@ -0,0 +1,110 @@ +/* +AMIS: Adaptive Multimedia Information System +Software for playing DAISY books +Homepage: http://amis.sf.net + +Copyright (C) 2004-2008 DAISY for All Project + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "stdafx.h" +#include "gui/dialogs/PublicationSummaryDialog.h" +#include "../resource.h" +#include "AmisCore.h" +#include "dtb/Dtb.h" +#include "Media.h" + +using namespace amis::gui::dialogs; + +BEGIN_MESSAGE_MAP(PublicationSummaryDialog, CDialog) + ON_WM_KEYUP() + ON_WM_KEYDOWN() + ON_WM_PAINT() +END_MESSAGE_MAP() + +PublicationSummaryDialog::PublicationSummaryDialog(CWnd* pParent /*=NULL*/) + : AmisDialogBase(PublicationSummaryDialog::IDD) +{ +} + +PublicationSummaryDialog::~PublicationSummaryDialog() +{ +} + +void PublicationSummaryDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} +BOOL PublicationSummaryDialog::OnInitDialog() +{ + return CDialog::OnInitDialog(); +} + +void PublicationSummaryDialog::OnPaint() +{ + CPaintDC dc(this); // device context for painting + // Let the window do its default painting... + CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 ); + //call the base class on_paint function + on_paint(); +} + + +BOOL PublicationSummaryDialog::PreTranslateMessage(MSG* pMsg) +{ + if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) + { + CWnd* p_wnd = this->GetFocus(); + if (p_wnd) + { + int id = p_wnd->GetDlgCtrlID(); + //inexplicably, the default behavior for pressing enter in a dialog is to close it. + //we're overriding this here. + if (pMsg->wParam == VK_RETURN) + { + //do nothing + } + } + } + return AmisDialogBase::PreTranslateMessage(pMsg); +} + +void PublicationSummaryDialog::setBook(amis::dtb::Dtb* pBook) +{ + mpBook = pBook; + amis::dtb::Metadata* p_meta = mpBook->getMetadata(); + amis::dtb::DaisyVersion version = mpBook->getDaisyVersion(); + + mpTitle = mpBook->getTitle(); + mCreator = p_meta->getMetadataContent("dc:creator"); + + if (version == amis::dtb::DAISY_202) + mTotalTime = p_meta->getMetadataContent("ncc:totalTime"); + else if (version == amis::dtb::ZED_2002 || version == amis::dtb::ZED_2005) + mTotalTime = p_meta->getMetadataContent("dtb:totalTime"); + + mPublisher = p_meta->getMetadataContent("dc:Publisher"); + mDescription = p_meta->getMetadataContent("dc:Description"); + mDate = p_meta->getMetadataContent("dc:Date"); + + mFormat = p_meta->getMetadataContent("dc:Format"); + //also check for the deprecated "ncc:format" + if (mFormat.size() == 0 && version == amis::dtb::DAISY_202) + mFormat = p_meta->getMetadataContent("ncc:format"); + + +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |