Compare commits

..

7 Commits

30 changed files with 1268 additions and 804 deletions

View File

@ -800,8 +800,9 @@ namespace DocFileFormat
}
}
XMLTools::XMLElement elem(L"w:br");
elem.AppendAttribute(L"w:type", L"textWrapping");
elem.AppendAttribute(L"w:clear", L"all");
//СЗ в МРФ Техноград о предоставлении ТП 1 квартал 2019_MO_Q31.doc
//elem.AppendAttribute(L"w:type", L"textWrapping");
//elem.AppendAttribute(L"w:clear", L"all");
m_pXmlWriter->WriteString(elem.GetXMLString());
}

View File

@ -968,7 +968,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
XmlUtils::replace_all(odfFormula, L"EXTERNALREF", L"file://");//снятие экранирования
if (std::wstring::npos != odfFormula.find(L"["))
if ((false == table_parts_.empty()) && (std::wstring::npos != odfFormula.find(L"[")))
{
for (size_t i = 0; i < table_parts_.size(); i++)
{
@ -1049,57 +1049,60 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
int moving_type = 0;
std::vector<std::wstring> distance;
boost::algorithm::split(distance, ref,boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
boost::algorithm::split(distance, ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (distance.size() > 1)
{
int col1, row1, col2, row2;
utils::parsing_ref(distance[0],col1,row1);
utils::parsing_ref(distance[1],col2,row2);
utils::parsing_ref(distance[0], col1, row1);
utils::parsing_ref(distance[1], col2, row2);
if (row2 - row1 > 0) moving_type = 2;
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_.insert(std::make_pair((unsigned int)ind, state));
shared_formulas_.push_back(state);
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
else
{
std::map<unsigned int, ods_shared_formula_state>::iterator pFind = shared_formulas_.find(ind);
if (pFind != shared_formulas_.end())
for ( size_t i = 0; i < shared_formulas_.size(); i++)
{
odf_formula = pFind->second.formula;
if (shared_formulas_[i].index == ind)
{
odf_formula = shared_formulas_[i].formula;
//поменять по ref формулу !!!
if (pFind->second.moving_type == 1)
{
tmp_column_ = pFind->second.base_column;
tmp_row_ = pFind->second.base_row;
//поменять по 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;
}
else 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;
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;
break;
}
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,12 +453,12 @@ private:
std::vector<ods_cell_state> cells_;
long cells_size_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::map<unsigned int, ods_shared_formula_state> shared_formulas_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::vector<ods_shared_formula_state> shared_formulas_;
std::vector<table_part_state> table_parts_;
std::vector<table_part_state> table_parts_;
std::vector<data_validation_state> data_validations_;
std::vector<data_validation_state> data_validations_;
odf_drawing_context drawing_context_;
odf_controls_context controls_context_;

View File

@ -1417,7 +1417,12 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
void DocxConverter::convert( ComplexTypes::Word::CShading* shading, _CP_OPT(odf_types::color)& odf_color)
{
if (!shading) return;
if ((shading->m_oVal.IsInit()) && ( shading->m_oVal->GetValue() == SimpleTypes::shdClear ||
shading->m_oVal->GetValue() == SimpleTypes::shdNil))
{
return;
}
convert(shading->m_oFill.GetPointer(), shading->m_oThemeFill.GetPointer(),
shading->m_oThemeFillTint.GetPointer(), shading->m_oThemeShade.GetPointer(), odf_color);

View File

@ -191,7 +191,6 @@ namespace Oox2Odf
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);
void convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf_writer::style_paragraph_properties *paragraph_properties);
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties, bool is_list_styles = false);
void convert(ComplexTypes::Word::CShading *oox_shading, odf_writer::style_text_properties *text_properties );
void convert(OOX::Logic::CFldSimple *oox_fld);
void convert(OOX::Logic::CFldChar *oox_fld);
void convert(OOX::Logic::CInstrText *oox_instrText);

View File

@ -3042,8 +3042,19 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
{
AddShapeType(oNodeT);
}
else if (
L"shape" == strNameP ||
}
}
if (oNode.GetNodes(L"*", oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNodeT;
oNodes.GetAt(i, oNodeT);
std::wstring strNameP = XmlUtils::GetNameNoNS(oNodeT.GetName());
if (L"shape" == strNameP ||
L"rect" == strNameP ||
L"oval" == strNameP ||
L"line" == strNameP ||

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,6 @@ namespace NSBinPptxRW
}
void CBinaryFileWriter::_WriteStringWithLength(const WCHAR* sBuffer, _UINT32 lCount, bool bByte)
{
//CheckBufferSize at first to prevent negative m_lPosition after Flush in CStreamBinaryWriter
if (sizeof(wchar_t) == 4)
{
_INT32 lSizeMemMax = 4 * lCount + 2;//2 - for null terminator
@ -1187,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

@ -579,52 +579,63 @@ std::wstring RtfBorder::RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
std::wstring sResult;
if( PROP_DEF != m_nColor )
{
RtfColor oColor;
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_COLOR_VALUE;
if( true == poRtfDocument->m_oColorTable.GetColor( m_nColor, oColor ) )
sResult += L" w:color=\"" + oColor.RenderToOOX(oNewParam) + L"\"";
}
if( PROP_DEF != m_nWidth ) //w:sz 1/8 twips (equivalent to 1/576th of an inch)
sResult += L" w:sz=\"" + std::to_wstring(2 * m_nWidth / 5 ) + L"\"";
if( PROP_DEF != m_nSpace )
sResult += L" w:space=\"" + std::to_wstring((int)RtfUtility::Twip2pt( m_nSpace )) + L"\"";
switch( m_eType )
{
case bt_brdrs: sResult += L" w:val=\"single\""; break;
case bt_brdrs: sResult += L" w:val=\"single\""; break;
case bt_brdrth: sResult += L" w:val=\"thick\""; break;
case bt_brdrsh: sResult += L" w:val=\"\"thin"; break;
case bt_brdrdb: sResult += L" w:val=\"double\""; break;
case bt_brdrdot: sResult += L" w:val=\"dotted\""; break;
case bt_brdrdash: sResult += L" w:val=\"dashed\""; break;
case bt_brdrdb: sResult += L" w:val=\"double\""; break;
case bt_brdrdot: sResult += L" w:val=\"dotted\""; break;
case bt_brdrdash: sResult += L" w:val=\"dashed\""; break;
case bt_brdrhair: sResult += L" w:val=\"hair\""; break;
case bt_brdrdashsm: sResult += L" w:val=\"dashSmallGap\""; break;
case bt_brdrdashd: sResult += L" w:val=\"dotDash\""; break;
case bt_brdrdashdd: sResult += L" w:val=\"dotDotDash\""; break;
case bt_brdrdashdd: sResult += L" w:val=\"dotDotDash\""; break;
case bt_brdrinset: sResult += L" w:val=\"inset\""; break;
case bt_brdrnone: sResult += L" w:val=\"nil\""; break;
case bt_brdroutset: sResult += L" w:val=\"outset\""; break;
case bt_brdrtriple: sResult += L" w:val=\"triple\""; break;
case bt_brdrnone: sResult += L" w:val=\"none\""; break;
case bt_brdroutset: sResult += L" w:val=\"outset\""; break;
case bt_brdrtriple: sResult += L" w:val=\"triple\""; break;
case bt_brdrtnthsg: sResult += L" w:val=\"thinThickSmallGap\""; break;
case bt_brdrthtnsg: sResult += L" w:val=\"thickThinSmallGap\""; break;
case bt_brdrtnthtnsg: sResult += L" w:val=\"thinThickThinSmallGap\""; break;
case bt_brdrtnthtnmg: sResult += L" w:val=\"thinThickThinMediumGap\""; break;
case bt_brdrtnthmg: sResult += L" w:val=\"thinThickMediumGap\""; break;
case bt_brdrthtnmg: sResult += L" w:val=\"thickThinMediumGap\""; break;
case bt_brdrtnthtnsg: sResult += L" w:val=\"thinThickThinSmallGap\""; break;
case bt_brdrtnthtnmg: sResult += L" w:val=\"thinThickThinMediumGap\"";break;
case bt_brdrtnthmg: sResult += L" w:val=\"thinThickMediumGap\""; break;
case bt_brdrthtnmg: sResult += L" w:val=\"thickThinMediumGap\""; break;
case bt_brdrtnthlg: sResult += L" w:val=\"thinThickLargeGap\""; break;
case bt_brdrthtnlg: sResult += L" w:val=\"thickThinLargeGap\""; break;
case bt_brdrtnthtnlg: sResult += L" w:val=\"thinThickThinLargeGap\""; break;
case bt_brdrwavy: sResult += L" w:val=\"wave\""; break;
case bt_brdrwavydb: sResult += L" w:val=\"doubleWave\""; break;
case bt_brdrdashdotstr: sResult += L" w:val=\"dashDotStroked\""; break;
case bt_brdrwavydb: sResult += L" w:val=\"doubleWave\""; break;
case bt_brdrdashdotstr: sResult += L" w:val=\"dashDotStroked\""; break;
case bt_brdremboss: sResult += L" w:val=\"threeDEmboss\""; break;
case bt_brdrengrave: sResult += L" w:val=\"threeDEngrave\""; break;
default:
break;
}
if( PROP_DEF != m_nColor )
{
RtfColor oColor;
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_COLOR_VALUE;
if (m_nColor == -1)
{
oColor.m_bAuto = true;
sResult += L" w:color=\"auto\"";
}
else if( true == poRtfDocument->m_oColorTable.GetColor( m_nColor, oColor ) )
sResult += L" w:color=\"" + oColor.RenderToOOX(oNewParam) + L"\"";
}
if( PROP_DEF != m_nWidth ) //w:sz 1/8 twips (equivalent to 1/576th of an inch)
{
sResult += L" w:sz=\"" + std::to_wstring(2 * m_nWidth / 5 ) + L"\"";
}
if( PROP_DEF != m_nSpace )
{
sResult += L" w:space=\"" + std::to_wstring((int)RtfUtility::Twip2pt( m_nSpace )) + L"\"";
}
if( false == sResult.empty() )
{
if( RENDER_TO_OOX_PARAM_BORDER_ATTRIBUTE == oRenderParameter.nType )

View File

@ -848,7 +848,7 @@ public:
m_eType = bt_brdrnone;
m_nWidth = 0;
m_nSpace = 0;
m_nColor = PROP_DEF;
m_nColor = -1; //auto
}
void Merge( RtfBorder& oBorPr )
{
@ -2416,18 +2416,18 @@ public:
void SetDefaultOOX()
{
SetDefault();
}
void SetDefault()
{
RtfTableProperty::SetDefault();
//не SetEmpty() !!!
m_oBorderLeft.SetDefault();
m_oBorderRight.SetDefault();
m_oBorderTop.SetDefault();
m_oBorderBottom.SetDefault();
m_oBorderVert.SetDefault();
m_oBorderHor.SetDefault();
m_oBorderHor.SetDefault();
}
//5.5 Доверенность_MO_Q139.rtf
void SetDefault()
{
RtfTableProperty::SetDefault();
DEFAULT_PROPERTY( m_nIndex )
DEFAULT_PROPERTY( m_nBandIndex )
DEFAULT_PROPERTY( m_bLastRow )
@ -2649,6 +2649,10 @@ public:
void SetDefaultRtf()
{
SetDefault();
//4.1 Наряд_R7_M133.rtf
m_nSpaceAfter = 0;
m_nSpaceBetween = 240;
}
void SetDefaultOOX()
{
@ -2701,7 +2705,7 @@ public:
m_oBorderTop.SetDefault();
m_oBorderLeft.SetDefault();
m_oBorderBottom.SetDefault();
m_oBorderRight.SetDefault();
m_oBorderRight.SetDefault();
m_oBorderBox.SetDefault();
m_oBorderBar.SetDefault();

View File

@ -1596,10 +1596,18 @@
RelativePath="..\Source\XlsxFormat\SharedStrings\SharedStrings.h"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\SharedStrings\Si.cpp"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\SharedStrings\Si.h"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\SharedStrings\Text.cpp"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\SharedStrings\Text.h"
>
@ -1636,6 +1644,10 @@
RelativePath="..\Source\XlsxFormat\Styles\NumFmts.h"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\Styles\rPr.cpp"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\Styles\rPr.h"
>

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

@ -105,11 +105,15 @@ namespace NSFile
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 inline LONG GetUnicodeStringFromUTF8BufferSize( LONG lCount );
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);

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
{