00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _CCPRINTDATA_H_
00028 #define _CCPRINTDATA_H_
00029
00030 #include "FileINI.h"
00031 #include <vector>
00032
00036 class CCPrintData
00037 {
00038 public:
00042 CCPrintData() : m_bTestPage(false) {};
00043
00044
00048 struct LinkData
00049 {
00053 LinkData() : nRepeat(1), nPage(0) {rectLocation.left = rectLocation.right = rectLocation.top = rectLocation.bottom = 0; ptOffset.x = ptOffset.y = 0;};
00058 LinkData(const LinkData& other) : sText(other.sText), sURL(other.sURL), sTitle(other.sTitle), nRepeat(other.nRepeat), rectLocation(other.rectLocation), ptOffset(other.ptOffset), nPage(other.nPage) {};
00066 LinkData(const std::tstring& sU, const std::tstring& sT, int n, LPCTSTR lpTitle = NULL) : sURL(sU), sText(sT), nRepeat(n), nPage(0), sTitle(lpTitle == NULL ? _T("") : lpTitle) {CleanText();};
00073 LinkData(const std::tstring& sU, const RECTL& rect, LPCTSTR lpTitle = NULL) : sURL(sU), rectLocation(rect), nPage(0), sTitle(lpTitle == NULL ? _T("") : lpTitle) {};
00082 LinkData(const RECTL& rect, int nP, long lX, long lY, LPCTSTR lpTitle = NULL) : nRepeat(1), nPage(nP), rectLocation(rect), sTitle(lpTitle == NULL ? _T("") : lpTitle) {CleanText(); ptOffset.x = lX; ptOffset.y = lY;};
00083
00084
00086 std::tstring sText;
00088 std::tstring sURL;
00090 std::tstring sTitle;
00092 int nRepeat;
00094 RECTL rectLocation;
00096 int nPage;
00098 POINTL ptOffset;
00099
00101 bool ToFile(std::tstring& sData, int nNum) const;
00103 bool FromFile(const TCHARSTR2STR& data, int nNum);
00108 bool IsLocation() const {return sText.empty();};
00113 bool IsInner() const {return IsLocation() && (nPage != 0);};
00115 void CleanText();
00116 };
00117
00121 struct PageData : std::list<LinkData>
00122 {
00126 PageData() {szPage.cx = szPage.cy = 0;};
00131 PageData(const PageData& other) : szPage(other.szPage) {insert(begin(), other.begin(), other.end());};
00132
00133
00135 SIZEL szPage;
00136
00138 bool ToFile(std::tstring& sData, int nPage) const;
00140 bool FromFile(class FileINI& file, int nPage);
00145 bool HasTextLink() const {for (const_iterator i = begin(); i != end(); i++) if (!(*i).IsLocation()) return true; return false;};
00149 void Clear() {clear(); szPage.cx = szPage.cy = 0;};
00150 };
00151
00152 protected:
00153
00155 std::vector<PageData> m_pages;
00157 PageData m_dummy;
00159 bool m_bTestPage;
00160
00161 public:
00162
00167 bool IsTestPage() const {return m_bTestPage;};
00172 bool HasData() const {return !m_pages.empty();};
00178 const PageData& GetPageData(int nPage) const
00179 {
00180 if ((nPage < 1) || (nPage > (int)m_pages.size()))
00181 return m_dummy;
00182 return m_pages[nPage - 1];
00183 };
00184
00189 size_t GetPageCount() const {return m_pages.size();};
00194 void SetTestPage(bool bSet = true) {m_bTestPage = bSet;};
00196 void AddLink(const std::tstring& sURL, const std::tstring& sText, int nPage, int nRepeat = 1);
00198 void AddLink(const std::tstring& sURL, const RECTL& rect, int nPage, LPCTSTR lpTitle = NULL);
00200 void AddLink(const RECTL& rect, int nPage, int nDestPage, long lX, long lY, LPCTSTR lpTitle = NULL);
00206 void SetPageSize(int nPage, const SIZEL& sz)
00207 {
00208 if ((nPage < 1) || (nPage > (int)m_pages.size()))
00209 return;
00210 m_pages[nPage - 1].szPage = sz;
00211 };
00212
00213
00215 bool LoadProcessData(HANDLE hPrinter);
00217 bool SaveProcessData(HANDLE hPrinter);
00219 bool UpdateProcessData(HANDLE hPrinter);
00221 bool ReloadProcessData(HANDLE hPrinter);
00222
00223
00225 void CleanSaved(HANDLE hPrinter);
00229 void CleanThis() {m_pages.clear(); m_bTestPage = false;};
00230
00231 #ifdef _DEBUG
00233 void Dump();
00234 #endif
00235
00236 protected:
00237
00239 void CleanOldData(HANDLE hPrinter);
00241 void CleanData(HANDLE hPrinter, DWORD dwProcessID);
00242
00244 bool WriteToFile(LPCTSTR lpFilename);
00246 bool ReadFromFile(LPCTSTR lpFilename);
00247
00249 void EnsurePage(int nPage);
00250 };
00251
00252 #endif //#define _CCPRINTDATA_H_