Пример #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;
    }
    
}
    char* input = strdup(gNormalObject);
    char* output = reinterpret_cast<char*>(proc.FilterData(ctx.get(), input, sizeof(gNormalObject), &outLen));
    
    INFO("Unaltered output:\n" << string(output, outLen));
    REQUIRE(outLen == sizeof(gNormalObject));
    REQUIRE(strncmp(input, output, outLen) == 0);
    
    if ( output != input )
        delete [] output;
    free(input);
}

TEST_CASE("Object tags for bound media should be replaced by iframes and buttons", "")
{
    ContainerPtr c = Container::OpenContainer(EPUB_PATH);
    PackagePtr pkg = c->DefaultPackage();
    
    ObjectPreprocessor proc(pkg);
    std::unique_ptr<FilterContext> ctx(proc.MakeFilterContext(nullptr));
    
    size_t outLen = 0;
    char* input = strdup(gGalleryObject);
    char* output = reinterpret_cast<char*>(proc.FilterData(ctx.get(), input, sizeof(gGalleryObject), &outLen));
    
    INFO("IFrame output:\n" << string(output, outLen));
    REQUIRE(outLen == sizeof(gGalleryIFrame));
    REQUIRE(strncmp(gGalleryIFrame, output, outLen) == 0);
}

TEST_CASE("The title of the 'Open Fullscreen' button may be replaced", "")
{
Пример #3
0
    std::call_once(__once, [&]() {
        SetErrorHandler([](const error_details& err) {
            if (err.epub_error_code() == EPUBError::OPFMissingModificationDateMetadata)
                return true;
            return DefaultErrorHandler(err);
        });
        __c = Container::OpenContainer(EPUB_PATH);
        SetErrorHandler(DefaultErrorHandler);
    });
    return __c;
}

TEST_CASE("SpineItems should have titles when they match a TOC item", "[toc]")
{
    ContainerPtr container = GetContainer();
    auto pkg = container->DefaultPackage();
    auto spine = pkg->FirstSpineItem();
    
    // in alice3.epub, the first item isn't in the TOC, and has an empty title
    // the full list should be:
    /*
     - ""
     - "I. Down the Rabbit-Hole"
     - "II. The Pool of Tears"
     - "III. A Caucus-Race and a Long Tale"
     - "IV. The Rabbit Sends in a Little Bill"
     - "V. Advice from a Caterpillar"
     - "VI. Pig and Pepper"
     - "VII. A Mad Tea-Party"
     - "VIII. The Queen's Croquet-Ground"
     - "IX. The Mock Turtle's Story"
Пример #4
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", "");
	
}