init repo

This commit is contained in:
nikolay ivanov
2014-07-05 18:22:49 +00:00
commit a8be6b9e72
17348 changed files with 9229832 additions and 0 deletions

View File

@@ -0,0 +1,190 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CALCCHAIN_FILE_INCLUDE_H_
#define OOX_CALCCHAIN_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CCalcCell : public WritingElementWithChilds<>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCalcCell)
CCalcCell()
{
}
virtual ~CCalcCell()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_CalcCell;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("a"), m_oArray )
WritingElement_ReadAttributes_Read_if ( oReader, _T("i"), m_oSheetId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("l"), m_oDependencyLevel )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("s"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("t"), m_oRef )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oArray;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSheetId;
nullable<SimpleTypes::COnOff<>> m_oDependencyLevel;
nullable<CString> m_oRef;
nullable<SimpleTypes::COnOff<>> m_oChildChain;
nullable<SimpleTypes::COnOff<>> m_oNewThread;
};
class CCalcChain : public OOX::File, public OOX::Spreadsheet::IFileContainer
{
public:
CCalcChain()
{
}
CCalcChain(const CPath& oPath)
{
read( oPath );
}
virtual ~CCalcChain()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("calcChain") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
sName = oReader.GetName();
if ( _T("c") == sName )
m_arrItems.Add(new CCalcCell(oReader));
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::CalcChain;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
private:
CPath m_oReadPath;
void ClearItems()
{
for ( int nIndex = 0; nIndex < m_arrItems.GetSize(); nIndex++ )
{
if ( m_arrItems[nIndex] )
delete m_arrItems[nIndex];
m_arrItems[nIndex] = NULL;
}
m_arrItems.RemoveAll();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
CSimpleArray<CCalcCell *> m_arrItems;
};
}
}
#endif // OOX_CALCCHAIN_FILE_INCLUDE_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,310 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CHART_FILE_INCLUDE_H_
#define OOX_CHART_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Title.h"
#include "Legend.h"
#include "PlotArea.h"
#include "ChartStyle.h"
#include "../../DocxFormat/Logic/AlternateContent.h"
namespace OOX
{
namespace Spreadsheet
{
static TCHAR* gc_sChartArea = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><c:lang val=\"en-US\"/><c:roundedCorners val=\"0\"/>%s<c:chart>%s<c:plotArea><c:layout/><c:areaChart><c:varyColors val=\"0\"/>%s%s%s<c:dLbls><c:showLegendKey val=\"0\"/>%s<c:showSerName val=\"0\"/><c:showPercent val=\"0\"/><c:showBubbleSize val=\"0\"/></c:dLbls><c:axId val=\"7622\"/><c:axId val=\"5026\"/></c:areaChart><c:catAx><c:axId val=\"7622\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"b\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"5026\"/><c:crossesAt val=\"0\"/><c:lblAlgn val=\"ctr\"/><c:auto val=\"1\"/><c:lblOffset val=\"100\"/></c:catAx><c:valAx><c:axId val=\"5026\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"l\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"7622\"/><c:crossesAt val=\"0\"/></c:valAx></c:plotArea>%s<c:plotVisOnly val=\"1\"/></c:chart>%s</c:chartSpace>");
static TCHAR* gc_sChartLine = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><c:lang val=\"en-US\"/><c:roundedCorners val=\"0\"/>%s<c:chart>%s<c:plotArea><c:layout/><c:lineChart><c:varyColors val=\"0\"/>%s%s%s<c:dLbls><c:dLblPos val=\"t\"/><c:showLegendKey val=\"0\"/>%s<c:showSerName val=\"0\"/><c:showPercent val=\"0\"/><c:showBubbleSize val=\"0\"/></c:dLbls><c:marker val=\"1\"/><c:axId val=\"3375\"/><c:axId val=\"13466\"/></c:lineChart><c:catAx><c:axId val=\"3375\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"b\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"13466\"/><c:crossesAt val=\"0\"/><c:lblAlgn val=\"ctr\"/><c:auto val=\"1\"/><c:lblOffset val=\"100\"/></c:catAx><c:valAx><c:axId val=\"13466\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"l\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"3375\"/><c:crossesAt val=\"0\"/></c:valAx></c:plotArea>%s<c:plotVisOnly val=\"1\"/></c:chart>%s</c:chartSpace>");
static TCHAR* gc_sChartPie = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><c:lang val=\"en-US\"/><c:roundedCorners val=\"0\"/>%s<c:chart>%s<c:plotArea><c:layout/><c:pieChart><c:varyColors val=\"1\"/>%s%s%s<c:dLbls><c:dLblPos val=\"outEnd\"/><c:showLegendKey val=\"0\"/>%s<c:showSerName val=\"0\"/><c:showPercent val=\"0\"/><c:showBubbleSize val=\"0\"/></c:dLbls><c:firstSliceAng val=\"0\"/></c:pieChart></c:plotArea>%s<c:plotVisOnly val=\"1\"/></c:chart>%s</c:chartSpace>");
static TCHAR* gc_sChartScatter = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><c:lang val=\"en-US\"/><c:roundedCorners val=\"0\"/>%s<c:chart>%s<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val=\"lineMarker\"/><c:varyColors val=\"0\" />%s%s%s<c:dLbls><c:showLegendKey val=\"0\"/>%s<c:showSerName val=\"0\"/><c:showPercent val=\"0\"/><c:showBubbleSize val=\"0\"/></c:dLbls><c:axId val=\"28581\"/><c:axId val=\"1636\"/></c:scatterChart><c:valAx><c:axId val=\"28581\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"b\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"1636\"/><c:crossesAt val=\"0\"/></c:valAx><c:valAx><c:axId val=\"1636\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"l\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"28581\"/><c:crossesAt val=\"0\"/></c:valAx></c:plotArea>%s<c:plotVisOnly val=\"1\"/></c:chart>%s</c:chartSpace>");
static TCHAR* gc_sChartBar = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><c:lang val=\"en-US\"/><c:roundedCorners val=\"0\"/>%s<c:chart>%s<c:plotArea><c:layout/><c:barChart><c:varyColors val=\"0\"/>%s%s%s<c:dLbls>%s<c:showLegendKey val=\"0\"/>%s<c:showSerName val=\"0\"/><c:showPercent val=\"0\"/><c:showBubbleSize val=\"0\"/></c:dLbls><c:gapWidth val=\"100\"/>%s<c:axId val=\"19816\"/><c:axId val=\"31185\"/></c:barChart><c:catAx><c:axId val=\"19816\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"b\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"31185\"/><c:crosses val=\"autoZero\"/><c:lblAlgn val=\"ctr\"/><c:auto val=\"1\"/><c:lblOffset val=\"100\"/></c:catAx><c:valAx><c:axId val=\"31185\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"l\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"19816\"/><c:crosses val=\"autoZero\"/></c:valAx></c:plotArea>%s<c:plotVisOnly val=\"1\"/></c:chart>%s</c:chartSpace>");
static TCHAR* gc_sChartStock = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><c:chartSpace xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"><c:lang val=\"en-US\"/><c:roundedCorners val=\"0\"/>%s<c:chart>%s<c:plotArea><c:layout/><c:stockChart><c:varyColors val=\"0\"/>%s%s%s<c:dLbls><c:showLegendKey val=\"0\"/>%s<c:showSerName val=\"0\"/><c:showPercent val=\"0\"/><c:showBubbleSize val=\"0\"/></c:dLbls><c:hiLowLines/><c:upDownBars><c:gapWidth val=\"150\"/><c:upBars/><c:downBars/></c:upDownBars><c:axId val=\"10364\"/><c:axId val=\"1630\"/></c:stockChart><c:dateAx><c:axId val=\"10364\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"b\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"1630\"/><c:crossesAt val=\"0\"/><c:auto val=\"1\"/><c:lblOffset val=\"100\"/></c:dateAx><c:valAx><c:axId val=\"1630\"/><c:scaling><c:orientation val=\"minMax\"/></c:scaling>%s%s%s<c:axPos val=\"l\"/><c:majorTickMark val=\"out\"/><c:minorTickMark val=\"none\"/><c:tickLblPos val=\"nextTo\"/>%s<c:crossAx val=\"10364\"/><c:crossesAt val=\"0\"/></c:valAx></c:plotArea>%s<c:plotVisOnly val=\"1\"/></c:chart>%s</c:chartSpace>");
class CChart : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChart)
CChart()
{
}
virtual ~CChart()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void toXML2(CStringWriter& writer, nullable<CChartStyle> oChartStyle, CString& sSpPr) const
{
if(m_oPlotArea.IsInit() && m_oPlotArea->m_oBasicChart.IsInit())
{
CString sChartPattern;
bool bPie = false;
bool bBar = false;
bool bScatter = false;
bool bLine = false;
switch(m_oPlotArea->m_oBasicChart->m_eType)
{
case OOX::Spreadsheet::chartbasicBarChart:
case OOX::Spreadsheet::chartbasicBar3DChart: sChartPattern = gc_sChartBar;bBar = true;break;
case OOX::Spreadsheet::chartbasicRadarChart:
case OOX::Spreadsheet::chartbasicAreaChart: sChartPattern = gc_sChartArea;break;
case OOX::Spreadsheet::chartbasicLineChart:
case OOX::Spreadsheet::chartbasicLine3DChart: sChartPattern = gc_sChartLine;bLine = true;break;
case OOX::Spreadsheet::chartbasicPieChart:
case OOX::Spreadsheet::chartbasicDoughnutChart: sChartPattern = gc_sChartPie;bPie = true;break;
case OOX::Spreadsheet::chartbasicBubbleChart:
case OOX::Spreadsheet::chartbasicScatterChart: sChartPattern = gc_sChartScatter;bScatter = true;break;
case OOX::Spreadsheet::chartbasicStockChart: sChartPattern = gc_sChartStock;break;
default:sChartPattern = gc_sChartLine;
}
CString title;
if(m_oTitle.IsInit())
{
CStringWriter sTempWriter;
m_oTitle->toXML(sTempWriter);
title = sTempWriter.GetCString();
}
CString style;
if(oChartStyle.IsInit())
style = oChartStyle->toXML();
else
{
CChartStyle oCChartStyle;
style = oCChartStyle.toXML();
}
CString sBarDir;
CString sGrouping;
CString sSeries;
CString sDataLabels;
CString sOverlap;
CString sCatAxDelete;
CString sCatAxMajorGrid;
CString sCatAxTitle;
CString sCatTxPr;
CString sValAxDelete;
CString sValAxMajorGrid;
CString sValAxTitle;
CString sValTxPr;
m_oPlotArea->toXML2(bScatter, bLine, sBarDir, sGrouping, sSeries, sDataLabels, sOverlap, sCatAxDelete, sCatAxMajorGrid, sCatAxTitle, sCatTxPr, sValAxDelete, sValAxMajorGrid, sValAxTitle, sValTxPr);
CStringWriter legend;
if(m_oLegend.IsInit())
m_oLegend->toXML(legend);
CString sChart;
if(bPie)
sChart.Format(sChartPattern, style, title, sBarDir, sGrouping, sSeries, sDataLabels, legend.GetCString(), sSpPr);
else if(bBar)
{
CString sDLblPos = _T("<c:dLblPos val=\"outEnd\"/>");
if(m_oPlotArea->m_oBasicChart.IsInit() && m_oPlotArea->m_oBasicChart->m_oGrouping.IsInit() && m_oPlotArea->m_oBasicChart->m_oGrouping->m_oVal.IsInit())
{
switch(m_oPlotArea->m_oBasicChart->m_oGrouping->m_oVal->GetValue())
{
case SimpleTypes::Spreadsheet::chartbargroupingPercentStacked : sDLblPos = _T("<c:dLblPos val=\"inEnd\"/>");break;
case SimpleTypes::Spreadsheet::chartbargroupingStacked : sDLblPos = _T("<c:dLblPos val=\"inEnd\"/>");break;
}
}
sChart.Format(sChartPattern, style, title, sBarDir, sGrouping, sSeries, sDLblPos, sDataLabels, sOverlap, sCatAxDelete, sCatAxMajorGrid, sCatAxTitle, sCatTxPr, sValAxDelete, sValAxMajorGrid, sValAxTitle, sValTxPr, legend.GetCString(), sSpPr);
}
else
sChart.Format(sChartPattern, style, title, sBarDir, sGrouping, sSeries, sDataLabels, sCatAxDelete, sCatAxMajorGrid, sCatAxTitle, sCatTxPr, sValAxDelete, sValAxMajorGrid, sValAxTitle, sValTxPr, legend.GetCString(), sSpPr);
writer.WriteStringC(sChart);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:title") == sName )
m_oTitle = oReader;
else if ( _T("c:legend") == sName )
m_oLegend = oReader;
else if ( _T("c:plotArea") == sName )
m_oPlotArea = oReader;
}
}
virtual EElementType getType () const
{
return et_c_Chart;
}
bool isValid()
{
if(m_oPlotArea.IsInit() && m_oPlotArea->m_oBasicChart.IsInit())
{
return OOX::Spreadsheet::chartbasicBubbleChart != m_oPlotArea->m_oBasicChart->m_eType;
}
return false;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartTitle> m_oTitle;
nullable<CChartLegend> m_oLegend;
nullable<CChartPlotArea> m_oPlotArea;
};
class CChartSpace : public OOX::FileGlobalEnumerated, public OOX::Spreadsheet::IFileContainer
{
public:
CChartSpace()
{
}
CChartSpace(const CPath& oPath)
{
read( oPath );
}
virtual ~CChartSpace()
{
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("c:chartSpace") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
sName = oReader.GetName();
if ( _T("c:chart") == sName )
m_oChart = oReader;
else if ( _T("c:style") == sName )
m_oStyle = oReader;
else if ( _T("mc:AlternateContent") == sName )
m_oAlternateContent = oReader;
else if ( _T("c:spPr") == sName )
m_sSpPr = oReader.GetOuterXml();
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
if(isValid())
{
write2(oPath.GetPath());
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write(oPath, oDirectory, oContent);
}
}
bool write2(const CString& sFilename) const
{
bool bRes = false;
if(isValid())
{
CStringWriter sXml;
toXML(sXml);
CDirectory::SaveToFile( sFilename, sXml.GetCString() );
bRes = true;
}
return bRes;
}
bool isValid() const
{
return m_oChart.IsInit() && m_oChart->isValid();
}
void toXML(CStringWriter& sXml) const
{
CString sSpPr;
if(m_sSpPr.IsInit())
sSpPr = m_sSpPr.get();
m_oChart->toXML2(sXml, m_oStyle, sSpPr);
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Charts;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChart> m_oChart;
nullable<CChartStyle> m_oStyle;
nullable<OOX::Logic::CAlternateContent> m_oAlternateContent;
nullable<CString> m_sSpPr;
};
}
}
#endif // OOX_CHART_FILE_INCLUDE_H_

View File

@@ -0,0 +1,94 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CHARTSTYLE_FILE_INCLUDE_H_
#define OOX_CHARTSTYLE_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CChartStyle : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartStyle)
CChartStyle()
{
}
virtual ~CChartStyle()
{
}
public:
virtual CString toXML() const
{
int nStyle = 0;
if(m_oVal.IsInit())
nStyle = m_oVal->GetValue();
if(false == (nStyle >= 1 && nStyle <= 48))
nStyle = 2;
CString sXml;
sXml.Format(_T("<mc:AlternateContent xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"><mc:Choice Requires=\"c14\" xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\"><c14:style val=\"%d\"/></mc:Choice><mc:Fallback><c:style val=\"%d\"/></mc:Fallback></mc:AlternateContent>"), 100 + nStyle, nStyle);
return sXml;
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(toXML());
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_c_ChartStyle;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oVal;
};
}
}
#endif // OOX_CHARTSTYLE_FILE_INCLUDE_H_

View File

@@ -0,0 +1,99 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_FROMTO_FILE_INCLUDE_H_
#define OOX_FROMTO_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CFromTo : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFromTo)
CFromTo()
{
}
virtual ~CFromTo()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("xdr:col") == sName )
m_oCol = oReader.GetText2();
else if ( _T("xdr:colOff") == sName )
m_oColOff = oReader.GetText2();
else if ( _T("xdr:row") == sName )
m_oRow = oReader.GetText2();
else if ( _T("xdr:rowOff") == sName )
m_oRowOff = oReader.GetText2();
}
}
virtual EElementType getType () const
{
return et_FromTo;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCol;
nullable<SimpleTypes::CEmu> m_oColOff;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRow;
nullable<SimpleTypes::CEmu> m_oRowOff;
};
}
}
#endif // OOX_FROMTO_FILE_INCLUDE_H_

View File

@@ -0,0 +1,161 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CHARTLAYOUT_FILE_INCLUDE_H_
#define OOX_CHARTLAYOUT_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CChartManualLayout : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartManualLayout)
CChartManualLayout() {}
virtual ~CChartManualLayout() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:h") == sName )
m_oH = oReader;
else if ( _T("c:hMode") == sName )
m_oHMode = oReader;
else if ( _T("c:layoutTarget") == sName )
m_oLayoutTarget = oReader;
else if ( _T("c:w") == sName )
m_oW = oReader;
else if ( _T("c:wMode") == sName )
m_oWMode = oReader;
else if ( _T("c:x") == sName )
m_oX = oReader;
else if ( _T("c:xMode") == sName )
m_oXMode = oReader;
else if ( _T("c:y") == sName )
m_oY = oReader;
else if ( _T("c:yMode") == sName )
m_oYMode = oReader;
}
}
virtual EElementType getType() const
{
return et_c_ManualLayout;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<ComplexTypes::Spreadsheet::CDouble> m_oH;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oHMode;
nullable<ComplexTypes::Spreadsheet::CChartLayoutTarget> m_oLayoutTarget;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oW;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oWMode;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oX;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oXMode;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oY;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oYMode;
};
class CChartLayout : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartLayout)
CChartLayout() {}
virtual ~CChartLayout() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:manualLayout") == sName )
m_oManualLayout = oReader;
}
}
virtual EElementType getType() const
{
return et_c_Layout;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartManualLayout> m_oManualLayout;
};
}
}
#endif // OOX_CHARTLAYOUT_FILE_INCLUDE_H_

View File

@@ -0,0 +1,342 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CHARTLEGEND_FILE_INCLUDE_H_
#define OOX_CHARTLEGEND_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CChartManualLayout : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartManualLayout)
CChartManualLayout() {}
virtual ~CChartManualLayout() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:h") == sName )
m_oH = oReader;
else if ( _T("c:hMode") == sName )
m_oHMode = oReader;
else if ( _T("c:layoutTarget") == sName )
m_oLayoutTarget = oReader;
else if ( _T("c:w") == sName )
m_oW = oReader;
else if ( _T("c:wMode") == sName )
m_oWMode = oReader;
else if ( _T("c:x") == sName )
m_oX = oReader;
else if ( _T("c:xMode") == sName )
m_oXMode = oReader;
else if ( _T("c:y") == sName )
m_oY = oReader;
else if ( _T("c:yMode") == sName )
m_oYMode = oReader;
}
}
virtual EElementType getType() const
{
return et_c_ManualLayout;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<ComplexTypes::Spreadsheet::CDouble> m_oH;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oHMode;
nullable<ComplexTypes::Spreadsheet::CChartLayoutTarget> m_oLayoutTarget;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oW;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oWMode;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oX;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oXMode;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oY;
nullable<ComplexTypes::Spreadsheet::CChartHMode> m_oYMode;
};
class CChartLayout : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartLayout)
CChartLayout() {}
virtual ~CChartLayout() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:manualLayout") == sName )
m_oManualLayout = oReader;
}
}
virtual EElementType getType() const
{
return et_c_Layout;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartManualLayout> m_oManualLayout;
};
class CChartLegendPos : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartLegendPos)
CChartLegendPos() {}
virtual ~CChartLegendPos() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType() const
{
return et_c_LegendPos;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CChartLegendPos<> > m_oVal;
};
class CChartLegendEntry : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartLegendEntry)
CChartLegendEntry() {}
virtual ~CChartLegendEntry() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oIndex.IsInit() && m_oIndex->m_oVal.IsInit() && (m_oDelete.IsInit() || m_oTxPr.IsInit()))
{
writer.WriteStringC(_T("<c:legendEntry>"));
if(m_oIndex.IsInit())
{
CString sXml;
sXml.Format(_T("<c:idx val=\"%d\"/>"), m_oIndex->m_oVal->GetValue());
writer.WriteStringC(sXml);
}
if(m_oDelete.IsInit())
{
CString sXml;
sXml.Format(_T("<c:delete val=\"%s\"/>"), m_oDelete->m_oVal.ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sXml);
}
if(m_oTxPr.IsInit() && m_oTxPr->m_oXml.IsInit())
writer.WriteStringC(m_oTxPr->m_oXml.get2());
writer.WriteStringC(_T("</c:legendEntry>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:idx") == sName )
m_oIndex = oReader;
else if ( _T("c:delete") == sName )
m_oDelete = oReader;
else if ( _T("c:txPr") == sName )
m_oTxPr = oReader;
}
}
virtual EElementType getType() const
{
return et_c_LegendEntry;
}
public:
nullable<ComplexTypes::Spreadsheet::CDecimalNumber> m_oIndex;
nullable<ComplexTypes::Spreadsheet::COnOff2<>> m_oDelete;
nullable<OOX::Spreadsheet::CChartRich > m_oTxPr;
};
class CChartLegend : public WritingElementWithChilds<CChartLegendEntry>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartLegend)
CChartLegend()
{
}
virtual ~CChartLegend()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(CString(_T("<c:legend>")));
CString sLegendPos = _T("r");
if(m_oLegendPos.IsInit() && m_oLegendPos->m_oVal.IsInit())
sLegendPos = m_oLegendPos->m_oVal->ToString();
CString sLegendPosXml;sLegendPosXml.Format(_T("<c:legendPos val=\"%s\"/>"), sLegendPos);
for(int i = 0 , length = m_arrItems.GetSize(); i < length; ++i)
{
m_arrItems[i]->toXML(writer);
}
writer.WriteStringC(sLegendPosXml);
writer.WriteStringC(CString(_T("<c:layout/>")));
CString sOverlay = _T("0");
if(m_oOverlay.IsInit())
sOverlay = m_oOverlay->m_oVal.ToString2(SimpleTypes::onofftostring1);
CString sOverlayXml;sOverlayXml.Format(_T("<c:overlay val=\"%s\"/>"), sOverlay);
writer.WriteStringC(sOverlayXml);
if(m_oTxPr.IsInit())
m_oTxPr->toXML(writer);
writer.WriteStringC(CString(_T("</c:legend>")));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:overlay") == sName )
m_oOverlay = oReader;
else if ( _T("c:layout") == sName )
m_oLayout = oReader;
else if ( _T("c:legendPos") == sName )
m_oLegendPos = oReader;
else if ( _T("c:legendEntry") == sName )
m_arrItems.Add(new CChartLegendEntry(oReader));
else if ( _T("c:txPr") == sName )
m_oTxPr = oReader;
}
}
virtual EElementType getType () const
{
return et_c_Legend;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<ComplexTypes::Spreadsheet::COnOff2<>> m_oOverlay;
nullable<CChartLegendPos> m_oLegendPos;
nullable<CChartLayout> m_oLayout;
nullable<CChartRich> m_oTxPr;
};
}
}
#endif // OOX_CHARTLEGEND_FILE_INCLUDE_H_

View File

@@ -0,0 +1,283 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CHARTPLOTAREA_FILE_INCLUDE_H_
#define OOX_CHARTPLOTAREA_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Title.h"
#include "BasicChart.h"
namespace OOX
{
namespace Spreadsheet
{
class CChartCatAx : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartCatAx)
CChartCatAx() {}
virtual ~CChartCatAx() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
void toXML2(CString& sDelete, CString& sMajorGrid, CString& sAxTitle, CString& sTxPr) const
{
if(m_oDelete.IsInit())
sDelete.Format(_T("<c:delete val=\"%s\"/>"), m_oDelete->m_oVal.ToString2(SimpleTypes::onofftostring1));
if(m_oAxPos.IsInit())
{
CString sAxPos;
sAxPos.Format(_T("<c:axPos %s/>"), m_oAxPos->ToString());
}
if(m_oMajorGridlines.IsInit() && true == m_oMajorGridlines->ToBool())
sMajorGrid = _T("<c:majorGridlines/>");
if(m_oTitle.IsInit())
{
CStringWriter temp;
m_oTitle->toXML(temp);
sAxTitle = temp.GetCString();
}
if(m_oTxPr.IsInit() && m_oTxPr->m_oXml.IsInit())
{
sTxPr = m_oTxPr->m_oXml.get();
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:title") == sName )
m_oTitle = oReader;
else if ( _T("c:delete") == sName )
m_oDelete = oReader;
else if ( _T("c:majorGridlines") == sName )
{
m_oMajorGridlines.Init();
m_oMajorGridlines->SetValue(SimpleTypes::onoffTrue);
}
else if ( _T("c:axPos") == sName )
m_oAxPos = oReader;
else if ( _T("c:numFmt") == sName )
m_oNumFmt = oReader;
else if ( _T("c:txPr") == sName )
m_oTxPr = oReader;
}
}
virtual EElementType getType() const
{
return et_c_CatAx;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartTitle> m_oTitle;
nullable<ComplexTypes::Spreadsheet::COnOff2<>> m_oDelete;
nullable<SimpleTypes::COnOff<>> m_oMajorGridlines;
nullable<ComplexTypes::Spreadsheet::CChartAxPos> m_oAxPos;
nullable<OOX::Spreadsheet::CNumFmt> m_oNumFmt;
nullable<OOX::Spreadsheet::CChartRich> m_oTxPr;
};
class CChartPlotArea : public WritingElementWithChilds<CChartCatAx>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartPlotArea)
CChartPlotArea()
{
}
virtual ~CChartPlotArea()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
void toXML2(bool bScatter, bool bLine, CString& sBarDir, CString& sGrouping, CString& sSeries, CString& sDataLabels, CString& sOverlap, CString& sCatAxDelete, CString& sCatAxMajorGrid, CString& sCatAxTitle, CString& sCatTxPr, CString& sValAxDelete, CString& sValAxMajorGrid, CString& sValAxTitle, CString& sValTxPr) const
{
if(m_oBasicChart.IsInit())
m_oBasicChart->toXML2(bScatter, bLine, sBarDir, sGrouping, sSeries, sDataLabels, sOverlap);
if(m_oCatAx.IsInit())
{
m_oCatAx->toXML2(sCatAxDelete, sCatAxMajorGrid, sCatAxTitle, sCatTxPr);
if(m_arrItems.GetSize() > 0)
m_arrItems[0]->toXML2(sValAxDelete, sValAxMajorGrid, sValAxTitle, sValTxPr);
}
else
{
if(m_arrItems.GetSize() > 0)
m_arrItems[0]->toXML2(sCatAxDelete, sCatAxMajorGrid, sCatAxTitle, sCatTxPr);
if(m_arrItems.GetSize() > 1)
m_arrItems[1]->toXML2(sValAxDelete, sValAxMajorGrid, sValAxTitle, sValTxPr);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:barChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicBarChart);
}
else if ( _T("c:bar3DChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicBar3DChart);
}
else if ( _T("c:lineChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicLineChart);
}
else if ( _T("c:line3DChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicLine3DChart);
}
else if ( _T("c:areaChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicAreaChart);
}
else if ( _T("c:area3DChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicArea3DChart);
}
else if ( _T("c:pieChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicPieChart);
}
else if ( _T("c:pie3DChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicPie3DChart);
}
else if ( _T("c:bubbleChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicBubbleChart);
}
else if ( _T("c:scatterChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicScatterChart);
}
else if ( _T("c:radarChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicRadarChart);
}
else if ( _T("c:doughnutChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicDoughnutChart);
}
else if ( _T("c:stockChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicStockChart);
}
else if ( _T("c:surfaceChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicSurfaceChart);
}
else if ( _T("c:surface3DChart") == sName )
{
m_oBasicChart = oReader;
m_oBasicChart->setBasicType(OOX::Spreadsheet::chartbasicSurface3DChart);
}
else if ( _T("c:catAx") == sName || _T("c:dateAx") == sName )
m_oCatAx = oReader;
else if ( _T("c:valAx") == sName )
m_arrItems.Add( new CChartCatAx(oReader));
else if ( _T("c:serAx") == sName )
m_oSerAx = oReader;
}
}
virtual EElementType getType () const
{
return et_c_PlotArea;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartCatAx> m_oCatAx;
nullable<CChartCatAx> m_oSerAx;
nullable<CChartBasicChart> m_oBasicChart;
};
}
}
#endif // OOX_CHARTPLOTAREA_FILE_INCLUDE_H_

View File

@@ -0,0 +1,349 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CHARTTITLE_FILE_INCLUDE_H_
#define OOX_CHARTTITLE_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CChartText : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartText)
CChartText() {}
virtual ~CChartText() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<a:t"));
if(-1 != m_sText.Find(' ') || -1 != m_sText.Find('\n'))
writer.WriteStringC(_T(" xml:space=\"preserve\""));
writer.WriteStringC(_T(">"));
writer.WriteStringC(XmlUtils::EncodeXmlString(m_sText));
writer.WriteStringC(_T("</a:t>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
m_sText = oReader.GetText2();
}
CString ToString() const
{
return m_sText;
}
virtual EElementType getType() const
{
return et_a_Text;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.GetAttributesCount() <= 0 )
return;
if ( !oReader.MoveToFirstAttribute() )
return;
CWCharWrapper wsName = oReader.GetName();
while( !wsName.IsNull() )
{
if ( _T("xml:space") == wsName )
{
m_oSpace = oReader.GetText();
break;
}
if ( !oReader.MoveToNextAttribute() )
break;
wsName = oReader.GetName();
}
oReader.MoveToElement();
}
public:
nullable<SimpleTypes::CXmlSpace<> > m_oSpace;
CString m_sText;
};
class CChartRun : public WritingElementWithChilds<CChartText>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartRun)
CChartRun()
{
}
virtual ~CChartRun()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("a:t") == sName )
m_arrItems.Add( new CChartText( oReader ));
}
}
virtual EElementType getType () const
{
return et_a_Run;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
class CChartParagraph : public WritingElementWithChilds<CChartRun>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartParagraph)
CChartParagraph()
{
}
virtual ~CChartParagraph()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("a:r") == sName )
m_arrItems.Add( new CChartRun( oReader ));
}
}
virtual EElementType getType () const
{
return et_a_Paragraph;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
class CChartRich : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartRich)
CChartRich() {}
virtual ~CChartRich() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oXml.IsInit())
writer.WriteStringC(m_oXml.get());
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
m_oXml.Init();
m_oXml->AppendFormat(_T("<c:rich xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">%s</c:rich>"), oReader.GetInnerXml());
}
virtual EElementType getType() const
{
return et_c_Rich;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CString> m_oXml;
};
class CChartTx : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartTx)
CChartTx() {}
virtual ~CChartTx() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<c:tx>"));
if(m_oRich.IsInit())
m_oRich->toXML(writer);
writer.WriteStringC(_T("</c:tx>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:rich") == sName )
m_oRich = oReader;
}
}
virtual EElementType getType() const
{
return et_c_Tx;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartRich> m_oRich;
};
class CChartTitle : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartTitle)
CChartTitle()
{
}
virtual ~CChartTitle()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<c:title>"));
if(m_oTx.IsInit())
m_oTx->toXML(writer);
writer.WriteStringC(_T("<c:layout/><c:overlay val=\"0\"/>"));
if(m_oTxPr.IsInit())
m_oTxPr->toXML(writer);
writer.WriteStringC(_T("</c:title>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:tx") == sName )
m_oTx = oReader;
else if ( _T("c:txPr") == sName )
m_oTxPr = oReader;
}
}
virtual EElementType getType () const
{
return et_c_Title;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartTx> m_oTx;
nullable<CChartRich> m_oTxPr;
};
}
}
#endif // OOX_CHARTTITLE_FILE_INCLUDE_H_

View File

