//--------------------------------------------------------------------------- // This Program is made by Maxleo21c(Park Sang Hoon). // It works in C++ Builder 6. // 2004. 07. 15. // // Reference : Scalable Vector Graphics(SVG) 1.2 // W3C Working Draft 10 May 2004 //--------------------------------------------------------------------------- #pragma hdrstop #include "Math.h" #include "ConvertToSVG.h" #include "GetVectorFontName.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- __fastcall TVector2SVG::TVector2SVG(bool _bRange, TRect _Src) { // ÀÌ ¹öÀüÀº ÆÄÀÏ Æ¯È÷ CDATA¿¡ ³»¿ëÀ» ±¸ºÐÇϱâ À§Çؼ­ »ç¿ëµÈ´Ù. Version = 100; //by maxleo21c(ÆÄÀÏ In/Out ÃÖÃÊ ¹öÀü) - (06.06.22) bRange = _bRange; Src.Left = _Src.Left; Src.Right = _Src.Right; Src.Top = _Src.Top; Src.Bottom = _Src.Bottom; } //--------------------------------------------------------------------------- __fastcall TVector2SVG::~TVector2SVG() { } //--------------------------------------------------------------------------- // by maxleo21c 070628 // XMLÀº space(#x20)À» Çϳª¹Û¿¡ ÀνÄÇÏÁö ¸øÇÏ´Â ¹®Á¦Á¡ÀÌ ÀÖ´Ù. ±× ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ SVG¿¡¼­´Â // xml:space="default" or "preserve"¸¦ Á¦°øÇÑ´Ù. Á¤º¸´Â ã¾Æº¸±â ¹Ù¶÷. // xml:space="default"¸¦ ÀÌ¿ëÇØ¼­ space¹®Á¦¸¦ ÇØ°áÇßÀ½. space¸¦ »ç¿ëÇÏÁö ¾Ê°í ±ÛÀÚÀÇ À§Ä¡°ª¸¸À¸·Î // svg ÆÄÀÏÀ» ¸¸µé¾úÀ½. ½ÇÁ¦ text data´Â CDATA¿¡ ¸ðµÎ ³Ö°í Text VersionÀ» 101·Î »óÇâ Á¶Á¤ÇßÀ½. void __fastcall TVector2SVG::InitSVGFile(String &buffer, String version, int Width, int Height) { buffer = "<\?xml version=\"1.0\" encoding=\"utf-8\"\?>\n"; buffer = buffer + "\n"; buffer = buffer + ""; buffer = buffer + "\n"; buffer = buffer + ""; buffer = buffer + "\n"; } //--------------------------------------------------------------------------- void __fastcall TVector2SVG::SVGDrawLine(String &buffer, DPOINT *pTemp, int nCount, TColor Color, TColor Brush, bool bFill, bool bWinding, double PenThick) { // ÇöÀç TexStylist Vector´Â ¸ðµç °ÍÀ» Curve·Î ±×¸®±â ¶§¹®¿¡ Çʿ䰡 ¾ø´Ù. String sColor, sBrush; sColor = sColor.sprintf(L"%06X", Color); sBrush = sBrush.sprintf(L"%06X", Brush); buffer = buffer + "\t"; buffer = buffer + ""; buffer = buffer + "\n"; } //--------------------------------------------------------------------------- //void __fastcall TVector2SVG::SVGDrawCurve(String &buffer, POINT *pTemp, TVecData *data, // String dn, String fn, int data_num, int &patternFill_ID) void __fastcall TVector2SVG::SVGDrawCurve(String &buffer, DPOINT *pTemp, TVecData *data, String dn, String fn, int data_num, int &patternFill_ID) { int Number; int nCount = data->nCount; int PenStyle = data->PenStyle; TColor Color = data->Color, Brush = data->Brush; double PenThick = data->PenThick; bool bClosed = data->bClosed, bFill = data->bFill, bWinding = data->bWinding, bRound = data->bRound; String sColor, sBrush, temp; sColor = sColor.sprintf(L"%06X", Color); sBrush = sBrush.sprintf(L"%06X", Brush); temp = buffer; bool bPatternFill = false; if (data->bPatternFill) { bPatternFill = true; buffer = buffer + "\t\n\t\t"; //SVGSavePatternBitmap(fn, dn, data, buffer, data_num); //Base64·Î ºÙÀ̵µ·Ï º¯°æ. 2007.08.14.diekun. if (!SVGSavePatternBitmapB64(fn, dn, data, buffer, data_num, patternFill_ID)) { buffer = temp + "\t"; bPatternFill = false; } else { buffer = buffer + "\n\t\t"; } } else { buffer = buffer + "\t"; } if (data->ParentTextBox) { String temp; Char s_temp[20]=L"0"; _stprintf(s_temp, L"myPath%d",data_num); temp = s_temp; buffer = buffer + "bPatternFill) { buffer = buffer + "fill=\"url(#pattern_id" + IntToStr(patternFill_ID) + ")\""; } else { if (bFill) { TColorToSVGColor(sBrush); if (bWinding) buffer = buffer + "fill=\"#" + sBrush + "\""; else { buffer = buffer + "fill=\"#" + sBrush + "\""; buffer = buffer + " fill-rule=\"evenodd\""; } } else buffer = buffer + "fill=\"none\""; } TColorToSVGColor(sColor); buffer = buffer + " stroke=\"#" + sColor + "\""; if (data->ChildList) PenThick = 0; buffer = buffer + " stroke-width=\"" + FloatToStr(PenThick) + "\""; if (bRound) { buffer = buffer + " stroke-linecap=\"round\""; buffer = buffer + " stroke-linejoin=\"round\""; } //P_DASH, P_DOT, P_DASHDOT, P_DASHDOTDOT if (PenStyle == 1) { // P_DASH = 1; buffer = buffer + " stroke-dasharray=\"" + FloatToStr(3*data->PenThick) + ", " + FloatToStr(data->PenThick) + "\""; } else if (PenStyle == 2) { // P_DOT = 2; buffer = buffer + " stroke-dasharray=\"" + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + "\""; } else if (PenStyle == 3) { // P_DASHDOT = 3; buffer = buffer + " stroke-dasharray=\"" + FloatToStr(3*data->PenThick) + ", " + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + "\""; } else if (PenStyle == 4) { // P_DASHDOTDOT = 4; buffer = buffer + " stroke-dasharray=\"" + FloatToStr(3*data->PenThick) + ", " + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + ", " + FloatToStr(data->PenThick) + "\""; } else if (PenStyle == 5) { // P_USERSTYLE 06.09.20 by maxleo21c int count = data->DashValues[0]; buffer = buffer + " stroke-dasharray=\""; for (int i = 1; i <= count; i++) { buffer = buffer + FloatToStr(data->DashValues[i]*data->PenThick); if (i < count) buffer = buffer + ", "; } buffer = buffer + "\""; } buffer = buffer + "/>\n"; if (bPatternFill && data->bPatternFill) { buffer = buffer + "\t\t"; buffer = buffer + MakePatternCDATA(data); buffer = buffer + "\n"; buffer = buffer + "\t\n"; } } //--------------------------------------------------------------------------- // by maxleo21c (06.06.12) // textBoxf¸¦ ÀúÀåÇÒ ¶§ vecdata¸¦ CDATA¿¡ ÀúÀåÇϱâ À§Çؼ­ ¸¸µç ÇÔ¼ö String __fastcall TVector2SVG::MakePatternCDATA(TVecData *data) { String t_string; //File Version°ü¸®°¡ ÇÊ¿äÇÒ °Í °°¾Æ¼­ Ãß°¡Çß´Ù. t_string = t_string + (IntToStr(Version) + "|"); t_string = t_string + (IntToStr(data->PatternAngle) + "|"); t_string = t_string + (IntToStr(data->PatternAdjustX) + "|"); t_string = t_string + (IntToStr(data->PatternAdjustY) + "|"); t_string = t_string + (IntToStr(data->RatioX) + "|"); t_string = t_string + (IntToStr(data->RatioY) + "|"); t_string = t_string + (IntToStr(data->TBitmapSource->Width) + "|"); t_string = t_string + (IntToStr(data->TBitmapSource->Height) + "|"); return t_string; } //--------------------------------------------------------------------------- /// ÆÐÅϺñÆ®¸ÊÀ» JPGÆÄÀÏ·Î ÀúÀåÇÏ¿© XML ±¸Á¶·Î ¸µÅ©½ÃÄÑÁÖ´Â ÇÔ¼ö //2007.08.13.diekun. //bool __fastcall TVector2SVG::SVGSavePatternBitmap(String fn, String dn, TVecData *data, // String &buffer, int count) bool __fastcall TVector2SVG::SVGSavePatternBitmap(String fn, String dn, TVecData *data, String &buffer, int count) { //String fullPath, newDir, file, jpgName; String fullPath, newDir, file, jpgName; file = fn.SubString(1, fn.Length()-4); newDir = dn + String("\\") + file; CreateDirectory(newDir.c_str(), NULL); jpgName = file + String(count); fullPath = FullPathName(newDir, jpgName + String(".jpg")); int x, y, width, height; width = data->TBitmap->Width; height = data->TBitmap->Height; x = data->First.x; y = data->First.y; buffer = buffer + "\n"; buffer = buffer + "\t\t\t"; buffer = buffer + "\n"; buffer = buffer + "xlink:sourcehref=\""; buffer = buffer + file + "/" +jpgName + "_s.jpg\"/>\n"; buffer = buffer + "\t\t"; int nFormat = FILE_JFIF, QFactor = 2; if(!data->TBitmap->SaveToFile(fullPath, nFormat, QFactor)) { return false; } // ¼Ò½ºµµ ÀúÀåÇØ¾ß svgÆÄÀÏÀ» ¿­¾úÀ» ¶§ ÆÐÅÏÀÌ ÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ ÁÖÁ¤ÀÌ // °¡´ÉÇÏ´Ù. ±×·¡¼­ TBitmapSourceµµ ÀúÀåÇØ¾ß ÇÒ °Í °°´Ù. ¤Ð¤Ð fullPath = FullPathName(newDir, jpgName + String("_s.jpg")); if(!data->TBitmapSource->SaveToFile(fullPath, nFormat, QFactor)) { return false; } return true; } //--------------------------------------------------------------------------- /// ÆÐÅϺñÆ®¸ÊÀ» Base64·Î ´ã¾Æ¼­ XML ±¸Á¶·Î Ãß°¡ÇØÁÖ´Â ÇÔ¼ö //2007.08.13.diekun. //bool __fastcall TVector2SVG::SVGSavePatternBitmapB64(String fn, String dn, TVecData *data, // String &buffer, int count, int &patternFill_ID) bool __fastcall TVector2SVG::SVGSavePatternBitmapB64(String fn, String dn, TVecData *data, String &buffer, int count, int &patternFill_ID) { String strBase64Img, strBase64ImgS; ////// //Base64¹æ½Ä¿¡¸¸ »ç¿ëµÇ´Â imgBuffer¿Í imgB64BufferÀÇ ÇÒ´ç //todo:2007.07.31.diekun. ¹öÆÛÀÇ »çÀÌÁî°¡ ÇöÀç 1¸Þ°¡·Î °íÁ¤µÇ¾î ÀÖÀ¸¹Ç·Î ÃßÈÄ ¿ë·®¹®Á¦°¡ »ý±æ ¼ö ÀÖ´Ù. //À̶§´Â LeadToolsÀÇ L_SaveBitmapBufferÀÇ callbackÇÔ¼ö »ç¿ë¹ýÀ» Âü°íÇÏ¿© ¼öÁ¤ÇØ¾ß ÇÑ´Ù. BYTE* imgBuffer; imgBuffer = (BYTE*)malloc(pow(2,20)); // imgBuffer´Â À̹ÌÁö Çȼ¿°ªÀ» °¡Á®¿À¹Ç·Î BYTE*·Î, imgB64Buffer´Â Base64Encode¿¡ ÀÇÇØ ¹®ÀÚ·Î º¯ÇüµÇ¹Ç·Î Char* char* imgB64Buffer; imgB64Buffer = (char*)malloc(pow(2,20)); if(imgBuffer==NULL || imgB64Buffer==NULL) { if(imgBuffer) free(imgBuffer); if(imgB64Buffer) free(imgB64Buffer); ShowMessage(IDS_MESSAGE_MEMORYLACK); return false; //<¸Þ¸ð¸® ÇÒ´ç ½ÇÆÐ } //Âü°í //:2007.07.31.diekun. ¹öÆÛÀÇ »çÀÌÁî°¡ ÇöÀç 1¸Þ°¡·Î °íÁ¤µÇ¾î ÀÖÀ¸¹Ç·Î ÃßÈÄ ¿ë·®¹®Á¦°¡ »ý±æ ¼ö ÀÖ´Ù. //À̶§´Â LeadToolsÀÇ L_SaveBitmapBufferÀÇ callbackÇÔ¼ö »ç¿ë¹ýÀ» Âü°íÇÏ¿© ¼öÁ¤ÇØ¾ß ÇÑ´Ù. bool bSucceed; // L_UINT32 imgFileSize = 0; L_ULONG imgFileSize = 0; // Casting ¿¡·¯ ¼öÁ¤ (2008. 01. 02. Annualring) bSucceed = L_SaveBitmapBuffer (imgBuffer, pow(2,20), &imgFileSize, data->TBitmap->Handle, FILE_JFIF//FILE_LEAD2JFIF//FILE_JPEG , 24, 2, NULL//pfnSaveBufferCB , NULL//pUserData , NULL//pSaveOptions ) == SUCCESS; if(!bSucceed) return false; Base64Encode(imgBuffer, imgFileSize, imgB64Buffer); //½ºÆ®¸µÀ¸·Î ÄÁ¹öÆ®µÈ ³»¿ëÀ» ¿Å±ä´Ù. strBase64Img = imgB64Buffer; bSucceed = L_SaveBitmapBuffer (imgBuffer, pow(2,20), &imgFileSize, data->TBitmapSource->Handle, FILE_JFIF//FILE_LEAD2JFIF//FILE_JPEG , 24, 2, NULL//pfnSaveBufferCB , NULL//pUserData , NULL//pSaveOptions ) == SUCCESS; if(!bSucceed) return false; Base64Encode(imgBuffer, imgFileSize, imgB64Buffer); strBase64ImgS = imgB64Buffer; // free(imgBuffer);//< À̹ÌÁö ¹öÆÛ¿¡ ÇÒ´çµÈ ¸Þ¸ð¸®¸¦ »èÁ¦ÇØÁØ´Ù. free(imgB64Buffer);//< À̹ÌÁö ¹öÆÛ¿¡ ÇÒ´çµÈ ¸Þ¸ð¸®¸¦ »èÁ¦ÇØÁØ´Ù. ////// int x, y, width, height; width = data->TBitmap->Width; height = data->TBitmap->Height; x = data->First.x; y = data->First.y; buffer = buffer + "\n"; buffer = buffer + "\t\t\t"; buffer = buffer + "\n"; buffer = buffer + (String)"data:image/jpeg;base64," + strBase64Img + "\" \n"; buffer = buffer + "xlink:sourcehref=\""; buffer = buffer + (String)"data:image/jpeg;base64," + strBase64ImgS + "\"/>\n"; buffer = buffer + "\t\t"; return true; } //--------------------------------------------------------------------------- void __fastcall TVector2SVG::SVGDrawRect(String &buffer, int FirstX, int FirstY, int SecondX, int SecondY, TColor Color, TColor Brush) { // ÇöÀç TexStylist Vector´Â ¸ðµç °ÍÀ» Curve·Î ±×¸®±â ¶§¹®¿¡ Çʿ䰡 ¾ø´Ù. } //--------------------------------------------------------------------------- void __fastcall TVector2SVG::SVGDrawEllipse(String &buffer, int FirstX, int FirstY, int SecondX, int SecondY, TColor Color, TColor Brush) { // ÇöÀç TexStylist Vector´Â ¸ðµç °ÍÀ» Curve·Î ±×¸®±â ¶§¹®¿¡ Çʿ䰡 ¾ø´Ù. } //--------------------------------------------------------------------------- void __fastcall TVector2SVG::SVGDrawText(String &buffer, int FirstX, int FirstY, String TextString, int nCount, LOGFONT Font, TColor Color) { String sColor; // String UnicodeString; String FontName; bool isRotated = false; sColor = sColor.sprintf(L"%06X", Color); TColorToSVGColor(sColor); if (Font.lfEscapement != 0) { isRotated = true; buffer += "\t"; buffer += "\n"; if (Font.lfEscapement > 0) Font.lfEscapement = -((Font.lfEscapement/10)%360); else Font.lfEscapement = (Font.lfEscapement/10)%360; buffer = buffer + "\t\t\n"; } if (isRotated) { buffer = buffer + "\t\t\t"; buffer = buffer + ""; buffer = buffer + "\n"; if (isRotated) buffer = buffer + "\t\t\t\t"; else buffer = buffer + "\t\t"; // buffer = buffer + UnicodeString; buffer = buffer + TextString; buffer = buffer + "\n"; if (isRotated) buffer = buffer + "\t\t\t\n\t\t\n\t"; else buffer = buffer + "\t"; buffer = buffer + "\n"; } //--------------------------------------------------------------------------- // TColor(BGR) -> SVGColor(RGB) void __fastcall TVector2SVG::TColorToSVGColor(String &svgColor) { Char RGB[7]; if (_tcslen(svgColor.c_str()) > 7) return; _tcscpy(RGB, svgColor.c_str()); svgColor.c_str()[0] = RGB[4]; svgColor.c_str()[1] = RGB[5]; svgColor.c_str()[4] = RGB[0]; svgColor.c_str()[5] = RGB[1]; } //--------------------------------------------------------------------------- // Çѱ۷Πǥ±âµÈ Font -> ÇѱÛÀ» ¾ËÆÄºª Ç¥±â·Î º¯°æÇÑ Font void __fastcall TVector2SVG::HangulToAlphabet(Char *FontFaceName, String &FontName) { if ( _tcscmp(FontFaceName, L"±¼¸²") == 0) FontName = "Gulim"; else if ( _tcscmp(FontFaceName, L"±¼¸²Ã¼") == 0 ) FontName = "GulimChe"; else if ( _tcscmp(FontFaceName, L"±Ã¼­") == 0 ) FontName = "Gungsuh"; else if ( _tcscmp(FontFaceName, L"±Ã¼­Ã¼") == 0 ) FontName = "GungsuhChe"; else if ( _tcscmp(FontFaceName, L"µ¸¿ò") == 0 ) FontName = "Dotum"; else if ( _tcscmp(FontFaceName, L"µ¸¿òü") == 0 ) FontName = "DotumChe"; else if ( _tcscmp(FontFaceName, L"¹ÙÅÁ") == 0 ) FontName = "Batang"; else if ( _tcscmp(FontFaceName, L"¹ÙÅÁü") == 0 ) FontName = "BatangChe"; // else if ( GetVectorFontName->GetFontFile(FontFaceName, FontName) ) return; else FontName = "Batang"; } //--------------------------------------------------------------------------- // Ansi -> UniCode bool __fastcall TVector2SVG::AnsiToUnicode(String TextString, String &string, int useByte, Char *sWord) { // int length, wlength=0; // Char wordBstr[100]; // // length = TextString.Length(); // wlength = TextString.CharBufSize() - 1; // ZeroMemory(wordBstr, sizeof(wordBstr)); // // if (useByte == 1){ // MultiByteToWideChar(CP_ACP, 0, sWord, 1, wordBstr, // sizeof(wordBstr) / sizeof(wordBstr[0])); // } else { // MultiByteToWideChar(CP_ACP, 0, sWord, 2, wordBstr, // sizeof(wordBstr) / sizeof(wordBstr[0])); // } // // if (string == NULL) return length == wlength; // // for (int i=0; i<_tcslen(wordBstr); i++) { // string += "&#x"; // string += UnicodeString().sprintf("%X",wordBstr[i]); // string += ";"; // } // // return length == wlength; } //--------------------------------------------------------------------------- // ÇѱÛÀÎÁö È®ÀÎ Çϱâ À§ÇÑ ÄÚµå (UniCode·Î È®ÀÎ) bool __fastcall TVector2SVG::ExistHangul(String TextString) { /* int length, wlength=0; Char *code; //////////////////////////////////////////////////// /////////// ³ªÁß¿¡ ´Ù½Ã È®ÀÎ ¿ä¸Á! ///////////////// //////////////////////////////////////////////////// length = TextString.Length(); wlength = TextString.WideCharBufSize() - 1; code = new Char[wlength]; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, TextString.c_str(), length, code, wlength); delete[] code; return length == wlength; */ } //--------------------------------------------------------------------------- // 070807 : ÅØ½ºÆ® ºÎºÐ¿¡¼­ ¿¡·¯°¡ ³¯ °æ¿ì ¿¡·¯ ¿©ºÎ¸¦ È®ÀÎÇϱâ À§Çؼ­ bool·Î º¯°æ bool __fastcall TVector2SVG::SVGDrawTextBox(String &buffer, TVecData *data, int StartX, int StartY) { String sColor; String TextString; String UnicodeString; String FontName; int angle = data->TextAngle; int linecount, wordcount; float realCharX; float realCharY=StartY; TSWordData *tsWordData; int lineHeight; Char sword[2]; // font À̸§ ÀúÀåÇÏ·Á°í String sCDATA; sCDATA = MakeTextBoxCDATA(data, false); if (angle) { buffer += "\t\n"; buffer += "\t\t\n"; if (angle > 0) angle = -(angle%360); else angle = angle%360; buffer = buffer + "\t\t\n"; realCharY = 0; } if (angle) { buffer = buffer + "\t\t\t\n"; } else { buffer = buffer + "\t\n"; buffer = buffer + "\t\t\n"; } linecount = data->ListOfAllLine->GetLineCount(); for (int i=0; iListOfAllLine->GetLineTextBox(i)->LineDataList->Count; if (wordcount == 0) continue; //¿¡·¯°¡ ¹ß»ýÇØ¼­ ±×³É skipÇÏ°Ô ¹Ù²Þ if (angle) { buffer += "\t\t\t\tListOfAllLine->GetLineTextBox(i)->LineDataList->Items[j]; if (tsWordData->Word[0] == L' ' && tsWordData->Word[1] == L'\0') { } else { buffer += FloatToStr(realCharX); buffer += " "; } realCharX += tsWordData->Interval * tsWordData->WidthGap; } buffer += "\" y=\""; buffer += FloatToStr(realCharY); buffer += "\">\n"; lineHeight = (data->ListOfAllLine->GetLineTextBox(i))->lineHeight; realCharY += ((lineHeight) * 0.8 * tsWordData->HeightGap); if (angle) buffer += "\t\t\t\t\tListOfAllLine->GetLineTextBox(i)->LineDataList->Items[k]; if (IsAnyDifferntStateForText(data, i, k)) { if (k) { buffer = buffer + "LFont.lfFaceName) ) buffer = buffer + " font-family=\"" + tsWordData->LFont.lfFaceName + "\""; else { FontName=""; HangulToAlphabet(tsWordData->LFont.lfFaceName, FontName); buffer = buffer + " font-family=\"" + FontName + "\""; } // buffer = buffer + " font-family=\"" + tsWordData->LFont.lfFaceName + "\""; sColor = sColor.sprintf(L"%06X", tsWordData->Color); TColorToSVGColor(sColor); /*Text dataÁß¿¡ ¸Ç ¸¶Áö¸· ±ÛÀÚ°¡ '\0' ³¡³ª´Â °ÍÀÌ ÀÖ¾ú´Âµ¥ Á¤È®ÇÏ°Ô "FûÁÖ¿îÈ£°íµ¿º¹SMS.svg" ÆÄÀÏÀ» ¿­¾î º¸¸é data count (i=13)13¹øÂ°ÀÎ "´ë¸®Á¡\0" ÀÌ·¸°Ô µé¾î°¡ ÀÖ¾ú´Ù. À̶§ '\0'ÀÇ LFont.lfHeight°¡ 0º¸´Ù À۾Ƽ­ ÆÄÀÏÀÌ ÀúÀåµÇÁö ¾Ê¾Ò´Ù. ¾î¶²¶§ ÀÌ·¸°Ô ¸¸µé¾î Áö´ÂÁö È®ÀÎÇØ º¼ Çʿ䰡 ÀÖÀ»°Í °°´Ù.*/ if (tsWordData->LFont.lfHeight > 1000 || tsWordData->LFont.lfHeight < 0) goto fail; buffer = buffer + " font-size=\"" + FloatToStr((float)tsWordData->LFont.lfHeight) + "\""; buffer = buffer + " fill=\"#" + sColor + "\""; if (tsWordData->LFont.lfItalic) buffer += " font-style=\"italic\""; if (tsWordData->LFont.lfWeight == FW_BOLD) buffer += " font-weight=\"bold\""; buffer = buffer + " length=\"" + IntToStr(GetTSPAN_Length(data, i, k, wordcount)) + "\""; buffer = buffer + ">"; } if (tsWordData->Word[0] == L' ' && tsWordData->Word[1] == L'\0') { } else { TextString=tsWordData->Word; // UnicodeString=""; // AnsiToUnicode(TextString, UnicodeString, tsWordData->UsedByte, tsWordData->Word); //& -> & //< -> < //> -> > //À§ 3°¡Áö ¿Ü¿¡µµ MSXML 2.0 ÀÌÀü¿¡¼­´Â ¾Æ·¡ µÎ¹®ÀÚµµ °°ÀÌ ¹Ù²ã¾ß ÇÕ´Ï´Ù. //' -> ' //" -> " if (TextString == "&") TextString = "&"; else if (TextString == "<") TextString = "<"; else if (TextString == ">") TextString = ">"; else if (TextString == "'") TextString = "'"; else if (TextString == "\"") TextString = """; buffer += TextString; } } buffer += "\n"; if (angle) buffer += "\t\t\t\t\n"; else buffer = buffer + "\t\t\n"; } if (angle) { buffer = buffer + "\t\t\t\n\t\t\n\t\t\n"; buffer = buffer + "\t\t"; buffer = buffer + sCDATA; buffer = buffer + "\n"; } else { buffer = buffer + "\t\t\n"; buffer = buffer + "\t\t"; buffer = buffer + sCDATA; buffer = buffer + "\n"; } buffer = buffer + "\t\n"; return true; fail: return false; } //--------------------------------------------------------------------------- //by maxleo21c(06.06.11) ¤»¤» Áý¿¡¼­ void __fastcall TVector2SVG::SVGDrawTextPath(String &buffer, TVecData *data, int StartX, int StartY, int data_num, int &patternFill_ID) { String sColor; String TextString; String UnicodeString; String FontName; int angle = data->TextAngle; int linecount, wordcount; float realCharX; float realCharY=StartY; TSWordData *tsWordData; int lineHeight; //POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) DPOINT *pPoints = NULL; TVecData *curveData; curveData = data->ListOfAllLine->CurveData; if (curveData->Kind == V_TEXTBOX) { //pPoints = new POINT[5]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); } else { if (curveData->bClosed && curveData->PenStyle == P_SOLID){ //pPoints = new POINT[(curveData->nCount+1)*3+1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * ((curveData->nCount+1)*3+1)); } else { //pPoints = new POINT[curveData->nCount*3+1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (curveData->nCount*3+1)); } } for (int i = 0; i < curveData->nCount*3 +1; i++) { if (bRange){ pPoints[i].x = curveData->pList[i].x - Src.Left; pPoints[i].y = curveData->pList[i].y - Src.Top; } else { pPoints[i].x = curveData->pList[i].x; pPoints[i].y = curveData->pList[i].y; } } buffer += "\t\n\t"; SVGDrawCurve(buffer, pPoints, curveData, String(""), String(""), data_num, patternFill_ID); String sCDATA; sCDATA = MakeTextBoxCDATA(data, true); buffer = buffer + "\t\t\n"; String temp; Char s_temp[20]=L"0"; _stprintf(s_temp, L"#myPath%d",data_num); temp = s_temp; buffer = buffer + "\t\t\t\n"; linecount = data->ListOfAllLine->GetLineCount(); for (int i=0; iListOfAllLine->GetLineTextBox(i)->LineDataList->Count; if (wordcount == 0) continue; //¿¡·¯°¡ ¹ß»ýÇØ¼­ ±×³É skipÇÏ°Ô ¹Ù²Þ buffer = buffer + "\t\t\tListOfAllLine->GetLineTextBox(i)->LineDataList->Items[k]; if (IsAnyDifferntStateForText(data, i, k)) { if (k) buffer += "\n\t\t\tLFont.lfFaceName) ) buffer = buffer + " font-family=\"" + tsWordData->LFont.lfFaceName + "\""; else { FontName=""; HangulToAlphabet(tsWordData->LFont.lfFaceName, FontName); buffer = buffer + " font-family=\"" + FontName + "\""; } // buffer = buffer + " font-family=\"" + tsWordData->LFont.lfFaceName + "\""; sColor = sColor.sprintf(L"%06X", tsWordData->Color); TColorToSVGColor(sColor); buffer = buffer + " font-size=\"" + FloatToStr((float)tsWordData->LFont.lfHeight) + "\""; buffer = buffer + " fill=\"#" + sColor + "\""; if (tsWordData->LFont.lfItalic) buffer += " font-style=\"italic\""; if (tsWordData->LFont.lfWeight == FW_BOLD) buffer += " font-weight=\"bold\""; buffer = buffer + " length=\"" + IntToStr(GetTSPAN_Length(data, i, k, wordcount)) + "\""; buffer = buffer + ">"; } TextString=tsWordData->Word; // UnicodeString=""; // AnsiToUnicode(TextString, UnicodeString, tsWordData->UsedByte, tsWordData->Word); buffer += TextString; } buffer = buffer + "\t\t\t\n"; } buffer = buffer + "\t\t\t\n"; buffer = buffer + "\t\t\n"; buffer = buffer + "\t\t"; buffer = buffer + sCDATA; buffer = buffer + "\n"; buffer = buffer + "\t\n"; //if (pPoints) delete []pPoints; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; } //--------------------------------------------------------------------------- // by maxleo21c (06.06.12) // textBoxf¸¦ ÀúÀåÇÒ ¶§ vecdata¸¦ CDATA¿¡ ÀúÀåÇϱâ À§Çؼ­ ¸¸µç ÇÔ¼ö String __fastcall TVector2SVG::MakeTextBoxCDATA(TVecData *tData, bool bTextPath) { String t_string, temp; int TextBoxVersion = 101; // °¢°¢ ¹öÀü ºÐ¸® ÇÏ´Â °ÍÀÌ ÁÁÀ» °Í °°¾Æ¼­ »õ·Î Ãß°¡ by maxleo21c 070628 //ȣȯ¹®Á¦·Î ¾Æ·¡ ³»¿ë Ãß°¡ AnsiString ansiWord; char aWord[2] = {0}; int usedByte = 1; //------------------------------------------------- //File Version°ü¸®°¡ ÇÊ¿äÇÒ °Í °°¾Æ¼­ Ãß°¡Çß´Ù. t_string = t_string + (IntToStr(TextBoxVersion) + "|"); if (bRange) { t_string = t_string + (FloatToStr(tData->First.x - Src.Left) + "|"); t_string = t_string + (FloatToStr(tData->First.y - Src.Top) + "|"); t_string = t_string + (FloatToStr(tData->Second.x - Src.Left) + "|"); t_string = t_string + (FloatToStr(tData->Second.y - Src.Top) + "|"); } else { t_string = t_string + (FloatToStr(tData->First.x) + "|"); t_string = t_string + (FloatToStr(tData->First.y) + "|"); t_string = t_string + (FloatToStr(tData->Second.x) + "|"); t_string = t_string + (FloatToStr(tData->Second.y) + "|"); } t_string = t_string + (IntToStr(tData->CharH) + "|"); t_string = t_string + (IntToStr(tData->CharW) + "|"); t_string = t_string + (FloatToStr(tData->TextAngle) + "|"); if (bRange) { t_string = t_string + (FloatToStr(tData->StartPoint.x - Src.Left) + "|"); t_string = t_string + (FloatToStr(tData->StartPoint.y - Src.Top) + "|"); t_string = t_string + (FloatToStr(tData->CenterPoint.x - Src.Left) + "|"); t_string = t_string + (FloatToStr(tData->CenterPoint.y - Src.Top) + "|"); } else { t_string = t_string + (FloatToStr(tData->StartPoint.x) + "|"); t_string = t_string + (FloatToStr(tData->StartPoint.y) + "|"); t_string = t_string + (FloatToStr(tData->CenterPoint.x) + "|"); t_string = t_string + (FloatToStr(tData->CenterPoint.y) + "|"); } int lineheight, wordcount, linecount; t_string = t_string + (IntToStr(tData->nCount) + "|"); linecount = tData->ListOfAllLine->LineCount; t_string = t_string + IntToStr(linecount); t_string = t_string + "|"; //LineCount ±¸ºÐÀÚ # t_string = t_string + "\n"; // ¿©±â¼­ ÁÙÀ» ¹Ù²ã ÁØ´Ù. TSWordData *srcWordData; for (int i=0; iListOfAllLine->GetLineTextBox(i)->LineDataList->Count; t_string = t_string + IntToStr(wordcount); t_string = t_string + "|"; //wordcount ±¸ºÐÀÚ % for (int j=0; jListOfAllLine->GetLineTextBox(i)->LineDataList->Items[j]; temp = srcWordData->LFont.lfFaceName; t_string = (t_string + temp + "|"); t_string = t_string + (FloatToStr(srcWordData->PPoint.x) + "|"); t_string = t_string + (FloatToStr(srcWordData->PPoint.y) + "|"); //10.2 ÀÌÇÏÀÇ ÇÏÀ§ ¹öÀü°úÀÇ È£È¯À» À§Çؼ­ ó¸®ÇÔ. ansiWord = srcWordData->Word; memset(aWord, 0, sizeof(char)*2); memcpy(aWord, ansiWord.c_str(), 2); usedByte = srcWordData->UsedByte; if (aWord[1] != 0) usedByte = 2; //------------------------------------------------- t_string = t_string + (IntToStr(usedByte) + "|"); //------------------------------------------------- t_string = t_string + (IntToStr(srcWordData->Interval) + "|"); t_string = t_string + (FloatToStr(srcWordData->HeightGap) + "|"); t_string = t_string + (FloatToStr(srcWordData->WidthGap) + "|"); if (bTextPath){ t_string = t_string + (IntToStr(1) + "|"); if (srcWordData->bNameChanged) t_string = t_string + (IntToStr(1) + "|"); else t_string = t_string + (IntToStr(0) + "|"); //-->by linuxjun for CurvedVectorText t_string = t_string + (FloatToStr(srcWordData->px) + "|"); t_string = t_string + (FloatToStr(srcWordData->py) + "|"); t_string = t_string + (FloatToStr(srcWordData->tx) + "|"); t_string = t_string + (FloatToStr(srcWordData->ty) + "|"); t_string = t_string + (FloatToStr(srcWordData->nx) + "|"); t_string = t_string + (FloatToStr(srcWordData->ny) + "|"); //<--by linuxjun for CurvedVectorText } else { t_string = t_string + (IntToStr(0) + "|"); } //by linuxjun for CurvedVectorText(Save) //ÀÌ ºÎºÐ¿¡ Data TypeÀÌ º¯ÇÑ ºÎºÐ¿¡ ´ëÇØ ÀúÀåÀ» ÇØÁÖ¾î¾ß ÇÔ. //Text ¹æ½Ä º¯°æ by maxleo21c 070628 version=101 for (int j=0; jUsedByte; j++) { //srcWordData->Word[j] == 0 À̸é StringÀÌ ³¡³ª±â ¶§¹®¿¡ ´õÀÌ»ó ÅØ½ºÆ®°¡ ´õÇØÁöÁö //¾Ê´Â´Ù. ÀÌ·± °æ¿ì°¡ HTML->SVG ÄÁ¹öÆ® ´ç½Ã ¸¸µé¾îÁø °ÍÀ¸·Î ÆÇ´ÜµÈ´Ù. - 070917 by maxleo21c if (srcWordData->Word[j] == 0) srcWordData->Word[j] = L' '; t_string += srcWordData->Word[j]; } t_string += "|"; } lineheight = tData->ListOfAllLine->GetLineTextBox(i)->lineHeight; // lineHeight ÀúÀå t_string = t_string + (IntToStr(lineheight) + "|"); t_string = t_string + "\n"; //¶óÀÎ Çϳª´ç ÇÑÁÙ¾¿ ÇØ¼­ ÁÙÀ» ¹Ù²ãÁØ´Ù. } return t_string; } //--------------------------------------------------------------------------- //070807 ¼öÁ¤ : ±âÁ¸ ¹æ½ÄÀ¸·Î ÇßÀ» °æ¿ì index¹øÈ£¿¡ ÀÇÇÑ data°ªÀ» °¡Á®¿ÀÁö ¸øÇß´Ù. // tWordData = (TSWordData *)data->ListOfAllLine->Items(index-1); ¹®Á¦ ÀÖ´Â ¹æ½Ä bool __fastcall TVector2SVG::IsAnyDifferntStateForText(TVecData *data, int linecount, int index) { TSWordData *tWordData, *sWordData; if (index==0) return true; tWordData = (TSWordData *)data->ListOfAllLine->GetLineTextBox(linecount)->LineDataList->Items[index-1]; sWordData = (TSWordData *)data->ListOfAllLine->GetLineTextBox(linecount)->LineDataList->Items[index]; if (tWordData->LFont.lfHeight != sWordData->LFont.lfHeight) return true; if (_tcscmp(tWordData->LFont.lfFaceName, sWordData->LFont.lfFaceName)) return true; if (tWordData->Color != sWordData->Color) return true; if (tWordData->HeightGap != sWordData->HeightGap) return true; if (tWordData->WidthGap != sWordData->WidthGap) return true; return false; } //--------------------------------------------------------------------------- //070807 ¼öÁ¤ : ±âÁ¸ ¹æ½ÄÀ¸·Î ÇßÀ» °æ¿ì index¹øÈ£¿¡ ÀÇÇÑ data°ªÀ» °¡Á®¿ÀÁö ¸øÇß´Ù. // tWordData = (TSWordData *)data->ListOfAllLine->Items(st); ÀÌ ¹æ½ÄÀº ¹®Á¦°¡ ÀÖ´Ù. int __fastcall TVector2SVG::GetTSPAN_Length(TVecData *data, int linecount, int st, int ed) { int length=0; TSWordData *tWordData, *sWordData; tWordData = (TSWordData *)data->ListOfAllLine->GetLineTextBox(linecount)->LineDataList->Items[st]; for (int i=st+1; iListOfAllLine->GetLineTextBox(linecount)->LineDataList->Items[i]; length++; if (tWordData->LFont.lfHeight != sWordData->LFont.lfHeight) return length; if (_tcscmp(tWordData->LFont.lfFaceName, sWordData->LFont.lfFaceName)) return length; if (tWordData->Color != sWordData->Color) return length; if (tWordData->HeightGap != sWordData->HeightGap) return length; if (tWordData->WidthGap != sWordData->WidthGap) return length; } return ed-st; } //--------------------------------------------------------------------------- void __fastcall TVector2SVG::ReturnStringInLine(TVecData *data, int index, String &stringline) { TSWordData *tWordData; int count = data->ListOfAllLine->GetLineTextBox(index)->LineDataList->Count; stringline.IsEmpty(); for (int i=0; iListOfAllLine->Items(i); stringline += tWordData->Word; } } //--------------------------------------------------------------------------- String __fastcall TVector2SVG::MakeMotiveCDATA(TVecData *tData) //by maxleo21c(06.06.12) { String buffer; int version = 170; //Version : 170 - MotiveObject Ãß°¡ buffer = buffer + "\t"; buffer = buffer + (IntToStr(version) + "|"); buffer = buffer + (IntToStr(tData->mode) + "|"); buffer = buffer + (FloatToStr(tData->gap) + "|"); buffer = buffer + (IntToStr(tData->motivecount) + "|"); buffer = buffer + (FloatToStr(tData->proportion) + "|"); buffer = buffer + (FloatToStr(tData->childwidth) + "|"); buffer = buffer + (FloatToStr(tData->childheight) + "|"); if (bRange) { buffer = buffer + (FloatToStr(tData->centerX - Src.Left) + "|"); buffer = buffer + (FloatToStr(tData->centerY - Src.Top) + "|"); } else { buffer = buffer + (FloatToStr(tData->centerX) + "|"); buffer = buffer + (FloatToStr(tData->centerY) + "|"); } buffer = buffer + (IntToStr(tData->ChildCount) + "|"); buffer = buffer + "\n"; return buffer; } //---------------------------------------------------------------------------