Beispiel #1
0
  void CreateAndInitializeFormPDF() {
    EXPECT_TRUE(OpenDocument("text_form_multiple.pdf"));
    m_page = LoadPage(0);
    ASSERT_TRUE(m_page);

    m_pFormFillEnv =
        CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle());
    CPDFSDK_AnnotIterator iter(m_pFormFillEnv->GetPageView(0),
                               CPDF_Annot::Subtype::WIDGET);
    // Normal text field.
    m_pAnnot = iter.GetFirstAnnot();
    ASSERT_TRUE(m_pAnnot);
    ASSERT_EQ(CPDF_Annot::Subtype::WIDGET, m_pAnnot->GetAnnotSubtype());

    // Read-only text field.
    CPDFSDK_Annot* pAnnotReadOnly = iter.GetNextAnnot(m_pAnnot);

    // Pre-filled text field with char limit of 10.
    m_pAnnotCharLimit = iter.GetNextAnnot(pAnnotReadOnly);
    ASSERT_TRUE(m_pAnnotCharLimit);
    ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
              m_pAnnotCharLimit->GetAnnotSubtype());
    CPDFSDK_Annot* pLastAnnot = iter.GetLastAnnot();
    ASSERT_EQ(m_pAnnotCharLimit, pLastAnnot);
  }
Beispiel #2
0
STDMETHODIMP CECR::Cut(BSTR FirmID, LONG CutType, LONG* ErrorCode)
{
    if(!bDocOpened)
    {
        OpenDocument(FirmID, DEP_NO, ErrorCode, NonFiskDocument);
        if (*ErrorCode == E_SUCCESS)
            PrintBuffer(FirmID, ErrorCode);
    }

    InitCmd();
    // команда
    to_numeric(215, m_Cmd, 3, m_Len);   //CLOSE
    // пароль
    to_char(OPERATOR_PASSWD, m_Cmd + m_Len, 4, m_Len);
    // обрезать чек
    to_numeric(CutType, m_Cmd + m_Len, 1, m_Len);   

    m_RspLen = 0;
    m_ECRList.PassCmd(FirmID, m_Cmd, m_Len, m_Rsp, m_RspLen, ErrorCode);
    if (*ErrorCode == E_SUCCESS)
    {
        ClearPrintBuffer();
        bDocOpened = FALSE;
    }

    return S_OK;
}
Beispiel #3
0
BOOL DocRoot::OnOpenDocument(const char* pszPathName)
  {
  if (gs_pPrj->pPrjDoc==NULL && !gs_pPrj->bDoingLoad)//sPrjFile.Length() > 0)
    {
    LogError("SysCAD", 0, "A project must be opened or a new project created.");
    bIsOpen = True; //ensures document/window is closed properly
    return False;
    }

  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands
  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once!

  OnAttachDoc(); // to connect and attach document to cmdblks

  //Strng Cmd;
  //Cmd.Set("LOAD DOCUMENT %s\r",pszPathName);
  //gs_pCmd->ProcessAStr(Cmd());
  OpenDocument(pszPathName);
  bIsOpen = True;

  //OnActivate(True); // to connect and attach document to cmdblks

  //gs_pCmd->SetDocForCmds(NULL);
  return True;
  }
TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) {
  EXPECT_TRUE(OpenDocument("testing/resources/named_dests.pdf"));

  // NULL FPDF_DEST case.
  EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), nullptr));

  // Page number directly in item from Dests NameTree.
  FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
  EXPECT_NE(nullptr, dest);
  EXPECT_EQ(1U, FPDFDest_GetPageIndex(document(), dest));

  // Page number via object reference in item from Dests NameTree.
  dest = FPDF_GetNamedDestByName(document(), "Next");
  EXPECT_NE(nullptr, dest);
  EXPECT_EQ(1U, FPDFDest_GetPageIndex(document(), dest));

  // Page number directly in item from Dests dictionary.
  dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
  EXPECT_NE(nullptr, dest);
  EXPECT_EQ(11U, FPDFDest_GetPageIndex(document(), dest));

  // Invalid object reference in item from Dests NameTree.
  dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
  EXPECT_NE(nullptr, dest);
  EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest));
}
Beispiel #5
0
TEST_F(FPDFStructTreeEmbedderTest, GetType) {
  ASSERT_TRUE(OpenDocument("tagged_alt_text.pdf"));
  FPDF_PAGE page = LoadPage(0);
  ASSERT_TRUE(page);

  {
    ScopedFPDFStructTree struct_tree(FPDF_StructTree_GetForPage(page));
    ASSERT_TRUE(struct_tree);
    ASSERT_EQ(1, FPDF_StructTree_CountChildren(struct_tree.get()));

    FPDF_STRUCTELEMENT element =
        FPDF_StructTree_GetChildAtIndex(struct_tree.get(), 0);
    ASSERT_NE(nullptr, element);

    unsigned short buffer[12];
    memset(buffer, 0, sizeof(buffer));
    // Deliberately pass in a small buffer size to make sure |buffer| remains
    // untouched.
    ASSERT_EQ(18U, FPDF_StructElement_GetType(element, buffer, 1));
    for (size_t i = 0; i < FX_ArraySize(buffer); ++i)
      EXPECT_EQ(0U, buffer[i]);

    ASSERT_EQ(18U, FPDF_StructElement_GetType(element, buffer, sizeof(buffer)));
    const wchar_t kExpected[] = L"Document";
    EXPECT_EQ(WideString(kExpected),
              WideString::FromUTF16LE(buffer, FXSYS_len(kExpected)));
  }

  UnloadPage(page);
}
TEST_F(FPDFParserEmbeddertest, Bug_481363) {
  // Test colorspace object with malformed dictionary.
  EXPECT_TRUE(OpenDocument("testing/resources/bug_481363.pdf"));
  FPDF_PAGE page = LoadPage(0);
  EXPECT_NE(nullptr, page);
  UnloadPage(page);
}
Beispiel #7
0
STDMETHODIMP CECR::MoveCash(BSTR FirmID, LONG Money, LONG DirectionIn, LONG* ErrorCode)
{
    DWORD dwDocType;
    DirectionIn ? dwDocType = CashInDocument : dwDocType = CashOutDocument;

    // открыть документ
    OpenDocument(FirmID, DEP_NO, ErrorCode, dwDocType);
    if (*ErrorCode == E_SUCCESS)
    {
        PrintBuffer(FirmID, ErrorCode);
        if (*ErrorCode == E_SUCCESS)
        {
            InitCmd();
            // команда
            to_numeric(214, m_Cmd, 3, m_Len);   //SETTENDER
            // пароль
            to_char(OPERATOR_PASSWD, m_Cmd + m_Len, 4, m_Len);
            // тип оплаты
            to_numeric(0, m_Cmd + m_Len, 2, m_Len);   
            // сумма
            to_smoney(Money, m_Cmd + m_Len, 10, m_Len);   

            m_RspLen = 11;
            m_ECRList.PassCmd(FirmID, m_Cmd, m_Len, m_Rsp, m_RspLen, ErrorCode);

            if (*ErrorCode == E_SUCCESS)
                Cut(FirmID, 1, ErrorCode);
        }
    }
    return S_OK;
}
Beispiel #8
0
TEST_F(FPDFDocEmbedderTest, ActionURI) {
  EXPECT_TRUE(OpenDocument("uri_action.pdf"));

  FPDF_PAGE page = LoadPage(0);
  ASSERT_TRUE(page);

  // The target action is nearly the size of the whole page.
  FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100);
  ASSERT_TRUE(link);

  FPDF_ACTION action = FPDFLink_GetAction(link);
  ASSERT_TRUE(action);
  EXPECT_EQ(static_cast<unsigned long>(PDFACTION_URI),
            FPDFAction_GetType(action));

  const char kExpectedResult[] = "https://example.com/page.html";
  const unsigned long kExpectedLength = sizeof(kExpectedResult);
  unsigned long bufsize = FPDFAction_GetURIPath(document(), action, nullptr, 0);
  ASSERT_EQ(kExpectedLength, bufsize);

  char buf[1024];
  EXPECT_EQ(bufsize, FPDFAction_GetURIPath(document(), action, buf, bufsize));
  EXPECT_STREQ(kExpectedResult, buf);

  // Other public methods are not appropriate for URI actions
  EXPECT_EQ(nullptr, FPDFAction_GetDest(document(), action));
  EXPECT_EQ(0u, FPDFAction_GetFilePath(action, buf, sizeof(buf)));

  UnloadPage(page);
}
Beispiel #9
0
TEST_F(FPDFDocEmbedderTest, DestGetPageIndex) {
  EXPECT_TRUE(OpenDocument("named_dests.pdf"));

  // NULL argument cases.
  EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(nullptr, nullptr));
  EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), nullptr));

  // Page number directly in item from Dests NameTree.
  FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
  EXPECT_TRUE(dest);
  EXPECT_EQ(1, FPDFDest_GetDestPageIndex(document(), dest));

  // Page number via object reference in item from Dests NameTree.
  dest = FPDF_GetNamedDestByName(document(), "Next");
  EXPECT_TRUE(dest);
  EXPECT_EQ(1, FPDFDest_GetDestPageIndex(document(), dest));

  // Page number directly in item from Dests dictionary.
  dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
  EXPECT_TRUE(dest);
  EXPECT_EQ(11, FPDFDest_GetDestPageIndex(document(), dest));

  // Invalid object reference in item from Dests NameTree.
  dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
  EXPECT_TRUE(dest);
  EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
}
Beispiel #10
0
STDMETHODIMP CRegistrator::DoReturn(BSTR FirmID, BSTR ReturnText, LONG Quantity, LONG Price, LONG DepNo, LONG* ErrorCode)
{
	*ErrorCode = E_SUCCESS;
	CRegistratorInfo* regInfo = m_RegistratorList.GetInfo(FirmID);
	if(!regInfo)
	{
		*ErrorCode = E_NOT_FOUND;
		return S_OK;
	}
	LONG nAmount = 0;

	// проверяем состояние документа
	BYTE nDocumentStatus;
	if(!GetDocumentStatus(regInfo->hCommPort, &nDocumentStatus, ErrorCode))
		return S_OK;

	// если документ не открыт
	if((nDocumentStatus & 0x0F) == 0)
	{
		// открываем документ
		if(!OpenDocument(regInfo->hCommPort, DepNo, '3', szCashierStoredName, ErrorCode))
			return CheckPaperStatus(regInfo, ErrorCode);

		if(!PrintBuffer(FirmID, ErrorCode))
			return CheckPaperStatus(regInfo, ErrorCode);

		m_nReturnAmount = 0;
	}

	if(RegisterInternal(regInfo->hCommPort, ReturnText, Quantity, Price, DepNo, &nAmount, ErrorCode))
		m_nReturnAmount += nAmount;

	return CheckPaperStatus(regInfo, ErrorCode);
}
Beispiel #11
0
STDMETHODIMP CRegistrator::Cut(BSTR FirmID, LONG CutType, LONG* ErrorCode)
{
	*ErrorCode = E_SUCCESS;
	CRegistratorInfo* regInfo = m_RegistratorList.GetInfo(FirmID);
	if(!regInfo)
	{
		*ErrorCode = E_NOT_FOUND;
		return S_OK;
	}
	
	// открываем документ
	BYTE nDocumentStatus;
	if(!GetDocumentStatus(regInfo->hCommPort, &nDocumentStatus, ErrorCode))
		return S_OK;

	// если документ не открыт
	if((nDocumentStatus & 0x0F) == 0)
	{
		if(!OpenDocument(regInfo->hCommPort, 1, '1', szCashierStoredName, ErrorCode))
			return CheckPaperStatus(regInfo, ErrorCode);

		if(!PrintBuffer(FirmID, ErrorCode))
			return CheckPaperStatus(regInfo, ErrorCode);
	}

	if(CloseDocInternal(regInfo, ErrorCode))
		m_ReceiptLines.RemoveAll();

//	PassCommand(regInfo->hCommPort, (LPBYTE) "25", NULL, 0, nReceivedMessage, ErrorCode);
	return CheckPaperStatus(regInfo, ErrorCode);
}
Beispiel #12
0
TEST_F(FPDFDocEmbedderTest, GetMetaText) {
  ASSERT_TRUE(OpenDocument("bug_601362.pdf"));

  // Invalid document / tag results in 0.
  unsigned short buf[128];
  EXPECT_EQ(0u, FPDF_GetMetaText(document(), nullptr, buf, sizeof(buf)));
  EXPECT_EQ(0u, FPDF_GetMetaText(nullptr, "", buf, sizeof(buf)));

  // Tags that do not eixst results in an empty wide string.
  EXPECT_EQ(2u, FPDF_GetMetaText(document(), "", buf, sizeof(buf)));
  EXPECT_EQ(2u, FPDF_GetMetaText(document(), "foo", buf, sizeof(buf)));
  ASSERT_EQ(2u, FPDF_GetMetaText(document(), "Title", buf, sizeof(buf)));
  ASSERT_EQ(2u, FPDF_GetMetaText(document(), "Author", buf, sizeof(buf)));
  ASSERT_EQ(2u, FPDF_GetMetaText(document(), "Subject", buf, sizeof(buf)));
  ASSERT_EQ(2u, FPDF_GetMetaText(document(), "Keywords", buf, sizeof(buf)));
  ASSERT_EQ(2u, FPDF_GetMetaText(document(), "Producer", buf, sizeof(buf)));

  constexpr wchar_t kExpectedCreator[] = L"Microsoft Word";
  ASSERT_EQ(30u, FPDF_GetMetaText(document(), "Creator", buf, sizeof(buf)));
  EXPECT_EQ(WideString(kExpectedCreator),
            WideString::FromUTF16LE(buf, FXSYS_len(kExpectedCreator)));

  constexpr wchar_t kExpectedCreationDate[] = L"D:20160411190039+00'00'";
  ASSERT_EQ(48u,
            FPDF_GetMetaText(document(), "CreationDate", buf, sizeof(buf)));
  EXPECT_EQ(WideString(kExpectedCreationDate),
            WideString::FromUTF16LE(buf, FXSYS_len(kExpectedCreationDate)));

  constexpr wchar_t kExpectedModDate[] = L"D:20160411190039+00'00'";
  ASSERT_EQ(48u, FPDF_GetMetaText(document(), "ModDate", buf, sizeof(buf)));
  EXPECT_EQ(WideString(kExpectedModDate),
            WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate)));
}
void TestOpenDocument( void )
{
    Err             err;
    DocumentInfo    docInfo;

    OS_Init();
    ReadPrefs();
    SetStandardFunctions();

    DeleteMetaDocument( TEST_DOCUMENT, 0 );

    StrCopy( docInfo.name, TEST_DOCUMENT );
    docInfo.cardNo      = 0;
    docInfo.size        = 550;
    docInfo.created     = -1139389298;
    docInfo.attributes  = 512;
    docInfo.categories  = 1;
    docInfo.location    = 0;
    docInfo.active      = true;
    docInfo.timestamp   = 0;
    docInfo.volumeRef   = 0;
    docInfo.numRecords  = 0;

    err = OpenDocument( &docInfo );
    ASSERT_MSG( "UnitTest.pdb must be installed", err == errNone );

    CloseDocument();
    OS_Release();
}
Beispiel #14
0
TEST_F(FPDFDocEmbedderTest, DestGetLocationInPage) {
  EXPECT_TRUE(OpenDocument("named_dests.pdf"));

  FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
  EXPECT_TRUE(dest);

  FPDF_BOOL hasX = 0;
  FPDF_BOOL hasY = 0;
  FPDF_BOOL hasZoom = 0;
  FS_FLOAT x = -1.0f;
  FS_FLOAT y = -1.0f;
  FS_FLOAT zoom = -1.0f;

  // NULL argument case
  EXPECT_FALSE(FPDFDest_GetLocationInPage(nullptr, &hasX, &hasY, &hasZoom, &x,
                                          &y, &zoom));

  // Actual argument case.
  EXPECT_TRUE(
      FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom));
  EXPECT_TRUE(hasX);
  EXPECT_TRUE(hasY);
  EXPECT_TRUE(hasZoom);
  EXPECT_EQ(0, x);
  EXPECT_EQ(0, y);
  EXPECT_EQ(1, zoom);
}
Beispiel #15
0
TEST_F(FPDFDocEmbedderTest, BUG_680376) {
  EXPECT_TRUE(OpenDocument("bug_680376.pdf"));

  // Page number directly in item from Dests NameTree.
  FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
  EXPECT_TRUE(dest);
  EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
}
CWordBinaryMetadataDiscoveryWorker::CWordBinaryMetadataDiscoveryWorker(
	const CStdString& sFilePath, CWordBinaryDiscoverStrategy* pStrategy)  :
    m_pStrategy(pStrategy),
	m_bDetailedDiscovery(true)
{
	Initialise();
	OpenDocument(sFilePath);
}
TEST_F(FPDFParserEmbeddertest, Bug_544880) {
  // Test self referencing /Pages object.
  EXPECT_TRUE(OpenDocument("bug_544880.pdf"));
  // Shouldn't crash. We don't check the return value here because we get the
  // the count from the "/Count 1" in the testcase (at the time of writing)
  // rather than the actual count (0).
  (void)GetPageCount();
}
Beispiel #18
0
TEST_F(FPDFDocEmbedderTest, DestGetView) {
  EXPECT_TRUE(OpenDocument("named_dests.pdf"));

  unsigned long numParams;
  FS_FLOAT params[4];

  numParams = 42;
  std::fill_n(params, 4, 42.4242f);
  EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_UNKNOWN_MODE),
            FPDFDest_GetView(nullptr, &numParams, params));
  EXPECT_EQ(0U, numParams);
  EXPECT_FLOAT_EQ(42.4242f, params[0]);

  numParams = 42;
  std::fill_n(params, 4, 42.4242f);
  FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
  EXPECT_TRUE(dest);
  EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_XYZ),
            FPDFDest_GetView(dest, &numParams, params));
  EXPECT_EQ(3U, numParams);
  EXPECT_FLOAT_EQ(0, params[0]);
  EXPECT_FLOAT_EQ(0, params[1]);
  EXPECT_FLOAT_EQ(1, params[2]);
  EXPECT_FLOAT_EQ(42.4242f, params[3]);

  numParams = 42;
  std::fill_n(params, 4, 42.4242f);
  dest = FPDF_GetNamedDestByName(document(), "Next");
  EXPECT_TRUE(dest);
  EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_FIT),
            FPDFDest_GetView(dest, &numParams, params));
  EXPECT_EQ(0U, numParams);
  EXPECT_FLOAT_EQ(42.4242f, params[0]);

  numParams = 42;
  std::fill_n(params, 4, 42.4242f);
  dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
  EXPECT_TRUE(dest);
  EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_XYZ),
            FPDFDest_GetView(dest, &numParams, params));
  EXPECT_EQ(3U, numParams);
  EXPECT_FLOAT_EQ(200, params[0]);
  EXPECT_FLOAT_EQ(400, params[1]);
  EXPECT_FLOAT_EQ(800, params[2]);
  EXPECT_FLOAT_EQ(42.4242f, params[3]);

  numParams = 42;
  std::fill_n(params, 4, 42.4242f);
  dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
  EXPECT_TRUE(dest);
  EXPECT_EQ(static_cast<unsigned long>(PDFDEST_VIEW_XYZ),
            FPDFDest_GetView(dest, &numParams, params));
  EXPECT_EQ(3U, numParams);
  EXPECT_FLOAT_EQ(0, params[0]);
  EXPECT_FLOAT_EQ(0, params[1]);
  EXPECT_FLOAT_EQ(-200, params[2]);
  EXPECT_FLOAT_EQ(42.4242f, params[3]);
}
TEST_F(FXGETextEmbedderTest, BadItalic) {
  // Shouldn't crash.
  EXPECT_TRUE(OpenDocument("bug_601362.pdf"));
  FPDF_PAGE page = LoadPage(0);
  EXPECT_NE(nullptr, page);
  FPDF_BITMAP bitmap = RenderPage(page);
  FPDFBitmap_Destroy(bitmap);
  UnloadPage(page);
}
Beispiel #20
0
// Check circular bookmarks will not cause infinite loop.
TEST_F(FPDFDocEmbedderTest, FindBookmarks_bug420) {
  // Open a file with circular bookmarks.
  EXPECT_TRUE(OpenDocument("bookmarks_circular.pdf"));

  // Try to find a title.
  std::unique_ptr<unsigned short, pdfium::FreeDeleter> title =
      GetFPDFWideString(L"anything");
  EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get()));
}
TEST_F(FPDFViewEmbeddertest, Page) {
  EXPECT_TRUE(OpenDocument("about_blank.pdf"));
  FPDF_PAGE page = LoadPage(0);
  EXPECT_NE(nullptr, page);
  EXPECT_EQ(612.0, FPDF_GetPageWidth(page));
  EXPECT_EQ(792.0, FPDF_GetPageHeight(page));
  UnloadPage(page);
  EXPECT_EQ(nullptr, LoadPage(1));
}
TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_557223) {
  // Should not crash
  EXPECT_TRUE(OpenDocument("bug_557223.pdf"));
  FPDF_PAGE page = LoadPage(0);
  EXPECT_NE(nullptr, page);
  FPDF_BITMAP bitmap = RenderPage(page);
  CompareBitmap(bitmap, 24, 24, "dc0ea1b743c2edb22c597cadc8537f7b");
  FPDFBitmap_Destroy(bitmap);
  UnloadPage(page);
}
Beispiel #23
0
TEST_F(FPDFDocEmbedderTest, GetMetaTextInAttachmentFile) {
  ASSERT_TRUE(OpenDocument("embedded_attachments.pdf"));

  // Make sure this is the date from the PDF itself and not the attached PDF.
  unsigned short buf[128];
  constexpr wchar_t kExpectedModDate[] = L"D:20170712214448-07'00'";
  ASSERT_EQ(48u, FPDF_GetMetaText(document(), "ModDate", buf, sizeof(buf)));
  EXPECT_EQ(WideString(kExpectedModDate),
            WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate)));
}
Beispiel #24
0
TEST_F(FPDFDocEmbedderTest, Bug_182) {
  ASSERT_TRUE(OpenDocument("bug_182.pdf"));

  unsigned short buf[128];
  constexpr wchar_t kExpectedTitle[] = L"Super Visual Formade 印刷";

  ASSERT_EQ(48u, FPDF_GetMetaText(document(), "Title", buf, sizeof(buf)));
  EXPECT_EQ(WideString(kExpectedTitle),
            WideString::FromUTF16LE(buf, FXSYS_len(kExpectedTitle)));
}
TEST_F(FPDFRenderLoadImageEmbeddertest, Bug_603518) {
  // Should not crash
  EXPECT_TRUE(OpenDocument("bug_603518.pdf"));
  FPDF_PAGE page = LoadPage(0);
  EXPECT_NE(nullptr, page);
  FPDF_BITMAP bitmap = RenderPage(page);
  CompareBitmap(bitmap, 749, 749, "b9e75190cdc5edf0069a408744ca07dc");
  FPDFBitmap_Destroy(bitmap);
  UnloadPage(page);
}
Beispiel #26
0
TEST_F(FXCodecEmbedderTest, Bug_631912) {
  // Test jbig2 image in PDF file can be loaded successfully.
  // Should not crash.
  EXPECT_TRUE(OpenDocument("bug_631912.pdf"));
  FPDF_PAGE page = LoadPage(0);
  ASSERT_TRUE(page);
  ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
  CompareBitmap(bitmap.get(), 691, 432, "24d75af646f8772c5ee7ced260452ae4");
  UnloadPage(page);
}
TEST_F(FXCodecEmbeddertest, Bug_631912) {
  // Test jbig2 image in PDF file can be loaded successfully.
  // Should not crash.
  EXPECT_TRUE(OpenDocument("bug_631912.pdf"));
  FPDF_PAGE page = LoadPage(0);
  EXPECT_NE(nullptr, page);
  FPDF_BITMAP bitmap = RenderPage(page);
  FPDFBitmap_Destroy(bitmap);
  UnloadPage(page);
}
TEST_F(FPDFViewEmbeddertest, ViewerRefDummy) {
  EXPECT_TRUE(OpenDocument("about_blank.pdf"));
  EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
  EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
  EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));

  char buf[100];
  EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(), "foo", nullptr, 0));
  EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(), "foo", buf, sizeof(buf)));
}
Beispiel #29
0
void MainFrame::OnOpenSelection(const std::string& value)
{
	auto fullPath = Wex::Path::Combine(project.GetProjectDirectory(), value);
	if (Wex::String::ToLower(fullPath) == Wex::String::ToLower(project.GetFileName()))
		MsgBox("Edit Project");
	else
		OpenDocument(fullPath);
	superBox.Close();
	activeWindow.SetFocus();
}
Beispiel #30
0
TEST_F(FPDFDocEmbedderTest, GetXFALinks) {
  EXPECT_TRUE(OpenDocument("simple_xfa.pdf"));

  ScopedFPDFPage page(FPDF_LoadPage(document(), 0));
  ASSERT_TRUE(page);

  FPDFLink_GetLinkAtPoint(page.get(), 150, 360);
  FPDFLink_GetLinkAtPoint(page.get(), 150, 420);

  // Test passes if it doesn't crash. See https://crbug.com/840922
}