@@ -0,0 +1,559 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_XLSXCOMMENTS_FILE_INCLUDE_H_
#define OOX_XLSXCOMMENTS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "../../DocxFormat/Logic/Vml.h"
#include "../SharedStrings/Si.h"
namespace OOX
{
namespace Spreadsheet
{
class CCommentItem
{
public:
nullable<unsigned int> m_nLeft;
nullable<unsigned int> m_nTop;
nullable<unsigned int> m_nRight;
nullable<unsigned int> m_nBottom;
nullable<unsigned int> m_nLeftOffset;
nullable<unsigned int> m_nTopOffset;
nullable<unsigned int> m_nRightOffset;
nullable<unsigned int> m_nBottomOffset;
nullable<double> m_dLeftMM;
nullable<double> m_dTopMM;
nullable<double> m_dWidthMM;
nullable<double> m_dHeightMM;
nullable<CString> m_sAuthor;
nullable<unsigned int> m_nRow;
nullable<unsigned int> m_nCol;
nullable<bool> m_bMove;
nullable<bool> m_bSize;
nullable<CSi> m_oText;
nullable<CString> m_sGfxdata;
CCommentItem()
{
}
bool IsValid()
{
return m_nRow.IsInit() && m_nCol.IsInit() && m_sAuthor.IsInit();
}
};
class CAuthors : public WritingElementWithChilds<CString>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CAuthors)
CAuthors()
{
}
virtual ~CAuthors()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(CString("<authors>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
{
CString sAuthor;sAuthor.Format(_T("<author>%s</author>"), XmlUtils::EncodeXmlString(*m_arrItems[i]));
writer.WriteStringC(sAuthor);
}
writer.WriteStringC(CString("</authors>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("author") == sName )
m_arrItems.Add(new CString(oReader.GetText2()));
}
}
virtual EElementType getType () const
{
return et_Authors;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
class CComment : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CComment)
CComment()
{
}
virtual ~CComment()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oRef.IsInit() && m_oAuthorId.IsInit() && m_oText.IsInit())
{
writer.WriteStringC(CString("<comment"));
if(m_oRef.IsInit())
{
CString sRef;sRef.Format(_T(" ref=\"%s\""), XmlUtils::EncodeXmlString(m_oRef->GetValue()));
writer.WriteStringC(sRef);
}
if(m_oAuthorId.IsInit())
{
CString sAuthorId;sAuthorId.Format(_T(" authorId=\"%d\""), m_oAuthorId->GetValue());
writer.WriteStringC(sAuthorId);
}
writer.WriteStringC(CString(">"));
writer.WriteStringC(CString("<text>"));
m_oText->toXML2(writer);
writer.WriteStringC(CString("</text>"));
writer.WriteStringC(CString("</comment>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("text") == sName )
m_oText =oReader;
}
}
virtual EElementType getType () const
{
return et_Comment;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("authorId"), m_oAuthorId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oRef;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oAuthorId;
nullable<CSi> m_oText;
};
class CCommentList : public WritingElementWithChilds<CComment>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCommentList)
CCommentList()
{
}
virtual ~CCommentList()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(CString("<commentList>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
{
m_arrItems[i]->toXML(writer);
}
writer.WriteStringC(CString("</commentList>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("comment") == sName )
m_arrItems.Add(new CComment(oReader));
}
}
virtual EElementType getType () const
{
return et_CommentList;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
class CComments : public OOX::FileGlobalEnumerated, public OOX::Spreadsheet::IFileContainer
{
public:
CComments()
{
}
CComments(const CPath& oPath)
{
read( oPath );
}
virtual ~CComments()
{
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("comments") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
sName = oReader.GetName();
if ( _T("authors") == sName )
m_oAuthors = oReader;
else if ( _T("commentList") == sName )
m_oCommentList = oReader;
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
CStringWriter sXml;
sXml.WriteStringC(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"));
if(m_oAuthors.IsInit())
m_oAuthors->toXML(sXml);
if(m_oCommentList.IsInit())
m_oCommentList->toXML(sXml);
sXml.WriteStringC(_T("</comments>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write(oPath, oDirectory, oContent);
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Comments;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CAuthors > m_oAuthors;
nullable<CCommentList > m_oCommentList;
};
class CLegacyDrawingWorksheet : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CLegacyDrawingWorksheet)
CLegacyDrawingWorksheet()
{
}
virtual ~CLegacyDrawingWorksheet()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oId.IsInit())
{
CString sVal;sVal.Format(_T("<legacyDrawing r:id=\"%s\"/>"), m_oId->GetValue());
writer.WriteStringC(sVal);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_FromTo;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oId;
};
class CLegacyDrawing : public OOX::FileGlobalEnumerated, public OOX::Spreadsheet::IFileContainer
{
public:
CLegacyDrawing()
{
m_mapComments = NULL;
}
CLegacyDrawing(const CPath& oPath)
{
m_mapComments = NULL;
read( oPath );
}
virtual ~CLegacyDrawing()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("xml") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
sName = oReader.GetName();
OOX::Vml::CShape *pItem = NULL;
if ( _T("v:shape") == sName )
{
pItem = new OOX::Vml::CShape( oReader );
if ( pItem )
m_arrItems.Add( pItem );
}
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
if(NULL != m_mapComments && m_mapComments->GetCount() > 0)
{
CStringWriter sXml;
sXml.WriteStringC(_T("<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout><v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\"><v:stroke joinstyle=\"miter\"/><v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/></v:shapetype>"));
int nIndex = 1025;
POSITION pos = m_mapComments->GetStartPosition();
while ( NULL != pos )
{
CAtlMap<CString, OOX::Spreadsheet::CCommentItem*>::CPair* pPair = m_mapComments->GetNext( pos );
if(NULL != pPair)
{
OOX::Spreadsheet::CCommentItem* comment = pPair->m_value;
CString sStyle;
if(comment->m_dLeftMM.IsInit())
{
SimpleTypes::CPoint oPoint;oPoint.FromMm(comment->m_dLeftMM.get());
sStyle.AppendFormat(_T("margin-left:%spt;"), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(oPoint.ToPoints()));
}
if(comment->m_dTopMM.IsInit())
{
SimpleTypes::CPoint oPoint;oPoint.FromMm(comment->m_dTopMM.get());
sStyle.AppendFormat(_T("margin-top:%spt;"), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(oPoint.ToPoints()));
}
if(comment->m_dWidthMM.IsInit())
{
SimpleTypes::CPoint oPoint;oPoint.FromMm(comment->m_dWidthMM.get());
sStyle.AppendFormat(_T("width:%spt;"), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(oPoint.ToPoints()));
}
if(comment->m_dHeightMM.IsInit())
{
SimpleTypes::CPoint oPoint;oPoint.FromMm(comment->m_dHeightMM.get());
sStyle.AppendFormat(_T("height:%spt;"), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(oPoint.ToPoints()));
}
CString sClientData;
sClientData.Append(_T("<x:ClientData ObjectType=\"Note\">"));
if(comment->m_bMove.IsInit() && true == comment->m_bMove.get())
sClientData.Append(_T("<x:MoveWithCells/>"));
if(comment->m_bSize.IsInit() && true == comment->m_bSize.get())
sClientData.Append(_T("<x:SizeWithCells/>"));
if(comment->m_nLeft.IsInit() && comment->m_nLeftOffset.IsInit() && comment->m_nTop.IsInit() && comment->m_nTopOffset.IsInit() &&
comment->m_nRight.IsInit() && comment->m_nRightOffset.IsInit() && comment->m_nBottom.IsInit() && comment->m_nBottomOffset.IsInit())
sClientData.AppendFormat(_T("<x:Anchor>%d, %d, %d, %d, %d, %d, %d, %d</x:Anchor>"),
comment->m_nLeft.get(), comment->m_nLeftOffset.get(), comment->m_nTop.get(), comment->m_nTopOffset.get(),
comment->m_nRight.get(), comment->m_nRightOffset.get(), comment->m_nBottom.get(), comment->m_nBottomOffset.get());
sClientData.Append(_T("<x:AutoFill>False</x:AutoFill>"));
if(comment->m_nRow.IsInit())
sClientData.AppendFormat(_T("<x:Row>%d</x:Row>"), comment->m_nRow.get());
if(comment->m_nCol.IsInit())
sClientData.AppendFormat(_T("<x:Column>%d</x:Column>"), comment->m_nCol.get());
sClientData.Append(_T("</x:ClientData>"));
CString sGfxdata;
if(comment->m_sGfxdata.IsInit())
sGfxdata.Format(_T("o:gfxdata=\"%s\""), comment->m_sGfxdata.get2());
CString sShape;sShape.Format(_T("<v:shape id=\"_x0000_s%d\" type=\"#_x0000_t202\" style='position:absolute;%sz-index:4;visibility:hidden' %s fillcolor=\"#ffffe1\" o:insetmode=\"auto\"><v:fill color2=\"#ffffe1\"/><v:shadow on=\"t\" color=\"black\" obscured=\"t\"/><v:path o:connecttype=\"none\"/><v:textbox style='mso-direction-alt:auto'><div style='text-align:left'></div></v:textbox>%s</v:shape>"), nIndex, sStyle, sGfxdata, sClientData);
sXml.WriteStringC(sShape);
nIndex++;
}
}
sXml.WriteStringC(_T("</xml>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.AddDefault( oPath.GetFilename() );
IFileContainer::Write(oPath, oDirectory, oContent);
}
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::LegacyDrawings;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
void ClearItems()
{
for ( int nIndex = 0; nIndex < m_arrItems.GetSize(); nIndex++ )
{
if ( m_arrItems[nIndex] )
delete m_arrItems[nIndex];
m_arrItems[nIndex] = NULL;
}
m_arrItems.RemoveAll();
}
public:
CSimpleArray<OOX::Vml::CShape *> m_arrItems;
CAtlMap<CString, OOX::Spreadsheet::CCommentItem*>* m_mapComments;
};
}
}
#endif // OOX_XLSXCOMMENTS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,48 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#include "CommonInclude.h"
#include "Common.h"
#define DBL_MAX 15
#define DBL_MAXDIG10 17
CString OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(double dVal)
{
char buffer[_CVTBUFSIZE];
_gcvt( dVal, DBL_MAXDIG10, buffer );
CString sRes(buffer);
int nLength = sRes.GetLength();
if(nLength > 0 && '.' == sRes[nLength - 1])
sRes = sRes.Left(nLength - 1);
return sRes;
}

View File

@@ -0,0 +1,43 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
namespace OOX
{
namespace Spreadsheet
{
namespace SpreadsheetCommon
{
CString WriteDouble(double dVal);
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "../Base/Nullable.h"
#include "../Common/SimpleTypes_Word.h"
#include "../Common/SimpleTypes_Shared.h"
#include "../DocxFormat/Rels.h"
#include "ComplexTypes_Spreadsheet.h"
#include "FileTypes_Spreadsheet.h"
#include "WritingElement.h"
#include "SimpleTypes_Spreadsheet.h"
#include "Common.h"
#include "IFileContainer_Spreadsheet.h"

View File

@@ -0,0 +1,495 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "../Common/ComplexTypes.h"
#include "SimpleTypes_Spreadsheet.h"
namespace ComplexTypes
{
namespace Spreadsheet
{
template<SimpleTypes::EOnOff eDefValue = SimpleTypes::onoffTrue>
class COnOff2 : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(COnOff2)
COnOff2()
{
}
virtual ~COnOff2()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
sResult += "val=\"";
sResult += m_oVal.ToString();
sResult += "\" ";
return sResult;
}
void FromBool(bool bVal)
{
m_oVal.FromBool(bVal);
}
public:
SimpleTypes::COnOff<eDefValue> m_oVal;
};
class CDecimalNumber : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CDecimalNumber)
CDecimalNumber()
{
}
virtual ~CDecimalNumber()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::CDecimalNumber<> > m_oVal;
};
class CString_ : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CString_)
CString_()
{
}
virtual ~CString_()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_sVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_sVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_sVal.IsInit() )
{
sResult += "val=\"";
sResult += m_sVal->GetString();
sResult += "\" ";
}
return sResult;
}
CString ToString2() const
{
CString sResult;
if ( m_sVal.IsInit() )
sResult += m_sVal.get();
return sResult;
}
public:
nullable<CString> m_sVal;
};
class CDouble : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CDouble)
CDouble()
{
}
virtual ~CDouble()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::CDouble > m_oVal;
};
class CPointMeasure : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CPointMeasure)
CPointMeasure()
{
}
virtual ~CPointMeasure()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::CPointMeasure<> > m_oVal;
};
class CChartLayoutTarget : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CChartLayoutTarget)
CChartLayoutTarget()
{
}
virtual ~CChartLayoutTarget()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::Spreadsheet::CChartLayoutTarget<> > m_oVal;
};
class CChartHMode : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CChartHMode)
CChartHMode()
{
}
virtual ~CChartHMode()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::Spreadsheet::CChartHMode<> > m_oVal;
};
class CChartAxPos : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CChartAxPos)
CChartAxPos()
{
}
virtual ~CChartAxPos()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::Spreadsheet::CChartAxPos<> > m_oVal;
};
class CChartBarGrouping : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CChartBarGrouping)
CChartBarGrouping()
{
}
virtual ~CChartBarGrouping()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::Spreadsheet::CChartBarGrouping<> > m_oVal;
};
class CChartBarDerection : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CChartBarDerection)
CChartBarDerection()
{
}
virtual ~CChartBarDerection()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::Spreadsheet::CChartBarDerection<> > m_oVal;
};
class CChartSymbol : public ComplexType
{
public:
ComplexTypes_AdditionConstructors(CChartSymbol)
CChartSymbol()
{
}
virtual ~CChartSymbol()
{
}
virtual void FromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("val"), m_oVal );
}
virtual void FromXML(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
virtual CString ToString() const
{
CString sResult;
if ( m_oVal.IsInit() )
{
sResult += "val=\"";
sResult += m_oVal->ToString();
sResult += "\" ";
}
return sResult;
}
public:
nullable<SimpleTypes::Spreadsheet::CChartSymbol<> > m_oVal;
};
}
}

View File

@@ -0,0 +1,173 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CELLANCHOR_FILE_INCLUDE_H_
#define OOX_CELLANCHOR_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "FromTo.h"
#include "Pic.h"
#include "GraphicFrame.h"
#include "Pos.h"
namespace OOX
{
namespace Spreadsheet
{
class CCellAnchor : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCellAnchor)
CCellAnchor(SimpleTypes::Spreadsheet::CCellAnchorType<>& oAnchorType = SimpleTypes::Spreadsheet::CCellAnchorType<>()):m_oAnchorType(oAnchorType)
{
}
virtual ~CCellAnchor()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(isValid())
{
CString sStart;
CString sEnd;
if(m_oFrom.IsInit() && m_oTo.IsInit())
{
sStart.Format(_T("<xdr:twoCellAnchor editAs=\"%s\">"), m_oAnchorType.ToString());
sEnd = _T("</xdr:twoCellAnchor>");
writer.WriteStringC(sStart);
if(m_oFrom.IsInit())
m_oFrom->toXML2(writer, _T("xdr:from"));
if(m_oTo.IsInit())
m_oTo->toXML2(writer, _T("xdr:to"));
}
else if(m_oFrom.IsInit() && m_oExt.IsInit())
{
sStart.Append(_T("<xdr:oneCellAnchor>"));
sEnd = _T("</xdr:oneCellAnchor>");
writer.WriteStringC(sStart);
if(m_oFrom.IsInit())
m_oFrom->toXML2(writer, _T("xdr:from"));
if(m_oExt.IsInit())
m_oExt->toXML(writer);
}
else if(m_oPos.IsInit() && m_oExt.IsInit())
{
sStart.Append(_T("<xdr:absoluteAnchor>"));
sEnd = _T("</xdr:absoluteAnchor>");
writer.WriteStringC(sStart);
if(m_oPos.IsInit())
m_oPos->toXML(writer);
if(m_oExt.IsInit())
m_oExt->toXML(writer);
}
else
return;
if(m_oXml.IsInit())
writer.WriteStringC(m_oXml.get());
if(m_oGraphicFrame.IsInit())
m_oGraphicFrame->toXML(writer);
writer.WriteStringC(sEnd);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("xdr:from") == sName )
m_oFrom = oReader;
else if ( _T("xdr:to") == sName )
m_oTo = oReader;
else if ( _T("xdr:pos") == sName )
m_oPos = oReader;
else if ( _T("xdr:ext") == sName )
m_oExt = oReader;
else if ( _T("xdr:graphicFrame") == sName )
m_oGraphicFrame = oReader;
else if ( _T("xdr:pic") == sName || _T("xdr:sp") == sName || _T("xdr:grpSp") == sName || _T("xdr:cxnSp") == sName || _T("mc:AlternateContent") == sName)
m_oXml = oReader.GetOuterXml();
}
}
virtual EElementType getType () const
{
return et_CellAnchor;
}
virtual void setAnchorType (SimpleTypes::Spreadsheet::ECellAnchorType eType)
{
m_oAnchorType.SetValue(eType);
}
virtual SimpleTypes::Spreadsheet::ECellAnchorType getAnchorType () const
{
return m_oAnchorType.GetValue();
}
bool isValid() const
{
SimpleTypes::Spreadsheet::ECellAnchorType eAnchorType = m_oAnchorType.GetValue();
if(!((m_oFrom.IsInit() && m_oTo.IsInit()) || (m_oFrom.IsInit() && m_oExt.IsInit()) || (m_oPos.IsInit() && m_oExt.IsInit())))
return false;
if(false == m_oXml.IsInit() && false == m_oGraphicFrame.IsInit())
return false;
return true;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
SimpleTypes::Spreadsheet::CCellAnchorType<> m_oAnchorType;
nullable<OOX::Spreadsheet::CFromTo> m_oFrom;
nullable<OOX::Spreadsheet::CFromTo> m_oTo;
nullable<OOX::Spreadsheet::CPos> m_oPos;
nullable<OOX::Spreadsheet::CExt> m_oExt;
nullable<OOX::Spreadsheet::CGraphicFrame> m_oGraphicFrame;
nullable<CString> m_oXml;
};
}
}
#endif // OOX_CELLANCHOR_FILE_INCLUDE_H_

View File

@@ -0,0 +1,218 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_DRAWING_FILE_INCLUDE_H_
#define OOX_DRAWING_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Image.h"
#include "CellAnchor.h"
namespace OOX
{
namespace Spreadsheet
{
class CDrawingWorksheet : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDrawingWorksheet)
CDrawingWorksheet()
{
}
virtual ~CDrawingWorksheet()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oId.IsInit())
{
CString sVal;sVal.Format(_T("<drawing r:id=\"%s\"/>"), m_oId->GetValue());
writer.WriteStringC(sVal);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_FromTo;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oId;
};
class CDrawing : public OOX::FileGlobalEnumerated, public OOX::Spreadsheet::IFileContainer
{
public:
CDrawing()
{
}
CDrawing(const CPath& oPath)
{
read( oPath );
}
virtual ~CDrawing()
{
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("xdr:wsDr") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
sName = oReader.GetName();
CCellAnchor *pItem = NULL;
if ( _T("xdr:absoluteAnchor") == sName )
{
pItem = new CCellAnchor( oReader );
pItem->m_oAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorAbsolute);
}
else if ( _T("xdr:oneCellAnchor") == sName )
{
pItem = new CCellAnchor( oReader );
pItem->m_oAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorOneCell);
}
else if ( _T("xdr:twoCellAnchor") == sName )
{
pItem = new CCellAnchor( oReader );
pItem->m_oAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorTwoCell);
}
if ( pItem )
m_arrItems.Add( pItem );
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
CStringWriter sXml;
sXml.WriteStringC(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><xdr:wsDr xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(sXml);
sXml.WriteStringC(_T("</xdr:wsDr>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write(oPath, oDirectory, oContent);
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Drawings;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
const OOX::RId AddImage (CString& sSrc)
{
smart_ptr<OOX::File> oImage = smart_ptr<OOX::File>( new OOX::Spreadsheet::Image( sSrc ) );
const OOX::RId rId = Add( oImage );
return rId;
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
void ClearItems()
{
for ( int nIndex = 0; nIndex < m_arrItems.GetSize(); nIndex++ )
{
if ( m_arrItems[nIndex] )
delete m_arrItems[nIndex];
m_arrItems[nIndex] = NULL;
}
m_arrItems.RemoveAll();
}
public:
CSimpleArray<CCellAnchor *> m_arrItems;
};
}
}
#endif // OOX_DRAWING_FILE_INCLUDE_H_

View File

@@ -0,0 +1,188 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_FROMTO_FILE_INCLUDE_H_
#define OOX_FROMTO_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CFromTo : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFromTo)
CFromTo()
{
}
virtual ~CFromTo()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void toXML2(CStringWriter& writer, CString sName) const
{
CString sStart;sStart.Format(_T("<%s>"), sName);
writer.WriteStringC(sStart);
if(m_oCol.IsInit())
{
CString sVal;sVal.Format(_T("<xdr:col>%d</xdr:col>"), m_oCol->GetValue());
writer.WriteStringC(sVal);
}
if(m_oColOff.IsInit())
{
CString sVal;sVal.Format(_T("<xdr:colOff>%I64d</xdr:colOff>"), m_oColOff->ToEmu());
writer.WriteStringC(sVal);
}
if(m_oRow.IsInit())
{
CString sVal;sVal.Format(_T("<xdr:row>%d</xdr:row>"), m_oRow->GetValue());
writer.WriteStringC(sVal);
}
if(m_oRowOff.IsInit())
{
CString sVal;sVal.Format(_T("<xdr:rowOff>%I64d</xdr:rowOff>"), m_oRowOff->ToEmu());
writer.WriteStringC(sVal);
}
CString sEnd;sEnd.Format(_T("</%s>"), sName);
writer.WriteStringC(sEnd);
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("xdr:col") == sName )
m_oCol = oReader.GetText2();
else if ( _T("xdr:colOff") == sName )
m_oColOff = oReader.GetText2();
else if ( _T("xdr:row") == sName )
m_oRow = oReader.GetText2();
else if ( _T("xdr:rowOff") == sName )
m_oRowOff = oReader.GetText2();
}
}
virtual EElementType getType () const
{
return et_FromTo;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCol;
nullable<SimpleTypes::CEmu> m_oColOff;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRow;
nullable<SimpleTypes::CEmu> m_oRowOff;
};
class CExt : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CExt)
CExt()
{
}
virtual ~CExt()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<xdr:ext"));
if(m_oCx.IsInit())
{
CString sVal;sVal.Format(_T(" cx=\"%I64d\""), m_oCx->ToEmu());
writer.WriteStringC(sVal);
}
if(m_oCy.IsInit())
{
CString sVal;sVal.Format(_T(" cy=\"%I64d\""), m_oCy->ToEmu());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Ext;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cx"), m_oCx )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cy"), m_oCy )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CEmu> m_oCx;
nullable<SimpleTypes::CEmu> m_oCy;
};
}
}
#endif // OOX_FROMTO_FILE_INCLUDE_H_

View File

@@ -0,0 +1,246 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_GRAPHICFRAME_FILE_INCLUDE_H_
#define OOX_GRAPHICFRAME_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CGraphicChart : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CGraphicChart)
CGraphicChart()
{
}
virtual ~CGraphicChart()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Blip;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oRId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId> m_oRId;
};
class CGraphicData : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CGraphicData)
CGraphicData()
{
}
virtual ~CGraphicData()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c:chart") == sName )
m_oChart = oReader;
}
}
virtual EElementType getType () const
{
return et_xdr_GraphicData;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CGraphicChart> m_oChart;
};
class CChartGraphic : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CChartGraphic)
CChartGraphic()
{
}
virtual ~CChartGraphic()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("a:graphicData") == sName )
m_oGraphicData = oReader;
}
}
virtual EElementType getType () const
{
return et_xdr_GraphicFrame;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CGraphicData> m_oGraphicData;
};
class CGraphicFrame : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CGraphicFrame)
CGraphicFrame()
{
}
virtual ~CGraphicFrame()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
CString sRes;
if(m_oChartGraphic.IsInit() && m_oChartGraphic->m_oGraphicData.IsInit() && m_oChartGraphic->m_oGraphicData->m_oChart.IsInit() && m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId.IsInit())
sRes.Format(_T("<xdr:graphicFrame macro=\"\"><xdr:nvGraphicFramePr><xdr:cNvPr id=\"1\" name=\"diagram\"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/></xdr:xfrm><a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%s\"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/>"), m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId->ToString());
writer.WriteStringC(sRes);
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
m_sXml.Init();
m_sXml->Append(oReader.GetOuterXml());
CString sXml;
sXml.Format(_T("<root xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">%s</root>"), m_sXml.get());
XmlUtils::CXmlLiteReader oSubReader;
oSubReader.FromString(sXml);
oSubReader.ReadNextNode();
oSubReader.ReadNextNode();
int nCurDepth = oSubReader.GetDepth();
while( oSubReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oSubReader.GetName();
if ( _T("a:graphic") == sName )
m_oChartGraphic = oSubReader;
}
}
virtual EElementType getType () const
{
return et_xdr_GraphicFrame;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CChartGraphic> m_oChartGraphic;
nullable<CString> m_sXml;
};
}
}
#endif // OOX_GRAPHICFRAME_FILE_INCLUDE_H_

View File

@@ -0,0 +1,81 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_SPREADSHEETIMAGE_INCLUDE_H_
#define OOX_SPREADSHEETIMAGE_INCLUDE_H_
#include "../CommonInclude.h"
#include "../../DocxFormat/Media/Media.h"
namespace OOX
{
namespace Spreadsheet
{
class Image : public Media
{
public:
Image()
{
}
Image(const CPath& filename)
{
read(filename);
}
virtual ~Image()
{
}
public:
virtual void write(const CPath& filename, const CPath& directory, CContentTypes& content) const
{
content.Registration(type().RelationType(), directory, filename.GetFilename());
}
public:
virtual const FileType type() const
{
return OOX::Spreadsheet::FileTypes::Image;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return m_filename.GetFilename();
}
};
}
}
#endif // OOX_SPREADSHEETIMAGE_INCLUDE_H_

View File

@@ -0,0 +1,191 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_PIC_FILE_INCLUDE_H_
#define OOX_PIC_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CBlip : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CBlip)
CBlip()
{
}
virtual ~CBlip()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Blip;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:embed"), m_oEmbed )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId> m_oEmbed;
};
class CBlipFill : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CBlipFill)
CBlipFill()
{
}
virtual ~CBlipFill()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("a:blip") == sName )
m_oBlip = oReader;
}
}
virtual EElementType getType () const
{
return et_BlipFill;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CBlip> m_oBlip;
};
class CPic : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPic)
CPic()
{
}
virtual ~CPic()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oBlipFill.IsInit() && m_oBlipFill->m_oBlip.IsInit() && m_oBlipFill->m_oBlip->m_oEmbed.IsInit())
{
CString sRes;sRes.Format(_T("<xdr:pic><xdr:nvPicPr><xdr:cNvPr id=\"1\" name=\"image\"/><xdr:cNvPicPr><a:picLocks noChangeAspect=\"1\"/></xdr:cNvPicPr></xdr:nvPicPr><xdr:blipFill><a:blip xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:embed=\"%s\" cstate=\"print\"><a:extLst><a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/></a:ext></a:extLst></a:blip><a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic><xdr:clientData/>"), m_oBlipFill->m_oBlip->m_oEmbed->GetValue());
writer.WriteStringC(sRes);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("xdr:blipFill") == sName )
m_oBlipFill = oReader;
}
}
virtual EElementType getType () const
{
return et_Pic;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CBlipFill> m_oBlipFill;
};
}
}
#endif // OOX_PIC_FILE_INCLUDE_H_

View File

@@ -0,0 +1,106 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_POS_FILE_INCLUDE_H_
#define OOX_POS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CPos : public WritingElementWithChilds<>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPos)
CPos()
{
}
virtual ~CPos()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<xdr:pos"));
if(m_oX.IsInit())
{
CString sVal;sVal.Format(_T(" x=\"%I64d\""), m_oX->ToEmu());
writer.WriteStringC(sVal);
}
if(m_oY.IsInit())
{
CString sVal;sVal.Format(_T(" y=\"%I64d\""), m_oY->ToEmu());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_FromTo;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), m_oX )
WritingElement_ReadAttributes_Read_if ( oReader, _T("y"), m_oY )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CEmu> m_oX;
nullable<SimpleTypes::CEmu> m_oY;
};
}
}
#endif // OOX_POS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,85 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#include "CommonInclude.h"
#include "FileTypes_Spreadsheet.h"
#include "SharedStrings/SharedStrings.h"
#include "Styles/Styles.h"
#include "Workbook/Workbook.h"
#include "Worksheets/Worksheet.h"
#include "CalcChain/CalcChain.h"
#include "../DocxFormat/Theme/Theme.h"
#include "Drawing/Image.h"
#include "Table/Table.h"
namespace OOX
{
namespace Spreadsheet
{
smart_ptr<OOX::File> CreateFile(const OOX::CPath& oPath, const OOX::Rels::CRelationShip& oRelation)
{
const CPath oFileName = oPath / oRelation.Filename();
if ( oRelation.Type() == FileTypes::Workbook )
return smart_ptr<OOX::File>(new CWorkbook( oFileName ));
else if ( oRelation.Type() == FileTypes::SharedStrings )
return smart_ptr<OOX::File>(new CSharedStrings( oFileName ));
else if ( oRelation.Type() == FileTypes::Styles )
return smart_ptr<OOX::File>(new CStyles( oFileName ));
else if ( oRelation.Type() == FileTypes::Worksheet )
return smart_ptr<OOX::File>(new CWorksheet( oFileName ));
else if ( oRelation.Type() == OOX::FileTypes::Theme )
return smart_ptr<OOX::File>(new CTheme( oFileName ));
else if ( oRelation.Type() == FileTypes::Drawings )
return smart_ptr<OOX::File>(new CDrawing( oFileName ));
else if ( oRelation.Type() == FileTypes::CalcChain )
return smart_ptr<OOX::File>(new CCalcChain( oFileName ));
else if ( oRelation.Type() == OOX::FileTypes::Image )
return smart_ptr<OOX::File>(new Image( oFileName ));
else if ( oRelation.Type() == FileTypes::Chartsheets )
return smart_ptr<OOX::File>(new CWorksheet( oFileName ));
else if ( oRelation.Type() == FileTypes::Table )
return smart_ptr<OOX::File>(new CTableFile( oFileName ));
else if ( oRelation.Type() == FileTypes::LegacyDrawings )
return smart_ptr<OOX::File>(new CLegacyDrawing( oFileName ));
else if ( oRelation.Type() == FileTypes::Comments )
return smart_ptr<OOX::File>(new CComments( oFileName ));
else if ( oRelation.Type() == FileTypes::Charts )
return smart_ptr<OOX::File>(new CChartSpace( oFileName ));
return smart_ptr<OOX::File>( new UnknowTypeFile() );
}
}
} // namespace OOX

View File

@@ -0,0 +1,56 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_XLSXFILE_FACTORY_INCLUDE_H_
#define OOX_XLSXFILE_FACTORY_INCLUDE_H_
#include "../Base/SmartPtr.h"
#include "../SystemUtility/SystemUtility.h"
namespace OOX
{
class File;
namespace Rels
{
class CRelationShip;
}
}
namespace OOX
{
namespace Spreadsheet
{
NSCommon::smart_ptr<OOX::File> CreateFile(const CPath& oPath, const OOX::Rels::CRelationShip& oRelation);
}
}
#endif // OOX_XLSXFILE_FACTORY_INCLUDE_H_

View File

@@ -0,0 +1,99 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_XSLXFILE_TYPES_SPREADSHEET_INCLUDE_H_
#define OOX_XSLXFILE_TYPES_SPREADSHEET_INCLUDE_H_
#include "../DocxFormat/FileType.h"
namespace OOX
{
namespace Spreadsheet
{
namespace FileTypes
{
const FileType Workbook(L"xl", L"workbook.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"));
const FileType SharedStrings(L"", L"sharedStrings.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"));
const FileType Styles(L"", L"styles.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"));
const FileType Worksheet(L"worksheets", L"sheet.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"), true);
const FileType Chartsheets(L"chartsheets", L"sheet.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"), true);
const FileType CalcChain(L"", L"calcChain.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain"));
const FileType Drawings(L"../drawings", L"drawing.xml",
_T("application/vnd.openxmlformats-officedocument.drawing+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"), true, true);
const FileType LegacyDrawings(L"../drawings", L"vmlDrawing.vml",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"), true, true);
const FileType Comments(L"../", L"comments.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"), true, true);
const FileType Image(L"../media", L"image.jpg",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"));
const FileType Charts(L"../charts", L"chart.xml",
_T("application/vnd.openxmlformats-officedocument.drawingml.chart+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"), true, true);
const FileType Table(L"../tables", L"table.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"), true, true);
const FileType Unknown(L"", L"", _T(""), _T(""));
}
}
}
#endif // OOX_XSLXFILE_TYPES_SPREADSHEET_INCLUDE_H_

View File

