Пример #1
0
void ReadiumJSApi::openEPub3(std::string path)	
{
    m_ignoreRemainingErrors = false;

    try{
        DWORD beginTimeMs = GetTickCount();
        ContainerPtr container = Container::OpenContainer(path);
        DWORD containerOpened = GetTickCount();
        
        if (container)
        {
            pkg = container->DefaultPackage();
            if (pkg == 0)
            {
                auto pkgs = container->Packages();
                if (pkgs.size() <= 0)
                {
					MessageBox(NULL, _T("ReadiumSDK: No packages found !"), _T("Error"), MB_OK);
                    return;
                }
                pkg = pkgs[0];
            }

            // by requesting an empty URL we effectively request the first spine item, usually the title page
            OpenPageRequest req = OpenPageRequest("", 0, "", "", "", "");

            ViewerSettings set(true, 100, 20);
            
            DWORD openBookStartedMs = GetTickCount();
            openBook(pkg, set, req);
            DWORD EndTimeTimeMs = GetTickCount();
        }
    }
    //catch (ePub3::epub_spec_error err)
    //{

    //}
    catch (...)
    {
        throw;
    }
    
}
Пример #2
0
void ReadiumJSApi::on_actionOpen_ePub3(std::string path)	//QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Files (*.epub)"));
{
//	CSingleLock lock(&g_cs, TRUE);
	
	try{
		////qDebug() << fileName;
		DWORD beginTimeMs = GetTickCount();
		ContainerPtr container = Container::OpenContainer(path);
		DWORD containerOpened = GetTickCount();
		if (container)
		{
			pkg = container->DefaultPackage();
			if (pkg == 0)
			{
				auto pkgs = container->Packages();
				if (pkgs.size() <= 0)
				{
					//QMessageBox messageBox;
					//messageBox.critical(0, "Error", "ReadiumSDK: No packages found !");
					//messageBox.setFixedSize(500, 200);
					//messageBox.exec();
					return;
				}
				pkg = pkgs[0];
			}
			//int contentLength = container->getArchiveInfoSize("titlepage.xhtml");

			OpenPageRequest req = OpenPageRequest::fromContentUrl("", "chapter_001.xhtml");//TODO:
			ViewerSettings set(true, 100, 20);
			
			DWORD openBookStartedMs = GetTickCount();
			openBook(pkg, set, req);
			DWORD EndTimeTimeMs = GetTickCount();
			
			//char buf[1024];wsprintf((LPWSTR)buf, L"TotalTime:%d ms\n Container::OpenContainer:%d  ms\nopenBook:%d  ms\n", (EndTimeTimeMs - beginTimeMs), (openBookStartedMs - beginTimeMs), (EndTimeTimeMs - containerOpened));
			//AfxMessageBox((LPCTSTR)buf);
			
			//BYTE* bytes = 0;
			//ULONGLONG pSize = 0;
			//getByteResp("/chapter_001.xhtml", &bytes, &pSize);
			//delete[]bytes;
			//getByteResp("/chapter_002.xhtml", &bytes, &pSize);
			//delete[]bytes;
			//getByteResp("/chapter_003.xhtml", &bytes, &pSize);

			//openContentUrl("chapter_001.xhtml", "");
			
			//ReadiumJsApi.openContentUrl((*list.begin())->Title().c_str(), "");
			//unique_ptr<ePub3::ByteStream> byteStream = pkg->ReadStreamForItemAtPath("titlepage.xhtml");

			//if (pkg)
			//{
				//CollectionPtr previewCollection = pkg->PreviewCollection();
				//unique_ptr<ePub3::ByteStream> byteStream1 = previewCollection->ReadStreamForItemAtPath("titlepage.xhtml");
			//}
		}


	}
	//catch (ePub3::epub_spec_error err)
	//{

	//}
	catch (...)
	{
		//qDebug() << "Exception!!!";
		throw;
	}

	//openContentUrl("chapter_001.xhtml", "");
	
}