本文整理汇总了C++中CFX_ByteString::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ CFX_ByteString::Format方法的具体用法?C++ CFX_ByteString::Format怎么用?C++ CFX_ByteString::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFX_ByteString
的用法示例。
在下文中一共展示了CFX_ByteString::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FocusGetData
void CPDF_ReflowedPage::FocusGetData(const CFX_AffineMatrix matrix, FX_INT32 x, FX_INT32 y, CFX_ByteString& str)
{
if (NULL == m_pReflowed) {
return;
}
CFX_AffineMatrix revMatrix;
revMatrix.SetReverse(matrix);
FX_FLOAT x1, y1;
revMatrix.Transform((float)x, (float)y, x1, y1);
int count = m_pReflowed->GetSize();
FX_FLOAT dx = 1000, dy = 1000;
FX_INT32 pos = 0;
FX_INT32 i;
for(i = 0; i < count; i++) {
CRF_Data* pData = (*m_pReflowed)[i];
FX_FLOAT tempdy = FXSYS_fabs(pData->m_PosY - y1);
if(FXSYS_fabs(tempdy - dy) < 1) {
continue;
}
CFX_FloatRect rect (0, pData->m_PosY + pData->m_Height, this->m_PageWidth, pData->m_PosY);
if(rect.Contains(x1, y1)) {
pos = i;
dx = 0;
dy = 0;
break;
} else if(tempdy < dy) {
dy = tempdy;
dx = FXSYS_fabs(pData->m_PosX - x1);
pos = i;
} else if (tempdy == dy) {
FX_FLOAT tempdx = FXSYS_fabs(pData->m_PosX - x1);
if(tempdx < dx) {
dx = tempdx;
pos = i;
}
} else if (tempdy > dy) {
break;
}
}
if(dx != 0 || dy != 0) {
count = count < (pos + 10) ? count : (pos + 10);
for(i = 0 > (pos - 10) ? 0 : (pos - 10); i < count; i++) {
CRF_Data* pData = (*m_pReflowed)[i];
FX_FLOAT tempdy = FXSYS_fabs(pData->m_PosY - y1);
if(tempdy < dy) {
dy = tempdy;
dx = FXSYS_fabs(pData->m_PosX - x1);
pos = i;
} else if (tempdy == dy) {
FX_FLOAT tempdx = FXSYS_fabs(pData->m_PosX - x1);
if(tempdx < dx) {
dx = tempdx;
pos = i;
}
}
}
}
str.Format("%d", pos);
}
示例2: CheckControl
FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
bool bChecked,
bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CPDF_FormControl* pControl = GetControl(iControlIndex);
if (!pControl) {
return FALSE;
}
if (!bChecked && pControl->IsChecked() == bChecked) {
return FALSE;
}
CFX_WideString csWExport = pControl->GetExportValue();
CFX_ByteString csBExport = PDF_EncodeText(csWExport);
int iCount = CountControls();
bool bUnison = PDF_FormField_IsUnison(this);
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pCtrl = GetControl(i);
if (bUnison) {
CFX_WideString csEValue = pCtrl->GetExportValue();
if (csEValue == csWExport) {
if (pCtrl->GetOnStateName() == pControl->GetOnStateName()) {
pCtrl->CheckControl(bChecked);
} else if (bChecked) {
pCtrl->CheckControl(FALSE);
}
} else if (bChecked) {
pCtrl->CheckControl(FALSE);
}
} else {
if (i == iControlIndex) {
pCtrl->CheckControl(bChecked);
} else if (bChecked) {
pCtrl->CheckControl(FALSE);
}
}
}
CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pDict, "Opt");
if (!ToArray(pOpt)) {
if (bChecked) {
m_pDict->SetAtName("V", csBExport);
} else {
CFX_ByteString csV;
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
if (pV) {
csV = pV->GetString();
}
if (csV == csBExport) {
m_pDict->SetAtName("V", "Off");
}
}
} else if (bChecked) {
CFX_ByteString csIndex;
csIndex.Format("%d", iControlIndex);
m_pDict->SetAtName("V", csIndex);
}
if (bNotify && m_pForm->m_pFormNotify)
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
return TRUE;
}
示例3: AddCachedTTCFace
FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, FX_DWORD checksum,
uint8_t* pData, FX_DWORD size, int font_offset)
{
CFX_ByteString key;
key.Format("%d:%d", ttc_size, checksum);
CTTFontDesc* pFontDesc = new CTTFontDesc;
pFontDesc->m_Type = 2;
pFontDesc->m_pFontData = pData;
for (int i = 0; i < 16; i ++) {
pFontDesc->m_TTCFace.m_pFaces[i] = NULL;
}
pFontDesc->m_RefCount ++;
key.Format("%d:%d", ttc_size, checksum);
m_FaceMap.SetAt(key, pFontDesc);
int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset);
pFontDesc->m_TTCFace.m_pFaces[face_index] = GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index);
return pFontDesc->m_TTCFace.m_pFaces[face_index];
}
示例4: GetCheckedAPState
CFX_ByteString CPDF_FormControl::GetCheckedAPState() {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csOn = GetOnStateName();
if (GetType() == CPDF_FormField::RadioButton ||
GetType() == CPDF_FormField::CheckBox) {
if (ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) {
int iIndex = m_pField->GetControlIndex(this);
csOn.Format("%d", iIndex);
}
}
if (csOn.IsEmpty())
csOn = "Yes";
return csOn;
}
示例5: GetCheckedAPState
CFX_ByteString CPDF_FormControl::GetCheckedAPState()
{
ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csOn = GetOnStateName();
if (GetType() == CPDF_FormField::RadioButton || GetType() == CPDF_FormField::CheckBox) {
CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pField->m_pDict, "Opt");
if (pOpt != NULL && pOpt->GetType() == PDFOBJ_ARRAY) {
int iIndex = m_pField->GetControlIndex(this);
csOn.Format("%d", iIndex);
}
}
if (csOn.IsEmpty()) {
csOn = "Yes";
}
return csOn;
}
示例6: GetCachedTTCFace
FXFT_Face CFX_FontMgr::GetCachedTTCFace(int ttc_size, FX_DWORD checksum,
int font_offset, FX_LPBYTE& pFontData)
{
CFX_ByteString key;
key.Format("%d:%d", ttc_size, checksum);
CTTFontDesc* pFontDesc = NULL;
m_FaceMap.Lookup(key, (void*&)pFontDesc);
if (pFontDesc == NULL) {
return NULL;
}
pFontData = pFontDesc->m_pFontData;
pFontDesc->m_RefCount ++;
int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset);
if (pFontDesc->m_TTCFace.m_pFaces[face_index] == NULL) {
pFontDesc->m_TTCFace.m_pFaces[face_index] = GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index);
}
return pFontDesc->m_TTCFace.m_pFaces[face_index];
}
示例7: PDFDocInit
FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
CPDF_Document* pSrcPDFDoc) {
if (!pDestPDFDoc || !pSrcPDFDoc)
return FALSE;
CPDF_Dictionary* pNewRoot = pDestPDFDoc->GetRoot();
if (!pNewRoot)
return FALSE;
CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo();
if (!DInfoDict)
return FALSE;
CFX_ByteString producerstr;
producerstr.Format("PDFium");
DInfoDict->SetFor("Producer", new CPDF_String(producerstr, FALSE));
CFX_ByteString cbRootType = pNewRoot->GetStringFor("Type", "");
if (cbRootType.IsEmpty())
pNewRoot->SetFor("Type", new CPDF_Name("Catalog"));
CPDF_Object* pElement = pNewRoot->GetObjectFor("Pages");
CPDF_Dictionary* pNewPages =
pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
if (!pNewPages) {
pNewPages = new CPDF_Dictionary(pDestPDFDoc->GetByteStringPool());
pNewRoot->SetReferenceFor("Pages", pDestPDFDoc,
pDestPDFDoc->AddIndirectObject(pNewPages));
}
CFX_ByteString cbPageType = pNewPages->GetStringFor("Type", "");
if (cbPageType == "") {
pNewPages->SetFor("Type", new CPDF_Name("Pages"));
}
if (!pNewPages->GetArrayFor("Kids")) {
pNewPages->SetIntegerFor("Count", 0);
pNewPages->SetReferenceFor("Kids", pDestPDFDoc,
pDestPDFDoc->AddIndirectObject(new CPDF_Array));
}
return TRUE;
}
示例8: DrawText
FX_BOOL CFX_PSRenderer::DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device,
FX_FLOAT font_size, FX_DWORD color,
int alpha_flag, void* pIccTransform)
{
StartRendering();
int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
if (alpha < 255) {
return FALSE;
}
if ((pObject2Device->a == 0 && pObject2Device->b == 0) || (pObject2Device->c == 0 && pObject2Device->d == 0)) {
return TRUE;
}
SetColor(color, alpha_flag, pIccTransform);
CFX_ByteTextBuf buf;
buf << FX_BSTRC("q[") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ")
<< pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d;
buf << FX_BSTRC(" ") << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f << "]cm\n";
if (pCache == NULL) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
FX_FONTCACHE_DEFINE(pCache, pFont);
int last_fontnum = -1;
for (int i = 0; i < nChars; i ++) {
int ps_fontnum, ps_glyphindex;
FindPSFontGlyph(pFaceCache, pFont, pCharPos[i], ps_fontnum, ps_glyphindex);
if (last_fontnum != ps_fontnum) {
buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff ") << font_size
<< FX_BSTRC(" Fs Sf ");
last_fontnum = ps_fontnum;
}
buf << pCharPos[i].m_OriginX << FX_BSTRC(" ")
<< pCharPos[i].m_OriginY << FX_BSTRC(" m");
CFX_ByteString hex;
hex.Format("<%02X>", ps_glyphindex);
buf << hex << FX_BSTRC("Tj\n");
}
buf << FX_BSTRC("Q\n");
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
return TRUE;
}
示例9: GetFontByCodePage
CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
CFX_ByteString bsHash;
bsHash.Format("%d, %d", wCodePage, dwFontStyles);
bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr;
if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
if (!pFonts)
return nullptr;
if (pFonts->GetSize() != 0)
return pFonts->GetAt(0)->Retain();
}
if (!pFonts)
pFonts = new CFX_ArrayTemplate<CFGAS_GEFont*>;
m_Hash2Fonts.SetAt(dwHash, pFonts);
CFX_FontDescriptorInfos* sortedFonts = nullptr;
if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) {
sortedFonts = new CFX_FontDescriptorInfos;
MatchFonts(*sortedFonts, wCodePage, dwFontStyles,
CFX_WideString(pszFontFamily), 0);
m_Hash2CandidateList.SetAt(dwHash, sortedFonts);
}
if (sortedFonts->GetSize() == 0)
return nullptr;
CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont;
CFGAS_GEFont* pFont =
LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
if (pFont)
pFont->SetLogicalFontStyle(dwFontStyles);
pFonts->Add(pFont);
return pFont;
}
示例10:
TEST(fxcrt, ByteStringFormatPrecision) {
{
CFX_ByteString str;
str.Format("%.2f", 1.12345);
EXPECT_EQ("1.12", str);
}
{
CFX_ByteString str;
str.Format("%.*f", 3, 1.12345);
EXPECT_EQ("1.123", str);
}
{
CFX_ByteString str;
str.Format("%f", 1.12345);
EXPECT_EQ("1.123450", str);
}
{
CFX_ByteString str;
str.Format("%-1f", 1.12345);
EXPECT_EQ("1.123450", str);
}
{
CFX_ByteString str;
str.Format("%0f", 1.12345);
EXPECT_EQ("1.123450", str);
}
{
CFX_ByteString str;
str.Format("%.1048576f", 1.2);
EXPECT_EQ("Bad precision", str);
}
}
示例11: rect
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
FS_MATRIX* matrix,
FS_RECTF* clipRect) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return FALSE;
CFX_ByteTextBuf textBuf;
textBuf << "q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right,
clipRect->top);
rect.Normalize();
CFX_ByteString bsClipping;
bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
rect.Width(), rect.Height());
textBuf << bsClipping;
CFX_ByteString bsMatix;
bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c,
matrix->d, matrix->e, matrix->f);
textBuf << bsMatix;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetElement("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr;
if (!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = new CPDF_Dictionary;
CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = new CPDF_Dictionary;
CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
if (CPDF_Array* pArray = ToArray(pContentObj)) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
if (CPDF_Array* pArray = pDirectObj->AsArray()) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream);
pPageDic->SetAtReference("Contents", pDoc,
pDoc->AddIndirectObject(pContentArray));
}
}
}
// Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources");
if (pRes) {
CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern");
if (pPattenDict) {
for (const auto& it : *pPattenDict) {
CPDF_Object* pObj = it.second;
if (pObj->IsReference())
pObj = pObj->GetDirect();
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
else if (CPDF_Stream* pStream = pObj->AsStream())
pDict = pStream->GetDict();
else
continue;
CFX_Matrix m = pDict->GetMatrixBy("Matrix");
CFX_Matrix t = *(CFX_Matrix*)matrix;
m.Concat(t);
pDict->SetAtMatrix("Matrix", m);
}
}
}
return TRUE;
}
示例12: if
//.........这里部分代码省略.........
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;
if (pFirstObj) {
if (pFirstObj->IsReference())
pFirstObj = pFirstObj->GetDirect();
if (!pFirstObj->IsStream())
continue;
pAPStream = pFirstObj->AsStream();
}
}
}
}
if (!pAPStream)
continue;
CPDF_Dictionary* pAPDic = pAPStream->GetDict();
CFX_Matrix matrix = pAPDic->GetMatrixFor("Matrix");
CFX_FloatRect rcStream;
if (pAPDic->KeyExist("Rect"))
rcStream = pAPDic->GetRectFor("Rect");
else if (pAPDic->KeyExist("BBox"))
rcStream = pAPDic->GetRectFor("BBox");
if (rcStream.IsEmpty())
continue;
CPDF_Object* pObj = pAPStream;
if (pObj) {
CPDF_Dictionary* pObjDic = pObj->GetDict();
if (pObjDic) {
pObjDic->SetNameFor("Type", "XObject");
pObjDic->SetNameFor("Subtype", "Form");
}
}
CPDF_Dictionary* pXObject = pNewXORes->GetDictFor("XObject");
if (!pXObject) {
pXObject = new CPDF_Dictionary(pDocument->GetByteStringPool());
pNewXORes->SetFor("XObject", pXObject);
}
CFX_ByteString sFormName;
sFormName.Format("F%d", i);
pXObject->SetReferenceFor(sFormName, pDocument,
pDocument->AddIndirectObject(pObj));
CPDF_StreamAcc acc;
acc.LoadAllData(pNewXObject);
const uint8_t* pData = acc.GetData();
CFX_ByteString sStream(pData, acc.GetSize());
if (matrix.IsIdentity()) {
matrix.a = 1.0f;
matrix.b = 0.0f;
matrix.c = 0.0f;
matrix.d = 1.0f;
matrix.e = 0.0f;
matrix.f = 0.0f;
}
CFX_ByteString sTemp;
CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix);
sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f,
sFormName.c_str());
sStream += sTemp;
pNewXObject->SetData(sStream.raw_str(), sStream.GetLength());
}
pPageDict->RemoveFor("Annots");
ObjectArray.RemoveAll();
RectArray.RemoveAll();
return FLATTEN_SUCCESS;
}
示例13: EncodeFontAlias
CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName, int32_t nCharset)
{
CFX_ByteString sPostfix;
sPostfix.Format("_%02X", nCharset);
return EncodeFontAlias(sFontName) + sPostfix;
}
示例14: rect
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX* matrix, FS_RECTF* clipRect)
{
if(!page)
return FALSE;
CFX_ByteTextBuf textBuf;
textBuf<<"q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right, clipRect->top);
rect.Normalize();
CFX_ByteString bsClipping;
bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom, rect.Width(), rect.Height());
textBuf<<bsClipping;
CFX_ByteString bsMatix;
bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,matrix->c,matrix->d,matrix->e,matrix->f);
textBuf<<bsMatix;
CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
if(!pContentObj)
pContentObj = pPageDic->GetArray("Contents");
if(!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if(!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pEndStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pEndStream->SetData((FX_LPCBYTE)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = NULL;
if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pContentObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc,pEndStream);
}
else if(pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE)
{
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
if(pDirectObj != NULL)
{
if(pDirectObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pDirectObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc,pEndStream);
}
else if(pDirectObj->GetType() == PDFOBJ_STREAM)
{
pContentArray = FX_NEW CPDF_Array();
pContentArray->AddReference(pDoc,pStream->GetObjNum());
pContentArray->AddReference(pDoc,pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream);
pPageDic->SetAtReference("Contents", pDoc, pDoc->AddIndirectObject(pContentArray));
}
}
}
//Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources"));
if(pRes)
{
CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern"));
if(pPattenDict)
{
FX_POSITION pos = pPattenDict->GetStartPos();
while(pos)
{
CPDF_Dictionary* pDict = NULL;
CFX_ByteString key;
CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
if(pObj->GetType() == PDFOBJ_REFERENCE)
pObj = pObj->GetDirect();
if(pObj->GetType() == PDFOBJ_DICTIONARY)
{
pDict = (CPDF_Dictionary*)pObj;
}
else if(pObj->GetType() == PDFOBJ_STREAM)
{
pDict = ((CPDF_Stream*)pObj)->GetDict();
}
else
continue;
CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
//.........这里部分代码省略.........
示例15: ExportData
void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
const CFX_WideString& wsFilePath,
bool bXDP) {
if (hDoc != m_pContext->GetXFADoc())
return;
if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) {
return;
}
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
if (!pFormFillEnv)
return;
int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
CFX_ByteString bs = wsFilePath.UTF16LE_Encode();
if (wsFilePath.IsEmpty()) {
if (!pFormFillEnv->GetFormFillInfo() ||
!pFormFillEnv->GetFormFillInfo()->m_pJsPlatform) {
return;
}
CFX_WideString filepath = pFormFillEnv->JS_fieldBrowse();
bs = filepath.UTF16LE_Encode();
}
int len = bs.GetLength();
FPDF_FILEHANDLER* pFileHandler =
pFormFillEnv->OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
(FPDF_WIDESTRING)bs.GetBuffer(len), "wb");
bs.ReleaseBuffer(len);
if (!pFileHandler)
return;
CFX_RetainPtr<IFX_SeekableStream> fileWrite =
MakeSeekableStream(pFileHandler);
CFX_ByteString content;
if (fileType == FXFA_SAVEAS_XML) {
content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
content.GetLength());
m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Data,
fileWrite, nullptr);
} else if (fileType == FXFA_SAVEAS_XDP) {
if (!m_pContext->GetPDFDoc())
return;
CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
if (!pRoot)
return;
CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
if (!pAcroForm)
return;
CPDF_Array* pArray = ToArray(pAcroForm->GetObjectFor("XFA"));
if (!pArray)
return;
int size = pArray->GetCount();
for (int i = 1; i < size; i += 2) {
CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
if (!pPrePDFObj->IsString())
continue;
if (!pPDFObj->IsReference())
continue;
CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect());
if (!pStream)
continue;
if (pPrePDFObj->GetString() == "form") {
m_pContext->GetXFADocView()->GetDoc()->SavePackage(XFA_HASHCODE_Form,
fileWrite, nullptr);
continue;
}
if (pPrePDFObj->GetString() == "datasets") {
m_pContext->GetXFADocView()->GetDoc()->SavePackage(
XFA_HASHCODE_Datasets, fileWrite, nullptr);
continue;
}
if (i == size - 1) {
CFX_WideString wPath = CFX_WideString::FromUTF16LE(
reinterpret_cast<const unsigned short*>(bs.c_str()),
bs.GetLength() / sizeof(unsigned short));
CFX_ByteString bPath = wPath.UTF8Encode();
const char* szFormat =
"\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
content.Format(szFormat, bPath.c_str());
fileWrite->WriteBlock(content.c_str(), fileWrite->GetSize(),
content.GetLength());
}
std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc);
pAcc->LoadAllData(pStream);
fileWrite->WriteBlock(pAcc->GetData(), fileWrite->GetSize(),
pAcc->GetSize());
}
}
fileWrite->Flush();
}