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

вернул параметр кодировки в txt file.ошибка при сохранении json для mailmerge.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64790 954022d7-b5bf-4e40-9824-e11837661b57
parent 614a118a
#include "File.h" #include "File.h"
#include "../Common/Utility.h" #include "../Common/Utility.h"
#include "TxtFile.h" #include "TxtFile.h"
...@@ -15,7 +15,7 @@ namespace Txt ...@@ -15,7 +15,7 @@ namespace Txt
{ {
m_listContent.clear(); m_listContent.clear();
} }
void File::read(const std::wstring& filename, int code_page) // void File::read(const std::wstring& filename, int code_page) // насильственное чтение в кодировке
{ {
m_listContent.clear(); m_listContent.clear();
...@@ -42,7 +42,7 @@ namespace Txt ...@@ -42,7 +42,7 @@ namespace Txt
TxtFile file(filename); TxtFile file(filename);
// //читаем юникод чтобы можно было выкинуть невалидные символы
if (file.isUtf8()) if (file.isUtf8())
{ {
...@@ -56,19 +56,22 @@ namespace Txt ...@@ -56,19 +56,22 @@ namespace Txt
{ {
m_listContent = file.readBigEndian(); m_listContent = file.readBigEndian();
} }
// , : //проверка убрана, потому что она работает в редких случаюх: если в первой строке есть английские символы
// BigEndian LittleEndian //далее не делается проверка BigEndian или LittleEndian
//notepad++ ansi . //notepad++ открывает такие файлы как ansi и мы будем также.
//else if (file.isUnicodeWithOutBOM()) //else if (file.isUnicodeWithOutBOM())
// listContentUnicode = file.readUnicodeWithOutBOM(); // listContentUnicode = file.readUnicodeWithOutBOM();
else else
{ {
if(-1 == m_nEncoding)
m_listContent = _transform(file.readAnsiOrCodePage(), Encoding::utf82unicode); m_listContent = _transform(file.readAnsiOrCodePage(), Encoding::utf82unicode);
else
m_listContent = _transform2(file.readAnsiOrCodePage(), m_nEncoding, Encoding::cp2unicode);
} }
m_listContentSize = file.getLinesCount(); m_listContentSize = file.getLinesCount();
//correctUnicode(listContentUnicode); - ( //correctUnicode(listContentUnicode); - ВЫТИРАЕТ ПРОБЕЛЫ в конце строки (
} }
......
#ifndef BINARY_WRITER #ifndef BINARY_WRITER
#define BINARY_WRITER #define BINARY_WRITER
#include "../../ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h" #include "../../ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h"
...@@ -916,7 +916,7 @@ namespace BinXlsxRW { ...@@ -916,7 +916,7 @@ namespace BinXlsxRW {
} }
else else
{ {
// //выбираем один цвет
if(fill.m_oGradientFill.IsInit()) if(fill.m_oGradientFill.IsInit())
{ {
const OOX::Spreadsheet::CGradientFill& gradient = fill.m_oGradientFill.get(); const OOX::Spreadsheet::CGradientFill& gradient = fill.m_oGradientFill.get();
...@@ -979,7 +979,7 @@ namespace BinXlsxRW { ...@@ -979,7 +979,7 @@ namespace BinXlsxRW {
//RFont //RFont
if(font.m_oRFont.IsInit() && font.m_oRFont->m_sVal.IsInit()) if(font.m_oRFont.IsInit() && font.m_oRFont->m_sVal.IsInit())
{ {
// //подбираем шрифт
CString sFont = oFontProcessor.getFont(font.m_oScheme, font.m_oRFont, font.m_oCharset, font.m_oFamily, theme); CString sFont = oFontProcessor.getFont(font.m_oScheme, font.m_oRFont, font.m_oCharset, font.m_oFamily, theme);
m_oBcw.m_oStream.WriteBYTE(c_oSerFontTypes::RFont); m_oBcw.m_oStream.WriteBYTE(c_oSerFontTypes::RFont);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
...@@ -1600,7 +1600,7 @@ namespace BinXlsxRW { ...@@ -1600,7 +1600,7 @@ namespace BinXlsxRW {
void WriteWorksheets(OOX::Spreadsheet::CWorkbook& workbook, std::map<CString, OOX::Spreadsheet::CWorksheet*>& aWorksheets) void WriteWorksheets(OOX::Spreadsheet::CWorkbook& workbook, std::map<CString, OOX::Spreadsheet::CWorksheet*>& aWorksheets)
{ {
int nCurPos; int nCurPos;
// //определяем порядок следования
if(workbook.m_oSheets.IsInit()) if(workbook.m_oSheets.IsInit())
{ {
std::vector<OOX::Spreadsheet::CSheet*>& aWs = workbook.m_oSheets->m_arrItems; std::vector<OOX::Spreadsheet::CSheet*>& aWs = workbook.m_oSheets->m_arrItems;
...@@ -1705,7 +1705,7 @@ namespace BinXlsxRW { ...@@ -1705,7 +1705,7 @@ namespace BinXlsxRW {
//Drawing //Drawing
if(oWorksheet.m_oDrawing.IsInit() && oWorksheet.m_oDrawing->m_oId.IsInit()) if(oWorksheet.m_oDrawing.IsInit() && oWorksheet.m_oDrawing->m_oId.IsInit())
{ {
// Drawing VmlDrawing //из Drawing могут быть ссылки на объекты в VmlDrawing
OOX::CVmlDrawing *currentVmlDrawing = NULL; OOX::CVmlDrawing *currentVmlDrawing = NULL;
if (oWorksheet.m_oLegacyDrawingWorksheet.IsInit() && if (oWorksheet.m_oLegacyDrawingWorksheet.IsInit() &&
...@@ -2215,7 +2215,7 @@ namespace BinXlsxRW { ...@@ -2215,7 +2215,7 @@ namespace BinXlsxRW {
nCol--; nCol--;
} }
// , 2 ( JavaScript, .. C++ ). . // Пишем теперь не строку, а 2 числа (чтобы не парсить на JavaScript, т.к. на C++ быстрее парсинг). Ускорение открытия файла.
nCurPos = m_oBcw.WriteItemStart(c_oSerCellTypes::RefRowCol); nCurPos = m_oBcw.WriteItemStart(c_oSerCellTypes::RefRowCol);
m_oBcw.m_oStream.WriteLONG(nRow); m_oBcw.m_oStream.WriteLONG(nRow);
m_oBcw.m_oStream.WriteLONG(nCol); m_oBcw.m_oStream.WriteLONG(nCol);
...@@ -2559,7 +2559,7 @@ namespace BinXlsxRW { ...@@ -2559,7 +2559,7 @@ namespace BinXlsxRW {
std::vector<SerializeCommon::CommentData*> aCommentDatas; std::vector<SerializeCommon::CommentData*> aCommentDatas;
getSavedComment(oComment, aCommentDatas); getSavedComment(oComment, aCommentDatas);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Comment); nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Comment);
// , , , Excel //записываем тот обьект, который был в бинарнике, подменяем только текст, который мог быть отредактирован в Excel
WriteComment(oComment, aCommentDatas, oComment.m_oText); WriteComment(oComment, aCommentDatas, oComment.m_oText);
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
...@@ -3047,7 +3047,7 @@ namespace BinXlsxRW { ...@@ -3047,7 +3047,7 @@ namespace BinXlsxRW {
OOX::Spreadsheet::CConditionalFormatValueObject* pCFVO = NULL; OOX::Spreadsheet::CConditionalFormatValueObject* pCFVO = NULL;
OOX::Spreadsheet::CColor* pColor = NULL; OOX::Spreadsheet::CColor* pColor = NULL;
// ToDo , // ToDo более правильно заделать виртуальную функцию, которая будет писать без привидения типов
int nCurPos = 0; int nCurPos = 0;
for (int i = 0, length = oColorScale.m_arrItems.size(); i < length; ++i) for (int i = 0, length = oColorScale.m_arrItems.size(); i < length; ++i)
...@@ -3310,7 +3310,7 @@ namespace BinXlsxRW { ...@@ -3310,7 +3310,7 @@ namespace BinXlsxRW {
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const CString& sXMLOptions) NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const CString& sXMLOptions)
{ {
OOX::CPath path(sFileDst); OOX::CPath path(sFileDst);
// media //создаем папку для media
CString mediaDir = path.GetDirectory() + gc_sMediaDirName; CString mediaDir = path.GetDirectory() + gc_sMediaDirName;
NSDirectory::CreateDirectory(string2std_string(mediaDir)); NSDirectory::CreateDirectory(string2std_string(mediaDir));
...@@ -3323,7 +3323,7 @@ namespace BinXlsxRW { ...@@ -3323,7 +3323,7 @@ namespace BinXlsxRW {
//oMimeFile.WriteStringUTF8(CString(_T("application/x-asc-spreadsheet"))); //oMimeFile.WriteStringUTF8(CString(_T("application/x-asc-spreadsheet")));
//oMimeFile.CloseFile(); //oMimeFile.CloseFile();
long nGrowSize = 1 * 1024 * 1024;//1 long nGrowSize = 1 * 1024 * 1024;//1мб
NSBinPptxRW::CBinaryFileWriter& oBufferedStream = *pOfficeDrawingConverter->m_pBinaryWriter; NSBinPptxRW::CBinaryFileWriter& oBufferedStream = *pOfficeDrawingConverter->m_pBinaryWriter;
m_oBcw = new BinaryCommonWriter(oBufferedStream); m_oBcw = new BinaryCommonWriter(oBufferedStream);
...@@ -3351,7 +3351,8 @@ namespace BinXlsxRW { ...@@ -3351,7 +3351,8 @@ namespace BinXlsxRW {
if (BinXlsxRW::c_oFileTypes::JSON == saveFileType) if (BinXlsxRW::c_oFileTypes::JSON == saveFileType)
{ {
CSVWriter::WriteFromXlsxToCsv(sFileDst, *pXlsx, CP_UTF8, _T(','), true); //todo 46 временно CP_UTF8
CSVWriter::WriteFromXlsxToCsv(sFileDst, *pXlsx, 46, _T(','), true);
} }
else else
{ {
...@@ -3386,7 +3387,7 @@ namespace BinXlsxRW { ...@@ -3386,7 +3387,7 @@ namespace BinXlsxRW {
if(NULL != pStyle && pStyle->m_oColors.IsInit() && pStyle->m_oColors->m_oIndexedColors.IsInit()) if(NULL != pStyle && pStyle->m_oColors.IsInit() && pStyle->m_oColors->m_oIndexedColors.IsInit())
pIndexedColors = pStyle->m_oColors->m_oIndexedColors.operator ->(); pIndexedColors = pStyle->m_oColors->m_oIndexedColors.operator ->();
// Theme ClrMap, rgb //важно в начале записать Theme и ClrMap, потому что они используются при дальнейшей записи для получения rgb цветов
OOX::CTheme* pTheme = oXlsx.GetTheme(); OOX::CTheme* pTheme = oXlsx.GetTheme();
BYTE* pThemeData = NULL; BYTE* pThemeData = NULL;
long nThemeDataSize = 0; long nThemeDataSize = 0;
...@@ -3456,10 +3457,10 @@ namespace BinXlsxRW { ...@@ -3456,10 +3457,10 @@ namespace BinXlsxRW {
} }
void WriteMainTableStart() void WriteMainTableStart()
{ {
int nTableCount = 128;// , . int nTableCount = 128;//Специально ставим большое число, чтобы не увеличивать его при добавлении очередной таблицы.
m_nRealTableCount = 0; m_nRealTableCount = 0;
m_nMainTableStart = m_oBcw->m_oStream.GetPosition(); m_nMainTableStart = m_oBcw->m_oStream.GetPosition();
// //вычисляем с какой позиции можно писать таблицы
int nmtItemSize = 5;//5 byte int nmtItemSize = 5;//5 byte
m_nLastFilePos = m_nMainTableStart + nTableCount * nmtItemSize; m_nLastFilePos = m_nMainTableStart + nTableCount * nmtItemSize;
//Write mtLen //Write mtLen
...@@ -3467,11 +3468,11 @@ namespace BinXlsxRW { ...@@ -3467,11 +3468,11 @@ namespace BinXlsxRW {
} }
void WriteMainTableEnd() void WriteMainTableEnd()
{ {
// //Количество таблиц
m_oBcw->m_oStream.SetPosition(m_nMainTableStart); m_oBcw->m_oStream.SetPosition(m_nMainTableStart);
m_oBcw->m_oStream.WriteBYTE(m_nRealTableCount); m_oBcw->m_oStream.WriteBYTE(m_nRealTableCount);
//Seek //Seek в конец
m_oBcw->m_oStream.SetPosition(m_nLastFilePos); m_oBcw->m_oStream.SetPosition(m_nLastFilePos);
} }
int WriteTableStart(BYTE type, int nStartPos = -1) int WriteTableStart(BYTE type, int nStartPos = -1)
...@@ -3485,18 +3486,18 @@ namespace BinXlsxRW { ...@@ -3485,18 +3486,18 @@ namespace BinXlsxRW {
m_oBcw->m_oStream.WriteLONG(m_nLastFilePos); m_oBcw->m_oStream.WriteLONG(m_nLastFilePos);
//Write table //Write table
// MainTable //Запоминаем позицию в MainTable
int nCurPos = m_oBcw->m_oStream.GetPosition(); int nCurPos = m_oBcw->m_oStream.GetPosition();
//Seek //Seek в свободную область
m_oBcw->m_oStream.SetPosition(m_nLastFilePos); m_oBcw->m_oStream.SetPosition(m_nLastFilePos);
return nCurPos; return nCurPos;
} }
void WriteTableEnd(int nCurPos) void WriteTableEnd(int nCurPos)
{ {
// //сдвигаем позицию куда можно следующую таблицу
m_nLastFilePos = m_oBcw->m_oStream.GetPosition(); m_nLastFilePos = m_oBcw->m_oStream.GetPosition();
m_nRealTableCount++; m_nRealTableCount++;
//Seek MainTable //Seek вобратно в MainTable
m_oBcw->m_oStream.SetPosition(nCurPos); m_oBcw->m_oStream.SetPosition(nCurPos);
} }
#ifdef DEFAULT_TABLE_STYLES #ifdef DEFAULT_TABLE_STYLES
......
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