@@ -0,0 +1,390 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#include "CommonInclude.h"
#include "IFileContainer_Spreadsheet.h"
#include "FileFactory_Spreadsheet.h"
#include "../DocxFormat/Rels.h"
#include "../DocxFormat/ContentTypes.h"
#include "../DocxFormat/FileType.h"
#include "../DocxFormat/External/External.h"
#include "../DocxFormat/External/HyperLink.h"
namespace OOX
{
namespace Spreadsheet
{
CAtlMap<CString, size_t> IFileContainer::m_mapEnumeratedGlobal;
UnknowTypeFile IFileContainer::Unknown;
void IFileContainer::Read (const OOX::CPath& oPath)
{
RELEASEOBJECT(m_pCurRels);
m_pCurRels = new OOX::CRels(oPath);
Read( *m_pCurRels, oPath.GetDirectory() );
}
void IFileContainer::Read (const OOX::CRels& oRels, const OOX::CPath& oPath)
{
int nCount = oRels.m_arrRelations.GetSize();
for ( int nIndex = 0; nIndex < nCount; ++nIndex )
{
smart_ptr<OOX::File>& pFile = OOX::Spreadsheet::CreateFile( oPath, oRels.m_arrRelations[nIndex] );
Add( oRels.m_arrRelations[nIndex].rId(), pFile );
}
}
void IFileContainer::Write(const OOX::CPath& oFileName, const OOX::CPath& oDirectory, OOX::CContentTypes& oContent) const
{
OOX::CPath oCurrent = oFileName.GetDirectory();
OOX::CRels oRels;
Write( oRels, oCurrent, oDirectory, oContent );
oRels.Write( oFileName );
}
void IFileContainer::Write(OOX::CRels& oRels, const OOX::CPath& oCurrent, const OOX::CPath& oDir, OOX::CContentTypes& oContent) const
{
CAtlMap<CString, size_t> mNamePair;
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
smart_ptr<OOX::File> pFile = pPair->m_value;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if ( !pExt.IsInit() )
{
OOX::CPath oDefDir = pFile->DefaultDirectory();
OOX::CPath oName = pFile->DefaultFileName();
if(false == pFile->m_sFilename.IsEmpty())
oName.SetName(pFile->m_sFilename, false);
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
if(true != pFile->m_bDoNotAddRels)
oRels.Registration( pPair->m_key, pFile->type(), oDefDir / oName );
}
else
{
oRels.Registration( pPair->m_key, pExt );
}
}
}
void IFileContainer::Commit (const OOX::CPath& oPath)
{
CAtlMap<CString, size_t> mNamepair;
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
smart_ptr<OOX::File> pFile = pPair->m_value;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if (!pExt.IsInit())
{
OOX::CPath oDefDir = pFile->DefaultDirectory();
OOX::CPath oName = pFile->DefaultFileName();
CAtlMap<CString, size_t>::CPair* pNamePair = mNamepair.Lookup( oName.m_strFilename );
if (NULL == pNamePair)
mNamepair.SetAt( oName.m_strFilename, 1 );
else
oName = oName + pNamePair->m_key;
OOX::CSystemUtility::CreateDirectories( oPath / oDefDir );
smart_ptr<OOX::IFileBuilder> pFileBuilder = pPair->m_value.smart_dynamic_cast<OOX::IFileBuilder>();
if ( pFileBuilder.is_init() )
pFileBuilder->Commit( oPath / oDefDir / oName );
}
}
}
void IFileContainer::Finalize(const OOX::CPath& oFileName, const OOX::CPath& oDirectory, OOX::CContentTypes& oContent)
{
OOX::CPath oCurrent = oFileName.GetDirectory();
OOX::CRels oRels;
Finalize( oRels, oCurrent, oDirectory, oContent );
oRels.Write( oFileName );
}
void IFileContainer::Finalize(OOX::CRels& oRels, const OOX::CPath& oCurrent, const OOX::CPath& oDir, OOX::CContentTypes& oContent)
{
CAtlMap<CString, size_t> mNamepair;
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
smart_ptr<OOX::File> pFile = pPair->m_value;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if ( !pExt.IsInit() )
{
OOX::CPath oDefDir = pFile->DefaultDirectory();
OOX::CPath oName = pFile->DefaultFileName();
CAtlMap<CString, size_t>::CPair* pNamePair = mNamepair.Lookup( oName.m_strFilename );
if ( NULL == pNamePair )
mNamepair.SetAt( oName.m_strFilename, 1 );
else
oName = oName + pNamePair->m_key;
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
smart_ptr<OOX::IFileBuilder> pFileBuilder = pFile.smart_dynamic_cast<OOX::IFileBuilder>();
if ( pFileBuilder.is_init() )
{
pFileBuilder->Finalize( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
}
else
{
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
}
oRels.Registration( pPair->m_key, pFile->type(), oDefDir / oName );
}
else
{
oRels.Registration( pPair->m_key, pExt );
}
}
}
const bool IFileContainer::IsExist(const FileType& oType) const
{
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
if ( oType == pPair->m_value->type() )
return true;
}
return false;
}
const bool IFileContainer::IsExist(const RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.Lookup(rId.get());
return ( NULL != pPair );
}
template<typename T>
const bool IFileContainer::IsExist() const
{
T oFile;
return IsExist( oFile.type() );
}
CString IFileContainer::IsExistHyperlink(smart_ptr<OOX::HyperLink>& pHyperLink)
{
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
if(OOX::FileTypes::HyperLink == pPair->m_value->type())
{
smart_ptr<OOX::HyperLink> pCurHyperlink = pPair->m_value.smart_dynamic_cast<OOX::HyperLink>();
if(pCurHyperlink->Uri().GetPath() == pHyperLink->Uri().GetPath())
return pPair->m_key;
}
}
return CString();
}
const bool IFileContainer::IsExternal(const OOX::RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.Lookup(rId.get());
if ( NULL != pPair )
{
CString sType = pPair->m_value->type().RelationType();
CString sName = pPair->m_value->type().DefaultFileName().m_strFilename;
return (( ( sType == OOX::FileTypes::ExternalAudio.RelationType() ) || ( sType == OOX::FileTypes::ExternalImage.RelationType() ) || ( sType == OOX::FileTypes::ExternalVideo.RelationType() ) ) && ( sName == _T("") ) );
}
return true;
}
smart_ptr<OOX::File> IFileContainer::Get(const FileType& oType)
{
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
if ( oType == pPair->m_value->type() )
return pPair->m_value;
}
return smart_ptr<OOX::File>(new UnknowTypeFile( Unknown ));
}
const RId IFileContainer::Add(smart_ptr<OOX::File>& pFile)
{
const RId rId = GetMaxRId().next();
Add( rId, pFile );
return rId;
}
void IFileContainer::Add(const OOX::RId& rId, smart_ptr<OOX::File>& pFile)
{
bool bEnumerated = pFile->type().Enumerated();
bool bEnumeratedGlobal = pFile->type().EnumeratedGlobal();
if(true == bEnumeratedGlobal || true == bEnumerated)
{
CAtlMap<CString, size_t>::CPair* pNamePair = NULL;
if(true == bEnumeratedGlobal)
pNamePair = m_mapEnumeratedGlobal.Lookup( pFile->type().OverrideType() );
else
pNamePair = m_mapAddNamePair.Lookup( pFile->type().OverrideType() );
int nIndex = 0;
if(NULL != pNamePair)
nIndex = pNamePair->m_value;
nIndex++;
if(true == bEnumeratedGlobal)
{
if(pFile.is<OOX::FileGlobalEnumerated>())
{
OOX::FileGlobalEnumerated& oFileGlobalEnumerated = pFile.as<OOX::FileGlobalEnumerated>();
oFileGlobalEnumerated.SetGlobalNumber(nIndex);
}
}
CString sPath = pFile->DefaultFileName().GetPath();
int nDotIndex = sPath.ReverseFind('.');
if(-1 != nDotIndex && nDotIndex > 0)
{
CString sDigit;sDigit.Format(_T("%d"), nIndex);
sPath.Insert(nDotIndex, sDigit);
}
pFile->m_sFilename = sPath;
if(true == bEnumeratedGlobal)
m_mapEnumeratedGlobal.SetAt( pFile->type().OverrideType(), nIndex );
else
m_mapAddNamePair.SetAt( pFile->type().OverrideType(), nIndex );
}
m_lMaxRid = max( m_lMaxRid, rId.getNumber() );
m_mContainer.SetAt( rId.get(), pFile );
}
smart_ptr<OOX::File> IFileContainer::Find(const FileType& oType) const
{
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
if ( oType == pPair->m_value->type() )
return pPair->m_value;
}
return smart_ptr<OOX::File>( (OOX::File*)new UnknowTypeFile() );
}
void IFileContainer::FindAllByType(const FileType& oType, CAtlMap<CString, smart_ptr<OOX::File>>& aOutput) const
{
POSITION pos = m_mContainer.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.GetNext( pos );
if ( oType == pPair->m_value->type() )
{
aOutput.SetAt(pPair->m_key, pPair->m_value);
}
}
}
smart_ptr<OOX::File> IFileContainer::Find(const OOX::RId& rId) const
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.Lookup(rId.get());
if ( NULL != pPair )
return pPair->m_value;
return smart_ptr<OOX::File>( (OOX::File*)new UnknowTypeFile() );
}
template<typename T>
T& IFileContainer::Find()
{
T oFile;
return dynamic_cast<T&>( Find( oFile.type() ) );
}
smart_ptr<OOX::File> IFileContainer::operator [](const OOX::RId rId)
{
CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_mContainer.Lookup(rId.get());
if ( NULL != pPair )
return pPair->m_value;
return smart_ptr<OOX::File>( (OOX::File*)new UnknowTypeFile() );
}
smart_ptr<OOX::File> IFileContainer::operator [](const FileType& oType)
{
return Find( oType );
}
const RId IFileContainer::GetMaxRId()
{
return RId( m_lMaxRid );
}
void IFileContainer::SetGlobalNumberByType(const CString& sOverrideType, int val)
{
m_mapEnumeratedGlobal.SetAt( sOverrideType, val );
}
int IFileContainer::GetGlobalNumberByType(const CString& sOverrideType)
{
CAtlMap<CString, size_t>::CPair* pNamePair = m_mapEnumeratedGlobal.Lookup( sOverrideType );
int nRes = 0;
if(NULL != pNamePair)
nRes = pNamePair->m_value;
return nRes;
}
}
} // namespace OOX

View File

@@ -0,0 +1,125 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_IFILE_CONTAINER_INCLUDE_H_
#define OOX_IFILE_CONTAINER_INCLUDE_H_
#include "../DocxFormat/RId.h"
#include "../DocxFormat/UnknowTypeFile.h"
#include "../DocxFormat/IFileBuilder.h"
namespace OOX
{
class File;
class FileType;
class CRels;
class CContentTypes;
class HyperLink;
}
namespace OOX
{
namespace Spreadsheet
{
class IFileContainer
{
public:
IFileContainer()
{
m_lMaxRid = 0;
m_pCurRels = NULL;
}
~IFileContainer()
{
RELEASEOBJECT(m_pCurRels);
}
protected:
CAtlMap<CString, smart_ptr<OOX::File>> m_mContainer;
size_t m_lMaxRid;
static CAtlMap<CString, size_t> m_mapEnumeratedGlobal;
protected:
void Read (const OOX::CPath& oPath);
void Read (const OOX::CRels& oRels, const CPath& oPath);
void Write(const OOX::CPath& oFileName, const CPath& oDir, OOX::CContentTypes& oContent) const;
void Write(OOX::CRels& oRels, const CPath& oCurrent, const CPath& oDir, OOX::CContentTypes& oContent) const;
protected:
void Commit (const CPath& oPath);
void Finalize(const CPath& oFilefilename, const CPath& oDir, OOX::CContentTypes& oContent);
void Finalize(OOX::CRels& oRels, const CPath& oCurrent, const CPath& oDir, OOX::CContentTypes& oContent);
public:
OOX::CRels* GetCurRls()
{
return m_pCurRels;
}
public:
template<typename T>
const bool IsExist() const;
const bool IsExist(const FileType& oType) const;
const bool IsExist(const OOX::RId& rId) const;
const bool IsExternal(const OOX::RId& rId) const;
CString IsExistHyperlink(smart_ptr<OOX::HyperLink>& pHyperLink);
smart_ptr<OOX::File> Get(const FileType& oType);
const RId Add(smart_ptr<OOX::File>& pFile);
void Add(const OOX::RId& rId, smart_ptr<OOX::File>& pFile);
template<typename T>
T& Find();
smart_ptr<OOX::File> Find(const FileType& type) const;
void FindAllByType(const FileType& oType, CAtlMap<CString, smart_ptr<OOX::File>>& aOutput) const;
smart_ptr<OOX::File> Find(const OOX::RId& type) const;
smart_ptr<OOX::File> operator [](const OOX::RId rId);
smart_ptr<OOX::File> operator [](const FileType& oType);
void SetGlobalNumberByType(const CString& sOverrideType, int val);
int GetGlobalNumberByType(const CString& sOverrideType);
protected:
static UnknowTypeFile Unknown;
private:
CAtlMap<CString, size_t> m_mapAddNamePair;
OOX::CRels* m_pCurRels;
const RId GetMaxRId();
};
}
}
#endif // OOX_IFILE_CONTAINER_INCLUDE_H_

View File

@@ -0,0 +1,153 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_PHONETIC_FILE_INCLUDE_H_
#define OOX_PHONETIC_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Text.h"
namespace OOX
{
namespace Spreadsheet
{
class CPhonetic : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPhonetic)
CPhonetic()
{
}
virtual ~CPhonetic()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_PhoneticPr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("alignment"), m_oAlignment )
WritingElement_ReadAttributes_Read_if ( oReader, _T("fontId"), m_oFontId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("type"), m_oType )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CPhoneticAlignment<>> m_oAlignment;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oFontId;
nullable<SimpleTypes::Spreadsheet::CPhoneticType<>> m_oType;
};
class CRPh : public WritingElementWithChilds<CText>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CRPh)
CRPh()
{
}
virtual ~CRPh()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("t") == sName )
m_arrItems.Add( new CText( oReader ));
}
}
virtual EElementType getType () const
{
return et_rPh;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("eb"), m_oEb )
WritingElement_ReadAttributes_Read_if ( oReader, _T("sb"), m_oSb )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oEb;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSb;
};
}
}
#endif // OOX_PHONETIC_FILE_INCLUDE_H_

View File

@@ -0,0 +1,105 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_RUN_FILE_INCLUDE_H_
#define OOX_RUN_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Text.h"
#include "../Styles/rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CRun : public WritingElementWithChilds<CText>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CRun)
CRun()
{
}
virtual ~CRun()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<r>"));
if(m_oRPr.IsInit())
m_oRPr->toXML(writer);
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</r>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("rPr") == sName )
m_oRPr = oReader;
else if ( _T("t") == sName )
m_arrItems.Add( new CText( oReader ));
}
}
virtual EElementType getType () const
{
return et_r;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CRPr> m_oRPr;
};
}
}
#endif // OOX_RUN_FILE_INCLUDE_H_

View File

@@ -0,0 +1,178 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_SHAREDSTRINGS_FILE_INCLUDE_H_
#define OOX_SHAREDSTRINGS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Si.h"
namespace OOX
{
namespace Spreadsheet
{
class CSharedStrings : public OOX::File, public OOX::Spreadsheet::IFileContainer
{
public:
CSharedStrings()
{
}
CSharedStrings(const CPath& oPath)
{
read( oPath );
}
virtual ~CSharedStrings()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("sst") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nSharedStringsDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nSharedStringsDepth ) )
{
sName = oReader.GetName();
WritingElement *pItem = NULL;
if ( _T("si") == sName )
pItem = new CSi( oReader );
if ( pItem )
m_arrItems.Add( pItem );
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
CStringWriter sXml;
sXml.WriteStringC(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\""));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
sXml.WriteStringC(sVal);
}
if(m_oUniqueCount.IsInit())
{
CString sVal;sVal.Format(_T(" uniqueCount=\"%d\""), m_oUniqueCount->GetValue());
sXml.WriteStringC(sVal);
}
sXml.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(sXml);
sXml.WriteStringC(_T("</sst>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::SharedStrings;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
const int AddSi(CSi* pSi)
{
int nIndex = m_arrItems.GetSize();
m_arrItems.Add( pSi );
return nIndex;
}
private:
CPath m_oReadPath;
void ClearItems()
{
for ( int nIndex = 0; nIndex < m_arrItems.GetSize(); nIndex++ )
{
if ( m_arrItems[nIndex] )
delete m_arrItems[nIndex];
m_arrItems[nIndex] = NULL;
}
m_arrItems.RemoveAll();
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_Read_if ( oReader, _T("uniqueCount"), m_oUniqueCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oUniqueCount;
CSimpleArray<WritingElement *> m_arrItems;
};
}
}
#endif // OOX_SHAREDSTRINGS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,138 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_SI_FILE_INCLUDE_H_
#define OOX_SI_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "PhoneticPr.h"
#include "Run.h"
namespace OOX
{
namespace Spreadsheet
{
class CSi : public WritingElementWithChilds<>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSi)
CSi()
{
}
virtual ~CSi()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<si>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</si>"));
}
virtual void toXML2(CStringWriter& writer) const
{
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
}
CString ToString()
{
CString sRes;
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
{
WritingElement* we = m_arrItems[i];
if(OOX::Spreadsheet::et_r == we->getType())
{
CRun* pRun = static_cast<CRun*>(we);
for(int j = 0, length2 = pRun->m_arrItems.GetSize(); j < length2; ++j)
{
CText* pText = pRun->m_arrItems[j];
sRes.Append(pText->ToString());
}
}
else if(OOX::Spreadsheet::et_t == we->getType())
{
CText* pText = static_cast<CText*>(we);
sRes.Append(pText->ToString());
}
}
return sRes;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
WritingElement *pItem = NULL;
if ( _T("phoneticPr") == sName )
pItem = new CPhonetic( oReader );
else if ( _T("r") == sName )
pItem = new CRun( oReader );
else if ( _T("rPh") == sName )
pItem = new CRPh( oReader );
else if ( _T("t") == sName )
pItem = new CText( oReader );
if ( NULL != pItem )
m_arrItems.Add( pItem );
}
}
virtual EElementType getType () const
{
return et_Si;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_SI_FILE_INCLUDE_H_

View File

@@ -0,0 +1,165 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_TEXT_FILE_INCLUDE_H_
#define OOX_TEXT_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CText : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CText)
CText() {}
virtual ~CText() {}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<t"));
if(-1 != m_sText.Find(' ') || -1 != m_sText.Find('\n'))
writer.WriteStringC(_T(" xml:space=\"preserve\""));
writer.WriteStringC(_T(">"));
writer.WriteStringC(XmlUtils::EncodeXmlString(m_sText));
writer.WriteStringC(_T("</t>"));
}
virtual void toXML2(CStringWriter& writer, CString name) const
{
writer.WriteStringC(_T("<"));
writer.WriteStringC(name);
if(-1 != m_sText.Find(' ') || -1 != m_sText.Find('\n'))
writer.WriteStringC(_T(" xml:space=\"preserve\""));
writer.WriteStringC(_T(">"));
writer.WriteStringC(XmlUtils::EncodeXmlString(m_sText));
writer.WriteStringC(_T("</"));
writer.WriteStringC(name);
writer.WriteStringC(_T(">"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
m_sText = oReader.GetText2();
m_sText.Replace(_T("\t"), _T(""));
if(!(m_oSpace.IsInit() && SimpleTypes::xmlspacePreserve == m_oSpace->GetValue()))
{
int nLength = m_sText.GetLength();
int nStartIndex = 0;
int nEndIndex = nLength - 1;
for(int i = nStartIndex; i < nLength; ++i)
{
TCHAR cElem = m_sText[i];
if(' ' == cElem || '\n' == cElem || '\r' == cElem)
nStartIndex++;
else
break;
}
for(int i = nEndIndex; i > nStartIndex; --i)
{
TCHAR cElem = m_sText[i];
if(' ' == cElem || '\n' == cElem || '\r' == cElem)
nEndIndex--;
else
break;
}
if(0 != nStartIndex || nLength - 1 != nEndIndex)
{
if(nStartIndex <= nEndIndex)
m_sText = m_sText.Mid(nStartIndex, nEndIndex - nStartIndex + 1);
else
m_sText.Empty();
}
}
}
CString ToString() const
{
return m_sText;
}
virtual EElementType getType() const
{
return et_t;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.GetAttributesCount() <= 0 )
return;
if ( !oReader.MoveToFirstAttribute() )
return;
CWCharWrapper wsName = oReader.GetName();
while( !wsName.IsNull() )
{
if ( _T("xml:space") == wsName )
{
m_oSpace = oReader.GetText();
break;
}
if ( !oReader.MoveToNextAttribute() )
break;
wsName = oReader.GetName();
}
oReader.MoveToElement();
}
public:
nullable<SimpleTypes::CXmlSpace<> > m_oSpace;
CString m_sText;
};
}
}
#endif // OOX_TEXT_FILE_INCLUDE_H_

View File

@@ -0,0 +1,174 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_RPR_FILE_INCLUDE_H_
#define OOX_RPR_FILE_INCLUDE_H_
#include "../../Base/Nullable.h"
#include "../../Common/SimpleTypes_Word.h"
#include "../../Common/SimpleTypes_Shared.h"
#include "../../Common/ComplexTypes.h"
#include "../SimpleTypes_Spreadsheet.h"
namespace OOX
{
namespace Spreadsheet
{
class CColor
{
public:
WritingElement_AdditionConstructors(CColor)
CColor()
{
}
virtual ~CColor()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("auto"), m_oAuto )
WritingElement_ReadAttributes_Read_if ( oReader, _T("indexed"), m_oIndexed )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rgb"), m_oRgb )
WritingElement_ReadAttributes_Read_if ( oReader, _T("theme"), m_oTheme )
WritingElement_ReadAttributes_Read_if ( oReader, _T("tint"), m_oTint )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oAuto;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oIndexed;
nullable<CString> m_oRgb;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oTheme;
nullable<SimpleTypes::CDouble> m_oTint;
};
class CRPr : public WritingElementWithChilds
{
public:
WritingElement_AdditionConstructors(CRPr)
CRPr()
{
}
virtual ~CRPr()
{
}
public:
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("b") == sName )
m_oBold = oReader;
else if ( _T("charset") == sName )
;
else if ( _T("color") == sName )
m_oColor = oReader;
else if ( _T("condense") == sName )
m_oCondense = oReader;
else if ( _T("extend") == sName )
m_oExtend = oReader;
else if ( _T("family") == sName )
;
else if ( _T("i") == sName )
m_oItalic = oReader;
else if ( _T("outline") == sName )
m_oOutline = oReader;
else if ( _T("rFont") == sName )
m_oRFont = oReader;
else if ( _T("scheme") == sName )
;
else if ( _T("shadow") == sName )
m_oShadow = oReader;
else if ( _T("strike") == sName )
m_oStrike = oReader;
else if ( _T("sz") == sName )
m_oSz = oReader;
else if ( _T("u") == sName )
m_oUnderline = oReader;
else if ( _T("vertAlign") == sName )
m_oVertAlign = oReader;
}
}
virtual EElementType getType () const
{
return et_rPr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oBold;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oCharset;
nullable<CColor> m_oColor;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oCondense;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oExtend;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oItalic;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oOutline;
nullable<ComplexTypes::Word::CString_ > m_oRFont;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oShadow;
nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oStrike;
nullable<ComplexTypes::Word::CDouble2> m_oSz;
nullable<SimpleTypes::Spreadsheet::CUnderline<> > m_oUnderline;
nullable<SimpleTypes::CVerticalAlignRun<> > m_oVertAlign;
};
}
}
#endif // OOX_RPR_FILE_INCLUDE_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,303 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_BORDERS_FILE_INCLUDE_H_
#define OOX_BORDERS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CBorderProp : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CBorderProp)
CBorderProp()
{
}
virtual ~CBorderProp()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
void toXML2(CStringWriter& writer, CString sName) const
{
writer.WriteStringC(_T("<"));
writer.WriteStringC(sName);
if(m_oStyle.IsInit())
{
CString sVal;sVal.Format(_T(" style=\"%s\""), m_oStyle->ToString());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
if(m_oColor.IsInit())
m_oColor->toXML2(writer, _T("color"));
writer.WriteStringC(_T("</"));
writer.WriteStringC(sName);
writer.WriteStringC(_T(">"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("color") == sName )
m_oColor = oReader;
}
}
virtual EElementType getType () const
{
return et_BorderProp;
}
bool IsEmpty()
{
return !(m_oStyle.IsInit() || m_oColor.IsInit());
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("style"), m_oStyle )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CBorderStyle<>> m_oStyle;
nullable<CColor> m_oColor;
};
class CBorder : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CBorder)
CBorder()
{
}
virtual ~CBorder()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<border"));
if(m_oDiagonalDown.IsInit() && SimpleTypes::onoffTrue == m_oDiagonalDown->GetValue())
{
CString sVal;sVal.Format(_T(" diagonalDown=\"%s\""), m_oDiagonalDown->ToString2( SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDiagonalUp.IsInit() && SimpleTypes::onoffTrue == m_oDiagonalUp->GetValue())
{
CString sVal;sVal.Format(_T(" diagonalUp=\"%s\""), m_oDiagonalUp->ToString2( SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
if(m_oStart.IsInit() && false == m_oStart->IsEmpty())
m_oStart->toXML2(writer, _T("left"));
else
writer.WriteStringC(_T("<left/>"));
if(m_oEnd.IsInit() && false == m_oEnd->IsEmpty())
m_oEnd->toXML2(writer, _T("right"));
else
writer.WriteStringC(_T("<right/>"));
if(m_oTop.IsInit() && false == m_oTop->IsEmpty())
m_oTop->toXML2(writer, _T("top"));
else
writer.WriteStringC(_T("<top/>"));
if(m_oBottom.IsInit() && false == m_oBottom->IsEmpty())
m_oBottom->toXML2(writer, _T("bottom"));
else
writer.WriteStringC(_T("<bottom/>"));
if(m_oDiagonal.IsInit() && false == m_oDiagonal->IsEmpty())
m_oDiagonal->toXML2(writer, _T("diagonal"));
else
writer.WriteStringC(_T("<diagonal/>"));
if(m_oHorizontal.IsInit() && false == m_oHorizontal->IsEmpty())
m_oHorizontal->toXML2(writer, _T("horizontal"));
if(m_oVertical.IsInit() && false == m_oVertical->IsEmpty())
m_oVertical->toXML2(writer, _T("vertical"));
writer.WriteStringC(_T("</border>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("bottom") == sName )
m_oBottom = oReader;
else if ( _T("diagonal") == sName )
m_oDiagonal = oReader;
else if ( _T("end") == sName || _T("right") == sName )
m_oEnd = oReader;
else if ( _T("horizontal") == sName )
m_oHorizontal = oReader;
else if ( _T("start") == sName || _T("left") == sName )
m_oStart = oReader;
else if ( _T("top") == sName )
m_oTop = oReader;
else if ( _T("vertical") == sName )
m_oVertical = oReader;
}
}
virtual EElementType getType () const
{
return et_Border;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("diagonalDown"), m_oDiagonalDown )
WritingElement_ReadAttributes_Read_if ( oReader, _T("diagonalUp"), m_oDiagonalUp )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outline"), m_oOutline )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oDiagonalDown;
nullable<SimpleTypes::COnOff<>> m_oDiagonalUp;
nullable<SimpleTypes::COnOff<>> m_oOutline;
nullable<CBorderProp> m_oBottom;
nullable<CBorderProp> m_oDiagonal;
nullable<CBorderProp> m_oEnd;
nullable<CBorderProp> m_oHorizontal;
nullable<CBorderProp> m_oStart;
nullable<CBorderProp> m_oTop;
nullable<CBorderProp> m_oVertical;
};
class CBorders : public WritingElementWithChilds<CBorder>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CBorders)
CBorders()
{
}
virtual ~CBorders()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<borders"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</borders>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("border") == sName )
m_arrItems.Add( new CBorder( oReader ));
}
}
virtual EElementType getType () const
{
return et_Borders;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_BORDERS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,184 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CELLSTYLES_FILE_INCLUDE_H_
#define OOX_CELLSTYLES_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CCellStyle : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCellStyle)
CCellStyle()
{
}
virtual ~CCellStyle()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<cellStyle"));
if(m_oName.IsInit())
{
CString sVal;sVal.Format(_T(" name=\"%s\""), XmlUtils::EncodeXmlString(m_oName.get()));
writer.WriteStringC(sVal);
}
if(m_oXfId.IsInit())
{
CString sVal;sVal.Format(_T(" xfId=\"%d\""), m_oXfId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oBuiltinId.IsInit())
{
CString sVal;sVal.Format(_T(" builtinId=\"%d\""), m_oBuiltinId->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_CellStyle;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("builtinId"), m_oBuiltinId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("customBuiltin"), m_oCustomBuiltin )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hidden"), m_oHidden )
WritingElement_ReadAttributes_Read_if ( oReader, _T("iLevel"), m_oILevel )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("xfId"), m_oXfId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oBuiltinId;
nullable<SimpleTypes::COnOff<>> m_oCustomBuiltin;
nullable<SimpleTypes::COnOff<>> m_oHidden;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oILevel;
nullable<CString> m_oName;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oXfId;
};
class CCellStyles : public WritingElementWithChilds<CCellStyle>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCellStyles)
CCellStyles()
{
}
virtual ~CCellStyles()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<cellStyles"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</cellStyles>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("cellStyle") == sName )
m_arrItems.Add( new CCellStyle( oReader ));
}
}
virtual EElementType getType () const
{
return et_CellStyles;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_CELLSTYLES_FILE_INCLUDE_H_

View File

@@ -0,0 +1,106 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_COLORS_FILE_INCLUDE_H_
#define OOX_COLORS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CColors : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CColors)
CColors()
{
}
virtual ~CColors()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("indexedColors") == sName )
m_oIndexedColors = oReader;
else if ( _T("mruColors") == sName )
m_oMruColors = oReader;
}
}
virtual EElementType getType () const
{
return et_Colors;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
nullable<CIndexedColors> m_oIndexedColors;
nullable<CMruColors> m_oMruColors;
};
}
}
#endif // OOX_COLORS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,372 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_FILLS_FILE_INCLUDE_H_
#define OOX_FILLS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CPatternFill : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPatternFill)
CPatternFill()
{
}
virtual ~CPatternFill()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<patternFill"));
if(m_oPatternType.IsInit())
{
CString sVal;sVal.Format(_T(" patternType=\"%s\""), m_oPatternType->ToString());
writer.WriteStringC(sVal);
}
if(m_oBgColor.IsInit() || m_oFgColor.IsInit())
{
writer.WriteStringC(_T(">"));
if(m_oBgColor.IsInit() && m_oFgColor.IsInit())
{
m_oFgColor->toXML2(writer, _T("fgColor"));
m_oBgColor->toXML2(writer, _T("bgColor"));
}
else if(m_oFgColor.IsInit())
{
m_oFgColor->toXML2(writer, _T("fgColor"));
m_oFgColor->toXML2(writer, _T("bgColor"));
}
else if(m_oBgColor.IsInit())
{
m_oBgColor->toXML2(writer, _T("fgColor"));
m_oBgColor->toXML2(writer, _T("bgColor"));
}
writer.WriteStringC(_T("</patternFill>"));
}
else
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("bgColor") == sName )
m_oBgColor = oReader;
else if ( _T("fgColor") == sName )
m_oFgColor = oReader;
}
}
virtual EElementType getType () const
{
return et_PatternFill;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("patternType"), m_oPatternType )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CPatternType<>> m_oPatternType;
nullable<CColor> m_oBgColor;
nullable<CColor> m_oFgColor;
};
class CGradientStop : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CGradientStop)
CGradientStop()
{
}
virtual ~CGradientStop()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("color") == sName )
m_oColor = oReader;
}
}
virtual EElementType getType () const
{
return et_GradientStop;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("position"), m_oPosition )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CDouble> m_oPosition;
nullable<CColor> m_oColor;
};
class CGradientFill : public WritingElementWithChilds<CGradientStop>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CGradientFill)
CGradientFill()
{
}
virtual ~CGradientFill()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("stop") == sName )
m_arrItems.Add( new CGradientStop( oReader ));
}
}
virtual EElementType getType () const
{
return et_GradientFill;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("bottom"), m_oBottom )
WritingElement_ReadAttributes_Read_if ( oReader, _T("degree"), m_oDegree )
WritingElement_ReadAttributes_Read_if ( oReader, _T("left"), m_oLeft )
WritingElement_ReadAttributes_Read_if ( oReader, _T("right"), m_oRight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("top"), m_oTop )
WritingElement_ReadAttributes_Read_if ( oReader, _T("type"), m_oType )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CDouble> m_oBottom;
nullable<SimpleTypes::CDouble> m_oDegree;
nullable<SimpleTypes::CDouble> m_oLeft;
nullable<SimpleTypes::CDouble> m_oRight;
nullable<SimpleTypes::CDouble> m_oTop;
nullable<SimpleTypes::Spreadsheet::CGradientType<>> m_oType;
};
class CFill : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFill)
CFill()
{
}
virtual ~CFill()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<fill>"));
if(m_oPatternFill.IsInit())
m_oPatternFill->toXML(writer);
writer.WriteStringC(_T("</fill>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("gradientFill") == sName )
m_oGradientFill = oReader;
else if ( _T("patternFill") == sName )
m_oPatternFill = oReader;
}
}
virtual EElementType getType () const
{
return et_Fill;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CGradientFill> m_oGradientFill;
nullable<CPatternFill> m_oPatternFill;
};
class CFills : public WritingElementWithChilds<CFill>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFills)
CFills()
{
}
virtual ~CFills()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<fills"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</fills>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("fill") == sName )
m_arrItems.Add( new CFill( oReader ));
}
}
virtual EElementType getType () const
{
return et_Fills;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_FILLS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,299 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_FONTS_FILE_INCLUDE_H_
#define OOX_FONTS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CFont : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFont)
CFont()
{
}
virtual ~CFont()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<font>"));
if(m_oBold.IsInit())
{
if(SimpleTypes::onoffTrue == m_oBold->m_oVal.GetValue())
writer.WriteStringC(_T("<b/>"));
else
writer.WriteStringC(_T("<b val=\"0\"/>"));
}
if(m_oCharset.IsInit() && m_oCharset->m_oCharset.IsInit())
{
CString sVal;sVal.Format(_T("<charset val=\"%s\"/>"), m_oCharset->m_oCharset->ToString());
writer.WriteStringC(sVal);
}
if(m_oColor.IsInit())
m_oColor->toXML2(writer, _T("color"));
if(m_oCondense.IsInit())
{
if(SimpleTypes::onoffTrue == m_oCondense->m_oVal.GetValue())
writer.WriteStringC(_T("<condense/>"));
else
writer.WriteStringC(_T("<condense val=\"0\"/>"));
}
if(m_oExtend.IsInit())
{
if(SimpleTypes::onoffTrue == m_oExtend->m_oVal.GetValue())
writer.WriteStringC(_T("<extend/>"));
else
writer.WriteStringC(_T("<extend val=\"0\"/>"));
}
if(m_oFamily.IsInit() && m_oFamily->m_oFontFamily.IsInit())
{
CString sVal;sVal.Format(_T("<family val=\"%s\"/>"), m_oFamily->m_oFontFamily->ToString());
writer.WriteStringC(sVal);
}
if(m_oItalic.IsInit())
{
if(SimpleTypes::onoffTrue == m_oItalic->m_oVal.GetValue())
writer.WriteStringC(_T("<i/>"));
else
writer.WriteStringC(_T("<i val=\"0\"/>"));
}
if(m_oOutline.IsInit())
{
if(SimpleTypes::onoffTrue == m_oOutline->m_oVal.GetValue())
writer.WriteStringC(_T("<outline/>"));
else
writer.WriteStringC(_T("<outline val=\"0\"/>"));
}
if(m_oRFont.IsInit() && m_oRFont->m_sVal.IsInit())
{
CString sVal;sVal.Format(_T("<name val=\"%s\"/>"), XmlUtils::EncodeXmlString(m_oRFont->m_sVal.get()));
writer.WriteStringC(sVal);
}
if(m_oScheme.IsInit() && m_oScheme->m_oFontScheme.IsInit())
{
CString sVal;sVal.Format(_T("<scheme val=\"%s\"/>"), m_oScheme->m_oFontScheme->ToString());
writer.WriteStringC(sVal);
}
if(m_oShadow.IsInit())
{
if(SimpleTypes::onoffTrue == m_oShadow->m_oVal.GetValue())
writer.WriteStringC(_T("<shadow/>"));
else
writer.WriteStringC(_T("<shadow val=\"0\"/>"));
}
if(m_oStrike.IsInit())
{
if(SimpleTypes::onoffTrue == m_oStrike->m_oVal.GetValue())
writer.WriteStringC(_T("<strike/>"));
else
writer.WriteStringC(_T("<strike val=\"0\"/>"));
}
if(m_oSz.IsInit() && m_oSz->m_oVal.IsInit())
{
CString sVal;sVal.Format(_T("<sz val=\"%s\"/>"), SpreadsheetCommon::WriteDouble(m_oSz->m_oVal->GetValue()));
writer.WriteStringC(sVal);
}
if(m_oUnderline.IsInit() && m_oUnderline->m_oUnderline.IsInit())
{
CString sVal;
if( SimpleTypes::underlineSingle != m_oUnderline->m_oUnderline->GetValue())
sVal.Format(_T("<u val=\"%s\"/>"), m_oUnderline->m_oUnderline->ToString());
else
sVal.Format(_T("<u/>"), m_oUnderline->m_oUnderline->ToString());
writer.WriteStringC(sVal);
}
if(m_oVertAlign.IsInit() && m_oVertAlign->m_oVerticalAlign.IsInit())
{
CString sVal;sVal.Format(_T("<vertAlign val=\"%s\"/>"), m_oVertAlign->m_oVerticalAlign->ToString());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("</font>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("b") == sName )
m_oBold = oReader;
else if ( _T("charset") == sName )
m_oCharset = oReader;
else if ( _T("color") == sName )
m_oColor = oReader;
else if ( _T("condense") == sName )
m_oCondense = oReader;
else if ( _T("extend") == sName )
m_oExtend = oReader;
else if ( _T("family") == sName )
m_oFamily = oReader;
else if ( _T("i") == sName )
m_oItalic = oReader;
else if ( _T("name") == sName )
m_oRFont = oReader;
else if ( _T("outline") == sName )
m_oOutline = oReader;
else if ( _T("scheme") == sName )
m_oScheme = oReader;
else if ( _T("shadow") == sName )
m_oShadow = oReader;
else if ( _T("strike") == sName )
m_oStrike = oReader;
else if ( _T("sz") == sName )
m_oSz = oReader;
else if ( _T("u") == sName )
m_oUnderline = oReader;
else if ( _T("vertAlign") == sName )
m_oVertAlign = oReader;
}
}
virtual EElementType getType () const
{
return et_Font;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oBold;
nullable<CCharset> m_oCharset;
nullable<CColor> m_oColor;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oCondense;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oExtend;
nullable<CFontFamily > m_oFamily;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oItalic;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oOutline;
nullable<ComplexTypes::Spreadsheet::CString_> m_oRFont;
nullable<CFontScheme> m_oScheme;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oShadow;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oStrike;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oSz;
nullable<CUnderline> m_oUnderline;
nullable<CVerticalAlign> m_oVertAlign;
};
class CFonts : public WritingElementWithChilds<CFont>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFonts)
CFonts()
{
}
virtual ~CFonts()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<fonts"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</fonts>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("font") == sName )
m_arrItems.Add( new CFont( oReader ));
}
}
virtual EElementType getType () const
{
return et_Fonts;
}
void AddFont (CFont* pFont)
{
m_arrItems.Add(pFont);
if(false == m_oCount.IsInit())
m_oCount.Init();
m_oCount->SetValue(m_arrItems.GetSize());
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_FONTS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,185 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_NUMFMTS_FILE_INCLUDE_H_
#define OOX_NUMFMTS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CNumFmt : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CNumFmt)
CNumFmt()
{
}
virtual ~CNumFmt()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
toXML2(writer, CString(_T("numFmt")));
}
void toXML2(CStringWriter& writer, CString& sHeader) const
{
writer.WriteStringC(_T("<") + sHeader);
if(m_oNumFmtId.IsInit())
{
CString sVal;sVal.Format(_T(" numFmtId=\"%d\""), m_oNumFmtId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oFormatCode.IsInit())
{
CString sVal;sVal.Format(_T(" formatCode=\"%s\""), XmlUtils::EncodeXmlString(m_oFormatCode.get()));
writer.WriteStringC(sVal);
}
if(m_oSourceLinked.IsInit())
{
CString sVal;
sVal.Format(_T(" sourceLinked=\"%s\""), m_oSourceLinked->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_NumFmt;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("formatCode"), m_oFormatCode )
WritingElement_ReadAttributes_Read_if ( oReader, _T("numFmtId"), m_oNumFmtId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("sourceLinked"), m_oSourceLinked )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString > m_oFormatCode;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oNumFmtId;
nullable<SimpleTypes::COnOff<>> m_oSourceLinked;
};
class CNumFmts : public WritingElementWithChilds<CNumFmt>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CNumFmts)
CNumFmts()
{
}
virtual ~CNumFmts()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0 )
{
writer.WriteStringC(_T("<numFmts"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</numFmts>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("numFmt") == sName )
m_arrItems.Add( new CNumFmt( oReader ));
}
}
virtual EElementType getType () const
{
return et_NumFmts;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_NUMFMTS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,264 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_STYLES_FILE_INCLUDE_H_
#define OOX_STYLES_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Borders.h"
#include "CellStyles.h"
#include "Xfs.h"
#include "Colors.h"
#include "Dxf.h"
#include "Fills.h"
#include "Fonts.h"
#include "NumFmts.h"
#include "TableStyles.h"
namespace OOX
{
namespace Spreadsheet
{
class CStyles : public OOX::File, public OOX::Spreadsheet::IFileContainer
{
public:
CStyles()
{
}
CStyles(const CPath& oPath)
{
read( oPath );
}
virtual ~CStyles()
{
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("styleSheet") == sName )
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
{
int nStylesDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nStylesDepth ) )
{
sName = oReader.GetName();
if ( _T("borders") == sName )
m_oBorders = oReader;
else if ( _T("cellStyles") == sName )
m_oCellStyles = oReader;
else if ( _T("cellStyleXfs") == sName )
m_oCellStyleXfs = oReader;
else if ( _T("cellXfs") == sName )
m_oCellXfs = oReader;
else if ( _T("colors") == sName )
m_oColors = oReader;
else if ( _T("dxfs") == sName )
m_oDxfs = oReader;
else if ( _T("fills") == sName )
m_oFills = oReader;
else if ( _T("fonts") == sName )
m_oFonts = oReader;
else if ( _T("numFmts") == sName )
m_oNumFmts = oReader;
else if ( _T("tableStyles") == sName )
m_oTableStyles = oReader;
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
CStringWriter sXml;
sXml.WriteStringC(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" mc:Ignorable=\"x14ac\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\">"));
if(m_oNumFmts.IsInit())
m_oNumFmts->toXML(sXml);
if(m_oFonts.IsInit())
m_oFonts->toXML(sXml);
if(m_oFills.IsInit())
m_oFills->toXML(sXml);
if(m_oBorders.IsInit())
m_oBorders->toXML(sXml);
if(m_oCellStyleXfs.IsInit())
m_oCellStyleXfs->toXML(sXml);
if(m_oCellXfs.IsInit())
m_oCellXfs->toXML(sXml);
if(m_oCellStyles.IsInit())
m_oCellStyles->toXML(sXml);
if(m_oColors.IsInit())
m_oColors->toXML(sXml);
if(m_oDxfs.IsInit())
m_oDxfs->toXML(sXml);
if(m_oTableStyles.IsInit())
m_oTableStyles->toXML(sXml);
sXml.WriteStringC(_T("</styleSheet>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
}
void PrepareToWrite()
{
if(false == m_oFills.IsInit())
m_oFills.Init();
if(m_oCellXfs.IsInit())
{
for(int i = 0, length = m_oCellXfs->m_arrItems.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::CXfs* xfs = m_oCellXfs->m_arrItems[i];
if (false == xfs->m_oXfId.IsInit())
{
xfs->m_oXfId.Init();
xfs->m_oXfId->SetValue(0);
}
}
}
if(false == m_oCellStyles.IsInit())
m_oCellStyles.Init();
if(false == m_oCellStyles->m_oCount.IsInit())
{
m_oCellStyles->m_oCount.Init();
m_oCellStyles->m_oCount->SetValue(1);
}
if(0 == m_oCellStyles->m_arrItems.GetSize())
{
CCellStyle* pCellStyle = new CCellStyle();
pCellStyle->m_oName = _T("Normal");
pCellStyle->m_oXfId.Init();
pCellStyle->m_oXfId->SetValue(0);
pCellStyle->m_oBuiltinId.Init();
pCellStyle->m_oBuiltinId->SetValue(0);
m_oCellStyles->m_arrItems.Add(pCellStyle);
}
if(false == m_oCellStyleXfs.IsInit())
m_oCellStyleXfs.Init();
if(false == m_oCellStyleXfs->m_oCount.IsInit())
{
m_oCellStyleXfs->m_oCount.Init();
m_oCellStyleXfs->m_oCount->SetValue(1);
}
if(0 == m_oCellStyleXfs->m_arrItems.GetSize())
{
CXfs* pXfs = new CXfs();
pXfs->m_oNumFmtId.Init();
pXfs->m_oNumFmtId->SetValue(0);
pXfs->m_oFontId.Init();
pXfs->m_oFontId->SetValue(0);
pXfs->m_oFillId.Init();
pXfs->m_oFillId->SetValue(0);
pXfs->m_oBorderId.Init();
pXfs->m_oBorderId->SetValue(0);
m_oCellStyleXfs->m_arrItems.Add(pXfs);
}
if(false == m_oDxfs.IsInit())
m_oDxfs.Init();
if(false == m_oDxfs->m_oCount.IsInit())
{
m_oDxfs->m_oCount.Init();
m_oDxfs->m_oCount->SetValue(0);
}
if(false == m_oTableStyles.IsInit())
{
m_oTableStyles.Init();
m_oTableStyles->m_oCount.Init();
m_oTableStyles->m_oCount->SetValue(0);
}
if(false == m_oTableStyles->m_oDefaultPivotStyle.IsInit())
m_oTableStyles->m_oDefaultTableStyle = _T("TableStyleMedium2");
if(false == m_oTableStyles->m_oDefaultPivotStyle.IsInit())
m_oTableStyles->m_oDefaultPivotStyle = _T("PivotStyleLight16");
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Styles;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<OOX::Spreadsheet::CBorders> m_oBorders;
nullable<OOX::Spreadsheet::CCellStyles> m_oCellStyles;
nullable<OOX::Spreadsheet::CCellStyleXfs> m_oCellStyleXfs;
nullable<OOX::Spreadsheet::CCellXfs> m_oCellXfs;
nullable<OOX::Spreadsheet::CColors> m_oColors;
nullable<OOX::Spreadsheet::CDxfs> m_oDxfs;
nullable<OOX::Spreadsheet::CFills> m_oFills;
nullable<OOX::Spreadsheet::CFonts> m_oFonts;
nullable<OOX::Spreadsheet::CNumFmts> m_oNumFmts;
nullable<OOX::Spreadsheet::CTableStyles> m_oTableStyles;
};
}
}
#endif // OOX_STYLES_FILE_INCLUDE_H_

View File

@@ -0,0 +1,275 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_TABLESTYLES_FILE_INCLUDE_H_
#define OOX_TABLESTYLES_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "rPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CTableStyleElement : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableStyleElement)
CTableStyleElement()
{
}
virtual ~CTableStyleElement()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oType.IsInit() && m_oDxfId.IsInit())
{
CString sXml;
if(m_oSize.IsInit())
sXml.Format(_T("<tableStyleElement type=\"%s\" size=\"%d\" dxfId=\"%d\"/>"), m_oType->ToString(), m_oSize->GetValue(), m_oDxfId->GetValue());
else
sXml.Format(_T("<tableStyleElement type=\"%s\" dxfId=\"%d\"/>"), m_oType->ToString(), m_oDxfId->GetValue());
writer.WriteStringC(sXml);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_TableStyleElement;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dxfId"), m_oDxfId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("size"), m_oSize )
WritingElement_ReadAttributes_Read_if ( oReader, _T("type"), m_oType )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oDxfId;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSize;
nullable<SimpleTypes::Spreadsheet::CTableStyleType<>> m_oType;
};
class CTableStyle : public WritingElementWithChilds<CTableStyleElement>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableStyle)
CTableStyle()
{
}
virtual ~CTableStyle()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oName.IsInit() && m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<tableStyle"));
if(m_oName.IsInit())
{
CString sName;
sName.Format(_T(" name=\"%s\""), XmlUtils::EncodeXmlString(m_oName.get2()));
writer.WriteStringC(sName);
}
if(m_oPivot.IsInit() && true == m_oPivot->ToBool())
writer.WriteStringC(_T(" table=\"0\""));
else
writer.WriteStringC(_T(" pivot=\"0\""));
if(m_oCount.IsInit())
{
CString sCount;
sCount.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sCount);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</tableStyle>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("tableStyleElement") == sName )
m_arrItems.Add( new CTableStyleElement( oReader ));
}
}
virtual EElementType getType () const
{
return et_TableStyle;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("pivot"), m_oPivot )
WritingElement_ReadAttributes_Read_if ( oReader, _T("table"), m_oTable )
WritingElement_ReadAttributes_Read_if ( oReader, _T("displayName"),m_oDisplayName )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
nullable<CString> m_oName;
nullable<SimpleTypes::COnOff<>> m_oPivot;
nullable<SimpleTypes::COnOff<>> m_oTable;
nullable<CString> m_oDisplayName;
};
class CTableStyles : public WritingElementWithChilds<CTableStyle>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableStyles)
CTableStyles()
{
}
virtual ~CTableStyles()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<tableStyles"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
if(m_oDefaultTableStyle.IsInit())
{
CString sVal;sVal.Format(_T(" defaultTableStyle=\"%s\""), XmlUtils::EncodeXmlString(m_oDefaultTableStyle.get()));
writer.WriteStringC(sVal);
}
if(m_oDefaultPivotStyle.IsInit())
{
CString sVal;sVal.Format(_T(" defaultPivotStyle=\"%s\""), XmlUtils::EncodeXmlString(m_oDefaultPivotStyle.get()));
writer.WriteStringC(sVal);
}
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</tableStyles>"));
}
else
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("tableStyle") == sName )
m_arrItems.Add( new CTableStyle( oReader ));
}
}
virtual EElementType getType () const
{
return et_TableStyles;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultPivotStyle"), m_oDefaultPivotStyle )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultTableStyle"), m_oDefaultTableStyle )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
nullable<CString> m_oDefaultPivotStyle;
nullable<CString> m_oDefaultTableStyle;
};
}
}
#endif // OOX_TABLESTYLES_FILE_INCLUDE_H_

