Commit 56380dbd authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

ASCOfficeDocxFile2, XlsxSerializerCom общие common

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58208 954022d7-b5bf-4e40-9824-e11837661b57
parent 9b7cbf1d
......@@ -7,11 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeDocxFile2", "ASCOf
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"
ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml2", "..\Common\DocxFormat\Source\XML\libxml2\win_build\libxml2.vcproj", "{21663823-DE45-479B-91D0-B4FEF4916EF0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -37,14 +32,6 @@ Global
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseASC|Win32.Build.0 = Release|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseOpenSource|Win32.ActiveCfg = ReleaseOpenSource|Win32
{A100103A-353E-45E8-A9B8-90B87CC5C0B0}.ReleaseOpenSource|Win32.Build.0 = ReleaseOpenSource|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.ActiveCfg = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.Build.0 = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.ActiveCfg = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.Build.0 = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.ReleaseASC|Win32.ActiveCfg = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.ReleaseASC|Win32.Build.0 = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.ReleaseOpenSource|Win32.ActiveCfg = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.ReleaseOpenSource|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="ASCOfficeDocxFile2"
ProjectGUID="{D02A88E6-5B2B-4A15-A4F6-C057F698FC53}"
RootNamespace="ASCOfficeDocxFile2"
......@@ -54,7 +54,7 @@
AdditionalOptions="/Zm1000"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)/../Common/DocxFormat/Source/XML/libxml2/XML/include&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects&quot;;&quot;$(SolutionDir)/../../AVSImageStudio3/AVSGraphics/Objects/Font/FreeType&quot;;&quot;$(SolutionDir)/../Common/DocxFormat/Source/DocxFormat&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;_USE_XMLLITE_READER_;USE_LITE_READER;USE_ATL_CSTRING;USE_AVSOFFICESTUDIO_XMLUTILS;SOLUTION_ASCOFFICEDOCXFILE2;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
......@@ -529,14 +529,6 @@
<Filter
Name="DocWrapper"
>
<File
RelativePath=".\DocWrapper\DocxSerializer.cpp"
>
</File>
<File
RelativePath=".\DocWrapper\DocxSerializer.h"
>
</File>
<File
RelativePath=".\DocWrapper\FontProcessor.cpp"
>
......@@ -545,54 +537,34 @@
RelativePath=".\DocWrapper\FontProcessor.h"
>
</File>
</Filter>
<Filter
Name="BinWiter"
>
<File
RelativePath="..\XlsxSerializerCom\Reader\BinaryWriter.h"
>
</File>
<File
RelativePath=".\BinWriter\BinReaderWriterDefines.h"
>
</File>
<File
RelativePath=".\BinWriter\BinWriters.h"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Reader\ChartFromToBinary.h"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Reader\CommonWriter.cpp"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Reader\CommonWriter.h"
RelativePath=".\DocWrapper\PptxSerializer.cpp"
>
</File>
<File
RelativePath=".\BinWriter\StreamUtils.h"
RelativePath=".\DocWrapper\PptxSerializer.h"
>
</File>
</Filter>
<Filter
Name="BinReader"
Name="XLSX"
>
<File
RelativePath=".\BinReader\Common.h"
>
</File>
<File
RelativePath=".\BinReader\FileDownloader.h"
<Filter
Name="Common"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Common\BinReaderWriterDefines.h"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Common\Common.cpp"
>
</File>
<File
RelativePath="..\XlsxSerializerCom\Common\Common.h"
>
</File>
</Filter>
<Filter
Name="Reader"
>
......@@ -605,11 +577,11 @@
>
</File>
<File
RelativePath=".\BinReader\ReaderClasses.h"
RelativePath="..\XlsxSerializerCom\Reader\CSVReader.h"
>
</File>
<File
RelativePath=".\BinReader\Readers.h"
RelativePath="..\XlsxSerializerCom\Reader\FontProcessor.h"
>
</File>
</Filter>
......@@ -617,51 +589,127 @@
Name="Writer"
>
<File
RelativePath=".\BinReader\ChartWriter.h"
RelativePath="..\XlsxSerializerCom\Reader\BinaryWriter.h"
>
</File>
<File
RelativePath=".\BinReader\CommentsWriter.h"
RelativePath="..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
>
</File>
<File
RelativePath=".\BinReader\ContentTypesWriter.h"
RelativePath="..\XlsxSerializerCom\Reader\ChartFromToBinary.h"
>
</File>
<File
RelativePath=".\BinReader\DocumentRelsWriter.h"
RelativePath="..\XlsxSerializerCom\Reader\CommonWriter.cpp"
>
</File>
<File
RelativePath=".\BinReader\DocumentWriter.h"
RelativePath="..\XlsxSerializerCom\Reader\CommonWriter.h"
>
</File>
<File
RelativePath=".\BinReader\FileWriter.h"
RelativePath="..\XlsxSerializerCom\Writer\CSVWriter.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="DOCX"
>
<File
RelativePath=".\DocWrapper\DocxSerializer.cpp"
>
</File>
<File
RelativePath=".\DocWrapper\DocxSerializer.h"
>
</File>
<Filter
Name="Reader"
>
<File
RelativePath=".\BinReader\fontTableWriter.h"
RelativePath=".\BinReader\ReaderClasses.h"
>
</File>
<File
RelativePath=".\BinReader\HeaderFooterWriter.h"
RelativePath=".\BinReader\Readers.h"
>
</File>
<Filter
Name="OOXWriter"
>
<File
RelativePath=".\BinReader\ChartWriter.h"
>
</File>
<File
RelativePath=".\BinReader\CommentsWriter.h"
>
</File>
<File
RelativePath=".\BinReader\ContentTypesWriter.h"
>
</File>
<File
RelativePath=".\BinReader\DocumentRelsWriter.h"
>
</File>
<File
RelativePath=".\BinReader\DocumentWriter.h"
>
</File>
<File
RelativePath=".\BinReader\FileWriter.h"
>
</File>
<File
RelativePath=".\BinReader\fontTableWriter.h"
>
</File>
<File
RelativePath=".\BinReader\HeaderFooterWriter.h"
>
</File>
<File
RelativePath=".\BinReader\MediaWriter.h"
>
</File>
<File
RelativePath=".\BinReader\NumberingWriter.h"
>
</File>
<File
RelativePath=".\BinReader\SettingWriter.h"
>
</File>
<File
RelativePath=".\BinReader\StylesWriter.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Common"
>
<File
RelativePath=".\BinReader\MediaWriter.h"
RelativePath=".\BinReader\FileDownloader.h"
>
</File>
</Filter>
<Filter
Name="Writer"
>
<File
RelativePath=".\BinReader\NumberingWriter.h"
RelativePath=".\BinWriter\BinReaderWriterDefines.h"
>
</File>
<File
RelativePath=".\BinReader\SettingWriter.h"
RelativePath=".\BinWriter\BinWriters.h"
>
</File>
<File
RelativePath=".\BinReader\StylesWriter.h"
RelativePath=".\BinWriter\StreamUtils.h"
>
</File>
</Filter>
......
#ifndef CHART_WRITER
#define CHART_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......
#ifndef COMMENTS_WRITER
#define COMMENTS_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......
#ifndef BINREADER_COMMON
#define BINREADER_COMMON
#include "FileDownloader.h"
#include "../../Common/Base64.h"
bool IsUnicodeSymbol( WCHAR symbol )
{
bool result = false;
if ( ( 0x0009 == symbol ) || ( 0x000A == symbol ) || ( 0x000D == symbol ) ||
( ( 0x0020 <= symbol ) && ( 0xD7FF >= symbol ) ) || ( ( 0xE000 <= symbol ) && ( symbol <= 0xFFFD ) ) ||
( ( 0x10000 <= symbol ) && symbol ) )
{
result = true;
}
return result;
}
void CorrectString(CString& strValue)
{
for (unsigned int i = 0, length = strValue.GetLength(); i < length; ++i )
{
if ( false == IsUnicodeSymbol( strValue.GetAt(i) ) )
{
strValue.SetAt(i, ' ');
}
}
strValue.Replace(_T("&"), _T("&amp;"));
strValue.Replace(_T("'"), _T("&apos;"));
strValue.Replace(_T("<"), _T("&lt;"));
strValue.Replace(_T(">"), _T("&gt;"));
strValue.Replace(_T("\""), _T("&quot;"));
}
long Round(double val)
{
return (long)(val+ 0.5);
}
CString DownloadImage(const CString& strFile)
{
CFileDownloader oDownloader(strFile, FALSE);
oDownloader.Start( 1 );
while ( oDownloader.IsRunned() )
{
::Sleep( 10 );
}
CString strFileName;
if ( oDownloader.IsFileDownloaded() )
{
strFileName = oDownloader.GetFilePath();
}
return strFileName;
}
VOID convertBase64ToImage (CString sImage, CString &pBase64)
{
HANDLE hFileWriteHandle;
//
hFileWriteHandle = ::CreateFile (sImage, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (INVALID_HANDLE_VALUE != hFileWriteHandle)
{
INT nUTF8Len = WideCharToMultiByte (CP_UTF8, 0, pBase64, pBase64.GetLength (), NULL, NULL, NULL, NULL);
CHAR *pUTF8String = new CHAR [nUTF8Len + 1];
::ZeroMemory (pUTF8String, sizeof (CHAR) * (nUTF8Len + 1));
WideCharToMultiByte (CP_UTF8, 0, pBase64, -1, pUTF8String, nUTF8Len, NULL, NULL);
CStringA sUnicode; sUnicode = pUTF8String;
delete[] pUTF8String;
// "data:image/jpg;base64,"
int nShift = 0;
int nIndex = sUnicode.Find("base64,");
if(-1 != nIndex)
{
nShift = nIndex + 7;
}
//
LONG lFileSize = sUnicode.GetLength () - nShift;
INT nDstLength = lFileSize;
BYTE *pBuffer = new BYTE [lFileSize];
::ZeroMemory (pBuffer, lFileSize);
Base64::Base64Decode ((LPCSTR)sUnicode.GetBuffer () + nShift, lFileSize, pBuffer, &nDstLength);
//
DWORD dwBytesWrite = 0;
::WriteFile (hFileWriteHandle, pBuffer, nDstLength, &dwBytesWrite, 0);
RELEASEARRAYOBJECTS (pBuffer);
CloseHandle (hFileWriteHandle);
}
}
#endif
\ No newline at end of file
#ifndef CONTENT_TYPES_WRITER
#define CONTENT_TYPES_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......
#ifndef DOCUMENT_RELS_WRITER
#define DOCUMENT_RELS_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......@@ -48,8 +48,8 @@ namespace Writers
}
CString AddRels(CString sType, CString sTarget, bool bExternal = false)
{
CorrectString(sType);
CorrectString(sTarget);
SerializeCommon::CorrectString(sType);
SerializeCommon::CorrectString(sTarget);
CString srId;srId.Format(_T("rId%d"), m_nRid);
CString sRels;
if(bExternal)
......
#ifndef DOCUMENT_WRITER
#define DOCUMENT_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../BinWriter/BinReaderWriterDefines.h";
namespace Writers
{
......@@ -31,7 +31,7 @@ namespace Writers
CString WriteSectPrHdrFtr()
{
CString sResult;
if(g_nCurFormatVersion < 5)
if(BinDocxRW::g_nCurFormatVersion < 5)
{
bool bTitlePage = false;
for(int i = 0, length = m_oHeaderFooterWriter.m_aHeaders.size(); i < length; ++i)
......
#ifndef HEADER_FOOTER_WRITER
#define HEADER_FOOTER_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......
#ifndef MEDIA_WRITER
#define MEDIA_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......
......@@ -50,14 +50,14 @@ public:
CString Write()
{
CString sRes = _T("");
long nWidth = Round(W * g_dKoef_mm_to_twips);
long nHeight = Round(H * g_dKoef_mm_to_twips);
long nMLeft = Round(Left * g_dKoef_mm_to_twips);
long nMTop = Round(Top * g_dKoef_mm_to_twips);
long nMRight = Round(Right * g_dKoef_mm_to_twips);
long nMBottom = Round(Bottom * g_dKoef_mm_to_twips);
long nMHeader = Round(Header * g_dKoef_mm_to_twips);
long nMFooter = Round(Footer * g_dKoef_mm_to_twips);
long nWidth = SerializeCommon::Round(W * g_dKoef_mm_to_twips);
long nHeight = SerializeCommon::Round(H * g_dKoef_mm_to_twips);
long nMLeft = SerializeCommon::Round(Left * g_dKoef_mm_to_twips);
long nMTop = SerializeCommon::Round(Top * g_dKoef_mm_to_twips);
long nMRight = SerializeCommon::Round(Right * g_dKoef_mm_to_twips);
long nMBottom = SerializeCommon::Round(Bottom * g_dKoef_mm_to_twips);
long nMHeader = SerializeCommon::Round(Header * g_dKoef_mm_to_twips);
long nMFooter = SerializeCommon::Round(Footer * g_dKoef_mm_to_twips);
if(!sHeaderFooterReference.IsEmpty())
sRes.Append(sHeaderFooterReference);
if(bSectionType)
......@@ -517,13 +517,13 @@ public:
}
if(bSpacing)
{
long nSpacing = Round( g_dKoef_mm_to_twips * Spacing);
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * Spacing);
CString sSpacing;sSpacing.Format(_T("<w:spacing w:val=\"%d\"/>"), nSpacing);
pCStringWriter->WriteString(sSpacing);
}
if(bPosition)
{
long nPosition = Round( g_dKoef_mm_to_hps * Position);
long nPosition = SerializeCommon::Round( g_dKoef_mm_to_hps * Position);
CString sPosition;sPosition.Format(_T("<w:position w:val=\"%d\"/>"), nPosition);
pCStringWriter->WriteString(sPosition);
}
......@@ -930,7 +930,7 @@ public:
if(bW)
{
sType = _T("dxa");
nVal = Round( g_dKoef_mm_to_twips * W);
nVal = SerializeCommon::Round( g_dKoef_mm_to_twips * W);
}
else
{
......@@ -987,13 +987,13 @@ public:
}
if(bSize)
{
long nSize = Round(g_dKoef_mm_to_eightpoint * Size);
long nSize = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * Size);
CString sSize;sSize.Format(_T(" w:sz=\"%d\""), nSize);
pCStringWriter->WriteString(sSize);
}
if(bSpace)
{
long nSpace = Round(g_dKoef_mm_to_pt * Space);
long nSpace = SerializeCommon::Round(g_dKoef_mm_to_pt * Space);
CString sSpace;sSpace.Format(_T(" w:space=\"%d\""), nSpace);
pCStringWriter->WriteString(sSpace);
}
......@@ -1172,7 +1172,7 @@ public:
if(bPStyle)
{
CString sStyleName = PStyle;
CorrectString(sStyleName);
SerializeCommon::CorrectString(sStyleName);
CString sFormatXml;sFormatXml.Format(_T("<w:pStyle w:val=\"%s\"/>"), sStyleName);
oWriter.WriteString(sFormatXml);
}
......@@ -1197,7 +1197,7 @@ public:
sText.AppendFormat(_T("%%%d"), (item->Number+1));
}
}
CorrectString(sText);
SerializeCommon::CorrectString(sText);
CString sTextXml;sTextXml.Format(_T("<w:lvlText w:val=\"%s\"/>"), sText);
oWriter.WriteString(sTextXml);
}
......@@ -1257,14 +1257,14 @@ public:
if(!StyleLink.IsEmpty())
{
CString sCorrectStyleLink = StyleLink;
CorrectString(sCorrectStyleLink);
SerializeCommon::CorrectString(sCorrectStyleLink);
CString sXml;sXml.Format(_T("<w:styleLink w:val=\"%s\"/>"), sCorrectStyleLink);
oWriterANum.WriteString(sXml);
}
if(!NumStyleLink.IsEmpty())
{
CString sCorrectNumStyleLink = NumStyleLink;
CorrectString(sCorrectNumStyleLink);
SerializeCommon::CorrectString(sCorrectNumStyleLink);
CString sXml;sXml.Format(_T("<w:numStyleLink w:val=\"%s\"/>"), sCorrectNumStyleLink);
oWriterANum.WriteString(sXml);
}
......@@ -1409,9 +1409,9 @@ public:
CString sCorrect_rId = rId;
CString sCorrect_tooltip = tooltip;
CString sCorrect_anchor = anchor;
CorrectString(sCorrect_rId);
CorrectString(sCorrect_tooltip);
CorrectString(sCorrect_anchor);
SerializeCommon::CorrectString(sCorrect_rId);
SerializeCommon::CorrectString(sCorrect_tooltip);
SerializeCommon::CorrectString(sCorrect_anchor);
CString sStart;
sStart.Format(_T("<w:hyperlink r:id=\"%s\""), sCorrect_rId);
if(false == tooltip.IsEmpty())
......@@ -1550,7 +1550,7 @@ public:
if(false == pComment->UserName.IsEmpty())
{
CString sUserName = pComment->UserName;
CorrectString(sUserName);
SerializeCommon::CorrectString(sUserName);
sRes.AppendFormat(_T(" w:author=\"%s\""), sUserName);
// initials
int nTokenPos = 0;
......@@ -1566,12 +1566,12 @@ public:
if(false == pComment->Date.IsEmpty())
{
CString sDate = pComment->Date;
CorrectString(sDate);
SerializeCommon::CorrectString(sDate);
sRes.AppendFormat(_T(" w:date=\"%s\""), sDate);
}
if(false == sInitials.IsEmpty())
{
CorrectString(sInitials);
SerializeCommon::CorrectString(sInitials);
sRes.AppendFormat(_T(" w:initials=\"%s\""), sInitials);
}
sRes.Append(_T(">"));
......@@ -1619,9 +1619,9 @@ public:
if(false == pComment->UserName.IsEmpty() && false == pComment->UserId.IsEmpty())
{
CString sUserName = pComment->UserName;
CorrectString(sUserName);
SerializeCommon::CorrectString(sUserName);
CString sUserId = pComment->UserId;
CorrectString(sUserId);
SerializeCommon::CorrectString(sUserId);
sRes.AppendFormat(_T("<w15:person w15:author=\"%s\"><w15:presenceInfo w15:providerId=\"Teamlab\" w15:userId=\"%s\"/></w15:person>"), sUserName, sUserId);
}
return sRes;
......@@ -1742,19 +1742,19 @@ public:
// if(false == UserName.IsEmpty())
// {
// CString sUserName = UserName;
// CorrectString(sUserName);
// SerializeCommon::CorrectString(sUserName);
// sRes.AppendFormat(_T(" w:author=\"%s\""), sUserName);
// }
// if(false == Date.IsEmpty())
// {
// CString sDate = Date;
// CorrectString(sDate);
// SerializeCommon::CorrectString(sDate);
// sRes.AppendFormat(_T(" w:date=\"%s\""), sDate);
// }
// if(false == Initials.IsEmpty())
// {
// CString sInitials = Initials;
// CorrectString(sInitials);
// SerializeCommon::CorrectString(sInitials);
// sRes.AppendFormat(_T(" w:initials=\"%s\""), sInitials);
// }
// sRes.Append(_T(">"));
......@@ -1771,12 +1771,12 @@ public:
// CString sRes;
// CString sFormat = _T("<w:p><w:pPr><w:spacing w:line=\"240\" w:after=\"0\" w:lineRule=\"auto\" w:before=\"0\"/><w:ind w:firstLine=\"0\" w:left=\"0\" w:right=\"0\"/><w:jc w:val=\"left\"/></w:pPr><w:r><w:rPr><w:rFonts w:eastAsia=\"Arial\" w:ascii=\"Arial\" w:hAnsi=\"Arial\" w:cs=\"Arial\"/><w:sz w:val=\"22\"/></w:rPr><w:t xml:space=\"preserve\">%s</w:t></w:r></w:p>");
// CString sName = pComment->UserName + _T(":");
// CorrectString(sName);
// SerializeCommon::CorrectString(sName);
// sRes.AppendFormat(sFormat, sName);
// if(false == pComment->Text.IsEmpty())
// {
// CString sText = pComment->Text;
// CorrectString(sText);
// SerializeCommon::CorrectString(sText);
// sRes.AppendFormat(sFormat, sText);
// }
// if(false == bCheckLast || pComment->replies.GetCount() > 0)
......@@ -2391,9 +2391,9 @@ public:
CString sCorrect_rId = rId;
CString sCorrect_tooltip = sTooltip;
CString sCorrect_anchor = sAnchor;
CorrectString(sCorrect_rId);
CorrectString(sCorrect_tooltip);
CorrectString(sCorrect_anchor);
SerializeCommon::CorrectString(sCorrect_rId);
SerializeCommon::CorrectString(sCorrect_tooltip);
SerializeCommon::CorrectString(sCorrect_anchor);
CString sStart;
sStart.Format(_T("<w:hyperlink r:id=\"%s\""), sCorrect_rId);
if(false == sTooltip.IsEmpty())
......
This diff is collapsed.
#ifndef SETTING_WRITER
#define SETTING_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......@@ -36,7 +36,7 @@ namespace Writers
}
void Prepare()
{
if(g_nCurFormatVersion < 5)
if(BinDocxRW::g_nCurFormatVersion < 5)
{
bool bevenAndOddHeaders = false;
for(int i = 0, length = m_oHeaderFooterWriter.m_aHeaders.size(); i < length; ++i)
......
#ifndef STYLES_WRITER
#define STYLES_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......
#ifndef FONT_TABLE_WRITER
#define FONT_TABLE_WRITER
#include "Common.h"
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
......@@ -112,7 +112,7 @@ namespace Writers
RELEASEARRAY(psaArray);
}
CorrectString(sFontName);
SerializeCommon::CorrectString(sFontName);
m_oWriter.WriteString(_T("<w:font w:name=\"") + sFontName + _T("\">"));
if(!sPanose.IsEmpty())
m_oWriter.WriteString(_T("<w:panose1 w:val=\"")+sPanose+_T("\"/>"));
......
#ifndef BIN_READER_WRITER_DEFINES
#define BIN_READER_WRITER_DEFINES
extern int g_nCurFormatVersion;
namespace BinDocxRW
{
const double eps = 0.001;
......@@ -97,6 +96,7 @@ const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt;
const static TCHAR* g_sFormatSignature = _T("DOCY");
const int g_nFormatVersion = 5;
extern int g_nCurFormatVersion;
namespace c_oAscWrapStyle{enum c_oSerFormat
{
Inline = 0,
......
......@@ -16,7 +16,7 @@
#include "../../DesktopEditor/common/Types.h"
#endif
int g_nCurFormatVersion = 0;
int BinDocxRW::g_nCurFormatVersion = 0;
#define BUFFER_GROW_SIZE 1 * 1024 * 1024 //1mb
......
#pragma once
extern int g_nCurFormatVersion;
namespace BinXlsxRW
{
const double g_dKoef_mm_to_pt = 72 / (2.54 * 10);
......@@ -11,6 +9,7 @@ namespace BinXlsxRW
const static TCHAR* g_sFormatSignature = _T("XLSY");
const int g_nFormatVersion = 2;
extern int g_nCurFormatVersion;
namespace c_oFileTypes{enum c_oFileTypes
{
......
#include "Common.h"
#include "BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/Base64.h"
#include "../../DesktopEditor/common/Types.h"
#include "../../ASCOfficeDocxFile2/BinReader/FileDownloader.h"
#include "../../DesktopEditor/common/file.h"
namespace SerializeCommon
{
bool IsUnicodeSymbol( WCHAR symbol )
{
bool result = false;
if ( ( 0x0009 == symbol ) || ( 0x000A == symbol ) || ( 0x000D == symbol ) ||
( ( 0x0020 <= symbol ) && ( 0xD7FF >= symbol ) ) || ( ( 0xE000 <= symbol ) && ( symbol <= 0xFFFD ) ) ||
( ( 0x10000 <= symbol ) && symbol ) )
{
result = true;
}
return result;
}
void CorrectString(CString& strValue)
{
for (unsigned int i = 0, length = strValue.GetLength(); i < length; ++i )
{
if ( false == IsUnicodeSymbol( strValue.GetAt(i) ) )
{
strValue.SetAt(i, ' ');
}
}
strValue.Replace(_T("&"), _T("&amp;"));
strValue.Replace(_T("'"), _T("&apos;"));
strValue.Replace(_T("<"), _T("&lt;"));
strValue.Replace(_T(">"), _T("&gt;"));
strValue.Replace(_T("\""), _T("&quot;"));
}
CString DownloadImage(const CString& strFile)
{
CFileDownloader oDownloader(strFile, FALSE);
oDownloader.Start( 1 );
while ( oDownloader.IsRunned() )
{
::Sleep( 10 );
}
CString strFileName;
if ( oDownloader.IsFileDownloaded() )
{
strFileName = oDownloader.GetFilePath();
}
return strFileName;
}
VOID convertBase64ToImage (CString sImage, CString &pBase64)
{
HANDLE hFileWriteHandle;
//
hFileWriteHandle = ::CreateFile (sImage, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (INVALID_HANDLE_VALUE != hFileWriteHandle)
{
INT nUTF8Len = WideCharToMultiByte (CP_UTF8, 0, pBase64, pBase64.GetLength (), NULL, NULL, NULL, NULL);
CHAR *pUTF8String = new CHAR [nUTF8Len + 1];
::ZeroMemory (pUTF8String, sizeof (CHAR) * (nUTF8Len + 1));
WideCharToMultiByte (CP_UTF8, 0, pBase64, -1, pUTF8String, nUTF8Len, NULL, NULL);
CStringA sUnicode; sUnicode = pUTF8String;
delete[] pUTF8String;
// "data:image/jpg;base64,"
int nShift = 0;
int nIndex = sUnicode.Find("base64,");
if(-1 != nIndex)
{
nShift = nIndex + 7;
}
//
LONG lFileSize = sUnicode.GetLength () - nShift;
INT nDstLength = lFileSize;
BYTE *pBuffer = new BYTE [lFileSize];
::ZeroMemory (pBuffer, lFileSize);
Base64::Base64Decode ((LPCSTR)sUnicode.GetBuffer () + nShift, lFileSize, pBuffer, &nDstLength);
//
DWORD dwBytesWrite = 0;
::WriteFile (hFileWriteHandle, pBuffer, nDstLength, &dwBytesWrite, 0);
RELEASEARRAYOBJECTS (pBuffer);
CloseHandle (hFileWriteHandle);
}
}
long Round(double val)
{
return (long)(val+ 0.5);
}
CString changeExtention(CString& sSourcePath, CString& sTargetExt)
{
wchar_t path_buffer[_MAX_PATH];
wchar_t drive[_MAX_DRIVE];
wchar_t dir[_MAX_DIR];
wchar_t fname[_MAX_FNAME];
wchar_t ext[_MAX_EXT];
_wsplitpath(sSourcePath, drive, dir, fname, ext);
_tmakepath(path_buffer, drive, dir, fname, sTargetExt);
return CString(path_buffer);
}
void ReadFileType(CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter)
{
result = BinXlsxRW::c_oFileTypes::XLSX;
nCodePage = CP_UTF8;
wcDelimiter = _T(',');
nullable<SimpleTypes::CUnsignedDecimalNumber<>> fileType;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> codePage;
nullable<CString> delimiter;
// Read options
XmlUtils::CXmlLiteReader oReader;
if (TRUE != oReader.FromString(sXMLOptions) || TRUE != oReader.IsValid())
return;
oReader.ReadNextNode(); // XmlOptions
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while(oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("fileOptions") == sName)
{
//
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("fileType"), fileType)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("codePage"), codePage)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("delimiter"), delimiter)
WritingElement_ReadAttributes_End(oReader)
result = (BYTE)fileType->GetValue();
nCodePage = (UINT)codePage->GetValue();
const CString& sDelimiter = delimiter.get();
if (0 < sDelimiter.GetLength())
wcDelimiter = sDelimiter.GetAt(0);
break;
}
}
return;
}
}
\ No newline at end of file
#pragma once
#include "../../ASCOfficeDocxFile2/BinReader/FileDownloader.h"
namespace SerializeCommon
{
bool IsUnicodeSymbol( WCHAR symbol )
{
bool result = false;
if ( ( 0x0009 == symbol ) || ( 0x000A == symbol ) || ( 0x000D == symbol ) ||
( ( 0x0020 <= symbol ) && ( 0xD7FF >= symbol ) ) || ( ( 0xE000 <= symbol ) && ( symbol <= 0xFFFD ) ) ||
( ( 0x10000 <= symbol ) && symbol ) )
{
result = true;
}
#ifdef _WIN32
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
return result;
}
void CorrectString(CString& strValue)
{
for (unsigned int i = 0, length = strValue.GetLength(); i < length; ++i )
{
if ( false == IsUnicodeSymbol( strValue.GetAt(i) ) )
{
strValue.SetAt(i, ' ');
}
}
strValue.Replace(_T("&"), _T("&amp;"));
strValue.Replace(_T("'"), _T("&apos;"));
strValue.Replace(_T("<"), _T("&lt;"));
strValue.Replace(_T(">"), _T("&gt;"));
strValue.Replace(_T("\""), _T("&quot;"));
}
CString DownloadImage(const CString& strFile)
{
CFileDownloader oDownloader(strFile, FALSE);
oDownloader.Start( 1 );
while ( oDownloader.IsRunned() )
{
::Sleep( 10 );
}
CString strFileName;
if ( oDownloader.IsFileDownloaded() )
{
strFileName = oDownloader.GetFilePath();
}
return strFileName;
}
VOID convertBase64ToImage (CString sImage, CString &pBase64)
{
HANDLE hFileWriteHandle;
//
hFileWriteHandle = ::CreateFile (sImage, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (INVALID_HANDLE_VALUE != hFileWriteHandle)
{
INT nUTF8Len = WideCharToMultiByte (CP_UTF8, 0, pBase64, pBase64.GetLength (), NULL, NULL, NULL, NULL);
CHAR *pUTF8String = new CHAR [nUTF8Len + 1];
::ZeroMemory (pUTF8String, sizeof (CHAR) * (nUTF8Len + 1));
#include <string>
#include <vector>
WideCharToMultiByte (CP_UTF8, 0, pBase64, -1, pUTF8String, nUTF8Len, NULL, NULL);
CStringA sUnicode; sUnicode = pUTF8String;
delete[] pUTF8String;
// "data:image/jpg;base64,"
int nShift = 0;
int nIndex = sUnicode.Find("base64,");
if(-1 != nIndex)
{
nShift = nIndex + 7;
}
//
LONG lFileSize = sUnicode.GetLength () - nShift;
INT nDstLength = lFileSize;
BYTE *pBuffer = new BYTE [lFileSize];
::ZeroMemory (pBuffer, lFileSize);
Base64::Base64Decode ((LPCSTR)sUnicode.GetBuffer () + nShift, lFileSize, pBuffer, &nDstLength);
//
DWORD dwBytesWrite = 0;
::WriteFile (hFileWriteHandle, pBuffer, nDstLength, &dwBytesWrite, 0);
RELEASEARRAYOBJECTS (pBuffer);
CloseHandle (hFileWriteHandle);
}
}
CString changeExtention(CString& sSourcePath, CString& sTargetExt)
{
wchar_t path_buffer[_MAX_PATH];
wchar_t drive[_MAX_DRIVE];
wchar_t dir[_MAX_DIR];
wchar_t fname[_MAX_FNAME];
wchar_t ext[_MAX_EXT];
_wsplitpath(sSourcePath, drive, dir, fname, ext);
_tmakepath(path_buffer, drive, dir, fname, sTargetExt);
return CString(path_buffer);
}
namespace SerializeCommon
{
bool IsUnicodeSymbol( WCHAR symbol );
void CorrectString(CString& strValue);
CString DownloadImage(const CString& strFile);
VOID convertBase64ToImage (CString sImage, CString &pBase64);
long Round(double val);
CString changeExtention(CString& sSourcePath, CString& sTargetExt);
class CommentData
{
public :
......@@ -121,45 +44,5 @@ namespace SerializeCommon
aReplies.clear();
}
};
void ReadFileType(CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter)
{
result = BinXlsxRW::c_oFileTypes::XLSX;
nCodePage = CP_UTF8;
wcDelimiter = _T(',');
nullable<SimpleTypes::CUnsignedDecimalNumber<>> fileType;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> codePage;
nullable<CString> delimiter;
// Read options
XmlUtils::CXmlLiteReader oReader;
if (TRUE != oReader.FromString(sXMLOptions) || TRUE != oReader.IsValid())
return;
oReader.ReadNextNode(); // XmlOptions
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while(oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("fileOptions") == sName)
{
//
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("fileType"), fileType)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("codePage"), codePage)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("delimiter"), delimiter)
WritingElement_ReadAttributes_End(oReader)
result = (BYTE)fileType->GetValue();
nCodePage = (UINT)codePage->GetValue();
const CString& sDelimiter = delimiter.get();
if (0 < sDelimiter.GetLength())
wcDelimiter = sDelimiter.GetAt(0);
break;
}
}
return;
}
void ReadFileType(CString& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter);
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment