Commit 724a6aa3 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

удаление старого PdfReader

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62490 954022d7-b5bf-4e40-9824-e11837661b57
parent 3d825a47
......@@ -276,24 +276,6 @@ ASCOfficeHtmlFile/HTMLReaderLib/docs/HTML[!!-~]Reader[!!-~]C++[!!-~]Class[!!-~]L
ASCOfficeHtmlFile/HTMLReaderLib/docs/HTML[!!-~]Reader[!!-~]C++[!!-~]Class[!!-~]Library[!!-~]-[!!-~]CodeProject_files/{DE88D139-2BDC-4852-AA40-7D613E9F19E7}.gif svn_mime_002dtype=application%2Foctet-stream
ASCOfficeOdfFile/linux svnc_tsvn_003alogminsize=5
ASCOfficeOdtFile/Resource/OdtTemplate.odt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/FreeType/freetype231.lib svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/FreeType/freetype2312_vs2005.lib svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/FreeType/freetype2312_vs2005_Debug.lib svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/FreeType/freetype231_vs2005.lib svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/d050000l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n019003l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n019004l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n019023l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n019024l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n021003l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n021004l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n021023l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n021024l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n022003l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n022004l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n022023l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/n022024l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFReader/Resources/s050000l.crpt svn_mime_002dtype=application%2Foctet-stream
ASCOfficePDFWriter/Linux svnc_tsvn_003alogminsize=5
ASCOfficePDFWriter/PdfWriterLib svnc_tsvn_003alogminsize=5
ASCOfficePDFWriter/PdfWriterLib/Linux svnc_tsvn_003alogminsize=5
// ASCOfficePDFReader.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll, uuid = "{2F5F8982-81C9-414D-BAB1-5385B6384FC1}",
name = "ASCOfficePDFReader",
helpstring = "ASCOfficePDFReader 1.0 Type Library",
resource_name = "IDR_ASCOFFICEPDFREADER")]
class CASCOfficePDFReaderModule
{
public:
// Override CAtlDllModuleT members
};
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define COMPONENT_NAME "OfficePDFReader"
#include "../Common/FileInfo.h"
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE
BEGIN
"\r\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// RCDATA
//
//IDR_Symbol RCDATA "Resources\\Adobe\\SY______.crpt"
//IDR_ZapfDingbats RCDATA "Resources\\Adobe\\d050000l.crpt"
//
//IDR_Helvetica RCDATA "Resources\\Adobe\\MyriadPro-Regular.crpt"
//IDR_HelveticaBold RCDATA "Resources\\Adobe\\MyriadPro-Bold.crpt"
//IDR_HelveticaOblique RCDATA "Resources\\Adobe\\MyriadPro-It.crpt"
//IDR_HelveticaBoldOblique RCDATA "Resources\\Adobe\\MyriadPro-BoldIt.crpt"
//
//IDR_TimesRoman RCDATA "Resources\\Adobe\\MinionPro-Regular.crpt"
//IDR_TimesBold RCDATA "Resources\\Adobe\\MinionPro-Bold.crpt"
//IDR_TimesItalic RCDATA "Resources\\Adobe\\MinionPro-It.crpt"
//IDR_TimesBoldItalic RCDATA "Resources\\Adobe\\MinionPro-BoldIt.crpt"
//
//IDR_Courier RCDATA "Resources\\Adobe\\CourierStd.crpt"
//IDR_CourierBold RCDATA "Resources\\Adobe\\CourierStd-Bold.crpt"
//IDR_CourierOblique RCDATA "Resources\\Adobe\\CourierStd-Oblique.crpt"
//IDR_CourierBoldOblique RCDATA "Resources\\Adobe\\CourierStd-BoldOblique.crpt"
//
//
//IDR_Symbol RCDATA "Resources\\MS\\s050000l.crpt"
//IDR_ZapfDingbats RCDATA "Resources\\MS\\d050000l.crpt"
//
//IDR_Helvetica RCDATA "Resources\\MS\\arial.crpt"
//IDR_HelveticaBold RCDATA "Resources\\MS\\arialbd.crpt"
////IDR_Helvetica RCDATA "Resources\\Raw\\Helvetica_Regular.crpt"
////IDR_HelveticaBold RCDATA "Resources\\Raw\\Helvetica_Bold.crpt"
//IDR_HelveticaOblique RCDATA "Resources\\MS\\ariali.crpt"
//IDR_HelveticaBoldOblique RCDATA "Resources\\MS\\arialbi.crpt"
//
//IDR_TimesRoman RCDATA "Resources\\MS\\times.crpt"
//IDR_TimesBold RCDATA "Resources\\MS\\timesbd.crpt"
//IDR_TimesItalic RCDATA "Resources\\MS\\timesi.crpt"
//IDR_TimesBoldItalic RCDATA "Resources\\MS\\timesbi.crpt"
//
//IDR_Courier RCDATA "Resources\\MS\\cour.crpt"
//IDR_CourierBold RCDATA "Resources\\MS\\courbd.crpt"
//IDR_CourierOblique RCDATA "Resources\\MS\\couri.crpt"
//IDR_CourierBoldOblique RCDATA "Resources\\MS\\courbi.crpt"
IDR_Symbol RCDATA "Resources\\s050000l.crpt"
IDR_ZapfDingbats RCDATA "Resources\\d050000l.crpt"
IDR_Helvetica RCDATA "Resources\\n019003l.crpt"
IDR_HelveticaBold RCDATA "Resources\\n019004l.crpt"
IDR_HelveticaOblique RCDATA "Resources\\n019023l.crpt"
IDR_HelveticaBoldOblique RCDATA "Resources\\n019024l.crpt"
IDR_TimesRoman RCDATA "Resources\\n021003l.crpt"
IDR_TimesBold RCDATA "Resources\\n021004l.crpt"
IDR_TimesItalic RCDATA "Resources\\n021023l.crpt"
IDR_TimesBoldItalic RCDATA "Resources\\n021024l.crpt"
IDR_Courier RCDATA "Resources\\n022003l.crpt"
IDR_CourierBold RCDATA "Resources\\n022004l.crpt"
IDR_CourierOblique RCDATA "Resources\\n022023l.crpt"
IDR_CourierBoldOblique RCDATA "Resources\\n022024l.crpt"
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_ASCOFFICEPDFREADER REGISTRY "ASCOfficePDFReader.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "ASCOfficePDFReader"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ASCOfficePDFReader'
'ASCOfficePDFReader.DLL'
{
val AppID = s '%APPID%'
}
}
}

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficePDFReader", "ASCOfficePDFReader_vs2005.vcproj", "{BCE14148-A4AB-4472-B690-E2B31926000F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
ReleaseASC|Win32 = ReleaseASC|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BCE14148-A4AB-4472-B690-E2B31926000F}.Debug|Win32.ActiveCfg = Debug|Win32
{BCE14148-A4AB-4472-B690-E2B31926000F}.Debug|Win32.Build.0 = Debug|Win32
{BCE14148-A4AB-4472-B690-E2B31926000F}.Release|Win32.ActiveCfg = Release|Win32
{BCE14148-A4AB-4472-B690-E2B31926000F}.Release|Win32.Build.0 = Release|Win32
{BCE14148-A4AB-4472-B690-E2B31926000F}.ReleaseASC|Win32.ActiveCfg = ReleaseASC|Win32
{BCE14148-A4AB-4472-B690-E2B31926000F}.ReleaseASC|Win32.Build.0 = ReleaseASC|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
This diff is collapsed.
This diff is collapsed.
#ifndef _ANNOT_H
#define _ANNOT_H
class XRef;
class Catalog;
class Graphics;
class GrFontDict;
//-------------------------------------------------------------------------------------------------------------------------------
// AnnotBorderStyle
//-------------------------------------------------------------------------------------------------------------------------------
enum AnnotBorderType
{
annotBorderSolid,
annotBorderDashed,
annotBorderBeveled,
annotBorderInset,
annotBorderUnderlined
};
class AnnotBorderStyle
{
public:
AnnotBorderStyle(AnnotBorderType eType, double dWidth, double *pDash, int nDashLength, double dR, double dG, double dB);
~AnnotBorderStyle();
AnnotBorderType GetType()
{
return m_eType;
}
double GetWidth()
{
return m_dWidth;
}
void GetDash(double **ppDash, int *pnDashLength)
{
*ppDash = m_pDash;
*pnDashLength = m_nDashLength;
}
void GetColor(double *pdR, double *pdG, double *pdB)
{
*pdR = m_dR;
*pdG = m_dG;
*pdB = m_dB;
}
private:
AnnotBorderType m_eType; //
double m_dWidth; //
double *m_pDash; // ,
int m_nDashLength; // m_pDash
double m_dR; //
double m_dG; //
double m_dB; //
};
//-------------------------------------------------------------------------------------------------------------------------------
// Annot
//-------------------------------------------------------------------------------------------------------------------------------
class Annot
{
public:
Annot(GlobalParams *pGlobalParams, XRef *pXref, Dict *pAcroForm, Dict *pDict, Ref *pRef);
~Annot();
BOOL CheckValidation()
{
return m_bValid;
}
void Draw(Graphics *pGraphics, BOOL pBrinting);
Object *GetAppearance(Object *pObject)
{
return m_oAppearance.Fetch( m_pXref, pObject );
}
AnnotBorderStyle *GetBorderStyle()
{
return m_pBorderStyle;
}
BOOL Match(Ref *pRef)
{
return m_oRef.nNum == pRef->nNum && m_oRef.nGen == pRef->nGen;
}
void GenerateFieldAppearance(Dict *pField, Dict *pAnnot, Dict *pAcroForm);
private:
void SetColor(Array *pArray, BOOL bFill, int nAdjust);
void DrawText(StringExt *seText, StringExt *seDA, GrFontDict *pFontDict, BOOL bMultiline, int nComb, int nQuadding, BOOL bTextField, BOOL bForceZapfDingbats);
void DrawListBox(StringExt **ppText, BOOL *pSelection, int nOptionsCount, int nTopIndex, StringExt *seDA, GrFontDict *pFontDict, BOOL bQuadding);
void GetNextLine(StringExt *seText, int nStart, GrFont *pFont, double dFontSize, double dMaxW, int *pEnd, double *pWidth, int *pNext);
void DrawCircle (double dX, double dY, double dRad, BOOL bFill);
void DrawCircleTopLeft (double dX, double dY, double dRad);
void DrawCircleBottomRight(double dX, double dY, double dRad);
Object *FieldLookup(Dict *pField, char *sKey, Object *pObject);
private:
XRef *m_pXref; // XRef PDF-
Ref m_oRef; // , Annotation
StringExt *m_seType; // Annotation
Object m_oAppearance; // Form XObject-
StringExt *m_seAppBuffer;
double m_dMinX; //
double m_dMinY; // , Annotation
double m_dMaxX; //
double m_dMaxY; //
unsigned int m_nFlags;
AnnotBorderStyle *m_pBorderStyle;
BOOL m_bValid;
GlobalParams *m_pGlobalParams;
};
//-------------------------------------------------------------------------------------------------------------------------------
// Annots
//-------------------------------------------------------------------------------------------------------------------------------
class Annots
{
public:
Annots(GlobalParams *pGlobalParams, XRef *pXref, Catalog *pCatalog, Object *pAnnotsObject);
~Annots();
int GetAnnotsCount()
{
return m_nAnnotsCount;
}
Annot *GetAnnot(int nIndex)
{
return m_ppAnnots[nIndex];
}
void GenerateAppearances(Dict *pAcroForm);
private:
void ScanFieldAppearances(Dict *pNode, Ref *pRef, Dict *pParent, Dict *pAcroForm);
Annot *FindAnnot(Ref *pRef);
private:
Annot **m_ppAnnots; // Annotations
int m_nAnnotsCount; //
GlobalParams *m_pGlobalParams;
};
#endif /* _ANNOT_H */
#include "stdafx.h"
#include <stdlib.h>
#include <stddef.h>
#include "MemoryUtils.h"
#include "Object.h"
#include "Array.h"
//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
Array::Array(XRef *pXRef)
{
m_pXRef = pXRef;
m_arrItems = NULL;
m_nItemSize = m_nCount = 0;
m_nRef = 1;
}
Array::~Array()
{
for ( int nIndex = 0; nIndex < m_nCount; ++nIndex)
m_arrItems[nIndex].Free();
MemUtilsFree(m_arrItems);
}
void Array::Add(Object *pItem)
{
if ( m_nCount == m_nItemSize )
{
if ( m_nCount == 0 )
{
m_nItemSize = 8;
}
else
{
m_nItemSize *= 2;
}
m_arrItems = (Object *)MemUtilsReallocArray( m_arrItems, m_nItemSize, sizeof(Object));
}
m_arrItems[m_nCount] = *pItem;
++m_nCount;
}
Object *Array::Get(int nIndex, Object *pObject)
{
if ( nIndex < 0 || nIndex >= m_nCount )
{
return pObject->InitNull();
}
return m_arrItems[nIndex].Fetch( m_pXRef, pObject);
}
Object *Array::GetCopy(int nIndex, Object *pObject)
{
if ( nIndex < 0 || nIndex >= m_nCount )
{
return pObject->InitNull();
}
return m_arrItems[nIndex].Copy(pObject);
}
#ifndef _ARRAY_H
#define _ARRAY_H
#include "Object.h"
class XRef;
//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
class Array
{
public:
Array(XRef *pXRef);
~Array();
int AddRef()
{
return ++m_nRef;
}
int Release()
{
return --m_nRef;
}
int GetCount()
{
return m_nCount;
}
void Add(Object *pItem);
Object *Get(int nIndex, Object *pObject);
Object *GetCopy(int nIndex, Object *pObject);
private:
XRef *m_pXRef; // Xref PDF
Object *m_arrItems; //
int m_nItemSize; //
int m_nCount; //
int m_nRef; //
};
#endif /* _ARRAY_H */
#ifndef _BUILT_INFONT_H
#define _BUILT_INFONT_H
struct BuiltinFont;
class BuiltinFontWidths;
//------------------------------------------------------------------------
struct BuiltinFontWidth
{
char *sName;
unsigned short unWidth;
BuiltinFontWidth *pNext;
};
struct BuiltinFont
{
char *sName;
char **ppDefaultBaseEncoding;
short nAscent;
short nDescent;
short arrBBox[4];
BuiltinFontWidth *pWidths;
int nSize;
};
//------------------------------------------------------------------------
static BOOL BuiltinFontGetWidth(BuiltinFont *pFont, char *sName, unsigned short *punWidth)
{
for ( int nIndex = 0; nIndex < pFont->nSize; nIndex++ )
{
BuiltinFontWidth oWitdh = pFont->pWidths[nIndex];
if ( !strcmp( oWitdh.sName, sName ) )
{
*punWidth = oWitdh.unWidth;
return TRUE;
}
}
return FALSE;
}
#endif /* _BUILT_INFONT_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef _CMAP_H
#define _CMAP_H
#include "CharTypes.h"
#include "GlobalParams.h"
#include "../Common/XmlUtils.h"
#include "../Common/TemporaryCS.h"
class StringExt;
struct CMapVectorEntry;
class CMapCache;
//-------------------------------------------------------------------------------------------------------------------------------
class CMap
{
public:
// CMap <seCollection> <seCMapName>.
// 1.
static CMap *Parse(CMapCache *pCache, StringExt *seCollection, StringExt *seCMapName, GlobalParams *pGlobalParams, wchar_t *wsFilePath = NULL);
~CMap();
//
void AddRef();
void Release();
// : registry-ordering.
StringExt *GetCollection()
{
return m_seCollection;
}
// true, CMap <seCollection> <seCMapName>.
BOOL Match(StringExt *seCollection, StringExt *seCMapName);
// CID , <sChar>,
// <nLen> .
CID GetCID(char *sChar, int nLen, int *pnUsed);
// Writing mode (0 = horizontal, 1 = vertical).
int GetWMode()
{
return m_nWMode;
}
void ToXml(CString sFilePath);
private:
CMap(GlobalParams *pGlobalParams, StringExt *seCollection, StringExt *seCMapName);
CMap(GlobalParams *pGlobalParams, StringExt *seCollection, StringExt *seCMapName, int nWMode);
void UseCMap(CMapCache *pCache, char *sUseName);
void CopyVector(CMapVectorEntry *pDest, CMapVectorEntry *pSrc);
void AddCodeSpace(CMapVectorEntry *pVector, unsigned int unStart, unsigned int unEnd, unsigned int unBytesCount);
void AddCIDs(unsigned int unStart, unsigned int unEnd, unsigned int unBytesCount, CID nFirstCID);
void FreeCMapVector(CMapVectorEntry *pVector);
void WriteVectorToXml(XmlUtils::CXmlWriter *pWriter, CMapVectorEntry *pVector);
private:
StringExt *m_seCollection; //
StringExt *m_seCMapName; //
int m_nWMode; // writing mode (0=horizontal, 1=vertical)
CMapVectorEntry *m_pVector; // vector for first byte (NULL for identity CMap)
int m_nRef; //
GlobalParams *m_pGlobalParams;
CRITICAL_SECTION m_oCS;
};
//-------------------------------------------------------------------------------------------------------------------------------
#define CMapCacheSize 4
class CMapCache
{
public:
CMapCache();
~CMapCache();
CMap *GetCMap(StringExt *seCollection, StringExt *seCMapName, GlobalParams *pGlobalParams, wchar_t *wsFilePath = NULL);
private:
CMap *m_ppCache[CMapCacheSize];
};
#endif /* _CMAP_H */
#include "stdafx.h"
#include <stddef.h>
#include "MemoryUtils.h"
#include "Object.h"
#include "XRef.h"
#include "Array.h"
#include "Dict.h"
#include "Page.h"
#include "Link.h"
#include "Catalog.h"
//------------------------------------------------------------------------
// Catalog
//------------------------------------------------------------------------
Catalog::Catalog(GlobalParams *pGlobalParams, XRef *pXref)
{
m_pGlobalParams = pGlobalParams;
m_bValid = TRUE;
m_pXref = pXref;
m_ppPages = NULL;
m_pPageRefs = NULL;
m_nPagesCount = m_nPagesSize = 0;
m_seBaseURI = NULL;
Object oCatalogDict;
m_pXref->GetCatalog(&oCatalogDict);
if ( !oCatalogDict.IsDict() )
{
// TO DO: Error "Catalog object is wrong type "
oCatalogDict.Free();
m_oDests.InitNull();
m_oNameTree.InitNull();
m_bValid = FALSE;
return;
}
// Pages
Object oPagesDict;
oCatalogDict.DictLookup("Pages", &oPagesDict);
if ( !oPagesDict.IsDict() )
{
// TO DO: Error "Top-level pages object is wrong type "
oPagesDict.Free();
oCatalogDict.Free();
m_oDests.InitNull();
m_oNameTree.InitNull();
m_bValid = FALSE;
return;
}
//
Object oTemp;
oPagesDict.DictLookup("Count", &oTemp);
if ( !oTemp.IsNum() ) // - ( IsNum, IsInt)
{
// TO DO: Error "Page count in top-level pages object is wrong type"
oTemp.Free();
oPagesDict.Free();
oCatalogDict.Free();
m_oDests.InitNull();
m_oNameTree.InitNull();
m_bValid = FALSE;
return;
}
int nPagesCount = 0;
m_nPagesSize = nPagesCount = (int)oTemp.GetNum();
oTemp.Free();
//
m_ppPages = (Page**)MemUtilsMallocArray( m_nPagesSize, sizeof(Page*));
m_pPageRefs = (Ref*)MemUtilsMallocArray( m_nPagesSize, sizeof(Ref));
for ( int nIndex = 0; nIndex < m_nPagesSize; ++nIndex )
{
m_ppPages[nIndex] = NULL;
m_pPageRefs[nIndex].nNum = -1;
m_pPageRefs[nIndex].nGen = -1;
}
char* sAlreadyRead = (char *)MemUtilsMalloc( m_pXref->GetObjectsCount() );
memset( sAlreadyRead, 0, m_pXref->GetObjectsCount() );
Object oPagesDictRef;
if ( oCatalogDict.DictLookupAndCopy("Pages", &oPagesDictRef)->IsRef() && oPagesDictRef.GetRefNum() >= 0 && oPagesDictRef.GetRefNum() < m_pXref->GetObjectsCount() )
{
sAlreadyRead[ oPagesDictRef.GetRefNum() ] = 1;
}
oPagesDictRef.Free();
m_nPagesCount = ReadPageTree( oPagesDict.GetDict(), NULL, 0, sAlreadyRead);
MemUtilsFree( sAlreadyRead );
if ( m_nPagesCount != nPagesCount )
{
// TO DO: Error "Page count in top-level pages object is incorrect"
}
oPagesDict.Free();
// Named destination
oCatalogDict.DictLookup("Dests", &m_oDests);
if ( oCatalogDict.DictLookup("Names", &oTemp)->IsDict() )
oTemp.DictLookup("Dests", &m_oNameTree);
else
m_oNameTree.InitNull();
oTemp.Free();
// URI
if ( oCatalogDict.DictLookup("URI", &oTemp)->IsDict() )
{
Object oBase;
if ( oTemp.DictLookup("Base", &oBase)->IsString() )
{
m_seBaseURI = oBase.GetString()->Copy();
}
oBase.Free();
}
oTemp.Free();
// Metadata
oCatalogDict.DictLookup("Metadata", &m_oMetadata);
// StructTreeRoot
oCatalogDict.DictLookup("StructTreeRoot", &m_oStructTreeRoot);
// Outlines
oCatalogDict.DictLookup("Outlines", &m_oOutline);
// AcroForm
oCatalogDict.DictLookup("AcroForm", &m_oAcroForm);
oCatalogDict.Free();
return;
}
Catalog::~Catalog()
{
if ( m_ppPages )
{
for ( int nIndex = 0; nIndex < m_nPagesSize; ++nIndex)
{
if ( m_ppPages[nIndex] )
{
delete m_ppPages[nIndex];
}
}
MemUtilsFree(m_ppPages);
MemUtilsFree(m_pPageRefs);
}
m_oDests.Free();
m_oNameTree.Free();
if ( m_seBaseURI )
{
delete m_seBaseURI;
}
m_oMetadata.Free();
m_oStructTreeRoot.Free();
m_oOutline.Free();
m_oAcroForm.Free();
}
StringExt *Catalog::ReadMetadata()
{
if ( !m_oMetadata.IsStream() )
{
return NULL;
}
Dict *pDict = m_oMetadata.StreamGetDict();
Object oTemp;
if ( !pDict->Search("Subtype", &oTemp)->IsName("XML") )
{
// TO DO: Error "Unknown Metadata type"
}
oTemp.Free();
StringExt *seResult = new StringExt();
m_oMetadata.StreamReset();
int nChar = 0;
// TO DO: xml ,
while ( ( nChar = m_oMetadata.StreamGetChar() ) != EOF )
{
seResult->Append( nChar );
}
m_oMetadata.StreamClose();
return seResult;
}
int Catalog::ReadPageTree( Dict *pPagesDict, PageAttrs *pAttrs, int nStart, char *sAlreadyRead)
{
PageAttrs *pPageAttrs = new PageAttrs( pAttrs, pPagesDict);
Object oKids;
pPagesDict->Search("Kids", &oKids);
if ( !oKids.IsArray() )
{
// TO DO: Error "Kids object is wrong type"
oKids.Free();
delete pPageAttrs;
m_bValid = FALSE;
return -1;
}
for ( int nIndex = 0; nIndex < oKids.ArrayGetLength(); ++nIndex )
{
Object oKidRef;
oKids.ArrayGetCopy( nIndex, &oKidRef);
if ( oKidRef.IsRef() && oKidRef.GetRefNum() >= 0 && oKidRef.GetRefNum() < m_pXref->GetObjectsCount() )
{
if ( sAlreadyRead[oKidRef.GetRefNum()] )
{
// TO DO: Error "Loop in Pages tree"
oKidRef.Free();
continue;
}
sAlreadyRead[ oKidRef.GetRefNum() ] = 1;
}
Object oKid;
oKids.ArrayGet( nIndex, &oKid);
if ( oKid.IsDict("Page") )
{
PageAttrs *pCurPageAttrs = new PageAttrs( pPageAttrs, oKid.GetDict() );
Page *pCurPage = new Page( m_pGlobalParams, m_pXref, nStart + 1, oKid.GetDict(), pCurPageAttrs );
if ( !pCurPage->IsValid() )
{
++nStart;
MemUtilsFree( pCurPage );
oKid.Free();
oKids.Free();
MemUtilsFree( pPageAttrs );
m_bValid = FALSE;
return -1;
}
if ( nStart >= m_nPagesSize )
{
m_nPagesSize += 32;
//
m_ppPages = (Page**)MemUtilsReallocArray( m_ppPages, m_nPagesSize, sizeof(Page *));
m_pPageRefs = (Ref*)MemUtilsReallocArray( m_pPageRefs, m_nPagesSize, sizeof(Ref));
for ( int nJ = m_nPagesSize - 32; nJ < m_nPagesSize; ++nJ )
{
m_ppPages[nJ] = NULL;
m_pPageRefs[nJ].nNum = -1;
m_pPageRefs[nJ].nGen = -1;
}
}
m_ppPages[nStart] = pCurPage;
if ( oKidRef.IsRef() )
{
m_pPageRefs[nStart].nNum = oKidRef.GetRefNum();
m_pPageRefs[nStart].nGen = oKidRef.GetRefGen();
}
++nStart;
}
else if ( oKid.IsDict() ) // - /Type
{
if ( ( nStart = ReadPageTree( oKid.GetDict(), pPageAttrs, nStart, sAlreadyRead) ) < 0 )
{
oKid.Free();
oKids.Free();
MemUtilsFree( pPageAttrs );
m_bValid = FALSE;
return -1;
}
}
else
{
// TO DO: Error "Kid object is wrong type"
}
oKid.Free();
oKidRef.Free();
}
delete pPageAttrs;
oKids.Free();
return nStart;
}
int Catalog::FindPage(int nNum, int nGen)
{
for ( int nIndex = 0; nIndex < m_nPagesCount; ++nIndex)
{
if ( m_pPageRefs[nIndex].nNum == nNum && m_pPageRefs[nIndex].nGen == nGen )
return nIndex + 1;
}
return 0;
}
LinkDestination *Catalog::FindDest(StringExt *seName)
{
BOOL bFound = FALSE;
Object oDestDict;
if ( m_oDests.IsDict() )
{
if ( !m_oDests.DictLookup( seName->GetBuffer(), &oDestDict)->IsNull() )
bFound = TRUE;
else
oDestDict.Free();
}
if ( !bFound && m_oNameTree.IsDict() )
{
if ( !FindDestInTree( &m_oNameTree, seName, &oDestDict)->IsNull() )
bFound = TRUE;
else
oDestDict.Free();
}
if ( !bFound )
return NULL;
// construct LinkDest
LinkDestination *pLinkDest = NULL;
if ( oDestDict.IsArray() )
{
pLinkDest = new LinkDestination( oDestDict.GetArray() );
}
else if ( oDestDict.IsDict() )
{
Object oTemp;
if ( oDestDict.DictLookup( "D", &oTemp)->IsArray() )
pLinkDest = new LinkDestination( oTemp.GetArray() );
else
{
// TO DO: Error "Bad named destination value"
}
oTemp.Free();
}
else
{
// TO DO: Error "Bad named destination value"
}
oDestDict.Free();
if ( pLinkDest && !pLinkDest->CheckValidate() )
{
delete pLinkDest;
pLinkDest = NULL;
}
return pLinkDest;
}
Object *Catalog::FindDestInTree(Object *pTree, StringExt *seName, Object *pObject)
{
BOOL bDone = FALSE, bFound = FALSE;
Object oNames;
if ( pTree->DictLookup("Names", &oNames)->IsArray() )
{
bDone = bFound = FALSE;
for ( int nIndex = 0; !bDone && nIndex < oNames.ArrayGetLength(); nIndex += 2 )
{
Object oCurName;
if ( oNames.ArrayGet( nIndex, &oCurName)->IsString() )
{
int nCompareRes = seName->Compare( oCurName.GetString() );
if ( nCompareRes == 0 )
{
oNames.ArrayGet( nIndex + 1, pObject);
bFound = TRUE;
bDone = TRUE;
}
else if ( nCompareRes < 0 )
{
bDone = TRUE;
}
}
oCurName.Free();
}
oNames.Free();
if ( !bFound )
pObject->InitNull();
return pObject;
}
oNames.Free();
bDone = FALSE;
Object oKids;
if ( pTree->DictLookup("Kids", &oKids)->IsArray() )
{
for ( int nIndex = 0; !bDone && nIndex < oKids.ArrayGetLength(); ++nIndex)
{
Object oKid;
if ( oKids.ArrayGet( nIndex, &oKid)->IsDict() )
{
Object oLimits;
if ( oKid.DictLookup("Limits", &oLimits)->IsArray() )
{
Object oLow;
if ( oLimits.ArrayGet(0, &oLow)->IsString() && seName->Compare( oLow.GetString() ) >= 0 )
{
Object oHigh;
if ( oLimits.ArrayGet( 1, &oHigh)->IsString() && seName->Compare( oHigh.GetString() ) <= 0 )
{
FindDestInTree( &oKid, seName, pObject);
bDone = TRUE;
}
oHigh.Free();
}
oLow.Free();
}
oLimits.Free();
}
oKid.Free();
}
}
oKids.Free();
if ( !bDone )
pObject->InitNull();
return pObject;
}
#ifndef _CATALOG_H
#define _CATALOG_H
#include "GlobalParams.h"
class XRef;
class Object;
class Page;
class PageAttrs;
struct Ref;
class LinkDestination;
//------------------------------------------------------------------------
// Catalog
//------------------------------------------------------------------------
class Catalog
{
public:
Catalog(GlobalParams *pGlobalParams, XRef *pXref);
~Catalog();
BOOL CheckValidation()
{
return m_bValid;
}
int GetPagesCount()
{
return m_nPagesCount;
}
Page *GetPage(int nIndex)
{
return m_ppPages[nIndex - 1];
}
Ref *GetPageRef(int nIndex)
{
return &m_pPageRefs[nIndex - 1];
}
StringExt *GetBaseURI()
{
return m_seBaseURI;
}
StringExt *ReadMetadata();
Object *GetStructTreeRoot()
{
return &m_oStructTreeRoot;
}
// , .
int FindPage(int nNum, int nGen);
// Named destination.
LinkDestination *FindDest(StringExt *seName);
Object *GetDests()
{
return &m_oDests;
}
Object *GetNameTree()
{
return &m_oNameTree;
}
Object *GetOutline()
{
return &m_oOutline;
}
Object *GetAcroForm()
{
return &m_oAcroForm;
}
private:
int ReadPageTree(Dict *pPages, PageAttrs *pAttrs, int nStart, char *sAlreadyRead);
Object *FindDestInTree(Object *pTree, StringExt *seName, Object *pObject);
private:
XRef *m_pXref; // xref PDF
Page **m_ppPages; //
Ref *m_pPageRefs; //
int m_nPagesCount; //
int m_nPagesSize; // ( )
Object m_oDests; // Destination dictionary
Object m_oNameTree; // Name tree
StringExt *m_seBaseURI; // URI
Object m_oMetadata; // Metadata
Object m_oStructTreeRoot; //
Object m_oOutline; // Outline
Object m_oAcroForm; // AcroForm
BOOL m_bValid; // True, atalog -
GlobalParams *m_pGlobalParams;
};
#endif /* _CATALOG_H */
This diff is collapsed.
This diff is collapsed.
#ifndef _CHARTYPES_H
#define _CHARTYPES_H
// Unicode-.
typedef unsigned int Unicode;
// CID.
typedef unsigned int CID;
// , :
// - 8-
// - 16- CID
// - Unicode
typedef unsigned int CharCode;
#endif /* _CHARTYPES_H */
#ifndef _CONSTANTS_H
#define _CONSTANTS_H
//-------------------------------------------------------------------------------------------------------------------------------
// PDF
#define SupportedPDFVersionStr "1.7"
#define SupportedPDFVersionNum 1.7
//-------------------------------------------------------------------------------------------------------------------------------
// Paper size
//-------------------------------------------------------------------------------------------------------------------------------
// ( (72dpi))
#ifndef A4_PAPER
#define DefaultPaperWidth 595 // ISO A4 (210x297 mm)
#define DefaultPaperHeight 842
#else
#define DefaultPaperWidth 612 // American letter (8.5x11")
#define DefaultPaperHeight 792
#endif
//-------------------------------------------------------------------------------------------------------------------------------
// Config file path
//-------------------------------------------------------------------------------------------------------------------------------
#if defined(VMS) || (defined(WIN32) && !defined(__CYGWIN32__))
#define UserConfigFile "pdfrc"
#define SysConfigFile "pdfrc"
#else
#define UserConfigFile ".pdfrc"
#define SysConfigFile ".pdfrc"
#endif
#endif /* _CONSTANTS_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment