Skip to content

Commit

Permalink
change function of qt5.0 in chart. etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
j2doll committed Sep 15, 2019
1 parent d2f7a90 commit 449c43c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 55 deletions.
39 changes: 20 additions & 19 deletions QXlsx/source/xlsxchart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ void Chart::saveToXmlFile(QIODevice *device) const
//
// chartSpace is the root node, which contains an element defining the chart,
// and an element defining the print settings for the chart.

writer.writeStartElement(QStringLiteral("c:chartSpace"));

writer.writeAttribute(QStringLiteral("xmlns:c"),
Expand All @@ -236,6 +237,7 @@ void Chart::saveToXmlFile(QIODevice *device) const
* It then has a plot area, which defines a layout and contains an element
* that corresponds to, and defines, the type of chart.
*/

d->saveXmlChart(writer);

writer.writeEndElement();// c:chartSpace
Expand Down Expand Up @@ -366,7 +368,6 @@ bool ChartPrivate::loadXmlPlotArea(QXmlStreamReader &reader)

bool ChartPrivate::loadXmlPlotAreaElement(QXmlStreamReader &reader)
{

if (reader.name() == QLatin1String("layout"))
{
//!ToDo
Expand All @@ -375,30 +376,30 @@ bool ChartPrivate::loadXmlPlotAreaElement(QXmlStreamReader &reader)
else if (reader.name().endsWith(QLatin1String("Chart")))
{
// for pieChart, barChart, ... (choose one)
if ( ! loadXmlXxxChart(reader) )
if ( !loadXmlXxxChart(reader) )
{
qDebug() << "[debug] failed to load chart";
return false;
}
}
else if (reader.name() == QLatin1String("catAx")) // choose one : catAx, dateAx, serAx, valAx
{
qDebug() << "loadXmlAxisCatAx()";
// qDebug() << "loadXmlAxisCatAx()";
loadXmlAxisCatAx(reader);
}
else if (reader.name() == QLatin1String("dateAx")) // choose one : catAx, dateAx, serAx, valAx
{
qDebug() << "loadXmlAxisDateAx()";
// qDebug() << "loadXmlAxisDateAx()";
loadXmlAxisDateAx(reader);
}
else if (reader.name() == QLatin1String("serAx")) // choose one : catAx, dateAx, serAx, valAx
{
qDebug() << "loadXmlAxisSerAx()";
// qDebug() << "loadXmlAxisSerAx()";
loadXmlAxisSerAx(reader);
}
else if (reader.name() == QLatin1String("valAx")) // choose one : catAx, dateAx, serAx, valAx
{
qDebug() << "loadXmlAxisValAx()";
// qDebug() << "loadXmlAxisValAx()";
loadXmlAxisValAx(reader);
}
else if (reader.name() == QLatin1String("dTable"))
Expand Down Expand Up @@ -1074,11 +1075,17 @@ void ChartPrivate::saveXmlSer(QXmlStreamWriter &writer, XlsxSeries *ser, int id)
writer.writeEmptyElement(QStringLiteral("c:order"));
writer.writeAttribute(QStringLiteral("val"), QString::number(id));

if (!ser->axDataSource_numRef.isEmpty()) {
if (!ser->axDataSource_numRef.isEmpty())
{
if (chartType == Chart::CT_ScatterChart || chartType == Chart::CT_BubbleChart)
{
writer.writeStartElement(QStringLiteral("c:xVal"));
}
else
{
writer.writeStartElement(QStringLiteral("c:cat"));
}

writer.writeStartElement(QStringLiteral("c:numRef"));
writer.writeTextElement(QStringLiteral("c:f"), ser->axDataSource_numRef);
writer.writeEndElement();//c:numRef
Expand Down Expand Up @@ -1235,13 +1242,10 @@ bool ChartPrivate::loadXmlAxisEG_AxShared(QXmlStreamReader &reader, XlsxAxis* ax
{
// qDebug() << "[debug]" << QTime::currentTime() << reader.name().toString();

if ( reader.name() == QLatin1String("axId") )
if ( reader.name() == QLatin1String("axId") ) // mandatory element
{
// mandatory element

// int axId = reader.attributes().value("val").toInt();
int axId = reader.attributes().value("val").string()->toInt(); // for Qt5.0

// dev57
uint axId = reader.attributes().value("val").toUInt(); // for Qt5.0
axis->axisId = axId;
}
else if ( reader.name() == QLatin1String("scaling") )
Expand Down Expand Up @@ -1307,13 +1311,10 @@ bool ChartPrivate::loadXmlAxisEG_AxShared(QXmlStreamReader &reader, XlsxAxis* ax
{
//!TODO
}
else if ( reader.name() == QLatin1String("crossAx") )
else if ( reader.name() == QLatin1String("crossAx") ) // mandatory element
{
// mandatory element

// int crossAx = reader.attributes().value(QLatin1String("val")).toInt();
int crossAx = reader.attributes().value(QLatin1String("val")).string()->toInt(); // for Qt5.0

// dev57
uint crossAx = reader.attributes().value(QLatin1String("val")).toUInt(); // for Qt5.0
axis->crossAx = crossAx;
}
else if ( reader.name() == QLatin1String("crosses") )
Expand Down
32 changes: 6 additions & 26 deletions QXlsx/source/xlsxchartsheet.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
/****************************************************************************
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
// xlsxchartsheet.cpp

#include "xlsxchartsheet.h"
#include "xlsxchartsheet_p.h"
#include "xlsxworkbook.h"
Expand All @@ -30,6 +8,7 @@
#include "xlsxdrawinganchor_p.h"
#include "xlsxchart.h"

#include <QtGlobal>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QDir>
Expand All @@ -56,11 +35,12 @@ ChartsheetPrivate::~ChartsheetPrivate()
* \internal
*/
Chartsheet::Chartsheet(const QString &name, int id, Workbook *workbook, CreateFlag flag)
:AbstractSheet(name, id, workbook, new ChartsheetPrivate(this, flag))
: AbstractSheet( name, id, workbook, new ChartsheetPrivate(this, flag) )
{
setSheetType(ST_ChartSheet);

if (flag == Chartsheet::F_NewFromScratch) {
if (flag == Chartsheet::F_NewFromScratch)
{
d_func()->drawing = QSharedPointer<Drawing>(new Drawing(this, flag));

DrawingAbsoluteAnchor *anchor = new DrawingAbsoluteAnchor(drawing(), DrawingAnchor::Picture);
Expand Down
2 changes: 1 addition & 1 deletion TestExcel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, char *argv[])
readStyle();
calendar();
chart();
chartsheet();
chartsheet();
datavalidation();
definename();
demo();
Expand Down
11 changes: 2 additions & 9 deletions TestExcel/richtext.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// richtext.cpp

// QXlsx
// MIT License
// https://github.com/j2doll/QXlsx
//
// QtXlsx
// https://github.com/dbzhang800/QtXlsxWriter
// http://qtxlsx.debao.me/
// MIT License

#include <QtGlobal>
#include <QtCore>

#include "xlsxdocument.h"
#include "xlsxrichstring.h"
#include "xlsxworkbook.h"
Expand Down

0 comments on commit 449c43c

Please sign in to comment.