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

убраны неиспользуемые подключения, ушли от GetFileAttributes для проверки...

убраны неиспользуемые подключения, ушли от GetFileAttributes для проверки существования файла и папки, некоторые файлы переведены в utf8.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58874 954022d7-b5bf-4e40-9824-e11837661b57
parent 12b7886d
......@@ -40,7 +40,7 @@ namespace Writers
if(false == IsEmpty())
{
CString sChartDir = m_sDir + _T("/word/charts");
CreateDirectory(sChartDir, NULL);
NSDirectory::CreateDirectory(string2std_string(sChartDir));
for(int i = 0, length = m_aCharts.size(); i < length; ++i)
{
ChartElem* elem = m_aCharts[i];
......
......@@ -21,7 +21,7 @@ namespace Writers
}
void AddImage(CString& sImg)
{
CreateDirectory(m_sMediaDir, NULL);
NSDirectory::CreateDirectory(string2std_string(m_sMediaDir));
//TCHAR tExt[256];
//TCHAR tFilename[256];
......
......@@ -18,7 +18,7 @@ public:
double Footer;
bool TitlePg;
bool EvenAndOddHeaders;
byte SectionType;
BYTE SectionType;
int PageNumStart;
bool bHeader;
......@@ -115,9 +115,9 @@ public:
class CThemeColor{
public:
bool Auto;
byte Color;
byte Tint;
byte Shade;
BYTE Color;
BYTE Tint;
BYTE Shade;
bool bShade;
bool bTint;
......@@ -295,7 +295,7 @@ public:
bool Caps;
bool SmallCaps;
double Position;
byte FontHint;
BYTE FontHint;
bool BoldCs;
bool ItalicCs;
long FontSizeCs;
......
......@@ -2333,8 +2333,7 @@ public:
}
//
DWORD dwFileAttr = ::GetFileAttributes( sFilePath );
if( dwFileAttr != INVALID_FILE_ATTRIBUTES && 0 == (dwFileAttr & FILE_ATTRIBUTE_DIRECTORY ) )
if(NSFile::CFileBinary::Exists(string2std_string(sFilePath)))
{
m_oFileWriter.m_oMediaWriter.AddImage(sFilePath);
if(bDeleteFile)
......@@ -5552,8 +5551,7 @@ public:
// rels
CString sRelsDir;
sRelsDir.Format(_T("%s\\word\\charts\\_rels"), m_oFileWriter.m_oChartWriter.m_sDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir );
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
......
......@@ -3,7 +3,7 @@
#include "BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h"
#include "String.h"
//#include "String.h"
#include <stack>
/*namespace BinDocxRW
......
......@@ -6,6 +6,7 @@
#include "../../Common/Base64.h"
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
#include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/MathEquation/MathEquation.h"
#include "BinEquationWriter.h"
......
#include "DocxSerializer.h"
#include "DocxSerializer.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../BinWriter/BinWriters.h"
#include "../BinReader/Readers.h"
#include "../ASCOfficePPTXFile/Editor/FontPicker.h"
#include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
#ifndef _WIN32
#include "../../DesktopEditor/common/Types.h"
......@@ -46,13 +46,13 @@ bool BinDocxRW::CDocxSerializer::saveToFile(CString& sSrcFileName, CString& sDst
pEmbeddedFontsManager = pFontPicker->GetNativeCutter();
// .
//добавляем весь латинский алфавит для списков.
pEmbeddedFontsManager->CheckString(CString(_T("abcdefghijklmnopqrstuvwxyz")));
//
//добавим мега шрифт
pEmbeddedFontsManager->CheckFont(_T("Wingdings 3"), fp.getFontManager());
pEmbeddedFontsManager->CheckFont(_T("Arial"), fp.getFontManager());
//pEmbeddedFontsManager
//pEmbeddedFontsManager добавляются все цифры
}
oDrawingConverter.SetFontDir(m_sFontDir);
......@@ -101,7 +101,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
oFile.ReadFile(pBase64Data, oFile.GetFileSize(), nBase64DataSize);
oFile.CloseFile();
//
//проверяем формат
bool bValidFormat = false;
CString sSignature(g_sFormatSignature);
int nSigLength = sSignature.GetLength();
......@@ -115,7 +115,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
}
if(bValidFormat)
{
// base64
//Читаем из файла версию и длину base64
int nIndex = nSigLength;
int nType = 0;
CStringA version = "";
......@@ -165,7 +165,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
oDrawingConverter.SetMediaDstPath(sMediaPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//
//папка с картинками
TCHAR tFolder[256];
TCHAR tDrive[256];
_tsplitpath( sSrcFileName, tDrive, tFolder, NULL, NULL );
......@@ -193,11 +193,11 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
m_pCurFileWriter->m_oNumberingWriter.Write();
m_pCurFileWriter->m_oFontTableWriter.Write();
m_pCurFileWriter->m_oHeaderFooterWriter.Write();
//Setting HeaderFooter, evenAndOddHeaders
//Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
m_pCurFileWriter->m_oSettingWriter.Write();
//Document HeaderFooter, sectPr
//Document пишем после HeaderFooter, чтобы заполнить sectPr
m_pCurFileWriter->m_oDocumentWriter.Write();
//Rels ContentTypes
//Rels и ContentTypes пишем в конце
//m_pCurFileWriter->m_oDocumentRelsWriter.Write(_T("document.xml.rels"));
m_pCurFileWriter->m_oContentTypesWriter.Write();
......
//#include "stdafx.h"
#include "FontProcessor.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Fonts.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/ASCUtils.h"
namespace DocWrapper {
......
#pragma once
#include "../stdafx.h"
//#include "../stdafx.h"
#include <map>
#ifdef _WIN32
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;
}
namespace ComplexTypes{
namespace Spreadsheet{
class CString_;
}
}
namespace OOX
{
class CFont;
......
......@@ -2,9 +2,9 @@
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../ASCOfficePPTXFile/Editor/FontPicker.h"
#include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
namespace BinXlsxRW{
int g_nCurFormatVersion = 0;
......@@ -139,8 +139,7 @@ namespace BinXlsxRW{
CString sRelsDir = sDrive + sFolder;
sRelsDir.Append(_T("_rels"));
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir );
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
OOX::CSystemUtility::CreateDirectories(sRelsDir);
oChartSpace.write2(sFilepath);
......
......@@ -9,6 +9,10 @@
#include "windows.h"
#include "windef.h"
#elif LINUX
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "File.h"
#elif MAC
#endif
......@@ -50,7 +54,32 @@ namespace NSDirectory
#ifdef WIN32
::CreateDirectoryW(strDirectory.c_str(), NULL);
#elif LINUX
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
if (stat((char*)pUtf8, &st) == -1) {
mkdir((char*)pUtf8, S_IRWXU | S_IRWXG | S_IRWXO);
}
delete [] pUtf8;
#elif MAC
#endif
}
static bool Exists(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
}
}
......
......@@ -504,7 +504,7 @@ namespace NSFile
BYTE* pData = NULL;
LONG lLen = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strXml.c_str(), strXml.size(), pData, lLen, bIsBOM);
CUtf8Converter::GetUtf8StringFromUnicode(strXml.c_str(), strXml.length(), pData, lLen, bIsBOM);
WriteFile(pData, lLen);
......@@ -518,6 +518,25 @@ namespace NSFile
oFile.CloseFile();
return true;
}
static bool Exists(const std::wstring& strFileName)
{
#if defined(WIN32) || defined(_WIN32_WCE)
FILE* pFile = _wfopen(strFileName.c_str(), L"rb");
#else
BYTE* pUtf8 = NULL;
LONG lLen = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false);
FILE* pFile = fopen((char*)pUtf8, "rb");
delete [] pUtf8;
#endif
if(NULL != pFile)
{
fclose(pFile);
return true;
}
else
return false;
}
};
}
......
......@@ -701,7 +701,7 @@ namespace BinXlsxRW {
{
m_oBcw.m_oStream.WriteBYTE(c_oSerBorderPropTypes::Style);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE((byte)borderProp.m_oStyle->GetValue());
m_oBcw.m_oStream.WriteBYTE((BYTE)borderProp.m_oStyle->GetValue());
}
};
void WriteCellStyleXfs(const OOX::Spreadsheet::CCellStyleXfs& cellStyleXfs)
......@@ -2427,7 +2427,7 @@ namespace BinXlsxRW {
OOX::CPath oNormalizedPath = OOX::CPath(pDrawing->GetReadPath().GetDirectory()) / oRels->Target().GetPath();
CString sChartPath = oNormalizedPath.GetPath();
//
if( INVALID_FILE_ATTRIBUTES != ::GetFileAttributes( sChartPath ) )
if( NSFile::CFileBinary::Exists(string2std_string(sChartPath)) )
{
CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath();
m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
......
#include "CSVReader.h"
#include "../../Common/MappingFile.h"
#include <map>
namespace CSVReader
......@@ -108,17 +107,18 @@ namespace CSVReader
pWorkbook->m_oSheets.Init();
pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
MemoryMapping::CMappingFile oMappingFile = MemoryMapping::CMappingFile();
if(FALSE != oMappingFile.Open(sFileName))
NSFile::CFileBinary oFile;
if(oFile.OpenFile(string2std_string(sFileName)))
{
long nFileSize = oMappingFile.GetSize();
LPCSTR pFileData = (LPCSTR)oMappingFile.GetData();
DWORD nFileSize = 0;
BYTE* pFileData = new BYTE[oFile.GetFileSize()];
oFile.ReadFile(pFileData, oFile.GetFileSize(), nFileSize);
oFile.CloseFile();
INT nSize = MultiByteToWideChar(nCodePage, 0, pFileData, nFileSize, NULL, 0);
INT nSize = MultiByteToWideChar(nCodePage, 0, (LPCSTR)pFileData, nFileSize, NULL, 0);
WCHAR *pTemp = new WCHAR [nSize];
memset(pTemp, 0, sizeof(WCHAR) * nSize);
MultiByteToWideChar (nCodePage, 0, pFileData, nFileSize, pTemp, nSize);
oMappingFile.Close();
MultiByteToWideChar (nCodePage, 0, (LPCSTR)pFileData, nFileSize, pTemp, nSize);
CONST WCHAR wcNewLineN = _T('\n');
CONST WCHAR wcNewLineR = _T('\r');
......
......@@ -15,7 +15,7 @@
namespace CSVReader
{
void AddCell(CString &sText, INT nStartCell, std::stack<INT> &oDeleteChars, OOX::Spreadsheet::CRow &oRow, INT nRow, INT nCol, BOOL bIsWrap);
void ReadFromCsvToXlsx(CString &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, CONST WCHAR wcDelimiter);
void ReadFromCsvToXlsx(CString &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter);
}
#endif //CSV_READER
#ifndef BINARY_READER
#define BINARY_READER
#include "../../Common/FileWriter.h"
#include "../../Common/MappingFile.h"
#include "../../Common/Base64.h"
#include "../../Common/ATLDefine.h"
......@@ -1597,7 +1595,8 @@ namespace BinXlsxRW {
CString sGfxdata;
if(TRUE == Base64::Base64Encode(pWriteBuffer, nWriteBufferLength, (LPSTR)pbBase64Buffer, &nBase64BufferLen, Base64::B64_BASE64_FLAG_NONE))
{
sGfxdata = CString((LPSTR)pbBase64Buffer, nBase64BufferLen);
std::wstring strGfxdata = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(pbBase64Buffer, nBase64BufferLen);
sGfxdata = CString(strGfxdata.c_str());
// Excel
sGfxdata.Append(_T("\r\n"));
}
......@@ -1842,8 +1841,7 @@ namespace BinXlsxRW {
{
CString sRelsDir;
sRelsDir.Format(_T("%s\\xl\\drawings\\_rels"), m_sDestinationDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir );
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_pOfficeDrawingConverter->SetDstContentRels();
......@@ -2421,8 +2419,7 @@ namespace BinXlsxRW {
// rels
CString sRelsDir;
sRelsDir.Format(_T("%s\\xl\\charts\\_rels"), m_sDestinationDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir );
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
if( !NSDirectory::Exists(string2std_string(sRelsDir)) )
OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_pOfficeDrawingConverter->SetDstContentRels();
......@@ -2544,8 +2541,7 @@ namespace BinXlsxRW {
if(pair->second->bNeedCreate)
{
pair->second->bNeedCreate = false;
DWORD dwFileAttr = ::GetFileAttributes( m_sMediaDir );
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
if( !NSDirectory::Exists(string2std_string(m_sMediaDir)) )
OOX::CSystemUtility::CreateDirectories(m_sMediaDir);
::CopyFile(pair->second->sPath, sNewImagePath, FALSE);
}
......@@ -2911,8 +2907,7 @@ namespace BinXlsxRW {
}
}
//
DWORD dwFileAttr = ::GetFileAttributes( sImageSrc );
if( dwFileAttr != INVALID_FILE_ATTRIBUTES && 0 == (dwFileAttr & FILE_ATTRIBUTE_DIRECTORY ) )
if(NSFile::CFileBinary::Exists(string2std_string(sImageSrc)))
{
m_sCurSrc = sImageSrc;
if(bAddToDelete)
......@@ -2936,11 +2931,13 @@ namespace BinXlsxRW {
int ReadFile(CString sSrcFileName, CString sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, CString& sXMLOptions)
{
bool bResultOk = false;
MemoryMapping::CMappingFile oMappingFile = MemoryMapping::CMappingFile();
if(FALSE != oMappingFile.Open(CString(sSrcFileName)))
NSFile::CFileBinary oFile;
if(oFile.OpenFile(string2std_string(sSrcFileName)))
{
long nBase64DataSize = oMappingFile.GetSize();
BYTE* pBase64Data = oMappingFile.GetData();
DWORD nBase64DataSize = 0;
BYTE* pBase64Data = new BYTE[oFile.GetFileSize()];
oFile.ReadFile(pBase64Data, oFile.GetFileSize(), nBase64DataSize);
oFile.CloseFile();
//
bool bValidFormat = false;
......@@ -3042,7 +3039,6 @@ namespace BinXlsxRW {
bResultOk = true;
}
}
oMappingFile.Close();
}
return S_OK;
}
......
......@@ -17,7 +17,7 @@
namespace CSVWriter
{
void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, CString &sWriteString, UINT &nCodePage, BOOL bIsEnd = FALSE);
void WriteFromXlsxToCsv(CString &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, CONST WCHAR wcDelimiter);
void WriteFromXlsxToCsv(CString &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter);
}
#endif //CSV_WRITER
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