Compare commits

...

11 Commits

28 changed files with 1414 additions and 979 deletions

View File

@ -303,14 +303,14 @@ void odf_text_context::start_element(office_element_ptr & elm, office_element_pt
text_elements_list_.push_back(state);
if (!current_level_.empty())
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(elm);
current_level_.push_back(state);
}
void odf_text_context::end_element()
{
if (single_paragraph_ == false && !current_level_.empty())
if (single_paragraph_ == false && false == current_level_.empty())
{
current_level_.pop_back();
}
@ -349,7 +349,7 @@ void odf_text_context::start_span(bool styled)
if (style_)
{
if (parent_span_style_.length() >0)
if (false == parent_span_style_.empty())
{
style_->style_parent_style_name_ = parent_span_style_;
}
@ -371,7 +371,7 @@ void odf_text_context::end_span()
{
if (styles_context_ == NULL || single_paragraph_)return;
if (current_level_.size() > 0)
if (false == current_level_.empty())
current_level_.pop_back();
text_properties_ = NULL;
@ -396,7 +396,7 @@ void odf_text_context::start_list_item()
text_elements_list_.push_back(state);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(list_elm);
current_level_.push_back(state);
@ -410,14 +410,14 @@ void odf_text_context::end_list_item()
if (list_state_.levels.back() == false) return;
if (current_level_.size() > 0)
if (false == current_level_.empty())
current_level_.pop_back();
list_state_.levels.back() = false;
}
void odf_text_context::start_list(std::wstring style_name) //todoooo add new_numbering ???
bool odf_text_context::start_list(std::wstring style_name) //todoooo add new_numbering ???
{
if (styles_context_ == NULL || single_paragraph_)return;
if (styles_context_ == NULL || single_paragraph_)return false;
office_element_ptr list_elm;
create_element(L"text", L"list", list_elm, odf_context_);
@ -427,7 +427,7 @@ void odf_text_context::start_list(std::wstring style_name) //todoooo add new_num
office_element_ptr style_elm;
odf_element_state state = { list_elm, style_name, style_elm, level};
if (style_name.length() > 0)
if (false == style_name.empty())
{
text_list* list = dynamic_cast<text_list*>(list_elm.get());
if (list)
@ -443,13 +443,15 @@ void odf_text_context::start_list(std::wstring style_name) //todoooo add new_num
}
text_elements_list_.push_back(state);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(list_elm);
current_level_.push_back(state);
list_state_.levels.push_back(false);
list_state_.started_list = true;
return true;
}
void odf_text_context::end_list()
{
@ -574,7 +576,7 @@ void odf_text_context::add_hyperlink (std::wstring ref, std::wstring display_tex
hyperlink->common_xlink_attlist_.href_ = ref;
hyperlink->common_xlink_attlist_.type_ = xlink_type::Simple;
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(elm);
}
@ -657,7 +659,7 @@ bool odf_text_context::set_type_break(int type, int clear)//todooo clear ???
office_element_ptr elm;
create_element(L"text", L"line-break", elm, odf_context_);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(elm);
}
return need_restart;

View File

@ -107,7 +107,7 @@ public:
void start_list_item ();
void end_list_item ();
void start_list (std::wstring style_name);
bool start_list (std::wstring style_name);
void end_list ();
bool is_need_break (){return bool(need_break_);}

View File

@ -1060,47 +1060,46 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
if (col2 - col1 > 0)moving_type = 1;
}
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
shared_formulas_.push_back(state);
shared_formulas_.insert(std::make_pair((unsigned int)ind, state));
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
else
{
for (size_t i = 0; i < shared_formulas_.size() ;i++)
std::map<unsigned int, ods_shared_formula_state>::iterator pFind = shared_formulas_.find(ind);
if (pFind != shared_formulas_.end())
{
if (shared_formulas_[i].index == ind)
{
odf_formula = shared_formulas_[i].formula;
odf_formula = pFind->second.formula;
//поменять по ref формулу !!!
if (shared_formulas_[i].moving_type == 1)
{
tmp_column_ = shared_formulas_[i].base_column;
tmp_row_ = shared_formulas_[i].base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_column,
boost::match_default | boost::format_all);
odf_formula = res;
}
if (shared_formulas_[i].moving_type == 2)
{
tmp_column_ = shared_formulas_[i].base_column;
tmp_row_ = shared_formulas_[i].base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_row,
boost::match_default | boost::format_all);
odf_formula = res;
}
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
//поменять по ref формулу !!!
if (pFind->second.moving_type == 1)
{
tmp_column_ = pFind->second.base_column;
tmp_row_ = pFind->second.base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_column,
boost::match_default | boost::format_all);
odf_formula = res;
}
else if (pFind->second.moving_type == 2)
{
tmp_column_ = pFind->second.base_column;
tmp_row_ = pFind->second.base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_row,
boost::match_default | boost::format_all);
odf_formula = res;
}
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
}
}

View File

@ -453,8 +453,8 @@ private:
std::vector<ods_cell_state> cells_;
long cells_size_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::vector<ods_shared_formula_state> shared_formulas_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::map<unsigned int, ods_shared_formula_state> shared_formulas_;
std::vector<table_part_state> table_parts_;

View File

@ -1052,19 +1052,22 @@ void odt_conversion_context::start_list_item(int level, std::wstring style_name
if (text_context()->list_state_.started_list == false)
{
text_context()->start_list(style_name);
//text_context()->set_list_continue(true); //??? держать в памяти все списки????
add_to_root();
if (text_context()->start_list(style_name))
{
//text_context()->set_list_continue(true); //??? держать в памяти все списки????
add_to_root();
}
}
text_context()->start_list_item();
text_context()->start_list_item();
if (text_context()->list_state_.style_name == style_name)
style_name = L"";
while (text_context()->list_state_.levels.size() < level)
{
text_context()->start_list(style_name);
if (false == text_context()->start_list(style_name))
break;
text_context()->start_list_item();
}
}
@ -1076,7 +1079,7 @@ void odt_conversion_context::set_no_list()
{
if (text_context()->list_state_.started_list == false) return;
while (text_context()->list_state_.levels.size()>0)
while (false == text_context()->list_state_.levels.empty())
{
text_context()->end_list_item();
text_context()->end_list();
@ -1205,16 +1208,16 @@ void odt_conversion_context::end_comment_content()
}
void odt_conversion_context::end_comment(int oox_comm_id)
{
bool added = comment_context_.find_by_id(oox_comm_id);
int index_added = comment_context_.find_by_id(oox_comm_id);
if (added == true)
if (index_added > 0 )
{
office_element_ptr comm_elm;
create_element(L"office", L"annotation-end", comm_elm, this);
comment_context_.end_comment(comm_elm, oox_comm_id);
if (text_context()->current_level_.size() > 0)
if (false == text_context()->current_level_.empty())
text_context()->current_level_.back().elm->add_child_element(comm_elm);
}
}

View File

@ -1854,7 +1854,10 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
{
while ((int)odf_context()->text_context()->list_state_.levels.size() < list_level)
{
odf_context()->text_context()->start_list(list_style_name);
if (false == odf_context()->text_context()->start_list(list_style_name))
{
break;
}
odf_context()->text_context()->start_list_item();
if (odf_context()->text_context()->list_state_.style_name == list_style_name)

View File

@ -966,6 +966,11 @@ namespace NSBinPptxRW
_WriteStringWithLength(s->c_str(), (_UINT32)s->length(), false);
}
void CBinaryFileWriter::WriteStringData(const WCHAR* pData, _UINT32 len)
{
_WriteStringWithLength(pData, len, false);
}
void CBinaryFileWriter::WriteString1Data(int type, const WCHAR* pData, _UINT32 len)
{
BYTE bType = (BYTE)type;
@ -1129,7 +1134,16 @@ namespace NSBinPptxRW
}
void CBinaryFileWriter::_WriteStringWithLength(const WCHAR* sBuffer, _UINT32 lCount, bool bByte)
{
CheckBufferSize(UINT32_SIZEOF);
if (sizeof(wchar_t) == 4)
{
_INT32 lSizeMemMax = 4 * lCount + 2;//2 - for null terminator
CheckBufferSize(UINT32_SIZEOF + lSizeMemMax);
}
else
{
_INT32 lSizeMem = 2 * lCount;
CheckBufferSize(UINT32_SIZEOF + lSizeMem);
}
//skip size
m_lPosition += UINT32_SIZEOF;
m_pStreamCur += UINT32_SIZEOF;
@ -1177,7 +1191,7 @@ namespace NSBinPptxRW
}
}
}
_UINT32 CStreamBinaryWriter::GetPosition()
_UINT32 CStreamBinaryWriter::GetPositionAbsolute()
{
return m_lPosition + m_lPositionFlushed;
}

View File

@ -329,6 +329,7 @@ namespace NSBinPptxRW
void WriteString1 (int type, const std::wstring& val);
void WriteString2 (int type, const NSCommon::nullable_string& val);
void WriteString (const std::wstring& val);
void WriteStringData(const WCHAR* pData, _UINT32 len);
void WriteString1Data(int type, const WCHAR* pData, _UINT32 len);
@ -416,7 +417,7 @@ namespace NSBinPptxRW
CStreamBinaryWriter(size_t bufferSize = 16777216);
void CheckBufferSize(_UINT32 lPlus);
_UINT32 GetPosition();
_UINT32 GetPositionAbsolute();
void CloseFile();
virtual void Flush();
};

View File

@ -212,7 +212,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
count = proc.repeated<BIGNAME>(0, 0);
while(count > 0)
{
m_arBIGNAME.insert(m_arNote.begin(), elements_.back());
m_arBIGNAME.insert(m_arBIGNAME.begin(), elements_.back());
elements_.pop_back();
count--;
}

View File

@ -333,7 +333,6 @@ namespace ComplexTypes
return sResult;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
@ -693,8 +692,6 @@ namespace ComplexTypes
return sResult;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты

View File

@ -42,6 +42,7 @@
#include "Pict.h"
#include "Annotations.h"
#include "AlternateContent.h"
#include "../../../../../DesktopEditor/common/StringExt.h"
namespace OOX
{
@ -215,100 +216,158 @@ namespace OOX
if ( oReader.IsEmptyNode() )
return;
fromXMLElems(oReader);
}
void fromXMLElems(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
WritingElement *pItem = NULL;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
WritingElement *pItem = NULL;
if ( _T("mc:AlternateContent") == sName )
pItem = new CAlternateContent( oReader );
else if ( _T("w:annotationRef") == sName )
pItem = new CAnnotationRef( oReader );
else if ( _T("w:br") == sName )
pItem = new CBr( oReader );
else if ( _T("w:commentReference") == sName )
pItem = new CCommentReference( oReader );
else if ( _T("w:contentPart") == sName )
pItem = new CContentPart( oReader );
else if ( _T("w:continuationSeparator") == sName )
pItem = new CContinuationSeparator( oReader );
else if ( _T("w:cr") == sName )
pItem = new CCr( oReader );
else if ( _T("w:dayLong") == sName )
pItem = new CDayLong( oReader );
else if ( _T("w:dayShort") == sName )
pItem = new CDayShort( oReader );
else if ( _T("w:delInstrText") == sName )
pItem = new CDelInstrText( oReader );
else if ( _T("w:delText") == sName )
pItem = new CDelText( oReader );
else if ( _T("w:drawing") == sName )
pItem = new CDrawing( oReader );
else if ( _T("w:endnoteRef") == sName )
pItem = new CEndnoteRef( oReader );
else if ( _T("w:endnoteReference") == sName )
pItem = new CEndnoteReference( oReader );
else if ( _T("w:fldChar") == sName )
pItem = new CFldChar( oReader );
else if ( _T("w:footnoteRef") == sName )
pItem = new CFootnoteRef( oReader );
else if ( _T("w:footnoteReference") == sName )
pItem = new CFootnoteReference( oReader );
else if ( _T("w:instrText") == sName )
pItem = new CInstrText( oReader );
else if ( _T("w:lastRenderedPageBreak") == sName )
pItem = new CLastRenderedPageBreak( oReader );
else if ( _T("w:monthLong") == sName )
pItem = new CMonthLong( oReader );
else if ( _T("w:monthShort") == sName )
pItem = new CMonthShort( oReader );
else if ( _T("w:noBreakHyphen") == sName )
pItem = new CNoBreakHyphen( oReader );
else if ( _T("w:object") == sName )
pItem = new CObject( oReader );
else if ( _T("w:pgNum") == sName )
pItem = new CPgNum( oReader );
else if ( _T("w:pict") == sName )
pItem = new CPicture( oReader );
else if ( _T("w:ptab") == sName )
pItem = new CPTab( oReader );
else if ( _T("w:rPr") == sName )
{
if (m_oRunProperty)
{
CRunProperty prop2(oReader);
CRunProperty newProp = CRunProperty::Merge(*m_oRunProperty, prop2);
pItem = m_oRunProperty = new CRunProperty(newProp);
}
else
{
pItem = m_oRunProperty = new CRunProperty( oReader );
}
}
else if ( _T("w:ruby") == sName )
pItem = new CRuby( oReader );
else if ( _T("w:separator") == sName )
pItem = new CSeparator( oReader );
else if ( _T("w:softHyphen") == sName )
pItem = new CSoftHyphen( oReader );
else if ( _T("w:sym") == sName )
pItem = new CSym( oReader );
else if ( _T("w:t") == sName )
pItem = new CText( oReader );
else if ( _T("w:tab") == sName )
pItem = new CTab( oReader );
else if ( _T("w:yearLong") == sName )
pItem = new CYearLong( oReader );
pItem = fromXMLElem(oReader);
if ( pItem )
m_arrItems.push_back( pItem );
}
if ((m_oRunProperty) && (m_oRunProperty->m_pText))
}
WritingElement* fromXMLElem(XmlUtils::CXmlLiteReader& oReader)
{
std::wstring sName = oReader.GetName();
WritingElement *pItem = NULL;
if ( _T("mc:AlternateContent") == sName )
pItem = new CAlternateContent( oReader );
else if ( _T("w:annotationRef") == sName )
pItem = new CAnnotationRef( oReader );
else if ( _T("w:br") == sName )
pItem = new CBr( oReader );
else if ( _T("w:commentReference") == sName )
pItem = new CCommentReference( oReader );
else if ( _T("w:contentPart") == sName )
pItem = new CContentPart( oReader );
else if ( _T("w:continuationSeparator") == sName )
pItem = new CContinuationSeparator( oReader );
else if ( _T("w:cr") == sName )
pItem = new CCr( oReader );
else if ( _T("w:dayLong") == sName )
pItem = new CDayLong( oReader );
else if ( _T("w:dayShort") == sName )
pItem = new CDayShort( oReader );
else if ( _T("w:delInstrText") == sName )
pItem = new CDelInstrText( oReader );
else if ( _T("w:delText") == sName )
pItem = new CDelText( oReader );
else if ( _T("w:drawing") == sName )
pItem = new CDrawing( oReader );
else if ( _T("w:endnoteRef") == sName )
pItem = new CEndnoteRef( oReader );
else if ( _T("w:endnoteReference") == sName )
pItem = new CEndnoteReference( oReader );
else if ( _T("w:fldChar") == sName )
pItem = new CFldChar( oReader );
else if ( _T("w:footnoteRef") == sName )
pItem = new CFootnoteRef( oReader );
else if ( _T("w:footnoteReference") == sName )
pItem = new CFootnoteReference( oReader );
else if ( _T("w:instrText") == sName )
pItem = new CInstrText( oReader );
else if ( _T("w:lastRenderedPageBreak") == sName )
pItem = new CLastRenderedPageBreak( oReader );
else if ( _T("w:monthLong") == sName )
pItem = new CMonthLong( oReader );
else if ( _T("w:monthShort") == sName )
pItem = new CMonthShort( oReader );
else if ( _T("w:noBreakHyphen") == sName )
pItem = new CNoBreakHyphen( oReader );
else if ( _T("w:object") == sName )
pItem = new CObject( oReader );
else if ( _T("w:pgNum") == sName )
pItem = new CPgNum( oReader );
else if ( _T("w:pict") == sName )
pItem = new CPicture( oReader );
else if ( _T("w:ptab") == sName )
pItem = new CPTab( oReader );
else if ( _T("w:rPr") == sName )
{
m_arrItems.push_back( m_oRunProperty->m_pText);
m_oRunProperty->m_pText = NULL;
if (m_oRunProperty)
{
CRunProperty prop2;
prop2.fromXML(oReader, this);
CRunProperty newProp = CRunProperty::Merge(*m_oRunProperty, prop2);
pItem = m_oRunProperty = new CRunProperty(newProp);
}
else
{
pItem = m_oRunProperty = new CRunProperty();
m_oRunProperty->fromXML(oReader, this);
}
}
else if ( _T("w:ruby") == sName )
pItem = new CRuby( oReader );
else if ( _T("w:separator") == sName )
pItem = new CSeparator( oReader );
else if ( _T("w:softHyphen") == sName )
pItem = new CSoftHyphen( oReader );
else if ( _T("w:sym") == sName )
pItem = new CSym( oReader );
else if ( _T("w:t") == sName )
{
fromXMLText(oReader);
}
else if ( _T("w:tab") == sName )
pItem = new CTab( oReader );
else if ( _T("w:yearLong") == sName )
pItem = new CYearLong( oReader );
return pItem;
}
void fromXMLText(XmlUtils::CXmlLiteReader& oReader)
{
//for <w:t>6<w:cr/>6</w:t>
nullable<SimpleTypes::CXmlSpace<> > oSpace;
CText::ReadAttributes(oReader, oSpace);
if ( oReader.IsEmptyNode() )
return;
bool bTrimLeft, bTrimRight;
bTrimLeft = bTrimRight = !(oSpace.IsInit() && SimpleTypes::xmlspacePreserve == oSpace->GetValue());
CText* pTextLast = NULL;
int nDepth = oReader.GetDepth();
XmlUtils::XmlNodeType eNodeType = XmlUtils::XmlNodeType_EndElement;
while (oReader.Read(eNodeType) && oReader.GetDepth() >= nDepth && XmlUtils::XmlNodeType_EndElement != eNodeType)
{
if (eNodeType == XmlUtils::XmlNodeType_Text || eNodeType == XmlUtils::XmlNodeType_Whitespace || eNodeType == XmlUtils::XmlNodeType_SIGNIFICANT_WHITESPACE)
{
const char* pValue = oReader.GetTextChar();
if(bTrimLeft)
{
bTrimLeft = false;
pValue += NSStringExt::FindFirstNotOfA(pValue, " \n\r\t");
}
if('\0' != pValue[0])
{
pTextLast = new CText();
NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pValue, strlen(pValue), pTextLast->m_sText);
m_arrItems.push_back( pTextLast );
}
}
else if (eNodeType == XmlUtils::XmlNodeType_Element)
{
WritingElement *pItem = fromXMLElem(oReader);
if ( pItem )
m_arrItems.push_back( pItem );
bTrimLeft = false;
pTextLast = NULL;
}
}
if(bTrimRight && pTextLast)
{
NSStringExt::RTrim(pTextLast->m_sText, L" \n\r\t");
}
}
virtual std::wstring toXML() const

View File

@ -810,9 +810,7 @@ namespace OOX
{
return et_w_t;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
static void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable<SimpleTypes::CXmlSpace<> >& oSpace)
{
if ( oReader.GetAttributesCount() <= 0 )
return;
@ -825,7 +823,7 @@ namespace OOX
{
if ( _T("xml:space") == wsName )
{
m_oSpace = oReader.GetText();
oSpace = oReader.GetText();
break;
}
@ -837,6 +835,12 @@ namespace OOX
oReader.MoveToElement();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader, m_oSpace);
}
public:

View File

@ -31,6 +31,21 @@
*/
#include "RunProperty.h"
#include "RunContent.h"
#include "Run.h"
#define FROM_XML_ELEM(oElem, oReader, pRun) \
{ \
oElem.Init(); \
if(pRun) \
{ \
oElem->ReadAttributes(oReader); \
pRun->fromXMLElems(oReader); \
} \
else \
{ \
oElem->FromXML(oReader); \
} \
}
namespace OOX
{
@ -153,50 +168,35 @@ namespace OOX
void CRunProperty::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
fromXML(oReader, NULL);
}
void CRunProperty::fromXML(XmlUtils::CXmlLiteReader& oReader, CRun* pRun)
{
//pRun for Run object -> XpertdocOnlineDemoEn.docx
if ( oReader.IsEmptyNode() )
return;
int nParentDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth ) )
{
std::wstring sName = oReader.GetName();
WritingElement *pItem = NULL;
std::wstring sName = oReader.GetName();
if ( _T("w:b") == sName )
m_oBold = oReader;
FROM_XML_ELEM(m_oBold, oReader, pRun)
else if ( _T("w:bCs") == sName )
{
if (!oReader.IsEmptyNode())
{
m_oBoldCs.Init();
int nParentDepth1 = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nParentDepth1 ) )
{
std::wstring sName1 = oReader.GetName();
if ( _T("w:t") == sName1 )
{
m_pText = new CText( oReader );
break;
}
}
}
else
m_oBoldCs = oReader;
}
FROM_XML_ELEM(m_oBoldCs, oReader, pRun)
else if ( _T("w:bdr") == sName )
m_oBdr = oReader;
else if ( _T("w:caps") == sName )
m_oCaps = oReader;
FROM_XML_ELEM(m_oCaps, oReader, pRun)
else if ( _T("w:color") == sName )
m_oColor = oReader;
else if ( _T("w:cs") == sName )
m_oCs = oReader;
FROM_XML_ELEM(m_oCs, oReader, pRun)
else if ( _T("w:del") == sName )
m_oDel = oReader;
else if ( _T("w:dstrike") == sName )
m_oDStrike = oReader;
FROM_XML_ELEM(m_oDStrike, oReader, pRun)
else if ( _T("w:eastAsianLayout") == sName )
m_oEastAsianLayout = oReader;
else if ( _T("w:effect") == sName )
@ -204,7 +204,7 @@ namespace OOX
else if ( _T("w:em") == sName )
m_oEm = oReader;
else if ( _T("w:emboss") == sName )
m_oEmboss = oReader;
FROM_XML_ELEM(m_oEmboss, oReader, pRun)
else if ( _T("w:fitText") == sName )
m_oFitText = oReader;
else if ( _T("w:highlight") == sName )
@ -212,25 +212,25 @@ namespace OOX
else if ( _T("w:ins") == sName )
m_oIns = oReader;
else if ( _T("w:i") == sName )
m_oItalic = oReader;
FROM_XML_ELEM(m_oItalic, oReader, pRun)
else if ( _T("w:iCs") == sName )
m_oItalicCs = oReader;
FROM_XML_ELEM(m_oItalicCs, oReader, pRun)
else if ( _T("w:imprint") == sName )
m_oImprint = oReader;
FROM_XML_ELEM(m_oImprint, oReader, pRun)
else if ( _T("w:kern") == sName )
m_oKern = oReader;
else if ( _T("w:lang") == sName )
m_oLang = oReader;
FROM_XML_ELEM(m_oLang, oReader, pRun)
else if ( _T("w:noProof") == sName )
m_oNoProof = oReader;
FROM_XML_ELEM(m_oNoProof, oReader, pRun)
else if ( _T("m:oMath") == sName )
m_oMath = oReader;
FROM_XML_ELEM(m_oMath, oReader, pRun)
else if ( _T("w:moveFrom") == sName )
m_oMoveFrom = oReader;
else if ( _T("w:moveTo") == sName )
m_oMoveTo = oReader;
else if ( _T("w:outline") == sName )
m_oOutline = oReader;
FROM_XML_ELEM(m_oOutline, oReader, pRun)
else if ( _T("w:position") == sName )
m_oPosition = oReader;
else if ( _T("w:rFonts") == sName )
@ -244,21 +244,21 @@ namespace OOX
else if ( !m_oRStyle.IsInit() && _T("w:pStyle") == sName )
m_oRStyle = oReader;
else if ( _T("w:rtl") == sName )
m_oRtL = oReader;
FROM_XML_ELEM(m_oRtL, oReader, pRun)
else if ( _T("w:shadow") == sName )
m_oShadow = oReader;
FROM_XML_ELEM(m_oShadow, oReader, pRun)
else if ( _T("w:shd") == sName )
m_oShd = oReader;
else if ( _T("w:smallCaps") == sName )
m_oSmallCaps = oReader;
FROM_XML_ELEM(m_oSmallCaps, oReader, pRun)
else if ( _T("w:snapToGrid") == sName )
m_oSnapToGrid = oReader;
FROM_XML_ELEM(m_oSnapToGrid, oReader, pRun)
else if ( _T("w:spacing") == sName )
m_oSpacing = oReader;
else if ( _T("w:specVanish") == sName )
m_oSpecVanish = oReader;
FROM_XML_ELEM(m_oSpecVanish, oReader, pRun)
else if ( _T("w:strike") == sName )
m_oStrike = oReader;
FROM_XML_ELEM(m_oStrike, oReader, pRun)
else if ( _T("w:sz") == sName )
m_oSz = oReader;
else if ( _T("w:szCs") == sName )
@ -266,13 +266,13 @@ namespace OOX
else if ( _T("w:u") == sName )
m_oU = oReader;
else if ( _T("w:vanish") == sName )
m_oVanish = oReader;
FROM_XML_ELEM(m_oVanish, oReader, pRun)
else if ( _T("w:vertAlign") == sName )
m_oVertAlign = oReader;
else if ( _T("w:w") == sName )
m_oW = oReader;
else if ( _T("w:webHidden") == sName )
m_oWebHidden = oReader;
FROM_XML_ELEM(m_oWebHidden, oReader, pRun)
else if (_T("w14:textOutline") == sName)
m_oTextOutline = oReader;
else if (_T("w14:textFill") == sName)

