Commit f8fcdb34 authored by konovalovsergey's avatar konovalovsergey Committed by Alexander Trofimov

add open/save sparkline

parent 59554c12
......@@ -150,7 +150,8 @@ SOURCES += docxformatlib.cpp \
../Source/Utility/DateTime.cpp \
../Source/Utility/TxtFile.cpp \
../Source/Base/unicode_util.cpp \
../../3dParty/pole/pole.cpp
../../3dParty/pole/pole.cpp \
../Source/DocxFormat/Drawing/DrawingExt.cpp
HEADERS += docxformatlib.h \
../Source/Base/Base.h \
......@@ -347,7 +348,8 @@ HEADERS += docxformatlib.h \
../Source/MathEquation/Types.h \
../Source/Base/unicode_util.h \
../Source/XlsxFormat/ExternalLinks/ExternalLinkPath.h \
../Source/XlsxFormat/ExternalLinks/ExternalLinks.h
../Source/XlsxFormat/ExternalLinks/ExternalLinks.h \
../Source/XlsxFormat/Worksheets/Sparkline.h
unix {
target.path = /usr/lib
INSTALLS += target
......
#include "DrawingExt.h"
#include "../../XlsxFormat/Worksheets/Sparkline.h"
namespace OOX
{
namespace Drawing
{
void COfficeArtExtension::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ((m_oUri.IsInit()) && (*m_oUri == _T("{63B3BB69-23CF-44E3-9099-C40C66FF867C}") || *m_oUri == _T("{05C60535-1F16-4fd2-B633-F4F36F0B64E0}")))//2.2.6.2 Legacy Object Wrapper
{
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CString sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (sName == _T("compatExt"))//2.3.1.2 compatExt
{ //attributes spid -https://msdn.microsoft.com/en-us/library/hh657207(v=office.12).aspx
m_oCompatExt = oReader;
}
else if (sName == _T("sparklineGroups"))
{
m_oSparklineGroups = oReader;
}
}
}
else
{
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
}
CString COfficeArtExtension::toXML() const
{
return toXMLWithNS(_T("a:"));
}
CString COfficeArtExtension::toXMLWithNS(const CString& sNamespace) const
{
CString sResult = _T("<");
sResult += sNamespace;
sResult += _T("ext");
sResult += m_sAdditionalNamespace;
if ( m_oUri.IsInit() )
{
sResult += _T(" uri=\"");
sResult += m_oUri->GetString();
sResult += _T("\">");
}
else
sResult += _T(">");
if(m_oCompatExt.IsInit())
{
sResult += m_oCompatExt->toXML();
}
if(m_oSparklineGroups.IsInit())
{
XmlUtils::CStringWriter writer;
m_oSparklineGroups->toXML(writer);
sResult += writer.GetData();
}
sResult += _T("</");
sResult += sNamespace;
sResult += _T("ext>");
return sResult;
}
}
}
......@@ -7,19 +7,20 @@
namespace OOX
{
namespace Spreadsheet
{
class CSparklineGroups;
}
namespace Drawing
{
//--------------------------------------------------------------------------------
// COfficeArtExtension 20.1.2.2.14 (Part 1)
//--------------------------------------------------------------------------------
class COfficeArtExtension : public WritingElement
class CCompatExt : public WritingElement
{
public:
WritingElement_AdditionConstructors(COfficeArtExtension)
COfficeArtExtension()
WritingElement_AdditionConstructors(CCompatExt)
CCompatExt()
{
}
virtual ~COfficeArtExtension()
virtual ~CCompatExt()
{
}
......@@ -27,49 +28,64 @@ namespace OOX
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("uri"), m_oUri );
//todo
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ((m_oUri.IsInit()) && (*m_oUri == _T("{63B3BB69-23CF-44E3-9099-C40C66FF867C}")))//2.2.6.2 Legacy Object Wrapper
{
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CString sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (sName == _T("compatExt"))//2.3.1.2 compatExt
{ //attributes spid -https://msdn.microsoft.com/en-us/library/hh657207(v=office.12).aspx
ReadAttributes( oReader );
}
}
}
else
{
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual CString toXML() const
{
CString sResult = _T("<a:ext ");
if ( m_oUri.IsInit() )
{
sResult += _T("uri=\"");
sResult += m_oUri->GetString();
sResult += _T("\">");
}
else
sResult += _T(">");
return _T("");
}
virtual EElementType getType() const
{
return OOX::et_a_compatExt;
}
sResult += _T("</a:ext>");
private:
return sResult;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
WritingElement_ReadAttributes_Start_No_NS( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("spid"), m_sSpId )
WritingElement_ReadAttributes_End( oReader )
}
public:
// Attributes
nullable<CString> m_sSpId;
// Childs
};
//--------------------------------------------------------------------------------
// COfficeArtExtension 20.1.2.2.14 (Part 1)
//--------------------------------------------------------------------------------
class COfficeArtExtension : public WritingElement
{
public:
WritingElement_AdditionConstructors(COfficeArtExtension)
COfficeArtExtension()
{
}
virtual ~COfficeArtExtension()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("uri"), m_oUri );
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
virtual CString toXML() const;
CString toXMLWithNS(const CString& sNamespace) const;
virtual EElementType getType() const
{
return OOX::et_a_ext;
......@@ -82,7 +98,6 @@ namespace OOX
// Читаем атрибуты
WritingElement_ReadAttributes_Start_No_NS( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("uri"), m_oUri )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("spid"), m_sSpId )
WritingElement_ReadAttributes_End( oReader )
}
......@@ -90,9 +105,11 @@ namespace OOX
// Attributes
nullable<CString> m_oUri;
nullable<CString> m_sSpId;
CString m_sAdditionalNamespace;
// Childs
nullable<CCompatExt> m_oCompatExt;
nullable<OOX::Spreadsheet::CSparklineGroups> m_oSparklineGroups;
};
//--------------------------------------------------------------------------------
// COfficeArtExtensionList 20.1.2.2.15 (Part 1)
......@@ -128,8 +145,8 @@ namespace OOX
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
CString sName = oReader.GetName();
if ( _T("a:ext") == sName )
CString sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("ext") == sName )
{
OOX::Drawing::COfficeArtExtension *oExt = new OOX::Drawing::COfficeArtExtension(oReader);
if (oExt) m_arrExt.push_back( oExt );
......@@ -137,16 +154,24 @@ namespace OOX
}
}
virtual CString toXML() const
{
return toXMLWithNS(_T("a:"));
}
CString toXMLWithNS(const CString& sNamespace) const
{
CString sResult = _T("<a:extLst>");
CString sResult = _T("<");
sResult += sNamespace;
sResult += _T("extLst>");
for ( unsigned int nIndex = 0; nIndex < m_arrExt.size(); nIndex++ )
{
if (m_arrExt[nIndex])
sResult += m_arrExt[nIndex]->toXML();
sResult += m_arrExt[nIndex]->toXMLWithNS(sNamespace);
}
sResult += _T("</a:extLst>");
sResult += _T("</");
sResult += sNamespace;
sResult += _T("extLst>");
return sResult;
}
......
......@@ -163,6 +163,7 @@ namespace OOX
et_a_effectRef, // <a:effectRef>
et_a_effectStyle, // <a:effectStyle>
et_a_effectStyleLst, // <a:effectStyleLst>
et_a_compatExt,
et_a_ext, // <a:ext>
et_a_extLst, // <a:extLst>
et_a_extraClrScheme, // <a:extraClrScheme>
......
......@@ -420,6 +420,9 @@ namespace OOX{
class AlternateContentChoice;
class AlternateContentFallback;
class CTextProperties;
bool FromXml_ST_DispBlanksAs(CString& val, ST_DispBlanksAs& eOut);
bool ToXml_ST_DispBlanksAs(ST_DispBlanksAs& val, CString& sOut);
///////////////////////////////////////////////////
class CT_extLst
{
......
#pragma once
#pragma once
#ifndef OOX_CELLANCHOR_FILE_INCLUDE_H_
#define OOX_CELLANCHOR_FILE_INCLUDE_H_
......@@ -101,11 +101,11 @@ namespace OOX
if ((m_oGraphicFrame.IsInit()) && (m_oGraphicFrame->m_oChartGraphic.IsInit()) &&
(m_oGraphicFrame->m_oChartGraphic->m_oGraphicData.IsInit()))
{
// ( )
//вытащим выше ссылку на объект (для удобства)
m_sSpId = m_oGraphicFrame->m_oChartGraphic->m_oGraphicData->m_sSpId;
}
}
// ... xml !!!!
//Так читать правильнее ... но для совместимости нужно хранить и все xml !!!!
//else if (_T("pic") == sName )
// m_oPicture = oReader;
//else if (_T("sp") == sName)
......@@ -121,7 +121,7 @@ namespace OOX
m_oXml = oReader.GetOuterXml();
{
XmlUtils::CXmlLiteReader oShapeReader;
// xml-
//сформируем полноценную xml-строку
CString xmlString;// = L"<?xml version=\"1.0\"?>";// encoding=\"UTF-8\"
xmlString += L"<root ";
xmlString += L"xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ";
......@@ -141,19 +141,20 @@ namespace OOX
if (_T("pic") == sName)
m_oPicture = oShapeReader;
else if (_T("sp") == sName)
{ // , , xml
// pptx:DrawingObjectConverter -
{ //тут может быть не полноценный объект, а ссылка на него, следовательно и xml что выше для
// pptx:DrawingObjectConverter будет не правильная - сотрем ее
m_oShape = oShapeReader;
if ((m_oShape.IsInit()) && (m_oShape->m_oNvSpPr.IsInit()) &&
(m_oShape->m_oNvSpPr->m_oCNvPr.IsInit()) && (m_oShape->m_oNvSpPr->m_oCNvPr->m_oExtLst.IsInit()))
{
for (int i=0; i < m_oShape->m_oNvSpPr->m_oCNvPr->m_oExtLst->m_arrExt.size();i++)
{
if (m_oShape->m_oNvSpPr->m_oCNvPr->m_oExtLst->m_arrExt[i]->m_sSpId.IsInit())
OOX::Drawing::COfficeArtExtension* pExt = m_oShape->m_oNvSpPr->m_oCNvPr->m_oExtLst->m_arrExt[i];
if (pExt->m_oCompatExt.IsInit() && pExt->m_oCompatExt->m_sSpId.IsInit())
{
// -> "" ( )
//собственно это и есть ссылка на обеъект -> переложим ее "повыше" (для удобства)
m_oXml.reset();
m_sSpId = m_oShape->m_oNvSpPr->m_oCNvPr->m_oExtLst->m_arrExt[i]->m_sSpId;
m_sSpId = pExt->m_oCompatExt->m_sSpId;
}
}
}
......@@ -167,8 +168,8 @@ namespace OOX
else if ( _T("AlternateContent") == sName)
{
//Demo-2010WinterOlympics2.xlsx
// - ...
//todooo fallback, (a14, ..)
//вариативность на разные версии офиса части параметров - кстати ... это может встретиться в ЛЮБОМ месте
//todooo сделать чтение не обязательно fallback, по выбору версии нужной нам (a14, ..)
{
nCurDepth++;
while( oReader.ReadNextSiblingNode( nCurDepth ) )
......@@ -242,10 +243,10 @@ namespace OOX
nullable<OOX::Spreadsheet::CShape> m_oShape;
nullable<OOX::Spreadsheet::CConnShape> m_oConnShape;
// pptx:ObjectDrawingConverter
// для pptx:ObjectDrawingConverter
nullable<CString> m_oXml;
//
//для удобства
nullable<CString> m_sSpId;
};
} //Spreadsheet
......
......@@ -2283,5 +2283,77 @@ namespace SimpleTypes
SimpleType_Operator_Equal (ST_CfvoType)
};
enum ESparklineType
{
Line = 0,
Column = 1,
Stacked = 2
};
template<ESparklineType eDefValue = Line>
class ST_SparklineType : public CSimpleType<ESparklineType, eDefValue>
{
public:
ST_SparklineType() {}
virtual ESparklineType FromString(CString &sValue)
{
if(_T("line") == sValue) this->m_eValue = Line;
else if(_T("column") == sValue) this->m_eValue = Column;
else if(_T("stacked") == sValue) this->m_eValue = Stacked;
else this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual CString ToString () const
{
switch(this->m_eValue)
{
case Line: return _T("line"); break;
case Column: return _T("column"); break;
case Stacked: return _T("stacked"); break;
default : return _T("line");
}
}
SimpleType_FromString (ESparklineType)
SimpleType_Operator_Equal (ST_SparklineType)
};
enum ESparklineAxisMinMax
{
Individual = 0,
Group = 1,
Custom = 2
};
template<ESparklineAxisMinMax eDefValue = Individual>
class ST_SparklineAxisMinMax : public CSimpleType<ESparklineAxisMinMax, eDefValue>
{
public:
ST_SparklineAxisMinMax() {}
virtual ESparklineAxisMinMax FromString(CString &sValue)
{
if(_T("individual") == sValue) this->m_eValue = Individual;
else if(_T("group") == sValue) this->m_eValue = Group;
else if(_T("custom") == sValue) this->m_eValue = Custom;
else this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual CString ToString () const
{
switch(this->m_eValue)
{
case Individual: return _T("individual"); break;
case Group: return _T("group"); break;
case Custom: return _T("custom"); break;
default: return _T("individual");
}
}
SimpleType_FromString (ESparklineAxisMinMax)
SimpleType_Operator_Equal (ST_SparklineAxisMinMax)
};
};// Spreadsheet
} // SimpleTypes
This diff is collapsed.
......@@ -124,6 +124,8 @@ namespace OOX
m_oLegacyDrawingWorksheet = oReader;
else if (_T("sheetPr") == sName)
m_oSheetPr = oReader;
else if (_T("extLst") == sName)
m_oExtLst = oReader;
}
}
if(m_oLegacyDrawingWorksheet.IsInit() && m_oLegacyDrawingWorksheet->m_oId.IsInit())
......@@ -336,6 +338,8 @@ namespace OOX
m_oLegacyDrawingWorksheet->toXML(sXml);
if(m_oTableParts.IsInit())
m_oTableParts->toXML(sXml);
if(m_oExtLst.IsInit())
sXml.WriteString(m_oExtLst->toXMLWithNS(_T("")));
sXml.WriteString(_T("</worksheet>"));
CDirectory::SaveToFile( oPath.GetPath(), sXml.GetData() );
......@@ -503,6 +507,8 @@ namespace OOX
std::map<CString, CCommentItem*> m_mapComments;
std::vector<OOX::Spreadsheet::CConditionalFormatting*> m_arrConditionalFormatting;
nullable<OOX::Spreadsheet::CSheetPr> m_oSheetPr;
nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;
};
} //Spreadsheet
} // namespace OOX
......
......@@ -322,7 +322,12 @@ namespace Spreadsheet
et_ConnectionNonVisualGraphicFrameProps,
et_GraphicChart,
et_ChartTextProperties,
et_ChartRichText
et_ChartRichText,
et_SparklineGroups,
et_SparklineGroup,
et_Sparklines,
et_Sparkline
};
class WritingElement
......
......@@ -200,7 +200,8 @@ namespace BinXlsxRW
ConditionalFormatting = 21,
SheetViews = 22,
SheetView = 23,
SheetPr = 24
SheetPr = 24,
SparklineGroups = 25
};}
namespace c_oSerWorksheetPropTypes{enum c_oSerWorksheetPropTypes
{
......@@ -726,6 +727,41 @@ namespace BinXlsxRW
TabColor = 9
};}
namespace c_oSer_Sparkline{enum c_oSer_Sparkline
{
SparklineGroup = 0,
ManualMax = 1,
ManualMin = 2,
LineWeight = 3,
Type = 4,
DateAxis = 5,
DisplayEmptyCellsAs = 6,
Markers = 7,
High = 8,
Low = 9,
First = 10,
Last = 11,
Negative = 12,
DisplayXAxis = 13,
DisplayHidden = 14,
MinAxisType = 15,
MaxAxisType = 16,
RightToLeft = 17,
ColorSeries = 18,
ColorNegative = 19,
ColorAxis = 20,
ColorMarkers = 21,
ColorFirst = 22,
ColorLast = 23,
ColorHigh = 24,
ColorLow = 25,
Ref = 26,
Sparklines = 27,
Sparkline = 28,
SparklineRef = 29,
SparklineSqRef = 30
};}
}
#endif //
This diff is collapsed.
//#include "stdafx.h"
//#include "stdafx.h"
#include "CommonWriter.h"
#include "../Common/BinReaderWriterDefines.h"
......@@ -18,7 +18,7 @@ namespace BinXlsxRW {
}
int BinaryCommonWriter::WriteItemWithLengthStart()
{
//
//Запоминаем позицию чтобы в конце записать туда длину
int nStartPos = m_oStream.GetPosition();
m_oStream.Skip(4);
return nStartPos;
......@@ -31,7 +31,7 @@ namespace BinXlsxRW {
m_oStream.WriteLONG(nEnd - nStart - 4);
m_oStream.SetPosition(nEnd);
}
void BinaryCommonWriter::WriteColor(const OOX::Spreadsheet::CColor& color, OOX::Spreadsheet::CIndexedColors* pIndexedColors, OOX::CTheme* theme)
void BinaryCommonWriter::WriteColor(const OOX::Spreadsheet::CColor& color, OOX::Spreadsheet::CIndexedColors* pIndexedColors)
{
if(color.m_oAuto.IsInit() && color.m_oAuto->ToBool())
{
......
#ifndef COMMON_WRITER
#ifndef COMMON_WRITER
#define COMMON_WRITER
#include "../../ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h"
......@@ -14,7 +14,7 @@ namespace BinXlsxRW {
void WriteItemEnd(int nStart);
int WriteItemWithLengthStart();
void WriteItemWithLengthEnd(int nStart);
void WriteColor(const OOX::Spreadsheet::CColor& color, OOX::Spreadsheet::CIndexedColors* pIndexedColors, OOX::CTheme* theme);
void WriteColor(const OOX::Spreadsheet::CColor& color, OOX::Spreadsheet::CIndexedColors* pIndexedColors);
void WriteBytesArray(BYTE* pData, long nDataSize);
};
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment