当前位置: 首页>>代码示例>>C++>>正文


C++ CPDF_Dictionary::SetNameFor方法代码示例

本文整理汇总了C++中CPDF_Dictionary::SetNameFor方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::SetNameFor方法的具体用法?C++ CPDF_Dictionary::SetNameFor怎么用?C++ CPDF_Dictionary::SetNameFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPDF_Dictionary的用法示例。


在下文中一共展示了CPDF_Dictionary::SetNameFor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateNewPage

CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
  CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pByteStringPool);
  pDict->SetNameFor("Type", "Page");
  uint32_t dwObjNum = AddIndirectObject(pDict);
  if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) {
    ReleaseIndirectObject(dwObjNum);
    return nullptr;
  }
  return pDict;
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:10,代码来源:cpdf_document.cpp

示例2: CreateNewDoc

void CPDF_Document::CreateNewDoc() {
  ASSERT(!m_pRootDict && !m_pInfoDict);
  m_pRootDict = new CPDF_Dictionary(m_pByteStringPool);
  m_pRootDict->SetNameFor("Type", "Catalog");
  AddIndirectObject(m_pRootDict);

  CPDF_Dictionary* pPages = new CPDF_Dictionary(m_pByteStringPool);
  pPages->SetNameFor("Type", "Pages");
  pPages->SetNumberFor("Count", 0);
  pPages->SetFor("Kids", new CPDF_Array);
  m_pRootDict->SetReferenceFor("Pages", this, AddIndirectObject(pPages));
  m_pInfoDict = new CPDF_Dictionary(m_pByteStringPool);
  AddIndirectObject(m_pInfoDict);
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:14,代码来源:cpdf_document.cpp

示例3:

TEST(cpdf_formfield, FPDF_GetFullName) {
  CFX_WideString name = FPDF_GetFullName(nullptr);
  EXPECT_TRUE(name.IsEmpty());

  CPDF_IndirectObjectHolder obj_holder;
  CPDF_Dictionary* root = new CPDF_Dictionary();
  obj_holder.AddIndirectObject(root);
  root->SetNameFor("T", "foo");
  name = FPDF_GetFullName(root);
  EXPECT_STREQ("foo", name.UTF8Encode().c_str());

  CPDF_Dictionary* dict1 = new CPDF_Dictionary();
  root->SetReferenceFor("Parent", &obj_holder,
                        obj_holder.AddIndirectObject(dict1));
  dict1->SetNameFor("T", "bar");
  name = FPDF_GetFullName(root);
  EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str());

  CPDF_Dictionary* dict2 = new CPDF_Dictionary();
  dict1->SetFor("Parent", dict2);
  name = FPDF_GetFullName(root);
  EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str());

  CPDF_Dictionary* dict3 = new CPDF_Dictionary();
  dict2->SetReferenceFor("Parent", &obj_holder,
                         obj_holder.AddIndirectObject(dict3));
  dict3->SetNameFor("T", "qux");
  name = FPDF_GetFullName(root);
  EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str());

  dict3->SetReferenceFor("Parent", &obj_holder, root->GetObjNum());
  name = FPDF_GetFullName(root);
  EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str());
  name = FPDF_GetFullName(dict1);
  EXPECT_STREQ("foo.qux.bar", name.UTF8Encode().c_str());
  name = FPDF_GetFullName(dict2);
  EXPECT_STREQ("bar.foo.qux", name.UTF8Encode().c_str());
  name = FPDF_GetFullName(dict3);
  EXPECT_STREQ("bar.foo.qux", name.UTF8Encode().c_str());
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:40,代码来源:cpdf_formfield_unittest.cpp

示例4: ProcessForm