View File

@ -702,6 +702,7 @@ namespace OOX
{
namespace Logic
{
class CRun;
class CRunProperty;
//--------------------------------------------------------------------------------
@ -770,6 +771,7 @@ namespace OOX
virtual void fromXML(XmlUtils::CXmlNode& oNode);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void fromXML(XmlUtils::CXmlLiteReader& oReader, CRun* pRun);
virtual std::wstring toXML() const
{
std::wstring sResult = _T("<w:rPr>");

View File

@ -106,16 +106,25 @@ namespace OOX
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx) xlsx->m_pCalcChain = this;
if (xlsx && xlsx->m_bNeedCalcChain) xlsx->m_pCalcChain = this;
}
CCalcChain(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx) xlsx->m_pCalcChain = this;
read( oRootPath, oPath );
if (xlsx)
{
if(xlsx->m_bNeedCalcChain)
{
xlsx->m_pCalcChain = this;
read( oRootPath, oPath );
}
}
else
{
read( oRootPath, oPath );
}
}
virtual ~CCalcChain()
{

View File

@ -35,18 +35,65 @@ namespace OOX
{
namespace Spreadsheet
{
void CText::fromXMLToXLSB(XmlUtils::CXmlLiteReader& oReader, SimpleTypes::Spreadsheet::ECellTypeType eType, _UINT16& nType, double& dValue, unsigned int& nValue, BYTE& bValue, std::wstring** psValue, bool& bForceFormula)
CStringXLSB::CStringXLSB(_UINT32 nSize)
{
SimpleTypes::EXmlSpace eSpace = SimpleTypes::xmlspaceDefault;
ReadAttributesToXLSB( oReader, eSpace );
m_nSize = nSize;
m_sBuffer = new WCHAR[m_nSize];
Clean();
}
CStringXLSB::~CStringXLSB()
{
RELEASEARRAYOBJECTS(m_sBuffer);
}
void CStringXLSB::Clean()
{
m_nLen = 0;
}
void CStringXLSB::fromXML(XmlUtils::CXmlLiteReader& oReader, bool bPreserve)
{
oReader.GetTextWithHHHH(bPreserve, m_sBuffer, m_nSize, m_nLen);
}
void CStringXLSB::fromStringA(const char* sVal)
{
LONG nLen = strlen((const char*)sVal);
checkBufferSize(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8BufferSize(nLen));
NSFile::CUtf8Converter::GetUnicodeStringFromUTF8WithHHHH((const BYTE*)sVal, nLen, m_sBuffer, m_nLen);
}
void CStringXLSB::checkBufferSize(_UINT32 nRequired)
{
if(nRequired > m_nSize)
{
while(nRequired > m_nSize)
{
m_nSize *= 2;
}
RELEASEOBJECT(m_sBuffer);
m_sBuffer = new WCHAR[m_nSize];
}
}
CTextXLSB::CTextXLSB(_UINT32 nSize):m_oValue(nSize)
{
Clean();
}
void CTextXLSB::Clean()
{
m_bIsInit = false;
m_oSpace.SetValue(SimpleTypes::xmlspaceDefault);
m_dValue = 0;
m_nValue = 0;
m_oValue.Clean();
}
void CTextXLSB::fromXML(XmlUtils::CXmlLiteReader& oReader, SimpleTypes::Spreadsheet::ECellTypeType eType)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
if(SimpleTypes::Spreadsheet::celltypeStr == eType || SimpleTypes::Spreadsheet::celltypeInlineStr == eType)
{
std::string sVal = oReader.GetText2A();
fromXMLToXLSB(sVal.c_str(), eSpace, eType, nType, dValue, nValue, bValue, psValue, bForceFormula);
m_bIsInit = true;
m_oValue.fromXML(oReader, SimpleTypes::xmlspacePreserve == m_oSpace.GetValue());
}
else
{
@ -56,114 +103,86 @@ namespace OOX
{
if (eNodeType == XmlUtils::XmlNodeType_Text)
{
fromXMLToXLSB(oReader.GetTextChar(), eSpace, eType, nType, dValue, nValue, bValue, psValue, bForceFormula);
const char* pVal = oReader.GetTextChar();
if(pVal[0] == '\0')
continue;
m_bIsInit = true;
if(SimpleTypes::Spreadsheet::celltypeNumber == eType)
{
//todo RkNumber
try
{
m_dValue = atof(pVal);
}
catch(...)
{ //1.3912059045063478e-310
//Lighting Load Calculation.xls
}
}
else if(SimpleTypes::Spreadsheet::celltypeSharedString == eType)
{
try
{
m_nValue = atoi(pVal);
}
catch(...)
{
}
}
else if(SimpleTypes::Spreadsheet::celltypeError == eType)
{
if(strcmp("#NULL!", pVal) == 0)
{
m_nValue = 0x00;
}
else if(strcmp("#DIV/0!", pVal) == 0)
{
m_nValue = 0x07;
}
else if(strcmp("#VALUE!", pVal) == 0)
{
m_nValue = 0x0F;
}
else if(strcmp("#REF!", pVal) == 0)
{
m_nValue = 0x17;
}
else if(strcmp("#NAME?", pVal) == 0)
{
m_nValue = 0x1D;
}
else if(strcmp("#NUM!", pVal) == 0)
{
m_nValue = 0x24;
}
else if(strcmp("#N/A", pVal) == 0)
{
m_nValue = 0x2A;
}
else if(strcmp("#GETTING_DATA", pVal) == 0)
{
m_nValue = 0x2B;
}
}
else if(SimpleTypes::Spreadsheet::celltypeBool == eType)
{
SimpleTypes::COnOff<> oOnOff;
oOnOff.FromStringA(pVal);
m_nValue = oOnOff.ToBool() ? 1 : 0;
}
}
}
}
}
void CText::fromXMLToXLSB(const char* pVal, SimpleTypes::EXmlSpace eSpace, SimpleTypes::Spreadsheet::ECellTypeType eType, _UINT16& nType, double& dValue, unsigned int& nValue, BYTE& bValue, std::wstring** psValue, bool& bForceFormula)
{
if(pVal[0] == '\0')
return;
if(SimpleTypes::Spreadsheet::celltypeNumber == eType)
{
//todo RkNumber
nType = XLSB::rt_CELL_REAL;
try
{
dValue = atof(pVal);
}
catch(...)
{ //1.3912059045063478e-310
//Lighting Load Calculation.xls
}
}
else if(SimpleTypes::Spreadsheet::celltypeSharedString == eType)
{
nType = XLSB::rt_CELL_ISST;
try
{
nValue = atoi(pVal);
}
catch(...)
{
}
}
else if(SimpleTypes::Spreadsheet::celltypeError == eType)
{
nType = XLSB::rt_CELL_ERROR;
if(strcmp("#NULL!", pVal) == 0)
{
bValue = 0x00;
}
else if(strcmp("#DIV/0!", pVal) == 0)
{
bValue = 0x07;
}
else if(strcmp("#VALUE!", pVal) == 0)
{
bValue = 0x0F;
}
else if(strcmp("#REF!", pVal) == 0)
{
bValue = 0x17;
}
else if(strcmp("#NAME?", pVal) == 0)
{
bValue = 0x1D;
}
else if(strcmp("#NUM!", pVal) == 0)
{
bValue = 0x24;
}
else if(strcmp("#N/A", pVal) == 0)
{
bValue = 0x2A;
}
else if(strcmp("#GETTING_DATA", pVal) == 0)
{
bValue = 0x2B;
}
}
else if(SimpleTypes::Spreadsheet::celltypeBool == eType)
{
nType = XLSB::rt_CELL_BOOL;
SimpleTypes::COnOff<> oOnOff;
oOnOff.FromStringA(pVal);
bValue = oOnOff.ToBool() ? 1 : 0;
}
else if(SimpleTypes::Spreadsheet::celltypeInlineStr == eType)
{
nType = XLSB::rt_CELL_ST;
if(NULL == (*psValue))
{
(*psValue) = new std::wstring();
}
(*psValue)->append(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pVal, (LONG)strlen(pVal)));
trimString(**psValue, eSpace);
}
else if(SimpleTypes::Spreadsheet::celltypeStr == eType)
{
bForceFormula = true;
nType = XLSB::rt_CELL_ST;
if(NULL == (*psValue))
{
(*psValue) = new std::wstring();
}
(*psValue)->append(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pVal, (LONG)strlen(pVal)));
trimString(**psValue, eSpace);
}
}
void CText::ReadAttributesToXLSB(XmlUtils::CXmlLiteReader& oReader, SimpleTypes::EXmlSpace& eSpace)
void CTextXLSB::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_StartChar( oReader )
if ( strcmp("space", wsName) == 0 )
{
SimpleTypes::CXmlSpace<> oSpace;
oSpace.FromStringA(oReader.GetTextChar());
eSpace = oSpace.GetValue();
break;
}
if ( strcmp("xml:space", wsName) == 0 )
{
m_oSpace.FromStringA(oReader.GetTextChar());
break;
}
WritingElement_ReadAttributes_EndChar( oReader )
}

View File

@ -40,6 +40,36 @@ namespace OOX
{
namespace Spreadsheet
{
class CStringXLSB
{
public:
CStringXLSB(_UINT32 nSize);
~CStringXLSB();
void Clean();
void fromXML(XmlUtils::CXmlLiteReader& oReader, bool bPreserve);
void fromStringA(const char* sVal);
public:
WCHAR* m_sBuffer;
LONG m_nSize;
LONG m_nLen;
protected:
void checkBufferSize(_UINT32 nRequired);
};
class CTextXLSB
{
public:
CTextXLSB(_UINT32 nSize);
void Clean();
void fromXML(XmlUtils::CXmlLiteReader& oReader, SimpleTypes::Spreadsheet::ECellTypeType eType);
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
public:
bool m_bIsInit;
SimpleTypes::CXmlSpace<> m_oSpace;
double m_dValue;
_UINT32 m_nValue;
CStringXLSB m_oValue;
};
//необработано:
class CText : public WritingElement
{
@ -100,9 +130,6 @@ namespace OOX
trimString(m_sText, GetSpace());
}
static void fromXMLToXLSB(XmlUtils::CXmlLiteReader& oReader, SimpleTypes::Spreadsheet::ECellTypeType eType, _UINT16& nType, double& dValue, unsigned int& nValue, BYTE& bValue, std::wstring** psValue, bool& bForceFormula);
static void fromXMLToXLSB(const char* pVal, SimpleTypes::EXmlSpace eSpace, SimpleTypes::Spreadsheet::ECellTypeType eType, _UINT16& nType, double& dValue, unsigned int& nValue, BYTE& bValue, std::wstring** psValue, bool& bForceFormula);
static void trimString(std::wstring& sVal, SimpleTypes::EXmlSpace eSpace);
std::wstring ToString() const
{
@ -140,7 +167,6 @@ namespace OOX
oReader.MoveToElement();
}
static void ReadAttributesToXLSB(XmlUtils::CXmlLiteReader& oReader, SimpleTypes::EXmlSpace& eSpace);
public:

View File

@ -1443,6 +1443,20 @@ namespace SimpleTypes
this->m_eValue = eDefValue;
return this->m_eValue;
}
ECellFormulaType FromStringA(const char* sValue)
{
if(strcmp("array", sValue) == 0)
this->m_eValue = cellformulatypeArray;
else if(strcmp("dataTable", sValue) == 0)
this->m_eValue = cellformulatypeDataTable;
else if(strcmp("normal", sValue) == 0)
this->m_eValue = cellformulatypeNormal;
else if(strcmp("shared", sValue) == 0)
this->m_eValue = cellformulatypeShared;
else
this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual std::wstring ToString () const
{

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,76 @@ namespace OOX
{
namespace Spreadsheet
{
class CFormulaXLSB
{
public:
CFormulaXLSB();
void Clean();
void fromXML(XmlUtils::CXmlLiteReader& oReader);
_UINT32 getXLSBSize() const;
_UINT16 toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream);
void toXLSBExt(NSBinPptxRW::CXlsbBinaryWriter& oStream);
public:
bool m_bIsInit;
CStringXLSB m_oFormula;
SimpleTypes::Spreadsheet::CCellFormulaType<SimpleTypes::Spreadsheet::cellformulatypeNormal> m_oT;
_INT32 m_nSi;
CStringXLSB m_oRef;
CStringXLSB m_oR1;
CStringXLSB m_oR2;
SimpleTypes::COnOff<> m_oAca;
SimpleTypes::COnOff<> m_oBx;
SimpleTypes::COnOff<> m_oCa;
SimpleTypes::COnOff<> m_oDel1;
SimpleTypes::COnOff<> m_oDel2;
SimpleTypes::COnOff<> m_oDt2D;
SimpleTypes::COnOff<> m_oDtr;
protected:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
};
class CCellXLSB
{
public:
CCellXLSB();
void Clean();
void fromXML(XmlUtils::CXmlLiteReader& oReader);
void toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream);
public:
_UINT32 m_nCol;
_UINT32 m_nStyle;
SimpleTypes::Spreadsheet::CCellTypeType<SimpleTypes::Spreadsheet::celltypeNumber> m_oType;
SimpleTypes::COnOff<> m_oShowPhonetic;
CTextXLSB m_oValue;
CFormulaXLSB m_oFormula;
nullable<CSi> m_oRichText;
protected:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
};
class CRowXLSB
{
public:
CRowXLSB();
void Clean();
void fromXMLToXLSB(XmlUtils::CXmlLiteReader& oReader, NSBinPptxRW::CXlsbBinaryWriter& oStream, CCellXLSB& oCell);
void toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream);
public:
_UINT32 m_nR;
_UINT32 m_nS;
SimpleTypes::COnOff<> m_oCustomFormat;
double m_dHt;
SimpleTypes::COnOff<> m_oHidden;
SimpleTypes::COnOff<> m_oCustomHeight;
BYTE m_nOutlineLevel;
SimpleTypes::COnOff<> m_oCollapsed;
SimpleTypes::COnOff<> m_oThickBot;
SimpleTypes::COnOff<> m_oThickTop;
SimpleTypes::COnOff<> m_oPh;
protected:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
};
class CFormula : public WritingElement
{
public:
@ -83,11 +153,7 @@ namespace OOX
m_sText = oReader.GetText3();
}
void fromXLSB (NSBinPptxRW::CBinaryFileReader& oStream);
_UINT16 toXLSB (NSBinPptxRW::CXlsbBinaryWriter& oStream);
void fromXLSBExt (NSBinPptxRW::CBinaryFileReader& oStream, _UINT16 nFlags);
void toXLSBExt (NSBinPptxRW::CXlsbBinaryWriter& oStream);
_UINT32 getXLSBSize() const;
virtual EElementType getType () const
{
return et_x_Formula;
@ -152,9 +218,7 @@ namespace OOX
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const;
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void fromXMLtoXLSB(XmlUtils::CXmlLiteReader& oReader, NSBinPptxRW::CXlsbBinaryWriter& oStream);
void fromXLSB (NSBinPptxRW::CBinaryFileReader& oStream, _UINT16 nType, _UINT32 nRow);
void toXLSB (NSBinPptxRW::CXlsbBinaryWriter& oStream) const;
virtual EElementType getType () const
{
@ -270,13 +334,11 @@ namespace OOX
}
static bool parseRef(std::wstring sRef, int& nRow, int& nCol);
static bool parseRefA(const char* sRef, int& nRow, int& nCol);
static bool parseRefColA(const char* sRef, int& nCol);
static bool parseRefColA(const char* sRef, _UINT32& nCol);
static std::wstring combineRef(int nRow, int nCol);
private:
void PrepareForBinaryWriter();
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader);
void ReadAttributesToXLSB(XmlUtils::CXmlLiteReader& oReader, int& nCol, unsigned int& nStyle, SimpleTypes::Spreadsheet::CCellTypeType<>& oType, bool& bShowPhonetic);
void toXLSB2 (NSBinPptxRW::CXlsbBinaryWriter& oStream, int nCol, unsigned int nStyle, bool bShowPhonetic, _UINT16 nType, double dValue, unsigned int nValue, BYTE bValue, std::wstring** psValue, bool bForceFormula, const nullable<CFormula>& oFormula, const nullable<CSi>& oRichText) const;
nullable<std::string> m_oRef;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRow;
@ -329,6 +391,7 @@ namespace OOX
void toXMLStart(NSStringUtils::CStringBuilder& writer) const;
void toXMLEnd(NSStringUtils::CStringBuilder& writer) const;
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void fromXMLToXLSB(XmlUtils::CXmlLiteReader& oReader, NSBinPptxRW::CXlsbBinaryWriter& oStream, CCellXLSB& oCell);
void fromXLSB (NSBinPptxRW::CBinaryFileReader& oStream, _UINT16 nType);
void toXLSB (NSBinPptxRW::CXlsbBinaryWriter& oStream) const;
virtual EElementType getType () const
@ -396,7 +459,6 @@ namespace OOX
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
void fromXLSB (NSBinPptxRW::CBinaryFileReader& oStream, _UINT16 nType, CSVWriter::CCSVWriter* pCSVWriter, NSFile::CStreamWriter& oStreamWriter);
void toXLSB (NSBinPptxRW::CXlsbBinaryWriter& oStream) const;
virtual EElementType getType () const
{
return et_x_SheetData;

View File

@ -102,6 +102,7 @@ namespace OOX
NSBinPptxRW::CXlsbBinaryWriter* m_pXlsbWriter;
int m_nLastReadRow;
int m_nLastReadCol;
bool m_bNeedCalcChain;// disable because it is useless but reading takes considerable time
std::vector<CWorksheet*> m_arWorksheets; //order as is
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*> m_mapWorksheets; //copy, for fast find - order by rId(name)
@ -124,6 +125,7 @@ namespace OOX
m_pXlsbWriter = NULL;
m_nLastReadRow = 0;
m_nLastReadCol = -1;
m_bNeedCalcChain = true;
bDeleteWorkbook = false;
bDeleteSharedStrings = false;

View File

@ -127,6 +127,26 @@ namespace NSFile
return lCount + 1;
}
std::wstring CUtf8Converter::GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount )
{
std::wstring strRes;
GetUnicodeStringFromUTF8_4bytes(pBuffer, lCount, strRes);
return strRes;
}
std::wstring CUtf8Converter::GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount )
{
std::wstring strRes;
GetUnicodeStringFromUTF8_2bytes(pBuffer, lCount, strRes);
return strRes;
}
std::wstring CUtf8Converter::GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount )
{
std::wstring strRes;
GetUnicodeStringFromUTF8(pBuffer, lCount, strRes);
return strRes;
}
void CUtf8Converter::GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount, std::wstring& sOutput )
{
WCHAR* pUnicodeString = new WCHAR[lCount + 1];
LONG lIndexUnicode = 0;
@ -205,13 +225,11 @@ namespace NSFile
pUnicodeString[lIndexUnicode] = 0;
std::wstring strRes(pUnicodeString);
sOutput.append(pUnicodeString);
delete [] pUnicodeString;
return strRes;
}
std::wstring CUtf8Converter::GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount )
void CUtf8Converter::GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount, std::wstring& sOutput )
{
WCHAR* pUnicodeString = new WCHAR[lCount + 1];
WCHAR* pStart = pUnicodeString;
@ -295,18 +313,16 @@ namespace NSFile
*pUnicodeString++ = 0;
std::wstring strRes(pStart);
sOutput.append(pStart);
delete [] pStart;
return strRes;
}
std::wstring CUtf8Converter::GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount )
void CUtf8Converter::GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount, std::wstring& sOutput )
{
if (sizeof(WCHAR) == 2)
return GetUnicodeStringFromUTF8_2bytes(pBuffer, lCount);
return GetUnicodeStringFromUTF8_4bytes(pBuffer, lCount);
GetUnicodeStringFromUTF8_2bytes(pBuffer, lCount, sOutput);
else
GetUnicodeStringFromUTF8_4bytes(pBuffer, lCount, sOutput);
}
#define CHECK_HHHH(pBuffer) \
@ -445,7 +461,7 @@ namespace NSFile
}
pUnicodeString[lIndexUnicode] = 0;
lOutputCount = lIndexUnicode;
lOutputCount = lIndexUnicode;
}
void CUtf8Converter::GetUnicodeStringFromUTF8WithHHHH_2bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount )
{
@ -542,8 +558,8 @@ namespace NSFile
}
}
lOutputCount = pUnicodeString - pStart;
*pUnicodeString++ = 0;
lOutputCount = pUnicodeString - pStart;
}
void CUtf8Converter::GetUnicodeStringFromUTF8WithHHHH( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount )
{

View File

@ -1,196 +1,200 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#if defined(GetTempPath)
#undef GetTempPath
#endif
#if defined(CreateFile)
#undef CreateFile
#endif
#if defined(CopyFile)
#undef CopyFile
#endif
#if defined(DeleteFile)
#undef DeleteFile
#endif
#ifndef _BUILD_FILE_CROSSPLATFORM_H_
#define _BUILD_FILE_CROSSPLATFORM_H_
#include <string>
#include <string.h>
#include <stdio.h>
#include "Base64.h"
#include "../../Common/kernel_config.h"
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val.c_str(), (LONG)val.length())
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
std::wstring KERNEL_DECL CorrectPathW(const std::wstring& path);
namespace NSFile
{
#define WriteUtf16_WCHAR(code, p) \
if (code < 0x10000) \
*p++ = code; \
else \
{ \
code -= 0x10000; \
*p++ = 0xD800 | ((code >> 10) & 0x03FF); \
*p++ = 0xDC00 | (code & 0x03FF); \
}
class CStringUtf16
{
public:
BYTE* Data;
int Length;
public:
CStringUtf16()
{
Data = NULL;
Length = 0;
}
~CStringUtf16()
{
RELEASEARRAYOBJECTS(Data);
}
};
class KERNEL_DECL CUtf8Converter
{
public:
static std::wstring GetUnicodeFromCharPtr(const char* pData, LONG lCount, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeFromCharPtr(const std::string& sParam, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount );
static void GetUnicodeStringFromUTF8WithHHHH_4bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH_2bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static inline LONG GetUnicodeStringFromUTF8BufferSize( LONG lCount );
static void GetUtf8StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode_2bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode2(const wchar_t* pUnicodes, LONG lCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode(const std::wstring& sData);
// utf16
static void GetUtf16StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, int& lOutputCount, bool bIsBOM = false);
static void GetUtf16StringFromUnicode_4bytes2(const wchar_t* pUnicodes, LONG lCount, CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const unsigned short* pUtf16, LONG lCount);
static inline long CheckHHHHChar(const BYTE* pBuffer);
static inline long CheckHHHHChar(const wchar_t* pBuffer);
};
class KERNEL_DECL CFileBinary
{
protected:
FILE* m_pFile;
long m_lFilePosition;
long m_lFileSize;
public:
CFileBinary();
virtual ~CFileBinary();
virtual void CloseFile();
FILE* GetFileNative();
long GetFileSize();
long GetFilePosition();
bool OpenFile(const std::wstring& sFileName, bool bRewrite = false);
bool CreateFileW(const std::wstring& sFileName);
bool CreateTempFile();
bool SeekFile(int lFilePosition, int nSeekMode = 0);
bool ReadFile(BYTE* pData, DWORD nBytesToRead, DWORD& dwSizeRead);
bool WriteFile(const BYTE* pData, DWORD nBytesCount);
long TellFile();
long SizeFile();
void WriteStringUTF8(const std::wstring& strXml, bool bIsBOM = false);
static bool ReadAllBytes(const std::wstring& strFileName, BYTE** ppData, DWORD& nBytesCount);
static bool ReadAllTextUtf8(const std::wstring& strFileName, std::wstring& sData);
static bool ReadAllTextUtf8A(const std::wstring& strFileName, std::string& sData);
static bool SaveToFile(const std::wstring& strFileName, const std::wstring& strXml, bool bIsBOM = false);
static bool Exists(const std::wstring& strFileName);
static bool Copy(const std::wstring& strSrc, const std::wstring& strDst);
static bool Remove(const std::wstring& strFileName);
static bool Move(const std::wstring& strSrc, const std::wstring& strDst);
static bool Truncate(const std::wstring& sPath, size_t nNewSize);
static std::wstring GetTempPath();
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
static FILE* OpenFileNative(const std::wstring& sFileName, const std::wstring& sMode);
};
class KERNEL_DECL CBase64Converter
{
public:
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
};
}
namespace NSFile
{
#define NS_FILE_MAX_PATH 32768
KERNEL_DECL std::wstring GetProcessPath();
KERNEL_DECL std::wstring GetProcessDirectory();
// CommonFunctions
KERNEL_DECL std::wstring GetFileExtention(const std::wstring& sPath);
KERNEL_DECL std::wstring GetFileName(const std::wstring& sPath);
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& sPath);
}
#endif //_BUILD_FILE_CROSSPLATFORM_H_
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#if defined(GetTempPath)
#undef GetTempPath
#endif
#if defined(CreateFile)
#undef CreateFile
#endif
#if defined(CopyFile)
#undef CopyFile
#endif
#if defined(DeleteFile)
#undef DeleteFile
#endif
#ifndef _BUILD_FILE_CROSSPLATFORM_H_
#define _BUILD_FILE_CROSSPLATFORM_H_
#include <string>
#include <string.h>
#include <stdio.h>
#include "Base64.h"
#include "../../Common/kernel_config.h"
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val.c_str(), (LONG)val.length())
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
std::wstring KERNEL_DECL CorrectPathW(const std::wstring& path);
namespace NSFile
{
#define WriteUtf16_WCHAR(code, p) \
if (code < 0x10000) \
*p++ = code; \
else \
{ \
code -= 0x10000; \
*p++ = 0xD800 | ((code >> 10) & 0x03FF); \
*p++ = 0xDC00 | (code & 0x03FF); \
}
class CStringUtf16
{
public:
BYTE* Data;
int Length;
public:
CStringUtf16()
{
Data = NULL;
Length = 0;
}
~CStringUtf16()
{
RELEASEARRAYOBJECTS(Data);
}
};
class KERNEL_DECL CUtf8Converter
{
public:
static std::wstring GetUnicodeFromCharPtr(const char* pData, LONG lCount, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeFromCharPtr(const std::string& sParam, INT bIsUtf8 = FALSE);
static std::wstring GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount );
static std::wstring GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount );
static void GetUnicodeStringFromUTF8_4bytes( BYTE* pBuffer, LONG lCount, std::wstring& sOutput );
static void GetUnicodeStringFromUTF8_2bytes( BYTE* pBuffer, LONG lCount, std::wstring& sOutput );
static void GetUnicodeStringFromUTF8( BYTE* pBuffer, LONG lCount, std::wstring& sOutput );
static void GetUnicodeStringFromUTF8WithHHHH_4bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH_2bytes( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static void GetUnicodeStringFromUTF8WithHHHH( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount );
static LONG GetUnicodeStringFromUTF8BufferSize( LONG lCount );
static void GetUtf8StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode_2bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static void GetUtf8StringFromUnicode(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, LONG& lOutputCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode2(const wchar_t* pUnicodes, LONG lCount, bool bIsBOM = false);
static std::string GetUtf8StringFromUnicode(const std::wstring& sData);
// utf16
static void GetUtf16StringFromUnicode_4bytes(const wchar_t* pUnicodes, LONG lCount, BYTE*& pData, int& lOutputCount, bool bIsBOM = false);
static void GetUtf16StringFromUnicode_4bytes2(const wchar_t* pUnicodes, LONG lCount, CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const CStringUtf16& data);
static std::wstring GetWStringFromUTF16(const unsigned short* pUtf16, LONG lCount);
static long CheckHHHHChar(const BYTE* pBuffer);
static long CheckHHHHChar(const wchar_t* pBuffer);
};
class KERNEL_DECL CFileBinary
{
protected:
FILE* m_pFile;
long m_lFilePosition;
long m_lFileSize;
public:
CFileBinary();
virtual ~CFileBinary();
virtual void CloseFile();
FILE* GetFileNative();
long GetFileSize();
long GetFilePosition();
bool OpenFile(const std::wstring& sFileName, bool bRewrite = false);
bool CreateFileW(const std::wstring& sFileName);
bool CreateTempFile();
bool SeekFile(int lFilePosition, int nSeekMode = 0);
bool ReadFile(BYTE* pData, DWORD nBytesToRead, DWORD& dwSizeRead);
bool WriteFile(const BYTE* pData, DWORD nBytesCount);
long TellFile();
long SizeFile();
void WriteStringUTF8(const std::wstring& strXml, bool bIsBOM = false);
static bool ReadAllBytes(const std::wstring& strFileName, BYTE** ppData, DWORD& nBytesCount);
static bool ReadAllTextUtf8(const std::wstring& strFileName, std::wstring& sData);
static bool ReadAllTextUtf8A(const std::wstring& strFileName, std::string& sData);
static bool SaveToFile(const std::wstring& strFileName, const std::wstring& strXml, bool bIsBOM = false);
static bool Exists(const std::wstring& strFileName);
static bool Copy(const std::wstring& strSrc, const std::wstring& strDst);
static bool Remove(const std::wstring& strFileName);
static bool Move(const std::wstring& strSrc, const std::wstring& strDst);
static bool Truncate(const std::wstring& sPath, size_t nNewSize);
static std::wstring GetTempPath();
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
static FILE* OpenFileNative(const std::wstring& sFileName, const std::wstring& sMode);
};
class KERNEL_DECL CBase64Converter
{
public:
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
};
}
namespace NSFile
{
#define NS_FILE_MAX_PATH 32768
KERNEL_DECL std::wstring GetProcessPath();
KERNEL_DECL std::wstring GetProcessDirectory();
// CommonFunctions
KERNEL_DECL std::wstring GetFileExtention(const std::wstring& sPath);
KERNEL_DECL std::wstring GetFileName(const std::wstring& sPath);
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& sPath);
}
#endif //_BUILD_FILE_CROSSPLATFORM_H_

