//--------------------------------------------------------------------------- #include #include #include #include #include #pragma hdrstop #include "TPDocObject.h" #include "TPTextIO.h" // TPDocument¸¦ TPDocSheafÀÇ ¸â¹öº¯¼ö·Î ¸¸µé¾îÁÖ±â À§ÇØ ¿©±â¼­ TPDocument Include // (2007. 11. 08 Annualring) #include "TPDocument.h" #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) #define PenThick 10 //--------------------------------------------------------------------------- #pragma package(smart_init) /* // ÆÄÀÏÀÌ ±úÁ®¼­ ¿äûÀÌ µé¾î¿ÔÀ» ¶§¿¡´Â ¿¡·¯³­ ºÎºÐÀ» ´ÙÀ½ Äڵ带 Ȱ¿ëÇÏ¿© // ã¾Æº¸µµ·Ï ÇÏÀÚ. (ÆÄÀÏ Æ÷ÀÎÅÍ À§Ä¡¸¦ ¸®ÅÏÇÏ´Â ÇÔ¼ö SetFilePointer) ///////Àӽà if (Type == 32) { int filePosition; filePosition = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); int a = 100; } */ //--------------------------------------------------------------------------- bool bShiftOnArrow = false; int TextVersion; int SaveVersion; //--------------------------------------------------------------------------- // // // Postfix // //--------------------------------------------------------------------------- class Postfix { private: char *infix, buf; int ifp, pfp; int __fastcall factor(); int __fastcall term(); public: char *postfix; __fastcall Postfix(char *); __fastcall ~Postfix(); int __fastcall convert(); }; //--------------------------------------------------------------------------- __fastcall Postfix::Postfix(char *ifd) { infix = ifd; ifp = pfp = 0; // ¼ö½Ä °è»ê¿¡¼­ 'I' ¾øÀ̵µ ¼ýÀÚ¸¦ Á÷Á¢ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ (2007. 08. 09 Annualring) //postfix = (char *)calloc(strlen(infix)+1, 1); // I ä¿ì±â¿¡ ÇÊ¿äÇÑ ¿©À¯°ø°£À» 99 ¸¸Å­ Ãß°¡ÇÔ. postfix = (char *)calloc(strlen(infix)+100, 1); } //--------------------------------------------------------------------------- __fastcall Postfix::~Postfix() { if (postfix) free(postfix); } //--------------------------------------------------------------------------- int __fastcall Postfix::factor() { // if (buf=='N' || buf=='C') { // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) if (buf=='N' || buf=='F' || buf=='n' || buf=='f') { postfix[pfp++] = buf; while (buf=infix[ifp], isdigit(buf)) { ifp++; postfix[pfp++] = buf; } buf = infix[ifp++]; return 0; } else if(buf=='S') { postfix[pfp++] = buf; while (buf=infix[ifp], isdigit(buf)) { ifp++; postfix[pfp++] = buf; } buf = infix[ifp++]; factor(); return 0; } else if (buf=='I') { int m = 0, p = 0; postfix[pfp++] = buf; while (1) { buf = infix[ifp]; if (!m && buf=='-') { ifp++; postfix[pfp++] = buf; } else if (!p && buf=='.') { ifp++; postfix[pfp++] = buf; p++; } else if (isdigit(buf)) { ifp++; postfix[pfp++] = buf; } else break; m++; } buf = infix[ifp++]; return 0; } else if (buf=='(') { if (convert()) return -1; if (buf!=')') return -1; buf = infix[ifp++]; return 0; } // ¼ö½Ä °è»ê¿¡¼­ 'I' ¾øÀ̵µ ¼ýÀÚ¸¦ Á÷Á¢ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ (2007. 08. 09 Annualring) else if (isdigit(buf) || buf == '-' || buf == '.') { int m = 0, p = 0; postfix[pfp++] = 'I'; // postfix[pfp++] = buf; ifp--; while (1) { buf = infix[ifp]; if (!m && buf=='-') { ifp++; postfix[pfp++] = buf; } else if (!p && buf=='.') { ifp++; postfix[pfp++] = buf; p++; } else if (isdigit(buf)) { ifp++; postfix[pfp++] = buf; } else break; m++; } buf = infix[ifp++]; return 0; } else return -1; } //--------------------------------------------------------------------------- int __fastcall Postfix::term() { char optor; if (factor()) return -1; while (buf=='*' || buf=='/') { optor = buf; buf = infix[ifp++]; if (factor()) return -1; postfix[pfp++] = optor; } return 0; } //--------------------------------------------------------------------------- int __fastcall Postfix::convert() { char optor; buf = infix[ifp++]; if (term()) return -1; while (buf=='+' || buf=='-') { optor = buf; buf = infix[ifp++]; if (term()) return -1; postfix[pfp++] = optor; } return 0; } //--------------------------------------------------------------------------- // // External Functions // //--------------------------------------------------------------------------- TCursor __fastcall GetCursor(TPDocControlMode dcm) { switch (dcm) { case dcmLeftTop: case dcmRightBottom: return crSizeNWSE; case dcmRightTop: case dcmLeftBottom: return crSizeNESW; case dcmCenterTop: case dcmCenterBottom: case dcmVertical: return crSizeNS; case dcmLeftCenter: case dcmRightCenter: case dcmHorizontal: return crSizeWE; case dcmFirst: case dcmMedium: case dcmLast: return crHandPoint; case dcmMove: return crSizeAll; } return crArrow; } //--------------------------------------------------------------------------- bool __fastcall TextLoadFromFile(HANDLE hFile, AnsiString &Text) { DWORD dwRead; int n; char *str = NULL; if (!ReadFile(hFile, &n, sizeof(int), &dwRead, NULL)) return false; if (n > 0) { if ((str = new char[n + 1]) == NULL) goto fail; str[n] = 0; if (!ReadFile(hFile, str, n, &dwRead, NULL)) goto fail; Text = str; delete [] str; } return true; fail: if (str) delete [] str; return false; } //--------------------------------------------------------------------------- bool __fastcall TextLoadFromFile(HANDLE hFile, WideString &Text) { DWORD dwRead; int n; wchar_t *str = NULL; char *ansi_str = NULL; if(TextVersion<16){ if (!ReadFile(hFile, &n, sizeof(int), &dwRead, NULL)) return false; if (n > 0) { if ((ansi_str = new char[n + 1]) == NULL) goto fail; ansi_str[n] = 0; if (!ReadFile(hFile, ansi_str, n, &dwRead, NULL)) goto fail; Text = WideString(ansi_str); delete []ansi_str; // delete str; } return true; } else{ if (!ReadFile(hFile, &n, sizeof(int), &dwRead, NULL)) return false; if (n > 0) { if ((str = new wchar_t[n+1]) == NULL) goto fail; str[n] = '\0'; if (!ReadFile(hFile, str, n*sizeof(wchar_t), &dwRead, NULL)) goto fail; //Text = WideString::Copy(str); Text = WideString(str); delete []str; } return true; } fail: if (ansi_str) delete []ansi_str; if (str) delete [] str; return false; } //--------------------------------------------------------------------------- bool __fastcall TextSaveToFile(HANDLE hFile, AnsiString Text) { DWORD dwWrite; int n; //n = Text.Length(); //AnsiString Length()ÇÔ¼ö°¡ Á¤»óÀûÀ¸·Î °è»êµÇÁö ¾Ê´Â °æ¿ì°¡ ÀÖ´Ù. Tex3D¿¡¼­ ¹ß°ßÇß´Ù. //¿¡·¯°¡ ¹ß»ý ÇÏ´Â ÆÄÀÏÀ» °Ë»çÇØ º» °æ°ú n°ªÀÌ ³Ê¹« Å©°Å³ª ÀÛÀº °ªÀº µé¾î°¡ ÀÖ´Â °æ¿ì°¡ //À־ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ if (Text.IsEmpty()) n = 0; else n = StrLen(Text.c_str()); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 if (!WriteFile(hFile, &n, sizeof(int), &dwWrite, NULL)) return false; if (n > 0) { if (!WriteFile(hFile, Text.c_str(), n, &dwWrite, NULL)) return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TextSaveToFile(HANDLE hFile, WideString Text) { DWORD dwWrite; int n; AnsiString AnsiText(Text.c_bstr()); if(SaveVersion<16){ //n = AnsiText.Length(); //AnsiString Length()ÇÔ¼ö°¡ Á¤»óÀûÀ¸·Î °è»êµÇÁö ¾Ê´Â °æ¿ì°¡ ÀÖ´Ù. Tex3D¿¡¼­ ¹ß°ßÇß´Ù. //¿¡·¯°¡ ¹ß»ý ÇÏ´Â ÆÄÀÏÀ» °Ë»çÇØ º» °æ°ú n°ªÀÌ ³Ê¹« Å©°Å³ª ÀÛÀº °ªÀº µé¾î°¡ ÀÖ´Â °æ¿ì°¡ //À־ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ if (AnsiText.IsEmpty()) n = 0; else n = StrLen(AnsiText.c_str()); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 if (!WriteFile(hFile, &n, sizeof(int), &dwWrite, NULL)) return false; if (n > 0) { if (!WriteFile(hFile, AnsiText.c_str(), n, &dwWrite, NULL)) return false; } return true; } else{ //n = Text.Length(); if (Text.IsEmpty()) n = 0; else n = wcslen(Text.c_bstr()); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 if (!WriteFile(hFile, &n, sizeof(int), &dwWrite, NULL)) return false; if (n > 0) { if (!WriteFile(hFile, Text.c_bstr(), n*sizeof(wchar_t), &dwWrite, NULL)) return false; } return true; } } //--------------------------------------------------------------------------- int __fastcall TextGetAllocateSize(AnsiString Text) { //return (sizeof(int) + Text.Length()); if (Text.IsEmpty()) return sizeof(int); else return (sizeof(int) + StrLen(Text.c_str())*sizeof(char)); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 } //--------------------------------------------------------------------------- int __fastcall TextGetAllocateSize(WideString Text) { //return (sizeof(int) + (sizeof(wchar_t)*Text.Length())); if (Text.IsEmpty()) return sizeof(int); else return (sizeof(int) + wcslen(Text.c_bstr())*sizeof(wchar_t)); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 } //--------------------------------------------------------------------------- BYTE* __fastcall TextCopyToMemory(BYTE *lp, AnsiString Text) { int n = 0; if (Text.IsEmpty()) n = 0; else n = StrLen(Text.c_str());//Text.Length(); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 memcpy(lp, &n, sizeof(int)); lp += sizeof(int); if (n > 0) { memcpy(lp, Text.c_str(), sizeof(char)*n); lp += (sizeof(char)*n); } return lp; } //--------------------------------------------------------------------------- BYTE* __fastcall TextCopyToMemory(BYTE *lp, WideString Text) { int n = 0; if (Text.IsEmpty()) n = 0; else n = wcslen(Text.c_bstr());//Text.Length(); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 memcpy(lp, &n, sizeof(int)); lp += sizeof(int); if (n > 0) { memcpy(lp, Text.c_bstr(), sizeof(wchar_t)*n); lp += (sizeof(wchar_t)*n); } return lp; } //--------------------------------------------------------------------------- BYTE* __fastcall TextCopyFromMemory(BYTE *lp, AnsiString &Text) { int n; char s; memcpy(&n, lp, sizeof(int)); lp += sizeof(int); if (n > 0) { char *TempStr = new char[n+1]; memcpy(TempStr, lp, n); TempStr[n]=0; Text = WideString(TempStr); delete []TempStr; lp += n; } return lp; } //--------------------------------------------------------------------------- BYTE* __fastcall TextCopyFromMemory(BYTE *lp, WideString &Text) { int n; //wchar_t s; memcpy(&n, lp, sizeof(int)); lp += sizeof(int); if (n > 0) { wchar_t *TempStr = new wchar_t[n+1]; // memcpy(Text.c_str(), lp, n); memcpy(TempStr, lp, sizeof(wchar_t)*n); TempStr[n]=0; Text = WideString(TempStr); delete []TempStr; lp += (sizeof(wchar_t)*n); } return lp; } //--------------------------------------------------------------------------- bool __fastcall ImageLoadFromFile(HANDLE hFile, TTexpiaBitmap *&Image) { DWORD dwRead; int w, h; WORD bpp; RGBQUAD rgb[256]; if (!ReadFile(hFile, &bpp, sizeof(WORD), &dwRead, NULL)) return NULL; if (bpp) { if (!ReadFile(hFile, &w, sizeof(int), &dwRead, NULL)) return NULL; if (!ReadFile(hFile, &h, sizeof(int), &dwRead, NULL)) return NULL; if (Image) delete Image; Image = NULL; if ((Image = new TTexpiaBitmap) == NULL) return NULL; if (bpp == 8) { if (!ReadFile(hFile, rgb, 256 * sizeof(RGBQUAD), &dwRead, NULL)) goto fail; if (!Image->Create(w, h, bpp, rgb)) goto fail; } else { if (!Image->Create(w, h, bpp)) goto fail; } if (!Image->LoadFromTexpiaFile(hFile, cmZLib)) goto fail; } return true; fail: if (Image) { delete Image; Image = NULL; } return false; } //--------------------------------------------------------------------------- bool __fastcall ImageSaveToFile(HANDLE hFile, TTexpiaBitmap *Image, bool bCopyFromClipboard) { DWORD dwWrite; int w, h; WORD bpp; RGBQUAD rgb[256]; if (Image && (Image->Width != 0 && Image->Height !=0)) { bpp = Image->BitsPerPixel; if (!WriteFile(hFile, &bpp, sizeof(WORD), &dwWrite, NULL)) return false; w = Image->Width; if (!WriteFile(hFile, &w, sizeof(int), &dwWrite, NULL)) return false; h = Image->Height; if (!WriteFile(hFile, &h, sizeof(int), &dwWrite, NULL)) return false; if (bpp == 8) { Image->GetColors(0, 256, rgb); if (!WriteFile(hFile, rgb, 256 * sizeof(RGBQUAD), &dwWrite, NULL)) return false; } // if(bCopyFromClipboard) L_FlipBitmap(Image->Handle); //Ŭ¸³ º¸µå ºÙ¿©³Ö±â ½Ã¿¡ µÚÁýÈ÷´Â ¹®Á¦ ÇØ°á by altang 07.06.08. if (!Image->SaveToTexpiaFile(hFile, cmZLib)){ // if(bCopyFromClipboard) L_FlipBitmap(Image->Handle); //Ŭ¸³ º¸µå ºÙ¿©³Ö±â ½Ã¿¡ µÚÁýÈ÷´Â ¹®Á¦ ÇØ°á by altang 07.06.08. return false; } // if(bCopyFromClipboard) L_FlipBitmap(Image->Handle); //Ŭ¸³ º¸µå ºÙ¿©³Ö±â ½Ã¿¡ µÚÁýÈ÷´Â ¹®Á¦ ÇØ°á by altang 07.06.08. } else { bpp = 0; if (!WriteFile(hFile, &bpp, sizeof(WORD), &dwWrite, NULL)) return false; } return true; } //--------------------------------------------------------------------------- int __fastcall ImageGetAllocateSize(TTexpiaBitmap *Image) { int size = 0; if (Image) { size += sizeof(WORD) + sizeof(int) + sizeof(int); if (Image->BitsPerPixel == 8) size += (256 * sizeof(RGBQUAD)); size += Image->BytesPerLine * Image->Height; return size; } else { return sizeof(WORD); } } //--------------------------------------------------------------------------- BYTE* __fastcall ImageCopyToMemory(BYTE *lp, TTexpiaBitmap *Image) { WORD bpp; RGBQUAD rgb[256]; int w, h; if (Image) { bpp = Image->BitsPerPixel; memcpy(lp, &bpp, sizeof(WORD)); lp += sizeof(WORD); if (bpp == 8) { Image->GetColors(0, 256, rgb); memcpy(lp, rgb, 256 * sizeof(RGBQUAD)); lp += 256 * sizeof(RGBQUAD); } w = Image->Width; memcpy(lp, &w, sizeof(int)); lp += sizeof(int); h = Image->Height; memcpy(lp, &h, sizeof(int)); lp += sizeof(int); Image->SaveToMemory(lp, Image->BytesPerLine); lp += Image->Height * Image->BytesPerLine; } else { bpp = 0; memcpy(lp, &bpp, sizeof(WORD)); lp += sizeof(WORD); } return lp; } //--------------------------------------------------------------------------- BYTE* __fastcall ImageCopyFromMemory(BYTE *lp, TTexpiaBitmap *&Image) { WORD bpp; RGBQUAD rgb[256]; int w, h; memcpy(&bpp, lp, sizeof(WORD)); lp += sizeof(WORD); if (bpp) { Image = new TTexpiaBitmap; if (bpp == 8) { Image->GetColors(0, 256, rgb); memcpy(rgb, lp, 256 * sizeof(RGBQUAD)); lp += 256 * sizeof(RGBQUAD); memcpy(&w, lp, sizeof(int)); lp += sizeof(int); memcpy(&h, lp, sizeof(int)); lp += sizeof(int); Image->Create(w, h, bpp, rgb); } else { memcpy(&w, lp, sizeof(int)); lp += sizeof(int); memcpy(&h, lp, sizeof(int)); lp += sizeof(int); Image->Create(w, h, bpp); } Image->LoadFromMemory(lp, Image->BytesPerLine); lp += Image->Height * Image->BytesPerLine; } return lp; } //--------------------------------------------------------------------------- bool __fastcall ImageCopy(TTexpiaBitmap *&Image, TTexpiaBitmap *srcImage) { if (srcImage && (srcImage->Width != 0 && srcImage->Height != 0)) { if (Image) delete Image; Image = NULL; //by david 20111207 Äڵ尡µå¿¡ °É¸®´Â °Í °°¾Æ¼­ Image = new TTexpiaBitmap; if (!Image->Copy(srcImage, SRCCOPY)) return false; } return true; } //--------------------------------------------------------------------------- /// ¼¿ º¹»ç½Ã¿¡, ¼ö½Ä¿¡ ÀÖ´Â ±âÁ¸ ¼¿µéÀÇ ID¸¦ »õ·Î¿î ¼¿µéÀÇ ID·Î º¯È¯ÇØÁÖ´Â ÇÔ¼ö. /** * ±âÁ¸ÀÇ Cell ID¿Í »õ·Ó°Ô ¹èÁ¤µÈ Cell ID¸¦ °¢°¢ String List·Î ¹Þ¾Æ TList *cell¿¡ * ÀÖ´Â CellÁß Formula¿¡ ´ëÇÏ¿© ¼ö½Ä ¹®ÀÚ¿­¿¡ ÀÖ´Â Cell ID¸¦ ¸ðµÎ º¯È¯ÇØÁØ´Ù. */ // (2007. 09. 07 Annualring) void __fastcall ConvertCellIDInFormula(TStringList* oldID, TStringList* newID, TList* cell) { if (cell->Count == 0) return; Postfix *pf; int i, j; TPDocElement* dp; TPDocFormula* docFormula; int changedMark[200]; int idCount; // ¸®½ºÆ® ´Ù ¸¸µé°í ÀÌÁ¦ Formula¸¦ ã´Â´Ù. for (i = 0; i < cell->Count; i++) { dp = (TPDocElement *)cell->Items[i]; if (dp->Type == detFormula) { // Formula ÀÌ¸é ¸®½ºÆ®¸¦ º¸°í ¼ö½ÄÀ» º¯°æÇØÁØ´Ù. docFormula = (TPDocFormula*)dp; AnsiString ansiFormula = (AnsiString) docFormula->Formula; pf = new Postfix(ansiFormula.c_str()); if (!pf->convert()) { // À¯È¿ÇÑ FormulaÀ̸é! idCount = FormulaIDCount(docFormula->Formula); for (j = 0; j < idCount; j++) { changedMark[j] = 0; } for (j = 0; j < oldID->Count; j++) { ReplaceWholeFormulaString(docFormula->Formula, (WideString)(oldID->operator [](j)), (WideString)(newID->operator [](j)), changedMark); } } if (pf) { delete pf; pf = NULL; } } } } //--------------------------------------------------------------------------- /// Wide String ³»ºÎÀÇ ¹®ÀÚ¿­À» ƯÁ¤ ºÎºÐ¸¸ º¯°æÇØÁÖ´Â ÇÔ¼ö. //(2007. 08. 23 Annualring) int __fastcall ReplaceFormulaString(WideString& strData, WideString& strSrc, WideString& strDest, int* changedMark) { int pos, newPos; int length; int formerIDCount; if (WideLowerCase(strSrc) == WideLowerCase(strDest)) { // ¹«ÇÑ ·çÇÁ µµ´Â °Í ¹æÁö! return 0; } int strData_length = 0, strSrc_length = 0; if (strData.IsEmpty()) strData_length = 0; else strData_length = wcslen(strSrc.c_bstr()); if (strSrc.IsEmpty()) strSrc_length = 0; else strSrc_length = wcslen(strSrc.c_bstr()); pos = FormulaStringPos(WideLowerCase(strData), WideLowerCase(strSrc)); // if (pos > 0 && ((strData.Length() < pos + 2) || !isdigit(AnsiString(strData)[pos+2])) ) { while (pos > 0) { formerIDCount = FormulaIDCount(strData.SubString(0, pos - 1)); length = strSrc_length;//strSrc.Length(); //¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 if (changedMark[formerIDCount] == 0) { strData.Delete(pos, length); strData.Insert(strDest, pos); changedMark[formerIDCount] = 1; return 1; } else if ((pos + length - 1) <= strData_length ) {//strData.Length()) { newPos = FormulaStringPos(WideLowerCase(strData.SubString(pos + length, strData_length )), WideLowerCase(strSrc));//strData.Length())), WideLowerCase(strSrc)); if (newPos == 0) { pos = 0; } else { pos = pos + length + newPos - 1; } } else { return 0; } } return 0; } //--------------------------------------------------------------------------- /// Wide String ³»ºÎÀÇ ¹®ÀÚ¿­À» ƯÁ¤ ¹®ÀÚ¿­À» °¡Áø ºÎºÐ¿¡ ´ëÇØ º¯°æÇØÁÖ´Â ÇÔ¼ö. // (2007. 08. 23 Annualring) int __fastcall ReplaceWholeFormulaString(WideString& strData, WideString& strSrc, WideString& strDest, int* changedMark) { int count = 0; while (ReplaceFormulaString(strData, strSrc, strDest, changedMark) > 0) { count++; } return count; } //--------------------------------------------------------------------------- /// ¼¿ ³Ñ¹öÀÇ PositionÀ» ¸®ÅÏ ÇÏ´Â ÇÔ¼ö // (2007. 08. 23 Annualring) int __fastcall FormulaStringPos(WideString& strData, WideString& strSrc) { WideString strTemp; char chTemp; int pos; int length = 0; if (strSrc.IsEmpty()) length = 0; else length = wcslen(strSrc.c_bstr());//strSrc.Length();//¿¡·¯ ¹ß»ý °¡´É¼º Á¦°Å by david 100127 int cutLength = 0; //n, N, f, F, i, I, +, -, /, *, (, ) strTemp = strData; while ((pos = strTemp.Pos(strSrc)) > 0) { // ¿¡·¯ ¼öÁ¤ > ¸¦ >= ·Î (2007. 08. 28 Annualring) if (wcslen(strTemp.c_bstr())/*strTemp.Length()*/ >= pos + length) { chTemp = AnsiString(strTemp)[pos+length]; switch (chTemp) { case 'n': case 'N': case 'f': case 'F': case 'i': case 'I': case '+': case '-': case '/': case '*': case '(': case ')': return pos + cutLength; break; default: strTemp.Delete(pos, length); cutLength = cutLength + length; break; } } else { return pos + cutLength; } } return 0; } //--------------------------------------------------------------------------- /// Wide String ³»ºÎ ID °³¼ö¸¦ ¸®ÅÏÇÏ´Â ÇÔ¼ö // (2007. 08. 24 Annualring) int __fastcall FormulaIDCount(WideString& strData) { int count = 0; int i; WCHAR ch; int length = 0; if (strData.IsEmpty()) length = 0; else length = wcslen(strData.c_bstr()); for (i = 0; i < length/*strData.Length()*/; i++) { ch = strData[i]; switch (ch) { case 'n': case 'N': case 'f': case 'F': count ++; break; } } return count; } //--------------------------------------------------------------------------- /// µÎ°³ÀÇ »ç°¢ÇüÀ» Çϳª·Î ÇÕ¼ºÇØÁÖ´Â ÇÔ¼ö // (2007. 11. 03 Annualring) RECT __fastcall ComposeRect(RECT aRect, RECT bRect) { RECT result; if (aRect.top < bRect.top) result.top = aRect.top; else result.top = bRect.top; if (aRect.left < bRect.left) result.left = aRect.left; else result.left = bRect.left; if (aRect.bottom > bRect.bottom) result.bottom = aRect.bottom; else result.bottom = bRect.bottom; if (aRect.right > bRect.right) result.right = aRect.right; else result.right = bRect.right; return result; } // // // TPDocBackGround // //--------------------------------------------------------------------------- // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 04 Annualring) __fastcall TPDocBackground::TPDocBackground() { FBgSet = false; // FPatternSet = false; BgColor = clWhite; // PatternColor = clWhite; // FBgPattern = dbpNone; } //--------------------------------------------------------------------------- bool __fastcall TPDocBackground::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; //Version; if (Version > CURRENT_VERSION) { return false; } // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) if (!ReadFile(hFile, &FBgSet, sizeof(bool), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FBgRGB, sizeof(RGBQUAD), &dwRead, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocBackground::SaveToFile(HANDLE hFile) { DWORD dwWrite; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) if (!WriteFile(hFile, &FBgSet, sizeof(bool), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FBgRGB, sizeof(RGBQUAD), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocBackground::GetAllocateSize() { // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) return (sizeof(bool) + sizeof(RGBQUAD)); } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocBackground::CopyToMemory(BYTE *lp) { memcpy(lp, &FBgSet, sizeof(bool)); lp += sizeof(bool); memcpy(lp, &FBgRGB, sizeof(RGBQUAD)); lp += sizeof(RGBQUAD); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocBackground::CopyFromMemory(BYTE *lp) { memcpy(&FBgSet, lp, sizeof(bool)); lp += sizeof(bool); memcpy(&FBgRGB, lp, sizeof(RGBQUAD)); lp += sizeof(RGBQUAD); return lp; } //--------------------------------------------------------------------------- TColor __fastcall TPDocBackground::GetBgColor() { return RGBToTColor(FBgRGB); } //--------------------------------------------------------------------------- /* TColor __fastcall TPDocBackground::GetPatternColor() { return RGBToTColor(FPatternRGB); } */ //--------------------------------------------------------------------------- void __fastcall TPDocBackground::SetBgColor(TColor newColor) { FBgRGB = TColorToRGB(newColor); } //--------------------------------------------------------------------------- /* void __fastcall TPDocBackground::SetPatternColor(TColor newColor) { FPatternRGB = TColorToRGB(newColor); } */ // // // TPDocViewStatus // //--------------------------------------------------------------------------- __fastcall TPDocViewStatus::TPDocViewStatus() { Position.x = Position.y = 0; ZoomIn = ZoomOut = 1; } //--------------------------------------------------------------------------- __fastcall TPDocViewStatus::TPDocViewStatus(POINT pt, int zi, int zo) { Position = pt; ZoomIn = zi; ZoomOut = zo; } //--------------------------------------------------------------------------- int __fastcall TPDocViewStatus::View2PatternX(int X) { return Position.x + X * ZoomOut / ZoomIn; } //--------------------------------------------------------------------------- int __fastcall TPDocViewStatus::View2PatternY(int Y) { return Position.y + Y * ZoomOut / ZoomIn; } //--------------------------------------------------------------------------- int __fastcall TPDocViewStatus::Pattern2ViewX(int X) { return (X - Position.x) * ZoomIn / ZoomOut; } //--------------------------------------------------------------------------- int __fastcall TPDocViewStatus::Pattern2ViewY(int Y) { return (Y - Position.y) * ZoomIn / ZoomOut; } int __fastcall TPDocViewStatus::Pattern2RectViewX(int X){ // X-=X%ZoomOut; return (X - Position.x) * ZoomIn / ZoomOut; } int __fastcall TPDocViewStatus::Pattern2RectViewY(int Y){ // Y-=Y%ZoomOut; return (Y - Position.y) * ZoomIn / ZoomOut; } //--------------------------------------------------------------------------- /*RECT __fastcall TPDocViewStatus::ChangeRect(RECT rc) { rc.left = rc.left * ZoomIn / ZoomOut; rc.top = rc.top * ZoomIn / ZoomOut; rc.right = rc.right * ZoomIn / ZoomOut; rc.bottom = rc.bottom * ZoomIn / ZoomOut; return rc; } */ //--------------------------------------------------------------------------- // // TPDocObject // //--------------------------------------------------------------------------- __fastcall TPDocObject::TPDocObject() { Parent = NULL; } //--------------------------------------------------------------------------- TFont *__fastcall TPDocObject::GetFont() { return NULL; } //--------------------------------------------------------------------------- // // TPDocElement // //--------------------------------------------------------------------------- __fastcall TPDocElement::TPDocElement(TPDocElementType t, RECT rc, TPDocLineStyle fstyle, TColor fcolor, bool visible) : TPDocObject() { Type = t; Range = rc; ControlMode = dcmNone; FrameStyle.left = fstyle; FrameStyle.top = fstyle; FrameStyle.right = fstyle; FrameStyle.bottom = fstyle; //FrameColor = fcolor; FrameColor.left = fcolor; FrameColor.top = fcolor; FrameColor.right = fcolor; FrameColor.bottom = fcolor; bVisible = visible; NowSelect = false; OldSelect = false; // ¿¹½Å °ËÅä - by monkman (2010.10.19) //DBData = new TPDBData; } //--------------------------------------------------------------------------- __fastcall TPDocElement::~TPDocElement() { // ¿¹½Å °ËÅä - by monkman (2010.10.19) //if (DBData) delete DBData; //DBData = NULL; } //--------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- RECT __fastcall TPDocElement::ConvertRange(TPDocViewStatus *vs) { RECT rc; rc = Range; if (Parent) { rc.left += Parent->Range.left; rc.top += Parent->Range.top; rc.right += Parent->Range.left; rc.bottom += Parent->Range.top; } if (vs) { rc.left = (rc.left - vs->Position.x) * vs->ZoomIn/ vs->ZoomOut; rc.top = (rc.top - vs->Position.y) * vs->ZoomIn/ vs->ZoomOut; rc.right = (rc.right - vs->Position.x) * vs->ZoomIn/ vs->ZoomOut; rc.bottom = (rc.bottom - vs->Position.y) * vs->ZoomIn/ vs->ZoomOut; } return rc; } //--------------------------------------------------------------------------- POINT __fastcall TPDocElement::ConvertPoint(POINT tp, TPDocViewStatus *vs) { if (Parent) { tp.x += Parent->Range.left; tp.y += Parent->Range.top; } if (vs) { tp.x = (tp.x - vs->Position.x) * vs->ZoomIn / vs->ZoomOut; tp.y = (tp.y - vs->Position.y) * vs->ZoomIn / vs->ZoomOut;; } return tp; } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintRange(HDC hDC, RECT rc) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int p; hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); hPen = CreatePen(psDash, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); Rectangle(hDC, rc.left, rc.top, rc.right + 1, rc.bottom + 1); SelectObject(hDC,hOldPen); DeleteObject(hPen); SelectObject(hDC, hOldBrush); } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintImage(HDC hDC, TTexpiaBitmap *Image, SIZE s, int x, int y) { double rx, ry, r; HDC hImageDC; int rvalue = 0; if (Image == NULL) return; if (Image->Width==0 && Image->Height==0) return; //0ÀÎ °æ¿ì¿¡ ±×¸²À» ±×·ÁÁÖ·Á´Ù Division By Zero ¿¡·¯³² ±×·± ÀÌÀ¯·Î Ãß°¡µÈ ÄÚµå.by linuxjun rx = (double)s.cx / Image->Width; ry = (double)s.cy / Image->Height; r = rx < ry ? rx : ry; hImageDC = Image->CreateDC(); // if (r < 1.0) { if (s.cx > Image->Width*r) { x += ( (s.cx - Image->Width*r)/2); } if (s.cy > Image->Height*r) { y += ( (s.cy - Image->Height*r)/2); } //SetStretchBltMode(hDC, COLORONCOLOR); //Áß±¹ ¿ÕÁ¾¿¡¼­ Ãà¼Ò½Ã À̹ÌÁö ¶óÀÎÀÌ º¸ÀÌÁö ¾Ê´Â´Ù°í ÇØ¼­ º¯°æÇÔ (12.6.19) SetStretchBltMode(hDC, HALFTONE); Image->BitmapRatio = r; rvalue = StretchBlt(hDC, x, y, Image->Width * r, Image->Height * r, hImageDC, 0, 0, Image->Width, Image->Height, SRCCOPY); if (rvalue==0) { DWORD abc = GetLastError(); int ab = 10; // ShowMessage("Image Copy fail //s"); } /* } else { rvalue = BitBlt(hDC, x + (s.cx - Image->Width) / 2, y + (s.cy - Image->Height) / 2, Image->Width, Image->Height, hImageDC, 0, 0, SRCCOPY); if (rvalue == 0) ShowMessage("Image Copy fail //b"); }*/ Image->DeleteDC(hImageDC); } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintSelect(HDC hDC, RECT rc, TPDocPaintSelectInEvent func) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int p; PaintRange(hDC, rc); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); if (func) func(hDC, rc); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); if (hOldBrush) SelectObject(hDC, hOldBrush); } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintSelectReport(HDC hDC, void *data, TPDocPaintSelectInReportEvent func) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int p; hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); if (func) func(hDC, data); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); if (hOldBrush) SelectObject(hDC, hOldBrush); } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintSelectInCommon(HDC hDC, RECT rc) { int p; Rectangle(hDC, rc.left-2, rc.top-2, rc.left+3, rc.top+3); Rectangle(hDC, rc.right-2, rc.top-2, rc.right+3, rc.top+3); Rectangle(hDC, rc.left-2, rc.bottom-2, rc.left+3, rc.bottom+3); Rectangle(hDC, rc.right-2, rc.bottom-2, rc.right+3, rc.bottom+3); p = (rc.right + rc.left) / 2; Rectangle(hDC, p-2, rc.top-2, p+3, rc.top+3); Rectangle(hDC, p-2, rc.bottom-2, p+3, rc.bottom+3); p = (rc.bottom + rc.top) / 2; Rectangle(hDC, rc.left-2, p-2, rc.left+3, p+3); Rectangle(hDC, rc.right-2, p-2, rc.right+3, p+3); } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- /* void __fastcall TPDocElement::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } //--------------------------------------------------------------------------- */ void __fastcall TPDocElement::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool select, int language, bool bSaveJPG) { } //--------------------------------------------------------------------------- //¼û±â±â ±â´ÉÀÌ ¼³Á¤µÈ ¼¿À» Report Mode¿¡¼­ paint ÇÏ´Â ÇÔ¼ö void __fastcall TPDocElement::PaintReportHidden(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool select, int language, bool bSaveJPG) { RECT rc = ConvertRange(&vs); if(!bPrint) { LOGBRUSH newLogBrush; newLogBrush.lbStyle = BS_HATCHED; newLogBrush.lbColor = 0xAAAAAA; newLogBrush.lbHatch = HS_BDIAGONAL; HBRUSH newBrush = CreateBrushIndirect(&newLogBrush); HBRUSH oldBrush = (HBRUSH)SelectObject(hDC, newBrush); HPEN newPen = CreatePen(PS_DOT, 1, 0xAAAAAA); HPEN oldPen = (HPEN)SelectObject(hDC, newPen); Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); SelectObject(hDC, oldBrush); SelectObject(hDC, oldPen); if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- //¼û±â±â ±â´ÉÀÌ ¼³Á¤µÈ ¼¿À» Design Mode¿¡¼­ paint ÇÏ´Â ÇÔ¼ö void __fastcall TPDocElement::PaintDesignHidden(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); // if(bSaveToJPG)//for ¾ÆÀ̺ñ 2005.6.15//»ö±ò¹Ù²ãÁÙ ºÎºÐ PaintForm(hDC, &vs, bPrint); /* if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReportHidden(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daCenter2, (WideString)"Hidden"); } */ TEXTMETRIC tm; GetTextMetrics(hDC, &tm); SetTextAlign(hDC, TA_CENTER); int px = (rc.right + rc.left) / 2; int py = (rc.bottom + rc.top - tm.tmHeight) / 2; TextOut(hDC, px, py, "HIDDEN", 6); if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocElement::IsExist(POINT pt) { if (Type == detArrow) { bool bResult = ((TPDocArrow *)this)->IsExist(pt); return bResult; } if(Type == detSheafImage){ //for linuxjun bool bResult = ((TPDocSheafImage *)this)->IsExist(pt); return bResult; /* //for linuxjun Shift·Î µû·Î ¼±Åà °¡´ÉÇÏ°Ô ÇϱâÀ§ÇØ ¸·À½. ((TPDocSheafImage *)this)->bSelected = false; if(pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2){ ((TPDocSheafImage *)this)->bSelected = true; } */ } return pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2; } //--------------------------------------------------------------------------- bool __fastcall TPDocElement::HasValue() { return false; } //--------------------------------------------------------------------------- int __fastcall TPDocElement::GetAllocateSize() { return 0; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocElement::CopyToMemory(BYTE *lp) { return NULL; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocElement::CopyFromMemory(BYTE *lp) { return NULL; } //--------------------------------------------------------------------------- TPDocControlMode __fastcall TPDocElement::GetControlMode(int X, int Y) { int p; TPDocControlMode dcm; if (Type == detArrow) { dcm = ((TPDocArrow *)this)->GetControlMode(X, Y); return dcm; } if (Y >= Range.top - 2 && Y < Range.top + 3) { if (X >= Range.left - 2 && X < Range.left + 3) return dcmLeftTop; else if (X >= Range.right - 2 && X < Range.right + 3) return dcmRightTop; else if (X >= (Range.right + Range.left) /2 - 2 && X < (Range.right + Range.left) /2 + 3) return dcmCenterTop; else if (X > Range.left && X < Range.right) return dcmMove; } else if (Y >= Range.bottom - 2 && Y < Range.bottom + 3) { if (X >= Range.left - 2 && X < Range.left + 3) return dcmLeftBottom; else if (X >= Range.right - 2 && X < Range.right + 3) return dcmRightBottom; else if (X >= (Range.right + Range.left) /2 - 2 && X < (Range.right + Range.left)/2 + 3) return dcmCenterBottom; else if (X > Range.left && X < Range.right) return dcmMove; } else { p = (Range.bottom + Range.top) /2; if (X >= Range.left - 2 && X < Range.left + 3) { if (Y >= p - 2 && Y < p + 3) return dcmLeftCenter; else if (Y > Range.top && Y < Range.bottom) return dcmMove; } else if (X >= Range.right - 2 && X < Range.right + 3) { if (Y >= p - 2 && Y < p + 3) return dcmRightCenter; else if (Y > Range.top && Y < Range.bottom) return dcmMove; } } return dcmNone; } //--------------------------------------------------------------------- void __fastcall TPDocElement::GetNewRange(int X, int Y) { FOldRect = Range; switch (ControlMode) { case dcmLeftTop: FOldRect.left = X; FOldRect.top = Y; break; case dcmCenterTop: FOldRect.top = Y; break; case dcmRightTop: FOldRect.top = Y; FOldRect.right = X; break; case dcmLeftCenter: FOldRect.left = X; break; case dcmRightCenter: FOldRect.right = X; break; case dcmLeftBottom: FOldRect.left = X; FOldRect.bottom = Y; break; case dcmCenterBottom: FOldRect.bottom = Y; break; case dcmRightBottom: FOldRect.right = X; FOldRect.bottom = Y; break; case dcmMove: FOldRect.left += X - FOldPoint.x; FOldRect.top += Y - FOldPoint.y; FOldRect.right += X - FOldPoint.x; FOldRect.bottom += Y - FOldPoint.y; break; } } //--------------------------------------------------------------------- void __fastcall TPDocElement::ControlModeMouseDown(TShiftState Shift, int X, int Y) { FOldPoint = Point(X, Y); FOldRect = Range; } //--------------------------------------------------------------------- void __fastcall TPDocElement::ControlModeMouseMove(HDC hDC, TPDocViewStatus &vs, int X, int Y) { PaintControl(hDC, vs); GetNewRange(X, Y); PaintControl(hDC, vs); } //--------------------------------------------------------------------- void __fastcall TPDocElement::ControlModeMouseUp() { switch (ControlMode) { case dcmMove: Range = FOldRect; if (Type == detChart) { if (Parent) { ((TPDocSheet *)Parent)->SetCursorIndex(); } } break; default: Range.left = min(FOldRect.left, FOldRect.right); Range.top = min(FOldRect.top, FOldRect.bottom); Range.right = max(FOldRect.left, FOldRect.right); Range.bottom = max(FOldRect.top, FOldRect.bottom); break; } } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintFrame(HDC hDC, RECT rc, TPDocBorder ls, TPDocFrameColor c, double t, bool bPrint) { //for ÀåÁø¸¸ (Ç¥) // Ææ ŸÀÔ Ãß°¡ (¿ø·¡ HPEN °³¼ö°¡ 5¿´´Ù.) HPEN hPen[14], hOldPen = NULL; HBRUSH hOldBrush = NULL; LOGBRUSH logb; POINT sp1, ep1, sp2, ep2, sp3, ep3; int i, gap; // µÎ²¨¿î ½Ç¼± // Ãß°¡ Excel Line (2007. 05. 07 Annualring) double intervalTimes; if (bPrint) { intervalTimes = 4; } else { intervalTimes = 1.25 * t; } DWORD Style1[] = {4 * intervalTimes, 4 * intervalTimes}; DWORD Style2[] = {18 * intervalTimes, 5 * intervalTimes}; DWORD Style3[] = {18 * intervalTimes, 6 * intervalTimes, 6 * intervalTimes, 6 * intervalTimes, 6 * intervalTimes, 6 * intervalTimes}; DWORD Style4[] = {18 * intervalTimes, 6 * intervalTimes, 6 * intervalTimes, 6 * intervalTimes}; try { logb.lbStyle = BS_SOLID; logb.lbColor = c.left; hPen[0] = ExtCreatePen(PS_GEOMETRIC|PS_SOLID|PS_ENDCAP_FLAT, t, &logb, 0, NULL); hPen[1] = ExtCreatePen(PS_GEOMETRIC|PS_SOLID|PS_ENDCAP_FLAT, 3*t, &logb, 0, NULL); hPen[2] = ExtCreatePen(PS_GEOMETRIC|PS_DASH|PS_ENDCAP_FLAT, t, &logb, 0, NULL); hPen[3] = ExtCreatePen(PS_GEOMETRIC|PS_DOT|PS_ENDCAP_FLAT, t, &logb, 0, NULL); hPen[4] = ExtCreatePen(PS_GEOMETRIC|PS_DASHDOT|PS_ENDCAP_FLAT, t, &logb, 0, NULL); // Ææ ŸÀÔ Ãß°¡ // Ãß°¡ Excel Line (2007. 05. 07 Annualring) hPen[5] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 2*t, &logb, 2, Style1); hPen[6] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 4*t, &logb, 2, Style2); hPen[7] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 2*t, &logb, 6, Style3); hPen[8] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 2*t, &logb, 4, Style4); hPen[9] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 4*t, &logb, 6, Style3); hPen[10] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 4*t, &logb, 4, Style4); hPen[11] = ExtCreatePen(PS_GEOMETRIC|PS_SOLID|PS_ENDCAP_FLAT, 4*t, &logb, 0, NULL); hPen[12] = ExtCreatePen(PS_GEOMETRIC|PS_USERSTYLE|PS_ENDCAP_FLAT, 2*t, &logb, 2, Style2); hPen[13] = ExtCreatePen(PS_GEOMETRIC|PS_SOLID|PS_ENDCAP_ROUND, 6*t, &logb, 0, NULL); //¿ÞÂÊ ¼± ±×¸®±â if (ls.top == dlsTwo || ls.top == dlsTwodown|| ls.top == dlsThree) sp1.y = sp2.y = sp3.y = rc.top - 2 * t; else if( ls.top == dlsTwoup ) sp1.y = sp2.y = sp3.y = rc.top - 3 * t; else sp1.y = sp2.y = sp3.y = rc.top; if (ls.bottom == dlsTwo || ls.bottom == dlsTwoup || ls.bottom == dlsThree) ep1.y = ep2.y = ep3.y = rc.bottom + 2 * t; else if( ls.bottom == dlsTwodown ) ep1.y = ep2.y = ep3.y = rc.bottom + 3 * t; else ep1.y = ep2.y = ep3.y = rc.bottom ; if (ls.left == dlsTwo || ls.left == dlsTwodown || ls.left == dlsTwoup || ls.left == dlsThree) { sp1.x = ep1.x = rc.left - 2 * t; sp2.x = ep2.x = rc.left + 2 * t; sp3.x = ep3.x = rc.left; if(ls.left == dlsTwoup) SelectObject(hDC, hPen[1]); else SelectObject(hDC, hPen[0]); MoveToEx(hDC, sp1.x, sp1.y, NULL); LineTo(hDC, ep1.x, ep1.y); if(ls.left == dlsTwodown) SelectObject(hDC, hPen[1]); else SelectObject(hDC, hPen[0]); MoveToEx(hDC, sp2.x, sp2.y, NULL); LineTo(hDC, ep2.x, ep2.y); if(ls.left == dlsThree){ SelectObject(hDC, hPen[0]); MoveToEx(hDC, sp3.x, sp3.y, NULL); LineTo(hDC, ep3.x, ep3.y); } } else if (ls.left == dlsOne || ls.left == dlsHeavy || ls.left == dlsDash || ls.left == dlsDot || ls.left == dlsDashdot) { sp1.x = ep1.x = rc.left; if((ls.left == dlsOne) || (ls.left == dlsHeavy)){ if(ls.left == dlsOne) SelectObject(hDC, hPen[0]); if(ls.left == dlsHeavy) SelectObject(hDC, hPen[1]); MoveToEx(hDC, sp1.x, sp1.y, NULL); LineTo(hDC, ep1.x, ep1.y); } else if((ls.left == dlsDash) || (ls.left == dlsDot) || (ls.left == dlsDashdot)){ if(ls.left == dlsDash) SelectObject(hDC, hPen[2]); if(ls.left == dlsDot) SelectObject(hDC, hPen[3]); if(ls.left == dlsDashdot) SelectObject(hDC, hPen[4]); // for(i=0;i Color hPen = CreatePen(psSolid, 1 * r, /*clBlack*/Color); hOldPen = (HPEN)SelectObject(hDC, hPen); hBrush = CreateSolidBrush(Color); hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); Rectangle(hDC, rect.left, rect.top, rect.right+1, rect.bottom+1); } __finally { if (hOldBrush) SelectObject(hDC, hOldBrush); if (hBrush) DeleteObject(hBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } // Report Mode¿¡¼­ ¼¿ ¼±ÅÃÀÌ Á¦´ë·Î ¾ÈµÇ´Â ¹®Á¦ ó¸® (2007. 07. 09 Annualring) // if (NowSelect) PaintIn(hDC, rect); } //--------------------------------------------------------------------------- /// ¼¿ ÇÁ·¹ÀÓÀ» ±×¸®´Â ÇÔ¼ö¿¡ ¼¿ ¹è°æ ±×¸®´Â ºÎºÐ±îÁö Ãß°¡ /** * ÁöÁ¤µÈ Element¿¡¼­¸¸, ±×¸®°í Background.BgSetÀÌ trueÀÎ °æ¿ì¿¡¸¸ PaintBackground * ¸¦ È£ÃâÇϵµ·Ï ÇØÁØ´Ù. ±×¸®°í ¹è°æÀ» ±×¸° ´ÙÀ½¿¡ FrameÀ» ±×¸®µµ·Ï ó¸®ÇØÁØ´Ù. */ // (2007. 09. 04 Annualring) void __fastcall TPDocElement::PaintFrame(HDC hDC, RECT rc, double t, bool bPrint) { // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 04 Annualring) // ÁöÁ¤µÈ Element¿¡¼­¸¸ Background ±×¸®±â 󸮰¡ µÇµµ·Ï (2007. 07. 09 Annualring) if (Type == detSignature || Type == detNumber || Type == detFormula || Type == detLabel || Type == detEdit || Type == detMemo || Type == detImage || Type == detTextImage || Type == detDate) { if (Background.BgSet) { PaintBackground(hDC, rc, t, Background.BgColor); } } // Frame ±×¸®±â¸¦ ³ªÁß¿¡ Çϵµ·Ï ó¸® if(bVisible) PaintFrame(hDC, rc, FrameStyle, FrameColor, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocElement::PaintIn(HDC hDC, RECT rc) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(BLACK_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); Rectangle(hDC, rc.left+3, rc.top+3, rc.right-2, rc.bottom-2); } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //---------------------------------------------------------------------------- // // TPDocLine // //--------------------------------------------------------------------------- __fastcall TPDocLine::TPDocLine(TPDocObject *Sender, RECT rc, TPDocLineType lt, TColor c, TPDocLineStyle ls) : TPDocElement(detLine, rc) { Parent = Sender; Type = lt; Color = c; Style = ls; } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocLine::PaintForm(HDC hDC, RECT rc, double t) { HPEN hPen[5], hOldPen = NULL; int p; try { switch (Type) { hOldPen = (HPEN)SelectObject(hDC, hPen); hPen[0] = CreatePen(psSolid, 1 * t, Color); hPen[1] = CreatePen(psSolid, 3 * t, Color); hPen[2] = CreatePen(psDash, 1 * t, Color); hPen[3] = CreatePen(psDot, 1 * t, Color); hPen[4] = CreatePen(psDashDot, 1 * t, Color); case dltHorizental: if (Style == dlsTwo || Style == dlsTwodown || Style == dlsTwoup || Style == dlsThree) { if(Style == dlsTwoup) SelectObject(hDC, hPen[1]); else SelectObject(hDC, hPen[0]); MoveToEx(hDC, rc.left, rc.top-2, NULL); LineTo(hDC, rc.right, rc.top-2); if(Style == dlsTwodown) SelectObject(hDC, hPen[1]); else SelectObject(hDC, hPen[0]); MoveToEx(hDC, rc.left, rc.top+2, NULL); LineTo(hDC, rc.right, rc.top+2); if(Style == dlsThree){ MoveToEx(hDC, rc.left, rc.top, NULL); LineTo(hDC, rc.right, rc.top); } } else if (Style == dlsOne || Style == dlsHeavy || Style == dlsDash || Style == dlsDot || Style == dlsDashdot) { if(Style == dlsOne) SelectObject(hDC, hPen[0]); if(Style == dlsHeavy) SelectObject(hDC, hPen[1]); if(Style == dlsDash) SelectObject(hDC, hPen[2]); if(Style == dlsDot) SelectObject(hDC, hPen[3]); if(Style == dlsDashdot) SelectObject(hDC, hPen[4]); MoveToEx(hDC, rc.left, rc.top, NULL); LineTo(hDC, rc.right, rc.top); } break; case dltVertical: if (Style == dlsTwo || Style == dlsTwodown || Style == dlsTwoup || Style == dlsThree) { if(Style == dlsTwoup) SelectObject(hDC, hPen[1]); else SelectObject(hDC, hPen[0]); MoveToEx(hDC, rc.left-2, rc.top, NULL); LineTo(hDC, rc.left-2, rc.bottom); if(Style == dlsTwodown) SelectObject(hDC, hPen[1]); else SelectObject(hDC, hPen[0]); MoveToEx(hDC, rc.left+2, rc.top, NULL); LineTo(hDC, rc.left+2, rc.bottom); if(Style == dlsThree){ MoveToEx(hDC, rc.left, rc.top, NULL); LineTo(hDC, rc.left, rc.bottom); } } else if (Style == dlsOne || Style == dlsHeavy || Style == dlsDash || Style == dlsDot || Style == dlsDashdot) { if(Style == dlsOne) SelectObject(hDC, hPen[0]); if(Style == dlsHeavy) SelectObject(hDC, hPen[1]); if(Style == dlsDash) SelectObject(hDC, hPen[2]); if(Style == dlsDot) SelectObject(hDC, hPen[3]); if(Style == dlsDashdot) SelectObject(hDC, hPen[4]); MoveToEx(hDC, rc.left, rc.top, NULL); LineTo(hDC, rc.left, rc.bottom); } break; case dltOblique: if (Style == dlsOne || Style == dlsHeavy || Style == dlsDash || Style == dlsDot || Style == dlsDashdot) { if(Style == dlsOne) SelectObject(hDC, hPen[0]); if(Style == dlsHeavy) SelectObject(hDC, hPen[1]); if(Style == dlsDash) SelectObject(hDC, hPen[2]); if(Style == dlsDot) SelectObject(hDC, hPen[3]); if(Style == dlsDashdot) SelectObject(hDC, hPen[4]); MoveToEx(hDC, rc.left, rc.top, NULL); LineTo(hDC, rc.right, rc.bottom); } break; } } __finally { if (hOldPen) SelectObject(hDC, hOldPen); if (hPen[0]) DeleteObject(hPen[0]); if (hPen[1]) DeleteObject(hPen[1]); if (hPen[2]) DeleteObject(hPen[2]); if (hPen[3]) DeleteObject(hPen[3]); if (hPen[4]) DeleteObject(hPen[4]); } } //--------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- void __fastcall TPDocLine::PaintSelectInHorizental(HDC hDC, RECT rc) { Rectangle(hDC, rc.left-2, rc.top-2, rc.left+3, rc.top+3); Rectangle(hDC, rc.right-2, rc.top-2, rc.right+3, rc.top+3); } //--------------------------------------------------------------------------- void __fastcall TPDocLine::PaintSelectInVertical(HDC hDC, RECT rc) { Rectangle(hDC, rc.left-2, rc.top-2, rc.left+3, rc.top+3); Rectangle(hDC, rc.left-2, rc.bottom-2, rc.left+3, rc.bottom+3); } //--------------------------------------------------------------------------- void __fastcall TPDocLine::PaintControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); nOldROP = SetROP2(hDC, R2_NOT); if (Type == dltHorizental) { MoveToEx(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), NULL); LineTo(hDC, vs.Pattern2ViewX(FOldRect.right), vs.Pattern2ViewY(FOldRect.top)); } else if (Type == dltVertical) { MoveToEx(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), NULL); LineTo(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.bottom)); } else { hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); } } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocLine::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut); } //--------------------------------------------------------------------------- void __fastcall TPDocLine::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) { switch (Type) { case dltHorizental: PaintSelect(hDC, rc, &PaintSelectInHorizental); break; case dltVertical: PaintSelect(hDC, rc, &PaintSelectInVertical); break; case dltOblique: PaintSelect(hDC, rc, &PaintSelectInCommon); break; } } else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); } //--------------------------------------------------------------------------- bool __fastcall TPDocLine::HasValue() { return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocLine::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!ReadFile(hFile, &Type, sizeof(TPDocLineType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Style, sizeof(TPDocLineStyle), &dwRead, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocLine::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!WriteFile(hFile, &Type, sizeof(TPDocLineType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Style, sizeof(TPDocLineStyle), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocLine::Copy(TPDocLine *src) { Type = src->Type; Color = src->Color; Style = src->Style; return true; } //--------------------------------------------------------------------------- TPDocControlMode __fastcall TPDocLine::GetControlMode(int X, int Y) { TPDocControlMode dcm; if (Type == dltHorizental) { if (Y >= Range.top - 2 && Y < Range.top + 3) { if (X >= Range.left - 2 && X < Range.left + 3) { return dcmLeftCenter; } else if (X >= Range.right - 2 && X < Range.right + 3) { return dcmRightCenter; } } } else if (Type == dltVertical) { if (X >= Range.left - 2 && X < Range.left + 3) { if (Y >= Range.top - 2 && Y < Range.top + 3) { return dcmCenterTop; } else if (Y >= Range.bottom - 2 && Y < Range.bottom + 3) { return dcmCenterBottom; } } } else { return TPDocElement::GetControlMode(X, Y); } return X >= Range.left && Y >= Range.top && X <= Range.right && Y <= Range.bottom ? dcmMove : dcmNone; } //--------------------------------------------------------------------------- // // TPDocBox // //--------------------------------------------------------------------------- __fastcall TPDocBox::TPDocBox(TPDocObject *Sender, RECT rc, TColor c, TPDocLineStyle ls) : TPDocElement(detBox, rc) { Parent = Sender; Color = c; Style = ls; } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocBox::PaintForm(HDC hDC, RECT range, double t, bool bPrint) { //qe PaintFrame(hDC, range, Style, Color); PaintFrame(hDC, range, t); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocBox::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocBox::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); } //--------------------------------------------------------------------------- bool __fastcall TPDocBox::HasValue() { return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocBox::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Style, sizeof(TPDocLineStyle), &dwRead, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocBox::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Style, sizeof(TPDocLineStyle), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocBox::Copy(TPDocBox *src) { Color = src->Color; Style = src->Style; return true; } //--------------------------------------------------------------------------- // // TPDocColorChip // //--------------------------------------------------------------------------- /* __fastcall TPDocColorChip::TPDocColorChip(TPDocObject *Sender, RECT rc, int m, AnsiString n, TColor c) : TPDocElement(detColorChip, rc) { Parent = Sender; Margin = m; Name = n; ptrColor = new TColor; Color = c; bHasCommonData = false; } //--------------------------------------------------------------------------- */ __fastcall TPDocColorChip::TPDocColorChip(TPDocObject *Sender, RECT rc, int m, WideString n, TColor c) : TPDocElement(detColorChip, rc) { Parent = Sender; Margin = m; Name = n; ptrColor = new TColor; Color = c; bHasCommonData = false; } //--------------------------------------------------------------------------- __fastcall TPDocColorChip::~TPDocColorChip(){ if(!bHasCommonData){ delete ptrColor; ptrColor = NULL; } } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocColorChip::PaintForm(HDC hDC, RECT range, double t, bool bPrint) { PaintFrame(hDC, range, t); } //--------------------------------------------------------------------------- TColor __fastcall TPDocColorChip::GetColor() { return *ptrColor; } //--------------------------------------------------------------------------- void __fastcall TPDocColorChip::SetColor(TColor color) { *ptrColor = color; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocColorChip::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocColorChip::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); NowSelect = TempSelect; // if (NowSelect) PaintIn(hDC, rc); // if (NowSelect) PaintIn(hDC, rc); }else{ if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocColorChip::HasValue() { if(Color) { return true; }else{ return false; } } //--------------------------------------------------------------------------- void __fastcall TPDocColorChip::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; RECT rc; double r; r = (double)vs.ZoomIn / vs.ZoomOut; rc = ConvertRange(&vs); rc.left += Margin * r; rc.top += Margin * r; rc.right -= Margin * r; rc.bottom -= Margin * r; try { hPen = CreatePen(psSolid, 1 * r, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hBrush = CreateSolidBrush(Color); hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); Rectangle(hDC, rc.left, rc.top, rc.right+1, rc.bottom+1); } __finally { if (hOldBrush) SelectObject(hDC, hOldBrush); if (hBrush) DeleteObject(hBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocColorChip::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; //if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, ptrColor, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Margin, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Name)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocColorChip::SaveToFile(HANDLE hFile) { DWORD dwWrite; //if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, ptrColor, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Margin, sizeof(int), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Name)) return false; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocColorChip::GetAllocateSize() { int size = 0; size = sizeof(TColor) + sizeof(int) + TextGetAllocateSize(Name); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocColorChip::CopyToMemory(BYTE *lp) { memcpy(lp, &Color, sizeof(TColor)); lp += sizeof(TColor); memcpy(lp, &Margin, sizeof(int)); lp += sizeof(int); lp = TextCopyToMemory(lp, Name); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocColorChip::CopyFromMemory(BYTE *lp) { memcpy(&Color, lp, sizeof(TColor)); lp += sizeof(TColor); memcpy(&Margin, lp, sizeof(int)); lp += sizeof(int); lp = TextCopyFromMemory(lp, Name); /* AnsiString TempString; lp = TextCopyFromMemory(lp, TempString); Name = TempString */ return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocColorChip::Copy(TPDocColorChip *src) { Color = src->Color; Margin = src->Margin; Name = src->Name; return true; } //--------------------------------------------------------------------------- // // TPDocText // //--------------------------------------------------------------------------- __fastcall TPDocText::TPDocText(TPDocObject *Sender, TPDocElementType ot, RECT rc, TPDocAlign ta) : TPDocElement(ot, rc) { Parent = Sender; FNewFont = false; Font = Parent->GetFont(); //Font->Name = "Tahoma"; ParentFont = Font; Align = ta; FieldName = ""; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } //--------------------------------------------------------------------------- __fastcall TPDocText::~TPDocText() { if (FNewFont) { if (Font){ if(Font!=ParentFont)delete Font; //delete Font; } } } //--------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- bool __fastcall TPDocText::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TFontCharset charset; TColor color; AnsiString FName; WideString WFName; int size; TFontStyles fstyle; TextVersion = Version; if (!ReadFile(hFile, &FNewFont, sizeof(bool), &dwRead, NULL)) return false; if (FNewFont) { Font = new TFont; if (!ReadFile(hFile, &charset, sizeof(TFontCharset), &dwRead, NULL)) return false; Font->Charset = charset; if (!ReadFile(hFile, &color, sizeof(TColor), &dwRead, NULL)) return false; Font->Color = color; if (!TextLoadFromFile(hFile, FName)) return false; Font->Name = FName; if (!ReadFile(hFile, &size, sizeof(int), &dwRead, NULL)) return false; Font->Size = size; if (!ReadFile(hFile, &fstyle, sizeof(TFontStyle), &dwRead, NULL)) return false; Font->Style = fstyle; } else { Font = Parent->GetFont(); } if (!ReadFile(hFile, &Align, sizeof(TPDocAlign), &dwRead, NULL)) return false; //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. if(Version>=12){ WFName=""; if (!TextLoadFromFile(hFile, WFName)) return false; FieldName = WFName; if(Version<15){ FieldName = ""; } } //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocText::SaveToFile(HANDLE hFile) { DWORD dwWrite; TFontCharset charset; TColor color; int size; TFontStyles fstyle; if (!WriteFile(hFile, &FNewFont, sizeof(bool), &dwWrite, NULL)) return false; if (FNewFont) { charset = Font->Charset; if (!WriteFile(hFile, &charset, sizeof(TFontCharset), &dwWrite, NULL)) return false; color = Font->Color; if (!WriteFile(hFile, &color, sizeof(TColor), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Font->Name)) return false; size = Font->Size; if (!WriteFile(hFile, &size, sizeof(int), &dwWrite, NULL)) return false; fstyle = Font->Style; if (!WriteFile(hFile, &fstyle, sizeof(TFontStyle), &dwWrite, NULL)) return false; } if (!WriteFile(hFile, &Align, sizeof(TPDocAlign), &dwWrite, NULL)) return false; //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. if (!TextSaveToFile(hFile, FieldName)) return false; //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. return true; } //--------------------------------------------------------------------------- int __fastcall TPDocText::GetAllocateSize() { int size = 0; size += sizeof(bool); if (FNewFont) size += (sizeof(TFontCharset) + sizeof(TColor) + TextGetAllocateSize(Font->Name) + sizeof(int) + sizeof(TFontStyle)); size += sizeof(TPDocAlign); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocText::CopyToMemory(BYTE *lp) { TFontCharset charset; TColor color; int size; TFontStyles fstyle; memcpy(lp, &FNewFont, sizeof(bool)); lp += sizeof(bool); if (FNewFont) { charset = Font->Charset; memcpy(lp, &charset, sizeof(TFontCharset)); lp += sizeof(TFontCharset); color = Font->Color; memcpy(lp, &color, sizeof(TColor)); lp += sizeof(TColor); lp = TextCopyToMemory(lp, Font->Name); size = Font->Size; memcpy(lp, &size, sizeof(int)); lp += sizeof(int); fstyle = Font->Style; memcpy(lp, &fstyle, sizeof(TFontStyle)); lp += sizeof(TFontStyle); } memcpy(lp, &Align, sizeof(TPDocAlign)); lp += sizeof(TPDocAlign); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocText::CopyFromMemory(BYTE *lp) { TFontCharset charset; TColor color; int size; TFontStyles fstyle; AnsiString name; memcpy(&FNewFont, lp, sizeof(bool)); lp += sizeof(bool); if (FNewFont) { Font = new TFont; memcpy(&charset, lp, sizeof(TFontCharset)); lp += sizeof(TFontCharset); Font->Charset = charset; memcpy(&color, lp, sizeof(TColor)); lp += sizeof(TColor); Font->Color = color; lp = TextCopyFromMemory(lp, name); Font->Name = name; memcpy(&size, lp, sizeof(int)); lp += sizeof(int); Font->Size = size; memcpy(&fstyle, lp, sizeof(TFontStyle)); lp += sizeof(TFontStyle); Font->Style = fstyle; } memcpy(&Align, lp, sizeof(TPDocAlign)); lp += sizeof(TPDocAlign); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocText::Copy(TPDocText *src) { SetFont(src->GetFont()); //for linuxjun /* for Qe Copy¿¡·¯ ¼öÁ¤À» À§ÇØ. ¿©·¯°³°¡ ¼±ÅÃµÈ »óÅ¿¡¼­ Font¸¦ º¹»çÇßÀ»¶§ //Áö¿öÁÖ´Â ºÎºÐ¿¡¼­ ´Ù¸¥ ³à¼®ÀÇ font¸¦ Áö¿öÁָ鼭 rtl60.bpl¿¡·¯°¡ ³ª°Ô µÇ´ÂÇö»ó¶§¹®¿¡ ¼öÁ¤. TFont *srcFont; FNewFont = src->NewFont; if (FNewFont) { Font = new TFont; srcFont = src->GetFont(); Font->Assign(srcFont); /*if (!ReadFile(hFile, &charset, sizeof(TFontCharset), &dwRead, NULL)) return false; Font->Charset = charset; if (!ReadFile(hFile, &color, sizeof(TColor), &dwRead, NULL)) return false; Font->Color = color; if (!TextLoadFromFile(hFile, FName)) return false; Font->Name = FName; if (!ReadFile(hFile, &size, sizeof(int), &dwRead, NULL)) return false; Font->Size = size; if (!ReadFile(hFile, &fstyle, sizeof(TFontStyle), &dwRead, NULL)) return false; Font->Style = fstyle;*/ /* for Qe Copy¿¡·¯ ¼öÁ¤À» À§ÇØ. ¿Ö³Ä¸é Font¸¦ ¼±ÅÃµÈ »óÅ¿¡¼­ //Áö¿öÁÖ´Â ºÎºÐ¿¡¼­ ´Ù¸¥ ³à¼®ÀÇ font¸¦ Áö¿öÁָ鼭 rtl60.bpl¿¡·¯°¡ ³ª°Ô µÇ´ÂÇö»ó¶§¹®¿¡ ¼öÁ¤. } else { Font = Parent->GetFont(); //for Qe }*/ Align = src->Align; /* if (Type == detSignature || Type == detNumber || Type == detFormula || Type == detLabel || Type == detEdit || Type == detMemo || Type == detImage || Type == detTextImage) { À̰͵鿡 ÇØ´çÇÏ´Â Type¿¡ ´ëÇØ¼­¸¸ Background¸¦ º¹»çÇÑ´Ù. (2007. 07. 19 Annualring) */ // Copy¿¡¼­µµ ¼¿ ¹è°æ º¹»çµÇµµ·Ï ¼öÁ¤ (2007. 07. 19 Annualring) if (Type == detNumber || Type == detFormula || Type == detLabel || Type == detEdit || Type == detMemo || Type == detImage || Type == detDate) { Background = src->Background; } return true; } bool __fastcall TPDocText::TPDocTextSetFont(TPDocText *src){ SetFont(src->GetFont()); //for linuxjun /* TFont *srcFont; FNewFont = src->NewFont; if (FNewFont) { Font = new TFont; srcFont = src->GetFont(); Font->Assign(srcFont); } else { Font = Parent->GetFont(); } */ Align = src->Align; return true; } //--------------------------------------------------------------------------- /* void __fastcall TPDocText::PaintText(HDC hDC, TFont *font, RECT rc, double zoom, TPDocAlign Align, AnsiString Text, bool multiline) { HFONT hOldFont; TEXTMETRIC tm; int px, py, i = 0, cnt, l, len, tempFontSize; char *ch, *nch, *sp, *ep, *tp; WORD wAlign; tempFontSize = ResizeFont(zoom, font); hOldFont = (HFONT)SelectObject(hDC, font->Handle); SetBkMode(hDC, TRANSPARENT); wAlign = GetTextAlign(hDC); GetTextMetrics(hDC, &tm); SetTextColor(hDC, font->Color); if (Align != daCenterVertical) { switch (Align) { case daLeftTop: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = rc.top + 2; break; case daCenterTop: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = rc.top + 2; break; case daRightTop: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = rc.top + 2; break; case daLeftCenter: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daCenter2: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daRightCenter: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daLeftBottom: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = rc.bottom - tm.tmHeight - 2; break; case daCenterBottom: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = rc.bottom - tm.tmHeight - 2; break; case daRightBottom: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = rc.bottom - tm.tmHeight - 2; break; } if (!multiline) { // date, edit, label, number, formula... ExtTextOut(hDC, px, py, ETO_CLIPPED, &rc, Text.c_str(), Text.Length(), NULL); } else { // for only sheaflabel.... sp = Text.c_str(); // ÁٹٲÞÀ» ÇØÁÖ±â À§ÇÔ.. ep = sp; tp = strchr(ep, '\n'); while(tp != NULL) { len = tp - ep - 1; ExtTextOut(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); i++; ep = tp + 1; tp = strchr(ep, '\n'); } if (*ep) { // when text is not ended with null character!! len = Text.Length() - (ep - sp); ExtTextOut(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); } } } else { // ¼¼·Î ÀÔ·Â... SetTextAlign(hDC, TA_CENTER); ch = Text.c_str(); cnt = TextLength(ch); px = (rc.right + rc.left)/2; py = (rc.bottom + rc.top - cnt*tm.tmHeight)/2; i = 0; while(*ch) { nch = CharNext(ch); l = nch - ch; ExtTextOut(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ch, l, NULL); ch = nch; i++; } } SetTextAlign(hDC, wAlign); SelectObject(hDC, hOldFont); RestoreFont(tempFontSize, font); } //--------------------------------------------------------------------------- */ void __fastcall TPDocText::PaintText(HDC hDC, TFont *font, RECT rc, double zoom, TPDocAlign Align, WideString Text, bool multiline) { HFONT hOldFont; TEXTMETRIC tm; int px, py, i = 0, cnt, l, len, tempFontSize; wchar_t *ch, *nch, *sp, *ep, *tp; WORD wAlign; tempFontSize = ResizeFont(zoom, font); hOldFont = (HFONT)SelectObject(hDC, font->Handle); SetBkMode(hDC, TRANSPARENT); wAlign = GetTextAlign(hDC); GetTextMetrics(hDC, &tm); SetTextColor(hDC, font->Color); if (Align != daCenterVertical) { switch (Align) { case daLeftTop: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = rc.top + 2; break; case daCenterTop: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = rc.top + 2; break; case daRightTop: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = rc.top + 2; break; case daLeftCenter: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daCenter2: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daRightCenter: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daLeftBottom: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = rc.bottom - tm.tmHeight - 2; break; case daCenterBottom: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = rc.bottom - tm.tmHeight - 2; break; case daRightBottom: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = rc.bottom - tm.tmHeight - 2; break; } if (!multiline) { // date, edit, label, number, formula... ExtTextOutW(hDC, px, py, ETO_CLIPPED, &rc, Text.c_bstr(), Text.Length(), NULL); } else { // for only sheaflabel.... sp = Text.c_bstr(); // ÁٹٲÞÀ» ÇØÁÖ±â À§ÇÔ.. ep = sp; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); while(tp != NULL) { len = tp - ep - 1; ExtTextOutW(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); i++; ep = tp + 1; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); } if (*ep) { // when text is not ended with null character!! len = Text.Length() - (ep - sp); ExtTextOutW(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); } } } else { // ¼¼·Î ÀÔ·Â... SetTextAlign(hDC, TA_CENTER); ch = Text.c_bstr(); cnt = TextLength(ch); px = (rc.right + rc.left)/2; py = (rc.bottom + rc.top - cnt*tm.tmHeight)/2; i = 0; while(*ch) { nch = CharNextW(ch); l = nch - ch; ExtTextOutW(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ch, l, NULL); ch = nch; i++; } } SetTextAlign(hDC, wAlign); SelectObject(hDC, hOldFont); RestoreFont(tempFontSize, font); } //--------------------------------------------------------------------------- /* int __fastcall TPDocText::TextLength(char *ch) { int cnt = 0; while(*ch) { ch = CharNext(ch); cnt++; } return cnt; } //--------------------------------------------------------------------------- */ int __fastcall TPDocText::TextLength(wchar_t *ch) { int cnt = 0; while(*ch) { ch = CharNextW(ch); cnt++; } return cnt; } //--------------------------------------------------------------------------- void __fastcall TPDocText::PaintNumber(HDC hDC, TFont *Font, RECT rc, double zoom, TPDocAlign Align, double Number, int Precision, bool decimal) { AnsiString Text, fmt; TFraction *fract; int remainder, portion, value; //Precision 6Àº ºÐ¼ö Ç¥±â¹æ½Ä decimalÀ» false·Î ó¸®Çؼ­ ºÐ¼ö·Î º¯È¯ if(Precision == 6) decimal = false; if (decimal) { // ½ÊÁø¼ö Ç¥½Ã ¹æ¹ý if (Precision == 7) { //Integer value = (int)Number; Text = Format("%d", OPENARRAY(TVarRec, (value))); } else if (Precision) { fmt = Format("%%.%df", OPENARRAY(TVarRec, (Precision))); Text = Format(fmt, OPENARRAY(TVarRec, (Number))); } else { Text = Number; } } else { // ºÐ¼ö Ç¥½Ã ¹æ¹ý.. fract = new TFraction(100); fract->Value(Number); if (fract->denominator == 1) { value = (int)Number; Text = Format("%d", OPENARRAY(TVarRec, (value))); } else { portion = (int)(fract->numerator/fract->denominator); remainder = fract->numerator - portion*fract->denominator; if (Number >= 0 ) { // positive if (portion) { Text = Format("%d %d/%d", OPENARRAY(TVarRec, (portion, remainder, fract->denominator))); } else { Text = Format("%d/%d", OPENARRAY(TVarRec, (remainder, fract->denominator))); } } else { // negitive if (portion) { Text = Format("-%d %d/%d", OPENARRAY(TVarRec, (portion, remainder, fract->denominator))); } else{ Text = Format("-%d/%d", OPENARRAY(TVarRec, (remainder, fract->denominator))); } } } delete fract; } PaintText(hDC, Font, rc, zoom, Align, Text); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- TFont *__fastcall TPDocText::GetFont() { return Font; } //--------------------------------------------------------------------------- void __fastcall TPDocText::SetFont(TFont *font, TColor color) { if (font) { if (FNewFont) { Font->Assign(font); } else { Font = new TFont; Font->Assign(font); FNewFont = true; } // Font->Color = color; } else { // if (Font) delete Font; if (Font){ // if(Font!=Parent->GetFont())delete Font; //°¡²û ¹ß»ýÇÏ´Â Àâ±âÈûµç¿¡·¯ÀÇ ¿øÀÎ => ¾Æ·¡ÄÚµå·Î ¼öÁ¤. if(Font!=ParentFont)delete Font; } // Font = Parent->GetFont(); //°¡²û ¹ß»ýÇÏ´Â Àâ±âÈûµç¿¡·¯ÀÇ ¿øÀÎ => ¾Æ·¡ÄÚµå·Î ¼öÁ¤. /* Ç¥¸¦ ¸¸µçÈÄ Cell¿¡ Item¼³Á¤ÈÄ UndoÇÏ°í ´Ù½Ã Cell¿¡ Item¼³Á¤ÇÒ°æ¿ì Áö¿öÁö´Â font°¡ Parent->GetFont()·Î ³Ñ¾î¿À´Â // ¿¡·¯¸¦ ¼öÁ¤ÇϱâÀ§ÇØ ÁÖ¼® ¾Æ·¡ ÄÚµå·Î ¼öÁ¤ÇÔ. Font = Parent->GetFont(); ParentFont = Font; //*/ Font = ParentFont; FNewFont = false; } } //--------------------------------------------------------------------------- int __fastcall TPDocText::ResizeFont(double ratio, TFont *font) { int temp; if (font == NULL) font = Font; if (font) { if (font->Size > 0) { temp = font->Size; font->Size = int(temp * ratio); } else { temp = font->Height; font->Height = int(temp * ratio); } return temp; } else return 0; } //--------------------------------------------------------------------------- void __fastcall TPDocText::RestoreFont(int size, TFont *font) { if (font == NULL) font = Font; if (font) { if (font->Size > 0) font->Size = size; else font->Height = size; } } //--------------------------------------------------------------------------- // // TPDocNumber // //--------------------------------------------------------------------------- int TPDocNumber::FIDCount = 0; //--------------------------------------------------------------------------- /* __fastcall TPDocNumber::TPDocNumber(TPDocObject *Sender, RECT rc, TPDocAlign ta, int p, bool h, AnsiString n) : TPDocText(Sender, detNumber, rc, ta) { FID = ++FIDCount; ptrNumber = new AnsiString; Number = ""; bHasCommonData = false; FPrecision = p; FHide = h; Name = n; FDecimal = true; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; } //--------------------------------------------------------------------------- */ __fastcall TPDocNumber::TPDocNumber(TPDocObject *Sender, RECT rc, TPDocAlign ta, int p, bool h, WideString n) : TPDocText(Sender, detNumber, rc, ta) { FID = ++FIDCount; ptrNumber = new WideString; Number = ""; bHasCommonData = false; FPrecision = p; FHide = h; Name = n; FDecimal = true; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) TPDocSheet* docSheet; if (Parent != NULL && ((TPDocElement*)Parent)->Type == detChart) { docSheet = ((TPDocChart*)Parent)->GetParentSheet(); if (docSheet != NULL) { docSheet->NumberIDCount += 1; FID = docSheet->NumberIDCount; } } } //--------------------------------------------------------------------------- __fastcall TPDocNumber::~TPDocNumber() { if(!bHasCommonData){ delete ptrNumber; ptrNumber = NULL; } } //--------------------------------------------------------------------------- /* AnsiString __fastcall TPDocNumber::GetPtrNumber() { return *ptrNumber; } //--------------------------------------------------------------------------- */ WideString __fastcall TPDocNumber::GetPtrNumber() { return *ptrNumber; } //--------------------------------------------------------------------------- /* void __fastcall TPDocNumber::SetPtrNumber(AnsiString number) { *ptrNumber = number; } //--------------------------------------------------------------------------- */ void __fastcall TPDocNumber::SetPtrNumber(WideString number) { *ptrNumber = number; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetPrecision(int ivalue) { FPrecision = ivalue; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetHide(bool bvalue) { FHide = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetDecimal(bool decimal) { FDecimal = decimal; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetXIndex(int value) { FXIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetYIndex(int value) { FYIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocNumber::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; // paintID°¡ trueÀÌ¸é ¼ýÀÚ ¾È º¸¿©ÁÖ±â (2007. 08. 10 Annualring) if (!paintID) { PaintReport(Sender,hDC,vs,bPrint,bSelect,language); } // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; // HasValueÀÏ ¶§µµ paintIDÀÌ trueÀÌ¸é º¸¿©ÁÖ±â (2007. 08. 09 Annualring) if (paintID) { PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daLeftTop, Format("N%d", OPENARRAY(TVarRec, (FID)))); } if (NowSelect) PaintIn(hDC, rc); }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daLeftTop, Format("N%d", OPENARRAY(TVarRec, (FID)))); if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocNumber::HasValue() { if(Number.Length()) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocNumber::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { double num; if (!bPrint || !FHide) { if (Number.Length() > 0) { //float num = 0; if (TryStrToFloat(Number, num)){ if (FPrecision == 0) { //user define PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Number); } else { PaintNumber(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, num, FPrecision, FDecimal); } } else { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Number); } /* try { num = StrToFloat(Number); PaintNumber(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, num, FPrecision, FDecimal); } catch (EConvertError &ec) { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Number); } */ /*catch (Exception &ec){ PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Number); } */ } } RECT rc = ConvertRange(&vs); if (NowSelect){ PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- /* void __fastcall TPDocNumber::SetNumber(AnsiString value) { AnsiString format, ff; double dval; if (value.Length() > 0) { try { if (Precision) { ff = AnsiString::StringOfChar('0', Precision); format = "0."+ff; } else { format = "0"; } dval = StrToFloat(value); Number = FormatFloat(format, dval); } catch (EConvertError &ec) { Number = value; } } else { Number = value; } } //--------------------------------------------------------------------------- */ /// ÀÏÁ¤ ÀÌ»óÀÇ °ªÀÌ Number¿¡ µé¾î¿Ã °æ¿ì Â÷´ÜÇϱâ À§ÇØ ¸®ÅÏ Å¸ÀÔ bool·Î º¯°æ // (2007. 06. 15 Annualring) bool __fastcall TPDocNumber::SetNumber(WideString value) { WideString format, ff; double dval; bool rtnValue = true; if (value.Length() > 0) { if (Precision) { ff = WideString(AnsiString::StringOfChar('0', Precision)); format = "0."+ff; } else { format = "0"; } if (TryStrToFloat(value, dval)){ //dval = StrToFloat(value); if (Precision == 0) { //user define Number = value; } else { if (Precision == 7) format = "0"; //Integer Number = FormatFloat(format, dval); } if (value.Length() >= 10) { rtnValue = false; } } else { Number = value; } /* try { if (Precision) { ff = WideString(AnsiString::StringOfChar('0', Precision)); format = "0."+ff; } else { format = "0"; } dval = StrToFloat(value); Number = FormatFloat(format, dval); if (value.Length() >= 10) { rtnValue = false; } } catch (EConvertError &ec) { Number = value; } */ } else { Number = value; } return rtnValue; } //--------------------------------------------------------------------------- bool __fastcall TPDocNumber::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &FID, sizeof(int), &dwRead, NULL)) return false; if (Version <= 3) { // replace with AnsiString from Version 4 if (!ReadFile(hFile, &FNumber, sizeof(double), &dwRead, NULL)) return false; } if (!ReadFile(hFile, &FPrecision, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FHide, sizeof(bool), &dwRead, NULL)) return false; // if (Version == 3) { if (Version >= 3) { if (!ReadFile(hFile, &FDecimal, sizeof(bool), &dwRead, NULL)) return false; } if (!TextLoadFromFile(hFile, Name)) return false; if (Version >= 4) { if (!TextLoadFromFile(hFile, Number)) return false; } if (Version >= 6) { if (!ReadFile(hFile, &FIndex, sizeof(int), &dwRead, NULL)) return false; } return true; */ if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &FID, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FPrecision, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FHide, sizeof(bool), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FDecimal, sizeof(bool), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Name)) return false; //if (!TextLoadFromFile(hFile, Number)) return false; // AnsiString TempStr; WideString TempStr; if (!TextLoadFromFile(hFile, TempStr)) return false; Number = TempStr; if (Version >= 6) { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocNumber::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &FID, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FPrecision, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FHide, sizeof(bool), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FDecimal, sizeof(bool), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Name)) return false; if (!TextSaveToFile(hFile, Number)) return false; //AnsiString TempStr=Number; //blocked by linuxjun for save error asdf // if (!TextLoadFromFile(hFile, TempStr)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocNumber::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (sizeof(int) + sizeof(int) + sizeof(bool) + sizeof(bool) + sizeof(int) + TextGetAllocateSize(Name) + TextGetAllocateSize(Number)); return size; //ÀÌ»óÇÑ ºÎºÐ for Qe } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocNumber::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); memcpy(lp, &FID, sizeof(int)); lp += sizeof(int); memcpy(lp, &FPrecision, sizeof(int)); lp += sizeof(int); memcpy(lp, &FHide, sizeof(bool)); lp += sizeof(bool); memcpy(lp, &FDecimal, sizeof(bool)); lp += sizeof(bool); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, Number); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocNumber::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); memcpy(&FID, lp, sizeof(int)); lp += sizeof(int); memcpy(&FPrecision, lp, sizeof(int)); lp += sizeof(int); memcpy(&FHide, lp, sizeof(bool)); lp += sizeof(bool); memcpy(&FDecimal, lp, sizeof(bool)); lp += sizeof(bool); lp = TextCopyFromMemory(lp, Name); //lp = TextCopyFromMemory(lp, Number); // AnsiString TempString; WideString TempString; lp = TextCopyFromMemory(lp, TempString); Number = TempString; return lp; } //--------------------------------------------------------------------------- // Number, FormulaÀÇ CopyÇÔ¼ö ¼öÁ¤ (2007. 03. 27 Annualring) bool __fastcall TPDocNumber::Copy(TPDocNumber *src, bool bCopyID) { TPDocText::Copy((TPDocText *)src); // (2007. 03. 27 Annualring) if (bCopyID) { FID = src->ID; } FPrecision = src->Precision; FHide = src->Hide; FDecimal = src->Decimal; Name = src->Name; Number = src->Number; FXIndex = src->XIndex; FYIndex = src->YIndex; return true; } //--------------------------------------------------------------------------- // // TPDocFormula // //--------------------------------------------------------------------------- int TPDocFormula::FIDCount = 0; //--------------------------------------------------------------------------- /* __fastcall TPDocFormula::TPDocFormula(TPDocObject *Sender, RECT rc, TPDocAlign ta, int p, bool h, AnsiString n, AnsiString f) : TPDocText(Sender, detFormula, rc, ta) { FID = ++FIDCount; FPrecision = p; FHide = h; Name = n; Formula = f; FDecimal = true; ptrANumber = new AnsiString; ANumber = ""; bHasCommonData = false; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; // Data = new bool; //added by k3dogs(20001029) formula¿¡¼­ ÀÚµ¿ °è»ê ÈÄ °³°³ÀÇ formula->ANumber¼öÁ¤ÇÒ ¼ö ÀÖ°Ô Ãß°¡. //boundary check¿¡¼­ ¸Þ¸ð¸®°¡ ¼¾´Ù°í ÇØ¼­¸®. Data = false; //ÃʱâÈ­.. trueÀÌ¸é ¼öÁ¤µÈ °ÍÀ¸·Î ÀÚµ¿°è»ê¿¡¼­ Á¦¿ÜµÈ´Ù. } //--------------------------------------------------------------------------- */ __fastcall TPDocFormula::TPDocFormula(TPDocObject *Sender, RECT rc, TPDocAlign ta, int p, bool h, WideString n, WideString f) : TPDocText(Sender, detFormula, rc, ta) { FID = ++FIDCount; FPrecision = p; FHide = h; Name = n; Formula = f; FDecimal = true; ptrANumber = new WideString; ANumber = ""; bHasCommonData = false; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; // Data = new bool; //added by k3dogs(20001029) formula¿¡¼­ ÀÚµ¿ °è»ê ÈÄ °³°³ÀÇ formula->ANumber¼öÁ¤ÇÒ ¼ö ÀÖ°Ô Ãß°¡. //boundary check¿¡¼­ ¸Þ¸ð¸®°¡ ¼¾´Ù°í ÇØ¼­¸®. Data = false; //ÃʱâÈ­.. trueÀÌ¸é ¼öÁ¤µÈ °ÍÀ¸·Î ÀÚµ¿°è»ê¿¡¼­ Á¦¿ÜµÈ´Ù. // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) TPDocSheet* docSheet; if (Parent != NULL && ((TPDocElement*)Parent)->Type == detChart) { docSheet = ((TPDocChart*)Parent)->GetParentSheet(); if (docSheet != NULL) { docSheet->FormulaIDCount += 1; FID = docSheet->FormulaIDCount; } } } //--------------------------------------------------------------------------- __fastcall TPDocFormula::~TPDocFormula() { if(!bHasCommonData){ delete ptrANumber; ptrANumber = NULL; } } //--------------------------------------------------------------------------- /* AnsiString __fastcall TPDocFormula::GetPtrANumber() { return *ptrANumber; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetPtrANumber(AnsiString aNumber) { *ptrANumber = aNumber; } //--------------------------------------------------------------------------- */ WideString __fastcall TPDocFormula::GetPtrANumber() { return *ptrANumber; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetPtrANumber(WideString aNumber) { *ptrANumber = aNumber; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetPrecision(int ivalue) { FPrecision = ivalue; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetHide(bool bvalue) { FHide = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetDecimal(bool decimal) { FDecimal = decimal; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetXIndex(int value) { FXIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetYIndex(int value) { FYIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocFormula::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; // paintID°¡ trueÀÌ¸é ¼ýÀÚ ¾È º¸¿©ÁÖ±â (2007. 08. 10 Annualring) if (!paintID) { PaintReport(Sender,hDC,vs,bPrint,bSelect,language); } // if (NowSelect) PaintIn(hDC, rc); // HasValueÀÏ ¶§µµ paintIDÀÌ trueÀÌ¸é º¸¿©ÁÖ±â (2007. 08. 09 Annualring) if (paintID) { PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daLeftTop, Format("F%d", OPENARRAY(TVarRec, (FID)))); } NowSelect = TempSelect; if (NowSelect) PaintIn(hDC, rc); }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daLeftTop, Format("F%d", OPENARRAY(TVarRec, (FID)))); if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocFormula::HasValue() { if( ANumber.Length()>0 || Formula.Length()>0 ) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocFormula::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { double num; // AnsiString temp; WideString temp; if (!bPrint || !FHide) { if (Formula.Length() > 0) { num = ((TPDocSheet *)Sender)->Calculation(Formula); temp = FloatToStr(num); SetNumber(temp); PaintNumber(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, num, FPrecision, FDecimal); } else { if (ANumber.Length() > 0) { if (TryStrToFloat(ANumber, num)){ PaintNumber(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, num, FPrecision, FDecimal); } else { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, ANumber); } /* try { num = StrToFloat(ANumber); PaintNumber(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, num, FPrecision, FDecimal); } catch (EConvertError &ec) { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, ANumber); } */ } } } RECT rc = ConvertRange(&vs); if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- /* void __fastcall TPDocFormula::SetNumber(AnsiString value) { AnsiString format, ff; double dval; int ival; if (value.Length() > 0) { try { if (Precision) { ff = AnsiString::StringOfChar('0', Precision); format = "0."+ff; } else { format = "0"; } dval = StrToFloat(value); ANumber = FormatFloat(format, dval); } catch (EConvertError &ec) { ANumber = value; } } else { ANumber = value; } } //--------------------------------------------------------------------------- */ void __fastcall TPDocFormula::SetNumber(WideString value) { WideString format, ff; double dval; int ival; if (value.Length() > 0) { if (Precision) { ff = WideString(AnsiString::StringOfChar('0', Precision)); format = "0."+ff; } else { format = "0"; } if (TryStrToFloat(value, dval)){ ANumber = FormatFloat(format, dval); } else { ANumber = value; } /* dval = StrToFloat(value); ANumber = FormatFloat(format, dval); try { if (Precision) { ff = WideString(AnsiString::StringOfChar('0', Precision)); format = "0."+ff; } else { format = "0"; } dval = StrToFloat(value); ANumber = FormatFloat(format, dval); } catch (EConvertError &ec) { ANumber = value; } */ } else { ANumber = value; } } //--------------------------------------------------------------------------- bool __fastcall TPDocFormula::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &FID, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Formula)) return false; if (!ReadFile(hFile, &FPrecision, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FHide, sizeof(bool), &dwRead, NULL)) return false; // if (Version == 3) { if (Version >= 3) { if (!ReadFile(hFile, &FDecimal, sizeof(bool), &dwRead, NULL)) return false; } if (!TextLoadFromFile(hFile, Name)) return false; if (Version >= 4) { if (!TextLoadFromFile(hFile, ANumber)) return false; } if (Version >= 6) { if (!ReadFile(hFile, &FIndex, sizeof(int), &dwRead, NULL)) return false; } return true; */ if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &FID, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Formula)) return false; if (!ReadFile(hFile, &FPrecision, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FHide, sizeof(bool), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FDecimal, sizeof(bool), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Name)) return false; //if (!TextLoadFromFile(hFile, ANumber)) return false; // AnsiString TempStr; WideString TempStr; if (!TextLoadFromFile(hFile, TempStr)) return false; ANumber = TempStr; if (Version >= 6) { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; } if (Version >= 7) { //by k3dogs formula ÀÚµ¿°è»ê ÈÄ formula->ANumber º¯°æ¿©ºÎ ÀúÀå. if (!ReadFile(hFile, &Data, sizeof(bool), &dwRead, NULL)) return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocFormula::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &FID, sizeof(int), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Formula)) return false; if (!WriteFile(hFile, &FPrecision, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FHide, sizeof(bool), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FDecimal, sizeof(bool), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Name)) return false; //if (!TextSaveToFile(hFile, ANumber)) return false; // AnsiString TempStr=ANumber; WideString TempStr=ANumber; if (!TextSaveToFile(hFile, TempStr)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Data, sizeof(bool), &dwWrite, NULL)) return false; //by k3dogs return true; } //--------------------------------------------------------------------------- int __fastcall TPDocFormula::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); //size of inºüÁü. ´Ù½Ã ä¿ö³ÖÀ½. for Qe size += (sizeof(int) + TextGetAllocateSize(Formula) + sizeof(int) + sizeof(bool) + sizeof(bool) + TextGetAllocateSize(Name) + TextGetAllocateSize(ANumber) + sizeof(bool)); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocFormula::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); memcpy(lp, &FID, sizeof(int)); lp += sizeof(int); lp = TextCopyToMemory(lp, Formula); memcpy(lp, &FPrecision, sizeof(int)); lp += sizeof(int); memcpy(lp, &FHide, sizeof(bool)); lp += sizeof(bool); memcpy(lp, &FDecimal, sizeof(bool)); lp += sizeof(bool); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, ANumber); memcpy(lp, &Data, sizeof(bool)); lp += sizeof(bool); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocFormula::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); memcpy(&FID, lp, sizeof(int)); lp += sizeof(int); lp = TextCopyFromMemory(lp, Formula); memcpy(&FPrecision, lp, sizeof(int)); lp += sizeof(int); memcpy(&FHide, lp, sizeof(bool)); lp += sizeof(bool); memcpy(&FDecimal, lp, sizeof(bool)); lp += sizeof(bool); lp = TextCopyFromMemory(lp, Name); //lp = TextCopyFromMemory(lp, ANumber); // AnsiString TempString; WideString TempString; lp = TextCopyFromMemory(lp, TempString); ANumber = TempString; memcpy(&Data, lp, sizeof(bool)); lp += sizeof(bool); return lp; } //--------------------------------------------------------------------------- // Number, FormulaÀÇ CopyÇÔ¼ö ¼öÁ¤ (2007. 03. 27 Annualring) bool __fastcall TPDocFormula::Copy(TPDocFormula *src, bool bCopyID) { TPDocText::Copy((TPDocText *)src); // (2007. 03. 27 Annualring) if (bCopyID) { FID = src->ID; } Formula = src->Formula; FPrecision = src->Precision; FHide = src->Hide; FDecimal = src->Decimal; Name = src->Name; ANumber = src->ANumber; FXIndex = src->XIndex; FYIndex = src->YIndex; Data = src->Data; return true; } //--------------------------------------------------------------------------- // // TPDocDate // //--------------------------------------------------------------------------- int TPDocDate::FIDCount = 0; //--------------------------------------------------------------------------- /*__fastcall TPDocDate::TPDocDate(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString n) : TPDocText(Sender, detDate, rc, ta) { ptrDate = new AnsiString; Date = ""; bHasCommonData = false; Name = n; FXIndex= -1; bFXIndex = false; FYIndex= -1; bFYIndex = false; } __fastcall TPDocDate::~TPDocDate(){ if(!bHasCommonData){ delete ptrDate; ptrDate = NULL; } } //--------------------------------------------------------------------------- */ __fastcall TPDocDate::TPDocDate(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString n) : TPDocText(Sender, detDate, rc, ta) { FID = ++FIDCount; ptrDate = new WideString; Date = ""; bHasCommonData = false; bHasReference = false; Name = n; FXIndex= -1; bFXIndex = false; FYIndex= -1; bFYIndex = false; DateFormat = 0; dateTime = dateTime.CurrentDate(); DateDifference = 0; ReferenceDate = ""; // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) TPDocSheet* docSheet; if (Parent != NULL && ((TPDocElement*)Parent)->Type == detChart) { docSheet = ((TPDocChart*)Parent)->GetParentSheet(); if (docSheet != NULL) { docSheet->DateIDCount += 1; FID = docSheet->DateIDCount; } //date type ¼¿À» paint ÇÒ ¶§ ³â, ¿ù, ÀÏÀ» ´Ù¸¥ ¾ð¾îÀÏ ¶§µµ Ç¥½ÃÇϱâ À§ÇØ FYearText = docSheet->Sheaf->SheafReportDoc->YearText; FMonthText = docSheet->Sheaf->SheafReportDoc->MonthText; FDayText = docSheet->Sheaf->SheafReportDoc->DayText; } } __fastcall TPDocDate::~TPDocDate(){ if(!bHasCommonData){ delete ptrDate; ptrDate = NULL; } } //--------------------------------------------------------------------------- /* AnsiString __fastcall TPDocDate::GetPtrDate() { return *ptrDate; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::SetPtrDate(AnsiString date) { *ptrDate = date; } //--------------------------------------------------------------------------- */ WideString __fastcall TPDocDate::GetPtrDate() { return *ptrDate; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::SetPtrDate(WideString date) { *ptrDate = date; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocDate::SetXIndex(int value) { FXIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::SetYIndex(int value) { FYIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- WideString __fastcall TPDocDate::SetDateFormat(TDateTime datetime) { //Date Çü½Ä¿¡ ¸Â´Â StringÀ» ¹Ýȯ switch(DateFormat){ case 0: return WideString((datetime+DateDifference).FormatString("yyyy/m/d")); case 1: return WideString((datetime+DateDifference).FormatString("yyyy'/'m'/'d")); case 2: return WideString((datetime+DateDifference).FormatString("yyyy") + FYearText + " " + (datetime+DateDifference).FormatString("m") + FMonthText + " " + (datetime+DateDifference).FormatString("dd") + FDayText); case 3: return WideString((datetime+DateDifference).FormatString("yy/m/d")); case 4: return WideString((datetime+DateDifference).FormatString("yy'/'m'/'d")); case 5: return WideString((datetime+DateDifference).FormatString("yy") + FYearText + " " + (datetime+DateDifference).FormatString("m") + FMonthText + " " + (datetime+DateDifference).FormatString("dd") + FDayText); case 6: return WideString((datetime+DateDifference).FormatString("m/d")); case 7: return WideString((datetime+DateDifference).FormatString("m'/'d")); case 8: return WideString((datetime+DateDifference).FormatString("m") + FMonthText + " " + (datetime+DateDifference).FormatString("dd") + FDayText); case 9: return WideString((datetime+DateDifference).FormatString("m'/'d'/'yy")); case 10: return WideString((datetime+DateDifference).FormatString("mm'/'dd'/'yy")); default: break; } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocDate::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocDate::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; if (!paintID){ PaintReport(Sender,hDC,vs,bPrint,bSelect,language); } // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; if(paintID){ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daLeftTop, Format("D%d", OPENARRAY(TVarRec, (FID)))); } if (NowSelect) PaintIn(hDC, rc); }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daLeftTop, Format("D%d", OPENARRAY(TVarRec, (FID)))); //PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daCenter2, (WideString) "Date"); if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocDate::HasValue() { if(Date.Length()) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocDate::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { TDateTime* ref; WideString pDate; if(this->bHasReference) { ref = (TDateTime*) ((TPDocSheet*) Sender)->GetDateFromString(this->ReferenceDate); if(ref) pDate = SetDateFormat(*ref); else pDate = "ERROR"; } else { pDate = SetDateFormat(dateTime); } PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, daCenter2, pDate); RECT rc = ConvertRange(&vs); if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocDate::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (Version <= 3) { if (!ReadFile(hFile, &Time, sizeof(SYSTEMTIME), &dwRead, NULL)) return false; } else if (Version >= 4) { if (!TextLoadFromFile(hFile, Date)) return false; } if (!TextLoadFromFile(hFile, Name)) return false; if (Version >= 5) if (!ReadFile(hFile, &FIndex, sizeof(int), &dwRead, NULL)) return false; return true; */ if (!TPDocText::LoadFromFile(hFile, Version)) return false; //if (!TextLoadFromFile(hFile, Date)) return false; // AnsiString TempStr; WideString TempStr; if (!TextLoadFromFile(hFile, TempStr)) return false; Date = TempStr; if (!TextLoadFromFile(hFile, Name)) return false; if (!ReadFile(hFile, &FID, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) { if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; } if(Version > 17){ if (!ReadFile(hFile, &DateFormat, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &bHasReference, sizeof(bool), &dwRead, NULL)) return false; if (!ReadFile(hFile, &dateTime, sizeof(TDateTime), &dwRead, NULL)) return false; if (!ReadFile(hFile, &DateDifference, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, ReferenceDate)) return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocDate::SaveToFile(HANDLE hFile) { if (SaveVersion < 18) return false; DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; //if (!TextSaveToFile(hFile, Date)) return false; // Version >= 4 // AnsiString TempStr = Date; WideString TempStr = Date; if (!TextSaveToFile(hFile, TempStr)) return false; // Version >= 4 if (!TextSaveToFile(hFile, Name)) return false; if (!WriteFile(hFile, &FID, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &DateFormat, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &bHasReference , sizeof(bool), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &dateTime, sizeof(TDateTime), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &DateDifference, sizeof(int), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, ReferenceDate)) return false; // Version >= 4 return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocDate::Copy(TPDocDate *src, bool bCopyID) { TPDocText::Copy((TPDocText *)src); if (bCopyID){ FID = src->ID; } Date = src->Date; Name = src->Name; FXIndex = src->XIndex; FYIndex = src->YIndex; dateTime = src->dateTime; DateFormat = src->DateFormat; bHasReference = src->bHasReference; DateDifference = src->DateDifference; ReferenceDate = src->ReferenceDate; return true; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocDate::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); memcpy(lp, &FID, sizeof(int)); lp += sizeof(int); memcpy(lp, &bHasReference, sizeof(bool)); lp += sizeof(bool); memcpy(lp, &dateTime, sizeof(TDateTime)); lp += sizeof(TDateTime); memcpy(lp, &DateFormat, sizeof(int)); lp += sizeof(int); memcpy(lp, &DateDifference, sizeof(int)); lp += sizeof(int); lp = TextCopyToMemory(lp, ReferenceDate); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, Date); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocDate::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); memcpy(&FID, lp, sizeof(int)); lp += sizeof(int); memcpy(&bHasReference, lp, sizeof(bool)); lp += sizeof(bool); memcpy(&dateTime, lp, sizeof(TDateTime)); lp += sizeof(TDateTime); memcpy(&DateFormat, lp, sizeof(int)); lp += sizeof(int); memcpy(&DateDifference, lp, sizeof(int)); lp += sizeof(int); lp = TextCopyFromMemory(lp, ReferenceDate); lp = TextCopyFromMemory(lp, Name); WideString TempString; lp = TextCopyFromMemory(lp, TempString); Date = TempString; return lp; } //--------------------------------------------------------------------------- TDateTime __fastcall TPDocDate::GetDateFromString(TObject *Sender, AnsiString ReferenceDate) { TDateTime* datetime = (TDateTime*) ((TPDocSheet*) Sender)->GetDateFromString(this->ReferenceDate); if(datetime) return *datetime; else return TDateTime().CurrentDateTime(); } //--------------------------------------------------------------------------- int __fastcall TPDocDate::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (sizeof(int) + sizeof(bool) + sizeof(TDateTime) + sizeof(int) + sizeof(int) + TextGetAllocateSize(ReferenceDate) + TextGetAllocateSize(Name) + TextGetAllocateSize(Date)) ; return size; } //--------------------------------------------------------------------------- // // TPDocImage // //--------------------------------------------------------------------------- /* __fastcall TPDocImage::TPDocImage(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString str) : TPDocText(Sender, detImage, rc, ta) { Image = NULL; ImgTitle = str; bImageChanged = false; } //--------------------------------------------------------------------------- */ __fastcall TPDocImage::TPDocImage(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString str, WideString n) : TPDocText(Sender, detImage, rc, ta) { Image = new TTexpiaBitmap; Name = n; ImgTitle = str; bHasCommonData = false; bImageChanged = false; bCopyFromClipboard = false; iFileLoad = 0; } //--------------------------------------------------------------------------- __fastcall TPDocImage::~TPDocImage() { if (Image) delete Image; Image = NULL; } //--------------------------------------------------------------------------- void __fastcall TPDocImage::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { if (ImgTitle.Length() > 0) { PaintText(hDC, Font, rc, t, Align, ImgTitle); } PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocImage::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocImage::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; TSize s; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() && (Image->Width != 0 && Image->Height != 0)){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; if (NowSelect) PaintIn(hDC, rc); }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daCenter2, (WideString)"Image"); if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocImage::HasValue() { if(Image) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocImage::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; TSize s; int th = 0; HFONT hOldFont; TEXTMETRIC tm; double r; r = (double)vs.ZoomIn / vs.ZoomOut; if (Image) { if (ImgTitle != (WideString) "") { hOldFont = (HFONT)SelectObject(hDC, Font->Handle); GetTextMetrics(hDC, &tm); th = tm.tmHeight; SelectObject(hDC, hOldFont); } rc = ConvertRange(&vs); s.cx = rc.right - rc.left - 6 * r; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - th * r - 6 * r; if(Image != NULL) PaintImage(hDC, Image, s, rc.left + 3*r, rc.top + th*r + 3*r); } rc = ConvertRange(&vs); if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocImage::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &Zoom, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Align, sizeof(TPDocAlign), &dwRead, NULL)) return false; if(Version > 17){ if (!TextLoadFromFile(hFile, Name)) return false; } if (!TextLoadFromFile(hFile, ImgTitle)) return false; if (!TextLoadFromFile(hFile, ImgDir)) return false; if (!ImageLoadFromFile(hFile, Image)) return false; bCopyFromClipboard = false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocImage::SaveToFile(HANDLE hFile) { DWORD dwWrite; TTexpiaBitmap *ImageToSave = NULL; if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &Zoom, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Align, sizeof(TPDocAlign), &dwWrite, NULL)) return false; if (SaveVersion > 17) { if (!TextSaveToFile(hFile, Name)) return false; } if (!TextSaveToFile(hFile, ImgTitle)) return false; if (!TextSaveToFile(hFile, ImgDir)) return false; if (!ImageCopy(ImageToSave,Image)) return false; // À̹ÌÁö Å©±â¸¦ ÁÙÀ̱â À§Çؼ­ Ãß°¡ (bSaveAsSmallImage°¡ trueÀ̸é ÀÛ°Ô º¯°æÇؼ­ ÀúÀå) by altang 07.04.16. if(bSaveAsSmallImage){ if(Image!=NULL &&(Image->Width != 0 && Image->Height != 0)) ImageToSave->ResizeStretch(ImageToSave->Handle->Width * Image->BitmapRatio, ImageToSave->Handle->Height * Image->BitmapRatio,true); if (!ImageSaveToFile(hFile, ImageToSave, bCopyFromClipboard)) return false; } else if (!ImageSaveToFile(hFile, ImageToSave, bCopyFromClipboard)) return false; delete ImageToSave; ImageToSave = NULL; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocImage::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (sizeof(int) + sizeof(TPDocAlign) + TextGetAllocateSize(Name) + TextGetAllocateSize(ImgTitle) + TextGetAllocateSize(ImgDir) + ImageGetAllocateSize(Image)); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocImage::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); memcpy(lp, &Zoom, sizeof(int)); lp += sizeof(int); memcpy(lp, &Align, sizeof(TPDocAlign)); lp += sizeof(TPDocAlign); memcpy(lp, &bCopyFromClipboard, sizeof(bool)); lp += sizeof(bool); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, ImgTitle); lp = TextCopyToMemory(lp, ImgDir); lp = ImageCopyToMemory(lp, Image); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocImage::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); memcpy(&Zoom, lp, sizeof(int)); lp += sizeof(int); memcpy(&Align, lp, sizeof(TPDocAlign)); lp += sizeof(TPDocAlign); memcpy(&bCopyFromClipboard, lp, sizeof(bool)); lp += sizeof(bool); lp = TextCopyFromMemory(lp, Name); lp = TextCopyFromMemory(lp, ImgTitle); lp = TextCopyFromMemory(lp, ImgDir); lp = ImageCopyFromMemory(lp, Image); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocImage::Copy(TPDocImage *src, bool bCopyID) { TPDocText::Copy((TPDocText *)src); Zoom = src->Zoom; Align = src->Align; if (bCopyID) { Name = src->Name; } ImgTitle = src->ImgTitle; ImgDir = src->ImgDir; if (!ImageCopy(Image, src->Image)) return false; if(src->bCopyFromClipboard){ L_FlipBitmap(Image->Handle); src->bCopyFromClipboard = false; } return true; } //--------------------------------------------------------------------------- // // TPDocSignature // //--------------------------------------------------------------------------- __fastcall TPDocSignature::TPDocSignature(TPDocObject *Sender, RECT rc) : TPDocElement(detSignature, rc) { Parent = Sender; Image = NULL; } //--------------------------------------------------------------------------- __fastcall TPDocSignature::~TPDocSignature() { if (Image) delete Image; Image = NULL; } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocSignature::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocSignature::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocSignature::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; TSize s; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; if (NowSelect) PaintIn(hDC, rc); }else{ if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocSignature::HasValue() { if(Image) return true; return false; } //--------------- ------------------------------------------------------------ void __fastcall TPDocSignature::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { int tw = 0, sw = 0; RECT rc; TSize s; double r; r = (double)vs.ZoomIn / vs.ZoomOut; sw = CheckFrame(); if (sw > 0) tw = 2*sw - 1; if (Image) { rc = ConvertRange(&vs); s.cx = rc.right - rc.left - tw * r; s.cy = rc.bottom - rc.top - tw * r; PaintImage(hDC, Image, s, rc.left + sw * r, rc.top + sw * r); } // if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocSignature::LoadFromFile(HANDLE hFile, int Version) { if (!ImageLoadFromFile(hFile, Image)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSignature::SaveToFile(HANDLE hFile) { if (!ImageSaveToFile(hFile, Image)) return false; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocSignature::GetAllocateSize() { int size = 0; size += ImageGetAllocateSize(Image); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocSignature::CopyToMemory(BYTE *lp) { lp = ImageCopyToMemory(lp, Image); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocSignature::CopyFromMemory(BYTE *lp) { lp = ImageCopyFromMemory(lp, Image); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocSignature::Copy(TPDocSignature *src) { /* if (Type == detSignature || Type == detNumber || Type == detFormula || Type == detLabel || Type == detEdit || Type == detMemo || Type == detImage || Type == detTextImage) { À̰͵鿡 ÇØ´çÇÏ´Â Type¿¡ ´ëÇØ¼­¸¸ Background¸¦ º¹»çÇÑ´Ù. (2007. 07. 19 Annualring) */ // Copy¿¡¼­µµ ¼¿ ¹è°æ º¹»çµÇµµ·Ï ¼öÁ¤ (2007. 07. 19 Annualring) Background = src->Background; if (!ImageCopy(Image, src->Image)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSignature::MakeBitmap() { int tw = 0, ww, hh; RECT rt; tw = CheckFrame(); if (tw > 0) tw = 2*tw - 1; ww = Range.right-Range.left - tw; hh = Range.bottom-Range.top - tw; rt = Rect(0, 0, ww, hh); if (Image == NULL) { if ((Image = new TTexpiaBitmap) == NULL) goto fail; if (!Image->Create(ww, hh, 24)) goto fail; } Image->FillRect(rt, clWhite); return true; fail: if (Image) { delete Image; Image = NULL; } return false; } //--------------------------------------------------------------------------- void __fastcall TPDocSignature::DrawLine(POINT sp, POINT ep) { HPEN hPen = NULL, hOldPen = NULL; HDC hDC = NULL; RECT rt = ConvertRange(); if (Image) { if (CheckRange(sp, ep)) { try { hDC = Image->CreateDC(); hPen = CreatePen(psSolid, 2, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); MoveToEx(hDC, sp.x-rt.left, sp.y-rt.top, NULL); LineTo(hDC, ep.x-rt.left, ep.y-rt.top); } __finally { if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); if (hDC) Image->DeleteDC(hDC); } } } } //--------------------------------------------------------------------------- bool __fastcall TPDocSignature::CheckRange(POINT sp, POINT ep) { int tw = 0; RECT rt; rt = ConvertRange(); tw = CheckFrame(); if (tw > 0) rt = Rect(rt.left+tw, rt.top+tw, rt.right-tw+1, rt.bottom-tw+1); if ((sp.x < rt.left) || (sp.x >= rt.right) || (sp.y < rt.top) || (sp.y >= rt.bottom)) { return false; } if ((ep.x < rt.left) || (ep.x >= rt.right) || (ep.y < rt.top) || (ep.y >= rt.bottom)) { return false; } return true; } //--------------------------------------------------------------------------- int __fastcall TPDocSignature::CheckFrame() { /* int tw = 0; switch(FrameStyle) { // ÇÁ·¹ÀÓÀÌ Àִ°æ¿ì ±×¸¸Å­ ±×·ÁÁÙ ¼ö ÀÖ´Â ¿µ¿ªÀÌ ÁÙ¾îµé±â¶§¹®¿¡.. case dlsOne: tw = 2; break; case dlsTwo: tw = 5; break; case dlsHeavy: tw = 4; break; } return tw;*/ return 5; } //--------------------------------------------------------------------------- // // TPDocLabel // //--------------------------------------------------------------------------- /* __fastcall TPDocLabel::TPDocLabel(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString t) : TPDocText(Sender, detLabel, rc, ta) { Text = t; bSaveToJPG = false; } //--------------------------------------------------------------------------- */ // by altang __fastcall TPDocLabel::TPDocLabel(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString t) : TPDocText(Sender, detLabel, rc, ta) { Text = t; bSaveToJPG = false; } // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocLabel::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { /*//for ¾ÆÀ̺ñ 2005.6.15 if (Text.Length() > 0) { PaintText(hDC, Font, rc, t, Align, Text); } */ PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocLabel::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocLabel::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); // if(bSaveToJPG)//for ¾ÆÀ̺ñ 2005.6.15//»ö±ò¹Ù²ãÁÙ ºÎºÐ//FrameColor PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; if (NowSelect) PaintIn(hDC, rc); }else{ if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocLabel::HasValue() { if(Text.Length()) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocLabel::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc = ConvertRange(&vs); if(!bSaveJPG||!bSaveToJPG){ //for ¾ÆÀ̺ñ 2005.6.15 if (Text.Length() > 0) { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Text); } } if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocLabel::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if(Version>=13){//for ¾ÆÀ̺ñ 2005.6.15 if (!ReadFile(hFile, &bSaveToJPG, sizeof(bool), &dwRead, NULL)) return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocLabel::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!WriteFile(hFile, &bSaveToJPG, sizeof(bool), &dwWrite, NULL)) return false;//for ¾ÆÀ̺ñ 2005.6.15 return true; } //--------------------------------------------------------------------------- int __fastcall TPDocLabel::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += TextGetAllocateSize(Text); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocLabel::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); lp = TextCopyToMemory(lp, Text); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocLabel::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, Text); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocLabel::Copy(TPDocLabel *src) { TPDocText::Copy((TPDocText *)src); Text = src->Text; return true; } //--------------------------------------------------------------------------- // // TPDocEdit // //--------------------------------------------------------------------------- /* __fastcall TPDocEdit::TPDocEdit(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString n) : TPDocText(Sender, detEdit, rc, ta) { Name = n; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; ptrK_Text = new AnsiString; ptrE_Text = new AnsiString; ptrI_Text = new AnsiString; ptrC_Text = new AnsiString; ptrJ_Text = new AnsiString; bHasCommonData = false; bSaveToJPG = false;//for ¾ÆÀ̺ñ 2005.6.15 // Unicode Å×½ºÆ® ¿ë Àӽà ÄÚµå (2007. 03. 16 Annualring) //AnsiString chineseCharset = "CHINESEBIG5_CHARSET"; //this->Font->Charset = CHINESEBIG5_CHARSET; } */ // by altang //--------------------------------------------------------------------------- __fastcall TPDocEdit::TPDocEdit(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString n) : TPDocText(Sender, detEdit, rc, ta) { Name = n; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; ptrK_Text = new WideString; ptrE_Text = new WideString; ptrI_Text = new WideString; ptrC_Text = new WideString; ptrJ_Text = new WideString; bHasCommonData = false; bSaveToJPG = false;//for ¾ÆÀ̺ñ 2005.6.15 // Unicode Å×½ºÆ® ¿ë Àӽà ÄÚµå (2007. 03. 16 Annualring) //AnsiString chineseCharset = "CHINESEBIG5_CHARSET"; //this->Font->Charset = CHINESEBIG5_CHARSET; } //--------------------------------------------------------------------------- __fastcall TPDocEdit::~TPDocEdit(){ //by altang if(!bHasCommonData) { /* delete ptrK_Text; ptrK_Text = NULL; delete ptrE_Text; ptrE_Text = NULL; delete ptrI_Text; ptrI_Text = NULL; delete ptrC_Text; ptrC_Text = NULL; delete ptrJ_Text; ptrJ_Text = NULL; */ delete ptrK_Text; ptrK_Text = NULL; delete ptrE_Text; ptrE_Text = NULL; delete ptrI_Text; ptrI_Text = NULL; delete ptrC_Text; ptrC_Text = NULL; delete ptrJ_Text; ptrJ_Text = NULL; }else{ //Remark CommonData ÁÖÀÇ »çÇ×. //ÀÌ»óÇÔ K_Text¸¸ CommonData·Î ¾¸ ±×·¯¹Ç·Î E,I,C,J_TextÀÇ ³»¿ëÀº CommonData°¡ //¼³Á¤µÇÀÖ´õ¶óµµ deleteÇØÁÖ¾î¾ß ÇÔ. /* delete ptrE_Text; ptrE_Text = NULL; delete ptrI_Text; ptrI_Text = NULL; delete ptrC_Text; ptrC_Text = NULL; delete ptrJ_Text; ptrJ_Text = NULL; */ delete ptrE_Text; ptrE_Text = NULL; delete ptrI_Text; ptrI_Text = NULL; delete ptrC_Text; ptrC_Text = NULL; delete ptrJ_Text; ptrJ_Text = NULL; } } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocEdit::Set_K_Text(WideString kt){ *ptrK_Text = kt; } void __fastcall TPDocEdit::Set_E_Text(WideString et){ *ptrE_Text = et; } void __fastcall TPDocEdit::Set_I_Text(WideString it) { *ptrI_Text = it; } void __fastcall TPDocEdit::Set_C_Text(WideString ct) { *ptrC_Text = ct; } void __fastcall TPDocEdit::Set_J_Text(WideString jt) { *ptrJ_Text = jt; } // ---------------------------------------------------------- /* AnsiString __fastcall TPDocEdit::Get_K_Text() { return *ptrK_Text; } AnsiString __fastcall TPDocEdit::Get_E_Text() { return *ptrE_Text; } AnsiString __fastcall TPDocEdit::Get_I_Text() { return *ptrI_Text; } AnsiString __fastcall TPDocEdit::Get_C_Text() { return *ptrC_Text; } AnsiString __fastcall TPDocEdit::Get_J_Text() { return *ptrJ_Text; } */ // ----------------------- for unicode by altang WideString __fastcall TPDocEdit::Get_K_Text() { return *ptrK_Text; } WideString __fastcall TPDocEdit::Get_E_Text() { return *ptrE_Text; } WideString __fastcall TPDocEdit::Get_I_Text() { return *ptrI_Text; } WideString __fastcall TPDocEdit::Get_C_Text() { return *ptrC_Text; } WideString __fastcall TPDocEdit::Get_J_Text() { return *ptrJ_Text; } // ----------------------------------------------- void __fastcall TPDocEdit::DestroyK_Text(){ /* delete ptrK_Text; ptrK_Text = NULL; */ delete ptrK_Text; ptrK_Text = NULL; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::SetXIndex(int value) { FXIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::SetYIndex(int value) { FYIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocEdit::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); // if(bSaveToJPG)//for ¾ÆÀ̺ñ 2005.6.15//»ö±ò¹Ù²ãÁÙ ºÎºÐ PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daCenter2, (WideString)"Edit"); } if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocEdit::HasValue() { //if(Name.Length()) return true; if(K_Text.Length()>0||E_Text.Length()>0||I_Text.Length()>0||C_Text.Length()>0||J_Text.Length()>0) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { //AnsiString Text; WideString Text; if (!this->Name.IsEmpty()) {//commonID°¡ µî·ÏµÇ¾î ÀÖ´Â °æ¿ì Text = K_Text; } else { switch (language) { case 0: Text = K_Text; break; case 1: Text = E_Text; break; case 2: Text = I_Text; break; case 3: Text = C_Text; break; case 4: Text = J_Text; break; } } if(!bSaveJPG||!bSaveToJPG){//for ¾ÆÀ̺ñ 2005.6.15 if (Text.Length() > 0) { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Text); } } RECT rc = ConvertRange(&vs); if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- /* void __fastcall TPDocEdit::SetText(AnsiString kt, AnsiString et, AnsiString it, AnsiString ct, AnsiString jt) { K_Text = kt; E_Text = et; I_Text = it; C_Text = ct; J_Text = jt; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::GetText(AnsiString &kt, AnsiString &et, AnsiString &it, AnsiString &ct, AnsiString &jt) { kt = K_Text; et = E_Text; it = I_Text; ct = C_Text; jt = J_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::SetK_Text(AnsiString kt) { if(kt.Length() == 0) { E_Text = ""; I_Text = ""; C_Text = ""; J_Text = ""; } E_Text = kt; I_Text = kt; C_Text = kt; J_Text = kt; K_Text = kt; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::GetK_Text(AnsiString &kt) { kt = K_Text; } //--------------------------------------------------------------------------- */ void __fastcall TPDocEdit::SetText(WideString kt, WideString et, WideString it, WideString ct, WideString jt) { K_Text = kt; E_Text = et; I_Text = it; C_Text = ct; J_Text = jt; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::GetText(WideString &kt, WideString &et, WideString &it, WideString &ct, WideString &jt) { kt = K_Text; et = E_Text; it = I_Text; ct = C_Text; jt = J_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::SetK_Text(WideString kt) { if(kt.Length() == 0) { E_Text = ""; I_Text = ""; C_Text = ""; J_Text = ""; } E_Text = kt; I_Text = kt; C_Text = kt; J_Text = kt; K_Text = kt; } //--------------------------------------------------------------------------- void __fastcall TPDocEdit::GetK_Text(WideString &kt) { kt = K_Text; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocEdit::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!TextLoadFromFile(hFile, Name)) return false; if (Version >= 5) if (!ReadFile(hFile, &FIndex, sizeof(int), &dwRead, NULL)) return false; return true; AnsiString Text; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (Version <= 5) { //if (!TextLoadFromFile(hFile, K_Text)) return false; if (!TextLoadFromFile(hFile, Text)) return false; K_Text = Text; if (!TextLoadFromFile(hFile, Name)) return false; if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; } else { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Name)) return false; if (!TextLoadFromFile(hFile, Text)) return false; K_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; E_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; I_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; C_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; J_Text = Text; if(Version>=13){//for ¾ÆÀ̺ñ 2005.6.15 if (!ReadFile(hFile, &bSaveToJPG, sizeof(bool), &dwRead, NULL)) return false; } } return true; } */ //--------------------------------------------------------------------------- bool __fastcall TPDocEdit::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!TextLoadFromFile(hFile, Name)) return false; if (Version >= 5) if (!ReadFile(hFile, &FIndex, sizeof(int), &dwRead, NULL)) return false; return true; */ WideString Text; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (Version <= 5) { //if (!TextLoadFromFile(hFile, K_Text)) return false; if (!TextLoadFromFile(hFile, Text)) return false; K_Text = Text; if (!TextLoadFromFile(hFile, Name)) return false; if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; } else { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Name)) return false; if (!TextLoadFromFile(hFile, Text)) return false; K_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; E_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; I_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; C_Text = Text; if (!TextLoadFromFile(hFile, Text)) return false; J_Text = Text; if(Version>=13){//for ¾ÆÀ̺ñ 2005.6.15 if (!ReadFile(hFile, &bSaveToJPG, sizeof(bool), &dwRead, NULL)) return false; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocEdit::SaveToFile(HANDLE hFile) { DWORD dwWrite; /* if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!TextSaveToFile(hFile, Name)) return false; if (!WriteFile(hFile, &FIndex, sizeof(int), &dwWrite, NULL)) return false; return true; */ if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Name)) return false; if (!TextSaveToFile(hFile, K_Text)) return false; if (!TextSaveToFile(hFile, E_Text)) return false; if (!TextSaveToFile(hFile, I_Text)) return false; if (!TextSaveToFile(hFile, C_Text)) return false; if (!TextSaveToFile(hFile, J_Text)) return false; if (!WriteFile(hFile, &bSaveToJPG, sizeof(bool), &dwWrite, NULL)) return false;//for ¾ÆÀ̺ñ 2005.6.15 return true; } //--------------------------------------------------------------------------- /* int __fastcall TPDocEdit::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (TextGetAllocateSize(Name) + TextGetAllocateSize(K_Text) + TextGetAllocateSize(E_Text) + TextGetAllocateSize(I_Text) + TextGetAllocateSize(C_Text) + TextGetAllocateSize(J_Text)); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocEdit::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, K_Text); lp = TextCopyToMemory(lp, E_Text); lp = TextCopyToMemory(lp, I_Text); lp = TextCopyToMemory(lp, C_Text); lp = TextCopyToMemory(lp, J_Text); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocEdit::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, Name); AnsiString TempString; //lp = TextCopyFromMemory(lp, K_Text); lp = TextCopyFromMemory(lp, TempString); K_Text=TempString; //lp = TextCopyFromMemory(lp, E_Text); lp = TextCopyFromMemory(lp, TempString); E_Text=TempString; //lp = TextCopyFromMemory(lp, I_Text); lp = TextCopyFromMemory(lp, TempString); I_Text=TempString; //lp = TextCopyFromMemory(lp, C_Text); lp = TextCopyFromMemory(lp, TempString); C_Text=TempString; //lp = TextCopyFromMemory(lp, J_Text); lp = TextCopyFromMemory(lp, TempString); J_Text=TempString; return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocEdit::Copy(TPDocEdit *src) { if (!TPDocText::Copy((TPDocText *)src)) return false; FXIndex = src->XIndex; FYIndex = src->YIndex; Name = src->Name; K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; return true; } //--------------------------------------------------------------------------- */ int __fastcall TPDocEdit::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (TextGetAllocateSize(Name) + TextGetAllocateSize(K_Text) + TextGetAllocateSize(E_Text) + TextGetAllocateSize(I_Text) + TextGetAllocateSize(C_Text) + TextGetAllocateSize(J_Text)); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocEdit::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, K_Text); lp = TextCopyToMemory(lp, E_Text); lp = TextCopyToMemory(lp, I_Text); lp = TextCopyToMemory(lp, C_Text); lp = TextCopyToMemory(lp, J_Text); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocEdit::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, Name); WideString TempString; //lp = TextCopyFromMemory(lp, K_Text); lp = TextCopyFromMemory(lp, TempString); K_Text=TempString; //lp = TextCopyFromMemory(lp, E_Text); lp = TextCopyFromMemory(lp, TempString); E_Text=TempString; //lp = TextCopyFromMemory(lp, I_Text); lp = TextCopyFromMemory(lp, TempString); I_Text=TempString; //lp = TextCopyFromMemory(lp, C_Text); lp = TextCopyFromMemory(lp, TempString); C_Text=TempString; //lp = TextCopyFromMemory(lp, J_Text); lp = TextCopyFromMemory(lp, TempString); J_Text=TempString; return lp; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocEdit::Copy(TPDocEdit *src) { if (!TPDocText::Copy((TPDocText *)src)) return false; FXIndex = src->XIndex; FYIndex = src->YIndex; Name = src->Name; K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; return true; } //--------------------------------------------------------------------------- */ // by altang bool __fastcall TPDocEdit::Copy(TPDocEdit *src, bool bCopyID) { if (!TPDocText::Copy((TPDocText *)src)) return false; FXIndex = src->XIndex; FYIndex = src->YIndex; // Common ID Ä«ÇÇ ¸·À» ¼ö ÀÖµµ·Ï (2007. 08. 27 Annualring) if (bCopyID) { Name = src->Name; } K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; return true; } //--------------------------------------------------------------------------- // // TPDocComboBox // //--------------------------------------------------------------------------- // ComboBox Type Item Ãß°¡ (2007. 02. 28 Annualring) /* __fastcall TPDocComboBox::TPDocComboBox(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString n) : TPDocText(Sender, detComboBox, rc, ta) { Name = n; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; ptrK_Text = new AnsiString; ptrE_Text = new AnsiString; ptrI_Text = new AnsiString; ptrC_Text = new AnsiString; ptrJ_Text = new AnsiString; bHasCommonData = false; bSaveToJPG = false;//for ¾ÆÀ̺ñ 2005.6.15 } //--------------------------------------------------------------------------- */ __fastcall TPDocComboBox::TPDocComboBox(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString n) : TPDocText(Sender, detComboBox, rc, ta) { Name = n; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; ptrData_Text = new WideString; bHasCommonData = false; bSaveToJPG = false;//for ¾ÆÀ̺ñ 2005.6.15 } //--------------------------------------------------------------------------- __fastcall TPDocComboBox::~TPDocComboBox(){ if(!bHasCommonData) { delete ptrData_Text; ptrData_Text = NULL; } } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::Set_Data_Text(WideString dt){ *ptrData_Text = dt; } WideString __fastcall TPDocComboBox::Get_Data_Text() { return *ptrData_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::DestroyData_Text(){ delete ptrData_Text; ptrData_Text = NULL; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::SetXIndex(int value) { FXIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::SetYIndex(int value) { FYIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); // if(bSaveToJPG)//for ¾ÆÀ̺ñ 2005.6.15//»ö±ò¹Ù²ãÁÙ ºÎºÐ PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; }else{ PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, daCenter2, (WideString) "Combo Box"); } if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocComboBox::HasValue() { //if(Name.Length()) return true; if(Data_Text.Length()>0) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { WideString Text; Text = Data_Text; if(!bSaveJPG||!bSaveToJPG){//for ¾ÆÀ̺ñ 2005.6.15 if (Text.Length() > 0) { PaintText(hDC, Font, ConvertRange(&vs), (double)vs.ZoomIn / vs.ZoomOut, Align, Text); } } RECT rc = ConvertRange(&vs); if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::SetData_Text(WideString dt) { Data_Text = dt; } //--------------------------------------------------------------------------- void __fastcall TPDocComboBox::GetData_Text(WideString &dt) { dt = Data_Text; } //--------------------------------------------------------------------------- bool __fastcall TPDocComboBox::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!TextLoadFromFile(hFile, Name)) return false; if (Version >= 5) if (!ReadFile(hFile, &FIndex, sizeof(int), &dwRead, NULL)) return false; return true; */ // AnsiString Text; WideString Text; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (Version <= 5) { //if (!TextLoadFromFile(hFile, K_Text)) return false; if (!TextLoadFromFile(hFile, Text)) return false; Data_Text = Text; if (!TextLoadFromFile(hFile, Name)) return false; if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; } else { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Name)) return false; if (!TextLoadFromFile(hFile, Text)) return false; Data_Text = Text; if(Version>=13){//for ¾ÆÀ̺ñ 2005.6.15 if (!ReadFile(hFile, &bSaveToJPG, sizeof(bool), &dwRead, NULL)) return false; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocComboBox::SaveToFile(HANDLE hFile) { DWORD dwWrite; /* if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!TextSaveToFile(hFile, Name)) return false; if (!WriteFile(hFile, &FIndex, sizeof(int), &dwWrite, NULL)) return false; return true; */ if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Name)) return false; if (!TextSaveToFile(hFile, Data_Text)) return false; if (!WriteFile(hFile, &bSaveToJPG, sizeof(bool), &dwWrite, NULL)) return false;//for ¾ÆÀ̺ñ 2005.6.15 return true; } //--------------------------------------------------------------------------- int __fastcall TPDocComboBox::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (TextGetAllocateSize(Name) + TextGetAllocateSize(Data_Text)); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocComboBox::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); lp = TextCopyToMemory(lp, Name); lp = TextCopyToMemory(lp, Data_Text); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocComboBox::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, Name); // AnsiString TempString; WideString TempString; //lp = TextCopyFromMemory(lp, Data_Text); lp = TextCopyFromMemory(lp, TempString); Data_Text=TempString; return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocComboBox::Copy(TPDocComboBox *src) { if (!TPDocText::Copy((TPDocText *)src)) return false; FXIndex = src->XIndex; FYIndex = src->YIndex; Name = src->Name; Data_Text = src->Data_Text; return true; } //--------------------------------------------------------------------------- // // TPDocMemo // //--------------------------------------------------------------------------- /* __fastcall TPDocMemo::TPDocMemo(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString t) : TPDocText(Sender, detMemo, rc, ta) { Title = t; TitleHeight = 0; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; bNewFont = false; MFont = NULL; } //--------------------------------------------------------------------------- */ // by altang __fastcall TPDocMemo::TPDocMemo(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString t) : TPDocText(Sender, detMemo, rc, ta) { Title = t; TitleHeight = 0; FXIndex = -1; bFXIndex = false; FYIndex = -1; bFYIndex = false; bNewFont = false; MFont = NULL; LineData = NULL; //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ bAutoLineFeed = false; } //--------------------------------------------------------------------------- __fastcall TPDocMemo::~TPDocMemo() { if (bNewFont) { if (MFont) { delete MFont; MFont = NULL; } } if (LineData) free(LineData); LineData = NULL; } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- /* void __fastcall TPDocMemo::PaintForm(HDC hDC, RECT rc, double t) { if (Title.Length() > 0) { PaintText(hDC, Font, rc, t, Align, Title); } PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- */ // by altang void __fastcall TPDocMemo::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { if (Title.Length() > 0) { PaintText(hDC, Font, rc, t, Align, Title); } PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocMemo::SetXIndex(int value) { FXIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocMemo::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocMemo::SetYIndex(int value) { FYIndex = value; } //--------------------------------------------------------------------------- void __fastcall TPDocMemo::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocMemo::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocMemo::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; TEXTMETRIC tm; HFONT hOldFont; TFont *tempfont; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if (bNewFont && MFont) tempfont = MFont; else tempfont = Font; if ( HasValue() ){ if (Title.Length() > 0) { hOldFont = (HFONT)SelectObject(hDC, Font->Handle); GetTextMetrics(hDC, &tm); TitleHeight = tm.tmHeight; SelectObject(hDC, hOldFont); } bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; if (NowSelect) PaintIn(hDC, rc); }else{ PaintText(hDC, tempfont, rc, (double)vs.ZoomIn / vs.ZoomOut, daCenter2, (WideString) "Memo"); if (Title.Length() > 0) { hOldFont = (HFONT)SelectObject(hDC, Font->Handle); GetTextMetrics(hDC, &tm); TitleHeight = tm.tmHeight; SelectObject(hDC, hOldFont); } if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- /* bool __fastcall TPDocMemo::HasValue() { if(Text.Length())return true; return false; } //--------------------------------------------------------------------------- */ // by altang bool __fastcall TPDocMemo::HasValue() { if(Text.Length())return true; return false; } //--------------------------------------------------------------------------- /* void __fastcall TPDocMemo::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { HFONT hOldFont = NULL; RECT rc; TEXTMETRIC tm; int i=0, len = 0, sy; char *sp, *tp, *ep; WORD wAlign; double r; int tempFontSize; wchar_t *wsp, *wtp, *wep; //by altang int wlen = 0; r = (double)vs.ZoomIn / vs.ZoomOut; rc = ConvertRange(&vs); if (Text.Length() > 0) { //rc = ConvertRange(&vs); try { if (bNewFont && MFont) { if (MFont->Size > 0) { tempFontSize = MFont->Size; MFont->Size = tempFontSize * vs.ZoomIn / vs.ZoomOut; } else { tempFontSize = MFont->Height; MFont->Height = tempFontSize * vs.ZoomIn / vs.ZoomOut; } hOldFont = (HFONT)SelectObject(hDC, MFont->Handle); SetTextColor(hDC, MFont->Color); } else { ResizeFont((double)vs.ZoomIn / vs.ZoomOut); hOldFont = (HFONT)SelectObject(hDC, Font->Handle); SetTextColor(hDC, Font->Color); } SetBkMode(hDC, TRANSPARENT); //wAlign = GetTextAlign(hDC); /* Alignment ¸Þ´º¾ÈÀÇ °ªÀº ´ÙÀ½°ú °°ÀÌ ¼³Á¤µÇ¾î ÀÖ´Ù. __finally Àü±îÁöÀÇ ºÎºÐÀº Á¤·Ä ±¸ÇöÀ» À§Çؼ­ ¾Æ·¡ ³¯Â¥¿¡ ¼öÁ¤µÇ¾úÀ½. 0 1 2 3 4 5 6 7 8 by altang 07.03.26 wAlign = this->Align; //Alignment ¸Þ´º¿¡¼­ ¼±ÅÃÇÑ °ªÀ» °¡Áö°í ¿Â´Ù switch(wAlign){ case 1: case 4: case 7: SetTextAlign(hDC, TA_CENTER); //Áß¾Ó Á¤·ÄÀ» ¼±Åýà »óÇÏÁ¤·Ä ¾øÀÌ Á¿츸 Áß¾ÓÀ¸·Î Á¤·Ä break; case 2: case 5: case 8: SetTextAlign(hDC, TA_RIGHT); //¿ìÃø Á¤·ÄÀ» ¼±Åýà »óÇÏÁ¤·Ä ¾øÀÌ Á¿츸 ¿ìÃøÀ¸·Î Á¤·Ä break; case 0: case 3: case 6: default: SetTextAlign(hDC, TA_LEFT); //ÁÂÃø Á¤·ÄÀ» ¼±Åýà »óÇÏÁ¤·Ä ¾øÀÌ Á¿츸 ÁÂÃøÀ¸·Î Á¤·Ä (±âº») break; } GetTextMetrics(hDC, &tm); sp = Text.c_str(); ep = sp; tp = strchr(ep, '\n'); wsp = Text.c_bstr(); wep = wsp; wtp = wcschr(wep, '\n'); // by altang; sy = rc.top + TitleHeight * r; while(tp != NULL) { // FontÀÇ Height°¡ ¹Ù²ð ¼ö ÀÖ´Ù.. len = tp - ep - 1; wlen = wtp - wep - 1; switch(wAlign){ case 1: case 4: case 7: //ExtTextOut(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, len, NULL); break; //Áß¾ÓÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 2: case 5: case 8: ///ExtTextOut(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, len, NULL); break; //¿ìÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 0: case 3: case 6: default: //ExtTextOut(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, len, NULL); break; //ÁÂÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. } i++; ep = tp + 1; tp = strchr(ep, '\n'); wep = wtp + 1; wtp = wcschr(wep, '\n'); // by altang; } if (*ep) { // when text is not ended with null character!! len = Text.Length() - (ep - sp); switch(wAlign){ case 1: case 4: case 7: //ExtTextOut(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, len, NULL); break; //Áß¾ÓÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 2: case 5: case 8: //ExtTextOut(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, len, NULL); break; //¿ìÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 0: case 3: case 6: default: //ExtTextOut(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, len, NULL); break; //ÁÂÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. } } SetTextAlign(hDC, wAlign); } __finally { if (hOldFont) SelectObject(hDC, hOldFont); if (bNewFont && MFont) { if (MFont->Size > 0) MFont->Size = tempFontSize; else MFont->Height = tempFontSize; } else { RestoreFont(tempFontSize); } } } if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- */ //by altang void __fastcall TPDocMemo::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { HFONT hOldFont = NULL; RECT rc; TEXTMETRIC tm; int i=0, sy; WORD wAlign; double r; int tempFontSize; wchar_t *wsp, *wtp, *wep, *twep; //by altang int wlen = 0; MemoLineInfo tLineData[100]; int line, subline; r = (double)vs.ZoomIn / vs.ZoomOut; rc = ConvertRange(&vs); if (Text.Length() > 0) { //rc = ConvertRange(&vs); try { if (bNewFont && MFont) { if (MFont->Size > 0) { tempFontSize = MFont->Size; MFont->Size = tempFontSize * vs.ZoomIn / vs.ZoomOut; } else { tempFontSize = MFont->Height; MFont->Height = tempFontSize * vs.ZoomIn / vs.ZoomOut; } hOldFont = (HFONT)SelectObject(hDC, MFont->Handle); SetTextColor(hDC, MFont->Color); } else { ResizeFont((double)vs.ZoomIn / vs.ZoomOut); hOldFont = (HFONT)SelectObject(hDC, Font->Handle); SetTextColor(hDC, Font->Color); } SetBkMode(hDC, TRANSPARENT); //wAlign = GetTextAlign(hDC); /* Alignment ¸Þ´º¾ÈÀÇ °ªÀº ´ÙÀ½°ú °°ÀÌ ¼³Á¤µÇ¾î ÀÖ´Ù. __finally Àü±îÁöÀÇ ºÎºÐÀº Á¤·Ä ±¸ÇöÀ» À§Çؼ­ ¾Æ·¡ ³¯Â¥¿¡ ¼öÁ¤µÇ¾úÀ½. 0 1 2 3 4 5 6 7 8 by altang 07.03.26*/ wAlign = this->Align; //Alignment ¸Þ´º¿¡¼­ ¼±ÅÃÇÑ °ªÀ» °¡Áö°í ¿Â´Ù switch(wAlign){ case 1: case 4: case 7: SetTextAlign(hDC, TA_CENTER); //Áß¾Ó Á¤·ÄÀ» ¼±Åýà »óÇÏÁ¤·Ä ¾øÀÌ Á¿츸 Áß¾ÓÀ¸·Î Á¤·Ä break; case 2: case 5: case 8: SetTextAlign(hDC, TA_RIGHT); //¿ìÃø Á¤·ÄÀ» ¼±Åýà »óÇÏÁ¤·Ä ¾øÀÌ Á¿츸 ¿ìÃøÀ¸·Î Á¤·Ä break; case 0: case 3: case 6: default: SetTextAlign(hDC, TA_LEFT); //ÁÂÃø Á¤·ÄÀ» ¼±Åýà »óÇÏÁ¤·Ä ¾øÀÌ Á¿츸 ÁÂÃøÀ¸·Î Á¤·Ä (±âº») break; } GetTextMetrics(hDC, &tm); wsp = Text.c_bstr(); wep = wsp; wtp = wcschr(wep, '\n'); // by altang; sy = rc.top + TitleHeight * r; if (!bAutoLineFeed) { //¿¹Àü ¹öÀüÀ¸·Î ÀÚµ¿ ÁÙ ¹Ù²Ù±â¸¦ ÇÏÁö ¾ÊÀ» °æ¿ì while(wtp != NULL) { // FontÀÇ Height°¡ ¹Ù²ð ¼ö ÀÖ´Ù.. wlen = wtp - wep - 1; switch(wAlign){ case 1: case 4: case 7: //ExtTextOut(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //Áß¾ÓÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 2: case 5: case 8: ///ExtTextOut(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //¿ìÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 0: case 3: case 6: default: //ExtTextOut(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //ÁÂÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. } i++; wep = wtp + 1; wtp = wcschr(wep, '\n'); // by altang; } if (*wep) { // when text is not ended with null character!! wlen = Text.Length() - (wep - wsp); switch(wAlign){ case 1: case 4: case 7: //ExtTextOut(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //Áß¾ÓÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 2: case 5: case 8: //ExtTextOut(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //¿ìÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 0: case 3: case 6: default: //ExtTextOut(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //ÁÂÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. } } } else { //¿©±âºÎÅÍ ÀÚµ¿ ÁÙ¹Ù²Þ Ã³¸® ºÎºÐ TSize size; int twlen = 0, nx = 0; twep = wep; line = 0; while(wtp != NULL) { // FontÀÇ Height°¡ ¹Ù²ð ¼ö ÀÖ´Ù.. wlen = wtp - twep - 1; twlen = wlen; if (wlen <= 0) break; subline = 0; GetTextExtentPointW(hDC, twep, twlen, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = 0; k= (rc.right-rc.left-5)) { if (k == 0) { twep = wep + 1; wlen = 1; nx = 1; } else { twep = wep + k; wlen = k; nx = k; } break; } } } while(true) { switch(wAlign){ case 1: case 4: case 7: //ExtTextOut(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //Áß¾ÓÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 2: case 5: case 8: ///ExtTextOut(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //¿ìÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 0: case 3: case 6: default: //ExtTextOut(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //ÁÂÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. } tLineData[i].Line = line; tLineData[i].SubLine = subline; tLineData[i].Len = wlen; i++; subline++; if (size.cx < (rc.right-rc.left-5)) break; else { wep = twep; wlen = wtp - wep - 1; if (wlen <= 0) break; GetTextExtentPointW(hDC, twep, wlen, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = nx, l = 0; k= (rc.right-rc.left-5)) { if (l == 0) { twep = wep + 1; wlen = 1; nx += 1; } else { twep = wep + l; wlen = l; nx += l; } break; } } } } } wep = wtp + 1; wtp = wcschr(wep, '\n'); // by altang; twep = wep; line++; } if (*wep) { // when text is not ended with null character!! wlen = Text.Length() - (wep - wsp); twlen = wlen; subline = 0; GetTextExtentPointW(hDC, twep, twlen, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = 0; k= (rc.right-rc.left-5)) { if (k == 0) { twep = wep + 1; wlen = 1; nx = 1; } else { twep = wep + k; wlen = k; nx = k; } break; } } } while(true) { switch(wAlign){ case 1: case 4: case 7: //ExtTextOut(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+((rc.right-rc.left)-tm.tmAveCharWidth)/2+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //Áß¾ÓÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 2: case 5: case 8: //ExtTextOut(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.right-tm.tmAveCharWidth+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //¿ìÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. case 0: case 3: case 6: default: //ExtTextOut(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); ExtTextOutW(hDC,rc.left+2*r, sy+tm.tmHeight*i, ETO_CLIPPED, &rc, wep, wlen, NULL); break; //ÁÂÃøÁ¤·Ä½Ã ¼¿ÀÇ Á¿ìÃø °ª°ú ¹®ÀÚÀÇ Å©±â¸¦ ÀÌ¿ëÇØ ÁÂÇ¥¸¦ °è»ê ÈÄ È­¸é¿¡ º¸¿©ÁØ´Ù. } tLineData[i].Line = line; tLineData[i].SubLine = subline; tLineData[i].Len = wlen; i++; subline++; if (size.cx < (rc.right-rc.left-5)) break; else { wep = twep; wlen = Text.Length() - (wep - wsp); if (wlen <= 0) break; GetTextExtentPointW(hDC, wep, wlen, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = nx, l = 0; k= (rc.right-rc.left-5)) { if (l == 0) { twep = wep + 1; wlen = 1; nx += 1; } else { twep = wep + l; wlen = l; nx += l; } break; } } } } } } else { tLineData[i].Line = line; tLineData[i].SubLine = 0; tLineData[i].Len = 0; i++; } }//else ¿©±â±îÁö ÁÙ¹Ù²Þ Ã³¸® ºÎºÐ SetTextAlign(hDC, wAlign); } __finally { if (hOldFont) SelectObject(hDC, hOldFont); if (bNewFont && MFont) { if (MFont->Size > 0) MFont->Size = tempFontSize; else MFont->Height = tempFontSize; } else { RestoreFont(tempFontSize); } } } if (LineData) free(LineData); LineData = NULL; nMemoLines = i; LineData = (MemoLineInfo*)calloc(nMemoLines + 1,sizeof(MemoLineInfo)); for (i = 0; i < nMemoLines; i++) LineData[i] = tLineData[i]; if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocMemo::SetFont(TFont *Font, TColor C) { if (MFont == NULL && bNewFont == false) { MFont = new TFont; bNewFont = true; } MFont->Assign(Font); MFont->Charset = DEFAULT_CHARSET; // MFont->Color = C; // MFont->Name = "MS Sans Serif"; // MFont->Size = 10; // MFont->Color = clBlack; // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- TFont *__fastcall TPDocMemo::GetFont() { if (bNewFont) return MFont; else return TPDocText::GetFont(); } //--------------------------------------------------------------------------- /* bool __fastcall TPDocMemo::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TFontCharset charset; TColor color; AnsiString FName; int size; TFontStyles fstyle; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Title)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!ReadFile(hFile, &TitleHeight, sizeof(int), &dwRead, NULL)) return false; if (Version >= 5) { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; //================ For Font... if (!ReadFile(hFile, &bNewFont, sizeof(bool), &dwRead, NULL)) return false; if (bNewFont) { MFont = new TFont; if (!ReadFile(hFile, &charset, sizeof(TFontCharset), &dwRead, NULL)) return false; MFont->Charset = charset; if (!ReadFile(hFile, &color, sizeof(TColor), &dwRead, NULL)) return false; MFont->Color = color; if (!TextLoadFromFile(hFile, FName)) return false; MFont->Name = FName; if (!ReadFile(hFile, &size, sizeof(int), &dwRead, NULL)) return false; MFont->Size = size; if (!ReadFile(hFile, &fstyle, sizeof(TFontStyle), &dwRead, NULL)) return false; MFont->Style = fstyle; } } return true; } //--------------------------------------------------------------------------- */ // by altang bool __fastcall TPDocMemo::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; TFontCharset charset; TColor color; AnsiString FName; int size; TFontStyles fstyle; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Title)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!ReadFile(hFile, &TitleHeight, sizeof(int), &dwRead, NULL)) return false; if (Version >= 5) { if (!ReadFile(hFile, &FXIndex, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &FYIndex, sizeof(int), &dwRead, NULL)) return false; //================ For Font... if (!ReadFile(hFile, &bNewFont, sizeof(bool), &dwRead, NULL)) return false; if (bNewFont) { MFont = new TFont; if (!ReadFile(hFile, &charset, sizeof(TFontCharset), &dwRead, NULL)) return false; MFont->Charset = charset; if (!ReadFile(hFile, &color, sizeof(TColor), &dwRead, NULL)) return false; MFont->Color = color; if (!TextLoadFromFile(hFile, FName)) return false; MFont->Name = FName; if (!ReadFile(hFile, &size, sizeof(int), &dwRead, NULL)) return false; MFont->Size = size; if (!ReadFile(hFile, &fstyle, sizeof(TFontStyle), &dwRead, NULL)) return false; MFont->Style = fstyle; } //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ if (Version > 18) if (!ReadFile(hFile, &bAutoLineFeed, sizeof(bool), &dwRead, NULL)) return false; } return true; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocMemo::SaveToFile(HANDLE hFile) { DWORD dwWrite; TFontCharset charset; TColor color; AnsiString FName; int size; TFontStyles fstyle; if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, Title)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!WriteFile(hFile, &TitleHeight, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; //============================ for font.... if (!WriteFile(hFile, &bNewFont, sizeof(bool), &dwWrite, NULL)) return false; if (bNewFont) { charset = MFont->Charset; if (!WriteFile(hFile, &charset, sizeof(TFontCharset), &dwWrite, NULL)) return false; color = MFont->Color; if (!WriteFile(hFile, &color, sizeof(TColor), &dwWrite, NULL)) return false; FName = MFont->Name; if (!TextSaveToFile(hFile, FName)) return false; size = MFont->Size; if (!WriteFile(hFile, &size, sizeof(int), &dwWrite, NULL)) return false; fstyle = MFont->Style; if (!WriteFile(hFile, &fstyle, sizeof(TFontStyle), &dwWrite, NULL)) return false; } return true; } //--------------------------------------------------------------------------- */ bool __fastcall TPDocMemo::SaveToFile(HANDLE hFile) { DWORD dwWrite; TFontCharset charset; TColor color; AnsiString FName; int size; TFontStyles fstyle; if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, Title)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!WriteFile(hFile, &TitleHeight, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FXIndex, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FYIndex, sizeof(int), &dwWrite, NULL)) return false; //============================ for font.... if (!WriteFile(hFile, &bNewFont, sizeof(bool), &dwWrite, NULL)) return false; if (bNewFont) { charset = MFont->Charset; if (!WriteFile(hFile, &charset, sizeof(TFontCharset), &dwWrite, NULL)) return false; color = MFont->Color; if (!WriteFile(hFile, &color, sizeof(TColor), &dwWrite, NULL)) return false; FName = MFont->Name; if (!TextSaveToFile(hFile, FName)) return false; size = MFont->Size; if (!WriteFile(hFile, &size, sizeof(int), &dwWrite, NULL)) return false; fstyle = MFont->Style; if (!WriteFile(hFile, &fstyle, sizeof(TFontStyle), &dwWrite, NULL)) return false; } //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ //ÆÄÀÏ ÀúÀåÇÒ ¶§ old versionÀ¸·Î ÀúÀåÇÏ´Â ±â´ÉÀÌ ÀÖ´Ù. old versionÀ¸·Î ÀúÀåÇϸé //version = 15·Î ¼¼ÆÃÀÌ µÈ´Ù. ±×·¡¼­ ¾Æ·¡¿Í °°ÀÌ if¹®ÀÌ ÇÊ¿äÇÏ´Ù. if (SaveVersion > 18) if (!WriteFile(hFile, &bAutoLineFeed, sizeof(bool), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- /* int __fastcall TPDocMemo::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (TextGetAllocateSize(Title) + TextGetAllocateSize(Text) + sizeof(int) + sizeof(bool)); if (bNewFont) size += (sizeof(TFontCharset) + sizeof(TColor) + TextGetAllocateSize(MFont->Name) + sizeof(int) + sizeof(TFontStyle)); return size; } //--------------------------------------------------------------------------- */ // by altang int __fastcall TPDocMemo::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (TextGetAllocateSize(Title) + TextGetAllocateSize(Text) + sizeof(int) + sizeof(bool)); if (bNewFont) size += (sizeof(TFontCharset) + sizeof(TColor) + TextGetAllocateSize(MFont->Name) + sizeof(int) + sizeof(TFontStyle)); //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ size += sizeof(bool); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocMemo::CopyToMemory(BYTE *lp) { TFontCharset charset; TColor color; int size; TFontStyles fstyle; lp = TPDocText::CopyToMemory(lp); lp = TextCopyToMemory(lp, Title); lp = TextCopyToMemory(lp, Text); memcpy(lp, &TitleHeight, sizeof(int)); lp += sizeof(int); memcpy(lp, &bNewFont, sizeof(bool)); lp += sizeof(bool); if (bNewFont) { charset = MFont->Charset; memcpy(lp, &charset, sizeof(TFontCharset)); lp += sizeof(TFontCharset); color = MFont->Color; memcpy(lp, &color, sizeof(TColor)); lp += sizeof(TColor); lp = TextCopyToMemory(lp, MFont->Name); size = MFont->Size; memcpy(lp, &size, sizeof(int)); lp += sizeof(int); fstyle = MFont->Style; memcpy(lp, &fstyle, sizeof(TFontStyle)); lp += sizeof(TFontStyle); } //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ memcpy(lp, &bAutoLineFeed, sizeof(bool)); lp += sizeof(bool); return lp; } //--------------------------------------------------------------------------- /* BYTE *__fastcall TPDocMemo::CopyFromMemory(BYTE *lp) { TFontCharset charset; TColor color; int size; TFontStyles fstyle; AnsiString name; lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, Title); lp = TextCopyFromMemory(lp, Text); memcpy(&TitleHeight, lp, sizeof(int)); lp += sizeof(int); memcpy(&bNewFont, lp, sizeof(bool)); lp += sizeof(bool); if (bNewFont) { MFont = new TFont; memcpy(&charset, lp, sizeof(TFontCharset)); lp += sizeof(TFontCharset); MFont->Charset = charset; memcpy(&color, lp, sizeof(TColor)); lp += sizeof(TColor); MFont->Color = color; lp = TextCopyFromMemory(lp, name); MFont->Name = name; memcpy(&size, lp, sizeof(int)); lp += sizeof(int); MFont->Size = size; memcpy(&fstyle, lp, sizeof(TFontStyle)); lp += sizeof(TFontStyle); MFont->Style = fstyle; } return lp; } //--------------------------------------------------------------------------- */ // by altang BYTE *__fastcall TPDocMemo::CopyFromMemory(BYTE *lp) { TFontCharset charset; TColor color; int size; TFontStyles fstyle; AnsiString name; lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, Title); lp = TextCopyFromMemory(lp, Text); memcpy(&TitleHeight, lp, sizeof(int)); lp += sizeof(int); memcpy(&bNewFont, lp, sizeof(bool)); lp += sizeof(bool); if (bNewFont) { MFont = new TFont; memcpy(&charset, lp, sizeof(TFontCharset)); lp += sizeof(TFontCharset); MFont->Charset = charset; memcpy(&color, lp, sizeof(TColor)); lp += sizeof(TColor); MFont->Color = color; lp = TextCopyFromMemory(lp, name); MFont->Name = name; memcpy(&size, lp, sizeof(int)); lp += sizeof(int); MFont->Size = size; memcpy(&fstyle, lp, sizeof(TFontStyle)); lp += sizeof(TFontStyle); MFont->Style = fstyle; } //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ memcpy(&bAutoLineFeed, lp, sizeof(bool)); lp += sizeof(bool); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocMemo::Copy(TPDocMemo *src) { TPDocText::Copy((TPDocText *)src); Title = src->Title; Text = src->Text; TitleHeight = src->TitleHeight; FXIndex = src->XIndex; FYIndex = src->YIndex; bNewFont = src->bNewFont; if (bNewFont) { MFont = new TFont; MFont->Assign(src->MFont); } //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ bAutoLineFeed = src->bAutoLineFeed; return true; } //--------------------------------------------------------------------------- // // TPDocInput // //--------------------------------------------------------------------------- /* __fastcall TPDocInput::TPDocInput(TPDocObject *Sender, RECT rc, TPDocAlign ta, TColor c, TPDocInputStyle s, AnsiString t, int p, TPDocInputMethod m) : TPDocText(Sender, detInput, rc, ta) { TPDocEdit *dp; RECT src; Text = t; Color = c; Style = s; Position = p; Method = m; if (Style == disHorizental) { src = Rect(p, 0, rc.right - rc.left, rc.bottom - rc.top); } else { src = Rect(0, p, rc.right - rc.left, rc.bottom - rc.top); } dp = new TPDocEdit(this,src); IPElement = (TPDocElement *)dp; bFXIndex = false; bFYIndex = false; } //--------------------------------------------------------------------------- */ __fastcall TPDocInput::TPDocInput(TPDocObject *Sender, RECT rc, TPDocAlign ta, TColor c, TPDocInputStyle s, WideString t, int p, TPDocInputMethod m) : TPDocText(Sender, detInput, rc, ta) { TPDocEdit *dp; RECT src; Text = t; Color = c; Style = s; Position = p; Method = m; if (Style == disHorizental) { src = Rect(p, 0, rc.right - rc.left, rc.bottom - rc.top); } else { src = Rect(0, p, rc.right - rc.left, rc.bottom - rc.top); } dp = new TPDocEdit(this,src); IPElement = (TPDocElement *)dp; bFXIndex = false; bFYIndex = false; } //--------------------------------------------------------------------------- __fastcall TPDocInput::~TPDocInput() { RemoveData(); } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocInput::RemoveData() { if (IPElement) { switch (IPElement->Type) { case detColorChip: delete (TPDocColorChip *)IPElement; IPElement = NULL; break; case detNumber: delete (TPDocNumber *)IPElement; IPElement = NULL; break; case detFormula: delete (TPDocFormula *)IPElement; IPElement = NULL; break; case detDate: delete (TPDocDate *)IPElement; IPElement = NULL; break; case detEdit: delete (TPDocEdit *)IPElement; IPElement = NULL; break; case detImage: delete (TPDocImage *)IPElement; IPElement = NULL; break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox: delete (TPDocComboBox *)IPElement; IPElement = NULL; break; } } } //--------------------------------------------------------------------------- void __fastcall TPDocInput::PaintForm(HDC hDC, RECT range, double t, bool bPrint) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int p; RECT rc; try { hPen = CreatePen(psSolid, 1 * t, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); Rectangle(hDC, range.left, range.top, range.right + 1, range.bottom + 1); if (Style == disVertical) { p = Position ? Position * t: range.bottom - range.top; MoveToEx(hDC, range.left, range.top + p, NULL); LineTo(hDC, range.right, range.top + p); if (Text.Length() > 0) { if (IPElement->Type != detImage || Method != dimAuto) { rc = Rect(range.left, range.top, range.right, range.top + p); PaintText(hDC, Font, rc, t, Align, Text); } } } else { p = Position ? Position * t: range.right - range.left; MoveToEx(hDC, range.left + p, range.top, NULL); LineTo(hDC, range.left + p, range.bottom); if (Text.Length() > 0) { if (IPElement->Type != detImage || Method != dimAuto) { rc = Rect(range.left, range.top, range.left + p, range.bottom); PaintText(hDC, Font, rc, t, Align, Text); } } } } __finally { if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } PaintFrame(hDC, range, t); //right range?? } //--------------------------------------------------------------------------- void __fastcall TPDocInput::SetInputStyle(TPDocInputStyle instyle) { if (instyle !=Style) { if (instyle == disHorizental) { Position = (Range.right - Range.left)/2; IPElement->Range = Rect(Position, 0, Range.right - Range.left, Range.bottom - Range.top); } else { Position = (Range.bottom - Range.top)/2; IPElement->Range = Rect(0, Position, Range.right - Range.left, Range.bottom - Range.top); } Style = instyle; } } //--------------------------------------------------------------------------- void __fastcall TPDocInput::SetbXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocInput::SetbYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- void __fastcall TPDocInput::PaintSelectIn(HDC hDC, RECT rc) { int px, py; PaintSelectInCommon(hDC, rc); if (Style == disVertical) { px = (rc.right + rc.left) / 2; py = rc.top+Position; //caution } else { px = rc.left+Position;//caution py = (rc.bottom + rc.top) / 2; } Rectangle(hDC, px-2, py-2, px+3, py+3); } //--------------------------------------------------------------------------- void __fastcall TPDocInput::PaintControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); if (Style == disVertical) { MoveToEx(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top + FOldPosition), NULL); LineTo(hDC, vs.Pattern2ViewX(FOldRect.right), vs.Pattern2ViewY(FOldRect.top + FOldPosition)); } else { MoveToEx(hDC, vs.Pattern2ViewX(FOldRect.left + FOldPosition), vs.Pattern2ViewY(FOldRect.top), NULL); LineTo(hDC, vs.Pattern2ViewX(FOldRect.left + FOldPosition), vs.Pattern2ViewY(FOldRect.bottom)); } } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocInput::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { int temp; PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); IPElement->PaintForm(hDC, vs); } //--------------------------------------------------------------------------- void __fastcall TPDocInput::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectIn); else PaintRange(hDC, rc); // if(IPElement->HasValue()){ // IPElement->PaintReport(Sender, hDC, vs, bPrint, false,language); // }else{ IPElement->PaintDesign(Sender, hDC, vs, bPrint, false,language, paintID); // } PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() )PaintReport(Sender,hDC,vs,bPrint,bSelect,language); } //--------------------------------------------------------------------------- bool __fastcall TPDocInput::HasValue() { if(Text.Length())return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocInput::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { int p; RECT range, rc; range = ConvertRange(&vs); IPElement->PaintReport(Sender, hDC, vs, bPrint, bselect, language); if (IPElement->Type == detImage && Method == dimAuto) { // this case Text is had to be changed... if (((TPDocImage *)IPElement)->Image != NULL) { if (Style == disVertical) { p = Position ? Position * vs.ZoomIn / vs.ZoomOut: range.bottom - range.top; if (Text.Length() > 0) { rc = Rect(range.left, range.top, range.right, range.top + p); PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text); } } else { p = Position ? Position * vs.ZoomIn / vs.ZoomOut : range.right - range.left; if (Text.Length() > 0) { rc = Rect(range.left, range.top, range.left + p, range.bottom); PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text); } } } } } //--------------------------------------------------------------------------- /* void __fastcall TPDocInput::SetImgDir(AnsiString imgdir) { ImageDir = imgdir; } //--------------------------------------------------------------------------- void __fastcall TPDocInput::SetInputText(AnsiString itext) { Text = itext; } //--------------------------------------------------------------------------- */ void __fastcall TPDocInput::SetImgDir(WideString imgdir) { ImageDir = imgdir; } //--------------------------------------------------------------------------- void __fastcall TPDocInput::SetInputText(WideString itext) { Text = itext; } //--------------------------------------------------------------------------- bool __fastcall TPDocInput::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TPDocElement *dp; TPDocElementType et; RECT rt; TextVersion = Version; RemoveData(); if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Style, sizeof(TPDocInputStyle), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!ReadFile(hFile, &Position, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Method, sizeof(TPDocInputMethod), &dwRead, NULL)) return false; if (!ReadFile(hFile, &et, sizeof(TPDocElementType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &rt, sizeof(RECT), &dwRead, NULL)) return false; switch (et) { case detColorChip: dp = new TPDocColorChip(this, rt); break; case detNumber: dp = new TPDocNumber(this, rt); break; case detFormula: dp = new TPDocFormula(this, rt); break; case detDate: dp = new TPDocDate(this, rt); break; case detEdit: dp = new TPDocEdit(this, rt); break; case detImage: dp = new TPDocImage(this, rt); break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox: dp = new TPDocComboBox(this, rt); break; case detNone: dp = NULL; break; default: dp = NULL; break; } if (dp) { if (!dp->LoadFromFile(hFile, Version)) return false; IPElement = (TPDocElement *)dp; } else { return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocInput::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Style, sizeof(TPDocInputStyle), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!WriteFile(hFile, &Position, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Method, sizeof(TPDocInputMethod), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &IPElement->Type, sizeof(TPDocElementType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &IPElement->Range, sizeof(RECT), &dwWrite, NULL)) return false; if (!IPElement->SaveToFile(hFile)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocInput::Copy(TPDocInput *src) { TPDocElement *dp; TPDocText::Copy((TPDocText *)src); Color = src->Color; Style = src->Style; Text = src->Text; Position = src->Position; Method = src->Method; switch (src->IPElement->Type) { case detColorChip: dp = new TPDocColorChip(this, src->IPElement->Range); ((TPDocColorChip *)dp)->Copy((TPDocColorChip *)src->IPElement); break; case detNumber: dp = new TPDocNumber(this, src->IPElement->Range); ((TPDocNumber *)dp)->Copy((TPDocNumber *)src->IPElement); break; case detFormula: dp = new TPDocFormula(this, src->IPElement->Range); ((TPDocFormula *)dp)->Copy((TPDocFormula *)src->IPElement); break; case detDate: dp = new TPDocDate(this, src->IPElement->Range); ((TPDocDate *)dp)->Copy((TPDocDate *)src->IPElement); break; case detEdit: dp = new TPDocEdit(this, src->IPElement->Range); ((TPDocEdit *)dp)->Copy((TPDocEdit *)src->IPElement); break; case detImage: dp = new TPDocImage(this, src->IPElement->Range); ((TPDocImage *)dp)->Copy((TPDocImage *)src->IPElement); break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox: dp = new TPDocComboBox(this, src->IPElement->Range); ((TPDocComboBox *)dp)->Copy((TPDocComboBox *)src->IPElement); break; } IPElement = (TPDocElement *)dp; // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocInput::IsExist(POINT pt) { if (TPDocElement::IsExist(pt)) { if (Style == disVertical) { FSelectTitle = pt.y - Range.top < Position; } else { FSelectTitle = pt.x - Range.left < Position; } return true; } return false; } //--------------------------------------------------------------------------- void __fastcall TPDocInput::SetElement(TPDocElement *Element, TPDocElementType et) { RECT src = IPElement->Range; /* switch (IPElement->Type) { case detColorChip: delete (TPDocColorChip *)IPElement; break; case detNumber: delete (TPDocNumber *)IPElement; break; case detFormula: delete (TPDocFormula *)IPElement; break; case detEdit: delete (TPDocEdit *)IPElement; break; case detImage: delete (TPDocImage *)IPElement; break; } */ RemoveData(); switch (et) { case detColorChip: IPElement = (TPDocElement *)(new TPDocColorChip(Element, src)); break; case detNumber: IPElement = (TPDocElement *)(new TPDocNumber(Element, src)); break; case detFormula: IPElement = (TPDocElement *)(new TPDocFormula(Element, src)); break; case detDate: IPElement = (TPDocElement *)(new TPDocDate(Element, src)); break; case detEdit: IPElement = (TPDocElement *)(new TPDocEdit(Element, src)); break; case detImage: IPElement = (TPDocElement *)(new TPDocImage(Element, src)); break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox: IPElement = (TPDocElement *)(new TPDocComboBox(Element, src)); break; } } //--------------------------------------------------------------------------- TPDocControlMode __fastcall TPDocInput::GetControlMode(int X, int Y) { int px, py; if (Style == disVertical) { px = (Range.right + Range.left) / 2; py = Range.top+Position; } else { px = Range.left+Position; py = (Range.bottom + Range.top) / 2; } if (X >= px - 2 && X < px + 3 && Y >= py - 2 && Y < py + 3) { return Style == disVertical ? dcmVertical : dcmHorizontal; } return TPDocElement::GetControlMode(X, Y); } //--------------------------------------------------------------------- void __fastcall TPDocInput::GetNewRange(int X, int Y) { switch (ControlMode) { case dcmHorizontal: if (X < Range.left) { FOldPosition = 0; } else if (X >= Range.right) { FOldPosition = Range.right - Range.left; } else { FOldPosition = X - Range.left; } break; case dcmVertical: if (Y < Range.top) { FOldPosition = 0; } else if (Y >= Range.bottom) { FOldPosition = Range.bottom - Range.top; } else { FOldPosition = Y - Range.top; } break; default: TPDocElement::GetNewRange(X, Y); break; } } //--------------------------------------------------------------------- void __fastcall TPDocInput::ControlModeMouseDown(TShiftState Shift, int X, int Y) { FOldPosition = Position; TPDocElement::ControlModeMouseDown(Shift, X, Y); } //--------------------------------------------------------------------- void __fastcall TPDocInput::ControlModeMouseMove(HDC hDC, TPDocViewStatus &vs, int X, int Y) { PaintControl(hDC, vs); GetNewRange(X, Y); PaintControl(hDC, vs); } //--------------------------------------------------------------------- void __fastcall TPDocInput::ControlModeMouseUp() { switch (ControlMode) { case dcmHorizontal: case dcmVertical: Position = FOldPosition; break; default: TPDocElement::ControlModeMouseUp(); break; } if (Style == disHorizental) { IPElement->Range = Rect(Position, 0, Range.right - Range.left, Range.bottom - Range.top); } else { IPElement->Range = Rect(0, Position, Range.right - Range.left, Range.bottom - Range.top); } } //--------------------------------------------------------------------------- // // TPDocChart // //--------------------------------------------------------------------------- int TPDocChart::FIDCount = 0; //--------------------------------------------------------------------------- __fastcall TPDocChart::TPDocChart(TPDocObject *Sender, RECT rc, TPDocAlign ta, int col, int row, TColor c, bool beditformula, TPDocElementType et) : TPDocText(Sender, detChart, rc, ta) { int i, j, x, y, gx, gy; int *PosX, *PosY; TPDocEdit *ep; TPDocColorChip *cp; TPDocNumber *np; TPDocFormula *fp; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) TPDocComboBox *cbp; // Chart óÀ½ »ý¼ºÇÒ ¶§ ³ôÀÌ ³Êºñ ¶È°°ÀÌ ¸ÂÃß±â (2007. 05. 21 Annualring) int xDistance, yDistance; FID = ++FIDCount; Cols = col; Rows = row; //FrameColor = c; FrameColor.left = c; FrameColor.top = c; FrameColor.right = c; FrameColor.bottom = c; EditFormula = beditformula; Cell = new TList; bFXIndex = false; bFYIndex = false; SelectCell = NULL; Sheet = NULL; // FNumber = -1; //by linuxjun FNumber = 0; //by linuxjun for linuxjun if (Cols == 0 || Rows == 0) return; xDistance = (rc.right - rc.left); gx = (rc.right - rc.left) / Cols; PosX = new int[(Cols + 1) * Rows]; for (i = 0; i < Rows; i++) { for (j = 0; j < Cols; j++) { // Chart óÀ½ »ý¼ºÇÒ ¶§ ³ôÀÌ ³Êºñ ¶È°°ÀÌ ¸ÂÃß±â (2007. 05. 21 Annualring) //PosX[i*(Cols+1) + j] = j * gx; PosX[i*(Cols+1) + j] = (xDistance * j) / Cols; } PosX[i*(Cols+1) + j] = rc.right - rc.left; } yDistance = (rc.bottom - rc.top); gy = (rc.bottom - rc.top) / Rows; PosY = new int[Cols * (Rows + 1)]; for (j = 0; j < Cols; j++) { for (i = 0; i < Rows; i++) { // Chart óÀ½ »ý¼ºÇÒ ¶§ ³ôÀÌ ³Êºñ ¶È°°ÀÌ ¸ÂÃß±â (2007. 05. 21 Annualring) //PosY[j*(Rows+1) + i] = i * gy; PosY[j*(Rows+1) + i] = (yDistance * i) / Rows; } PosY[j*(Rows+1) + i] = rc.bottom - rc.top; } for (y = 0; y < Rows; y++) { for (x = 0; x < Cols; x++) { switch (et) { case detEdit : ep = new TPDocEdit(this, Rect(PosX[y*(Cols+1) + x], PosY[x*(Rows+1) + y], PosX[y*(Cols+1) + x + 1], PosY[x*(Rows+1) + y +1])); ep->FrameColor = FrameColor; Cell->Add(ep); break; case detColorChip : cp = new TPDocColorChip(this, Rect(PosX[y*(Cols+1) + x], PosY[x*(Rows+1) + y], PosX[y*(Cols+1) + x + 1], PosY[x*(Rows+1) + y +1])); cp->FrameColor = FrameColor; Cell->Add(cp); break; case detNumber : np = new TPDocNumber(this, Rect(PosX[y*(Cols+1) + x], PosY[x*(Rows+1) + y], PosX[y*(Cols+1) + x + 1], PosY[x*(Rows+1) + y +1])); np->FrameColor = FrameColor; Cell->Add(np); break; case detFormula : fp = new TPDocFormula(this, Rect(PosX[y*(Cols+1) + x], PosY[x*(Rows+1) + y], PosX[y*(Cols+1) + x + 1], PosY[x*(Rows+1) + y +1])); fp->FrameColor = FrameColor; Cell->Add(fp); break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox : cbp = new TPDocComboBox(this, Rect(PosX[y*(Cols+1) + x], PosY[x*(Rows+1) + y], PosX[y*(Cols+1) + x + 1], PosY[x*(Rows+1) + y +1])); cbp->FrameColor = FrameColor; Cell->Add(cbp); break; } } } if (PosY) { delete [] PosY; PosY = NULL; } if (PosX) { delete [] PosX; PosX = NULL; } SetCursorIndex(); } //--------------------------------------------------------------------------- __fastcall TPDocChart::~TPDocChart() { RemoveData(); } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocChart::RemoveData() { TPDocElement *dp = NULL; if (Cell) { for (int i = 0; i < Cell->Count; i++) { // while (Cell->Count) { // dp = (TPDocElement *)Cell->First(); // Cell->Remove(dp); dp = (TPDocElement *)Cell->Items[i]; if (dp) { switch (dp->Type) { case detColorChip: delete (TPDocColorChip *)dp; dp = NULL; break; case detNumber: delete (TPDocNumber *)dp; dp = NULL; break; case detFormula: delete (TPDocFormula *)dp; dp = NULL; break; case detLabel: delete (TPDocLabel *)dp; dp = NULL; break; case detEdit: delete (TPDocEdit *)dp; dp = NULL; break; case detImage: delete (TPDocImage *)dp; dp = NULL; break; case detTextImage: delete (TPDocTextImage *)dp; dp = NULL; break; case detMemo: delete (TPDocMemo *)dp; dp = NULL; break; case detDate: delete (TPDocDate *)dp; dp = NULL; break; case detSignature: delete (TPDocSignature *)dp; dp = NULL; break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox: delete (TPDocComboBox *)dp; dp = NULL; break; } } } Cell->Clear(); delete Cell; Cell = NULL; } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { /* HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int i, x, y, gx, gy; TPDocObject *dp; try { hPen = CreatePen(psSolid, 1, Color); hOldPen = SelectObject(hDC, hPen); hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); for (i = 0; i < Cell->Count; i++) { dp = (TPDocObject *)Cell->Items[i]; Rectangle(hDC, rc.left + dp->Range.left, rc.top + dp->Range.top, rc.left + dp->Range.right + 1, rc.top + dp->Range.bottom + 1); } } __finally { if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); }*/ // PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetbFXIndex(bool bvalue) { bFXIndex = bvalue; } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetbFYIndex(bool bvalue) { bFYIndex = bvalue; } //--------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- void __fastcall TPDocChart::PaintSelectIn(HDC hDC, RECT rc) { PaintSelectInCommon(hDC, rc); } //--------------------------------------------------------------------------- void __fastcall TPDocChart::PaintControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; int i, j, x, y; TPDocElement *dp = NULL; try { if(ControlMode == dcmLeftTop || ControlMode == dcmRightTop || ControlMode == dcmLeftBottom || ControlMode == dcmRightBottom || ControlMode == dcmCenterTop || ControlMode == dcmLeftCenter) { hPen = CreatePen(PS_DOT, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_XORPEN); x = vs.Pattern2ViewX(FOldRect.left + FOldPositionX); y = vs.Pattern2ViewY(FOldRect.top + FOldPositionY); if(ControlMode == dcmLeftTop) { Rectangle(hDC, x, y, vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); }else if(ControlMode == dcmRightTop) { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), y, x, vs.Pattern2ViewY(FOldRect.bottom + 1)); }else if(ControlMode == dcmLeftBottom) { Rectangle(hDC, x, vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), y); }else if(ControlMode == dcmRightBottom) { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), x, y); }else if(ControlMode == dcmLeftCenter) { Rectangle(hDC, x, vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); }else if(ControlMode == dcmCenterTop) { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), y, vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); } }else if (ControlMode == dcmHorizontal) { hPen = CreatePen(PS_DOT, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_XORPEN); x = vs.Pattern2ViewX(FOldRect.left + FOldPositionX); if (x < FOldRect.right) { MoveToEx(hDC, x, vs.Pattern2ViewY(FOldRect.top), NULL); LineTo(hDC, x, vs.Pattern2ViewY(FOldRect.bottom)); } else { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), x, vs.Pattern2ViewY(FOldRect.bottom + 1)); } } else if (ControlMode == dcmVertical) { hPen = CreatePen(PS_DOT, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_XORPEN); y = vs.Pattern2ViewY(FOldRect.top + FOldPositionY); if (y < FOldRect.bottom) { MoveToEx(hDC, vs.Pattern2ViewX(FOldRect.left), y, NULL); LineTo(hDC, vs.Pattern2ViewX(FOldRect.right), y); } else { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), y); } } else if (ControlMode == dcmSelect) { hPen = CreatePen(PS_SOLID, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(BLACK_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect != dp->OldSelect) { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left + dp->Range.left) +3, vs.Pattern2ViewY(FOldRect.top + dp->Range.top) +3, vs.Pattern2ViewX(FOldRect.left + dp->Range.right) -2, vs.Pattern2ViewY(FOldRect.top + dp->Range.bottom) -2); dp->OldSelect = dp->NowSelect; } } } else if (ControlMode != dcmNone) { hPen = CreatePen(PS_DOT, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_XORPEN); Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left), vs.Pattern2ViewY(FOldRect.top), vs.Pattern2ViewX(FOldRect.right + 1), vs.Pattern2ViewY(FOldRect.bottom + 1)); } } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::PaintReportControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; int i, j, x, y; TPDocElement *dp = NULL; try { hPen = CreatePen(PS_SOLID, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(BLACK_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect != dp->OldSelect) { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left + dp->Range.left) +3, vs.Pattern2ViewY(FOldRect.top + dp->Range.top) +3, vs.Pattern2ViewX(FOldRect.left + dp->Range.right) -2, vs.Pattern2ViewY(FOldRect.top + dp->Range.bottom) -2); dp->OldSelect = dp->NowSelect; } } } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetCursorIndex() { if (Cell->Count == 0) return; TPDocElement *ep, *dp; int temp_left, temp_right; int last_left, last_right; for(int i = 0 ; i < Cell->Count ; i++) { ep = (TPDocElement *)Cell->Items[i]; ep->IndexR.left = -1; // ºÙ¾îÀÖ´Â Index°¡ ¾øÀ» ¶§ NULLÀÇ Àǹ̷Π-1 ep->IndexR.right = -1; ep->IndexR.up = -1; ep->IndexR.down = -1; for(int j = 0; j < Cell->Count; j++) { dp = (TPDocElement*)Cell->Items[j]; //left Index if(ep->Range.left - 1 > dp->Range.left && ep->Range.left - 1 < dp->Range.right && ep->Range.top + 1 > dp->Range.top && ep->Range.top + 1 < dp->Range.bottom) ep->IndexR.left = j; //right Index if(ep->Range.right + 1 > dp->Range.left && ep->Range.right + 1 < dp->Range.right && ep->Range.top + 1 > dp->Range.top && ep->Range.top + 1 < dp->Range.bottom) ep->IndexR.right = j; //up Index if(ep->Range.left + 1 > dp->Range.left && ep->Range.left + 1 < dp->Range.right && ep->Range.top - 1 > dp->Range.top && ep->Range.top - 1 < dp->Range.bottom) ep->IndexR.up = j; //down Index if(ep->Range.left + 1 > dp->Range.left && ep->Range.left + 1 < dp->Range.right && ep->Range.bottom + 1 > dp->Range.top && ep->Range.bottom + 1 < dp->Range.bottom) ep->IndexR.down = j; } /* for(int j = 0 ; j < Cell->Count ; j++) // Index µ¹¸é¼­ ÇØ´çÇÏ´Â Index Relation ÁöÁ¤ { dp = (TPDocElement *)Cell->Items[j]; if(dp->Range.left < ep->Range.left - 1 && dp->Range.right > ep->Range.left - 1 && dp->Range.top < ep->Range.top + 1 && dp->Range.bottom > ep->Range.top + 1) // ¿ÞÂÊ index ã±â ep->IndexR.left = j; else if(dp->Range.left < ep->Range.right + 1 && dp->Range.right > ep->Range.right + 1 && dp->Range.top < ep->Range.top + 1 && dp->Range.bottom > ep->Range.top + 1) // ¿À¸¥ÂÊ Index ã±â ep->IndexR.right = j; else if(dp->Range.left < ep->Range.left + 1 && dp->Range.right > ep->Range.left + 1 && dp->Range.top < ep->Range.top - 1 && dp->Range.bottom > ep->Range.top - 1) // À§ÂÊ Index ã±â ep->IndexR.up = j; else if(dp->Range.left < ep->Range.left + 1 && dp->Range.right > ep->Range.left + 1 && dp->Range.top < ep->Range.bottom + 1 && dp->Range.bottom > ep->Range.bottom + 1) // ¿À¸¥ÂÊ Index ã±â ep->IndexR.down = j; } temp_left = ep->IndexR.left; temp_right = ep->IndexR.right; for(int j = 0 ; j < Cell->Count ; j++) // Index µ¹¸é¼­ ÇØ´çÇÏ´Â Index Relation ÁöÁ¤ { dp = (TPDocElement *)Cell->Items[j]; if (dp->Type == detEdit || dp->Type == detDate || dp->Type == detMemo || dp->Type == detNumber || dp->Type == detFormula) { // ComboBox Type Item °ü·ÃÇØ¼­ Ãß°¡ ÇÏÁö ¾Ê¾Ò´Ù. ¿Ö³ÄÇϸé Cursor°¡ ÇÊ¿ä ¾ø´Â °´Ã¼À̱⠶§¹®¿¡ (2007. 03. 05 Annualring) if(ep->IndexR.left == -1) // Ç¥ÀÇ °¡Àå ¿ÞÂÊÀ϶§ À§ÂÊ ÃÖ¿ìÃø Cell °Ë»ö { if(dp->Range.bottom > ep->Range.top - 1 && dp->Range.top < ep->Range.top - 1) { if(temp_left == -1) { last_left = dp->Range.left; temp_left = j; } else if(last_left < dp->Range.left) // ´õ ¿ìÃøÀÇ CellÀÏ °æ¿ì { last_left = dp->Range.left; temp_left = j; } } } if(ep->IndexR.right == -1) // Ç¥ÀÇ °¡Àå ¿À¸¥ÂÊÀ϶§ ¾Æ·¡ÂÊ ÃÖÁÂÃø Cell °Ë»ö { if(dp->Range.bottom > ep->Range.bottom + 1 && dp->Range.top < ep->Range.bottom + 1) { if(temp_right == -1) { last_right = dp->Range.left; temp_right = j; } else if(last_right > dp->Range.left) // ´õ ÁÂÃøÀÇ CellÀÏ °æ¿ì { last_right = dp->Range.left; temp_right = j; } } } } } ep->IndexR.left = temp_left; ep->IndexR.right = temp_right; */ } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetSheet(TPDocSheet *sheet){ Sheet = sheet; } // UnitCell ÇÔ¼ö ¼öÁ¤ (Cell Index ¸ÂÃß±â) (2007. 03. 29 Annualring) void __fastcall TPDocChart::UnitCell() { if (Cell->Count == 0) return; TPDocElement *default_dep, *dep; TPDocColorChip *cp; TPDocNumber *np; TPDocFormula *fp; TPDocLabel *lp; TPDocEdit *ep; TPDocImage *ip; TPDocTextImage *tp; TPDocMemo *mp; TPDocDate *dp; TPDocSignature *sp; TPDocLineStyle ls; TColor fc; // bool first = true; //Cell Áß °¡Àå ù¹øÂ° ³ª¿À´Â ³ðÀÇ top ÇÁ·¹ÀÓ½ºÅ¸ÀÏÀ» µû¿Â´Ù. int i, cnt; int firstCellIndex = -1; // (2007. 03. 28 Annualring) int standardCellIndex; // (2007. 03. 28 Annualring) RECT rt; TPDocElementType et; // FNumber¿¡ ÇØ´çÇÏ´Â ³à¼®Àº Áö¿ìÁö ¾Ê´Â´Ù. default_dep =(TPDocElement *)Cell->Items[FNumber]; rt = default_dep->Range; et = default_dep->Type; // Cell IndexÁ¤·Ä °ü·Ã // ÇÕÄ¡±â ±âÁØ ¼¿À» ¼¿ ÇÕÄ¡±â ÇÒ ¼¿µé Áß °¡Àå ºü¸¥ Index·Î ÇØÁØ´Ù. // (2007. 03. 28 Annualring) for (i = 0, cnt = 0; i < Cell->Count;i++) { dep = (TPDocElement *)Cell->Items[i]; if (dep->NowSelect) { if (firstCellIndex < 0) { firstCellIndex = i; } cnt++; } } ///////// if (cnt <= 1) return; //¼±ÅÃµÈ°Ô Çϳª¸¸ ÀÖÀ¸¸é ÇÕÄ¥Çʿ䰡 ¾ø´Ù! ElementUndoSave(); //For Undo UndoSave(this); //for Undo for (i = 0; i < Cell->Count; ) { dep = (TPDocElement *)Cell->Items[i]; if (dep->NowSelect) { //if (first) { ls = dep->FrameStyle.top; fc = dep->FrameColor; first = false; } rt.left = min((int)rt.left, (int)dep->Range.left); rt.top = min((int)rt.top, (int)dep->Range.top); rt.right = max((int)rt.right, (int)dep->Range.right); rt.bottom = max((int)rt.bottom, (int)dep->Range.bottom); if (default_dep == dep) { i++; continue; } Cell->Remove(dep); DeleteUndoSave(dep); /* For Delete Undo switch (dep->Type) { case detColorChip: delete (TPDocColorChip *)dep; break; case detNumber: delete (TPDocNumber *)dep; break; case detFormula: delete (TPDocFormula *)dep; break; case detLabel: delete (TPDocLabel *)dep; break; case detEdit: delete (TPDocEdit *)dep; break; case detImage: delete (TPDocImage *)dep; break; case detTextImage: delete (TPDocTextImage *)dep; break; case detMemo: delete (TPDocMemo *)dep; break; case detDate: delete (TPDocDate *)dep; break; case detSignature: delete (TPDocSignature *)dep; break; } */ } else i++; } UndoSave(default_dep); //for Undo default_dep->Range = rt; // Cell IndexÁ¤·Ä °ü·Ã // ÇÕÄ¡±â ±âÁØ ¼¿À» ¼¿ ÇÕÄ¡±â ÇÒ ¼¿µé Áß °¡Àå ºü¸¥ Index·Î ÇØÁØ´Ù. // (2007. 03. 28 Annualring) standardCellIndex = Cell->IndexOf(default_dep); Cell->Move(standardCellIndex, firstCellIndex); /////////// SetCursorIndex(); } //--------------------------------------------------------------------------- /** * Cell Index À¯Áö¸¦ À§ÇØ ¼öÁ¤ * Cell ³ª´©±â¸¦ ½ÇÇàÇϸé Cell Index ¼ø¼­°¡ ¹Ù²î´Â ¹®Á¦ ÇØ°á * ÇÔ¼ö¸í devide -> divide ·Î ¼öÁ¤ (2007. 06. 12 Annualring) */ // (2007. 03. 27 Annualring) void __fastcall TPDocChart::DivideCell(int row, int col) { if (Cell->Count == 0) return; TPDocElement *dep, *dp; /*TPDocColorChip *cp; TPDocNumber *np; TPDocFormula *fp; TPDocLabel *lp; TPDocEdit *ep; TPDocImage *ip; TPDocTextImage *tp; TPDocMemo *mp; TPDocDate *dp; TPDocSignature *sp; TPDocLineStyle ls; TColor fc; */ RECT rt; TPDocElementType et; TList *Temp; int i, x, y, w, h; int selectCellCount = 0; // (2007. 03. 27. Annualring) TList *cellInsertIndex; // (2007. 03. 27. Annualring) int dividedCellCount; // (2007. 03. 27. Annualring) int xDistance, yDistance; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) /** TPDocNumber::FIDCount = 0; TPDocFormula::FIDCount = 0; TPDocChart::FIDCount = 0; // ÇÏÁö¸¸ ChartÀÇ CopyÇÔ¼ö´Â ¹Ù²ÙÁö ¾Ê¾Ò´Ù. (2007. 03. 27 Annualring) */ // ÀÏ´Ü UniqueNumberingÀ» Disable ½ÃÄѳõÀÚ (2007. 03. 27 Annualring) // µðÀÚÀÎ½Ç ¿äûÀ¸·Î º¯°æ (2007. 08. 20 Annualring) bool isUniqueNumbering = true; ///< ³ª´©¾îÁø ¼¿ µéÀÌ °¢°¢ °íÀ¯ÇÑ ID¸¦ °¡Áö°Ô ÇÒ °ÍÀÎÁöÀÇ ¿©ºÎ¸¦ ÀúÀåÇÏ´Â º¯¼ö ElementUndoSave(); //For Undo UndoSave(this); //for Undo Temp = new TList; cellInsertIndex = new TList; // (2007. 03. 27. Annualring) for (i = 0; i < Cell->Count; ) { dep = (TPDocElement *)Cell->Items[i]; if (dep->NowSelect) { Cell->Remove(dep); Temp->Add(dep); cellInsertIndex->Add((void*)(i + (col * row * selectCellCount))); // (2007. 03. 27. Annualring) selectCellCount++; // (2007. 03. 27. Annualring) } else i++; } selectCellCount = 0; // (2007. 03. 27. Annualring) while (Temp->Count) { dep = (TPDocElement *)Temp->First(); // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) xDistance = (dep->Range.right - dep->Range.left); yDistance = (dep->Range.bottom - dep->Range.top); w = xDistance / col; h = yDistance / row; dividedCellCount = 0; // (2007. 03. 27. Annualring) switch (dep->Type) { case detColorChip: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocColorChip(this, rt); ((TPDocColorChip *)dp)->Copy((TPDocColorChip *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocColorChip *)dep; //For DeleteUndo break; case detNumber: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocNumber(this, rt); // (2007. 03. 27 Annualring) ((TPDocNumber *)dp)->Copy((TPDocNumber *)dep, !isUniqueNumbering); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocNumber *)dp)->SetNumber(""); CreateUndoSave(dp); // (2007. 03. 27. Annualring) // ´Ù¸¥°Ç ´Ù ±¦ÂúÀºµ¥ ±âÁ¸ ÅØ½º¿÷¿¡ ¹®Á¦°¡ Á» ÀÖ´Â µí. // ³ª´©¾îÁø ¼¿µéÀÌ ¸ðµÎ °°Àº FID¸¦ °¡Áø´Ù. ±×¸®°í ±× ¿øÀÎÀº // CopyÇÔ¼ö¿¡ ÀÖ´Ù. (2007. 03. 27 Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocNumber *)dep; //For DeleteUndo break; case detFormula: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocFormula(this, rt); // (2007. 03. 27 Annualring) ((TPDocFormula *)dp)->Copy((TPDocFormula *)dep, !isUniqueNumbering); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocFormula *)dp)->SetNumber(""); CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocFormula *)dep; //For DeleteUndo break; case detLabel: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocLabel(this, rt); ((TPDocLabel *)dp)->Copy((TPDocLabel *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocLabel *)dep; //For DeleteUndo break; case detEdit: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocEdit(this, rt); ((TPDocEdit *)dp)->Copy((TPDocEdit *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocEdit *)dp)->SetK_Text((WideString)""); CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocEdit *)dep; //For DeleteUndo break; case detImage: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocImage(this, rt); ((TPDocImage *)dp)->Copy((TPDocImage *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) { if (((TPDocImage *)dp)->Image != NULL) { delete ((TPDocImage *)dp)->Image; ((TPDocImage *)dp)->Image = NULL; } } CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocImage *)dep; //For DeleteUndo break; case detTextImage: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocTextImage(this, rt); ((TPDocTextImage *)dp)->Copy((TPDocTextImage *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) { if (((TPDocTextImage *)dp)->Image != NULL) { delete ((TPDocTextImage *)dp)->Image; ((TPDocTextImage *)dp)->Image = NULL; } } CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocTextImage *)dep; //For DeleteUndo break; case detMemo: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocMemo(this, rt); ((TPDocMemo *)dp)->Copy((TPDocMemo *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocMemo *)dp)->Text = ""; CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocMemo *)dep; //For DeleteUndo break; case detDate: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocDate(this, rt); ((TPDocDate *)dp)->Copy((TPDocDate *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocDate *)dp)->Date = ""; CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocDate *)dep; //For DeleteUndo break; case detSignature: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocSignature(this, rt); ((TPDocSignature *)dp)->Copy((TPDocSignature *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocSignature *)dp)->Image->FillRect(Rect(0, 0, ((TPDocSignature *)dp)->Image->Width, ((TPDocSignature *)dp)->Image->Height), clWhite); CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocSignature *)dep; //For DeleteUndo break; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) case detComboBox: for (y = 0; y < row; y++) { // rt.top = dep->Range.top + y*h; // if (y == row -1) rt.bottom = dep->Range.bottom; // else rt.bottom = dep->Range.top + (y+1)*h; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.top = dep->Range.top + (y * yDistance) / row; if (y == row -1) rt.bottom = dep->Range.bottom; else rt.bottom = dep->Range.top + ((y + 1) * yDistance) / row; for (x = 0; x < col; x++) { // rt.left = dep->Range.left + x*w; // if (x == col -1) rt.right = dep->Range.right; // else rt.right = dep->Range.left + (x+1)*w; // ¼¿ ³ª´©±â ÇÒ¶§ ³Êºñ ³ôÀ̰¡ ±ÕµîÇÏÁö ¾ÊÀº ¹®Á¦ ÇØ°á (2007. 06. 12. Annualring) rt.left = dep->Range.left + (x * xDistance) / col; if (x == col -1) rt.right = dep->Range.right; else rt.right = dep->Range.left + ((x+1) * xDistance) / col; dp = new TPDocComboBox(this, rt); ((TPDocComboBox *)dp)->Copy((TPDocComboBox *)dep); dp->Range = rt; //±âÁ¸ ¼¿ Å׵θ® ¼³Á¤ Àû¿ëµÇµµ·Ï Ãß°¡ dp->FrameStyle = dep->FrameStyle; dp->FrameColor = dep->FrameColor; if (!(x == 0 && y == 0)) ((TPDocComboBox *)dp)->SetData_Text(""); CreateUndoSave(dp); // (2007. 03. 27. Annualring) //Cell->Add(dp); Cell->Insert(((int)cellInsertIndex->Items[selectCellCount]) + dividedCellCount, dp); dividedCellCount++; /////////////// (2007. 03. 27. Annualring) } } Temp->Remove(dep); DeleteUndoSave(dep); //For DeleteUndo //delete (TPDocComboBox *)dep; //For DeleteUndo break; } selectCellCount++; // (2007. 03. 27. Annualring) } delete Temp; SetCursorIndex(); /* while (Temp->Count) { dep = (TPDocElement *)Temp->First(); ls = dep->FrameStyle.top; fc = dep->FrameColor; w = (dep->Range.right - dep->Range.left) / col; h = (dep->Range.bottom - dep->Range.top) / row; switch (dep->Type) { case detColorChip: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; cp = new TPDocColorChip(this, rt); cp->FrameStyle.left = ls; cp->FrameStyle.right = ls; cp->FrameStyle.top = ls; cp->FrameStyle.bottom = ls; cp->FrameColor = fc; Cell->Add(cp); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; cp = new TPDocColorChip(this, rt); cp->FrameStyle.left = ls; cp->FrameStyle.right = ls; cp->FrameStyle.top = ls; cp->FrameStyle.bottom = ls; cp->FrameColor = fc; Cell->Add(cp); } delete (TPDocColorChip *)dep; break; case detNumber: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; np = new TPDocNumber(this, rt); np->FrameStyle.left = ls; np->FrameStyle.right = ls; np->FrameStyle.top = ls; np->FrameStyle.bottom = ls; np->FrameColor = fc; Cell->Add(np); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; np = new TPDocNumber(this, rt); np->FrameStyle.left = ls; np->FrameStyle.right = ls; np->FrameStyle.top = ls; np->FrameStyle.bottom = ls; np->FrameColor = fc; Cell->Add(np); } delete (TPDocNumber *)dep; break; case detFormula: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; fp = new TPDocFormula(this, rt); fp->FrameStyle.left = ls; fp->FrameStyle.right = ls; fp->FrameStyle.top = ls; fp->FrameStyle.bottom = ls; fp->FrameColor = fc; Cell->Add(fp); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; fp = new TPDocFormula(this, rt); fp->FrameStyle.left = ls; fp->FrameStyle.right = ls; fp->FrameStyle.top = ls; fp->FrameStyle.bottom = ls; fp->FrameColor = fc; Cell->Add(fp); } delete (TPDocFormula *)dep; break; case detLabel: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; lp = new TPDocLabel(this, rt); lp->FrameStyle.left = ls; lp->FrameStyle.right = ls; lp->FrameStyle.top = ls; lp->FrameStyle.bottom = ls; lp->FrameColor = fc; Cell->Add(lp); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; lp = new TPDocLabel(this, rt); lp->FrameStyle.left = ls; lp->FrameStyle.right = ls; lp->FrameStyle.top = ls; lp->FrameStyle.bottom = ls; lp->FrameColor = fc; Cell->Add(lp); } delete (TPDocLabel *)dep; break; case detEdit: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; ep = new TPDocEdit(this, rt); ep->FrameStyle.left = ls; ep->FrameStyle.right = ls; ep->FrameStyle.top = ls; ep->FrameStyle.bottom = ls; ep->FrameColor = fc; Cell->Add(ep); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; ep = new TPDocEdit(this, rt); ep->FrameStyle.left = ls; ep->FrameStyle.right = ls; ep->FrameStyle.top = ls; ep->FrameStyle.bottom = ls; ep->FrameColor = fc; Cell->Add(ep); } delete (TPDocEdit *)dep; break; case detImage: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; ip = new TPDocImage(this, rt); ip->FrameStyle.left = ls; ip->FrameStyle.right = ls; ip->FrameStyle.top = ls; ip->FrameStyle.bottom = ls; ip->FrameColor = fc; Cell->Add(ip); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; ip = new TPDocImage(this, rt); ip->FrameStyle.left = ls; ip->FrameStyle.right = ls; ip->FrameStyle.top = ls; ip->FrameStyle.bottom = ls; ip->FrameColor = fc; Cell->Add(ip); } delete (TPDocImage *)dep; break; case detTextImage: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; tp = new TPDocTextImage(this, rt); tp->FrameStyle.left = ls; tp->FrameStyle.right = ls; tp->FrameStyle.top = ls; tp->FrameStyle.bottom = ls; tp->FrameColor = fc; Cell->Add(tp); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; tp = new TPDocTextImage(this, rt); tp->FrameStyle.left = ls; tp->FrameStyle.right = ls; tp->FrameStyle.top = ls; tp->FrameStyle.bottom = ls; tp->FrameColor = fc; Cell->Add(tp); } delete (TPDocTextImage *)dep; break; case detMemo: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; mp = new TPDocMemo(this, rt); mp->FrameStyle.left = ls; mp->FrameStyle.right = ls; mp->FrameStyle.top = ls; mp->FrameStyle.bottom = ls; mp->FrameColor = fc; Cell->Add(mp); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; mp = new TPDocMemo(this, rt); mp->FrameStyle.left = ls; mp->FrameStyle.right = ls; mp->FrameStyle.top = ls; mp->FrameStyle.bottom = ls; mp->FrameColor = fc; Cell->Add(mp); } delete (TPDocMemo *)dep; break; case detDate: for (y = 0; y < row; y++) { if (y == row -1) { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.bottom; } else { rt.top = dep->Range.top + y*h; rt.bottom = dep->Range.top + (y+1)*h; } for (x = 0; x < col -1; x++) { rt.left = dep->Range.left + x*w; rt.right = dep->Range.left + (x+1)*w; dp = new TPDocDate(this, rt); dp->FrameStyle.left = ls; dp->FrameStyle.right = ls; dp->FrameStyle.top = ls; dp->FrameStyle.bottom = ls; dp->FrameColor = fc; Cell->Add(dp); } rt.left = dep->Range.left + x*w; rt.right = dep->Range.right; dp = new TPDocDate(this, rt); dp->FrameStyle.left = ls; dp->FrameStyle.right = ls; dp->FrameStyle.top = ls; dp->FrameStyle.bottom = ls; dp->FrameColor = fc; Cell->Add(dp); } delete (TPDocDate *)dep; break; default: break; } Temp->Remove(dep); } delete Temp;*/ } //-------------------------------------------------------------------------- void __fastcall TPDocChart::SetPrecision(int value) { if (Cell->Count == 0) return; TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { //if(Sheet)Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo if (dp->Type == detNumber) ((TPDocNumber *)dp)->Precision = value; else if (dp->Type == detFormula) ((TPDocFormula *)dp)->Precision = value; } } } //-------------------------------------------------------------------------- /* void __fastcall TPDocChart::SetCaption(AnsiString str) { ElementUndoSave(); //For Undo TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { //if(Sheet)Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo if (dp->Type == detLabel) ((TPDocLabel *)dp)->Text = str; else if (dp->Type == detImage) ((TPDocImage *)dp)->ImgTitle = str; else if (dp->Type == detMemo) ((TPDocMemo *)dp)->Title = str; } } } //-------------------------------------------------------------------------- */ // by altang void __fastcall TPDocChart::SetCaption(WideString str) { if (Cell->Count == 0) return; ElementUndoSave(); //For Undo TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { //if(Sheet)Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo if (dp->Type == detLabel) ((TPDocLabel *)dp)->Text = str; else if (dp->Type == detImage) ((TPDocImage *)dp)->ImgTitle = str; else if (dp->Type == detMemo) ((TPDocMemo *)dp)->Title = str; } } } //-------------------------------------------------------------------------- void __fastcall TPDocChart::SetID(AnsiString str) { if (Cell->Count == 0) return; /* TPDocElement *dp; dp = (TPDocElement *)Cell->Items[FNumber]; if (dp->NowSelect) { if (dp->Type == detNumber) ((TPDocNumber *)dp)->Name = str; else if (dp->Type == detFormula) ((TPDocFormula *)dp)->Name = str; else if (dp->Type == detDate) ((TPDocDate *)dp)->Name = str; else if (dp->Type == detEdit) ((TPDocEdit *)dp)->Name = str; else if (dp->Type == detColorChip) ((TPDocColorChip *)dp)->Name = str; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) else if (dp->Type == detComboBox) ((TPDocComboBox *)dp)->Name = str; else if (dp->Type == detImage) ((TPDocImage *)dp)->Name = str; } */ //¿©·¯ ¼¿ÀÌ ¼±ÅÃµÈ °æ¿ì ID¸¦ ¼±ÅÃµÈ ¼¿ ¸ðµÎ¿¡ ´ëÇØ À§ÇØ ¼öÁ¤ for (int idx = 0; idx < Cell->Count; idx++) { TPDocElement *dp = (TPDocElement*)Cell->Items[idx]; if (dp->NowSelect) { if (dp->Type == detNumber) ((TPDocNumber *)dp)->Name = str; else if (dp->Type == detFormula) ((TPDocFormula *)dp)->Name = str; else if (dp->Type == detDate) ((TPDocDate *)dp)->Name = str; else if (dp->Type == detEdit) ((TPDocEdit *)dp)->Name = str; else if (dp->Type == detColorChip) ((TPDocColorChip *)dp)->Name = str; // ComboBox Type Item Ãß°¡ (2007. 03. 05 Annualring) else if (dp->Type == detComboBox) ((TPDocComboBox *)dp)->Name = str; else if (dp->Type == detImage) ((TPDocImage *)dp)->Name = str; } } } //-------------------------------------------------------------------------- void __fastcall TPDocChart::SetSaveJpgOn() //for ¾ÆÀ̺ñ 2005.06.15 { if (Cell->Count == 0) return; TPDocElement *dp; for (int i = 0; i < Cell->Count;i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ if(dp->Type == detLabel){ ((TPDocLabel *)dp)->bSaveToJPG = false; }else if(dp->Type == detEdit){ ((TPDocEdit *)dp)->bSaveToJPG = false; } } } } //-------------------------------------------------------------------------- void __fastcall TPDocChart::SetSaveJpgOff() //for ¾ÆÀ̺ñ 2005.06.15 { if (Cell->Count == 0) return; TPDocElement *dp; for (int i = 0; i < Cell->Count;i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ if(dp->Type == detLabel){ ((TPDocLabel *)dp)->bSaveToJPG = true; }else if(dp->Type == detEdit){ ((TPDocEdit *)dp)->bSaveToJPG = true; } } } } //-------------------------------------------------------------------------- void __fastcall TPDocChart::SelectAllCell() { if (Cell->Count == 0) return; TPDocElement *dp; SelectUndoSave(); //For Undo for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if(dp->OldSelect!=true || dp->NowSelect!=true){ UndoSave(dp); //for Undo } dp->NowSelect = true; dp->OldSelect = true; } } //-------------------------------------------------------------------------- void __fastcall TPDocChart::SetCellFrame(TPDocLineStyle lt, bool bleft, bool btop, bool bright, bool bbottom, bool bhorz, bool bvert) { if (Cell->Count == 0) return; RECT rt; int i; TPDocElement *dp; rt = GetPerfectRect(); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { // Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo if (bleft) { if (dp->Range.left == rt.left) dp->FrameStyle.left = lt; } if (bright && bvert) { if (dp->Range.left != rt.left) dp->FrameStyle.left = lt; dp->FrameStyle.right = lt; } else if (!bright && bvert) { if (dp->Range.left != rt.left) dp->FrameStyle.left = lt; if (dp->Range.right != rt.right) dp->FrameStyle.right = lt; } else if (bright && !bvert) { if (dp->Range.right == rt.right) dp->FrameStyle.right = lt; } if (btop) { if (dp->Range.top == rt.top) dp->FrameStyle.top = lt; } if (bbottom && bhorz) { if (dp->Range.top != rt.top) dp->FrameStyle.top = lt; dp->FrameStyle.bottom = lt; } else if (!bbottom && bhorz) { if (dp->Range.top != rt.top) dp->FrameStyle.top = lt; if (dp->Range.bottom != rt.bottom) dp->FrameStyle.bottom = lt; } else if (bbottom && !bhorz) { if (dp->Range.bottom == rt.bottom) dp->FrameStyle.bottom = lt; } } } } //--------------------------------------------------------------------------- //void __fastcall TPDocChart::SetCellColor(TColor color) //frameÀÇ line type ó·³ °¢ º¯¸¶´Ù ¼³Á¤ÇÒ ¼ö ÀÖµµ·Ï ¼öÁ¤ void __fastcall TPDocChart::SetCellColor(TColor color, bool bleft, bool btop, bool bright, bool bbottom, bool bhorz, bool bvert) { if (Cell->Count == 0) return; RECT rt = GetPerfectRect(); TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (bleft) { if (dp->Range.left == rt.left) dp->FrameColor.left = color; } if (bright && bvert) { if (dp->Range.left != rt.left) dp->FrameColor.left = color; dp->FrameColor.right = color; } else if (!bright && bvert) { if (dp->Range.left != rt.left) dp->FrameColor.left = color; if (dp->Range.right != rt.right) dp->FrameColor.right = color; } else if (bright && !bvert) { if (dp->Range.right == rt.right) dp->FrameColor.right = color; } if (btop) { if (dp->Range.top == rt.top) dp->FrameColor.top = color; } if (bbottom && bhorz) { if (dp->Range.top != rt.top) dp->FrameColor.top = color; dp->FrameColor.bottom = color; } else if (!bbottom && bhorz) { if (dp->Range.top != rt.top) dp->FrameColor.top = color; if (dp->Range.bottom != rt.bottom) dp->FrameColor.bottom = color; } else if (bbottom && !bhorz) { if (dp->Range.bottom == rt.bottom) dp->FrameColor.bottom = color; } } } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetCellFrameForMultiSelect(TPDocLineStyle lt, bool bleft, bool btop, bool bright, bool bbottom) { if (Cell->Count == 0) return; TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (bleft) dp->FrameStyle.left = lt; if (btop) dp->FrameStyle.top = lt; if (bright) dp->FrameStyle.right = lt; if (bbottom) dp->FrameStyle.bottom = lt; } } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetCellColorForMultiSelect(TColor color, bool bleft, bool btop, bool bright, bool bbottom) { if (Cell->Count == 0) return; TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (bleft) dp->FrameColor.left = color; if (btop) dp->FrameColor.top = color; if (bright) dp->FrameColor.right = color; if (bbottom) dp->FrameColor.bottom = color; } } } //--------------------------------------------------------------------------- /*bool __fastcall TPDocChart::SetCellSize(int col, int row, TPDocElementType et) { int i, j, gx, gy; TPDocEdit *ep; TPDocColorChip *cp; TPDocNumber *np; TPDocFormula *fp; int *PosX, *PosY; RemoveData(); Cols = col; Rows = row; Cell = new TList; gx = (Range.right - Range.left) / Cols; PosX = new int[(Cols + 1) * Rows]; for (i = 0; i < Rows; i++) { for (j = 0; j < Cols; j++) PosX[i*(Cols+1) + j] = j * gx; PosX[i*(Cols+1) + j] = Range.right - Range.left; } gy = (Range.bottom - Range.top) / Rows; PosY = new int[Cols * (Rows + 1)]; for (j = 0; j < Cols; j++) { for (i = 0; i < Rows; i++) PosY[j*(Rows+1) + i] = i * gy; PosY[j*(Rows+1) + i] = Range.bottom - Range.top; } for (i = 0; i < Rows; i++) { for (j = 0; j < Cols; j++) { switch (et) { case detEdit : ep = new TPDocEdit(this, Rect(PosX[i*(Cols+1) + j], PosY[j*(Rows+1) + i], PosX[i*(Cols+1) + j + 1], PosY[j*(Rows+1) + i +1])); Cell->Add(ep); break; case detColorChip : cp = new TPDocColorChip(this, Rect(PosX[i*(Cols+1) + j], PosY[j*(Rows+1) + i], PosX[i*(Cols+1) + j + 1], PosY[j*(Rows+1) + i +1])); Cell->Add(cp); break; case detNumber : np = new TPDocNumber(this, Rect(PosX[i*(Cols+1) + j], PosY[j*(Rows+1) + i], PosX[i*(Cols+1) + j + 1], PosY[j*(Rows+1) + i +1])); Cell->Add(np); break; case detFormula : fp = new TPDocFormula(this, Rect(PosX[i*(Cols+1) + j], PosY[j*(Rows+1) + i], PosX[i*(Cols+1) + j + 1], PosY[j*(Rows+1) + i +1])); Cell->Add(fp); break; } } } delete PosX; delete PosY; return true; fail: RemoveData(); return false; } */ //--------------------------------------------------------------------------- TFont *_fastcall TPDocChart::GetFont() { ///* TPDocElement *dp = NULL; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect) { if (!(dp->Type == detColorChip || dp->Type == detTextImage || dp->Type == detSignature)) { if (dp->Type == detMemo) return ((TPDocMemo *)dp)->GetFont(); else return ((TPDocText *)dp)->GetFont(); } } } //*/ return Font; } /* TFont *__fastcall TPDocChart::GetSelectedEltFont(){ TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (!(dp->Type == detColorChip || dp->Type == detTextImage || dp->Type == detSignature)) { if (dp->Type == detMemo) return ((TPDocMemo *)dp)->GetFont(); else return ((TPDocText *)dp)->GetFont(); } } } return Font; } */ //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetFont(TFont *font, TColor color) { if (Cell->Count == 0) return; TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (dp->Type == detMemo) ((TPDocMemo *)dp)->SetFont(font, color); else if (!(dp->Type == detColorChip || dp->Type == detTextImage || dp->Type == detSignature)) ((TPDocText *)dp)->SetFont(font, color); } } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetAlign(TPDocAlign al) { if (Cell->Count == 0) return; ElementUndoSave(); //For Undo TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (!(dp->Type == detColorChip || dp->Type == detTextImage || dp->Type == detSignature)) { //if(Sheet)Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo ((TPDocText *)dp)->Align = al; } } } } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsPerfectRect() { if (Cell->Count == 0) return false; //¼±ÅÃµÈ ¼¿·Î ÀÌ·ç¾îÁø ¿µ¿ªÀÌ ¿ÏÀüÇÑ »ç°¢Çü ¸ð¾çÀÎÁö ÆÇ´ÜÇÏ´Â ÇÔ¼ö TPDocElement *dp; int i, s1, s2; RECT rt; bool sw = true; s1 = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (sw) {rt = dp->Range; sw = false;} s1 += (dp->Range.right - dp->Range.left) * (dp->Range.bottom - dp->Range.top); rt.left = min((int)dp->Range.left, (int)rt.left); rt.right = max((int)dp->Range.right, (int)rt.right); rt.top = min((int)dp->Range.top, (int)rt.top); rt.bottom = max((int)dp->Range.bottom, (int)rt.bottom); } } s2 = (rt.bottom - rt.top) * (rt.right - rt.left); if (s1 == s2) return true; else return false; } //--------------------------------------------------------------------------- RECT __fastcall TPDocChart::GetPerfectRect() { TPDocElement *dp = NULL; int i; RECT rt; bool sw = true; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect) { if (sw) {rt = dp->Range; sw = false;} rt.left = min((int)dp->Range.left, (int)rt.left); rt.right = max((int)dp->Range.right, (int)rt.right); rt.top = min((int)dp->Range.top, (int)rt.top); rt.bottom = max((int)dp->Range.bottom, (int)rt.bottom); } } return rt; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsOneSelect() { if (Cell->Count == 0) return false; TPDocElement *dp = NULL; int cnt = 0; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect) { cnt++; if (cnt > 1) return false; } } if (cnt == 1) return true; else return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsSelecting() { if (Cell->Count == 0) return false; TPDocElement *dp = NULL; int cnt = 0; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect) { cnt++; if (cnt >= 1) return true; } } if (cnt == 0) return false; else return true; } //--------------------------------------------------------------------------- //ÇöÀç chartÀÇ ¼¿µéÀÌ ´ÙÁß¼±ÅÃµÈ »óÅÂÀÎÁö ¿©ºÎ¸¦ ¾Ë¾Æ³»´Â ÇÔ¼ö //IsPerfectRect() ÀÌ¿ëÇØ¼­ ¸¸µê bool __fastcall TPDocChart::IsMultiSelect() { TPDocElement *dp = NULL; int i, s1, s2; RECT rt; bool sw = true; s1 = 0; int cnt = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect) { cnt++; if (sw) {rt = dp->Range; sw = false;} s1 += (dp->Range.right - dp->Range.left) * (dp->Range.bottom - dp->Range.top); rt.left = min((int)dp->Range.left, (int)rt.left); rt.right = max((int)dp->Range.right, (int)rt.right); rt.top = min((int)dp->Range.top, (int)rt.top); rt.bottom = max((int)dp->Range.bottom, (int)rt.bottom); } } s2 = (rt.bottom - rt.top) * (rt.right - rt.left); if(cnt > 1 && s1 != s2) return true; else return false; } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SelectUndoSave(){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; Sheet->SelectUndoSave(); } } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsDesignMode(){ /* TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; if(Sheet->Design); } */ return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::ElementUndoSave(){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; return Sheet->ElementUndoSave(); } return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::ElementSizeUndoSave(){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; return Sheet->ElementSizeUndoSave(); } return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::ElementAddUndoSave(){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; return Sheet->ElementAddUndoSave(); } return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::UndoSave(TPDocElement *Src){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; Sheet->UndoSave(Src); } // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::DeleteUndoSave(TPDocElement *Src){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; Sheet->DeleteUndoSave(Src); } // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::CreateUndoSave(TPDocElement *Src){ TPDocSheet * Sheet; if(Parent){ Sheet = (TPDocSheet *)Parent; Sheet->CreateUndoSave(Src); } // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetElement(TPDocElement *Element, TPDocElementType et, bool bOnlyOne, bool bAutoLineFeed) { int i, n; RECT rt; TPDocElement *dp = NULL; TPDocColorChip *cp; TPDocNumber *np; TPDocFormula *fp; TPDocLabel *lp; TPDocEdit *ep; TPDocImage *ip; TPDocTextImage *tp; TPDocMemo *mp; TPDocSignature *sp; // ComboBox Type Item Ãß°¡ (2007. 03. 02 Annualring) TPDocComboBox *cbp; TPDocDate *dtp; TPDocBorder fs; //TColor fc; TPDocFrameColor fc; bool bselect; TFont *font; TFont *oldFont = new TFont; TPDocAlign ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) TPDocBackground background; bool visible; if (bOnlyOne) { //¼±ÅõȰͿ¡ »ó°ü¾øÀÌ Ä¿¼­°¡ ÀÖ´Â ¾ÆÀÌÅÛ Çϳª¸¸ ¹Ù²Ü·Á°í ÇÒ¶§ ElementUndoSave(); //For Undo UndoSave(this); //for Undo dp = (TPDocElement *)Cell->Items[FNumber]; if (dp) { rt = dp->Range; fs = dp->FrameStyle; fc = dp->FrameColor; visible = dp->bVisible; bselect = dp->NowSelect; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) background = dp->Background; if (dp->Type == detMemo) { font = ((TPDocMemo *)dp)->GetFont(); oldFont->Assign(font); // Edit->Memo->Edit ¿¡·¯ ¼öÁ¤ (2007. 07. 20 Annualring) ta = daRightCenter; //ta = ((TPDocText *)dp)->Align; } else if (!(dp->Type == detColorChip || dp->Type == detSignature || dp->Type == detTextImage)) { font = ((TPDocText *)dp)->GetFont(); oldFont->Assign(font); ta = ((TPDocText *)dp)->Align; } Cell->Remove(dp); DeleteUndoSave(dp); //For DeleteUndo //delete dp; //For DeleteUndo switch (et) { // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) /* if (Type == detSignature || Type == detNumber || Type == detFormula || Type == detLabel || Type == detEdit || Type == detMemo || Type == detImage || Type == detTextImage) { À̰͵鿡 ÇØ´çÇÏ´Â Type¿¡ ´ëÇØ¼­¸¸ Background¸¦ º¹»çÇÑ´Ù. (2007. 07. 10 Annualring) */ case detColorChip: cp = new TPDocColorChip(Element, rt); cp->FrameStyle = fs; cp->FrameColor = fc; cp->bVisible = visible; cp->NowSelect = bselect; cp->OldSelect = bselect; CreateUndoSave(cp); Cell->Insert(FNumber, cp); break; case detNumber: np = new TPDocNumber(Element, rt); np->FrameStyle = fs; np->FrameColor = fc; np->bVisible = visible; np->NowSelect = bselect; np->OldSelect = bselect; ((TPDocText *)np)->SetFont(oldFont); ((TPDocText *)np)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) np->Background = background; CreateUndoSave(np); Cell->Insert(FNumber, np); break; case detFormula: fp = new TPDocFormula(Element, rt); fp->FrameStyle = fs; fp->FrameColor = fc; fp->bVisible = visible; fp->NowSelect = bselect; fp->OldSelect = bselect; ((TPDocText *)fp)->SetFont(oldFont); ((TPDocText *)fp)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) fp->Background = background; CreateUndoSave(fp); Cell->Insert(FNumber, fp); break; case detLabel: lp = new TPDocLabel(Element, rt); lp->FrameStyle = fs; lp->FrameColor = fc; lp->bVisible = visible; lp->NowSelect = bselect; lp->OldSelect = bselect; ((TPDocText *)lp)->SetFont(oldFont); ((TPDocText *)lp)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) lp->Background = background; CreateUndoSave(lp); Cell->Insert(FNumber, lp); break; case detEdit: ep = new TPDocEdit(Element, rt); ep->FrameStyle = fs; ep->FrameColor = fc; ep->bVisible = visible; ep->NowSelect = bselect; ep->OldSelect = bselect; ((TPDocText *)ep)->SetFont(oldFont); // (2007. 07. 20 Annualring) //((TPDocText *)ep)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) ep->Background = background; CreateUndoSave(ep); Cell->Insert(FNumber, ep); break; case detImage: ip = new TPDocImage(Element, rt); ip->FrameStyle = fs; ip->FrameColor = fc; ip->bVisible = visible; ip->NowSelect = bselect; ip->OldSelect = bselect; ((TPDocText *)ip)->SetFont(oldFont); ((TPDocText *)ip)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) ip->Background = background; CreateUndoSave(ip); Cell->Insert(FNumber, ip); break; case detMemo: mp = new TPDocMemo(Element, rt); mp->FrameStyle = fs; mp->FrameColor = fc; mp->bVisible = visible; mp->NowSelect = bselect; mp->OldSelect = bselect; ((TPDocMemo *)mp)->SetFont(oldFont); //((TPDocText *)mp)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) mp->Background = background; mp->AutoLineFeed = bAutoLineFeed; //MemoÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ CreateUndoSave(mp); Cell->Insert(FNumber, mp); break; case detTextImage: tp = new TPDocTextImage(Element, rt); tp->FrameStyle = fs; tp->FrameColor = fc; tp->bVisible = visible; tp->NowSelect = bselect; tp->OldSelect = bselect; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) tp->Background = background; CreateUndoSave(tp); Cell->Insert(FNumber, tp); break; case detSignature: sp = new TPDocSignature(Element, rt); sp->FrameStyle = fs; sp->FrameColor = fc; sp->bVisible = visible; sp->NowSelect = bselect; sp->OldSelect = bselect; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) sp->Background = background; CreateUndoSave(sp); Cell->Insert(FNumber, sp); break; // ComboBox Type Item Ãß°¡ (2007. 03. 02 Annualring) case detComboBox: cbp = new TPDocComboBox(Element, rt); cbp->FrameStyle = fs; cbp->FrameColor = fc; cbp->bVisible = visible; cbp->NowSelect = bselect; cbp->OldSelect = bselect; ((TPDocText *)cbp)->SetFont(oldFont); ((TPDocText *)cbp)->Align = ta; CreateUndoSave(cbp); Cell->Insert(FNumber, cbp); break; case detDate: dtp = new TPDocDate(Element, rt); dtp->FrameStyle = fs; dtp->FrameColor = fc; dtp->bVisible = visible; dtp->NowSelect = bselect; dtp->OldSelect = bselect; ((TPDocText *)dtp)->SetFont(oldFont); ((TPDocText *)dtp)->Align = ta; CreateUndoSave(dtp); Cell->Insert(FNumber, dtp); break; } } } else { ElementUndoSave(); //For Undo UndoSave(this); //for Undo for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (dp->NowSelect) { // µðÀÚÀÎ½Ç ¿äûÀ¸·Î ¼ýÀÚ ÆíÁýÀÎ °æ¿ì º¯ÇÏÁö ¾Êµµ·Ï. // (2007. 08. 16 Annualring) if (dp->Type == detNumber && et == detNumber) { continue; } rt = dp->Range; fs = dp->FrameStyle; fc = dp->FrameColor; visible = dp->bVisible; bselect = dp->NowSelect; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) background = dp->Background; if (dp->Type == detMemo) { font = ((TPDocMemo *)dp)->GetFont(); oldFont->Assign(font); // Edit->Memo->Edit ¿¡·¯ ¼öÁ¤ (2007. 07. 20 Annualring) ta = daRightCenter; } else if (!(dp->Type == detColorChip || dp->Type == detSignature || dp->Type == detTextImage)) { font = ((TPDocText *)dp)->GetFont(); oldFont->Assign(font); ta = ((TPDocText *)dp)->Align; } Cell->Remove(dp); DeleteUndoSave(dp); //For DeleteUndo //delete dp; //For DeleteUndo switch (et) { case detColorChip: cp = new TPDocColorChip(Element, rt); cp->FrameStyle = fs; cp->FrameColor = fc; cp->bVisible = visible; cp->NowSelect = bselect; cp->OldSelect = bselect; CreateUndoSave(cp); Cell->Insert(i, cp); break; case detNumber: np = new TPDocNumber(Element, rt); np->FrameStyle = fs; np->FrameColor = fc; np->bVisible = visible; np->NowSelect = bselect; np->OldSelect = bselect; ((TPDocText *)np)->SetFont(oldFont); ((TPDocText *)np)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) np->Background = background; CreateUndoSave(np); Cell->Insert(i, np); break; case detFormula: fp = new TPDocFormula(Element, rt); fp->FrameStyle = fs; fp->FrameColor = fc; fp->bVisible = visible; fp->NowSelect = bselect; fp->OldSelect = bselect; ((TPDocText *)fp)->SetFont(oldFont); ((TPDocText *)fp)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) fp->Background = background; CreateUndoSave(fp); Cell->Insert(i, fp); break; case detLabel: lp = new TPDocLabel(Element, rt); lp->FrameStyle = fs; lp->FrameColor = fc; lp->bVisible = visible; lp->NowSelect = bselect; lp->OldSelect = bselect; ((TPDocText *)lp)->SetFont(oldFont); //((TPDocText *)lp)->Align = ta; //¶óº§Àº ¹«Á¶°Ç °¡¿îµ¥·Î ÇØ´Þ·¡. ((TPDocText *)lp)->Align = daCenter2; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) lp->Background = background; CreateUndoSave(lp); Cell->Insert(i, lp); break; case detEdit: ep = new TPDocEdit(Element, rt); ep->FrameStyle = fs; ep->FrameColor = fc; ep->bVisible = visible; ep->NowSelect = bselect; ep->OldSelect = bselect; ((TPDocText *)ep)->SetFont(oldFont); // (2007. 07. 20 Annualring) ((TPDocText *)ep)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) ep->Background = background; CreateUndoSave(ep); Cell->Insert(i, ep); break; case detImage: ip = new TPDocImage(Element, rt); ip->FrameStyle = fs; ip->FrameColor = fc; ip->bVisible = visible; ip->NowSelect = bselect; ip->OldSelect = bselect; ((TPDocText *)ip)->SetFont(oldFont); ((TPDocText *)ip)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) ip->Background = background; CreateUndoSave(ip); Cell->Insert(i, ip); break; case detMemo: mp = new TPDocMemo(Element, rt); mp->FrameStyle = fs; mp->FrameColor = fc; mp->bVisible = visible; mp->NowSelect = bselect; mp->OldSelect = bselect; ((TPDocMemo *)mp)->SetFont(oldFont); //((TPDocText *)dp)->Align = ta; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) mp->Background = background; mp->AutoLineFeed = bAutoLineFeed; //MemoÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ CreateUndoSave(mp); Cell->Insert(i, mp); break; case detTextImage: tp = new TPDocTextImage(Element, rt); tp->FrameStyle = fs; tp->FrameColor = fc; tp->bVisible = visible; tp->NowSelect = bselect; tp->OldSelect = bselect; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) tp->Background = background; CreateUndoSave(tp); Cell->Insert(i, tp); break; case detSignature: sp = new TPDocSignature(Element, rt); sp->FrameStyle = fs; sp->FrameColor = fc; sp->bVisible = visible; sp->NowSelect = bselect; sp->OldSelect = bselect; // ¼¿ ¹è°æ ¼³Á¤ (2007. 07. 10 Annualring) sp->Background = background; CreateUndoSave(sp); Cell->Insert(i, sp); break; // ComboBox Type Item Ãß°¡ (2007. 03. 02 Annualring) case detComboBox: cbp = new TPDocComboBox(Element, rt); cbp->FrameStyle = fs; cbp->FrameColor = fc; cbp->bVisible = visible; cbp->NowSelect = bselect; cbp->OldSelect = bselect; ((TPDocText *)cbp)->SetFont(oldFont); ((TPDocText *)cbp)->Align = ta; CreateUndoSave(cbp); Cell->Insert(i, cbp); break; case detDate: dtp = new TPDocDate(Element, rt); dtp->FrameStyle = fs; dtp->FrameColor = fc; dtp->bVisible = visible; dtp->NowSelect = bselect; dtp->OldSelect = bselect; ((TPDocText *)dtp)->SetFont(oldFont); ((TPDocText *)dtp)->Align = ta; CreateUndoSave(dtp); Cell->Insert(i, dtp); break; } } } } delete oldFont; SetCursorIndex(); } //--------------------------------------------------------------------------- void __fastcall TPDocChart::ExcelSetElement(TPDocElement *Element, TPDocElementType et,int index) { int i, n; RECT rt; TPDocElement *dp = NULL; TPDocColorChip *cp; TPDocNumber *np; TPDocFormula *fp; TPDocLabel *lp; TPDocEdit *ep; TPDocImage *ip; TPDocTextImage *tp; TPDocMemo *mp; TPDocSignature *sp; TPDocBorder fs; //TColor fc; TPDocFrameColor fc; bool bselect; TFont *font; TFont *oldFont = new TFont; TPDocAlign ta; bool visible; i = index; dp = (TPDocElement *)Cell->Items[index]; if (dp == NULL) return; ElementUndoSave(); //For Undo UndoSave(this); //for Undo rt = dp->Range; fs = dp->FrameStyle; fc = dp->FrameColor; visible = dp->bVisible; bselect = dp->NowSelect; if (dp->Type == detMemo) { font = ((TPDocMemo *)dp)->GetFont(); oldFont->Assign(font); // Edit->Memo->Edit ¿¡·¯ ¼öÁ¤ (2007. 07. 20 Annualring) ta = daRightCenter; } else if (!(dp->Type == detColorChip || dp->Type == detSignature || dp->Type == detTextImage)) { font = ((TPDocText *)dp)->GetFont(); oldFont->Assign(font); ta = ((TPDocText *)dp)->Align; } Cell->Remove(dp); DeleteUndoSave(dp); //For DeleteUndo switch (et) { case detColorChip: cp = new TPDocColorChip(Element, rt); cp->FrameStyle = fs; cp->FrameColor = fc; cp->bVisible = visible; cp->NowSelect = bselect; cp->OldSelect = bselect; //CreateUndoSave(cp); Cell->Insert(i, cp); break; case detNumber: np = new TPDocNumber(Element, rt); np->FrameStyle = fs; np->FrameColor = fc; np->bVisible = visible; np->NowSelect = bselect; np->OldSelect = bselect; ((TPDocText *)np)->SetFont(oldFont); ((TPDocText *)np)->Align = ta; //CreateUndoSave(np); Cell->Insert(i, np); break; case detFormula: fp = new TPDocFormula(Element, rt); fp->FrameStyle = fs; fp->FrameColor = fc; fp->bVisible = visible; fp->NowSelect = bselect; fp->OldSelect = bselect; ((TPDocText *)fp)->SetFont(oldFont); ((TPDocText *)fp)->Align = ta; //CreateUndoSave(fp); Cell->Insert(i, fp); break; case detLabel: lp = new TPDocLabel(Element, rt); lp->FrameStyle = fs; lp->FrameColor = fc; lp->bVisible = visible; lp->NowSelect = bselect; lp->OldSelect = bselect; ((TPDocText *)lp)->SetFont(oldFont); //((TPDocText *)lp)->Align = ta; //¶óº§Àº ¹«Á¶°Ç °¡¿îµ¥·Î ÇØ´Þ·¡. ((TPDocText *)lp)->Align = daCenter2; //CreateUndoSave(lp); Cell->Insert(i, lp); break; case detEdit: ep = new TPDocEdit(Element, rt); ep->FrameStyle = fs; ep->FrameColor = fc; ep->bVisible = visible; ep->NowSelect = bselect; ep->OldSelect = bselect; ((TPDocText *)ep)->SetFont(oldFont); ((TPDocText *)ep)->Align = ta; //CreateUndoSave(ep); Cell->Insert(i, ep); break; case detImage: ip = new TPDocImage(Element, rt); ip->FrameStyle = fs; ip->FrameColor = fc; ip->bVisible = visible; ip->NowSelect = bselect; ip->OldSelect = bselect; ((TPDocText *)ip)->SetFont(oldFont); ((TPDocText *)ip)->Align = ta; //CreateUndoSave(ip); Cell->Insert(i, ip); break; case detMemo: mp = new TPDocMemo(Element, rt); mp->FrameStyle = fs; mp->FrameColor = fc; mp->bVisible = visible; mp->NowSelect = bselect; mp->OldSelect = bselect; ((TPDocMemo *)mp)->SetFont(oldFont); //((TPDocText *)dp)->Align = ta; //CreateUndoSave(mp); Cell->Insert(i, mp); break; case detTextImage: tp = new TPDocTextImage(Element, rt); tp->FrameStyle = fs; tp->FrameColor = fc; tp->bVisible = visible; tp->NowSelect = bselect; tp->OldSelect = bselect; //CreateUndoSave(tp); Cell->Insert(i, tp); break; case detSignature: sp = new TPDocSignature(Element, rt); sp->FrameStyle = fs; sp->FrameColor = fc; sp->bVisible = visible; sp->NowSelect = bselect; sp->OldSelect = bselect; //CreateUndoSave(sp); Cell->Insert(i, sp); break; } delete oldFont; SetCursorIndex(); } //--------------------------------------------------------------------------- TPDocElement * __fastcall TPDocChart::getCell(int index) { return (TPDocElement *)Cell->Items[index]; } //--------------------------------------------------------------------------- /* AnsiString __fastcall TPDocChart::GetSpeedFormula(int item) { TPDocElement *dp; bool bFirst = true, bAll; AnsiString str = "", ch; RECT rt; int i, cnt; rt = ((TPDocElement *)Cell->Items[FNumber])->Range; for (i = 0, cnt = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) cnt++; } bAll = cnt <= 1; //¼±ÅÃµÈ ¿µ¿ª¸¸ °è»ê¹üÀ§¿¡ ³ÖÀ»Áö ¸ðµç ¼¿À» °è»ê¹üÀ§¿¡ ³ÖÀ»Áö °áÁ¤. switch (item) { case 0: //°¡·Î ÇÕ°è for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.top == rt.top && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "N" + AnsiString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + AnsiString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "F" + AnsiString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + AnsiString(((TPDocFormula *)dp)->ID); } } } } return str; case 1: //¼¼·Î ÇÕ°è for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.left == rt.left && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "N" + AnsiString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + AnsiString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "F" + AnsiString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + AnsiString(((TPDocFormula *)dp)->ID); } } } } return str; case 2: //°¡·Î Æò±Õ for (i = 0, cnt = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.top == rt.top && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "(N" + AnsiString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + AnsiString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "(F" + AnsiString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + AnsiString(((TPDocFormula *)dp)->ID); } } cnt++; } } if (cnt != 0) str += ")/" + AnsiString(cnt); return str; case 3: //¼¼·Î Æò±Õ for (i = 0, cnt = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.left == rt.left && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "(N" + AnsiString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + AnsiString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "(F" + AnsiString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + AnsiString(((TPDocFormula *)dp)->ID); } } cnt++; } } if (cnt != 0) str += ")/" + AnsiString(cnt); return str; default: return str; } } //--------------------------------------------------------------------------- */ WideString __fastcall TPDocChart::GetSpeedFormula(int item) { if (Cell->Count == 0) return ""; TPDocElement *dp = NULL; bool bFirst = true, bAll; WideString str = "", ch; RECT rt; int i, cnt; rt = ((TPDocElement *)Cell->Items[FNumber])->Range; for (i = 0, cnt = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp && dp->NowSelect) cnt++; } bAll = cnt <= 1; //¼±ÅÃµÈ ¿µ¿ª¸¸ °è»ê¹üÀ§¿¡ ³ÖÀ»Áö ¸ðµç ¼¿À» °è»ê¹üÀ§¿¡ ³ÖÀ»Áö °áÁ¤. switch (item) { case 0: //°¡·Î ÇÕ°è for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if ((bAll || (dp && dp->NowSelect)) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.top == rt.top && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "N" + WideString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + WideString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "F" + WideString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + WideString(((TPDocFormula *)dp)->ID); } } } } return str; case 1: //¼¼·Î ÇÕ°è for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.left == rt.left && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "N" + WideString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + WideString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "F" + WideString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + WideString(((TPDocFormula *)dp)->ID); } } } } return str; case 2: //°¡·Î Æò±Õ for (i = 0, cnt = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.top == rt.top && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "(N" + WideString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + WideString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "(F" + WideString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + WideString(((TPDocFormula *)dp)->ID); } } cnt++; } } // °¡·Î Æò±Õ, ¼¼·Î Æò±Õ À߸ø ³ª¿À´Â ¹®Á¦ ÇØ°á (2007. 06. 21 Annualring) if (cnt != 0) str += ")/I" + WideString(cnt); return str; case 3: //¼¼·Î Æò±Õ for (i = 0, cnt = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if ((bAll || dp->NowSelect) && (dp->Type == detNumber || dp->Type == detFormula) && dp->Range.left == rt.left && (i != FNumber)) { if (dp->Type == detNumber) { if (bFirst) { str = "(N" + WideString(((TPDocNumber *)dp)->ID); bFirst = false; } else { str += "+N" + WideString(((TPDocNumber *)dp)->ID); } } else { if (bFirst) { str = "(F" + WideString(((TPDocFormula *)dp)->ID); bFirst = false; } else { str += "+F" + WideString(((TPDocFormula *)dp)->ID); } } cnt++; } } // °¡·Î Æò±Õ, ¼¼·Î Æò±Õ À߸ø ³ª¿À´Â ¹®Á¦ ÇØ°á (2007. 06. 21 Annualring) if (cnt != 0) str += ")/I" + WideString(cnt); return str; default: return str; } } //--------------------------------------------------------------------------- TPDocElement * __fastcall TPDocChart::GetSelectElement() { if (Cell->Count == 0) return NULL; TPDocElement *dp; /* if(FNumber != -1){ //by linuxjun TList dp = (TPDocElement *)Cell->Items[FNumber]; return dp; }else{ // dp = (TPDocElement *)Cell->Items[0]; //for Qe // return dp; return NULL; //by linuxjun } */ if (Cell->Count == 0) return dp = NULL; try{ dp = (TPDocElement *)Cell->Items[FNumber]; //for Qe }catch(EListError &ec){ if(Cell->Count){ dp = (TPDocElement *)Cell->Items[0]; //for Qe }else{ dp = NULL; } } return dp; } //--------------------------------------------------------------------------- TPDocControlMode __fastcall TPDocChart::GetControlMode(int X, int Y) { //¼¿ÀÇ right¿Í bottomÀ» ±âÁØÀ¸·Î »ï´Â´Ù. int i, j, px, py, p; TPDocElement *dp = NULL; //cell Å׵θ® ºÎºÐ ¼±Åà - »óÁÂ, »ó¿ì, ÇÏÁÂ, ÇÏ¿ì, À̵¿ ¼±ÅÃ. //if (X > Range.left - 3 && X < Range.left + 3 && Y > Range.top - 3 && Y < Range.top + 3) return dcmLeftTop; //else if (X > Range.right - 3 && X < Range.right + 3 && Y > Range.top - 3 && Y < Range.top + 3) return dcmRightTop; //else if (X > Range.left - 3 && X < Range.left + 3 && Y > Range.bottom - 3 && Y < Range.bottom + 3) return dcmLeftBottom; //else if (X > Range.right - 3 && X < Range.right + 3 && Y > Range.bottom - 3 && Y < Range.bottom + 3) return dcmRightBottom; ///else if (X > Range.left && X < Range.right && Y > Range.top - 2 && Y < Range.top + 3) return dcmCenterTop; //else if (X > Range.left - 2 && X < Range.left + 3 && Y > Range.top && Y < Range.bottom) return dcmLeftCenter; //else if ((X > Range.left && X < Range.right && Y > Range.top - 6 && Y < Range.top - 2) || (X > Range.left && X < Range.right && Y > Range.bottom + 2 && Y < Range.bottom + 6) || (X > Range.left - 6 && X < Range.left - 2 && Y > Range.top && Y < Range.bottom) || (X > Range.right + 2 && X < Range.right + 6 && Y > Range.top && Y < Range.bottom)) return dcmMove; //dcmLeftTop if (X > Range.left - 3 && X < Range.left + 3 && Y > Range.top - 3 && Y < Range.top + 3) { for(i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (X - Range.left > dp->Range.left - 3 && X - Range.left < dp->Range.left + 3 && Y - Range.top > dp->Range.top - 3 && Y - Range.top < dp->Range.top + 3) { FNumber = i; FOldPositionX = dp->Range.left; FOldPositionY = dp->Range.top; return dcmLeftTop; } } } //dcmRightTop else if (X > Range.right - 3 && X < Range.right + 3 && Y > Range.top - 3 && Y < Range.top + 3) { for(i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (X - Range.left > dp->Range.right - 3 && X - Range.left < dp->Range.right + 3 && Y - Range.top > dp->Range.top - 3 && Y - Range.top < dp->Range.top + 3) { FNumber = i; FOldPositionX = dp->Range.right; FOldPositionY = dp->Range.top; return dcmRightTop; } } } //dcmLeftBottom else if (X > Range.left - 3 && X < Range.left + 3 && Y > Range.bottom - 3 && Y < Range.bottom + 3) { for(i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (X - Range.left > dp->Range.left - 3 && X - Range.left < dp->Range.left + 3 && Y - Range.top > dp->Range.bottom - 3 && Y - Range.top < dp->Range.bottom + 3) { FNumber = i; FOldPositionX = dp->Range.left; FOldPositionY = dp->Range.bottom; return dcmLeftBottom; } } } //dcmRightBottom else if (X > Range.right - 3 && X < Range.right + 3 && Y > Range.bottom - 3 && Y < Range.bottom + 3) { for(i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (X - Range.left > dp->Range.right - 3 && X - Range.left < dp->Range.right + 3 && Y - Range.top > dp->Range.bottom - 3 && Y - Range.top < dp->Range.bottom + 3) { FNumber = i; FOldPositionX = dp->Range.right; FOldPositionY = dp->Range.bottom; return dcmRightBottom; } } } //dcmCenterTop else if (X > Range.left && X < Range.right && Y > Range.top - 3 && Y < Range.top + 3) { for(i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (Y - Range.top > dp->Range.top && Y - Range.top < dp->Range.bottom) { FNumber = i; FOldPositionY = dp->Range.top; return dcmCenterTop; } } } //dcmLeftCenter else if(X > Range.left - 3 && X < Range.left + 3 && Y > Range.top && Y < Range.bottom) { for(i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (X - Range.left > dp->Range.left && X - Range.left < dp->Range.right) { FNumber = i; FOldPositionX = dp->Range.left; return dcmLeftCenter; } } } //cell¾ÈÀÇ ¼±Åà for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (X - Range.left > dp->Range.right - 3 && X - Range.left < dp->Range.right + 3) { if (Y - Range.top > dp->Range.top && Y - Range.top < dp->Range.bottom) { FNumber = i; FOldPositionX = dp->Range.right; return dcmHorizontal; } } if (Y - Range.top > dp->Range.bottom - 3 && Y - Range.top < dp->Range.bottom + 3) { if (X - Range.left > dp->Range.left && X - Range.left < dp->Range.right) { FNumber = i; FOldPositionY = dp->Range.bottom; return dcmVertical; } } } if (PtInRect(&Range, Point(X, Y))) return dcmSelect; else return dcmNone; } //--------------------------------------------------------------------- void __fastcall TPDocChart::GetNewRange(int X, int Y) { switch (ControlMode) { case dcmHorizontal: if (X - Range.left <= FMinX) { FOldPositionX = FMinX; } else if (X - Range.left >= FMaxX) { FOldPositionX = FMaxX; } else { FOldPositionX = X - Range.left; } break; case dcmVertical: if (Y - Range.top <= FMinY) { FOldPositionY = FMinY; } else if (Y - Range.top >= FMaxY) { FOldPositionY = FMaxY; } else { FOldPositionY = Y - Range.top; } break; case dcmLeftTop: if(X - Range.left >= FMaxX) { FOldPositionX = FMaxX; }else { FOldPositionX = X - Range.left; } if(Y - Range.top >= FMaxY) { FOldPositionY = FMaxY; }else { FOldPositionY = Y - Range.top; } break; case dcmRightTop: if(X - Range.left <= FMinX) { FOldPositionX = FMinX; }else { FOldPositionX = X - Range.left; } if(Y - Range.top >= FMaxY) { FOldPositionY = FMaxY; }else { FOldPositionY = Y - Range.top; } break; case dcmLeftBottom: if(X - Range.left >= FMaxX) { FOldPositionX = FMaxX; }else { FOldPositionX = X - Range.left; } if(Y - Range.top <= FMinY) { FOldPositionY = FMinY; }else { FOldPositionY = Y - Range.top; } break; case dcmRightBottom: if(X - Range.left <= FMinX) { FOldPositionX = FMinX; }else { FOldPositionX = X - Range.left; } if(Y - Range.top <= FMinY) { FOldPositionY = FMinY; }else { FOldPositionY = Y - Range.top; } break; case dcmCenterTop: if(Y - Range.top >= FMaxY) { FOldPositionY = FMaxY; }else { FOldPositionY = Y - Range.top; } break; case dcmLeftCenter: if(X - Range.left >= FMaxX) { FOldPositionX = FMaxX; }else { FOldPositionX = X - Range.left; } break; default: TPDocElement::GetNewRange(X, Y); break; } } //--------------------------------------------------------------------- void __fastcall TPDocChart::GetSelectCell(POINT ep) { SelectUndoSave(); //For Undo RECT rc; TPDocElement *dp; rc = Rect(min(sp.x, ep.x), min(sp.y, ep.y), max(sp.x, ep.x), max(sp.y, ep.y)); for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; if (rc.left < dp->Range.right && rc.right > dp->Range.left && rc.top < dp->Range.bottom && rc.bottom > dp->Range.top) { if(dp->NowSelect == false){ // if(Sheet)Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo } dp->NowSelect = true; }else{ if(dp->NowSelect == true){ // if(Sheet)Sheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo } dp->NowSelect = false; } } } //---------------------------------------------------------------------- void __fastcall TPDocChart::SetSelectMode(TShiftState Shift) { if (Cell->Count == 0) return; bool bselect, bTop, bBottom, bNotEdge; int i, cnt = 0; bool bOuter = false; TPDocElement *dp; RECT rt; bselect = ((TPDocElement *)Cell->Items[FNumber])->NowSelect; bTop = false; bBottom = false; AllSizeMode = false; if (bselect || Shift.Contains(ssShift)) { for (i = 0; i < Cell->Count; i++) { if (((TPDocElement *)Cell->Items[i])->NowSelect) cnt++; } if (cnt == Cell->Count) { SelectMode = dsmAll; if (Shift.Contains(ssShift)) AllSizeMode = true; // ÄÁÆ®·Ñ¿¡¼­ ½¬ÇÁÆ®·Î º¯°æ 07.05.31 by altang } else if (cnt == 1 || Shift.Contains(ssShift)) { rt = ((TPDocElement *)Cell->Items[FNumber])->Range; if (ControlMode == dcmHorizontal) { bOuter = rt.right == (Range.right - Range.left); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.top < rt.bottom && dp->Range.bottom > rt.top && dp->Range.left == rt.right) { if (rt.top == dp->Range.top) bTop = true; if (rt.bottom == dp->Range.bottom) bBottom = true; } } } else if (ControlMode == dcmVertical) { bOuter = rt.bottom == (Range.bottom - Range.top); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left < rt.right && dp->Range.right > rt.left && dp->Range.top == rt.bottom) { if (rt.left == dp->Range.left) bTop = true; if (rt.right == dp->Range.right) bBottom = true; } } } if (bOuter) SelectMode = dsmSelect; else if (bTop && bBottom) SelectMode = dsmOne; else SelectMode = dsmSingularity; } else { rt = ((TPDocElement *)Cell->Items[FNumber])->Range; if (ControlMode == dcmHorizontal) { bOuter = rt.right == (Range.right - Range.left); if (bOuter) { bTop = true; bBottom = true; } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect && dp->Range.right == rt.right) { rt.top = min((int)dp->Range.top, (int)rt.top); rt.bottom = max((int)dp->Range.bottom, (int)rt.bottom); } } for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.top < rt.bottom && dp->Range.bottom > rt.top && (dp->Range.left == rt.right || dp->Range.right == Range.right)) { if (rt.top == dp->Range.top) bTop = true; if (rt.bottom == dp->Range.bottom) bBottom = true; } } } } else if (ControlMode == dcmVertical) { bOuter = rt.bottom == (Range.bottom - Range.top); if (bOuter) { bTop = true; bBottom = true; } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect && dp->Range.bottom == rt.bottom) { rt.left = min((int)dp->Range.left, (int)rt.left); rt.right = max((int)dp->Range.right, (int)rt.right); } } for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left < rt.right && dp->Range.right > rt.left && dp->Range.top == rt.bottom) { if (rt.left == dp->Range.left) bTop = true; if (rt.right == dp->Range.right) bBottom = true; } } } } if (bTop && bBottom) { SelectMode = dsmSelect; if (Shift.Contains(ssShift)) AllSizeMode = true; //ÄÁÆ®·Ñ¿¡¼­ ½¬ÇÁÆ®·Î º¯°æ 07.05.31 by altang } else { SelectMode = dsmSingularity; } } } else SelectMode = dsmAll; } //---------------------------------------------------------------------- void __fastcall TPDocChart::SearchScope() { if (Cell->Count == 0) return; int i; TPDocElement *dp; RECT rt, dt; FMaxX = 10000; FMinX = 0; FMaxY = 10000; FMinY = 0; switch (ControlMode) { case dcmLeftCenter: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.left == FOldPositionX) { FMaxX = min((int)rt.right, FMaxX); } } FMaxX -= 3; break; case dcmCenterTop: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.top == FOldPositionY) { FMaxY = min((int)rt.bottom, FMaxY); } } FMaxY -= 3; break; case dcmLeftTop: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.left == FOldPositionX) { FMaxX = min((int)rt.right, FMaxX); } if (rt.top == FOldPositionY) { FMaxY = min((int)rt.bottom, FMaxY); } } FMaxX -= 3; FMaxY -= 3; break; case dcmRightTop: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.right == FOldPositionX) { FMinX = max((int)rt.left, FMinX); } if (rt.top == FOldPositionY) { FMaxY = min((int)rt.bottom, FMaxY); } } FMinX += 3; FMaxY -= 3; break; case dcmLeftBottom: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.left == FOldPositionX) { FMaxX = min((int)rt.right, FMaxX); } if (rt.bottom == FOldPositionY) { FMinY = max((int)rt.top, FMinY); } } FMaxX -= 3; FMinY += 3; break; case dcmRightBottom: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.right == FOldPositionX) { FMinX = max((int)rt.left, FMinX); } if (rt.bottom == FOldPositionY) { FMinY = max((int)rt.top, FMinY); } } FMinX += 3; FMinY += 3; break; case dcmHorizontal: switch (SelectMode) { case dsmAll: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.left == FOldPositionX) { FMaxX = min((int)rt.right, FMaxX); } else if (rt.right == FOldPositionX) { FMinX = max((int)rt.left, FMinX); } } FMaxX -= 3; FMinX += 3; break; case dsmOne: rt = ((TPDocElement *)Cell->Items[FNumber])->Range; FMinX = rt.left; for (i = 0; i < Cell->Count; i++) { dt = ((TPDocElement *)Cell->Items[i])->Range; if (dt.top < rt.bottom && dt.bottom > rt.top) { if (dt.left == rt.right) FMaxX = min((int)dt.right, FMaxX); } } FMaxX -= 3; FMinX += 3; break; case dsmSelect: rt = ((TPDocElement *)Cell->Items[FNumber])->Range; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (dp->Range.right == rt.right) { rt.top = min((int)dp->Range.top, (int)rt.top); rt.bottom = max((int)dp->Range.bottom, (int)rt.bottom); } } } for (i = 0; i < Cell->Count; i++) { //qe test dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.top < rt.bottom && dp->Range.bottom > rt.top && dp->Range.left == FOldPositionX) FMaxX = min((int)dp->Range.right, FMaxX); else if (dp->NowSelect && dp->Range.right == FOldPositionX) FMinX = max((int)dp->Range.left, FMinX); } FMaxX -= 3; FMinX += 3; break; case dsmSingularity: FMaxX = FOldPositionX; FMinX = FOldPositionX; break; } break; case dcmVertical: switch (SelectMode) { case dsmAll: for (i = 0; i < Cell->Count; i++) { rt = ((TPDocElement *)Cell->Items[i])->Range; if (rt.top == FOldPositionY) { FMaxY = min((int)rt.bottom, FMaxY); } else if (rt.bottom == FOldPositionY) { FMinY = max((int)rt.top, FMinY); } } FMaxY -= 3; FMinY += 3; break; case dsmOne: rt = ((TPDocElement *)Cell->Items[FNumber])->Range; FMinY = rt.top; for (i = 0; i < Cell->Count; i++) { dt = ((TPDocElement *)Cell->Items[i])->Range; if (dt.left < rt.right && dt.right > rt.left) { if (dt.top == rt.bottom) FMaxY = min((int)dt.bottom, FMaxY); } } FMaxY -= 3; FMinY += 3; break; case dsmSelect: rt = ((TPDocElement *)Cell->Items[FNumber])->Range; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (dp->Range.right == rt.right) { rt.left = min((int)dp->Range.left, (int)rt.left); rt.right = max((int)dp->Range.right, (int)rt.right); } } } for (i = 0; i < Cell->Count; i++) { //qe test dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left < rt.right && dp->Range.right > rt.left && dp->Range.top == FOldPositionY) FMaxY = min((int)dp->Range.bottom, FMaxY); else if (dp->NowSelect && dp->Range.bottom == FOldPositionY) FMinY = max((int)dp->Range.top, FMinY); } FMaxY -= 3; FMinY += 3; break; case dsmSingularity: FMaxY = FOldPositionY; FMinY = FOldPositionY; break; } break; } } //--------------------------------------------------------------------- void __fastcall TPDocChart::ReportSelectMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { if (Button == mbRight) return; if (Cell->Count == 0) goto fail; TPDocElement *dp; sp = Point(X - Range.left, Y - Range.top); SelectCell = (TPDocElement *)Cell->Items[FNumber]; bMouseDown = true; // SelectUndoSave(); //For Undo for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if(dp->OldSelect!=false || dp->NowSelect!=false){ SelectUndoSave(); //For Undo //Æ÷¹Ä·¯ ¿¡·¯ ¼öÁ¤À» À§ÇØÇÊ¿äÇÏ´Ù°í ÆÇ´ÜµÇ´ÂºÎºÐ. UndoSave(dp); //for Undo } dp->OldSelect = false; dp->NowSelect = false; } fail: TPDocElement::ControlModeMouseDown(Shift, X, Y); } //--------------------------------------------------------------------- void __fastcall TPDocChart::ReportSelectMouseMove(HDC hDC, TPDocViewStatus vs, int X, int Y) { TPDocElement *dp; POINT p = Point(X - Range.left, Y - Range.top); //óÀ½ ¸¶¿ì½º´Ù¿îÇÑ ¼¿À» ¹þ¾î³µÀ»¶§ ºÎÅÍ ¼±Åà µÇ°Ô.. if (SelectCell == NULL) return; if (bMouseDown && PtInRect(&(SelectCell->Range), p) == false){ // SelectUndoSave(); GetSelectCell(Point(X - Range.left, Y - Range.top)); } PaintReportControl(hDC, vs); } //--------------------------------------------------------------------- void __fastcall TPDocChart::ReportSelectMouseUp(TShiftState Shift, int X, int Y) { SelectCell = NULL; bMouseDown = false; } //--------------------------------------------------------------------- void __fastcall TPDocChart::ControlModeMouseDown(TShiftState Shift, int X, int Y) { TPDocElement *dp; int i; switch (ControlMode) { case dcmLeftTop: case dcmRightTop: case dcmLeftBottom: case dcmRightBottom: case dcmCenterTop: case dcmLeftCenter: SetSelectMode(Shift); SearchScope(); break; case dcmHorizontal: // ElementUndoSave(); //For Undo SetSelectMode(Shift); SearchScope(); break; case dcmVertical: // ElementUndoSave(); //For Undo SetSelectMode(Shift); SearchScope(); break; case dcmSelect: sp = Point(X - Range.left, Y - Range.top); //Cell ´ÙÁß¼±ÅÃÀ» ±¸ÇöÇÏ´ø Áß ¹®Á¦°¡ ÀÖ¾î ÁÖ¼®Ã³¸®ÇÔ... /* SelectUndoSave(); //For Undo for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if(dp->OldSelect!=false || dp->NowSelect!=false){ UndoSave(dp); //for Undo } dp->OldSelect = false; dp->NowSelect = false; } */ break; default: break; } TPDocElement::ControlModeMouseDown(Shift, X, Y); } //--------------------------------------------------------------------- void __fastcall TPDocChart::ControlModeMouseMove(HDC hDC, TPDocViewStatus &vs, int X, int Y) { switch (ControlMode) { case dcmSelect: //Sheet->SelectUndoSave(); // SelectUndoSave(); GetSelectCell(Point(X - Range.left, Y - Range.top)); PaintControl(hDC, vs); break; default: PaintControl(hDC, vs); GetNewRange(X, Y); PaintControl(hDC, vs); break; } } //--------------------------------------------------------------------- void __fastcall TPDocChart::ControlModeMouseUp() { int i, dx, dy, m; TPDocElement *dp; RECT rt, limit; POINT pt; switch (ControlMode) { case dcmLeftTop: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dx = -(FOldPositionX - rt.left); //ºÎ¸ð »ç°¢Çü ¿À¸¥ÂÊ¿¡¼­ °Å¸®¸¸Å­ÀÇ ºñÀ²·Î ¼¿ ´Ã·ÁÁÜ dy = -(FOldPositionY - rt.top); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if (dp->Range.left != 0) dp->Range.left += dp->Range.left * dx / (Range.right - Range.left); dp->Range.right += dp->Range.right * dx / (Range.right - Range.left); //for Y if (dp->Range.top != 0) dp->Range.top += dp->Range.top * dy / (Range.bottom - Range.top); dp->Range.bottom += dp->Range.bottom * dy / (Range.bottom - Range.top); } } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if(dp->Range.left != 0) dp->Range.left -= (FOldPositionX - rt.left); dp->Range.right -= (FOldPositionX - rt.left); //for Y if(dp->Range.top != 0) dp->Range.top -= (FOldPositionY - rt.top); dp->Range.bottom -= (FOldPositionY - rt.top); } } Range.left += (FOldPositionX - rt.left); Range.top += (FOldPositionY - rt.top); break; case dcmRightTop: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dx = FOldPositionX - rt.right; //ºÎ¸ð »ç°¢Çü ¿À¸¥ÂÊ¿¡¼­ °Å¸®¸¸Å­ÀÇ ºñÀ²·Î ¼¿ ´Ã·ÁÁÜ dy = -(FOldPositionY - rt.top); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if (dp->Range.left != 0) dp->Range.left += dp->Range.left * dx / (Range.right - Range.left); dp->Range.right += dp->Range.right * dx / (Range.right - Range.left); //for Y if (dp->Range.top != 0) dp->Range.top += dp->Range.top * dy / (Range.bottom - Range.top); dp->Range.bottom += dp->Range.bottom * dy / (Range.bottom - Range.top); } } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if(dp->Range.right == rt.right) dp->Range.right = FOldPositionX; //for Y if(dp->Range.top != 0) dp->Range.top -= (FOldPositionY - rt.top); dp->Range.bottom -= (FOldPositionY - rt.top); } } Range.right += (FOldPositionX - rt.right); Range.top += (FOldPositionY - rt.top); break; case dcmLeftBottom: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dx = -(FOldPositionX - rt.left); //ºÎ¸ð »ç°¢Çü ¿À¸¥ÂÊ¿¡¼­ °Å¸®¸¸Å­ÀÇ ºñÀ²·Î ¼¿ ´Ã·ÁÁÜ dy = FOldPositionY - rt.bottom; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if (dp->Range.left != 0) dp->Range.left += dp->Range.left * dx / (Range.right - Range.left); dp->Range.right += dp->Range.right * dx / (Range.right - Range.left); //for Y if (dp->Range.top != 0) dp->Range.top += dp->Range.top * dy / (Range.bottom - Range.top); dp->Range.bottom += dp->Range.bottom * dy / (Range.bottom - Range.top); } } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if(dp->Range.left != 0) dp->Range.left -= (FOldPositionX - rt.left); dp->Range.right -= (FOldPositionX - rt.left); //for Y if(dp->Range.bottom == rt.bottom) dp->Range.bottom = FOldPositionY; } } Range.left += (FOldPositionX - rt.left); Range.bottom += (FOldPositionY - rt.bottom); break; case dcmRightBottom: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dx = FOldPositionX - rt.right; //ºÎ¸ð »ç°¢Çü ¿À¸¥ÂÊ¿¡¼­ °Å¸®¸¸Å­ÀÇ ºñÀ²·Î ¼¿ ´Ã·ÁÁÜ dy = FOldPositionY - rt.bottom; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if (dp->Range.left != 0) dp->Range.left += dp->Range.left * dx / (Range.right - Range.left); dp->Range.right += dp->Range.right * dx / (Range.right - Range.left); //for Y if (dp->Range.top != 0) dp->Range.top += dp->Range.top * dy / (Range.bottom - Range.top); dp->Range.bottom += dp->Range.bottom * dy / (Range.bottom - Range.top); } } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if(dp->Range.right == rt.right) dp->Range.right = FOldPositionX; //for Y if(dp->Range.bottom == rt.bottom) dp->Range.bottom = FOldPositionY; } } Range.right += (FOldPositionX - rt.right); Range.bottom += (FOldPositionY - rt.bottom); break; case dcmCenterTop: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dy = -(FOldPositionY - rt.top); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for Y if (dp->Range.top != 0) dp->Range.top += dp->Range.top * dy / (Range.bottom - Range.top); dp->Range.bottom += dp->Range.bottom * dy / (Range.bottom - Range.top); } } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for Y if(dp->Range.top != 0) dp->Range.top -= (FOldPositionY - rt.top); dp->Range.bottom -= (FOldPositionY - rt.top); } } Range.top += (FOldPositionY - rt.top); break; case dcmLeftCenter: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dx = -(FOldPositionX - rt.left); //ºÎ¸ð »ç°¢Çü ¿À¸¥ÂÊ¿¡¼­ °Å¸®¸¸Å­ÀÇ ºñÀ²·Î ¼¿ ´Ã·ÁÁÜ for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if (dp->Range.left != 0) dp->Range.left += dp->Range.left * dx / (Range.right - Range.left); dp->Range.right += dp->Range.right * dx / (Range.right - Range.left); } } else { for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo //for X if(dp->Range.left != 0) dp->Range.left -= (FOldPositionX - rt.left); dp->Range.right -= (FOldPositionX - rt.left); } } Range.left += (FOldPositionX - rt.left); break; case dcmHorizontal: switch (SelectMode) { case dsmAll: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; if (AllSizeMode) { dx = FOldPositionX - rt.right; //ºÎ¸ð »ç°¢Çü ¿ÞÂÊ¿¡¼­ °Å¸®¸¸Å­ÀÇ ºñÀ²·Î ¼¿ ´Ã·ÁÁÜ for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo if (dp->Range.left != 0) dp->Range.left += dp->Range.left * dx / rt.right; dp->Range.right += dp->Range.right * dx / rt.right; m = max(m, (int)dp->Range.right); } Range.right = Range.left + m; } else { rt = ((TPDocElement *)Cell->Items[FNumber])->Range; m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left == rt.right){ UndoSave(dp); //for Undo dp->Range.left = FOldPositionX; } else if (dp->Range.right == rt.right) { UndoSave(dp); //for Undo dp->Range.right = FOldPositionX; } m = max(m, (int)dp->Range.right); } Range.right = Range.left + m; } break; case dsmOne: ElementSizeUndoSave(); dp = (TPDocElement *)Cell->Items[FNumber]; UndoSave(dp); //for Undo rt = dp->Range; dp->Range.right = FOldPositionX; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.top < rt.bottom && dp->Range.bottom > rt.top) { UndoSave(dp); //for Undo if (dp->Range.left == rt.right) dp->Range.left = FOldPositionX; } } SetCursorIndex(); break; case dsmSelect: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; limit = rt; //¸ÕÀú ¼±ÅÃµÈ ¿µ¿ªÀÇ ¹üÀ§ limit¸¦ ã´Â´Ù. for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { limit.left = min((int)dp->Range.left, (int)limit.left); limit.right = max((int)dp->Range.right, (int)limit.right); if (dp->Range.right == rt.right) { limit.top = min((int)dp->Range.top, (int)limit.top); limit.bottom = max((int)dp->Range.bottom, (int)limit.bottom); } } } if (AllSizeMode) { dx = FOldPositionX - rt.right; m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left < limit.right && dp->Range.right > limit.left) { UndoSave(dp); //for Undo if (dp->Range.left > limit.left) dp->Range.left += (dp->Range.left - limit.left) * dx / (rt.right - limit.left); if (dp->Range.right < limit.right) dp->Range.right += (dp->Range.right - limit.left) * dx / (rt.right - limit.left); else dp->Range.right += dx; } else { if (dp->Range.right > limit.left) { UndoSave(dp); //for Undo dp->Range.left += dx; dp->Range.right += dx; } } m = max(m, (int)dp->Range.right); } Range.right = Range.left + m; } else { m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; //¼±ÅõȰͰú »ó°ü¾øÀÌ ¼¿ÀÌ y¹æÇâÀÇ ¹üÀ§¿¡ ÀÖ°í left°¡ ¿Å±â·Á´Â ¼¿ÀÇ right¿Í °°Àº¼¿À» ãÀ½. //ÀÌ´Â ¼±ÅõÇÁö ¾ÊÀº ¼¿Áß¿¡µµ left°¡ ¹Ù²î¾î¾ß ÇÏ´Â °æ¿ìµµ Àֱ⠶§¹®ÀÌ´Ù. if (dp->Range.top < limit.bottom && dp->Range.bottom > limit.top && dp->Range.left == rt.right) { UndoSave(dp); //for Undo dp->Range.left = FOldPositionX; } //¼±ÅÃµÈ ¼¿ÀÇ right ¸¸ °í·ÁÇØÁÖ¸é µÈ´Ù. else if (dp->NowSelect && dp->Range.right == rt.right) { UndoSave(dp); //for Undo dp->Range.right = FOldPositionX; } //¸Ç¸ð¼­¸®ÀÇ °æ¿ì ¼±ÅõȰͰú ¹«°üÇÏ°Ô ´Ù°°ÀÌ ¿òÁ÷¿©¾ßÇÏ´Â ¿î¸í. else if (rt.right == Range.right - Range.left && dp->Range.right == rt.right) { UndoSave(dp); //for Undo dp->Range.right = FOldPositionX; } m = max(m, (int)dp->Range.right); } Range.right = Range.left + m; } SetCursorIndex(); break; case dsmSingularity: break; } break; case dcmVertical: switch (SelectMode) { case dsmAll: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; if (AllSizeMode) { dy = FOldPositionY - rt.bottom; m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; UndoSave(dp); //for Undo if (dp->Range.top != Range.top) dp->Range.top += dp->Range.top * dy / rt.bottom; dp->Range.bottom += dp->Range.bottom * dy / rt.bottom; m = max(m, (int)dp->Range.bottom); } Range.bottom = Range.top + m; } else { m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.top == rt.bottom){ UndoSave(dp); //for Undo dp->Range.top = FOldPositionY; } else if (dp->Range.bottom == rt.bottom){ UndoSave(dp); //for Undo dp->Range.bottom = FOldPositionY; } m = max(m, (int)dp->Range.bottom); } Range.bottom = Range.top + m; } break; case dsmOne: ElementSizeUndoSave(); dp = (TPDocElement *)Cell->Items[FNumber]; UndoSave(dp); //for Undo rt = dp->Range; dp->Range.bottom = FOldPositionY; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left < rt.right && dp->Range.right > rt.left) { if (dp->Range.top == rt.bottom){ UndoSave(dp); //for Undo dp->Range.top = FOldPositionY; } } } SetCursorIndex(); break; case dsmSelect: ElementSizeUndoSave(); UndoSave(this); //for Undo rt = ((TPDocElement *)Cell->Items[FNumber])->Range; limit = rt; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { limit.top = min((int)dp->Range.top, (int)limit.top); limit.bottom = max((int)dp->Range.bottom, (int)limit.bottom); if (dp->Range.bottom == rt.bottom) { limit.left = min((int)dp->Range.left, (int)limit.left); limit.right = max((int)dp->Range.right, (int)limit.right); } } } if (AllSizeMode) { dy = FOldPositionY - rt.bottom; m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.top < limit.bottom && dp->Range.bottom > limit.top) { UndoSave(dp); //for Undo if (dp->Range.top > limit.top) dp->Range.top += (dp->Range.top - limit.top) * dy / (rt.bottom - limit.top); if (dp->Range.bottom < limit.bottom) dp->Range.bottom += (dp->Range.bottom - limit.top) * dy / (rt.bottom - limit.top); else dp->Range.bottom += dy; } else { if (dp->Range.bottom > limit.top) { UndoSave(dp); //for Undo dp->Range.top += dy; dp->Range.bottom += dy; } } if (dp->Range.top == limit.bottom){ UndoSave(dp); //for Undo dp->Range.top += (dp->Range.top - limit.top) * dy / (rt.bottom - limit.top); } m = max(m, (int)dp->Range.bottom); } Range.bottom = Range.top + m; } else { m = 0; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.left < limit.right && dp->Range.right > limit.left && dp->Range.top == rt.bottom) { UndoSave(dp); //for Undo dp->Range.top = FOldPositionY; } else if (dp->NowSelect && dp->Range.bottom == rt.bottom) { UndoSave(dp); //for Undo dp->Range.bottom = FOldPositionY; } else if (rt.bottom == Range.bottom - Range.top && dp->Range.bottom == rt.bottom) //¸Ç¸ð¼­¸®ÀÇ °æ¿ì ¼±ÅõȰͰú ¹«°üÇÏ°Ô ´Ù°°ÀÌ ¿òÁ÷¿©¾ßÇÏ´Â ¿î¸í. { UndoSave(dp); //for Undo dp->Range.bottom = FOldPositionY; } m = max(m, (int)dp->Range.bottom); } Range.bottom = Range.top + m; } SetCursorIndex(); break; case dsmSingularity: break; } break; case dcmSelect: break; default: pt.x = Range.right - Range.left; pt.y = Range.bottom - Range.top; ElementSizeUndoSave(); UndoSave(this); TPDocElement::ControlModeMouseUp(); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->Range.right == pt.x || dp->Range.bottom == pt.y){ UndoSave(dp); //for Undo if (dp->Range.right == pt.x) dp->Range.right = Range.right - Range.left; if (dp->Range.bottom == pt.y) dp->Range.bottom = Range.bottom - Range.top; } } break; } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::ConsiderRightButton(HDC hDC, TPDocViewStatus &vs, int X, int Y) { int i; int nOldROP = 0; TPDocElement *dp; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; bool sw = false; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { if (PtInRect(&dp->Range, Point(X - Range.left, Y - Range.top))) { sw = true; break; } } } if (sw == false) { SelectUndoSave(); //For Undo for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (PtInRect(&dp->Range, Point(X - Range.left, Y - Range.top))) { if(dp->NowSelect!=true){ UndoSave(dp); //for Undo } dp->NowSelect = true; } else { if(dp->NowSelect!=false){ UndoSave(dp); //for Undo } dp->NowSelect = false; } } try { hPen = CreatePen(PS_SOLID, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(BLACK_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect != dp->OldSelect) { Rectangle(hDC, vs.Pattern2ViewX(FOldRect.left + dp->Range.left) +3, vs.Pattern2ViewY(FOldRect.top + dp->Range.top) +3, vs.Pattern2ViewX(FOldRect.left + dp->Range.right) -2, vs.Pattern2ViewY(FOldRect.top + dp->Range.bottom) -2); dp->OldSelect = dp->NowSelect; } } } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } } //--------------------------------------------------------------------- void __fastcall TPDocChart::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { int i; TPDocElement *dp; PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if(dp->bVisible) dp->PaintForm(hDC, vs, bPrint); } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { if (Cell->Count == 0) return; RECT rc; TPDocElement *dp; int i, x, y, cnt; char str[5]; if (ControlMode != dcmNone) { /*TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return;*/ } rc = ConvertRange(&vs); if (bSelect) { for (i = 0, cnt = 0; i < Cell->Count; i++) { if (((TPDocElement *)Cell->Items[i])->NowSelect) cnt++; } if (cnt == 0) { //¼¿Áß¿¡ ¼±ÅõȰÍÀÌ ÇϳªµÎ ¾øÀ¸¸é ù¹øÂ° ¼¿À» ¼±ÅÃÇØÁÜ. // if(((TPDocElement *)Cell->Items[FNumber])->NowSelect!=true || ((TPDocElement *)Cell->Items[FNumber])->OldSelect!=true){ // SelectUndoSave(); //For Undo // UndoSave((TPDocElement *)Cell->Items[FNumber]); //for Undo // } dp = (TPDocElement *)Cell->Items[FNumber]; if (dp) { dp->NowSelect = true; dp->OldSelect = true; } } } else { //¸ðµç ¼¿ ¼±ÅÃ ÇØÁ¦. for (i = 0; i < Cell->Count; i++) { // if(((TPDocElement *)Cell->Items[i])->NowSelect!=false || ((TPDocElement *)Cell->Items[i])->OldSelect!=false){ // SelectUndoSave(); //For Undo // UndoSave((TPDocElement *)Cell->Items[i]); //for Undo // } dp = (TPDocElement *)Cell->Items[i]; if (dp) { dp->NowSelect = false; dp->OldSelect = false; } } } if (bSelect) PaintSelect(hDC, rc, &PaintSelectIn); else PaintRange(hDC, rc); for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp == NULL) continue; // if(dp->HasValue()){ // dp->PaintReport(Sender, hDC, vs, bPrint, false,language); // }else{ if (dp->bVisible) dp->PaintDesign(Sender, hDC, vs, bPrint, false, language, paintID); else dp->PaintDesignHidden(Sender, hDC, vs, bPrint, false, language, paintID); // } } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::ResetDesignSelection() { if (Cell->Count == 0) return; for (int i = 0; i < Cell->Count; i++) { ((TPDocElement *)Cell->Items[i])->NowSelect = false; // ((TPDocElement *)Cell->Items[i])->OldSelect = false; } } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::HasValue() { return false; } //--------------------------------------------------------------------------- void __fastcall TPDocChart::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { if (Cell->Count == 0) return; int i, j, k, center; double gab; WideString C_Value; TPDocElement *dp; int cnt; if (!bselect) { //¸ðµç ¼¿ ¼±ÅÃ ÇØÁ¦. for (i = 0; i < Cell->Count; i++) { ((TPDocElement *)Cell->Items[i])->NowSelect = false; ((TPDocElement *)Cell->Items[i])->OldSelect = false; } } if (EditFormula) { //±âµµ»ê¾÷ÀÇ ÆíÂ÷¿¡ ÀÇÇØ °ªÀÌ °è»êµÇ´Â ºÎºÐ.... if ((Rows == 1) || (Cols < 4)) //ÆíÂ÷¿¡ ÀÇÇØ °è»êµÇ¾îÁú ºÎºÐÀÌ ¾ø´Â°æ¿ìÀ̹ǷΠgoto next; //ÀϹÝÀûÀÎ Chartó·³ Ç¥½Ã.... dp = (TPDocElement *)Cell->Items[Cols]; if(dp->Type != detEdit) //Chart¸¦ Çü½Ä¿¡ ¸Â°Ô ¸¸µéÁö ¸øÇÑ °æ¿ì... goto next; //ÀϹÝÀûÀÎ Chartó·³ Ç¥½Ã.... ((TPDocEdit *)dp)->GetK_Text(C_Value); center = FindCenter(C_Value); // Áß½ÉÀÌ µÇ´Â À§Ä¡¸¦ ±¸ÇÔ.. ResetFormula(); for (j=0; jItems[j*Cols + k]; if (k>1 && dp->Type == detFormula) { // Formula must be setted... /* blocked by k3dogs ÀÚµ¿°è»ê¸¸ µÇ´Â °æ¿ì. SetFormula(j, k, center); } dp->PaintReport(Sender, hDC, vs, bPrint, bselect, language); } */ //==========by k3dogs(20001029) Data°ªÀÌ trueÀ̸é SetFormula¸¦ Áö³ªÃļ­ ÀÚµ¿°è»ê¿¡¼­ Á¦¿ÜµÇ¾î ANumber¸¦ º¸Á¸ÇÑ´Ù. if ( (0<= FSelectRow< Rows) && (0<= FSelectCol< Cols) && (0<= (FSelectRow*Cols+FSelectCol) < Rows*Cols) ) { ((TPDocFormula *)dp)->Data = true; if ( (FSelectCol == 0 && FSelectRow == 1)) { ((TPDocFormula *)dp)->Data = false; } if ( FSelectCol == center || FSelectCol == 1) { if (FSelectRow == j) ((TPDocFormula *)dp)->Data = false; } if ( (((TPDocFormula *)dp)->Data==false) ) SetFormula(j, k, center); } } dp->PaintReport(Sender, hDC, vs, bPrint, bselect, language, bSaveJPG); } //========================================================= } else { // TPDocEdit·Î¼­ ¹®ÀÚµéÀÌ µé¾î°£´Ù... for (k=0; kItems[k]; dp->PaintReport(Sender, hDC, vs, bPrint, bselect, language, bSaveJPG); } } } } else { // ÀϹÝÀûÀÎ Â÷Æ®¿Í °°ÀÌ ±×·ÁÁø´Ù. next: for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if(dp->bVisible) dp->PaintReport(Sender, hDC, vs, bPrint, bselect, language, bSaveJPG); else dp->PaintReportHidden(Sender, hDC, vs, bPrint, bselect, language, bSaveJPG); //else if(dp->NowSelect) dp->PaintIn(hDC,ConvertRange(&vs)); // For Test (2007. 07. 09 Annualring) // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 04 Annualring) // if (dp->Background.BgSet) { // dp->PaintBackground(hDC, dp->ConvertRange(&vs), dp->Background.BgColor); // } } } } //--------------------------------------------------------------------------- /*int __fastcall TPDocChart::FindCenter(AnsiString C_Value) { int i; AnsiString str; TPDocElement *sep; if (C_Value.Length() > 0) { for (i=2; iItems[i]; if (sep->Type == detEdit) { ((TPDocEdit *)sep)->GetK_Text(str); if(C_Value.AnsiCompare(str) == 0) return i; } } return -1; //can't find center..... } else { return -1; //can't find center..... } } //--------------------------------------------------------------------------- */ int __fastcall TPDocChart::FindCenter(WideString C_Value) { int i; WideString str; TPDocElement *sep; if (C_Value.Length() > 0) { for (i=2; iItems[i]; if (sep->Type == detEdit) { ((TPDocEdit *)sep)->GetK_Text(str); if(C_Value == str) return i; } } return -1; //can't find center..... } else { return -1; //can't find center..... } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetFormula(int row, int col, int center) { int gab, absgab, CID; double value; // Warning ¼öÁ¤ (2007. 05. 17 Annualring) WideString ff, txt; TPDocElement *sep; TPDocFormula *fp, *cfp; TPDocNumber *np; if (center == col || center < 0) return; sep = (TPDocElement *)Cell->Items[row*Cols+center]; if (((TPDocFormula *)sep)->ANumber.Length() == 0) return; sep = (TPDocElement *)Cell->Items[col]; ((TPDocEdit *)sep)->GetK_Text(txt); if (txt.Length() == 0) return; sep = (TPDocElement *)Cell->Items[row*Cols+center]; cfp = (TPDocFormula *)sep; sep = (TPDocElement *)Cell->Items[row*Cols+col]; if (sep->Type == detFormula) { fp = (TPDocFormula *)sep; sep = (TPDocElement *)Cell->Items[row*Cols+1]; np = (TPDocNumber *)sep; if (np->Number.Length() > 0) { if (TryStrToFloat(np->Number, value)){ gab = col - center; absgab = fabs(gab); CID = cfp->ID; // ¸Å¹ø ãÀ»°ÍÀÌ ¾Æ´Ï¶ó PaintReport¿¡¼­ ã´Â°ÍÀÌ ¾î¶³Áö... if (gab > 0) ff = "+I" + IntToStr(absgab)+ "*I" + FloatToStr(value); else ff = "-I" + IntToStr(absgab)+ "*I" + FloatToStr(value); fp->Formula ="F"+IntToStr(CID) + ff; } else { return; } /* try { value = StrToFloat(np->Number); gab = col - center; absgab = fabs(gab); CID = cfp->ID; // ¸Å¹ø ãÀ»°ÍÀÌ ¾Æ´Ï¶ó PaintReport¿¡¼­ ã´Â°ÍÀÌ ¾î¶³Áö... if (gab > 0) ff = "+I" + IntToStr(absgab)+ "*I" + FloatToStr(value); else ff = "-I" + IntToStr(absgab)+ "*I" + FloatToStr(value); fp->Formula ="F"+IntToStr(CID) + ff; } catch (EConvertError &ec) { return; } */ } } } //--------------------------------------------------------------------------- void __fastcall TPDocChart::ResetFormula() { if (Cell->Count == 0) return; int i; TPDocElement *sep; for (i=0; iCount; i++) { sep = (TPDocElement *)Cell->Items[i]; if (sep && sep->Type == detFormula) { if (((TPDocFormula *)sep)->Formula.Length() > 0) { ((TPDocFormula *)sep)->Formula = ""; // ((TPDocFormula *)sep)->ANumber = ""; blocked by k3dogs(20001029) } if ( ((TPDocFormula *)sep)->ANumber.Length()<= 0 ) ((TPDocFormula *)sep)->ANumber = ""; //added by k3dogs(20001029) } } } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; int i, count; TPDocElement *dp; RECT rc; TPDocElementType et; TPDocBorder bd; //TColor fc; TPDocFrameColor fc; TextVersion = Version; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) TPDocBackground* background = NULL; bool visible = true; RemoveData(); if (!TPDocText::LoadFromFile(hFile, Version)) return false; // TODO : TexWork File ¹öÀü ¿Ã¸®¸é ¿©±â ¼öÁ¤ÇÒ °Í!! if (CURRENT_VERSION < Version) return false; if (!ReadFile(hFile, &FID, sizeof(int), &dwRead, NULL)) return false; if (Version < 8) { if (!ReadFile(hFile, &Cols, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Rows, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &EditFormula, sizeof(bool), &dwRead, NULL)) return false; SetFilePointer(hFile, (Cols + Rows -2) * sizeof(int), NULL, FILE_CURRENT); /*PosX = new int[Cols + 1]; if (!ReadFile(hFile, PosX + 1, (Cols - 1) * sizeof(int), &dwRead, NULL)) return false; PosX[0] = 0; PosX[Cols] = Range.right - Range.left; PosY = new int[Rows + 1]; if (!ReadFile(hFile, PosY + 1, (Rows - 1) * sizeof(int), &dwRead, NULL)) return false; PosY[0] = 0; PosY[Rows] = Range.bottom - Range.top;*/ } Cell = new TList; if (Version < 8) { for (i = 0; i < Cols * Rows; i++) { if (!ReadFile(hFile, &et, sizeof(TPDocElementType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &rc, sizeof(RECT), &dwRead, NULL)) return false; switch (et) { case detColorChip: dp = new TPDocColorChip(this, rc); break; case detNumber: dp = new TPDocNumber(this, rc); break; case detFormula: dp = new TPDocFormula(this, rc); break; case detLabel: dp = new TPDocLabel(this, rc); break; case detEdit: dp = new TPDocEdit(this, rc); break; case detImage: dp = new TPDocImage(this, rc); break; case detDate: dp = new TPDocDate(this, rc); break; case detNone: dp = NULL; break; default: dp = NULL; break; } if (dp) { if (!dp->LoadFromFile(hFile, Version)) return false; Cell->Add(dp); } } } else { if (!ReadFile(hFile, &count, sizeof(int), &dwRead, NULL)) return false; for (i = 0; i < count; i++) { if (!ReadFile(hFile, &et, sizeof(TPDocElementType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &rc, sizeof(RECT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &bd, sizeof(TPDocBorder), &dwRead, NULL)) return false; if (Version < 18) { TColor tempColor; if (!ReadFile(hFile, &tempColor, sizeof(TColor), &dwRead, NULL)) return false; fc.left = tempColor; fc.top = tempColor; fc.right = tempColor; fc.bottom = tempColor; } else if (Version >= 18) // TODO : TexWork File ¹öÀü ¿Ã¸®¸é ¿©±â ¼öÁ¤ÇÒ °Í!! { if (!ReadFile(hFile, &fc, sizeof(TPDocFrameColor), &dwRead, NULL)) return false; } if(Version > 17) { if (!ReadFile(hFile, &visible, sizeof(bool), &dwRead, NULL)) return false; } // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) if (Version > 16) { background = new TPDocBackground(); if (!background->LoadFromFile(hFile, Version)) return false; } switch (et) { case detColorChip: dp = new TPDocColorChip(this, rc); break; case detNumber: dp = new TPDocNumber(this, rc); break; case detFormula: dp = new TPDocFormula(this, rc); break; case detLabel: dp = new TPDocLabel(this, rc); break; case detEdit: dp = new TPDocEdit(this, rc); break; case detDate: dp = new TPDocDate(this, rc); break; case detImage: dp = new TPDocImage(this, rc); break; case detMemo: dp = new TPDocMemo(this, rc); break; case detTextImage: dp = new TPDocTextImage(this, rc); break; case detSignature: dp = new TPDocSignature(this, rc); break; // ComboBox Load Ãß°¡. (2007. 05. 03 Annualring) case detComboBox: dp = new TPDocComboBox(this, rc); break; case detNone: dp = NULL; break; default: dp = NULL; break; } if (dp) { dp->FrameStyle = bd; dp->FrameColor = fc; dp->bVisible = visible; if (Version > 17) { dp->bVisible = visible; } // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) if (Version > 16) { dp->Background = *background; } if (!dp->LoadFromFile(hFile, Version)) return false; Cell->Add(dp); } if (background) { // ¸Þ¸ð¸® ´©¼ö ó¸® (2007. 07. 13 Annualring) delete background; background = NULL; } } } SetCursorIndex(); return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::SaveToFile(HANDLE hFile) { DWORD dwWrite; int i, count; TPDocElement *dp; if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &FID, sizeof(int), &dwWrite, NULL)) return false; //if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; //if (!WriteFile(hFile, &EditFormula, sizeof(bool), &dwWrite, NULL)) return false; count = Cell->Count; if (!WriteFile(hFile, &count, sizeof(int), &dwWrite, NULL)) return false; for (i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; dp->bSaveAsSmallImage = bSaveAsSmallImage; //À̹ÌÁö¸¦ ÁÙ¿©¼­ ÀúÀåÇϱâ À§ÇØ Ãß°¡ by altang 07.04.16. if (!WriteFile(hFile, &dp->Type, sizeof(TPDocElementType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &dp->Range, sizeof(RECT), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &dp->FrameStyle, sizeof(TPDocBorder), &dwWrite, NULL)) return false; if (SaveVersion < 18) { if (!WriteFile(hFile, &dp->FrameColor.left, sizeof(TColor), &dwWrite, NULL)) return false; } else { if (!WriteFile(hFile, &dp->FrameColor, sizeof(TPDocFrameColor), &dwWrite, NULL)) return false; } if (SaveVersion > 17) { if (!WriteFile(hFile, &dp->bVisible, sizeof(bool), &dwWrite, NULL)) return false; } // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) // Save Version ÀÌ 16º¸´Ù ³ôÀ» ¶§¸¸ ÀúÀåÇϵµ·Ï º¯°æ (2007. 07. 13 Annualring) if (SaveVersion > 16) { if (!dp->Background.SaveToFile(hFile)) return false; } if (!dp->SaveToFile(hFile)) return false; } return true; } //--------------------------------------------------------------------------- int __fastcall TPDocChart::GetAllocateSize() { if (Cell->Count == 0) return 0; int size = 0; int SelectedCellCnt = 0; TPDocElement *dp; size += TPDocText::GetAllocateSize(); size += sizeof(int); //FID size += sizeof(int); //Selected Cell Count for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ //size += (sizeof(TPDocElementType) + sizeof(RECT) + sizeof(TPDocBorder) + sizeof(TColor) + sizeof(bool)); size += (sizeof(TPDocElementType) + sizeof(RECT) + sizeof(TPDocBorder) + sizeof(TPDocFrameColor) + sizeof(bool)); // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) size += dp->Background.GetAllocateSize(); size += dp->GetAllocateSize(); SelectedCellCnt++; } } // size +=sizeof(TList); // size +=sizeof(POINT)*SelectedCellCnt; size +=sizeof(TPoint)*SelectedCellCnt; if(SelectedCellCnt>0){ return size; }else{ return 0; } } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocChart::CopyToMemory(BYTE *lp) { TPDocElement *dp; TList *TempList; TPoint *TempPt; int cnt = 0; lp = TPDocText::CopyToMemory(lp); memcpy(lp, &FID, sizeof(int)); lp += sizeof(int); for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) cnt++; } memcpy(lp, &cnt, sizeof(int)); lp += sizeof(int); for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ memcpy(lp, &dp->Type, sizeof(TPDocElementType)); lp += sizeof(TPDocElementType); memcpy(lp, &dp->Range, sizeof(RECT)); lp += sizeof(RECT); memcpy(lp, &dp->FrameStyle, sizeof(TPDocBorder)); lp += sizeof(TPDocBorder); //memcpy(lp, &dp->FrameColor, sizeof(TColor)); //lp += sizeof(TColor); memcpy(lp, &dp->FrameColor, sizeof(TPDocFrameColor)); lp += sizeof(TPDocFrameColor); memcpy(lp, &dp->bVisible, sizeof(bool)); lp += sizeof(bool); // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) dp->Background.CopyToMemory(lp); lp += dp->Background.GetAllocateSize(); if(dp->Type!=detColorChip) lp = dp->CopyToMemory(lp); } } TempList = GetCellCoordinate(true); TempPt = GetMinSelectedElt(TempList); int x = TempPt->x; int y = TempPt->y; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ TempPt=(TPoint *)TempList->Items[i]; TempPt->x=TempPt->x - x; TempPt->y=TempPt->y - y; memcpy(lp, (TPoint *)TempList->Items[i], sizeof(TPoint)); lp += sizeof(TPoint); } } /* while (TempList->Count) { TempPt = (TPoint *)TempList->Last(); TempList->Remove(TempPt); delete TempPt; }*/ for (int i = 0; i < TempList->Count; i++) { TempPt = (TPoint *)TempList->Items[i]; delete TempPt; } TempList->Clear(); delete TempList; return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsLatticeSelected(){ TPDocElement *dp; /////////////////////////////////////////////// TList *RectList = new TList; bool bResult; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ RectList->Add(&dp->Range); } } bResult = IsLattice(RectList); RectList->Clear(); delete RectList; //latticeÇüÅÂÀÎÁö üũ /////////////////////////////////////////////// return bResult; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::CanUseSameHeight(){ TPDocElement *dp; /////////////////////////////////////////////// TList *RectList = new TList; bool bResult; int cnt = 0; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ RectList->Add(&dp->Range); cnt++; } } if(cnt){ bResult = AreRows(RectList); }else{ bResult = false; } delete RectList; //latticeÇüÅÂÀÎÁö üũ /////////////////////////////////////////////// return bResult; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::CanUseSameWidth(){ TPDocElement *dp; /////////////////////////////////////////////// TList *RectList = new TList; bool bResult; int cnt = 0; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ RectList->Add(&dp->Range); cnt++; } } if(cnt){ bResult = AreColumns(RectList); }else{ bResult = false; } delete RectList; //latticeÇüÅÂÀÎÁö üũ /////////////////////////////////////////////// return bResult; } //--------------------------------------------------------------------------- int __fastcall intCompare(void *item1,void *item2){ int val1 = *((int *)item1); int val2 = *((int *)item2); return val1-val2; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::LetCellsHasSameHeight(TPDocSheet *Sheet){ //int __fastcall intCompare(void *item1,void *item2); ElementUndoSave(); //For Undo TPDocElement *dp; TPoint *Result; TPoint *Temp; Result = NULL; RECT * TempRect; /* ____________________ | | ____________________ | | | ____________________ CellµéÀÌ À§¿Í °°ÀÌ °¢°¢ÀÇ Rowµé ÇüÅ·Π¸ð¿©Àִ°æ¿ì . */ //===================================================// /////////////////////////////////////////////// TList *RangeList = new TList; bool bResult; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ RangeList->Add(&dp->Range); } } ////////////////////////////////////////////////¸¶Áö¸· üũ //for linuxjun if(!CheckCellArrangement(RangeList,dnbdTop)||!CheckCellArrangement(RangeList,dnbdRight)){ RangeList->Clear(); delete RangeList; //latticeÇüÅÂÀÎÁö üũ return false; } for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ Sheet->UndoSave(dp); //for Undo } } //////////////////////////////////////////////// //===================================================// int *AxisValue=new int[RangeList->Count+1]; int *ValueLength=new int[RangeList->Count+1]; int *FixedValue=new int[RangeList->Count+1]; // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) int *IsAligned = new int[Cell->Count]; int cnt = RangeList->Count; int num = 0; int y = -1; int minY = -1; int maxY = -1; ////////////////////////////////////////////////////// // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) for (int i = 0; i < Cell->Count; i++) { IsAligned[i] = false; } for (int i = 0; i < cnt+1; i++) { AxisValue[i]=-1; ValueLength[i]=0; } for (int i = 0; i < cnt; i++) { TempRect = (RECT *)RangeList->Items[i]; y=TempRect->top; if(minY==-1){ minY=TempRect->top; }else if(minY>TempRect->top){ minY=TempRect->top; } for(int j = 0;jItems[i]; y=TempRect->bottom; if(maxY==-1){ maxY = TempRect->bottom; }else if(maxYbottom){ maxY = TempRect->bottom; } /* for(int j = 1;jAdd(&(AxisValue[i])); } } // num -= 1; SortedList->Sort(intCompare); ////////////////////////////////////////// for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ // RangeList->Add(&dp->Range); for(int j = 0; j< cnt +1;j++){ // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) if(AxisValue[j]==dp->Range.top && !IsAligned[i]){ dp->Range.top =minY + (maxY-minY)*( SortedList->IndexOf(&(AxisValue[j])) )/num ; dp->Range.bottom=minY + (maxY-minY)*( SortedList->IndexOf(&(AxisValue[j]))+1 )/num ; if (dp->IndexR.down > -1 && dp->IndexR.down < Cell->Count){ TPDocElement *down = (TPDocElement *)Cell->Items[dp->IndexR.down]; if (false == down->NowSelect && down->Range.top != dp->Range.bottom){ down->Range.top = dp->Range.bottom; } } // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) IsAligned[i] = true; } if(AxisValue[j]==dp->Range.bottom){ } } } } // for(int i RECT * TempRECT; while(RangeList->Count){ TempRECT=(RECT *)RangeList->First(); RangeList->Remove(TempRECT); } delete RangeList; //latticeÇüÅÂÀÎÁö üũ int * TempInt; while(SortedList->Count){ TempInt=(int *)SortedList->First(); SortedList->Remove(TempInt); } delete SortedList; //latticeÇüÅÂÀÎÁö üũ delete []AxisValue; delete []ValueLength; delete []FixedValue; // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) delete []IsAligned; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::LetCellsHasSameWidth(TPDocSheet *Sheet){ int __fastcall intCompare(void *item1,void *item2); ElementUndoSave(); //For Undo TPDocElement *dp; TPoint *Result; TPoint *Temp; Result = NULL; RECT * TempRect; /* ____________________ | | | | |_________| | | | ____________________ CellµéÀÌ À§¿Í °°ÀÌ °¢°¢ÀÇ Columnsµé ÇüÅ·Π¸ð¿©Àִ°æ¿ì . */ //===================================================// /////////////////////////////////////////////// TList *RangeList = new TList; bool bResult; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ RangeList->Add(&dp->Range); } } ////////////////////////////////////////////////¸¶Áö¸· üũ //for linuxjun if(!CheckCellArrangement(RangeList,dnbdTop)||!CheckCellArrangement(RangeList,dnbdRight)){ RangeList->Clear(); delete RangeList; //latticeÇüÅÂÀÎÁö üũ return false; } for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ Sheet->UndoSave(dp); //for Undo } } //////////////////////////////////////////////// //===================================================// int *AxisValue=new int[RangeList->Count+1]; int *ValueLength=new int[RangeList->Count+1]; int *FixedValue=new int[RangeList->Count+1]; // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) int *IsAligned = new int[Cell->Count]; int cnt = RangeList->Count; int num = 0; int x = -1; int minX = -1; int maxX = -1; ////////////////////////////////////////////////////// // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) for (int i = 0; i < Cell->Count; i++) { IsAligned[i] = false; } for (int i = 0; i < cnt+1; i++) { AxisValue[i]=-1; ValueLength[i]=0; } for (int i = 0; i < cnt; i++) { TempRect = (RECT *)RangeList->Items[i]; x=TempRect->left; if(minX==-1){ minX=TempRect->left; }else if(minX>TempRect->left){ minX=TempRect->left; } for(int j = 0;jItems[i]; x=TempRect->right; if(maxX==-1){ maxX = TempRect->right; }else if(maxXright){ maxX = TempRect->right; } /* for(int j = 1;jAdd(&(AxisValue[i])); } } // num -= 1; SortedList->Sort(intCompare); ////////////////////////////////////////// for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ // RangeList->Add(&dp->Range); for(int j = 0; j< cnt +1;j++){ // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) if(AxisValue[j]==dp->Range.left && !IsAligned[i]){ dp->Range.left =minX + (maxX-minX)*( SortedList->IndexOf(&(AxisValue[j])) )/num ; dp->Range.right=minX + (maxX-minX)*( SortedList->IndexOf(&(AxisValue[j]))+1 )/num ; // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) IsAligned[i] = true; } if(AxisValue[j]==dp->Range.right){ } } } } // for(int i RECT * TempRECT; while(RangeList->Count){ TempRECT=(RECT *)RangeList->First(); RangeList->Remove(TempRECT); } delete RangeList; //latticeÇüÅÂÀÎÁö üũ int * TempInt; while(SortedList->Count){ TempInt=(int *)SortedList->First(); SortedList->Remove(TempInt); } delete SortedList; //latticeÇüÅÂÀÎÁö üũ delete []AxisValue; delete []ValueLength; delete []FixedValue; // ¼¿ ³ª´« ´ÙÀ½¿¡ ´Ù¸¥ ¼¿°ú ³ôÀÌ, ³Êºñ ¸ÂÃâ ¶§ ¿¡·¯³ª´Â ¹®Á¦ ó¸® (2007. 06. 13 Annualring) delete []IsAligned; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::LetCellsBeLattice(TPDocSheet *Sheet){ ElementUndoSave(); //For Undo TPDocElement *dp; // TList *RangeList; TList *SelectedRectList; // TList *SrcRectList; TList *TempList1; TList *TempList2; int nSel=0; int numLeft = 0; int numBottom = 0; int numTemp = 0; int TempNum = 0; // int TempList2Cnt = 0; // int SelectedCnt = 0; int nResult; // RangeList = new TList; SelectedRectList= new TList; RECT * Temp; RECT * Pivot; /////////////////initialize for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; // RangeList->Add(&dp->Range); /* Temp = new RECT; Temp->left = dp->Range.left; Temp->right = dp->Range.right; Temp->top = dp->Range.top; Temp->bottom = dp->Range.bottom; RangeList->Add(Temp); */ if (dp->NowSelect){ Temp = new RECT; Temp->left = dp->Range.left; Temp->right = dp->Range.right; Temp->top = dp->Range.top; Temp->bottom = dp->Range.bottom; SelectedRectList->Add(Temp); nSel++; } } //////////////////////////////////////////////////////////////////////// ///////////////////Condition Check! if(IsLattice(SelectedRectList)){ //if Cells has already Lattice Structure,Do Nothing! // DeAllocateRectList(RangeList); DeAllocateRectList(SelectedRectList); return true; } ///////////////////ProCedure1 ///////////////////Step1 : Make Lattice Structure At SelectedRectList // SrcRectList = new TList; TempList1 = new TList; TempList2 = new TList; //Check Condition1 FindEdgeElts(TempList1,SelectedRectList,dnbdLeft); numLeft = TempList1->Count; FindEdgeElts(TempList2,TempList1,dnbdBottom); if(TempList2->Count != 1){ //°¡Àå¿ÞÂÊ¿¡ °¡Àå ¾Æ·¡ÂÊÀÌ µÇ´Â Minima ¿ø¼Ò°¡ 1°³°¡ ¾Æ´Ï¸é //Lattice·Î ¸¸µé¼ö ¾ø´Ù. goto fail; } Pivot = (RECT *)TempList2->First(); //Check Condition2 TempList1->Clear();TempList2->Clear(); FindEdgeElts(TempList1,SelectedRectList,dnbdBottom); FindEdgeElts(TempList2,TempList1,dnbdLeft); numBottom = TempList1->Count; Temp = (RECT *)TempList2->First(); // TempList2Cnt = TempList2->Count; // SelectedCnt = SelectedRectList->Count; if( (TempList2->Count != 1) || Temp != Pivot || (SelectedRectList->Count != numBottom * numLeft)){ // if( (TempList2Cnt != 1) || Temp != Pivot || (SelectedCnt != numBottom * numLeft)){ //°¡À徯·¡ ÂÊ¿¡ °¡Àå ¿ÞÂÊÀÌ µÇ´Â Minima ¿ø¼Ò°¡ 1°³°¡ ¾Æ´Ï¸é //¶Ç´Â °¡Àå¿ÞÂÊÀ¸·Î °£ÈÄ À§ÂÊÀ¸·Î °¡¼­ ¸¸³­ ¿ø¼Ò¿Í °¡Àå À§ÂÊÀ¸·Î °£ÈÄ ¿ÞÂÊÀ¸·Î °¡¼­ ¸¸³­ ¿ø¼Ò°¡ //´Þ¸£¸é //¶Ç´Â °¡Àå ¿ÞÂÊÀÇ ¿ø¼ÒµéÀÇ °¹¼ö¿Í °¡ÀåÀ§ÂÊÀÇ ¿ø¼ÒµéÀÇ °¹¼öÀÇ °öÀÌ Àüü ¿ø¼ÒÀÇ °¹¼ö¿Í ´Ù¸£¸é, //Lattice·Î ¸¸µé¼ö ¾ø´Ù. goto fail; } //Check Condition3 if(!CheckCellArrangement(SelectedRectList,dnbdTop)){ goto fail; } /* TempList1->Clear();TempList2->Clear(); FindEdgeElts(TempList1,SelectedRectList,dnbdTop); Temp = (RECT *)TempList1->First(); TempNum = Temp->top; for(int i=0; iCount;i++){ Temp = (RECT *)TempList1->Items[i]; if(Temp->top != TempNum){ //topµéÀÌ Áï, ²À´ë±â ¿ø¼ÒµéÀÇ top°ªÀÌ °°Àº°ª Áï, lineÀ» ÀÌ·çÁö ¾ÊÀ¸¸é false goto fail; } } */ //Check Condition4 if(!CheckCellArrangement(SelectedRectList,dnbdRight)){ goto fail; } /* TempList1->Clear();TempList2->Clear(); FindEdgeElts(TempList1,SelectedRectList,dnbdRight); Temp = (RECT *)TempList1->First(); TempNum = Temp->right; for(int i=0; iCount;i++){ Temp = (RECT *)TempList1->Items[i]; if(Temp->right != TempNum){ //rightµéÀÌ Áï, ¿À¸¥ÂÊ¿ø¼ÒµéÀÇ right°ªÀÌ °°Àº°ª Áï, lineÀ» ÀÌ·çÁö ¾ÊÀ¸¸é false goto fail; } }*/ //Row Á¤·Ä. // SrcRectList->Add(Pivot); TempList1->Clear();TempList2->Clear(); FindEdgeElts(TempList1,SelectedRectList,dnbdLeft); Temp = Pivot; for(int i = 0; i < numLeft; i++){ TempNum = FitOneRow(Temp,SelectedRectList,i); //½ÇÁ¦·Î ÀÏÀ» ÇØÁÖ´Â ºÎºÐ. if(TempNum == -1 || TempNum+1 != numBottom) goto fail; TempList2->Clear(); numTemp = FindNeighbor(Temp , TempList2, TempList1, dnbdTop); if(numTemp != 1){ if(i == numLeft-1 && numTemp == 0 ){ }else{ //¿ÞÂʰ͵éÀÇ °¹¼ö¿Í ¿¬°áµÈ ¿ÞÂʸ®½ºÆ®ÀÇ °¹¼ö°¡ Ʋ¸®¸é ¾ÈµÊ. goto fail; } } if(TempList2->Count == 1){ Temp = (RECT *)TempList2->First(); }else if(TempList2->Count!=0){ //TempList2ÀÇ ¿ø¼ÒÀÇ °¹¼ö°¡ 0,1ÀÌ ¾Æ´Ï¶ó¸é ¿¡·¯! goto fail; } } //Column Á¤·Ä. TempList1->Clear();TempList2->Clear(); FindEdgeElts(TempList1,SelectedRectList,dnbdBottom); Temp = Pivot; for(int i = 0; i < numBottom; i++){ TempNum = FitOneColumn(Temp,SelectedRectList,i); //½ÇÁ¦·Î ÀÏÀ» ÇØÁÖ´Â ºÎºÐ. if(TempNum == -1 || TempNum+1 != numLeft) goto fail; TempList2->Clear(); numTemp = FindNeighbor(Temp , TempList2, TempList1, dnbdRight); if(numTemp != 1){ if(i == numBottom-1 && numTemp == 0 ){ }else{ //¿ÞÂʰ͵éÀÇ °¹¼ö¿Í ¿¬°áµÈ ¿ÞÂʸ®½ºÆ®ÀÇ °¹¼ö°¡ Ʋ¸®¸é ¾ÈµÊ. goto fail; } } if(TempList2->Count == 1){ Temp = (RECT *)TempList2->First(); }else if(TempList2->Count!=0){ goto fail; } } /* nResult = FitOtherRect(SelectedRectList,SrcRectList,0); if(nResult == -1){ goto fail; } */ for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ Sheet->UndoSave(dp); //for Undo } } ///////////////////ProCedure2 ///////////////////Step2 : Change Other Rectange to fit the Place numTemp = 0; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ Temp = (RECT *)SelectedRectList->Items[numTemp++]; dp->Range.left = Temp->left; dp->Range.right = Temp->right; dp->Range.top = Temp->top; dp->Range.bottom = Temp->bottom; } } //////////////////destroy // DeAllocateRectList(RangeList); DeAllocateRectList(SelectedRectList); // SrcRectList->Crear(); delete SrcRectList; TempList1->Clear();TempList2->Clear(); delete TempList1; delete TempList2; return true; fail: // DeAllocateRectList(RangeList); DeAllocateRectList(SelectedRectList); // SrcRectList->Crear(); delete SrcRectList; TempList1->Clear();TempList2->Clear(); delete TempList1; delete TempList2; return false; } //--------------------------------------------------------------------------- int __fastcall TPDocChart::FindNeighbor(RECT * Pivot,TList *Result, TList *SrcRect,int direction){ RECT * Temp; int num=0; for(int i = 0;iCount;i++){ Temp = (RECT *)SrcRect->Items[i]; switch(direction){ case dnbdLeft: // if(Pivot->left == Temp->right){ if( Temp->left < Pivot->left && Pivot->left <= Temp->right && Temp->right right){ if( (Pivot->top <= Temp->top && Temp->top < Pivot->bottom) || (Pivot->top < Temp->bottom && Temp->bottom <=Pivot->bottom) || (Temp->top <= Pivot->top && Pivot->top < Temp->bottom) || (Temp->top < Pivot->bottom && Pivot->bottom <= Temp->bottom) ) { if(Temp->left!=Temp->right){ Result->Add(Temp); num++; } } } break; case dnbdRight: // if( Pivot->right == Temp->left){ if( Temp->left <= Pivot->right && Pivot->right < Temp->right && Pivot ->left < Temp->left){ if( (Pivot->top <= Temp->top && Temp->top < Pivot->bottom) || (Pivot->top < Temp->bottom && Temp->bottom <=Pivot->bottom) || (Temp->top <= Pivot->top && Pivot->top < Temp->bottom) || (Temp->top < Pivot->bottom && Pivot->bottom <= Temp->bottom) ) { if(Temp->left!=Temp->right){ Result->Add(Temp); num++; } } } break; case dnbdTop: // if( Pivot->top == Temp->bottom){ if(Temp->top < Pivot->top && Pivot->top <= Temp->bottom && Temp->bottom < Pivot->bottom){ if( (Pivot->left <= Temp->left && Temp->left < Pivot->right) || (Pivot->left < Temp->right && Temp->right <=Pivot->right) || (Temp->left <= Pivot->left && Pivot->left < Temp->right) || (Temp->left < Pivot->right && Pivot->right <=Temp->right) ) { if(Temp->top!=Temp->bottom){ Result->Add(Temp); num++; } } } break; case dnbdBottom: // if( Pivot->bottom == Temp->top){ if( Temp->top <= Pivot->bottom && Pivot->bottom < Temp->bottom && Pivot->top < Temp->top){ if( (Pivot->left <= Temp->left && Temp->left < Pivot->right) || (Pivot->left < Temp->right && Temp->right <=Pivot->right) || (Temp->left <= Pivot->left && Pivot->left < Temp->right) || (Temp->left < Pivot->right && Pivot->right <=Temp->right) ) { if(Temp->top!=Temp->bottom){ Result->Add(Temp); num++; } } } break; } } return num; } //--------------------------------------------------------------------------- int __fastcall TPDocChart::FindEdgeElts(TList *Result, TList *SrcRect,int direction){ RECT * Temp; //init TList *TempList; int num=0; TempList = new TList; //init for(int i = 0;iCount;i++){ Temp = (RECT *)SrcRect->Items[i]; TempList->Clear(); FindNeighbor(Temp,TempList,SrcRect,direction); if(TempList->Count==0){ Result->Add(Temp); num++; } } TempList->Clear(); delete TempList; //destroy return num; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::CheckCellArrangement(TList *SrcRect,int direction){ TList * TempList1; TList * TempList2; RECT * Temp; int TempNum; TempList1 = new TList; TempList2 = new TList; FindEdgeElts(TempList1,SrcRect,direction); Temp = (RECT *)TempList1->First(); switch(direction){ case dnbdLeft: TempNum = Temp->left; for(int i=0; iCount;i++){ Temp = (RECT *)TempList1->Items[i]; if(Temp->left != TempNum){ //topµéÀÌ Áï, ²À´ë±â ¿ø¼ÒµéÀÇ top°ªÀÌ °°Àº°ª Áï, lineÀ» ÀÌ·çÁö ¾ÊÀ¸¸é false goto fail; } } break; case dnbdRight: TempNum = Temp->right; for(int i=0; iCount;i++){ Temp = (RECT *)TempList1->Items[i]; if(Temp->right != TempNum){ //topµéÀÌ Áï, ²À´ë±â ¿ø¼ÒµéÀÇ top°ªÀÌ °°Àº°ª Áï, lineÀ» ÀÌ·çÁö ¾ÊÀ¸¸é false goto fail; } } break; case dnbdTop: TempNum = Temp->top; for(int i=0; iCount;i++){ Temp = (RECT *)TempList1->Items[i]; if(Temp->top != TempNum){ //topµéÀÌ Áï, ²À´ë±â ¿ø¼ÒµéÀÇ top°ªÀÌ °°Àº°ª Áï, lineÀ» ÀÌ·çÁö ¾ÊÀ¸¸é false goto fail; } } break; case dnbdBottom: TempNum = Temp->bottom; for(int i=0; iCount;i++){ Temp = (RECT *)TempList1->Items[i]; if(Temp->bottom != TempNum){ //topµéÀÌ Áï, ²À´ë±â ¿ø¼ÒµéÀÇ top°ªÀÌ °°Àº°ª Áï, lineÀ» ÀÌ·çÁö ¾ÊÀ¸¸é false goto fail; } } break; } TempList1->Clear();TempList2->Clear(); delete TempList1; delete TempList2; return true; fail: TempList1->Clear();TempList2->Clear(); delete TempList1; delete TempList2; return false; } /* //--------------------------------------------------------------------------- int __fastcall TPDocChart::FitOtherRect(TList *DestRects,TList *SrcRect,int Step){ RECT *From; RECT To; RECT *Pivot; RECT *Temp; int num; if(Step >= SrcRectList->Count || Step <0) return -1; //Valid Check! Pivot = (RECT *)SrcRect->Items[Step]; num = 0; for(int i = 0 ; iCount;i++){ Temp = (RECT *)DestRects->Items[i]; if(Temp->left == Pivot->Right){ if( (Temp->top >= Pivot->top && Temp->top <= Pivot->bottom) || (Temp->bottom >= Pivot->top && Temp->bottom <=Pivot->bottom) ) { if(num == 0 ){ From = Temp; }else{ } num++; } } } // From.left = Temp->left; From.right = Temp->right; // From.top = Temp->top; From.bottom = Temp->bottom; To.left = Temp->left; To.right = Temp->right; To.top = Temp->top; To.bottom = Temp->bottom; } */ //--------------------------------------------------------------------------- int __fastcall TPDocChart::FitOneRow(RECT *Pivot,TList *SrcRect,int Step){ RECT *Temp; RECT *NBD; //NeighBor RECT To; TList *RightList; TList *RightBottomList; TList *NBDList; //NeighBor List int numTemp; RightList = new TList; RightBottomList = new TList; NBDList = new TList; Temp = Pivot; int nResult = 0; do{ RightBottomList->Clear(); RightList->Clear(); //½ÃÀÛÇϱâÀü¿¡ ²À ÃʱâÈ­ ÀØÁö¸»°Í! FindNeighbor(Temp,RightList,SrcRect, dnbdRight); //¿À¸¥Âʸ鿡 ºÙÀº ¿ø¼ÒµéÀ» ¸ðµÎ RightList¿¡ ÀúÀå½ÃŲ´Ù. if(RightList->Count == 0)break; //ÇѰ³ ÀÌ»ó ºÙ¾îÀÖÀ¸¸é FindEdgeElts(RightBottomList,RightList,dnbdBottom); //±×Áß °¡Àå ¾Æ·§ÂÊ¿¡ ÀÖ´Â ¿ø¼Ò¸¦ ÅÃÇÑ´Ù. if( RightBottomList->Count == 1 ) { Temp = (RECT *)RightBottomList->First(); if(Pivot->top != Temp->top || Pivot->bottom != Temp->bottom) { //Check whether new Rect destroy existing Rect NBDList->Clear(); FindNeighbor(Temp,NBDList,SrcRect, dnbdTop); for(int i=0;iCount;i++){ NBD=(RECT *)NBDList->Items[i]; if(NBD->top > Pivot->top){ goto fail; } } /////////////////////////////////////////////// Temp->top = Pivot->top; if(Step) Temp->bottom = Pivot->bottom; //StepÀÌ 0ÀÌ ¾Æ´Ò¶§¸¸ ¼¼ÆÃÇØÁÜ. } nResult++; }else{break;} }while(RightBottomList->Count>0); RightBottomList->Clear(); delete RightBottomList; RightList->Clear(); delete RightList; NBDList->Clear(); delete NBDList; return nResult; fail: RightBottomList->Clear(); delete RightBottomList; RightList->Clear(); delete RightList; NBDList->Clear(); delete NBDList; return -1; } //--------------------------------------------------------------------------- int __fastcall TPDocChart::FitOneColumn(RECT *Pivot,TList *SrcRect,int Step){ RECT *Temp; RECT *NBD; //NeighBor RECT To; TList *TopList; TList *TopLeftList; TList *NBDList; //NeighBor List int numTemp; TopList= new TList; TopLeftList= new TList; NBDList = new TList; Temp = Pivot; int nResult = 0; do{ TopLeftList->Clear(); TopList->Clear(); //½ÃÀÛÇϱâÀü¿¡ ²À ÃʱâÈ­ ÀØÁö¸»°Í! FindNeighbor(Temp,TopList,SrcRect, dnbdTop); //top ¸é¿¡ Á¢ÇØÀÖ´Â ¸ðµç ¿ø¼ÒµéÀ» TopList¿¡ ÀúÀå½ÃŲ´Ù. if(TopList->Count == 0)break; FindEdgeElts(TopLeftList,TopList,dnbdLeft); //±×Áß °¡Àå ¿ÞÂʰÍÀ» ÅÃÇÑ´Ù. if( TopLeftList->Count == 1 ) { Temp = (RECT *)TopLeftList->First(); if(Pivot->left != Temp->left || Pivot->right != Temp->right) { //Check whether new Rect destroy existing Rect NBDList->Clear(); FindNeighbor(Temp,NBDList,SrcRect, dnbdRight); for(int i=0;iCount;i++){ NBD=(RECT *)NBDList->Items[i]; if(NBD->right < Pivot->right){ goto fail; } } /////////////////////////////////////////////// if(Step) Temp->left = Pivot->left; //StepÀÌ 0ÀÌ ¾Æ´Ò¶§¸¸ ¼¼ÆÃÇØÁÜ. Temp->right = Pivot->right; } nResult++; }else{break;} }while(TopLeftList->Count>0); // FindNeighbor(Temp,TopList,SrcRect, dnbdTop); TopLeftList->Clear(); delete TopLeftList; TopList->Clear(); delete TopList; NBDList->Clear(); delete NBDList; return nResult; fail: TopLeftList->Clear(); delete TopLeftList; TopList->Clear(); delete TopList; NBDList->Clear(); delete NBDList; return -1; } /* //--------------------------------------------------------------------------- bool __fastcall ChangeOneRect(RECT *From,RECT To,TList *SrcRect){ } */ //--------------------------------------------------------------------------- bool __fastcall TPDocChart::DeAllocateRectList(TList *List){ RECT * Temp; while(List->Count){ Temp=(RECT *)List->Last(); List->Remove(Temp); delete Temp; } delete List; // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- int __fastcall TPDocChart::GetSelectElementNum(){ TPDocElement *dp; int nResult=0; for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ nResult++; } } return nResult; // return 0; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsPasted(){ return bPasted; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocChart::CopyFromMemory(BYTE *lp) { TPDocElement *dp, *de, *se; TList *TempList, *srcIndex, *dstIndex; TPoint *sip, *dip, base; int cnt, i, j; TPDocChart *TempChart; TPDocElementType type; RECT range; TPDocBorder frameStyle; //TColor frameColor; TPDocFrameColor frameColor; int SelectedNum; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) TPDocBackground* background = NULL; int newIDNumber; bool visible; TStringList* oldID; TStringList* newID; oldID = new TStringList; newID = new TStringList; lp = TPDocText::CopyFromMemory(lp); memcpy(&FID, lp, sizeof(int)); lp += sizeof(int); memcpy(&cnt, lp, sizeof(int)); lp += sizeof(int); TempChart = new TPDocChart(Parent, Rect(0, 0, 0, 0), daCenter2, 0, 0); for (i = 0; i < cnt; i++){ memcpy(&type, lp, sizeof(TPDocElementType)); lp += sizeof(TPDocElementType); memcpy(&range, lp, sizeof(RECT)); lp += sizeof(RECT); memcpy(&frameStyle, lp, sizeof(TPDocBorder)); lp += sizeof(TPDocBorder); //memcpy(&frameColor, lp, sizeof(TColor)); //lp += sizeof(TColor); memcpy(&frameColor, lp, sizeof(TPDocFrameColor)); lp += sizeof(TPDocFrameColor); memcpy(&visible, lp, sizeof(bool)); lp += sizeof(bool); // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) background = new TPDocBackground(); background->CopyFromMemory(lp); lp += background->GetAllocateSize(); switch (type) { case detColorChip: dp = new TPDocColorChip(TempChart, range); break; case detNumber: dp = new TPDocNumber(TempChart, range); break; case detFormula: dp = new TPDocFormula(TempChart, range); break; case detLabel: dp = new TPDocLabel(TempChart, range); break; case detEdit: dp = new TPDocEdit(TempChart, range); break; case detImage: dp = new TPDocImage(TempChart, range); break; case detMemo: dp = new TPDocMemo(TempChart, range); break; case detTextImage: dp = new TPDocTextImage(TempChart, range); break; case detSignature: dp = new TPDocSignature(TempChart, range); break; case detDate: dp = new TPDocDate(TempChart, range); break; default: dp = NULL; break; } if (dp) { dp->FrameStyle = frameStyle; dp->FrameColor = frameColor; dp->bVisible = visible; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) dp->Background = *background; // ID ´Â º¹»çµÇÁö ¾Êµµ·Ï! (2007. 08. 21 Annualring) if (dp->Type == detNumber) { newID->Add("N" + (AnsiString)(((TPDocNumber*)dp)->ID)); newIDNumber = ((TPDocNumber*)dp)->ID; } else if (dp->Type == detFormula) { newID->Add("F" + (AnsiString)(((TPDocFormula*)dp)->ID)); newIDNumber = ((TPDocFormula*)dp)->ID; } else if (dp->Type == detDate) { newID->Add("D" + (AnsiString)(((TPDocDate*)dp)->ID)); newIDNumber = ((TPDocDate*)dp)->ID; } lp = dp->CopyFromMemory(lp); // ID ´Â º¹»çµÇÁö ¾Êµµ·Ï! (2007. 08. 21 Annualring) if (dp->Type == detNumber) { oldID->Add("N" + (AnsiString)(((TPDocNumber*)dp)->ID)); ((TPDocNumber*)dp)->ID = newIDNumber; } else if (dp->Type == detFormula) { oldID->Add("F" + (AnsiString)(((TPDocFormula*)dp)->ID)); ((TPDocFormula*)dp)->ID = newIDNumber; } else if (dp->Type == detDate) { oldID->Add("D" + (AnsiString)(((TPDocDate*)dp)->ID)); ((TPDocDate*)dp)->ID = newIDNumber; } TempChart->Cell->Add(dp); } if (background) { // ¸Þ¸ð¸® ´©¼ö ó¸® (2007. 07. 13 Annualring) delete background; background = NULL; } } // ¿©±â¼­ ÀçÁ¤·Ä ConvertCellIDInFormula(oldID, newID, TempChart->Cell); if (oldID) { oldID->Clear(); delete oldID; oldID = NULL; } if (newID) { newID->Clear(); delete newID; newID = NULL; } srcIndex = new TList; for (int i = 0; i < cnt; i++){ sip = new TPoint; memcpy(sip, lp, sizeof(TPoint)); lp += sizeof(TPoint); srcIndex->Add(sip); } //<----------for Qe-------------->// SelectedNum=0; //* for linuxjun for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ SelectedNum++; } } //*/ if (SelectedNum <= 1){ dstIndex = GetCellCoordinate(); }else{ dstIndex = GetCellCoordinate(true); //¼¿ ¼±ÅÃµÈ »óÅ¿¡¼­ ºÙ¿©³Ö±â¸¦ À§ÇØ Á¸Àç. } if (SelectedNum <= 1){ // dstIndex = GetCellCoordinate(); base = *((TPoint *)dstIndex->Items[FNumber]); }else{ base = *GetMinSelectedElt(dstIndex); //¾à°£ ºÒ¾È for Qe } /////////////////////////////////////////////// TList *RectList = new TList; for (i = 0; i < TempChart->Cell->Count; i++) { sip = (TPoint *)srcIndex->Items[i]; for (j = 0; j < Cell->Count; j++) { dip = (TPoint *)dstIndex->Items[j]; if (sip->x == (dip->x - base.x) && sip->y == (dip->y - base.y)) break; } if (j < Cell->Count) { de = (TPDocElement *)Cell->Items[j]; RectList->Add(&de->Range); } } if(IsLattice(RectList)){ //latticeÇüÅÂÀÎÁö üũ for (i = 0; i < TempChart->Cell->Count; i++) { sip = (TPoint *)srcIndex->Items[i]; for (j = 0; j < Cell->Count; j++) { dip = (TPoint *)dstIndex->Items[j]; if (sip->x == (dip->x - base.x) && sip->y == (dip->y - base.y)) break; } if (j < Cell->Count) { se = (TPDocElement *)TempChart->Cell->Items[i]; de = (TPDocElement *)Cell->Items[j]; OverWriteCell(de, se, j); } } bPasted = true; }else{ bPasted = false; } delete RectList; //latticeÇüÅÂÀÎÁö üũ /////////////////////////////////////////////// while (srcIndex->Count) { sip = (TPoint *)srcIndex->Last(); srcIndex->Remove(sip); delete sip; } delete srcIndex; while (dstIndex->Count) { dip = (TPoint *)dstIndex->Last(); dstIndex->Remove(dip); delete dip; } delete dstIndex; delete TempChart; SetCursorIndex(); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::CopyCreateFromMemory(BYTE *lp, int left, int top, bool bCopyID) { TPDocElement *dp, *de, *se; TPoint *sip, *dip, base; int cnt, i, j; TPDocChart *TempChart; TPDocElementType type; RECT range; TPDocBorder frameStyle; //TColor frameColor; TPDocFrameColor frameColor; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) TPDocBackground* background = NULL; TStringList* oldID; TStringList* newID; bool visible; lp = TPDocText::CopyFromMemory(lp); memcpy(&FID, lp, sizeof(int)); lp += sizeof(int); memcpy(&cnt, lp, sizeof(int)); lp += sizeof(int); TempChart = new TPDocChart(Parent, Range, daCenter2, 0, 0); for (i = 0; i < cnt; i++){ memcpy(&type, lp, sizeof(TPDocElementType)); lp += sizeof(TPDocElementType); memcpy(&range, lp, sizeof(RECT)); lp += sizeof(RECT); memcpy(&frameStyle, lp, sizeof(TPDocBorder)); lp += sizeof(TPDocBorder); //memcpy(&frameColor, lp, sizeof(TColor)); //lp += sizeof(TColor); memcpy(&frameColor, lp, sizeof(TPDocFrameColor)); lp += sizeof(TPDocFrameColor); memcpy(&visible, lp, sizeof(bool)); lp += sizeof(bool); // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) background = new TPDocBackground(); background->CopyFromMemory(lp); lp += background->GetAllocateSize(); switch (type) { case detColorChip: dp = new TPDocColorChip(TempChart, range); break; case detNumber: dp = new TPDocNumber(TempChart, range); break; case detFormula: dp = new TPDocFormula(TempChart, range); break; case detLabel: dp = new TPDocLabel(TempChart, range); break; case detEdit: dp = new TPDocEdit(TempChart, range); break; case detImage: dp = new TPDocImage(TempChart, range); break; case detMemo: dp = new TPDocMemo(TempChart, range); break; case detTextImage: dp = new TPDocTextImage(TempChart, range); break; case detSignature: dp = new TPDocSignature(TempChart, range); break; case detDate: dp = new TPDocDate(TempChart, range); break; default: dp = NULL; break; } if (dp) { dp->FrameStyle = frameStyle; dp->FrameColor = frameColor; dp->bVisible = visible; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) dp->Background = *background; if(dp->Type!=detColorChip) lp = dp->CopyFromMemory(lp); dp->NowSelect = true; TempChart->Cell->Add(dp); } if (background) { // ¸Þ¸ð¸® ´©¼ö ó¸® (2007. 07. 13 Annualring) delete background; background = NULL; } } if (TempChart->IsPerfectRect()) { range = TempChart->GetPerfectRect(); Range.left = left; Range.top = top; Range.right = (range.right - range.left) + left; Range.bottom = (range.bottom - range.top) + top; for (i = 0; i < cnt; i++) { dp = (TPDocElement *)TempChart->Cell->Items[i]; dp->Range.left -= range.left; dp->Range.right -= range.left; dp->Range.top -= range.top; dp->Range.bottom -= range.top; } Copy(TempChart, bCopyID); // TempChart Áö¿ì±â Àü¿¡ ¿©±â¼­ ÇöÀç Â÷Æ®¿Í TempChart¸¦ ºñ±³ÇÏ¿© ¼ö½ÄÀ» º¯°æÇØÁØ´Ù. // ¼ö½Ä¿¡ µé¾î°¡´Â ¹®ÀÚµé n, N, f, F, i, I, +, -, /, *, (, ) ¿©±â¼­ Àß ÆÇ´Ü // (2007. 08. 22 Annualring) // pf = new Postfix(((AnsiString)Formula).c_str()); // if (!pf->convert()) { oldID = new TStringList; newID = new TStringList; // oldID ¸¸µé±â for (i = 0; i < TempChart->Cell->Count; i++) { dp = (TPDocElement *)TempChart->Cell->Items[i]; switch (dp->Type) { case detNumber: oldID->Add("N" + (AnsiString)(((TPDocNumber*)dp)->ID)); break; case detFormula: oldID->Add("F" + (AnsiString)(((TPDocNumber*)dp)->ID)); break; } } // newID ¸¸µé±â for (i = 0; i < this->Cell->Count; i++) { dp = (TPDocElement *)this->Cell->Items[i]; switch (dp->Type) { case detNumber: newID->Add("N" + (AnsiString)(((TPDocNumber*)dp)->ID)); break; case detFormula: newID->Add("F" + (AnsiString)(((TPDocNumber*)dp)->ID)); break; } } ConvertCellIDInFormula(oldID, newID, this->Cell); if (oldID) { oldID->Clear(); delete oldID; oldID = NULL; } if (newID) { newID->Clear(); delete newID; newID = NULL; } /* if (pf) { delete pf; pf = NULL; } */ delete TempChart; return true; } else { delete TempChart; return false; } } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::RemoveSelectedCells() { TPDocElement *dp; int nResult=0; bool bDeleted; for (int i =0;i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ nResult++; } } if(nResult){ ElementUndoSave(); //For Undo UndoSave(this); //for Undo nResult=0; } for (int i = 0; i< Cell->Count;i++){ dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ bDeleted = RemoveCellData(dp,i); if(bDeleted)nResult++; } } SetCursorIndex(); if(nResult){ return true; }else{ return false; } } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::RemoveCellData(TPDocElement *dst, int index) { TPDocElement *dp = NULL; switch (dst->Type) { case detColorChip: //dp = new TPDocColorChip(this, dst->Range); //break; ((TPDocColorChip *)dst)->Color = clWhite; return true; case detNumber: /* dp = new TPDocNumber(this, dst->Range); ((TPDocText *)dp)->TPDocTextSetFont((TPDocText *)dst); break; */ ((TPDocNumber *)dst)->Number = ""; return true; case detFormula: //dp = new TPDocFormula(this, dst->Range); //((TPDocText *)dp)->TPDocTextSetFont((TPDocText *)dst); //break; return true; case detLabel: dp = new TPDocLabel(this, dst->Range); ((TPDocText *)dp)->TPDocTextSetFont((TPDocText *)dst); break; case detEdit: ((TPDocEdit *)dst)->SetK_Text((WideString)""); //dp = new TPDocEdit(this, dst->Range); //((TPDocText *)dp)->TPDocTextSetFont((TPDocText *)dst); //break; return true; case detImage: dp = new TPDocImage(this, dst->Range); ((TPDocText *)dp)->TPDocTextSetFont((TPDocText *)dst); break; case detMemo: dp = new TPDocMemo(this, dst->Range); ((TPDocText *)dp)->TPDocTextSetFont((TPDocText *)dst); break; case detTextImage: dp = new TPDocTextImage(this, dst->Range); // dp->TPDocText::Copy((TPDocText *)src); break; case detSignature: dp = new TPDocSignature(this, dst->Range); break; case detDate: dp = new TPDocDate(this, dst->Range); break; default: dp = NULL; return false; } if (dp) { dp->FrameStyle = dst->FrameStyle; dp->FrameColor = dst->FrameColor; dp->bVisible = dst->bVisible; //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB AnsiString DstFieldName=""; switch (dst->Type) { //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB DstFieldName = ((TPDocNumber *)dst)->FieldName; break; case detFormula: DstFieldName = ((TPDocFormula *)dst)->FieldName; break; case detDate: DstFieldName = ((TPDocDate *)dst)->FieldName; break; case detEdit: DstFieldName = ((TPDocEdit *)dst)->FieldName; break; //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB } switch (dp->Type) { //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB ((TPDocNumber *)dp)->FieldName = DstFieldName; break; case detFormula: ((TPDocFormula *)dp)->FieldName = DstFieldName; break; case detDate: ((TPDocDate *)dp)->FieldName = DstFieldName; break; case detEdit: ((TPDocEdit *)dp)->FieldName = DstFieldName; break; //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB } //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB Cell->Remove(dst); DeleteUndoSave(dst); //For DeleteUndo //delete dst; //For DeleteUndo CreateUndoSave(dp); Cell->Insert(index, dp); } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::OverWriteCell(TPDocElement *dst, TPDocElement *src, int index) { TPDocElement *dp; switch (src->Type) { case detColorChip: dp = new TPDocColorChip(this, dst->Range); if (!((TPDocColorChip *)dp)->Copy((TPDocColorChip *)src)) return false; ((TPDocColorChip *)dp)->Name = ""; break; case detNumber: dp = new TPDocNumber(this, dst->Range); if (!((TPDocNumber *)dp)->Copy((TPDocNumber *)src)) return false; ((TPDocNumber *)dp)->Name = ""; break; case detFormula: dp = new TPDocFormula(this, dst->Range); if (!((TPDocFormula *)dp)->Copy((TPDocFormula *)src)) return false; ((TPDocFormula *)dp)->Name = ""; break; case detLabel: dp = new TPDocLabel(this, dst->Range); if (!((TPDocLabel *)dp)->Copy((TPDocLabel *)src)) return false; break; case detEdit: dp = new TPDocEdit(this, dst->Range); if (!((TPDocEdit *)dp)->Copy((TPDocEdit *)src)) return false; ((TPDocEdit *)dp)->Name = ""; break; case detImage: dp = new TPDocImage(this, dst->Range); if (!((TPDocImage *)dp)->Copy((TPDocImage *)src)) return false; ((TPDocImage *)dp)->Name = ""; break; case detMemo: dp = new TPDocMemo(this, dst->Range); if (!((TPDocMemo *)dp)->Copy((TPDocMemo *)src)) return false; break; case detTextImage: dp = new TPDocTextImage(this, dst->Range); if (!((TPDocTextImage *)dp)->Copy((TPDocTextImage *)src)) return false; break; case detSignature: dp = new TPDocSignature(this, dst->Range); if (!((TPDocSignature *)dp)->Copy((TPDocSignature *)src)) return false; break; case detDate: dp = new TPDocDate(this, dst->Range); if (!((TPDocDate *)dp)->Copy((TPDocDate *)src)) return false; ((TPDocDate *)dp)->Name = ""; break; default: dp = NULL; return false; // ((TPDocDate *)dp)dp->name = ""; //commonData Error¼öÁ¤À» À§ÇØ ³ÖÀ½ ±×·±µ¥ detDate´Â Àß »ç¿ëµÇÁö ¾ÊÀ¸¹Ç·Î copy±¸ÇöÀÌ // ¾ÈµÇ¾îÀÖÀ½. } if (dp) { ElementUndoSave(); //For Undo UndoSave(this); //for Undo dp->FrameStyle = src->FrameStyle; dp->FrameColor = src->FrameColor; dp->bVisible = src->bVisible; //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB AnsiString DstFieldName=""; switch (dst->Type) { //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB DstFieldName = ((TPDocNumber *)dst)->FieldName; break; case detFormula: DstFieldName = ((TPDocFormula *)dst)->FieldName; break; case detDate: DstFieldName = ((TPDocDate *)dst)->FieldName; break; case detEdit: DstFieldName = ((TPDocEdit *)dst)->FieldName; break; //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB } switch (dp->Type) { //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB ((TPDocNumber *)dp)->FieldName = DstFieldName; break; case detFormula: ((TPDocFormula *)dp)->FieldName = DstFieldName; break; case detDate: ((TPDocDate *)dp)->FieldName = DstFieldName; break; case detEdit: ((TPDocEdit *)dp)->FieldName = DstFieldName; break; //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB } //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB Cell->Remove(dst); DeleteUndoSave(dst); //For DeleteUndo //delete dst; //For DeleteUndo CreateUndoSave(dp); //For CreateUndo Cell->Insert(index, dp); } return true; } //--------------------------------------------------------------------------- TList *__fastcall TPDocChart::GetCellCoordinate(bool bSelectedState){ TPDocElement *dp; TPDocElement *pivot; TList * PtList; TList * SortList; TList * TempList; TPoint ** ArrSort; TPoint * Temp; int StartX,StartY; int EndX,EndY; if(Cell->Count){ PtList = new TList; TempList = new TList; SortList = new TList; ArrSort = new TPoint * [Cell->Count]; Temp = GetMinSelectedCoord(); StartX=Temp->x; StartY=Temp->y; delete Temp; Temp = GetMaxSelectedCoord(); EndX=Temp->x; EndY=Temp->y; delete Temp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; //ArrSort[i]=new Point(dp->Range.top,dp->Range.left); // if(dp->Range.left >= StartX){ ArrSort[i]=new TPoint(dp->Range.left,dp->Range.top); // }else{ // ArrSort[i]=new TPoint(dp->Range.left,dp->Range.top+EndY+1); // } } // SortList->Add(ArrSort[0]); int j; // int *TempInt; for( int i =0;i < Cell->Count;i++) { pivot = (TPDocElement *)Cell->Items[i]; for(j= 0;j < SortList->Count;j++) { // dp = (TPDocElement *)Cell->Items[i]; Temp = (TPoint *)SortList->Items[j]; if(pivot->Range.top < Temp->y || pivot->Range.top == Temp->y && pivot->Range.left < Temp->x){ break; } } SortList->Insert(j,ArrSort[i]); // TempInt = new int; *TempInt = i; // TempList->Insert(j,TempInt); } //j=0; Temp=(TPoint *)SortList->Items[0]; j=Temp->y-1; int x=0; int y=-1; // TempList->Add(new TPoint(y,x)); for( int i=0;i < Cell->Count;i++){ Temp=(TPoint *)SortList->Items[i]; if(bSelectedState){ if( (Temp->y >= StartY && Temp->x >=StartX)&& (Temp->y <= EndY && Temp->x <=EndX) ){ if(Temp->y>j) { y++; x=0; j=Temp->y; }else{ x++; } TempList->Add(new TPoint(y,x)); }else{ TempList->Add(new TPoint(-1,-1)); } }else{ if( (Temp->y >= StartY && Temp->x >=StartX) ){ if(Temp->y>j) { y++; x=0; j=Temp->y; }else{ x++; } TempList->Add(new TPoint(y,x)); }else{ TempList->Add(new TPoint(-1,-1)); } } } for(int i =0;iCount;i++){ PtList->Add(TempList->Items[SortList->IndexOf(ArrSort[i])]); } //=========deleteºÎºÐ==========// /* while(TempList->Count){ Temp=(TPoint *)TempList->First(); TempList->Remove(Temp); } */ delete TempList; TempList=NULL; while(SortList->Count){ Temp=(TPoint *)SortList->First(); SortList->Remove(Temp); delete Temp; } delete SortList; /* for(int i=0;iCount;i++){ delete ArrSort[i]; }*/ delete []ArrSort; //=============================// }else{ return NULL; } return PtList; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsLattice(TList *RangeList){ TPDocElement *dp; TPoint *Result; TPoint *Temp; Result = NULL; RECT * TempRect; /* ____________________ | | | ____________________ | | | ____________________ CellµéÀÌ À§¿Í °°ÀÌ °¢°¢ lineÀÌ ¸Â´Â »óÅÂÀÎÁö Ã¼Å©ÇØÁÖ´Â ÇÔ¼ö. */ int *AxisValue=new int[RangeList->Count]; int cnt = RangeList->Count; int numx,numy; int x = -1; int y = -1; ////////////////////////////////////////////////////// for (int i = 0; i < cnt; i++) { AxisValue[i]=-1; } for (int i = 0; i < cnt; i++) { TempRect = (RECT *)RangeList->Items[i]; // x=TempRect->left; x=TempRect->right; for(int j = 0;jItems[i]; y=TempRect->top; for(int j = 0;jItems[i]; // x=TempRect->right; x=TempRect->left; for(int j = 0;jItems[i]; y=TempRect->bottom; for(int j = 0;jCount]; int *ValueLength=new int[RangeList->Count]; int cnt = RangeList->Count; int numx,numy; int x = -1; int w = -1; int y = -1; int h = -1; ////////////////////////////////////////////////////// for (int i = 0; i < cnt; i++) { AxisValue[i]=-1; ValueLength[i]=0; } for (int i = 0; i < cnt; i++) { TempRect = (RECT *)RangeList->Items[i]; x=TempRect->left; h = TempRect->bottom - TempRect->top; for(int j = 0;jItems[i]; x=TempRect->right; h = TempRect->bottom - TempRect->top; for(int j = 0;jCount]; int *ValueLength=new int[RangeList->Count]; int cnt = RangeList->Count; int numx,numy; int x = -1; int w = -1; int y = -1; int h = -1; ////////////////////////////////////////////////////// for (int i = 0; i < cnt; i++) { AxisValue[i]=-1; ValueLength[i]=0; } for (int i = 0; i < cnt; i++) { TempRect = (RECT *)RangeList->Items[i]; y=TempRect->top; w = TempRect->right - TempRect->left; for(int j = 0;jItems[i]; y=TempRect->bottom; w = TempRect->right- TempRect->left; for(int j = 0;jCount; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ Temp = (TPoint *)CoordList->Items[i]; if(!Result){ if(Temp->x>=0&&Temp->y>=0){ Result = Temp; } }else if(Temp->yy || Temp->y==Result->y && Temp->x < Result->x){ if(Temp->x>=0&&Temp->y>=0){ Result = Temp; } } } } return Result; } TPoint * __fastcall TPDocChart::GetMinSelectedCoord() { TPDocElement *dp; TPoint *Result; TPoint *Temp; Result = NULL; int StartX,StartY; StartX=-1; StartY=-1; int SelectedNum=0; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect){ SelectedNum++; // Temp = (TPoint *)CoordList->Items[i]; if(StartX==-1||StartX>dp->Range.left){ StartX=dp->Range.left; } if(StartY==-1||StartY>dp->Range.top){ StartY=dp->Range.top; } /* Temp = new TPoint(dp->Range.left,dp->Range.top); if(!Result){ Result = Temp; }else if(Temp->yy || Temp->y==Result->y && Temp->x < Result->x){ delete Result; Result = Temp; }else{ delete Temp; } */ } } if(!SelectedNum){ dp = (TPDocElement *)Cell->Items[FNumber]; StartX=dp->Range.left; StartY=dp->Range.top; } Result = new TPoint(StartX,StartY); return Result; } //--------------------------------------------------------------------------- TPoint * __fastcall TPDocChart::GetMaxSelectedCoord() { TPDocElement *dp; TPoint *Result; TPoint *Temp; Result = NULL; int EndX,EndY; EndX=-1; EndY=-1; int SelectedNum=0; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; // Temp = (TPoint *)CoordList->Items[i]; if (dp->NowSelect){ SelectedNum++; if(EndX==-1||EndXRange.left){ EndX=dp->Range.left; } if(EndY==-1||EndY < dp->Range.top){ EndY=dp->Range.top; } /* Temp = new TPoint(dp->Range.left,dp->Range.top); if(!Result){ Result = Temp; }else if(Temp->yy || Temp->y==Result->y && Temp->x < Result->x){ delete Result; Result = Temp; }else{ delete Temp; } */ } } Result = new TPoint(EndX,EndY); return Result; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::Copy(TPDocChart *src, bool bCopyID) { TPDocText::Copy((TPDocText *)src); TPDocElement *dp = NULL, *sp = NULL; FID = src->ID; for (int i = 0; i < src->Cell->Count; i++) { sp = (TPDocElement *)src->Cell->Items[i]; switch (sp->Type) { case detColorChip: dp = new TPDocColorChip(this, sp->Range); if (!((TPDocColorChip *)dp)->Copy((TPDocColorChip *)sp)) return false; break; case detNumber: dp = new TPDocNumber(this, sp->Range); if (!((TPDocNumber *)dp)->Copy((TPDocNumber *)sp, bCopyID)) return false; break; case detFormula: dp = new TPDocFormula(this, sp->Range); // bCopyID Ãß°¡, ¼¿ º¹»ç½Ã¿¡ ID°¡ º¹»ç ¾È µÇµµ·Ï (2007. 08. 14 Annualring) if (!((TPDocFormula *)dp)->Copy((TPDocFormula *)sp, bCopyID)) return false; break; case detLabel: dp = new TPDocLabel(this, sp->Range); if (!((TPDocLabel *)dp)->Copy((TPDocLabel *)sp)) return false; break; case detEdit: dp = new TPDocEdit(this, sp->Range); // bCopyID Ãß°¡, Edit º¹»ç½Ã¿¡ Name º¹»ç°¡ ¾È µÇµµ·Ï (2007. 08. 27 Annualring) if (!((TPDocEdit *)dp)->Copy((TPDocEdit *)sp, bCopyID)) return false; break; case detImage: dp = new TPDocImage(this, sp->Range); if (!((TPDocImage *)dp)->Copy((TPDocImage *)sp, bCopyID)) return false; break; case detMemo: dp = new TPDocMemo(this, sp->Range); if (!((TPDocMemo *)dp)->Copy((TPDocMemo *)sp)) return false; break; case detTextImage: dp = new TPDocTextImage(this, sp->Range); if (!((TPDocTextImage *)dp)->Copy((TPDocTextImage *)sp)) return false; break; case detSignature: dp = new TPDocSignature(this, sp->Range); if (!((TPDocSignature *)dp)->Copy((TPDocSignature *)sp)) return false; break; case detDate: dp = new TPDocDate(this, sp->Range); if (!((TPDocDate *)dp)->Copy((TPDocDate *)sp, bCopyID)) return false; break; case detNone: dp = NULL; break; default: dp = NULL; break; } if (dp) { dp->FrameStyle = sp->FrameStyle; dp->FrameColor = sp->FrameColor; dp->bVisible = sp->bVisible; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 06 Annualring) dp->Background = sp->Background; Cell->Add(dp); } } SetCursorIndex(); return true; } //--------------------------------------------------------------------------- POINT __fastcall TPDocChart::GetRowCol() { return Point(Rows, Cols); } //--------------------------------------------------------------------------- void __fastcall TPDocChart::SetCellSelect() { TPDocElement *dp = (TPDocElement *)Cell->Items[FNumber]; if(dp->NowSelect!=true){ SelectUndoSave(); //For Undo UndoSave(dp); //for Undo } dp->NowSelect = true; } //--------------------------------------------------------------------------- bool __fastcall TPDocChart::IsExist(POINT pt) { int x, y; RECT rt; POINT p; p.x = pt.x - Range.left; p.y = pt.y - Range.top; if (TPDocElement::IsExist(pt)) { for (int i = 0; i < Cell->Count; i++) { rt = ((TPDocObject *)Cell->Items[i])->Range; if (PtInRect(&rt, p)) { FNumber = i; break; } } return true; } return false; } //--------------------------------------------------------------------------- // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 05 Annualring) void __fastcall TPDocChart::SetBackground(bool newBgSet, TColor newBgColor) { ElementUndoSave(); //For Undo TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (dp->NowSelect) { // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 05 Annualring) if (!(dp->Type == detColorChip /*|| dp->Type == detTextImage || dp->Type == detSignature*/)) { // if(currentSheet)currentSheet->UndoSave(dp); //for Undo UndoSave(dp); //for Undo dp->Background.BgSet = newBgSet; dp->Background.BgColor = newBgColor; //((TPDocText *)dp)->Align = al; } } } } //--------------------------------------------------------------------------- // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) TPDocSheet* __fastcall TPDocChart::GetParentSheet() { if(Parent){ return (TPDocSheet *)Parent; } return NULL; } //-------------------------------------------------------------------------- void __fastcall TPDocChart::RemoveSelectedCell() { //¼±ÅÃµÈ ¼¿¸¸ »èÁ¦ÇÏ´Â ÇÔ¼ö (Àüü Ç¥°¡ ¾Æ´Ñ) RECT rc, chartrc; int ExpectedArea = 0, TotalArea = 0; rc.left = 100000; rc.top = 100000; rc.right = - 100000; rc.bottom = - 100000; chartrc.left = 100000; chartrc.top = 100000; chartrc.right = - 100000; chartrc.bottom = - 100000; for(int i = 0; i < Cell->Count; i++) { TPDocElement* sep = (TPDocElement*) Cell->Items[i]; if(sep->NowSelect) { rc.left = Min((int)rc.left,(int)sep->Range.left); rc.top = Min((int)rc.top,(int)sep->Range.top); rc.right = Max((int)rc.right,(int)sep->Range.right); rc.bottom = Max((int)rc.bottom,(int)sep->Range.bottom); TotalArea += (sep->Range.right - sep->Range.left) * (sep->Range.bottom - sep->Range.top); } chartrc.left = Min((int)chartrc.left,(int)sep->Range.left); chartrc.top = Min((int)chartrc.top,(int)sep->Range.top); chartrc.right = Max((int)chartrc.right,(int)sep->Range.right); chartrc.bottom = Max((int)chartrc.bottom,(int)sep->Range.bottom); } ExpectedArea = (rc.right - rc.left) * (rc.bottom - rc.top); if(ExpectedArea != TotalArea) return; if(!(rc.left == chartrc.left && rc.right == chartrc.right || rc.top == chartrc.top && rc.bottom == chartrc.bottom)) return; ElementUndoSave(); UndoSave(this); for(int i = 0; i < Cell->Count; i++) { TPDocElement* sep = (TPDocElement*) Cell->Items[i]; if(sep->NowSelect) { //UndoSave(sep); Cell->Remove(sep); DeleteUndoSave(sep); i--; } } for(int i = 0; i < Cell->Count; i++) { TPDocElement* sep = (TPDocElement*) Cell->Items[i]; UndoSave(sep); if(rc.left == chartrc.left && rc.right == chartrc.right){ if(sep->Range.top > rc.top) { sep->Range.top -= (rc.bottom - rc.top); sep->Range.bottom -= (rc.bottom - rc.top); } } else if(rc.top == chartrc.top && rc.bottom == chartrc.bottom) { if(sep->Range.left > rc.left) { sep->Range.left -= (rc.right - rc.left); sep->Range.right -= (rc.right - rc.left); } } } if(rc.left == chartrc.left && rc.right == chartrc.right) Range.bottom -= (rc.bottom - rc.top); else if(rc.top == chartrc.top && rc.bottom == chartrc.bottom) Range.right -= (rc.right - rc.left); } //-------------------------------------------------------------------------- //Cell Size º¯°æ ´ÜÃàŰ ±¸Çö ///////////////////////////////////////////////////////////////// //shift key¸¦ ´©¸¥ °æ¿ì »ç¿ë : Shift¸¦ ´©¸¥ °æ¿ì ÇØ´ç Àüü Ç¥ÀÇ Å©±â´Â º¯ÇÏÁö ¾Ê°í Cell size¸¸ º¯ÇÑ´Ù.(ÇÑ±Û ÇÁ·Î±×·¥°ú °°Àº µ¿ÀÛ) //CellÀÇ sizeÀÇ Å©±â º¯°æ ¹üÀ§¸¦ ±¸ÇÑ´Ù. void __fastcall TPDocChart::SearchScope(RECT& limitRect) { if(ControlMode == dcmHorizontal) { FMaxX = Range.right; FMinX = 0; }else if(ControlMode == dcmVertical) { FMaxY = Range.bottom; FMinY = 0; } //¼±ÅÃµÈ CellÀÇ ¿µ¿ªÀ» ±¸ÇÔ limitRect = ((TPDocElement*)Cell->Items[FNumber])->Range; for(int i = 0; i < Cell->Count; i++) { TPDocElement *tempCell = (TPDocElement*)Cell->Items[i]; if(tempCell->NowSelect) { if(ControlMode == dcmHorizontal) { if(tempCell->Range.right == limitRect.right) { limitRect.top = min(tempCell->Range.top, limitRect.top); limitRect.bottom = max(tempCell->Range.bottom, limitRect.bottom); } }else if(ControlMode == dcmVertical) { if(tempCell->Range.bottom == limitRect.bottom) { limitRect.left = min(tempCell->Range.left, limitRect.left); limitRect.right = max(tempCell->Range.right, limitRect.right); } } } } //º¯°æ °¡´ÉÇÑ Cell sizeÀÇ ÃÖ´ë/ÃÖ¼Ò¸¦ ±¸ÇÑ´Ù. bool bAvailable1 = false, bAvailable2 = false; //CellÀ» º¯°æÇÒ ¼ö ¾ø´Â °æ¿ì¸¦ Á¶»ç for(int i = 0; i < Cell->Count; i++) { TPDocElement *tempCell = (TPDocElement*)Cell->Items[i]; if(ControlMode == dcmHorizontal) { if(tempCell->Range.right == limitRect.right && tempCell->NowSelect) FMinX = max(FMinX, tempCell->Range.left); else if(tempCell->Range.left == limitRect.right && tempCell->Range.top < limitRect.bottom && tempCell->Range.bottom > limitRect.top) { FMaxX = min(FMaxX, tempCell->Range.right); if(tempCell->Range.top == limitRect.top) bAvailable1 = true; if(tempCell->Range.bottom == limitRect.bottom) bAvailable2 = true; } }else if(ControlMode == dcmVertical) { if(tempCell->Range.bottom == limitRect.bottom && tempCell->NowSelect) FMinY = max(FMinY, tempCell->Range.top); else if(tempCell->Range.top == limitRect.bottom && tempCell->Range.left < limitRect.right && tempCell->Range.right > limitRect.left) { FMaxY = min(FMaxY, tempCell->Range.bottom); if(tempCell->Range.left == limitRect.left) bAvailable1 = true; if(tempCell->Range.right == limitRect.right) bAvailable2 = true; } } } if(ControlMode == dcmHorizontal) { FMaxX -= 3; FMinX += 3; }else if(ControlMode == dcmVertical) { FMaxY -= 3; FMinY += 3; } //CellÀ» º¯°æ ÇÒ ¼ö ¾ø´Â °æ¿ì if(bAvailable1 == false || bAvailable2 == false) { FMaxX = FOldPositionX; FMinX = FOldPositionX; FMaxY = FOldPositionY; FMinY = FOldPositionY; } } //--------------------------------------------------------------------------- //Shift + ¹æÇâŰ¿¡ µû¶ó val¸¸Å­ CellÀÇ size¸¦ º¯°æÇÏ´Â ÇÔ¼ö void __fastcall TPDocChart::ResizeCellForShift(TPDocControlMode ctrlMode, int val) { if(IsMultiSelect()) return; //´ÙÁß ¼±ÅÃÀ» ÇÑ °æ¿ì ¹®Á¦°¡ ÀÖ¾î ½ÇÇà¾ÈµÇµµ·Ï ¸·À½ ControlMode = ctrlMode; //¼±ÅÃµÈ CellÀ» ±¸ÇÑ´Ù. for(int i = Cell->Count - 1; i >= 0; i--) { TPDocElement *tempCell = (TPDocElement*)Cell->Items[i]; if(tempCell->NowSelect == true) { FNumber = i; FOldPositionX = tempCell->Range.right; FOldPositionY = tempCell->Range.bottom; break; } } //CellÀÇ boundary¸¦ ±¸ÇÑ´Ù. RECT limitRect; SearchScope(limitRect); //º¯°æµÉ ÁÂÇ¥°ª if(ControlMode == dcmHorizontal) { FOldPositionX += val; if(FOldPositionX < FMinX) FOldPositionX = FMinX; if(FOldPositionX > FMaxX) FOldPositionX = FMaxX; }else if(ControlMode == dcmVertical) { FOldPositionY += val; if(FOldPositionY < FMinY) FOldPositionY = FMinY; if(FOldPositionY > FMaxY) FOldPositionY = FMaxY; } ElementSizeUndoSave(); UndoSave(this); //CellÀÇ Size º¯°æ for(int i = 0; i < Cell->Count; i++) { TPDocElement *tempCell = (TPDocElement*)Cell->Items[i]; if(ControlMode == dcmHorizontal) { if(tempCell->Range.left == limitRect.right && tempCell->Range.top < limitRect.bottom && tempCell->Range.bottom > limitRect.top) //¼±ÅÃµÈ Cell ÀÌ¿ô CellÀÇ left¸¦ º¯°æ { if(tempCell->IndexR.left > 0) { TPDocElement *leftCell = (TPDocElement*)Cell->Items[tempCell->IndexR.left]; if(leftCell->NowSelect == false) continue; } UndoSave(tempCell); tempCell->Range.left = FOldPositionX; }else if(tempCell->Range.right == Range.right - Range.left) //chartÀÇ °æ°èºÎºÐÀÇ CellÀº º¯°æ X { continue; }else if(tempCell->Range.right == limitRect.right && tempCell->NowSelect) //¼±ÅÃµÈ CellÀÇ right¸¦ º¯°æ { UndoSave(tempCell); tempCell->Range.right = FOldPositionX; } }else if(ControlMode == dcmVertical) { if(tempCell->Range.top == limitRect.bottom && tempCell->Range.left < limitRect.right && tempCell->Range.right > limitRect.left) //¼±ÅÃµÈ Cell ÀÌ¿ô CellÀÇ topÀ» º¯°æ { if(tempCell->IndexR.up > 0) { TPDocElement *upCell = (TPDocElement*)Cell->Items[tempCell->IndexR.up]; if(upCell->NowSelect == false) continue; } UndoSave(tempCell); tempCell->Range.top = FOldPositionY; }else if(tempCell->Range.bottom == Range.bottom - Range.top) //chartÀÇ °æ°èºÎºÐÀÇ CellÀº º¯°æ X { continue; }else if(tempCell->Range.bottom == limitRect.bottom && tempCell->NowSelect) //¼±ÅÃµÈ CellÀÇ bottomÀ» º¯°æ { UndoSave(tempCell); tempCell->Range.bottom = FOldPositionY; } } } SetCursorIndex(); ControlMode = dcmNone; } //--------------------------------------------------------------------------- //lineListÀÇ item¿¡ CellÀÇ lineÀ» Ãß°¡ÇÏ´Â ÇÔ¼ö : ResizeCellForCtrl(...) ¿¡¼­ »ç¿ë void __fastcall TPDocChart::InsertLine(TList* lineList) { for(int i = 0; i < Cell->Count; i++) { TPDocElement* cellItem = (TPDocElement*)Cell->Items[i]; TLineInfo* theLine = new TLineInfo; if(ControlMode == dcmHorizontal) theLine->Position = cellItem->Range.right; else if(ControlMode == dcmVertical) theLine->Position = cellItem->Range.bottom; theLine->Variation = 0; if(lineList->Count == 0) lineList->Add(theLine); for(int lineIdx = 0; lineIdx < lineList->Count; lineIdx++) { TLineInfo* tempLineInfo = (TLineInfo*)lineList->Items[lineIdx]; if(theLine->Position == tempLineInfo->Position) break; if(theLine->Position < tempLineInfo->Position) { lineList->Insert(lineIdx, theLine); break; } if(lineIdx == lineList->Count - 1) lineList->Add(theLine); } } } //--------------------------------------------------------------------------- //Ctrl + ¹æÇâŰ¿¡ µû¶ó val¸¸Å­ CellÀÇ size¸¦ º¯°æÇÏ´Â ÇÔ¼ö void __fastcall TPDocChart::ResizeCellForCtrl(TPDocControlMode ctrlMode, int val) { ControlMode = ctrlMode; TList* lineList = new TList; InsertLine(lineList); bool bEnable = true; TLineInfo* prevLine = NULL; TLineInfo* crtLine = NULL; for(int lineIdx = 0; lineIdx < lineList->Count; lineIdx++) { crtLine = (TLineInfo*)lineList->Items[lineIdx]; if(prevLine) { crtLine->Variation = prevLine->Variation; } for(int cellIdx = 0; cellIdx < Cell->Count; cellIdx++) { TPDocElement* cellItem = (TPDocElement*)Cell->Items[cellIdx]; if( (ControlMode == dcmHorizontal && crtLine->Position == cellItem->Range.right) || (ControlMode == dcmVertical && crtLine->Position == cellItem->Range.bottom) ) { if(cellItem->NowSelect == true) { crtLine->Variation += val; if(prevLine) { if(crtLine->Position + crtLine->Variation < prevLine->Position + prevLine->Variation + 3) bEnable = false; }else { if(crtLine->Position + crtLine->Variation < 3) bEnable = false; } break; } } } prevLine = crtLine; } if(bEnable == true) { ElementSizeUndoSave(); UndoSave(this); int maxPos = 0; for(int cellIdx = 0; cellIdx < Cell->Count; cellIdx++) { TPDocElement* cellItem = (TPDocElement*)Cell->Items[cellIdx]; UndoSave(cellItem); for(int lineIdx = 0; lineIdx < lineList->Count; lineIdx++) { TLineInfo* theLine = (TLineInfo*)lineList->Items[lineIdx]; if(ControlMode == dcmHorizontal) { if(cellItem->Range.left == theLine->Position) cellItem->Range.left += theLine->Variation; if(cellItem->Range.right == theLine->Position) cellItem->Range.right += theLine->Variation; }else if(ControlMode == dcmVertical) { if(cellItem->Range.top == theLine->Position) cellItem->Range.top += theLine->Variation; if(cellItem->Range.bottom == theLine->Position) cellItem->Range.bottom += theLine->Variation; } } if(ControlMode == dcmHorizontal) maxPos = max(maxPos, cellItem->Range.right); else if(ControlMode == dcmVertical) maxPos = max(maxPos, cellItem->Range.bottom); } if(ControlMode == dcmHorizontal) Range.right = Range.left + maxPos; else if(ControlMode == dcmVertical) Range.bottom = Range.top + maxPos; } while(lineList->Count) { TLineInfo* line = (TLineInfo*)lineList->Last(); lineList->Remove(line); } delete lineList; SetCursorIndex(); ControlMode = dcmNone; } //--------------------------------------------------------------------------- //¼¿ ´ÙÁß¼±Åà void __fastcall TPDocChart::MultiSelect(HDC hDC, TPDocViewStatus &vs, int X, int Y) { if(ControlMode == dcmSelect) { GetMultiSelectCell(Point(X - Range.left, Y - Range.top)); PaintControl(hDC, vs); } } //--------------------------------------------------------------------- void __fastcall TPDocChart::GetMultiSelectCell(POINT pt) { SelectUndoSave(); //For Undo TPDocElement *dp; for (int i = 0; i < Cell->Count; i++) { dp = (TPDocElement *)Cell->Items[i]; if (pt.x > dp->Range.left && pt.x < dp->Range.right && pt.y > dp->Range.top && pt.y < dp->Range.bottom) { UndoSave(dp); if (dp->NowSelect == false) { dp->NowSelect = true; } else if (dp->NowSelect == true) { dp->NowSelect = false; } } } } //--------------------------------------------------------------------- // // TPDocArrow // //--------------------------------------------------------------------------- /* __fastcall TPDocArrow::TPDocArrow(TPDocObject *Sender, RECT rc, TPDocArrowType at, POINT tsp, POINT tep, POINT ttp, TPDocAlign ta, AnsiString t, TColor c) : TPDocText(Sender, detArrow, rc, ta) { Parent = Sender; K_Text = t; Type = at; Color = c; sp = tsp; ep = tep; tp = ttp; //==========================//¸ÇóÀ½ ¼±ÅÃÇßÀ»¶§ controlmodedown¿¡ µé¾î°¡Áö ¸øÇؼ­ FOldArrow[0] = sp; //FOldArrowÀÇ °ªÀÌ Á¤ÇØÁöÁö ¾Ê¾Æ¼­ ±×¸²À» ±×¸®Áö ¸øÇϱ⠶§¹®¿¡.. FOldArrow[1] = ep; //if select at first time, as cannot get into controlmodedown event, FOldArrow is not defined, FOldArrow[2] = tp; //so cannot draw line from sp to ep. //========================== bSelected = false; // Arrow MultiSelect bDefaultAlign = true; // dat3Point ArrowÀÇ text Ãâ·Â µÇ´Â allignment¹æÇâÁ¶ÀýÀ»À§ÇØ ÇÊ¿ä. } //-------------------------------------------------------------------------- */ __fastcall TPDocArrow::TPDocArrow(TPDocObject *Sender, RECT rc, TPDocArrowType at, POINT tsp, POINT tep, POINT ttp, TPDocAlign ta, WideString t, TColor c) : TPDocText(Sender, detArrow, rc, ta) { Parent = Sender; K_Text = t; Type = at; Color = c; sp = tsp; ep = tep; tp = ttp; //==========================//¸ÇóÀ½ ¼±ÅÃÇßÀ»¶§ controlmodedown¿¡ µé¾î°¡Áö ¸øÇؼ­ FOldArrow[0] = sp; //FOldArrowÀÇ °ªÀÌ Á¤ÇØÁöÁö ¾Ê¾Æ¼­ ±×¸²À» ±×¸®Áö ¸øÇϱ⠶§¹®¿¡.. FOldArrow[1] = ep; //if select at first time, as cannot get into controlmodedown event, FOldArrow is not defined, FOldArrow[2] = tp; //so cannot draw line from sp to ep. //========================== bSelected = false; // Arrow MultiSelect bDefaultAlign = true; // dat3Point ArrowÀÇ text Ãâ·Â µÇ´Â allignment¹æÇâÁ¶ÀýÀ»À§ÇØ ÇÊ¿ä. } //-------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- void __fastcall TPDocArrow::PaintSelectIn(HDC hDC, void *data) { POINT ttp; int tx, ty; ArrowData *ad = (ArrowData *)data; Rectangle(hDC, ad->fad.x-2, ad->fad.y-2, ad->fad.x+3, ad->fad.y+3); Rectangle(hDC, ad->ead.x-2, ad->ead.y-2, ad->ead.x+3, ad->ead.y+3); if (Type == dat3Point) { Rectangle(hDC, ad->tad.x-2, ad->tad.y-2, ad->tad.x+3, ad->tad.y+3); } } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::PaintControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); nOldROP = SetROP2(hDC, R2_NOT); MoveToEx(hDC, vs.Pattern2ViewX(FOldArrow[0].x), vs.Pattern2ViewY(FOldArrow[0].y), NULL); LineTo(hDC, vs.Pattern2ViewX(FOldArrow[1].x), vs.Pattern2ViewY(FOldArrow[1].y)); if (Type == dat3Point) { LineTo(hDC, vs.Pattern2ViewX(FOldArrow[2].x), vs.Pattern2ViewY(FOldArrow[2].y)); } } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } //-------------------------------------------------------------------------- void __fastcall TPDocArrow::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { } //-------------------------------------------------------------------------- bool __fastcall TPDocArrow::HasValue() { return false; } //-------------------------------------------------------------------------- void __fastcall TPDocArrow::ToggleTextAllign(){ bDefaultAlign = !bDefaultAlign; } //-------------------------------------------------------------------------- bool __fastcall TPDocArrow::GetbDefaultAlign(){ return bDefaultAlign; } //-------------------------------------------------------------------------- void __fastcall TPDocArrow::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; RECT rc; POINT pt[3], mp, ssp, eep, ttp; double theta, yy, ty, tx; ArrowData AD, TD; // AnsiString Text; WideString Text; double r, penSize = 0; r = (double)vs.ZoomIn / vs.ZoomOut; int WidthRes, HeightRes; WidthRes = GetDeviceCaps(hDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hDC, LOGPIXELSY); if(bPrint) { if(bselect) { // bPrint=true ÇÁ¸°Æ®¸ðµåÀ̸鼭 bselect=true ÀÌ¸é ¿ëÁö¸ÂÃã Ãâ·Â TSize Area; double ratiox, ratioy; int dx=30, dy=30; Area.cx = GetDeviceCaps(hDC, HORZRES) * vs.ZoomOut / WidthRes; Area.cy = GetDeviceCaps(hDC, VERTRES) * vs.ZoomOut / HeightRes; ratiox = double(Area.cx - dx * 2) / double( ((TPDocSheet *) Sender)->Range.right); ratioy = double(Area.cy - dy * 2) / double( ((TPDocSheet *) Sender)->Range.bottom); WidthRes *= min(ratiox, ratioy); HeightRes *= min(ratiox, ratioy); } r = (double)WidthRes / vs.ZoomOut; } TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } if (bselect && !bPrint) { PaintControl(hDC, vsc); AD.fad = ConvertPoint(FOldArrow[0], &vs); AD.ead = ConvertPoint(FOldArrow[1], &vs); if (Type == dat3Point) { AD.tad = ConvertPoint(FOldArrow[2], &vs); } PaintSelectReport(hDC, &AD, &PaintSelectIn); ArrowTextOut(hDC, &AD, language, r); return; } AD.fad = ConvertPoint(sp, &vs); AD.ead = ConvertPoint(ep, &vs); if (Type == dat3Point) { AD.tad = ConvertPoint(tp, &vs); } else { AD.tad.x = 0; AD.tad.y = 0; } gdp::PointF *pTemps = new gdp::PointF[3]; gdp::Graphics graphics(hDC); gdp::Color penColor(GetRValue(Color), GetGValue(Color), GetBValue(Color)); gdp::Pen ObjectPen(penColor); if(bPrint) { penSize = WidthRes / vs.ZoomOut; gdp::Pen ObjectPen(penColor, penSize); // ÇÁ¸°Æ® ¸ðµåÀ϶§ Ææ»çÀÌÁî Ãß°¡ graphics.SetPageUnit(gdp::UnitPixel); } try { /* hPen = CreatePen(psSolid, 1 * r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); hBrush = CreateSolidBrush(Color); hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); MoveToEx(hDC, AD.fad.x, AD.fad.y, NULL); LineTo(hDC, AD.ead.x, AD.ead.y);*/ pTemps[0].X = AD.fad.x; pTemps[0].Y = AD.fad.y; pTemps[1].X = AD.ead.x; pTemps[1].Y = AD.ead.y; pTemps[2].X = AD.tad.x; pTemps[2].Y = AD.tad.y; graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); graphics.DrawLine(&ObjectPen, pTemps[0], pTemps[1]); if (Type == dat3Point) { //LineTo(hDC, AD.tad.x, AD.tad.y); graphics.DrawLine(&ObjectPen, pTemps[1], pTemps[2]); } if (Type != datNone) DrawArrow(hDC, &AD, r, bPrint); if (Type == datBoth_Normal || Type == datBoth_Hor_Over || Type == datBoth_Hor_Below || Type == datBoth_Ver_Left || Type == datBoth_Ver_Right) { DrawAddedLine(hDC, &AD, bPrint, penSize); TD.fad = AD.ead; TD.ead = AD.fad; DrawArrow(hDC, &TD, r, bPrint); } else if (Type == datBoth_None) { //DrawAddedLine(hDC, &AD); TD.fad = AD.ead; TD.ead = AD.fad; DrawArrow(hDC, &TD, r, bPrint); } ArrowTextOut(hDC, &AD, language, r); } __finally { if (hOldBrush) SelectObject(hDC, hOldBrush); if (hBrush) DeleteObject(hBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //-------------------------------------------------------------------------- void __fastcall TPDocArrow::DrawArrow(HDC hDC, ArrowData *AD, double r ,bool bPrint) { double theta, tx, ty, yy; POINT pt[3]; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; gdp::PointF *pTemps = new gdp::PointF[3]; gdp::Graphics graphics(hDC); gdp::Color penColor(GetRValue(Color), GetGValue(Color), GetBValue(Color)); gdp::SolidBrush blackBrush(penColor); if(bPrint) graphics.SetPageUnit(gdp::UnitPixel); pt[0] = AD->fad; if (AD->fad.x == AD->ead.x) { if (AD->fad.y < AD->ead.y) { pt[1] = Point(AD->fad.x - 3.5 * r, AD->fad.y + 7 * r); pt[2] = Point(AD->fad.x + 3.5 * r, AD->fad.y + 7 * r); } else { pt[1] = Point(AD->fad.x - 3.5 * r, AD->fad.y - 7 * r); pt[2] = Point(AD->fad.x + 3.5 * r, AD->fad.y - 7 * r); } } else if (AD->fad.y == AD->ead.y) { if (AD->fad.x < AD->ead.x) { pt[1] = Point(AD->fad.x + 7 * r, AD->fad.y - 3.5 * r); pt[2] = Point(AD->fad.x + 7 * r, AD->fad.y + 3.5 * r); } else { pt[1] = Point(AD->fad.x - 7 * r, AD->fad.y - 3.5 * r); pt[2] = Point(AD->fad.x - 7 * r, AD->fad.y + 3.5 * r); } } else { theta = atan(double(AD->fad.y-AD->ead.y) / (AD->ead.x-AD->fad.x)); yy = 7 * r * fabs(sin(theta)); ty = 3.5 * r * cos(theta); tx = 3.5 * r * fabs(sin(theta)); if (AD->fad.x < AD->ead.x) { if (AD->fad.y < AD->ead.y) { pt[1] = Point(AD->fad.x + 7 * r * cos(theta) - tx, AD->fad.y + yy + ty); pt[2] = Point(AD->fad.x + 7 * r * cos(theta) + tx, AD->fad.y + yy - ty); } else { pt[1] = Point(AD->fad.x + 7 * r * cos(theta)- tx, AD->fad.y- yy - ty); pt[2] = Point(AD->fad.x + 7 * r * cos(theta) + tx, AD->fad.y- yy + ty); } } else { if (AD->fad.y < AD->ead.y) { pt[1] = Point(AD->fad.x - 7 * r * cos(theta) - tx, AD->fad.y + yy - ty); pt[2] = Point(AD->fad.x - 7 * r * cos(theta) + tx, AD->fad.y + yy + ty); } else { pt[1] = Point(AD->fad.x - 7 * r *cos(theta) - tx, AD->fad.y - yy + ty); pt[2] = Point(AD->fad.x - 7 * r * cos(theta) + tx, AD->fad.y - yy - ty); } } } for(int i=0; i<3; i++) { pTemps[i].X = pt[i].x; pTemps[i].Y = pt[i].y; } // Polygon(hDC, pt, 3); graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); graphics.FillPolygon(&blackBrush, pTemps, 3); } //-------------------------------------------------------------------------- void __fastcall TPDocArrow::ArrowTextOut(HDC hDC, ArrowData *AD, int language, double zoom) { int th, tempFontSize; HFONT hOldFont; WORD wAlign; switch(language) { case 0: Text = K_Text; break; case 1: Text = E_Text; break; case 2: Text = I_Text; break; case 3: Text = C_Text; break; case 4: Text = J_Text; break; } try { tempFontSize = ResizeFont(zoom, Font); hOldFont = (HFONT)SelectObject(hDC, Font->Handle); SetBkMode(hDC, TRANSPARENT); wAlign = GetTextAlign(hDC); // Font->Name = "Tahoma"; SetTextColor(hDC, Font->Color); //by altang if (Type == datSingle || Type == datNone) { if (AD->fad.x == AD->ead.x) { SetTextAlign(hDC, TA_CENTER); } else { if (AD->fad.x < AD->ead.x) { if(bDefaultAlign){ SetTextAlign(hDC, TA_LEFT); }else{ SetTextAlign(hDC, TA_RIGHT); } } else { if(bDefaultAlign){ SetTextAlign(hDC, TA_RIGHT); }else{ SetTextAlign(hDC, TA_LEFT); } } } } else if (Type == datBoth_Normal || Type == datBoth_None || Type == datBoth_Hor_Over || Type == datBoth_Hor_Below) { SetTextAlign(hDC, TA_CENTER); } else if (Type == datBoth_Ver_Left) { //È­»ìÇ¥ÀÇ ¿ÞÂÊÀ¸·Î ±ÛÀ» ¾´´Ù. SetTextAlign(hDC, TA_RIGHT); } else if (Type == datBoth_Ver_Right) { //È­»ìÇ¥ÀÇ ¿À¸¥ÂÊÀ¸·Î ±ÛÀ» ¾´´Ù. SetTextAlign(hDC, TA_LEFT); } else if (Type == dat3Point) { if(bDefaultAlign){ if (AD->ead.x < AD->tad.x) { //for linuxjun SetTextAlign(hDC, TA_LEFT); } else { SetTextAlign(hDC, TA_RIGHT); } }else{ //bDefaultAlign°ªÀÌ falseÀΰæ¿ì´Â ¿ø·¡ default¹æÇâ°ú ¹Ý´ë¹æÇâÀ¸·Î text°¡ ½áÁø´Ù. if (AD->ead.x < AD->tad.x) { //for linuxjun SetTextAlign(hDC, TA_RIGHT); } else { SetTextAlign(hDC, TA_LEFT); } } } /* tagSIZE size; wchar_t *ch=Text.c_bstr(); GetTextExtentPoint32W(hDC,ch ,Text.Length(),&size); TCanvas *can = newf TCanvas(); can->Handle = hDC; // size = WideCanvasTextExtent(can, Text); */ DrawText(hDC, AD, Text); SetTextAlign(hDC, wAlign); } __finally { if (hOldFont) SelectObject(hDC, hOldFont); RestoreFont(tempFontSize); } } //-------------------------------------------------------------------------- // Text ±×·ÁÁú ¿µ¿ªÀ» °è»êÇÏ¿© ¸®ÅÏÇÏ´Â ÇÔ¼ö (2007. 10. 31 Annualring) RECT __fastcall TPDocArrow::GetNewTextRange() { RECT resultRect = Rect(MaxInt, MaxInt, -MaxInt, -MaxInt); if (!(((TPDocSheet*)Parent)->Sheaf)) { return resultRect; } TPDocument* reportDoc = ((TPDocSheet*)Parent)->Sheaf->SheafReportDoc; HDC hDC = reportDoc->GetHandle(); TPDocViewStatus vs = reportDoc->GetViewStatus(); int language = reportDoc->lang; double zoom = (double)vs.ZoomIn / vs.ZoomOut; unsigned int textAlign; ArrowData AD; RECT currentLine; int currentTspY; int th, tempFontSize; HFONT hOldFont; AD.fad = ConvertPoint(sp, &vs); AD.ead = ConvertPoint(ep, &vs); if (Type == dat3Point) { AD.tad = ConvertPoint(tp, &vs); } switch(language) { case 0: Text = K_Text; break; case 1: Text = E_Text; break; case 2: Text = I_Text; break; case 3: Text = C_Text; break; case 4: Text = J_Text; break; } try { tempFontSize = ResizeFont(zoom); hOldFont = (HFONT)SelectObject(hDC, Font->Handle); SetBkMode(hDC, TRANSPARENT); // Font->Name = "Tahoma"; if (Type == datSingle || Type == datNone) { if (AD.fad.x == AD.ead.x) { textAlign = TA_CENTER; } else { if (AD.fad.x < AD.ead.x) { if(bDefaultAlign){ textAlign = TA_LEFT; }else{ textAlign = TA_RIGHT; } } else { if(bDefaultAlign){ textAlign = TA_RIGHT; }else{ textAlign = TA_LEFT; } } } } else if (Type == datBoth_Normal || Type == datBoth_None || Type == datBoth_Hor_Over || Type == datBoth_Hor_Below) { textAlign = TA_CENTER; } else if (Type == datBoth_Ver_Left) { //È­»ìÇ¥ÀÇ ¿ÞÂÊÀ¸·Î ±ÛÀ» ¾´´Ù. textAlign = TA_RIGHT; } else if (Type == datBoth_Ver_Right) { //È­»ìÇ¥ÀÇ ¿À¸¥ÂÊÀ¸·Î ±ÛÀ» ¾´´Ù. textAlign =TA_LEFT; } else if (Type == dat3Point) { if(bDefaultAlign){ if (AD.ead.x < AD.tad.x) { //for linuxjun textAlign = TA_LEFT; } else { textAlign = TA_RIGHT; } }else{ //bDefaultAlign°ªÀÌ falseÀΰæ¿ì´Â ¿ø·¡ default¹æÇâ°ú ¹Ý´ë¹æÇâÀ¸·Î text°¡ ½áÁø´Ù. if (AD.ead.x < AD.tad.x) { //for linuxjun textAlign = TA_RIGHT; } else { textAlign = TA_LEFT; } } } TEXTMETRIC tm; int i=0, len = 0, lcnt, both = 1; wchar_t *wchSp, *wchTp, *wchEp; POINT tsp; WideString str; int sum=0, ts = 0; GetTextMetrics(hDC, &tm); tsp = AD.ead; lcnt = FindLineCount(Text); // ±Û¾¾ÀÇ ³ôÀ̸¸Å­ À§¿¡¼­ ½ÃÀÛ. switch (Type) { case datSingle: case datNone: if (AD.ead.x == AD.fad.x) { if (AD.ead.y > AD.fad.y) { lcnt = 0; tsp.y += 2; } } else { tsp.y -= tm.tmHeight/2; if (AD.ead.x > AD.fad.x) tsp.x += 2; else tsp.x -= 2; lcnt = lcnt/2; } break; case datBoth_Normal: case datBoth_None: both = 2; tsp.x = (AD.fad.x + AD.ead.x)/2; tsp.y = (AD.fad.y + AD.ead.y)/2; break; case datBoth_Hor_Over: tsp.x = (AD.fad.x + AD.ead.x)/2; break; case datBoth_Hor_Below: lcnt = 0; tsp.x = (AD.fad.x + AD.ead.x)/2; tsp.y += 2; break; case datBoth_Ver_Left: both = 2; tsp.x -= 2; tsp.y = (AD.fad.y + AD.ead.y - tm.tmHeight)/2; break; case datBoth_Ver_Right: both = 2; tsp.x += 2; tsp.y = (AD.fad.y + AD.ead.y - tm.tmHeight)/2; break; case dat3Point: // ÇØÁÙ°Ô ¾ø´ç.... break; } // (2007. 11. 13 Annualring) if (Text.Length() == 0) Text = WideString(" "); wchSp = Text.c_bstr(); if(wchSp != NULL){ // by altang wchEp = wchSp; if(wchEp==NULL) wchEp = WideString('\n'); wchTp = wcschr(wchEp, '\n'); while(wchTp != NULL) { // ¿©±â¿¡¼­ Range¸¦ ±¸ÇÑ´Ù!! tagSIZE size; len = wchTp - wchEp - 1; // Range of rc is right??? GetTextExtentPoint32W(hDC,wchEp ,len, &size); currentTspY = tsp.y - tm.tmHeight*(lcnt/both - i); if (textAlign == TA_LEFT) { currentLine = Rect(tsp.x, currentTspY, tsp.x + size.cx, currentTspY + size.cy); } if (textAlign == TA_RIGHT) { currentLine = Rect(tsp.x - size.cx, currentTspY, tsp.x, currentTspY + size.cy); } if (textAlign == TA_CENTER) { currentLine = Rect(tsp.x + (-size.cx) * 0.5, currentTspY, tsp.x + size.cx * 0.5, currentTspY + size.cy); } resultRect = ComposeRect(currentLine, resultRect); i++; wchEp = wchTp + 1; if(wchEp==NULL) wchEp = WideString('\n'); wchTp = wcschr(wchEp, '\n'); } if (*wchEp) { // when text is not ended with null character!! len = Text.Length() - (wchEp - wchSp); tagSIZE size; GetTextExtentPoint32W(hDC,wchEp ,len, &size); currentTspY = tsp.y - tm.tmHeight*(lcnt/both - i); if (textAlign == TA_LEFT) { currentLine = Rect(tsp.x, currentTspY, tsp.x + size.cx, currentTspY + size.cy); } if (textAlign == TA_RIGHT) { currentLine = Rect(tsp.x - size.cx, currentTspY, tsp.x, currentTspY + size.cy); } if (textAlign == TA_CENTER) { currentLine = Rect(tsp.x + (-size.cx) * 0.5, currentTspY, tsp.x + size.cx * 0.5, currentTspY + size.cy); } resultRect = ComposeRect(currentLine, resultRect); } } } __finally { if (hOldFont) SelectObject(hDC, hOldFont); RestoreFont(tempFontSize); resultRect = InverseConvertRange(resultRect, &vs); return resultRect; } } //-------------------------------------------------------------------------- /// ÇöÀçÀÇ Text Range¸¦ ¸®ÅÏÇÏ´Â ÇÔ¼ö. ÇöÀç TextRange°¡ invalidÇÏ¸é »õ·Î °è»êÇØ¼­ ¸®ÅÏÇÑ´Ù. // (2007. 11. 19 Annualring) RECT __fastcall TPDocArrow::GetTextRange() { if (FTextRange.left > FTextRange.right) { FTextRange = GetNewTextRange(); } return FTextRange; } //--------------------------------------------------------------------------- // Text Rangeµµ ConvertÇÏ´Â ÇÔ¼ö Ãß°¡ (2007. 11. 21 Annualring) RECT __fastcall TPDocArrow::ConvertTextRange(TPDocViewStatus *vs) { RECT rc; rc = FTextRange; if (Parent) { rc.left += Parent->Range.left; rc.top += Parent->Range.top; rc.right += Parent->Range.left; rc.bottom += Parent->Range.top; } if (vs) { rc.left = (rc.left - vs->Position.x) * vs->ZoomIn/ vs->ZoomOut; rc.top = (rc.top - vs->Position.y) * vs->ZoomIn/ vs->ZoomOut; rc.right = (rc.right - vs->Position.x) * vs->ZoomIn/ vs->ZoomOut; rc.bottom = (rc.bottom - vs->Position.y) * vs->ZoomIn/ vs->ZoomOut; } return rc; } //-------------------------------------------------------------------------- RECT __fastcall TPDocArrow::InverseConvertRange(RECT rect, TPDocViewStatus *vs) { RECT rc; rc = rect; if (vs) { rc.left = ((rc.left * vs->ZoomOut) / vs->ZoomIn) + vs->Position.x; rc.top = ((rc.top * vs->ZoomOut) / vs->ZoomIn) + vs->Position.y; rc.right = ((rc.right * vs->ZoomOut) / vs->ZoomIn) + vs->Position.x; rc.bottom = ((rc.bottom * vs->ZoomOut) / vs->ZoomIn) + vs->Position.y; } if (Parent) { rc.left -= Parent->Range.left; rc.top -= Parent->Range.top; rc.right -= Parent->Range.left; rc.bottom -= Parent->Range.top; } return rc; } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::DrawText(HDC hDC, ArrowData *AD, WideString Text) { TEXTMETRIC tm; int i=0, len = 0, lcnt, both = 1; wchar_t *sp, *tp, *ep; POINT tsp; WideString str; int sum=0, ts = 0; GetTextMetrics(hDC, &tm); tsp = AD->ead; lcnt = FindLineCount(Text); // ±Û¾¾ÀÇ ³ôÀ̸¸Å­ À§¿¡¼­ ½ÃÀÛ. switch (Type) { case datSingle: case datNone: if (AD->ead.x == AD->fad.x) { if (AD->ead.y > AD->fad.y) { lcnt = 0; tsp.y += 2; } } else { tsp.y -= tm.tmHeight/2; if (AD->ead.x > AD->fad.x) tsp.x += 2; else tsp.x -= 2; lcnt = lcnt/2; } break; case datBoth_Normal: case datBoth_None: both = 2; tsp.x = (AD->fad.x + AD->ead.x)/2; tsp.y = (AD->fad.y + AD->ead.y)/2; break; case datBoth_Hor_Over: tsp.x = (AD->fad.x + AD->ead.x)/2; break; case datBoth_Hor_Below: lcnt = 0; tsp.x = (AD->fad.x + AD->ead.x)/2; tsp.y += 2; break; case datBoth_Ver_Left: both = 2; tsp.x -= 2; tsp.y = (AD->fad.y + AD->ead.y - tm.tmHeight)/2; break; case datBoth_Ver_Right: both = 2; tsp.x += 2; tsp.y = (AD->fad.y + AD->ead.y - tm.tmHeight)/2; break; case dat3Point: // ÇØÁÙ°Ô ¾ø´ç.... break; } sp = Text.c_bstr(); if(sp != NULL){ // by altang ep = sp; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); while(tp != NULL) { len = tp - ep - 1; // Range of rc is right??? ExtTextOutW (hDC, tsp.x, tsp.y - tm.tmHeight*(lcnt/both - i), ETO_CLIPPED, NULL, ep, len, NULL); i++; ep = tp + 1; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); } if (*ep) { // when text is not ended with null character!! len = Text.Length() - (ep - sp); ExtTextOutW(hDC, tsp.x, tsp.y - tm.tmHeight*(lcnt/both - i), ETO_CLIPPED, NULL, ep, len, NULL); } } } //-------------------------------------------------------------------------- int __fastcall TPDocArrow::FindLineCount(WideString Text) { wchar_t *sp, *ep, *tp; int i=0; sp = Text.c_bstr(); ep = sp; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); while(tp != NULL) { i++; ep = tp + 1; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); } i++; return i; } //-------------------------------------------------------------------------- void __fastcall TPDocArrow::DrawAddedLine(HDC hDC, ArrowData *AD, bool bPrint, double penSize) { double theta, slope, xx, yy; POINT pt[4]; gdp::PointF *pTemps = new gdp::PointF[4]; gdp::Graphics graphics(hDC); gdp::Color penColor(GetRValue(Color), GetGValue(Color), GetBValue(Color)); gdp::Pen ObjectPen(penColor); if(bPrint) { gdp::Pen ObjectPen(penColor, penSize); graphics.SetPageUnit(gdp::UnitPixel); } if (AD->fad.x == AD->ead.x) { pt[0] = Point(AD->fad.x-10, AD->fad.y); pt[1] = Point(AD->fad.x+10, AD->fad.y); pt[2] = Point(AD->ead.x-10, AD->ead.y); pt[3] = Point(AD->ead.x+10, AD->ead.y); } else if (AD->fad.y == AD->ead.y) { pt[0] = Point(AD->fad.x, AD->fad.y-10); pt[1] = Point(AD->fad.x, AD->fad.y+10); pt[2] = Point(AD->ead.x, AD->ead.y-10); pt[3] = Point(AD->ead.x, AD->ead.y+10); } else { theta = atan(double(AD->fad.y-AD->ead.y) / (AD->ead.x-AD->fad.x)); yy = 10*fabs(cos(theta)); xx = 10*fabs(sin(theta)); slope = double(AD->fad.y-AD->ead.y) / (AD->ead.x-AD->fad.x); if (slope < 0) xx = -xx; //slope¿¡ µû¶ó xx °ªÀÌ ¹Ù²î¾î¾ßÇÑ´Ù. pt[0] = Point(AD->fad.x-xx, AD->fad.y-yy); pt[1] = Point(AD->fad.x+xx, AD->fad.y+yy); pt[2] = Point(AD->ead.x-xx, AD->ead.y-yy); pt[3] = Point(AD->ead.x+xx, AD->ead.y+yy); } for(int i=0; i<4; i++) { pTemps[i].X = pt[i].x; pTemps[i].Y = pt[i].y; } graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); graphics.DrawLine(&ObjectPen, pTemps[0], pTemps[1]); graphics.DrawLine(&ObjectPen, pTemps[2], pTemps[3]); /* MoveToEx(hDC, pt[0].x, pt[0].y, NULL); LineTo(hDC, pt[1].x, pt[1].y); MoveToEx(hDC, pt[2].x, pt[2].y, NULL); LineTo(hDC, pt[3].x, pt[3].y); */ } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::SetText(WideString kt, WideString et, WideString it, WideString ct, WideString jt) { K_Text = kt; E_Text = et; I_Text = it; C_Text = ct; J_Text = jt; } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::GetText(WideString &kt, WideString &et, WideString &it, WideString &ct, WideString &jt) { kt = K_Text; et = E_Text; it = I_Text; ct = C_Text; jt = J_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::SetK_Text(WideString kt) { if (kt.Length() == 0) { E_Text = ""; I_Text = ""; C_Text = ""; J_Text = ""; K_Text = ""; } // ¼öÁ¤ Property°¡ Á¦´ë·Î µ¿ÀÛ ¾ÈÇÏ´Â ¹®Á¦ (2007. 11. 27 Annualring) K_Text = kt; E_Text = K_Text; I_Text = K_Text; C_Text = K_Text; J_Text = K_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::GetK_Text(WideString &kt) { kt = K_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::Get_Text(WideString &kt) { kt = Text; } //--------------------------------------------------------------------------- bool __fastcall TPDocArrow::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; /* if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, Text)) return false; if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Type, sizeof(TPDocArrowType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &sp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &ep, sizeof(POINT), &dwRead, NULL)) return false; if (Type == dat3Point) { if (!ReadFile(hFile, &tp, sizeof(POINT), &dwRead, NULL)) return false; } return true; */ if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (Version <= 5) { // FK_Text ¸¦ Á÷Á¢ »ç¿ëÇÑ °æ¿ì ¹Ýµå½Ã RefreshTextRange¸¦ ÇØÁÙ°Í!!! // (2007. 11. 27 Annualring) if (!TextLoadFromFile(hFile, FK_Text)) return false; RefreshTextRange(); if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Type, sizeof(TPDocArrowType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &sp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &ep, sizeof(POINT), &dwRead, NULL)) return false; if (Type == dat3Point) { if (!ReadFile(hFile, &tp, sizeof(POINT), &dwRead, NULL)) return false; } } else if(Version <= 9){ if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Type, sizeof(TPDocArrowType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &sp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &ep, sizeof(POINT), &dwRead, NULL)) return false; if (Type == dat3Point) { if (!ReadFile(hFile, &tp, sizeof(POINT), &dwRead, NULL)) return false; } // FK_Text ¸¦ Á÷Á¢ »ç¿ëÇÑ °æ¿ì ¹Ýµå½Ã RefreshTextRange¸¦ ÇØÁÙ°Í!!! // (2007. 11. 27 Annualring) if (!TextLoadFromFile(hFile, FK_Text)) return false; RefreshTextRange(); if (!TextLoadFromFile(hFile, E_Text)) return false; if (!TextLoadFromFile(hFile, I_Text)) return false; if (!TextLoadFromFile(hFile, C_Text)) return false; if (!TextLoadFromFile(hFile, J_Text)) return false; } else if(Version <= 13){ if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Type, sizeof(TPDocArrowType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &sp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &ep, sizeof(POINT), &dwRead, NULL)) return false; if (Type == dat3Point) { if (!ReadFile(hFile, &tp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &bDefaultAlign, sizeof(bool), &dwRead, NULL)) return false; //for bDefualtAlign 's Save } // FK_Text ¸¦ Á÷Á¢ »ç¿ëÇÑ °æ¿ì ¹Ýµå½Ã RefreshTextRange¸¦ ÇØÁÙ°Í!!! // (2007. 11. 27 Annualring) if (!TextLoadFromFile(hFile, FK_Text)) return false; RefreshTextRange(); if (!TextLoadFromFile(hFile, E_Text)) return false; if (!TextLoadFromFile(hFile, I_Text)) return false; if (!TextLoadFromFile(hFile, C_Text)) return false; if (!TextLoadFromFile(hFile, J_Text)) return false; }else{ if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Type, sizeof(TPDocArrowType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &sp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &ep, sizeof(POINT), &dwRead, NULL)) return false; if (Type == dat3Point) { if (!ReadFile(hFile, &tp, sizeof(POINT), &dwRead, NULL)) return false; } if (!ReadFile(hFile, &bDefaultAlign, sizeof(bool), &dwRead, NULL)) return false; //for bDefualtAlign 's Save // FK_Text ¸¦ Á÷Á¢ »ç¿ëÇÑ °æ¿ì ¹Ýµå½Ã RefreshTextRange¸¦ ÇØÁÙ°Í!!! // (2007. 11. 27 Annualring) if (!TextLoadFromFile(hFile, FK_Text)) return false; RefreshTextRange(); if (!TextLoadFromFile(hFile, E_Text)) return false; if (!TextLoadFromFile(hFile, I_Text)) return false; if (!TextLoadFromFile(hFile, C_Text)) return false; if (!TextLoadFromFile(hFile, J_Text)) return false; } //by k3dogs(20001029)arrow ÃʱâÈ­°¡ µÇÁö ¾Ê¾Æ¼­. »ý¼ºÀÚ¿¡ ÀÖ¾î¾ß Çϴµ¥ TPDocElement »ý¼ºÀÚ°¡ ¸¶¶¥Ä¡ ¾Ê¾Æ ¿©±â ³Ö¾ú´Ù. //==========================//¸ÇóÀ½ ¼±ÅÃÇßÀ»¶§ controlmodedown¿¡ µé¾î°¡Áö ¸øÇؼ­ FOldArrow[0] = sp; //FOldArrowÀÇ °ªÀÌ Á¤ÇØÁöÁö ¾Ê¾Æ¼­ ±×¸²À» ±×¸®Áö ¸øÇϱ⠶§¹®¿¡.. FOldArrow[1] = ep; //if select at first time, as cannot get into controlmodedown event, FOldArrow is not defined, FOldArrow[2] = tp; //so cannot draw line from sp to ep. //========================== return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocArrow::SaveToFile(HANDLE hFile) { DWORD dwWrite; /* if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, Text)) return false; if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Type, sizeof(TPDocArrowType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &sp, sizeof(POINT), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &ep, sizeof(POINT), &dwWrite, NULL)) return false; if (Type == dat3Point) { if (!WriteFile(hFile, &tp, sizeof(POINT), &dwWrite, NULL)) return false; } return true; */ if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Type, sizeof(TPDocArrowType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &sp, sizeof(POINT), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &ep, sizeof(POINT), &dwWrite, NULL)) return false; if (Type == dat3Point) { if (!WriteFile(hFile, &tp, sizeof(POINT), &dwWrite, NULL)) return false; // if (!WriteFile(hFile, &bDefaultAlign, sizeof(bool), &dwWrite, NULL)) return false; //for bDefualtAlign 's Save } if (!WriteFile(hFile, &bDefaultAlign, sizeof(bool), &dwWrite, NULL)) return false; //for bDefualtAlign 's Save if (!TextSaveToFile(hFile, K_Text)) return false; // SetKTextPrivate(K_Text); if (!TextSaveToFile(hFile, E_Text)) return false; if (!TextSaveToFile(hFile, I_Text)) return false; if (!TextSaveToFile(hFile, C_Text)) return false; if (!TextSaveToFile(hFile, J_Text)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocArrow::Copy(TPDocArrow *src) { TPDocText::Copy((TPDocText *)src); Color = src->Color; Type = src->Type; sp = src->sp; ep = src->ep; if (Type == dat3Point) tp = src->tp; K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; //<----------È­»ìÇ¥ ¼±Åýà ¾Èº¸¿©Áö´Â¿¡·¯¼öÁ¤-------->// bDefaultAlign = src->bDefaultAlign; FOldArrow[0] = src->FOldArrow[0]; FOldArrow[1] = src->FOldArrow[1]; FOldArrow[2] = src->FOldArrow[2]; //<-------------------------------------------------->// return true; } int __fastcall TPDocArrow::GetAllocateSize(){ int size =0; size += sizeof(RECT); size += TPDocText::GetAllocateSize(); size += (sizeof(TColor) + sizeof(TPDocArrowType) + sizeof(POINT)*3 + TextGetAllocateSize(K_Text) +TextGetAllocateSize(E_Text) +TextGetAllocateSize(I_Text) +TextGetAllocateSize(C_Text) +TextGetAllocateSize(J_Text) + sizeof(bool) + sizeof(POINT)*3); return size; } BYTE *__fastcall TPDocArrow::CopyToMemory(BYTE *lp) { memcpy(lp, &Range, sizeof(RECT)); lp += sizeof(RECT); lp = TPDocText::CopyToMemory(lp); memcpy(lp, &Color, sizeof(TColor)); lp += sizeof(TColor); memcpy(lp, &Type, sizeof(TPDocArrowType)); lp += sizeof(TPDocArrowType); memcpy(lp, &sp, sizeof(POINT)); lp += sizeof(POINT); memcpy(lp, &ep, sizeof(POINT)); lp += sizeof(POINT); if (Type == dat3Point){ memcpy(lp, &tp, sizeof(POINT)); lp += sizeof(POINT); } lp = TextCopyToMemory(lp, K_Text); lp = TextCopyToMemory(lp, E_Text); lp = TextCopyToMemory(lp, I_Text); lp = TextCopyToMemory(lp, C_Text); lp = TextCopyToMemory(lp, J_Text); memcpy(lp,&bDefaultAlign,sizeof(bool)); lp += sizeof(bool); memcpy(lp,&(FOldArrow[0]),sizeof(POINT)); lp += sizeof(POINT); memcpy(lp,&(FOldArrow[1]),sizeof(POINT)); lp += sizeof(POINT); memcpy(lp,&(FOldArrow[2]),sizeof(POINT)); lp += sizeof(POINT); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocArrow::CopyFromMemory(BYTE *lp) { memcpy(&Range, lp, sizeof(RECT)); lp += sizeof(RECT); lp = TPDocText::CopyFromMemory(lp); memcpy(&Color, lp, sizeof(TColor)); lp += sizeof(TColor); memcpy(&Type, lp, sizeof(TPDocArrowType)); lp += sizeof(TPDocArrowType); memcpy(&sp, lp, sizeof(POINT)); lp += sizeof(POINT); memcpy(&ep, lp, sizeof(POINT)); lp += sizeof(POINT); if (Type == dat3Point){ memcpy(&tp, lp, sizeof(POINT)); lp += sizeof(POINT); } AnsiString TempString; // FK_Text ¸¦ Á÷Á¢ »ç¿ëÇÑ °æ¿ì ¹Ýµå½Ã RefreshTextRange¸¦ ÇØÁÙ°Í!!! // (2007. 11. 27 Annualring) lp = TextCopyFromMemory(lp, FK_Text); RefreshTextRange(); lp = TextCopyFromMemory(lp, E_Text); lp = TextCopyFromMemory(lp, I_Text); lp = TextCopyFromMemory(lp, C_Text); lp = TextCopyFromMemory(lp, J_Text); memcpy(&bDefaultAlign, lp, sizeof(bool)); lp += sizeof(bool); memcpy(&(FOldArrow[0]), lp, sizeof(POINT)); lp += sizeof(POINT); memcpy(&(FOldArrow[1]), lp, sizeof(POINT)); lp += sizeof(POINT); memcpy(&(FOldArrow[2]), lp, sizeof(POINT)); lp += sizeof(POINT); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocArrow::ShiftArrow(POINT From,POINT To){ int deltaX = To.x-From.x; int deltaY = To.y-From.y; Range.left +=deltaX; Range.right +=deltaX; Range.top +=deltaY; Range.bottom +=deltaY; sp.x +=deltaX; sp.y +=deltaY; ep.x +=deltaX; ep.y +=deltaY; if (Type == dat3Point){ tp.x +=deltaX; tp.y +=deltaY; } FOldArrow[0].x +=deltaX; FOldArrow[0].y +=deltaY; FOldArrow[1].x +=deltaX; FOldArrow[1].y +=deltaY; FOldArrow[2].x +=deltaX; FOldArrow[2].y +=deltaY; // Arrow °¡ À̵¿ÇßÀ» ¶§µµ TextRange¸¦ ´Ù½Ã °è»êÇØÁØ´Ù. (2007. 11. 09 Annualring) FTextRange = GetNewTextRange(); return true; } //--------------------------------------------------------------------------- void __fastcall TPDocArrow::ShiftArrow(int moveX, int moveY) { sp.x +=moveX; sp.y +=moveY; ep.x +=moveX; ep.y +=moveY; if (Type == dat3Point){ tp.x +=moveX; tp.y +=moveY; } Range.left +=moveX; Range.right +=moveX; Range.top +=moveY; Range.bottom +=moveY; FOldArrow[0].x +=moveX; FOldArrow[0].y +=moveY; FOldArrow[1].x +=moveX; FOldArrow[1].y +=moveY; FOldArrow[2].x +=moveX; FOldArrow[2].y +=moveY; // Arrow °¡ À̵¿ÇßÀ» ¶§µµ TextRange¸¦ ´Ù½Ã °è»êÇØÁØ´Ù. (2007. 11. 09 Annualring) FTextRange = GetNewTextRange(); } //--------------------------------------------------------------------------- TPDocControlMode __fastcall TPDocArrow::GetControlMode(int X, int Y) { TPDocControlMode dcm; if ((X >= sp.x-2) && (X < sp.x+3) && (Y >= sp.y-2) && (Y < sp.y+3)) { return dcmFirst; } if (Type == dat3Point) { if ((X >= tp.x-2) && (X < tp.x+3) && (Y >= tp.y-2) && (Y < tp.y+3)) { return dcmMedium; } } if ((X >= ep.x-2) && (X < ep.x+3) && (Y >= ep.y-2) && (Y < ep.y+3)) { return dcmLast; } bool bResult =false; HRGN rgn = NULL; HPEN hPen, hOldPen; TTexpiaBitmap *tempbitmap; tempbitmap = new TTexpiaBitmap; tempbitmap->Create(Range.right,Range.bottom,1); HDC dcDst = tempbitmap->CreateDC(); POINT ptemp[7]; int nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, WINDING); hPen = CreatePen(PS_SOLID, PenThick, RGB(0,0,0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); if (Type == dat3Point) { ptemp[0] = sp; ptemp[1] = sp; ptemp[2] = ep; ptemp[3] = ep; ptemp[4] = ep; ptemp[5] = tp; ptemp[6] = tp; BeginPath(dcDst); PolyBezier (dcDst, ptemp, 7); } else { ptemp[0] = sp; ptemp[1] = sp; ptemp[2] = ep; ptemp[3] = ep; BeginPath(dcDst); PolyBezier (dcDst, ptemp, 4); } EndPath(dcDst); WidenPath(dcDst); rgn = PathToRegion(dcDst); if (PtInRegion(rgn, X, Y)) bResult = true; if (rgn) { DeleteObject(rgn); rgn = NULL;} SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldPen)); tempbitmap->DeleteDC(dcDst); hPen = NULL; hOldPen = NULL; delete tempbitmap; if (bResult) return dcmMove; else return dcmNone; //return X >= Range.left && Y >= Range.top && X <= Range.right && Y <= Range.bottom ? dcmMove : dcmNone; } //--------------------------------------------------------------------- void __fastcall TPDocArrow::GetNewRange(int X, int Y) { int tx, ty; bool bfrect = true; switch (ControlMode) { case dcmFirst: switch (Type) { case datSingle: case datBoth_Normal: case datBoth_None: case dat3Point: case datNone: FOldArrow[0] = Point(X, Y); break; case datBoth_Hor_Over: case datBoth_Hor_Below: FOldArrow[0] = Point(X, FOldArrow[0].y); break; case datBoth_Ver_Left: case datBoth_Ver_Right: FOldArrow[0] = Point(FOldArrow[0].x, Y); break; } break; case dcmMedium: FOldArrow[2] = Point(X, Y); // FOldArrow[1].y = FOldArrow[2].y; //for linuxjun ÆíÁý ±â´ÉÀ¸·Î È­»ìÇ¥ ±æÀÌ ´Ã¸±¶§ ÀÌ»óÇØÁö´ÂÇö»ó ¶§¹®¿¡ ¸·À½. break; case dcmLast: switch (Type) { case datSingle: case datBoth_Normal: case datBoth_None: case datNone: FOldArrow[1] = Point(X, Y); break; case datBoth_Hor_Over: case datBoth_Hor_Below: FOldArrow[1] = Point(X, FOldArrow[1].y); break; case datBoth_Ver_Left: case datBoth_Ver_Right: FOldArrow[1] = Point(FOldArrow[1].x, Y); break; case dat3Point: FOldArrow[1] = Point(X, Y); // FOldArrow[2].y = FOldArrow[1].y; //for linuxjun ÆíÁý ±â´ÉÀ¸·Î È­»ìÇ¥ ±æÀÌ ´Ã¸±¶§ ÀÌ»óÇØÁö´ÂÇö»ó ¶§¹®¿¡ ¸·À½. break; } break; case dcmMove: tx = X - FOldPoint.x; ty = Y - FOldPoint.y; FOldArrow[0] = Point(sp.x+tx, sp.y+ty); FOldArrow[1] = Point(ep.x+tx, ep.y+ty); if (Type == dat3Point) { FOldArrow[2] = Point(tp.x+tx, tp.y+ty); } FOldRect = Rect(Range.left+tx, Range.top+ty, Range.right+tx, Range.bottom+ty); bfrect = false; break; } if (bfrect) { FOldRect = ReArrangeRect(false); } } //--------------------------------------------------------------------- void __fastcall TPDocArrow::ControlModeMouseDown(TShiftState Shift, int X, int Y) { FOldArrow[0] = sp; FOldArrow[1] = ep; if (Type == dat3Point) { FOldArrow[2] = tp; } FOldRect = Range; FOldPoint = Point(X, Y); } //--------------------------------------------------------------------- void __fastcall TPDocArrow::ControlModeMouseMove(HDC hDC, TPDocViewStatus &vs, int X, int Y) { PaintControl(hDC, vs); GetNewRange(X, Y); PaintControl(hDC, vs); } //--------------------------------------------------------------------- void __fastcall TPDocArrow::ControlModeMouseUp() { bool bfrect = true; switch (ControlMode) { case dcmFirst: sp = FOldArrow[0]; break; case dcmMedium: tp = FOldArrow[2]; ep = FOldArrow[1]; break; case dcmLast: ep = FOldArrow[1]; if (Type == dat3Point) { tp = FOldArrow[2]; } break; case dcmMove: sp = FOldArrow[0]; ep = FOldArrow[1]; if (Type == dat3Point) { tp = FOldArrow[2]; } Range = FOldRect; bfrect = false; break; } if (bfrect) { Range = ReArrangeRect(true); } //qe È­»ìÇ¥ÀÇ ½¬¿î Ȱ¼ºÈ­¸¦ À§ÇØ ¹üÀ§¸¦ ³ÐÈù´Ù. if((Range.right - Range.left) < 8 ){ Range.left = Range.left -5; Range.right = Range.right + 5; } if((Range.bottom - Range.top) < 8){ Range.top = Range.top - 5; Range.bottom = Range.bottom + 5; } // È­»ìÇ¥ ¸ð¾ç º¯°æ½Ã¿¡ TextRange ´Ù½Ã °è»ê (2007. 11. 13 Annualring) FTextRange = GetNewTextRange(); } //--------------------------------------------------------------------------- RECT __fastcall TPDocArrow::ReArrangeRect(bool breal) { long tx, ty; POINT pt[3]; RECT rt; if (breal) { pt[0] = sp; pt[1] = ep; if (Type == dat3Point) { pt[2] = tp; } } else { pt[0] = FOldArrow[0]; pt[1] = FOldArrow[1]; if (Type == dat3Point) { pt[2] = FOldArrow[2]; } } if (Type == dat3Point) { tx = min(pt[0].x, pt[1].x); tx = min(pt[2].x, tx); ty = min(pt[0].y, pt[1].y); ty = min(pt[2].y, ty); rt.left = tx; rt.top = ty; tx = max(pt[0].x, pt[1].x); tx = max(pt[2].x, tx); ty = max(pt[0].y, pt[1].y); ty = max(pt[2].y, ty); rt.right = tx; rt.bottom = ty; } else { if (pt[0].x < pt[1].x) { rt.left = pt[0].x; rt.right = pt[1].x; } else { rt.left = pt[1].x; rt.right = pt[0].x; } if (pt[0].y < pt[1].y) { rt.top = pt[0].y; rt.bottom = pt[1].y; } else { rt.top = pt[1].y; rt.bottom = pt[0].y; } } return rt; } //--------------------------------------------------------------------------- bool __fastcall TPDocArrow::IsExist(POINT pt) { bool bResult = false; HRGN rgn = NULL; HPEN hPen, hOldPen; TTexpiaBitmap *tempbitmap; tempbitmap = new TTexpiaBitmap; tempbitmap->Create(Range.right,Range.bottom,1); HDC dcDst = tempbitmap->CreateDC(); POINT ptemp[7]; int nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, WINDING); hPen = CreatePen(PS_SOLID, PenThick, RGB(0,0,0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); if (Type == dat3Point) { ptemp[0] = sp; ptemp[1] = sp; ptemp[2] = ep; ptemp[3] = ep; ptemp[4] = ep; ptemp[5] = tp; ptemp[6] = tp; BeginPath(dcDst); PolyBezier (dcDst, ptemp, 7); } else { ptemp[0] = sp; ptemp[1] = sp; ptemp[2] = ep; ptemp[3] = ep; BeginPath(dcDst); PolyBezier (dcDst, ptemp, 4); } EndPath(dcDst); WidenPath(dcDst); rgn = PathToRegion(dcDst); if (PtInRegion(rgn, pt.x, pt.y)) bResult = true; if (rgn) { DeleteObject(rgn); rgn = NULL;} SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldPen)); tempbitmap->DeleteDC(dcDst); hPen = NULL; hOldPen = NULL; delete tempbitmap; if (bShiftOnArrow && bResult) { bSelected = !bSelected; if (!bSelected) bResult = false; } if (!bShiftOnArrow) bSelected = bResult; else bResult = bSelected; //¼±ÅõÇÀÖ´Â ºÎºÐÀ» shift´­·¯Á®ÀÖÀ»¶§ ±×´ë·ÎµÑ·Á´ÂºÎºÐ. return bResult; } void __fastcall TPDocArrow::SetToUndoData(TPDocArrowUndoData *AUD){ AUD->Color = Color; AUD->Type = Type; AUD->sp = sp; AUD->ep = ep; if (AUD->Type == dat3Point) AUD->tp = tp; AUD->K_Text = K_Text; AUD->E_Text = E_Text; AUD->I_Text = I_Text; AUD->C_Text = C_Text; AUD->J_Text = J_Text; //<----------È­»ìÇ¥ ¼±Åýà ¾Èº¸¿©Áö´Â¿¡·¯¼öÁ¤-------->// AUD->bDefaultAlign = bDefaultAlign; AUD->FOldArrow[0] = FOldArrow[0]; AUD->FOldArrow[1] = FOldArrow[1]; AUD->FOldArrow[2] = FOldArrow[2]; //<-------------------------------------------------->// AUD->bSelected = bSelected; } void __fastcall TPDocArrow::GetFromUndoData(TPDocArrowUndoData *AUD){ Color = AUD->Color; Type = AUD->Type; sp = AUD->sp; ep = AUD->ep; if (Type == dat3Point) tp = AUD->tp; // SetKTextPrivate(AUD->K_Text); K_Text = AUD->K_Text; E_Text = AUD->E_Text; I_Text = AUD->I_Text; C_Text = AUD->C_Text; J_Text = AUD->J_Text; //<----------È­»ìÇ¥ ¼±Åýà ¾Èº¸¿©Áö´Â¿¡·¯¼öÁ¤-------->// bDefaultAlign = AUD->bDefaultAlign; FOldArrow[0] = AUD->FOldArrow[0]; FOldArrow[1] = AUD->FOldArrow[1]; FOldArrow[2] = AUD->FOldArrow[2]; //<-------------------------------------------------->// bSelected = AUD->bSelected; } /// Text¸¦ SettingÇϰí TextRange¸¦ ¾÷µ¥ÀÌÆ®ÇÏ´Â Private ÇÔ¼ö Ãß°¡ // (2007. 11. 07 Annualring) void __fastcall TPDocArrow::SetKTextPrivate(WideString newText) { FK_Text = newText; RefreshTextRange(); } void __fastcall TPDocArrow::RefreshTextRange() { FTextRange = GetNewTextRange(); } //--------------------------------------------------------------------------- // // TPDocSheafImage // //--------------------------------------------------------------------------- __fastcall TPDocSheafImage::TPDocSheafImage(TPDocObject *Sender, RECT rc) : TPDocText(Sender, detSheafImage, rc) //TPDocElement(detSheafImage, rc) { Parent = Sender; Image = NULL; FOldRect = Range; // SelectedÀÎ °æ¿ì¿¡PaintControl¿¡¼­ FOldRect¸¦ ÃʱâÈ­ÇØÁà¾ßÇÔ.... bSelected = false; // SheafImage MultiSelect bImageChanged = false; } //--------------------------------------------------------------------------- __fastcall TPDocSheafImage::~TPDocSheafImage() { if (Image) delete Image; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocSheafImage::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } //--------------------------------------------------------------------------- void __fastcall TPDocSheafImage::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafImage::HasValue() { if(Image) return true; return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafImage::IsExist(POINT pt){ //for linuxjun shift·Î µû·Î ¼±ÅÃÀÌ °¡´ÉÇÏ°Ô ÇϱâÀ§ÇØ Ãß°¡·Î ±¸ÇöÇßÀ½. bool bResult = false; /* ((TPDocSheafImage *)this)->bSelected = false; if(pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2){ ((TPDocSheafImage *)this)->bSelected = true; } */ if(pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2){ bResult = true; } if (bShiftOnArrow && bResult) { bSelected = !bSelected; if (!bSelected) bResult = false; } if (!bShiftOnArrow) bSelected = bResult; else bResult = bSelected; //¼±ÅõÇÀÖ´Â ºÎºÐÀ» shift´­·¯Á®ÀÖÀ»¶§ ±×´ë·ÎµÑ·Á´ÂºÎºÐ. return bResult; //return pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafImage::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; TSize s; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); // ImageÀÇ RectPaint½Ã¿¡ À̹ÌÁö À§Ä¡°¡ ¾à°£¾¿ ±úÁö´Â ¹®Á¦ 󸮸¦ À§ÇÏ¿© º¸Á¤ // (2007. 11. 21 Annualring) if (!bPrint && vs.Position.x > Range.left) { rc.left -= 1; rc.right -= 1; } if (!bPrint && vs.Position.y > Range.top) { rc.top -= 1; rc.bottom -= 1; } //////////////// if (bselect) { PaintControl(hDC, vsc); // ÇÊ¿äÇѰ¡?? ¾ø´ø°Å °°Àºµ¥... // ¸Ç óÀ½ÀÇ °æ¿ì FOldRect°¡ ÃʱâÈ­ µÇ¾î¾ß ÇÔ->»ý¼ºÀÚ¿¡... PaintSelect(hDC, rc, &PaintSelectInCommon); if (Image) { s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } return; } if (Image) { s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } /* if (!bPrint) { try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = SelectObject(hDC, hPen); hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); Rectangle(hDC, rc.left, rc.top, rc.right+1, rc.bottom+1); } __finally { if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } }*/ } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafImage::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TColor C; TextVersion = Version; if (Version >= 5) { if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!ReadFile(hFile, &Zoom, sizeof(int), &dwRead, NULL)) return false; if (!TextLoadFromFile(hFile, ImgDir)) return false; if (!ImageLoadFromFile(hFile, Image)) return false; } else { if (!ReadFile(hFile, &Zoom, sizeof(int), &dwRead, NULL)) return false; if (!ReadFile(hFile, &C, sizeof(TColor), &dwRead, NULL)) return false; if (!ImageLoadFromFile(hFile, Image)) return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafImage::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; if (!WriteFile(hFile, &Zoom, sizeof(int), &dwWrite, NULL)) return false; if (!TextSaveToFile(hFile, ImgDir)) return false; if (!ImageSaveToFile(hFile, Image)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafImage::Copy(TPDocSheafImage *src) { TPDocText::Copy((TPDocText *)src); Zoom = src->Zoom; ImgDir = src->ImgDir; if (!ImageCopy(Image, src->Image)) return false; return true; } //--------------------------------------------------------------------------- // // TPDocThumbnailImage // //--------------------------------------------------------------------------- __fastcall TPDocThumbnailImage::TPDocThumbnailImage(TPDocObject *Sender, RECT rc) : TPDocText(Sender, detThumbnailImage, rc) //TPDocElement(detThumbnailImage, rc) { Parent = Sender; Image = NULL; FOldRect = Range; // SelectedÀÎ °æ¿ì¿¡PaintControl¿¡¼­ FOldRect¸¦ ÃʱâÈ­ÇØÁà¾ßÇÔ.... bSelected = false; // ThumbnailImage MultiSelect // FrameColor = clAqua; //FrameColor = clLime; FrameColor.left = clLime; FrameColor.top = clLime; FrameColor.right = clLime; FrameColor.bottom = clLime; bIsPrimary = true; // bImageChanged = false; } //--------------------------------------------------------------------------- __fastcall TPDocThumbnailImage::~TPDocThumbnailImage() { if (Image) delete Image; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocThumbnailImage::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } void __fastcall TPDocThumbnailImage::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { /* if (Text.Length() > 0) { PaintText(hDC, Font, rc, t, Align, Text); } */ //FrameColor = clLime; FrameColor.left = clLime; FrameColor.top = clLime; FrameColor.right = clLime; FrameColor.bottom = clLime; PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocThumbnailImage::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; rc = ConvertRange(&vs); // if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); // else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImage::HasValue() { if(Image) return true; return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImage::IsExist(POINT pt){ //for linuxjun shift·Î µû·Î ¼±ÅÃÀÌ °¡´ÉÇÏ°Ô ÇϱâÀ§ÇØ Ãß°¡·Î ±¸ÇöÇßÀ½. bool bResult = false; if(pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2){ bResult = true; } //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. /*//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. if (bShiftOnArrow && bResult) { bSelected = !bSelected; if (!bSelected) bResult = false; } if (!bShiftOnArrow) bSelected = bResult; else bResult = bSelected; //¼±ÅõÇÀÖ´Â ºÎºÐÀ» shift´­·¯Á®ÀÖÀ»¶§ ±×´ë·ÎµÑ·Á´ÂºÎºÐ. return bResult; //return pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2; */ bSelected = false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } //--------------------------------------------------------------------------- void __fastcall TPDocThumbnailImage::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; TSize s; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bselect) { PaintControl(hDC, vsc); // ÇÊ¿äÇѰ¡?? ¾ø´ø°Å °°Àºµ¥... // ¸Ç óÀ½ÀÇ °æ¿ì FOldRect°¡ ÃʱâÈ­ µÇ¾î¾ß ÇÔ->»ý¼ºÀÚ¿¡... PaintSelect(hDC, rc, &PaintSelectInCommon); if (Image) { s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } return; } if (Image) { s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImage::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!ReadFile(hFile, &Range, sizeof(RECT), &dwRead, NULL)) return false; if (Version < 18) { TColor tempColor; if (!ReadFile(hFile, &tempColor, sizeof(TColor), &dwRead, NULL)) return false; FrameColor.left = tempColor; FrameColor.top = tempColor; FrameColor.right = tempColor; FrameColor.bottom = tempColor; } else { if (!ReadFile(hFile, &FrameColor, sizeof(TPDocFrameColor), &dwRead, NULL)) return false; } if (!ReadFile(hFile, &bIsPrimary, sizeof(bool), &dwRead, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImage::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!WriteFile(hFile, &Range, sizeof(RECT), &dwWrite, NULL)) return false; //if (!WriteFile(hFile, &FrameColor, sizeof(TColor), &dwWrite, NULL)) return false; if (SaveVersion < 18) { if (!WriteFile(hFile, &FrameColor.left, sizeof(TColor), &dwWrite, NULL)) return false; } else { if (!WriteFile(hFile, &FrameColor, sizeof(TPDocFrameColor), &dwWrite, NULL)) return false; } if (!WriteFile(hFile, &bIsPrimary, sizeof(bool), &dwWrite, NULL)) return false; return true; } /* //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImage::Copy(TPDocThumbnailImage *src) { TPDocText::Copy((TPDocText *)src); Zoom = src->Zoom; ImgDir = src->ImgDir; if (!ImageCopy(Image, src->Image)) return false; return true; } */ //--------------------------------------------------------------------------- // // TPDocThumbnailImageJPG // //--------------------------------------------------------------------------- __fastcall TPDocThumbnailImageJPG::TPDocThumbnailImageJPG(TPDocObject *Sender, RECT rc) : TPDocText(Sender, detThumbnailImageJPG, rc) //TPDocElement(detThumbnailImage, rc) { Parent = Sender; Image = NULL; FOldRect = Range; // SelectedÀÎ °æ¿ì¿¡PaintControl¿¡¼­ FOldRect¸¦ ÃʱâÈ­ÇØÁà¾ßÇÔ.... bSelected = false; // ThumbnailImage MultiSelect // FrameColor = clAqua; //FrameColor = clRed; FrameColor.left = clRed; FrameColor.top = clRed; FrameColor.right = clRed; FrameColor.bottom = clRed; bIsPrimary = true; // bImageChanged = false; } //--------------------------------------------------------------------------- __fastcall TPDocThumbnailImageJPG::~TPDocThumbnailImageJPG() { if (Image) delete Image; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocThumbnailImageJPG::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } void __fastcall TPDocThumbnailImageJPG::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { /* if (Text.Length() > 0) { PaintText(hDC, Font, rc, t, Align, Text); } */ PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocThumbnailImageJPG::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; rc = ConvertRange(&vs); // if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); // else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImageJPG::HasValue() { if(Image) return true; return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImageJPG::IsExist(POINT pt){ //for linuxjun shift·Î µû·Î ¼±ÅÃÀÌ °¡´ÉÇÏ°Ô ÇϱâÀ§ÇØ Ãß°¡·Î ±¸ÇöÇßÀ½. bool bResult = false; if(pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2){ bResult = true; } //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. /*//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. if (bShiftOnArrow && bResult) { bSelected = !bSelected; if (!bSelected) bResult = false; } if (!bShiftOnArrow) bSelected = bResult; else bResult = bSelected; //¼±ÅõÇÀÖ´Â ºÎºÐÀ» shift´­·¯Á®ÀÖÀ»¶§ ±×´ë·ÎµÑ·Á´ÂºÎºÐ. return bResult; //return pt.x >= Range.left - 2 && pt.y >= Range.top -2 && pt.x <= Range.right + 2 && pt.y <= Range.bottom -2; */ bSelected = false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } //--------------------------------------------------------------------------- void __fastcall TPDocThumbnailImageJPG::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; TSize s; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bselect) { PaintControl(hDC, vsc); // ÇÊ¿äÇѰ¡?? ¾ø´ø°Å °°Àºµ¥... // ¸Ç óÀ½ÀÇ °æ¿ì FOldRect°¡ ÃʱâÈ­ µÇ¾î¾ß ÇÔ->»ý¼ºÀÚ¿¡... PaintSelect(hDC, rc, &PaintSelectInCommon); if (Image) { s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } return; } if (Image) { s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImageJPG::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!ReadFile(hFile, &Range, sizeof(RECT), &dwRead, NULL)) return false; if (Version < 18) { TColor tempColor; if (!ReadFile(hFile, &tempColor, sizeof(TColor), &dwRead, NULL)) return false; FrameColor.left = tempColor; FrameColor.top = tempColor; FrameColor.right = tempColor; FrameColor.bottom = tempColor; } else { if (!ReadFile(hFile, &FrameColor, sizeof(TPDocFrameColor), &dwRead, NULL)) return false; } if (!ReadFile(hFile, &bIsPrimary, sizeof(bool), &dwRead, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocThumbnailImageJPG::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!WriteFile(hFile, &Range, sizeof(RECT), &dwWrite, NULL)) return false; //if (!WriteFile(hFile, &FrameColor, sizeof(TColor), &dwWrite, NULL)) return false; if (SaveVersion < 18) { if (!WriteFile(hFile, &FrameColor.left, sizeof(TColor), &dwWrite, NULL)) return false; } else { if (!WriteFile(hFile, &FrameColor, sizeof(TPDocFrameColor), &dwWrite, NULL)) return false; } if (!WriteFile(hFile, &bIsPrimary, sizeof(bool), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- // // TPDocSheafLabel // //--------------------------------------------------------------------------- /* __fastcall TPDocSheafLabel::TPDocSheafLabel(TPDocObject *Sender, RECT rc, TPDocAlign ta, AnsiString t) : TPDocText(Sender, detSheafLabel, rc, ta) { K_Text = t; FOldRect = Range; // PaintControl¿¡¼­ ÃʱâÈ­ µÇ¾îÀÖ¾î¾ß ¿¡·¯¹ß»ýÀÌ ¾ÈµÊ... } //--------------------------------------------------------------------------- */ __fastcall TPDocSheafLabel::TPDocSheafLabel(TPDocObject *Sender, RECT rc, TPDocAlign ta, WideString t) : TPDocText(Sender, detSheafLabel, rc, ta) { K_Text = t; FOldRect = Range; // PaintControl¿¡¼­ ÃʱâÈ­ µÇ¾îÀÖ¾î¾ß ¿¡·¯¹ß»ýÀÌ ¾ÈµÊ... LineData = NULL; bInit = false; //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ bAutoLineFeed = false; } //--------------------------------------------------------------------------- __fastcall TPDocSheafLabel::~TPDocSheafLabel() { if (LineData) free(LineData); LineData = NULL; } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- /*void __fastcall TPDocSheafLabel::PaintForm(HDC hDC, RECT rc) { } */ //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::PaintSheafLabelText(HDC hDC, TFont *font, RECT rc, double zoom, TPDocAlign Align, WideString Text, bool multiline) { HFONT hOldFont; TEXTMETRIC tm; int px, py, i = 0, cnt, l, len, tempFontSize; wchar_t *ch, *nch, *sp, *ep, *tp, *tep; WORD wAlign; MemoLineInfo tLineData[100]; int line, subline; tempFontSize = ResizeFont(zoom, font); hOldFont = (HFONT)SelectObject(hDC, font->Handle); SetBkMode(hDC, TRANSPARENT); wAlign = GetTextAlign(hDC); GetTextMetrics(hDC, &tm); SetTextColor(hDC, font->Color); if (Align != daCenterVertical) { switch (Align) { case daLeftTop: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = rc.top + 2; break; case daCenterTop: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = rc.top + 2; break; case daRightTop: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = rc.top + 2; break; case daLeftCenter: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daCenter2: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daRightCenter: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = (rc.bottom + rc.top - tm.tmHeight) / 2; break; case daLeftBottom: SetTextAlign(hDC, TA_LEFT); px = rc.left + 2; py = rc.bottom - tm.tmHeight - 2; break; case daCenterBottom: SetTextAlign(hDC, TA_CENTER); px = (rc.right + rc.left) / 2; py = rc.bottom - tm.tmHeight - 2; break; case daRightBottom: SetTextAlign(hDC, TA_RIGHT); px = rc.right - 2; py = rc.bottom - tm.tmHeight - 2; break; } sp = Text.c_bstr(); // ÁٹٲÞÀ» ÇØÁÖ±â À§ÇÔ.. ep = sp; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); TSize size; int tlen = 0, nx = 0; tep = ep; line = 0; while(tp != NULL) { len = tp - tep - 1; tlen = len; if (len <= 0) break; subline = 0; GetTextExtentPointW(hDC, tep, tlen, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = 0; k < len; k++) { GetTextExtentPointW(hDC, tep, k+1, &size); if (size.cx >= (rc.right-rc.left-5)) { if (k == 0) { tep = ep + 1; len = 1; nx = 1; } else { tep = ep + k; len = k; nx = k; } break; } } } while(true) { ExtTextOutW(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); tLineData[i].Line = line; tLineData[i].SubLine = subline; tLineData[i].Len = len; i++; subline++; if (size.cx < (rc.right-rc.left-5)) break; else { ep = tep; len = tp - ep - 1; if (len <= 0) break; GetTextExtentPointW(hDC, tep, len, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = nx, l = 0; k < tlen; k++, l++) { GetTextExtentPointW(hDC, tep, l+1, &size); if (size.cx >= (rc.right-rc.left-5)) { if (l == 0) { tep = ep + 1; len = 1; nx += 1; } else { tep = ep + l; len = l; nx += l; } break; } } } } } ep = tp + 1; if(ep==NULL) ep = WideString('\n'); tp = wcschr(ep, '\n'); tep = ep; line++; } if (*ep) { // when text is not ended with null character!! len = Text.Length() - (ep - sp); tlen = len; subline = 0; GetTextExtentPointW(hDC, tep, tlen, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = 0; k < len; k++) { GetTextExtentPointW(hDC, tep, k+1, &size); if (size.cx >= (rc.right-rc.left-5)) { if (k == 0) { tep = ep + 1; len = 1; nx = 1; } else { tep = ep + k; len = k; nx = k; } break; } } } while(true) { ExtTextOutW(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ep, len, NULL); tLineData[i].Line = line; tLineData[i].SubLine = subline; tLineData[i].Len = len; i++; subline++; if (size.cx < (rc.right-rc.left-5)) break; else { ep = tep; len = Text.Length() - (ep - sp); if (len <= 0) break; GetTextExtentPointW(hDC, ep, len, &size); if (size.cx >= (rc.right-rc.left-5)) { for (int k = nx, l = 0; k < tlen; k++, l++) { GetTextExtentPointW(hDC, tep, l+1, &size); if (size.cx >= (rc.right-rc.left-5)) { if (l == 0) { tep = ep + 1; len = 1; nx += 1; } else { tep = ep + l; len = l; nx += l; } break; } } } } } } else { tLineData[i].Line = line; tLineData[i].SubLine = 0; tLineData[i].Len = 0; i++; } if (LineData) free(LineData); LineData = NULL; nMemoLines = i; LineData = (MemoLineInfo*)calloc(nMemoLines + 1, sizeof(MemoLineInfo)); for (i = 0; i < nMemoLines; i++) LineData[i] = tLineData[i]; } else { // ¼¼·Î ÀÔ·Â... SetTextAlign(hDC, TA_CENTER); ch = Text.c_bstr(); cnt = TextLength(ch); px = (rc.right + rc.left)/2; py = (rc.bottom + rc.top - cnt*tm.tmHeight)/2; i = 0; while(*ch) { nch = CharNextW(ch); l = nch - ch; ExtTextOutW(hDC, px, py+tm.tmHeight*i, ETO_CLIPPED, &rc, ch, l, NULL); ch = nch; i++; } } SetTextAlign(hDC, wAlign); SelectObject(hDC, hOldFont); RestoreFont(tempFontSize, font); bInit = true; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLabel::HasValue() { if(K_Text.Length()>0||E_Text.Length()>0||I_Text.Length()>0||C_Text.Length()>0||J_Text.Length()>0)return true; return false; } //--------------------------------------------------------------------------- /* void __fastcall TPDocSheafLabel::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; AnsiString Text; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); switch (language) { case 0: Text = K_Text; break; case 1: Text = E_Text; break; case 2: Text = I_Text; break; case 3: Text = C_Text; break; case 4: Text = J_Text; break; } Text = K_Text;//gabriel: 20060913 if (bselect) { PaintControl(hDC, vsc); // ¸Ç óÀ½¿¡ FOldRect°¡ ÃʱâÈ­ µÇ¾îÀÖ¾î¾ß ÇÔ.-->»ý¼ºÀÚ¿¡¼­.... PaintSelect(hDC, rc, &PaintSelectInCommon); if (Text.Length() > 0) PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text, true); return; } if (Text.Length() > 0) PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text, true); //qe //if (!bPrint) // PaintFrame(hDC, rc, dlsOne, clBlack); // right Range?? && be viewed in ReportTool } //--------------------------------------------------------------------------- */ void __fastcall TPDocSheafLabel::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; WideString Text; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); switch (language) { case 0: Text = K_Text; break; case 1: Text = E_Text; break; case 2: Text = I_Text; break; case 3: Text = C_Text; break; case 4: Text = J_Text; break; } //2006³âµµ¿¡ TPDocSheafLabelÀº ½îÀ×ÅÒÀÌ ¹Ý¿µµÇÁö ¾Êµµ·Ï ¼öÁ¤µÇ¾î ÀÖ¾ú´Ù. //±×·¡¼­ ¾Æ·¡ ÁÙÀ» ÁÖ¼®À¸·Î ¸·À½ - david 20140422 //Text = K_Text;//gabriel: 20060913 if (bselect) { PaintControl(hDC, vsc); // ¸Ç óÀ½¿¡ FOldRect°¡ ÃʱâÈ­ µÇ¾îÀÖ¾î¾ß ÇÔ.-->»ý¼ºÀÚ¿¡¼­.... PaintSelect(hDC, rc, &PaintSelectInCommon); if (!bAutoLineFeed) { //±âÁ¸ ¼Ò½º ºÎºÐ (ÀÚµ¿ ÁÙ ¹Ù²Ù±â ÇÏÁö ¾ÊÀ½) if (Text.Length() > 0) PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text, true); } else { //ÁÙ ¹Ù²Þ ó¸® ºÎºÐ if (Text.Length() > 0) PaintSheafLabelText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text, true); } return; } if (!bAutoLineFeed) { //±âÁ¸ ¼Ò½º ºÎºÐ (ÀÚµ¿ ÁÙ ¹Ù²Ù±â ÇÏÁö ¾ÊÀ½) if (Text.Length() > 0) PaintText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text, true); } else { //ÁÙ ¹Ù²Þ ó¸® ºÎºÐ if (Text.Length() > 0) PaintSheafLabelText(hDC, Font, rc, (double)vs.ZoomIn / vs.ZoomOut, Align, Text, true); } //qe //if (!bPrint) // PaintFrame(hDC, rc, dlsOne, clBlack); // right Range?? && be viewed in ReportTool } //--------------------------------------------------------------------------- /* void __fastcall TPDocSheafLabel::SetText(AnsiString kt, AnsiString et, AnsiString it, AnsiString ct, AnsiString jt) { K_Text = kt; E_Text = et; I_Text = it; C_Text = ct; J_Text = jt; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::GetText(AnsiString &kt, AnsiString &et, AnsiString &it, AnsiString &ct, AnsiString &jt) { kt = K_Text; et = E_Text; it = I_Text; ct = C_Text; jt = J_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::SetK_Text(AnsiString kt) { if (kt.Length() == 0) { E_Text = ""; I_Text = ""; C_Text = ""; J_Text = ""; } K_Text = kt; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::GetK_Text(AnsiString &kt) { kt = K_Text; } //--------------------------------------------------------------------------- */ void __fastcall TPDocSheafLabel::SetText(WideString kt, WideString et, WideString it, WideString ct, WideString jt) { K_Text = kt; E_Text = et; I_Text = it; C_Text = ct; J_Text = jt; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::GetText(WideString &kt, WideString &et, WideString &it, WideString &ct, WideString &jt) { kt = K_Text; et = E_Text; it = I_Text; ct = C_Text; jt = J_Text; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::SetK_Text(WideString kt) { if (kt.Length() == 0) { E_Text = ""; I_Text = ""; C_Text = ""; J_Text = ""; } K_Text = kt; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabel::GetK_Text(WideString &kt) { kt = K_Text; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLabel::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!TPDocText::LoadFromFile(hFile, Version)) return false; if (!TextLoadFromFile(hFile, K_Text)) return false; if (!TextLoadFromFile(hFile, E_Text)) return false; if (!TextLoadFromFile(hFile, I_Text)) return false; if (!TextLoadFromFile(hFile, C_Text)) return false; if (!TextLoadFromFile(hFile, J_Text)) return false; //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ if (Version > 18) if (!ReadFile(hFile, &bAutoLineFeed, sizeof(bool), &dwRead, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLabel::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!TPDocText::SaveToFile(hFile)) return false; if (!TextSaveToFile(hFile, K_Text)) return false; if (!TextSaveToFile(hFile, E_Text)) return false; if (!TextSaveToFile(hFile, I_Text)) return false; if (!TextSaveToFile(hFile, C_Text)) return false; if (!TextSaveToFile(hFile, J_Text)) return false; //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ if (SaveVersion > 18) if (!WriteFile(hFile, &bAutoLineFeed, sizeof(bool), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLabel::Copy(TPDocSheafLabel *src) { TPDocText::Copy((TPDocText *)src); K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; //Memo, SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ bAutoLineFeed = src->bAutoLineFeed; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocSheafLabel::GetAllocateSize() { int size = 0; size += TPDocText::GetAllocateSize(); size += (TextGetAllocateSize(K_Text) +TextGetAllocateSize(E_Text) +TextGetAllocateSize(I_Text) +TextGetAllocateSize(C_Text) +TextGetAllocateSize(J_Text) + sizeof(bool)); return size; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocSheafLabel::CopyToMemory(BYTE *lp) { lp = TPDocText::CopyToMemory(lp); lp = TextCopyToMemory(lp, K_Text); lp = TextCopyToMemory(lp, E_Text); lp = TextCopyToMemory(lp, I_Text); lp = TextCopyToMemory(lp, C_Text); lp = TextCopyToMemory(lp, J_Text); memcpy(lp,&bAutoLineFeed,sizeof(bool)); lp += sizeof(bool); return lp; } //--------------------------------------------------------------------------- BYTE *__fastcall TPDocSheafLabel::CopyFromMemory(BYTE *lp) { lp = TPDocText::CopyFromMemory(lp); lp = TextCopyFromMemory(lp, K_Text); lp = TextCopyFromMemory(lp, E_Text); lp = TextCopyFromMemory(lp, I_Text); lp = TextCopyFromMemory(lp, C_Text); lp = TextCopyFromMemory(lp, J_Text); memcpy(&bAutoLineFeed,lp,sizeof(bool)); lp += sizeof(bool); } //--------------------------------------------------------------------------- // // TPDocTextImage // //--------------------------------------------------------------------------- __fastcall TPDocTextImage::TPDocTextImage(TPDocObject *Sender, RECT rc) : TPDocElement(detTextImage, rc) { Parent = Sender; Image = NULL; bImageChanged = false; } //--------------------------------------------------------------------------- __fastcall TPDocTextImage::~TPDocTextImage() { if (Image) delete Image; } //--------------------------------------------------------------------------- void __fastcall TPDocTextImage::PaintForm(HDC hDC, RECT rc, double t, bool bPrint) { PaintFrame(hDC, rc, t, bPrint); } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocTextImage::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { PaintForm(hDC, ConvertRange(vs), (double)vs->ZoomIn / vs->ZoomOut, bPrint); } //--------------------------------------------------------------------------- void __fastcall TPDocTextImage::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; TSize s; if (ControlMode != dcmNone) { TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); PaintControl(hDC, vsc); return; } rc = ConvertRange(&vs); if (bSelect) PaintSelect(hDC, rc, &PaintSelectInCommon); else PaintRange(hDC, rc); PaintForm(hDC, rc, (double)vs.ZoomIn / vs.ZoomOut); if ( HasValue() ){ bool TempSelect = NowSelect; NowSelect = false; PaintReport(Sender,hDC,vs,bPrint,bSelect,language); // if (NowSelect) PaintIn(hDC, rc); NowSelect = TempSelect; if (NowSelect) PaintIn(hDC, rc); }else{ if (NowSelect) PaintIn(hDC, rc); } } //--------------------------------------------------------------------------- bool __fastcall TPDocTextImage::HasValue() { if(Image) return true; return false; } //--------------------------------------------------------------------------- void __fastcall TPDocTextImage::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; TSize s; if (Image) { rc = ConvertRange(&vs); s.cx = rc.right - rc.left - 6; // ¿©À¯ºÐÀ» ³Ö¾îÁÜ. s.cy = rc.bottom - rc.top - 6; PaintImage(hDC, Image, s, rc.left + 3, rc.top + 3); } if (NowSelect) PaintIn(hDC, rc); } //--------------------------------------------------------------------------- bool __fastcall TPDocTextImage::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!ReadFile(hFile, &Zoom, sizeof(int), &dwRead, NULL)) return false; if (!ImageLoadFromFile(hFile, Image)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocTextImage::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!WriteFile(hFile, &Zoom, sizeof(int), &dwWrite, NULL)) return false; if (!ImageSaveToFile(hFile, Image)) return false; return true; } //--------------------------------------------------------------------------- int __fastcall TPDocTextImage::GetAllocateSize() { int size = 0; size += (sizeof(int) + ImageGetAllocateSize(Image)); return size; } //--------------------------------------------------------------------------- BYTE* __fastcall TPDocTextImage::CopyToMemory(BYTE *lp) { memcpy(lp, &Zoom, sizeof(int)); lp += sizeof(int); lp = ImageCopyToMemory(lp, Image); return lp; } //--------------------------------------------------------------------------- BYTE* __fastcall TPDocTextImage::CopyFromMemory(BYTE *lp) { memcpy(&Zoom, lp, sizeof(int)); lp += sizeof(int); lp = ImageCopyFromMemory(lp, Image); return lp; } //--------------------------------------------------------------------------- bool __fastcall TPDocTextImage::Copy(TPDocTextImage *src) { Zoom = src->Zoom; /* if (Type == detSignature || Type == detNumber || Type == detFormula || Type == detLabel || Type == detEdit || Type == detMemo || Type == detImage || Type == detTextImage) { À̰͵鿡 ÇØ´çÇÏ´Â Type¿¡ ´ëÇØ¼­¸¸ Background¸¦ º¹»çÇÑ´Ù. (2007. 07. 19 Annualring) */ // Copy¿¡¼­µµ ¼¿ ¹è°æ º¹»çµÇµµ·Ï ¼öÁ¤ (2007. 07. 19 Annualring) Background = src->Background; if (!ImageCopy(Image, src->Image)) return false; return true; } //--------------------------------------------------------------------------- // // TPDocSheafLine // //--------------------------------------------------------------------------- __fastcall TPDocSheafLine::TPDocSheafLine(TPDocObject *Sender, RECT rc, TPDocSheafLineType lt, POINT tsp, POINT tep, TColor c) : TPDocElement(detSheafLine, rc) { Parent = Sender; Type = lt; Color = c; sp = tsp; ep = tep; FOldArrow[0] = sp; FOldArrow[1] = ep; } //--------------------------------------------------------------------------- // Private Methods //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::PaintForm(HDC hDC, RECT rc, double t) { } //--------------------------------------------------------------------------- // Protected Methods //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::PaintSelectIn(HDC hDC, void *data) { ArrowData *ad = (ArrowData *)data; Rectangle(hDC, ad->fad.x-2, ad->fad.y-2, ad->fad.x+3, ad->fad.y+3); Rectangle(hDC, ad->ead.x-2, ad->ead.y-2, ad->ead.x+3, ad->ead.y+3); } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::PaintControl(HDC hDC, TPDocViewStatus &vs) { HPEN hPen = NULL, hOldPen = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); nOldROP = SetROP2(hDC, R2_NOT); MoveToEx(hDC, vs.Pattern2ViewX(FOldArrow[0].x), vs.Pattern2ViewY(FOldArrow[0].y), NULL); LineTo(hDC, vs.Pattern2ViewX(FOldArrow[1].x), vs.Pattern2ViewY(FOldArrow[1].y)); } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::PaintForm(HDC hDC, TPDocViewStatus *vs, bool bPrint) { } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { RECT rc; ArrowData AD; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } if (bSelect) { PaintControl(hDC, vsc); AD.fad = ConvertPoint(FOldArrow[0], &vs); AD.ead = ConvertPoint(FOldArrow[1], &vs); PaintSelectReport(hDC, &AD, &PaintSelectIn); return; } DrawLine(hDC, &vs); } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLine::HasValue() { return false; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::PaintReport(TPDocObject *Sender, HDC hDC, TPDocViewStatus &vs, bool bPrint, bool bselect, int language, bool bSaveJPG) { RECT rc; ArrowData AD; TPDocViewStatus vsc(vs.Position, vs.ZoomIn, vs.ZoomOut); if (ControlMode != dcmNone) { PaintControl(hDC, vsc); return; } if (bselect) { PaintControl(hDC, vsc); AD.fad = ConvertPoint(FOldArrow[0], &vs); AD.ead = ConvertPoint(FOldArrow[1], &vs); PaintSelectReport(hDC, &AD, &PaintSelectIn); return; } DrawLine(hDC, &vs); } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::DrawLine(HDC hDC, TPDocViewStatus *vs) { HPEN hPen = NULL, hOldPen = NULL; POINT csp, cep; double r, tangen_x, tangen_y; int i; r = (double)vs->ZoomIn / vs->ZoomOut; csp = ConvertPoint(sp, vs); cep = ConvertPoint(ep, vs); try { switch (Type) { case dsltNormal: hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); MoveToEx(hDC, csp.x, csp.y, NULL); LineTo(hDC, cep.x, cep.y); break; case dsltDash: if((cep.x == csp.x) && (cep.y == csp.y)) return; hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); tangen_x = ((cep.x - csp.x) / sqrt((cep.x - csp.x)*(cep.x - csp.x) + (cep.y - csp.y)*(cep.y - csp.y))) *10*(1*r<1 ? 1 : 1*r); tangen_y = ((cep.y - csp.y) / sqrt((cep.x - csp.x)*(cep.x - csp.x) + (cep.y - csp.y)*(cep.y - csp.y))) *10*(1*r<1 ? 1 : 1*r); for(i=0;;i=i+2){ if((((cep.x <= csp.x) && (cep.x >= csp.x + i*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + i*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + i*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + i*tangen_y)))) break; MoveToEx(hDC, csp.x + i*tangen_x, csp.y + i*tangen_y, NULL); if((((cep.x <= csp.x) && (cep.x >= csp.x + (i+1)*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + (i+1)*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + (i+1)*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + (i+1)*tangen_y)))){ LineTo(hDC, cep.x, cep.y); break; } else LineTo(hDC, csp.x + (i+1)*tangen_x, csp.y + (i+1)*tangen_y); } break; case dsltThick: hPen = CreatePen(psSolid, 3*r<1 ? 1 : 3*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); MoveToEx(hDC, csp.x, csp.y, NULL); LineTo(hDC, cep.x, cep.y); break; case dsltDot: if((cep.x == csp.x) && (cep.y == csp.y)) return; hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); tangen_x = ((cep.x - csp.x) / sqrt((cep.x - csp.x)*(cep.x - csp.x) + (cep.y - csp.y)*(cep.y - csp.y))) *3*(1*r<1 ? 1 : 1*r); tangen_y = ((cep.y - csp.y) / sqrt((cep.x - csp.x)*(cep.x - csp.x) + (cep.y - csp.y)*(cep.y - csp.y))) *3*(1*r<1 ? 1 : 1*r); for(i=0;;i=i+2){ if((((cep.x <= csp.x) && (cep.x >= csp.x + i*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + i*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + i*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + i*tangen_y)))) break; MoveToEx(hDC, csp.x + i*tangen_x, csp.y + i*tangen_y, NULL); if((((cep.x <= csp.x) && (cep.x >= csp.x + (i+1)*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + (i+1)*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + (i+1)*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + (i+1)*tangen_y)))){ LineTo(hDC, cep.x, cep.y); break; } else LineTo(hDC, csp.x + (i+1)*tangen_x, csp.y + (i+1)*tangen_y); } break; case dsltDashdot: if((cep.x == csp.x) && (cep.y == csp.y)) return; hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); tangen_x = ((cep.x - csp.x) / sqrt((cep.x - csp.x)*(cep.x - csp.x) + (cep.y - csp.y)*(cep.y - csp.y))) *3*(1*r<1 ? 1 : 1*r); tangen_y = ((cep.y - csp.y) / sqrt((cep.x - csp.x)*(cep.x - csp.x) + (cep.y - csp.y)*(cep.y - csp.y))) *3*(1*r<1 ? 1 : 1*r); for(i=0;;i=i+8){ if((((cep.x <= csp.x) && (cep.x >= csp.x + i*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + i*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + i*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + i*tangen_y)))) break; MoveToEx(hDC, csp.x + i*tangen_x, csp.y + i*tangen_y, NULL); if((((cep.x <= csp.x) && (cep.x >= csp.x + (i+3)*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + (i+3)*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + (i+3)*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + (i+3)*tangen_y)))){ LineTo(hDC, cep.x, cep.y); break; } else LineTo(hDC, csp.x + (i+3)*tangen_x, csp.y + (i+3)*tangen_y); if((((cep.x <= csp.x) && (cep.x >= csp.x + (i+5)*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + (i+5)*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + (i+5)*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + (i+5)*tangen_y)))) break; MoveToEx(hDC, csp.x + (i+5)*tangen_x, csp.y + (i+5)*tangen_y, NULL); if((((cep.x <= csp.x) && (cep.x >= csp.x + (i+6)*tangen_x))||((cep.x >= csp.x) && (cep.x <= csp.x + (i+6)*tangen_x))) &&(((cep.y <= csp.y) && (cep.y >= csp.y + (i+6)*tangen_y))||((cep.y >= csp.y) && (cep.y <= csp.y + (i+6)*tangen_y)))){ LineTo(hDC, cep.x, cep.y); break; } else LineTo(hDC, csp.x + (i+6)*tangen_x, csp.y + (i+6)*tangen_y); } break; case dsltTwo: case dsltTwodown: case dsltTwoup: case dsltThree: if(Type == dsltTwoup) hPen = CreatePen(psSolid, 3*r<1 ? 1 : 3*r, Color); else hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); MoveToEx(hDC, csp.x, csp.y, NULL); LineTo(hDC, cep.x, cep.y); if (hPen) DeleteObject(hPen); if(Type == dsltTwodown){ hPen = CreatePen(psSolid, 3*r<1 ? 1 : 3*r, Color); } else{ hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); } hOldPen = (HPEN)SelectObject(hDC, hPen); double r2 = 2*r<1 ? 1: 2*r; double r3 = 3*r<1 ? 1: 3*r; double r4 = 4*r<1 ? 1: 4*r; if((cep.x != csp.x) && (cep.y != csp.y)){ float asp = (float)(cep.x - csp.x) / (float)(cep.y - csp.y); if(asp > 0 && asp < 1){ MoveToEx(hDC, csp.x-r3, csp.y+r2, NULL); LineTo(hDC, cep.x-r3, cep.y+r2); } else if(asp >= 1){ MoveToEx(hDC, csp.x-r2, csp.y+r3, NULL); LineTo(hDC, cep.x-r2, cep.y+r3); } else if(asp < 0 && asp > -1){ MoveToEx(hDC, csp.x+r3, csp.y+r2, NULL); LineTo(hDC, cep.x+r3, cep.y+r2); } else if(asp <= -1){ MoveToEx(hDC, csp.x+r2, csp.y+r3, NULL); LineTo(hDC, cep.x+r2, cep.y+r3); } } else if((cep.x == csp.x) && (cep.y != csp.y)){ MoveToEx(hDC, csp.x+r4, csp.y, NULL); LineTo(hDC, cep.x+r4, cep.y); } else if((cep.x != csp.x) && (cep.y == csp.y)){ MoveToEx(hDC, csp.x, csp.y+r4, NULL); LineTo(hDC, cep.x, cep.y+r4); } if(Type == dsltThree){ if (hPen) DeleteObject(hPen); hPen = CreatePen(psSolid, 1*r<1 ? 1 : 1*r, Color); hOldPen = (HPEN)SelectObject(hDC, hPen); if((cep.x != csp.x) && (cep.y != csp.y)){ float asp = (float)(cep.x - csp.x) / (float)(cep.y - csp.y); if(asp > 0 && asp < 1){ MoveToEx(hDC, csp.x+r3, csp.y-r2, NULL); LineTo(hDC, cep.x+r3, cep.y-r2); } else if(asp >= 1){ MoveToEx(hDC, csp.x+r2, csp.y-r3, NULL); LineTo(hDC, cep.x+r2, cep.y-r3); } else if(asp < 0 && asp > -1){ MoveToEx(hDC, csp.x-r3, csp.y-r2, NULL); LineTo(hDC, cep.x-r3, cep.y-r2); } else if(asp <= -1){ MoveToEx(hDC, csp.x-r2, csp.y-r3, NULL); LineTo(hDC, cep.x-r2, cep.y-r3); } } else if((cep.x == csp.x) && (cep.y != csp.y)){ MoveToEx(hDC, csp.x-r4, csp.y, NULL); LineTo(hDC, cep.x-r4, cep.y); } else if((cep.x != csp.x) && (cep.y == csp.y)){ MoveToEx(hDC, csp.x, csp.y-r4, NULL); LineTo(hDC, cep.x, cep.y-r4); } } break; } } __finally { if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLine::LoadFromFile(HANDLE hFile, int Version) { DWORD dwRead; TextVersion = Version; if (!ReadFile(hFile, &Type, sizeof(TPDocLineType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &Color, sizeof(TColor), &dwRead, NULL)) return false; if (!ReadFile(hFile, &sp, sizeof(POINT), &dwRead, NULL)) return false; if (!ReadFile(hFile, &ep, sizeof(POINT), &dwRead, NULL)) return false; //by k3dogs(20001029)arrow ÃʱâÈ­°¡ µÇÁö ¾Ê¾Æ¼­. »ý¼ºÀÚ¿¡ ÀÖ¾î¾ß ÇÑ´Ù°í ÇÔ. //==========================//¸ÇóÀ½ ¼±ÅÃÇßÀ»¶§ controlmodedown¿¡ µé¾î°¡Áö ¸øÇؼ­ FOldArrow[0] = sp; //FOldArrowÀÇ °ªÀÌ Á¤ÇØÁöÁö ¾Ê¾Æ¼­ ±×¸²À» ±×¸®Áö ¸øÇϱ⠶§¹®¿¡.. FOldArrow[1] = ep; //if select at first time, as cannot get into controlmodedown event, FOldArrow is not defined, //so cannot draw line from sp to ep. //========================== return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLine::SaveToFile(HANDLE hFile) { DWORD dwWrite; if (!WriteFile(hFile, &Type, sizeof(TPDocLineType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Color, sizeof(TColor), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &sp, sizeof(POINT), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &ep, sizeof(POINT), &dwWrite, NULL)) return false; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheafLine::Copy(TPDocSheafLine *src) { Type = src->Type; Color = src->Color; sp = src->sp; ep = src->ep; return true; } //--------------------------------------------------------------------------- TPDocControlMode __fastcall TPDocSheafLine::GetControlMode(int X, int Y) { TPDocControlMode dcm; if ((X > sp.x-2) && (X < sp.x+3) && (Y > sp.y-2) && (Y < sp.y+3)) return dcmFirst; if ((X > ep.x-2) && (X < ep.x+3) && (Y > ep.y-2) && (Y < ep.y+3)) return dcmLast; return X >= Range.left && Y >= Range.top && X <= Range.right && Y <= Range.bottom ? dcmMove : dcmNone; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLine::GetNewRange(int X, int Y) { int tx, ty; bool bfrect = true; switch (ControlMode) { case dcmFirst: FOldArrow[0] = Point(X, Y); break; case dcmLast: FOldArrow[1] = Point(X, Y); break; case dcmMove: tx = X - FOldPoint.x; ty = Y - FOldPoint.y; FOldArrow[0] = Point(sp.x+tx, sp.y+ty); FOldArrow[1] = Point(ep.x+tx, ep.y+ty); FOldRect = Rect(Range.left+tx, Range.top+ty, Range.right+tx, Range.bottom+ty); bfrect = false; break; } if (bfrect) { FOldRect = ReArrangeRect(false); } } //--------------------------------------------------------------------- void __fastcall TPDocSheafLine::ControlModeMouseDown(TShiftState Shift, int X, int Y) { FOldArrow[0] = sp; FOldArrow[1] = ep; FOldRect = Range; FOldPoint = Point(X, Y); } //--------------------------------------------------------------------- void __fastcall TPDocSheafLine::ControlModeMouseMove(HDC hDC, TPDocViewStatus &vs, int X, int Y) { PaintControl(hDC, vs); GetNewRange(X, Y); PaintControl(hDC, vs); } //--------------------------------------------------------------------- void __fastcall TPDocSheafLine::ControlModeMouseUp() { bool bfrect = true; switch (ControlMode) { case dcmFirst: sp = FOldArrow[0]; break; case dcmLast: ep = FOldArrow[1]; break; case dcmMove: sp = FOldArrow[0]; ep = FOldArrow[1]; Range = FOldRect; bfrect = false; break; } if (bfrect) { Range = ReArrangeRect(true); } //qe ¶óÀÎÀÇ ½¬¿î Ȱ¼ºÈ­¸¦ À§ÇØ ¹üÀ§¸¦ ³ÐÈù´Ù. if((Range.right - Range.left) < 8 ){ Range.left = Range.left -5; Range.right = Range.right + 5; } if((Range.bottom - Range.top) < 8){ Range.top = Range.top - 5; Range.bottom = Range.bottom + 5; } } //--------------------------------------------------------------------------- RECT __fastcall TPDocSheafLine::ReArrangeRect(bool breal) { long tx, ty; POINT pt[2]; RECT rt; if (breal) { pt[0] = sp; pt[1] = ep; } else { pt[0] = FOldArrow[0]; pt[1] = FOldArrow[1]; } if (pt[0].x < pt[1].x) { rt.left = pt[0].x; rt.right = pt[1].x; } else { rt.left = pt[1].x; rt.right = pt[0].x; } if (pt[0].y < pt[1].y) { rt.top = pt[0].y; rt.bottom = pt[1].y; } else { rt.top = pt[1].y; rt.bottom = pt[0].y; } return rt; } //--------------------------------------------------------------------------- // // TPDocCommonData // //--------------------------------------------------------------------------- __fastcall TPDocCommonData::TPDocCommonData() { Type = detNone; Data = NULL; } //--------------------------------------------------------------------------- __fastcall TPDocCommonData::TPDocCommonData(TPDocElementType t, int id) { Type = t; ID = id; switch (Type) { case detColorChip: Data = new TColor; *(TColor *)Data = clWhite; // colorchipÀÌ ÀÓÀÇÀÇ Ä®¶ó·Î ä¿öÁö´Â °ÍÀ» ¸·±âÀ§ÇØ. break; case detEdit: case detNumber: case detFormula: case detDate: Data = new AnsiString; break; case detImage: Data = new TTexpiaBitmap; break; default: Data = NULL; break; } } //--------------------------------------------------------------------------- __fastcall TPDocCommonData::~TPDocCommonData() { /* switch (Type) { case detColorChip: delete (TColor *)Data; Data = NULL; break; case detEdit: delete (AnsiString *)Data; Data = NULL; break; case detNumber: case detFormula: delete (double *)Data; Data = NULL; break; case detDate: delete (SYSTEMTIME *)Data; Data = NULL; break; } Type = detNone; */ switch (Type) { case detColorChip: delete (TColor *)Data; Data = NULL; break; case detEdit: case detNumber: case detFormula: case detDate: delete (AnsiString *)Data; Data = NULL; break; case detImage: delete (TTexpiaBitmap *) Data; Data = NULL; break; } Type = detNone; } //--------------------------------------------------------------------------- // // TPDocSheet // //--------------------------------------------------------------------------- // Private Method //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetOrientation(TPrinterOrientation orient) { RECT rt = Range; if ( FOrientation != orient) { FOrientation = orient; Range = Rect(0, 0, rt.bottom, rt.right); } } //--------------------------------------------------------------------------- //__fastcall TPDocSheet::TPDocSheet(TPDocSheaf *Sender) : TPDocObject() /// »ý¼ºÀÚ¿¡ ¸Å°³º¯¼ö Ãß°¡ // (2007. 02. 08 Annualring) __fastcall TPDocSheet::TPDocSheet(TPDocSheaf *Sender, bool isEditable, TFont *defaultFont) : TPDocElement(detSheet,Rect(0,0,0,0)) { Range.left = 0; Range.top = 0; DotsPerInch = 160; Range.right = 7.6*160; //¿©À¯ºÐÀ» À§ÇØ 7.8*11 inch Range.bottom = 10.8*160; VI = 0; HI = 0; ParentSheaf = Sender; FOrientation = poPortrait; FFont = new TFont; if (defaultFont) { FFont->Assign(defaultFont); } else { FFont->Handle = (HFONT) GetStockObject(DEFAULT_GUI_FONT); // À©µµ¿ì ±âº» ±Û²ÃÀ» °¡Á®¿È - by monkman (2010.06.04) FFont->Charset = DEFAULT_CHARSET; FFont->Color = clBlack; //FFont->Name = "Tahoma"; FFont->Size = 10; } Element = new TList; Bitmap = NULL; SheetType = dstA4; XIndexCount = -1; YIndexCount = -1; FileName = ""; Modify = false; Undo = new TPUndo; bUndoLocked = false; if(ParentSheaf!=NULL){ FUndoSave = ParentSheaf->OnUndoSave; FOnPaintVector = ParentSheaf->OnPaintVector; }else{ FUndoSave = NULL; FOnPaintVector = NULL; } TPVectorUndo = NULL; FEditable = isEditable; ThumbnailRange.top = 0; ThumbnailRange.left = 0; ThumbnailRange.right = 0; ThumbnailRange.bottom = 0; ThumbnailRangeJPG.top = 0; ThumbnailRangeJPG.left = 0; ThumbnailRangeJPG.right = 0; ThumbnailRangeJPG.bottom = 0; // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) NumberIDCount = 0; FormulaIDCount = 0; DateIDCount = 0; ChartIDCount = 0; } //--------------------------------------------------------------------------- __fastcall TPDocSheet::~TPDocSheet() { TPDocElement *dp; if (Bitmap) delete Bitmap; if (Element) { /* while (Element->Count) { dp = (TPDocElement *)Element->First(); Element->Remove(dp); delete dp; } delete Element; */ for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp) { switch (dp->Type) { case detLine: delete (TPDocLine*)dp; dp = NULL; break; case detBox: delete (TPDocBox*)dp; dp = NULL; break; case detColorChip: delete (TPDocColorChip*)dp; dp = NULL; break; case detSignature: delete (TPDocSignature*)dp; dp = NULL; break; case detNumber: delete (TPDocNumber*)dp; dp = NULL; break; case detFormula: delete (TPDocFormula*)dp; dp = NULL; break; case detDate: delete (TPDocDate*)dp; dp = NULL; break; case detLabel: delete (TPDocLabel*)dp; dp = NULL; break; case detEdit: delete (TPDocEdit*)dp; dp = NULL; break; case detMemo: delete (TPDocMemo*)dp; dp = NULL; break; case detImage: delete (TPDocImage*)dp; dp = NULL; break; case detInput: delete (TPDocInput*)dp; dp = NULL; break; case detChart: delete (TPDocChart*)dp; dp = NULL; break; case detArrow: delete (TPDocArrow*)dp; dp = NULL; break; case detSheafImage: delete (TPDocSheafImage*)dp; dp = NULL; break; case detSheafLabel: delete (TPDocSheafLabel*)dp; dp = NULL; break; case detTextImage: delete (TPDocTextImage*)dp; dp = NULL; break; case detSheafLine: delete (TPDocSheafLine*)dp; dp = NULL; break; case detThumbnailImage: delete (TPDocThumbnailImage*)dp; dp = NULL; break; //by linuxjun for À¯½ºÇÏÀÌÅØ case detThumbnailImageJPG: delete (TPDocThumbnailImageJPG*)dp; dp = NULL; break; //by linuxjun for À¯½ºÇÏÀÌÅØ default: delete dp; dp = NULL; } } } Element->Clear(); delete Element; Element = NULL; } if (FFont) delete FFont; delete Undo; if(TPVectorUndo){ delete TPVectorUndo; TPVectorUndo = NULL; } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddLine(RECT rc, TPDocLineType lt, TColor c, TPDocLineStyle ls) { TPDocLine *dp = new TPDocLine(this, rc, lt, c, ls); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddBox(RECT rc, TColor c, TPDocLineStyle ls) { TPDocBox *dp = new TPDocBox(this, rc, c, ls); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- /* void __fastcall TPDocSheet::AddColorChip(RECT rc, int m, AnsiString n, TColor c) { TPDocColorChip *dp = new TPDocColorChip(this, rc, m, n, c); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddNumber(RECT rc, TPDocAlign ta, int p, bool h, AnsiString n) { TPDocNumber *dp = new TPDocNumber(this, rc, ta, p, h, n); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddFormula(RECT rc, TPDocAlign ta, int p, bool h, AnsiString n, AnsiString f) { TPDocFormula *dp = new TPDocFormula(this, rc, ta, p, h, n, f); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddDate(RECT rc, TPDocAlign ta, AnsiString n) { TPDocDate *dp = new TPDocDate(this, rc, ta, n); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddLabel(RECT rc, TPDocAlign ta, AnsiString t) { TPDocLabel *dp = new TPDocLabel(this, rc, ta, t); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddEdit(RECT rc, TPDocAlign ta, AnsiString n) { TPDocEdit *dp = new TPDocEdit(this, rc, ta, n); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddMemo(RECT rc, TPDocAlign ta, AnsiString t) { TPDocMemo *dp = new TPDocMemo(this, rc, ta, t); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddInput(RECT rc, TPDocAlign ta, TColor c, TPDocInputStyle s, AnsiString t, int p, TPDocInputMethod m) { TPDocInput *dp = new TPDocInput(this, rc, ta, c, s, t, p, m); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddImage(RECT rc, TPDocAlign ta, AnsiString t) { TPDocImage *dp = new TPDocImage(this, rc, ta, t); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- */ void __fastcall TPDocSheet::AddNumber(RECT rc, TPDocAlign ta, int p, bool h, WideString n) { TPDocNumber *dp = new TPDocNumber(this, rc, ta, p, h, n); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddFormula(RECT rc, TPDocAlign ta, int p, bool h, WideString n, WideString f) { TPDocFormula *dp = new TPDocFormula(this, rc, ta, p, h, n, f); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddDate(RECT rc, TPDocAlign ta, WideString n) { TPDocDate *dp = new TPDocDate(this, rc, ta, n); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddLabel(RECT rc, TPDocAlign ta, WideString t) { TPDocLabel *dp = new TPDocLabel(this, rc, ta, t); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddEdit(RECT rc, TPDocAlign ta, WideString n) { TPDocEdit *dp = new TPDocEdit(this, rc, ta, n); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddMemo(RECT rc, TPDocAlign ta, WideString t) { TPDocMemo *dp = new TPDocMemo(this, rc, ta, t); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ // ¾Æ¿¹ InputÀ̶ó´Â °´Ã¼°¡ »ý±â´Â °ÍÀ» ¸·À½ (2007. 08. 16 Annualring) /* void __fastcall TPDocSheet::AddInput(RECT rc, TPDocAlign ta, TColor c, TPDocInputStyle s, WideString t, int p, TPDocInputMethod m) { TPDocInput *dp = new TPDocInput(this, rc, ta, c, s, t, p, m); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } */ //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddImage(RECT rc, TPDocAlign ta, WideString t) { TPDocImage *dp = new TPDocImage(this, rc, ta, t); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddSignature(RECT rc) { TPDocSignature *dp = new TPDocSignature(this, rc); ElementUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::AddChart(RECT rc, TPDocAlign ta, int col, int row, TColor c, bool beditformula, TPDocElementType et) { TPDocChart *dp; dp = new TPDocChart(this, rc, ta, col, row, c, beditformula, et); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); SetCursorIndex(); return true; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddThumbnailImage(RECT rc) { TPDocThumbnailImage *dp; dp = new TPDocThumbnailImage(this, rc); /* ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo */ //To Do :: °°Àº Sheaf³»¿¡ ÀÖ´Â ´Ù¸¥ Sheet¿¡ ThumbnailImage°¡ ¾ø´ÂÁö Ã¼Å©ÇØ¾ßÇÔ. //üũÈÄ ÀÖ´Ù¸é ¾ø¾ÖÁÖ¾î¾ßÇÔ. //À̺κÐÀº mainReportÀÇ AddThumbnail¿¡¼­ ÇØÁִ°ÍÀÌ Àû´çÇØº¸ÀÓ Element->Add(dp); // SetCursorIndex(); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddThumbnailImageJPG(RECT rc) { TPDocThumbnailImageJPG *dp; dp = new TPDocThumbnailImageJPG(this, rc); /* ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo */ //To Do :: °°Àº Sheaf³»¿¡ ÀÖ´Â ´Ù¸¥ Sheet¿¡ ThumbnailImage°¡ ¾ø´ÂÁö Ã¼Å©ÇØ¾ßÇÔ. //üũÈÄ ÀÖ´Ù¸é ¾ø¾ÖÁÖ¾î¾ßÇÔ. //À̺κÐÀº mainReportÀÇ AddThumbnail¿¡¼­ ÇØÁִ°ÍÀÌ Àû´çÇØº¸ÀÓ Element->Add(dp); // SetCursorIndex(); } //--------------------------------------------------------------------------- /* TPDocArrow * __fastcall TPDocSheet::AddArrow(RECT rc, TPDocArrowType at, POINT sp, POINT ep, POINT tp, TPDocAlign ta, AnsiString t, TColor c) { TPDocArrow *dp; dp = new TPDocArrow(this, rc, at, sp, ep, tp, ta, t, c); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); //<------------------------------------------------------------------------>// SetOnlyOnebSelected(dp); //for CnI return dp; //<------------------------------------------------------------------------>// } //--------------------------------------------------------------------------- */ TPDocArrow * __fastcall TPDocSheet::AddArrow(RECT rc, TPDocArrowType at, POINT sp, POINT ep, POINT tp, TPDocAlign ta, WideString t, TColor c) { TPDocArrow *dp; dp = new TPDocArrow(this, rc, at, sp, ep, tp, ta, t, c); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); //<------------------------------------------------------------------------>// SetOnlyOnebSelected(dp); //for CnI return dp; //<------------------------------------------------------------------------>// } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddSheafImage(RECT rc) { TPDocSheafImage *dp; dp = new TPDocSheafImage(this, rc); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); //<------------------------------------------------------------------------>// SetOnlyOnebSelected(dp); //for CnI //<------------------------------------------------------------------------>// } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetOnlyOnebSelected(TPDocElement *dp) { //<---»õ·Î ±×¸²À» Ãß°¡ÇÒ¶§ Àü¿¡ ¼±ÅÃµÈ ¿µ¿ªÀÌ Áö¿öÁö°í Áö±Ý ±×¸®´Â ºÎºÐÀÌ-->// ResetbSelected(); //¼±Åà µÇÀÖ°Ô ÇϱâÀ§ÇØ À̺κÐÀ» Ãß°¡½ÃÅ´ switch(dp->Type){ case detArrow: ((TPDocArrow *)dp)->bSelected=true; //by linuxjun break; case detSheafImage: ((TPDocSheafImage *)dp)->bSelected=true; //by linuxjun break; default: break; } //<------------------------------------------------------------------------>// } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::ResetbSelected() { TPDocElement *dp = NULL; for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == detSheafImage) { ((TPDocSheafImage *)dp)->bSelected=false; } if (dp->Type == detArrow) { ((TPDocArrow *)dp)->bSelected=false; } } } //--------------------------------------------------------------------------- /* void __fastcall TPDocSheet::AddSheafLabel(RECT rc, TPDocAlign ta, AnsiString t) { TPDocSheafLabel *dp = new TPDocSheafLabel(this, rc, ta, t); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- */ TPDocSheafLabel * __fastcall TPDocSheet::AddSheafLabel(RECT rc, TPDocAlign ta, WideString t, bool bAutoLineFeed) { TPDocSheafLabel *dp = new TPDocSheafLabel(this, rc, ta, t); dp->AutoLineFeed = bAutoLineFeed; //SheafLabelÀÇ AutoLineFeed ¿©ºÎ¸¦ È®ÀÎ Çϱâ À§Çؼ­ Ãß°¡ ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); SetOnlyOnebSelected(dp); return dp; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddTextImage(RECT rc) { TPDocTextImage *dp = new TPDocTextImage(this, rc); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddSheafLine(RECT rc, TPDocSheafLineType lt, POINT tsp, POINT tep, TColor c) { TPDocSheafLine *dp = new TPDocSheafLine(this, rc, lt, tsp, tep, c); ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CopyCreateFromMemory(BYTE *lpData, int left, int top, bool bCopyID) { TPDocChart *dp; dp = new TPDocChart(this, Rect(0, 0, 0, 0), daCenter2, 0, 0); if (((TPDocChart *)dp)->CopyCreateFromMemory(lpData, left, top, bCopyID)) { // ¸Þ¸ð¸® ´©¼ö ó¸® (2007. 08. 30 Annualring) // ElementUndoSave(); -> À̰о²¸é »õ·Î »ý±ä °ÍÀº Á¦´ë·Î »èÁ¦°¡ ¾ÈµÈ´Ù!!!!!!! // »ç¿ëÇÒ ¶§ ÁÖÀÇÇÒ °Í. ElementAddUndoSave(); //For Undo UndoSave(this); //for Undo CreateUndoSave(dp); //for Undo Element->Add(dp); SetCursorIndex(); return true; } else return false; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocSheet::CheckName(AnsiString str, TPDocElement *s) { int i; AnsiString name = ""; TPDocElement *sep; for (i=0; iCount; i++) { sep = (TPDocElement *)Element->Items[i]; if (sep->Type == detInput) { if (!CheckName_Input(str, s, (TPDocInput *)sep)) return false; } else if (sep->Type == detChart) { if (!CheckName_Chart(str, s, (TPDocChart *)sep)) return false; } else { if (s != sep) { switch (sep->Type) { case detColorChip: name = ((TPDocColorChip *)sep)->Name; break; case detNumber: name = ((TPDocNumber *)sep)->Name; break; case detFormula: name = ((TPDocFormula *)sep)->Name; break; case detDate: name = ((TPDocDate *)sep)->Name; break; case detEdit: name = ((TPDocEdit *)sep)->Name; break; } if (name.Length() > 0) { if (str.AnsiCompare(name) == 0) { return false; } name = ""; } } } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckField(AnsiString str, TPDocElement *s) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i; AnsiString name = ""; TPDocElement *sep; for (i=0; iCount; i++) { sep = (TPDocElement *)Element->Items[i]; if (sep->Type == detInput) { if (!CheckField_Input(str, s, (TPDocInput *)sep)) return false; } else if (sep->Type == detChart) { if (!CheckField_Chart(str, s, (TPDocChart *)sep)) return false; } else { if (s != sep) { switch (sep->Type) { /* case detColorChip: FieldName = ((TPDocColorChip *)sep)->FieldName; break; case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB name = ((TPDocNumber *)sep)->FieldName; break; case detFormula: name = ((TPDocFormula *)sep)->FieldName; break; case detDate: name = ((TPDocDate *)sep)->FieldName; break; case detEdit: name = ((TPDocEdit *)sep)->FieldName; break; } if (name.Length() > 0) { if (str.AnsiCompare(name) == 0) { return false; } name = ""; } } } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckName_Input(AnsiString str, TPDocElement *s, TPDocInput *ip) { AnsiString name = ""; if (s) { if (s == ip->IPElement) // if two Elements are same, don't need to check... return true; } switch (ip->IPElement->Type) { case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->Name; break; case detNumber: name = ((TPDocNumber *)ip->IPElement)->Name; break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->Name; break; case detDate: name = ((TPDocDate *)ip->IPElement)->Name; break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->Name; break; } if (name.Length()> 0) { if (str.AnsiCompare(name) == 0) { return false; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckField_Input(AnsiString str, TPDocElement *s, TPDocInput *ip) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { AnsiString name = ""; if (s) { if (s == ip->IPElement) // if two Elements are same, don't need to check... return true; } switch (ip->IPElement->Type) { /* case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->FieldName; break; case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB name = ((TPDocNumber *)ip->IPElement)->FieldName; break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->FieldName; break; case detDate: name = ((TPDocDate *)ip->IPElement)->FieldName; break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->FieldName; break; } if (name.Length()> 0) { if (str.AnsiCompare(name) == 0) { return false; } } return true; } //--------------------------------------------------------------------------- */ bool __fastcall TPDocSheet::CheckName(WideString str, TPDocElement *s) { int i; WideString name = ""; TPDocElement *sep; for (i=0; iCount; i++) { sep = (TPDocElement *)Element->Items[i]; if (sep->Type == detInput) { if (!CheckName_Input(str, s, (TPDocInput *)sep)) return false; } else if (sep->Type == detChart) { if (!CheckName_Chart(str, s, (TPDocChart *)sep)) return false; } else { if (s != sep) { switch (sep->Type) { case detColorChip: name = ((TPDocColorChip *)sep)->Name; break; case detNumber: name = ((TPDocNumber *)sep)->Name; break; case detFormula: name = ((TPDocFormula *)sep)->Name; break; case detDate: name = ((TPDocDate *)sep)->Name; break; case detEdit: name = ((TPDocEdit *)sep)->Name; break; case detImage: name = ((TPDocImage *)sep)->Name; break; } if (name.Length() > 0) { if (str.operator ==(name)) { return false; } name = ""; } } } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckField(WideString str, TPDocElement *s) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i; WideString name = ""; TPDocElement *sep; for (i=0; iCount; i++) { sep = (TPDocElement *)Element->Items[i]; if (sep->Type == detInput) { if (!CheckField_Input(str, s, (TPDocInput *)sep)) return false; } else if (sep->Type == detChart) { if (!CheckField_Chart(str, s, (TPDocChart *)sep)) return false; } else { if (s != sep) { switch (sep->Type) { /* case detColorChip: FieldName = ((TPDocColorChip *)sep)->FieldName; break; */ case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB name = ((TPDocNumber *)sep)->FieldName; break; case detFormula: name = ((TPDocFormula *)sep)->FieldName; break; case detDate: name = ((TPDocDate *)sep)->FieldName; break; case detEdit: name = ((TPDocEdit *)sep)->FieldName; break; // SheafImage¿Í SheafLabelµµ Ãß°¡ (2007. 08. 03 Annualring) case detSheafImage: name = ((TPDocSheafImage *)sep)->FieldName; break; case detSheafLabel: name = ((TPDocSheafLabel *)sep)->FieldName; break; // TPDocImage, TPDocMemo, TPDocColorChip¿¡µµ Field¼³Á¤ °¡´ÉÇÏ°Ô (2007. 08. 08 Annualring) case detImage: name = ((TPDocImage *)sep)->FieldName; break; case detMemo: name = ((TPDocMemo *)sep)->FieldName; break; // case detColorChip: // name = ((TPDocColorChip *)sep)->FieldName; // break; } if (name.Length() > 0) { if (str.operator ==(name)) { return false; } name = ""; } } } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckName_Input(WideString str, TPDocElement *s, TPDocInput *ip) { WideString name = ""; if (s) { if (s == ip->IPElement) // if two Elements are same, don't need to check... return true; } switch (ip->IPElement->Type) { case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->Name; break; case detNumber: name = ((TPDocNumber *)ip->IPElement)->Name; break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->Name; break; case detDate: name = ((TPDocDate *)ip->IPElement)->Name; break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->Name; break; case detImage: name = ((TPDocImage *)ip->IPElement)->Name; break; // by altang image } if (name.Length()> 0) { if (str.operator ==(name)) { return false; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckField_Input(WideString str, TPDocElement *s, TPDocInput *ip) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { WideString name = ""; if (s) { if (s == ip->IPElement) // if two Elements are same, don't need to check... return true; } switch (ip->IPElement->Type) { /* case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->FieldName; break; */ case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB name = ((TPDocNumber *)ip->IPElement)->FieldName; break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->FieldName; break; case detDate: name = ((TPDocDate *)ip->IPElement)->FieldName; break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->FieldName; break; } if (name.Length()> 0) { if (str.operator ==(name)) { return false; } } return true; } //--------------------------------------------------------------------------- int __fastcall TPDocSheet::GetFieldCount_Input(TPDocInput *ip)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { TPDocElement *sep = ip->IPElement; switch (ip->IPElement->Type) { /* case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->FieldName; break; */ case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: case detFormula: case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0)return 1; break; } return 0; } //--------------------------------------------------------------------------- /* AnsiString __fastcall TPDocSheet::GetFieldValue_Input(int SheetNum, TPDocInput *ip)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { TPDocElement *sep = ip->IPElement; AnsiString SheetNumStr=SheetNum; // switch (ip->IPElement->Type) { switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->FieldName; break; case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocEdit *)sep)->K_Text; return ((TPDocEdit *)sep)->K_Text; } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocNumber *)sep)->Number; return ((TPDocNumber *)sep)->Number; } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocFormula *)sep)->ANumber; return ((TPDocFormula *)sep)->ANumber; } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocDate *)sep)->Date; return ((TPDocDate *)sep)->Date; } break; } return ""; } //--------------------------------------------------------------------------- */ // by altang WideString __fastcall TPDocSheet::GetFieldValue_Input(int SheetNum, TPDocInput *ip)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { TPDocElement *sep = ip->IPElement; WideString SheetNumStr = (WideString) _itow(SheetNum,SheetNumStr,10); // switch (ip->IPElement->Type) { switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->FieldName; break; */ case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocEdit *)sep)->K_Text; return ((TPDocEdit *)sep)->K_Text; } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocNumber *)sep)->Number; return ((TPDocNumber *)sep)->Number; } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocFormula *)sep)->ANumber; return ((TPDocFormula *)sep)->ANumber; } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ // return SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocDate *)sep)->Date; return ((TPDocDate *)sep)->Date; } break; } return ""; } //--------------------------------------------------------------------------- RECT* __fastcall TPDocSheet::GetFieldRange_Input(int SheetNum, TPDocInput *ip)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { TPDocElement *sep = ip->IPElement; AnsiString SheetNumStr=SheetNum; RECT * Temp; // switch (ip->IPElement->Type) { switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->FieldName; break; */ case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+ip->Range.left; Temp->right = sep->Range.right+ip->Range.left; Temp->top = sep->Range.top+ip->Range.top; Temp->bottom = sep->Range.bottom+ip->Range.top; return Temp; } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+ip->Range.left; Temp->right = sep->Range.right+ip->Range.left; Temp->top = sep->Range.top+ip->Range.top; Temp->bottom = sep->Range.bottom+ip->Range.top; return Temp; } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+ip->Range.left; Temp->right = sep->Range.right+ip->Range.left; Temp->top = sep->Range.top+ip->Range.top; Temp->bottom = sep->Range.bottom+ip->Range.top; return Temp; } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+ip->Range.left; Temp->right = sep->Range.right+ip->Range.left; Temp->top = sep->Range.top+ip->Range.top; Temp->bottom = sep->Range.bottom+ip->Range.top; return Temp; } break; } return NULL; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocSheet::CheckField_Chart(AnsiString str, TPDocElement *s, TPDocChart *cp) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i, cnt; AnsiString name = ""; TPDocElement *sep; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; if (s) { if (s == sep) // if two Elements are same, don't need to check... // return true; continue; } switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)sep)->FieldName; break; case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB name = ((TPDocNumber *)sep)->FieldName; break; case detFormula: name = ((TPDocFormula *)sep)->FieldName; break; case detDate: name = ((TPDocDate *)sep)->FieldName; break; case detEdit: name = ((TPDocEdit *)sep)->FieldName; break; } if (name.Length()> 0) { if (str.AnsiCompare(name) == 0) { return false; } name=""; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckName_Chart(AnsiString str, TPDocElement *s, TPDocChart *cp) { int i, cnt; AnsiString name = ""; TPDocElement *sep; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; if (s) { if (s == sep) // if two Elements are same, don't need to check... continue; } switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)sep)->Name; break; case detNumber: name = ((TPDocNumber *)sep)->Name; break; case detFormula: name = ((TPDocFormula *)sep)->Name; break; case detDate: name = ((TPDocDate *)sep)->Name; break; case detEdit: name = ((TPDocEdit *)sep)->Name; break; } if (name.Length()> 0) { if (str.AnsiCompare(name) == 0) { return false; } name=""; } } return true; } //--------------------------------------------------------------------------- */ bool __fastcall TPDocSheet::CheckField_Chart(WideString str, TPDocElement *s, TPDocChart *cp) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i, cnt; WideString name = ""; TPDocElement *sep; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; if (s) { if (s == sep) // if two Elements are same, don't need to check... // return true; continue; } switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)sep)->FieldName; break; */ case detNumber: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB name = ((TPDocNumber *)sep)->FieldName; break; case detFormula: name = ((TPDocFormula *)sep)->FieldName; break; case detDate: name = ((TPDocDate *)sep)->FieldName; break; case detEdit: name = ((TPDocEdit *)sep)->FieldName; break; // TPDocImage, TPDocMemo, TPDocColorChip¿¡µµ Field¼³Á¤ °¡´ÉÇÏ°Ô (2007. 08. 08 Annualring) case detImage: name = ((TPDocImage *)sep)->FieldName; break; case detMemo: name = ((TPDocMemo *)sep)->FieldName; break; // case detColorChip: // name = ((TPDocColorChip *)sep)->FieldName; break; } if (name.Length()> 0) { if (str.operator ==(name)) { return false; } name=""; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::CheckName_Chart(WideString str, TPDocElement *s, TPDocChart *cp) { int i, cnt; WideString name = ""; TPDocElement *sep; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; if (s) { if (s == sep) // if two Elements are same, don't need to check... continue; } switch (sep->Type) { /* case detColorChip: name = ((TPDocColorChip *)sep)->Name; break; */ case detNumber: name = ((TPDocNumber *)sep)->Name; break; case detFormula: name = ((TPDocFormula *)sep)->Name; break; case detDate: name = ((TPDocDate *)sep)->Name; break; case detEdit: name = ((TPDocEdit *)sep)->Name; break; case detImage: name = ((TPDocImage *)sep)->Name; break; //by altang image } if (name.Length()> 0) { if (str.operator ==(name)) { return false; } name=""; } } return true; } //--------------------------------------------------------------------------- int __fastcall TPDocSheet::GetFieldCount_Chart(TPDocChart *cp)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i, cnt; int nResult = 0; TPDocElement *sep; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; switch (sep->Type) { case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: case detFormula: case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0) nResult++; break; } } return nResult; } //--------------------------------------------------------------------------- TStringList * __fastcall TPDocSheet::GetFieldValue_Chart(int SheetNum, TStringList* ResultList, TPDocChart *cp)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i, cnt; int nResult = 0; TPDocElement *sep; AnsiString SheetNumStr=SheetNum; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; switch (sep->Type) { case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ // ResultList->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocEdit *)sep)->K_Text); ResultList->Add(((TPDocEdit *)sep)->K_Text); // by altang } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ // ResultList->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocNumber *)sep)->Number); ResultList->Add(((TPDocNumber *)sep)->Number); } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ // ResultList->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocFormula *)sep)->ANumber); ResultList->Add(((TPDocFormula *)sep)->ANumber); } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ // ResultList->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocDate *)sep)->Date); ResultList->Add(((TPDocDate *)sep)->Date); } break; } } return ResultList; } //--------------------------------------------------------------------------- TList * __fastcall TPDocSheet::GetFieldRange_Chart(int SheetNum, TList* ResultList, TPDocChart *cp)//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { int i, cnt; int nResult = 0; TPDocElement *sep; RECT * Temp; AnsiString SheetNumStr=SheetNum; cnt = cp->Cell->Count; for (i=0; iCell->Items[i]; switch (sep->Type) { case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+cp->Range.left; Temp->right = sep->Range.right+cp->Range.left; Temp->top = sep->Range.top+cp->Range.top; Temp->bottom = sep->Range.bottom+cp->Range.top; ResultList->Add(Temp); } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+cp->Range.left; Temp->right = sep->Range.right+cp->Range.left; Temp->top = sep->Range.top+cp->Range.top; Temp->bottom = sep->Range.bottom+cp->Range.top; ResultList->Add(Temp); } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+cp->Range.left; Temp->right = sep->Range.right+cp->Range.left; Temp->top = sep->Range.top+cp->Range.top; Temp->bottom = sep->Range.bottom+cp->Range.top; ResultList->Add(Temp); } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ Temp = new RECT; Temp->left = sep->Range.left+cp->Range.left; Temp->right = sep->Range.right+cp->Range.left; Temp->top = sep->Range.top+cp->Range.top; Temp->bottom = sep->Range.bottom+cp->Range.top; ResultList->Add(Temp); } break; } } return ResultList; } //--------------------------------------------------------------------------- TFont *__fastcall TPDocSheet::GetFont() { return FFont; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetFont(TFont *font, TColor color) { FFont->Assign(font); // FFont->Color = color; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::RemoveDataWithoutUndoSave(TPDocElement *dp) { Element->Remove(dp); delete dp; dp = NULL; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::RemoveData(TPDocElement *dp) { ElementUndoSave(); //For Undo UndoSave(this); //for Undo DeleteUndoSave(dp); //for Undo Element->Remove(dp); // delete dp; //block for UndoError¼öÁ¤. } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::RemoveData() { TPDocElement *dp; if(Element->Count){ ElementUndoSave(); //For Undo UndoSave(this); //for Undo } while (Element->Count) { dp = (TPDocElement *)Element->First(); Element->Remove(dp); DeleteUndoSave(dp); //for Undo // delete dp; //for Undo } ResetFIDCount(); // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) ResetFIDCountForSheet(); } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::PaintDesign(TPDocObject *Sender,HDC hDC, TPDocViewStatus &vs,bool bPrint, bool bSelect,int language, bool paintID) { return; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::LoadFromFile(HANDLE hFile, int Version) { int i, n; TPDocElement *dp; DWORD dwRead; TPDocElementType Type; RECT rc; TPDocLineStyle fstyle = dlsNone; TPDocBorder border; //TColor fc; TPDocFrameColor fc; TextVersion = Version; bool visible = true; #ifdef IVY_CONVERT2 int count1 = 0, count2 = 0; RECT tRange; #endif if (!TextLoadFromFile(hFile, Title)) return false; if (!ReadFile(hFile, &DotsPerInch, sizeof(int), &dwRead, NULL)) return false; if (DotsPerInch < 0) return false; //¿¡·¯Ã³¸®¸¦ À§Çؼ­ Ãß°¡ david 100127 if (!ReadFile(hFile, &rc, sizeof(RECT), &dwRead, NULL)) return false; Range = rc; if (!ReadFile(hFile, &FOrientation, sizeof(TPrinterOrientation), &dwRead, NULL)) return false; if (!ReadFile(hFile, &SheetType, sizeof(TPDocSheetType), &dwRead, NULL)) return false; if (!ReadFile(hFile, &n, sizeof(int), &dwRead, NULL)) return false; if (Version >= 5) if (!ReadFile(hFile, &XIndexCount, sizeof(int), &dwRead, NULL)) return false; if (Version >= 8) if (!ReadFile(hFile, &YIndexCount, sizeof(int), &dwRead, NULL)) return false; for (i = 0; i < n; i++) { if (!ReadFile(hFile, &Type, sizeof(TPDocElementType), &dwRead, NULL)) return false; if (int(Type) < 0) return false; //0º¸´Ù ÀÛÀº °ªÀÌ µé¾î°¡¸é ¿¡·¯´Ù. if (!ReadFile(hFile, &rc, sizeof(RECT), &dwRead, NULL)) return false; if (Version < 8) { if (!ReadFile(hFile, &fstyle, sizeof(TPDocLineStyle), &dwRead, NULL)) return false; if (fstyle != dlsNone) { TColor tempColor; if (!ReadFile(hFile, &fc, sizeof(TColor), &dwRead, NULL)) return false; fc.left = tempColor; fc.left = tempColor; fc.right = tempColor; fc.bottom = tempColor; } switch (Type) { case detLine: dp = new TPDocLine(this, rc); break; case detBox: dp = new TPDocBox(this, rc); break; case detColorChip: dp = new TPDocColorChip(this, rc); break; case detSignature: dp = new TPDocSignature(this, rc); break; case detNumber: dp = new TPDocNumber(this, rc); break; case detFormula: dp = new TPDocFormula(this, rc); break; case detDate: dp = new TPDocDate(this, rc); break; case detLabel: dp = new TPDocLabel(this, rc); break; case detEdit: dp = new TPDocEdit(this, rc); break; case detMemo: dp = new TPDocMemo(this, rc); break; case detImage: dp = new TPDocImage(this, rc); break; case detInput: dp = new TPDocInput(this, rc); break; case detChart: dp = new TPDocChart(this, rc); break; case detArrow: dp = new TPDocArrow(this, rc); break; case detSheafImage: dp = new TPDocSheafImage(this, rc); break; case detSheafLabel: dp = new TPDocSheafLabel(this, rc); break; case detTextImage: dp = new TPDocTextImage(this, rc); break; case detSheafLine: dp = new TPDocSheafLine(this, rc); break; case detNone: dp = NULL; break; default: dp = NULL; break; } if (dp) { dp->FrameStyle.left = fstyle; dp->FrameStyle.top = fstyle; dp->FrameStyle.right = fstyle; dp->FrameStyle.bottom = fstyle; if (fstyle != dlsNone) { // if fstyle == dslNone, what I do for FrameColor ??????? dp->FrameColor = fc; } dp->bVisible = visible; } } else { //if (!ReadFile(hFile, &border, sizeof(TPDocBorder), &dwRead, NULL)) return false; //if (!ReadFile(hFile, &fc, sizeof(TColor), &dwRead, NULL)) return false; switch (Type) { case detLine: dp = new TPDocLine(this, rc); break; case detBox: dp = new TPDocBox(this, rc); break; case detColorChip: dp = new TPDocColorChip(this, rc); break; case detSignature: dp = new TPDocSignature(this, rc); break; case detNumber: dp = new TPDocNumber(this, rc); break; case detFormula: dp = new TPDocFormula(this, rc); break; case detDate: dp = new TPDocDate(this, rc); break; case detLabel: dp = new TPDocLabel(this, rc); break; case detEdit: dp = new TPDocEdit(this, rc); break; case detMemo: dp = new TPDocMemo(this, rc); break; case detImage: dp = new TPDocImage(this, rc); break; case detInput: dp = new TPDocInput(this, rc); break; case detChart: dp = new TPDocChart(this, rc); break; case detArrow: dp = new TPDocArrow(this, rc); break; case detSheafImage: dp = new TPDocSheafImage(this, rc); break; case detSheafLabel: dp = new TPDocSheafLabel(this, rc); break; case detTextImage: dp = new TPDocTextImage(this, rc); break; case detSheafLine: dp = new TPDocSheafLine(this, rc); break; case detThumbnailImage: dp = new TPDocThumbnailImage(this, rc); //by linuxjun for À¯½ºÇÏÀÌÅØ //¾ÆÀ̺ñŬ·´¿¡¼­ ÆÄÀÏ ÄÁ¹öÆ®¸¦ ¿äÃ»ÇØ¼­ Ãß°¡ ÇÑ ³»¿ë - 20120522 //±âÁ¸ ¹öÀü¿¡¼­´Â JpgÀúÀå ¿µ¿ªÀÌ Thumbnail ¿µ¿ªÀ̾ú´Ù. µû¶ó¼­ ÃֽйöÀü¿¡¼­ //±âÁ¸ ÆÄÀÏÀ» ¿­¾î ÀúÀåÇϸé jpg ÆÄÀÏÀÌ ÀúÀåµÇÁö ¾Ê´Â ¹®Á¦°¡ ¹ß»ýÇØ¼­ ±âÁ¸ ÆÄÀÏÀ» //¿­¸é ÀÚµ¿À¸·Î jpg ¿µ¿ªÀ» °°Àº Å©±â·Î ¸¸µé¾î ÁÖµµ·Ï ó¸®Çß´Ù. //ÄÁ¹öÆ® ÇÏÁö ¾ÊÀº ÆÄÀϵµ ó¸®Çϱâ À§Çؼ­ ¾ÆÀ̺ñŬ·´ Àü¿ë¿¡ Æ÷ÇÔ #ifdef IVY_CONVERT2 count1++; #endif break; case detThumbnailImageJPG: dp = new TPDocThumbnailImageJPG(this, rc); //by linuxjun for À¯½ºÇÏÀÌÅØ #ifdef IVY_CONVERT2 count2++; #endif break; case detNone: dp = NULL; break; default: dp = NULL; break; } //dp->FrameColor = fc; } if (dp) { if (!dp->LoadFromFile(hFile, Version)) return false; Element->Add(dp); } #ifdef IVY_CONVERT2 if (Type == detThumbnailImage) { tRange = dp->Range; } #endif } #ifdef IVY_CONVERT2 if (count1 && count2 == 0) { dp = new TPDocThumbnailImageJPG(this, rc); dp->Range = tRange; Element->Add(dp); } #endif SetCursorIndex(); // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) SetFIDCount(); // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) SetFIDCountForSheet(); return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::SaveToFile(HANDLE hFile) { int i, n; TPDocElement *dp; DWORD dwWrite; if (!TextSaveToFile(hFile, Title)) return false; if (!WriteFile(hFile, &DotsPerInch, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &Range, sizeof(RECT), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &FOrientation, sizeof(TPrinterOrientation), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &SheetType, sizeof(TPDocSheetType), &dwWrite, NULL)) return false; n = Element->Count; if (!WriteFile(hFile, &n, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &XIndexCount, sizeof(int), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &YIndexCount, sizeof(int), &dwWrite, NULL)) return false; for (i = 0; i < n; i++) { dp = (TPDocElement *)Element->Items[i]; if (!WriteFile(hFile, &dp->Type, sizeof(TPDocElementType), &dwWrite, NULL)) return false; if (!WriteFile(hFile, &dp->Range, sizeof(RECT), &dwWrite, NULL)) return false; //qe if (!WriteFile(hFile, &dp->FrameStyle, sizeof(TPDocBorder), &dwWrite, NULL)) return false; // if (!WriteFile(hFile, &dp->FrameColor, sizeof(TColor), &dwWrite, NULL)) return false; dp->bSaveAsSmallImage = bSaveAsSmallImage; //À̹ÌÁö »çÀÌÁî ÀÛ°Ô ÀúÀåÇϱâ À§Çؼ­ Ãß°¡ by altang 07.04.16. if (!dp->SaveToFile(hFile)) return false; } Modify=false; return true; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocSheet::LoadFromFile(AnsiString Filename) { HANDLE hFile = INVALID_HANDLE_VALUE; int version; DWORD dwRead; RemoveData(); if ((hFile = CreateFile(Filename.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; // dwFileSize = GetFileSize(hFile, NULL); // if ((hFileMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, dwFileSize, // NULL)) == NULL) goto fail; if (!ReadFile(hFile, &version, sizeof(int), &dwRead, NULL)) goto fail; if (!LoadFromFile(hFile, version)) goto fail; CloseHandle(hFile); SetFIDCount(); return true; fail: RemoveData(); if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); return false; } //--------------------------------------------------------------------------- */ /// sheet ÆÄÀÏÀ» ¿­¶§ ºÒ·ÁÁø´Ù. /** file version 16 ÀÌÈĺÎÅÍ ¹öÀü Á¤º¸¸¦ version º¯¼ö¾È¿¡ ³Ö¾îÁÖ´Â ºÎºÐÀÌ Ãß°¡µÇ¾ú´Ù. */ bool __fastcall TPDocSheet::LoadFromFile(WideString Filename) { HANDLE hFile = INVALID_HANDLE_VALUE; int version; DWORD dwRead; RemoveData(); if ((hFile = CreateFileW(Filename.c_bstr(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; // dwFileSize = GetFileSize(hFile, NULL); // if ((hFileMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, dwFileSize, // NULL)) == NULL) goto fail; if (!ReadFile(hFile, &version, sizeof(int), &dwRead, NULL)) goto fail; TextVersion = version; this->version = version; if (!LoadFromFile(hFile, version)) goto fail; CloseHandle(hFile); SetFIDCount(); // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) SetFIDCountForSheet(); return true; fail: RemoveData(); if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); return false; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocSheet::SaveToFile(AnsiString Filename) { HANDLE hFile = INVALID_HANDLE_VALUE; // int version = 0; // int version = 1; // int version = 2; // 1--->2 In TPDocInput, to save Method and ImageDir; // int version = 3; // 2--->3 In Number & Formula, to save type of number (decimal or fraction); // int version = 4; // 3--->4 In Date, SYSTEMTIME--> Replace with AnsiString // int version = 5; // 4--->5 For Index // int version = 6; // 5--->6 For Index Number and Formula // int version = 7; //6--->7 For Formula Data // int version = 8; //7--->8 For Chart and etc...by qe(2002.1) // int version = 9; //8->9 For Dat3PointArrow // int version = 10; //10->11 For Dat3PointArrow // int version = 11; //11->12 For À¯½ºÇÏÀÌÅØ dll°ü·Ã ThumnailÀ̹ÌÁö Ãß°¡¸¦ À§ÇÔ. // int version = 12, n, i; //12->13 For À¯½ºÇÏÀÌÅØ DB¿ë TextÈ­ÀÏÀ» À§ÇÑ Field°ª ÀúÀåÀ» À§ÇÔ //for ¾ÆÀ̺ñ // int version = 13, n, i; //13->14 For À¯½ºÇÏÀÌÅØ ±×¸²¿¡ ±ÛÀÚ ¾Èº¸ÀÌ°Ô ÇϱâÀ§ÇÔ//for ¾ÆÀ̺ñ // int version = 14, n, i; //13->14 For ¾ÆÀ̺ñ È­»ìÇ¥¿¡ ±ÛÀÚ ³Ö´Â À§Ä¡ Á¶ÀýÀ» À§ÇØ int version = 15, n, i; //14->15 À¯½ºÇÏÀÌÅØ DB¿ë TextÈ­ÀÏÀ» À§ÇÑ Field°ª ÀúÀåÀ» À§ÇÔ //for ¾ÆÀ̺ñ DWORD dwWrite; if ((hFile = CreateFile(Filename.c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; if (!WriteFile(hFile, &version, sizeof(int), &dwWrite, NULL)) goto fail; Title = ExtractFileName(Filename); if (!SaveToFile(hFile)) goto fail; CloseHandle(hFile); return true; fail: if (hFile!=INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(Filename.c_str()); } return false; } bool __fastcall TPDocSheet::SaveThumbnailImage(HANDLE hFile, TPDocThumbnailImage *dp) { TTexpiaBitmap *ThumbnailImage; TTexpiaBitmap *tempImage; bool result; DWORD dwWrite; //if ((Pattern = new TTexpiaBitmap)==NULL) goto fail; ThumbnailImage = NULL; tempImage = NULL; tempImage = new TTexpiaBitmap; //To Do ´Ù±¹¾î Áö¿øÀÌ °¡´ÉÇϵµ·Ï ³ªÁß¿¡ lang °ª¿¡ ´ëÇÑ Ã³¸®ºÎºÐÀ» ¸¸µé¾îÁÖ¾î¾ßÇÔ. result=PaintToBitmap(tempImage, 0, true); //Korean -> 0 if(result){ ThumbnailImage = new TTexpiaBitmap; ThumbnailImage->Create(dp->Range.right - dp->Range.left, dp->Range.bottom - dp->Range.top, 24); ThumbnailImage->Copy(0,0,dp->Range.right - dp->Range.left, dp->Range.bottom - dp->Range.top, tempImage, dp->Range.left, dp->Range.top, SRCCOPY); if (!WriteFile(hFile, &result, sizeof(bool), &dwWrite, NULL)) return false; //errorÇڵ鸵À» À§ÇØ if (!ImageSaveToFile(hFile, ThumbnailImage)) return false; }else{ if (!WriteFile(hFile, &result, sizeof(bool), &dwWrite, NULL)) return false; return false; } if(ThumbnailImage){delete ThumbnailImage; ThumbnailImage = NULL;} if(tempImage){delete tempImage; tempImage = NULL;} return true; } //--------------------------------------------------------------------------- */ bool __fastcall TPDocSheet::SaveToFile(WideString Filename) { HANDLE hFile = INVALID_HANDLE_VALUE; // int version = 0; // int version = 1; // int version = 2; // 1--->2 In TPDocInput, to save Method and ImageDir; // int version = 3; // 2--->3 In Number & Formula, to save type of number (decimal or fraction); // int version = 4; // 3--->4 In Date, SYSTEMTIME--> Replace with AnsiString // int version = 5; // 4--->5 For Index // int version = 6; // 5--->6 For Index Number and Formula // int version = 7; //6--->7 For Formula Data // int version = 8; //7--->8 For Chart and etc...by qe(2002.1) // int version = 9; //8->9 For Dat3PointArrow // int version = 10; //10->11 For Dat3PointArrow // int version = 11; //11->12 For À¯½ºÇÏÀÌÅØ dll°ü·Ã ThumnailÀ̹ÌÁö Ãß°¡¸¦ À§ÇÔ. // int version = 12, n, i; //12->13 For À¯½ºÇÏÀÌÅØ DB¿ë TextÈ­ÀÏÀ» À§ÇÑ Field°ª ÀúÀåÀ» À§ÇÔ //for ¾ÆÀ̺ñ // int version = 13, n, i; //13->14 For À¯½ºÇÏÀÌÅØ ±×¸²¿¡ ±ÛÀÚ ¾Èº¸ÀÌ°Ô ÇϱâÀ§ÇÔ//for ¾ÆÀ̺ñ // int version = 14, n, i; //13->14 For ¾ÆÀ̺ñ È­»ìÇ¥¿¡ ±ÛÀÚ ³Ö´Â À§Ä¡ Á¶ÀýÀ» À§ÇØ // int version = 15, n, i; //14->15 À¯½ºÇÏÀÌÅØ DB¿ë TextÈ­ÀÏÀ» À§ÇÑ Field°ª ÀúÀåÀ» À§ÇÔ //for ¾ÆÀ̺ñ // version 16 // 15->16 À¯´ÏÄÚµå Áö¿ø ¹æ½ÄÀ¸·Î º¯°æ int version = this->version; if(version < 15){ SaveVersion = 15; version = 15; } else SaveVersion = version; this->version = this->oldversion; int n, i; //15->16 À¯´ÏÄÚµå Áö¿ø DWORD dwWrite; if ((hFile = CreateFileW(Filename.c_bstr(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; if (!WriteFile(hFile, &SaveVersion, sizeof(int), &dwWrite, NULL)) goto fail; Title = ExtractFileNameW(Filename); if (!SaveToFile(hFile)) goto fail; CloseHandle(hFile); return true; fail: if (hFile!=INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(Filename.c_bstr()); } return false; } bool __fastcall TPDocSheet::SaveThumbnailImage(HANDLE hFile, TPDocThumbnailImage *dp) { TTexpiaBitmap *ThumbnailImage = NULL; TTexpiaBitmap *tempImage = NULL; TTexpiaBitmap *saveImage = NULL; //Image ºñÀ²À» ¸ÂÃß±â À§ÇÑ Àӽà Bitmap bool result; DWORD dwWrite; //if ((Pattern = new TTexpiaBitmap)==NULL) goto fail; ThumbnailImage = NULL; tempImage = NULL; tempImage = new TTexpiaBitmap; //saveImage ÃʱâÈ­ RECT rect; #ifndef ELLITE_BASIC saveImage = new TTexpiaBitmap; saveImage->Create(200,200,24); rect.top=0; rect.left=0; rect.right=200; rect.bottom=200; saveImage->Create(rect.right,rect.bottom,24); saveImage->FillRect(rect,RGB(255,255,255)); #endif //To Do ´Ù±¹¾î Áö¿øÀÌ °¡´ÉÇϵµ·Ï ³ªÁß¿¡ lang °ª¿¡ ´ëÇÑ Ã³¸®ºÎºÐÀ» ¸¸µé¾îÁÖ¾î¾ßÇÔ. result=PaintToBitmap(tempImage, 0, true); //Korean -> 0 if(result){ ThumbnailImage = new TTexpiaBitmap; ThumbnailImage->Create(dp->Range.right - dp->Range.left, dp->Range.bottom - dp->Range.top, 24); ThumbnailImage->Copy(0,0,dp->Range.right - dp->Range.left, dp->Range.bottom - dp->Range.top, tempImage, dp->Range.left, dp->Range.top, SRCCOPY); if (!WriteFile(hFile, &result, sizeof(bool), &dwWrite, NULL)) goto fail; //errorÇڵ鸵À» À§ÇØ #ifndef ELLITE_BASIC //ThubmnailImageÀÇ ºñÀ²ÀÌ º¯°æµÇÁö ¾Êµµ·Ï ó¸® 07.04.25. by altang if(ThumbnailImage->Width >= ThumbnailImage->Height){ ThumbnailImage->ResizeStretch(200,(200*ThumbnailImage->Height)/ThumbnailImage->Width,true); saveImage->CopyToRect(0,(200-ThumbnailImage->Height)/2,ThumbnailImage,SRCCOPY); } else{ ThumbnailImage->ResizeStretch((200*ThumbnailImage->Width)/ThumbnailImage->Height,200,true); saveImage->CopyToRect((200-ThumbnailImage->Width)/2,0,ThumbnailImage,SRCCOPY); } // Image ÀúÀåºÎºÐ if (!ImageSaveToFile(hFile, saveImage)) goto fail; #else //ELLITE_BASIC¿¡¼­´Â ThumbnailÀ̹ÌÁö¸¦ ¾îÆÐ·²º£À̽º¿Í ¿¬µ¿Çؼ­ ERP¿¡¼­ »ç¿ëÀ» ÇÑ´Ù. //V3.4ºÎÅÍ »ç¿ëÀ» Çϰí ÀÖÀ¸¸ç ThumbnailÀ̹ÌÁö°¡ ÁöÁ¤ÇÑ Å©±â¸¸Å­ ÀúÀåÇØ¼­ °¡Áö°í ÀÖ¾î¾ß ÇÑ´Ù. //ERP¿¡¼­ ÀÌ À̹ÌÁö¸¦ ÀÌ¿ëÇÏ¿© È­¸é¿¡ Ç¥½ÃÇϱ⠶§¹®ÀÌ´Ù. by david 2012.1.18 // Image ÀúÀåºÎºÐ if (!ImageSaveToFile(hFile, ThumbnailImage)) goto fail; #endif } else{ if (!WriteFile(hFile, &result, sizeof(bool), &dwWrite, NULL)) goto fail; goto fail; } if(ThumbnailImage){delete ThumbnailImage; ThumbnailImage = NULL;} if(tempImage){delete tempImage; tempImage = NULL;} if(saveImage){delete saveImage; saveImage = NULL;} return true; fail: if(ThumbnailImage){delete ThumbnailImage; ThumbnailImage = NULL;} if(tempImage){delete tempImage; tempImage = NULL;} if(saveImage){delete saveImage; saveImage = NULL;} return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::PaintToBitmap(TTexpiaBitmap *Pattern, int lan, bool bSaveJPG) { TPDocSheet *TempSheet; TPDocViewStatus vs; TPDocElement *ep; HDC pDC = NULL; TempSheet = this; Pattern->Create(TempSheet->Range.right, TempSheet->Range.bottom, 24); // Pattern->DotsPerInch = TempSheet->DotsPerInch; Pattern->FillRect(TempSheet->Range, clWhite); if ((pDC = Pattern->CreateDC()) == NULL) goto fail; for (int k=0; kElement->Count; k++) { ep = (TPDocElement *)TempSheet->Element->Items[k]; ep->PaintForm(pDC, &vs); //20141023 ¿¡¸®Æ®¿¡¼­ 2013³âµµ¿¡ ¿äûÇÑ ³»¿ëÀ» ´Ù½Ã ¼öÁ¤ÇØ ´Þ¶ó°í ÇÔ. #ifdef ELLITE_BASIC if (ep->Type == detArrow || ep->Type == detSheafLabel) continue; #else if (ep->Type == detArrow || ep->Type == detSheafLabel || ep->Type == detSheafLine) continue; #endif ep->PaintReport((TPDocObject *)TempSheet, pDC, vs, true, false, lan, bSaveJPG); } //To Do :VecDraw->PrintDraw°ü·Ã ÇÔ¼ö Æ÷ÀÎÅÍ ¸¸µé°Í FOnPaintVector(pDC, vs.Position.x, vs.Position.y, 160, 160, TempSheet->DotsPerInch, TempSheet); //for À¯½ºÇÏÀÌÅØ // VecDraw->PrintDraw(pDC, vs.Position.x, vs.Position.y, 160, 160, TempSheet->DotsPerInch, TempSheet); //Vector ¶§¹®¿¡ È­»ìÇ¥°¡ Áö¿öÁö´Â ¹®Á¦·Î ´Ù½Ã ±×¸² for (int k=0; kElement->Count; k++) { ep = (TPDocElement *)TempSheet->Element->Items[k]; #ifdef ELLITE_BASIC if (ep->Type == detSheafLabel) { #else if (ep->Type == detSheafLabel || ep->Type == detSheafLine) { #endif ep->PaintReport((TPDocObject *)TempSheet, pDC, vs, true, false, lan, bSaveJPG); } else if (ep->Type == detArrow) { ep->PaintReport((TPDocObject *)TempSheet, pDC, vs, false, false, lan, bSaveJPG); } } if (pDC) Pattern->DeleteDC(pDC); // Pattern->DotsPerInch = TempSheet->DotsPerInch; return true; fail: if (pDC) Pattern->DeleteDC(pDC); return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::Copy(TPDocSheet *src) { TPDocElement *dp, *sp; Title = src->Title; DotsPerInch = src->DotsPerInch; Range = src->Range; FOrientation = src->Orientation; SheetType = src->SheetType; XIndexCount = src->XIndexCount; YIndexCount = src->YIndexCount; for (int i = 0; i < src->Element->Count; i++) { sp = (TPDocElement *)src->Element->Items[i]; switch (sp->Type) { case detLine: dp = new TPDocLine(this, sp->Range); if (!((TPDocLine *)dp)->Copy((TPDocLine *)sp)) return false; Element->Add(dp); break; case detBox: dp = new TPDocBox(this, sp->Range); if (!((TPDocBox *)dp)->Copy((TPDocBox *)sp)) return false; Element->Add(dp); break; case detColorChip: dp = new TPDocColorChip(this, sp->Range); if (!((TPDocColorChip *)dp)->Copy((TPDocColorChip *)sp)) return false; Element->Add(dp); break; case detSignature: dp = new TPDocSignature(this, sp->Range); if (!((TPDocSignature *)dp)->Copy((TPDocSignature *)sp)) return false; Element->Add(dp); break; case detNumber: dp = new TPDocNumber(this, sp->Range); if (!((TPDocNumber *)dp)->Copy((TPDocNumber *)sp)) return false; Element->Add(dp); break; case detFormula: dp = new TPDocFormula(this, sp->Range); if (!((TPDocFormula *)dp)->Copy((TPDocFormula *)sp)) return false; Element->Add(dp); break; case detDate: dp = new TPDocDate(this, sp->Range); if (!((TPDocDate *)dp)->Copy((TPDocDate *)sp)) return false; Element->Add(dp); break; case detLabel: dp = new TPDocLabel(this, sp->Range); if (!((TPDocLabel *)dp)->Copy((TPDocLabel *)sp)) return false; Element->Add(dp); break; case detEdit: dp = new TPDocEdit(this, sp->Range); if (!((TPDocEdit *)dp)->Copy((TPDocEdit *)sp)) return false; Element->Add(dp); break; case detMemo: dp = new TPDocMemo(this, sp->Range); if (!((TPDocMemo *)dp)->Copy((TPDocMemo *)sp)) return false; Element->Add(dp); break; case detImage: dp = new TPDocImage(this, sp->Range); if (!((TPDocImage *)dp)->Copy((TPDocImage *)sp)) return false; Element->Add(dp); break; case detInput: // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ // ¾Æ¿¹ InputÀ̶ó´Â °´Ã¼°¡ »ý±â´Â °ÍÀ» ¸·À½ (2007. 08. 16 Annualring) /* dp = new TPDocInput(this, sp->Range); if (!((TPDocInput *)dp)->Copy((TPDocInput *)sp)) return false; Element->Add(dp); */ break; case detChart: dp = new TPDocChart(this, sp->Range, daCenter2, 0, 0); if (!((TPDocChart *)dp)->Copy((TPDocChart *)sp)) return false; Element->Add(dp); break; case detArrow: dp = new TPDocArrow(this, sp->Range); if (!((TPDocArrow *)dp)->Copy((TPDocArrow *)sp)) return false; Element->Add(dp); break; case detSheafImage: dp = new TPDocSheafImage(this, sp->Range); if (!((TPDocSheafImage *)dp)->Copy((TPDocSheafImage *)sp)) return false; Element->Add(dp); break; case detSheafLabel: dp = new TPDocSheafLabel(this, sp->Range); if (!((TPDocSheafLabel *)dp)->Copy((TPDocSheafLabel *)sp)) return false; Element->Add(dp); break; case detTextImage: dp = new TPDocTextImage(this, sp->Range); if (!((TPDocTextImage *)dp)->Copy((TPDocTextImage *)sp)) return false; Element->Add(dp); break; case detSheafLine: dp = new TPDocSheafLine(this, sp->Range); if (!((TPDocSheafLine *)dp)->Copy((TPDocSheafLine *)sp)) return false; Element->Add(dp); break; } // Element->Add(dp); } SetCursorIndex(); return true; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::ResetFIDCount() { TPDocNumber::FIDCount = 0; TPDocFormula::FIDCount = 0; TPDocChart::FIDCount = 0; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::ResetFIDCountForSheet() { // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) NumberIDCount = 0; FormulaIDCount = 0; DateIDCount = 0; ChartIDCount = 0; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetFIDCount() { int nfid=0, ffid=0, cfid=0; int i, cnt, tcnt, k; TPDocElement *dp, *tp; TPDocInput *ip; TPDocChart *cp; cnt = Element->Count; for (i=0; iItems[i]; if (dp->Type == detNumber) { if (((TPDocNumber *)dp)->ID > nfid) nfid = ((TPDocNumber *)dp)->ID; } else if (dp->Type == detFormula) { if (((TPDocFormula *)dp)->ID > ffid) ffid = ((TPDocFormula *)dp)->ID; } else if (dp->Type == detInput) { tp = ((TPDocInput *)dp)->IPElement; if (tp->Type == detNumber) { if (((TPDocNumber *)tp)->ID > nfid) { nfid = ((TPDocNumber *)tp)->ID; } } else if (tp->Type == detFormula) { if (((TPDocFormula *)tp)->ID > ffid) { ffid = ((TPDocFormula *)tp)->ID; } } } else if (dp->Type == detChart) { cp = (TPDocChart *)dp; if (cp->ID > cfid) { cfid = cp->ID; } tcnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (tp->Type == detNumber) { if (((TPDocNumber *)tp)->ID > nfid) { nfid = ((TPDocNumber *)tp)->ID; } } else if (tp->Type == detFormula) { if (((TPDocFormula *)tp)->ID > ffid) { ffid = ((TPDocFormula *)tp)->ID; } } } } } // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) if (TPDocNumber::FIDCount < nfid) { TPDocNumber::FIDCount = nfid; } if (TPDocFormula::FIDCount < ffid) { TPDocFormula::FIDCount = ffid; } if (TPDocChart::FIDCount < cfid) { TPDocChart::FIDCount = cfid; } } //--------------------------------------------------------------------------- // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) void __fastcall TPDocSheet::SetFIDCountForSheet() { int nfid=0, ffid=0, cfid=0, dfid = 0;; int i, cnt, tcnt, k; TPDocElement *dp, *tp; TPDocInput *ip; TPDocChart *cp; cnt = Element->Count; for (i=0; iItems[i]; if (dp->Type == detNumber) { if (((TPDocNumber *)dp)->ID > nfid) nfid = ((TPDocNumber *)dp)->ID; } else if (dp->Type == detFormula) { if (((TPDocFormula *)dp)->ID > ffid) ffid = ((TPDocFormula *)dp)->ID; } else if (dp->Type == detDate) { if (((TPDocDate *)dp)->ID > dfid) dfid = ((TPDocDate *)dp)->ID; } else if (dp->Type == detInput) { tp = ((TPDocInput *)dp)->IPElement; if (tp->Type == detNumber) { if (((TPDocNumber *)tp)->ID > nfid) nfid = ((TPDocNumber *)tp)->ID; } else if (tp->Type == detFormula) { if (((TPDocFormula *)tp)->ID > ffid) ffid = ((TPDocFormula *)tp)->ID; } else if (tp->Type == detDate) { if (((TPDocDate *)tp)->ID > dfid) dfid = ((TPDocDate *)tp)->ID; } } else if (dp->Type == detChart) { cp = (TPDocChart *)dp; if (cp->ID > cfid) cfid = cp->ID; tcnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (tp->Type == detNumber) { if (((TPDocNumber *)tp)->ID > nfid) nfid = ((TPDocNumber *)tp)->ID; } else if (tp->Type == detFormula) { if (((TPDocFormula *)tp)->ID > ffid) ffid = ((TPDocFormula *)tp)->ID; } else if (tp->Type == detDate) { if (((TPDocDate *)tp)->ID > dfid) dfid = ((TPDocDate *)tp)->ID; } } } } // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) /* NumberIDCount = nfid; FormulaIDCount = ffid; ChartIDCount = cfid; */ // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 14 Annualring) if (NumberIDCount < nfid) { NumberIDCount = nfid; } if (FormulaIDCount < ffid) { FormulaIDCount = ffid; } if (DateIDCount < dfid) { DateIDCount = dfid; } if (ChartIDCount < cfid) { ChartIDCount = cfid; } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetRange(int w, int h) { Range = Rect(0, 0, w, h); } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::FindRange(RECT sr, RECT tr, POINT pt) { double sl, dl, mx1, mx2, my1, my2; //¸¶¿ì½º Ä¿¼­¿¡ ¿µ¿ªÀÇ Áß½ÉÀÌ °¡Àå °¡±î¿î °´Ã¼¸¦ ¼±ÅÃÇÑ´Ù. modified by qe mx1 = (sr.left + sr.right)/2; my1 = (sr.top + sr.bottom)/2; sl = (pt.x - mx1)*(pt.x - mx1) + (pt.y - my1)*(pt.y - my1); mx2 = (tr.left + tr.right)/2; my2 = (tr.top + tr.bottom)/2; dl = (pt.x - mx2)*(pt.x - mx2) + (pt.y - my2)*(pt.y - my2); return dl < sl; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SelectUndoSave(){ if(FUndoSave != NULL){ FUndoSave(UT_SELECTION); //UT_SELECTIONÀº 2 ·Î DefineµÇÀÖ´Ù. } } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::ElementUndoSave(){ if(FUndoSave != NULL){ return FUndoSave(UT_ELEMENT); //UT_ELEMENTÀº 16 ·Î DefineµÇÀÖ´Ù. } return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::ElementMoveUndoSave(){ if(FUndoSave != NULL){ return FUndoSave(UT_ELTMOVE); } return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::ElementSizeUndoSave(){ if(FUndoSave != NULL){ return FUndoSave(UT_ELTSIZE); } return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::ElementAddUndoSave(){ if(FUndoSave != NULL){ return FUndoSave(UT_ELTADD); } return false; } //--------------------------------------------------------------------------- /* TPDocElement *__fastcall TPDocSheet::Select(POINT pt, bool Design, bool bShift) { TPDocElement *dp, *tp = NULL; bool next = false; bShiftOnArrow = bShift; // SelectUndoSave(); //by linuxjun For Undo for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == detArrow) { if (dp->IsExist(pt)) { tp = dp; } } else if (dp->IsExist(pt)) { //===================== // ÀÛÀº ¿µ¿ªÀÇ °´Ã¼°¡ Å« °´Ã¼ÀÇ ¾È¿¡ ÀÖ´Â °æ¿ì... if (next) { if (Design) { if (FindRange(tp->Range, dp->Range, pt)) tp = dp; } else { if (tp == NULL) tp = dp; else if (dp->Type != detBox && FindRange(tp->Range, dp->Range, pt)) tp = dp; } } else { if (Design) tp = dp; else if (dp->Type != detBox) tp =dp; next = true; } //===================== } } return tp; } */ //--------------------------------------------------------------------------- // ¼±ÅÃÇÒ Element¸¦ ÀǹÌÇÏ´Â ¸Å°³º¯¼ö targetElement¸¦ Ãß°¡ // ¸í½ÃÀûÀ¸·Î Element¸¦ ¼±ÅÃÇÒ ¼ö ÀÖ°Ô ¸¸µë. (2007. 04. 16 Annualring) TPDocElement *__fastcall TPDocSheet::Select(POINT pt, bool Design, bool bShift) { TPDocElement *dp, *tp = NULL; bool next = false; bShiftOnArrow = bShift; // SelectUndoSave(); //by linuxjun For Undo for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == detArrow) { if (dp->IsExist(pt)) { tp = dp; } } } if(tp)return tp; for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == detArrow) { continue; }else if (dp->Type == detSheafImage){ if (dp->IsExist(pt)) { tp = dp; } } else if (dp->IsExist(pt)) { //===================== // ÀÛÀº ¿µ¿ªÀÇ °´Ã¼°¡ Å« °´Ã¼ÀÇ ¾È¿¡ ÀÖ´Â °æ¿ì... if (next) { if (Design) { if (FindRange(tp->Range, dp->Range, pt)) tp = dp; } else { if (tp == NULL) tp = dp; else if (dp->Type != detBox && FindRange(tp->Range, dp->Range, pt)) tp = dp; } } else { if (Design) tp = dp; else if (dp->Type != detBox) tp =dp; next = true; } //===================== } } return tp; } //--------------------------------------------------------------------------- // ¿ø·¡ÀÇ SelectÇÔ¼ö¿¡ ¼±ÅÃÇÒ Element¸¦ ÀǹÌÇÏ´Â ¸Å°³º¯¼ö targetElement¸¦ Ãß°¡ // ¸í½ÃÀûÀ¸·Î Element¸¦ ¼±ÅÃÇÒ ¼ö ÀÖ°Ô ¸¸µë. (2007. 04. 16 Annualring) TPDocElement *__fastcall TPDocSheet::ElementSelect(POINT pt, bool Design, bool bShift, TPDocElement *targetElement) { TPDocElement *dp, *tp = NULL; bool next = false; bShiftOnArrow = bShift; // SelectUndoSave(); //by linuxjun For Undo for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == detArrow) { if (dp->IsExist(pt)) { if (targetElement == NULL || dp == targetElement) { // (2007. 04. 16 Annualring) tp = dp; } } } } if(tp)return tp; for (int i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == detArrow) { continue; }else if (dp->Type == detSheafImage){ if (dp->IsExist(pt)) { if (targetElement == NULL || dp == targetElement) { // (2007. 04. 16 Annualring) tp = dp; } } } else if (dp->IsExist(pt)) { //===================== // ÀÛÀº ¿µ¿ªÀÇ °´Ã¼°¡ Å« °´Ã¼ÀÇ ¾È¿¡ ÀÖ´Â °æ¿ì... if (next) { if (Design) { if (FindRange(tp->Range, dp->Range, pt)) tp = dp; } else { if (tp == NULL) { if (targetElement == NULL || dp == targetElement) { // (2007. 04. 16 Annualring) tp = dp; } } else if (dp->Type != detBox && FindRange(tp->Range, dp->Range, pt)) { if (targetElement == NULL || dp == targetElement) { // (2007. 04. 16 Annualring) tp = dp; } } } } else { if (Design) { if (targetElement == NULL || dp == targetElement) { // (2007. 04. 16 Annualring) tp = dp; } } else if (dp->Type != detBox) { if (targetElement == NULL || dp == targetElement) { // (2007. 04. 16 Annualring) tp = dp; } } next = true; } //===================== } } return tp; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //================================ char ch, num[20]; // where do I declare ?? int pfp; Postfix *pf; //================================ char * __fastcall TPDocSheet::Constant() { int i = 0, m = 0, p = 0; while (1) { ch = pf->postfix[pfp]; if (!m && ch=='-') { pfp++; num[i++] = ch; } else if (!p && ch=='.') { pfp++; num[i++] = ch; p++; } else if (isdigit(ch)) { pfp++; num[i++] = ch; } else break; m++; } num[i] = 0; return num; } //--------------------------------------------------------------------------- char * __fastcall TPDocSheet::Variable() { int i = 0; while (ch=pf->postfix[pfp], isdigit(ch)) { pfp++; num[i++] = ch; } num[i] = 0; return num; } /*--------------------------------------------------------------------------- char * __fastcall TPDocSheet::FMsearch(TPDocElementType Type) { int i; TPDocElement *dp; for (i=0; iCount; i++) { dp = (TPDocElement *)Element->Items[i]; if (dp->Type == Type) { ; // yield(dp); What do I do?? } } } */ //--------------------------------------------------------------------------- void* __fastcall TPDocSheet::GetDateFromString(AnsiString ReferenceDate) { if (ParentSheaf) { return ParentSheaf->GetDateFromString(ReferenceDate, this); } return NULL; } //--------------------------------------------------------------------------- double __fastcall TPDocSheet::Calculation(AnsiString Formula) { if (ParentSheaf) { return ParentSheaf->Calculation(Formula, this); } int i, j, cnt, ccnt, k; double td1, td2, d; TPDocElement *dp, *tp; TPDocNumber *np; TPDocFormula *fp; TPDocInput *ip; TPDocChart *cp; std::stack< double, std::vector > > s; if (Element) { cnt = Element->Count; } else { cnt = 0; } if (Formula !="") { pf = new Postfix(Formula.c_str()); if (!pf->convert()) { pfp = 0; while (ch=pf->postfix[pfp++], ch) { switch (ch) { case 'N': case 'n': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) d = 0.0; j = atoi(Variable()); for (i=0; iItems[i]; if (dp->Type == detNumber) { np = (TPDocNumber *)dp; if (np->ID == j) { if (np->Number.Length() > 0) { if (!TryStrToFloat(np->Number, d)) d = 0.0; /* try { d = StrToFloat(np->Number); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } else if (dp->Type == detInput) { ip = (TPDocInput*)dp; if (ip->IPElement->Type == detNumber) { np = (TPDocNumber *)ip->IPElement; if (np->ID == j) { if (np->Number.Length() > 0) { if (!TryStrToFloat(np->Number, d)) d = 0.0; /* try { d = StrToFloat(np->Number); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } } else if (dp->Type == detChart) { cp = (TPDocChart *)dp; ccnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (tp->Type == detNumber) { np = (TPDocNumber *)tp; if (np->ID == j) { //Is it right?? if (np->Number.Length() > 0) { if (!TryStrToFloat(np->Number, d)) d = 0.0; /* try { d = StrToFloat(np->Number); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } } } } break; // case 'C': // d = 0.0; j = atoi(Variable()); // for (i=0; iItems[i]; // if (dp->Type == detChart) { // cp =(TPDocChart *)dp; // ccnt = cp->Cell->Count; // for (k=0; kCell->Items[k]; // if (tp->Type == detNumber) { // np = (TPDocNumber *)tp; // if (np->ID == j) { //Is it right?? // d = np->Number; // break; // } // } // } // } // } // break; case 'F': case 'f': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) d = 0.0; j = atoi(Variable()); for (i=0; iItems[i]; if (dp->Type == detFormula) { fp = (TPDocFormula *)dp; if (fp->ID == j) { if (fp->ANumber.Length() > 0) { if (!TryStrToFloat(fp->ANumber, d)) d = 0.0; /* try { d = StrToFloat(fp->ANumber); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } else if (dp->Type == detInput) { ip = (TPDocInput*)dp; if (ip->IPElement->Type == detFormula) { fp = (TPDocFormula *)ip->IPElement; if (fp->ID == j) { if (fp->ANumber.Length() > 0) { if (!TryStrToFloat(fp->ANumber, d)) d = 0.0; /* try { d = StrToFloat(fp->ANumber); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } } else if (dp->Type == detChart) { cp = (TPDocChart *)dp; ccnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (tp->Type == detFormula) { fp = (TPDocFormula *)tp; if (fp->ID == j) { //Is it right?? if (fp->ANumber.Length() > 0) { if (!TryStrToFloat(fp->ANumber, d)) d = 0.0; /* try { d = StrToFloat(fp->ANumber); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } } } } break; case 'I': case 'i': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) d = atof(Constant()); break; case '+': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); d = td1+td2; break; case '-': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); d = td1-td2; break; case '*': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); d = td1*td2; break; case '/': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); if (td2!=0.0) d = td1/(td2); break; // ¼ö½Ä °è»ê¿¡¼­ 'I' ¾øÀ̵µ ¼ýÀÚ¸¦ Á÷Á¢ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ (2007. 08. 09 Annualring) /* default: if (isdigit(ch) || ch == '-') { pfp--; d = atof(Constant()); } break; */ } s.push(d); } td1 = s.top(); s.pop(); } delete pf; } else { td1 = 0; } return td1; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheet::MakeBitmap(int zi, int zo) { HDC hDC = NULL, thDC = NULL; TPDocElement *dp; int i; if (Bitmap) { delete Bitmap; Bitmap = NULL; } if ((Bitmap = new TTexpiaBitmap) == NULL) goto fail; if (!Bitmap->Create(Range.right, Range.bottom, 24)) goto fail; Bitmap->FillRect(Range, clWhite); if ((hDC = Bitmap->CreateDC()) == NULL) goto fail; for (i = 0; i < Element->Count; i++) { dp = (TPDocElement *)Element->Items[i]; dp->PaintForm(hDC); } Bitmap->DeleteDC(hDC); return true; fail: if (Bitmap) { if (hDC) Bitmap->DeleteDC(hDC); delete Bitmap; Bitmap = NULL; } return false; } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::DeleteBitmap() { if (Bitmap) { delete Bitmap; Bitmap = NULL; } } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddCommonData(TPDocCommonDataMap &cdm) { int i, n; TPDocElement *ep; // AnsiString name = ""; WideString name = ""; TPDocCommonData *cdp = NULL; TPDocCommonDataMap::iterator p; typedef TPDocCommonDataMap::value_type value_type; for (i = 0; i < Element->Count; i++) { ep = (TPDocElement *)Element->Items[i]; AddCommonData_Element(ep,cdm); } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddCommonData_Element(TPDocElement *ep,TPDocCommonDataMap &cdm) { // AnsiString name = ""; WideString name = ""; TPDocCommonData *cdp = NULL; TPDocCommonDataMap::iterator p; typedef TPDocCommonDataMap::value_type value_type; switch (ep->Type) { case detColorChip: name = ((TPDocColorChip *)ep)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } break; case detEdit: name = ((TPDocEdit *)ep)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } break; case detNumber: name = ((TPDocNumber *)ep)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } break; case detFormula: name = ((TPDocFormula *)ep)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } break; case detDate: name = ((TPDocDate *)ep)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } break; case detImage: name = ((TPDocImage *)ep)->Name; if (name.Length() > 0) { name = "TPDocImage:"+name; } break; case detInput: name = ""; AddCommonData_Input((TPDocInput *)ep, cdm); break; case detChart: AddCommonData_Chart((TPDocChart *)ep, cdm); name = ""; break; default: name = ""; break; } if (name.Length() > 0) { p = cdm.find(name); //¸¸¾à ãÁö ¸øÇϸé end()°ªÀ» ³Ñ±è if (p == cdm.end()) { TPDocCommonData * tempData = new TPDocCommonData(ep->Type, ID); // cdm.insert(value_type(AnsiString(name), tempData)); cdm.insert(value_type(WideString(name), tempData)); SetCommonDataPtr(ep, tempData, true); }else{ SetCommonDataPtr(ep, p->second,false); } }else{ ResetCommonDataPtr(ep); } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetCommonDataPtr( TPDocElement *ep,TPDocCommonData *CommonData,bool bFirstAdd){ switch (ep->Type) { case detColorChip: if(bFirstAdd){ *((TColor *)CommonData->Data) = ((TPDocColorChip *)ep)->Color; } if(!((TPDocColorChip *)ep)->bHasCommonData){ delete ((TPDocColorChip *)ep)->ptrColor; ((TPDocColorChip *)ep)->ptrColor = NULL; ((TPDocColorChip *)ep)->bHasCommonData = true; } ((TPDocColorChip *)ep)->ptrColor = (TColor *)CommonData->Data; /* if(!bFirstAdd){ //for Undo ((TPDocColorChip *)ep)->Color = *(TColor *)CommonData->Data; } */ break; case detEdit: if(bFirstAdd){ // AnsiString txt; WideString txt; ((TPDocEdit *)ep)->GetK_Text(txt); // *(AnsiString *)CommonData->Data = txt; *(WideString *)CommonData->Data = txt; } if(!((TPDocEdit *)ep)->bHasCommonData){ ((TPDocEdit *)ep)->DestroyK_Text(); ((TPDocEdit *)ep)->bHasCommonData = true; } ((TPDocEdit *)ep)->ptrK_Text = (WideString *)CommonData->Data; break; case detNumber: if(bFirstAdd){ // *(AnsiString *)CommonData->Data = ((TPDocNumber *)ep)->Number; *(WideString *)CommonData->Data = ((TPDocNumber *)ep)->Number; } if(!((TPDocNumber *)ep)->bHasCommonData){ delete ((TPDocNumber *)ep)->ptrNumber; ((TPDocNumber *)ep)->ptrNumber = NULL; ((TPDocNumber *)ep)->bHasCommonData = true; } ((TPDocNumber *)ep)->ptrNumber = (WideString *)CommonData->Data; break; case detFormula: if(bFirstAdd){ // *(AnsiString *)CommonData->Data = ((TPDocFormula *)ep)->ANumber; *(WideString *)CommonData->Data = ((TPDocFormula *)ep)->ANumber; } if(!((TPDocFormula *)ep)->bHasCommonData){ delete ((TPDocFormula *)ep)->ptrANumber; ((TPDocFormula *)ep)->ptrANumber = NULL; ((TPDocFormula *)ep)->bHasCommonData = true; } // ((TPDocFormula *)ep)->ptrANumber = (AnsiString *)CommonData->Data; ((TPDocFormula *)ep)->ptrANumber = (WideString *)CommonData->Data; break; case detDate: if(bFirstAdd){ *(TDateTime *)CommonData->Data = ((TPDocDate *)ep)->dateTime; } if(!((TPDocDate *)ep)->bHasCommonData){ //delete ((TPDocDate *)ep)->dateTime; ((TPDocDate *)ep)->dateTime = NULL; ((TPDocDate *)ep)->bHasCommonData = true; } ((TPDocDate *)ep)->dateTime =*(TDateTime *)CommonData->Data; break; case detImage: if(bFirstAdd){ (TTexpiaBitmap *)CommonData->Data = ((TPDocImage *)ep)->Image; } if(!((TPDocImage *)ep)->bHasCommonData){ ((TPDocImage *)ep)->bHasCommonData = true; } ((TPDocImage *)ep)->Image = (TTexpiaBitmap *)CommonData->Data; break; } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::ResetCommonDataPtr( TPDocElement *ep){ switch (ep->Type) { case detColorChip: if(((TPDocColorChip *)ep)->bHasCommonData){ TColor TempColor = ((TPDocColorChip *)ep)->Color; ((TPDocColorChip *)ep)->ptrColor = new TColor; *((TPDocColorChip *)ep)->ptrColor = TempColor; ((TPDocColorChip *)ep)->bHasCommonData = false; } break; case detEdit: if(((TPDocEdit *)ep)->bHasCommonData){ WideString txt = *((TPDocEdit *)ep)->ptrK_Text; ((TPDocEdit *)ep)->ptrK_Text = new WideString; *((TPDocEdit *)ep)->ptrK_Text = txt; ((TPDocEdit *)ep)->bHasCommonData = false; } break; case detNumber: if(((TPDocNumber *)ep)->bHasCommonData){ WideString TempStr = ((TPDocNumber *)ep)->Number; ((TPDocNumber *)ep)->ptrNumber = new WideString; *((TPDocNumber *)ep)->ptrNumber = TempStr; ((TPDocNumber *)ep)->bHasCommonData = false; } break; case detFormula: if(((TPDocFormula *)ep)->bHasCommonData){ WideString TempStr = ((TPDocFormula *)ep)->ANumber; ((TPDocFormula *)ep)->ptrANumber = new WideString; *((TPDocFormula *)ep)->ptrANumber = TempStr; ((TPDocFormula *)ep)->bHasCommonData = false; } break; case detDate: if(((TPDocDate *)ep)->bHasCommonData){ WideString TempStr = ((TPDocDate *)ep)->Date; ((TPDocDate *)ep)->ptrDate = new WideString; *((TPDocDate *)ep)->ptrDate = TempStr; ((TPDocDate *)ep)->bHasCommonData = false; } break; case detImage: if(((TPDocImage *)ep)->bHasCommonData){ TTexpiaBitmap* TempImage = new TTexpiaBitmap; TempImage->Copy((TTexpiaBitmap*)((TPDocImage *)ep)->Image,SRCCOPY); ((TPDocImage *)ep)->Image = new TTexpiaBitmap; // by altang image //((TPDocImage *)ep)->Image = TempImage; ((TTexpiaBitmap*)((TPDocImage *)ep)->Image)->Copy(TempImage,SRCCOPY); ((TPDocImage *)ep)->bHasCommonData = false; } break; } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddCommonData_Input(TPDocInput *ip, TPDocCommonDataMap &cdm) { // AnsiString name=""; WideString name=""; TPDocCommonData *cdp = NULL; TPDocCommonDataMap::iterator p; typedef TPDocCommonDataMap::value_type value_type; switch (ip->IPElement->Type) { case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } break; case detNumber: name = ((TPDocNumber *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } break; case detDate: name = ((TPDocDate *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } break; case detImage: name = ((TPDocImage *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocImage:"+name; } break; default: name = ""; break; } if (name.Length() > 0) { p = cdm.find(name); //¸¸¾à ãÁö ¸øÇϸé end()°ªÀ» ³Ñ±è if (p == cdm.end()) { //cdm.insert(value_type(AnsiString(name), new TPDocCommonData(ip->IPElement->Type, ID))); TPDocCommonData * tempData = new TPDocCommonData(ip->IPElement->Type, ID); // cdm.insert(value_type(AnsiString(name), tempData)); cdm.insert(value_type(WideString(name), tempData)); SetCommonDataPtr(ip->IPElement, tempData, true); }else{ SetCommonDataPtr(ip->IPElement, p->second,false); } }else{ ResetCommonDataPtr(ip->IPElement); } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::AddCommonData_Chart(TPDocChart *cp, TPDocCommonDataMap &cdm) { int i, cnt; TPDocElement *ep; // AnsiString name = ""; WideString name = ""; TPDocCommonData *cdp = NULL; TPDocCommonDataMap::iterator p; typedef TPDocCommonDataMap::value_type value_type; cnt = cp->Cell->Count; for (i = 0; i < cnt; i++) { ep = (TPDocElement *)cp->Cell->Items[i]; switch (ep->Type) { case detColorChip: name = ((TPDocColorChip *)ep)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } break; case detEdit: name = ((TPDocEdit *)ep)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } break; case detNumber: name = ((TPDocNumber *)ep)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } break; case detFormula: name = ((TPDocFormula *)ep)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } break; case detDate: name = ((TPDocDate *)ep)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } break; case detImage: name = ((TPDocImage *)ep)->Name; if (name.Length() > 0) { name = "TPDocImage:"+name; } break; default: name = ""; break; } /* if (name.Length() > 0) { p = cdm.find(name); //¸¸¾à ãÁö ¸øÇϸé end()°ªÀ» ³Ñ±è if (p == cdm.end()) { cdm.insert(value_type(AnsiString(name), new TPDocCommonData(ep->Type, ID))); } } */ if (name.Length() > 0) { p = cdm.find(name); //¸¸¾à ãÁö ¸øÇϸé end()°ªÀ» ³Ñ±è if (p == cdm.end()) { TPDocCommonData * tempData = new TPDocCommonData(ep->Type, ID); // cdm.insert(value_type(AnsiString(name), tempData)); cdm.insert(value_type(WideString(name), tempData)); SetCommonDataPtr(ep, tempData, true); }else{ SetCommonDataPtr(ep, p->second,false); } }else{ ResetCommonDataPtr(ep); } } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::GetCommonData(TPDocCommonDataMap &cdm) { /* int i; TPDocElement *ep; AnsiString name = "", txt; TPDocCommonDataMap::iterator p; for (i = 0; i < Element->Count; i++) { ep = (TPDocElement *)Element->Items[i]; switch (ep->Type) { case detColorChip: name = ((TPDocColorChip *)ep)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } p = cdm.find(name); if (p != cdm.end()) { //qe test *((TColor *)((&p)->second->Data)) = ((TPDocColorChip *)ep)->Color; } break; case detEdit: name = ((TPDocEdit *)ep)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocEdit *)ep)->GetK_Text(txt); *(AnsiString *)p->second->Data = txt; } break; case detNumber: name = ((TPDocNumber *)ep)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocNumber *)ep)->Number; } break; case detFormula: name = ((TPDocFormula *)ep)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocFormula *)ep)->ANumber; } break; case detDate: name = ((TPDocDate *)ep)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocDate *)ep)->Date; // Version >= 4 } break; case detInput: GetCommonData_Input((TPDocInput *)ep, cdm); break; case detChart: GetCommonData_Chart((TPDocChart *)ep, cdm); break; } } */ } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::GetCommonData_Input(TPDocInput *ip, TPDocCommonDataMap &cdm) { /* AnsiString name = "", txt; TPDocCommonDataMap::iterator p; switch (ip->IPElement->Type) { case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(TColor *)p->second->Data = ((TPDocColorChip *)ip->IPElement)->Color; } break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocEdit *)ip->IPElement)->GetK_Text(txt); *(AnsiString *)p->second->Data = txt; } break; case detNumber: name = ((TPDocNumber *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocNumber *)ip->IPElement)->Number; } break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocFormula *)ip->IPElement)->ANumber; } break; case detDate: name = ((TPDocDate *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocDate *)ip->IPElement)->Date; } break; } */ } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::GetCommonData_Chart(TPDocChart *cp, TPDocCommonDataMap &cdm) { /* int i, cnt; TPDocElement *ep; AnsiString name = "", txt; TPDocCommonDataMap::iterator p; cnt = cp->Cell->Count; for (i = 0; i < cnt; i++) { ep = (TPDocElement *)cp->Cell->Items[i]; switch (ep->Type) { case detColorChip: name = ((TPDocColorChip *)ep)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(TColor *)p->second->Data = ((TPDocColorChip *)ep)->Color; } break; case detEdit: name = ((TPDocEdit *)ep)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocEdit *)ep)->GetK_Text(txt); *(AnsiString *)p->second->Data = txt; } break; case detNumber: name = ((TPDocNumber *)ep)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocNumber *)ep)->Number; } break; case detFormula: name = ((TPDocFormula *)ep)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocFormula *)ep)->ANumber; } break; case detDate: name = ((TPDocDate *)ep)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } p = cdm.find(name); if (p != cdm.end()) { *(AnsiString *)p->second->Data = ((TPDocDate *)ep)->Date; } break; } } */ } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetCommonData(TPDocCommonDataMap &cdm) { /* int i; TPDocElement *ep; AnsiString name = ""; TPDocCommonDataMap::iterator p; for (i = 0; i < Element->Count; i++) { ep = (TPDocElement *)Element->Items[i]; switch (ep->Type) { case detColorChip: name = ((TPDocColorChip *)ep)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocColorChip *)ep)->Color = *(TColor *)p->second->Data; } break; case detEdit: name = ((TPDocEdit *)ep)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocEdit *)ep)->SetText(*(AnsiString *)p->second->Data); } break; case detNumber: name = ((TPDocNumber *)ep)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocNumber *)ep)->Number = *(AnsiString *)p->second->Data; } break; case detFormula: name = ((TPDocFormula *)ep)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocFormula *)ep)->ANumber = *(AnsiString *)p->second->Data; } break; case detDate: name = ((TPDocDate *)ep)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocDate *)ep)->Date = *(AnsiString *)p->second->Data; } break; case detInput: SetCommonData_Input((TPDocInput *)ep, cdm); break; case detChart: SetCommonData_Chart((TPDocChart *)ep, cdm); break; } } */ } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetCommonData_Input(TPDocInput *ip, TPDocCommonDataMap &cdm) { /* AnsiString name = ""; TPDocCommonDataMap::iterator p; switch (ip->IPElement->Type) { case detColorChip: name = ((TPDocColorChip *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocColorChip *)ip->IPElement)->Color = *(TColor *)p->second->Data; } break; case detEdit: name = ((TPDocEdit *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocEdit *)ip->IPElement)->SetText(*(AnsiString *)p->second->Data); } break; case detNumber: name = ((TPDocNumber *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocNumber *)ip->IPElement)->Number = *(AnsiString *)p->second->Data; } break; case detFormula: name = ((TPDocFormula *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocFormula *)ip->IPElement)->ANumber = *(AnsiString *)p->second->Data; } break; case detDate: name = ((TPDocDate *)ip->IPElement)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocDate *)ip->IPElement)->Date = *(AnsiString *)p->second->Data; } break; } */ } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetCommonData_Chart(TPDocChart *cp, TPDocCommonDataMap &cdm) { /* int i, cnt; TPDocElement *ep; AnsiString name = ""; TPDocCommonDataMap::iterator p; cnt = cp->Cell->Count; for (i = 0; i < cnt; i++) { ep = (TPDocElement *)cp->Cell->Items[i]; switch (ep->Type) { case detColorChip: name = ((TPDocColorChip *)ep)->Name; if (name.Length() > 0) { name = "TPDocColorChip:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocColorChip *)ep)->Color = *(TColor *)p->second->Data; } break; case detEdit: name = ((TPDocEdit *)ep)->Name; if (name.Length() > 0) { name = "TPDocEdit:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocEdit *)ep)->SetText(*(AnsiString *)p->second->Data); } break; case detNumber: name = ((TPDocNumber *)ep)->Name; if (name.Length() > 0) { name = "TPDocNumber:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocNumber *)ep)->Number = *(AnsiString *)p->second->Data; } break; case detFormula: name = ((TPDocFormula *)ep)->Name; if (name.Length() > 0) { name = "TPDocFormula:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocFormula *)ep)->ANumber = *(AnsiString *)p->second->Data; } break; case detDate: name = ((TPDocDate *)ep)->Name; if (name.Length() > 0) { name = "TPDocDate:"+name; } p = cdm.find(name); if (p != cdm.end()) { ((TPDocDate *)ep)->Date = *(AnsiString *)p->second->Data; } break; } } */ } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::PaintData(HDC hDC, TPDocSheet *sheet, bool bprint) { int i;//, cnt = 0; TPDocElement *ep; TPDocViewStatus vs; for (i=0; iCount; i++) { ep = (TPDocElement *)Element->Items[i]; ep->PaintReport(sheet, hDC, vs, bprint, false, 0); // 0-->Korean } } //--------------------------------------------------------------------------- void __fastcall TPDocSheet::SetCursorIndex() { TPDocElement *ep, *ep_temp; int temp_left, temp_right, temp_up, temp_down; int last_left, last_right, last_up, last_down; for(int i = 0 ; i < Element->Count ; i++) { ep = (TPDocElement *)Element->Items[i]; ep->IndexR.left = -1; // À̵¿ÇÒ Index°¡ ¾øÀ» ¶§ NULLÀÇ Àǹ̷Π-1 ep->IndexR.right = -1; ep->IndexR.up = -1; ep->IndexR.down = -1; temp_left = -1; temp_right = -1; temp_up = -1; temp_down = -1; if (ep->Type != detChart) continue; for(int j = 0 ; j < Element->Count ; j++) // Index µ¹¸é¼­ ÇØ´çÇÏ´Â Index Relation ÁöÁ¤ { ep_temp = (TPDocElement *)Element->Items[j]; if (ep_temp->Type != detChart) continue; if(ep_temp->Range.left < ep->Range.left) // ¿ÞÂÊ¿¡ À§Ä¡ÇÑ indexÁß °¡Àå °¡±î¿î Inex¸¦ ãÀ½ { if(temp_left == -1) { last_left = ep_temp->Range.left; temp_left = j; } else if(last_left < ep_temp->Range.left) { last_left = ep_temp->Range.left; temp_left = j; } } if(ep_temp->Range.left > ep->Range.left) // ¿À¸¥ÂÊ¿¡ À§Ä¡ÇÑ indexÁß °¡Àå °¡±î¿î Inex¸¦ ãÀ½ { if(temp_right == -1) { last_right = ep_temp->Range.left; temp_right = j; } else if(last_right > ep_temp->Range.left) { last_right = ep_temp->Range.left; temp_right = j; } } if(ep_temp->Range.top < ep->Range.top) // À§ÂÊ¿¡ À§Ä¡ÇÑ indexÁß °¡Àå °¡±î¿î Inex¸¦ ãÀ½ { if(temp_up == -1) { last_up = ep_temp->Range.top; temp_up = j; } else if(last_up < ep_temp->Range.top) { last_up = ep_temp->Range.top; temp_up = j; } } if(ep_temp->Range.top > ep->Range.top) // ¾Æ·¡¿¡ À§Ä¡ÇÑ indexÁß °¡Àå °¡±î¿î Inex¸¦ ãÀ½ { if(temp_down == -1) { last_down = ep_temp->Range.top; temp_down = j; } else if(last_down > ep_temp->Range.top) { last_down = ep_temp->Range.top; temp_down = j; } } } if(temp_left != -1) ep->IndexR.left = temp_left; if(temp_right != -1) ep->IndexR.right = temp_right; if(temp_up != -1) ep->IndexR.up = temp_up; if(temp_down != -1) ep->IndexR.down = temp_down; } } bool __fastcall TPDocSheet::UndoRead() { Undo->UndoRead(); // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } bool __fastcall TPDocSheet::RedoRead() { Undo->RedoRead(); // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } void __fastcall TPDocSheet::RemoveFirstUndoData(){ Undo->RemoveFirst(); } void __fastcall TPDocSheet::RemoveLastUndoData(){ Undo->RemoveLast(); } void __fastcall TPDocSheet::AddUndoStep(){ Undo->AddUndoStep(); } bool __fastcall TPDocSheet::UndoSave(TPDocElement *Src,bool bClipboard) { if(bUndoLocked){ return false; } if(Src != NULL){ // Undo->AddUndoStep(); Undo->UndoSave(Src,bClipboard); return true; } return false; /* TPDocElement *sp; Undo->AddUndoStep(); sp = tp; if(tp->Type == detChart){ sp = ((TPDocChart *)tp)->GetSelectElement(); } Undo->UndoSave(sp); */ } bool __fastcall TPDocSheet::DeleteUndoSave(TPDocElement *Src) { if(bUndoLocked){ return false; } if(Src != NULL){ // Undo->AddUndoStep(); Undo->DeleteUndoSave(Src); return true; } return false; } bool __fastcall TPDocSheet::CreateUndoSave(TPDocElement *Src) { if(bUndoLocked){ return false; } if(Src != NULL){ // Undo->AddUndoStep(); Undo->CreateUndoSave(Src); return true; } return false; } void __fastcall TPDocSheet::LockUndoSave() { bUndoLocked = true; } void __fastcall TPDocSheet::UnLockUndoSave() { bUndoLocked = false; } //--------------------------------------------------------------------------- /*bool __fastcall TPDocSheet::SendToPrinter(TPDocSheet *Sender, int page, bool bCenter, int language) { HDC hPrintDC, hDC = NULL, phDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y, i, sx, sy, temp, dx, dy, SizeFontSheet; TSize Area, n, s; TPDocElement *ep; bPrinting = true; Printer()->Title = Title; Printer()->Copies = page; Printer()->Orientation = Orientation; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * DotsPerInch / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * DotsPerInch / HeightRes; n.cx = ((Range.right - 1) / Area.cx) + 1; n.cy = ((Range.bottom - 1) / Area.cy) + 1; if (Area.cx > Range.right) dx = (Area.cx - Range.right) / 2; //È­¸é Áß¾Ó¿¡ À§Ä¡½Ã۱â À§ÇØ else dx = 0; if (Area.cy > Range.bottom) dy = (Area.cy - Range.bottom) / 2; else dy = 0; TPDocViewStatus vs; //============================ for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; vs.Position.x = Src.Left + dx; vs.Position.y = Src.Top + dy; vs.ZoomIn = WidthRes; vs.ZoomOut = DotsPerInch; for (i=0; iCount; i++) { ep = (TPDocElement *)Element->Items[i]; ep->PaintForm(Printer()->Canvas->Handle, &vs); ep->PaintReport((TPDocObject *)Sender, Printer()->Canvas->Handle, vs, true, false, language); } // VecDraw->PrintDraw(Printer()->Canvas->Handle, ps.Position.x, ps.Position.y, WidthRes, HeightRes, DotsPerInch); } } Printer()->EndDoc(); bPrinting = false; return true; fail: return false; } */ //--------------------------------------------------------------------------- // // TPDocSheaf // //--------------------------------------------------------------------------- /// »ý¼ºÀÚ¿¡ ¸Å°³º¯¼ö Ãß°¡ // (2007. 02. 08 Annualring) __fastcall TPDocSheaf::TPDocSheaf(bool isMultiSheaf, bool isAdministrator) { ID = 0; Sheet = new TList; FileName = ""; hSheafFile = INVALID_HANDLE_VALUE; Modify = false; StepNumber = -1; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. version = CURRENT_VERSION; FIsMultiSheaf = isMultiSheaf; FIsAdministrator = isAdministrator; } //--------------------------------------------------------------------------- __fastcall TPDocSheaf::~TPDocSheaf() { RemoveData(); if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); if (Sheet) delete Sheet; } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- TPDocSheet *__fastcall TPDocSheaf::GetSheet(int n) { return (TPDocSheet *)Sheet->Items[n]; } TPDocSheet *__fastcall TPDocSheaf::GetSheetFromID(int ID) { TPDocSheet * dp; for(int i = 0;iCount;i++){ dp = (TPDocSheet *)Sheet->Items[i]; if(dp->ID==ID){ return dp; } } return NULL; } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::AddSheet(TPDocSheet *Value) { Value->ID = ID++; Sheet->Add(Value); } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::InsertSheet(int Index, TPDocSheet *Value) { Value->ID = ID++; Sheet->Insert(Index, Value); } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::MoveSheet(int Source, int Target) { /* TPDocSheet *dp; dp = GetSheet(Source); if (Source > Target) { Sheet->Insert(Target, dp); dp = GetSheet(Source + 1); } else { if (Target == (Sheet->Cunt - 1)) { Sheet->Add(dp); } else { Sheet->Insert(Target + 1, dp); } } Sheet->Remove(dp); */ Sheet->Move(Source, Target); } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::DeleteSheet(int Index) { TPDocSheet *dp = (TPDocSheet *)Sheet->Items[Index]; Sheet->Remove(dp); if (dp) delete dp; } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::RemoveData() { TPDocSheet *dp; int *id; // TPDocCommonData *cdm; ID = 0; if (Sheet) { while (Sheet->Count) { dp = (TPDocSheet *)Sheet->First(); Sheet->Remove(dp); delete dp; dp = NULL; } } while (CommonDataMap.size()) { TPDocCommonDataMap::iterator p = CommonDataMap.begin(); delete CommonDataMap[p->first]; CommonDataMap.erase(p); } } //--------------------------------------------------------------------------- // ³¯Â¥ÀÇ ¼øÈ¯ ÂüÁ¶¸¦ °Ë»çÇÑ´Ù - by monkman (2010.05.13) bool __fastcall TPDocSheaf::CheckReferenceDate(AnsiString strCurrentReferenceDate, AnsiString strCheckDate) { TPDocSheet *docSheet = NULL; TPDocElement *docElement = NULL, *docChildElement = NULL; TPDocDate *docDate = NULL; TPDocChart *docChart = NULL; AnsiString tempDate; int nCount; // ÀڽŠÂüÁ¶ °ª for (int i = 0; i < this->Sheet->Count; i++) { docSheet = (TPDocSheet*) this->Sheet->Items[i]; if (docSheet->Element) nCount = docSheet->Element->Count; else nCount = 0; for (int j = 0; j < nCount; j++) { docElement = (TPDocElement *)docSheet->Element->Items[j]; if(docElement->Type == detChart) { docChart = (TPDocChart *) docElement; for (int k = 0; k < docChart->Cell->Count; k++) { docChildElement = (TPDocElement *)docChart->Cell->Items[k]; if (docChildElement->Type == detDate) { docDate = (TPDocDate *)docChildElement; // ¼øÈ¯ ÂüÁ¶ÇÏ´Â °æ¿ì tempDate = "S" + IntToStr(docSheet->ID) + "D" + docDate->ID; if (tempDate == strCurrentReferenceDate) { if (docDate->ReferenceDate == strCheckDate) return true; else return CheckReferenceDate(docDate->ReferenceDate, strCheckDate); } } } } } } return false; } //--------------------------------------------------------------------------- void* __fastcall TPDocSheaf::GetDateFromString(AnsiString ReferenceDate, TPDocSheet *os) { TPDocSheet *st; TPDocElement *dp, *tp; TPDocDate *ddp; TPDocChart *cp; AnsiString Data = "", SheetData = "", CellData = ""; int n = 0, s = 0, j = 0, cnt = 0; st = os; Data = ReferenceDate; Data = Data.SubString(2,ReferenceDate.Length() - 1); n = Data.AnsiPos("D"); SheetData = Data.SubString(1,n-1); CellData = Data.SubString(n+1,Data.Length() - n); try { s = SheetData.ToInt(); j = CellData.ToInt(); } catch(EConvertError &excpetion) { return NULL; } st = (TPDocSheet*) this->Sheet->Items[s]; if (st->Element) cnt = st->Element->Count; else cnt = 0; for(int i = 0; i < cnt; i++) { dp = (TPDocElement *)st->Element->Items[i]; if(dp->Type == detChart) { cp = (TPDocChart *) dp; for(int k = 0; k < cp->Cell->Count; k++) { tp = (TPDocElement *)cp->Cell->Items[k]; if(tp->Type == detDate) { ddp = (TPDocDate *) tp; if(ddp->ID == j){ if(ddp->bHasReference) return TPDocSheaf::GetDateFromString(ddp->ReferenceDate,st); else return (void*)(&(ddp->dateTime)); } } } } } return NULL; } //--------------------------------------------------------------------------- double __fastcall TPDocSheaf::Calculation(AnsiString Formula, TPDocSheet *os) { int i, j, cnt, ccnt, k; double td1, td2, d; TPDocSheet *st; TPDocElement *dp, *tp; TPDocNumber *np; TPDocFormula *fp; TPDocInput *ip; TPDocChart *cp; std::stack< double, std::vector > > s; double result; st = os; if (Formula !="") { if(result = PresetFormulaCalculation(Formula,os)) return result; pf = new Postfix(Formula.c_str()); if (!pf->convert()) { pfp = 0; while (ch=pf->postfix[pfp++], ch) { switch (ch) { case 'S': case 's': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) j = atoi(st->Variable()); for (i = 0; i < Sheet->Count; i++) { st = (TPDocSheet *)Sheet->Items[i]; if (st->ID == j) break; } break; case 'N': case 'n': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) d = 0.0; j = atoi(st->Variable()); if (st->Element) cnt = st->Element->Count; else cnt = 0; for (i=0; iElement->Items[i]; if (dp->Type == detNumber) { np = (TPDocNumber *)dp; if (np->ID == j) { if (np->Number.Length() > 0) { if (!TryStrToFloat(np->Number, d)) d = 0.0; /* try { d = StrToFloat(np->Number); } catch (EConvertError &ec) { d = 0.0; // d = StrWithCommaToFloat(np->Number); } */ } break; } } else if (dp->Type == detInput) { ip = (TPDocInput*)dp; if (ip->IPElement->Type == detNumber) { np = (TPDocNumber *)ip->IPElement; if (np->ID == j) { if (np->Number.Length() > 0) { if (!TryStrToFloat(np->Number, d)) d = 0.0; /* try { d = StrToFloat(np->Number); } catch (EConvertError &ec) { d = 0.0; // d = StrWithCommaToFloat(np->Number); } */ } break; } } } else if (dp->Type == detChart) { cp = (TPDocChart *)dp; ccnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (tp->Type == detNumber) { np = (TPDocNumber *)tp; if (np->ID == j) { //Is it right?? if (np->Number.Length() > 0) { if (!TryStrToFloat(np->Number, d)) d = 0.0; /* try { d = StrToFloat(np->Number); } catch (EConvertError &ec) { d = 0.0; // d = StrWithCommaToFloat(np->Number); } */ } break; } } } } } st = os; break; case 'F': case 'f': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) d = 0.0; j = atoi(st->Variable()); if (st->Element) cnt = st->Element->Count; else cnt = 0; for (i=0; iElement->Items[i]; if (dp->Type == detFormula) { fp = (TPDocFormula *)dp; if (fp->ID == j) { if (fp->ANumber.Length() > 0) { if (!TryStrToFloat(fp->ANumber, d)) d = 0.0; /* try { d = StrToFloat(fp->ANumber); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } else if (dp->Type == detInput) { ip = (TPDocInput*)dp; if (ip->IPElement->Type == detFormula) { fp = (TPDocFormula *)ip->IPElement; if (fp->ID == j) { if (fp->ANumber.Length() > 0) { if (!TryStrToFloat(fp->ANumber, d)) d = 0.0; /* try { d = StrToFloat(fp->ANumber); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } } else if (dp->Type == detChart) { cp = (TPDocChart *)dp; ccnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (tp->Type == detFormula) { fp = (TPDocFormula *)tp; if (fp->ID == j) { //Is it right?? if (fp->ANumber.Length() > 0) { if (!TryStrToFloat(fp->ANumber, d)) d = 0.0; /* try { d = StrToFloat(fp->ANumber); } catch (EConvertError &ec) { d = 0.0; } */ } break; } } } } } st = os; break; case 'I': case 'i': // µðÀÚÀÎ½Ç ¿äûÀ¸·Î NÀÌ ¼Ò¹®ÀÚ ÀÏ ¶§µµ ¼¿ ³Ñ¹ö·Î ÀνÄÇϵµ·Ï º¯°æ (2007. 08. 13 Annualring) d = atof(st->Constant()); break; case '+': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); d = td1+td2; break; case '-': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); d = td1-td2; break; case '*': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); d = td1*td2; break; case '/': td2 = s.top(); s.pop(); td1 = s.top(); s.pop(); if (td2!=0.0) d = td1/(td2); break; // ¼ö½Ä °è»ê¿¡¼­ 'I' ¾øÀ̵µ ¼ýÀÚ¸¦ Á÷Á¢ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ (2007. 08. 09 Annualring) /* default: if (isdigit(ch) || ch == '-') { pfp--; d = atof(st->Constant()); } break; */ } s.push(d); } td1 = s.top(); s.pop(); } delete pf; } else { td1 = 0; } return td1; } //--------------------------------------------------------------------------- double __fastcall TPDocSheaf::PresetFormulaCalculation(AnsiString Formula, TPDocSheet *os) { int ileftparenthesis = -1, icomma = -1; AnsiString FunctionName = "", Data = "", SheetData = "", CellData = "", preData = ""; int i, c, s, cnt, ccnt, k, j; double td1, td2, d = 0.0; TPDocSheet *st; TPDocElement *dp, *tp; TPDocNumber *np; TPDocFormula *fp; TPDocChart *cp; double result = 0; st = os; TList *numList = new TList; ileftparenthesis = Formula.LastDelimiter("("); FunctionName = Formula.SubString(0,ileftparenthesis - 1); Data = Formula.SubString(ileftparenthesis + 1,Formula.Length() - ileftparenthesis - 1); preData = Data; TStringList *sList = new TStringList; sList->Delimiter = ','; sList->DelimitedText = Data; for(int i = 0; i < sList->Count; i++) { AnsiString CurrentData = sList->Strings[i]; int nf = CurrentData.AnsiPos("F"); int nn = CurrentData.AnsiPos("N"); if(nf == 0) { SheetData = CurrentData.SubString(2,CurrentData.AnsiPos("N") - 2); CellData = CurrentData.SubString(CurrentData.AnsiPos("N") + 1,CurrentData.Length() - CurrentData.AnsiPos("N")); } else if(nn == 0) { SheetData = CurrentData.SubString(2,CurrentData.AnsiPos("F") - 2); CellData = CurrentData.SubString(CurrentData.AnsiPos("F") + 1,CurrentData.Length() - CurrentData.AnsiPos("F")); } if (SheetData.IsEmpty() || CellData.IsEmpty()) return NULL; //¿¡·¯Ã³¸®¸¦ À§Çؼ­ by david 100127] if (!TryStrToInt(SheetData.c_str(), s)) return NULL; if (!TryStrToInt(CellData.c_str(), j)) return NULL; /*try { s = SheetData.ToInt(); j = CellData.ToInt(); } catch(EConvertError &excpetion) { return NULL; }*/ st = (TPDocSheet*) this->Sheet->Items[s]; if (st->Element) cnt = st->Element->Count; else cnt = 0; for(int i = 0; i < cnt; i++) { dp = (TPDocElement *)st->Element->Items[i]; if(dp->Type == detChart) { cp = (TPDocChart *) dp; for(int k = 0; k < cp->Cell->Count; k++) { tp = (TPDocElement *)cp->Cell->Items[k]; if(nf == 0 && tp->Type == detNumber) { np = (TPDocNumber *) tp; if(np->ID == j) { if(np->Number.Length() > 0) { double num = 0; if (TryStrToFloat(np->Number, num)){ numList->Add(new double(num)); } else { d = 0.0; } /* try{ numList->Add(new double(StrToFloat(np->Number))); } catch(EConvertError &ec){ d = 0.0; } */ } } } if(nn == 0 && tp->Type == detFormula) { fp = (TPDocFormula *) tp; if(fp->ID == j) { if(fp->Number) { double num = 0; if (TryStrToFloat(fp->ANumber, num)){ numList->Add(new double(num)); } else { d = 0.0; } /* try{ numList->Add(new double(StrToFloat(fp->ANumber))); } catch(EConvertError &ec){ d = 0.0; } */ } } } } } } } if(FunctionName == "SUM") { for(int x = 0; x < numList->Count; x++){ result += *((double*) numList->Items[x]); } } else if(FunctionName == "AVERAGE") { for(int x = 0; x < numList->Count; x++){ result += *((double*) numList->Items[x]); } result /= numList->Count; } else { delete numList; numList = NULL; return NULL; } if(numList) { Double* tempd; for(int x = 0; x < numList->Count; x++) { tempd = (Double*) numList->Items[x]; if(tempd) {delete tempd; tempd = NULL;}; } delete numList; numList = NULL; } return result; } //--------------------------------------------------------------------------- double __fastcall TPDocSheaf::StrWithCommaToFloat(AnsiString Number){ double d; int pos; AnsiString StrComma = ","; // Warning ¼öÁ¤ (2007. 05. 17 Annualring) pos = Number.AnsiPos(StrComma); while(pos){ Number.Delete(pos,1); pos = Number.AnsiPos(StrComma); } if (!TryStrToFloat(Number, d)) d = 0.0; /* try { d = StrToFloat(Number); } catch (EConvertError &ec) { d = 0.0; } */ return d; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocSheaf::LoadFromFile(AnsiString Filename) { //HANDLE hFile = INVALID_HANDLE_VALUE; int version, n, i; int ThumbnailCnt; int PrimaryThumbnailNum; DWORD dwRead; TPDocSheet *dp; RemoveData(); if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } // dwFileSize = GetFileSize(hFile, NULL); // if ((hFileMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, dwFileSize, // NULL)) == NULL) goto fail; if (!ReadFile(hSheafFile, &version, sizeof(int), &dwRead, NULL)) goto fail; if (!TextLoadFromFile(hSheafFile, Title)) return false; if (version >= 8) { if (!TextLoadFromFile(hSheafFile, Title1)) return false; if (!TextLoadFromFile(hSheafFile, Title2)) return false; if (!TextLoadFromFile(hSheafFile, Title3)) return false; if (!TextLoadFromFile(hSheafFile, Title4)) return false; if(version >=12){ if (!ReadFile(hSheafFile, &StepNumber, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hSheafFile, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hSheafFile, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hSheafFile, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } for (i = 0; i < n; i++) { dp = new TPDocSheet(this); if (!dp->LoadFromFile(hSheafFile, version)) goto fail; Sheet->Add(dp); // if (FVectorLoadFromFile && version > 8) if (FVectorLoadSheetFromFile && version > 8) { bool isVector; if (!ReadFile(hSheafFile, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hSheafFile, i); if (isVector) FVectorLoadSheetFromFile(hSheafFile, dp, i); } dp->ID = ID++; } // CloseHandle(hSheafFile); return true; fail: RemoveData(); if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); return false; } //--------------------------------------------------------------------------- */ bool __fastcall TPDocSheaf::LoadFromFile(WideString Filename) { //HANDLE hFile = INVALID_HANDLE_VALUE; int version, n, i; int ThumbnailCnt; int PrimaryThumbnailNum; DWORD dwRead; TPDocSheet *dp; RemoveData(); if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } // dwFileSize = GetFileSize(hFile, NULL); // if ((hFileMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, dwFileSize, // NULL)) == NULL) goto fail; if (!ReadFile(hSheafFile, &version, sizeof(int), &dwRead, NULL)) goto fail; // TODO : TexWork File ¹öÀü ¿Ã¸®¸é ¿©±â ¼öÁ¤ÇÒ °Í!! if (version > CURRENT_VERSION) { // »óÀ§ ¹öÀü üũ - by monkman (2009.05.26) MessageDlg("Cannot open newer version file.", mtInformation, TMsgDlgButtons() << mbOK, 0); goto fail; } TextVersion = version; this->version = version; if (!TextLoadFromFile(hSheafFile, Title)) return false; if (version >= 8) { if (!TextLoadFromFile(hSheafFile, Title1)) return false; if (!TextLoadFromFile(hSheafFile, Title2)) return false; if (!TextLoadFromFile(hSheafFile, Title3)) return false; if (!TextLoadFromFile(hSheafFile, Title4)) return false; if(version >=12){ if (!ReadFile(hSheafFile, &StepNumber, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hSheafFile, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hSheafFile, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hSheafFile, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } for (i = 0; i < n; i++) { dp = new TPDocSheet(this); if (!dp->LoadFromFile(hSheafFile, version)) goto fail; Sheet->Add(dp); dp->ID = ID; // if (FVectorLoadFromFile && version > 8) if (FVectorLoadSheetFromFile && version > 8) { bool isVector; if (!ReadFile(hSheafFile, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hSheafFile, i); if (isVector) FVectorLoadSheetFromFile(hSheafFile, dp, i); } ID++; // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) dp->SetFIDCount(); // ¼¿ ³Ñ¹ö Áߺ¹ ¹®Á¦ ÇØ°áÀ» À§ÇØ (2007. 08. 16 Annualring) dp->SetFIDCountForSheet(); } // CloseHandle(hSheafFile); return true; fail: RemoveData(); // ¿ÏÀüÈ÷ Áö¿ìµµ·Ï Ãß°¡ - by monkman (2009.05.28) if (Sheet) delete Sheet; Sheet = NULL; if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); // ÃʱâÈ­ Ãß°¡ - by monkman (2009.05.28) hSheafFile = INVALID_HANDLE_VALUE; return false; } //--------------------------------------------------------------------------- /* // .ssf ÆÄÀÏÀ» Àбâ À§ÇÑ ÇÔ¼ö (2007. 02. 02 Annualring) bool __fastcall TPDocSheaf::LoadFromSingleSheafFile(AnsiString Filename) { //HANDLE hFile = INVALID_HANDLE_VALUE; int version, n, i; int ThumbnailCnt; int PrimaryThumbnailNum; DWORD dwRead; TPDocSheet *dp; SingleSheafHeader SSFHeader; // ¹öÀü ´ÙÀ½¿¡ ÀÐÀ» Çì´õ (2007. 02. 02 Annualring) RemoveData(); if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } // dwFileSize = GetFileSize(hFile, NULL); // if ((hFileMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, dwFileSize, // NULL)) == NULL) goto fail; if (!ReadFile(hSheafFile, &version, sizeof(int), &dwRead, NULL)) goto fail; // ¹öÀü ´ÙÀ½¿¡ ÀÖ´Â Çì´õ¸¦ Àд´Ù. (2007. 02. 02 Annualring) if (!ReadFile(hSheafFile, &SSFHeader, sizeof(SingleSheafHeader), &dwRead, NULL)) return false; if (!TextLoadFromFile(hSheafFile, Title)) return false; if (version >= 8) { if (!TextLoadFromFile(hSheafFile, Title1)) return false; if (!TextLoadFromFile(hSheafFile, Title2)) return false; if (!TextLoadFromFile(hSheafFile, Title3)) return false; if (!TextLoadFromFile(hSheafFile, Title4)) return false; if(version >=12){ if (!ReadFile(hSheafFile, &StepNumber, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hSheafFile, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hSheafFile, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hSheafFile, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } for (i = 0; i < n; i++) { // EditableÀ» ¸í½ÃÀûÀ¸·Î true·Î ÇØ¼­ Àоî¿Â´Ù. (2007. 02. 02 Annualring) dp = new TPDocSheet(this, true); if (!dp->LoadFromFile(hSheafFile, version)) goto fail; Sheet->Add(dp); // if (FVectorLoadFromFile && version > 8) if (FVectorLoadSheetFromFile && version > 8) { bool isVector; if (!ReadFile(hSheafFile, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hSheafFile, i); if (isVector) FVectorLoadSheetFromFile(hSheafFile, dp, i); } dp->ID = ID++; } // CloseHandle(hSheafFile); return true; fail: RemoveData(); if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); return false; } //--------------------------------------------------------------------------- */ // .ssf ÆÄÀÏÀ» Àбâ À§ÇÑ ÇÔ¼ö (2007. 02. 02 Annualring) bool __fastcall TPDocSheaf::LoadFromSingleSheafFile(WideString Filename) { //HANDLE hFile = INVALID_HANDLE_VALUE; int version, n, i; int ThumbnailCnt; int PrimaryThumbnailNum; DWORD dwRead; TPDocSheet *dp; SingleSheafHeader SSFHeader; // ¹öÀü ´ÙÀ½¿¡ ÀÐÀ» Çì´õ (2007. 02. 02 Annualring) RemoveData(); if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } // dwFileSize = GetFileSize(hFile, NULL); // if ((hFileMap = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, dwFileSize, // NULL)) == NULL) goto fail; if (!ReadFile(hSheafFile, &version, sizeof(int), &dwRead, NULL)) goto fail; TextVersion = version; // ¹öÀü ´ÙÀ½¿¡ ÀÖ´Â Çì´õ¸¦ Àд´Ù. (2007. 02. 02 Annualring) if (!ReadFile(hSheafFile, &SSFHeader, sizeof(SingleSheafHeader), &dwRead, NULL)) return false; if (!TextLoadFromFile(hSheafFile, Title)) return false; if (version >= 8) { if (!TextLoadFromFile(hSheafFile, Title1)) return false; if (!TextLoadFromFile(hSheafFile, Title2)) return false; if (!TextLoadFromFile(hSheafFile, Title3)) return false; if (!TextLoadFromFile(hSheafFile, Title4)) return false; if(version >=12){ if (!ReadFile(hSheafFile, &StepNumber, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hSheafFile, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hSheafFile, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hSheafFile, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } for (i = 0; i < n; i++) { // EditableÀ» ¸í½ÃÀûÀ¸·Î true·Î ÇØ¼­ Àоî¿Â´Ù. (2007. 02. 02 Annualring) dp = new TPDocSheet(this, true); if (!dp->LoadFromFile(hSheafFile, version)) goto fail; Sheet->Add(dp); dp->ID = ID; // if (FVectorLoadFromFile && version > 8) if (FVectorLoadSheetFromFile && version > 8) { bool isVector; if (!ReadFile(hSheafFile, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hSheafFile, i); if (isVector) FVectorLoadSheetFromFile(hSheafFile, dp, i); } //dp->ID = ID++; ID++; } // CloseHandle(hSheafFile); return true; fail: RemoveData(); if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); return false; } //--------------------------------------------------------------------------- /* bool __fastcall TPDocSheaf::AddFromFile(AnsiString Filename) { HANDLE hf = INVALID_HANDLE_VALUE; int version, n, i; int temp; int ThumbnailCnt; int PrimaryThumbnailNum; AnsiString str; DWORD dwRead; TPDocSheet *dp; if ((hf = CreateFile(Filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; if (!ReadFile(hf, &version, sizeof(int), &dwRead, NULL)) goto fail; if (!TextLoadFromFile(hf, str)) return false; //ÇÊ¿ä¾ø´Â °ªÀÌÁö¸¸ ±×³É Àд´Ù. if (version >= 8) { if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if(version >=12){ //by linuxjun for ¾ÆÀ̺ñ ¿ä±¸»çÇ× Add Sheaf½Ã ¿¡·¯³ª´Â ¹®Á¦¼öÁ¤À§ÇØ. if (!ReadFile(hf, &temp, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hf, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hf, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hf, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } // ÆÄÀÏ ¿©·¯°³ ÇÕÄ¡±â ¸¸µé°Å¸é ÀÌÂÊÀ» Àß º¼°Í. LoadFromFile À̿ܿ¡µµ ó¸®ÇؾßÇÒ °ÍµéÀÌ ÀÖ´Ù. (2007. 01. 08 Annualring) for (i = 0; i < n; i++) { dp = new TPDocSheet(this); if (!dp->LoadFromFile(hf, version)) goto fail; Sheet->Add(dp); if (FVectorLoadFromFile && version > 8) { bool isVector; if (!ReadFile(hf, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hf, Sheet->Count); if (isVector) FVectorLoadFromFile(hf, Sheet->Count-1); //Sheet->Add(dp);¸¦ ¹Ø¿¡¼­ À§·Î ¿Ã·ÈÀ¸¹Ç·Î Sheet->Count-1 ·Î ¹Ù²Þ. } dp->ID = ID++; } CloseHandle(hf); return true; fail: RemoveData(); if (hf!=INVALID_HANDLE_VALUE) CloseHandle(hf); return false; } //--------------------------------------------------------------------------- */ bool __fastcall TPDocSheaf::AddFromFile(WideString Filename) { HANDLE hf = INVALID_HANDLE_VALUE; int version, n, i; int temp; int ThumbnailCnt; int PrimaryThumbnailNum; WideString str; DWORD dwRead; TPDocSheet *dp; if ((hf = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; if (!ReadFile(hf, &version, sizeof(int), &dwRead, NULL)) goto fail; TextVersion = version; if (!TextLoadFromFile(hf, str)) return false; //ÇÊ¿ä¾ø´Â °ªÀÌÁö¸¸ ±×³É Àд´Ù. if (version >= 8) { if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if(version >=12){ //by linuxjun for ¾ÆÀ̺ñ ¿ä±¸»çÇ× Add Sheaf½Ã ¿¡·¯³ª´Â ¹®Á¦¼öÁ¤À§ÇØ. if (!ReadFile(hf, &temp, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hf, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hf, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hf, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hf); } } // ÆÄÀÏ ¿©·¯°³ ÇÕÄ¡±â ¸¸µé°Å¸é ÀÌÂÊÀ» Àß º¼°Í. LoadFromFile À̿ܿ¡µµ ó¸®ÇؾßÇÒ °ÍµéÀÌ ÀÖ´Ù. (2007. 01. 08 Annualring) for (i = 0; i < n; i++) { dp = new TPDocSheet(this); dp->ID = ID; //VecDataÀÇ SheetInstance¿Í sheetÀÇ ID°¡ ºÒÀÏÄ¡ÇØ ±×·ÁÁöÁö ¾Ê´Â ¹®Á¦ ¹ß»ý => dp->LoadFromFile()Çϱâ Àü¿¡ ¼³Á¤Çϵµ·Ï ¼öÁ¤ if (!dp->LoadFromFile(hf, version)) goto fail; Sheet->Add(dp); if (FVectorLoadFromFile && version > 8) { bool isVector; if (!ReadFile(hf, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hf, Sheet->Count); if (isVector) FVectorLoadFromFile(hf, Sheet->Count-1); //Sheet->Add(dp);¸¦ ¹Ø¿¡¼­ À§·Î ¿Ã·ÈÀ¸¹Ç·Î Sheet->Count-1 ·Î ¹Ù²Þ. } //dp->ID = ID++; ID++; } CloseHandle(hf); return true; fail: RemoveData(); if (hf!=INVALID_HANDLE_VALUE) CloseHandle(hf); return false; } //--------------------------------------------------------------------------- /* // ÇöÀç·Î¼­´Â LoadFromSingleSheafFile·Î Àоî¿Â SheetµéÀº ¸ðµÎ EditableÀÌ trueÀ̰í // AddFromSingleSheafFile·Î Àоî¿Â SheetµéÀº ¸ðµÎ EditableÀÌ false°¡ µÇµµ·Ï ÇØµÎ¾ú´Ù. // ±×·¯³ª À̰͵µ ¹Ù²î¾î¾ß ÇÒÁöµµ ¸ð¸£°Ú´Ù. (2007. 02. 21 Annualring) // .ssf ÆÄÀÏÀ» ´õÇϱâ À§ÇÑ ÇÔ¼ö (2007. 02. 08 Annualring) bool __fastcall TPDocSheaf::AddFromSingleSheafFile(AnsiString Filename) { HANDLE hf = INVALID_HANDLE_VALUE; int version, n, i; int temp; int ThumbnailCnt; int PrimaryThumbnailNum; AnsiString str; DWORD dwRead; TPDocSheet *dp; SingleSheafHeader SSFHeader; // ¹öÀü ´ÙÀ½¿¡ ÀÐÀ» Çì´õ (2007. 02. 02 Annualring) if ((hf = CreateFile(Filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; if (!ReadFile(hf, &version, sizeof(int), &dwRead, NULL)) goto fail; // ¹öÀü ´ÙÀ½¿¡ ÀÖ´Â Çì´õ¸¦ Àд´Ù. (2007. 02. 02 Annualring) if (!ReadFile(hSheafFile, &SSFHeader, sizeof(SingleSheafHeader), &dwRead, NULL)) return false; if (!TextLoadFromFile(hf, str)) return false; //ÇÊ¿ä¾ø´Â °ªÀÌÁö¸¸ ±×³É Àд´Ù. if (version >= 8) { if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if(version >=12){ //by linuxjun for ¾ÆÀ̺ñ ¿ä±¸»çÇ× Add Sheaf½Ã ¿¡·¯³ª´Â ¹®Á¦¼öÁ¤À§ÇØ. if (!ReadFile(hf, &temp, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hf, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hf, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hf, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } // ÆÄÀÏ ¿©·¯°³ ÇÕÄ¡±â ¸¸µé°Å¸é ÀÌÂÊÀ» Àß º¼°Í. LoadFromFile À̿ܿ¡µµ ó¸®ÇؾßÇÒ °ÍµéÀÌ ÀÖ´Ù. (2007. 01. 08 Annualring) for (i = 0; i < n; i++) { // ¸í½ÃÀûÀ¸·Î false·Î ÇØ¼­ Àоî¿Â´Ù. (2007. 02. 21 Annualring) dp = new TPDocSheet(this, false); if (!dp->LoadFromFile(hf, version)) goto fail; Sheet->Add(dp); if (FVectorLoadFromFile && version > 8) { bool isVector; if (!ReadFile(hf, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hf, Sheet->Count); if (isVector) FVectorLoadFromFile(hf, Sheet->Count-1); //Sheet->Add(dp);¸¦ ¹Ø¿¡¼­ À§·Î ¿Ã·ÈÀ¸¹Ç·Î Sheet->Count-1 ·Î ¹Ù²Þ. } dp->ID = ID++; } CloseHandle(hf); return true; fail: RemoveData(); if (hf!=INVALID_HANDLE_VALUE) CloseHandle(hf); return false; } //--------------------------------------------------------------------------- */ // ÇöÀç·Î¼­´Â LoadFromSingleSheafFile·Î Àоî¿Â SheetµéÀº ¸ðµÎ EditableÀÌ trueÀ̰í // AddFromSingleSheafFile·Î Àоî¿Â SheetµéÀº ¸ðµÎ EditableÀÌ false°¡ µÇµµ·Ï ÇØµÎ¾ú´Ù. // ±×·¯³ª À̰͵µ ¹Ù²î¾î¾ß ÇÒÁöµµ ¸ð¸£°Ú´Ù. (2007. 02. 21 Annualring) // .ssf ÆÄÀÏÀ» ´õÇϱâ À§ÇÑ ÇÔ¼ö (2007. 02. 08 Annualring) bool __fastcall TPDocSheaf::AddFromSingleSheafFile(WideString Filename) { HANDLE hf = INVALID_HANDLE_VALUE; int version, n, i; int temp; int ThumbnailCnt; int PrimaryThumbnailNum; WideString str; DWORD dwRead; TPDocSheet *dp; SingleSheafHeader SSFHeader; // ¹öÀü ´ÙÀ½¿¡ ÀÐÀ» Çì´õ (2007. 02. 02 Annualring) if ((hf = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; if (!ReadFile(hf, &version, sizeof(int), &dwRead, NULL)) goto fail; TextVersion = version; // ¹öÀü ´ÙÀ½¿¡ ÀÖ´Â Çì´õ¸¦ Àд´Ù. (2007. 02. 02 Annualring) if (!ReadFile(hSheafFile, &SSFHeader, sizeof(SingleSheafHeader), &dwRead, NULL)) return false; if (!TextLoadFromFile(hf, str)) return false; //ÇÊ¿ä¾ø´Â °ªÀÌÁö¸¸ ±×³É Àд´Ù. if (version >= 8) { if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if (!TextLoadFromFile(hf, str)) return false; if(version >=12){ //by linuxjun for ¾ÆÀ̺ñ ¿ä±¸»çÇ× Add Sheaf½Ã ¿¡·¯³ª´Â ¹®Á¦¼öÁ¤À§ÇØ. if (!ReadFile(hf, &temp, sizeof(int), &dwRead, NULL)) goto fail; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } } if (!ReadFile(hf, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 11){ //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ Àоî¿Â´Ù if (!ReadFile(hf, &ThumbnailCnt, sizeof(int), &dwRead, NULL)) goto fail; if(ThumbnailCnt>0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hf, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. LoadThumbnailImage(hSheafFile); } } // ÆÄÀÏ ¿©·¯°³ ÇÕÄ¡±â ¸¸µé°Å¸é ÀÌÂÊÀ» Àß º¼°Í. LoadFromFile À̿ܿ¡µµ ó¸®ÇؾßÇÒ °ÍµéÀÌ ÀÖ´Ù. (2007. 01. 08 Annualring) for (i = 0; i < n; i++) { // ¸í½ÃÀûÀ¸·Î false·Î ÇØ¼­ Àоî¿Â´Ù. (2007. 02. 21 Annualring) dp = new TPDocSheet(this, false); if (!dp->LoadFromFile(hf, version)) goto fail; Sheet->Add(dp); dp->ID = ID; if (FVectorLoadFromFile && version > 8) { bool isVector; if (!ReadFile(hf, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; // if (isVector) FVectorLoadFromFile(hf, Sheet->Count); if (isVector) FVectorLoadFromFile(hf, Sheet->Count-1); //Sheet->Add(dp);¸¦ ¹Ø¿¡¼­ À§·Î ¿Ã·ÈÀ¸¹Ç·Î Sheet->Count-1 ·Î ¹Ù²Þ. } //dp->ID = ID++; ID++; } CloseHandle(hf); return true; fail: RemoveData(); if (hf!=INVALID_HANDLE_VALUE) CloseHandle(hf); return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheaf::ChangeToReadOnlyMode() { if (hSheafFile!=INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); } if ((hSheafFile = CreateFileW(FileName.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) { // bHasHandle = true; return false; } return true; } //--------------------------------------------------------------------------- // SaveToFileÇÔ¼öÀÇ º¸Á¶ÇÔ¼ö (2007. 02. 01 Annualring) bool __fastcall TPDocSheaf::SaveThumbnailToFile(HANDLE hFile) { TPDocThumbnailImage* ThumbnailElement = NULL; TPDocSheet* ThumbnailSheet = NULL; TPDocSheet* tempSheet = NULL; TPDocElement *sep; DWORD dwWrite; int ThumbnailCnt; int PrimaryThumbnailNum; //11¿¡¼­ Ãß°¡µÈ ºÎºÐÀÓ|----> //Sheaf¾È¿¡ ÀÖ´Â ThumbnailImage¸¦ ã¾Æ³½´Ù. //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ ¼¼¼­ ÀúÀåÇϰí, primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ ÀúÀåÇÑ´Ù. ThumbnailCnt = 0; for (int i = 0; i < Sheet->Count; i++){ tempSheet = (TPDocSheet *)Sheet->Items[i]; for (int j = 0; j < tempSheet->Element->Count; j++) { sep = (TPDocElement *)tempSheet->Element->Items[j]; if (sep->Type == detThumbnailImage) { // tempSheet->RemoveDataWithoutUndoSave(sep); ThumbnailSheet = tempSheet; ThumbnailElement = (TPDocThumbnailImage *)sep; ThumbnailCnt++; } } } if (!WriteFile(hFile, &ThumbnailCnt, sizeof(int), &dwWrite, NULL)) return false; //ThumbnailÀ̹ÌÁöÀÇ °¹¼ö¸¦ ¼¼¼­ ÀúÀåÇϰí, primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ ÀúÀåÇÑ´Ù. if(ThumbnailCnt>0){ PrimaryThumbnailNum = 0; //Áö±ÝÀº 0¹øÂ° À̹ÌÁö°¡ ¹«Á¶°Ç primary°¡ µÊ. if (!WriteFile(hFile, &PrimaryThumbnailNum, sizeof(int), &dwWrite, NULL)) return false; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ ÀúÀåÇÑ´Ù. // ThumbnailSheet->SaveThumbnailImage(hFile, ThumbnailElement); SaveThumbnailImage(hFile, ThumbnailSheet, ThumbnailElement); } //<-----|11¿¡¼­ Ãß°¡µÈ ºÎºÐ return true; } //--------------------------------------------------------------------------- // SaveToFileÇÔ¼öÀÇ º¸Á¶ÇÔ¼ö (2007. 02. 01 Annualring) bool __fastcall TPDocSheaf::SaveTitlesToFile(HANDLE hFile) { if (!TextSaveToFile(hFile, Title)) return false; if (!TextSaveToFile(hFile, Title1)) return false; if (!TextSaveToFile(hFile, Title2)) return false; if (!TextSaveToFile(hFile, Title3)) return false; if (!TextSaveToFile(hFile, Title4)) return false; // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } //--------------------------------------------------------------------------- /* Todo: ! ÇöÀç·Î¼­´Â SaveToFile, SaveSingleSheafToFileµîÀ¸·Î ¿ëµµ¿¡ µû¶ó ÇÔ¼ö¸¦ ³ª´©¾î µÎ¾úÁö¸¸ °á±¹¿¡´Â Çϳª·Î ÇÕÃľßÇÒ °ÍÀÌ´Ù. (2007. 02. 01 Annualring) */ /* bool __fastcall TPDocSheaf::SaveToFile(AnsiString Filename) { // HANDLE hFile = INVALID_HANDLE_VALUE; // int version = 1, n, i; //version===> must be same to version of Sheet // int version = 2, n, i; //version===> must be same to version of Sheet // int version = 3, n, i; //version===> must be same to version of Sheet // int version = 4, n, i; //version===> must be same to version of Sheet // int version = 5, n, i; //version===> must be same to version of Sheet // int version = 6, n, i; //version===> must be same to version of Sheet // int version = 7, n, i; //version===> must be same to version of Sheet // int version = 8, n, i; //version===> must be same to version of Sheet (qe up 2002.1) // int version = 9, n, i; //version===> must be same to version of Sheet (GreenFish up 2003.2) // int version = 10, n, i; //version===> must be same to version of Sheet (GreenFish up 2003.2) // int version = 11, n, i; //version===> must be same to version of Sheet (GreenFish up 2003.2) // int version = 12, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // int version = 13, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // int version = 14, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ int version = 15, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // int ThumbnailCnt; // int PrimaryThumbnailNum; DWORD dwWrite; TPDocSheet *dp; // TPDocElement *sep; // TPDocThumbnailImage *ThumbnailElement; // TPDocSheet *ThumbnailSheet,*tempSheet; // TPDocSheet* tempSheet; // bool bHasHandle = false; // if ((hFile = CreateFile(Filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, // FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; // ¹®Á¦ÀÇ ¼ÒÁö°¡ ÀÖÀ½. ÆÄÀÏÀÌ ¾øÀ» ¶§ ¿¡·¯°¡ ³² (2007. 01. 08 Annualring) if (FileName.AnsiCompareIC(Filename)) { if (hSheafFile!=INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); } if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { // bHasHandle = true; goto fail; } } if (SetFilePointer(hSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hSheafFile, &version, sizeof(int), &dwWrite, NULL)) goto fail; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hSheafFile)) return false; if (!WriteFile(hSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. n = Sheet->Count; if (!WriteFile(hSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; if (!dp->SaveToFile(hSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ // if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, i); // version 9¿¡¼­ Ãß°¡ } // SetEndOfFile(hSheafFile); //weave¿¡·¯¸¦ ÅëÇØ Àǽɳª´Â ºÎºÐ CreateFileMappingÀÌ ÀÖÀ¸¸é Á¶½ÉÇØ¾ßÇÔ by linuxjun Modify=false; // CloseHandle(hSheafFile); return true; fail: //if (hSheafFile!=INVALID_HANDLE_VALUE) { //CloseHandle(hSheafFile); //DeleteFile(Filename.c_str()); //} ///* ÀúÀå°ü·Ã ¿¡·¯¼öÁ¤À» À§ÇØ È¤½Ã³ª ÇØ¼­ ³Ö¾î º½. ¿¡·¯¸¦ ¼öÁ¤ÇÒ¼öÀÖÀ»Áö ¾øÀ»Áö´Â ¾Ë¼ö ¾øÀ½. ¼öÁ¤µÆ±æ...±â¿öÇϸç.. by linuxjun // if ( bHasHandle && hSheafFile == INVALID_HANDLE_VALUE ){ if ( hSheafFile == INVALID_HANDLE_VALUE ){ if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFile(Filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } } // return false; } //--------------------------------------------------------------------------- */ /* Todo: ! ÇöÀç·Î¼­´Â SaveToFile, SaveSingleSheafToFileµîÀ¸·Î ¿ëµµ¿¡ µû¶ó ÇÔ¼ö¸¦ ³ª´©¾î µÎ¾úÁö¸¸ °á±¹¿¡´Â Çϳª·Î ÇÕÃľßÇÒ °ÍÀÌ´Ù. (2007. 02. 01 Annualring) */ bool __fastcall TPDocSheaf::SaveToFile(WideString Filename) { // HANDLE hFile = INVALID_HANDLE_VALUE; // int version = 1, n, i; //version===> must be same to version of Sheet // int version = 2, n, i; //version===> must be same to version of Sheet // int version = 3, n, i; //version===> must be same to version of Sheet // int version = 4, n, i; //version===> must be same to version of Sheet // int version = 5, n, i; //version===> must be same to version of Sheet // int version = 6, n, i; //version===> must be same to version of Sheet // int version = 7, n, i; //version===> must be same to version of Sheet // int version = 8, n, i; //version===> must be same to version of Sheet (qe up 2002.1) // int version = 9, n, i; //version===> must be same to version of Sheet (GreenFish up 2003.2) // int version = 10, n, i; //version===> must be same to version of Sheet (GreenFish up 2003.2) // int version = 11, n, i; //version===> must be same to version of Sheet (GreenFish up 2003.2) // int version = 12, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // int version = 13, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // int version = 14, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // int version = 15, n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ // version 16 // 15->16 À¯´ÏÄÚµå Áö¿ø ¹æ½ÄÀ¸·Î º¯°æ // version 17 // 16->17 ¼¿ ¹è°æ»ö ¹× ¹«´Ì Á¤º¸ Ãß°¡ // version 18 // 17->18 ¼¿ Å׵θ® »ö ÀúÀå type ¼öÁ¤ // version 19 // 18->19 Auto Line Feed Ãß°¡ int n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ if(version <16){ SaveVersion = 15; } else { SaveVersion = CURRENT_VERSION;//version; } // int ThumbnailCnt; // int PrimaryThumbnailNum; DWORD dwWrite; TPDocSheet *dp; // TPDocElement *sep; // TPDocThumbnailImage *ThumbnailElement; // TPDocSheet *ThumbnailSheet,*tempSheet; // TPDocSheet* tempSheet; // bool bHasHandle = false; // if ((hFile = CreateFile(Filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, // FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) goto fail; /* // ¹®Á¦ÀÇ ¼ÒÁö°¡ ÀÖÀ½. ÆÄÀÏÀÌ ¾øÀ» ¶§ ¿¡·¯°¡ ³² (2007. 01. 08 Annualring) if (UpperCase(FileName) == UpperCase(FileName)){ if (hSheafFile!=INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); } if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { // bHasHandle = true; goto fail; } } if (SetFilePointer(hSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hSheafFile, &SaveVersion, sizeof(int), &dwWrite, NULL)) goto fail; TextVersion = SaveVersion; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hSheafFile)) return false; if (!WriteFile(hSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. n = Sheet->Count; if (!WriteFile(hSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; dp->bSaveAsSmallImage = bSaveAsSmallImage; if (!dp->SaveToFile(hSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ // if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, i); // version 9¿¡¼­ Ãß°¡ } // SetEndOfFile(hSheafFile); //weave¿¡·¯¸¦ ÅëÇØ Àǽɳª´Â ºÎºÐ CreateFileMappingÀÌ ÀÖÀ¸¸é Á¶½ÉÇØ¾ßÇÔ by linuxjun Modify=false; // CloseHandle(hSheafFile); return true; */ if (UpperCase(FileName) == UpperCase(Filename)) { if (hSheafFile != INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); hSheafFile = INVALID_HANDLE_VALUE; } } HANDLE hTempSheafFile = INVALID_HANDLE_VALUE; //fileÀ» ÀúÀåÇÒ¶§ Àӽà handleÀ» °¡Áö°í »ç¿ëÇϰí ÀúÀåÀÌ ¿Ï·áµÇ¸é hSheafFile¿¡ update½ÃŰ°í ½ÇÆÐÇϸé fileÀ» Áö¿ì°í ´Ý¾ÆÁØ´Ù. // ½Äº°¹øÈ£ 190823 hTempSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL); if (hTempSheafFile == INVALID_HANDLE_VALUE) goto fail; if (SetFilePointer(hTempSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hTempSheafFile, &SaveVersion, sizeof(int), &dwWrite, NULL)) goto fail; TextVersion = SaveVersion; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hTempSheafFile)) return false; if (!WriteFile(hTempSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. n = Sheet->Count; if (!WriteFile(hTempSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hTempSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; dp->bSaveAsSmallImage = bSaveAsSmallImage; if (!dp->SaveToFile(hTempSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hTempSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ // if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, i); // version 9¿¡¼­ Ãß°¡ } // SetEndOfFile(hSheafFile); //weave¿¡·¯¸¦ ÅëÇØ Àǽɳª´Â ºÎºÐ CreateFileMappingÀÌ ÀÖÀ¸¸é Á¶½ÉÇØ¾ßÇÔ by linuxjun Modify=false; // CloseHandle(hSheafFile); if (hSheafFile != INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); hSheafFile = hTempSheafFile; return true; fail: //if (hSheafFile!=INVALID_HANDLE_VALUE) { //CloseHandle(hSheafFile); //DeleteFile(Filename.c_str()); //} /* ÀúÀå°ü·Ã ¿¡·¯¼öÁ¤À» À§ÇØ È¤½Ã³ª ÇØ¼­ ³Ö¾î º½. ¿¡·¯¸¦ ¼öÁ¤ÇÒ¼öÀÖÀ»Áö ¾øÀ»Áö´Â ¾Ë¼ö ¾øÀ½. ¼öÁ¤µÆ±æ...±â¿öÇϸç.. by linuxjun // if ( bHasHandle && hSheafFile == INVALID_HANDLE_VALUE ){ if ( hSheafFile == INVALID_HANDLE_VALUE ){ if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } } */ //ÀúÀåÀ» ½ÇÆÐÇÑ °æ¿ì file handleÀ» ´Ý°í fileÀÌ ÀúÀåµÈ °ÍÀÌ ÀÖÀ¸¸é »èÁ¦ÇÑ´Ù. if (hTempSheafFile != INVALID_HANDLE_VALUE) { CloseHandle(hTempSheafFile); } if(FileExists(Filename)) DeleteFileW(Filename.c_bstr()); return false; } //--------------------------------------------------------------------------- // ÇÔ¼ö Ãß°¡ (2007. 01. 31 Annualring) // EditableÇÑ Sheet¸¸ ÀúÀåÇϵµ·Ï ÇÑ´Ù. ±× ¿ÜÀÇ ±â´ÉÀº ±âÁ¸ÀÇ SaveToFile°ú °°´Ù. bool __fastcall TPDocSheaf::SaveToSingleSheafFile(WideString Filename) { // version = 16; int n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ DWORD dwWrite; TPDocSheet *dp; SingleSheafHeader SSFHeader; // ¹öÀü ´ÙÀ½¿¡ ³ÖÀ» Çì´õ (2007. 02. 01 Annualring) /* // ¹®Á¦ÀÇ ¼ÒÁö°¡ ÀÖÀ½. ÆÄÀÏÀÌ ¾øÀ» ¶§ ¿¡·¯°¡ ³² (2007. 01. 08 Annualring) if (UpperCase(FileName) == UpperCase(FileName)) { if (hSheafFile!=INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); } if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } } if (SetFilePointer(hSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hSheafFile, &version, sizeof(int), &dwWrite, NULL)) goto fail; TextVersion = version; // ¹öÀü ´ÙÀ½¿¡ Çì´õ¸¦ ³Ö´Â´Ù. (2007. 02. 01 Annualring) if (!WriteFile(hSheafFile, &SSFHeader, sizeof(SingleSheafHeader), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hSheafFile)) return false; if (!WriteFile(hSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. // Editable Sheet Count·Î ¼öÁ¤ (2007. 01. 31 Annualring) n = GetEditableSheetCount(); if (!WriteFile(hSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; n = Sheet->Count; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; // Editable Sheet¸¸ ÀúÀåÇϵµ·Ï ¼öÁ¤ (2007. 01. 31 Annualring) if (dp->Editable) { if (!dp->SaveToFile(hSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ } } // SetEndOfFile(hSheafFile); //weave¿¡·¯¸¦ ÅëÇØ Àǽɳª´Â ºÎºÐ CreateFileMappingÀÌ ÀÖÀ¸¸é Á¶½ÉÇØ¾ßÇÔ by linuxjun Modify=false; // CloseHandle(hSheafFile); return true; */ if (UpperCase(FileName) == UpperCase(Filename)) { if (hSheafFile != INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); hSheafFile = INVALID_HANDLE_VALUE; } } HANDLE hTempSheafFile; //fileÀ» ÀúÀåÇÒ¶§ Àӽà handleÀ» °¡Áö°í »ç¿ëÇϰí ÀúÀåÀÌ ¿Ï·áµÇ¸é hSheafFile¿¡ update½ÃŰ°í ½ÇÆÐÇϸé fileÀ» Áö¿ì°í ´Ý¾ÆÁØ´Ù. hTempSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL); if (hTempSheafFile == INVALID_HANDLE_VALUE) goto fail; if (SetFilePointer(hSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hSheafFile, &version, sizeof(int), &dwWrite, NULL)) goto fail; TextVersion = version; // ¹öÀü ´ÙÀ½¿¡ Çì´õ¸¦ ³Ö´Â´Ù. (2007. 02. 01 Annualring) if (!WriteFile(hSheafFile, &SSFHeader, sizeof(SingleSheafHeader), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hSheafFile)) return false; if (!WriteFile(hSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. // Editable Sheet Count·Î ¼öÁ¤ (2007. 01. 31 Annualring) n = GetEditableSheetCount(); if (!WriteFile(hSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; n = Sheet->Count; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; // Editable Sheet¸¸ ÀúÀåÇϵµ·Ï ¼öÁ¤ (2007. 01. 31 Annualring) if (dp->Editable) { if (!dp->SaveToFile(hSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ } } // SetEndOfFile(hSheafFile); //weave¿¡·¯¸¦ ÅëÇØ Àǽɳª´Â ºÎºÐ CreateFileMappingÀÌ ÀÖÀ¸¸é Á¶½ÉÇØ¾ßÇÔ by linuxjun Modify=false; // CloseHandle(hSheafFile); if (hSheafFile != INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); hSheafFile = hTempSheafFile; return true; fail: /* ÀúÀå°ü·Ã ¿¡·¯¼öÁ¤À» À§ÇØ È¤½Ã³ª ÇØ¼­ ³Ö¾î º½. ¿¡·¯¸¦ ¼öÁ¤ÇÒ¼öÀÖÀ»Áö ¾øÀ»Áö´Â ¾Ë¼ö ¾øÀ½. ¼öÁ¤µÆ±æ...±â¿öÇϸç.. by linuxjun // fail µÚ¿¡ goto failÀÌ À־ ¹«ÇÑ·çÇÁÀÇ À§ÇèÀÌ ÀÖÀ½. ¹Ýµå½Ã °íÃÄ¾ß ÇÔ. (2007. 02. 01 Annualring) // if ( bHasHandle && hSheafFile == INVALID_HANDLE_VALUE ){ if ( hSheafFile == INVALID_HANDLE_VALUE ) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } } */ if (hTempSheafFile != INVALID_HANDLE_VALUE) CloseHandle(hTempSheafFile); if(FileExists(Filename)) DeleteFileW(Filename.c_bstr()); return false; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheaf::SaveToMultiSheafFile(WideString Filename) { // version = 16; int n, i; //version===> must be same to version of Sheet //for ¾ÆÀ̺ñ DWORD dwWrite; TPDocSheet *dp; /* // ¹®Á¦ÀÇ ¼ÒÁö°¡ ÀÖÀ½. ÆÄÀÏÀÌ ¾øÀ» ¶§ ¿¡·¯°¡ ³² (2007. 01. 08 Annualring) if (UpperCase(FileName) == UpperCase(FileName)) { if (hSheafFile!=INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); } if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } } if (SetFilePointer(hSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hSheafFile, &version, sizeof(int), &dwWrite, NULL)) goto fail; TextVersion = version; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hSheafFile)) return false; if (!WriteFile(hSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. n = Sheet->Count; if (!WriteFile(hSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; if (!dp->SaveToFile(hSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ } Modify=false; return true; */ if (UpperCase(FileName) == UpperCase(Filename)) { if (hSheafFile != INVALID_HANDLE_VALUE) { CloseHandle(hSheafFile); hSheafFile = INVALID_HANDLE_VALUE; } } HANDLE hTempSheafFile; //fileÀ» ÀúÀåÇÒ¶§ Àӽà handleÀ» °¡Áö°í »ç¿ëÇϰí ÀúÀåÀÌ ¿Ï·áµÇ¸é hSheafFile¿¡ update½ÃŰ°í ½ÇÆÐÇϸé fileÀ» Áö¿ì°í ´Ý¾ÆÁØ´Ù. hTempSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL); if (hTempSheafFile == INVALID_HANDLE_VALUE) goto fail; if (SetFilePointer(hSheafFile, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!WriteFile(hSheafFile, &version, sizeof(int), &dwWrite, NULL)) goto fail; TextVersion = version; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveTitlesToFile(hSheafFile)) return false; if (!WriteFile(hSheafFile, &StepNumber, sizeof(int), &dwWrite, NULL)) return false; //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. n = Sheet->Count; if (!WriteFile(hSheafFile, &n, sizeof(int), &dwWrite, NULL)) return false; // º¸Á¶ÇÔ¼ö·Î ´ëü (2007. 02. 01 Annualring) if (!SaveThumbnailToFile(hSheafFile)) return false; for (i = 0; i < n; i++) { dp = (TPDocSheet *)Sheet->Items[i]; if (!dp->SaveToFile(hSheafFile)) return false; if (FVectorSaveToFile) FVectorSaveToFile(hSheafFile, dp->ID); // version 9¿¡¼­ Ãß°¡ } Modify=false; if (hSheafFile != INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); hSheafFile = hTempSheafFile; return true; fail: /* if ( hSheafFile == INVALID_HANDLE_VALUE ) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { if ((hSheafFile = CreateFileW(Filename.c_bstr(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE) goto fail; } } */ if (hTempSheafFile != INVALID_HANDLE_VALUE) CloseHandle(hTempSheafFile); if(FileExists(Filename)) DeleteFileW(Filename.c_bstr()); return false; } //--------------------------------------------------------------------------- //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. bool __fastcall TPDocSheaf::SaveToJPGFile(WideString Filename) { WideString fn, ext; ext = ".jpg"; wchar_t * TempString; TPDocSheet *dp; TPDocElement *sep; TPDocThumbnailImageJPG *ThumbnailElement; TPDocSheet *ThumbnailSheet,*tempSheet; TTexpiaBitmap *ThumbnailImage; TTexpiaBitmap *tempImage; bool result; int ThumbnailCnt,StringLength; ThumbnailElement = NULL; ThumbnailSheet = NULL; ThumbnailCnt = 0; bool bGym = false; int index; for (int i = 0; i < Sheet->Count; i++){ tempSheet = (TPDocSheet *)Sheet->Items[i]; for (int j = 0; j < tempSheet->Element->Count; j++) { sep = (TPDocElement *)tempSheet->Element->Items[j]; //Elite¿¡¼­ JPG¸ðµå¸¦ »ç¿ëÇÏÁö ¾Ê°í Thumbnail¸¸ »ç¿ëÇϱ⠶§¹®¿¡ //Thumbnail¿µ¿ªÀ» jpg·Î ÀúÀåÇϱ⸦ ¿øÇؼ­ Á¶°Ç¹®À» ¹Ù²å½À´Ï´Ù - 191025 ½Å±â¼· #ifdef ELLITE_BASIC if (sep->Type == detThumbnailImage) { ThumbnailSheet = tempSheet; ThumbnailElement = (TPDocThumbnailImageJPG *)sep; ThumbnailCnt++; } #else if (sep->Type == detThumbnailImageJPG) { //tempSheet->RemoveDataWithoutUndoSave(sep); ThumbnailSheet = tempSheet; ThumbnailElement = (TPDocThumbnailImageJPG *)sep; ThumbnailCnt++; } #endif #ifdef IVY_CONVERT2 else if (sep->Type == detChart) { TPDocChart* chart = (TPDocChart*)sep; TPDocElement *dp = NULL; for (int i = 0 ;i < chart->Cell->Count; i++) { dp = (TPDocElement*)chart->Cell->Items[i]; switch (dp->Type) { case detLabel: { WideString kt = ((TPDocLabel*)dp)->Text; if (kt == WideString("¸¶Å©") && i == 0) { bGym = true; } break; } } if (bGym) break; else if (i > 0) break; } } #endif } } if(ThumbnailCnt>0){ fn = Filename; //fn = ExtractFileNameW(fn); fn = fn.SubString(0,fn.Length()-4); fn = fn + ext; ThumbnailImage = NULL; tempImage = NULL; tempImage = new TTexpiaBitmap; result = ThumbnailSheet->PaintToBitmap(tempImage, 0, true); //Korean -> 0 if(result){ ThumbnailImage = new TTexpiaBitmap; ThumbnailImage->Create(ThumbnailElement->Range.right - ThumbnailElement->Range.left, ThumbnailElement->Range.bottom - ThumbnailElement->Range.top, 24); ThumbnailImage->Copy(0,0,ThumbnailElement->Range.right - ThumbnailElement->Range.left, ThumbnailElement->Range.bottom - ThumbnailElement->Range.top, tempImage, ThumbnailElement->Range.left, ThumbnailElement->Range.top, SRCCOPY); bool result = ThumbnailImage->SaveToFile(fn, FILE_LEAD2JFIF, 30, ThumbnailSheet->DotsPerInch); // ¿©±â¼­ ThumbnailImage°¡ ÀúÀåµÈ´Ù. if (!result) return false; //201410 ¾ÆÀ̺ñ ¿äû»çÇ× - Ãß°¡·Î @ºÙ¿© jpg ÆÄÀÏ »ý¼º ¿äû #ifdef IVY_CONVERT2 TTexpiaBitmap *tempImage2; AnsiString filePath2 = fn; AnsiString fileName2 = ExtractFileName(filePath2); filePath2 = filePath2.SubString(1, filePath2.Pos(fileName2)-1); fn = filePath2 + "@" + fileName2; if (TRect(ThumbnailElement->Range) == TRect(16,160,1192,872)) {//ÇлýºÀ tempImage2 = new TTexpiaBitmap; tempImage2->Create(830-58, 565-4, 24); tempImage2->Copy(0,0,830-58, 565-4, ThumbnailImage, 58, 4, SRCCOPY); tempImage2->SaveToFile(fn, FILE_LEAD2JFIF, 30, ThumbnailSheet->DotsPerInch); delete tempImage2; tempImage2 = NULL; } else if (TRect(ThumbnailElement->Range) == TRect(16,168,1192,968)) { tempImage2 = new TTexpiaBitmap; if (bGym) {//üÀ°º¹ tempImage2->Create(940-1, 534-42, 24); tempImage2->Copy(0,0,940-1, 534-42, ThumbnailImage, 1, 42, SRCCOPY); tempImage2->SaveToFile(fn, FILE_LEAD2JFIF, 30, ThumbnailSheet->DotsPerInch); } else { //»ýȰº¹ tempImage2->Create(840-1,610-1, 24); tempImage2->Copy(0,0,840-1,610-1, ThumbnailImage, 1, 1, SRCCOPY); tempImage2->SaveToFile(fn, FILE_LEAD2JFIF, 30, ThumbnailSheet->DotsPerInch); } delete tempImage2; tempImage2 = NULL; } #endif } if(tempImage){delete tempImage; tempImage = NULL;} if(ThumbnailImage){delete ThumbnailImage; ThumbnailImage = NULL;} return true; }else{ return false; } } //--------------------------------------------------------------------------- //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. //-->for ¾ÆÀ̺ñ ¿ä±¸»çÇ×.for TextDB bool __fastcall TPDocSheaf::LoadFromTextDBFile(WideString Filename) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { TPDocSheet *tempSheet; TPDocElement *sep; int SheetNum; WideString FieldName; WideString FieldValue; TPTextIn *IOManager = new TPTextIn(); IOManager->LoadFromFile(Filename); for(int i = 0; iGetCount();i++){ if(!IOManager->IsOK(i))continue; //¿¡·¯ Çڵ鸵 SheetNum = IOManager->GetSheetNum(i); if(SheetNum >= Sheet->Count)continue;//¿¡·¯ Çڵ鸵 FieldName = IOManager->GetFieldName(i); FieldValue = IOManager->GetFieldValue(i); tempSheet = (TPDocSheet *)Sheet->Items[SheetNum]; for (int j = 0; j < tempSheet->Element->Count; j++) { sep = (TPDocElement *)tempSheet->Element->Items[j]; switch(sep->Type){ // case detColorChip: case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocEdit *)sep)->K_Text,&(sep->Range)); if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocEdit *)sep)->K_Text=FieldValue; } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocNumber *)sep)->Number,&(sep->Range)); if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocNumber *)sep)->Number=FieldValue; } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocFormula *)sep)->ANumber,&(sep->Range)); if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocFormula *)sep)->ANumber=FieldValue; } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocDate *)sep)->Date,&(sep->Range)); if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocDate *)sep)->Date=FieldValue; } break; case detInput: sep = ((TPDocInput *)sep)->IPElement; switch(sep->Type){ case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocEdit *)sep)->K_Text=FieldValue; } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocNumber *)sep)->Number=FieldValue; } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocFormula *)sep)->ANumber=FieldValue; } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocDate *)sep)->Date=FieldValue; } break; } break; case detChart: TPDocChart *cp = (TPDocChart *)sep; int cnt = cp->Cell->Count; for(int k=0; kCell->Items[k]; switch (sep->Type) { case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocEdit *)sep)->K_Text=FieldValue; } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocNumber *)sep)->Number=FieldValue; } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocFormula *)sep)->ANumber=FieldValue; } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ if(((TPDocText *)sep)->FieldName == FieldName) ((TPDocDate *)sep)->Date=FieldValue; } break; } } break; } } } delete IOManager; return true; } //--------------------------------------------------------------------------- bool __fastcall TPDocSheaf::SaveToTextDBFile(WideString Filename) //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB { WideString fn, ext; ext = ".txt"; char * TempString; TPDocSheet *dp; TPDocElement *sep; // TPDocThumbnailImage *ThumbnailElement; // TPDocSheet *ThumbnailSheet,*tempSheet; TPDocSheet *tempSheet; TTexpiaBitmap *ThumbnailImage; TTexpiaBitmap *tempImage; bool result; int DBElmCnt,StringLength; TPTextOut *IOManager; TStringList *SaveList; // ThumbnailElement = NULL; // ThumbnailSheet = NULL; DBElmCnt = 0; int index; for (int i = 0; i < Sheet->Count; i++){ tempSheet = (TPDocSheet *)Sheet->Items[i]; for (int j = 0; j < tempSheet->Element->Count; j++) { sep = (TPDocElement *)tempSheet->Element->Items[j]; switch(sep->Type){ // case detColorChip: case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB case detNumber: case detFormula: case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0)DBElmCnt++; break; case detInput: DBElmCnt+=tempSheet->GetFieldCount_Input((TPDocInput *)sep); break; case detChart: DBElmCnt+=tempSheet->GetFieldCount_Chart((TPDocChart *)sep); break; } } } if(DBElmCnt>0){ //fn = ChangeFileExt(Filename, ".txt"); fn = Filename; fn = fn.SubString(0,fn.Length()-4); fn += ".txt."; //index = fn.LastDelimiter("."); //LastDelimiter("."); ±¸ÇöºÎºÐ WideStringÀº LastDelimiter¸¦ Áö¿øÇÏÁö ¾Ê´Â´Ù. /* TempString = fn.c_str(); StringLength = fn.Length(); TempString[StringLength-3]='j'; TempString[StringLength-2]='p'; TempString[StringLength-1]='g'; */ /* ThumbnailImage = NULL; tempImage = NULL; tempImage = new TTexpiaBitmap; result = ThumbnailSheet->PaintToBitmap(tempImage, 0, true); //Korean -> 0 if(result){ ThumbnailImage = new TTexpiaBitmap; ThumbnailImage->Create(ThumbnailElement->Range.right - ThumbnailElement->Range.left, ThumbnailElement->Range.bottom - ThumbnailElement->Range.top, 24); ThumbnailImage->Copy(0,0,ThumbnailElement->Range.right - ThumbnailElement->Range.left, ThumbnailElement->Range.bottom - ThumbnailElement->Range.top, tempImage, ThumbnailElement->Range.left, ThumbnailElement->Range.top, SRCCOPY); ThumbnailImage->SaveToFile(fn, FILE_LEAD2JFIF, 30, ThumbnailSheet->DotsPerInch); } if(tempImage){delete tempImage; tempImage = NULL;} if(ThumbnailImage){delete ThumbnailImage; ThumbnailImage = NULL;} */ IOManager = new TPTextOut(); SaveList = new TStringList; AnsiString SheetNumStr; RECT *TempRect; for (int i = 0; i < Sheet->Count; i++){ tempSheet = (TPDocSheet *)Sheet->Items[i]; SheetNumStr=i; for (int j = 0; j < tempSheet->Element->Count; j++) { sep = (TPDocElement *)tempSheet->Element->Items[j]; switch(sep->Type){ // case detColorChip: case detEdit: //for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. for TextDB if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocEdit *)sep)->K_Text,&(sep->Range)); TempRect = new RECT; TempRect->left = sep->Range.left; TempRect->right = sep->Range.right; TempRect->top = sep->Range.top; TempRect->bottom = sep->Range.bottom; IOManager->Add(((TPDocEdit *)sep)->K_Text,TempRect); } break; case detNumber: if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocNumber *)sep)->Number,&(sep->Range)); TempRect = new RECT; TempRect->left = sep->Range.left; TempRect->right = sep->Range.right; TempRect->top = sep->Range.top; TempRect->bottom = sep->Range.bottom; IOManager->Add(((TPDocNumber *)sep)->Number,TempRect); } break; case detFormula: if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocFormula *)sep)->ANumber,&(sep->Range)); TempRect = new RECT; TempRect->left = sep->Range.left; TempRect->right = sep->Range.right; TempRect->top = sep->Range.top; TempRect->bottom = sep->Range.bottom; IOManager->Add(((TPDocFormula *)sep)->ANumber,TempRect); } break; case detDate: if(((TPDocText *)sep)->FieldName.Length() > 0){ // IOManager->Add(SheetNumStr+"|"+((TPDocText *)sep)->FieldName+"|"+((TPDocDate *)sep)->Date,&(sep->Range)); TempRect = new RECT; TempRect->left = sep->Range.left; TempRect->right = sep->Range.right; TempRect->top = sep->Range.top; TempRect->bottom = sep->Range.bottom; IOManager->Add(((TPDocDate *)sep)->Date,TempRect); } break; case detInput: if((tempSheet->GetFieldValue_Input(i, (TPDocInput *)sep)).Length()>0){ IOManager->Add(tempSheet->GetFieldValue_Input(i, (TPDocInput *)sep),tempSheet->GetFieldRange_Input(i, (TPDocInput *)sep)); } break; case detChart: if(tempSheet->GetFieldCount_Chart((TPDocChart *)sep)>0){ TStringList * InputList = new TStringList(); TList * InputRangeList = new TList(); IOManager->Add(tempSheet->GetFieldValue_Chart(i, InputList,(TPDocChart *)sep),tempSheet->GetFieldRange_Chart(i, InputRangeList,(TPDocChart *)sep)); InputList->Clear(); InputRangeList->Clear(); delete InputList; delete InputRangeList; } // DBElmCnt+=GetFieldCount_Chart(sep); break; } } SaveList->Add(IOManager->GetTextData()); IOManager->Clear(); } SaveList->SaveToFile(fn); // IOManager->SaveToFile(fn, true); delete IOManager; SaveList->Clear(); delete SaveList; return true; }else{ return false; } } //------------------------------------------------------------------------------- // by altang //<--for ¾ÆÀ̺ñ ¿ä±¸»çÇ×.for TextDB void __fastcall TPDocSheaf::SaveThumbnailImage(HANDLE hSheafFile,TPDocSheet *ThumbnailSheet, TPDocThumbnailImage *ThumbnailElement) { ThumbnailSheet->SaveThumbnailImage(hSheafFile, ThumbnailElement); } TTexpiaBitmap * __fastcall TPDocSheaf::LoadThumbnailImage(HANDLE hSheafFile) { DWORD dwRead; bool result; TTexpiaBitmap *tempImage = NULL; if (!ReadFile(hSheafFile, &result, sizeof(bool), &dwRead, NULL)) return NULL; if(result){ if (!ImageLoadFromFile(hSheafFile, tempImage)) return NULL; if(tempImage){delete tempImage; tempImage = NULL;} } return NULL; //Áö±ÝÀº ±×¸²À» loadÇÒ Çʿ䰡 ¾øÀ¸¹Ç·Î NULL ·Î ¹Ýȯ ¹ÞÀ½. } //--------------------------------------------------------------------------- int __fastcall TPDocSheaf::GetCount() { return Sheet->Count; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::AddCommonData(int n) { TPDocSheet *sheet = (TPDocSheet *)Sheet->Items[n]; sheet->AddCommonData(CommonDataMap); } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::GetCommonData(int n) { TPDocSheet *sheet = (TPDocSheet *)Sheet->Items[n]; sheet->GetCommonData(CommonDataMap); } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::SetCommonData(int n) { TPDocSheet *sheet = (TPDocSheet *)Sheet->Items[n]; sheet->SetCommonData(CommonDataMap); } //--------------------------------------------------------------------------- // ÆíÁý °¡´É ½ÃÆ® ¼ö¸¦ ¸®ÅÏÇÏ´Â ÇÔ¼ö (2007. 02. 08 Annualring) int __fastcall TPDocSheaf::GetEditableSheetCount() { int i, result; TPDocSheet *sheet; result = 0; for (i = 0; i < Sheet->Count; i++) { sheet = (TPDocSheet *)Sheet->Items[i]; if (sheet->Editable) { result++; } } return result; } //--------------------------------------------------------------------------- void __fastcall TPDocSheaf::EraseCommonData(TPDocElementType elementType, AnsiString name) { typedef TPDocCommonDataMap::key_type key_type; CommonDataMap.erase(key_type(name)); } //--------------------------------------------------------------------------- bool __fastcall LoadImageFromFile(WideString FileName,DWORD pos,TTexpiaBitmap *&Image) { DWORD dwRead; int w, h; WORD bpp; RGBQUAD rgb[256]; HANDLE hFile = CreateFileW(FileName.c_bstr(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL); SetFilePointer(hFile, pos, 0, FILE_BEGIN); if (!ReadFile(hFile, &bpp, sizeof(WORD), &dwRead, NULL)) goto fail; if (bpp) { if (!ReadFile(hFile, &w, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &h, sizeof(int), &dwRead, NULL)) goto fail; if(Image){ // if(w!=Image->Width || h != Image->Height){ delete Image; Image = NULL; // }else{ // if (!ReadFile(hFile, rgb, 256 * sizeof(RGBQUAD), &dwRead, NULL)) goto fail; // } } if (Image == NULL){ if ((Image = new TTexpiaBitmap) == NULL) goto fail; if (bpp == 8) { if (!ReadFile(hFile, rgb, 256 * sizeof(RGBQUAD), &dwRead, NULL)) goto fail; if (!Image->Create(w, h, bpp, rgb)) goto fail; } else { if (!Image->Create(w, h, bpp)) goto fail; } } if (!Image->LoadFromTexpiaFile(hFile, cmNone)) goto fail; }else{ if(Image != NULL){ delete Image; Image = NULL; } } CloseHandle(hFile); return true; fail: // if (Image) { delete Image; Image = NULL; } CloseHandle(hFile); return false; } //--------------------------------------------------------------------------- bool __fastcall SaveImageToFile(WideString FileName,DWORD pos, TTexpiaBitmap *Image,bool bClipboard) { DWORD dwWrite; int w, h; WORD bpp; RGBQUAD rgb[256]; TTexpiaBitmap *ImageToSave = NULL; HANDLE hFile = CreateFileW(FileName.c_bstr(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL); SetFilePointer(hFile, pos, 0, FILE_BEGIN); if (Image && (Image->Width != 0 && Image->Height != 0)) { if (!ImageCopy(ImageToSave,Image)) return false; bpp = Image->BitsPerPixel; if (!WriteFile(hFile, &bpp, sizeof(WORD), &dwWrite, NULL)) goto fail; w = Image->Width; if (!WriteFile(hFile, &w, sizeof(int), &dwWrite, NULL)) goto fail; h = Image->Height; if (!WriteFile(hFile, &h, sizeof(int), &dwWrite, NULL)) goto fail; if (bpp == 8) { Image->GetColors(0, 256, rgb); if (!WriteFile(hFile, rgb, 256 * sizeof(RGBQUAD), &dwWrite, NULL)) goto fail; } // if(bClipboard) L_FlipBitmap(Image->Handle); if (!ImageToSave->SaveToTexpiaFile(hFile, cmNone)) goto fail; // if(bClipboard) L_FlipBitmap(Image->Handle); } else { bpp = 0; if (!WriteFile(hFile, &bpp, sizeof(WORD), &dwWrite, NULL)) goto fail; } delete ImageToSave; CloseHandle(hFile); return true; fail: // if (Image) { delete Image; Image = NULL; } CloseHandle(hFile); return false; } //--------------------------------------------------------------------------- __fastcall TPUndo::TPUndo() { DataOfUndo = new TList; IndexOfUndo = -1; /* blurBitmap = _blurBitmap; previewBitmap = _previewBitmap; tempBitmap = _tempBitmap; WorkArea = _WorkArea; */ FileName = GetUndoFileName(); pos = 0; IsFirstRedo=true; CurrentBundle = NULL; } //--------------------------------------------------------------------------- WideString __fastcall TPUndo::GetUndoFileName(){ char tp[MAX_PATH+1], fn[MAX_PATH+1]; GetTempPath(MAX_PATH, tp); if (tp[strlen(tp)-1]=='\\') tp[strlen(tp)-1] = 0; while (1) { sprintf(fn, "%s\\TexWork%05X.do", tp, rand() & 0xFFFFF); if (!FileExists(fn)) break; } return (WideString)fn; } //--------------------------------------------------------------------------- __fastcall TPUndo::~TPUndo() { ExitUndo(); } void __fastcall TPUndo::ExitUndo(){ while(DataOfUndo->Count>IndexOfUndo+1){ RemoveLast(); } while(DataOfUndo->Count){ RemoveFirst(); } /* while(DataOfUndo->Count){ RemoveLast(); } */ delete DataOfUndo; if (FileExists(FileName)) DeleteFile(FileName); } //--------------------------------------------------------------------------- bool __fastcall TPUndo::canundo() { return DataOfUndo->Count>0 && IndexOfUndo>-1; } //--------------------------------------------------------------------------- bool __fastcall TPUndo::canredo() { return IndexOfUndo < DataOfUndo->Count-1; } //--------------------------------------------------------------------------- void __fastcall TPUndo::AddUndoStep() { /* º¹ÀâÇÑ ÀÌÀ¯·Î À̺κÐÀÌ ¸·¾ÆÁ®¾ß ÇÔ. Index°ü¸®¸¦ À§ÇØ ÇÊ¿äÇÔ. if(CurrentBundle!=NULL){ if(CurrentBundle->BundleOfUndoData->Count==0)return; } */ CurrentBundle = new TPUndoBundle(this); IndexOfUndo++; int TempIndex = IndexOfUndo; while(DataOfUndo->Count > TempIndex) { RemoveLast(); } IndexOfUndo = TempIndex; DataOfUndo->Add(CurrentBundle); } //--------------------------------------------------------------------------- void __fastcall TPUndo::AddToUndoBundle(TPDocObjectUndoData * tdu){ if(CurrentBundle == NULL) AddUndoStep(); TPDocObjectUndoData * TempUndoData = NULL; if(CurrentBundle->BundleOfUndoData->Count>0){ for(int i = 0;iBundleOfUndoData->Count;i++){ TempUndoData = (TPDocObjectUndoData *)CurrentBundle->BundleOfUndoData->Items[i]; if(TempUndoData->SrcData==tdu->SrcData){ // CurrentBundle->RemoveLastUndo(); CurrentBundle->DeleteData(tdu); //Áߺ¹µÇ¼­ AddToUndoBundleµÈ°æ¿ì´Â óÀ½°ÍÀ» ³²°ÜµÐ´Ù. return; } } } CurrentBundle->AddUndoData(tdu); } void __fastcall TPUndo::AddToDeleteUndoBundle(TPDocObjectUndoData * tdu){ TPDocObjectUndoData * TempUndoData = NULL; if(CurrentBundle->BundleOfUndoData->Count>0){ for(int i = 0;iBundleOfUndoData->Count;i++){ TempUndoData = (TPDocObjectUndoData *)CurrentBundle->BundleOfUndoData->Items[i]; if(TempUndoData->SrcData==tdu->SrcData){ // CurrentBundle->RemoveLastUndo(); if(TempUndoData->bDeleted==true) { CurrentBundle->DeleteData(tdu); //Áߺ¹µÇ¼­ AddToUndoBundleµÈ°æ¿ì´Â óÀ½°ÍÀ» ³²°ÜµÐ´Ù. return; } } } } tdu->bDeleted = true; CurrentBundle->AddUndoData(tdu); } void __fastcall TPUndo::AddToCreateUndoBundle(TPDocObjectUndoData * tdu){ TPDocObjectUndoData * TempUndoData = NULL; if(CurrentBundle->BundleOfUndoData->Count>0){ for(int i = 0;iBundleOfUndoData->Count;i++){ TempUndoData = (TPDocObjectUndoData *)CurrentBundle->BundleOfUndoData->Items[i]; if(TempUndoData->SrcData==tdu->SrcData){ // CurrentBundle->RemoveLastUndo(); if(TempUndoData->bCreated==true) { CurrentBundle->DeleteData(tdu); //Áߺ¹µÇ¼­ AddToUndoBundleµÈ°æ¿ì´Â óÀ½°ÍÀ» ³²°ÜµÐ´Ù. return; } } } } tdu->bCreated = true; CurrentBundle->AddUndoData(tdu); } /* void __fastcall TPUndo::AddToRedoBundle(TPDocObjectUndoData * tdu){ CurrentBundle->AddRedoData(tdu); } */ /* void __fastcall TPUndo::GetSaveFileInfo(AnsiString &fileName, DWORD &posi, TTexpiaBitmap *Image){ fileName = FileName; posi = pos; SaveImageToFile(fileName, posi,Image); pos += ImageGetAllocateSize(Image); if(pos > (DWORD)2*1024*1024*1024){ pos = 0; //2G°¡ ³Ñ´Â °æ¿ì ´Ù½Ã ¿øÁ¡¿¡¼­ ÀúÀå½ÃÀÛÇÏ°Ô ¹Ù²ãÁÜ. } } */ void __fastcall TPUndo::GetSaveFileInfo(WideString &fileName, DWORD &posi, TTexpiaBitmap *Image,bool bClipboard){ fileName = FileName; posi = pos; SaveImageToFile(fileName, posi,Image,bClipboard); pos += ImageGetAllocateSize(Image); if(pos > (DWORD)2*1024*1024*1024){ pos = 0; //2G°¡ ³Ñ´Â °æ¿ì ´Ù½Ã ¿øÁ¡¿¡¼­ ÀúÀå½ÃÀÛÇÏ°Ô ¹Ù²ãÁÜ. } } //--------------------------------------------------------------------------- /* //--------------------------------------------------------------------------- int __fastcall TPUndo::ImageGetAllocateSize(TTexpiaBitmap *Image) { int size = 0; if (Image) { size += sizeof(WORD) + sizeof(int) + sizeof(int); if (Image->BitsPerPixel == 8) size += (256 * sizeof(RGBQUAD)); size += Image->BytesPerLine * Image->Height; return size; } else { return sizeof(WORD); } } */ //--------------------------------------------------------------------------- void __fastcall TPUndo::UndoSave(TPDocObject *src, bool bClipboard) //UndoSave´Â actionÀü¿¡ ½ÇÇàÇÑ´Ù { //AddUndoStep(); switch(((TPDocElement *)src)->Type){ case detNone: // // break; case detLine: { TPDocLineUndoData * TDU=new TPDocLineUndoData(); TDU->SetData((TPDocLine *)src); AddToUndoBundle(TDU); } break; case detBox: { TPDocBoxUndoData * TDU=new TPDocBoxUndoData(); TDU->SetData((TPDocBox *)src); AddToUndoBundle(TDU); } break; case detColorChip: { TPDocColorChipUndoData * TDU=new TPDocColorChipUndoData(); TDU->SetData((TPDocColorChip *)src); AddToUndoBundle(TDU); } break; case detSignature: { TPDocSignatureUndoData * TDU=new TPDocSignatureUndoData(); TDU->SetData((TPDocSignature *)src); GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); AddToUndoBundle(TDU); } break; case detNumber: { TPDocNumberUndoData * TDU=new TPDocNumberUndoData(); TDU->SetData((TPDocNumber *)src); AddToUndoBundle(TDU); } break; case detFormula: { TPDocFormulaUndoData * TDU=new TPDocFormulaUndoData(); TDU->SetData((TPDocFormula *)src); AddToUndoBundle(TDU); } break; case detDate: { TPDocDateUndoData * TDU=new TPDocDateUndoData(); TDU->SetData((TPDocDate *)src); AddToUndoBundle(TDU); } break; case detLabel: { TPDocLabelUndoData * TDU=new TPDocLabelUndoData(); TDU->SetData((TPDocLabel *)src); AddToUndoBundle(TDU); } break; case detEdit: { TPDocEditUndoData * TDU=new TPDocEditUndoData(); TDU->SetData((TPDocEdit *)src); AddToUndoBundle(TDU); } break; case detMemo: { TPDocMemoUndoData * TDU=new TPDocMemoUndoData(); TDU->SetData((TPDocMemo *)src); AddToUndoBundle(TDU); } break; case detImage: { TPDocImageUndoData * TDU=new TPDocImageUndoData(); TDU->SetData((TPDocImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image,bClipboard); } AddToUndoBundle(TDU); } break; case detInput: { TPDocInputUndoData * TDU=new TPDocInputUndoData(); TDU->SetData((TPDocInput *)src); AddToUndoBundle(TDU); } break; case detChart: { TPDocChartUndoData * TDU=new TPDocChartUndoData(); TDU->SetData((TPDocChart *)src); AddToUndoBundle(TDU); } break; case detArrow: { TPDocArrowUndoData * TDU=new TPDocArrowUndoData(); TDU->SetData((TPDocArrow *)src); AddToUndoBundle(TDU); } break; case detSheafImage: { TPDocSheafImageUndoData * TDU=new TPDocSheafImageUndoData(); TDU->SetData((TPDocSheafImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToUndoBundle(TDU); } break; case detSheafLabel: { TPDocSheafLabelUndoData * TDU=new TPDocSheafLabelUndoData(); TDU->SetData((TPDocSheafLabel *)src); AddToUndoBundle(TDU); } break; case detTextImage: { TPDocTextImageUndoData * TDU=new TPDocTextImageUndoData(); TDU->SetData((TPDocTextImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToUndoBundle(TDU); } break; case detSheafLine: { TPDocSheafLineUndoData * TDU=new TPDocSheafLineUndoData(); TDU->SetData((TPDocSheafLine *)src); AddToUndoBundle(TDU); } break; case detSheet: { TPDocSheetUndoData * TDU=new TPDocSheetUndoData(); TDU->SetData((TPDocSheet *)src); AddToUndoBundle(TDU); } break; // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) case detComboBox: { TPDocComboBoxUndoData * TDU=new TPDocComboBoxUndoData(); TDU->SetData((TPDocComboBox *)src); AddToUndoBundle(TDU); } break; } } //--------------------------------------------------------------------------- void __fastcall TPUndo::DeleteUndoSave(TPDocObject *src) //UndoSave´Â actionÀü¿¡ ½ÇÇàÇÑ´Ù { //AddUndoStep(); switch(((TPDocElement *)src)->Type){ case detNone: // // break; case detLine: { TPDocLineUndoData * TDU=new TPDocLineUndoData(); TDU->SetData((TPDocLine *)src); AddToDeleteUndoBundle(TDU); } break; case detBox: { TPDocBoxUndoData * TDU=new TPDocBoxUndoData(); TDU->SetData((TPDocBox *)src); AddToDeleteUndoBundle(TDU); } break; case detColorChip: { TPDocColorChipUndoData * TDU=new TPDocColorChipUndoData(); TDU->SetData((TPDocColorChip *)src); AddToDeleteUndoBundle(TDU); } break; case detSignature: { TPDocSignatureUndoData * TDU=new TPDocSignatureUndoData(); TDU->SetData((TPDocSignature *)src); GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); AddToDeleteUndoBundle(TDU); } break; case detNumber: { TPDocNumberUndoData * TDU=new TPDocNumberUndoData(); TDU->SetData((TPDocNumber *)src); AddToDeleteUndoBundle(TDU); } break; case detFormula: { TPDocFormulaUndoData * TDU=new TPDocFormulaUndoData(); TDU->SetData((TPDocFormula *)src); AddToDeleteUndoBundle(TDU); } break; case detDate: { TPDocDateUndoData * TDU=new TPDocDateUndoData(); TDU->SetData((TPDocDate *)src); AddToDeleteUndoBundle(TDU); } break; case detLabel: { TPDocLabelUndoData * TDU=new TPDocLabelUndoData(); TDU->SetData((TPDocLabel *)src); AddToDeleteUndoBundle(TDU); } break; case detEdit: { TPDocEditUndoData * TDU=new TPDocEditUndoData(); TDU->SetData((TPDocEdit *)src); AddToDeleteUndoBundle(TDU); } break; case detMemo: { TPDocMemoUndoData * TDU=new TPDocMemoUndoData(); TDU->SetData((TPDocMemo *)src); AddToDeleteUndoBundle(TDU); } break; case detImage: { TPDocImageUndoData * TDU=new TPDocImageUndoData(); TDU->SetData((TPDocImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToDeleteUndoBundle(TDU); } break; case detInput: { TPDocInputUndoData * TDU=new TPDocInputUndoData(); TDU->SetData((TPDocInput *)src); AddToDeleteUndoBundle(TDU); } break; case detChart: { TPDocChartUndoData * TDU=new TPDocChartUndoData(); TDU->SetData((TPDocChart *)src); AddToDeleteUndoBundle(TDU); } break; case detArrow: { TPDocArrowUndoData * TDU=new TPDocArrowUndoData(); TDU->SetData((TPDocArrow *)src); AddToDeleteUndoBundle(TDU); } break; case detSheafImage: { TPDocSheafImageUndoData * TDU=new TPDocSheafImageUndoData(); TDU->SetData((TPDocSheafImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToDeleteUndoBundle(TDU); } break; case detSheafLabel: { TPDocSheafLabelUndoData * TDU=new TPDocSheafLabelUndoData(); TDU->SetData((TPDocSheafLabel *)src); AddToDeleteUndoBundle(TDU); } break; case detTextImage: { TPDocTextImageUndoData * TDU=new TPDocTextImageUndoData(); TDU->SetData((TPDocTextImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToDeleteUndoBundle(TDU); } break; case detSheafLine: { TPDocSheafLineUndoData * TDU=new TPDocSheafLineUndoData(); TDU->SetData((TPDocSheafLine *)src); AddToDeleteUndoBundle(TDU); } break; case detSheet: { TPDocSheetUndoData * TDU=new TPDocSheetUndoData(); TDU->SetData((TPDocSheet *)src); AddToDeleteUndoBundle(TDU); } break; // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) case detComboBox: { TPDocComboBoxUndoData * TDU=new TPDocComboBoxUndoData(); TDU->SetData((TPDocComboBox *)src); AddToDeleteUndoBundle(TDU); } break; } } //--------------------------------------------------------------------------- void __fastcall TPUndo::CreateUndoSave(TPDocObject *src) //UndoSave´Â actionÀü¿¡ ½ÇÇàÇÑ´Ù { //AddUndoStep(); switch(((TPDocElement *)src)->Type){ case detNone: // // break; case detLine: { TPDocLineUndoData * TDU=new TPDocLineUndoData(); TDU->SetData((TPDocLine *)src); AddToCreateUndoBundle(TDU); } break; case detBox: { TPDocBoxUndoData * TDU=new TPDocBoxUndoData(); TDU->SetData((TPDocBox *)src); AddToCreateUndoBundle(TDU); } break; case detColorChip: { TPDocColorChipUndoData * TDU=new TPDocColorChipUndoData(); TDU->SetData((TPDocColorChip *)src); AddToCreateUndoBundle(TDU); } break; case detSignature: { TPDocSignatureUndoData * TDU=new TPDocSignatureUndoData(); TDU->SetData((TPDocSignature *)src); GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); AddToCreateUndoBundle(TDU); } break; case detNumber: { TPDocNumberUndoData * TDU=new TPDocNumberUndoData(); TDU->SetData((TPDocNumber *)src); AddToCreateUndoBundle(TDU); } break; case detFormula: { TPDocFormulaUndoData * TDU=new TPDocFormulaUndoData(); TDU->SetData((TPDocFormula *)src); AddToCreateUndoBundle(TDU); } break; case detDate: { TPDocDateUndoData * TDU=new TPDocDateUndoData(); TDU->SetData((TPDocDate *)src); AddToCreateUndoBundle(TDU); } break; case detLabel: { TPDocLabelUndoData * TDU=new TPDocLabelUndoData(); TDU->SetData((TPDocLabel *)src); AddToCreateUndoBundle(TDU); } break; case detEdit: { TPDocEditUndoData * TDU=new TPDocEditUndoData(); TDU->SetData((TPDocEdit *)src); AddToCreateUndoBundle(TDU); } break; case detMemo: { TPDocMemoUndoData * TDU=new TPDocMemoUndoData(); TDU->SetData((TPDocMemo *)src); AddToCreateUndoBundle(TDU); } break; case detImage: { TPDocImageUndoData * TDU=new TPDocImageUndoData(); TDU->SetData((TPDocImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToCreateUndoBundle(TDU); } break; case detInput: { TPDocInputUndoData * TDU=new TPDocInputUndoData(); TDU->SetData((TPDocInput *)src); AddToCreateUndoBundle(TDU); } break; case detChart: { TPDocChartUndoData * TDU=new TPDocChartUndoData(); TDU->SetData((TPDocChart *)src); AddToCreateUndoBundle(TDU); } break; case detArrow: { TPDocArrowUndoData * TDU=new TPDocArrowUndoData(); TDU->SetData((TPDocArrow *)src); AddToCreateUndoBundle(TDU); } break; case detSheafImage: { TPDocSheafImageUndoData * TDU=new TPDocSheafImageUndoData(); TDU->SetData((TPDocSheafImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToCreateUndoBundle(TDU); } break; case detSheafLabel: { TPDocSheafLabelUndoData * TDU=new TPDocSheafLabelUndoData(); TDU->SetData((TPDocSheafLabel *)src); AddToCreateUndoBundle(TDU); } break; case detTextImage: { TPDocTextImageUndoData * TDU=new TPDocTextImageUndoData(); TDU->SetData((TPDocTextImage *)src); if(TDU->bImageChanged){ GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } AddToCreateUndoBundle(TDU); } break; case detSheafLine: { TPDocSheafLineUndoData * TDU=new TPDocSheafLineUndoData(); TDU->SetData((TPDocSheafLine *)src); AddToCreateUndoBundle(TDU); } break; case detSheet: { TPDocSheetUndoData * TDU=new TPDocSheetUndoData(); TDU->SetData((TPDocSheet *)src); AddToCreateUndoBundle(TDU); } break; // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) case detComboBox: { TPDocComboBoxUndoData * TDU=new TPDocComboBoxUndoData(); TDU->SetData((TPDocComboBox *)src); AddToCreateUndoBundle(TDU); } break; } } //--------------------------------------------------------------------------- void __fastcall TPUndo::UndoRead() { if( canundo() ) { //RedoSave(); getUndoBundle(IndexOfUndo--); UndoBundle->UndoDatas(); } } //--------------------------------------------------------------------------- void __fastcall TPUndo::RedoRead() { if( canredo() ) { getUndoBundle(++IndexOfUndo); UndoBundle->RedoDatas(); } } //--------------------------------------------------------------------------- void __fastcall TPUndo::getUndoBundle(int IndexOfUndo) { // TPUndoBundle *tempBundle; if(IndexOfUndoCount){ UndoBundle=(TPUndoBundle *)DataOfUndo->Items[IndexOfUndo]; }else{ UndoBundle=(TPUndoBundle *)DataOfUndo->Last(); } // return *tempBundle; } //--------------------------------------------------------------------------- bool __fastcall TPUndo::RemoveLast() { TPUndoBundle * tempBundle; tempBundle = (TPUndoBundle *)DataOfUndo->Last(); DataOfUndo->Remove(tempBundle); tempBundle->bCreateAtTail = true; delete tempBundle; if(DataOfUndo->Count<=IndexOfUndo)IndexOfUndo=DataOfUndo->Count-1; return true; } //--------------------------------------------------------------------------- bool __fastcall TPUndo::RemoveFirst() { TPUndoBundle * tempBundle; tempBundle = (TPUndoBundle *)DataOfUndo->First(); DataOfUndo->Remove(tempBundle); tempBundle->bDeleteAtHead = true; delete tempBundle; if(IndexOfUndo>-1)IndexOfUndo--; return true; } //--------------------------------------------------------------------------- __fastcall TPDocObjectUndoData::TPDocObjectUndoData(){ bCreated = false; bDeleted = false; bDeleteAtHead = false; bCreateAtTail = false; } __fastcall TPDocObjectUndoData::~TPDocObjectUndoData(){ if(bDeleted){ if(bDeleteAtHead){ TPDocElement *dp; dp = (TPDocElement *)SrcData; switch (dp->Type) { case detColorChip: delete (TPDocColorChip *)dp; break; case detNumber: delete (TPDocNumber *)dp; break; case detFormula: delete (TPDocFormula *)dp; break; case detLabel: delete (TPDocLabel *)dp; break; case detEdit: delete (TPDocEdit *)dp; break; case detImage: delete (TPDocImage *)dp; break; case detTextImage: delete (TPDocTextImage *)dp; break; case detMemo: delete (TPDocMemo *)dp; break; case detDate: delete (TPDocDate *)dp; break; case detSignature: delete (TPDocSignature *)dp; break; //<--------------------»©¸Ô¾ú´ø ºÎºÐ---------------------->// case detLine: delete (TPDocLine *)dp; break; case detBox: delete (TPDocBox *)dp; break; case detInput: delete (TPDocInput *)dp; break; //case detChart: delete (TPDocChart *)dp; break; case detArrow: delete (TPDocArrow *)dp; break; case detSheafImage: delete (TPDocSheafImage *)dp; break; case detSheafLabel: delete (TPDocSheafLabel *)dp; break; case detSheafLine: delete (TPDocSheafLine *)dp; break; //case detSheet: } } } if(bCreated){ if(bCreateAtTail){ TPDocElement *dp; dp = (TPDocElement *)SrcData; switch (dp->Type) { case detColorChip: delete (TPDocColorChip *)dp; break; case detNumber: delete (TPDocNumber *)dp; break; case detFormula: delete (TPDocFormula *)dp; break; case detLabel: delete (TPDocLabel *)dp; break; case detEdit: delete (TPDocEdit *)dp; break; case detImage: delete (TPDocImage *)dp; break; case detTextImage: delete (TPDocTextImage *)dp; break; case detMemo: delete (TPDocMemo *)dp; break; case detDate: delete (TPDocDate *)dp; break; case detSignature: delete (TPDocSignature *)dp; break; //<--------------------»©¸Ô¾ú´ø ºÎºÐ---------------------->// case detLine: delete (TPDocLine *)dp; break; case detBox: delete (TPDocBox *)dp; break; case detInput: delete (TPDocInput *)dp; break; //case detChart: delete (TPDocChart *)dp; break; case detArrow: delete (TPDocArrow *)dp; break; case detSheafImage: delete (TPDocSheafImage *)dp; break; case detSheafLabel: delete (TPDocSheafLabel *)dp; break; case detSheafLine: delete (TPDocSheafLine *)dp; break; //case detSheet: } } } } __fastcall TPUndoBundle::TPUndoBundle(TPUndo *Parent){ BundleOfUndoData = new TList(); BundleOfRedoData = new TList(); IsFirstRedoStep = true; bDeleteAtHead = false; bCreateAtTail = false; ParentUndoManager = Parent; } __fastcall TPUndoBundle::~TPUndoBundle(){ //DeleteBundleData(); while(BundleOfUndoData->Count){ RemoveLastUndo(); } delete BundleOfUndoData; while(BundleOfRedoData->Count){ RemoveLastRedo(); } delete BundleOfRedoData; } void __fastcall TPUndoBundle::AddUndoData(TPDocObjectUndoData * TDUT){ BundleOfUndoData->Add(TDUT); } TPDocObjectUndoData * __fastcall TPUndoBundle::MakeRedoData(TPDocObjectUndoData * TDUT){ TPDocObject *src = TDUT->SrcData; switch(((TPDocElement *)src)->Type){ case detNone: // // break; case detLine: { TPDocLineUndoData * TDU=new TPDocLineUndoData(); TDU->SetData((TPDocLine *)src); return TDU; } case detBox: { TPDocBoxUndoData * TDU=new TPDocBoxUndoData(); TDU->SetData((TPDocBox *)src); return TDU; } case detColorChip: { TPDocColorChipUndoData * TDU=new TPDocColorChipUndoData(); TDU->SetData((TPDocColorChip *)src); return TDU; } case detSignature: { TPDocSignatureUndoData * TDU=new TPDocSignatureUndoData(); TDU->SetData((TPDocSignature *)src); ParentUndoManager->GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); return TDU; } case detNumber: { TPDocNumberUndoData * TDU=new TPDocNumberUndoData(); TDU->SetData((TPDocNumber *)src); return TDU; } case detFormula: { TPDocFormulaUndoData * TDU=new TPDocFormulaUndoData(); TDU->SetData((TPDocFormula *)src); return TDU; } case detDate: { TPDocDateUndoData * TDU=new TPDocDateUndoData(); TDU->SetData((TPDocDate *)src); return TDU; } case detLabel: { TPDocLabelUndoData * TDU=new TPDocLabelUndoData(); TDU->SetData((TPDocLabel *)src); return TDU; } case detEdit: { TPDocEditUndoData * TDU=new TPDocEditUndoData(); TDU->SetData((TPDocEdit *)src); return TDU; } case detMemo: { TPDocMemoUndoData * TDU=new TPDocMemoUndoData(); TDU->SetData((TPDocMemo *)src); return TDU; } case detImage: { TPDocImageUndoData * TDU=new TPDocImageUndoData(); TDU->SetData((TPDocImage *)src); TDU->bImageChanged = ((TPDocImageUndoData *)TDUT)->bImageChanged; if(TDU->bImageChanged){ ParentUndoManager->GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); ((TPDocImage *)src)->bCopyFromClipboard = false; if(((TPDocImage *)src)->iFileLoad > 0) ((TPDocImage *)src)->iFileLoad--; } return TDU; } case detInput: { TPDocInputUndoData * TDU=new TPDocInputUndoData(); TDU->SetData((TPDocInput *)src); return TDU; } case detChart: { TPDocChartUndoData * TDU=new TPDocChartUndoData(); TDU->SetData((TPDocChart *)src); return TDU; } case detArrow: { TPDocArrowUndoData * TDU=new TPDocArrowUndoData(); TDU->SetData((TPDocArrow *)src); return TDU; } case detSheafImage: { TPDocSheafImageUndoData * TDU=new TPDocSheafImageUndoData(); TDU->SetData((TPDocSheafImage *)src); TDU->bImageChanged = ((TPDocSheafImageUndoData *)TDUT)->bImageChanged; if(TDU->bImageChanged){ ParentUndoManager->GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } return TDU; } case detSheafLabel: { TPDocSheafLabelUndoData * TDU=new TPDocSheafLabelUndoData(); TDU->SetData((TPDocSheafLabel *)src); return TDU; } case detTextImage: { TPDocTextImageUndoData * TDU=new TPDocTextImageUndoData(); TDU->SetData((TPDocTextImage *)src); TDU->bImageChanged = ((TPDocTextImageUndoData *)TDUT)->bImageChanged; if(TDU->bImageChanged){ ParentUndoManager->GetSaveFileInfo(TDU->FileName,TDU->pos,TDU->SrcData->Image); } return TDU; } case detSheafLine: { TPDocSheafLineUndoData * TDU=new TPDocSheafLineUndoData(); TDU->SetData((TPDocSheafLine *)src); return TDU; } case detSheet: { TPDocSheetUndoData * TDU=new TPDocSheetUndoData(); TDU->SetData((TPDocSheet *)src); return TDU; } // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) case detComboBox: { TPDocComboBoxUndoData * TDU=new TPDocComboBoxUndoData(); TDU->SetData((TPDocComboBox *)src); return TDU; } } TPDocObjectUndoData * TDOU = new TPDocObjectUndoData(); TDOU->SetData(src); return TDOU; } void __fastcall TPUndoBundle::AddRedoData(TPDocObjectUndoData * UndoData) { TPDocObjectUndoData * TDUT; TDUT = MakeRedoData(UndoData); BundleOfRedoData->Add(TDUT); } bool __fastcall TPUndoBundle::UndoDatas() { TPDocObjectUndoData *tempData; //for(int i = 0 ; i < BundleOfUndoData->Count; i++) for(int i = BundleOfUndoData->Count-1 ; i >=0 ; i--) { tempData = (TPDocObjectUndoData *)BundleOfUndoData->Items[i]; if(IsFirstRedoStep){ AddRedoData(tempData); //Redo Data¸¦ ¸¸µé±â À§ÇÑ ºÎºÐ } tempData->GetData(); } if(IsFirstRedoStep){ IsFirstRedoStep = false; } // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } bool __fastcall TPUndoBundle::RedoDatas() { TPDocObjectUndoData *tempData; //for(int i = 0 ; i < BundleOfRedoData->Count; i++) for(int i = BundleOfUndoData->Count-1 ; i >=0 ; i--) { tempData = (TPDocObjectUndoData *)BundleOfRedoData->Items[i]; tempData->GetData(); } // Warning ¼öÁ¤ (2007. 05. 17 Annualring) return true; } bool __fastcall TPUndoBundle::RemoveLastUndo() { TPDocObjectUndoData * tempData; tempData = (TPDocObjectUndoData *)BundleOfUndoData->Last(); BundleOfUndoData->Remove(tempData); tempData->bDeleteAtHead = bDeleteAtHead; tempData->bCreateAtTail = bCreateAtTail; DeleteData(tempData); //delete tempData; //delete´Â °¢°¢ÀÇ type¿¡ ¸Â°Ô Áö¿ö¾ß ÇϹǷΠ°¢ÀÚÀÇ Å¬·¡½º¿¡¼­ Çϴ°ÍÀ¸·Î ÇÑ´Ù. return true; } bool __fastcall TPUndoBundle::RemoveLastRedo() { TPDocObjectUndoData * tempData; tempData = (TPDocObjectUndoData *)BundleOfRedoData->Last(); BundleOfRedoData->Remove(tempData); tempData->bDeleteAtHead = bDeleteAtHead; tempData->bCreateAtTail = bCreateAtTail; DeleteData(tempData); //delete tempData; //delete´Â °¢°¢ÀÇ type¿¡ ¸Â°Ô Áö¿ö¾ß ÇϹǷΠ°¢ÀÚÀÇ Å¬·¡½º¿¡¼­ Çϴ°ÍÀ¸·Î ÇÑ´Ù. return true; } /* bool __fastcall TPUndoBundle::DeleteBundleData(){ TPDocObjectUndoData * tempData; for(int i = 0;iItems[i]; DeleteData(tempData); } for(int i = 0;iItems[i]; DeleteData(tempData); } return true; } */ bool __fastcall TPUndoBundle::DeleteData(TPDocObjectUndoData *Data){ switch(Data->type){ case detNone: //delete Data; break; case detLine: delete (TPDocLineUndoData *)Data; break; case detBox: delete (TPDocBoxUndoData *)Data; break; case detColorChip: delete (TPDocColorChipUndoData *)Data; break; case detSignature: delete (TPDocSignatureUndoData *)Data; break; case detNumber: delete (TPDocNumberUndoData *)Data; break; case detFormula: delete (TPDocFormulaUndoData *)Data; break; case detDate: delete (TPDocDateUndoData *)Data; break; case detLabel: delete (TPDocLabelUndoData *)Data; break; case detEdit: delete (TPDocEditUndoData *)Data; break; case detMemo: delete (TPDocMemoUndoData *)Data; break; case detImage: delete (TPDocImageUndoData *)Data; break; case detInput: delete (TPDocInputUndoData *)Data; break; case detChart: delete (TPDocChartUndoData *)Data; break; case detArrow: delete (TPDocArrowUndoData *)Data; break; case detSheafImage: delete (TPDocSheafImageUndoData *)Data; break; case detSheafLabel: delete (TPDocSheafLabelUndoData *)Data; break; case detTextImage: delete (TPDocTextImageUndoData *)Data; break; case detSheafLine: delete (TPDocSheafLineUndoData *)Data; break; case detSheet: delete (TPDocSheetUndoData *)Data; break; // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) case detComboBox: delete (TPDocComboBoxUndoData *)Data; break; } return true; } //--------------------------------------------------------------------------- void __fastcall TPDocObjectUndoData::SetData(TPDocObject *src){ type = detNone; SrcData = src; } void __fastcall TPDocObjectUndoData::GetData(){ } //--------------------------------------------------------------------------- void __fastcall TPDocElementUndoData::SetData(TPDocElement *src){ type = ((TPDocElement *)src)->Type; TPDocObjectUndoData::SrcData = src; Range = src->Range; SrcData = src; } void __fastcall TPDocElementUndoData::SetParentData(TPDocElement *src){ TPDocObjectUndoData::SrcData = src; Range = src->Range; FOldRect = src->FOldRect; FOldPoint = src->FOldPoint; FOldArrow[0] = src->FOldArrow[0]; FOldArrow[1] = src->FOldArrow[1]; FOldArrow[2] = src->FOldArrow[2]; NowSelect = src->NowSelect; OldSelect = src->OldSelect; FrameStyle = src->FrameStyle; FrameColor = src->FrameColor; bVisible = src->bVisible; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 04 Annualring) Background = src->Background; } void __fastcall TPDocElementUndoData::GetData(){ // TPDocElement *tempData = (TPDocElement *)src; SrcData->Range = Range; SrcData->NowSelect = NowSelect; } void __fastcall TPDocElementUndoData::GetParentData(TPDocElement *SrcData){ SrcData->Range = Range; SrcData->FOldRect = FOldRect; SrcData->FOldPoint = FOldPoint; SrcData->FOldArrow[0] = FOldArrow[0]; SrcData->FOldArrow[1] = FOldArrow[1]; SrcData->FOldArrow[2] = FOldArrow[2]; SrcData->NowSelect = NowSelect; SrcData->OldSelect = OldSelect; SrcData->FrameStyle = FrameStyle; SrcData->FrameColor = FrameColor; SrcData->bVisible = bVisible; // ¼¿ ¹è°æ Ãß°¡ (2007. 07. 04 Annualring) SrcData->Background = Background; } //--------------------------------------------------------------------------- void __fastcall TPDocLineUndoData::SetData(TPDocLine *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; Type = src->Type; Color = src->Color; Style = src->Style; } void __fastcall TPDocLineUndoData::GetData(){ // TPDocLine *tempData = (TPDocLine *)data; GetParentData(SrcData); SrcData->Type = Type; SrcData->Color = Color; SrcData->Style = Style; } //--------------------------------------------------------------------------- void __fastcall TPDocBoxUndoData::SetData(TPDocBox *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; Color = src->Color; Style = src->Style; } void __fastcall TPDocBoxUndoData::GetData(){ // TPDocBox *tempData = (TPDocBox *)src; // Data->Data = Data; GetParentData(SrcData); SrcData->Color = Color; SrcData->Style = Style; } //--------------------------------------------------------------------------- void __fastcall TPDocColorChipUndoData::SetData(TPDocColorChip *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; bHasCommonData = src->bHasCommonData; Color = src->Color; Margin = src->Margin; Name = src->Name; } void __fastcall TPDocColorChipUndoData::GetData(){ // TPDocColorChip *tempData = (TPDocColorChip *)src; // Data->Data = Data; GetParentData(SrcData); SrcData->bHasCommonData = bHasCommonData; SrcData->Color = Color; SrcData->Margin = Margin; SrcData->Name = Name; } //--------------------------------------------------------------------------- void __fastcall TPDocSignatureUndoData::SetData(TPDocSignature *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; //SetFont(src->GetFont()); //if (!ImageCopy(Image, src->Image)) return false; // ImageSave(Image, src->Image); } void __fastcall TPDocSignatureUndoData::GetData(){ // TPDocSignature *tempData = (TPDocSignature *)src; //PutFont(SrcData); //SetFont(src->GetFont()); GetParentData(SrcData); LoadImageFromFile(FileName, pos, SrcData->Image); //if (!ImageCopy(Image, src->Image)) return false; } //--------------------------------------------------------------------------- __fastcall TPDocTextUndoData::TPDocTextUndoData() { Font = new TFont; // newFont = Font; } __fastcall TPDocTextUndoData::~TPDocTextUndoData() { // Font = NULL; // delete newFont; delete Font; } void __fastcall TPDocTextUndoData::SetData(TPDocText *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; SetFont(src); //for linuxjun Align = src->Align; FieldName = src->FieldName; } void __fastcall TPDocTextUndoData::GetData(){ // TPDocText *tempData = (TPDocText *)src; GetParentData(SrcData); PutFont(SrcData); SrcData->Align = Align; SrcData->FieldName = FieldName; } //--------------------------------------------------------------------------- void __fastcall TPDocTextUndoData::SetFont(TPDocText *src) { FNewFont = src->NewFont; Font->Assign(src->GetFont()); /* if (font) { if (FNewFont) { Font->Assign(font); } else { Font = new TFont; Font->Assign(font); FNewFont = true; } // Font->Color = color; } else { if (Font) delete Font; Font = Parent->GetFont(); FNewFont = false; } */ } //--------------------------------------------------------------------------- void __fastcall TPDocTextUndoData::PutFont(TPDocText *src) { if(!FNewFont){ src->SetFont(NULL); }else{ src->SetFont(Font); } /* if (font) { if (FNewFont) { Font->Assign(font); } else { Font = new TFont; Font->Assign(font); FNewFont = true; } // Font->Color = color; } else { if (Font) delete Font; Font = Parent->GetFont(); FNewFont = false; } */ } //--------------------------------------------------------------------------- void __fastcall TPDocNumberUndoData::SetData(TPDocNumber *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; // TPDocTextUndoData::SetData((TPDocText *)SrcData); TPDocTextUndoData::SetData((TPDocText *)src); bHasCommonData = src->bHasCommonData; // FID = src->ID; //FID´Â »ý¼ºµÉ¶§ ÇÒ´ç µÇ¾îÁö´Â°ÍÀ̰í Áß°£¿¡ ¹Ù²îÁö ¾Ê´Â °ªÀÌ´Ù. FPrecision = src->Precision; FHide = src->Hide; FDecimal = src->Decimal; Name = src->Name; Number = src->Number; FXIndex = src->XIndex; FYIndex = src->YIndex; } void __fastcall TPDocNumberUndoData::GetData(){ // TPDocNumber *tempData = (TPDocNumber *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->bHasCommonData = bHasCommonData; // SrcData->ID = FID; //FID´Â »ý¼ºµÉ¶§ ÇÒ´ç µÇ¾îÁö´Â°ÍÀ̰í Áß°£¿¡ ¹Ù²îÁö ¾Ê´Â °ªÀÌ´Ù. SrcData->Precision = FPrecision; SrcData->Hide = FHide; SrcData->Decimal = FDecimal; SrcData->Name = Name; SrcData->Number = Number; SrcData->XIndex = FXIndex; SrcData->YIndex = FYIndex; } //--------------------------------------------------------------------------- void __fastcall TPDocFormulaUndoData::SetData(TPDocFormula *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); bHasCommonData = src->bHasCommonData; // FID = src->ID; //FID´Â »ý¼ºµÉ¶§ ÇÒ´ç µÇ¾îÁö´Â°ÍÀ̰í Áß°£¿¡ ¹Ù²îÁö ¾Ê´Â °ªÀÌ´Ù. Formula = src->Formula; FPrecision = src->Precision; FHide = src->Hide; FDecimal = src->Decimal; Name = src->Name; ANumber = src->ANumber; FXIndex = src->XIndex; FYIndex = src->YIndex; Data = src->Data; } void __fastcall TPDocFormulaUndoData::GetData(){ // TPDocFormula *tempData = (TPDocFormula *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->bHasCommonData = bHasCommonData; // SrcData->FID = FID; //FID´Â »ý¼ºµÉ¶§ ÇÒ´ç µÇ¾îÁö´Â°ÍÀ̰í Áß°£¿¡ ¹Ù²îÁö ¾Ê´Â °ªÀÌ´Ù. SrcData->Formula = Formula; SrcData->Precision = FPrecision; SrcData->Hide = FHide; SrcData->Decimal = FDecimal; SrcData->Name = Name; SrcData->ANumber = ANumber; SrcData->XIndex = FXIndex; SrcData->YIndex = FYIndex; SrcData->Data = Data; } //--------------------------------------------------------------------------- void __fastcall TPDocDateUndoData::SetData(TPDocDate *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); bHasCommonData = src->bHasCommonData; bHasReference = src->bHasReference; Date = src->Date; Name = src->Name; FXIndex = src->XIndex; FYIndex = src->YIndex; DateFormat = src->DateFormat; dateTime = src->dateTime; DateDifference = src->DateDifference; ReferenceDate = src->ReferenceDate; } void __fastcall TPDocDateUndoData::GetData(){ // TPDocDate *tempData = (TPDocDate *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->bHasCommonData = bHasCommonData; SrcData->bHasReference = bHasReference; SrcData->Date = Date; SrcData->Name = Name; SrcData->XIndex = FXIndex; SrcData->YIndex = FYIndex; SrcData->DateFormat = DateFormat; SrcData->dateTime = dateTime; SrcData->DateDifference = DateDifference; SrcData->ReferenceDate = ReferenceDate; } //--------------------------------------------------------------------------- void __fastcall TPDocLabelUndoData::SetData(TPDocLabel *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); Text = src->Text; } void __fastcall TPDocLabelUndoData::GetData(){ // TPDocLabel *tempData = (TPDocLabel *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->Text = Text; } //--------------------------------------------------------------------------- //bool __fastcall TPDocEditUndoData::SetData(TPDocEdit *src) void __fastcall TPDocEditUndoData::SetData(TPDocEdit *src) { type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; //if(!TPDocTextUndoData::SetData((TPDocText *)src)) return false; TPDocTextUndoData::SetData((TPDocText *)src); //if (!TPDocText::Copy((TPDocText *)src)) return false; bHasCommonData = src->bHasCommonData; FXIndex = src->XIndex; FYIndex = src->YIndex; Name = src->Name; K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; // return true; } void __fastcall TPDocEditUndoData::GetData(){ // TPDocEdit *tempData = (TPDocEdit *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->bHasCommonData = bHasCommonData; SrcData->XIndex = FXIndex; SrcData->YIndex = FYIndex; SrcData->Name = Name; SrcData->K_Text = K_Text; SrcData->E_Text = E_Text; SrcData->I_Text = I_Text; SrcData->C_Text = C_Text; SrcData->J_Text = J_Text; } //--------------------------------------------------------------------------- // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) void __fastcall TPDocComboBoxUndoData::SetData(TPDocComboBox *src) { type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; //if(!TPDocTextUndoData::SetData((TPDocText *)src)) return false; TPDocTextUndoData::SetData((TPDocText *)src); //if (!TPDocText::Copy((TPDocText *)src)) return false; bHasCommonData = src->bHasCommonData; FXIndex = src->XIndex; FYIndex = src->YIndex; Name = src->Name; Data_Text = src->Data_Text; // return true; } //--------------------------------------------------------------------------- // ComboBox Type Item Ãß°¡ (Undo °ü·Ã) (2007. 03. 05 Annualring) void __fastcall TPDocComboBoxUndoData::GetData(){ // TPDocEdit *tempData = (TPDocEdit *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->bHasCommonData = bHasCommonData; SrcData->XIndex = FXIndex; SrcData->YIndex = FYIndex; SrcData->Name = Name; SrcData->Data_Text = Data_Text; } //--------------------------------------------------------------------------- __fastcall TPDocMemoUndoData::TPDocMemoUndoData(){ bNewFont = false; MFont = NULL; } __fastcall TPDocMemoUndoData::~TPDocMemoUndoData(){ if(bNewFont){ if(MFont){ delete MFont; MFont = NULL; } } } void __fastcall TPDocMemoUndoData::SetData(TPDocMemo *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); Title = src->Title; Text = src->Text; TitleHeight = src->TitleHeight; FXIndex = src->XIndex; FYIndex = src->YIndex; bNewFont = src->bNewFont; if (bNewFont) { MFont = new TFont; MFont->Assign(src->MFont); } } void __fastcall TPDocMemoUndoData::GetData(){ // TPDocMemo *tempData = (TPDocMemo *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->Title = Title; SrcData->Text = Text; SrcData->TitleHeight = TitleHeight; SrcData->XIndex = FXIndex; SrcData->YIndex = FYIndex; if(SrcData->bNewFont){ SrcData->bNewFont = bNewFont; if (SrcData->bNewFont) { SrcData->MFont->Assign(MFont); }else{ if(SrcData->MFont){ delete SrcData->MFont; SrcData->MFont = NULL; } } }else{ SrcData->bNewFont = bNewFont; if (SrcData->bNewFont) { SrcData->MFont = new TFont; SrcData->MFont->Assign(MFont); }else if(SrcData->MFont){ delete SrcData->MFont; SrcData->MFont = NULL; } } } //--------------------------------------------------------------------------- void __fastcall TPDocImageUndoData::SetData(TPDocImage *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); Zoom = src->Zoom; Align = src->Align; Name = src->Name; ImgTitle = src->ImgTitle; ImgDir = src->ImgDir; bImageChanged = src->bImageChanged; bHasCommonData = src->bHasCommonData; src->bImageChanged = false; // if (!ImageCopy(Image, src->Image)) return false; } void __fastcall TPDocImageUndoData::GetData(){ // TPDocImage *tempData = (TPDocImage *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->Zoom = Zoom; SrcData->Align = Align; SrcData->Name = Name; SrcData->ImgTitle = ImgTitle; SrcData->ImgDir = ImgDir; SrcData->bImageChanged = false; SrcData->bHasCommonData = bHasCommonData; if(bImageChanged){ LoadImageFromFile(FileName, pos, SrcData->Image); } //if (!ImagePaste(Image, Data->Image)) return false; } //--------------------------------------------------------------------------- void __fastcall TPDocInputUndoData::SetData(TPDocInput *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); Color = src->Color; Style = src->Style; Text = src->Text; Position = src->Position; Method = src->Method; TPDocElement *dp; switch (src->IPElement->Type) { case detColorChip: dp = new TPDocColorChip(this->SrcData, src->IPElement->Range); ((TPDocColorChip *)dp)->Copy((TPDocColorChip *)src->IPElement); break; case detNumber: dp = new TPDocNumber(this->SrcData, src->IPElement->Range); ((TPDocNumber *)dp)->Copy((TPDocNumber *)src->IPElement); break; case detFormula: dp = new TPDocFormula(this->SrcData, src->IPElement->Range); ((TPDocFormula *)dp)->Copy((TPDocFormula *)src->IPElement); break; case detDate: dp = new TPDocDate(this->SrcData, src->IPElement->Range); ((TPDocDate *)dp)->Copy((TPDocDate *)src->IPElement); break; case detEdit: dp = new TPDocEdit(this->SrcData, src->IPElement->Range); ((TPDocEdit *)dp)->Copy((TPDocEdit *)src->IPElement); break; case detImage: dp = new TPDocImage(this->SrcData, src->IPElement->Range); ((TPDocImage *)dp)->Copy((TPDocImage *)src->IPElement); break; } IPElement = (TPDocElement *)dp; } void __fastcall TPDocInputUndoData::GetData(){ // TPDocInput *tempData = (TPDocInput *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->Color = Color; SrcData->Style = Style; SrcData->Text = Text; SrcData->Position = Position; SrcData->Method = Method; TPDocElement *dp; switch (IPElement->Type) { case detColorChip: dp = new TPDocColorChip(this->SrcData, IPElement->Range); ((TPDocColorChip *)dp)->Copy((TPDocColorChip *)IPElement); break; case detNumber: dp = new TPDocNumber(this->SrcData, IPElement->Range); ((TPDocNumber *)dp)->Copy((TPDocNumber *)IPElement); break; case detFormula: dp = new TPDocFormula(this->SrcData, IPElement->Range); ((TPDocFormula *)dp)->Copy((TPDocFormula *)IPElement); break; case detDate: dp = new TPDocDate(this->SrcData, IPElement->Range); ((TPDocDate *)dp)->Copy((TPDocDate *)IPElement); break; case detEdit: dp = new TPDocEdit(this->SrcData, IPElement->Range); ((TPDocEdit *)dp)->Copy((TPDocEdit *)IPElement); break; case detImage: dp = new TPDocImage(this->SrcData, IPElement->Range); ((TPDocImage *)dp)->Copy((TPDocImage *)IPElement); break; } SrcData->IPElement = (TPDocElement *)dp; } //--------------------------------------------------------------------------- void __fastcall TPDocChartUndoData::SetData(TPDocChart *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; FNumber = src->Number; Cell = NULL; CopyCellList(src); } void __fastcall TPDocChartUndoData::GetData(){ // TPDocChart *tempData = (TPDocChart *)src; GetParentData(SrcData); PasteCellList(SrcData); SrcData->Number=FNumber; } void __fastcall TPDocChartUndoData::CopyCellList(TPDocChart *src){ if(Cell != NULL){ Cell->Clear(); delete Cell; } Cell = new TList; for (int i = 0; i< src->Cell->Count;i++){ Cell->Add(src->Cell->Items[i]); } } void __fastcall TPDocChartUndoData::PasteCellList(TPDocChart *data){ if(data->Cell != NULL){ data->Cell->Clear(); delete data->Cell; } if(Cell == NULL)return; data->Cell = new TList; for (int i = 0; i< Cell->Count;i++){ data->Cell->Add(Cell->Items[i]); } } //--------------------------------------------------------------------------- void __fastcall TPDocArrowUndoData::SetData(TPDocArrow *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); SrcData->SetToUndoData(this); } void __fastcall TPDocArrowUndoData::GetData(){ // TPDocArrow *tempData = (TPDocArrow *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->GetFromUndoData(this); } //--------------------------------------------------------------------------- void __fastcall TPDocSheafImageUndoData::SetData(TPDocSheafImage *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); Zoom = src->Zoom; ImgDir = src->ImgDir; bImageChanged = src->bImageChanged; src->bImageChanged = false; // Image = src->Image; bSelected = src->bSelected; // if (!ImageCopy(Image, src->Image)) return false; //return true; } void __fastcall TPDocSheafImageUndoData::GetData(){ // TPDocSheafImage *tempData = (TPDocSheafImage *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->Zoom = Zoom; SrcData->ImgDir = ImgDir; // SrcData->Image = Image; SrcData->bImageChanged = false; if(bImageChanged){ LoadImageFromFile(FileName, pos, SrcData->Image); } SrcData->bSelected = bSelected; //if (!ImagePaste(Image, Data->Image)) return false; //return true; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLabelUndoData::SetData(TPDocSheafLabel *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; TPDocTextUndoData::SetData((TPDocText *)src); SrcData->GetText(K_Text,E_Text,I_Text,C_Text,J_Text); /* K_Text = src->K_Text; E_Text = src->E_Text; I_Text = src->I_Text; C_Text = src->C_Text; J_Text = src->J_Text; */ } void __fastcall TPDocSheafLabelUndoData::GetData(){ // TPDocSheafLabel *tempData = (TPDocSheafLabel *)src; //TPDocTextUndoData::GetData((TPDocText *)SrcData); TPDocTextUndoData::GetData(); SrcData->SetText(K_Text,E_Text,I_Text,C_Text,J_Text); /* SrcData->K_Text = K_Text; SrcData->E_Text = E_Text; SrcData->I_Text = I_Text; SrcData->C_Text = C_Text; SrcData->J_Text = J_Text; */ } //--------------------------------------------------------------------------- void __fastcall TPDocTextImageUndoData::SetData(TPDocTextImage *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; Zoom = src->Zoom; bImageChanged = src->bImageChanged; src->bImageChanged = false; // if (!ImageCopy(Image, src->Image)) return false; } void __fastcall TPDocTextImageUndoData::GetData(){ // TPDocTextImage *tempData = (TPDocTextImage *)src; GetParentData(SrcData); SrcData->Zoom = Zoom; SrcData->bImageChanged = false; if(bImageChanged){ LoadImageFromFile(FileName, pos, SrcData->Image); } //if (!ImagePaste(Image, Data->Image)) return false; } //--------------------------------------------------------------------------- void __fastcall TPDocSheafLineUndoData::SetData(TPDocSheafLine *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; Type = src->Type; Color = src->Color; sp = src->sp; ep = src->ep; } void __fastcall TPDocSheafLineUndoData::GetData(){ // TPDocSheafLine *tempData = (TPDocSheafLine *)src; GetParentData(SrcData); SrcData->Type = Type; SrcData->Color = Color; SrcData->sp = sp; SrcData->ep = ep; } //--------------------------------------------------------------------------- void __fastcall TPDocSheetUndoData::SetData(TPDocSheet *src){ type = ((TPDocElement *)src)->Type; SetParentData(src); SrcData = src; Element = NULL; CopyElementList(src); } void __fastcall TPDocSheetUndoData::GetData(){ // TPDocChart *tempData = (TPDocChart *)src; GetParentData(SrcData); PasteElementList(SrcData); } void __fastcall TPDocSheetUndoData::CopyElementList(TPDocSheet *src){ if(Element != NULL){ Element->Clear(); delete Element; } Element = new TList; for (int i = 0; i< src->Element->Count;i++){ Element->Add(src->Element->Items[i]); } } void __fastcall TPDocSheetUndoData::PasteElementList(TPDocSheet *data){ if(data->Element != NULL){ data->Element->Clear(); delete data->Element; } if(Element == NULL)return; data->Element = new TList; for (int i = 0; i< Element->Count;i++){ data->Element->Add(Element->Items[i]); } } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- WideString ExtractFileNameW(WideString fullfn){ wchar_t* fnc = fullfn.c_bstr(); int i = 0; for(i = fullfn.Length(); ; i--){ wchar_t tmp = fnc[i]; if(tmp == '\\' || i==0) break; } if(i==0) return L""; else return fullfn.SubString(i+2,fullfn.Length()-i-1); } //--------------------------------------------------------------------------- // ¿¹½Å °ËÅä - by monkman (2010.10.19) __fastcall TPDBData::TPDBData() { FIDManager = NULL; FOrderManager = NULL; Init(); } //--------------------------------------------------------------------------- __fastcall TPDBData::~TPDBData() { //if (tpBUImage) delete tpBUImage; //tpBUImage = NULL; } //--------------------------------------------------------------------------- void __fastcall TPDBData::Init() { FID = -1; FDataType = detNone; FDataChanged = false; FOrder = -1; FQueryType = qtNone; FSelectQuery = ""; FInsertQuery = ""; FUpdateQuery = ""; FDeleteQuery = ""; FQuery = ""; // Data //clBUColor = clBlack; //if (tpBUImage == NULL) tpBUImage = new TTexpiaBitmap; //wstrBUImgTitle = ""; //nBUPrecision = 0; //wstrBUNumber = ""; //dBUNumber = 0.0; //wstrBUYear = ""; //wstrBUMonth = ""; //wstrBUDay = ""; //wstrBUText = ""; //wstrBUK_Text = ""; //wstrBUE_Text = ""; //wstrBUI_Text = ""; //wstrBUC_Text = ""; //wstrBUJ_Text = ""; //wstrBUTitle = ""; } //--------------------------------------------------------------------------- void __fastcall TPDBData::SetID(AnsiString strID) { // ¾ÆÀ̵𰡠°íÀ¯ÇÑÁö Áߺ¹ üũ ÈÄ Áߺ¹µÇÁö ¾Ê¾Ò´Ù¸é ÇÒ´çÇÑ´Ù if (FIDManager) { if (FIDManager(this, strID)) { FID = strID; } } } //--------------------------------------------------------------------------- void __fastcall TPDBData::SetOrder(int nOrder) { // ¾ÆÀ̵𰡠°íÀ¯ÇÑÁö Áߺ¹ üũ ÈÄ Áߺ¹µÇÁö ¾Ê¾Ò´Ù¸é ÇÒ´çÇÑ´Ù if (FOrderManager) { if (FOrderManager(this, nOrder)) { FOrder = nOrder; } } } //--------------------------------------------------------------------------- bool __fastcall TPDBData::CheckValidQuery(AnsiString strQuery) { bool bReturn = true; // »ç¿ëÇÏ¸é ¾ÈµÇ´Â Äõ¸®¹® °Ë»ç if (strQuery.UpperCase().Pos("ALTER") > 0 || strQuery.UpperCase().Pos("CREATE") > 0 || strQuery.UpperCase().Pos("DROP") > 0) { bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameColorChip(TPDocColorChip *clchipCurrent, TPDocColorChip *clchipOrigin) { bool bReturn = true; if (clchipCurrent && clchipOrigin) { if (clchipOrigin->Color != clchipCurrent->Color) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameNumber(TPDocNumber *numCurrent, TPDocNumber *numOrigin) { bool bReturn = true; if (numCurrent && numOrigin) { if (numCurrent->Precision != numOrigin->Precision || numCurrent->Number != numOrigin->Number) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameFormula(TPDocFormula *fmlCurrent, TPDocFormula *fmlOrigin) { bool bReturn = true; if (fmlCurrent && fmlOrigin) { if (fmlCurrent->Precision != fmlOrigin->Precision || fmlCurrent->Number != fmlOrigin->Number) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameDate(TPDocDate *dtCurrent, TPDocDate *dtOrigin) { bool bReturn = true; if (dtCurrent && dtOrigin) { if (dtCurrent->YearText != dtOrigin->YearText || dtCurrent->MonthText != dtOrigin->MonthText || dtCurrent->DayText != dtOrigin->DayText) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameLabel(TPDocLabel *lbCurrent, TPDocLabel *lbOrigin) { bool bReturn = true; if (lbCurrent && lbOrigin) { if (lbCurrent->Text != lbOrigin->Text) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameEdit(TPDocEdit *edCurrent, TPDocEdit *edOrigin) { bool bReturn = true; if (edCurrent && edOrigin) { if (edCurrent->K_Text != edOrigin->K_Text || edCurrent->E_Text != edOrigin->E_Text || edCurrent->I_Text != edOrigin->I_Text || edCurrent->C_Text != edOrigin->C_Text || edCurrent->J_Text != edOrigin->J_Text) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameMemo(TPDocMemo *mmCurrent, TPDocMemo *mmOrigin) { bool bReturn = true; if (mmCurrent && mmOrigin) { if (mmCurrent->Title != mmOrigin->Title || mmCurrent->Text != mmOrigin->Text) bReturn = false; } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::IsSameImage(TTexpiaBitmap *imgCurrent, TTexpiaBitmap *imgOrigin) { BYTE *pSrc = NULL, *pDst = NULL; RGBQUAD rgbSrc[256], rgbDst[256]; bool bReturn = true; if (imgCurrent && imgOrigin) { if (imgCurrent->Width == imgOrigin->Width && imgCurrent->Height == imgOrigin->Height && imgCurrent->BitsPerPixel == imgOrigin->BitsPerPixel) { // 8bitÀÏ ¶§ Ä÷¯ ¸ÕÀú ºñ±³ (¼Óµµ °³¼±) if (imgCurrent->BitsPerPixel == 8) { imgOrigin->GetColors(0, 256, rgbSrc); imgCurrent->GetColors(0, 256, rgbDst); for (int i = 0; i < 256; i++) { if (rgbSrc[i].rgbRed != rgbDst[i].rgbRed || rgbSrc[i].rgbGreen != rgbDst[i].rgbGreen || rgbSrc[i].rgbBlue != rgbDst[i].rgbBlue) { bReturn = false; break; } } // ¹ÙÀÌÆ® µ¥ÀÌÅÍ ºñ±³ if (bReturn == false) { imgOrigin->StartScanLine(); imgCurrent->StartScanLine(); for (int y = 0; y < imgOrigin->Height; y++) { pSrc = imgOrigin->GetScanLine(y); pDst = imgCurrent->GetScanLine(y); if (memcmp(pSrc, pDst, imgOrigin->BytesPerLine) != 0) { bReturn = false; break; } } imgCurrent->StopScanLine(); imgOrigin->StopScanLine(); } } } else { bReturn = false; } } else { bReturn = true; } return bReturn; } //--------------------------------------------------------------------------- WideString __fastcall TPDBData::GetQuery() { WideString wstrQuery; switch (FQueryType) { case qtSelect: wstrQuery = FSelectQuery; break; case qtInsert: wstrQuery = FInsertQuery; break; case qtUpdate: wstrQuery = FUpdateQuery; break; case qtDelete: wstrQuery = FDeleteQuery; break; } // Insert³ª UpdateÀÇ °æ¿ì µ¥ÀÌÅͰ¡ º¯°æµÇÁö ¾Ê¾ÒÀ¸¸é, ¹Ý¿µÇÏÁö ¾Êµµ·Ï ÇÑ´Ù if ((FQueryType == qtInsert || FQueryType == qtUpdate) && FDataChanged == false) { wstrQuery = ""; } return wstrQuery; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::SetQuery(AnsiString strQuery) { bool bReturn = false; if (CheckValidQuery(strQuery)) { // Äõ¸® ÀÔ·Â if (strQuery.UpperCase().Pos("SELECT") == 1) { FSelectQuery = strQuery; bReturn = true; } if (strQuery.UpperCase().Pos("INSERT") == 1) { FInsertQuery = strQuery; bReturn = true; } if (strQuery.UpperCase().Pos("UPDATE") == 1) { FUpdateQuery = strQuery; bReturn = true; } if (strQuery.UpperCase().Pos("DELETE") == 1) { FDeleteQuery = strQuery; bReturn = true; } } return bReturn; } //--------------------------------------------------------------------------- bool __fastcall TPDBData::CompareElement(TPDocElement *elmtCurrent, TPDocElement *elmtOriginal) { bool bReturn = true; if (elmtCurrent->Type != elmtOriginal->Type) bReturn = false; if (bReturn == true) { switch (elmtCurrent->Type) { case detColorChip: bReturn = IsSameColorChip((TPDocColorChip *)elmtCurrent, (TPDocColorChip *)elmtOriginal); break; case detNumber: bReturn = IsSameNumber((TPDocNumber *)elmtCurrent, (TPDocNumber *)elmtOriginal); break; case detFormula: bReturn = IsSameFormula((TPDocFormula *)elmtCurrent, (TPDocFormula *)elmtOriginal); break; case detDate: bReturn = IsSameDate((TPDocDate *)elmtCurrent, (TPDocDate *)elmtOriginal); break; case detLabel: bReturn = IsSameLabel((TPDocLabel *)elmtCurrent, (TPDocLabel *)elmtOriginal); break; case detEdit: bReturn = IsSameEdit((TPDocEdit *)elmtCurrent, (TPDocEdit *)elmtOriginal); break; case detMemo: bReturn = IsSameMemo((TPDocMemo *)elmtCurrent, (TPDocMemo *)elmtOriginal); break; case detImage: bReturn = IsSameImage((TTexpiaBitmap *)((TPDocImage *)elmtCurrent)->Image, (TTexpiaBitmap *)((TPDocImage *)elmtOriginal)->Image); break; case detSignature: bReturn = IsSameImage((TTexpiaBitmap *)((TPDocSignature *)elmtCurrent)->Image, (TTexpiaBitmap *)((TPDocSignature *)elmtOriginal)->Image); break; default: bReturn = false; break; } } FDataChanged = bReturn; return bReturn; } //---------------------------------------------------------------------------