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

fix Win32 build

fix linux build

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59519 954022d7-b5bf-4e40-9824-e11837661b57
parent ba0f88a9
......@@ -47,8 +47,10 @@ namespace Writers
CString sRelPath = _T("/word/charts/") + elem->filename;
CString sAbsPath = m_sDir + sRelPath;
OOX::CPath filePath = sAbsPath;
CFile oFile;
oFile.CreateFile(sAbsPath);
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n")));
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
......
......@@ -34,11 +34,13 @@ namespace Writers
{
if(false == m_sComment.IsEmpty())
{
OOX::CPath filePath = m_sDir + _T("\\word\\comments.xml");
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\comments.xml"));
oFile.WriteStringUTF8(g_string_comment_Start);
oFile.WriteStringUTF8(m_sComment);
oFile.WriteStringUTF8(g_string_comment_End);
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(g_string_comment_Start);
oFile.WriteStringUTF8(m_sComment);
oFile.WriteStringUTF8(g_string_comment_End);
oFile.CloseFile();
//Content_Types
......
......@@ -27,9 +27,11 @@ namespace Writers
m_oWriter.Write(m_oAdditional);
m_oWriter.WriteString(g_string_ct_End);
OOX::CPath filePath = m_sDir + _T("/[Content_Types].xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.CreateFile (m_sDir + _T("/[Content_Types].xml"));
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
......
......@@ -3,6 +3,7 @@
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../BinWriter/BinReaderWriterDefines.h";
namespace Writers
{
class DocumentWriter : public ContentWriter
......@@ -17,15 +18,17 @@ namespace Writers
}
void Write()
{
OOX::CPath filePath = m_sDir + _T("\\word\\document.xml");
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\document.xml"));
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.CloseFile();
}
CString WriteSectPrHdrFtr()
......
......@@ -22,16 +22,18 @@ namespace Writers
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
CString m_sThemePath;
bool m_bSaveChartAsImg;
ContentTypesWriter m_oContentTypesWriter;
FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter;
StylesWriter m_oStylesWriter;
NumberingWriter m_oNumberingWriter;
HeaderFooterWriter m_oHeaderFooterWriter;
SettingWriter m_oSettingWriter;
CommentsWriter m_oCommentsWriter;
ChartWriter m_oChartWriter;
ContentTypesWriter m_oContentTypesWriter;
FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter;
StylesWriter m_oStylesWriter;
NumberingWriter m_oNumberingWriter;
HeaderFooterWriter m_oHeaderFooterWriter;
SettingWriter m_oSettingWriter;
CommentsWriter m_oCommentsWriter;
ChartWriter m_oChartWriter;
int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments;
public:
......
......@@ -68,8 +68,11 @@ namespace Writers
}
void WriteItem(CString sHeader, CString& sFilename, ContentWriter& m_oWriter, bool bHeader)
{
OOX::CPath filePath = m_sDir + _T("\\word\\") + sFilename;
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\" + sFilename));
oFile.CreateFile(filePath.GetPath());
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_Start);
else
......
......@@ -18,11 +18,13 @@ namespace Writers
{
nImageCount = 0;
m_sMediaDir = m_sDir + _T("\\word\\media");
OOX::CPath filePath = m_sMediaDir;
m_sMediaDir = filePath.GetDirectory();
}
CString AddImageGetNewPath()
{
if( !NSDirectory::Exists(string2std_string(m_sMediaDir)) )
OOX::CSystemUtility::CreateDirectories(m_sMediaDir);
OOX::CSystemUtility::CreateDirectories(m_sMediaDir);
CString sNewImgName;sNewImgName.Format(_T("image%d.jpg"), (nImageCount + 1));
CString sNewImg = m_sMediaDir + _T("/") + sNewImgName;
......
......@@ -34,8 +34,11 @@ namespace Writers
m_oWriter.Write(m_oNumList);
m_oWriter.WriteString(g_string_n_End);
OOX::CPath filePath = m_sDir + _T("\\word\\numbering.xml");
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\numbering.xml"));
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
......
......@@ -21,8 +21,10 @@ namespace Writers
void Write()
{
Prepare();
OOX::CPath filePath = m_sDir + _T("\\word\\settings.xml");
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\settings.xml"));
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(g_string_set_Start);
oFile.WriteStringUTF8(m_oSettingWriter.GetData());
oFile.WriteStringUTF8(g_string_set_Default);
......
......@@ -48,8 +48,11 @@ namespace Writers
m_oWriter.Write(m_Styles);
m_oWriter.WriteString(g_string_st_End);
OOX::CPath filePath = m_sDir + _T("\\word\\styles.xml");
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\styles.xml"));
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
......
......@@ -65,8 +65,11 @@ namespace Writers
m_oWriter.WriteString(g_string_ft_End);
OOX::CPath filePath = m_sDir + _T("\\word\\fontTable.xml");
CFile oFile;
oFile.CreateFile(m_sDir + _T("\\word\\fontTable.xml"));
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
......
......@@ -28,6 +28,10 @@
#define DOUBLE_MAIN 10000
#ifdef _WIN32
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#endif
namespace NSBinPptxRW
{
inline LONG __strlen(const char* str)
......
......@@ -118,8 +118,27 @@ namespace NSDirectory
return oArray;
}
static bool Exists(const std::wstring& strDirectory)
{
#ifdef WIN32
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
#elif LINUX
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
bool bRes = (0 == stat((char*)pUtf8, &st)) && S_ISDIR(st.st_mode);
delete [] pUtf8;
return bRes;
#elif MAC
return true;
#endif
}
static bool CreateDirectory(const std::wstring& strDirectory)
{
if (Exists(strDirectory) == true) return true;
#ifdef WIN32
return FALSE != ::CreateDirectoryW(strDirectory.c_str(), NULL);
#elif LINUX
......@@ -158,23 +177,6 @@ namespace NSDirectory
rmdir((char*)pUtf8);
delete [] pUtf8;
#elif MAC
#endif
}
static bool Exists(const std::wstring& strDirectory)
{
#ifdef WIN32
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
#elif LINUX
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
bool bRes = (0 == stat((char*)pUtf8, &st)) && S_ISDIR(st.st_mode);
delete [] pUtf8;
return bRes;
#elif MAC
return true;
#endif
}
}
......
......@@ -12,6 +12,8 @@
#include <wchar.h>
#endif
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace NSFile
{
#define WriteUtf16_WCHAR(code, p) \
......
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