Compare commits

..

3 Commits

Author SHA1 Message Date
9b7ad03465 OdfFormatWriter - presentation notes 2017-05-04 15:12:48 +03:00
3162bb0bfe open/save csv with user defined delimiters 2017-05-04 14:01:01 +03:00
ec95648c43 fix bug 34910 2017-05-04 11:21:05 +03:00
23 changed files with 189 additions and 83 deletions

View File

@ -85,7 +85,7 @@ void draw_page::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
draw_page_attr_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
for (int i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
@ -107,7 +107,7 @@ const wchar_t * presentation_footer_decl::name = L"footer-decl";
// CP_XML_ATTR_OPT(L"presentation:name", presentation_name_);
//}
//////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------
const wchar_t * presentation_date_time_decl::ns = L"presentation";
const wchar_t * presentation_date_time_decl::name = L"date-time-decl";
//
@ -119,5 +119,33 @@ const wchar_t * presentation_date_time_decl::name = L"date-time-decl";
//}
//
//------------------------------------------------------
const wchar_t * presentation_notes::ns = L"presentation";
const wchar_t * presentation_notes::name = L"notes";
void presentation_notes::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void presentation_notes::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void presentation_notes::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
attlist_.serialize(CP_GET_XML_NODE());
for (int i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
}

View File

@ -79,7 +79,7 @@ public:
office_element_ptr_array content_;
office_element_ptr animation_;
draw_page_attr draw_page_attr_;
draw_page_attr attlist_;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_page);
@ -127,6 +127,26 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_date_time_decl);
//---------------------------------------------------------------------
class presentation_notes : public office_element_impl<presentation_notes>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationNotes;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
office_element_ptr_array content_;
draw_page_attr attlist_;
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_notes);
}
}

View File

@ -84,7 +84,7 @@ void odf_master_state::set_name(std::wstring & name)
if (!style_)return;
style_->style_master_page_attlist_.style_name_ = name;
style_->attlist_.style_name_ = name;
}
void odf_master_state::set_display_name(std::wstring & name)
{
@ -92,7 +92,7 @@ void odf_master_state::set_display_name(std::wstring & name)
if (!style_)return;
style_->style_master_page_attlist_.style_display_name_ = name;
style_->attlist_.style_display_name_ = name;
}
void odf_master_state::set_layout_style_name(std::wstring name)
@ -101,14 +101,14 @@ void odf_master_state::set_layout_style_name(std::wstring name)
if (!style_)return;
style_->style_master_page_attlist_.style_page_layout_name_ = name;
style_->attlist_.style_page_layout_name_ = name;
}
std::wstring odf_master_state::get_name()
{
style_master_page* style_ = dynamic_cast<style_master_page*>(elements_[0].elm.get());
if (!style_)return L"";
return style_->style_master_page_attlist_.style_name_.get_value_or(L"");
return style_->attlist_.style_name_.get_value_or(L"");
}
void odf_master_state::add_footer(office_element_ptr & elm)
{

View File

@ -147,7 +147,16 @@ void odp_conversion_context::end_drawings()
{
current_slide().drawing_context()->clear();
}
void odp_conversion_context::start_note()
{
office_element_ptr note_elm;
create_element(L"presentation", L"notes", note_elm, this);
current_slide().drawing_context()->start_drawing();
current_slide().drawing_context()->start_element(note_elm);
slide_context_.start_page(note_elm);
}
void odp_conversion_context::start_comment(int oox_comm_id)
{
office_element_ptr comm_elm;
@ -182,6 +191,15 @@ void odp_conversion_context::end_comment()
current_slide().drawing_context()->end_element();
current_slide().drawing_context()->end_drawing();
}
void odp_conversion_context::end_note()
{
slide_context_.end_page();
slide_context_.remove_page();
current_slide().drawing_context()->end_element();
current_slide().drawing_context()->end_drawing();
}
}
}

View File

@ -77,6 +77,9 @@ public:
void start_comment_content ();
void end_comment_content ();
void start_note();
void end_note();
private:
odp_slide_context slide_context_;

View File

@ -72,12 +72,12 @@ void odp_page_state::set_page_name(std::wstring name)
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
if (page)
page->draw_page_attr_.draw_name_ = name;
page->attlist_.draw_name_ = name;
else
{
//style_master_page *master_page = dynamic_cast<style_master_page*>(page_elm_.get());
//if (master_page)
// master_page->style_master_page_attlist_.style_display_name_ = name;
// master_page->attlist_.style_display_name_ = name;
}
}
@ -88,7 +88,7 @@ void odp_page_state::set_layout_page(std::wstring name)
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
if (page == NULL)return;
page->draw_page_attr_.page_layout_name_ = name;
page->attlist_.page_layout_name_ = name;
}
void odp_page_state::set_master_page(std::wstring name)
@ -98,7 +98,7 @@ void odp_page_state::set_master_page(std::wstring name)
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
if (page == NULL)return;
page->draw_page_attr_.master_page_name_ = name;
page->attlist_.master_page_name_ = name;
}
void odp_page_state::set_page_style(office_element_ptr & elm)
@ -111,12 +111,18 @@ void odp_page_state::set_page_style(office_element_ptr & elm)
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
if (page)
page->draw_page_attr_.draw_style_name_ = office_page_style_->style_name_;
page->attlist_.draw_style_name_ = office_page_style_->style_name_;
else
{
style_master_page *master_page = dynamic_cast<style_master_page*>(page_elm_.get());
if (master_page)
master_page->style_master_page_attlist_.draw_style_name_ = office_page_style_->style_name_;
master_page->attlist_.draw_style_name_ = office_page_style_->style_name_;
else
{
presentation_notes* notes = dynamic_cast<presentation_notes*>(page_elm_.get());
if (notes)
notes->attlist_.draw_style_name_ = office_page_style_->style_name_;
}
}
}
void odp_page_state::add_child_element( const office_element_ptr & child_element)

View File