View File

@@ -0,0 +1,483 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_XFS_FILE_INCLUDE_H_
#define OOX_XFS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CAligment : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CAligment)
CAligment()
{
}
virtual ~CAligment()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<alignment"));
if(m_oHorizontal.IsInit())
{
CString sVal;sVal.Format(_T(" horizontal=\"%s\""), m_oHorizontal->ToString());
writer.WriteStringC(sVal);
}
if(m_oIndent.IsInit())
{
CString sVal;sVal.Format(_T(" indent=\"%d\""), m_oIndent->GetValue());
writer.WriteStringC(sVal);
}
if(m_oJustifyLastLine.IsInit())
{
CString sVal;sVal.Format(_T(" justifyLastLine=\"%s\""), m_oJustifyLastLine->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oReadingOrder.IsInit())
{
CString sVal;sVal.Format(_T(" readingOrder=\"%d\""), m_oReadingOrder->GetValue());
writer.WriteStringC(sVal);
}
if(m_oRelativeIndent.IsInit())
{
CString sVal;sVal.Format(_T(" relativeIndent=\"%d\""), m_oRelativeIndent->GetValue());
writer.WriteStringC(sVal);
}
if(m_oShrinkToFit.IsInit())
{
CString sVal;sVal.Format(_T(" shrinkToFit=\"%s\""), m_oShrinkToFit->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oTextRotation.IsInit())
{
CString sVal;sVal.Format(_T(" textRotation=\"%d\""), m_oTextRotation->GetValue());
writer.WriteStringC(sVal);
}
if(m_oVertical.IsInit())
{
CString sVal;sVal.Format(_T(" vertical=\"%s\""), m_oVertical->ToString());
writer.WriteStringC(sVal);
}
if(m_oWrapText.IsInit())
{
CString sVal;sVal.Format(_T(" wrapText=\"%s\""), m_oWrapText->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Aligment;
}
bool IsEmpty()
{
return !(m_oHorizontal.IsInit() || m_oIndent.IsInit() || m_oJustifyLastLine.IsInit() || m_oReadingOrder.IsInit() || m_oRelativeIndent.IsInit() ||
m_oShrinkToFit.IsInit() || m_oTextRotation.IsInit() || (m_oVertical.IsInit() && SimpleTypes::Spreadsheet::verticalalignmentBottom != m_oVertical->GetValue()) || m_oWrapText.IsInit());
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("horizontal"), m_oHorizontal )
WritingElement_ReadAttributes_Read_if ( oReader, _T("indent"), m_oIndent )
WritingElement_ReadAttributes_Read_if ( oReader, _T("justifyLastLine"), m_oJustifyLastLine )
WritingElement_ReadAttributes_Read_if ( oReader, _T("readingOrder"), m_oReadingOrder )
WritingElement_ReadAttributes_Read_if ( oReader, _T("relativeIndent"), m_oRelativeIndent )
WritingElement_ReadAttributes_Read_if ( oReader, _T("shrinkToFit"), m_oShrinkToFit )
WritingElement_ReadAttributes_Read_if ( oReader, _T("textRotation"), m_oTextRotation )
WritingElement_ReadAttributes_Read_if ( oReader, _T("vertical"), m_oVertical )
WritingElement_ReadAttributes_Read_if ( oReader, _T("wrapText"), m_oWrapText )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CHorizontalAlignment<>> m_oHorizontal;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oIndent;
nullable<SimpleTypes::COnOff<>> m_oJustifyLastLine;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oReadingOrder;
nullable<SimpleTypes::CDecimalNumber<>> m_oRelativeIndent;
nullable<SimpleTypes::COnOff<>> m_oShrinkToFit;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oTextRotation;
nullable<SimpleTypes::Spreadsheet::CVerticalAlignment<>> m_oVertical;
nullable<SimpleTypes::COnOff<>> m_oWrapText;
};
class CProtection : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CProtection)
CProtection()
{
}
virtual ~CProtection()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Protection;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hidden"), m_oHidden )
WritingElement_ReadAttributes_Read_if ( oReader, _T("locked"), m_oLocked )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oHidden;
nullable<SimpleTypes::COnOff<>> m_oLocked;
};
class CXfs : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CXfs)
CXfs()
{
}
virtual ~CXfs()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<xf"));
if(m_oFontId.IsInit())
{
CString sVal;sVal.Format(_T(" fontId=\"%d\""), m_oFontId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oFillId.IsInit())
{
CString sVal;sVal.Format(_T(" fillId=\"%d\""), m_oFillId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oBorderId.IsInit())
{
CString sVal;sVal.Format(_T(" borderId=\"%d\""), m_oBorderId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oNumFmtId.IsInit())
{
CString sVal;sVal.Format(_T(" numFmtId=\"%d\""), m_oNumFmtId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oXfId.IsInit())
{
CString sVal;sVal.Format(_T(" xfId=\"%d\""), m_oXfId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oApplyNumberFormat.IsInit())
{
CString sVal;sVal.Format(_T(" applyNumberFormat=\"%s\""), m_oApplyNumberFormat->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oApplyFont.IsInit())
{
CString sVal;sVal.Format(_T(" applyFont=\"%s\""), m_oApplyFont->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oApplyFill.IsInit())
{
CString sVal;sVal.Format(_T(" applyFill=\"%s\""), m_oApplyFill->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oApplyBorder.IsInit())
{
CString sVal;sVal.Format(_T(" applyBorder=\"%s\""), m_oApplyBorder->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oApplyAlignment.IsInit())
{
CString sVal;sVal.Format(_T(" applyAlignment=\"%s\""), m_oApplyAlignment->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oQuotePrefix.IsInit())
{
CString sVal;sVal.Format(_T(" quotePrefix=\"%s\""), m_oQuotePrefix->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oAligment.IsInit())
{
writer.WriteStringC(_T(">"));
m_oAligment->toXML(writer);
writer.WriteStringC(_T("</xf>"));
}
else
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("alignment") == sName )
m_oAligment = oReader;
else if( _T("protection") == sName )
m_oProtection = oReader;
}
}
virtual EElementType getType () const
{
return et_Xfs;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyAlignment"), m_oApplyAlignment )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyBorder"), m_oApplyBorder )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyFill"), m_oApplyFill )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyFont"), m_oApplyFont )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyNumberFormat"), m_oApplyNumberFormat )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyProtection"), m_oApplyProtection )
WritingElement_ReadAttributes_Read_if ( oReader, _T("borderId"), m_oBorderId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("fillId"), m_oFillId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("fontId"), m_oFontId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("numFmtId"), m_oNumFmtId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("pivotButton"), m_oPivotButton )
WritingElement_ReadAttributes_Read_if ( oReader, _T("quotePrefix"), m_oQuotePrefix )
WritingElement_ReadAttributes_Read_if ( oReader, _T("xfId"), m_oXfId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oApplyAlignment;
nullable<SimpleTypes::COnOff<>> m_oApplyBorder;
nullable<SimpleTypes::COnOff<>> m_oApplyFill;
nullable<SimpleTypes::COnOff<>> m_oApplyFont;
nullable<SimpleTypes::COnOff<>> m_oApplyNumberFormat;
nullable<SimpleTypes::COnOff<>> m_oApplyProtection;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oBorderId;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oFillId;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oFontId;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oNumFmtId;
nullable<SimpleTypes::COnOff<>> m_oPivotButton;
nullable<SimpleTypes::COnOff<>> m_oQuotePrefix;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oXfId;
nullable<CAligment> m_oAligment;
nullable<CProtection> m_oProtection;
};
class CCellXfs : public WritingElementWithChilds<CXfs>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCellXfs)
CCellXfs()
{
}
virtual ~CCellXfs()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<cellXfs"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</cellXfs>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("xf") == sName )
m_arrItems.Add( new CXfs( oReader ));
}
}
virtual EElementType getType () const
{
return et_CellXfs;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
class CCellStyleXfs : public WritingElementWithChilds<CXfs>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCellStyleXfs)
CCellStyleXfs()
{
}
virtual ~CCellStyleXfs()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<cellStyleXfs"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</cellStyleXfs>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("xf") == sName )
m_arrItems.Add( new CXfs( oReader ));
}
}
virtual EElementType getType () const
{
return et_CellStyleXfs;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_XFS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,191 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_DXFS_FILE_INCLUDE_H_
#define OOX_DXFS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Borders.h"
#include "Fills.h"
#include "Fonts.h"
#include "NumFmts.h"
namespace OOX
{
namespace Spreadsheet
{
class CDxf : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDxf)
CDxf()
{
}
virtual ~CDxf()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(CString(_T("<dxf>")));
if(m_oFont.IsInit())
m_oFont->toXML(writer);
if(m_oNumFmt.IsInit())
m_oNumFmt->toXML(writer);
if(m_oFill.IsInit())
m_oFill->toXML(writer);
if(m_oAlignment.IsInit())
m_oAlignment->toXML(writer);
if(m_oBorder.IsInit())
m_oBorder->toXML(writer);
if(m_oProtection.IsInit())
m_oProtection->toXML(writer);
writer.WriteStringC(CString(_T("</dxf>")));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("alignment") == sName )
m_oAlignment = oReader;
else if ( _T("border") == sName )
m_oBorder = oReader;
else if ( _T("fill") == sName )
m_oFill = oReader;
else if ( _T("font") == sName )
m_oFont = oReader;
else if ( _T("numFmt") == sName )
m_oNumFmt = oReader;
else if ( _T("protection") == sName )
m_oProtection = oReader;
}
}
virtual EElementType getType () const
{
return et_Dxf;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CAligment> m_oAlignment;
nullable<CBorder> m_oBorder;
nullable<CFill> m_oFill;
nullable<CFont> m_oFont;
nullable<CNumFmt> m_oNumFmt;
nullable<CProtection> m_oProtection;
};
class CDxfs : public WritingElementWithChilds<CDxf>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDxfs)
CDxfs()
{
}
virtual ~CDxfs()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<dxfs"));
if(m_oCount.IsInit())
{
CString sVal;sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</dxfs>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("dxf") == sName )
m_arrItems.Add( new CDxf(oReader));
}
}
virtual EElementType getType () const
{
return et_Dxfs;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_DXFS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,840 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_RPR_FILE_INCLUDE_H_
#define OOX_RPR_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CRgbColor : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CRgbColor)
CRgbColor()
{
}
virtual ~CRgbColor()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_RgbColor;
}
private:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rgb"), m_oRgb )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CHexColor> m_oRgb;
};
class CIndexedColors : public WritingElementWithChilds<CRgbColor>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CIndexedColors)
CIndexedColors()
{
}
virtual ~CIndexedColors()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("rgbColor") == sName )
m_arrItems.Add( new CRgbColor( oReader ));
}
}
virtual EElementType getType () const
{
return et_IndexedColors;
}
static bool GetDefaultRGBAByIndex(int index, unsigned char& unR, unsigned char& unG, unsigned char& unB, unsigned char& unA)
{
unA = 255;
switch(index)
{
case 0 : unR = 0x00; unG = 0x00; unB = 0x00; break;
case 1 : unR = 0xFF; unG = 0xFF; unB = 0xFF; break;
case 2 : unR = 0xFF; unG = 0x00; unB = 0x00; break;
case 3 : unR = 0x00; unG = 0xFF; unB = 0x00; break;
case 4 : unR = 0x00; unG = 0x00; unB = 0xFF; break;
case 5 : unR = 0xFF; unG = 0xFF; unB = 0x00; break;
case 6 : unR = 0xFF; unG = 0x00; unB = 0xFF; break;
case 7 : unR = 0x00; unG = 0xFF; unB = 0xFF; break;
case 8 : unR = 0x00; unG = 0x00; unB = 0x00; break;
case 9 : unR = 0xFF; unG = 0xFF; unB = 0xFF; break;
case 10: unR = 0xFF; unG = 0x00; unB = 0x00; break;
case 11: unR = 0x00; unG = 0xFF; unB = 0x00; break;
case 12: unR = 0x00; unG = 0x00; unB = 0xFF; break;
case 13: unR = 0xFF; unG = 0xFF; unB = 0x00; break;
case 14: unR = 0xFF; unG = 0x00; unB = 0xFF; break;
case 15: unR = 0x00; unG = 0xFF; unB = 0xFF; break;
case 16: unR = 0x80; unG = 0x00; unB = 0x00; break;
case 17: unR = 0x00; unG = 0x80; unB = 0x00; break;
case 18: unR = 0x00; unG = 0x00; unB = 0x80; break;
case 19: unR = 0x80; unG = 0x80; unB = 0x00; break;
case 20: unR = 0x80; unG = 0x00; unB = 0x80; break;
case 21: unR = 0x00; unG = 0x80; unB = 0x80; break;
case 22: unR = 0xC0; unG = 0xC0; unB = 0xC0; break;
case 23: unR = 0x80; unG = 0x80; unB = 0x80; break;
case 24: unR = 0x99; unG = 0x99; unB = 0xFF; break;
case 25: unR = 0x99; unG = 0x33; unB = 0x66; break;
case 26: unR = 0xFF; unG = 0xFF; unB = 0xCC; break;
case 27: unR = 0xCC; unG = 0xFF; unB = 0xFF; break;
case 28: unR = 0x66; unG = 0x00; unB = 0x66; break;
case 29: unR = 0xFF; unG = 0x80; unB = 0x80; break;
case 30: unR = 0x00; unG = 0x66; unB = 0xCC; break;
case 31: unR = 0xCC; unG = 0xCC; unB = 0xFF; break;
case 32: unR = 0x00; unG = 0x00; unB = 0x80; break;
case 33: unR = 0xFF; unG = 0x00; unB = 0xFF; break;
case 34: unR = 0xFF; unG = 0xFF; unB = 0x00; break;
case 35: unR = 0x00; unG = 0xFF; unB = 0xFF; break;
case 36: unR = 0x80; unG = 0x00; unB = 0x80; break;
case 37: unR = 0x80; unG = 0x00; unB = 0x00; break;
case 38: unR = 0x00; unG = 0x80; unB = 0x80; break;
case 39: unR = 0x00; unG = 0x00; unB = 0xFF; break;
case 40: unR = 0x00; unG = 0xCC; unB = 0xFF; break;
case 41: unR = 0xCC; unG = 0xFF; unB = 0xFF; break;
case 42: unR = 0xCC; unG = 0xFF; unB = 0xCC; break;
case 43: unR = 0xFF; unG = 0xFF; unB = 0x99; break;
case 44: unR = 0x99; unG = 0xCC; unB = 0xFF; break;
case 45: unR = 0xFF; unG = 0x99; unB = 0xCC; break;
case 46: unR = 0xCC; unG = 0x99; unB = 0xFF; break;
case 47: unR = 0xFF; unG = 0xCC; unB = 0x99; break;
case 48: unR = 0x33; unG = 0x66; unB = 0xFF; break;
case 49: unR = 0x33; unG = 0xCC; unB = 0xCC; break;
case 50: unR = 0x99; unG = 0xCC; unB = 0x00; break;
case 51: unR = 0xFF; unG = 0xCC; unB = 0x00; break;
case 52: unR = 0xFF; unG = 0x99; unB = 0x00; break;
case 53: unR = 0xFF; unG = 0x66; unB = 0x00; break;
case 54: unR = 0x66; unG = 0x66; unB = 0x99; break;
case 55: unR = 0x96; unG = 0x96; unB = 0x96; break;
case 56: unR = 0x00; unG = 0x33; unB = 0x66; break;
case 57: unR = 0x33; unG = 0x99; unB = 0x66; break;
case 58: unR = 0x00; unG = 0x33; unB = 0x00; break;
case 59: unR = 0x33; unG = 0x33; unB = 0x00; break;
case 60: unR = 0x99; unG = 0x33; unB = 0x00; break;
case 61: unR = 0x99; unG = 0x33; unB = 0x66; break;
case 62: unR = 0x33; unG = 0x33; unB = 0x99; break;
case 63: unR = 0x33; unG = 0x33; unB = 0x33; break;
case 64: unR = 0x00; unG = 0x00; unB = 0x00; break;
case 65: unR = 0xFF; unG = 0xFF; unB = 0xFF; break;
default: return false;
}
return true;
}
static int GetDefaultIndexByRGBA( unsigned char unR, unsigned char unG, unsigned char unB, unsigned char unA)
{
if(255 != unA)
return -1;
int nIndex = -1;
if(unR == 0x00 && unG == 0x00 && unB == 0x00)
nIndex = 64;
else if(unR == 0xFF && unG == 0xFF && unB == 0xFF)
nIndex = 65;
else if(unR == 0x00 && unG == 0x00 && unB == 0x00)
nIndex = 0;
else if(unR == 0xFF && unG == 0xFF && unB == 0xFF)
nIndex = 1;
else if(unR == 0xFF && unG == 0x00 && unB == 0x00)
nIndex = 2;
else if(unR == 0x00 && unG == 0xFF && unB == 0x00)
nIndex = 3;
else if(unR == 0x00 && unG == 0x00 && unB == 0xFF)
nIndex = 4;
else if(unR == 0xFF && unG == 0xFF && unB == 0x00)
nIndex = 5;
else if(unR == 0xFF && unG == 0x00 && unB == 0xFF)
nIndex = 6;
else if(unR == 0x00 && unG == 0xFF && unB == 0xFF)
nIndex = 7;
else if(unR == 0x00 && unG == 0x00 && unB == 0x00)
nIndex = 8;
else if(unR == 0xFF && unG == 0xFF && unB == 0xFF)
nIndex = 9;
else if(unR == 0xFF && unG == 0x00 && unB == 0x00)
nIndex = 10;
else if(unR == 0x00 && unG == 0xFF && unB == 0x00)
nIndex = 11;
else if(unR == 0x00 && unG == 0x00 && unB == 0xFF)
nIndex = 12;
else if(unR == 0xFF && unG == 0xFF && unB == 0x00)
nIndex = 13;
else if(unR == 0xFF && unG == 0x00 && unB == 0xFF)
nIndex = 14;
else if(unR == 0x00 && unG == 0xFF && unB == 0xFF)
nIndex = 15;
else if(unR == 0x80 && unG == 0x00 && unB == 0x00)
nIndex = 16;
else if(unR == 0x00 && unG == 0x80 && unB == 0x00)
nIndex = 17;
else if(unR == 0x00 && unG == 0x00 && unB == 0x80)
nIndex = 18;
else if(unR == 0x80 && unG == 0x80 && unB == 0x00)
nIndex = 19;
else if(unR == 0x80 && unG == 0x00 && unB == 0x80)
nIndex = 20;
else if(unR == 0x00 && unG == 0x80 && unB == 0x80)
nIndex = 21;
else if(unR == 0xC0 && unG == 0xC0 && unB == 0xC0)
nIndex = 22;
else if(unR == 0x80 && unG == 0x80 && unB == 0x80)
nIndex = 23;
else if(unR == 0x99 && unG == 0x99 && unB == 0xFF)
nIndex = 24;
else if(unR == 0x99 && unG == 0x33 && unB == 0x66)
nIndex = 25;
else if(unR == 0xFF && unG == 0xFF && unB == 0xCC)
nIndex = 26;
else if(unR == 0xCC && unG == 0xFF && unB == 0xFF)
nIndex = 27;
else if(unR == 0x66 && unG == 0x00 && unB == 0x66)
nIndex = 28;
else if(unR == 0xFF && unG == 0x80 && unB == 0x80)
nIndex = 29;
else if(unR == 0x00 && unG == 0x66 && unB == 0xCC)
nIndex = 30;
else if(unR == 0xCC && unG == 0xCC && unB == 0xFF)
nIndex = 31;
else if(unR == 0x00 && unG == 0x00 && unB == 0x80)
nIndex = 32;
else if(unR == 0xFF && unG == 0x00 && unB == 0xFF)
nIndex = 33;
else if(unR == 0xFF && unG == 0xFF && unB == 0x00)
nIndex = 34;
else if(unR == 0x00 && unG == 0xFF && unB == 0xFF)
nIndex = 35;
else if(unR == 0x80 && unG == 0x00 && unB == 0x80)
nIndex = 36;
else if(unR == 0x80 && unG == 0x00 && unB == 0x00)
nIndex = 37;
else if(unR == 0x00 && unG == 0x80 && unB == 0x80)
nIndex = 38;
else if(unR == 0x00 && unG == 0x00 && unB == 0xFF)
nIndex = 39;
else if(unR == 0x00 && unG == 0xCC && unB == 0xFF)
nIndex = 40;
else if(unR == 0xCC && unG == 0xFF && unB == 0xFF)
nIndex = 41;
else if(unR == 0xCC && unG == 0xFF && unB == 0xCC)
nIndex = 42;
else if(unR == 0xFF && unG == 0xFF && unB == 0x99)
nIndex = 43;
else if(unR == 0x99 && unG == 0xCC && unB == 0xFF)
nIndex = 44;
else if(unR == 0xFF && unG == 0x99 && unB == 0xCC)
nIndex = 45;
else if(unR == 0xCC && unG == 0x99 && unB == 0xFF)
nIndex = 46;
else if(unR == 0xFF && unG == 0xCC && unB == 0x99)
nIndex = 47;
else if(unR == 0x33 && unG == 0x66 && unB == 0xFF)
nIndex = 48;
else if(unR == 0x33 && unG == 0xCC && unB == 0xCC)
nIndex = 49;
else if(unR == 0x99 && unG == 0xCC && unB == 0x00)
nIndex = 50;
else if(unR == 0xFF && unG == 0xCC && unB == 0x00)
nIndex = 51;
else if(unR == 0xFF && unG == 0x99 && unB == 0x00)
nIndex = 52;
else if(unR == 0xFF && unG == 0x66 && unB == 0x00)
nIndex = 53;
else if(unR == 0x66 && unG == 0x66 && unB == 0x99)
nIndex = 54;
else if(unR == 0x96 && unG == 0x96 && unB == 0x96)
nIndex = 55;
else if(unR == 0x00 && unG == 0x33 && unB == 0x66)
nIndex = 56;
else if(unR == 0x33 && unG == 0x99 && unB == 0x66)
nIndex = 57;
else if(unR == 0x00 && unG == 0x33 && unB == 0x00)
nIndex = 58;
else if(unR == 0x33 && unG == 0x33 && unB == 0x00)
nIndex = 59;
else if(unR == 0x99 && unG == 0x33 && unB == 0x00)
nIndex = 60;
else if(unR == 0x99 && unG == 0x33 && unB == 0x66)
nIndex = 61;
else if(unR == 0x33 && unG == 0x33 && unB == 0x99)
nIndex = 62;
else if(unR == 0x33 && unG == 0x33 && unB == 0x33)
nIndex = 63;
return nIndex;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
class CColor : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CColor)
CColor()
{
}
virtual ~CColor()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
toXML2(writer, _T("color"));
}
void toXML2(CStringWriter& writer, CString sName) const
{
writer.WriteStringC(_T("<"));
writer.WriteStringC(sName);
if(m_oAuto.IsInit())
{
CString sVal;sVal.Format(_T(" auto=\"%s\""), m_oAuto->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oIndexed.IsInit())
{
CString sVal;sVal.Format(_T(" indexed=\"%d\""), m_oIndexed->GetValue());
writer.WriteStringC(sVal);
}
if(m_oRgb.IsInit())
{
int nIndex = OOX::Spreadsheet::CIndexedColors::GetDefaultIndexByRGBA(m_oRgb->Get_R(), m_oRgb->Get_G(), m_oRgb->Get_B(), m_oRgb->Get_A());
if(-1 == nIndex)
{
CString sVal;sVal.Format(_T(" rgb=\"%s\""), m_oRgb->ToString());
writer.WriteStringC(sVal);
}
else
{
CString sVal;sVal.Format(_T(" indexed=\"%d\""), nIndex);
writer.WriteStringC(sVal);
}
}
if(m_oThemeColor.IsInit())
{
CString sVal;sVal.Format(_T(" theme=\"%d\""), m_oThemeColor->GetValue());
writer.WriteStringC(sVal);
}
if(m_oTint.IsInit())
{
CString sVal;sVal.Format(_T(" tint=\"%s\""), SpreadsheetCommon::WriteDouble(m_oTint->GetValue()));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Color;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("auto"), m_oAuto )
WritingElement_ReadAttributes_Read_if ( oReader, _T("indexed"), m_oIndexed )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rgb"), m_oRgb )
WritingElement_ReadAttributes_Read_if ( oReader, _T("theme"), m_oThemeColor )
WritingElement_ReadAttributes_Read_if ( oReader, _T("tint"), m_oTint )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oAuto;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oIndexed;
nullable<SimpleTypes::Spreadsheet::CHexColor> m_oRgb;
nullable<SimpleTypes::Spreadsheet::CThemeColor<>> m_oThemeColor;
nullable<SimpleTypes::CDouble> m_oTint;
};
class CMruColors : public WritingElementWithChilds<CColor>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CMruColors)
CMruColors()
{
}
virtual ~CMruColors()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("color") == sName )
m_arrItems.Add( new CColor( oReader ));
}
}
virtual EElementType getType () const
{
return et_MruColors;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
class CCharset
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCharset)
CCharset()
{
}
virtual ~CCharset()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oCharset )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CFontCharset<>> m_oCharset;
};
class CVerticalAlign
{
public:
WritingElementSpreadsheet_AdditionConstructors(CVerticalAlign)
CVerticalAlign()
{
}
virtual ~CVerticalAlign()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVerticalAlign )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CVerticalAlignRun<>> m_oVerticalAlign;
};
class CFontFamily
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFontFamily)
CFontFamily()
{
}
virtual ~CFontFamily()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oFontFamily )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CFontFamily<>> m_oFontFamily;
};
class CFontScheme
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFontScheme)
CFontScheme()
{
}
virtual ~CFontScheme()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oFontScheme )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CFontScheme<>> m_oFontScheme;
};
class CUnderline
{
public:
WritingElementSpreadsheet_AdditionConstructors(CUnderline)
CUnderline()
{
}
virtual ~CUnderline()
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oUnderline )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CUnderline<>> m_oUnderline;
};
class CRPr : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CRPr)
CRPr()
{
}
virtual ~CRPr()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<rPr>"));
if(m_oBold.IsInit())
{
if(SimpleTypes::onoffTrue == m_oBold->m_oVal.GetValue())
writer.WriteStringC(_T("<b/>"));
else
writer.WriteStringC(_T("<b val=\"false\"/>"));
}
if(m_oCharset.IsInit() && m_oCharset->m_oCharset.IsInit())
{
CString sVal;sVal.Format(_T("<charset val=\"%s\"/>"), m_oCharset->m_oCharset->ToString());
writer.WriteStringC(sVal);
}
if(m_oColor.IsInit())
m_oColor->toXML2(writer, _T("color"));
if(m_oCondense.IsInit())
{
if(SimpleTypes::onoffTrue == m_oCondense->m_oVal.GetValue())
writer.WriteStringC(_T("<condense/>"));
else
writer.WriteStringC(_T("<condense val=\"false\"/>"));
}
if(m_oExtend.IsInit())
{
if(SimpleTypes::onoffTrue == m_oExtend->m_oVal.GetValue())
writer.WriteStringC(_T("<extend/>"));
else
writer.WriteStringC(_T("<extend val=\"false\"/>"));
}
if(m_oFamily.IsInit() && m_oFamily->m_oFontFamily.IsInit())
{
CString sVal;sVal.Format(_T("<family val=\"%s\"/>"), m_oFamily->m_oFontFamily->ToString());
writer.WriteStringC(sVal);
}
if(m_oItalic.IsInit())
{
if(SimpleTypes::onoffTrue == m_oItalic->m_oVal.GetValue())
writer.WriteStringC(_T("<i/>"));
else
writer.WriteStringC(_T("<i val=\"false\"/>"));
}
if(m_oOutline.IsInit())
{
if(SimpleTypes::onoffTrue == m_oOutline->m_oVal.GetValue())
writer.WriteStringC(_T("<outline/>"));
else
writer.WriteStringC(_T("<outline val=\"false\"/>"));
}
if(m_oRFont.IsInit() && m_oRFont->m_sVal.IsInit())
{
CString sVal;sVal.Format(_T("<rFont val=\"%s\"/>"), XmlUtils::EncodeXmlString(m_oRFont->m_sVal.get()));
writer.WriteStringC(sVal);
}
if(m_oScheme.IsInit() && m_oScheme->m_oFontScheme.IsInit())
{
CString sVal;sVal.Format(_T("<scheme val=\"%s\"/>"), m_oScheme->m_oFontScheme->ToString());
writer.WriteStringC(sVal);
}
if(m_oShadow.IsInit())
{
if(SimpleTypes::onoffTrue == m_oShadow->m_oVal.GetValue())
writer.WriteStringC(_T("<shadow/>"));
else
writer.WriteStringC(_T("<shadow val=\"false\"/>"));
}
if(m_oStrike.IsInit())
{
if(SimpleTypes::onoffTrue == m_oStrike->m_oVal.GetValue())
writer.WriteStringC(_T("<strike/>"));
else
writer.WriteStringC(_T("<strike val=\"false\"/>"));
}
if(m_oSz.IsInit() && m_oSz->m_oVal.IsInit())
{
CString sVal;sVal.Format(_T("<sz val=\"%s\"/>"), SpreadsheetCommon::WriteDouble(m_oSz->m_oVal->GetValue()));
writer.WriteStringC(sVal);
}
if(m_oUnderline.IsInit() && m_oUnderline->m_oUnderline.IsInit())
{
CString sVal;
if( SimpleTypes::underlineSingle != m_oUnderline->m_oUnderline->GetValue())
sVal.Format(_T("<u val=\"%s\"/>"), m_oUnderline->m_oUnderline->ToString());
else
sVal.Format(_T("<u/>"), m_oUnderline->m_oUnderline->ToString());
writer.WriteStringC(sVal);
}
if(m_oVertAlign.IsInit() && m_oVertAlign->m_oVerticalAlign.IsInit())
{
CString sVal;sVal.Format(_T("<vertAlign val=\"%s\"/>"), m_oVertAlign->m_oVerticalAlign->ToString());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("</rPr>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("b") == sName )
m_oBold = oReader;
else if ( _T("charset") == sName )
m_oCharset = oReader;
else if ( _T("color") == sName )
m_oColor = oReader;
else if ( _T("condense") == sName )
m_oCondense = oReader;
else if ( _T("extend") == sName )
m_oExtend = oReader;
else if ( _T("family") == sName )
m_oFamily = oReader;
else if ( _T("i") == sName )
m_oItalic = oReader;
else if ( _T("outline") == sName )
m_oOutline = oReader;
else if ( _T("rFont") == sName || _T("name") == sName)
m_oRFont = oReader;
else if ( _T("scheme") == sName )
m_oScheme = oReader;
else if ( _T("shadow") == sName )
m_oShadow = oReader;
else if ( _T("strike") == sName )
m_oStrike = oReader;
else if ( _T("sz") == sName )
m_oSz = oReader;
else if ( _T("u") == sName )
m_oUnderline = oReader;
else if ( _T("vertAlign") == sName )
m_oVertAlign = oReader;
}
}
virtual EElementType getType () const
{
return et_rPr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oBold;
nullable<CCharset> m_oCharset;
nullable<CColor> m_oColor;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oCondense;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oExtend;
nullable<CFontFamily > m_oFamily;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oItalic;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oOutline;
nullable<ComplexTypes::Spreadsheet::CString_> m_oRFont;
nullable<CFontScheme> m_oScheme;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oShadow;
nullable<ComplexTypes::Spreadsheet::COnOff2<SimpleTypes::onoffTrue> > m_oStrike;
nullable<ComplexTypes::Spreadsheet::CDouble> m_oSz;
nullable<CUnderline> m_oUnderline;
nullable<CVerticalAlign> m_oVertAlign;
};
}
}
#endif // OOX_RPR_FILE_INCLUDE_H_