void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf,
                                            const uint8_t* data,
                                            uint32_t size,
                                            CFX_Matrix& matrix) {
  if (!data || !size)
    return;

  CPDF_Dictionary* pFormDict =
      new CPDF_Dictionary(m_pDocument->GetByteStringPool());
  pFormDict->SetNameFor("Type", "XObject");
  pFormDict->SetNameFor("Subtype", "Form");

  CFX_FloatRect bbox = m_pPage->GetPageBBox();
  matrix.TransformRect(bbox);
  pFormDict->SetRectFor("BBox", bbox);

  CPDF_Stream* pStream = new CPDF_Stream;
  pStream->InitStream(data, size, pFormDict);
  buf << "q " << matrix << " cm ";

  CFX_ByteString name = RealizeResource(pStream, "XObject");
  buf << "/" << PDF_NameEncode(name) << " Do Q\n";
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:23,代码来源:cpdf_pagecontentgenerator.cpp

示例5: CalculateEncodingDict

size_t CPDF_Document::CalculateEncodingDict(int charset,
                                            CPDF_Dictionary* pBaseDict) {
  size_t i;
  for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
    if (g_FX_CharsetUnicodes[i].m_Charset == charset)
      break;
  }
  if (i == FX_ArraySize(g_FX_CharsetUnicodes))
    return i;
  CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary(m_pByteStringPool);
  pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding");
  CPDF_Array* pArray = new CPDF_Array;
  pArray->AddInteger(128);
  const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
  for (int j = 0; j < 128; j++) {
    CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
    pArray->AddName(name.IsEmpty() ? ".notdef" : name);
  }
  pEncodingDict->SetFor("Differences", pArray);
  pBaseDict->SetReferenceFor("Encoding", this,
                             AddIndirectObject(pEncodingDict));

  return i;
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:24,代码来源:cpdf_document.cpp

示例6: AddWindowsFont

CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
                                         FX_BOOL bVert,
                                         FX_BOOL bTranslateName) {
  pLogFont->lfHeight = -1000;
  pLogFont->lfWidth = 0;
  HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
  HDC hDC = CreateCompatibleDC(nullptr);
  hFont = SelectObject(hDC, hFont);
  int tm_size = GetOutlineTextMetrics(hDC, 0, nullptr);
  if (tm_size == 0) {
    hFont = SelectObject(hDC, hFont);
    DeleteObject(hFont);
    DeleteDC(hDC);
    return nullptr;
  }

  LPBYTE tm_buf = FX_Alloc(BYTE, tm_size);
  OUTLINETEXTMETRIC* ptm = reinterpret_cast<OUTLINETEXTMETRIC*>(tm_buf);
  GetOutlineTextMetrics(hDC, tm_size, ptm);
  int flags = CalculateFlags(false, pLogFont->lfItalic != 0,
                             (pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH,
                             (pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN,
                             (pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT,
                             pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET);

  bool bCJK = pLogFont->lfCharSet == FXFONT_CHINESEBIG5_CHARSET ||
              pLogFont->lfCharSet == FXFONT_GB2312_CHARSET ||
              pLogFont->lfCharSet == FXFONT_HANGUL_CHARSET ||
              pLogFont->lfCharSet == FXFONT_SHIFTJIS_CHARSET;
  CFX_ByteString basefont;
  if (bTranslateName && bCJK)
    basefont = FPDF_GetPSNameFromTT(hDC);

  if (basefont.IsEmpty())
    basefont = pLogFont->lfFaceName;

  int italicangle = ptm->otmItalicAngle / 10;
  int ascend = ptm->otmrcFontBox.top;
  int descend = ptm->otmrcFontBox.bottom;
  int capheight = ptm->otmsCapEmHeight;
  int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom,
                 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top};
  FX_Free(tm_buf);
  basefont.Replace(" ", "");
  CPDF_Dictionary* pBaseDict = new CPDF_Dictionary(m_pByteStringPool);
  pBaseDict->SetNameFor("Type", "Font");
  CPDF_Dictionary* pFontDict = pBaseDict;
  if (!bCJK) {
    if (pLogFont->lfCharSet == FXFONT_ANSI_CHARSET ||
        pLogFont->lfCharSet == FXFONT_DEFAULT_CHARSET ||
        pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET) {
      pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding");
    } else {
      CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict);
    }
    int char_widths[224];
    GetCharWidth(hDC, 32, 255, char_widths);
    CPDF_Array* pWidths = new CPDF_Array;
    for (size_t i = 0; i < 224; i++)
      pWidths->AddInteger(char_widths[i]);
    ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM,
                   pLogFont->lfItalic != 0, basefont, pWidths);
  } else {
    pFontDict =
        ProcessbCJK(pBaseDict, pLogFont->lfCharSet, bVert, basefont,
                    [&hDC](FX_WCHAR start, FX_WCHAR end, CPDF_Array* widthArr) {
                      InsertWidthArray(hDC, start, end, widthArr);
                    });
  }
  AddIndirectObject(pBaseDict);
  CPDF_Array* pBBox = new CPDF_Array;
  for (int i = 0; i < 4; i++)
    pBBox->AddInteger(bbox[i]);
  CPDF_Dictionary* pFontDesc =
      CalculateFontDesc(this, basefont, flags, italicangle, ascend, descend,
                        pBBox, pLogFont->lfWeight / 5);
  pFontDesc->SetIntegerFor("CapHeight", capheight);
  pFontDict->SetReferenceFor("FontDescriptor", this,
                             AddIndirectObject(pFontDesc));
  hFont = SelectObject(hDC, hFont);
  DeleteObject(hFont);
  DeleteDC(hDC);
  return LoadFont(pBaseDict);
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:84,代码来源:cpdf_document.cpp

示例7: AddFont

CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
  if (!pFont)
    return nullptr;

  bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
              charset == FXFONT_GB2312_CHARSET ||
              charset == FXFONT_HANGUL_CHARSET ||
              charset == FXFONT_SHIFTJIS_CHARSET;
  CFX_ByteString basefont = pFont->GetFamilyName();
  basefont.Replace(" ", "");
  int flags =
      CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(),
                     false, false, charset == FXFONT_SYMBOL_CHARSET);

  CPDF_Dictionary* pBaseDict = new CPDF_Dictionary(m_pByteStringPool);
  pBaseDict->SetNameFor("Type", "Font");
  std::unique_ptr<CFX_UnicodeEncoding> pEncoding(
      new CFX_UnicodeEncoding(pFont));
  CPDF_Dictionary* pFontDict = pBaseDict;
  if (!bCJK) {
    CPDF_Array* pWidths = new CPDF_Array;
    for (int charcode = 32; charcode < 128; charcode++) {
      int glyph_index = pEncoding->GlyphFromCharCode(charcode);
      int char_width = pFont->GetGlyphWidth(glyph_index);
      pWidths->AddInteger(char_width);
    }
    if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET ||
        charset == FXFONT_SYMBOL_CHARSET) {
      pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding");
      for (int charcode = 128; charcode <= 255; charcode++) {
        int glyph_index = pEncoding->GlyphFromCharCode(charcode);
        int char_width = pFont->GetGlyphWidth(glyph_index);
        pWidths->AddInteger(char_width);
      }
    } else {
      size_t i = CalculateEncodingDict(charset, pBaseDict);
      if (i < FX_ArraySize(g_FX_CharsetUnicodes)) {
        const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
        for (int j = 0; j < 128; j++) {
          int glyph_index = pEncoding->GlyphFromCharCode(pUnicodes[j]);
          int char_width = pFont->GetGlyphWidth(glyph_index);
          pWidths->AddInteger(char_width);
        }
      }
    }
    ProcessNonbCJK(pBaseDict, pFont->IsBold(), pFont->IsItalic(), basefont,
                   pWidths);
  } else {
    pFontDict = ProcessbCJK(pBaseDict, charset, bVert, basefont,
                            [pFont, &pEncoding](FX_WCHAR start, FX_WCHAR end,
                                                CPDF_Array* widthArr) {
                              InsertWidthArray1(pFont, pEncoding.get(), start,
                                                end, widthArr);
                            });
  }
  AddIndirectObject(pBaseDict);
  int italicangle =
      pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0;
  FX_RECT bbox;
  pFont->GetBBox(bbox);
  CPDF_Array* pBBox = new CPDF_Array;
  pBBox->AddInteger(bbox.left);
  pBBox->AddInteger(bbox.bottom);
  pBBox->AddInteger(bbox.right);
  pBBox->AddInteger(bbox.top);
  int32_t nStemV = 0;
  if (pFont->GetSubstFont()) {
    nStemV = pFont->GetSubstFont()->m_Weight / 5;
  } else {
    static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'};
    const size_t count = FX_ArraySize(stem_chars);
    uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
    nStemV = pFont->GetGlyphWidth(glyph);
    for (size_t i = 1; i < count; i++) {
      glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
      int width = pFont->GetGlyphWidth(glyph);
      if (width > 0 && width < nStemV)
        nStemV = width;
    }
  }
  CPDF_Dictionary* pFontDesc =
      CalculateFontDesc(this, basefont, flags, italicangle, pFont->GetAscent(),
                        pFont->GetDescent(), pBBox, nStemV);
  pFontDict->SetReferenceFor("FontDescriptor", this,
                             AddIndirectObject(pFontDesc));
  return LoadFont(pBaseDict);
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:87,代码来源:cpdf_document.cpp

示例8: ProcessbCJK

CPDF_Dictionary* CPDF_Document::ProcessbCJK(
    CPDF_Dictionary* pBaseDict,
    int charset,
    FX_BOOL bVert,
    CFX_ByteString basefont,
    std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) {
  CPDF_Dictionary* pFontDict = new CPDF_Dictionary(m_pByteStringPool);
  CFX_ByteString cmap;
  CFX_ByteString ordering;
  int supplement = 0;
  CPDF_Array* pWidthArray = new CPDF_Array;
  switch (charset) {
    case FXFONT_CHINESEBIG5_CHARSET:
      cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
      ordering = "CNS1";
      supplement = 4;
      pWidthArray->AddInteger(1);
      Insert(0x20, 0x7e, pWidthArray);
      break;
    case FXFONT_GB2312_CHARSET:
      cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
      ordering = "GB1";
      supplement = 2;
      pWidthArray->AddInteger(7716);
      Insert(0x20, 0x20, pWidthArray);
      pWidthArray->AddInteger(814);
      Insert(0x21, 0x7e, pWidthArray);
      break;
    case FXFONT_HANGUL_CHARSET:
      cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
      ordering = "Korea1";
      supplement = 2;
      pWidthArray->AddInteger(1);
      Insert(0x20, 0x7e, pWidthArray);
      break;
    case FXFONT_SHIFTJIS_CHARSET:
      cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
      ordering = "Japan1";
      supplement = 5;
      pWidthArray->AddInteger(231);
      Insert(0x20, 0x7d, pWidthArray);
      pWidthArray->AddInteger(326);
      Insert(0xa0, 0xa0, pWidthArray);
      pWidthArray->AddInteger(327);
      Insert(0xa1, 0xdf, pWidthArray);
      pWidthArray->AddInteger(631);
      Insert(0x7e, 0x7e, pWidthArray);
      break;
  }
  pBaseDict->SetNameFor("Subtype", "Type0");
  pBaseDict->SetNameFor("BaseFont", basefont);
  pBaseDict->SetNameFor("Encoding", cmap);
  pFontDict->SetFor("W", pWidthArray);
  pFontDict->SetNameFor("Type", "Font");
  pFontDict->SetNameFor("Subtype", "CIDFontType2");
  pFontDict->SetNameFor("BaseFont", basefont);
  CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary(m_pByteStringPool);
  pCIDSysInfo->SetStringFor("Registry", "Adobe");
  pCIDSysInfo->SetStringFor("Ordering", ordering);
  pCIDSysInfo->SetIntegerFor("Supplement", supplement);
  pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo);
  CPDF_Array* pArray = new CPDF_Array;
  pBaseDict->SetFor("DescendantFonts", pArray);
  pArray->AddReference(this, AddIndirectObject(pFontDict));
  return pFontDict;
}
开发者ID:hfiguiere,项目名称:pdfium,代码行数:66,代码来源:cpdf_document.cpp