View File

@ -239,6 +239,50 @@ namespace NSStringExt
wsString.replace(nPos, nFromLen, wsTo);
}
}
static inline void LTrim(std::wstring &str, const wchar_t* chars)
{
str.erase(0, str.find_first_not_of(chars));
}
static inline void RTrim(std::wstring &str, const wchar_t* chars)
{
str.erase(str.find_last_not_of(chars) + 1);
}
static inline long FindFirstNotOfA(const char* str, const char* chars)
{
long res = 0;
while('\0' != str[res])
{
long index = 0;
while('\0' != chars[index] && chars[index] != str[res])
{
index++;
}
if('\0' == chars[index])
{
break;
}
res++;
}
return res;
}
static inline long FindLastNotOf(const wchar_t* str, unsigned int unLen, const wchar_t* chars)
{
long res = unLen - 1;
while(res >= 0)
{
long index = 0;
while('\0' != chars[index] && chars[index] != str[res])
{
index++;
}
if('\0' == chars[index])
{
break;
}
res--;
}
return res;
}
}
#endif // _BUILD_STRING_CROSSPLATFORM_H_

View File

@ -115,6 +115,7 @@ namespace XmlUtils
std::string GetText2A();
std::wstring GetText3();
void GetTextWithHHHH(bool bPreserve, wchar_t*& sBuffer, long& nSize, long& nLen);
std::wstring GetOuterXml();
std::wstring GetInnerXml();