View File

@@ -0,0 +1,905 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_AUTOFILTER_FILE_INCLUDE_H_
#define OOX_AUTOFILTER_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CSortCondition : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSortCondition)
CSortCondition()
{
}
virtual ~CSortCondition()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oDescending.IsInit() || m_oRef.IsInit() || m_oSortBy.IsInit() || m_oDxfId.IsInit())
{
writer.WriteStringC(CString(_T("<sortCondition")));
if(m_oSortBy.IsInit())
{
CString sXml;
sXml.Format(_T(" sortBy=\"%s\""), m_oSortBy->ToString());
writer.WriteStringC(sXml);
}
if(m_oDescending.IsInit())
{
CString sXml;
sXml.Format(_T(" descending=\"%s\""), m_oDescending->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sXml);
}
if(m_oRef.IsInit())
{
CString sXml;
sXml.Format(_T(" ref=\"%s\""), XmlUtils::EncodeXmlString(m_oRef->GetValue()));
writer.WriteStringC(sXml);
}
if(m_oDxfId.IsInit())
{
CString sXml;
sXml.Format(_T(" dxfId=\"%d\""), m_oDxfId->GetValue());
writer.WriteStringC(sXml);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_SortCondition;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("descending"), m_oDescending )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("sortBy"), m_oSortBy )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dxfId"), m_oDxfId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<> > m_oDescending;
nullable<SimpleTypes::CRelationshipId > m_oRef;
nullable<SimpleTypes::Spreadsheet::CSortBy<> > m_oSortBy;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oDxfId;
};
class CSortState : public WritingElementWithChilds<CSortCondition>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSortState)
CSortState()
{
}
virtual ~CSortState()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oRef.IsInit() && m_arrItems.GetSize() > 0)
{
CString sXml;
sXml.Format(_T("<sortState ref=\"%s\""), XmlUtils::EncodeXmlString(m_oRef->GetValue()));
if(m_oCaseSensitive.IsInit())
sXml.AppendFormat(_T(" caseSensitive=\"%s\""), m_oCaseSensitive->ToString2(SimpleTypes::onofftostring1));
sXml.Append(_T(">"));
writer.WriteStringC(sXml);
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(CString(_T("</sortState>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("sortCondition") == sName )
m_arrItems.Add(new CSortCondition(oReader));
}
}
virtual EElementType getType () const
{
return et_SortState;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("caseSensitive"), m_oCaseSensitive )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oRef;
nullable<SimpleTypes::COnOff<> > m_oCaseSensitive;
};
class CColorFilter : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CColorFilter)
CColorFilter()
{
}
virtual ~CColorFilter()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oDxfId.IsInit())
{
CString sXml;
sXml.Format(_T("<colorFilter dxfId=\"%d\""), m_oDxfId->GetValue());
writer.WriteStringC(sXml);
if(m_oCellColor.IsInit() && false == m_oCellColor->ToBool())
writer.WriteStringC(CString(_T(" cellColor=\"0\"")));
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_ColorFilter;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cellColor"), m_oCellColor )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dxfId"), m_oDxfId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<> > m_oCellColor;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oDxfId;
};
class CDynamicFilter : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDynamicFilter)
CDynamicFilter()
{
}
virtual ~CDynamicFilter()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oType.IsInit())
{
CString sXml;
sXml.Format(_T("<dynamicFilter type=\"%s\""), m_oType->ToString());
writer.WriteStringC(sXml);
if(m_oVal.IsInit())
{
CString sVal;
sVal.Format(_T(" val=\"%s\""), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(m_oVal->GetValue()));
writer.WriteStringC(sVal);
}
if(m_oMaxVal.IsInit())
{
CString sVal;
sVal.Format(_T(" maxVal=\"%s\""), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(m_oMaxVal->GetValue()));
writer.WriteStringC(sVal);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_DynamicFilter;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("type"), m_oType )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_Read_if ( oReader, _T("maxVal"), m_oMaxVal )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CDynamicFilterType<> > m_oType;
nullable<SimpleTypes::CDouble > m_oVal;
nullable<SimpleTypes::CDouble > m_oMaxVal;
};
class CCustomFilter : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCustomFilter)
CCustomFilter()
{
}
virtual ~CCustomFilter()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oOperator.IsInit() && m_oVal.IsInit())
{
CString sXml;
sXml.Format(_T("<customFilter operator=\"%s\" val=\"%s\"/>"), m_oOperator->ToString(), m_oVal.get());
writer.WriteStringC(sXml);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_CustomFilters;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("operator"), m_oOperator )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CCustomFilter<> > m_oOperator;
nullable<CString > m_oVal;
};
class CCustomFilters : public WritingElementWithChilds<CCustomFilter>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCustomFilters)
CCustomFilters()
{
}
virtual ~CCustomFilters()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(CString(_T("<customFilters")));
if(m_oAnd.IsInit() && true == m_oAnd->ToBool())
writer.WriteStringC(CString(_T(" and=\"1\"")));
writer.WriteStringC(CString(_T(">")));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(CString(_T("</customFilters>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("customFilter") == sName )
m_arrItems.Add( new CCustomFilter(oReader));
}
}
virtual EElementType getType () const
{
return et_CustomFilters;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("and"), m_oAnd )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<> > m_oAnd;
};
class CFilter : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFilter)
CFilter()
{
}
virtual ~CFilter()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oVal.IsInit())
{
CString sXml;
sXml.Format(_T("<filter val=\"%s\"/>"), XmlUtils::EncodeXmlString(m_oVal.get()));
writer.WriteStringC(sXml);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Filter;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString > m_oVal;
};
class CDateGroupItem : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDateGroupItem)
CDateGroupItem()
{
}
virtual ~CDateGroupItem()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oDateTimeGrouping.IsInit())
{
writer.WriteStringC(CString(_T("<dateGroupItem")));
if(m_oYear.IsInit())
{
CString sXml;
sXml.Format(_T(" year=\"%d\""), m_oYear->GetValue());
writer.WriteStringC(sXml);
}
if(m_oMonth.IsInit())
{
CString sXml;
sXml.Format(_T(" month=\"%d\""), m_oMonth->GetValue());
writer.WriteStringC(sXml);
}
if(m_oDay.IsInit())
{
CString sXml;
sXml.Format(_T(" day=\"%d\""), m_oDay->GetValue());
writer.WriteStringC(sXml);
}
if(m_oHour.IsInit())
{
CString sXml;
sXml.Format(_T(" hour=\"%d\""), m_oHour->GetValue());
writer.WriteStringC(sXml);
}
if(m_oMinute.IsInit())
{
CString sXml;
sXml.Format(_T(" minute=\"%d\""), m_oMinute->GetValue());
writer.WriteStringC(sXml);
}
if(m_oSecond.IsInit())
{
CString sXml;
sXml.Format(_T(" second=\"%d\""), m_oSecond->GetValue());
writer.WriteStringC(sXml);
}
if(m_oDateTimeGrouping.IsInit())
{
CString sXml;
sXml.Format(_T(" dateTimeGrouping=\"%s\""), m_oDateTimeGrouping->ToString());
writer.WriteStringC(sXml);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_DateGroupItem;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dateTimeGrouping"), m_oDateTimeGrouping )
WritingElement_ReadAttributes_Read_if ( oReader, _T("day"), m_oDay )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hour"), m_oHour )
WritingElement_ReadAttributes_Read_if ( oReader, _T("minute"), m_oMinute )
WritingElement_ReadAttributes_Read_if ( oReader, _T("month"), m_oMonth )
WritingElement_ReadAttributes_Read_if ( oReader, _T("second"), m_oSecond )
WritingElement_ReadAttributes_Read_if ( oReader, _T("year"), m_oYear )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CDateTimeGroup<> > m_oDateTimeGrouping;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oDay;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oHour;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oMinute;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oMonth;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oSecond;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oYear;
};
class CFilters : public WritingElementWithChilds<>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFilters)
CFilters()
{
}
virtual ~CFilters()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<filters"));
if(m_oBlank.IsInit())
{
CString sXml;
sXml.Format(_T(" blank=\"%s\""), m_oBlank->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sXml);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</filters>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("dateGroupItem") == sName )
m_arrItems.Add( new CDateGroupItem(oReader));
if ( _T("filter") == sName )
m_arrItems.Add( new CFilter(oReader));
}
}
virtual EElementType getType () const
{
return et_Filters;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("blank"), m_oBlank )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<> > m_oBlank;
};
class CTop10 : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTop10)
CTop10()
{
}
virtual ~CTop10()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oVal.IsInit())
{
writer.WriteStringC(CString(_T("<top10")));
if(m_oTop.IsInit() && false == m_oTop->ToBool())
writer.WriteStringC(CString(_T(" top=\"0\"")));
if(m_oPercent.IsInit() && true == m_oPercent->ToBool())
writer.WriteStringC(CString(_T(" percent=\"1\"")));
if(m_oVal.IsInit())
{
CString sXml;
sXml.Format(_T(" val=\"%s\""), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(m_oVal->GetValue()));
writer.WriteStringC(sXml);
}
if(m_oFilterVal.IsInit())
{
CString sXml;
sXml.Format(_T(" filterVal=\"%s\""), OOX::Spreadsheet::SpreadsheetCommon::WriteDouble(m_oFilterVal->GetValue()));
writer.WriteStringC(sXml);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_ColorFilter;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("filterVal"), m_oFilterVal )
WritingElement_ReadAttributes_Read_if ( oReader, _T("percent"), m_oPercent )
WritingElement_ReadAttributes_Read_if ( oReader, _T("top"), m_oTop )
WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), m_oVal )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CDouble > m_oFilterVal;
nullable<SimpleTypes::COnOff<> > m_oPercent;
nullable<SimpleTypes::COnOff<> > m_oTop;
nullable<SimpleTypes::CDouble > m_oVal;
};
class CFilterColumn : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFilterColumn)
CFilterColumn()
{
}
virtual ~CFilterColumn()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oColId.IsInit() && (m_oColorFilter.IsInit() || m_oDynamicFilter.IsInit() || m_oCustomFilters.IsInit() || m_oFilters.IsInit() ||
m_oTop10.IsInit() || m_oShowButton.IsInit() || m_oHiddenButton.IsInit()))
{
CString sXml;
sXml.Format(_T("<filterColumn colId=\"%d\""), m_oColId->GetValue());
writer.WriteStringC(sXml);
if(m_oShowButton.IsInit() && false == m_oShowButton->ToBool())
writer.WriteStringC(CString(_T(" showButton=\"0\"")));
if(m_oHiddenButton.IsInit())
{
CString sXml;sXml.Format(_T(" hiddenButton=\"%s\""), m_oHiddenButton->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sXml);
}
writer.WriteStringC(CString(_T(">")));
if(m_oColorFilter.IsInit())
m_oColorFilter->toXML(writer);
if(m_oDynamicFilter.IsInit())
m_oDynamicFilter->toXML(writer);
if(m_oCustomFilters.IsInit())
m_oCustomFilters->toXML(writer);
if(m_oFilters.IsInit())
m_oFilters->toXML(writer);
if(m_oTop10.IsInit())
m_oTop10->toXML(writer);
writer.WriteStringC(CString(_T("</filterColumn>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("colorFilter") == sName )
m_oColorFilter = oReader;
else if ( _T("dynamicFilter") == sName )
m_oDynamicFilter = oReader;
else if ( _T("customFilters") == sName )
m_oCustomFilters = oReader;
else if ( _T("filters") == sName )
m_oFilters = oReader;
else if ( _T("top10") == sName )
m_oTop10 = oReader;
}
}
virtual EElementType getType () const
{
return et_FilterColumn;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("colId"), m_oColId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hiddenButton"), m_oHiddenButton )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showButton"), m_oShowButton )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oColId;
nullable<SimpleTypes::COnOff<> > m_oHiddenButton;
nullable<SimpleTypes::COnOff<> > m_oShowButton;
nullable<CColorFilter > m_oColorFilter;
nullable<CDynamicFilter > m_oDynamicFilter;
nullable<CCustomFilters > m_oCustomFilters;
nullable<CFilters > m_oFilters;
nullable<CTop10 > m_oTop10;
};
class CAutofilter : public WritingElementWithChilds<CFilterColumn>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CAutofilter)
CAutofilter()
{
}
virtual ~CAutofilter()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oRef.IsInit())
{
CString sXml;
sXml.Format(_T("<autoFilter ref=\"%s\">"), XmlUtils::EncodeXmlString(m_oRef->GetValue()));
writer.WriteStringC(sXml);
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
if(m_oSortState.IsInit())
m_oSortState->toXML(writer);
writer.WriteStringC(CString(_T("</autoFilter>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("filterColumn") == sName )
m_arrItems.Add(new CFilterColumn(oReader));
else if ( _T("sortState") == sName )
m_oSortState = oReader;
}
}
virtual EElementType getType () const
{
return et_Autofilter;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oRef;
nullable<CSortState > m_oSortState;
};
}
}
#endif // OOX_AUTOFILTER_FILE_INCLUDE_H_

View File

@@ -0,0 +1,588 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_TABLE_FILE_INCLUDE_H_
#define OOX_TABLE_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "Autofilter.h"
namespace OOX
{
namespace Spreadsheet
{
class CTableStyleInfo : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableStyleInfo)
CTableStyleInfo()
{
}
virtual ~CTableStyleInfo()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oName.IsInit())
{
int nShowColumnStripes = 0;
int nShowFirstColumn = 0;
int nShowLastColumn = 0;
int nShowRowStripes = 0;
if(m_oShowColumnStripes.IsInit() && true == m_oShowColumnStripes->ToBool())
nShowColumnStripes = 1;
if(m_oShowFirstColumn.IsInit() && true == m_oShowFirstColumn->ToBool())
nShowFirstColumn = 1;
if(m_oShowLastColumn.IsInit() && true == m_oShowLastColumn->ToBool())
nShowLastColumn = 1;
if(m_oShowRowStripes.IsInit() && true == m_oShowRowStripes->ToBool())
nShowRowStripes = 1;
CString sXml;
sXml.Format(_T("<tableStyleInfo name=\"%s\" showFirstColumn=\"%d\" showLastColumn=\"%d\" showRowStripes=\"%d\" showColumnStripes=\"%d\"/>"), XmlUtils::EncodeXmlString(m_oName.get()), nShowFirstColumn, nShowLastColumn, nShowRowStripes, nShowColumnStripes);
writer.WriteStringC(sXml);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_TableStyleInfo;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showColumnStripes"), m_oShowColumnStripes )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showFirstColumn"), m_oShowFirstColumn )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showLastColumn"), m_oShowLastColumn )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showRowStripes"), m_oShowRowStripes )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString > m_oName;
nullable<SimpleTypes::COnOff<> > m_oShowColumnStripes;
nullable<SimpleTypes::COnOff<> > m_oShowFirstColumn;
nullable<SimpleTypes::COnOff<> > m_oShowLastColumn;
nullable<SimpleTypes::COnOff<> > m_oShowRowStripes;
};
class CTableColumn : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableColumn)
CTableColumn()
{
}
virtual ~CTableColumn()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
CString sRoot;
writer.WriteStringC(CString(_T("<tableColumn")));
if(m_oId.IsInit())
{
CString sXml;
sXml.Format(_T(" id=\"%d\""), m_oId->GetValue());
writer.WriteStringC(sXml);
}
if(m_oName.IsInit())
{
CString sXml;
sXml.Format(_T(" name=\"%s\""), XmlUtils::EncodeXmlString(m_oName.get()));
writer.WriteStringC(sXml);
}
if(m_oTotalsRowLabel.IsInit())
{
CString sXml;
sXml.Format(_T(" totalsRowLabel=\"%s\""), XmlUtils::EncodeXmlString(m_oTotalsRowLabel.get()));
writer.WriteStringC(sXml);
}
if(m_oTotalsRowFunction.IsInit())
{
CString sXml;
sXml.Format(_T(" totalsRowFunction=\"%s\""), m_oTotalsRowFunction->ToString());
writer.WriteStringC(sXml);
}
if(m_oDataDxfId.IsInit())
{
CString sXml;
sXml.Format(_T(" dataDxfId=\"%d\""), m_oDataDxfId->GetValue());
writer.WriteStringC(sXml);
}
if(m_oTotalsRowFormula.IsInit() || m_oCalculatedColumnFormula.IsInit())
{
writer.WriteStringC(CString(_T(">")));
if(m_oTotalsRowFormula.IsInit())
{
CString sXml;
sXml.Format(_T("<totalsRowFormula>%s</totalsRowFormula>"), XmlUtils::EncodeXmlString(m_oTotalsRowFormula.get()));
writer.WriteStringC(sXml);
}
if(m_oCalculatedColumnFormula.IsInit())
{
CString sXml;
sXml.Format(_T("<calculatedColumnFormula>%s</calculatedColumnFormula>"), XmlUtils::EncodeXmlString(m_oCalculatedColumnFormula.get()));
writer.WriteStringC(sXml);
}
writer.WriteStringC(CString(_T("</tableColumn>")));
}
else
{
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("totalsRowFormula") == sName )
m_oTotalsRowFormula = oReader.GetText2();
else if ( _T("calculatedColumnFormula") == sName )
m_oCalculatedColumnFormula = oReader.GetText2();
}
}
virtual EElementType getType () const
{
return et_TableColumn;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("id"), m_oId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("totalsRowLabel"), m_oTotalsRowLabel )
WritingElement_ReadAttributes_Read_if ( oReader, _T("totalsRowFunction"), m_oTotalsRowFunction )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dataDxfId"), m_oDataDxfId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oId;
nullable<CString > m_oName;
nullable<CString > m_oTotalsRowLabel;
nullable<SimpleTypes::Spreadsheet::CTotalsRowFunction<> > m_oTotalsRowFunction;
nullable<CString > m_oTotalsRowFormula;
nullable<CString > m_oCalculatedColumnFormula;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oDataDxfId;
};
class CTableColumns : public WritingElementWithChilds<CTableColumn>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableColumns)
CTableColumns()
{
}
virtual ~CTableColumns()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
CString sRoot;
sRoot.Format(_T("<tableColumns count=\"%d\">"), m_arrItems.GetSize());
writer.WriteStringC(sRoot);
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(CString(_T("</tableColumns>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("tableColumn") == sName )
m_arrItems.Add(new CTableColumn(oReader));
}
}
virtual EElementType getType () const
{
return et_TableColumns;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oCount;
};
class CTable : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTable)
CTable()
{
}
virtual ~CTable()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void toXML2(CStringWriter& writer, int nIndex) const
{
if(m_oRef.IsInit() && m_oDisplayName.IsInit())
{
CString sRoot;
sRoot.Format(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><table xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" id=\"%d\" name=\"%s\" displayName=\"%s\" ref=\"%s\""), nIndex, m_oDisplayName.get(), m_oDisplayName.get(), m_oRef->GetValue());
writer.WriteStringC(sRoot);
if(m_oHeaderRowCount.IsInit() && 0 == m_oHeaderRowCount->GetValue())
writer.WriteStringC(CString(_T(" headerRowCount=\"0\"")));
if(m_oTotalsRowCount.IsInit() && m_oTotalsRowCount->GetValue() > 0)
writer.WriteStringC(CString(_T(" totalsRowCount=\"1\"")));
else
writer.WriteStringC(CString(_T(" totalsRowShown=\"0\"")));
writer.WriteStringC(CString(_T(">")));
if(m_oAutoFilter.IsInit())
m_oAutoFilter->toXML(writer);
if(m_oSortState.IsInit())
m_oSortState->toXML(writer);
if(m_oTableColumns.IsInit())
m_oTableColumns->toXML(writer);
if(m_oTableStyleInfo.IsInit())
m_oTableStyleInfo->toXML(writer);
writer.WriteStringC(_T("</table>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("autoFilter") == sName )
m_oAutoFilter = oReader;
else if ( _T("sortState") == sName )
m_oSortState = oReader;
else if ( _T("tableColumns") == sName )
m_oTableColumns = oReader;
else if ( _T("tableStyleInfo") == sName )
m_oTableStyleInfo = oReader;
}
}
virtual EElementType getType () const
{
return et_Table;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("headerRowCount"), m_oHeaderRowCount )
WritingElement_ReadAttributes_Read_if ( oReader, _T("totalsRowCount"), m_oTotalsRowCount )
WritingElement_ReadAttributes_Read_if ( oReader, _T("displayName"), m_oDisplayName )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oRef;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oHeaderRowCount;
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oTotalsRowCount;
nullable<CString > m_oDisplayName;
nullable<CAutofilter > m_oAutoFilter;
nullable<CSortState > m_oSortState;
nullable<CTableColumns > m_oTableColumns;
nullable<CTableStyleInfo > m_oTableStyleInfo;
};
class CTablePart : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTablePart)
CTablePart()
{
}
virtual ~CTablePart()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oRId.IsInit())
{
CString sXml;
sXml.Format(_T("<tablePart r:id=\"%s\"/>"), m_oRId->GetValue());
writer.WriteStringC(sXml);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_TablePart;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oRId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oRId;
};
class CTableParts : public WritingElementWithChilds<CTablePart>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CTableParts)
CTableParts()
{
}
virtual ~CTableParts()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
CString sXml;
sXml.Format(_T("<tableParts count=\"%d\">"), m_arrItems.GetSize());
writer.WriteStringC(sXml);
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(CString(_T("</tableParts>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("tablePart") == sName )
m_arrItems.Add(new CTablePart(oReader));
}
}
virtual EElementType getType () const
{
return et_TableParts;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oCount;
};
class CTableFile : public OOX::FileGlobalEnumerated, public OOX::Spreadsheet::IFileContainer
{
public:
CTableFile()
{
}
CTableFile(const CPath& oPath)
{
read( oPath );
}
virtual ~CTableFile()
{
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
m_oTable = oReader;
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
if(m_oTable.IsInit())
{
CStringWriter sXml;
int nGlobalNumber = OOX::FileGlobalEnumerated::GetGlobalNumber();
m_oTable->toXML2(sXml, nGlobalNumber);
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Table;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
nullable<CTable> m_oTable;
};
}
}
#endif // OOX_TABLE_FILE_INCLUDE_H_

View File

@@ -0,0 +1,104 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_WORKBOOK_FILE_INCLUDE_H_
#define OOX_WORKBOOK_FILE_INCLUDE_H_
#include "../../Base/Nullable.h"
#include "FileTypes.h"
namespace OOX
{
namespace Spreadsheet
{
class CWorkbook : public OOX::File, public IFileContainer
{
public:
CWorkbook()
{
}
CWorkbook(const CPath& oPath)
{
}
virtual ~CWorkbook()
{
}
public:
virtual void read(const CPath& oPath)
{
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Workbook;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
public:
void ClearItems()
{
}
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("w:conformance"), m_oConformance )
WritingElement_ReadAttributes_End( oReader )
}
public:
CSimpleArray<WritingElement *> m_arrItems;
};
}
}
#endif // OOX_WORKBOOK_FILE_INCLUDE_H_

View File