@ -44,8 +44,9 @@ namespace cpdoccore {
namespace odf_writer {
odp_slide_context::odp_slide_context(odp_conversion_context & Context): context_(Context), table_context_(&Context), comment_context_(&Context)
odp_slide_context::odp_slide_context(odp_conversion_context & Context) : context_(Context), table_context_(&Context), comment_context_(&Context)
{
count_slides_ = 0;
styles_context_ = Context.styles_context();
}
void odp_slide_context::set_styles_context(odf_style_context* styles_context)
@ -67,17 +68,13 @@ void odp_slide_context::start_page(office_element_ptr & elm)
{
page_state_list_.push_back( odp_page_state(&context_, elm) );
std::wstring style_name_new = L"dp" + boost::lexical_cast<std::wstring>(page_state_list_.size());
std::wstring style_name_new = L"dp" + std::to_wstring(++count_slides_);
office_element_ptr & style = styles_context_->add_or_find(style_name_new, style_family::DrawingPage, true);
style->create_child_element(L"style", L"drawing-page-properties");
state().set_page_style(style);
state().drawing_context()->set_styles_context(styles_context_);
//для свойств страницы, а не таблицы - нужно создать master-page c page layout и связать по имени со стилем таблицы
//причем здесь, т.к. с другой стороны это ВСЕ еще свойства листа. то есть совйства листа разделить на свйства страницы и таблицы ..
//todooo
//????
}
void odp_slide_context::end_page()
@ -85,6 +82,11 @@ void odp_slide_context::end_page()
state().drawing_context()->finalize(state().page_elm_);
}
void odp_slide_context::remove_page()
{
page_state_list_.pop_back();
}
odf_table_context* odp_slide_context::table_context()
{
return &table_context_;

View File

@ -53,6 +53,8 @@ public:
void start_page (office_element_ptr & elm);
void end_page ();
void remove_page();
void set_styles_context(odf_style_context* styles_context);
odf_style_context* get_styles_context();
@ -81,6 +83,7 @@ private:
odf_comment_context comment_context_;
std::list<odp_page_state> page_state_list_;
int count_slides_;
friend class odp_conversion_context;

View File

@ -157,8 +157,6 @@ enum ElementType
typeStylePresentationPlaceholder,
typeStyleDrawingPageProperties,
typePresentationNotes,
typeStyleColumns,
typeStyleColumn,
typeStyleColumnSep,
@ -264,6 +262,7 @@ enum ElementType
typeDrawPage,
typePresentationFooterDecl,
typePresentationDateTimeDecl,
typePresentationNotes,
typeAnimPar,
typeAnimSeq,

View File

@ -1270,7 +1270,7 @@ void style_master_page::serialize(std::wostream & strm)
{
CP_XML_NODE_SIMPLE()
{
style_master_page_attlist_.serialize( CP_GET_XML_NODE());
attlist_.serialize( CP_GET_XML_NODE());
if (style_footer_) style_footer_->serialize(CP_XML_STREAM());
if (style_header_) style_header_->serialize(CP_XML_STREAM());

View File

@ -505,7 +505,7 @@ public:
int find_placeHolderIndex(odf_types::presentation_class::type placeHolder,int & last_idx);
style_master_page_attlist style_master_page_attlist_;
style_master_page_attlist attlist_;
office_element_ptr style_header_;
office_element_ptr style_header_left_;

View File

@ -1947,17 +1947,17 @@ void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeSt
for (size_t i = 0; i < oox_txBody->Paragrs.size(); i++)
{
convert(&oox_txBody->Paragrs[i], oox_txBody->lstStyle.GetPointer());
//внешние настройки для текста
convert(oox_txBody->bodyPr.GetPointer());
if (oox_style)
{
convert(&oox_style->fontRef);
}
}
odf_context()->drawing_context()->set_text( odf_context()->text_context());
//внешние настройки для текста
convert(oox_txBody->bodyPr.GetPointer());
if (oox_style)
{
convert(&oox_style->fontRef);
}
odf_context()->end_text_context();
}
void OoxConverter::convert(PPTX::Logic::ArcTo *oox_geom_path)

View File

@ -412,6 +412,18 @@ void PptxConverter::convert_slides()
void PptxConverter::convert(PPTX::NotesSlide *oox_note)
{
if (!oox_note) return;
odp_context->start_note();
current_slide = dynamic_cast<OOX::IFileContainer*>(oox_note);
if (oox_note->clrMapOvr.IsInit() && oox_note->clrMapOvr->overrideClrMapping.IsInit())
current_clrMap = oox_note->clrMapOvr->overrideClrMapping.GetPointer();
//current_txStyles = oox_note->Master->txStyles.GetPointer();
convert_slide(&oox_note->cSld, NULL, true, true);
odp_context->end_note();
}
void PptxConverter::convert(OOX::WritingElement *oox_unknown)

View File

@ -182,12 +182,14 @@ namespace PPTX
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileWriter* pOldWriter = oDrawingConverter.m_pBinaryWriter;
oDrawingConverter.m_pBinaryWriter = pWriter;
oDrawingConverter.m_pBinaryWriter = pWriter;
smart_ptr<OOX::IFileContainer> oldRels = oDrawingConverter.GetRels();
oDrawingConverter.SetRels(pChart.smart_dynamic_cast<OOX::IFileContainer>());
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(*pWriter, &oDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(*pChart);
oDrawingConverter.SetRels(oldRels);
oDrawingConverter.m_pBinaryWriter = pOldWriter;
}
std::wstring ChartRec::toXML() const

View File

@ -333,6 +333,7 @@ namespace NExtractTools
int* m_nFormatTo;
int* m_nCsvTxtEncoding;
int* m_nCsvDelimiter;
std::wstring* m_sCsvDelimiterChar;
bool* m_bPaid;
bool* m_bFromChanges;
bool* m_bDontSaveAdditional;
@ -356,6 +357,7 @@ namespace NExtractTools
m_nFormatTo = NULL;
m_nCsvTxtEncoding = NULL;
m_nCsvDelimiter = NULL;
m_sCsvDelimiterChar = NULL;
m_bPaid = NULL;
m_bFromChanges = NULL;
m_bDontSaveAdditional = NULL;
@ -379,6 +381,7 @@ namespace NExtractTools
RELEASEOBJECT(m_nFormatTo);
RELEASEOBJECT(m_nCsvTxtEncoding);
RELEASEOBJECT(m_nCsvDelimiter);
RELEASEOBJECT(m_sCsvDelimiterChar);
RELEASEOBJECT(m_bPaid);
RELEASEOBJECT(m_bFromChanges);
RELEASEOBJECT(m_bDontSaveAdditional);
@ -456,6 +459,8 @@ namespace NExtractTools
m_nCsvTxtEncoding = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_nCsvDelimiter") == sName)
m_nCsvDelimiter = new int(XmlUtils::GetInteger(sValue));
else if(_T("m_nCsvDelimiterChar") == sName)
m_sCsvDelimiterChar = new std::wstring(sValue);
else if(_T("m_bPaid") == sName)
m_bPaid = new bool(XmlUtils::GetBoolean2(sValue));
else if(_T("m_bFromChanges") == sName)
@ -475,6 +480,10 @@ namespace NExtractTools
else if(_T("m_sPassword") == sName)
m_sPassword = new std::wstring(sValue);
}
else if(_T("m_nCsvDelimiterChar") == sName)
{
m_sCsvDelimiterChar = new std::wstring(L"");
}
}
}
}
@ -492,8 +501,8 @@ namespace NExtractTools
std::wstring getXmlOptions()
{
std::wstring sRes;
int nCsvEncoding = 65001; //utf8
std::string cDelimiter = ",";
int nCsvEncoding = 46;//65001 utf8
std::wstring cDelimiter = L"";
if(NULL != m_nCsvTxtEncoding)
nCsvEncoding = *m_nCsvTxtEncoding;
@ -501,13 +510,17 @@ namespace NExtractTools
{
switch (*m_nCsvDelimiter)
{
case TCSVD_TAB: cDelimiter = "\t"; break;
case TCSVD_SEMICOLON: cDelimiter = ";"; break;
case TCSVD_COLON: cDelimiter = ":"; break;
case TCSVD_COMMA: cDelimiter = ","; break;
case TCSVD_SPACE: cDelimiter = " "; break;
case TCSVD_TAB: cDelimiter = L"\t"; break;
case TCSVD_SEMICOLON: cDelimiter = L";"; break;
case TCSVD_COLON: cDelimiter = L":"; break;
case TCSVD_COMMA: cDelimiter = L","; break;
case TCSVD_SPACE: cDelimiter = L" "; break;
}
}
if(NULL != m_sCsvDelimiterChar)
{
cDelimiter = *m_sCsvDelimiterChar;
}
int nFileType = 1;
if(NULL != m_nFormatFrom && AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == *m_nFormatFrom)
nFileType = 2;
@ -522,7 +535,7 @@ namespace NExtractTools
}
sRes = L"<xmlOptions><fileOptions fileType='" + std::to_wstring(nFileType);
sRes += L"' codePage='" + std::to_wstring(nCsvEncoding);
sRes += L"' delimiter='" + std::wstring(cDelimiter.begin(), cDelimiter.end()) + L"' " + sSaveType;
sRes += L"' delimiter='" + XmlUtils::EncodeXmlString(cDelimiter) + L"' " + sSaveType;
sRes += L"/><TXTOptions><Encoding>" + std::to_wstring(nCsvEncoding) + L"</Encoding></TXTOptions></xmlOptions>";
return sRes;
@ -602,7 +615,7 @@ namespace NExtractTools
eRes = TCD_ERROR;
}
}
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom && (NULL == m_nCsvTxtEncoding || NULL == m_nCsvDelimiter))
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom && (NULL == m_nCsvTxtEncoding || (NULL == m_nCsvDelimiter && NULL == m_sCsvDelimiterChar)))
{
if(!getDontSaveAdditional())
{

View File

@ -40,10 +40,6 @@
#endif
#include "../../DesktopEditor/common/File.h"
#ifndef CP_UTF8
#define CP_UTF8 65001
#endif
namespace SerializeCommon
{
std::wstring DownloadImage(const std::wstring& strFile)
@ -99,11 +95,11 @@ namespace SerializeCommon
return sSourcePath.substr(0, nIndex + 1) + sTargetExt;
return sSourcePath;
}
void ReadFileType(const std::wstring& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter, BYTE& cSaveFileType)
void ReadFileType(const std::wstring& sXMLOptions, BYTE& result, UINT& nCodePage, std::wstring& sDelimiter, BYTE& cSaveFileType)
{
result = BinXlsxRW::c_oFileTypes::XLSX;
nCodePage = CP_UTF8;
wcDelimiter = _T(',');
nCodePage = 46;//todo 46 временно CP_UTF8
sDelimiter = _T("");
cSaveFileType = BinXlsxRW::c_oFileTypes::XLSX;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> fileType;
@ -142,9 +138,7 @@ namespace SerializeCommon
cSaveFileType = (BYTE)saveFileType->GetValue();
if (delimiter.IsInit())
{
const std::wstring& sDelimiter = delimiter.get();
if (0 < sDelimiter.length())
wcDelimiter = sDelimiter[0];
sDelimiter = delimiter.get();
}
break;
}

View File

@ -72,7 +72,7 @@ namespace SerializeCommon
aReplies.clear();
}
};
void ReadFileType(const std::wstring& sXMLOptions, BYTE& result, UINT& nCodePage, WCHAR& wcDelimiter, BYTE& saveFileType);
void ReadFileType(const std::wstring& sXMLOptions, BYTE& result, UINT& nCodePage, std::wstring& wcDelimiter, BYTE& saveFileType);
}
#endif //SERIALIZER_COMMON

View File

@ -3926,16 +3926,16 @@ namespace BinXlsxRW
// File Type
BYTE fileType;
UINT nCodePage;
WCHAR wcDelimiter;
std::wstring sDelimiter;
BYTE saveFileType;
SerializeCommon::ReadFileType(sXMLOptions, fileType, nCodePage, wcDelimiter, saveFileType);
SerializeCommon::ReadFileType(sXMLOptions, fileType, nCodePage, sDelimiter, saveFileType);
OOX::Spreadsheet::CXlsx *pXlsx = NULL;
switch(fileType)
{
case BinXlsxRW::c_oFileTypes::CSV:
pXlsx = new OOX::Spreadsheet::CXlsx();
CSVReader::ReadFromCsvToXlsx(sInputDir, *pXlsx, nCodePage, wcDelimiter);
CSVReader::ReadFromCsvToXlsx(sInputDir, *pXlsx, nCodePage, sDelimiter);
break;
case BinXlsxRW::c_oFileTypes::XLSX:
default:
@ -3946,8 +3946,8 @@ namespace BinXlsxRW
if (BinXlsxRW::c_oFileTypes::JSON == saveFileType)
{
//todo 46 временно CP_UTF8
CSVWriter::WriteFromXlsxToCsv(sFileDst, *pXlsx, 46, _T(','), true);
//todo 46 временно CP_UTF8
CSVWriter::WriteFromXlsxToCsv(sFileDst, *pXlsx, 46, std::wstring(L","), true);
}
else
{

View File

@ -81,7 +81,7 @@ namespace CSVReader
pCell->setRowCol(nRow, nCol);
oRow.m_arrItems.push_back(pCell);
}
void ReadFromCsvToXlsx(const std::wstring &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter)
void ReadFromCsvToXlsx(const std::wstring &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const std::wstring& sDelimiter)
{
// Создадим Workbook
oXlsx.CreateWorkbook();
@ -169,6 +169,20 @@ namespace CSVReader
INT nSize = sFileDataW.length();
const WCHAR *pTemp =sFileDataW.c_str();
WCHAR wcDelimiterLeading = L'\0';
WCHAR wcDelimiterTrailing = L'\0';
int nDelimiterSize = 0;
if (sDelimiter.length() > 0)
{
wcDelimiterLeading = sDelimiter[0];
nDelimiterSize = 1;
if (2 == sizeof(wchar_t) && 0xD800 <= wcDelimiterLeading && wcDelimiterLeading <= 0xDBFF && sDelimiter.length() > 1)
{
wcDelimiterTrailing = sDelimiter[1];
nDelimiterSize = 2;
}
}
const WCHAR wcNewLineN = _T('\n');
const WCHAR wcNewLineR = _T('\r');
const WCHAR wcQuote = _T('"');
@ -188,7 +202,7 @@ namespace CSVReader
for (INT nIndex = 0; nIndex < nSize; ++nIndex)
{
wcCurrent = pTemp[nIndex];
if (wcDelimiter == wcCurrent)
if (wcDelimiterLeading == wcCurrent && (L'\0' == wcDelimiterTrailing || (nIndex + 1 < nSize && wcDelimiterTrailing == pTemp[nIndex + 1])))
{
if (bInQuote)
continue;
@ -197,7 +211,7 @@ namespace CSVReader
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
bIsWrap = false;
nStartCell = nIndex + 1;
nStartCell = nIndex + nDelimiterSize;
if (nStartCell == nSize)
{
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);

View File

@ -40,7 +40,7 @@
namespace CSVReader
{
void AddCell(std::wstring &sText, INT nStartCell, std::stack<INT> &oDeleteChars, OOX::Spreadsheet::CRow &oRow, INT nRow, INT nCol, bool bIsWrap);
void ReadFromCsvToXlsx(const std::wstring &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter);
void ReadFromCsvToXlsx(const std::wstring &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const std::wstring& wcDelimiter);
}
#endif //CSV_READER

View File

@ -3916,10 +3916,10 @@ namespace BinXlsxRW {
std::wstring sDstPathCSV = sDstPath;
BYTE fileType;
UINT nCodePage;
WCHAR wcDelimiter;
std::wstring sDelimiter;
BYTE saveFileType;
SerializeCommon::ReadFileType(sXMLOptions, fileType, nCodePage, wcDelimiter, saveFileType);
SerializeCommon::ReadFileType(sXMLOptions, fileType, nCodePage, sDelimiter, saveFileType);
// Делаем для CSV перебивку пути, иначе создается папка с одинаковым имеем (для rels) и файл не создается.
if (BinXlsxRW::c_oFileTypes::CSV == fileType)
@ -3943,7 +3943,7 @@ namespace BinXlsxRW {
switch(fileType)
{
case BinXlsxRW::c_oFileTypes::CSV:
CSVWriter::WriteFromXlsxToCsv(sDstPathCSV, oXlsx, nCodePage, wcDelimiter, false);
CSVWriter::WriteFromXlsxToCsv(sDstPathCSV, oXlsx, nCodePage, sDelimiter, false);
break;
case BinXlsxRW::c_oFileTypes::XLSX:
default:

View File

@ -64,7 +64,7 @@ namespace CSVWriter
}
}
}
void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, std::wstring &sWriteString, UINT &nCodePage, bool bIsEnd)
void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, const std::wstring &sWriteString, UINT &nCodePage, bool bIsEnd)
{
if (NULL == pFile || NULL == pWriteBuffer)
return;
@ -84,7 +84,7 @@ namespace CSVWriter
if (nCountChars + nCurrentIndex > c_nSize || bIsEnd)
{
// Буффер заполнился, пишем
if (nCodePage == CP_UTF16)
if (nCodePage == 48 && 2 == sizeof(wchar_t))//todo 48 временно CP_UTF16
{
pFile->WriteFile((BYTE*)*pWriteBuffer, sizeof (WCHAR) * nCurrentIndex);
}
@ -106,23 +106,23 @@ namespace CSVWriter
nCurrentIndex += nCountChars;
}
}
void WriteFromXlsxToCsv(const std::wstring &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter, bool bJSON)
void WriteFromXlsxToCsv(const std::wstring &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const std::wstring& sDelimiter, bool bJSON)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sFileDst);
// Нужно записать шапку
if (CP_UTF8 == nCodePage)
if (46 == nCodePage)//todo 46 временно CP_UTF8
{
BYTE arUTF8[3] = {0xEF, 0xBB, 0xBF};
oFile.WriteFile(arUTF8, 3);
}
else if (CP_UTF16 == nCodePage)
else if (48 == nCodePage)//todo 48 временно CP_UTF16
{
BYTE arUTF16[2] = {0xFF, 0xFE};
oFile.WriteFile(arUTF16, 2);
}
else if (CP_unicodeFFFE == nCodePage)
else if (49 == nCodePage)//todo 49 временно CP_unicodeFFFE
{
BYTE arBigEndian[2] = {0xFE, 0xFF};
oFile.WriteFile(arBigEndian, 2);
@ -169,9 +169,8 @@ namespace CSVWriter
if (NULL != pWorksheet && pWorksheet->m_oSheetData.IsInit())
{
OOX::Spreadsheet::CSharedStrings *pSharedStrings = oXlsx.GetSharedStrings();
std::wstring sDelimiter = _T(""); sDelimiter += wcDelimiter;
std::wstring sEscape = _T("\"\n");
sEscape += wcDelimiter;
sEscape += sDelimiter;
std::wstring sEndJson = std::wstring(_T("]"));
std::wstring sQuote = _T("\"");
std::wstring sDoubleQuote = _T("\"\"");

View File

@ -32,20 +32,13 @@
#ifndef CSV_WRITER
#define CSV_WRITER
#define CP_UTF16 1200
#define CP_unicodeFFFE 1201
#ifndef CP_UTF8
#define CP_UTF8 65001
#endif
#include "../../DesktopEditor/common/File.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
namespace CSVWriter
{
void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, std::wstring &sWriteString, UINT &nCodePage, bool bIsEnd = false);
void WriteFromXlsxToCsv(const std::wstring &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter, bool bJSON);
void WriteFile(NSFile::CFileBinary *pFile, WCHAR **pWriteBuffer, INT &nCurrentIndex, const std::wstring &sWriteString, UINT &nCodePage, bool bIsEnd = false);
void WriteFromXlsxToCsv(const std::wstring &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const std::wstring& wcDelimiter, bool bJSON);
}
#endif //CSV_WRITER