View File

@ -164,6 +164,10 @@ namespace XmlUtils
{
return m_pInternal->GetText3();
}
void CXmlLiteReader::GetTextWithHHHH(bool bPreserve, wchar_t*& sBuffer, long& nSize, long& nLen)
{
return m_pInternal->GetTextWithHHHH(bPreserve, sBuffer, nSize,nLen);
}
std::wstring CXmlLiteReader::GetOuterXml()
{

View File

@ -33,6 +33,7 @@
#define _BUILD_XMLLIGHT_PRIVATE_CROSSPLATFORM_H_
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/common/StringExt.h"
#ifdef _IOS
#include <libxml2/libxml/xmlreader.h>
@ -411,6 +412,65 @@ namespace XmlUtils
return sResult;
}
void CheckBufferSize(unsigned int nOffset, unsigned int nRequired, wchar_t*& sBuffer, long& nSize)
{
if(nOffset + nRequired > nSize)
{
if(0 == nSize)
{
nSize = nOffset + nRequired;
}
while(nOffset + nRequired > nSize)
{
nSize *= 2;
}
RELEASEOBJECT(sBuffer);
sBuffer = new WCHAR[nSize];
}
}
void GetTextWithHHHH(bool bPreserve, wchar_t*& sBuffer, long& nSize, long& nLen)
{
nLen = 0;
if ( !IsValid() )
return;
if ( 0 != xmlTextReaderIsEmptyElement(reader) )
return;
bool bTrimLeft, bTrimRight;
bTrimLeft = bTrimRight = !bPreserve;
LONG lOutputCount = 0;
int nDepth = GetDepth();
XmlNodeType eNodeType = XmlNodeType_EndElement;
while ( Read( eNodeType ) && GetDepth() >= nDepth && XmlNodeType_EndElement != eNodeType )
{
if ( eNodeType == XmlNodeType_Text || eNodeType == XmlNodeType_Whitespace || eNodeType == XmlNodeType_SIGNIFICANT_WHITESPACE )
{
const xmlChar* pValue = xmlTextReaderConstValue(reader);
if(NULL != pValue)
{
const char* pValueA = (const char*)pValue;
if(bTrimLeft)
{
bTrimLeft = false;
pValueA += NSStringExt::FindFirstNotOfA(pValueA, " \n\r\t");
}
if('\0' != pValueA[0])
{
LONG nLenA = strlen((const char*)pValueA);
LONG nRequired = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8BufferSize(nLenA);
CheckBufferSize(nLen, nRequired, sBuffer, nSize);
wchar_t* sBufferCur = sBuffer + nLen;
NSFile::CUtf8Converter::GetUnicodeStringFromUTF8WithHHHH((const BYTE*)pValueA, nLenA, sBufferCur, lOutputCount);
nLen += lOutputCount;
}
}
}
}
if(bTrimRight)
{
nLen = NSStringExt::FindLastNotOf(sBuffer, nLen, L" \n\r\t") + 1;
}
}
inline std::wstring GetOuterXml()
{
return GetXml(false);

View File

@ -6357,20 +6357,21 @@ _UINT32 BinaryFileWriter::Open(const std::wstring& sInputDir, const std::wstring
if (bIsNoBase64)
{
pXlsx = new OOX::Spreadsheet::CXlsx();
pXlsx->m_bNeedCalcChain = false;
NSBinPptxRW::CXlsbBinaryWriter oXlsbWriter;
oXlsbWriter.CreateFileW(sFileDst);
//write dummy header and main table
oXlsbWriter.WriteStringUtf8(WriteFileHeader(0, g_nFormatVersionNoBase64));
oXlsbWriter.WriteReserved(GetMainTableSize());
int nDataStartPos = oXlsbWriter.GetPosition();
int nDataStartPos = oXlsbWriter.GetPositionAbsolute();
pXlsx->m_pXlsbWriter = &oXlsbWriter;
//parse
pXlsx->Read(OOX::CPath(sInputDir));
pXlsx->m_pXlsbWriter = NULL;
oXlsbWriter.CloseFile();
m_nLastFilePosOffset = oXlsbWriter.GetPosition() - nDataStartPos;
m_nLastFilePosOffset = oXlsbWriter.GetPositionAbsolute() - nDataStartPos;
}
else
{