@@ -0,0 +1,197 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_BOOKVIEWS_FILE_INCLUDE_H_
#define OOX_BOOKVIEWS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CWorkbookView : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CWorkbookView)
CWorkbookView()
{
}
virtual ~CWorkbookView()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<workbookView"));
if(m_oXWindow.IsInit())
{
CString sVal;sVal.Format(_T(" xWindow=\"%d\""), m_oXWindow->GetValue());
writer.WriteStringC(sVal);
}
if(m_oYWindow.IsInit())
{
CString sVal;sVal.Format(_T(" yWindow=\"%d\""), m_oYWindow->GetValue());
writer.WriteStringC(sVal);
}
if(m_oWindowWidth.IsInit())
{
CString sVal;sVal.Format(_T(" windowWidth=\"%d\""), m_oWindowWidth->GetValue());
writer.WriteStringC(sVal);
}
if(m_oWindowHeight.IsInit())
{
CString sVal;sVal.Format(_T(" windowHeight=\"%d\""), m_oWindowHeight->GetValue());
writer.WriteStringC(sVal);
}
if(m_oActiveTab.IsInit())
{
CString sVal;sVal.Format(_T(" activeTab=\"%d\""), m_oActiveTab->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_WorkbookView;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("activeTab"), m_oActiveTab )
WritingElement_ReadAttributes_Read_if ( oReader, _T("autoFilterDateGrouping"), m_oAutoFilterDateGrouping )
WritingElement_ReadAttributes_Read_if ( oReader, _T("firstSheet"), m_oFirstSheet )
WritingElement_ReadAttributes_Read_if ( oReader, _T("minimized"), m_oMinimized )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showHorizontalScroll"), m_oShowHorizontalScroll )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showSheetTabs"), m_oShowSheetTabs )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showVerticalScroll"), m_oShowVerticalScroll )
WritingElement_ReadAttributes_Read_if ( oReader, _T("tabRatio"), m_oTabRatio )
WritingElement_ReadAttributes_Read_if ( oReader, _T("visibility"), m_oVisibility )
WritingElement_ReadAttributes_Read_if ( oReader, _T("windowHeight"), m_oWindowHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("windowWidth"), m_oWindowWidth )
WritingElement_ReadAttributes_Read_if ( oReader, _T("xWindow"), m_oXWindow )
WritingElement_ReadAttributes_Read_if ( oReader, _T("yWindow"), m_oYWindow )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oActiveTab;
nullable<SimpleTypes::COnOff<>> m_oAutoFilterDateGrouping;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oFirstSheet;
nullable<SimpleTypes::COnOff<>> m_oMinimized;
nullable<SimpleTypes::COnOff<>> m_oShowHorizontalScroll;
nullable<SimpleTypes::COnOff<>> m_oShowSheetTabs;
nullable<SimpleTypes::COnOff<>> m_oShowVerticalScroll;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oTabRatio;
nullable<SimpleTypes::Spreadsheet::CVisibleType<>> m_oVisibility;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oWindowHeight;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oWindowWidth;
nullable<SimpleTypes::CDecimalNumber<>> m_oXWindow;
nullable<SimpleTypes::CDecimalNumber<>> m_oYWindow;
};
class CBookViews : public WritingElementWithChilds<CWorkbookView>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CBookViews)
CBookViews()
{
}
virtual ~CBookViews()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<bookViews>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</bookViews>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("workbookView") == sName )
m_arrItems.Add( new CWorkbookView( oReader ));
}
}
virtual EElementType getType () const
{
return et_BookViews;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_BOOKVIEWS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,197 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_DEFINEDNAMES_FILE_INCLUDE_H_
#define OOX_DEFINEDNAMES_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CDefinedName : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDefinedName)
CDefinedName()
{
}
virtual ~CDefinedName()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<definedName"));
if(m_oName.IsInit())
{
CString sVal;sVal.Format(_T(" name=\"%s\""), XmlUtils::EncodeXmlString(m_oName.get()));
writer.WriteStringC(sVal);
}
if(m_oLocalSheetId.IsInit())
{
CString sVal;sVal.Format(_T(" localSheetId=\"%d\""), m_oLocalSheetId->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
if(m_oRef.IsInit())
writer.WriteStringC(XmlUtils::EncodeXmlString(m_oRef.get()));
writer.WriteStringC(_T("</definedName>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
m_oRef = oReader.GetText2();
}
virtual EElementType getType () const
{
return et_DefinedName;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("comment"), m_oComment )
WritingElement_ReadAttributes_Read_if ( oReader, _T("customMenu"), m_oCustomMenu )
WritingElement_ReadAttributes_Read_if ( oReader, _T("description"), m_oDescription )
WritingElement_ReadAttributes_Read_if ( oReader, _T("function"), m_oFunction )
WritingElement_ReadAttributes_Read_if ( oReader, _T("functionGroupId"), m_oFunctionGroupId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("help"), m_oHelp )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hidden"), m_oHidden )
WritingElement_ReadAttributes_Read_if ( oReader, _T("localSheetId"), m_oLocalSheetId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("publishToServer"), m_oPublishToServer )
WritingElement_ReadAttributes_Read_if ( oReader, _T("shortcutKey "), m_oShortcutKey )
WritingElement_ReadAttributes_Read_if ( oReader, _T("statusBar "), m_oStatusBar )
WritingElement_ReadAttributes_Read_if ( oReader, _T("vbProcedure "), m_oVbProcedure )
WritingElement_ReadAttributes_Read_if ( oReader, _T("workbookParameter "), m_oWorkbookParameter )
WritingElement_ReadAttributes_Read_if ( oReader, _T("xlm "), m_oXlm )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString> m_oComment;
nullable<CString> m_oCustomMenu;
nullable<CString> m_oDescription;
nullable<SimpleTypes::COnOff<>> m_oFunction;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oFunctionGroupId;
nullable<CString> m_oHelp;
nullable<SimpleTypes::COnOff<>> m_oHidden;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oLocalSheetId;
nullable<CString> m_oName;
nullable<SimpleTypes::COnOff<>> m_oPublishToServer;
nullable<CString> m_oShortcutKey;
nullable<CString> m_oStatusBar;
nullable<SimpleTypes::COnOff<>> m_oVbProcedure;
nullable<SimpleTypes::COnOff<>> m_oWorkbookParameter;
nullable<SimpleTypes::COnOff<>> m_oXlm;
nullable<CString> m_oRef;
};
class CDefinedNames : public WritingElementWithChilds<CDefinedName>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDefinedNames)
CDefinedNames()
{
}
virtual ~CDefinedNames()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<definedNames>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</definedNames>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("definedName") == sName )
m_arrItems.Add( new CDefinedName( oReader ));
}
}
virtual EElementType getType () const
{
return et_BookViews;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_DEFINEDNAMES_FILE_INCLUDE_H_

View File

@@ -0,0 +1,176 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_SHEETS_FILE_INCLUDE_H_
#define OOX_SHEETS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CSheet : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheet)
CSheet()
{
}
virtual ~CSheet()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<sheet"));
if(m_oName.IsInit())
{
CString sVal;sVal.Format(_T(" name=\"%s\""), XmlUtils::EncodeXmlString(m_oName.get()));
writer.WriteStringC(sVal);
}
if(m_oSheetId.IsInit())
{
CString sVal;sVal.Format(_T(" sheetId=\"%d\""), m_oSheetId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oState.IsInit())
{
CString sVal;sVal.Format(_T(" state=\"%s\""), m_oState->ToString());
writer.WriteStringC(sVal);
}
if(m_oRid.IsInit())
{
CString sVal;sVal.Format(_T(" r:id=\"%s\""), m_oRid->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Sheet;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oRid )
WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("sheetId"), m_oSheetId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("state"), m_oState )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId> m_oRid;
nullable<CString> m_oName;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSheetId;
nullable<SimpleTypes::Spreadsheet::CVisibleType<>> m_oState;
};
class CSheets : public WritingElementWithChilds<CSheet>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheets)
CSheets()
{
}
virtual ~CSheets()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<sheets>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</sheets>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("sheet") == sName )
m_arrItems.Add( new CSheet( oReader ));
}
}
virtual EElementType getType () const
{
return et_Sheets;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_SHEETS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,203 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_WORKBOOK_FILE_INCLUDE_H_
#define OOX_WORKBOOK_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "BookViews.h"
#include "DefinedNames.h"
#include "Sheets.h"
#include "WorkbookPr.h"
namespace OOX
{
namespace Spreadsheet
{
class CWorkbook : public OOX::File, public OOX::Spreadsheet::IFileContainer
{
public:
CWorkbook()
{
}
CWorkbook(const CPath& oPath)
{
read(oPath);
}
virtual ~CWorkbook()
{
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("workbook") == sName )
{
if ( !oReader.IsEmptyNode() )
{
int nDocumentDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nDocumentDepth ) )
{
sName = oReader.GetName();
if ( _T("bookViews") == sName )
m_oBookViews = oReader;
else if ( _T("definedNames") == sName )
m_oDefinedNames = oReader;
else if ( _T("sheets") == sName )
m_oSheets = oReader;
else if ( _T("workbookPr") == sName )
m_oWorkbookPr = oReader;
}
}
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
CStringWriter sXml;
sXml.WriteStringC(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">"));
if(m_oWorkbookPr.IsInit())
m_oWorkbookPr->toXML(sXml);
if(m_oBookViews.IsInit())
m_oBookViews->toXML(sXml);
if(m_oSheets.IsInit())
m_oSheets->toXML(sXml);
if(m_oDefinedNames.IsInit())
m_oDefinedNames->toXML(sXml);
sXml.WriteStringC(_T("<calcPr calcId=\"145621\"/>"));
sXml.WriteStringC(_T("</workbook>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Workbook;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
void PrepareToWrite()
{
if(false == m_oWorkbookPr.IsInit())
m_oWorkbookPr.Init();
if(false == m_oBookViews.IsInit())
m_oBookViews.Init();
if(0 == m_oBookViews->m_arrItems.GetSize())
m_oBookViews->m_arrItems.Add(new OOX::Spreadsheet::CWorkbookView());
OOX::Spreadsheet::CWorkbookView* pWorkbookView = m_oBookViews->m_arrItems[0];
if(false == pWorkbookView->m_oXWindow.IsInit())
{
pWorkbookView->m_oXWindow.Init();
pWorkbookView->m_oXWindow->SetValue(360);
}
if(false == pWorkbookView->m_oYWindow.IsInit())
{
pWorkbookView->m_oYWindow.Init();
pWorkbookView->m_oYWindow->SetValue(15);
}
if(false == pWorkbookView->m_oWindowWidth.IsInit())
{
pWorkbookView->m_oWindowWidth.Init();
pWorkbookView->m_oWindowWidth->SetValue(20955);
}
if(false == pWorkbookView->m_oWindowHeight.IsInit())
{
pWorkbookView->m_oWindowHeight.Init();
pWorkbookView->m_oWindowHeight->SetValue(9720);
}
}
private:
CPath m_oReadPath;
public:
nullable<OOX::Spreadsheet::CBookViews> m_oBookViews;
nullable<OOX::Spreadsheet::CDefinedNames> m_oDefinedNames;
nullable<OOX::Spreadsheet::CSheets> m_oSheets;
nullable<OOX::Spreadsheet::CWorkbookPr> m_oWorkbookPr;
};
}
}
#endif // OOX_WORKBOOK_FILE_INCLUDE_H_

View File

@@ -0,0 +1,147 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_WORKBOOKPR_FILE_INCLUDE_H_
#define OOX_WORKBOOKPR_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CWorkbookPr : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CWorkbookPr)
CWorkbookPr()
{
}
virtual ~CWorkbookPr()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<workbookPr"));
if(m_oDefaultThemeVersion.IsInit())
{
CString sVal;sVal.Format(_T(" defaultThemeVersion=\"%d\""), m_oDefaultThemeVersion->GetValue());
writer.WriteStringC(sVal);
}
if(m_oDate1904.IsInit())
{
CString sVal;sVal.Format(_T(" date1904=\"%s\""), m_oDate1904->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDateCompatibility.IsInit())
{
CString sVal;sVal.Format(_T(" dateCompatibility=\"%s\""), m_oDateCompatibility->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_WorkbookPr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("allowRefreshQuery"), m_oAllowRefreshQuery )
WritingElement_ReadAttributes_Read_if ( oReader, _T("autoCompressPictures"), m_oAutoCompressPictures )
WritingElement_ReadAttributes_Read_if ( oReader, _T("backupFile"), m_oBackupFile )
WritingElement_ReadAttributes_Read_if ( oReader, _T("checkCompatibility"), m_oCheckCompatibility )
WritingElement_ReadAttributes_Read_if ( oReader, _T("codeName"), m_oCodeName )
WritingElement_ReadAttributes_Read_if ( oReader, _T("date1904"), m_oDate1904 )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dateCompatibility"), m_oDateCompatibility )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultThemeVersion"), m_oDefaultThemeVersion )
WritingElement_ReadAttributes_Read_if ( oReader, _T("filterPrivacy"), m_oFilterPrivacy )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hidePivotFieldList"), m_oHidePivotFieldList )
WritingElement_ReadAttributes_Read_if ( oReader, _T("promptedSolutions"), m_oPromptedSolutions )
WritingElement_ReadAttributes_Read_if ( oReader, _T("publishItems"), m_oPublishItems )
WritingElement_ReadAttributes_Read_if ( oReader, _T("refreshAllConnections"), m_oRefreshAllConnections )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showBorderUnselectedTables"), m_oShowBorderUnselectedTables )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showInkAnnotation"), m_oShowInkAnnotation )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showObjects"), m_oShowObjects )
WritingElement_ReadAttributes_Read_if ( oReader, _T("showPivotChartFilter"), m_oShowPivotChartFilter )
WritingElement_ReadAttributes_Read_if ( oReader, _T("updateLinks"), m_oUpdateLinks )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oAllowRefreshQuery;
nullable<SimpleTypes::COnOff<>> m_oAutoCompressPictures;
nullable<SimpleTypes::COnOff<>> m_oBackupFile;
nullable<SimpleTypes::COnOff<>> m_oCheckCompatibility;
nullable<SimpleTypes::COnOff<>> m_oCodeName;
nullable<SimpleTypes::COnOff<>> m_oDate1904;
nullable<SimpleTypes::COnOff<>> m_oDateCompatibility;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oDefaultThemeVersion;
nullable<SimpleTypes::COnOff<>> m_oFilterPrivacy;
nullable<SimpleTypes::COnOff<>> m_oHidePivotFieldList;
nullable<SimpleTypes::COnOff<>> m_oPromptedSolutions;
nullable<SimpleTypes::COnOff<>> m_oPublishItems;
nullable<SimpleTypes::COnOff<>> m_oRefreshAllConnections;
nullable<SimpleTypes::COnOff<>> m_oShowBorderUnselectedTables;
nullable<SimpleTypes::COnOff<>> m_oShowInkAnnotation;
nullable<SimpleTypes::COnOff<>> m_oShowObjects;
nullable<SimpleTypes::COnOff<>> m_oShowPivotChartFilter;
nullable<SimpleTypes::Spreadsheet::CUpdateLinksType<>> m_oUpdateLinks;
};
}
}
#endif // OOX_WORKBOOKPR_FILE_INCLUDE_H_

View File

@@ -0,0 +1,219 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_COLS_FILE_INCLUDE_H_
#define OOX_COLS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CCol : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCol)
CCol()
{
}
virtual ~CCol()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<col"));
if(m_oBestFit.IsInit())
{
CString sVal; sVal.Format(_T(" bestFit=\"%s\""), m_oBestFit->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oCollapsed.IsInit())
{
CString sVal; sVal.Format(_T(" collapsed=\"%s\""), m_oCollapsed->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oCustomWidth.IsInit())
{
CString sVal; sVal.Format(_T(" customWidth=\"%s\""), m_oCustomWidth->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oHidden.IsInit())
{
CString sVal; sVal.Format(_T(" hidden=\"%s\""), m_oHidden->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oMin.IsInit())
{
CString sVal; sVal.Format(_T(" min=\"%d\""), m_oMin->GetValue());
writer.WriteStringC(sVal);
}
if(m_oMax.IsInit())
{
CString sVal; sVal.Format(_T(" max=\"%d\""), m_oMax->GetValue());
writer.WriteStringC(sVal);
}
if(m_oOutlineLevel.IsInit())
{
CString sVal; sVal.Format(_T(" outlineLevel=\"%d\""), m_oOutlineLevel->GetValue());
writer.WriteStringC(sVal);
}
if(m_oPhonetic.IsInit())
{
CString sVal; sVal.Format(_T(" phonetic=\"%s\""), m_oPhonetic->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oStyle.IsInit())
{
CString sVal; sVal.Format(_T(" style=\"%d\""), m_oStyle->GetValue());
writer.WriteStringC(sVal);
}
if(m_oWidth.IsInit())
{
CString sVal; sVal.Format(_T(" width=\"%s\""), SpreadsheetCommon::WriteDouble(m_oWidth->GetValue()));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Col;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("bestFit"), m_oBestFit)
WritingElement_ReadAttributes_Read_if ( oReader, _T("collapsed"), m_oCollapsed )
WritingElement_ReadAttributes_Read_if ( oReader, _T("customWidth"), m_oCustomWidth )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hidden"), m_oHidden )
WritingElement_ReadAttributes_Read_if ( oReader, _T("max"), m_oMax )
WritingElement_ReadAttributes_Read_if ( oReader, _T("min"), m_oMin )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outlineLevel"), m_oOutlineLevel )
WritingElement_ReadAttributes_Read_if ( oReader, _T("phonetic"), m_oPhonetic )
WritingElement_ReadAttributes_Read_if ( oReader, _T("style"), m_oStyle )
WritingElement_ReadAttributes_Read_if ( oReader, _T("width"), m_oWidth )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oBestFit;
nullable<SimpleTypes::COnOff<>> m_oCollapsed;
nullable<SimpleTypes::COnOff<>> m_oCustomWidth;
nullable<SimpleTypes::COnOff<>> m_oHidden;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMax;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMin;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oOutlineLevel;
nullable<SimpleTypes::COnOff<>> m_oPhonetic;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oStyle;
nullable<SimpleTypes::CDouble> m_oWidth;
};
class CCols : public WritingElementWithChilds<CCol>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCols)
CCols()
{
}
virtual ~CCols()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<cols>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</cols>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("col") == sName )
m_arrItems.Add( new CCol( oReader ));
}
}
virtual EElementType getType () const
{
return et_Cols;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_COLS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,607 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_CONDITIONALFORMATTING_FILE_INCLUDE_H_
#define OOX_CONDITIONALFORMATTING_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CConditionalFormatValueObject : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CConditionalFormatValueObject)
CConditionalFormatValueObject()
{
}
virtual ~CConditionalFormatValueObject()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (m_oType.IsInit())
{
CString sValue;
CString sRoot;
sRoot.Format(_T("<cfvo type=\"%s\""), m_oType.get());
writer.WriteStringC(sRoot);
if (m_oGte.IsInit() && false == m_oGte->ToBool())
writer.WriteStringC(_T (" gte=\"0\""));
if (m_oVal.IsInit())
{
sValue.Format(_T(" val=\"%s\""), m_oVal.get());
writer.WriteStringC(sValue);
}
writer.WriteStringC(_T("/>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
}
virtual EElementType getType () const
{
return et_ConditionalFormatValueObject;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("gte") , m_oGte)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("type") , m_oType)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("val") , m_oVal)
WritingElement_ReadAttributes_End(oReader)
}
public:
nullable<SimpleTypes::COnOff<>> m_oGte;
nullable<CString> m_oType;
nullable<CString> m_oVal;
};
class CColorScale : public WritingElementWithChilds<WritingElement>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CColorScale)
CColorScale()
{
}
virtual ~CColorScale()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (3 < m_arrItems.GetSize())
{
CString sValue;
writer.WriteStringC(_T("<colorScale>"));
for (int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</colorScale>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("cfvo") == sName)
m_arrItems.Add(new CConditionalFormatValueObject(oReader));
else if (_T("color") == sName)
m_arrItems.Add(new CColor(oReader));
}
}
virtual EElementType getType () const
{
return et_ColorScale;
}
public:
};
class CDataBar : public WritingElementWithChilds<CConditionalFormatValueObject>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDataBar)
CDataBar()
{
}
virtual ~CDataBar()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (2 == m_arrItems.GetSize() && m_oColor.IsInit())
{
CString sValue;
writer.WriteStringC(_T("<dataBar"));
if (m_oMaxLength.IsInit())
{
sValue.Format(_T(" maxLength=\"%d\""), m_oMaxLength->GetValue());
writer.WriteStringC(sValue);
}
if (m_oMaxLength.IsInit())
{
sValue.Format(_T(" maxLength=\"%d\""), m_oMaxLength->GetValue());
writer.WriteStringC(sValue);
}
if (m_oShowValue.IsInit() && false == m_oShowValue->ToBool())
{
writer.WriteStringC(_T(" showValue=\"0\""));
}
writer.WriteStringC(_T(">"));
for (int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
m_oColor->toXML2(writer, _T("color"));
writer.WriteStringC(_T("</dataBar>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("cfvo") == sName)
m_arrItems.Add(new CConditionalFormatValueObject(oReader));
else if (_T("color") == sName)
m_oColor = oReader;
}
}
virtual EElementType getType () const
{
return et_DataBar;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("maxLength") , m_oMaxLength)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("minLength") , m_oMinLength)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("showValue") , m_oShowValue)
WritingElement_ReadAttributes_End(oReader)
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMaxLength;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMinLength;
nullable<SimpleTypes::COnOff<>> m_oShowValue;
nullable<CColor> m_oColor;
};
class CFormulaCF : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFormulaCF)
CFormulaCF()
{
}
virtual ~CFormulaCF()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<formula>"));
writer.WriteStringC(XmlUtils::EncodeXmlString(m_sText));
writer.WriteStringC(_T("</formula>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if (oReader.IsEmptyNode())
return;
m_sText = oReader.GetText2();
}
virtual EElementType getType () const
{
return et_FormulaCF;
}
public:
CString m_sText;
};
class CIconSet : public WritingElementWithChilds<CConditionalFormatValueObject>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CIconSet)
CIconSet()
{
}
virtual ~CIconSet()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (1 < m_arrItems.GetSize())
{
CString sValue;
writer.WriteStringC(_T("<iconSet"));
if (m_oIconSet.IsInit())
{
sValue.Format(_T(" iconSet=\"%s\""), m_oIconSet.get());
writer.WriteStringC(sValue);
}
if (m_oPercent.IsInit() && false == m_oPercent->ToBool())
{
writer.WriteStringC(_T(" percent=\"0\""));
}
if (m_oReverse.IsInit() && true == m_oReverse->ToBool())
{
writer.WriteStringC(_T(" reverse=\"1\""));
}
if (m_oShowValue.IsInit() && false == m_oShowValue->ToBool())
{
writer.WriteStringC(_T(" showValue=\"0\""));
}
writer.WriteStringC(_T(">"));
for (int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</iconSet>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("cfvo") == sName)
m_arrItems.Add(new CConditionalFormatValueObject(oReader));
}
}
virtual EElementType getType () const
{
return et_IconSet;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("iconSet") , m_oIconSet)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("percent") , m_oPercent)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("reverse") , m_oReverse)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("showValue") , m_oShowValue)
WritingElement_ReadAttributes_End(oReader)
}
public:
nullable<CString> m_oIconSet;
nullable<SimpleTypes::COnOff<>> m_oPercent;
nullable<SimpleTypes::COnOff<>> m_oReverse;
nullable<SimpleTypes::COnOff<>> m_oShowValue;
};
class CConditionalFormattingRule : public WritingElementWithChilds<WritingElement>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CConditionalFormattingRule)
CConditionalFormattingRule()
{
}
virtual ~CConditionalFormattingRule()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (m_oType.IsInit() && m_oPriority.IsInit() && 0 < m_arrItems.GetSize())
{
CString sValue;
CString sRoot;
sRoot.Format(_T("<cfRule type=\"%s\" priority=\"%d\""), m_oType.get(), m_oPriority->GetValue());
writer.WriteStringC(sRoot);
if (m_oAboveAverage.IsInit() && false == m_oAboveAverage->ToBool())
writer.WriteStringC(_T (" aboveAverage=\"0\""));
if (m_oBottom.IsInit() && true == m_oBottom->ToBool())
writer.WriteStringC(_T (" bottom=\"1\""));
if (m_oDxfId.IsInit())
{
sValue.Format(_T(" dxfId=\"%d\""), m_oDxfId->GetValue());
writer.WriteStringC(sValue);
}
if (m_oEqualAverage.IsInit() && true == m_oEqualAverage->ToBool())
writer.WriteStringC(_T (" equalAverage=\"1\""));
if (m_oOperator.IsInit())
{
sValue.Format(_T(" text=\"%s\""), m_oOperator.get());
writer.WriteStringC(sValue);
}
if (m_oPercent.IsInit() && true == m_oPercent->ToBool())
writer.WriteStringC(_T (" percent=\"1\""));
if (m_oRank.IsInit())
{
sValue.Format(_T(" rank=\"%d\""), m_oRank->GetValue());
writer.WriteStringC(sValue);
}
if (m_oStdDev.IsInit())
{
sValue.Format(_T(" stdDev=\"%d\""), m_oStdDev->GetValue());
writer.WriteStringC(sValue);
}
if (m_oStopIfTrue.IsInit() && true == m_oStopIfTrue->ToBool())
writer.WriteStringC(_T (" stopIfTrue=\"1\""));
if (m_oText.IsInit())
{
sValue.Format(_T(" text=\"%s\""), m_oText.get());
writer.WriteStringC(sValue);
}
if (m_oTimePeriod.IsInit())
{
sValue.Format(_T(" timePeriod=\"%s\""), m_oTimePeriod.get());
writer.WriteStringC(sValue);
}
writer.WriteStringC(_T(">"));
for (int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</cfRule>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("colorScale") == sName)
m_arrItems.Add(new CColorScale(oReader));
else if (_T("dataBar") == sName)
m_arrItems.Add(new CDataBar(oReader));
else if (_T("formula") == sName)
m_arrItems.Add(new CFormulaCF(oReader));
else if (_T("iconSet") == sName)
m_arrItems.Add(new CIconSet(oReader));
}
}
virtual EElementType getType () const
{
return et_ConditionalFormattingRule;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("aboveAverage") , m_oAboveAverage)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("bottom") , m_oBottom)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("dxfId") , m_oDxfId)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("equalAverage") , m_oEqualAverage)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("operator") , m_oOperator)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("percent") , m_oPercent)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("priority") , m_oPriority)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("rank") , m_oRank)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("stdDev") , m_oStdDev)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("stopIfTrue") , m_oStopIfTrue)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("text") , m_oText)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("timePeriod") , m_oTimePeriod)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("type") , m_oType)
WritingElement_ReadAttributes_End(oReader)
}
public:
nullable<SimpleTypes::COnOff<>> m_oAboveAverage;
nullable<SimpleTypes::COnOff<>> m_oBottom;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oDxfId;
nullable<SimpleTypes::COnOff<>> m_oEqualAverage;
nullable<CString> m_oOperator;
nullable<SimpleTypes::COnOff<>> m_oPercent;
nullable<SimpleTypes::CDecimalNumber<>> m_oPriority;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRank;
nullable<SimpleTypes::CDecimalNumber<>> m_oStdDev;
nullable<SimpleTypes::COnOff<>> m_oStopIfTrue;
nullable<CString> m_oText;
nullable<CString> m_oTimePeriod;
nullable<CString> m_oType;
};
class CConditionalFormatting : public WritingElementWithChilds<CConditionalFormattingRule>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CConditionalFormatting)
CConditionalFormatting()
{
}
virtual ~CConditionalFormatting()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (m_oSqRef.IsInit() && 0 < m_arrItems.GetSize())
{
CString sRoot;
sRoot.Format(_T("<conditionalFormatting sqref=\"%s\""), m_oSqRef->GetValue());
writer.WriteStringC(sRoot);
if (m_oPivot.IsInit() && true == m_oPivot->ToBool())
{
writer.WriteStringC(_T (" pivot=\"1\""));
}
writer.WriteStringC(_T(">"));
for (int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</conditionalFormatting>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("cfRule") == sName)
m_arrItems.Add(new CConditionalFormattingRule(oReader));
}
}
virtual EElementType getType () const
{
return et_ConditionalFormatting;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if (oReader, _T("sqref") , m_oSqRef)
WritingElement_ReadAttributes_Read_else_if (oReader, _T("pivot") , m_oPivot)
WritingElement_ReadAttributes_End(oReader)
}
public:
nullable<SimpleTypes::COnOff<>> m_oPivot;
nullable<SimpleTypes::CRelationshipId > m_oSqRef;
};
}
}
#endif // OOX_CONDITIONALFORMATTING_FILE_INCLUDE_H_

View File

@@ -0,0 +1,184 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_HYPERLINKS_FILE_INCLUDE_H_
#define OOX_HYPERLINKS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CHyperlink : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CHyperlink)
CHyperlink()
{
}
virtual ~CHyperlink()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<hyperlink"));
if(m_oDisplay.IsInit())
{
CString sVal; sVal.Format(_T(" display=\"%s\""), XmlUtils::EncodeXmlString(m_oDisplay.get()));
writer.WriteStringC(sVal);
}
if(m_oRid.IsInit())
{
CString sVal; sVal.Format(_T(" r:id=\"%s\""), m_oRid->GetValue());
writer.WriteStringC(sVal);
}
if(m_oLocation.IsInit())
{
CString sVal; sVal.Format(_T(" location=\"%s\""), XmlUtils::EncodeXmlString(m_oLocation.get()));
writer.WriteStringC(sVal);
}
if(m_oRef.IsInit())
{
CString sVal; sVal.Format(_T(" ref=\"%s\""), XmlUtils::EncodeXmlString(m_oRef.get()));
writer.WriteStringC(sVal);
}
if(m_oTooltip.IsInit())
{
CString sVal; sVal.Format(_T(" tooltip=\"%s\""), XmlUtils::EncodeXmlString(m_oTooltip.get()));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Hyperlink;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("display"), m_oDisplay)
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oRid )
WritingElement_ReadAttributes_Read_if ( oReader, _T("location"), m_oLocation )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("tooltip"), m_oTooltip )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString> m_oDisplay;
nullable<SimpleTypes::CRelationshipId> m_oRid;
nullable<CString> m_oLocation;
nullable<CString> m_oRef;
nullable<CString> m_oTooltip;
};
class CHyperlinks : public WritingElementWithChilds<CHyperlink>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CHyperlinks)
CHyperlinks()
{
}
virtual ~CHyperlinks()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<hyperlinks>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</hyperlinks>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("hyperlink") == sName )
m_arrItems.Add( new CHyperlink( oReader ));
}
}
virtual EElementType getType () const
{
return et_Hyperlinks;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_HYPERLINKS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,170 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_MERGECELLS_FILE_INCLUDE_H_
#define OOX_MERGECELLS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CMergeCell : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CMergeCell)
CMergeCell()
{
}
virtual ~CMergeCell()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<mergeCell"));
if(m_oRef.IsInit())
{
CString sVal; sVal.Format(_T(" ref=\"%s\""), XmlUtils::EncodeXmlString(m_oRef.get()));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_MergeCell;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString> m_oRef;
};
class CMergeCells : public WritingElementWithChilds<CMergeCell>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CMergeCells)
CMergeCells()
{
}
virtual ~CMergeCells()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<mergeCells"));
if(m_oCount.IsInit())
{
CString sVal; sVal.Format(_T(" count=\"%d\""), m_oCount->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</mergeCells>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("mergeCell") == sName )
m_arrItems.Add( new CMergeCell( oReader ));
}
}
virtual EElementType getType () const
{
return et_MergeCells;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
}
}
#endif // OOX_MERGECELLS_FILE_INCLUDE_H_

View File