示例9: if


//.........这里部分代码省略.........

  CPDF_Stream* pNewXObject = new CPDF_Stream(
      nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool()));

  uint32_t dwObjNum = pDocument->AddIndirectObject(pNewXObject);
  CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject");
  if (!pPageXObject) {
    pPageXObject = new CPDF_Dictionary(pDocument->GetByteStringPool());
    pRes->SetFor("XObject", pPageXObject);
  }

  CFX_ByteString key = "";
  int nStreams = ObjectArray.GetSize();

  if (nStreams > 0) {
    for (int iKey = 0; /*iKey < 100*/; iKey++) {
      char sExtend[5] = {};
      FXSYS_itoa(iKey, sExtend, 10);
      key = CFX_ByteString("FFT") + CFX_ByteString(sExtend);
      if (!pPageXObject->KeyExist(key))
        break;
    }
  }

  SetPageContents(key, pPageDict, pDocument);

  CPDF_Dictionary* pNewXORes = nullptr;

  if (!key.IsEmpty()) {
    pPageXObject->SetReferenceFor(key, pDocument, dwObjNum);
    CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict();
    pNewXORes = new CPDF_Dictionary(pDocument->GetByteStringPool());
    pNewOXbjectDic->SetFor("Resources", pNewXORes);
    pNewOXbjectDic->SetNameFor("Type", "XObject");
    pNewOXbjectDic->SetNameFor("Subtype", "Form");
    pNewOXbjectDic->SetIntegerFor("FormType", 1);
    pNewOXbjectDic->SetNameFor("Name", "FRM");
    CFX_FloatRect rcBBox = pPageDict->GetRectFor("ArtBox");
    pNewOXbjectDic->SetRectFor("BBox", rcBBox);
  }

  for (int i = 0; i < nStreams; i++) {
    CPDF_Dictionary* pAnnotDic = ObjectArray.GetAt(i);
    if (!pAnnotDic)
      continue;

    CFX_FloatRect rcAnnot = pAnnotDic->GetRectFor("Rect");
    rcAnnot.Normalize();

    CFX_ByteString sAnnotState = pAnnotDic->GetStringFor("AS");
    CPDF_Dictionary* pAnnotAP = pAnnotDic->GetDictFor("AP");
    if (!pAnnotAP)
      continue;

    CPDF_Stream* pAPStream = pAnnotAP->GetStreamFor("N");
    if (!pAPStream) {
      CPDF_Dictionary* pAPDic = pAnnotAP->GetDictFor("N");
      if (!pAPDic)
        continue;

      if (!sAnnotState.IsEmpty()) {
        pAPStream = pAPDic->GetStreamFor(sAnnotState);
      } else {
        auto it = pAPDic->begin();
        if (it != pAPDic->end()) {
          CPDF_Object* pFirstObj = it->second;
开发者ID:hfiguiere,项目名称:pdfium,代码行数:67,代码来源:fpdf_flatten.cpp


注:本文中的CPDF_Dictionary::SetNameFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。