@@ -0,0 +1,495 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_SHEETDATA_FILE_INCLUDE_H_
#define OOX_SHEETDATA_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "../SharedStrings/Si.h"
namespace OOX
{
namespace Spreadsheet
{
class CFormula : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CFormula)
CFormula()
{
}
virtual ~CFormula()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<f"));
if(m_oAca.IsInit())
{
CString sVal; sVal.Format(_T(" aca=\"%s\""), m_oAca->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oBx.IsInit())
{
CString sVal; sVal.Format(_T(" bx=\"%s\""), m_oBx->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oCa.IsInit())
{
CString sVal; sVal.Format(_T(" ca=\"%s\""), m_oCa->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDel1.IsInit())
{
CString sVal; sVal.Format(_T(" del1=\"%s\""), m_oDel1->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDel2.IsInit())
{
CString sVal; sVal.Format(_T(" del2=\"%s\""), m_oDel2->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDt2D.IsInit())
{
CString sVal; sVal.Format(_T(" dt2D=\"%s\""), m_oDt2D->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDtr.IsInit())
{
CString sVal; sVal.Format(_T(" dtr=\"%s\""), m_oDtr->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oR1.IsInit())
{
CString sVal; sVal.Format(_T(" r1=\"%s\""), m_oR1.get());
writer.WriteStringC(sVal);
}
if(m_oR2.IsInit())
{
CString sVal; sVal.Format(_T(" r2=\"%s\""), m_oR2.get());
writer.WriteStringC(sVal);
}
if(m_oRef.IsInit())
{
CString sVal; sVal.Format(_T(" ref=\"%s\""), m_oRef.get());
writer.WriteStringC(sVal);
}
if(m_oSi.IsInit())
{
CString sVal; sVal.Format(_T(" si=\"%d\""), m_oSi->GetValue());
writer.WriteStringC(sVal);
}
if(m_oT.IsInit())
{
CString sVal; sVal.Format(_T(" t=\"%s\""), m_oT->ToString());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
writer.WriteStringC(XmlUtils::EncodeXmlString(m_sText));
writer.WriteStringC(_T("</f>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
m_sText = oReader.GetText2();
}
virtual EElementType getType () const
{
return et_Formula;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("aca"), m_oAca )
WritingElement_ReadAttributes_Read_if ( oReader, _T("bx"), m_oBx )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ca"), m_oCa )
WritingElement_ReadAttributes_Read_if ( oReader, _T("del1"), m_oDel1 )
WritingElement_ReadAttributes_Read_if ( oReader, _T("del2"), m_oDel2 )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dt2D"), m_oDt2D )
WritingElement_ReadAttributes_Read_if ( oReader, _T("dtr"), m_oDtr )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r1"), m_oR1 )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r2"), m_oR2 )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("si"), m_oSi )
WritingElement_ReadAttributes_Read_if ( oReader, _T("t"), m_oT )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oAca;
nullable<SimpleTypes::COnOff<>> m_oBx;
nullable<SimpleTypes::COnOff<>> m_oCa;
nullable<SimpleTypes::COnOff<>> m_oDel1;
nullable<SimpleTypes::COnOff<>> m_oDel2;
nullable<SimpleTypes::COnOff<>> m_oDt2D;
nullable<SimpleTypes::COnOff<>> m_oDtr;
nullable<CString> m_oR1;
nullable<CString> m_oR2;
nullable<CString> m_oRef;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSi;
nullable<SimpleTypes::Spreadsheet::CCellFormulaType<>> m_oT;
CString m_sText;
};
class CCell : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CCell)
CCell()
{
}
virtual ~CCell()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<c"));
if(m_oCellMetadata.IsInit())
{
CString sVal; sVal.Format(_T(" cm=\"%d\""), m_oCellMetadata->GetValue());
writer.WriteStringC(sVal);
}
if(m_oShowPhonetic.IsInit())
{
CString sVal; sVal.Format(_T(" ph=\"%s\""), m_oShowPhonetic->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oRef.IsInit())
{
CString sVal; sVal.Format(_T(" r=\"%s\""), m_oRef.get());
writer.WriteStringC(sVal);
}
if(m_oStyle.IsInit())
{
CString sVal; sVal.Format(_T(" s=\"%d\""), m_oStyle->GetValue());
writer.WriteStringC(sVal);
}
if(m_oType.IsInit() && SimpleTypes::Spreadsheet::celltypeNumber != m_oType->GetValue())
{
CString sVal; sVal.Format(_T(" t=\"%s\""), m_oType->ToString());
writer.WriteStringC(sVal);
}
if(m_oValueMetadata.IsInit())
{
CString sVal; sVal.Format(_T(" vm=\"%d\""), m_oValueMetadata->GetValue());
writer.WriteStringC(sVal);
}
if(m_oFormula.IsInit() || m_oRichText.IsInit() || m_oValue.IsInit())
{
writer.WriteStringC(_T(">"));
if(m_oFormula.IsInit())
m_oFormula->toXML(writer);
if(m_oRichText.IsInit())
m_oRichText->toXML2(writer);
if(m_oValue.IsInit())
m_oValue->toXML2(writer, _T("v"));
writer.WriteStringC(_T("</c>"));
}
else
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("f") == sName )
m_oFormula = oReader;
else if ( _T("is") == sName )
m_oRichText = oReader;
else if ( _T("v") == sName )
m_oValue = oReader;
}
}
virtual EElementType getType () const
{
return et_Cell;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cm"), m_oCellMetadata )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ph"), m_oShowPhonetic )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r"), m_oRef )
WritingElement_ReadAttributes_Read_if ( oReader, _T("s"), m_oStyle )
WritingElement_ReadAttributes_Read_if ( oReader, _T("t"), m_oType )
WritingElement_ReadAttributes_Read_if ( oReader, _T("vm"), m_oValueMetadata )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCellMetadata;
nullable<SimpleTypes::COnOff<>> m_oShowPhonetic;
nullable<CString> m_oRef;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oStyle;
nullable<SimpleTypes::Spreadsheet::CCellTypeType<>> m_oType;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oValueMetadata;
nullable<CFormula> m_oFormula;
nullable<CSi> m_oRichText;
nullable<CText> m_oValue;
};
class CRow : public WritingElementWithChilds<CCell>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CRow)
CRow()
{
}
virtual ~CRow()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<row"));
if(m_oCollapsed.IsInit())
{
CString sVal; sVal.Format(_T(" collapsed=\"%s\""), m_oCollapsed->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oCustomFormat.IsInit())
{
CString sVal; sVal.Format(_T(" customFormat=\"%s\""), m_oCustomFormat->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oHt.IsInit())
{
CString sVal; sVal.Format(_T(" ht=\"%s\""), SpreadsheetCommon::WriteDouble(m_oHt->GetValue()));
writer.WriteStringC(sVal);
}
if(m_oCustomHeight.IsInit())
{
CString sVal; sVal.Format(_T(" customHeight=\"%s\""), m_oCustomHeight->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oHidden.IsInit())
{
CString sVal; sVal.Format(_T(" hidden=\"%s\""), m_oHidden->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oOutlineLevel.IsInit())
{
CString sVal; sVal.Format(_T(" outlineLevel=\"%d\""), m_oOutlineLevel->GetValue());
writer.WriteStringC(sVal);
}
if(m_oPh.IsInit())
{
CString sVal; sVal.Format(_T(" ph=\"%s\""), m_oPh->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oR.IsInit())
{
CString sVal; sVal.Format(_T(" r=\"%d\""), m_oR->GetValue());
writer.WriteStringC(sVal);
}
if(m_oS.IsInit())
{
CString sVal; sVal.Format(_T(" s=\"%d\""), m_oS->GetValue());
writer.WriteStringC(sVal);
}
if(m_oThickBot.IsInit())
{
CString sVal; sVal.Format(_T(" thickBot=\"%s\""), m_oThickBot->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oThickTop.IsInit())
{
CString sVal; sVal.Format(_T(" thickTop=\"%s\""), m_oThickTop->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T(">"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</row>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("c") == sName )
m_arrItems.Add( new CCell( oReader ));
}
}
virtual EElementType getType () const
{
return et_Row;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("collapsed"), m_oCollapsed )
WritingElement_ReadAttributes_Read_if ( oReader, _T("customFormat"), m_oCustomFormat )
WritingElement_ReadAttributes_Read_if ( oReader, _T("customHeight"), m_oCustomHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("hidden"), m_oHidden )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ht"), m_oHt )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outlineLevel"), m_oOutlineLevel )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ph"), m_oPh )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r"), m_oR )
WritingElement_ReadAttributes_Read_if ( oReader, _T("s"), m_oS )
WritingElement_ReadAttributes_Read_if ( oReader, _T("thickBot"), m_oThickBot )
WritingElement_ReadAttributes_Read_if ( oReader, _T("thickTop"), m_oThickTop )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oCollapsed;
nullable<SimpleTypes::COnOff<>> m_oCustomFormat;
nullable<SimpleTypes::COnOff<>> m_oCustomHeight;
nullable<SimpleTypes::COnOff<>> m_oHidden;
nullable<SimpleTypes::CDouble> m_oHt;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oOutlineLevel;
nullable<SimpleTypes::COnOff<>> m_oPh;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oR;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oS;
nullable<SimpleTypes::COnOff<>> m_oThickBot;
nullable<SimpleTypes::COnOff<>> m_oThickTop;
};
class CSheetData : public WritingElementWithChilds<CRow>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheetData)
CSheetData()
{
}
virtual ~CSheetData()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<sheetData>"));
for(int i = 0, length = m_arrItems.GetSize(); i < length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</sheetData>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("row") == sName )
m_arrItems.Add(new CRow( oReader ));
}
}
virtual EElementType getType () const
{
return et_SheetData;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
};
}
}
#endif // OOX_SHEETDATA_FILE_INCLUDE_H_

View File

@@ -0,0 +1,474 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_WORKSHEET_FILE_INCLUDE_H_
#define OOX_WORKSHEET_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "../../DocxFormat/External/HyperLink.h"
#include "../../DocxFormat/Media/Image.h"
#include "SheetData.h"
#include "Cols.h"
#include "Hyperlinks.h"
#include "MergeCells.h"
#include "WorksheetChildOther.h"
#include "../Drawing/Drawing.h"
#include "../Chart/Chart.h"
#include "../Table/Table.h"
#include "../Comments/Comments.h"
#include "ConditionalFormatting.h"
namespace OOX
{
namespace Spreadsheet
{
class CWorksheet : public OOX::File, public OOX::Spreadsheet::IFileContainer
{
public:
CWorksheet()
{
}
CWorksheet(const CPath& oPath)
{
read( oPath );
}
virtual ~CWorksheet()
{
ClearItems();
}
public:
virtual void read(const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
CWCharWrapper sName = oReader.GetName();
if ( _T("worksheet") == sName || _T("chartsheet") == sName)
{
if ( !oReader.IsEmptyNode() )
{
int nDocumentDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nDocumentDepth ) )
{
sName = oReader.GetName();
if ( _T("cols") == sName )
m_oCols = oReader;
else if ( _T("dimension") == sName )
m_oDimension = oReader;
else if ( _T("drawing") == sName )
m_oDrawing = oReader;
else if ( _T("hyperlinks") == sName )
m_oHyperlinks = oReader;
else if ( _T("mergeCells") == sName )
m_oMergeCells = oReader;
else if ( _T("pageMargins") == sName )
m_oPageMargins = oReader;
else if ( _T("pageSetup") == sName )
m_oPageSetup = oReader;
else if ( _T("printOptions") == sName )
m_oPrintOptions = oReader;
else if ( _T("sheetData") == sName )
m_oSheetData = oReader;
else if (_T("conditionalFormatting") == sName)
m_arrConditionalFormatting.Add(new CConditionalFormatting(oReader));
else if ( _T("sheetFormatPr") == sName )
m_oSheetFormatPr = oReader;
else if ( _T("sheetViews") == sName )
m_oSheetViews = oReader;
else if ( _T("autoFilter") == sName )
m_oAutofilter = oReader;
else if ( _T("tableParts") == sName )
m_oTableParts = oReader;
else if ( _T("legacyDrawing") == sName )
m_oLegacyDrawingWorksheet = oReader;
else if (_T("sheetPr") == sName)
m_oSheetPr = oReader;
}
}
if(m_oLegacyDrawingWorksheet.IsInit() && m_oLegacyDrawingWorksheet->m_oId.IsInit())
{
OOX::RId oRId(m_oLegacyDrawingWorksheet->m_oId->GetValue());
smart_ptr<OOX::File> oLegacyDrawing = IFileContainer::Find(oRId);
smart_ptr<OOX::File> oComments = IFileContainer::Get(FileTypes::Comments);
if (oComments.IsInit() && FileTypes::Comments == oComments->type() && oLegacyDrawing.IsInit() && FileTypes::LegacyDrawings == oLegacyDrawing->type())
{
OOX::Spreadsheet::CComments* pComments = static_cast<OOX::Spreadsheet::CComments*>(oComments.operator->());
OOX::Spreadsheet::CLegacyDrawing* pLegacyDrawing = static_cast<OOX::Spreadsheet::CLegacyDrawing*>(oLegacyDrawing.operator->());
PrepareComments(pComments, pLegacyDrawing);
}
}
}
}
void PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::Spreadsheet::CLegacyDrawing* pLegacyDrawing)
{
CSimpleArray<CString*> aAuthors = pComments->m_oAuthors->m_arrItems;
if(pComments->m_oCommentList.IsInit())
{
CSimpleArray<OOX::Spreadsheet::CComment*> aComments = pComments->m_oCommentList->m_arrItems;
for(int i = 0, length = aComments.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::CComment* pComment = aComments[i];
if(pComment->m_oRef.IsInit() && pComment->m_oAuthorId.IsInit())
{
int nRow, nCol;
if(parseRef(pComment->m_oRef->GetValue(), nRow, nCol))
{
CCommentItem* pCommentItem = new CCommentItem();
pCommentItem->m_nRow = nRow - 1;
pCommentItem->m_nCol = nCol - 1;
unsigned int nAuthorId = pComment->m_oAuthorId->GetValue();
if(nAuthorId < (unsigned int)aAuthors.GetSize())
pCommentItem->m_sAuthor = *aAuthors[nAuthorId];
OOX::Spreadsheet::CSi* pSi = pComment->m_oText.GetPointerEmptyNullable();
if(NULL != pSi)
pCommentItem->m_oText.reset(pSi);
CString sNewId;sNewId.Format(_T("%d-%d"), pCommentItem->m_nRow.get(), pCommentItem->m_nCol.get());
m_mapComments.SetAt(sNewId, pCommentItem);
}
}
}
}
for(int i = 0, length = pLegacyDrawing->m_arrItems.GetSize(); i < length; ++i)
{
OOX::Vml::CShape* pShape = pLegacyDrawing->m_arrItems[i];
for(int j = 0, length2 = pShape->m_arrItems.GetSize(); j < length2; ++j)
{
OOX::WritingElement* pElem = pShape->m_arrItems[j];
if( OOX::et_v_ClientData == pElem->getType())
{
OOX::Vml::CClientData* pClientData = static_cast<OOX::Vml::CClientData*>(pElem);
if(pClientData->m_oRow.IsInit() && pClientData->m_oColumn.IsInit())
{
int nRow = pClientData->m_oRow->GetValue();
int nCol = pClientData->m_oColumn->GetValue();
CString sId;sId.Format(_T("%d-%d"), nRow, nCol);
CAtlMap<CString, CCommentItem*>::CPair* pPair = m_mapComments.Lookup(sId);
if(NULL != pPair)
{
CCommentItem* pCommentItem = pPair->m_value;
if(pShape->m_oGfxData.IsInit())
pCommentItem->m_sGfxdata = pShape->m_oGfxData.get2();
if(pClientData->m_oAnchor.IsInit())
{
const CString& sAnchor = pClientData->m_oAnchor.get();
CSimpleArray<int> m_aAnchor;
int nTokenPos = 0;
CString strToken = sAnchor.Tokenize(_T(","), nTokenPos);
while (!strToken.IsEmpty())
{
strToken.Trim();
m_aAnchor.Add(_wtoi(strToken));
strToken = sAnchor.Tokenize(_T(","), nTokenPos);
}
if(8 == m_aAnchor.GetSize())
{
pCommentItem->m_nLeft = m_aAnchor[0];
pCommentItem->m_nLeftOffset = m_aAnchor[1];
pCommentItem->m_nTop = m_aAnchor[2];
pCommentItem->m_nTopOffset = m_aAnchor[3];
pCommentItem->m_nRight = m_aAnchor[4];
pCommentItem->m_nRightOffset = m_aAnchor[5];
pCommentItem->m_nBottom = m_aAnchor[6];
pCommentItem->m_nBottomOffset = m_aAnchor[7];
}
}
if(pClientData->m_oMoveWithCells.IsInit())
pCommentItem->m_bMove = pClientData->m_oMoveWithCells->ToBool();
if(pClientData->m_oSizeWithCells.IsInit())
pCommentItem->m_bSize = pClientData->m_oSizeWithCells->ToBool();
for(int k = 0 ,length3 = pShape->m_oStyle->m_arrProperties.GetSize(); k < length3; ++k)
{
SimpleTypes::Vml::CCssProperty oProperty = pShape->m_oStyle->m_arrProperties[k];
if(SimpleTypes::Vml::cssptMarginLeft == oProperty.get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty.get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dLeftMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptMarginTop == oProperty.get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty.get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dTopMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptWidth == oProperty.get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty.get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dWidthMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptHeight == oProperty.get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty.get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dHeightMM = oPoint.ToMm();
}
}
}
}
}
}
}
}
}
void PrepareToWrite()
{
if(false == m_oSheetFormatPr.IsInit())
m_oSheetFormatPr.Init();
if(false == m_oSheetFormatPr->m_oDefaultRowHeight.IsInit())
{
m_oSheetFormatPr->m_oDefaultRowHeight.Init();
m_oSheetFormatPr->m_oDefaultRowHeight->SetValue(15);
}
if(false == m_oSheetViews.IsInit())
m_oSheetViews.Init();
if(0 == m_oSheetViews->m_arrItems.GetSize())
m_oSheetViews->m_arrItems.Add(new CSheetView());
CSheetView* pSheetView = m_oSheetViews->m_arrItems[0];
if(false == pSheetView->m_oWorkbookViewId.IsInit())
{
pSheetView->m_oWorkbookViewId.Init();
pSheetView->m_oWorkbookViewId->SetValue(0);
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
CStringWriter sXml;
sXml.WriteStringC(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" mc:Ignorable=\"x14ac\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\">"));
if(m_oSheetPr.IsInit())
m_oSheetPr->toXML(sXml);
if(m_oSheetViews.IsInit())
m_oSheetViews->toXML(sXml);
if(m_oSheetFormatPr.IsInit())
m_oSheetFormatPr->toXML(sXml);
if(m_oCols.IsInit())
m_oCols->toXML(sXml);
if(m_oSheetData.IsInit())
m_oSheetData->toXML(sXml);
for (int nIndex = 0, nLength = (int)m_arrConditionalFormatting.GetCount(); nIndex < nLength; ++nIndex)
m_arrConditionalFormatting[nIndex]->toXML();
if(m_oAutofilter.IsInit())
m_oAutofilter->toXML(sXml);
if(m_oMergeCells.IsInit())
m_oMergeCells->toXML(sXml);
if(m_oHyperlinks.IsInit())
m_oHyperlinks->toXML(sXml);
if(m_oPrintOptions.IsInit())
m_oPrintOptions->toXML(sXml);
if(m_oPageMargins.IsInit())
m_oPageMargins->toXML(sXml);
if(m_oPageSetup.IsInit())
m_oPageSetup->toXML(sXml);
if(m_oDrawing.IsInit())
m_oDrawing->toXML(sXml);
if(m_oLegacyDrawingWorksheet.IsInit())
m_oLegacyDrawingWorksheet->toXML(sXml);
if(m_oTableParts.IsInit())
m_oTableParts->toXML(sXml);
sXml.WriteStringC(_T("</worksheet>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetCString() );
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Worksheet;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
const CPath& GetReadPath()
{
return m_oReadPath;
}
const OOX::RId AddHyperlink (CString& sHref)
{
smart_ptr<OOX::HyperLink> oHyperlink = smart_ptr<OOX::HyperLink>( new OOX::HyperLink( OOX::CPath(sHref, false) ) );
CString sExistRId = IsExistHyperlink(oHyperlink);
if(sExistRId.IsEmpty())
{
smart_ptr<OOX::File> oHyperlinkFile = oHyperlink.smart_dynamic_cast<OOX::File>();
const OOX::RId rId = Add( oHyperlinkFile );
return rId;
}
else
{
const OOX::RId rId(sExistRId);
return rId;
}
}
static bool parseRef(CString sRef, int& nRow, int& nCol)
{
bool bRes = false;
nRow = 0;
nCol = 0;
int nLegnth = sRef.GetLength();
if(nLegnth > 0)
{
int nIndex = 0;
sRef.MakeUpper();
TCHAR cCurLetter = sRef[nIndex];
while('A' <= cCurLetter && cCurLetter <= 'Z' && nIndex < nLegnth)
{
nIndex++;
cCurLetter = sRef[nIndex];
}
if(nIndex > 0)
{
CString sAdd = sRef.Left(nIndex);
CString sDig = sRef.Right(nLegnth - nIndex);
for(int i = 0, length = sAdd.GetLength(); i < length; ++i)
{
nCol = nCol * 26 + sAdd[i] - 'A' + 1;
}
nRow = _wtoi(sDig);
bRes = true;
}
}
return bRes;
}
static CString combineRef(int nRow, int nCol)
{
nRow++;
CString sRes;
if (nCol >= 702) {
int nDig = (nCol / 676 - 1) % 26;
sRes.AppendChar('A' + nDig);
}
if (nCol >= 26) {
int nDig = (nCol / 26 - 1) % 26;
sRes.AppendChar('A' + nDig);
}
sRes.AppendChar('A' + (nCol % 26));
sRes.AppendFormat(_T("%d"), nRow);
return sRes;
}
private:
void ClearItems()
{
POSITION pos = m_mapComments.GetStartPosition();
while ( NULL != pos )
{
CAtlMap<CString, CCommentItem*>::CPair* pPair = m_mapComments.GetNext( pos );
delete pPair->m_value;
}
m_mapComments.RemoveAll();
m_arrConditionalFormatting.FreeAll();
}
private:
CPath m_oReadPath;
public:
nullable<OOX::Spreadsheet::CCols> m_oCols;
nullable<OOX::Spreadsheet::CDimension> m_oDimension;
nullable<OOX::Spreadsheet::CDrawingWorksheet> m_oDrawing;
nullable<OOX::Spreadsheet::CHyperlinks> m_oHyperlinks;
nullable<OOX::Spreadsheet::CMergeCells> m_oMergeCells;
nullable<OOX::Spreadsheet::CSheetData> m_oSheetData;
nullable<OOX::Spreadsheet::CSheetFormatPr> m_oSheetFormatPr;
nullable<OOX::Spreadsheet::CSheetViews> m_oSheetViews;
nullable<OOX::Spreadsheet::CPageMargins> m_oPageMargins;
nullable<OOX::Spreadsheet::CPageSetup> m_oPageSetup;
nullable<OOX::Spreadsheet::CPrintOptions> m_oPrintOptions;
nullable<OOX::Spreadsheet::CAutofilter> m_oAutofilter;
nullable<OOX::Spreadsheet::CTableParts> m_oTableParts;
nullable<OOX::Spreadsheet::CLegacyDrawingWorksheet> m_oLegacyDrawingWorksheet;
CAtlMap<CString, CCommentItem*> m_mapComments;
CPtrAtlArray<OOX::Spreadsheet::CConditionalFormatting*> m_arrConditionalFormatting;
nullable<OOX::Spreadsheet::CSheetPr> m_oSheetPr;
};
}
}
#endif // OOX_WORKSHEET_FILE_INCLUDE_H_

View File

@@ -0,0 +1,835 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_WORKSHEETCHILDSOTHER_FILE_INCLUDE_H_
#define OOX_WORKSHEETCHILDSOTHER_FILE_INCLUDE_H_
#include "../CommonInclude.h"
namespace OOX
{
namespace Spreadsheet
{
class CPageMargins : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPageMargins)
CPageMargins()
{
}
virtual ~CPageMargins()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oLeft.IsInit() || m_oTop.IsInit() || m_oRight.IsInit() || m_oBottom.IsInit() || m_oHeader.IsInit() || m_oFooter.IsInit())
{
writer.WriteStringC(CString(_T("<pageMargins")));
if(m_oLeft.IsInit())
{
CString sLeft;
sLeft.Format(_T(" left=\"%s\""), SpreadsheetCommon::WriteDouble(m_oLeft->ToInches()));
writer.WriteStringC(sLeft);
}
if(m_oRight.IsInit())
{
CString sRight;
sRight.Format(_T(" right=\"%s\""), SpreadsheetCommon::WriteDouble(m_oRight->ToInches()));
writer.WriteStringC(sRight);
}
if(m_oTop.IsInit())
{
CString sTop;
sTop.Format(_T(" top=\"%s\""), SpreadsheetCommon::WriteDouble(m_oTop->ToInches()));
writer.WriteStringC(sTop);
}
if(m_oBottom.IsInit())
{
CString sBottom;
sBottom.Format(_T(" bottom=\"%s\""), SpreadsheetCommon::WriteDouble(m_oBottom->ToInches()));
writer.WriteStringC(sBottom);
}
if(m_oHeader.IsInit())
{
CString sHeader;
sHeader.Format(_T(" header=\"%s\""), SpreadsheetCommon::WriteDouble(m_oHeader->ToInches()));
writer.WriteStringC(sHeader);
}
if(m_oFooter.IsInit())
{
CString sFooter;
sFooter.Format(_T(" footer=\"%s\""), SpreadsheetCommon::WriteDouble(m_oFooter->ToInches()));
writer.WriteStringC(sFooter);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_PageMargins;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("left"), m_oLeft)
WritingElement_ReadAttributes_Read_if ( oReader, _T("top"), m_oTop)
WritingElement_ReadAttributes_Read_if ( oReader, _T("right"), m_oRight)
WritingElement_ReadAttributes_Read_if ( oReader, _T("bottom"), m_oBottom)
WritingElement_ReadAttributes_Read_if ( oReader, _T("header"), m_oHeader)
WritingElement_ReadAttributes_Read_if ( oReader, _T("footer"), m_oFooter)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CInch> m_oLeft;
nullable<SimpleTypes::CInch> m_oTop;
nullable<SimpleTypes::CInch> m_oRight;
nullable<SimpleTypes::CInch> m_oBottom;
nullable<SimpleTypes::CInch> m_oHeader;
nullable<SimpleTypes::CInch> m_oFooter;
};
class CPageSetup : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPageSetup)
CPageSetup()
{
}
virtual ~CPageSetup()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oPaperSize.IsInit() || m_oOrientation.IsInit())
{
writer.WriteStringC(CString(_T("<pageSetup")));
if(m_oPaperSize.IsInit())
{
CString sPaperSize;
sPaperSize.Format(_T(" paperSize=\"%s\""), m_oPaperSize->ToString());
writer.WriteStringC(sPaperSize);
}
if(m_oOrientation.IsInit())
{
CString sOrientation;
sOrientation.Format(_T(" orientation=\"%s\""), m_oOrientation->ToString());
writer.WriteStringC(sOrientation);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_PageSetup;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("orientation"), m_oOrientation)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperSize"), m_oPaperSize)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CPageOrientation<>> m_oOrientation;
nullable<SimpleTypes::Spreadsheet::CPageSize<>> m_oPaperSize;
};
class CPrintOptions : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPrintOptions)
CPrintOptions()
{
}
virtual ~CPrintOptions()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_oGridLines.IsInit() || m_oGridLinesSet.IsInit() || m_oHeadings.IsInit())
{
writer.WriteStringC(CString(_T("<printOptions")));
if(m_oHeadings.IsInit())
{
CString sHeadings;
sHeadings.Format(_T(" headings=\"%s\""), m_oHeadings->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sHeadings);
}
if(m_oGridLines.IsInit())
{
CString sGridLines;
sGridLines.Format(_T(" gridLines=\"%s\""), m_oGridLines->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sGridLines);
}
if(m_oGridLinesSet.IsInit())
{
CString sGridLinesSet;
sGridLinesSet.Format(_T(" gridLinesSet=\"%s\""), m_oGridLinesSet->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sGridLinesSet);
}
writer.WriteStringC(CString(_T("/>")));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_PrintOptions;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("gridLines"), m_oGridLines)
WritingElement_ReadAttributes_Read_if ( oReader, _T("gridLinesSet"), m_oGridLinesSet)
WritingElement_ReadAttributes_Read_if ( oReader, _T("headings"), m_oHeadings)
WritingElement_ReadAttributes_Read_if ( oReader, _T("horizontalCentered"), m_oHorizontalCentered)
WritingElement_ReadAttributes_Read_if ( oReader, _T("verticalCentered"), m_oVerticalCentered)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oGridLines;
nullable<SimpleTypes::COnOff<>> m_oGridLinesSet;
nullable<SimpleTypes::COnOff<>> m_oHeadings;
nullable<SimpleTypes::COnOff<>> m_oHorizontalCentered;
nullable<SimpleTypes::COnOff<>> m_oVerticalCentered;
};
class CDimension : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CDimension)
CDimension()
{
}
virtual ~CDimension()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Dimension;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString> m_oRef;
};
class CSheetFormatPr : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheetFormatPr)
CSheetFormatPr()
{
}
virtual ~CSheetFormatPr()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<sheetFormatPr"));
if(m_oBaseColWidth.IsInit())
{
CString sVal; sVal.Format(_T(" baseColWidth=\"%d\""), m_oBaseColWidth->GetValue());
writer.WriteStringC(sVal);
}
if(m_oCustomHeight.IsInit())
{
CString sVal; sVal.Format(_T(" customHeight=\"%s\""), m_oCustomHeight->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oDefaultColWidth.IsInit())
{
CString sVal; sVal.Format(_T(" defaultColWidth=\"%s\""), SpreadsheetCommon::WriteDouble(m_oDefaultColWidth->GetValue()));
writer.WriteStringC(sVal);
}
if(m_oDefaultRowHeight.IsInit())
{
CString sVal; sVal.Format(_T(" defaultRowHeight=\"%s\""), SpreadsheetCommon::WriteDouble(m_oDefaultRowHeight->GetValue()));
writer.WriteStringC(sVal);
}
if(m_oOutlineLevelCol.IsInit())
{
CString sVal; sVal.Format(_T(" outlineLevelCol=\"%d\""), m_oOutlineLevelCol->GetValue());
writer.WriteStringC(sVal);
}
if(m_oOutlineLevelRow.IsInit())
{
CString sVal; sVal.Format(_T(" outlineLevelRow=\"%d\""), m_oOutlineLevelRow->GetValue());
writer.WriteStringC(sVal);
}
if(m_oThickBottom.IsInit())
{
CString sVal; sVal.Format(_T(" thickBottom=\"%s\""), m_oThickBottom->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oThickTop.IsInit())
{
CString sVal; sVal.Format(_T(" thickTop=\"%s\""), m_oThickTop->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oZeroHeight.IsInit())
{
CString sVal; sVal.Format(_T(" zeroHeight=\"%s\""), m_oZeroHeight->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_SheetFormatPr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("baseColWidth"), m_oBaseColWidth)
WritingElement_ReadAttributes_Read_if ( oReader, _T("customHeight"), m_oCustomHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultColWidth"), m_oDefaultColWidth )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultRowHeight"), m_oDefaultRowHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outlineLevelCol"), m_oOutlineLevelCol )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outlineLevelRow"), m_oOutlineLevelRow )
WritingElement_ReadAttributes_Read_if ( oReader, _T("thickBottom"), m_oThickBottom )
WritingElement_ReadAttributes_Read_if ( oReader, _T("thickTop"), m_oThickTop )
WritingElement_ReadAttributes_Read_if ( oReader, _T("zeroHeight"), m_oZeroHeight )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oBaseColWidth;
nullable<SimpleTypes::COnOff<>> m_oCustomHeight;
nullable<SimpleTypes::CDouble> m_oDefaultColWidth;
nullable<SimpleTypes::CDouble> m_oDefaultRowHeight;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oOutlineLevelCol;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oOutlineLevelRow;
nullable<SimpleTypes::COnOff<>> m_oThickBottom;
nullable<SimpleTypes::COnOff<>> m_oThickTop;
nullable<SimpleTypes::COnOff<>> m_oZeroHeight;
};
class CPane : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CPane)
CPane()
{
}
virtual ~CPane()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Pane;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("activePane") , m_oActivePane)
WritingElement_ReadAttributes_Read_if ( oReader, _T("state") , m_oState)
WritingElement_ReadAttributes_Read_if ( oReader, _T("topLeftCell") , m_oTopLeftCell)
WritingElement_ReadAttributes_Read_if ( oReader, _T("xSplit") , m_oXSplit)
WritingElement_ReadAttributes_Read_if ( oReader, _T("ySplit") , m_oYSplit)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString> m_oActivePane;
nullable<CString> m_oState;
nullable<CString> m_oTopLeftCell;
nullable<SimpleTypes::CDouble> m_oXSplit;
nullable<SimpleTypes::CDouble> m_oYSplit;
};
class CSheetView : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheetView)
CSheetView()
{
}
virtual ~CSheetView()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
writer.WriteStringC(_T("<sheetView"));
if(m_oColorId.IsInit())
{
CString sVal; sVal.Format(_T(" colorId=\"%d\""), m_oColorId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oDefaultGridColor.IsInit())
{
CString sVal; sVal.Format(_T(" defaultGridColor=\"%s\""), m_oDefaultGridColor->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oRightToLeft.IsInit())
{
CString sVal; sVal.Format(_T(" rightToLeft=\"%s\""), m_oRightToLeft->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowFormulas.IsInit())
{
CString sVal; sVal.Format(_T(" showFormulas=\"%s\""), m_oShowFormulas->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowGridLines.IsInit())
{
CString sVal; sVal.Format(_T(" showGridLines=\"%s\""), m_oShowGridLines->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowOutlineSymbols.IsInit())
{
CString sVal; sVal.Format(_T(" showOutlineSymbols=\"%s\""), m_oShowOutlineSymbols->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowRowColHeaders.IsInit())
{
CString sVal; sVal.Format(_T(" showRowColHeaders=\"%s\""), m_oShowRowColHeaders->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowRuler.IsInit())
{
CString sVal; sVal.Format(_T(" showRuler=\"%s\""), m_oShowRuler->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowWhiteSpace.IsInit())
{
CString sVal; sVal.Format(_T(" showWhiteSpace=\"%s\""), m_oShowWhiteSpace->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oShowZeros.IsInit())
{
CString sVal; sVal.Format(_T(" showZeros=\"%s\""), m_oShowZeros->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oWabSelected.IsInit())
{
CString sVal; sVal.Format(_T(" tabSelected=\"%s\""), m_oWabSelected->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oTopLeftCell.IsInit())
{
CString sVal; sVal.Format(_T(" topLeftCell=\"%s\""), m_oTopLeftCell.get());
writer.WriteStringC(sVal);
}
if(m_oView.IsInit())
{
CString sVal; sVal.Format(_T(" view=\"%s\""), m_oView->ToString());
writer.WriteStringC(sVal);
}
if(m_oWindowProtection.IsInit())
{
CString sVal; sVal.Format(_T(" windowProtection=\"%s\""), m_oWindowProtection->ToString2(SimpleTypes::onofftostring1));
writer.WriteStringC(sVal);
}
if(m_oWorkbookViewId.IsInit())
{
CString sVal; sVal.Format(_T(" workbookViewId=\"%d\""), m_oWorkbookViewId->GetValue());
writer.WriteStringC(sVal);
}
if(m_oZoomScale.IsInit())
{
CString sVal; sVal.Format(_T(" zoomScale=\"%d\""), m_oZoomScale->GetValue());
writer.WriteStringC(sVal);
}
if(m_oZoomScaleNormal.IsInit())
{
CString sVal; sVal.Format(_T(" zoomScaleNormal=\"%d\""), m_oZoomScaleNormal->GetValue());
writer.WriteStringC(sVal);
}
if(m_oZoomScalePageLayoutView.IsInit())
{
CString sVal; sVal.Format(_T(" zoomScalePageLayoutView=\"%d\""), m_oZoomScalePageLayoutView->GetValue());
writer.WriteStringC(sVal);
}
if(m_oZoomScaleSheetLayoutView.IsInit())
{
CString sVal; sVal.Format(_T(" zoomScaleSheetLayoutView=\"%d\""), m_oZoomScaleSheetLayoutView->GetValue());
writer.WriteStringC(sVal);
}
writer.WriteStringC(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
CWCharWrapper sName = oReader.GetName();
if (_T("pane") == sName)
m_oPane = oReader;
}
}
virtual EElementType getType () const
{
return et_SheetView;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("colorId"), m_oColorId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultGridColor"), m_oDefaultGridColor)
WritingElement_ReadAttributes_Read_if ( oReader, _T("rightToLeft"), m_oRightToLeft)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showFormulas"), m_oShowFormulas)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showGridLines"), m_oShowGridLines)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showOutlineSymbols"), m_oShowOutlineSymbols)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showRowColHeaders"), m_oShowRowColHeaders)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showRuler"), m_oShowRuler)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showWhiteSpace"), m_oShowWhiteSpace)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showZeros"), m_oShowZeros)
WritingElement_ReadAttributes_Read_if ( oReader, _T("tabSelected"), m_oWabSelected)
WritingElement_ReadAttributes_Read_if ( oReader, _T("topLeftCell"), m_oTopLeftCell)
WritingElement_ReadAttributes_Read_if ( oReader, _T("view"), m_oView)
WritingElement_ReadAttributes_Read_if ( oReader, _T("windowProtection"), m_oWindowProtection)
WritingElement_ReadAttributes_Read_if ( oReader, _T("workbookViewId"), m_oWorkbookViewId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScale"), m_oZoomScale)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScaleNormal"), m_oZoomScaleNormal)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScalePageLayoutView"), m_oZoomScalePageLayoutView)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScaleSheetLayoutView"), m_oZoomScaleSheetLayoutView)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CPane> m_oPane;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oColorId;
nullable<SimpleTypes::COnOff<>> m_oDefaultGridColor;
nullable<SimpleTypes::COnOff<>> m_oRightToLeft;
nullable<SimpleTypes::COnOff<>> m_oShowFormulas;
nullable<SimpleTypes::COnOff<>> m_oShowGridLines;
nullable<SimpleTypes::COnOff<>> m_oShowOutlineSymbols;
nullable<SimpleTypes::COnOff<>> m_oShowRowColHeaders;
nullable<SimpleTypes::COnOff<>> m_oShowRuler;
nullable<SimpleTypes::COnOff<>> m_oShowWhiteSpace;
nullable<SimpleTypes::COnOff<>> m_oShowZeros;
nullable<SimpleTypes::COnOff<>> m_oWabSelected;
nullable<CString> m_oTopLeftCell;
nullable<SimpleTypes::Spreadsheet::CSheetViewType<>>m_oView;
nullable<SimpleTypes::COnOff<>> m_oWindowProtection;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oWorkbookViewId;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oZoomScale;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oZoomScaleNormal;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oZoomScalePageLayoutView;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oZoomScaleSheetLayoutView;
};
class CSheetViews : public WritingElementWithChilds<CSheetView>
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheetViews)
CSheetViews()
{
}
virtual ~CSheetViews()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if(m_arrItems.GetSize() > 0)
{
writer.WriteStringC(_T("<sheetViews>"));
for(int i = 0, length = m_arrItems.GetSize(); i< length; ++i)
m_arrItems[i]->toXML(writer);
writer.WriteStringC(_T("</sheetViews>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("sheetView") == sName )
m_arrItems.Add( new CSheetView( oReader ));
}
}
virtual EElementType getType () const
{
return et_SheetViews;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
}
public:
};
class CSheetPr : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSheetPr)
CSheetPr()
{
}
virtual ~CSheetPr()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(CStringWriter& writer) const
{
if (m_oTabColor.IsInit())
{
writer.WriteStringC(_T("<sheetPr>"));
m_oTabColor->toXML2(writer, _T("tabColor"));
writer.WriteStringC(_T("</sheetPr>"));
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CWCharWrapper sName = oReader.GetName();
if ( _T("tabColor") == sName )
m_oTabColor = oReader;
}
}
virtual EElementType getType () const
{
return et_SheetPr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("codeName"), m_oCodeName )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("enableFormatConditionsCalculation"), m_oEnableFormatConditionsCalculation )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("filterMode"), m_oFilterMode )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("published"), m_oPublished )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("syncHorizontal"), m_oSyncHorizontal )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("syncRef"), m_oSyncRef )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("syncVertical"), m_oSyncVertical )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("transitionEntry"), m_oTransitionEntry )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("transitionEvaluation"), m_oTransitionEvaluation )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CColor> m_oTabColor;
nullable<CString> m_oCodeName;
nullable<SimpleTypes::COnOff<>> m_oEnableFormatConditionsCalculation;
nullable<SimpleTypes::COnOff<>> m_oFilterMode;
nullable<SimpleTypes::COnOff<>> m_oPublished;
nullable<SimpleTypes::COnOff<>> m_oSyncHorizontal;
nullable<CString> m_oSyncRef;
nullable<SimpleTypes::COnOff<>> m_oSyncVertical;
nullable<SimpleTypes::COnOff<>> m_oTransitionEntry;
nullable<SimpleTypes::COnOff<>> m_oTransitionEvaluation;
};
}
}
#endif // OOX_WORKSHEETCHILDSOTHER_FILE_INCLUDE_H_

View File

@@ -0,0 +1,767 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "../XML/XmlUtils.h"
#include "atlstr.h"
namespace OOX
{
namespace Spreadsheet
{
#define WritingElementSpreadsheet_AdditionConstructors(Class) \
Class(XmlUtils::CXmlLiteReader& oReader)\
{\
fromXML( oReader );\
}\
const Class& operator =(const XmlUtils::CXmlLiteReader& oReader)\
{\
fromXML( (XmlUtils::CXmlLiteReader&)oReader );\
return *this;\
}
const double c_ag_Inch_to_MM = 25.4;
const double c_ag_1pxWidth = 25.4 / 96;
static wchar_t g_wc_amp = wchar_t('&');
static wchar_t g_wc_apos = wchar_t('\'');
static wchar_t g_wc_lt = wchar_t('<');
static wchar_t g_wc_qt = wchar_t('>');
static wchar_t g_wc_quot = wchar_t('\"');
static _bstr_t g_bstr_amp = L"&amp;";
static _bstr_t g_bstr_apos = L"&apos;";
static _bstr_t g_bstr_lt = L"&lt;";
static _bstr_t g_bstr_qt = L"&gt;";
static _bstr_t g_bstr_quot = L"\"";
static _bstr_t g_bstr_mdash = L"&mdash;";
class CTextItem
{
protected:
wchar_t* m_pData;
size_t m_lSize;
wchar_t* m_pDataCur;
size_t m_lSizeCur;
public:
CTextItem()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
}
CTextItem(const CTextItem& oSrc)
{
m_pData = NULL;
*this = oSrc;
}
CTextItem& operator=(const CTextItem& oSrc)
{
RELEASEMEM(m_pData);
m_lSize = oSrc.m_lSize;
m_lSizeCur = oSrc.m_lSizeCur;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(m_pData, oSrc.m_pData, m_lSizeCur * sizeof(wchar_t));
m_pDataCur = m_pData + m_lSizeCur;
return *this;
}
CTextItem(const size_t& nLen)
{
m_lSize = nLen;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
}
CTextItem(wchar_t* pData, const size_t& nLen)
{
m_lSize = nLen;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(m_pData, pData, m_lSize * sizeof(wchar_t));
m_lSizeCur = m_lSize;
m_pDataCur = m_pData + m_lSize;
}
CTextItem(wchar_t* pData, BYTE* pUnicodeChecker = NULL)
{
size_t nLen = GetStringLen(pData);
m_lSize = nLen;
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(m_pData, pData, m_lSize * sizeof(wchar_t));
m_lSizeCur = m_lSize;
m_pDataCur = m_pData + m_lSize;
if (NULL != pUnicodeChecker)
{
wchar_t* pMemory = m_pData;
while (pMemory < m_pDataCur)
{
if (!pUnicodeChecker[*pMemory])
*pMemory = wchar_t(' ');
++pMemory;
}
}
}
virtual ~CTextItem()
{
RELEASEMEM(m_pData);
}
AVSINLINE void AddSize(const size_t& nSize)
{
if (NULL == m_pData)
{
m_lSize = max(nSize, 1000);
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
if (NULL != pRealloc)
{
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
AVSINLINE wchar_t* GetData()
{
return m_pData;
}
AVSINLINE size_t GetCurSize()
{
return m_lSizeCur;
}
public:
AVSINLINE void operator+=(const CTextItem& oTemp)
{
WriteString(oTemp.m_pData, oTemp.m_lSizeCur);
}
AVSINLINE void operator+=(_bstr_t& oTemp)
{
size_t nLen = oTemp.length();
WriteString(oTemp.GetBSTR(), nLen);
}
AVSINLINE void operator+=(CString& oTemp)
{
size_t nLen = (size_t)oTemp.GetLength();
#ifdef _UNICODE
WriteString(oTemp.GetBuffer(), nLen);
#else
CStringW str = (CStringW)oTemp;
WriteString(str.GetBuffer(), nLen);
#endif
}
AVSINLINE wchar_t& operator[](const size_t& nIndex)
{
return m_pData[nIndex];
}
AVSINLINE void SetText(BSTR& bsText)
{
ClearNoAttack();
size_t nLen = GetStringLen(bsText);
WriteString(bsText, nLen);
}
AVSINLINE void AddSpace()
{
AddSize(1);
*m_pDataCur = wchar_t(' ');
++m_lSizeCur;
++m_pDataCur;
}
AVSINLINE void AddSpaceFirst()
{
AddSize(1);
wchar_t* pMemory = new wchar_t[m_lSizeCur];
memcpy(pMemory, m_pData, m_lSizeCur * sizeof(wchar_t));
memcpy(m_pData + 1, pMemory, m_lSizeCur * sizeof(wchar_t));
RELEASEARRAYOBJECTS(pMemory);
*m_pData = wchar_t(' ');
++m_lSizeCur;
++m_pDataCur;
}
AVSINLINE BOOL IsEqual(const CTextItem& oItem)const
{
const wchar_t* pNew = oItem.m_pData;
for (size_t i = 0; i < m_lSizeCur; ++i)
{
if (m_pData[i] != pNew[i])
return FALSE;
}
return TRUE;
}
AVSINLINE BOOL IsEqualLast(CTextItem& oItem, BOOL bIsAddSpace)const
{
if (bIsAddSpace != TRUE)
return FALSE;
size_t size_cur = m_lSizeCur;
size_t size_item = oItem.m_lSizeCur;
wchar_t* p1 = m_pData;
wchar_t* p2 = oItem.m_pData;
for (size_t i = m_lSizeCur - 1; i >= 0; --i)
{
if (WCHAR(' ') != p1[i])
break;
--size_cur;
}
for (size_t i = oItem.m_lSizeCur - 1; i >= 0; --i)
{
if (WCHAR(' ') != p2[i])
break;
--size_item;
}
size_t len = min(size_cur, size_item);
p1 = m_pData + size_cur - len;
p2 = oItem.m_pData + size_item - len;
for (size_t i = 0; i < len; ++i, ++p1, ++p2)
if (*p1 != *p2)
return FALSE;
if (bIsAddSpace && (size_cur != m_lSizeCur) && (size_item == oItem.m_lSizeCur))
oItem.AddSpace();
return TRUE;
}
AVSINLINE void CorrectUnicode(const BYTE* pUnicodeChecker)
{
if (NULL != pUnicodeChecker)
{
wchar_t* pMemory = m_pData;
while (pMemory < m_pDataCur)
{
if (!pUnicodeChecker[*pMemory])
*pMemory = wchar_t(' ');
++pMemory;
}
}
}
AVSINLINE void RemoveLastSpaces()
{
wchar_t* pMemory = m_pDataCur - 1;
while ((pMemory > m_pData) && (wchar_t(' ') == *pMemory))
{
--pMemory;
--m_lSizeCur;
--m_pDataCur;
}
}
AVSINLINE bool IsSpace()
{
if (1 != m_lSizeCur)
return false;
return (wchar_t(' ') == *m_pData);
}
AVSINLINE void CheckLastSpanLine()
{
if (0 == m_lSizeCur)
return;
if ((wchar_t(' ') == m_pData[m_lSizeCur - 1]) || (wchar_t('-') == m_pData[m_lSizeCur - 1]))
return;
AddSpace();
}
public:
AVSINLINE void WriteString(wchar_t* pString, const size_t& nLen)
{
AddSize(nLen);
memcpy(m_pDataCur, pString, nLen << 1);
m_pDataCur += nLen;
m_lSizeCur += nLen;
}
AVSINLINE size_t GetSize()
{
return m_lSize;
}
AVSINLINE void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE size_t GetStringLen(wchar_t* pData)
{
wchar_t* s = pData;
for (; *s != 0; ++s);
return (size_t)(s - pData);
}
AVSINLINE CString GetCString()
{
CString str(m_pData, (int)m_lSizeCur);
return str;
}
AVSINLINE wchar_t* GetBuffer()
{
return m_pData;
}
};
class CStringWriter : public CTextItem
{
public:
CStringWriter() : CTextItem()
{
}
virtual ~CStringWriter()
{
}
public:
AVSINLINE void WriteStringB(_bstr_t& bsString)
{
size_t nLen = bsString.length();
CTextItem::WriteString(bsString.GetBSTR(), nLen);
}
AVSINLINE void WriteString(CString sString)
{
size_t nLen = (size_t)sString.GetLength();
#ifdef _UNICODE
CTextItem::WriteString(sString.GetBuffer(), nLen);
#else
CStringW str = (CStringW)sString;
WriteString(str.GetBuffer(), nLen);
#endif
}
AVSINLINE void WriteStringC(const CString& sString)
{
size_t nLen = (size_t)sString.GetLength();
CString* pStr = const_cast<CString*>(&sString);
#ifdef _UNICODE
CTextItem::WriteString(pStr->GetBuffer(), nLen);
#else
CStringW str = (CStringW)sString;
WriteString(str.GetBuffer(), nLen);
#endif
}
AVSINLINE void Write(CStringWriter& oWriter)
{
CTextItem::WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
}
AVSINLINE void WriteI(CTextItem& oItem)
{
CTextItem::WriteString(oItem.GetData(), oItem.GetCurSize());
}
AVSINLINE void WriteString(wchar_t* pString, const size_t& nLen)
{
CTextItem::AddSize(nLen);
memcpy(m_pDataCur, pString, nLen << 1);
m_pDataCur += nLen;
m_lSizeCur += nLen;
}
void WriteTextHTML(CTextItem& oItem)
{
size_t nCurrent = 0;
size_t nCount = oItem.GetCurSize();
size_t nCurrentOld = nCurrent;
wchar_t* pData = oItem.GetData();
wchar_t* pStartData = pData;
while (nCurrent < nCount)
{
wchar_t c = *pData++;
if (g_wc_amp == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_amp);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (g_wc_lt == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_lt);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (g_wc_qt == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_qt);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (g_wc_quot == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_quot);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (8212 == (USHORT)c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_mdash);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else
{
++nCurrent;
}
}
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
}
void WriteTextXML(CTextItem& oItem)
{
size_t nCurrent = 0;
size_t nCount = oItem.GetCurSize();
size_t nCurrentOld = nCurrent;
wchar_t* pData = oItem.GetData();
wchar_t* pStartData = pData;
while (nCurrent < nCount)
{
wchar_t c = *pData++;
if (g_wc_amp == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_amp);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (g_wc_lt == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_lt);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (g_wc_qt == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_qt);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else if (g_wc_quot == c)
{
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
WriteStringB(g_bstr_quot);
++nCurrent;
nCurrentOld = nCurrent;
pStartData = pData;
}
else
{
++nCurrent;
}
}
if (nCurrentOld != nCurrent)
WriteString(pStartData, nCurrent - nCurrentOld);
}
};
enum EElementType
{
et_Unknown,
et_BookViews,
et_WorkbookPr,
et_WorkbookView,
et_DefinedNames,
et_DefinedName,
et_Sheets,
et_Sheet,
et_Si,
et_PhoneticPr,
et_r,
et_rPr,
et_rPh,
et_t,
et_Borders,
et_Border,
et_BorderProp,
et_CellStyles,
et_CellStyle,
et_CellStyleXfs,
et_CellXfs,
et_Xfs,
et_Aligment,
et_Protection,
et_Colors,
et_Color,
et_RgbColor,
et_IndexedColors,
et_MruColors,
et_Dxfs,
et_Dxf,
et_Fills,
et_Fill,
et_GradientFill,
et_GradientStop,
et_PatternFill,
et_BgColor,
et_FgColor,
et_Fonts,
et_Font,
et_NumFmts,
et_NumFmt,
et_TableStyles,
et_TableStyle,
et_TableStyleElement,
et_SheetData,
et_Row,
et_Cell,
et_Formula,
et_Cols,
et_Col,
et_Hyperlinks,
et_Hyperlink,
et_PageMargins,
et_PageSetup,
et_PrintOptions,
et_MergeCells,
et_MergeCell,
et_Dimension,
et_SheetFormatPr,
et_CellAnchor,
et_Pic,
et_BlipFill,
et_Blip,
et_FromTo,
et_Pos,
et_Ext,
et_CalcCell,
et_SheetViews,
et_SheetView,
et_c_Chart,
et_c_ChartStyle,
et_c_Title,
et_c_Tx,
et_c_Rich,
et_a_Paragraph,
et_a_Run,
et_a_Text,
et_c_Legend,
et_c_Overlay,
et_c_LegendPos,
et_c_LegendEntry,
et_c_Layout,
et_c_ManualLayout,
et_c_PlotArea,
et_c_CatAx,
et_c_ValAx,
et_c_CatAy,
et_c_ValAy,
et_c_BasicChart,
et_c_Series,
et_c_NumPoint,
et_c_NumCache,
et_c_NumCacheRef,
et_c_NumCacheValues,
et_c_SeriesCat,
et_c_StrCacheRef,
et_c_SeriesTx,
et_c_SeriesMarker,
et_c_SeriesDataLabels,
et_c_SeriesShapeProperties,
et_c_SeriesShapeIndex,
et_c_SeriesShapeOrder,
et_c_SeriesShapeOutline,
et_xdr_GraphicFrame,
et_xdr_GraphicData,
et_TableParts,
et_TablePart,
et_Table,
et_TableColumns,
et_TableColumn,
et_TableStyleInfo,
et_SortState,
et_SortCondition,
et_Autofilter,
et_FilterColumn,
et_ColorFilter,
et_DynamicFilter,
et_CustomFilters,
et_Filters,
et_Filter,
et_DateGroupItem,
et_Authors,
et_CommentList,
et_Comment,
et_ConditionalFormatting,
et_ConditionalFormattingRule,
et_ColorScale,
et_DataBar,
et_FormulaCF,
et_IconSet,
et_ConditionalFormatValueObject,
et_SheetPr,
et_Pane
};
class WritingElement
{
public:
WritingElement(){}
virtual ~WritingElement() {}
virtual void toXML(CStringWriter& writer) const = 0;
virtual CString toXML() const = 0;
virtual EElementType getType() const
{
return et_Unknown;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) {}
};
template<typename ElemType = WritingElement>
class WritingElementWithChilds : public WritingElement
{
public:
WritingElementWithChilds(){}
virtual ~WritingElementWithChilds() {ClearItems();}
virtual void ClearItems()
{
for ( int nIndex = 0; nIndex < m_arrItems.GetSize(); nIndex++ )
{
if ( m_arrItems[nIndex] )
delete m_arrItems[nIndex];
m_arrItems[nIndex] = NULL;
}
m_arrItems.RemoveAll();
}
CSimpleArray<ElemType *> m_arrItems;
};
}
}

View File

@@ -0,0 +1,474 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#ifndef OOX_XLSX_INCLUDE_H_
#define OOX_XLSX_INCLUDE_H_
#include "../Base/SmartPtr.h"
#include "../DocxFormat/IFileContainer.h"
#include "../SystemUtility/FileSystem/Directory.h"
#include "../DocxFormat/Theme/Theme.h"
#include "../DocxFormat/App.h"
#include "../DocxFormat/Core.h"
#include "Workbook/Workbook.h"
#include "SharedStrings/SharedStrings.h"
#include "Styles/Styles.h"
#include "Worksheets/Worksheet.h"
#include "CalcChain/CalcChain.h"
namespace OOX
{
namespace Spreadsheet
{
class CXlsx : public OOX::Spreadsheet::IFileContainer
{
public:
CXlsx()
{
init();
}
CXlsx(const CPath& oFilePath)
{
init();
Read( oFilePath );
}
~CXlsx()
{
if(bDeleteWorkbook)
RELEASEOBJECT(m_pWorkbook);
if(bDeleteSharedStrings)
RELEASEOBJECT(m_pSharedStrings);
if(bDeleteStyles)
RELEASEOBJECT(m_pStyles);
if(bDeleteTheme)
RELEASEOBJECT(m_pTheme);
if(bDeleteCalcChain)
RELEASEOBJECT(m_pCalcChain);
if(bDeleteWorksheets)
{
POSITION pos = m_aWorksheets.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, CWorksheet*>::CPair* pPair = m_aWorksheets.GetNext( pos );
delete pPair->m_value;
}
}
}
public:
BOOL Read(const CPath& oFilePath)
{
OOX::CRels oRels( oFilePath / L"/" );
IFileContainer::Read( oRels, oFilePath );
smart_ptr<OOX::File> pFile = Find(OOX::Spreadsheet::FileTypes::Workbook);
if (pFile.IsInit() && OOX::Spreadsheet::FileTypes::Workbook == pFile->type())
m_pWorkbook = (OOX::Spreadsheet::CWorkbook*)pFile.operator->();
else
m_pWorkbook = NULL;
if ( m_pWorkbook )
{
OOX::Spreadsheet::IFileContainer* pDocumentContainer = (OOX::Spreadsheet::IFileContainer*)m_pWorkbook;
pFile = pDocumentContainer->Find( OOX::Spreadsheet::FileTypes::SharedStrings );
if ( pFile.IsInit() && OOX::Spreadsheet::FileTypes::SharedStrings == pFile->type() )
m_pSharedStrings = (OOX::Spreadsheet::CSharedStrings*)pFile.operator->();
else
m_pSharedStrings = NULL;
pFile = pDocumentContainer->Find( OOX::Spreadsheet::FileTypes::Styles );
if ( pFile.IsInit() && OOX::Spreadsheet::FileTypes::Styles == pFile->type() )
m_pStyles = (OOX::Spreadsheet::CStyles*)pFile.operator->();
else
m_pStyles = NULL;
pFile = pDocumentContainer->Find(OOX::FileTypes::Theme);
if (pFile.IsInit() && OOX::FileTypes::Theme == pFile->type())
m_pTheme = (OOX::CTheme*)pFile.operator->();
else
m_pTheme = NULL;
pFile = pDocumentContainer->Find(OOX::Spreadsheet::FileTypes::CalcChain);
if (pFile.IsInit() && OOX::Spreadsheet::FileTypes::CalcChain == pFile->type())
m_pCalcChain = (OOX::Spreadsheet::CCalcChain*)pFile.operator->();
else
m_pCalcChain = NULL;
CAtlMap<CString, smart_ptr<OOX::File>> aWorksheetsFiles;
pDocumentContainer->FindAllByType(OOX::Spreadsheet::FileTypes::Worksheet, aWorksheetsFiles);
pDocumentContainer->FindAllByType(OOX::Spreadsheet::FileTypes::Chartsheets, aWorksheetsFiles);
POSITION pos = aWorksheetsFiles.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = aWorksheetsFiles.GetNext( pos );
m_aWorksheets.SetAt(pPair->m_key, (OOX::Spreadsheet::CWorksheet*)pPair->m_value.operator->());
}
}
return TRUE;
}
BOOL Write(const CPath& oDirPath, CString& sTempTheme, CString& sAdditionalContentTypes)
{
if(NULL == m_pWorkbook || 0 == m_aWorksheets.GetCount())
return FALSE;
PrepareToWrite();
OOX::CContentTypes oContentTypes;
OOX::CApp* pApp = new OOX::CApp();
pApp->SetDocSecurity(0);
pApp->SetScaleCrop(false);
pApp->SetCompany(_T("Ascensio System"));
pApp->SetLinksUpToDate(false);
pApp->SetSharedDoc(false);
pApp->SetHyperlinksChanged(false);
smart_ptr<OOX::File> pAppFile(pApp);
const OOX::RId oAppRId = Add(pAppFile);
OOX::CCore* pCore = new OOX::CCore();
pCore->SetCreator(_T(""));
pCore->SetLastModifiedBy(_T(""));
smart_ptr<OOX::File> pCoreFile(pCore);
const OOX::RId oCoreRId = Add(pCoreFile);
CPath oXlPath = oDirPath / m_pWorkbook->DefaultDirectory();
WriteWorkbook(oXlPath, sTempTheme);
IFileContainer::Write(oDirPath / _T("/"), OOX::CPath(_T("")), oContentTypes);
if(!sAdditionalContentTypes.IsEmpty())
{
CString sAdditionalContentTypesWrapped;
sAdditionalContentTypesWrapped.Format(_T("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">%s</Types>"), sAdditionalContentTypes);
OOX::CContentTypes oTempContentTypes;
oTempContentTypes.ReadFromString(sAdditionalContentTypesWrapped);
POSITION pos = oTempContentTypes.m_arrOverride.GetStartPosition();
while ( NULL != pos )
{
CAtlMap<CString, ContentTypes::COverride>::CPair* pPair = oTempContentTypes.m_arrOverride.GetNext( pos );
ContentTypes::COverride& oOverride = pPair->m_value;
const OOX::CPath& oPath = oOverride.filename();
oContentTypes.Registration(oOverride.type(), oPath.GetDirectory(), oPath.GetFilename());
}
}
oContentTypes.Write(oDirPath);
return TRUE;
}
BOOL WriteWorkbook(const CPath& oDirPath, CString& sTempTheme)
{
OOX::CTheme* pTheme = new OOX::CTheme();
pTheme->DoNotWriteContent(true);
smart_ptr<OOX::File> pThemeFile(pTheme);
m_pWorkbook->Add(pThemeFile);
CPath oThemeDir = oDirPath / pTheme->DefaultDirectory();
OOX::CSystemUtility::CreateDirectories( oThemeDir );
::CopyFile(sTempTheme, (oThemeDir / pTheme->DefaultFileName()).GetPath(), FALSE);
if(NULL != m_pSharedStrings && m_pSharedStrings->m_arrItems.GetSize() > 0)
{
smart_ptr<OOX::File> pSharedStringsFile(m_pSharedStrings);
bDeleteSharedStrings = false;
m_pWorkbook->Add(pSharedStringsFile);
}
if(NULL != m_pStyles)
{
smart_ptr<OOX::File> pStylesFile(m_pStyles);
bDeleteStyles = false;
m_pWorkbook->Add(pStylesFile);
}
smart_ptr<OOX::File> pWorkbookFile(m_pWorkbook);
bDeleteWorkbook = false;
Add(pWorkbookFile);
return TRUE;
}
void PrepareToWrite()
{
if(NULL != m_pWorkbook)
m_pWorkbook->PrepareToWrite();
if(NULL != m_pStyles)
m_pStyles->PrepareToWrite();
POSITION pos = m_aWorksheets.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, CWorksheet*>::CPair* pPair = m_aWorksheets.GetNext( pos );
pPair->m_value->PrepareToWrite();
}
}
public:
CWorkbook *GetWorkbook () const
{
return m_pWorkbook;
}
CWorkbook *CreateWorkbook ()
{
if(bDeleteWorkbook)
RELEASEOBJECT(m_pWorkbook);
m_pWorkbook = new CWorkbook();
bDeleteWorkbook = true;
return m_pWorkbook;
}
CSharedStrings *GetSharedStrings () const
{
return m_pSharedStrings;
}
CSharedStrings *CreateSharedStrings ()
{
if(bDeleteSharedStrings)
RELEASEOBJECT(m_pSharedStrings);
m_pSharedStrings = new CSharedStrings();
bDeleteSharedStrings = true;
return m_pSharedStrings;
}
CStyles *GetStyles () const
{
return m_pStyles;
}
CStyles *CreateStyles ()
{
if(bDeleteStyles)
RELEASEOBJECT(m_pStyles);
m_pStyles = new CStyles();
bDeleteStyles = true;
return m_pStyles;
}
CTheme *GetTheme () const
{
return m_pTheme;
}
CCalcChain *GetCalcChain () const
{
return m_pCalcChain;
}
CAtlMap<CString, CWorksheet*> &GetWorksheets ()
{
return m_aWorksheets;
}
void PrepareWorkbook()
{
IFileContainer::m_mapEnumeratedGlobal.RemoveAll();
if(NULL != m_pStyles )
{
if(false == m_pStyles->m_oFonts.IsInit())
m_pStyles->m_oFonts.Init();
if(m_pStyles->m_oFonts->m_arrItems.GetSize() == 0)
m_pStyles->m_oFonts->AddFont(new OOX::Spreadsheet::CFont());
OOX::Spreadsheet::CFont* pFont = m_pStyles->m_oFonts->m_arrItems[0];
if(false == pFont->m_oRFont.IsInit())
{
pFont->m_oRFont.Init();
pFont->m_oRFont->m_sVal = _T("Arial");
}
if(false == pFont->m_oSz.IsInit() || false == pFont->m_oSz->m_oVal.IsInit())
{
pFont->m_oSz.Init();
pFont->m_oSz->m_oVal.Init();
pFont->m_oSz->m_oVal->SetValue(11.0);
}
if(false == m_pStyles->m_oFills.IsInit())
m_pStyles->m_oFills.Init();
if(m_pStyles->m_oFills->m_arrItems.GetSize() == 0)
m_pStyles->m_oFills->m_arrItems.Add(new OOX::Spreadsheet::CFill());
OOX::Spreadsheet::CFill* pFill = m_pStyles->m_oFills->m_arrItems[0];
if(false == pFill->m_oGradientFill.IsInit())
{
if(false == pFill->m_oPatternFill.IsInit())
pFill->m_oPatternFill.Init();
if(false == pFill->m_oPatternFill->m_oPatternType.IsInit())
pFill->m_oPatternFill->m_oPatternType.Init();
pFill->m_oPatternFill->m_oPatternType->SetValue(SimpleTypes::Spreadsheet::patterntypeNone);
}
if(false == m_pStyles->m_oBorders.IsInit())
m_pStyles->m_oBorders.Init();
if(m_pStyles->m_oBorders->m_arrItems.GetSize() == 0)
m_pStyles->m_oBorders->m_arrItems.Add(new OOX::Spreadsheet::CBorder());
if(false == m_pStyles->m_oCellXfs.IsInit())
m_pStyles->m_oCellXfs.Init();
if(m_pStyles->m_oCellXfs->m_arrItems.GetSize() == 0)
m_pStyles->m_oCellXfs->m_arrItems.Add(new OOX::Spreadsheet::CXfs());
OOX::Spreadsheet::CXfs* pXfs = m_pStyles->m_oCellXfs->m_arrItems[0];
if(false == pXfs->m_oBorderId.IsInit())
{
pXfs->m_oBorderId.Init();
pXfs->m_oBorderId->SetValue(0);
}
if(false == pXfs->m_oFillId.IsInit())
{
pXfs->m_oFillId.Init();
pXfs->m_oFillId->SetValue(0);
}
if(false == pXfs->m_oFontId.IsInit())
{
pXfs->m_oFontId.Init();
pXfs->m_oFontId->SetValue(0);
}
if(false == pXfs->m_oNumFmtId.IsInit())
{
pXfs->m_oNumFmtId.Init();
pXfs->m_oNumFmtId->SetValue(0);
}
}
POSITION pos = m_aWorksheets.GetStartPosition();
while ( NULL != pos )
{
const CAtlMap<CString, CWorksheet*>::CPair* pPair = m_aWorksheets.GetNext( pos );
PrepareWorksheet(pPair->m_value);
}
}
private:
void PrepareWorksheet(CWorksheet* pWorksheet)
{
if(pWorksheet->m_oSheetData.IsInit())
{
CSimpleArray<OOX::Spreadsheet::CRow*>& aRows = pWorksheet->m_oSheetData->m_arrItems;
for(int i = 0, length = aRows.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::CRow* pRow = aRows[i];
CSimpleArray<OOX::Spreadsheet::CCell*>& aCells = pRow->m_arrItems;
for(int j = 0, length2 = aCells.GetSize(); j < length2; ++j)
{
OOX::Spreadsheet::CCell* pCell = aCells[j];
if(pCell->m_oType.IsInit())
{
if(SimpleTypes::Spreadsheet::celltypeInlineStr == pCell->m_oType->GetValue())
{
CSharedStrings* pSharedStrings = GetSharedStrings();
if(NULL == pSharedStrings)
pSharedStrings = CreateSharedStrings();
OOX::Spreadsheet::CSi* pSi = pCell->m_oRichText.GetPointerEmptyNullable();
if(NULL != pSi)
{
int nIndex = pSharedStrings->AddSi(pSi);
pCell->m_oValue.Init();
pCell->m_oValue->m_sText.Format(_T("%d"), nIndex);
pCell->m_oType.Init();
pCell->m_oType->SetValue(SimpleTypes::Spreadsheet::celltypeSharedString);
}
}
else if(SimpleTypes::Spreadsheet::celltypeStr == pCell->m_oType->GetValue() || SimpleTypes::Spreadsheet::celltypeError == pCell->m_oType->GetValue())
{
CSharedStrings* pSharedStrings = GetSharedStrings();
if(NULL == pSharedStrings)
pSharedStrings = CreateSharedStrings();
CString sValue;
if(pCell->m_oValue.IsInit())
sValue = pCell->m_oValue->ToString();
CSi* pSi = new CSi();
CText* pText = new CText();
pText->m_sText = sValue;
pSi->m_arrItems.Add(pText);
int nIndex = pSharedStrings->AddSi(pSi);
pCell->m_oValue.Init();
pCell->m_oValue->m_sText.Format(_T("%d"), nIndex);
if(SimpleTypes::Spreadsheet::celltypeStr == pCell->m_oType->GetValue())
{
pCell->m_oType.Init();
pCell->m_oType->SetValue(SimpleTypes::Spreadsheet::celltypeSharedString);
}
}
}
}
}
}
}
void init()
{
m_pWorkbook = NULL;
m_pSharedStrings = NULL;
m_pStyles = NULL;
m_pTheme = NULL;
m_pCalcChain = NULL;
bDeleteWorkbook = false;
bDeleteSharedStrings = false;
bDeleteStyles = false;
bDeleteTheme = false;
bDeleteCalcChain = false;
bDeleteWorksheets = false;
}
private:
CWorkbook *m_pWorkbook;
bool bDeleteWorkbook;
CSharedStrings *m_pSharedStrings;
bool bDeleteSharedStrings;
CStyles *m_pStyles;
bool bDeleteStyles;
CTheme *m_pTheme;
bool bDeleteTheme;
CCalcChain *m_pCalcChain;
bool bDeleteCalcChain;
CAtlMap<CString, CWorksheet*> m_aWorksheets;
bool bDeleteWorksheets;
};
}
}
#endif // OOX_XLSX_INCLUDE_H_