mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-16 04:42:53 +08:00
Add and apply clang-format
This project has no standard on coding style, some files use tab, others space, and new Merge Requests usually break the current formatting with this clang-format we can easy this.
This commit is contained in:
parent
499901003f
commit
db608768a3
93
.clang-format
Normal file
93
.clang-format
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# .clang-format for Cutelyst projects 2023-04-18
|
||||||
|
# Tries to be close to Qt coding style
|
||||||
|
# but meh for ASql lambdas which LambdaBodyIndentation ins't enough
|
||||||
|
---
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: 'false'
|
||||||
|
AlignConsecutiveAssignments: 'true'
|
||||||
|
AlignConsecutiveDeclarations: 'false'
|
||||||
|
AllowShortEnumsOnASingleLine: 'true'
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
AlignOperands: 'true'
|
||||||
|
AlignTrailingComments: 'true'
|
||||||
|
AllowAllArgumentsOnNextLine: 'true'
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: 'false'
|
||||||
|
AllowShortBlocksOnASingleLine: 'false'
|
||||||
|
AllowShortCaseLabelsOnASingleLine: 'false'
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: Inline
|
||||||
|
AllowShortLoopsOnASingleLine: 'false'
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: 'false'
|
||||||
|
AlwaysBreakTemplateDeclarations: 'Yes'
|
||||||
|
BinPackArguments: 'false'
|
||||||
|
BinPackParameters: 'false'
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: 'true'
|
||||||
|
AfterClass: 'true'
|
||||||
|
AfterEnum: 'false'
|
||||||
|
AfterFunction: true
|
||||||
|
SplitEmptyFunction: 'true'
|
||||||
|
SplitEmptyRecord: 'true'
|
||||||
|
SplitEmptyNamespace: 'true'
|
||||||
|
BreakBeforeTernaryOperators: 'true'
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: BeforeComma
|
||||||
|
BreakStringLiterals: 'true'
|
||||||
|
CompactNamespaces: 'false'
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
|
||||||
|
ConstructorInitializerIndentWidth: '4'
|
||||||
|
ContinuationIndentWidth: '4'
|
||||||
|
ColumnLimit: 100
|
||||||
|
Cpp11BracedListStyle: 'true'
|
||||||
|
FixNamespaceComments: 'true'
|
||||||
|
ForEachMacros:
|
||||||
|
- forever # avoids { wrapped to next line
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<Q.*'
|
||||||
|
Priority: 200
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IndentAccessModifiers: 'false'
|
||||||
|
IndentCaseLabels: 'false'
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWidth: '4'
|
||||||
|
IndentWrappedFunctionNames: 'true'
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: 'true'
|
||||||
|
Language: Cpp
|
||||||
|
LambdaBodyIndentation: OuterScope
|
||||||
|
NamespaceIndentation: None
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: 'true'
|
||||||
|
SortIncludes: 'true'
|
||||||
|
SortUsingDeclarations: 'false'
|
||||||
|
SpaceAfterCStyleCast: 'true'
|
||||||
|
SpaceAfterLogicalNot: 'false'
|
||||||
|
SpaceAfterTemplateKeyword: 'true'
|
||||||
|
SpaceBeforeAssignmentOperators: 'true'
|
||||||
|
SpaceBeforeCpp11BracedList: 'false'
|
||||||
|
SpaceBeforeCtorInitializerColon: 'true'
|
||||||
|
SpaceBeforeInheritanceColon: 'true'
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: 'true'
|
||||||
|
SpaceInEmptyParentheses: 'false'
|
||||||
|
SpacesInAngles: 'false'
|
||||||
|
SpacesInCStyleCastParentheses: 'false'
|
||||||
|
SpacesInContainerLiterals: 'false'
|
||||||
|
SpacesInParentheses: 'false'
|
||||||
|
SpacesInSquareBrackets: 'false'
|
||||||
|
Standard: Cpp11
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- C_ATTR
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
...
|
@ -1,19 +1,19 @@
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
@ -22,12 +22,11 @@ extern int test(QVector<QVariant> params);
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
QVector<QVariant> testParams;
|
QVector<QVariant> testParams;
|
||||||
int ret = test(testParams);
|
int ret = test(testParams);
|
||||||
// qDebug() << "test return value : " << ret;
|
// qDebug() << "test return value : " << ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
// test.cpp
|
// test.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
int test( QVector<QVariant> params );
|
int test(QVector<QVariant> params);
|
||||||
int test1( QVector<QVariant> params );
|
int test1(QVector<QVariant> params);
|
||||||
int test2( QVector<QVariant> params );
|
int test2(QVector<QVariant> params);
|
||||||
|
|
||||||
int test( QVector<QVariant> params )
|
int test(QVector<QVariant> params)
|
||||||
{
|
{
|
||||||
// return test1( params );
|
// return test1( params );
|
||||||
return test2( params );
|
return test2(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test1( QVector<QVariant> params )
|
int test1(QVector<QVariant> params)
|
||||||
{
|
{
|
||||||
qDebug() << "[debug] current path : " << QDir::currentPath();
|
qDebug() << "[debug] current path : " << QDir::currentPath();
|
||||||
|
|
||||||
@ -36,33 +36,33 @@ int test1( QVector<QVariant> params )
|
|||||||
|
|
||||||
Document doc;
|
Document doc;
|
||||||
|
|
||||||
doc.write( "A1", QVariant(QDateTime::currentDateTimeUtc()) );
|
doc.write("A1", QVariant(QDateTime::currentDateTimeUtc()));
|
||||||
doc.write( "A2", QVariant(double(10.5)) );
|
doc.write("A2", QVariant(double(10.5)));
|
||||||
doc.write( "A3", QVariant(QDate(2019, 10, 9)) );
|
doc.write("A3", QVariant(QDate(2019, 10, 9)));
|
||||||
doc.write( "A4", QVariant(QTime(10, 9, 5)) );
|
doc.write("A4", QVariant(QTime(10, 9, 5)));
|
||||||
doc.write( "A5", QVariant((int) 40000) );
|
doc.write("A5", QVariant((int) 40000));
|
||||||
|
|
||||||
qDebug() << "doc.read()";
|
qDebug() << "doc.read()";
|
||||||
qDebug() << doc.read( 1, 1 ).type() << doc.read( 1, 1 );
|
qDebug() << doc.read(1, 1).type() << doc.read(1, 1);
|
||||||
qDebug() << doc.read( 2, 1 ).type() << doc.read( 2, 1 );
|
qDebug() << doc.read(2, 1).type() << doc.read(2, 1);
|
||||||
qDebug() << doc.read( 3, 1 ).type() << doc.read( 3, 1 );
|
qDebug() << doc.read(3, 1).type() << doc.read(3, 1);
|
||||||
qDebug() << doc.read( 4, 1 ).type() << doc.read( 4, 1 );
|
qDebug() << doc.read(4, 1).type() << doc.read(4, 1);
|
||||||
qDebug() << doc.read( 5, 1 ).type() << doc.read( 5, 1 );
|
qDebug() << doc.read(5, 1).type() << doc.read(5, 1);
|
||||||
qDebug() << "\n";
|
qDebug() << "\n";
|
||||||
|
|
||||||
qDebug() << "doc.cellAt()->value()";
|
qDebug() << "doc.cellAt()->value()";
|
||||||
qDebug() << doc.cellAt( 1, 1 )->value().type() << doc.cellAt( 1, 1 )->value();
|
qDebug() << doc.cellAt(1, 1)->value().type() << doc.cellAt(1, 1)->value();
|
||||||
qDebug() << doc.cellAt( 2, 1 )->value().type() << doc.cellAt( 2, 1 )->value();
|
qDebug() << doc.cellAt(2, 1)->value().type() << doc.cellAt(2, 1)->value();
|
||||||
qDebug() << doc.cellAt( 3, 1 )->value().type() << doc.cellAt( 3, 1 )->value();
|
qDebug() << doc.cellAt(3, 1)->value().type() << doc.cellAt(3, 1)->value();
|
||||||
qDebug() << doc.cellAt( 4, 1 )->value().type() << doc.cellAt( 4, 1 )->value();
|
qDebug() << doc.cellAt(4, 1)->value().type() << doc.cellAt(4, 1)->value();
|
||||||
qDebug() << doc.cellAt( 5, 1 )->value().type() << doc.cellAt( 5, 1 )->value();
|
qDebug() << doc.cellAt(5, 1)->value().type() << doc.cellAt(5, 1)->value();
|
||||||
|
|
||||||
doc.saveAs("datetime.xlsx");
|
doc.saveAs("datetime.xlsx");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test2( QVector<QVariant> params )
|
int test2(QVector<QVariant> params)
|
||||||
{
|
{
|
||||||
qDebug() << "[debug] current path : " << QDir::currentPath();
|
qDebug() << "[debug] current path : " << QDir::currentPath();
|
||||||
|
|
||||||
@ -72,26 +72,26 @@ int test2( QVector<QVariant> params )
|
|||||||
|
|
||||||
Document doc;
|
Document doc;
|
||||||
|
|
||||||
doc.write( "A1", QVariant(QDateTime::currentDateTimeUtc()) );
|
doc.write("A1", QVariant(QDateTime::currentDateTimeUtc()));
|
||||||
doc.write( "A2", QVariant(double(10.5)) );
|
doc.write("A2", QVariant(double(10.5)));
|
||||||
doc.write( "A3", QVariant(QDate(2019, 10, 9)) );
|
doc.write("A3", QVariant(QDate(2019, 10, 9)));
|
||||||
doc.write( "A4", QVariant(QTime(10, 9, 5)) );
|
doc.write("A4", QVariant(QTime(10, 9, 5)));
|
||||||
doc.write( "A5", QVariant((int) 40000) );
|
doc.write("A5", QVariant((int) 40000));
|
||||||
|
|
||||||
qDebug() << "doc.read()";
|
qDebug() << "doc.read()";
|
||||||
qDebug() << doc.read( 1, 1 ).type() << doc.read( 1, 1 );
|
qDebug() << doc.read(1, 1).type() << doc.read(1, 1);
|
||||||
qDebug() << doc.read( 2, 1 ).type() << doc.read( 2, 1 );
|
qDebug() << doc.read(2, 1).type() << doc.read(2, 1);
|
||||||
qDebug() << doc.read( 3, 1 ).type() << doc.read( 3, 1 );
|
qDebug() << doc.read(3, 1).type() << doc.read(3, 1);
|
||||||
qDebug() << doc.read( 4, 1 ).type() << doc.read( 4, 1 );
|
qDebug() << doc.read(4, 1).type() << doc.read(4, 1);
|
||||||
qDebug() << doc.read( 5, 1 ).type() << doc.read( 5, 1 );
|
qDebug() << doc.read(5, 1).type() << doc.read(5, 1);
|
||||||
qDebug() << "\n";
|
qDebug() << "\n";
|
||||||
|
|
||||||
qDebug() << "doc.cellAt()->value()";
|
qDebug() << "doc.cellAt()->value()";
|
||||||
qDebug() << doc.cellAt( 1, 1 )->value().type() << doc.cellAt( 1, 1 )->value();
|
qDebug() << doc.cellAt(1, 1)->value().type() << doc.cellAt(1, 1)->value();
|
||||||
qDebug() << doc.cellAt( 2, 1 )->value().type() << doc.cellAt( 2, 1 )->value();
|
qDebug() << doc.cellAt(2, 1)->value().type() << doc.cellAt(2, 1)->value();
|
||||||
qDebug() << doc.cellAt( 3, 1 )->value().type() << doc.cellAt( 3, 1 )->value();
|
qDebug() << doc.cellAt(3, 1)->value().type() << doc.cellAt(3, 1)->value();
|
||||||
qDebug() << doc.cellAt( 4, 1 )->value().type() << doc.cellAt( 4, 1 )->value();
|
qDebug() << doc.cellAt(4, 1)->value().type() << doc.cellAt(4, 1)->value();
|
||||||
qDebug() << doc.cellAt( 5, 1 )->value().type() << doc.cellAt( 5, 1 )->value();
|
qDebug() << doc.cellAt(5, 1)->value().type() << doc.cellAt(5, 1)->value();
|
||||||
qDebug() << "\n";
|
qDebug() << "\n";
|
||||||
|
|
||||||
doc.saveAs("datetime.xlsx");
|
doc.saveAs("datetime.xlsx");
|
||||||
@ -99,81 +99,78 @@ int test2( QVector<QVariant> params )
|
|||||||
qDebug() << "\n\ndoc2\n";
|
qDebug() << "\n\ndoc2\n";
|
||||||
|
|
||||||
Document doc2("datetime.xlsx");
|
Document doc2("datetime.xlsx");
|
||||||
if ( !doc2.load() )
|
if (!doc2.load()) {
|
||||||
{
|
qWarning() << "failed to load datetime.xlsx";
|
||||||
qWarning() << "failed to load datetime.xlsx" ;
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
qDebug() << "\n\n";
|
qDebug() << "\n\n";
|
||||||
|
|
||||||
doc2.write( "A6", QVariant(QDateTime::currentDateTimeUtc()) );
|
doc2.write("A6", QVariant(QDateTime::currentDateTimeUtc()));
|
||||||
doc2.write( "A7", QVariant(double(10.5)) );
|
doc2.write("A7", QVariant(double(10.5)));
|
||||||
doc2.write( "A8", QVariant(QDate(2019, 10, 9)) );
|
doc2.write("A8", QVariant(QDate(2019, 10, 9)));
|
||||||
doc2.write( "A9", QVariant(QTime(10, 9, 5)) );
|
doc2.write("A9", QVariant(QTime(10, 9, 5)));
|
||||||
doc2.write( "A10", QVariant((int) 40000) );
|
doc2.write("A10", QVariant((int) 40000));
|
||||||
|
|
||||||
qDebug() << "doc2.read()";
|
qDebug() << "doc2.read()";
|
||||||
qDebug() << doc2.read( 1, 1 ).type() << doc2.read( 1, 1 );
|
qDebug() << doc2.read(1, 1).type() << doc2.read(1, 1);
|
||||||
qDebug() << doc2.read( 2, 1 ).type() << doc2.read( 2, 1 );
|
qDebug() << doc2.read(2, 1).type() << doc2.read(2, 1);
|
||||||
qDebug() << doc2.read( 3, 1 ).type() << doc2.read( 3, 1 );
|
qDebug() << doc2.read(3, 1).type() << doc2.read(3, 1);
|
||||||
qDebug() << doc2.read( 4, 1 ).type() << doc2.read( 4, 1 );
|
qDebug() << doc2.read(4, 1).type() << doc2.read(4, 1);
|
||||||
qDebug() << doc2.read( 5, 1 ).type() << doc2.read( 5, 1 );
|
qDebug() << doc2.read(5, 1).type() << doc2.read(5, 1);
|
||||||
qDebug() << doc2.read( 6, 1 ).type() << doc2.read( 6, 1 );
|
qDebug() << doc2.read(6, 1).type() << doc2.read(6, 1);
|
||||||
qDebug() << doc2.read( 7, 1 ).type() << doc2.read( 7, 1 );
|
qDebug() << doc2.read(7, 1).type() << doc2.read(7, 1);
|
||||||
qDebug() << doc2.read( 8, 1 ).type() << doc2.read( 8, 1 );
|
qDebug() << doc2.read(8, 1).type() << doc2.read(8, 1);
|
||||||
qDebug() << doc2.read( 9, 1 ).type() << doc2.read( 9, 1 );
|
qDebug() << doc2.read(9, 1).type() << doc2.read(9, 1);
|
||||||
qDebug() << doc2.read(10, 1 ).type() << doc2.read(10, 1 );
|
qDebug() << doc2.read(10, 1).type() << doc2.read(10, 1);
|
||||||
qDebug() << "\n";
|
qDebug() << "\n";
|
||||||
|
|
||||||
qDebug() << "doc2.cellAt()->value()";
|
qDebug() << "doc2.cellAt()->value()";
|
||||||
qDebug() << doc2.cellAt( 1, 1 )->value().type() << doc2.cellAt( 1, 1 )->value();
|
qDebug() << doc2.cellAt(1, 1)->value().type() << doc2.cellAt(1, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 2, 1 )->value().type() << doc2.cellAt( 2, 1 )->value();
|
qDebug() << doc2.cellAt(2, 1)->value().type() << doc2.cellAt(2, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 3, 1 )->value().type() << doc2.cellAt( 3, 1 )->value();
|
qDebug() << doc2.cellAt(3, 1)->value().type() << doc2.cellAt(3, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 4, 1 )->value().type() << doc2.cellAt( 4, 1 )->value();
|
qDebug() << doc2.cellAt(4, 1)->value().type() << doc2.cellAt(4, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 5, 1 )->value().type() << doc2.cellAt( 5, 1 )->value();
|
qDebug() << doc2.cellAt(5, 1)->value().type() << doc2.cellAt(5, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 6, 1 )->value().type() << doc2.cellAt( 6, 1 )->value();
|
qDebug() << doc2.cellAt(6, 1)->value().type() << doc2.cellAt(6, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 7, 1 )->value().type() << doc2.cellAt( 7, 1 )->value();
|
qDebug() << doc2.cellAt(7, 1)->value().type() << doc2.cellAt(7, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 8, 1 )->value().type() << doc2.cellAt( 8, 1 )->value();
|
qDebug() << doc2.cellAt(8, 1)->value().type() << doc2.cellAt(8, 1)->value();
|
||||||
qDebug() << doc2.cellAt( 9, 1 )->value().type() << doc2.cellAt( 9, 1 )->value();
|
qDebug() << doc2.cellAt(9, 1)->value().type() << doc2.cellAt(9, 1)->value();
|
||||||
qDebug() << doc2.cellAt(10, 1 )->value().type() << doc2.cellAt(10, 1 )->value();
|
qDebug() << doc2.cellAt(10, 1)->value().type() << doc2.cellAt(10, 1)->value();
|
||||||
doc2.saveAs("datetime2.xlsx");
|
doc2.saveAs("datetime2.xlsx");
|
||||||
|
|
||||||
qDebug() << "\n\ndoc3\n";
|
qDebug() << "\n\ndoc3\n";
|
||||||
|
|
||||||
Document doc3("datetime2.xlsx");
|
Document doc3("datetime2.xlsx");
|
||||||
if ( !doc3.load() )
|
if (!doc3.load()) {
|
||||||
{
|
qWarning() << "failed to load datetime2.xlsx";
|
||||||
qWarning() << "failed to load datetime2.xlsx" ;
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
qDebug() << "\n\n";
|
qDebug() << "\n\n";
|
||||||
|
|
||||||
qDebug() << "doc3.read()";
|
qDebug() << "doc3.read()";
|
||||||
qDebug() << doc3.read( 1, 1 ).type() << doc3.read( 1, 1 );
|
qDebug() << doc3.read(1, 1).type() << doc3.read(1, 1);
|
||||||
qDebug() << doc3.read( 2, 1 ).type() << doc3.read( 2, 1 );
|
qDebug() << doc3.read(2, 1).type() << doc3.read(2, 1);
|
||||||
qDebug() << doc3.read( 3, 1 ).type() << doc3.read( 3, 1 );
|
qDebug() << doc3.read(3, 1).type() << doc3.read(3, 1);
|
||||||
qDebug() << doc3.read( 4, 1 ).type() << doc3.read( 4, 1 );
|
qDebug() << doc3.read(4, 1).type() << doc3.read(4, 1);
|
||||||
qDebug() << doc3.read( 5, 1 ).type() << doc3.read( 5, 1 );
|
qDebug() << doc3.read(5, 1).type() << doc3.read(5, 1);
|
||||||
qDebug() << doc3.read( 6, 1 ).type() << doc3.read( 6, 1 );
|
qDebug() << doc3.read(6, 1).type() << doc3.read(6, 1);
|
||||||
qDebug() << doc3.read( 7, 1 ).type() << doc3.read( 7, 1 );
|
qDebug() << doc3.read(7, 1).type() << doc3.read(7, 1);
|
||||||
qDebug() << doc3.read( 8, 1 ).type() << doc3.read( 8, 1 );
|
qDebug() << doc3.read(8, 1).type() << doc3.read(8, 1);
|
||||||
qDebug() << doc3.read( 9, 1 ).type() << doc3.read( 9, 1 );
|
qDebug() << doc3.read(9, 1).type() << doc3.read(9, 1);
|
||||||
qDebug() << doc3.read(10, 1 ).type() << doc3.read(10, 1 );
|
qDebug() << doc3.read(10, 1).type() << doc3.read(10, 1);
|
||||||
qDebug() << "\n";
|
qDebug() << "\n";
|
||||||
|
|
||||||
qDebug() << "doc3.cellAt()->value()";
|
qDebug() << "doc3.cellAt()->value()";
|
||||||
qDebug() << doc3.cellAt( 1, 1 )->value().type() << doc3.cellAt( 1, 1 )->value();
|
qDebug() << doc3.cellAt(1, 1)->value().type() << doc3.cellAt(1, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 2, 1 )->value().type() << doc3.cellAt( 2, 1 )->value();
|
qDebug() << doc3.cellAt(2, 1)->value().type() << doc3.cellAt(2, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 3, 1 )->value().type() << doc3.cellAt( 3, 1 )->value();
|
qDebug() << doc3.cellAt(3, 1)->value().type() << doc3.cellAt(3, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 4, 1 )->value().type() << doc3.cellAt( 4, 1 )->value();
|
qDebug() << doc3.cellAt(4, 1)->value().type() << doc3.cellAt(4, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 5, 1 )->value().type() << doc3.cellAt( 5, 1 )->value();
|
qDebug() << doc3.cellAt(5, 1)->value().type() << doc3.cellAt(5, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 6, 1 )->value().type() << doc3.cellAt( 6, 1 )->value();
|
qDebug() << doc3.cellAt(6, 1)->value().type() << doc3.cellAt(6, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 7, 1 )->value().type() << doc3.cellAt( 7, 1 )->value();
|
qDebug() << doc3.cellAt(7, 1)->value().type() << doc3.cellAt(7, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 8, 1 )->value().type() << doc3.cellAt( 8, 1 )->value();
|
qDebug() << doc3.cellAt(8, 1)->value().type() << doc3.cellAt(8, 1)->value();
|
||||||
qDebug() << doc3.cellAt( 9, 1 )->value().type() << doc3.cellAt( 9, 1 )->value();
|
qDebug() << doc3.cellAt(9, 1)->value().type() << doc3.cellAt(9, 1)->value();
|
||||||
qDebug() << doc3.cellAt(10, 1 )->value().type() << doc3.cellAt(10, 1 )->value();
|
qDebug() << doc3.cellAt(10, 1)->value().type() << doc3.cellAt(10, 1)->value();
|
||||||
doc2.saveAs("datetime2.xlsx");
|
doc2.saveAs("datetime2.xlsx");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,39 +2,33 @@
|
|||||||
#ifndef DYNARRAY2D_H
|
#ifndef DYNARRAY2D_H
|
||||||
#define DYNARRAY2D_H
|
#define DYNARRAY2D_H
|
||||||
|
|
||||||
// Code from https://www.qtcentre.org/threads/31440-two-dimensional-array-size-determined-dynamically
|
// Code from
|
||||||
// Some code is fixed by j2doll
|
// https://www.qtcentre.org/threads/31440-two-dimensional-array-size-determined-dynamically Some
|
||||||
|
// code is fixed by j2doll
|
||||||
|
|
||||||
template <typename T> class DynArray2D
|
template <typename T>
|
||||||
|
class DynArray2D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynArray2D(int n, int m)
|
DynArray2D(int n, int m)
|
||||||
{
|
{
|
||||||
_n = n;
|
_n = n;
|
||||||
_array = new T*[n];
|
_array = new T *[n];
|
||||||
for(int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++) {
|
||||||
{
|
|
||||||
_array[i] = new T[m];
|
_array[i] = new T[m];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setValue(int n, int m, T v)
|
void setValue(int n, int m, T v) { _array[n][m] = v; }
|
||||||
{
|
|
||||||
_array[n][m] = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
T getValue(int n, int m)
|
T getValue(int n, int m) { return _array[n][m]; }
|
||||||
{
|
|
||||||
return _array[n][m];
|
|
||||||
}
|
|
||||||
|
|
||||||
~DynArray2D()
|
~DynArray2D()
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < _n ; i++)
|
for (int i = 0; i < _n; i++) {
|
||||||
{
|
delete[] _array[i];
|
||||||
delete [] _array[i];
|
|
||||||
}
|
}
|
||||||
delete [] _array;
|
delete[] _array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -42,5 +36,4 @@ protected:
|
|||||||
int _n;
|
int _n;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // DYNARRAY2D_H
|
#endif // DYNARRAY2D_H
|
||||||
|
@ -6,27 +6,25 @@
|
|||||||
|
|
||||||
#include "XlsxTableModel.h"
|
#include "XlsxTableModel.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
XlsxTableModel::XlsxTableModel(const QList<QString> &colTitle, QList<VLIST> data, QObject *parent)
|
XlsxTableModel::XlsxTableModel(const QList<QString> &colTitle, QList<VLIST> data, QObject *parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
// [1] set name of column
|
// [1] set name of column
|
||||||
|
|
||||||
m_colNames = colTitle;
|
m_colNames = colTitle;
|
||||||
m_roleCount = m_colNames.size();
|
m_roleCount = m_colNames.size();
|
||||||
|
|
||||||
// [2] set data
|
// [2] set data
|
||||||
|
|
||||||
for (int dc = 0; dc < data.size() ; dc++ )
|
for (int dc = 0; dc < data.size(); dc++) {
|
||||||
{
|
VLIST vList = data.at(dc);
|
||||||
VLIST vList = data.at(dc);
|
m_the_data.append(vList);
|
||||||
m_the_data.append( vList );
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XlsxTableModel::testData()
|
void XlsxTableModel::testData()
|
||||||
@ -42,9 +40,9 @@ void XlsxTableModel::testData()
|
|||||||
|
|
||||||
// set name of column
|
// set name of column
|
||||||
|
|
||||||
m_colNames.append( QString( "COL1" ) );
|
m_colNames.append(QString("COL1"));
|
||||||
m_colNames.append( QString( "COL2" ) );
|
m_colNames.append(QString("COL2"));
|
||||||
m_colNames.append( QString( "COL3" ) );
|
m_colNames.append(QString("COL3"));
|
||||||
|
|
||||||
m_roleCount = m_colNames.size();
|
m_roleCount = m_colNames.size();
|
||||||
|
|
||||||
@ -54,51 +52,49 @@ void XlsxTableModel::testData()
|
|||||||
list1.append(QVariant("Alpha"));
|
list1.append(QVariant("Alpha"));
|
||||||
list1.append(QVariant(10));
|
list1.append(QVariant(10));
|
||||||
list1.append(QVariant(100.0));
|
list1.append(QVariant(100.0));
|
||||||
m_the_data.append( list1 );
|
m_the_data.append(list1);
|
||||||
|
|
||||||
VLIST list2;
|
VLIST list2;
|
||||||
list2.append(QVariant("Beta"));
|
list2.append(QVariant("Beta"));
|
||||||
list2.append(QVariant(20));
|
list2.append(QVariant(20));
|
||||||
list2.append(QVariant(200.0));
|
list2.append(QVariant(200.0));
|
||||||
m_the_data.append( list2 );
|
m_the_data.append(list2);
|
||||||
|
|
||||||
VLIST list3;
|
VLIST list3;
|
||||||
list3.append(QVariant("Gamma"));
|
list3.append(QVariant("Gamma"));
|
||||||
list3.append(QVariant(30));
|
list3.append(QVariant(30));
|
||||||
list3.append(QVariant(300.0));
|
list3.append(QVariant(300.0));
|
||||||
m_the_data.append( list3 );
|
m_the_data.append(list3);
|
||||||
|
|
||||||
VLIST list4;
|
VLIST list4;
|
||||||
list4.append(QVariant("Delta"));
|
list4.append(QVariant("Delta"));
|
||||||
list4.append(QVariant(40));
|
list4.append(QVariant(40));
|
||||||
list4.append(QVariant(400.0));
|
list4.append(QVariant(400.0));
|
||||||
m_the_data.append( list4 );
|
m_the_data.append(list4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int XlsxTableModel::rowCount(const QModelIndex& parent) const
|
int XlsxTableModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
return m_the_data.size();
|
return m_the_data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int XlsxTableModel::columnCount(const QModelIndex& parent) const
|
int XlsxTableModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
return m_roleCount;
|
return m_roleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant XlsxTableModel::data(const QModelIndex& index, int role) const
|
QVariant XlsxTableModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
// current column & row
|
// current column & row
|
||||||
int col = index.column();
|
int col = index.column();
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
|
|
||||||
// check boudaries
|
// check boudaries
|
||||||
if ( col < 0 || columnCount() <= col ||
|
if (col < 0 || columnCount() <= col || row < 0 || rowCount() <= row) {
|
||||||
row < 0 || rowCount() <= row )
|
qDebug() << "[Warning]"
|
||||||
{
|
<< " col=" << col << ", row=" << row;
|
||||||
qDebug() << "[Warning]" << " col=" << col << ", row=" << row;
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,32 +103,28 @@ QVariant XlsxTableModel::data(const QModelIndex& index, int role) const
|
|||||||
QVariant ret;
|
QVariant ret;
|
||||||
int cmpRole;
|
int cmpRole;
|
||||||
|
|
||||||
for (int ic = 0; ic < m_the_data.size() ; ic++)
|
for (int ic = 0; ic < m_the_data.size(); ic++) {
|
||||||
{
|
if (row == ic) {
|
||||||
if ( row == ic )
|
|
||||||
{
|
|
||||||
QList<QVariant> vList = m_the_data.at(ic);
|
QList<QVariant> vList = m_the_data.at(ic);
|
||||||
for (int jc = 0; jc < vList.size() ; jc++ )
|
for (int jc = 0; jc < vList.size(); jc++) {
|
||||||
{
|
int plusOneRole = (int) (Qt::UserRole);
|
||||||
int plusOneRole = (int)(Qt::UserRole);
|
plusOneRole = plusOneRole + 1;
|
||||||
plusOneRole = plusOneRole + 1;
|
cmpRole = plusOneRole + jc;
|
||||||
cmpRole = plusOneRole + jc;
|
if (role == cmpRole) {
|
||||||
if ( role == cmpRole )
|
|
||||||
{
|
|
||||||
QVariant var = vList.at(jc);
|
QVariant var = vList.at(jc);
|
||||||
if ( ! var.isValid() ) var.setValue( QString("") ) ;
|
if (!var.isValid())
|
||||||
if ( var.isNull() ) var.setValue( QString("") ) ;
|
var.setValue(QString(""));
|
||||||
|
if (var.isNull())
|
||||||
|
var.setValue(QString(""));
|
||||||
ret = var;
|
ret = var;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug()
|
qDebug() << "data: "
|
||||||
<< "data: "
|
<< " col=" << col << ", row=" << row << ", role=" << role << ", cmpRole=" << cmpRole
|
||||||
<< " col=" << col << ", row=" << row
|
<< ", value=" << ret.toString();
|
||||||
<< ", role=" << role << ", cmpRole=" << cmpRole
|
|
||||||
<< ", value=" << ret.toString();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -141,11 +133,10 @@ QHash<int, QByteArray> XlsxTableModel::roleNames() const
|
|||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
for ( int ic = 0 ; ic < m_roleCount ; ic++)
|
for (int ic = 0; ic < m_roleCount; ic++) {
|
||||||
{
|
|
||||||
QString strRole = m_colNames.at(ic);
|
QString strRole = m_colNames.at(ic);
|
||||||
int roleNo = (Qt::UserRole+1) + ic;
|
int roleNo = (Qt::UserRole + 1) + ic;
|
||||||
roles.insert( roleNo, strRole.toLatin1() );
|
roles.insert(roleNo, strRole.toLatin1());
|
||||||
}
|
}
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
@ -157,16 +148,12 @@ QStringList XlsxTableModel::customRoleNames()
|
|||||||
QMap<int, QString> res;
|
QMap<int, QString> res;
|
||||||
QHashIterator<int, QByteArray> i(roleNames());
|
QHashIterator<int, QByteArray> i(roleNames());
|
||||||
|
|
||||||
while ( i.hasNext() )
|
while (i.hasNext()) {
|
||||||
{
|
|
||||||
i.next();
|
i.next();
|
||||||
if ( i.key() > Qt::UserRole )
|
if (i.key() > Qt::UserRole) {
|
||||||
{
|
res[i.key()] = i.value();
|
||||||
res[ i.key() ] = i.value();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.values();
|
return res.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,19 +7,19 @@
|
|||||||
#ifndef XLSX_MODEL_H
|
#ifndef XLSX_MODEL_H
|
||||||
#define XLSX_MODEL_H
|
#define XLSX_MODEL_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QList>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QAbstractTableModel>
|
#include <QVector>
|
||||||
|
#include <QtGlobal>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
typedef QList<QVariant> VLIST;
|
typedef QList<QVariant> VLIST;
|
||||||
|
|
||||||
@ -29,13 +29,14 @@ class XlsxTableModel : public QAbstractTableModel
|
|||||||
|
|
||||||
// method that is called by QML script
|
// method that is called by QML script
|
||||||
Q_PROPERTY(QStringList customRoleNames READ customRoleNames CONSTANT)
|
Q_PROPERTY(QStringList customRoleNames READ customRoleNames CONSTANT)
|
||||||
public: QStringList customRoleNames();
|
public:
|
||||||
|
QStringList customRoleNames();
|
||||||
|
|
||||||
public: // constrcutor
|
public: // constrcutor
|
||||||
XlsxTableModel(const QList<QString> &colTitle, QList<VLIST> data, QObject *parent = NULL);
|
XlsxTableModel(const QList<QString> &colTitle, QList<VLIST> data, QObject *parent = NULL);
|
||||||
|
|
||||||
public: // virtual function of parent object
|
public: // virtual function of parent object
|
||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
||||||
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
||||||
@ -44,10 +45,9 @@ protected:
|
|||||||
void testData(); // test function.
|
void testData(); // test function.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<VLIST> m_the_data; // table cell data
|
QList<VLIST> m_the_data; // table cell data
|
||||||
QList<QString> m_colNames; // column name
|
QList<QString> m_colNames; // column name
|
||||||
quint32 m_roleCount; // role count (same as column count)
|
quint32 m_roleCount; // role count (same as column count)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,116 +4,107 @@
|
|||||||
|
|
||||||
// main.cpp
|
// main.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxcellrange.h"
|
||||||
#include <QObject>
|
#include "xlsxchart.h"
|
||||||
#include <QString>
|
#include "xlsxchartsheet.h"
|
||||||
#include <QUrl>
|
#include "xlsxdocument.h"
|
||||||
#include <QList>
|
#include "xlsxrichstring.h"
|
||||||
#include <QVariant>
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QQmlApplicationEngine>
|
|
||||||
#include <QQmlContext>
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
#include <QDebug>
|
||||||
#include "xlsxchartsheet.h"
|
#include <QGuiApplication>
|
||||||
#include "xlsxcellrange.h"
|
#include <QList>
|
||||||
#include "xlsxchart.h"
|
#include <QObject>
|
||||||
#include "xlsxrichstring.h"
|
#include <QQmlApplicationEngine>
|
||||||
#include "xlsxworkbook.h"
|
#include <QQmlContext>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
|
|
||||||
#include "XlsxTableModel.h"
|
|
||||||
#include "DynArray2D.h"
|
#include "DynArray2D.h"
|
||||||
|
#include "XlsxTableModel.h"
|
||||||
|
|
||||||
std::string convertFromNumberToExcelColumn(int n);
|
std::string convertFromNumberToExcelColumn(int n);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
QQmlContext* ctxt = engine.rootContext();
|
QQmlContext *ctxt = engine.rootContext();
|
||||||
|
|
||||||
QXlsx::Document xlsx( ":/test.xlsx" ); // load xlsx
|
QXlsx::Document xlsx(":/test.xlsx"); // load xlsx
|
||||||
if (!xlsx.load())
|
if (!xlsx.load()) {
|
||||||
{
|
|
||||||
qDebug() << "[ERROR] Failed to load xlsx";
|
qDebug() << "[ERROR] Failed to load xlsx";
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> colTitle; // list of column title
|
QList<QString> colTitle; // list of column title
|
||||||
QVector<CellLocation> vcl; // vector of cell(s) location
|
QVector<CellLocation> vcl; // vector of cell(s) location
|
||||||
Worksheet* wsheet = (Worksheet*) xlsx.workbook()->activeSheet();
|
Worksheet *wsheet = (Worksheet *) xlsx.workbook()->activeSheet();
|
||||||
if ( NULL == wsheet )
|
if (NULL == wsheet) {
|
||||||
{
|
|
||||||
qDebug() << "[ERROR] Failed to get active sheet";
|
qDebug() << "[ERROR] Failed to get active sheet";
|
||||||
return (-2);
|
return (-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rowMax = -1;
|
int rowMax = -1;
|
||||||
int colMax = -1;
|
int colMax = -1;
|
||||||
vcl = wsheet->getFullCells( &rowMax, &colMax );
|
vcl = wsheet->getFullCells(&rowMax, &colMax);
|
||||||
|
|
||||||
Q_ASSERT( (-1) != rowMax ); // To CHECK
|
Q_ASSERT((-1) != rowMax); // To CHECK
|
||||||
Q_ASSERT( (-1) != colMax );
|
Q_ASSERT((-1) != colMax);
|
||||||
|
|
||||||
for (int ic = 0 ; ic < colMax ; ic++)
|
for (int ic = 0; ic < colMax; ic++) {
|
||||||
{
|
|
||||||
std::string strCol = convertFromNumberToExcelColumn(ic + 1);
|
std::string strCol = convertFromNumberToExcelColumn(ic + 1);
|
||||||
QString colName = QString::fromStdString( strCol );
|
QString colName = QString::fromStdString(strCol);
|
||||||
colTitle.append( colName );
|
colTitle.append(colName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make cell matrix that has (colMax x rowMax) size.
|
// make cell matrix that has (colMax x rowMax) size.
|
||||||
|
|
||||||
DynArray2D< std::string > dynIntArray(colMax, rowMax);
|
DynArray2D<std::string> dynIntArray(colMax, rowMax);
|
||||||
|
|
||||||
for ( int icl = 0; icl < vcl.size(); ++icl )
|
for (int icl = 0; icl < vcl.size(); ++icl) {
|
||||||
{
|
CellLocation cl = vcl.at(icl); // cell location
|
||||||
CellLocation cl = vcl.at(icl); // cell location
|
|
||||||
|
|
||||||
// NOTICE: First cell of tableWidget is 0.
|
// NOTICE: First cell of tableWidget is 0.
|
||||||
// But first cell of Qxlsx document is 1.
|
// But first cell of Qxlsx document is 1.
|
||||||
int row = cl.row - 1;
|
int row = cl.row - 1;
|
||||||
int col = cl.col - 1;
|
int col = cl.col - 1;
|
||||||
|
|
||||||
auto ptrCell = cl.cell; // cell pointer
|
auto ptrCell = cl.cell; // cell pointer
|
||||||
|
|
||||||
// value of cell
|
// value of cell
|
||||||
QVariant var = ptrCell->value();
|
QVariant var = ptrCell->value();
|
||||||
QString str = var.toString();
|
QString str = var.toString();
|
||||||
|
|
||||||
// set string value to (col, row)
|
// set string value to (col, row)
|
||||||
dynIntArray.setValue( col, row, str.toStdString() );
|
dynIntArray.setValue(col, row, str.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<VLIST> xlsxData;
|
QList<VLIST> xlsxData;
|
||||||
for (int ir = 0; ir < rowMax; ir++ )
|
for (int ir = 0; ir < rowMax; ir++) {
|
||||||
{
|
|
||||||
VLIST vl;
|
VLIST vl;
|
||||||
for (int ic = 0; ic < colMax; ic++)
|
for (int ic = 0; ic < colMax; ic++) {
|
||||||
{
|
std::string value = dynIntArray.getValue(ic, ir);
|
||||||
std::string value = dynIntArray.getValue( ic, ir );
|
vl.append(QString::fromStdString(value));
|
||||||
vl.append( QString::fromStdString(value) );
|
|
||||||
}
|
}
|
||||||
xlsxData.append(vl);
|
xlsxData.append(vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model for tableview
|
// set model for tableview
|
||||||
XlsxTableModel xlsxTableModel(colTitle, xlsxData);
|
XlsxTableModel xlsxTableModel(colTitle, xlsxData);
|
||||||
ctxt->setContextProperty( "xlsxModel", &xlsxTableModel );
|
ctxt->setContextProperty("xlsxModel", &xlsxTableModel);
|
||||||
|
|
||||||
engine.load( QUrl(QStringLiteral("qrc:/main.qml")) ); // load QML
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); // load QML
|
||||||
if ( engine.rootObjects().isEmpty() )
|
if (engine.rootObjects().isEmpty()) {
|
||||||
{
|
|
||||||
qDebug() << "Failed to load qml";
|
qDebug() << "Failed to load qml";
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -130,29 +121,26 @@ std::string convertFromNumberToExcelColumn(int n)
|
|||||||
std::string stdString;
|
std::string stdString;
|
||||||
|
|
||||||
char str[1000]; // To store result (Excel column name)
|
char str[1000]; // To store result (Excel column name)
|
||||||
int i = 0; // To store current index in str which is result
|
int i = 0; // To store current index in str which is result
|
||||||
|
|
||||||
while ( n > 0 )
|
while (n > 0) {
|
||||||
{
|
|
||||||
// Find remainder
|
// Find remainder
|
||||||
int rem = n % 26;
|
int rem = n % 26;
|
||||||
|
|
||||||
// If remainder is 0, then a 'Z' must be there in output
|
// If remainder is 0, then a 'Z' must be there in output
|
||||||
if ( rem == 0 )
|
if (rem == 0) {
|
||||||
{
|
|
||||||
str[i++] = 'Z';
|
str[i++] = 'Z';
|
||||||
n = (n/26) - 1;
|
n = (n / 26) - 1;
|
||||||
}
|
} else // If remainder is non-zero
|
||||||
else // If remainder is non-zero
|
|
||||||
{
|
{
|
||||||
str[i++] = (rem-1) + 'A';
|
str[i++] = (rem - 1) + 'A';
|
||||||
n = n / 26;
|
n = n / 26;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
|
|
||||||
// Reverse the string and print result
|
// Reverse the string and print result
|
||||||
std::reverse( str, str + strlen(str) );
|
std::reverse(str, str + strlen(str));
|
||||||
|
|
||||||
stdString = str;
|
stdString = str;
|
||||||
return stdString;
|
return stdString;
|
||||||
|
@ -2,21 +2,21 @@
|
|||||||
// QXlsx // MIT License // https://github.com/j2doll/QXlsx
|
// QXlsx // MIT License // https://github.com/j2doll/QXlsx
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// [0] include QXlsx headers
|
// [0] include QXlsx headers
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
@ -30,18 +30,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QXlsx::Document xlsxW;
|
QXlsx::Document xlsxW;
|
||||||
|
|
||||||
int row = 1; int col = 1; //
|
int row = 1;
|
||||||
|
int col = 1; //
|
||||||
|
|
||||||
// xlsxW.write("A1", "Hello Qt!"); // write "Hello Qt!" to cell(A,1). it's shared string.
|
// xlsxW.write("A1", "Hello Qt!"); // write "Hello Qt!" to cell(A,1). it's shared string.
|
||||||
QVariant writeValue = QString("Hello Qt!");
|
QVariant writeValue = QString("Hello Qt!");
|
||||||
xlsxW.write(row, col, writeValue);
|
xlsxW.write(row, col, writeValue);
|
||||||
|
|
||||||
if ( xlsxW.saveAs("Test.xlsx") ) // save the document as 'Test.xlsx'
|
if (xlsxW.saveAs("Test.xlsx")) // save the document as 'Test.xlsx'
|
||||||
{
|
{
|
||||||
qDebug() << "[debug] success to write xlsx file";
|
qDebug() << "[debug] success to write xlsx file";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << "[debug][error] failed to write xlsx file";
|
qDebug() << "[debug][error] failed to write xlsx file";
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
@ -51,25 +50,21 @@ int main(int argc, char *argv[])
|
|||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
// [2] Reading excel file(*.xlsx)
|
// [2] Reading excel file(*.xlsx)
|
||||||
|
|
||||||
Document xlsxR("Test.xlsx");
|
Document xlsxR("Test.xlsx");
|
||||||
if ( xlsxR.load() ) // load excel file
|
if (xlsxR.load()) // load excel file
|
||||||
{
|
{
|
||||||
qDebug() << "[debug] success to load xlsx file.";
|
qDebug() << "[debug] success to load xlsx file.";
|
||||||
|
|
||||||
Cell* cell = xlsxR.cellAt(row, col); // get cell pointer.
|
Cell *cell = xlsxR.cellAt(row, col); // get cell pointer.
|
||||||
if ( cell != NULL )
|
if (cell != NULL) {
|
||||||
{
|
QVariant var =
|
||||||
QVariant var = cell->readValue(); // read cell value (number(double), QDateTime, QString ...)
|
cell->readValue(); // read cell value (number(double), QDateTime, QString ...)
|
||||||
qDebug() << "[debug] cell(1,1) is " << var; // Display value. It is 'Hello Qt!'.
|
qDebug() << "[debug] cell(1,1) is " << var; // Display value. It is 'Hello Qt!'.
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << "[debug][error] cell(1,1) is not set.";
|
qDebug() << "[debug][error] cell(1,1) is not set.";
|
||||||
exit(-2);
|
exit(-2);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << "[debug][error] failed to load xlsx file.";
|
qDebug() << "[debug][error] failed to load xlsx file.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
@ -22,12 +22,11 @@ extern int test(QVector<QVariant> params);
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
QVector<QVariant> testParams;
|
QVector<QVariant> testParams;
|
||||||
int ret = test(testParams);
|
int ret = test(testParams);
|
||||||
// qDebug() << "test return value : " << ret;
|
// qDebug() << "test return value : " << ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
// test.cpp
|
// test.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QImage>
|
|
||||||
#include <QRgb>
|
|
||||||
#include <QRandomGenerator>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
#include <QRgb>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
int test162( QVector<QVariant> params )
|
int test162(QVector<QVariant> params)
|
||||||
{
|
{
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
|
|
||||||
@ -31,22 +31,17 @@ int test162( QVector<QVariant> params )
|
|||||||
xlsx.saveAs("image1.xlsx");
|
xlsx.saveAs("image1.xlsx");
|
||||||
|
|
||||||
Document xlsx2("image1.xlsx");
|
Document xlsx2("image1.xlsx");
|
||||||
qDebug() << "xlsx2" ;
|
qDebug() << "xlsx2";
|
||||||
qDebug() << " image count : " << xlsx.getImageCount();
|
qDebug() << " image count : " << xlsx.getImageCount();
|
||||||
xlsx2.saveAs("image2.xlsx");
|
xlsx2.saveAs("image2.xlsx");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test( QVector<QVariant> params )
|
int test(QVector<QVariant> params)
|
||||||
{
|
{
|
||||||
qDebug() << "[debug] current path : " << QDir::currentPath();
|
qDebug() << "[debug] current path : " << QDir::currentPath();
|
||||||
// return test162( params );
|
// return test162( params );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,11 +30,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -49,75 +49,76 @@ extern "C" {
|
|||||||
* 4 -> magenta
|
* 4 -> magenta
|
||||||
* 5 -> cyan
|
* 5 -> cyan
|
||||||
*/
|
*/
|
||||||
int colorprintf(int color, const char *format, ...) {
|
int colorprintf(int color, const char *format, ...)
|
||||||
int fcolor = -1, retval = -99;
|
{
|
||||||
va_list args;
|
int fcolor = -1, retval = -99;
|
||||||
|
va_list args;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
fcolor = FOREGROUND_RED;
|
fcolor = FOREGROUND_RED;
|
||||||
} else if (color == 1) {
|
} else if (color == 1) {
|
||||||
fcolor = FOREGROUND_GREEN;
|
fcolor = FOREGROUND_GREEN;
|
||||||
} else if (color == 2) {
|
} else if (color == 2) {
|
||||||
fcolor = FOREGROUND_RED | FOREGROUND_GREEN;
|
fcolor = FOREGROUND_RED | FOREGROUND_GREEN;
|
||||||
} else if (color == 3) {
|
} else if (color == 3) {
|
||||||
fcolor = FOREGROUND_BLUE;
|
fcolor = FOREGROUND_BLUE;
|
||||||
} else if (color == 4) {
|
} else if (color == 4) {
|
||||||
fcolor = FOREGROUND_RED | FOREGROUND_BLUE;
|
fcolor = FOREGROUND_RED | FOREGROUND_BLUE;
|
||||||
} else if (color == 5) {
|
} else if (color == 5) {
|
||||||
fcolor = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
fcolor = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||||
}
|
}
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
|
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
|
||||||
WORD wOldColorAttrs;
|
WORD wOldColorAttrs;
|
||||||
HANDLE hStdout;
|
HANDLE hStdout;
|
||||||
if (fcolor != -1) {
|
if (fcolor != -1) {
|
||||||
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
if ((hStdout == NULL) || (hStdout == INVALID_HANDLE_VALUE)) {
|
if ((hStdout == NULL) || (hStdout == INVALID_HANDLE_VALUE)) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
if (GetConsoleScreenBufferInfo(hStdout, &csbiInfo) == 0) {
|
if (GetConsoleScreenBufferInfo(hStdout, &csbiInfo) == 0) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
wOldColorAttrs = csbiInfo.wAttributes;
|
wOldColorAttrs = csbiInfo.wAttributes;
|
||||||
if (SetConsoleTextAttribute(hStdout, fcolor | FOREGROUND_INTENSITY) == 0) {
|
if (SetConsoleTextAttribute(hStdout, fcolor | FOREGROUND_INTENSITY) == 0) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
fcolor = 1;
|
fcolor = 1;
|
||||||
} else if (color == 1) {
|
} else if (color == 1) {
|
||||||
fcolor = 2;
|
fcolor = 2;
|
||||||
} else if (color == 2) {
|
} else if (color == 2) {
|
||||||
fcolor = 3;
|
fcolor = 3;
|
||||||
} else if (color == 3) {
|
} else if (color == 3) {
|
||||||
fcolor = 4;
|
fcolor = 4;
|
||||||
} else if (color == 4) {
|
} else if (color == 4) {
|
||||||
fcolor = 5;
|
fcolor = 5;
|
||||||
} else if (color == 5) {
|
} else if (color == 5) {
|
||||||
fcolor = 6;
|
fcolor = 6;
|
||||||
}
|
}
|
||||||
if (fcolor != -1 && printf("\033[1;3%dm", fcolor) < 0) {
|
if (fcolor != -1 && printf("\033[1;3%dm", fcolor) < 0) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
if (!args) {
|
if (!args) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
retval = vprintf(format, args);
|
retval = vprintf(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
if (fcolor != -1) {
|
if (fcolor != -1) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (SetConsoleTextAttribute(hStdout, wOldColorAttrs) == 0) {
|
if (SetConsoleTextAttribute(hStdout, wOldColorAttrs) == 0) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (printf("\033[0m") < 0) {
|
if (printf("\033[0m") < 0) {
|
||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
@ -22,11 +22,10 @@ extern int test(QVector<QVariant> params);
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
QVector<QVariant> testParams;
|
QVector<QVariant> testParams;
|
||||||
int ret = test(testParams);
|
int ret = test(testParams);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
// test.cpp
|
// test.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
@ -30,21 +30,19 @@ using namespace std;
|
|||||||
// #include "colorprintf.h" // https://github.com/VittGam/colorprintf
|
// #include "colorprintf.h" // https://github.com/VittGam/colorprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int test( QVector<QVariant> params );
|
int test(QVector<QVariant> params);
|
||||||
|
|
||||||
int test( QVector<QVariant> params )
|
int test(QVector<QVariant> params)
|
||||||
{
|
{
|
||||||
qDebug() << "[debug] current path : " << QDir::currentPath();
|
qDebug() << "[debug] current path : " << QDir::currentPath();
|
||||||
|
|
||||||
QFile fileNames(":/xlsx_files/dir2.txt");
|
QFile fileNames(":/xlsx_files/dir2.txt");
|
||||||
if ( !fileNames.open(QIODevice::ReadOnly | QIODevice::Text) )
|
if (!fileNames.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
{
|
|
||||||
qDebug() << "[debug] failed to load dir2.txt";
|
qDebug() << "[debug] failed to load dir2.txt";
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!fileNames.atEnd())
|
while (!fileNames.atEnd()) {
|
||||||
{
|
|
||||||
QByteArray line = fileNames.readLine();
|
QByteArray line = fileNames.readLine();
|
||||||
|
|
||||||
QString strArg(line);
|
QString strArg(line);
|
||||||
@ -56,19 +54,13 @@ int test( QVector<QVariant> params )
|
|||||||
{
|
{
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
Document output2(currentFilename);
|
Document output2(currentFilename);
|
||||||
if ( output2.load() )
|
if (output2.load()) {
|
||||||
{
|
if (output2.saveAs(strArg3)) {
|
||||||
if ( output2.saveAs( strArg3 ) )
|
|
||||||
{
|
|
||||||
qDebug() << "[debug] xlsx is saved. " << strArg3;
|
qDebug() << "[debug] xlsx is saved. " << strArg3;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qCritical() << "[debug] failed to save. " << strArg3;
|
qCritical() << "[debug] failed to save. " << strArg3;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qCritical() << "[debug] failed to load. " << strArg3;
|
qCritical() << "[debug] failed to load. " << strArg3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,4 +68,3 @@ int test( QVector<QVariant> params )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,17 +15,13 @@ class QXLSX_EXPORT AbstractOOXmlFile
|
|||||||
Q_DECLARE_PRIVATE(AbstractOOXmlFile)
|
Q_DECLARE_PRIVATE(AbstractOOXmlFile)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum CreateFlag
|
enum CreateFlag { F_NewFromScratch, F_LoadFromExists };
|
||||||
{
|
|
||||||
F_NewFromScratch,
|
|
||||||
F_LoadFromExists
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~AbstractOOXmlFile();
|
virtual ~AbstractOOXmlFile();
|
||||||
|
|
||||||
virtual void saveToXmlFile(QIODevice *device) const = 0;
|
virtual void saveToXmlFile(QIODevice *device) const = 0;
|
||||||
virtual bool loadFromXmlFile(QIODevice *device) = 0;
|
virtual bool loadFromXmlFile(QIODevice *device) = 0;
|
||||||
|
|
||||||
virtual QByteArray saveToXmlData() const;
|
virtual QByteArray saveToXmlData() const;
|
||||||
virtual bool loadFromXmlData(const QByteArray &data);
|
virtual bool loadFromXmlData(const QByteArray &data);
|
||||||
|
@ -3,9 +3,8 @@
|
|||||||
#ifndef XLSXOOXMLFILE_P_H
|
#ifndef XLSXOOXMLFILE_P_H
|
||||||
#define XLSXOOXMLFILE_P_H
|
#define XLSXOOXMLFILE_P_H
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
#include "xlsxrelationships_p.h"
|
#include "xlsxrelationships_p.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
@ -15,11 +14,11 @@ class AbstractOOXmlFilePrivate
|
|||||||
Q_DECLARE_PUBLIC(AbstractOOXmlFile)
|
Q_DECLARE_PUBLIC(AbstractOOXmlFile)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AbstractOOXmlFilePrivate(AbstractOOXmlFile* q, AbstractOOXmlFile::CreateFlag flag);
|
AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag);
|
||||||
virtual ~AbstractOOXmlFilePrivate();
|
virtual ~AbstractOOXmlFilePrivate();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString filePathInPackage; //such as "xl/worksheets/sheet1.xml"
|
QString filePathInPackage; // such as "xl/worksheets/sheet1.xml"
|
||||||
|
|
||||||
Relationships *relationships;
|
Relationships *relationships;
|
||||||
AbstractOOXmlFile::CreateFlag flag;
|
AbstractOOXmlFile::CreateFlag flag;
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#ifndef XLSXABSTRACTSHEET_H
|
#ifndef XLSXABSTRACTSHEET_H
|
||||||
#define XLSXABSTRACTSHEET_H
|
#define XLSXABSTRACTSHEET_H
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
// NOTE: If all Qt compiler supports C++1x, recommend to use a 'class enum'.
|
// NOTE: If all Qt compiler supports C++1x, recommend to use a 'class enum'.
|
||||||
enum SheetType { ST_WorkSheet, ST_ChartSheet, ST_DialogSheet, ST_MacroSheet };
|
enum SheetType { ST_WorkSheet, ST_ChartSheet, ST_DialogSheet, ST_MacroSheet };
|
||||||
enum SheetState { SS_Visible,SS_Hidden, SS_VeryHidden };
|
enum SheetState { SS_Visible, SS_Hidden, SS_VeryHidden };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString sheetName() const;
|
QString sheetName() const;
|
||||||
|
@ -3,15 +3,14 @@
|
|||||||
#ifndef XLSXABSTRACTSHEET_P_H
|
#ifndef XLSXABSTRACTSHEET_P_H
|
||||||
#define XLSXABSTRACTSHEET_P_H
|
#define XLSXABSTRACTSHEET_P_H
|
||||||
|
|
||||||
#include <QString>
|
#include "xlsxabstractooxmlfile_p.h"
|
||||||
|
#include "xlsxabstractsheet.h"
|
||||||
|
#include "xlsxdrawing_p.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include <QString>
|
||||||
|
|
||||||
#include "xlsxabstractsheet.h"
|
|
||||||
#include "xlsxabstractooxmlfile_p.h"
|
|
||||||
#include "xlsxdrawing_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
#ifndef QXLSX_XLSXCELL_H
|
#ifndef QXLSX_XLSXCELL_H
|
||||||
#define QXLSX_XLSXCELL_H
|
#define QXLSX_XLSXCELL_H
|
||||||
|
|
||||||
|
#include "xlsxformat.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QVariant>
|
||||||
#include "xlsxglobal.h"
|
#include <QtGlobal>
|
||||||
#include "xlsxformat.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ class WorksheetPrivate;
|
|||||||
|
|
||||||
class QXLSX_EXPORT Cell
|
class QXLSX_EXPORT Cell
|
||||||
{
|
{
|
||||||
Q_DECLARE_PRIVATE(Cell)
|
Q_DECLARE_PRIVATE(Cell)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Worksheet;
|
friend class Worksheet;
|
||||||
@ -43,38 +43,37 @@ public:
|
|||||||
SharedStringType,
|
SharedStringType,
|
||||||
StringType,
|
StringType,
|
||||||
CustomType, // custom or un-defined cell type
|
CustomType, // custom or un-defined cell type
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Cell(const QVariant &data = QVariant(),
|
Cell(const QVariant &data = QVariant(),
|
||||||
CellType type = NumberType,
|
CellType type = NumberType,
|
||||||
const Format &format = Format(),
|
const Format &format = Format(),
|
||||||
Worksheet *parent = nullptr,
|
Worksheet *parent = nullptr,
|
||||||
qint32 styleIndex = (-1) );
|
qint32 styleIndex = (-1));
|
||||||
Cell(const Cell * const cell);
|
Cell(const Cell *const cell);
|
||||||
~Cell();
|
~Cell();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CellPrivate * const d_ptr; // See D-pointer and Q-pointer of Qt, for more information.
|
CellPrivate *const d_ptr; // See D-pointer and Q-pointer of Qt, for more information.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CellType cellType() const;
|
CellType cellType() const;
|
||||||
QVariant value() const;
|
QVariant value() const;
|
||||||
QVariant readValue() const;
|
QVariant readValue() const;
|
||||||
Format format() const;
|
Format format() const;
|
||||||
|
|
||||||
bool hasFormula() const;
|
|
||||||
CellFormula formula() const;
|
|
||||||
|
|
||||||
bool isDateTime() const;
|
bool hasFormula() const;
|
||||||
|
CellFormula formula() const;
|
||||||
|
|
||||||
|
bool isDateTime() const;
|
||||||
QVariant dateTime() const; // QDateTime, QDate, QTime
|
QVariant dateTime() const; // QDateTime, QDate, QTime
|
||||||
|
|
||||||
bool isRichString() const;
|
bool isRichString() const;
|
||||||
|
|
||||||
qint32 styleNumber() const;
|
qint32 styleNumber() const;
|
||||||
|
|
||||||
static bool isDateType(CellType cellType, const Format &format);
|
|
||||||
|
|
||||||
|
static bool isDateType(CellType cellType, const Format &format);
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
#ifndef XLSXCELL_P_H
|
#ifndef XLSXCELL_P_H
|
||||||
#define XLSXCELL_P_H
|
#define XLSXCELL_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxcell.h"
|
#include "xlsxcell.h"
|
||||||
#include "xlsxcellrange.h"
|
|
||||||
#include "xlsxrichstring.h"
|
|
||||||
#include "xlsxcellformula.h"
|
#include "xlsxcellformula.h"
|
||||||
|
#include "xlsxcellrange.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
#include "xlsxrichstring.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -20,10 +20,12 @@ class CellPrivate
|
|||||||
Q_DECLARE_PUBLIC(Cell)
|
Q_DECLARE_PUBLIC(Cell)
|
||||||
public:
|
public:
|
||||||
CellPrivate(Cell *p);
|
CellPrivate(Cell *p);
|
||||||
CellPrivate(const CellPrivate * const cp);
|
CellPrivate(const CellPrivate *const cp);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Worksheet *parent;
|
Worksheet *parent;
|
||||||
Cell *q_ptr;
|
Cell *q_ptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Cell::CellType cellType;
|
Cell::CellType cellType;
|
||||||
QVariant value;
|
QVariant value;
|
||||||
|
@ -24,14 +24,14 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CellFormula();
|
CellFormula();
|
||||||
CellFormula(const char *formula, FormulaType type=NormalType);
|
CellFormula(const char *formula, FormulaType type = NormalType);
|
||||||
CellFormula(const QString &formula, FormulaType type=NormalType);
|
CellFormula(const QString &formula, FormulaType type = NormalType);
|
||||||
CellFormula(const QString &formula, const CellRange &ref, FormulaType type);
|
CellFormula(const QString &formula, const CellRange &ref, FormulaType type);
|
||||||
CellFormula(const CellFormula &other);
|
CellFormula(const CellFormula &other);
|
||||||
~CellFormula();
|
~CellFormula();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CellFormula &operator =(const CellFormula &other);
|
CellFormula &operator=(const CellFormula &other);
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
FormulaType formulaType() const;
|
FormulaType formulaType() const;
|
||||||
@ -39,11 +39,12 @@ public:
|
|||||||
CellRange reference() const;
|
CellRange reference() const;
|
||||||
int sharedIndex() const;
|
int sharedIndex() const;
|
||||||
|
|
||||||
bool operator == (const CellFormula &formula) const;
|
bool operator==(const CellFormula &formula) const;
|
||||||
bool operator != (const CellFormula &formula) const;
|
bool operator!=(const CellFormula &formula) const;
|
||||||
|
|
||||||
bool saveToXml(QXmlStreamWriter &writer) const;
|
bool saveToXml(QXmlStreamWriter &writer) const;
|
||||||
bool loadFromXml(QXmlStreamReader &reader);
|
bool loadFromXml(QXmlStreamReader &reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Worksheet;
|
friend class Worksheet;
|
||||||
friend class WorksheetPrivate;
|
friend class WorksheetPrivate;
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#ifndef XLSXCELLFORMULA_P_H
|
#ifndef XLSXCELLFORMULA_P_H
|
||||||
#define XLSXCELLFORMULA_P_H
|
#define XLSXCELLFORMULA_P_H
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxcellformula.h"
|
#include "xlsxcellformula.h"
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
#include <QSharedData>
|
#include <QSharedData>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -15,15 +15,17 @@ QT_BEGIN_NAMESPACE_XLSX
|
|||||||
class CellFormulaPrivate : public QSharedData
|
class CellFormulaPrivate : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CellFormulaPrivate(const QString &formula, const CellRange &reference, CellFormula::FormulaType type);
|
CellFormulaPrivate(const QString &formula,
|
||||||
|
const CellRange &reference,
|
||||||
|
CellFormula::FormulaType type);
|
||||||
CellFormulaPrivate(const CellFormulaPrivate &other);
|
CellFormulaPrivate(const CellFormulaPrivate &other);
|
||||||
~CellFormulaPrivate();
|
~CellFormulaPrivate();
|
||||||
|
|
||||||
QString formula; //formula contents
|
QString formula; // formula contents
|
||||||
CellFormula::FormulaType type;
|
CellFormula::FormulaType type;
|
||||||
CellRange reference;
|
CellRange reference;
|
||||||
bool ca; //Calculate Cell
|
bool ca; // Calculate Cell
|
||||||
int si; //Shared group index
|
int si; // Shared group index
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
#ifndef CELL_LOCATION_H
|
#ifndef CELL_LOCATION_H
|
||||||
#define CELL_LOCATION_H
|
#define CELL_LOCATION_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxglobal.h"
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QList>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include <QList>
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
#ifndef QXLSX_XLSXCELLRANGE_H
|
#ifndef QXLSX_XLSXCELLRANGE_H
|
||||||
#define QXLSX_XLSXCELLRANGE_H
|
#define QXLSX_XLSXCELLRANGE_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxcellreference.h"
|
#include "xlsxcellreference.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ public:
|
|||||||
CellRange(const CellRange &other);
|
CellRange(const CellRange &other);
|
||||||
~CellRange();
|
~CellRange();
|
||||||
|
|
||||||
QString toString(bool row_abs=false, bool col_abs=false) const;
|
QString toString(bool row_abs = false, bool col_abs = false) const;
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
inline void setFirstRow(int row) { top = row; }
|
inline void setFirstRow(int row) { top = row; }
|
||||||
inline void setLastRow(int row) { bottom = row; }
|
inline void setLastRow(int row) { bottom = row; }
|
||||||
@ -40,23 +40,24 @@ public:
|
|||||||
inline CellReference bottomLeft() const { return CellReference(bottom, left); }
|
inline CellReference bottomLeft() const { return CellReference(bottom, left); }
|
||||||
inline CellReference bottomRight() const { return CellReference(bottom, right); }
|
inline CellReference bottomRight() const { return CellReference(bottom, right); }
|
||||||
|
|
||||||
inline void operator =(const CellRange &other)
|
inline void operator=(const CellRange &other)
|
||||||
{
|
{
|
||||||
top = other.top;
|
top = other.top;
|
||||||
bottom = other.bottom;
|
bottom = other.bottom;
|
||||||
left = other.left;
|
left = other.left;
|
||||||
right = other.right;
|
right = other.right;
|
||||||
}
|
}
|
||||||
inline bool operator ==(const CellRange &other) const
|
inline bool operator==(const CellRange &other) const
|
||||||
{
|
{
|
||||||
return top==other.top && bottom==other.bottom
|
return top == other.top && bottom == other.bottom && left == other.left &&
|
||||||
&& left == other.left && right == other.right;
|
right == other.right;
|
||||||
}
|
}
|
||||||
inline bool operator !=(const CellRange &other) const
|
inline bool operator!=(const CellRange &other) const
|
||||||
{
|
{
|
||||||
return top!=other.top || bottom!=other.bottom
|
return top != other.top || bottom != other.bottom || left != other.left ||
|
||||||
|| left != other.left || right != other.right;
|
right != other.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(const QString &range);
|
void init(const QString &range);
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#ifndef QXLSX_XLSXCELLREFERENCE_H
|
#ifndef QXLSX_XLSXCELLREFERENCE_H
|
||||||
#define QXLSX_XLSXCELLREFERENCE_H
|
#define QXLSX_XLSXCELLREFERENCE_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class QXLSX_EXPORT CellReference
|
class QXLSX_EXPORT CellReference
|
||||||
@ -19,7 +19,7 @@ public:
|
|||||||
CellReference(const CellReference &other);
|
CellReference(const CellReference &other);
|
||||||
~CellReference();
|
~CellReference();
|
||||||
|
|
||||||
QString toString(bool row_abs=false, bool col_abs=false) const;
|
QString toString(bool row_abs = false, bool col_abs = false) const;
|
||||||
static CellReference fromString(const QString &cell);
|
static CellReference fromString(const QString &cell);
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
inline void setRow(int row) { _row = row; }
|
inline void setRow(int row) { _row = row; }
|
||||||
@ -27,14 +27,15 @@ public:
|
|||||||
inline int row() const { return _row; }
|
inline int row() const { return _row; }
|
||||||
inline int column() const { return _column; }
|
inline int column() const { return _column; }
|
||||||
|
|
||||||
inline bool operator ==(const CellReference &other) const
|
inline bool operator==(const CellReference &other) const
|
||||||
{
|
{
|
||||||
return _row==other._row && _column==other._column;
|
return _row == other._row && _column == other._column;
|
||||||
}
|
}
|
||||||
inline bool operator !=(const CellReference &other) const
|
inline bool operator!=(const CellReference &other) const
|
||||||
{
|
{
|
||||||
return _row!=other._row || _column!=other._column;
|
return _row != other._row || _column != other._column;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(const QString &cell);
|
void init(const QString &cell);
|
||||||
int _row, _column;
|
int _row, _column;
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
#ifndef QXLSX_CHART_H
|
#ifndef QXLSX_CHART_H
|
||||||
#define QXLSX_CHART_H
|
#define QXLSX_CHART_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxabstractooxmlfile.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -21,33 +21,52 @@ class QXLSX_EXPORT Chart : public AbstractOOXmlFile
|
|||||||
{
|
{
|
||||||
Q_DECLARE_PRIVATE(Chart)
|
Q_DECLARE_PRIVATE(Chart)
|
||||||
public:
|
public:
|
||||||
enum ChartType { // 16 type of chart (ECMA 376)
|
enum ChartType { // 16 type of chart (ECMA 376)
|
||||||
CT_NoStatementChart = 0, // Zero is internally used for unknown types
|
CT_NoStatementChart = 0, // Zero is internally used for unknown types
|
||||||
CT_AreaChart, CT_Area3DChart, CT_LineChart,
|
CT_AreaChart,
|
||||||
CT_Line3DChart, CT_StockChart, CT_RadarChart,
|
CT_Area3DChart,
|
||||||
CT_ScatterChart, CT_PieChart, CT_Pie3DChart,
|
CT_LineChart,
|
||||||
CT_DoughnutChart, CT_BarChart, CT_Bar3DChart,
|
CT_Line3DChart,
|
||||||
CT_OfPieChart, CT_SurfaceChart, CT_Surface3DChart,
|
CT_StockChart,
|
||||||
|
CT_RadarChart,
|
||||||
|
CT_ScatterChart,
|
||||||
|
CT_PieChart,
|
||||||
|
CT_Pie3DChart,
|
||||||
|
CT_DoughnutChart,
|
||||||
|
CT_BarChart,
|
||||||
|
CT_Bar3DChart,
|
||||||
|
CT_OfPieChart,
|
||||||
|
CT_SurfaceChart,
|
||||||
|
CT_Surface3DChart,
|
||||||
CT_BubbleChart,
|
CT_BubbleChart,
|
||||||
};
|
};
|
||||||
enum ChartAxisPos { None = (-1), Left = 0, Right, Top, Bottom };
|
enum ChartAxisPos { None = (-1), Left = 0, Right, Top, Bottom };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AbstractSheet;
|
friend class AbstractSheet;
|
||||||
friend class Worksheet;
|
friend class Worksheet;
|
||||||
friend class Chartsheet;
|
friend class Chartsheet;
|
||||||
friend class DrawingAnchor;
|
friend class DrawingAnchor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Chart(AbstractSheet *parent, CreateFlag flag);
|
Chart(AbstractSheet *parent, CreateFlag flag);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Chart();
|
~Chart();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addSeries(const CellRange &range, AbstractSheet *sheet = NULL, bool headerH = false, bool headerV = false, bool swapHeaders = false);
|
void addSeries(const CellRange &range,
|
||||||
|
AbstractSheet *sheet = NULL,
|
||||||
|
bool headerH = false,
|
||||||
|
bool headerV = false,
|
||||||
|
bool swapHeaders = false);
|
||||||
void setChartType(ChartType type);
|
void setChartType(ChartType type);
|
||||||
void setChartStyle(int id);
|
void setChartStyle(int id);
|
||||||
void setAxisTitle(Chart::ChartAxisPos pos, QString axisTitle);
|
void setAxisTitle(Chart::ChartAxisPos pos, QString axisTitle);
|
||||||
void setChartTitle(QString strchartTitle);
|
void setChartTitle(QString strchartTitle);
|
||||||
void setChartLegend(Chart::ChartAxisPos legendPos, bool overlap = false);
|
void setChartLegend(Chart::ChartAxisPos legendPos, bool overlap = false);
|
||||||
void setGridlinesEnable(bool majorGridlinesEnable = false, bool minorGridlinesEnable = false);
|
void setGridlinesEnable(bool majorGridlinesEnable = false, bool minorGridlinesEnable = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool loadFromXmlFile(QIODevice *device) override;
|
bool loadFromXmlFile(QIODevice *device) override;
|
||||||
void saveToXmlFile(QIODevice *device) const override;
|
void saveToXmlFile(QIODevice *device) const override;
|
||||||
|
@ -3,30 +3,30 @@
|
|||||||
#ifndef QXLSX_CHART_P_H
|
#ifndef QXLSX_CHART_P_H
|
||||||
#define QXLSX_CHART_P_H
|
#define QXLSX_CHART_P_H
|
||||||
|
|
||||||
#include <QObject>
|
#include "xlsxabstractooxmlfile_p.h"
|
||||||
#include <QString>
|
#include "xlsxchart.h"
|
||||||
#include <QVector>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QList>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xlsxabstractooxmlfile_p.h"
|
#include <QList>
|
||||||
#include "xlsxchart.h"
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class XlsxSeries
|
class XlsxSeries
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//At present, we care about number cell ranges only!
|
// At present, we care about number cell ranges only!
|
||||||
QString numberDataSource_numRef; // yval, val
|
QString numberDataSource_numRef; // yval, val
|
||||||
QString axDataSource_numRef; // xval, cat
|
QString axDataSource_numRef; // xval, cat
|
||||||
QString headerH_numRef;
|
QString headerH_numRef;
|
||||||
QString headerV_numRef;
|
QString headerV_numRef;
|
||||||
bool swapHeader = false;
|
bool swapHeader = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XlsxAxis
|
class XlsxAxis
|
||||||
@ -34,23 +34,19 @@ class XlsxAxis
|
|||||||
public:
|
public:
|
||||||
enum Type { T_None = (-1), T_Cat, T_Val, T_Date, T_Ser };
|
enum Type { T_None = (-1), T_Cat, T_Val, T_Date, T_Ser };
|
||||||
enum AxisPos { None = (-1), Left, Right, Top, Bottom };
|
enum AxisPos { None = (-1), Left, Right, Top, Bottom };
|
||||||
public:
|
|
||||||
XlsxAxis(){}
|
|
||||||
|
|
||||||
XlsxAxis( Type t,
|
public:
|
||||||
XlsxAxis::AxisPos p,
|
XlsxAxis() {}
|
||||||
int id,
|
|
||||||
int crossId,
|
XlsxAxis(Type t, XlsxAxis::AxisPos p, int id, int crossId, QString axisTitle = QString())
|
||||||
QString axisTitle = QString())
|
|
||||||
{
|
{
|
||||||
type = t;
|
type = t;
|
||||||
axisPos = p;
|
axisPos = p;
|
||||||
axisId = id;
|
axisId = id;
|
||||||
crossAx = crossId;
|
crossAx = crossId;
|
||||||
|
|
||||||
if ( !axisTitle.isEmpty() )
|
if (!axisTitle.isEmpty()) {
|
||||||
{
|
axisNames[p] = axisTitle;
|
||||||
axisNames[ p ] = axisTitle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +55,7 @@ public:
|
|||||||
XlsxAxis::AxisPos axisPos;
|
XlsxAxis::AxisPos axisPos;
|
||||||
int axisId;
|
int axisId;
|
||||||
int crossAx;
|
int crossAx;
|
||||||
QMap< XlsxAxis::AxisPos, QString > axisNames;
|
QMap<XlsxAxis::AxisPos, QString> axisNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChartPrivate : public AbstractOOXmlFilePrivate
|
class ChartPrivate : public AbstractOOXmlFilePrivate
|
||||||
@ -73,8 +69,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
bool loadXmlChart(QXmlStreamReader &reader);
|
bool loadXmlChart(QXmlStreamReader &reader);
|
||||||
bool loadXmlPlotArea(QXmlStreamReader &reader);
|
bool loadXmlPlotArea(QXmlStreamReader &reader);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool loadXmlPlotAreaElement(QXmlStreamReader &reader);
|
bool loadXmlPlotAreaElement(QXmlStreamReader &reader);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool loadXmlXxxChart(QXmlStreamReader &reader);
|
bool loadXmlXxxChart(QXmlStreamReader &reader);
|
||||||
bool loadXmlSer(QXmlStreamReader &reader);
|
bool loadXmlSer(QXmlStreamReader &reader);
|
||||||
@ -82,25 +80,27 @@ public:
|
|||||||
QString loadXmlStrRef(QXmlStreamReader &reader);
|
QString loadXmlStrRef(QXmlStreamReader &reader);
|
||||||
bool loadXmlChartTitle(QXmlStreamReader &reader);
|
bool loadXmlChartTitle(QXmlStreamReader &reader);
|
||||||
bool loadXmlChartLegend(QXmlStreamReader &reader);
|
bool loadXmlChartLegend(QXmlStreamReader &reader);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool loadXmlChartTitleTx(QXmlStreamReader &reader);
|
bool loadXmlChartTitleTx(QXmlStreamReader &reader);
|
||||||
bool loadXmlChartTitleTxRich(QXmlStreamReader &reader);
|
bool loadXmlChartTitleTxRich(QXmlStreamReader &reader);
|
||||||
bool loadXmlChartTitleTxRichP(QXmlStreamReader &reader);
|
bool loadXmlChartTitleTxRichP(QXmlStreamReader &reader);
|
||||||
bool loadXmlChartTitleTxRichP_R(QXmlStreamReader &reader);
|
bool loadXmlChartTitleTxRichP_R(QXmlStreamReader &reader);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool loadXmlAxisCatAx(QXmlStreamReader &reader);
|
bool loadXmlAxisCatAx(QXmlStreamReader &reader);
|
||||||
bool loadXmlAxisDateAx(QXmlStreamReader &reader);
|
bool loadXmlAxisDateAx(QXmlStreamReader &reader);
|
||||||
bool loadXmlAxisSerAx(QXmlStreamReader &reader);
|
bool loadXmlAxisSerAx(QXmlStreamReader &reader);
|
||||||
bool loadXmlAxisValAx(QXmlStreamReader &reader);
|
bool loadXmlAxisValAx(QXmlStreamReader &reader);
|
||||||
bool loadXmlAxisEG_AxShared(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Scaling(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Scaling(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title_Overlay(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title_Overlay(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title_Tx(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title_Tx(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title_Tx_Rich(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title_Tx_Rich(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P_pPr(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P_pPr(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P_R(QXmlStreamReader &reader, XlsxAxis* axis);
|
bool loadXmlAxisEG_AxShared_Title_Tx_Rich_P_R(QXmlStreamReader &reader, XlsxAxis *axis);
|
||||||
|
|
||||||
QString readSubTree(QXmlStreamReader &reader);
|
QString readSubTree(QXmlStreamReader &reader);
|
||||||
|
|
||||||
@ -118,29 +118,29 @@ public:
|
|||||||
void saveXmlChartLegend(QXmlStreamWriter &writer) const;
|
void saveXmlChartLegend(QXmlStreamWriter &writer) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void saveXmlAxisCatAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
|
void saveXmlAxisCatAx(QXmlStreamWriter &writer, XlsxAxis *axis) const;
|
||||||
void saveXmlAxisDateAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
|
void saveXmlAxisDateAx(QXmlStreamWriter &writer, XlsxAxis *axis) const;
|
||||||
void saveXmlAxisSerAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
|
void saveXmlAxisSerAx(QXmlStreamWriter &writer, XlsxAxis *axis) const;
|
||||||
void saveXmlAxisValAx(QXmlStreamWriter &writer, XlsxAxis* axis) const;
|
void saveXmlAxisValAx(QXmlStreamWriter &writer, XlsxAxis *axis) const;
|
||||||
|
|
||||||
void saveXmlAxisEG_AxShared(QXmlStreamWriter &writer, XlsxAxis* axis) const;
|
void saveXmlAxisEG_AxShared(QXmlStreamWriter &writer, XlsxAxis *axis) const;
|
||||||
void saveXmlAxisEG_AxShared_Title(QXmlStreamWriter &writer, XlsxAxis* axis) const;
|
void saveXmlAxisEG_AxShared_Title(QXmlStreamWriter &writer, XlsxAxis *axis) const;
|
||||||
QString GetAxisPosString( XlsxAxis::AxisPos axisPos ) const;
|
QString GetAxisPosString(XlsxAxis::AxisPos axisPos) const;
|
||||||
QString GetAxisName(XlsxAxis* ptrXlsxAxis) const;
|
QString GetAxisName(XlsxAxis *ptrXlsxAxis) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Chart::ChartType chartType;
|
Chart::ChartType chartType;
|
||||||
QList< std::shared_ptr<XlsxSeries> > seriesList;
|
QList<std::shared_ptr<XlsxSeries>> seriesList;
|
||||||
QList< std::shared_ptr<XlsxAxis> > axisList;
|
QList<std::shared_ptr<XlsxAxis>> axisList;
|
||||||
QMap< XlsxAxis::AxisPos, QString > axisNames;
|
QMap<XlsxAxis::AxisPos, QString> axisNames;
|
||||||
QString chartTitle;
|
QString chartTitle;
|
||||||
AbstractSheet* sheet;
|
AbstractSheet *sheet;
|
||||||
Chart::ChartAxisPos legendPos;
|
Chart::ChartAxisPos legendPos;
|
||||||
bool legendOverlay;
|
bool legendOverlay;
|
||||||
bool majorGridlinesEnabled;
|
bool majorGridlinesEnabled;
|
||||||
bool minorGridlinesEnabled;
|
bool minorGridlinesEnabled;
|
||||||
|
|
||||||
QString layout; // only for storing a readed file
|
QString layout; // only for storing a readed file
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
#ifndef XLSXCHARTSHEET_H
|
#ifndef XLSXCHARTSHEET_H
|
||||||
#define XLSXCHARTSHEET_H
|
#define XLSXCHARTSHEET_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include "xlsxabstractsheet.h"
|
#include "xlsxabstractsheet.h"
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class Workbook;
|
class Workbook;
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
#ifndef XLSXCHARTSHEET_P_H
|
#ifndef XLSXCHARTSHEET_P_H
|
||||||
#define XLSXCHARTSHEET_P_H
|
#define XLSXCHARTSHEET_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxabstractsheet_p.h"
|
#include "xlsxabstractsheet_p.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
#ifndef QXLSX_XLSXCOLOR_P_H
|
#ifndef QXLSX_XLSXCOLOR_P_H
|
||||||
#define QXLSX_XLSXCOLOR_P_H
|
#define QXLSX_XLSXCOLOR_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class Styles;
|
class Styles;
|
||||||
@ -19,8 +19,8 @@ class XlsxColor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit XlsxColor(const QColor &color = QColor());
|
explicit XlsxColor(const QColor &color = QColor());
|
||||||
explicit XlsxColor(const QString &theme, const QString &tint=QString());
|
explicit XlsxColor(const QString &theme, const QString &tint = QString());
|
||||||
explicit XlsxColor (int index);
|
explicit XlsxColor(int index);
|
||||||
|
|
||||||
bool isThemeColor() const;
|
bool isThemeColor() const;
|
||||||
bool isIndexedColor() const;
|
bool isIndexedColor() const;
|
||||||
@ -36,7 +36,7 @@ public:
|
|||||||
static QColor fromARGBString(const QString &c);
|
static QColor fromARGBString(const QString &c);
|
||||||
static QString toARGBString(const QColor &c);
|
static QString toARGBString(const QColor &c);
|
||||||
|
|
||||||
bool saveToXml(QXmlStreamWriter &writer, const QString &node=QString()) const;
|
bool saveToXml(QXmlStreamWriter &writer, const QString &node = QString()) const;
|
||||||
bool loadFromXml(QXmlStreamReader &reader);
|
bool loadFromXml(QXmlStreamReader &reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -44,12 +44,12 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(QT_NO_DATASTREAM)
|
#if !defined(QT_NO_DATASTREAM)
|
||||||
QDataStream &operator<<(QDataStream &, const XlsxColor &);
|
QDataStream &operator<<(QDataStream &, const XlsxColor &);
|
||||||
QDataStream &operator>>(QDataStream &, XlsxColor &);
|
QDataStream &operator>>(QDataStream &, XlsxColor &);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
QDebug operator<<(QDebug dbg, const XlsxColor &c);
|
QDebug operator<<(QDebug dbg, const XlsxColor &c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,17 +3,17 @@
|
|||||||
#ifndef QXLSX_XLSXCONDITIONALFORMATTING_H
|
#ifndef QXLSX_XLSXCONDITIONALFORMATTING_H
|
||||||
#define QXLSX_XLSXCONDITIONALFORMATTING_H
|
#define QXLSX_XLSXCONDITIONALFORMATTING_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
|
||||||
#include <QList>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QSharedDataPointer>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxcellreference.h"
|
#include "xlsxcellreference.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QList>
|
||||||
|
#include <QSharedDataPointer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
class ConditionalFormattingTest;
|
class ConditionalFormattingTest;
|
||||||
|
|
||||||
@ -70,15 +70,7 @@ public:
|
|||||||
Highlight_Expression
|
Highlight_Expression
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ValueObjectType
|
enum ValueObjectType { VOT_Formula, VOT_Max, VOT_Min, VOT_Num, VOT_Percent, VOT_Percentile };
|
||||||
{
|
|
||||||
VOT_Formula,
|
|
||||||
VOT_Max,
|
|
||||||
VOT_Min,
|
|
||||||
VOT_Num,
|
|
||||||
VOT_Percent,
|
|
||||||
VOT_Percentile
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConditionalFormatting();
|
ConditionalFormatting();
|
||||||
@ -86,13 +78,32 @@ public:
|
|||||||
~ConditionalFormatting();
|
~ConditionalFormatting();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool addHighlightCellsRule(HighlightRuleType type, const Format &format, bool stopIfTrue=false);
|
bool addHighlightCellsRule(HighlightRuleType type,
|
||||||
bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const Format &format, bool stopIfTrue=false);
|
const Format &format,
|
||||||
bool addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const QString &formula2, const Format &format, bool stopIfTrue=false);
|
bool stopIfTrue = false);
|
||||||
bool addDataBarRule(const QColor &color, bool showData=true, bool stopIfTrue=false);
|
bool addHighlightCellsRule(HighlightRuleType type,
|
||||||
bool addDataBarRule(const QColor &color, ValueObjectType type1, const QString &val1, ValueObjectType type2, const QString &val2, bool showData=true, bool stopIfTrue=false);
|
const QString &formula1,
|
||||||
bool add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue=false);
|
const Format &format,
|
||||||
bool add3ColorScaleRule(const QColor &minColor, const QColor &midColor, const QColor &maxColor, bool stopIfTrue=false);
|
bool stopIfTrue = false);
|
||||||
|
bool addHighlightCellsRule(HighlightRuleType type,
|
||||||
|
const QString &formula1,
|
||||||
|
const QString &formula2,
|
||||||
|
const Format &format,
|
||||||
|
bool stopIfTrue = false);
|
||||||
|
bool addDataBarRule(const QColor &color, bool showData = true, bool stopIfTrue = false);
|
||||||
|
bool addDataBarRule(const QColor &color,
|
||||||
|
ValueObjectType type1,
|
||||||
|
const QString &val1,
|
||||||
|
ValueObjectType type2,
|
||||||
|
const QString &val2,
|
||||||
|
bool showData = true,
|
||||||
|
bool stopIfTrue = false);
|
||||||
|
bool
|
||||||
|
add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue = false);
|
||||||
|
bool add3ColorScaleRule(const QColor &minColor,
|
||||||
|
const QColor &midColor,
|
||||||
|
const QColor &maxColor,
|
||||||
|
bool stopIfTrue = false);
|
||||||
|
|
||||||
QList<CellRange> ranges() const;
|
QList<CellRange> ranges() const;
|
||||||
|
|
||||||
@ -101,7 +112,7 @@ public:
|
|||||||
void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
|
void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
|
||||||
void addRange(const CellRange &range);
|
void addRange(const CellRange &range);
|
||||||
|
|
||||||
//needed by QSharedDataPointer!!
|
// needed by QSharedDataPointer!!
|
||||||
ConditionalFormatting &operator=(const ConditionalFormatting &other);
|
ConditionalFormatting &operator=(const ConditionalFormatting &other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -110,7 +121,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool saveToXml(QXmlStreamWriter &writer) const;
|
bool saveToXml(QXmlStreamWriter &writer) const;
|
||||||
bool loadFromXml(QXmlStreamReader &reader, Styles* styles = NULL);
|
bool loadFromXml(QXmlStreamReader &reader, Styles *styles = NULL);
|
||||||
|
|
||||||
QSharedDataPointer<ConditionalFormattingPrivate> d;
|
QSharedDataPointer<ConditionalFormattingPrivate> d;
|
||||||
};
|
};
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
#ifndef XLSXCONDITIONALFORMATTING_P_H
|
#ifndef XLSXCONDITIONALFORMATTING_P_H
|
||||||
#define XLSXCONDITIONALFORMATTING_P_H
|
#define XLSXCONDITIONALFORMATTING_P_H
|
||||||
|
|
||||||
#include <QSharedData>
|
#include "xlsxcolor_p.h"
|
||||||
#include <QMap>
|
#include "xlsxconditionalformatting.h"
|
||||||
|
#include "xlsxformat.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xlsxconditionalformatting.h"
|
#include <QMap>
|
||||||
#include "xlsxformat.h"
|
#include <QSharedData>
|
||||||
#include "xlsxcolor_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -18,12 +18,14 @@ class XlsxCfVoData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XlsxCfVoData()
|
XlsxCfVoData()
|
||||||
:gte(true)
|
: gte(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XlsxCfVoData(ConditionalFormatting::ValueObjectType type, const QString &value, bool gte=true)
|
XlsxCfVoData(ConditionalFormatting::ValueObjectType type, const QString &value, bool gte = true)
|
||||||
:type(type), value(value), gte(gte)
|
: type(type)
|
||||||
|
, value(value)
|
||||||
|
, gte(gte)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ public:
|
|||||||
enum Attribute {
|
enum Attribute {
|
||||||
A_type,
|
A_type,
|
||||||
A_dxfId,
|
A_dxfId,
|
||||||
//A_priority,
|
// A_priority,
|
||||||
A_stopIfTrue,
|
A_stopIfTrue,
|
||||||
A_aboveAverage,
|
A_aboveAverage,
|
||||||
A_percent,
|
A_percent,
|
||||||
@ -68,8 +70,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
XlsxCfRuleData()
|
XlsxCfRuleData()
|
||||||
:priority(1)
|
: priority(1)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int priority;
|
int priority;
|
||||||
Format dxfFormat;
|
Format dxfFormat;
|
||||||
@ -83,13 +86,13 @@ public:
|
|||||||
ConditionalFormattingPrivate(const ConditionalFormattingPrivate &other);
|
ConditionalFormattingPrivate(const ConditionalFormattingPrivate &other);
|
||||||
~ConditionalFormattingPrivate();
|
~ConditionalFormattingPrivate();
|
||||||
|
|
||||||
void writeCfVo(QXmlStreamWriter &writer, const XlsxCfVoData& cfvo) const;
|
void writeCfVo(QXmlStreamWriter &writer, const XlsxCfVoData &cfvo) const;
|
||||||
bool readCfVo(QXmlStreamReader &reader, XlsxCfVoData& cfvo);
|
bool readCfVo(QXmlStreamReader &reader, XlsxCfVoData &cfvo);
|
||||||
bool readCfRule(QXmlStreamReader &reader, XlsxCfRuleData *cfRule, Styles *styles);
|
bool readCfRule(QXmlStreamReader &reader, XlsxCfRuleData *cfRule, Styles *styles);
|
||||||
bool readCfDataBar(QXmlStreamReader &reader, XlsxCfRuleData *cfRule);
|
bool readCfDataBar(QXmlStreamReader &reader, XlsxCfRuleData *cfRule);
|
||||||
bool readCfColorScale(QXmlStreamReader &reader, XlsxCfRuleData *cfRule);
|
bool readCfColorScale(QXmlStreamReader &reader, XlsxCfRuleData *cfRule);
|
||||||
|
|
||||||
QList<std::shared_ptr<XlsxCfRuleData> >cfRules;
|
QList<std::shared_ptr<XlsxCfRuleData>> cfRules;
|
||||||
QList<CellRange> ranges;
|
QList<CellRange> ranges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
#ifndef XLSXCONTENTTYPES_H
|
#ifndef XLSXCONTENTTYPES_H
|
||||||
#define XLSXCONTENTTYPES_H
|
#define XLSXCONTENTTYPES_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMap>
|
#include <QtGlobal>
|
||||||
#include <QIODevice>
|
|
||||||
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public:
|
|||||||
void addDefault(const QString &key, const QString &value);
|
void addDefault(const QString &key, const QString &value);
|
||||||
void addOverride(const QString &key, const QString &value);
|
void addOverride(const QString &key, const QString &value);
|
||||||
|
|
||||||
//Convenient funcation for addOverride()
|
// Convenient funcation for addOverride()
|
||||||
void addDocPropCore();
|
void addDocPropCore();
|
||||||
void addDocPropApp();
|
void addDocPropApp();
|
||||||
void addStyles();
|
void addStyles();
|
||||||
@ -43,6 +43,7 @@ public:
|
|||||||
|
|
||||||
void saveToXmlFile(QIODevice *device) const override;
|
void saveToXmlFile(QIODevice *device) const override;
|
||||||
bool loadFromXmlFile(QIODevice *device) override;
|
bool loadFromXmlFile(QIODevice *device) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<QString, QString> m_defaults;
|
QMap<QString, QString> m_defaults;
|
||||||
QMap<QString, QString> m_overrides;
|
QMap<QString, QString> m_overrides;
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
#ifndef QXLSX_XLSXDATAVALIDATION_H
|
#ifndef QXLSX_XLSXDATAVALIDATION_H
|
||||||
#define QXLSX_XLSXDATAVALIDATION_H
|
#define QXLSX_XLSXDATAVALIDATION_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxglobal.h"
|
|
||||||
|
|
||||||
class QXmlStreamReader;
|
class QXmlStreamReader;
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
@ -25,20 +25,9 @@ class DataValidationPrivate;
|
|||||||
class QXLSX_EXPORT DataValidation
|
class QXLSX_EXPORT DataValidation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ValidationType
|
enum ValidationType { None, Whole, Decimal, List, Date, Time, TextLength, Custom };
|
||||||
{
|
|
||||||
None,
|
|
||||||
Whole,
|
|
||||||
Decimal,
|
|
||||||
List,
|
|
||||||
Date,
|
|
||||||
Time,
|
|
||||||
TextLength,
|
|
||||||
Custom
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ValidationOperator
|
enum ValidationOperator {
|
||||||
{
|
|
||||||
Between,
|
Between,
|
||||||
NotBetween,
|
NotBetween,
|
||||||
Equal,
|
Equal,
|
||||||
@ -49,16 +38,14 @@ public:
|
|||||||
GreaterThanOrEqual
|
GreaterThanOrEqual
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ErrorStyle
|
enum ErrorStyle { Stop, Warning, Information };
|
||||||
{
|
|
||||||
Stop,
|
|
||||||
Warning,
|
|
||||||
Information
|
|
||||||
};
|
|
||||||
|
|
||||||
DataValidation();
|
DataValidation();
|
||||||
DataValidation(ValidationType type, ValidationOperator op=Between, const QString &formula1=QString()
|
DataValidation(ValidationType type,
|
||||||
, const QString &formula2=QString(), bool allowBlank=false);
|
ValidationOperator op = Between,
|
||||||
|
const QString &formula1 = QString(),
|
||||||
|
const QString &formula2 = QString(),
|
||||||
|
bool allowBlank = false);
|
||||||
DataValidation(const DataValidation &other);
|
DataValidation(const DataValidation &other);
|
||||||
~DataValidation();
|
~DataValidation();
|
||||||
|
|
||||||
@ -81,8 +68,8 @@ public:
|
|||||||
void setErrorStyle(ErrorStyle es);
|
void setErrorStyle(ErrorStyle es);
|
||||||
void setFormula1(const QString &formula);
|
void setFormula1(const QString &formula);
|
||||||
void setFormula2(const QString &formula);
|
void setFormula2(const QString &formula);
|
||||||
void setErrorMessage(const QString &error, const QString &title=QString());
|
void setErrorMessage(const QString &error, const QString &title = QString());
|
||||||
void setPromptMessage(const QString &prompt, const QString &title=QString());
|
void setPromptMessage(const QString &prompt, const QString &title = QString());
|
||||||
void setAllowBlank(bool enable);
|
void setAllowBlank(bool enable);
|
||||||
void setPromptMessageVisible(bool visible);
|
void setPromptMessageVisible(bool visible);
|
||||||
void setErrorMessageVisible(bool visible);
|
void setErrorMessageVisible(bool visible);
|
||||||
@ -96,6 +83,7 @@ public:
|
|||||||
|
|
||||||
bool saveToXml(QXmlStreamWriter &writer) const;
|
bool saveToXml(QXmlStreamWriter &writer) const;
|
||||||
static DataValidation loadFromXml(QXmlStreamReader &reader);
|
static DataValidation loadFromXml(QXmlStreamReader &reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<DataValidationPrivate> d;
|
QSharedDataPointer<DataValidationPrivate> d;
|
||||||
};
|
};
|
||||||
|
@ -3,18 +3,22 @@
|
|||||||
#ifndef XLSXDATAVALIDATION_P_H
|
#ifndef XLSXDATAVALIDATION_P_H
|
||||||
#define XLSXDATAVALIDATION_P_H
|
#define XLSXDATAVALIDATION_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QSharedData>
|
|
||||||
|
|
||||||
#include "xlsxdatavalidation.h"
|
#include "xlsxdatavalidation.h"
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class DataValidationPrivate : public QSharedData
|
class DataValidationPrivate : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DataValidationPrivate();
|
DataValidationPrivate();
|
||||||
DataValidationPrivate(DataValidation::ValidationType type, DataValidation::ValidationOperator op, const QString &formula1, const QString &formula2, bool allowBlank);
|
DataValidationPrivate(DataValidation::ValidationType type,
|
||||||
|
DataValidation::ValidationOperator op,
|
||||||
|
const QString &formula1,
|
||||||
|
const QString &formula2,
|
||||||
|
bool allowBlank);
|
||||||
DataValidationPrivate(const DataValidationPrivate &other);
|
DataValidationPrivate(const DataValidationPrivate &other);
|
||||||
~DataValidationPrivate();
|
~DataValidationPrivate();
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
#ifndef QXLSX_XLSXDATETYPE_H
|
#ifndef QXLSX_XLSXDATETYPE_H
|
||||||
#define QXLSX_XLSXDATETYPE_H
|
#define QXLSX_XLSXDATETYPE_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDate>
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxglobal.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -19,30 +19,30 @@ class QXLSX_EXPORT DateType
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DateType();
|
DateType();
|
||||||
/*
|
/*
|
||||||
DateType(bool is1904 = false);
|
DateType(bool is1904 = false);
|
||||||
DateType(double d, bool is1904 = false);
|
DateType(double d, bool is1904 = false);
|
||||||
DateType(QDateTime qdt, bool is1904 = false);
|
DateType(QDateTime qdt, bool is1904 = false);
|
||||||
DateType(QDate qd, bool is1904 = false);
|
DateType(QDate qd, bool is1904 = false);
|
||||||
DateType(QTime qt, bool is1904 = false);
|
DateType(QTime qt, bool is1904 = false);
|
||||||
public:
|
public:
|
||||||
enum currentDateType { DateAndTimeType, OnlyDateType, OnlyTimeType };
|
enum currentDateType { DateAndTimeType, OnlyDateType, OnlyTimeType };
|
||||||
public:
|
public:
|
||||||
currentDateType getType();
|
currentDateType getType();
|
||||||
bool getValue(QDateTime* pQdt);
|
bool getValue(QDateTime* pQdt);
|
||||||
bool getValue(QDate* pQd);
|
bool getValue(QDate* pQd);
|
||||||
bool getValue(QTime* pQt);
|
bool getValue(QTime* pQt);
|
||||||
bool getValue(double* pD);
|
bool getValue(double* pD);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isSet;
|
bool isSet;
|
||||||
double dValue;
|
double dValue;
|
||||||
bool is1904Type;
|
bool is1904Type;
|
||||||
currentDateType dType;
|
currentDateType dType;
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,22 +3,22 @@
|
|||||||
#ifndef XLSXDOCPROPSAPP_H
|
#ifndef XLSXDOCPROPSAPP_H
|
||||||
#define XLSXDOCPROPSAPP_H
|
#define XLSXDOCPROPSAPP_H
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class DocPropsApp : public AbstractOOXmlFile
|
class DocPropsApp : public AbstractOOXmlFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DocPropsApp(CreateFlag flag);
|
DocPropsApp(CreateFlag flag);
|
||||||
|
|
||||||
void addPartTitle(const QString &title);
|
void addPartTitle(const QString &title);
|
||||||
void addHeadingPair(const QString &name, int value);
|
void addHeadingPair(const QString &name, int value);
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList m_titlesOfPartsList;
|
QStringList m_titlesOfPartsList;
|
||||||
QList<std::pair<QString, int> > m_headingPairsList;
|
QList<std::pair<QString, int>> m_headingPairsList;
|
||||||
QMap<QString, QString> m_properties;
|
QMap<QString, QString> m_properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#ifndef XLSXDOCPROPSCORE_H
|
#ifndef XLSXDOCPROPSCORE_H
|
||||||
#define XLSXDOCPROPSCORE_H
|
#define XLSXDOCPROPSCORE_H
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -21,7 +21,7 @@ public:
|
|||||||
bool setProperty(const QString &name, const QString &value);
|
bool setProperty(const QString &name, const QString &value);
|
||||||
QString property(const QString &name) const;
|
QString property(const QString &name) const;
|
||||||
QStringList propertyNames() const;
|
QStringList propertyNames() const;
|
||||||
|
|
||||||
void saveToXmlFile(QIODevice *device) const override;
|
void saveToXmlFile(QIODevice *device) const override;
|
||||||
bool loadFromXmlFile(QIODevice *device) override;
|
bool loadFromXmlFile(QIODevice *device) override;
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
#ifndef QXLSX_XLSXDOCUMENT_H
|
#ifndef QXLSX_XLSXDOCUMENT_H
|
||||||
#define QXLSX_XLSXDOCUMENT_H
|
#define QXLSX_XLSXDOCUMENT_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxformat.h"
|
||||||
#include <QObject>
|
#include "xlsxglobal.h"
|
||||||
#include <QVariant>
|
#include "xlsxworksheet.h"
|
||||||
|
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QObject>
|
||||||
#include "xlsxglobal.h"
|
#include <QVariant>
|
||||||
#include "xlsxformat.h"
|
#include <QtGlobal>
|
||||||
#include "xlsxworksheet.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -26,102 +26,105 @@ class DocumentPrivate;
|
|||||||
|
|
||||||
class QXLSX_EXPORT Document : public QObject
|
class QXLSX_EXPORT Document : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DECLARE_PRIVATE(Document) // D-Pointer. Qt classes have a Q_DECLARE_PRIVATE
|
Q_DECLARE_PRIVATE(Document) // D-Pointer. Qt classes have a Q_DECLARE_PRIVATE
|
||||||
// macro in the public class. The macro reads: qglobal.h
|
// macro in the public class. The macro reads: qglobal.h
|
||||||
public:
|
public:
|
||||||
explicit Document(QObject *parent = nullptr);
|
explicit Document(QObject *parent = nullptr);
|
||||||
Document(const QString& xlsxName, QObject* parent = nullptr);
|
Document(const QString &xlsxName, QObject *parent = nullptr);
|
||||||
Document(QIODevice* device, QObject* parent = nullptr);
|
Document(QIODevice *device, QObject *parent = nullptr);
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
|
bool write(const CellReference &cell, const QVariant &value, const Format &format = Format());
|
||||||
|
bool write(int row, int col, const QVariant &value, const Format &format = Format());
|
||||||
|
|
||||||
|
QVariant read(const CellReference &cell) const;
|
||||||
|
QVariant read(int row, int col) const;
|
||||||
|
|
||||||
bool write(const CellReference &cell, const QVariant &value, const Format &format=Format());
|
|
||||||
bool write(int row, int col, const QVariant &value, const Format &format=Format());
|
|
||||||
|
|
||||||
QVariant read(const CellReference &cell) const;
|
|
||||||
QVariant read(int row, int col) const;
|
|
||||||
|
|
||||||
int insertImage(int row, int col, const QImage &image);
|
int insertImage(int row, int col, const QImage &image);
|
||||||
bool getImage(int imageIndex, QImage& img);
|
bool getImage(int imageIndex, QImage &img);
|
||||||
bool getImage(int row, int col, QImage& img);
|
bool getImage(int row, int col, QImage &img);
|
||||||
uint getImageCount();
|
uint getImageCount();
|
||||||
|
|
||||||
Chart *insertChart(int row, int col, const QSize &size);
|
|
||||||
|
|
||||||
bool mergeCells(const CellRange &range, const Format &format=Format());
|
|
||||||
bool unmergeCells(const CellRange &range);
|
|
||||||
|
|
||||||
bool setColumnWidth(const CellRange &range, double width);
|
Chart *insertChart(int row, int col, const QSize &size);
|
||||||
bool setColumnFormat(const CellRange &range, const Format &format);
|
|
||||||
bool setColumnHidden(const CellRange &range, bool hidden);
|
|
||||||
bool setColumnWidth(int column, double width);
|
|
||||||
bool setColumnFormat(int column, const Format &format);
|
|
||||||
bool setColumnHidden(int column, bool hidden);
|
|
||||||
bool setColumnWidth(int colFirst, int colLast, double width);
|
|
||||||
bool setColumnFormat(int colFirst, int colLast, const Format &format);
|
|
||||||
bool setColumnHidden(int colFirst, int colLast, bool hidden);
|
|
||||||
|
|
||||||
double columnWidth(int column);
|
|
||||||
Format columnFormat(int column);
|
|
||||||
bool isColumnHidden(int column);
|
|
||||||
|
|
||||||
bool setRowHeight(int row, double height);
|
bool mergeCells(const CellRange &range, const Format &format = Format());
|
||||||
bool setRowFormat(int row, const Format &format);
|
bool unmergeCells(const CellRange &range);
|
||||||
bool setRowHidden(int row, bool hidden);
|
|
||||||
bool setRowHeight(int rowFirst, int rowLast, double height);
|
|
||||||
bool setRowFormat(int rowFirst, int rowLast, const Format &format);
|
|
||||||
bool setRowHidden(int rowFirst, int rowLast, bool hidden);
|
|
||||||
|
|
||||||
double rowHeight(int row);
|
bool setColumnWidth(const CellRange &range, double width);
|
||||||
Format rowFormat(int row);
|
bool setColumnFormat(const CellRange &range, const Format &format);
|
||||||
bool isRowHidden(int row);
|
bool setColumnHidden(const CellRange &range, bool hidden);
|
||||||
|
bool setColumnWidth(int column, double width);
|
||||||
|
bool setColumnFormat(int column, const Format &format);
|
||||||
|
bool setColumnHidden(int column, bool hidden);
|
||||||
|
bool setColumnWidth(int colFirst, int colLast, double width);
|
||||||
|
bool setColumnFormat(int colFirst, int colLast, const Format &format);
|
||||||
|
bool setColumnHidden(int colFirst, int colLast, bool hidden);
|
||||||
|
|
||||||
bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
|
double columnWidth(int column);
|
||||||
bool groupColumns(int colFirst, int colLast, bool collapsed = true);
|
Format columnFormat(int column);
|
||||||
|
bool isColumnHidden(int column);
|
||||||
bool addDataValidation(const DataValidation &validation);
|
|
||||||
bool addConditionalFormatting(const ConditionalFormatting &cf);
|
|
||||||
|
|
||||||
Cell *cellAt(const CellReference &cell) const;
|
bool setRowHeight(int row, double height);
|
||||||
Cell *cellAt(int row, int col) const;
|
bool setRowFormat(int row, const Format &format);
|
||||||
|
bool setRowHidden(int row, bool hidden);
|
||||||
|
bool setRowHeight(int rowFirst, int rowLast, double height);
|
||||||
|
bool setRowFormat(int rowFirst, int rowLast, const Format &format);
|
||||||
|
bool setRowHidden(int rowFirst, int rowLast, bool hidden);
|
||||||
|
|
||||||
bool defineName(const QString &name, const QString &formula,
|
double rowHeight(int row);
|
||||||
const QString &comment=QString(), const QString &scope=QString());
|
Format rowFormat(int row);
|
||||||
|
bool isRowHidden(int row);
|
||||||
|
|
||||||
CellRange dimension() const;
|
bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
|
||||||
|
bool groupColumns(int colFirst, int colLast, bool collapsed = true);
|
||||||
|
|
||||||
QString documentProperty(const QString &name) const;
|
bool addDataValidation(const DataValidation &validation);
|
||||||
void setDocumentProperty(const QString &name, const QString &property);
|
bool addConditionalFormatting(const ConditionalFormatting &cf);
|
||||||
QStringList documentPropertyNames() const;
|
|
||||||
|
|
||||||
QStringList sheetNames() const;
|
Cell *cellAt(const CellReference &cell) const;
|
||||||
bool addSheet(const QString &name = QString(),
|
Cell *cellAt(int row, int col) const;
|
||||||
|
|
||||||
|
bool defineName(const QString &name,
|
||||||
|
const QString &formula,
|
||||||
|
const QString &comment = QString(),
|
||||||
|
const QString &scope = QString());
|
||||||
|
|
||||||
|
CellRange dimension() const;
|
||||||
|
|
||||||
|
QString documentProperty(const QString &name) const;
|
||||||
|
void setDocumentProperty(const QString &name, const QString &property);
|
||||||
|
QStringList documentPropertyNames() const;
|
||||||
|
|
||||||
|
QStringList sheetNames() const;
|
||||||
|
bool addSheet(const QString &name = QString(),
|
||||||
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
||||||
bool insertSheet(int index, const QString &name = QString(),
|
bool insertSheet(int index,
|
||||||
|
const QString &name = QString(),
|
||||||
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
||||||
bool selectSheet(const QString &name);
|
bool selectSheet(const QString &name);
|
||||||
bool selectSheet(int index);
|
bool selectSheet(int index);
|
||||||
bool renameSheet(const QString &oldName, const QString &newName);
|
bool renameSheet(const QString &oldName, const QString &newName);
|
||||||
bool copySheet(const QString &srcName, const QString &distName = QString());
|
bool copySheet(const QString &srcName, const QString &distName = QString());
|
||||||
bool moveSheet(const QString &srcName, int distIndex);
|
bool moveSheet(const QString &srcName, int distIndex);
|
||||||
bool deleteSheet(const QString &name);
|
bool deleteSheet(const QString &name);
|
||||||
|
|
||||||
Workbook *workbook() const;
|
Workbook *workbook() const;
|
||||||
AbstractSheet *sheet(const QString &sheetName) const;
|
AbstractSheet *sheet(const QString &sheetName) const;
|
||||||
AbstractSheet *currentSheet() const;
|
AbstractSheet *currentSheet() const;
|
||||||
Worksheet *currentWorksheet() const;
|
Worksheet *currentWorksheet() const;
|
||||||
|
|
||||||
bool save() const;
|
bool save() const;
|
||||||
bool saveAs(const QString &xlsXname) const;
|
bool saveAs(const QString &xlsXname) const;
|
||||||
bool saveAs(QIODevice *device) const;
|
bool saveAs(QIODevice *device) const;
|
||||||
|
|
||||||
// copy style from one xlsx file to other
|
// copy style from one xlsx file to other
|
||||||
static bool copyStyle(const QString &from, const QString &to);
|
static bool copyStyle(const QString &from, const QString &to);
|
||||||
|
|
||||||
bool isLoadPackage() const;
|
bool isLoadPackage() const;
|
||||||
bool load() const; // equals to isLoadPackage()
|
bool load() const; // equals to isLoadPackage()
|
||||||
|
|
||||||
bool changeimage(int filenoinmidea,QString newfile); // add by liufeijin20181025
|
bool changeimage(int filenoinmidea, QString newfile); // add by liufeijin20181025
|
||||||
|
|
||||||
bool autosizeColumnWidth(const CellRange &range);
|
bool autosizeColumnWidth(const CellRange &range);
|
||||||
bool autosizeColumnWidth(int column);
|
bool autosizeColumnWidth(int column);
|
||||||
@ -129,13 +132,12 @@ public:
|
|||||||
bool autosizeColumnWidth(void);
|
bool autosizeColumnWidth(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<int, int> getMaximalColumnWidth(int firstRow=1, int lastRow=INT_MAX);
|
QMap<int, int> getMaximalColumnWidth(int firstRow = 1, int lastRow = INT_MAX);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(Document) // Disables the use of copy constructors and
|
Q_DISABLE_COPY(Document) // Disables the use of copy constructors and
|
||||||
// assignment operators for the given Class.
|
// assignment operators for the given Class.
|
||||||
DocumentPrivate* const d_ptr;
|
DocumentPrivate *const d_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
#ifndef XLSXDOCUMENT_P_H
|
#ifndef XLSXDOCUMENT_P_H
|
||||||
#define XLSXDOCUMENT_P_H
|
#define XLSXDOCUMENT_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxworkbook.h"
|
|
||||||
#include "xlsxcontenttypes_p.h"
|
#include "xlsxcontenttypes_p.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -23,17 +23,17 @@ public:
|
|||||||
bool loadPackage(QIODevice *device);
|
bool loadPackage(QIODevice *device);
|
||||||
bool savePackage(QIODevice *device) const;
|
bool savePackage(QIODevice *device) const;
|
||||||
|
|
||||||
// copy style from one xlsx file to other
|
// copy style from one xlsx file to other
|
||||||
static bool copyStyle(const QString &from, const QString &to);
|
static bool copyStyle(const QString &from, const QString &to);
|
||||||
|
|
||||||
Document *q_ptr;
|
Document *q_ptr;
|
||||||
const QString defaultPackageName; //default name when package name not specified
|
const QString defaultPackageName; // default name when package name not specified
|
||||||
QString packageName; //name of the .xlsx file
|
QString packageName; // name of the .xlsx file
|
||||||
|
|
||||||
QMap<QString, QString> documentProperties; //core, app and custom properties
|
QMap<QString, QString> documentProperties; // core, app and custom properties
|
||||||
QSharedPointer<Workbook> workbook;
|
QSharedPointer<Workbook> workbook;
|
||||||
std::shared_ptr<ContentTypes> contentTypes;
|
std::shared_ptr<ContentTypes> contentTypes;
|
||||||
bool isLoad;
|
bool isLoad;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
#ifndef QXLSX_DRAWING_H
|
#ifndef QXLSX_DRAWING_H
|
||||||
#define QXLSX_DRAWING_H
|
#define QXLSX_DRAWING_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
#include "xlsxrelationships_p.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxrelationships_p.h"
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
|
||||||
|
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
#ifndef QXLSX_XLSXDRAWINGANCHOR_P_H
|
#ifndef QXLSX_XLSXDRAWINGANCHOR_P_H
|
||||||
#define QXLSX_XLSXDRAWINGANCHOR_P_H
|
#define QXLSX_XLSXDRAWINGANCHOR_P_H
|
||||||
|
|
||||||
#include <QPoint>
|
#include "xlsxglobal.h"
|
||||||
#include <QSize>
|
|
||||||
#include <QString>
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include <QPoint>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QSize>
|
||||||
|
#include <QString>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -20,20 +20,19 @@ class Drawing;
|
|||||||
class MediaFile;
|
class MediaFile;
|
||||||
class Chart;
|
class Chart;
|
||||||
|
|
||||||
//Helper class
|
// Helper class
|
||||||
struct XlsxMarker
|
struct XlsxMarker {
|
||||||
{
|
XlsxMarker() {}
|
||||||
XlsxMarker(){}
|
|
||||||
XlsxMarker(int row, int column, int rowOffset, int colOffset)
|
XlsxMarker(int row, int column, int rowOffset, int colOffset)
|
||||||
:cell(QPoint(row, column)), offset(rowOffset, colOffset)
|
: cell(QPoint(row, column))
|
||||||
|
, offset(rowOffset, colOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int row() const {return cell.x();}
|
int row() const { return cell.x(); }
|
||||||
int col() const {return cell.y();}
|
int col() const { return cell.y(); }
|
||||||
int rowOff() const {return offset.width();}
|
int rowOff() const { return offset.width(); }
|
||||||
int colOff() const {return offset.height();}
|
int colOff() const { return offset.height(); }
|
||||||
|
|
||||||
QPoint cell;
|
QPoint cell;
|
||||||
QSize offset;
|
QSize offset;
|
||||||
@ -42,24 +41,17 @@ struct XlsxMarker
|
|||||||
class DrawingAnchor
|
class DrawingAnchor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ObjectType {
|
enum ObjectType { GraphicFrame, Shape, GroupShape, ConnectionShape, Picture, Unknown };
|
||||||
GraphicFrame,
|
|
||||||
Shape,
|
|
||||||
GroupShape,
|
|
||||||
ConnectionShape,
|
|
||||||
Picture,
|
|
||||||
Unknown
|
|
||||||
};
|
|
||||||
|
|
||||||
DrawingAnchor(Drawing *drawing, ObjectType objectType);
|
DrawingAnchor(Drawing *drawing, ObjectType objectType);
|
||||||
virtual ~DrawingAnchor();
|
virtual ~DrawingAnchor();
|
||||||
|
|
||||||
void setObjectPicture(const QImage &img);
|
void setObjectPicture(const QImage &img);
|
||||||
bool getObjectPicture(QImage &img);
|
bool getObjectPicture(QImage &img);
|
||||||
|
|
||||||
void setObjectGraphicFrame(QSharedPointer<Chart> chart);
|
void setObjectGraphicFrame(QSharedPointer<Chart> chart);
|
||||||
|
|
||||||
virtual bool loadFromXml(QXmlStreamReader &reader) = 0;
|
virtual bool loadFromXml(QXmlStreamReader &reader) = 0;
|
||||||
virtual void saveToXml(QXmlStreamWriter &writer) const = 0;
|
virtual void saveToXml(QXmlStreamWriter &writer) const = 0;
|
||||||
|
|
||||||
virtual int row() const;
|
virtual int row() const;
|
||||||
@ -78,7 +70,9 @@ protected:
|
|||||||
|
|
||||||
void saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const;
|
void saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const;
|
||||||
void saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const;
|
void saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const;
|
||||||
void saveXmlMarker(QXmlStreamWriter &writer, const XlsxMarker &marker, const QString &node) const;
|
void saveXmlMarker(QXmlStreamWriter &writer,
|
||||||
|
const XlsxMarker &marker,
|
||||||
|
const QString &node) const;
|
||||||
void saveXmlObject(QXmlStreamWriter &writer) const;
|
void saveXmlObject(QXmlStreamWriter &writer) const;
|
||||||
void saveXmlObjectShape(QXmlStreamWriter &writer) const;
|
void saveXmlObjectShape(QXmlStreamWriter &writer) const;
|
||||||
void saveXmlObjectGroupShape(QXmlStreamWriter &writer) const;
|
void saveXmlObjectGroupShape(QXmlStreamWriter &writer) const;
|
||||||
@ -92,40 +86,40 @@ protected:
|
|||||||
QSharedPointer<Chart> m_chartFile;
|
QSharedPointer<Chart> m_chartFile;
|
||||||
|
|
||||||
int m_id;
|
int m_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int getm_id();
|
int getm_id();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// liufeij {{
|
||||||
|
void setObjectShape(const QImage &img); // liufeij
|
||||||
|
|
||||||
// liufeij {{
|
QString editASName;
|
||||||
void setObjectShape(const QImage &img); // liufeij
|
|
||||||
|
|
||||||
QString editASName;
|
|
||||||
// below only for twocellanchor shape
|
// below only for twocellanchor shape
|
||||||
QPoint posTA; // for shape liufeij 20181024
|
QPoint posTA; // for shape liufeij 20181024
|
||||||
QSize extTA; // for shape liufeij 20181024
|
QSize extTA; // for shape liufeij 20181024
|
||||||
int rotWithShapeTA; //// for shape liufeij 20181024
|
int rotWithShapeTA; //// for shape liufeij 20181024
|
||||||
int dpiTA; //// for shape liufeij 20181024
|
int dpiTA; //// for shape liufeij 20181024
|
||||||
QString sp_textlink,sp_macro,sp_blip_cstate,sp_blip_rembed;
|
QString sp_textlink, sp_macro, sp_blip_cstate, sp_blip_rembed;
|
||||||
|
|
||||||
// BELOW only for cxnSp shape
|
// BELOW only for cxnSp shape
|
||||||
QString cxnSp_filpV,cxnSp_macro;
|
QString cxnSp_filpV, cxnSp_macro;
|
||||||
// belwo for cxnsp and sp
|
// belwo for cxnsp and sp
|
||||||
QString xsp_cNvPR_name,xsp_cNvPR_id; //x measns shape and cxnSp together using
|
QString xsp_cNvPR_name, xsp_cNvPR_id; // x measns shape and cxnSp together using
|
||||||
QString xbwMode; // same as above
|
QString xbwMode; // same as above
|
||||||
QString xIn_algn,xIn_cmpd,xIn_cap,xIn_w; //cxnSp only need xIn_w
|
QString xIn_algn, xIn_cmpd, xIn_cap, xIn_w; // cxnSp only need xIn_w
|
||||||
QString xprstGeom_prst;
|
QString xprstGeom_prst;
|
||||||
QString x_headEnd_w,x_headEnd_len,x_headEnd_tyep;
|
QString x_headEnd_w, x_headEnd_len, x_headEnd_tyep;
|
||||||
QString x_tailEnd_w,x_tailEnd_len,x_tailEnd_tyep;
|
QString x_tailEnd_w, x_tailEnd_len, x_tailEnd_tyep;
|
||||||
QString Style_inref_idx,style_fillref_idx,style_effectref_idx,style_forntref_idx;
|
QString Style_inref_idx, style_fillref_idx, style_effectref_idx, style_forntref_idx;
|
||||||
QString Style_inref_val,style_fillref_val,style_effectref_val,style_forntref_val;
|
QString Style_inref_val, style_fillref_val, style_effectref_val, style_forntref_val;
|
||||||
// liufeij }}
|
// liufeij }}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawingAbsoluteAnchor : public DrawingAnchor
|
class DrawingAbsoluteAnchor : public DrawingAnchor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType=Unknown);
|
DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType = Unknown);
|
||||||
|
|
||||||
QPoint pos;
|
QPoint pos;
|
||||||
QSize ext;
|
QSize ext;
|
||||||
@ -137,7 +131,7 @@ public:
|
|||||||
class DrawingOneCellAnchor : public DrawingAnchor
|
class DrawingOneCellAnchor : public DrawingAnchor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType=Unknown);
|
DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType = Unknown);
|
||||||
|
|
||||||
XlsxMarker from;
|
XlsxMarker from;
|
||||||
QSize ext;
|
QSize ext;
|
||||||
@ -152,7 +146,7 @@ public:
|
|||||||
class DrawingTwoCellAnchor : public DrawingAnchor
|
class DrawingTwoCellAnchor : public DrawingAnchor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType=Unknown);
|
DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType = Unknown);
|
||||||
|
|
||||||
XlsxMarker from;
|
XlsxMarker from;
|
||||||
XlsxMarker to;
|
XlsxMarker to;
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
#ifndef QXLSX_FORMAT_H
|
#ifndef QXLSX_FORMAT_H
|
||||||
#define QXLSX_FORMAT_H
|
#define QXLSX_FORMAT_H
|
||||||
|
|
||||||
#include <QFont>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QList>
|
|
||||||
#include <QExplicitlySharedDataPointer>
|
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QExplicitlySharedDataPointer>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QList>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
class FormatTest;
|
class FormatTest;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
@ -27,15 +27,9 @@ class FormatPrivate;
|
|||||||
class QXLSX_EXPORT Format
|
class QXLSX_EXPORT Format
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum FontScript
|
enum FontScript { FontScriptNormal, FontScriptSuper, FontScriptSub };
|
||||||
{
|
|
||||||
FontScriptNormal,
|
|
||||||
FontScriptSuper,
|
|
||||||
FontScriptSub
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FontUnderline
|
enum FontUnderline {
|
||||||
{
|
|
||||||
FontUnderlineNone,
|
FontUnderlineNone,
|
||||||
FontUnderlineSingle,
|
FontUnderlineSingle,
|
||||||
FontUnderlineDouble,
|
FontUnderlineDouble,
|
||||||
@ -43,8 +37,7 @@ public:
|
|||||||
FontUnderlineDoubleAccounting
|
FontUnderlineDoubleAccounting
|
||||||
};
|
};
|
||||||
|
|
||||||
enum HorizontalAlignment
|
enum HorizontalAlignment {
|
||||||
{
|
|
||||||
AlignHGeneral,
|
AlignHGeneral,
|
||||||
AlignLeft,
|
AlignLeft,
|
||||||
AlignHCenter,
|
AlignHCenter,
|
||||||
@ -55,8 +48,7 @@ public:
|
|||||||
AlignHDistributed
|
AlignHDistributed
|
||||||
};
|
};
|
||||||
|
|
||||||
enum VerticalAlignment
|
enum VerticalAlignment {
|
||||||
{
|
|
||||||
AlignTop,
|
AlignTop,
|
||||||
AlignVCenter,
|
AlignVCenter,
|
||||||
AlignBottom,
|
AlignBottom,
|
||||||
@ -64,8 +56,7 @@ public:
|
|||||||
AlignVDistributed
|
AlignVDistributed
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BorderStyle
|
enum BorderStyle {
|
||||||
{
|
|
||||||
BorderNone,
|
BorderNone,
|
||||||
BorderThin,
|
BorderThin,
|
||||||
BorderMedium,
|
BorderMedium,
|
||||||
@ -82,16 +73,14 @@ public:
|
|||||||
BorderSlantDashDot
|
BorderSlantDashDot
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DiagonalBorderType
|
enum DiagonalBorderType {
|
||||||
{
|
|
||||||
DiagonalBorderNone,
|
DiagonalBorderNone,
|
||||||
DiagonalBorderDown,
|
DiagonalBorderDown,
|
||||||
DiagonalBorderUp,
|
DiagonalBorderUp,
|
||||||
DiagnoalBorderBoth
|
DiagnoalBorderBoth
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FillPattern
|
enum FillPattern {
|
||||||
{
|
|
||||||
PatternNone,
|
PatternNone,
|
||||||
PatternSolid,
|
PatternSolid,
|
||||||
PatternMediumGray,
|
PatternMediumGray,
|
||||||
@ -200,16 +189,19 @@ public:
|
|||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
bool operator == (const Format &format) const;
|
bool operator==(const Format &format) const;
|
||||||
bool operator != (const Format &format) const;
|
bool operator!=(const Format &format) const;
|
||||||
|
|
||||||
QVariant property(int propertyId, const QVariant &defaultValue=QVariant()) const;
|
QVariant property(int propertyId, const QVariant &defaultValue = QVariant()) const;
|
||||||
void setProperty(int propertyId, const QVariant &value, const QVariant &clearValue=QVariant(), bool detach=true);
|
void setProperty(int propertyId,
|
||||||
|
const QVariant &value,
|
||||||
|
const QVariant &clearValue = QVariant(),
|
||||||
|
bool detach = true);
|
||||||
void clearProperty(int propertyId);
|
void clearProperty(int propertyId);
|
||||||
bool hasProperty(int propertyId) const;
|
bool hasProperty(int propertyId) const;
|
||||||
|
|
||||||
bool boolProperty(int propertyId, bool defaultValue=false) const;
|
bool boolProperty(int propertyId, bool defaultValue = false) const;
|
||||||
int intProperty(int propertyId, int defaultValue=0) const;
|
int intProperty(int propertyId, int defaultValue = 0) const;
|
||||||
double doubleProperty(int propertyId, double defaultValue = 0.0) const;
|
double doubleProperty(int propertyId, double defaultValue = 0.0) const;
|
||||||
QString stringProperty(int propertyId, const QString &defaultValue = QString()) const;
|
QString stringProperty(int propertyId, const QString &defaultValue = QString()) const;
|
||||||
QColor colorProperty(int propertyId, const QColor &defaultValue = QColor()) const;
|
QColor colorProperty(int propertyId, const QColor &defaultValue = QColor()) const;
|
||||||
@ -243,10 +235,11 @@ public:
|
|||||||
void setFillIndex(int index);
|
void setFillIndex(int index);
|
||||||
void setXfIndex(int index);
|
void setXfIndex(int index);
|
||||||
void setDxfIndex(int index);
|
void setDxfIndex(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Styles;
|
friend class Styles;
|
||||||
friend class ::FormatTest;
|
friend class ::FormatTest;
|
||||||
friend QDebug operator<<(QDebug, const Format &f);
|
friend QDebug operator<<(QDebug, const Format &f);
|
||||||
|
|
||||||
int theme() const;
|
int theme() const;
|
||||||
|
|
||||||
@ -254,7 +247,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
QDebug operator<<(QDebug dbg, const Format &f);
|
QDebug operator<<(QDebug dbg, const Format &f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -2,37 +2,36 @@
|
|||||||
#ifndef XLSXFORMAT_P_H
|
#ifndef XLSXFORMAT_P_H
|
||||||
#define XLSXFORMAT_P_H
|
#define XLSXFORMAT_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxformat.h"
|
||||||
#include <QSharedData>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QSharedData>
|
||||||
#include "xlsxformat.h"
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class FormatPrivate : public QSharedData
|
class FormatPrivate : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum FormatType
|
enum FormatType {
|
||||||
{
|
FT_Invalid = 0,
|
||||||
FT_Invalid = 0,
|
FT_NumFmt = 0x01,
|
||||||
FT_NumFmt = 0x01,
|
FT_Font = 0x02,
|
||||||
FT_Font = 0x02,
|
FT_Alignment = 0x04,
|
||||||
FT_Alignment = 0x04,
|
FT_Border = 0x08,
|
||||||
FT_Border = 0x08,
|
FT_Fill = 0x10,
|
||||||
FT_Fill = 0x10,
|
|
||||||
FT_Protection = 0x20
|
FT_Protection = 0x20
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Property {
|
enum Property {
|
||||||
P_STARTID,
|
P_STARTID,
|
||||||
|
|
||||||
//numFmt
|
// numFmt
|
||||||
P_NumFmt_Id,
|
P_NumFmt_Id,
|
||||||
P_NumFmt_FormatCode,
|
P_NumFmt_FormatCode,
|
||||||
|
|
||||||
//font
|
// font
|
||||||
P_Font_STARTID,
|
P_Font_STARTID,
|
||||||
P_Font_Size = P_Font_STARTID,
|
P_Font_Size = P_Font_STARTID,
|
||||||
P_Font_Italic,
|
P_Font_Italic,
|
||||||
@ -51,7 +50,7 @@ public:
|
|||||||
P_Font_Extend,
|
P_Font_Extend,
|
||||||
P_Font_ENDID,
|
P_Font_ENDID,
|
||||||
|
|
||||||
//border
|
// border
|
||||||
P_Border_STARTID,
|
P_Border_STARTID,
|
||||||
P_Border_LeftStyle = P_Border_STARTID,
|
P_Border_LeftStyle = P_Border_STARTID,
|
||||||
P_Border_RightStyle,
|
P_Border_RightStyle,
|
||||||
@ -66,14 +65,14 @@ public:
|
|||||||
P_Border_DiagonalType,
|
P_Border_DiagonalType,
|
||||||
P_Border_ENDID,
|
P_Border_ENDID,
|
||||||
|
|
||||||
//fill
|
// fill
|
||||||
P_Fill_STARTID,
|
P_Fill_STARTID,
|
||||||
P_Fill_Pattern = P_Fill_STARTID,
|
P_Fill_Pattern = P_Fill_STARTID,
|
||||||
P_Fill_BgColor,
|
P_Fill_BgColor,
|
||||||
P_Fill_FgColor,
|
P_Fill_FgColor,
|
||||||
P_Fill_ENDID,
|
P_Fill_ENDID,
|
||||||
|
|
||||||
//alignment
|
// alignment
|
||||||
P_Alignment_STARTID,
|
P_Alignment_STARTID,
|
||||||
P_Alignment_AlignH = P_Alignment_STARTID,
|
P_Alignment_AlignH = P_Alignment_STARTID,
|
||||||
P_Alignment_AlignV,
|
P_Alignment_AlignV,
|
||||||
@ -83,7 +82,7 @@ public:
|
|||||||
P_Alignment_ShinkToFit,
|
P_Alignment_ShinkToFit,
|
||||||
P_Alignment_ENDID,
|
P_Alignment_ENDID,
|
||||||
|
|
||||||
//protection
|
// protection
|
||||||
P_Protection_Locked,
|
P_Protection_Locked,
|
||||||
P_Protection_Hidden,
|
P_Protection_Hidden,
|
||||||
|
|
||||||
@ -94,7 +93,7 @@ public:
|
|||||||
FormatPrivate(const FormatPrivate &other);
|
FormatPrivate(const FormatPrivate &other);
|
||||||
~FormatPrivate();
|
~FormatPrivate();
|
||||||
|
|
||||||
bool dirty; //The key re-generation is need.
|
bool dirty; // The key re-generation is need.
|
||||||
QByteArray formatKey;
|
QByteArray formatKey;
|
||||||
|
|
||||||
bool font_dirty;
|
bool font_dirty;
|
||||||
@ -124,7 +123,6 @@ public:
|
|||||||
QMap<int, QVariant> properties;
|
QMap<int, QVariant> properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,25 +4,25 @@
|
|||||||
#define XLSXGLOBAL_H
|
#define XLSXGLOBAL_H
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QByteArray>
|
||||||
|
#include <QIODevice>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
|
||||||
#include <QIODevice>
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#if defined(QXlsx_SHAREDLIB)
|
#if defined(QXlsx_SHAREDLIB)
|
||||||
#if defined(QXlsx_EXPORTS)
|
# if defined(QXlsx_EXPORTS)
|
||||||
# define QXLSX_EXPORT Q_DECL_EXPORT
|
# define QXLSX_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define QXLSX_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
# define QXLSX_EXPORT Q_DECL_IMPORT
|
# define QXLSX_EXPORT
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
# define QXLSX_EXPORT
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx {
|
#define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx {
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -14,10 +14,10 @@ class MediaFile
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MediaFile(const QString &fileName);
|
MediaFile(const QString &fileName);
|
||||||
MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString());
|
MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType = QString());
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString());
|
void set(const QByteArray &bytes, const QString &suffix, const QString &mimeType = QString());
|
||||||
QString suffix() const;
|
QString suffix() const;
|
||||||
QString mimeType() const;
|
QString mimeType() const;
|
||||||
QByteArray contents() const;
|
QByteArray contents() const;
|
||||||
|
@ -38,21 +38,20 @@
|
|||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QIODevice>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QIODevice>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
struct XlsxRelationship
|
struct XlsxRelationship {
|
||||||
{
|
|
||||||
QString id;
|
QString id;
|
||||||
QString type;
|
QString type;
|
||||||
QString target;
|
QString target;
|
||||||
QString targetMode;
|
QString targetMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Relationships
|
class Relationships
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Relationships();
|
Relationships();
|
||||||
@ -65,7 +64,9 @@ public:
|
|||||||
void addDocumentRelationship(const QString &relativeType, const QString &target);
|
void addDocumentRelationship(const QString &relativeType, const QString &target);
|
||||||
void addPackageRelationship(const QString &relativeType, const QString &target);
|
void addPackageRelationship(const QString &relativeType, const QString &target);
|
||||||
void addMsPackageRelationship(const QString &relativeType, const QString &target);
|
void addMsPackageRelationship(const QString &relativeType, const QString &target);
|
||||||
void addWorksheetRelationship(const QString &relativeType, const QString &target, const QString &targetMode=QString());
|
void addWorksheetRelationship(const QString &relativeType,
|
||||||
|
const QString &target,
|
||||||
|
const QString &targetMode = QString());
|
||||||
|
|
||||||
void saveToXmlFile(QIODevice *device) const;
|
void saveToXmlFile(QIODevice *device) const;
|
||||||
QByteArray saveToXmlData() const;
|
QByteArray saveToXmlData() const;
|
||||||
@ -79,7 +80,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList<XlsxRelationship> relationships(const QString &type) const;
|
QList<XlsxRelationship> relationships(const QString &type) const;
|
||||||
void addRelationship(const QString &type, const QString &target, const QString &targetMode=QString());
|
void addRelationship(const QString &type,
|
||||||
|
const QString &target,
|
||||||
|
const QString &targetMode = QString());
|
||||||
|
|
||||||
QList<XlsxRelationship> m_relationships;
|
QList<XlsxRelationship> m_relationships;
|
||||||
};
|
};
|
||||||
|
@ -25,23 +25,24 @@
|
|||||||
#ifndef XLSXRICHSTRING_H
|
#ifndef XLSXRICHSTRING_H
|
||||||
#define XLSXRICHSTRING_H
|
#define XLSXRICHSTRING_H
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxformat.h"
|
#include "xlsxformat.h"
|
||||||
#include <QVariant>
|
#include "xlsxglobal.h"
|
||||||
#include <QStringList>
|
|
||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
class RichStringPrivate;
|
class RichStringPrivate;
|
||||||
class RichString;
|
class RichString;
|
||||||
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
|
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
|
||||||
uint qHash(const RichString &rs, uint seed = 0) Q_DECL_NOTHROW;
|
uint qHash(const RichString &rs, uint seed = 0) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
class QXLSX_EXPORT RichString
|
class QXLSX_EXPORT RichString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RichString();
|
RichString();
|
||||||
explicit RichString(const QString& text);
|
explicit RichString(const QString &text);
|
||||||
RichString(const RichString &other);
|
RichString(const RichString &other);
|
||||||
~RichString();
|
~RichString();
|
||||||
|
|
||||||
@ -60,26 +61,27 @@ public:
|
|||||||
operator QVariant() const;
|
operator QVariant() const;
|
||||||
|
|
||||||
RichString &operator=(const RichString &other);
|
RichString &operator=(const RichString &other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW;
|
friend uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW;
|
||||||
friend bool operator==(const RichString &rs1, const RichString &rs2);
|
friend bool operator==(const RichString &rs1, const RichString &rs2);
|
||||||
friend bool operator!=(const RichString &rs1, const RichString &rs2);
|
friend bool operator!=(const RichString &rs1, const RichString &rs2);
|
||||||
friend bool operator<(const RichString &rs1, const RichString &rs2);
|
friend bool operator<(const RichString &rs1, const RichString &rs2);
|
||||||
friend QDebug operator<<(QDebug dbg, const RichString &rs);
|
friend QDebug operator<<(QDebug dbg, const RichString &rs);
|
||||||
|
|
||||||
QSharedDataPointer<RichStringPrivate> d;
|
QSharedDataPointer<RichStringPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const RichString &rs1, const RichString &rs2);
|
bool operator==(const RichString &rs1, const RichString &rs2);
|
||||||
bool operator!=(const RichString &rs1, const RichString &rs2);
|
bool operator!=(const RichString &rs1, const RichString &rs2);
|
||||||
bool operator<(const RichString &rs1, const RichString &rs2);
|
bool operator<(const RichString &rs1, const RichString &rs2);
|
||||||
bool operator==(const RichString &rs1, const QString &rs2);
|
bool operator==(const RichString &rs1, const QString &rs2);
|
||||||
bool operator==(const QString &rs1, const RichString &rs2);
|
bool operator==(const QString &rs1, const RichString &rs2);
|
||||||
bool operator!=(const RichString &rs1, const QString &rs2);
|
bool operator!=(const RichString &rs1, const QString &rs2);
|
||||||
bool operator!=(const QString &rs1, const RichString &rs2);
|
bool operator!=(const QString &rs1, const RichString &rs2);
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
QDebug operator<<(QDebug dbg, const RichString &rs);
|
QDebug operator<<(QDebug dbg, const RichString &rs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -36,23 +36,24 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QHash>
|
#include "xlsxabstractooxmlfile.h"
|
||||||
#include <QStringList>
|
|
||||||
#include <QIODevice>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxabstractooxmlfile.h"
|
|
||||||
|
#include <QHash>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class XlsxSharedStringInfo
|
class XlsxSharedStringInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XlsxSharedStringInfo(int index=0, int count = 1) :
|
XlsxSharedStringInfo(int index = 0, int count = 1)
|
||||||
index(index), count(count)
|
: index(index)
|
||||||
|
, count(count)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +61,13 @@ public:
|
|||||||
int count;
|
int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SharedStrings : public AbstractOOXmlFile
|
class SharedStrings : public AbstractOOXmlFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SharedStrings(CreateFlag flag);
|
SharedStrings(CreateFlag flag);
|
||||||
int count() const;
|
int count() const;
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
int addSharedString(const QString &string);
|
int addSharedString(const QString &string);
|
||||||
int addSharedString(const RichString &string);
|
int addSharedString(const RichString &string);
|
||||||
void removeSharedString(const QString &string);
|
void removeSharedString(const QString &string);
|
||||||
@ -82,13 +83,13 @@ public:
|
|||||||
bool loadFromXmlFile(QIODevice *device) override;
|
bool loadFromXmlFile(QIODevice *device) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readString(QXmlStreamReader &reader); // <si>
|
void readString(QXmlStreamReader &reader); // <si>
|
||||||
void readRichStringPart(QXmlStreamReader &reader, RichString &rich); // <r>
|
void readRichStringPart(QXmlStreamReader &reader, RichString &rich); // <r>
|
||||||
void readPlainStringPart(QXmlStreamReader &reader, RichString &rich); // <v>
|
void readPlainStringPart(QXmlStreamReader &reader, RichString &rich); // <v>
|
||||||
Format readRichStringPart_rPr(QXmlStreamReader &reader);
|
Format readRichStringPart_rPr(QXmlStreamReader &reader);
|
||||||
void writeRichStringPart_rPr(QXmlStreamWriter &writer, const Format &format) const;
|
void writeRichStringPart_rPr(QXmlStreamWriter &writer, const Format &format) const;
|
||||||
|
|
||||||
QHash<RichString, XlsxSharedStringInfo> m_stringTable; //for fast lookup
|
QHash<RichString, XlsxSharedStringInfo> m_stringTable; // for fast lookup
|
||||||
QList<RichString> m_stringList;
|
QList<RichString> m_stringList;
|
||||||
int m_stringCount;
|
int m_stringCount;
|
||||||
};
|
};
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
//
|
//
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
@ -36,30 +36,32 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QIODevice>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QSharedPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QIODevice>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
// class StylesTest;
|
// class StylesTest;
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxformat.h"
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
#include "xlsxformat.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class Format;
|
class Format;
|
||||||
class XlsxColor;
|
class XlsxColor;
|
||||||
|
|
||||||
struct XlsxFormatNumberData
|
struct XlsxFormatNumberData {
|
||||||
{
|
XlsxFormatNumberData()
|
||||||
XlsxFormatNumberData() : formatIndex(0) {}
|
: formatIndex(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int formatIndex;
|
int formatIndex;
|
||||||
QString formatString;
|
QString formatString;
|
||||||
@ -70,9 +72,9 @@ class Styles : public AbstractOOXmlFile
|
|||||||
public:
|
public:
|
||||||
Styles(CreateFlag flag);
|
Styles(CreateFlag flag);
|
||||||
~Styles();
|
~Styles();
|
||||||
void addXfFormat(const Format &format, bool force=false);
|
void addXfFormat(const Format &format, bool force = false);
|
||||||
Format xfFormat(int idx) const;
|
Format xfFormat(int idx) const;
|
||||||
void addDxfFormat(const Format &format, bool force=false);
|
void addDxfFormat(const Format &format, bool force = false);
|
||||||
Format dxfFormat(int idx) const;
|
Format dxfFormat(int idx) const;
|
||||||
|
|
||||||
void saveToXmlFile(QIODevice *device) const override;
|
void saveToXmlFile(QIODevice *device) const override;
|
||||||
@ -93,7 +95,10 @@ private:
|
|||||||
void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false) const;
|
void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false) const;
|
||||||
void writeBorders(QXmlStreamWriter &writer) const;
|
void writeBorders(QXmlStreamWriter &writer) const;
|
||||||
void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false) const;
|
void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false) const;
|
||||||
void writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) const;
|
void writeSubBorder(QXmlStreamWriter &writer,
|
||||||
|
const QString &type,
|
||||||
|
int style,
|
||||||
|
const XlsxColor &color) const;
|
||||||
void writeCellXfs(QXmlStreamWriter &writer) const;
|
void writeCellXfs(QXmlStreamWriter &writer) const;
|
||||||
void writeDxfs(QXmlStreamWriter &writer) const;
|
void writeDxfs(QXmlStreamWriter &writer) const;
|
||||||
void writeDxf(QXmlStreamWriter &writer, const Format &format) const;
|
void writeDxf(QXmlStreamWriter &writer, const Format &format) const;
|
||||||
@ -106,7 +111,10 @@ private:
|
|||||||
bool readFill(QXmlStreamReader &reader, Format &format);
|
bool readFill(QXmlStreamReader &reader, Format &format);
|
||||||
bool readBorders(QXmlStreamReader &reader);
|
bool readBorders(QXmlStreamReader &reader);
|
||||||
bool readBorder(QXmlStreamReader &reader, Format &format);
|
bool readBorder(QXmlStreamReader &reader, Format &format);
|
||||||
bool readSubBorder(QXmlStreamReader &reader, const QString &name, Format::BorderStyle &style, XlsxColor &color);
|
bool readSubBorder(QXmlStreamReader &reader,
|
||||||
|
const QString &name,
|
||||||
|
Format::BorderStyle &style,
|
||||||
|
XlsxColor &color);
|
||||||
bool readCellXfs(QXmlStreamReader &reader);
|
bool readCellXfs(QXmlStreamReader &reader);
|
||||||
bool readDxfs(QXmlStreamReader &reader);
|
bool readDxfs(QXmlStreamReader &reader);
|
||||||
bool readDxf(QXmlStreamReader &reader);
|
bool readDxf(QXmlStreamReader &reader);
|
||||||
@ -116,8 +124,8 @@ private:
|
|||||||
bool readCellStyleXfs(QXmlStreamReader &reader);
|
bool readCellStyleXfs(QXmlStreamReader &reader);
|
||||||
|
|
||||||
QHash<QString, int> m_builtinNumFmtsHash;
|
QHash<QString, int> m_builtinNumFmtsHash;
|
||||||
QMap<int, QSharedPointer<XlsxFormatNumberData> > m_customNumFmtIdMap;
|
QMap<int, QSharedPointer<XlsxFormatNumberData>> m_customNumFmtIdMap;
|
||||||
QHash<QString, QSharedPointer<XlsxFormatNumberData> > m_customNumFmtsHash;
|
QHash<QString, QSharedPointer<XlsxFormatNumberData>> m_customNumFmtsHash;
|
||||||
int m_nextCustomNumFmtId;
|
int m_nextCustomNumFmtId;
|
||||||
QList<Format> m_fontsList;
|
QList<Format> m_fontsList;
|
||||||
QList<Format> m_fillsList;
|
QList<Format> m_fillsList;
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
#ifndef XLSXTHEME_H
|
#ifndef XLSXTHEME_H
|
||||||
#define XLSXTHEME_H
|
#define XLSXTHEME_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
|
||||||
#include <QIODevice>
|
|
||||||
|
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QString>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class Theme : public AbstractOOXmlFile
|
class Theme : public AbstractOOXmlFile
|
||||||
|
@ -3,31 +3,30 @@
|
|||||||
#ifndef XLSXUTILITY_H
|
#ifndef XLSXUTILITY_H
|
||||||
#define XLSXUTILITY_H
|
#define XLSXUTILITY_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QColor>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDate>
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxglobal.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class CellReference;
|
class CellReference;
|
||||||
|
|
||||||
bool parseXsdBoolean(const QString &value, bool defaultValue=false);
|
bool parseXsdBoolean(const QString &value, bool defaultValue = false);
|
||||||
|
|
||||||
QStringList splitPath(const QString &path);
|
QStringList splitPath(const QString &path);
|
||||||
QString getRelFilePath(const QString &filePath);
|
QString getRelFilePath(const QString &filePath);
|
||||||
|
|
||||||
double datetimeToNumber(const QDateTime &dt, bool is1904=false);
|
double datetimeToNumber(const QDateTime &dt, bool is1904 = false);
|
||||||
QVariant datetimeFromNumber(double num, bool is1904=false);
|
QVariant datetimeFromNumber(double num, bool is1904 = false);
|
||||||
double timeToNumber(const QTime &t);
|
double timeToNumber(const QTime &t);
|
||||||
|
|
||||||
QString createSafeSheetName(const QString &nameProposal);
|
QString createSafeSheetName(const QString &nameProposal);
|
||||||
@ -36,7 +35,9 @@ QString unescapeSheetName(const QString &sheetName);
|
|||||||
|
|
||||||
bool isSpaceReserveNeeded(const QString &string);
|
bool isSpaceReserveNeeded(const QString &string);
|
||||||
|
|
||||||
QString convertSharedFormula(const QString &rootFormula, const CellReference &rootCell, const CellReference &cell);
|
QString convertSharedFormula(const QString &rootFormula,
|
||||||
|
const CellReference &rootCell,
|
||||||
|
const CellReference &cell);
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
#endif // XLSXUTILITY_H
|
#endif // XLSXUTILITY_H
|
||||||
|
@ -3,17 +3,17 @@
|
|||||||
#ifndef XLSXWORKBOOK_H
|
#ifndef XLSXWORKBOOK_H
|
||||||
#define XLSXWORKBOOK_H
|
#define XLSXWORKBOOK_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractooxmlfile.h"
|
||||||
#include <QList>
|
#include "xlsxabstractsheet.h"
|
||||||
#include <QImage>
|
#include "xlsxglobal.h"
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QIODevice>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include <QIODevice>
|
||||||
#include "xlsxabstractooxmlfile.h"
|
#include <QImage>
|
||||||
#include "xlsxabstractsheet.h"
|
#include <QList>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -39,34 +39,40 @@ public:
|
|||||||
int sheetCount() const;
|
int sheetCount() const;
|
||||||
AbstractSheet *sheet(int index) const;
|
AbstractSheet *sheet(int index) const;
|
||||||
|
|
||||||
AbstractSheet *addSheet(const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
AbstractSheet *addSheet(const QString &name = QString(),
|
||||||
AbstractSheet *insertSheet(int index, const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
||||||
|
AbstractSheet *insertSheet(int index,
|
||||||
|
const QString &name = QString(),
|
||||||
|
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
||||||
bool renameSheet(int index, const QString &name);
|
bool renameSheet(int index, const QString &name);
|
||||||
bool deleteSheet(int index);
|
bool deleteSheet(int index);
|
||||||
bool copySheet(int index, const QString &newName=QString());
|
bool copySheet(int index, const QString &newName = QString());
|
||||||
bool moveSheet(int srcIndex, int distIndex);
|
bool moveSheet(int srcIndex, int distIndex);
|
||||||
|
|
||||||
AbstractSheet *activeSheet() const;
|
AbstractSheet *activeSheet() const;
|
||||||
bool setActiveSheet(int index);
|
bool setActiveSheet(int index);
|
||||||
|
|
||||||
// void addChart();
|
// void addChart();
|
||||||
bool defineName(const QString &name, const QString &formula, const QString &comment=QString(), const QString &scope=QString());
|
bool defineName(const QString &name,
|
||||||
|
const QString &formula,
|
||||||
|
const QString &comment = QString(),
|
||||||
|
const QString &scope = QString());
|
||||||
bool isDate1904() const;
|
bool isDate1904() const;
|
||||||
void setDate1904(bool date1904);
|
void setDate1904(bool date1904);
|
||||||
bool isStringsToNumbersEnabled() const;
|
bool isStringsToNumbersEnabled() const;
|
||||||
void setStringsToNumbersEnabled(bool enable=true);
|
void setStringsToNumbersEnabled(bool enable = true);
|
||||||
bool isStringsToHyperlinksEnabled() const;
|
bool isStringsToHyperlinksEnabled() const;
|
||||||
void setStringsToHyperlinksEnabled(bool enable=true);
|
void setStringsToHyperlinksEnabled(bool enable = true);
|
||||||
bool isHtmlToRichStringEnabled() const;
|
bool isHtmlToRichStringEnabled() const;
|
||||||
void setHtmlToRichStringEnabled(bool enable=true);
|
void setHtmlToRichStringEnabled(bool enable = true);
|
||||||
QString defaultDateFormat() const;
|
QString defaultDateFormat() const;
|
||||||
void setDefaultDateFormat(const QString &format);
|
void setDefaultDateFormat(const QString &format);
|
||||||
|
|
||||||
//internal used member
|
// internal used member
|
||||||
void addMediaFile(std::shared_ptr<MediaFile> media, bool force=false);
|
void addMediaFile(std::shared_ptr<MediaFile> media, bool force = false);
|
||||||
QList<std::shared_ptr<MediaFile> > mediaFiles() const;
|
QList<std::shared_ptr<MediaFile>> mediaFiles() const;
|
||||||
void addChartFile(QSharedPointer<Chart> chartFile);
|
void addChartFile(QSharedPointer<Chart> chartFile);
|
||||||
QList<QSharedPointer<Chart> > chartFiles() const;
|
QList<QSharedPointer<Chart>> chartFiles() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Worksheet;
|
friend class Worksheet;
|
||||||
@ -85,9 +91,11 @@ private:
|
|||||||
Theme *theme();
|
Theme *theme();
|
||||||
QList<QImage> images();
|
QList<QImage> images();
|
||||||
QList<Drawing *> drawings();
|
QList<Drawing *> drawings();
|
||||||
QList<QSharedPointer<AbstractSheet> > getSheetsByTypes(AbstractSheet::SheetType type) const;
|
QList<QSharedPointer<AbstractSheet>> getSheetsByTypes(AbstractSheet::SheetType type) const;
|
||||||
QStringList worksheetNames() const;
|
QStringList worksheetNames() const;
|
||||||
AbstractSheet *addSheet(const QString &name, int sheetId, AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
AbstractSheet *addSheet(const QString &name,
|
||||||
|
int sheetId,
|
||||||
|
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -3,32 +3,37 @@
|
|||||||
#ifndef XLSXWORKBOOK_P_H
|
#ifndef XLSXWORKBOOK_P_H
|
||||||
#define XLSXWORKBOOK_P_H
|
#define XLSXWORKBOOK_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractooxmlfile_p.h"
|
||||||
|
#include "xlsxrelationships_p.h"
|
||||||
|
#include "xlsxsimpleooxmlfile_p.h"
|
||||||
|
#include "xlsxtheme_p.h"
|
||||||
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxworkbook.h"
|
|
||||||
#include "xlsxabstractooxmlfile_p.h"
|
|
||||||
#include "xlsxtheme_p.h"
|
|
||||||
#include "xlsxsimpleooxmlfile_p.h"
|
|
||||||
#include "xlsxrelationships_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
struct XlsxDefineNameData
|
struct XlsxDefineNameData {
|
||||||
{
|
|
||||||
XlsxDefineNameData()
|
XlsxDefineNameData()
|
||||||
:sheetId(-1)
|
: sheetId(-1)
|
||||||
{}
|
{
|
||||||
XlsxDefineNameData(const QString &name, const QString &formula, const QString &comment, int sheetId=-1)
|
}
|
||||||
:name(name), formula(formula), comment(comment), sheetId(sheetId)
|
XlsxDefineNameData(const QString &name,
|
||||||
|
const QString &formula,
|
||||||
|
const QString &comment,
|
||||||
|
int sheetId = -1)
|
||||||
|
: name(name)
|
||||||
|
, formula(formula)
|
||||||
|
, comment(comment)
|
||||||
|
, sheetId(sheetId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
QString name;
|
QString name;
|
||||||
QString formula;
|
QString formula;
|
||||||
QString comment;
|
QString comment;
|
||||||
//using internal sheetId, instead of the localSheetId(order in the workbook)
|
// using internal sheetId, instead of the localSheetId(order in the workbook)
|
||||||
int sheetId;
|
int sheetId;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,13 +44,13 @@ public:
|
|||||||
WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag);
|
WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag);
|
||||||
|
|
||||||
QSharedPointer<SharedStrings> sharedStrings;
|
QSharedPointer<SharedStrings> sharedStrings;
|
||||||
QList<QSharedPointer<AbstractSheet> > sheets;
|
QList<QSharedPointer<AbstractSheet>> sheets;
|
||||||
QList<QSharedPointer<SimpleOOXmlFile> > externalLinks;
|
QList<QSharedPointer<SimpleOOXmlFile>> externalLinks;
|
||||||
QStringList sheetNames;
|
QStringList sheetNames;
|
||||||
QSharedPointer<Styles> styles;
|
QSharedPointer<Styles> styles;
|
||||||
QSharedPointer<Theme> theme;
|
QSharedPointer<Theme> theme;
|
||||||
QList<std::shared_ptr<MediaFile> > mediaFiles;
|
QList<std::shared_ptr<MediaFile>> mediaFiles;
|
||||||
QList<QSharedPointer<Chart> > chartFiles;
|
QList<QSharedPointer<Chart>> chartFiles;
|
||||||
QList<XlsxDefineNameData> definedNamesList;
|
QList<XlsxDefineNameData> definedNamesList;
|
||||||
|
|
||||||
bool strings_to_numbers_enabled;
|
bool strings_to_numbers_enabled;
|
||||||
@ -63,7 +68,7 @@ public:
|
|||||||
int firstsheet;
|
int firstsheet;
|
||||||
int table_count;
|
int table_count;
|
||||||
|
|
||||||
//Used to generate new sheet name and id
|
// Used to generate new sheet name and id
|
||||||
int last_worksheet_index;
|
int last_worksheet_index;
|
||||||
int last_chartsheet_index;
|
int last_chartsheet_index;
|
||||||
int last_sheet_id;
|
int last_sheet_id;
|
||||||
|
@ -3,22 +3,22 @@
|
|||||||
#ifndef XLSXWORKSHEET_H
|
#ifndef XLSXWORKSHEET_H
|
||||||
#define XLSXWORKSHEET_H
|
#define XLSXWORKSHEET_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QPointF>
|
|
||||||
#include <QIODevice>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QImage>
|
|
||||||
|
|
||||||
#include "xlsxabstractsheet.h"
|
#include "xlsxabstractsheet.h"
|
||||||
#include "xlsxcell.h"
|
#include "xlsxcell.h"
|
||||||
|
#include "xlsxcelllocation.h"
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxcellreference.h"
|
#include "xlsxcellreference.h"
|
||||||
#include "xlsxcelllocation.h"
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
class WorksheetTest;
|
class WorksheetTest;
|
||||||
|
|
||||||
@ -51,44 +51,78 @@ public:
|
|||||||
~Worksheet();
|
~Worksheet();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool write(const CellReference &row_column, const QVariant &value, const Format &format=Format());
|
bool write(const CellReference &row_column,
|
||||||
bool write(int row, int column, const QVariant &value, const Format &format=Format());
|
const QVariant &value,
|
||||||
|
const Format &format = Format());
|
||||||
|
bool write(int row, int column, const QVariant &value, const Format &format = Format());
|
||||||
|
|
||||||
QVariant read(const CellReference &row_column) const;
|
QVariant read(const CellReference &row_column) const;
|
||||||
QVariant read(int row, int column) const;
|
QVariant read(int row, int column) const;
|
||||||
|
|
||||||
bool writeString(const CellReference &row_column, const QString &value, const Format &format=Format());
|
bool writeString(const CellReference &row_column,
|
||||||
bool writeString(int row, int column, const QString &value, const Format &format=Format());
|
const QString &value,
|
||||||
bool writeString(const CellReference &row_column, const RichString &value, const Format &format=Format());
|
const Format &format = Format());
|
||||||
bool writeString(int row, int column, const RichString &value, const Format &format=Format());
|
bool writeString(int row, int column, const QString &value, const Format &format = Format());
|
||||||
|
bool writeString(const CellReference &row_column,
|
||||||
|
const RichString &value,
|
||||||
|
const Format &format = Format());
|
||||||
|
bool writeString(int row, int column, const RichString &value, const Format &format = Format());
|
||||||
|
|
||||||
bool writeInlineString(const CellReference &row_column, const QString &value, const Format &format=Format());
|
bool writeInlineString(const CellReference &row_column,
|
||||||
bool writeInlineString(int row, int column, const QString &value, const Format &format=Format());
|
const QString &value,
|
||||||
|
const Format &format = Format());
|
||||||
|
bool writeInlineString(int row,
|
||||||
|
int column,
|
||||||
|
const QString &value,
|
||||||
|
const Format &format = Format());
|
||||||
|
|
||||||
bool writeNumeric(const CellReference &row_column, double value, const Format &format=Format());
|
bool writeNumeric(const CellReference &row_column,
|
||||||
bool writeNumeric(int row, int column, double value, const Format &format=Format());
|
double value,
|
||||||
|
const Format &format = Format());
|
||||||
|
bool writeNumeric(int row, int column, double value, const Format &format = Format());
|
||||||
|
|
||||||
bool writeFormula(const CellReference &row_column, const CellFormula &formula, const Format &format=Format(), double result=0);
|
bool writeFormula(const CellReference &row_column,
|
||||||
bool writeFormula(int row, int column, const CellFormula &formula, const Format &format=Format(), double result=0);
|
const CellFormula &formula,
|
||||||
|
const Format &format = Format(),
|
||||||
|
double result = 0);
|
||||||
|
bool writeFormula(int row,
|
||||||
|
int column,
|
||||||
|
const CellFormula &formula,
|
||||||
|
const Format &format = Format(),
|
||||||
|
double result = 0);
|
||||||
|
|
||||||
bool writeBlank(const CellReference &row_column, const Format &format=Format());
|
bool writeBlank(const CellReference &row_column, const Format &format = Format());
|
||||||
bool writeBlank(int row, int column, const Format &format=Format());
|
bool writeBlank(int row, int column, const Format &format = Format());
|
||||||
|
|
||||||
bool writeBool(const CellReference &row_column, bool value, const Format &format=Format());
|
bool writeBool(const CellReference &row_column, bool value, const Format &format = Format());
|
||||||
bool writeBool(int row, int column, bool value, const Format &format=Format());
|
bool writeBool(int row, int column, bool value, const Format &format = Format());
|
||||||
|
|
||||||
bool writeDateTime(const CellReference &row_column, const QDateTime& dt, const Format &format=Format());
|
bool writeDateTime(const CellReference &row_column,
|
||||||
bool writeDateTime(int row, int column, const QDateTime& dt, const Format &format=Format());
|
const QDateTime &dt,
|
||||||
|
const Format &format = Format());
|
||||||
|
bool writeDateTime(int row, int column, const QDateTime &dt, const Format &format = Format());
|
||||||
|
|
||||||
// dev67
|
// dev67
|
||||||
bool writeDate(const CellReference &row_column, const QDate& dt, const Format &format=Format());
|
bool writeDate(const CellReference &row_column,
|
||||||
bool writeDate(int row, int column, const QDate& dt, const Format &format=Format());
|
const QDate &dt,
|
||||||
|
const Format &format = Format());
|
||||||
|
bool writeDate(int row, int column, const QDate &dt, const Format &format = Format());
|
||||||
|
|
||||||
bool writeTime(const CellReference &row_column, const QTime& t, const Format &format=Format());
|
bool
|
||||||
bool writeTime(int row, int column, const QTime& t, const Format &format=Format());
|
writeTime(const CellReference &row_column, const QTime &t, const Format &format = Format());
|
||||||
|
bool writeTime(int row, int column, const QTime &t, const Format &format = Format());
|
||||||
|
|
||||||
bool writeHyperlink(const CellReference &row_column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
|
bool writeHyperlink(const CellReference &row_column,
|
||||||
bool writeHyperlink(int row, int column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
|
const QUrl &url,
|
||||||
|
const Format &format = Format(),
|
||||||
|
const QString &display = QString(),
|
||||||
|
const QString &tip = QString());
|
||||||
|
bool writeHyperlink(int row,
|
||||||
|
int column,
|
||||||
|
const QUrl &url,
|
||||||
|
const Format &format = Format(),
|
||||||
|
const QString &display = QString(),
|
||||||
|
const QString &tip = QString());
|
||||||
|
|
||||||
bool addDataValidation(const DataValidation &validation);
|
bool addDataValidation(const DataValidation &validation);
|
||||||
bool addConditionalFormatting(const ConditionalFormatting &cf);
|
bool addConditionalFormatting(const ConditionalFormatting &cf);
|
||||||
@ -97,19 +131,19 @@ public:
|
|||||||
Cell *cellAt(int row, int column) const;
|
Cell *cellAt(int row, int column) const;
|
||||||
|
|
||||||
int insertImage(int row, int column, const QImage &image);
|
int insertImage(int row, int column, const QImage &image);
|
||||||
bool getImage(int imageIndex, QImage& img);
|
bool getImage(int imageIndex, QImage &img);
|
||||||
bool getImage(int row, int column, QImage& img);
|
bool getImage(int row, int column, QImage &img);
|
||||||
uint getImageCount();
|
uint getImageCount();
|
||||||
|
|
||||||
Chart *insertChart(int row, int column, const QSize &size);
|
Chart *insertChart(int row, int column, const QSize &size);
|
||||||
|
|
||||||
bool mergeCells(const CellRange &range, const Format &format=Format());
|
bool mergeCells(const CellRange &range, const Format &format = Format());
|
||||||
bool unmergeCells(const CellRange &range);
|
bool unmergeCells(const CellRange &range);
|
||||||
QList<CellRange> mergedCells() const;
|
QList<CellRange> mergedCells() const;
|
||||||
|
|
||||||
bool setColumnWidth(const CellRange& range, double width);
|
bool setColumnWidth(const CellRange &range, double width);
|
||||||
bool setColumnFormat(const CellRange& range, const Format &format);
|
bool setColumnFormat(const CellRange &range, const Format &format);
|
||||||
bool setColumnHidden(const CellRange& range, bool hidden);
|
bool setColumnHidden(const CellRange &range, bool hidden);
|
||||||
bool setColumnWidth(int colFirst, int colLast, double width);
|
bool setColumnWidth(int colFirst, int colLast, double width);
|
||||||
bool setColumnFormat(int colFirst, int colLast, const Format &format);
|
bool setColumnFormat(int colFirst, int colLast, const Format &format);
|
||||||
bool setColumnHidden(int colFirst, int colLast, bool hidden);
|
bool setColumnHidden(int colFirst, int colLast, bool hidden);
|
||||||
@ -118,9 +152,9 @@ public:
|
|||||||
Format columnFormat(int column);
|
Format columnFormat(int column);
|
||||||
bool isColumnHidden(int column);
|
bool isColumnHidden(int column);
|
||||||
|
|
||||||
bool setRowHeight(int rowFirst,int rowLast, double height);
|
bool setRowHeight(int rowFirst, int rowLast, double height);
|
||||||
bool setRowFormat(int rowFirst,int rowLast, const Format &format);
|
bool setRowFormat(int rowFirst, int rowLast, const Format &format);
|
||||||
bool setRowHidden(int rowFirst,int rowLast, bool hidden);
|
bool setRowHidden(int rowFirst, int rowLast, bool hidden);
|
||||||
|
|
||||||
double rowHeight(int row);
|
double rowHeight(int row);
|
||||||
Format rowFormat(int row);
|
Format rowFormat(int row);
|
||||||
@ -151,9 +185,9 @@ public:
|
|||||||
void setOutlineSymbolsVisible(bool visible);
|
void setOutlineSymbolsVisible(bool visible);
|
||||||
bool isWhiteSpaceVisible() const;
|
bool isWhiteSpaceVisible() const;
|
||||||
void setWhiteSpaceVisible(bool visible);
|
void setWhiteSpaceVisible(bool visible);
|
||||||
bool setStartPage(int spagen); //add by liufeijin20181028
|
bool setStartPage(int spagen); // add by liufeijin20181028
|
||||||
|
|
||||||
QVector<CellLocation> getFullCells(int* maxRow, int* maxCol);
|
QVector<CellLocation> getFullCells(int *maxRow, int *maxCol);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void saveToXmlFile(QIODevice *device) const override;
|
void saveToXmlFile(QIODevice *device) const override;
|
||||||
|
@ -3,76 +3,78 @@
|
|||||||
#ifndef XLSXWORKSHEET_P_H
|
#ifndef XLSXWORKSHEET_P_H
|
||||||
#define XLSXWORKSHEET_P_H
|
#define XLSXWORKSHEET_P_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QImage>
|
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
#include "xlsxworksheet.h"
|
|
||||||
#include "xlsxabstractsheet_p.h"
|
#include "xlsxabstractsheet_p.h"
|
||||||
#include "xlsxcell.h"
|
#include "xlsxcell.h"
|
||||||
#include "xlsxdatavalidation.h"
|
|
||||||
#include "xlsxconditionalformatting.h"
|
|
||||||
#include "xlsxcellformula.h"
|
#include "xlsxcellformula.h"
|
||||||
|
#include "xlsxconditionalformatting.h"
|
||||||
|
#include "xlsxdatavalidation.h"
|
||||||
|
#include "xlsxworksheet.h"
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
class QXmlStreamReader;
|
class QXmlStreamReader;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
const int XLSX_ROW_MAX = 1048576;
|
const int XLSX_ROW_MAX = 1048576;
|
||||||
const int XLSX_COLUMN_MAX = 16384;
|
const int XLSX_COLUMN_MAX = 16384;
|
||||||
const int XLSX_STRING_MAX = 32767;
|
const int XLSX_STRING_MAX = 32767;
|
||||||
|
|
||||||
class SharedStrings;
|
class SharedStrings;
|
||||||
|
|
||||||
struct XlsxHyperlinkData
|
struct XlsxHyperlinkData {
|
||||||
{
|
enum LinkType { External, Internal };
|
||||||
enum LinkType
|
|
||||||
{
|
|
||||||
External,
|
|
||||||
Internal
|
|
||||||
};
|
|
||||||
|
|
||||||
XlsxHyperlinkData(LinkType linkType=External, const QString &target=QString(), const QString &location=QString()
|
XlsxHyperlinkData(LinkType linkType = External,
|
||||||
, const QString &display=QString(), const QString &tip=QString())
|
const QString &target = QString(),
|
||||||
:linkType(linkType), target(target), location(location), display(display), tooltip(tip)
|
const QString &location = QString(),
|
||||||
|
const QString &display = QString(),
|
||||||
|
const QString &tip = QString())
|
||||||
|
: linkType(linkType)
|
||||||
|
, target(target)
|
||||||
|
, location(location)
|
||||||
|
, display(display)
|
||||||
|
, tooltip(tip)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkType linkType;
|
LinkType linkType;
|
||||||
QString target; //For External link
|
QString target; // For External link
|
||||||
QString location;
|
QString location;
|
||||||
QString display;
|
QString display;
|
||||||
QString tooltip;
|
QString tooltip;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ECMA-376 Part1 18.3.1.81
|
// ECMA-376 Part1 18.3.1.81
|
||||||
struct XlsxSheetFormatProps
|
struct XlsxSheetFormatProps {
|
||||||
{
|
XlsxSheetFormatProps(
|
||||||
XlsxSheetFormatProps(int baseColWidth = 8,
|
int baseColWidth = 8,
|
||||||
bool customHeight = false,
|
bool customHeight = false,
|
||||||
double defaultColWidth = 8.430f, // https://learn.microsoft.com/en-us/office/troubleshoot/excel/determine-column-widths
|
double defaultColWidth =
|
||||||
double defaultRowHeight = 15,
|
8.430f, // https://learn.microsoft.com/en-us/office/troubleshoot/excel/determine-column-widths
|
||||||
quint8 outlineLevelCol = 0,
|
double defaultRowHeight = 15,
|
||||||
quint8 outlineLevelRow = 0,
|
quint8 outlineLevelCol = 0,
|
||||||
bool thickBottom = false,
|
quint8 outlineLevelRow = 0,
|
||||||
bool thickTop = false,
|
bool thickBottom = false,
|
||||||
bool zeroHeight = false) :
|
bool thickTop = false,
|
||||||
baseColWidth(baseColWidth),
|
bool zeroHeight = false)
|
||||||
customHeight(customHeight),
|
: baseColWidth(baseColWidth)
|
||||||
defaultColWidth(defaultColWidth),
|
, customHeight(customHeight)
|
||||||
defaultRowHeight(defaultRowHeight),
|
, defaultColWidth(defaultColWidth)
|
||||||
outlineLevelCol(outlineLevelCol),
|
, defaultRowHeight(defaultRowHeight)
|
||||||
outlineLevelRow(outlineLevelRow),
|
, outlineLevelCol(outlineLevelCol)
|
||||||
thickBottom(thickBottom),
|
, outlineLevelRow(outlineLevelRow)
|
||||||
thickTop(thickTop),
|
, thickBottom(thickBottom)
|
||||||
zeroHeight(zeroHeight) {
|
, thickTop(thickTop)
|
||||||
|
, zeroHeight(zeroHeight)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int baseColWidth;
|
int baseColWidth;
|
||||||
@ -86,13 +88,15 @@ struct XlsxSheetFormatProps
|
|||||||
bool zeroHeight;
|
bool zeroHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct XlsxRowInfo
|
struct XlsxRowInfo {
|
||||||
{
|
XlsxRowInfo(double height = 0, const Format &format = Format(), bool hidden = false)
|
||||||
XlsxRowInfo(double height=0, const Format &format=Format(), bool hidden=false) :
|
: customHeight(false)
|
||||||
customHeight(false), height(height), format(format), hidden(hidden), outlineLevel(0)
|
, height(height)
|
||||||
, collapsed(false)
|
, format(format)
|
||||||
|
, hidden(hidden)
|
||||||
|
, outlineLevel(0)
|
||||||
|
, collapsed(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool customHeight;
|
bool customHeight;
|
||||||
@ -103,25 +107,23 @@ struct XlsxRowInfo
|
|||||||
bool collapsed;
|
bool collapsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct XlsxColumnInfo
|
struct XlsxColumnInfo {
|
||||||
{
|
XlsxColumnInfo(int firstColumn, // = 0,
|
||||||
XlsxColumnInfo( int firstColumn, // = 0,
|
int lastColumn, // = 1,
|
||||||
int lastColumn, // = 1,
|
bool isSetWidth,
|
||||||
bool isSetWidth,
|
double width = 0,
|
||||||
double width = 0,
|
const Format &format = Format(),
|
||||||
const Format &format = Format(),
|
bool hidden = false)
|
||||||
bool hidden = false)
|
: width(width)
|
||||||
: width(width),
|
, format(format)
|
||||||
format(format),
|
, firstColumn(firstColumn)
|
||||||
firstColumn(firstColumn),
|
, lastColumn(lastColumn)
|
||||||
lastColumn(lastColumn),
|
, outlineLevel(0)
|
||||||
outlineLevel(0),
|
, isSetWidth(isSetWidth)
|
||||||
isSetWidth(isSetWidth),
|
, customWidth(false)
|
||||||
customWidth(false),
|
, hidden(hidden)
|
||||||
hidden(hidden),
|
, collapsed(false)
|
||||||
collapsed(false)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double width;
|
double width;
|
||||||
@ -144,7 +146,7 @@ public:
|
|||||||
~WorksheetPrivate();
|
~WorksheetPrivate();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int checkDimensions(int row, int col, bool ignore_row=false, bool ignore_col=false);
|
int checkDimensions(int row, int col, bool ignore_row = false, bool ignore_col = false);
|
||||||
Format cellFormat(int row, int col) const;
|
Format cellFormat(int row, int col) const;
|
||||||
QString generateDimensionString() const;
|
QString generateDimensionString() const;
|
||||||
void calculateSpans() const;
|
void calculateSpans() const;
|
||||||
@ -152,7 +154,10 @@ public:
|
|||||||
void validateDimension();
|
void validateDimension();
|
||||||
|
|
||||||
void saveXmlSheetData(QXmlStreamWriter &writer) const;
|
void saveXmlSheetData(QXmlStreamWriter &writer) const;
|
||||||
void saveXmlCellData(QXmlStreamWriter &writer, int row, int col, std::shared_ptr<Cell> cell) const;
|
void saveXmlCellData(QXmlStreamWriter &writer,
|
||||||
|
int row,
|
||||||
|
int col,
|
||||||
|
std::shared_ptr<Cell> cell) const;
|
||||||
void saveXmlMergeCells(QXmlStreamWriter &writer) const;
|
void saveXmlMergeCells(QXmlStreamWriter &writer) const;
|
||||||
void saveXmlHyperlinks(QXmlStreamWriter &writer) const;
|
void saveXmlHyperlinks(QXmlStreamWriter &writer) const;
|
||||||
void saveXmlDrawings(QXmlStreamWriter &writer) const;
|
void saveXmlDrawings(QXmlStreamWriter &writer) const;
|
||||||
@ -169,22 +174,22 @@ public:
|
|||||||
void loadXmlSheetViews(QXmlStreamReader &reader);
|
void loadXmlSheetViews(QXmlStreamReader &reader);
|
||||||
void loadXmlHyperlinks(QXmlStreamReader &reader);
|
void loadXmlHyperlinks(QXmlStreamReader &reader);
|
||||||
|
|
||||||
QList<QSharedPointer<XlsxRowInfo> > getRowInfoList(int rowFirst, int rowLast);
|
QList<QSharedPointer<XlsxRowInfo>> getRowInfoList(int rowFirst, int rowLast);
|
||||||
QList<QSharedPointer<XlsxColumnInfo> > getColumnInfoList(int colFirst, int colLast);
|
QList<QSharedPointer<XlsxColumnInfo>> getColumnInfoList(int colFirst, int colLast);
|
||||||
QList<int> getColumnIndexes(int colFirst, int colLast);
|
QList<int> getColumnIndexes(int colFirst, int colLast);
|
||||||
bool isColumnRangeValid(int colFirst, int colLast);
|
bool isColumnRangeValid(int colFirst, int colLast);
|
||||||
|
|
||||||
SharedStrings *sharedStrings() const;
|
SharedStrings *sharedStrings() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QMap<int, QMap<int, std::shared_ptr<Cell> > > cellTable;
|
QMap<int, QMap<int, std::shared_ptr<Cell>>> cellTable;
|
||||||
|
|
||||||
QMap<int, QMap<int, QString> > comments;
|
QMap<int, QMap<int, QString>> comments;
|
||||||
QMap<int, QMap<int, QSharedPointer<XlsxHyperlinkData> > > urlTable;
|
QMap<int, QMap<int, QSharedPointer<XlsxHyperlinkData>>> urlTable;
|
||||||
QList<CellRange> merges;
|
QList<CellRange> merges;
|
||||||
QMap<int, QSharedPointer<XlsxRowInfo> > rowsInfo;
|
QMap<int, QSharedPointer<XlsxRowInfo>> rowsInfo;
|
||||||
QMap<int, QSharedPointer<XlsxColumnInfo> > colsInfo;
|
QMap<int, QSharedPointer<XlsxColumnInfo>> colsInfo;
|
||||||
QMap<int, QSharedPointer<XlsxColumnInfo> > colsInfoHelper;
|
QMap<int, QSharedPointer<XlsxColumnInfo>> colsInfoHelper;
|
||||||
|
|
||||||
QList<DataValidation> dataValidationsList;
|
QList<DataValidation> dataValidationsList;
|
||||||
QList<ConditionalFormatting> conditionalFormattingList;
|
QList<ConditionalFormatting> conditionalFormattingList;
|
||||||
@ -226,7 +231,7 @@ public:
|
|||||||
// header footer, liufeijin
|
// header footer, liufeijin
|
||||||
QString MoodFooter;
|
QString MoodFooter;
|
||||||
QString ModdHeader;
|
QString ModdHeader;
|
||||||
QString MoodalignWithMargins; // add align 20190619
|
QString MoodalignWithMargins; // add align 20190619
|
||||||
|
|
||||||
XlsxSheetFormatProps sheetFormatProps;
|
XlsxSheetFormatProps sheetFormatProps;
|
||||||
|
|
||||||
@ -244,7 +249,6 @@ public:
|
|||||||
QRegularExpression urlPattern;
|
QRegularExpression urlPattern;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static double calculateColWidth(int characters);
|
static double calculateColWidth(int characters);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,19 +3,18 @@
|
|||||||
#ifndef QXLSX_XLSXZIPREADER_P_H
|
#ifndef QXLSX_XLSXZIPREADER_P_H
|
||||||
#define QXLSX_XLSXZIPREADER_P_H
|
#define QXLSX_XLSXZIPREADER_P_H
|
||||||
|
|
||||||
#include <QScopedPointer>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QIODevice>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <QStringList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
class QZipReader;
|
class QZipReader;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
class ZipReader
|
class ZipReader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ZipReader(const QString &fileName);
|
explicit ZipReader(const QString &fileName);
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
#ifndef QXLSX_ZIPWRITER_H
|
#ifndef QXLSX_ZIPWRITER_H
|
||||||
#define QXLSX_ZIPWRITER_H
|
#define QXLSX_ZIPWRITER_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
|
||||||
#include <QIODevice>
|
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QString>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
class QZipWriter;
|
class QZipWriter;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
// xlsxabstractooxmlfile.cpp
|
// xlsxabstractooxmlfile.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractooxmlfile.h"
|
||||||
|
|
||||||
|
#include "xlsxabstractooxmlfile_p.h"
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxabstractooxmlfile.h"
|
|
||||||
#include "xlsxabstractooxmlfile_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag=AbstractOOXmlFile::F_NewFromScratch)
|
AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(
|
||||||
: relationships(new Relationships), flag(flag), q_ptr(q)
|
AbstractOOXmlFile *q,
|
||||||
|
AbstractOOXmlFile::CreateFlag flag = AbstractOOXmlFile::F_NewFromScratch)
|
||||||
|
: relationships(new Relationships)
|
||||||
|
, flag(flag)
|
||||||
|
, q_ptr(q)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate()
|
AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate()
|
||||||
{
|
{
|
||||||
if (relationships) {
|
if (relationships) {
|
||||||
delete relationships;
|
delete relationships;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,14 +35,13 @@ AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
AbstractOOXmlFile::AbstractOOXmlFile(CreateFlag flag)
|
AbstractOOXmlFile::AbstractOOXmlFile(CreateFlag flag)
|
||||||
:d_ptr(new AbstractOOXmlFilePrivate(this, flag))
|
: d_ptr(new AbstractOOXmlFilePrivate(this, flag))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractOOXmlFile::AbstractOOXmlFile(AbstractOOXmlFilePrivate *d)
|
AbstractOOXmlFile::AbstractOOXmlFile(AbstractOOXmlFilePrivate *d)
|
||||||
:d_ptr(d)
|
: d_ptr(d)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractOOXmlFile::~AbstractOOXmlFile()
|
AbstractOOXmlFile::~AbstractOOXmlFile()
|
||||||
@ -83,7 +86,6 @@ QString AbstractOOXmlFile::filePath() const
|
|||||||
return d->filePathInPackage;
|
return d->filePathInPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
@ -93,5 +95,4 @@ Relationships *AbstractOOXmlFile::relationships() const
|
|||||||
return d->relationships;
|
return d->relationships;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
// xlsxabstractsheet.cpp
|
// xlsxabstractsheet.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "xlsxabstractsheet.h"
|
#include "xlsxabstractsheet.h"
|
||||||
|
|
||||||
#include "xlsxabstractsheet_p.h"
|
#include "xlsxabstractsheet_p.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag)
|
AbstractSheetPrivate::AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag)
|
||||||
: AbstractOOXmlFilePrivate(p, flag)
|
: AbstractOOXmlFilePrivate(p, flag)
|
||||||
{
|
{
|
||||||
type = AbstractSheet::ST_WorkSheet;
|
type = AbstractSheet::ST_WorkSheet;
|
||||||
sheetState = AbstractSheet::SS_Visible;
|
sheetState = AbstractSheet::SS_Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractSheetPrivate::~AbstractSheetPrivate()
|
AbstractSheetPrivate::~AbstractSheetPrivate() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class AbstractSheet
|
\class AbstractSheet
|
||||||
@ -52,15 +51,17 @@ AbstractSheetPrivate::~AbstractSheetPrivate()
|
|||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
AbstractSheet::AbstractSheet(const QString &name, int id, Workbook *workbook, AbstractSheetPrivate *d) :
|
AbstractSheet::AbstractSheet(const QString &name,
|
||||||
AbstractOOXmlFile(d)
|
int id,
|
||||||
|
Workbook *workbook,
|
||||||
|
AbstractSheetPrivate *d)
|
||||||
|
: AbstractOOXmlFile(d)
|
||||||
{
|
{
|
||||||
d_func()->name = name;
|
d_func()->name = name;
|
||||||
d_func()->id = id;
|
d_func()->id = id;
|
||||||
d_func()->workbook = workbook;
|
d_func()->workbook = workbook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the name of the sheet.
|
* Returns the name of the sheet.
|
||||||
*/
|
*/
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
// xlsxcell.cpp
|
// xlsxcell.cpp
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDate>
|
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
#include "xlsxcell.h"
|
#include "xlsxcell.h"
|
||||||
|
|
||||||
#include "xlsxcell_p.h"
|
#include "xlsxcell_p.h"
|
||||||
#include "xlsxformat.h"
|
#include "xlsxformat.h"
|
||||||
#include "xlsxformat_p.h"
|
#include "xlsxformat_p.h"
|
||||||
#include "xlsxutility_p.h"
|
#include "xlsxutility_p.h"
|
||||||
#include "xlsxworksheet.h"
|
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
|
#include "xlsxworksheet.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
CellPrivate::CellPrivate(Cell *p) :
|
CellPrivate::CellPrivate(Cell *p)
|
||||||
q_ptr(p)
|
: q_ptr(p)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPrivate::CellPrivate(const CellPrivate * const cp)
|
CellPrivate::CellPrivate(const CellPrivate *const cp)
|
||||||
: parent(cp->parent)
|
: parent(cp->parent)
|
||||||
, cellType(cp->cellType)
|
, cellType(cp->cellType)
|
||||||
, value(cp->value)
|
, value(cp->value)
|
||||||
@ -33,7 +33,6 @@ CellPrivate::CellPrivate(const CellPrivate * const cp)
|
|||||||
, richString(cp->richString)
|
, richString(cp->richString)
|
||||||
, styleNumber(cp->styleNumber)
|
, styleNumber(cp->styleNumber)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -58,27 +57,27 @@ CellPrivate::CellPrivate(const CellPrivate * const cp)
|
|||||||
* Created by Worksheet only.
|
* Created by Worksheet only.
|
||||||
*/
|
*/
|
||||||
// qint32 styleIndex = (-1)
|
// qint32 styleIndex = (-1)
|
||||||
Cell::Cell(const QVariant &data,
|
Cell::Cell(const QVariant &data,
|
||||||
CellType type,
|
CellType type,
|
||||||
const Format &format,
|
const Format &format,
|
||||||
Worksheet *parent,
|
Worksheet *parent,
|
||||||
qint32 styleIndex ) :
|
qint32 styleIndex)
|
||||||
d_ptr(new CellPrivate(this))
|
: d_ptr(new CellPrivate(this))
|
||||||
{
|
{
|
||||||
d_ptr->value = data;
|
d_ptr->value = data;
|
||||||
d_ptr->cellType = type;
|
d_ptr->cellType = type;
|
||||||
d_ptr->format = format;
|
d_ptr->format = format;
|
||||||
d_ptr->parent = parent;
|
d_ptr->parent = parent;
|
||||||
d_ptr->styleNumber = styleIndex;
|
d_ptr->styleNumber = styleIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
Cell::Cell(const Cell * const cell):
|
Cell::Cell(const Cell *const cell)
|
||||||
d_ptr(new CellPrivate(cell->d_ptr))
|
: d_ptr(new CellPrivate(cell->d_ptr))
|
||||||
{
|
{
|
||||||
d_ptr->q_ptr = this;
|
d_ptr->q_ptr = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -86,8 +85,8 @@ Cell::Cell(const Cell * const cell):
|
|||||||
*/
|
*/
|
||||||
Cell::~Cell()
|
Cell::~Cell()
|
||||||
{
|
{
|
||||||
if ( NULL != d_ptr )
|
if (NULL != d_ptr)
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -95,9 +94,9 @@ Cell::~Cell()
|
|||||||
*/
|
*/
|
||||||
Cell::CellType Cell::cellType() const
|
Cell::CellType Cell::cellType() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
return d->cellType;
|
return d->cellType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -105,72 +104,56 @@ Cell::CellType Cell::cellType() const
|
|||||||
*/
|
*/
|
||||||
QVariant Cell::value() const
|
QVariant Cell::value() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
return d->value;
|
return d->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Return the data content of this Cell for reading
|
* Return the data content of this Cell for reading
|
||||||
*/
|
*/
|
||||||
QVariant Cell::readValue() const
|
QVariant Cell::readValue() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
QVariant ret; // return value
|
QVariant ret; // return value
|
||||||
ret = d->value;
|
ret = d->value;
|
||||||
|
|
||||||
Format fmt = this->format();
|
Format fmt = this->format();
|
||||||
|
|
||||||
if (isDateTime())
|
if (isDateTime()) {
|
||||||
{
|
|
||||||
QVariant vDT = dateTime();
|
QVariant vDT = dateTime();
|
||||||
if ( vDT.isNull() )
|
if (vDT.isNull()) {
|
||||||
{
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/QtExcel/QXlsx/issues/171
|
// https://github.com/QtExcel/QXlsx/issues/171
|
||||||
// https://www.qt.io/blog/whats-new-in-qmetatype-qvariant
|
// https://www.qt.io/blog/whats-new-in-qmetatype-qvariant
|
||||||
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
||||||
if ( vDT.metaType().id() == QMetaType::QDateTime )
|
if (vDT.metaType().id() == QMetaType::QDateTime) {
|
||||||
{
|
ret = vDT;
|
||||||
ret = vDT;
|
} else if (vDT.metaType().id() == QMetaType::QDate) {
|
||||||
}
|
ret = vDT;
|
||||||
else if ( vDT.metaType().id() == QMetaType::QDate )
|
} else if (vDT.metaType().id() == QMetaType::QTime) {
|
||||||
{
|
ret = vDT;
|
||||||
ret = vDT;
|
} else {
|
||||||
}
|
return QVariant();
|
||||||
else if ( vDT.metaType().id() == QMetaType::QTime )
|
}
|
||||||
{
|
#else
|
||||||
ret = vDT;
|
if (vDT.type() == QVariant::DateTime) {
|
||||||
}
|
ret = vDT;
|
||||||
else
|
} else if (vDT.type() == QVariant::Date) {
|
||||||
{
|
ret = vDT;
|
||||||
return QVariant();
|
} else if (vDT.type() == QVariant::Time) {
|
||||||
}
|
ret = vDT;
|
||||||
#else
|
} else {
|
||||||
if ( vDT.type() == QVariant::DateTime )
|
return QVariant();
|
||||||
{
|
}
|
||||||
ret = vDT;
|
#endif
|
||||||
}
|
|
||||||
else if ( vDT.type() == QVariant::Date )
|
|
||||||
{
|
|
||||||
ret = vDT;
|
|
||||||
}
|
|
||||||
else if ( vDT.type() == QVariant::Time )
|
|
||||||
{
|
|
||||||
ret = vDT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// QDateTime dt = dateTime();
|
// QDateTime dt = dateTime();
|
||||||
// ret = dt;
|
// ret = dt;
|
||||||
|
|
||||||
// QString strFormat = fmt.numberFormat();
|
// QString strFormat = fmt.numberFormat();
|
||||||
// if (!strFormat.isEmpty())
|
// if (!strFormat.isEmpty())
|
||||||
// {
|
// {
|
||||||
@ -185,9 +168,9 @@ QVariant Cell::readValue() const
|
|||||||
|
|
||||||
// if (styleNo == 11)
|
// if (styleNo == 11)
|
||||||
// {
|
// {
|
||||||
// QTime timeValue = dt.time(); // only time. (HH:mm:ss)
|
// QTime timeValue = dt.time(); // only time. (HH:mm:ss)
|
||||||
// ret = timeValue;
|
// ret = timeValue;
|
||||||
// return ret;
|
// return ret;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if (styleNo == 12)
|
// if (styleNo == 12)
|
||||||
@ -196,42 +179,41 @@ QVariant Cell::readValue() const
|
|||||||
|
|
||||||
// if (styleNo == 13) // (HH:mm:ss)
|
// if (styleNo == 13) // (HH:mm:ss)
|
||||||
// {
|
// {
|
||||||
// double dValue = d->value.toDouble();
|
// double dValue = d->value.toDouble();
|
||||||
// int day = int(dValue); // unit is day.
|
// int day = int(dValue); // unit is day.
|
||||||
// double deciamlPointValue1 = dValue - double(day);
|
// double deciamlPointValue1 = dValue - double(day);
|
||||||
|
|
||||||
// double dHour = deciamlPointValue1 * (double(1.0) / double(24.0));
|
// double dHour = deciamlPointValue1 * (double(1.0) / double(24.0));
|
||||||
// int hour = int(dHour);
|
// int hour = int(dHour);
|
||||||
|
|
||||||
// double deciamlPointValue2 = deciamlPointValue1 - (double(hour) * (double(1.0) / double(24.0)));
|
// double deciamlPointValue2 = deciamlPointValue1 - (double(hour) * (double(1.0) /
|
||||||
// double dMin = deciamlPointValue2 * (double(1.0) / double(60.0));
|
// double(24.0))); double dMin = deciamlPointValue2 * (double(1.0) / double(60.0)); int min
|
||||||
// int min = int(dMin);
|
// = int(dMin);
|
||||||
|
|
||||||
// double deciamlPointValue3 = deciamlPointValue2 - (double(min) * (double(1.0) / double(60.0)));
|
// double deciamlPointValue3 = deciamlPointValue2 - (double(min) * (double(1.0) /
|
||||||
// double dSec = deciamlPointValue3 * (double(1.0) / double(60.0));
|
// double(60.0))); double dSec = deciamlPointValue3 * (double(1.0) / double(60.0)); int sec
|
||||||
// int sec = int(dSec);
|
// = int(dSec);
|
||||||
|
|
||||||
// int totalHour = hour + (day * 24);
|
|
||||||
|
|
||||||
// QString strTime;
|
// int totalHour = hour + (day * 24);
|
||||||
// strTime = QString("%1:%2:%3").arg(totalHour).arg(min).arg(sec);
|
|
||||||
// ret = strTime;
|
|
||||||
|
|
||||||
// return ret;
|
// QString strTime;
|
||||||
|
// strTime = QString("%1:%2:%3").arg(totalHour).arg(min).arg(sec);
|
||||||
|
// ret = strTime;
|
||||||
|
|
||||||
|
// return ret;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return ret;
|
// return ret;
|
||||||
// */
|
// */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFormula())
|
if (hasFormula()) {
|
||||||
{
|
QString formulaString = this->formula().formulaText();
|
||||||
QString formulaString = this->formula().formulaText();
|
ret = formulaString;
|
||||||
ret = formulaString;
|
return ret; // return formula string
|
||||||
return ret; // return formula string
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -239,9 +221,9 @@ QVariant Cell::readValue() const
|
|||||||
*/
|
*/
|
||||||
Format Cell::format() const
|
Format Cell::format() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
return d->format;
|
return d->format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -249,9 +231,9 @@ Format Cell::format() const
|
|||||||
*/
|
*/
|
||||||
bool Cell::hasFormula() const
|
bool Cell::hasFormula() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
return d->formula.isValid();
|
return d->formula.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -259,9 +241,9 @@ bool Cell::hasFormula() const
|
|||||||
*/
|
*/
|
||||||
CellFormula Cell::formula() const
|
CellFormula Cell::formula() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
return d->formula;
|
return d->formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -269,28 +251,22 @@ CellFormula Cell::formula() const
|
|||||||
*/
|
*/
|
||||||
bool Cell::isDateTime() const
|
bool Cell::isDateTime() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
Cell::CellType cellType = d->cellType;
|
Cell::CellType cellType = d->cellType;
|
||||||
double dValue = d->value.toDouble(); // number
|
double dValue = d->value.toDouble(); // number
|
||||||
// QString strValue = d->value.toString().toUtf8();
|
// QString strValue = d->value.toString().toUtf8();
|
||||||
bool isValidFormat = d->format.isValid();
|
bool isValidFormat = d->format.isValid();
|
||||||
bool isDateTimeFormat = d->format.isDateTimeFormat(); // datetime format
|
bool isDateTimeFormat = d->format.isDateTimeFormat(); // datetime format
|
||||||
|
|
||||||
// dev67
|
// dev67
|
||||||
if ( cellType == NumberType ||
|
if (cellType == NumberType || cellType == DateType || cellType == CustomType) {
|
||||||
cellType == DateType ||
|
if (dValue >= 0 && isValidFormat && isDateTimeFormat) {
|
||||||
cellType == CustomType )
|
|
||||||
{
|
|
||||||
if ( dValue >= 0 &&
|
|
||||||
isValidFormat &&
|
|
||||||
isDateTimeFormat )
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -299,29 +275,28 @@ bool Cell::isDateTime() const
|
|||||||
/*
|
/*
|
||||||
QDateTime Cell::dateTime() const
|
QDateTime Cell::dateTime() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
if (!isDateTime())
|
if (!isDateTime())
|
||||||
return QDateTime();
|
return QDateTime();
|
||||||
|
|
||||||
return datetimeFromNumber(d->value.toDouble(), d->parent->workbook()->isDate1904());
|
return datetimeFromNumber(d->value.toDouble(), d->parent->workbook()->isDate1904());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
QVariant Cell::dateTime() const
|
QVariant Cell::dateTime() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
if (!isDateTime())
|
if (!isDateTime()) {
|
||||||
{
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
// dev57
|
// dev57
|
||||||
|
|
||||||
QVariant ret;
|
QVariant ret;
|
||||||
double dValue = d->value.toDouble();
|
double dValue = d->value.toDouble();
|
||||||
bool isDate1904 = d->parent->workbook()->isDate1904();
|
bool isDate1904 = d->parent->workbook()->isDate1904();
|
||||||
ret = datetimeFromNumber(dValue, isDate1904);
|
ret = datetimeFromNumber(dValue, isDate1904);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,35 +305,30 @@ QVariant Cell::dateTime() const
|
|||||||
*/
|
*/
|
||||||
bool Cell::isRichString() const
|
bool Cell::isRichString() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
if ( d->cellType != SharedStringType &&
|
if (d->cellType != SharedStringType && d->cellType != InlineStringType &&
|
||||||
d->cellType != InlineStringType &&
|
d->cellType != StringType) {
|
||||||
d->cellType != StringType )
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->richString.isRichString();
|
return d->richString.isRichString();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32 Cell::styleNumber() const
|
qint32 Cell::styleNumber() const
|
||||||
{
|
{
|
||||||
Q_D(const Cell);
|
Q_D(const Cell);
|
||||||
|
|
||||||
qint32 ret = d->styleNumber;
|
qint32 ret = d->styleNumber;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Cell::isDateType(CellType cellType, const Format &format)
|
bool Cell::isDateType(CellType cellType, const Format &format)
|
||||||
{
|
{
|
||||||
if ( cellType == NumberType ||
|
if (cellType == NumberType || cellType == DateType || cellType == CustomType) {
|
||||||
cellType == DateType ||
|
|
||||||
cellType == CustomType )
|
|
||||||
{
|
|
||||||
return format.isValid() && format.isDateTimeFormat();
|
return format.isValid() && format.isDateTimeFormat();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -1,40 +1,46 @@
|
|||||||
// xlsxcellformula.cpp
|
// xlsxcellformula.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxcellformula.h"
|
||||||
|
|
||||||
|
#include "xlsxcellformula_p.h"
|
||||||
|
#include "xlsxutility_p.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include <QDebug>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "xlsxcellformula.h"
|
|
||||||
#include "xlsxcellformula_p.h"
|
|
||||||
#include "xlsxutility_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
CellFormulaPrivate::CellFormulaPrivate(const QString &formula_, const CellRange &ref_, CellFormula::FormulaType type_)
|
CellFormulaPrivate::CellFormulaPrivate(const QString &formula_,
|
||||||
:formula(formula_), type(type_), reference(ref_), ca(false), si(0)
|
const CellRange &ref_,
|
||||||
|
CellFormula::FormulaType type_)
|
||||||
|
: formula(formula_)
|
||||||
|
, type(type_)
|
||||||
|
, reference(ref_)
|
||||||
|
, ca(false)
|
||||||
|
, si(0)
|
||||||
{
|
{
|
||||||
//Remove the formula '=' sign if exists
|
// Remove the formula '=' sign if exists
|
||||||
if (formula.startsWith(QLatin1String("=")))
|
if (formula.startsWith(QLatin1String("=")))
|
||||||
formula.remove(0,1);
|
formula.remove(0, 1);
|
||||||
else if (formula.startsWith(QLatin1String("{=")) && formula.endsWith(QLatin1String("}")))
|
else if (formula.startsWith(QLatin1String("{=")) && formula.endsWith(QLatin1String("}")))
|
||||||
formula = formula.mid(2, formula.length()-3);
|
formula = formula.mid(2, formula.length() - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
CellFormulaPrivate::CellFormulaPrivate(const CellFormulaPrivate &other)
|
CellFormulaPrivate::CellFormulaPrivate(const CellFormulaPrivate &other)
|
||||||
: QSharedData(other)
|
: QSharedData(other)
|
||||||
, formula(other.formula), type(other.type), reference(other.reference)
|
, formula(other.formula)
|
||||||
, ca(other.ca), si(other.si)
|
, type(other.type)
|
||||||
|
, reference(other.reference)
|
||||||
|
, ca(other.ca)
|
||||||
|
, si(other.si)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellFormulaPrivate::~CellFormulaPrivate()
|
CellFormulaPrivate::~CellFormulaPrivate() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class CellFormula
|
\class CellFormula
|
||||||
@ -56,41 +62,38 @@ CellFormulaPrivate::~CellFormulaPrivate()
|
|||||||
*/
|
*/
|
||||||
CellFormula::CellFormula()
|
CellFormula::CellFormula()
|
||||||
{
|
{
|
||||||
//The d pointer is initialized with a null pointer
|
// The d pointer is initialized with a null pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Creates a new formula with the given \a formula and \a type.
|
* Creates a new formula with the given \a formula and \a type.
|
||||||
*/
|
*/
|
||||||
CellFormula::CellFormula(const char *formula, FormulaType type)
|
CellFormula::CellFormula(const char *formula, FormulaType type)
|
||||||
:d(new CellFormulaPrivate(QString::fromLatin1(formula), CellRange(), type))
|
: d(new CellFormulaPrivate(QString::fromLatin1(formula), CellRange(), type))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Creates a new formula with the given \a formula and \a type.
|
* Creates a new formula with the given \a formula and \a type.
|
||||||
*/
|
*/
|
||||||
CellFormula::CellFormula(const QString &formula, FormulaType type)
|
CellFormula::CellFormula(const QString &formula, FormulaType type)
|
||||||
:d(new CellFormulaPrivate(formula, CellRange(), type))
|
: d(new CellFormulaPrivate(formula, CellRange(), type))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Creates a new formula with the given \a formula, \a ref and \a type.
|
* Creates a new formula with the given \a formula, \a ref and \a type.
|
||||||
*/
|
*/
|
||||||
CellFormula::CellFormula(const QString &formula, const CellRange &ref, FormulaType type)
|
CellFormula::CellFormula(const QString &formula, const CellRange &ref, FormulaType type)
|
||||||
:d(new CellFormulaPrivate(formula, ref, type))
|
: d(new CellFormulaPrivate(formula, ref, type))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Creates a new formula with the same attributes as the \a other formula.
|
Creates a new formula with the same attributes as the \a other formula.
|
||||||
*/
|
*/
|
||||||
CellFormula::CellFormula(const CellFormula &other)
|
CellFormula::CellFormula(const CellFormula &other)
|
||||||
:d(other.d)
|
: d(other.d)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +101,7 @@ CellFormula::CellFormula(const CellFormula &other)
|
|||||||
Assigns the \a other formula to this formula, and returns a
|
Assigns the \a other formula to this formula, and returns a
|
||||||
reference to this formula.
|
reference to this formula.
|
||||||
*/
|
*/
|
||||||
CellFormula &CellFormula::operator =(const CellFormula &other)
|
CellFormula &CellFormula::operator=(const CellFormula &other)
|
||||||
{
|
{
|
||||||
d = other.d;
|
d = other.d;
|
||||||
return *this;
|
return *this;
|
||||||
@ -107,10 +110,7 @@ CellFormula &CellFormula::operator =(const CellFormula &other)
|
|||||||
/*!
|
/*!
|
||||||
* Destroys this formula.
|
* Destroys this formula.
|
||||||
*/
|
*/
|
||||||
CellFormula::~CellFormula()
|
CellFormula::~CellFormula() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the type of the formula.
|
* Returns the type of the formula.
|
||||||
@ -187,7 +187,7 @@ int CellFormula::sharedIndex() const
|
|||||||
*
|
*
|
||||||
* The possible values for this attribute are defined by the W3C XML Schema
|
* The possible values for this attribute are defined by the W3C XML Schema
|
||||||
* boolean datatype.
|
* boolean datatype.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* del2 (Input 2 Deleted) // not-impplmented attribute
|
/* del2 (Input 2 Deleted) // not-impplmented attribute
|
||||||
*
|
*
|
||||||
@ -257,8 +257,7 @@ bool CellFormula::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
// shared (Shared Formula)
|
// shared (Shared Formula)
|
||||||
|
|
||||||
QString t;
|
QString t;
|
||||||
switch (d->type)
|
switch (d->type) {
|
||||||
{
|
|
||||||
case CellFormula::ArrayType:
|
case CellFormula::ArrayType:
|
||||||
t = QStringLiteral("array");
|
t = QStringLiteral("array");
|
||||||
break;
|
break;
|
||||||
@ -282,8 +281,7 @@ bool CellFormula::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
// character node of this element.
|
// character node of this element.
|
||||||
writer.writeStartElement(QStringLiteral("f"));
|
writer.writeStartElement(QStringLiteral("f"));
|
||||||
|
|
||||||
if (!t.isEmpty())
|
if (!t.isEmpty()) {
|
||||||
{
|
|
||||||
writer.writeAttribute(QStringLiteral("t"), t); // write type(t)
|
writer.writeAttribute(QStringLiteral("t"), t); // write type(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,12 +295,9 @@ bool CellFormula::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
// The possible values for this attribute are defined by the ST_Ref
|
// The possible values for this attribute are defined by the ST_Ref
|
||||||
// simple type (§18.18.62).
|
// simple type (§18.18.62).
|
||||||
|
|
||||||
if ( d->type == CellFormula::SharedType ||
|
if (d->type == CellFormula::SharedType || d->type == CellFormula::ArrayType ||
|
||||||
d->type == CellFormula::ArrayType ||
|
d->type == CellFormula::DataTableType) {
|
||||||
d->type == CellFormula::DataTableType )
|
if (d->reference.isValid()) {
|
||||||
{
|
|
||||||
if (d->reference.isValid())
|
|
||||||
{
|
|
||||||
writer.writeAttribute(QStringLiteral("ref"), d->reference.toString());
|
writer.writeAttribute(QStringLiteral("ref"), d->reference.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,8 +315,7 @@ bool CellFormula::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
// An instance of a datatype that is defined as ·boolean· can have the
|
// An instance of a datatype that is defined as ·boolean· can have the
|
||||||
// following legal literals {true, false, 1, 0}.
|
// following legal literals {true, false, 1, 0}.
|
||||||
|
|
||||||
if (d->ca)
|
if (d->ca) {
|
||||||
{
|
|
||||||
writer.writeAttribute(QStringLiteral("ca"), QStringLiteral("1"));
|
writer.writeAttribute(QStringLiteral("ca"), QStringLiteral("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,14 +331,12 @@ bool CellFormula::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
// what the formula expression should be based on the cell's relative
|
// what the formula expression should be based on the cell's relative
|
||||||
// location to the master formula cell.
|
// location to the master formula cell.
|
||||||
|
|
||||||
if (d->type == CellFormula::SharedType)
|
if (d->type == CellFormula::SharedType) {
|
||||||
{
|
|
||||||
int si = d->si;
|
int si = d->si;
|
||||||
writer.writeAttribute(QStringLiteral("si"), QString::number(si));
|
writer.writeAttribute(QStringLiteral("si"), QString::number(si));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->formula.isEmpty())
|
if (!d->formula.isEmpty()) {
|
||||||
{
|
|
||||||
QString strFormula = d->formula;
|
QString strFormula = d->formula;
|
||||||
writer.writeCharacters(strFormula); // write formula
|
writer.writeCharacters(strFormula); // write formula
|
||||||
}
|
}
|
||||||
@ -365,23 +357,19 @@ bool CellFormula::loadFromXml(QXmlStreamReader &reader)
|
|||||||
d = new CellFormulaPrivate(QString(), CellRange(), NormalType);
|
d = new CellFormulaPrivate(QString(), CellRange(), NormalType);
|
||||||
|
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
QString typeString = attributes.value(QLatin1String("t")).toString();
|
QString typeString = attributes.value(QLatin1String("t")).toString();
|
||||||
|
|
||||||
// branch: shared-formula
|
// branch: shared-formula
|
||||||
//
|
//
|
||||||
if (typeString == QLatin1String("array")) {
|
if (typeString == QLatin1String("array")) {
|
||||||
d->type = ArrayType;
|
d->type = ArrayType;
|
||||||
}
|
} else if (typeString == QLatin1String("shared")) {
|
||||||
else if (typeString == QLatin1String("shared")) {
|
|
||||||
d->type = SharedType;
|
d->type = SharedType;
|
||||||
}
|
} else if (typeString == QLatin1String("normal")) {
|
||||||
else if (typeString == QLatin1String("normal")) {
|
|
||||||
d->type = NormalType;
|
d->type = NormalType;
|
||||||
}
|
} else if (typeString == QLatin1String("dataTable")) {
|
||||||
else if (typeString == QLatin1String("dataTable")) {
|
|
||||||
d->type = DataTableType;
|
d->type = DataTableType;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/*
|
/*
|
||||||
// undefined type
|
// undefined type
|
||||||
// qDebug() << "Undefined type" << typeString;
|
// qDebug() << "Undefined type" << typeString;
|
||||||
@ -399,14 +387,11 @@ bool CellFormula::loadFromXml(QXmlStreamReader &reader)
|
|||||||
// ref (Range of Cells)
|
// ref (Range of Cells)
|
||||||
// Range of cells which the formula applies to.
|
// Range of cells which the formula applies to.
|
||||||
// Only required for shared formula, array formula or data table.
|
// Only required for shared formula, array formula or data table.
|
||||||
if ( d->type == CellFormula::SharedType ||
|
if (d->type == CellFormula::SharedType || d->type == CellFormula::ArrayType ||
|
||||||
d->type == CellFormula::ArrayType ||
|
d->type == CellFormula::DataTableType) {
|
||||||
d->type == CellFormula::DataTableType )
|
if (attributes.hasAttribute(QLatin1String("ref"))) {
|
||||||
{
|
|
||||||
if (attributes.hasAttribute(QLatin1String("ref")))
|
|
||||||
{
|
|
||||||
QString refString = attributes.value(QLatin1String("ref")).toString();
|
QString refString = attributes.value(QLatin1String("ref")).toString();
|
||||||
d->reference = CellRange(refString);
|
d->reference = CellRange(refString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,13 +401,11 @@ bool CellFormula::loadFromXml(QXmlStreamReader &reader)
|
|||||||
// Optional attribute to optimize load performance by sharing formulas.
|
// Optional attribute to optimize load performance by sharing formulas.
|
||||||
// When a formula is a shared formula (t value is shared) then this value
|
// When a formula is a shared formula (t value is shared) then this value
|
||||||
// indicates the group to which this particular cell's formula belongs.
|
// indicates the group to which this particular cell's formula belongs.
|
||||||
if ( d->type == CellFormula::SharedType )
|
if (d->type == CellFormula::SharedType) {
|
||||||
{
|
|
||||||
QString ca = attributes.value(QLatin1String("si")).toString();
|
QString ca = attributes.value(QLatin1String("si")).toString();
|
||||||
d->ca = parseXsdBoolean(ca, false);
|
d->ca = parseXsdBoolean(ca, false);
|
||||||
|
|
||||||
if (attributes.hasAttribute(QLatin1String("si")))
|
if (attributes.hasAttribute(QLatin1String("si"))) {
|
||||||
{
|
|
||||||
d->si = attributes.value(QLatin1String("si")).toInt();
|
d->si = attributes.value(QLatin1String("si")).toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -435,19 +418,17 @@ bool CellFormula::loadFromXml(QXmlStreamReader &reader)
|
|||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
bool CellFormula::operator ==(const CellFormula &formula) const
|
bool CellFormula::operator==(const CellFormula &formula) const
|
||||||
{
|
{
|
||||||
return d->formula == formula.d->formula && d->type == formula.d->type
|
return d->formula == formula.d->formula && d->type == formula.d->type && d->si == formula.d->si;
|
||||||
&& d->si ==formula.d->si;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
bool CellFormula::operator !=(const CellFormula &formula) const
|
bool CellFormula::operator!=(const CellFormula &formula) const
|
||||||
{
|
{
|
||||||
return d->formula != formula.d->formula || d->type != formula.d->type
|
return d->formula != formula.d->formula || d->type != formula.d->type || d->si != formula.d->si;
|
||||||
|| d->si !=formula.d->si;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// xlsxcelllocation.cpp
|
// xlsxcelllocation.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxcelllocation.h"
|
||||||
|
|
||||||
|
#include "xlsxcell.h"
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
|
||||||
#include "xlsxcell.h"
|
|
||||||
#include "xlsxcelllocation.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
// xlsxcellrange.cpp
|
// xlsxcellrange.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
|
||||||
#include <QPoint>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
|
|
||||||
#include "xlsxcellreference.h"
|
#include "xlsxcellreference.h"
|
||||||
|
|
||||||
|
#include <QPoint>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -24,7 +25,10 @@ QT_BEGIN_NAMESPACE_XLSX
|
|||||||
whose rowCount() and columnCount() are 0.
|
whose rowCount() and columnCount() are 0.
|
||||||
*/
|
*/
|
||||||
CellRange::CellRange()
|
CellRange::CellRange()
|
||||||
: top(-1), left(-1), bottom(-2), right(-2)
|
: top(-1)
|
||||||
|
, left(-1)
|
||||||
|
, bottom(-2)
|
||||||
|
, right(-2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,13 +39,18 @@ CellRange::CellRange()
|
|||||||
\sa topRow(), leftColumn(), bottomRow(), rightColumn()
|
\sa topRow(), leftColumn(), bottomRow(), rightColumn()
|
||||||
*/
|
*/
|
||||||
CellRange::CellRange(int top, int left, int bottom, int right)
|
CellRange::CellRange(int top, int left, int bottom, int right)
|
||||||
: top(top), left(left), bottom(bottom), right(right)
|
: top(top)
|
||||||
|
, left(left)
|
||||||
|
, bottom(bottom)
|
||||||
|
, right(right)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CellRange::CellRange(const CellReference &topLeft, const CellReference &bottomRight)
|
CellRange::CellRange(const CellReference &topLeft, const CellReference &bottomRight)
|
||||||
: top(topLeft.row()), left(topLeft.column())
|
: top(topLeft.row())
|
||||||
, bottom(bottomRight.row()), right(bottomRight.column())
|
, left(topLeft.column())
|
||||||
|
, bottom(bottomRight.row())
|
||||||
|
, right(bottomRight.column())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,16 +78,16 @@ void CellRange::init(const QString &range)
|
|||||||
if (rs.size() == 2) {
|
if (rs.size() == 2) {
|
||||||
CellReference start(rs[0]);
|
CellReference start(rs[0]);
|
||||||
CellReference end(rs[1]);
|
CellReference end(rs[1]);
|
||||||
top = start.row();
|
top = start.row();
|
||||||
left = start.column();
|
left = start.column();
|
||||||
bottom = end.row();
|
bottom = end.row();
|
||||||
right = end.column();
|
right = end.column();
|
||||||
} else {
|
} else {
|
||||||
CellReference p(rs[0]);
|
CellReference p(rs[0]);
|
||||||
top = p.row();
|
top = p.row();
|
||||||
left = p.column();
|
left = p.column();
|
||||||
bottom = p.row();
|
bottom = p.row();
|
||||||
right = p.column();
|
right = p.column();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,16 +96,17 @@ void CellRange::init(const QString &range)
|
|||||||
other range.
|
other range.
|
||||||
*/
|
*/
|
||||||
CellRange::CellRange(const CellRange &other)
|
CellRange::CellRange(const CellRange &other)
|
||||||
: top(other.top), left(other.left), bottom(other.bottom), right(other.right)
|
: top(other.top)
|
||||||
|
, left(other.left)
|
||||||
|
, bottom(other.bottom)
|
||||||
|
, right(other.right)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Destroys the range.
|
Destroys the range.
|
||||||
*/
|
*/
|
||||||
CellRange::~CellRange()
|
CellRange::~CellRange() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Convert the range to string notation, such as "A1:B5".
|
Convert the range to string notation, such as "A1:B5".
|
||||||
@ -107,7 +117,7 @@ QString CellRange::toString(bool row_abs, bool col_abs) const
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
if (left == right && top == bottom) {
|
if (left == right && top == bottom) {
|
||||||
//Single cell
|
// Single cell
|
||||||
return CellReference(top, left).toString(row_abs, col_abs);
|
return CellReference(top, left).toString(row_abs, col_abs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// xlsxcellreference.cpp
|
// xlsxcellreference.cpp
|
||||||
|
|
||||||
#include "xlsxcellreference.h"
|
#include "xlsxcellreference.h"
|
||||||
#include <QStringList>
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -12,12 +12,16 @@ namespace {
|
|||||||
|
|
||||||
int intPow(int x, int p)
|
int intPow(int x, int p)
|
||||||
{
|
{
|
||||||
if (p == 0) return 1;
|
if (p == 0)
|
||||||
if (p == 1) return x;
|
return 1;
|
||||||
|
if (p == 1)
|
||||||
|
return x;
|
||||||
|
|
||||||
int tmp = intPow(x, p/2);
|
int tmp = intPow(x, p / 2);
|
||||||
if (p%2 == 0) return tmp * tmp;
|
if (p % 2 == 0)
|
||||||
else return x * tmp * tmp;
|
return tmp * tmp;
|
||||||
|
else
|
||||||
|
return x * tmp * tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString col_to_name(int col_num)
|
QString col_to_name(int col_num)
|
||||||
@ -32,7 +36,7 @@ QString col_to_name(int col_num)
|
|||||||
remainder = col_num % 26;
|
remainder = col_num % 26;
|
||||||
if (remainder == 0)
|
if (remainder == 0)
|
||||||
remainder = 26;
|
remainder = 26;
|
||||||
col_str.prepend(QChar('A'+remainder-1));
|
col_str.prepend(QChar('A' + remainder - 1));
|
||||||
col_num = (col_num - 1) / 26;
|
col_num = (col_num - 1) / 26;
|
||||||
}
|
}
|
||||||
it = col_cache.insert(col_num, col_str);
|
it = col_cache.insert(col_num, col_str);
|
||||||
@ -43,16 +47,16 @@ QString col_to_name(int col_num)
|
|||||||
|
|
||||||
int col_from_name(const QString &col_str)
|
int col_from_name(const QString &col_str)
|
||||||
{
|
{
|
||||||
int col = 0;
|
int col = 0;
|
||||||
int expn = 0;
|
int expn = 0;
|
||||||
for (int i=col_str.size()-1; i>-1; --i) {
|
for (int i = col_str.size() - 1; i > -1; --i) {
|
||||||
col += (col_str[i].unicode() - 'A' + 1) * intPow(26, expn);
|
col += (col_str[i].unicode() - 'A' + 1) * intPow(26, expn);
|
||||||
expn++;
|
expn++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
} //namespace
|
} // namespace
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class CellReference
|
\class CellReference
|
||||||
@ -66,7 +70,8 @@ int col_from_name(const QString &col_str)
|
|||||||
Constructs an invalid Cell Reference
|
Constructs an invalid Cell Reference
|
||||||
*/
|
*/
|
||||||
CellReference::CellReference()
|
CellReference::CellReference()
|
||||||
: _row(-1), _column(-1)
|
: _row(-1)
|
||||||
|
, _column(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +79,8 @@ CellReference::CellReference()
|
|||||||
Constructs the Reference from the given \a row, and \a column.
|
Constructs the Reference from the given \a row, and \a column.
|
||||||
*/
|
*/
|
||||||
CellReference::CellReference(int row, int column)
|
CellReference::CellReference(int row, int column)
|
||||||
: _row(row), _column(column)
|
: _row(row)
|
||||||
|
, _column(column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +109,8 @@ void CellReference::init(const QString &cell_str)
|
|||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
const QString col_str = match.captured(1);
|
const QString col_str = match.captured(1);
|
||||||
const QString row_str = match.captured(2);
|
const QString row_str = match.captured(2);
|
||||||
_row = row_str.toInt();
|
_row = row_str.toInt();
|
||||||
_column = col_from_name(col_str);
|
_column = col_from_name(col_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,16 +119,15 @@ void CellReference::init(const QString &cell_str)
|
|||||||
other Reference.
|
other Reference.
|
||||||
*/
|
*/
|
||||||
CellReference::CellReference(const CellReference &other)
|
CellReference::CellReference(const CellReference &other)
|
||||||
: _row(other._row), _column(other._column)
|
: _row(other._row)
|
||||||
|
, _column(other._column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Destroys the Reference.
|
Destroys the Reference.
|
||||||
*/
|
*/
|
||||||
CellReference::~CellReference()
|
CellReference::~CellReference() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Convert the Reference to string notation, such as "A1" or "$A$1".
|
Convert the Reference to string notation, such as "A1" or "$A$1".
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +1,29 @@
|
|||||||
// xlsxchartsheet.cpp
|
// xlsxchartsheet.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include "xlsxchartsheet.h"
|
#include "xlsxchartsheet.h"
|
||||||
|
|
||||||
|
#include "xlsxchart.h"
|
||||||
#include "xlsxchartsheet_p.h"
|
#include "xlsxchartsheet_p.h"
|
||||||
#include "xlsxworkbook.h"
|
|
||||||
#include "xlsxutility_p.h"
|
|
||||||
#include "xlsxdrawing_p.h"
|
#include "xlsxdrawing_p.h"
|
||||||
#include "xlsxdrawinganchor_p.h"
|
#include "xlsxdrawinganchor_p.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxutility_p.h"
|
||||||
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
ChartsheetPrivate::ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag)
|
ChartsheetPrivate::ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag)
|
||||||
: AbstractSheetPrivate(p, flag), chart(0)
|
: AbstractSheetPrivate(p, flag)
|
||||||
{
|
, chart(0)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ChartsheetPrivate::~ChartsheetPrivate()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChartsheetPrivate::~ChartsheetPrivate() {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Chartsheet
|
\class Chartsheet
|
||||||
\inmodule QtXlsx
|
\inmodule QtXlsx
|
||||||
@ -35,15 +34,15 @@ ChartsheetPrivate::~ChartsheetPrivate()
|
|||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
Chartsheet::Chartsheet(const QString &name, int id, Workbook *workbook, CreateFlag flag)
|
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);
|
setSheetType(ST_ChartSheet);
|
||||||
|
|
||||||
if (flag == Chartsheet::F_NewFromScratch)
|
if (flag == Chartsheet::F_NewFromScratch) {
|
||||||
{
|
|
||||||
d_func()->drawing = std::make_shared<Drawing>(this, flag);
|
d_func()->drawing = std::make_shared<Drawing>(this, flag);
|
||||||
|
|
||||||
DrawingAbsoluteAnchor *anchor = new DrawingAbsoluteAnchor(drawing(), DrawingAnchor::Picture);
|
DrawingAbsoluteAnchor *anchor =
|
||||||
|
new DrawingAbsoluteAnchor(drawing(), DrawingAnchor::Picture);
|
||||||
|
|
||||||
anchor->pos = QPoint(0, 0);
|
anchor->pos = QPoint(0, 0);
|
||||||
anchor->ext = QSize(9293679, 6068786);
|
anchor->ext = QSize(9293679, 6068786);
|
||||||
@ -64,7 +63,7 @@ Chartsheet::Chartsheet(const QString &name, int id, Workbook *workbook, CreateFl
|
|||||||
|
|
||||||
Chartsheet *Chartsheet::copy(const QString &distName, int distId) const
|
Chartsheet *Chartsheet::copy(const QString &distName, int distId) const
|
||||||
{
|
{
|
||||||
//:Todo
|
//: Todo
|
||||||
Q_UNUSED(distName)
|
Q_UNUSED(distName)
|
||||||
Q_UNUSED(distId)
|
Q_UNUSED(distId)
|
||||||
return 0;
|
return 0;
|
||||||
@ -73,9 +72,7 @@ Chartsheet *Chartsheet::copy(const QString &distName, int distId) const
|
|||||||
/*!
|
/*!
|
||||||
* Destroys this workssheet.
|
* Destroys this workssheet.
|
||||||
*/
|
*/
|
||||||
Chartsheet::~Chartsheet()
|
Chartsheet::~Chartsheet() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the chart object of the sheet.
|
* Returns the chart object of the sheet.
|
||||||
@ -95,23 +92,28 @@ void Chartsheet::saveToXmlFile(QIODevice *device) const
|
|||||||
QXmlStreamWriter writer(device);
|
QXmlStreamWriter writer(device);
|
||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeDefaultNamespace(QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
|
writer.writeDefaultNamespace(
|
||||||
writer.writeNamespace(QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), QStringLiteral("r"));
|
QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
|
||||||
|
writer.writeNamespace(
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"),
|
||||||
|
QStringLiteral("r"));
|
||||||
writer.writeStartElement(QStringLiteral("chartsheet"));
|
writer.writeStartElement(QStringLiteral("chartsheet"));
|
||||||
|
|
||||||
writer.writeStartElement(QStringLiteral("sheetViews"));
|
writer.writeStartElement(QStringLiteral("sheetViews"));
|
||||||
writer.writeEmptyElement(QStringLiteral("sheetView"));
|
writer.writeEmptyElement(QStringLiteral("sheetView"));
|
||||||
writer.writeAttribute(QStringLiteral("workbookViewId"), QString::number(0));
|
writer.writeAttribute(QStringLiteral("workbookViewId"), QString::number(0));
|
||||||
writer.writeAttribute(QStringLiteral("zoomToFit"), QStringLiteral("1"));
|
writer.writeAttribute(QStringLiteral("zoomToFit"), QStringLiteral("1"));
|
||||||
writer.writeEndElement(); //sheetViews
|
writer.writeEndElement(); // sheetViews
|
||||||
|
|
||||||
int idx = d->workbook->drawings().indexOf(d->drawing.get());
|
int idx = d->workbook->drawings().indexOf(d->drawing.get());
|
||||||
d->relationships->addWorksheetRelationship(QStringLiteral("/drawing"), QStringLiteral("../drawings/drawing%1.xml").arg(idx+1));
|
d->relationships->addWorksheetRelationship(
|
||||||
|
QStringLiteral("/drawing"), QStringLiteral("../drawings/drawing%1.xml").arg(idx + 1));
|
||||||
|
|
||||||
writer.writeEmptyElement(QStringLiteral("drawing"));
|
writer.writeEmptyElement(QStringLiteral("drawing"));
|
||||||
writer.writeAttribute(QStringLiteral("r:id"), QStringLiteral("rId%1").arg(d->relationships->count()));
|
writer.writeAttribute(QStringLiteral("r:id"),
|
||||||
|
QStringLiteral("rId%1").arg(d->relationships->count()));
|
||||||
|
|
||||||
writer.writeEndElement();//chartsheet
|
writer.writeEndElement(); // chartsheet
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,11 +126,11 @@ bool Chartsheet::loadFromXmlFile(QIODevice *device)
|
|||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("drawing")) {
|
if (reader.name() == QLatin1String("drawing")) {
|
||||||
QString rId = reader.attributes().value(QStringLiteral("r:id")).toString();
|
QString rId = reader.attributes().value(QStringLiteral("r:id")).toString();
|
||||||
QString name = d->relationships->getRelationshipById(rId).target;
|
QString name = d->relationships->getRelationshipById(rId).target;
|
||||||
|
|
||||||
const auto parts = splitPath(filePath());
|
const auto parts = splitPath(filePath());
|
||||||
QString path = QDir::cleanPath(parts.first() + QLatin1String("/") + name);
|
QString path = QDir::cleanPath(parts.first() + QLatin1String("/") + name);
|
||||||
|
|
||||||
d->drawing = std::make_shared<Drawing>(this, F_LoadFromExists);
|
d->drawing = std::make_shared<Drawing>(this, F_LoadFromExists);
|
||||||
d->drawing->setFilePath(path);
|
d->drawing->setFilePath(path);
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
// xlsxcolor.cpp
|
// xlsxcolor.cpp
|
||||||
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "xlsxcolor_p.h"
|
#include "xlsxcolor_p.h"
|
||||||
#include "xlsxstyles_p.h"
|
#include "xlsxstyles_p.h"
|
||||||
#include "xlsxutility_p.h"
|
#include "xlsxutility_p.h"
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
XlsxColor::XlsxColor(const QColor &color)
|
XlsxColor::XlsxColor(const QColor &color)
|
||||||
@ -18,15 +18,13 @@ XlsxColor::XlsxColor(const QColor &color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
XlsxColor::XlsxColor(const QString &theme, const QString &tint)
|
XlsxColor::XlsxColor(const QString &theme, const QString &tint)
|
||||||
:val(QStringList()<<theme<<tint)
|
: val(QStringList() << theme << tint)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XlsxColor::XlsxColor(int index)
|
XlsxColor::XlsxColor(int index)
|
||||||
:val(index)
|
: val(index)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XlsxColor::isRgbColor() const
|
bool XlsxColor::isRgbColor() const
|
||||||
@ -67,7 +65,7 @@ QStringList XlsxColor::themeColor() const
|
|||||||
bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const
|
bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const
|
||||||
{
|
{
|
||||||
if (!node.isEmpty())
|
if (!node.isEmpty())
|
||||||
writer.writeEmptyElement(node); //color, bgColor, fgColor
|
writer.writeEmptyElement(node); // color, bgColor, fgColor
|
||||||
else
|
else
|
||||||
writer.writeEmptyElement(QStringLiteral("color"));
|
writer.writeEmptyElement(QStringLiteral("color"));
|
||||||
|
|
||||||
@ -89,34 +87,33 @@ bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const
|
|||||||
|
|
||||||
bool XlsxColor::loadFromXml(QXmlStreamReader &reader)
|
bool XlsxColor::loadFromXml(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
const auto& attributes = reader.attributes();
|
const auto &attributes = reader.attributes();
|
||||||
|
|
||||||
if (attributes.hasAttribute(QLatin1String("rgb"))) {
|
if (attributes.hasAttribute(QLatin1String("rgb"))) {
|
||||||
const auto& colorString = attributes.value(QLatin1String("rgb")).toString();
|
const auto &colorString = attributes.value(QLatin1String("rgb")).toString();
|
||||||
val.setValue(fromARGBString(colorString));
|
val.setValue(fromARGBString(colorString));
|
||||||
} else if (attributes.hasAttribute(QLatin1String("indexed"))) {
|
} else if (attributes.hasAttribute(QLatin1String("indexed"))) {
|
||||||
int index = attributes.value(QLatin1String("indexed")).toInt();
|
int index = attributes.value(QLatin1String("indexed")).toInt();
|
||||||
val.setValue(index);
|
val.setValue(index);
|
||||||
} else if (attributes.hasAttribute(QLatin1String("theme"))) {
|
} else if (attributes.hasAttribute(QLatin1String("theme"))) {
|
||||||
const auto& theme = attributes.value(QLatin1String("theme")).toString();
|
const auto &theme = attributes.value(QLatin1String("theme")).toString();
|
||||||
const auto& tint = attributes.value(QLatin1String("tint")).toString();
|
const auto &tint = attributes.value(QLatin1String("tint")).toString();
|
||||||
val.setValue(QStringList()<<theme<<tint);
|
val.setValue(QStringList() << theme << tint);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
XlsxColor::operator QVariant() const
|
XlsxColor::operator QVariant() const
|
||||||
{
|
{
|
||||||
const auto& cref
|
const auto &cref
|
||||||
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
||||||
= QMetaType::fromType<XlsxColor>();
|
= QMetaType::fromType<XlsxColor>();
|
||||||
#else
|
#else
|
||||||
= qMetaTypeId<XlsxColor>() ;
|
= qMetaTypeId<XlsxColor>();
|
||||||
#endif
|
#endif
|
||||||
return QVariant(cref, this);
|
return QVariant(cref, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QColor XlsxColor::fromARGBString(const QString &c)
|
QColor XlsxColor::fromARGBString(const QString &c)
|
||||||
{
|
{
|
||||||
QColor color;
|
QColor color;
|
||||||
@ -137,15 +134,15 @@ QString XlsxColor::toARGBString(const QColor &c)
|
|||||||
QDataStream &operator<<(QDataStream &s, const XlsxColor &color)
|
QDataStream &operator<<(QDataStream &s, const XlsxColor &color)
|
||||||
{
|
{
|
||||||
if (color.isInvalid())
|
if (color.isInvalid())
|
||||||
s<<0;
|
s << 0;
|
||||||
else if (color.isRgbColor())
|
else if (color.isRgbColor())
|
||||||
s<<1<<color.rgbColor();
|
s << 1 << color.rgbColor();
|
||||||
else if (color.isIndexedColor())
|
else if (color.isIndexedColor())
|
||||||
s<<2<<color.indexedColor();
|
s << 2 << color.indexedColor();
|
||||||
else if (color.isThemeColor())
|
else if (color.isThemeColor())
|
||||||
s<<3<<color.themeColor();
|
s << 3 << color.themeColor();
|
||||||
else
|
else
|
||||||
s<<4;
|
s << 4;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -153,20 +150,20 @@ QDataStream &operator<<(QDataStream &s, const XlsxColor &color)
|
|||||||
QDataStream &operator>>(QDataStream &s, XlsxColor &color)
|
QDataStream &operator>>(QDataStream &s, XlsxColor &color)
|
||||||
{
|
{
|
||||||
int marker(4);
|
int marker(4);
|
||||||
s>>marker;
|
s >> marker;
|
||||||
if (marker == 0) {
|
if (marker == 0) {
|
||||||
color = XlsxColor();
|
color = XlsxColor();
|
||||||
} else if (marker == 1) {
|
} else if (marker == 1) {
|
||||||
QColor c;
|
QColor c;
|
||||||
s>>c;
|
s >> c;
|
||||||
color = XlsxColor(c);
|
color = XlsxColor(c);
|
||||||
} else if (marker == 2) {
|
} else if (marker == 2) {
|
||||||
int indexed;
|
int indexed;
|
||||||
s>>indexed;
|
s >> indexed;
|
||||||
color = XlsxColor(indexed);
|
color = XlsxColor(indexed);
|
||||||
} else if (marker == 3) {
|
} else if (marker == 3) {
|
||||||
QStringList list;
|
QStringList list;
|
||||||
s>>list;
|
s >> list;
|
||||||
color = XlsxColor(list[0], list[1]);
|
color = XlsxColor(list[0], list[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,5 +189,4 @@ QDebug operator<<(QDebug dbg, const XlsxColor &c)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE_XLSX
|
QT_END_NAMESPACE_XLSX
|
||||||
|
@ -1,46 +1,55 @@
|
|||||||
// xlsxconditionalformatting.cpp
|
// xlsxconditionalformatting.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxconditionalformatting.h"
|
||||||
|
|
||||||
|
#include "xlsxcellrange.h"
|
||||||
|
#include "xlsxconditionalformatting_p.h"
|
||||||
|
#include "xlsxstyles_p.h"
|
||||||
|
#include "xlsxworksheet.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include <QDebug>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "xlsxconditionalformatting.h"
|
|
||||||
#include "xlsxconditionalformatting_p.h"
|
|
||||||
#include "xlsxworksheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
|
||||||
#include "xlsxstyles_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
ConditionalFormattingPrivate::ConditionalFormattingPrivate()
|
ConditionalFormattingPrivate::ConditionalFormattingPrivate() {}
|
||||||
{
|
|
||||||
|
|
||||||
|
ConditionalFormattingPrivate::ConditionalFormattingPrivate(
|
||||||
|
const ConditionalFormattingPrivate &other)
|
||||||
|
: QSharedData(other)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ConditionalFormattingPrivate::ConditionalFormattingPrivate(const ConditionalFormattingPrivate &other)
|
ConditionalFormattingPrivate::~ConditionalFormattingPrivate() {}
|
||||||
:QSharedData(other)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void ConditionalFormattingPrivate::writeCfVo(QXmlStreamWriter &writer,
|
||||||
|
const XlsxCfVoData &cfvo) const
|
||||||
ConditionalFormattingPrivate::~ConditionalFormattingPrivate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConditionalFormattingPrivate::writeCfVo(QXmlStreamWriter &writer, const XlsxCfVoData &cfvo) const
|
|
||||||
{
|
{
|
||||||
writer.writeEmptyElement(QStringLiteral("cfvo"));
|
writer.writeEmptyElement(QStringLiteral("cfvo"));
|
||||||
QString type;
|
QString type;
|
||||||
switch(cfvo.type) {
|
switch (cfvo.type) {
|
||||||
case ConditionalFormatting::VOT_Formula: type=QStringLiteral("formula"); break;
|
case ConditionalFormatting::VOT_Formula:
|
||||||
case ConditionalFormatting::VOT_Max: type=QStringLiteral("max"); break;
|
type = QStringLiteral("formula");
|
||||||
case ConditionalFormatting::VOT_Min: type=QStringLiteral("min"); break;
|
break;
|
||||||
case ConditionalFormatting::VOT_Num: type=QStringLiteral("num"); break;
|
case ConditionalFormatting::VOT_Max:
|
||||||
case ConditionalFormatting::VOT_Percent: type=QStringLiteral("percent"); break;
|
type = QStringLiteral("max");
|
||||||
case ConditionalFormatting::VOT_Percentile: type=QStringLiteral("percentile"); break;
|
break;
|
||||||
default: break;
|
case ConditionalFormatting::VOT_Min:
|
||||||
|
type = QStringLiteral("min");
|
||||||
|
break;
|
||||||
|
case ConditionalFormatting::VOT_Num:
|
||||||
|
type = QStringLiteral("num");
|
||||||
|
break;
|
||||||
|
case ConditionalFormatting::VOT_Percent:
|
||||||
|
type = QStringLiteral("percent");
|
||||||
|
break;
|
||||||
|
case ConditionalFormatting::VOT_Percentile:
|
||||||
|
type = QStringLiteral("percentile");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
writer.writeAttribute(QStringLiteral("type"), type);
|
writer.writeAttribute(QStringLiteral("type"), type);
|
||||||
writer.writeAttribute(QStringLiteral("val"), cfvo.value);
|
writer.writeAttribute(QStringLiteral("val"), cfvo.value);
|
||||||
@ -56,7 +65,6 @@ void ConditionalFormattingPrivate::writeCfVo(QXmlStreamWriter &writer, const Xls
|
|||||||
* The conditional formatting can be applied to a single cell or ranges of cells.
|
* The conditional formatting can be applied to a single cell or ranges of cells.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\enum ConditionalFormatting::HighlightRuleType
|
\enum ConditionalFormatting::HighlightRuleType
|
||||||
|
|
||||||
@ -118,18 +126,16 @@ void ConditionalFormattingPrivate::writeCfVo(QXmlStreamWriter &writer, const Xls
|
|||||||
Construct a conditional formatting object
|
Construct a conditional formatting object
|
||||||
*/
|
*/
|
||||||
ConditionalFormatting::ConditionalFormatting()
|
ConditionalFormatting::ConditionalFormatting()
|
||||||
:d(new ConditionalFormattingPrivate())
|
: d(new ConditionalFormattingPrivate())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a copy of \a other.
|
Constructs a copy of \a other.
|
||||||
*/
|
*/
|
||||||
ConditionalFormatting::ConditionalFormatting(const ConditionalFormatting &other)
|
ConditionalFormatting::ConditionalFormatting(const ConditionalFormatting &other)
|
||||||
:d(other.d)
|
: d(other.d)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -142,20 +148,21 @@ ConditionalFormatting &ConditionalFormatting::operator=(const ConditionalFormatt
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroy the object.
|
* Destroy the object.
|
||||||
*/
|
*/
|
||||||
ConditionalFormatting::~ConditionalFormatting()
|
ConditionalFormatting::~ConditionalFormatting() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Add a hightlight rule with the given \a type, \a formula1, \a formula2,
|
* Add a hightlight rule with the given \a type, \a formula1, \a formula2,
|
||||||
* \a format and \a stopIfTrue.
|
* \a format and \a stopIfTrue.
|
||||||
* Return false if failed.
|
* Return false if failed.
|
||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const QString &formula1, const QString &formula2, const Format &format, bool stopIfTrue)
|
bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type,
|
||||||
|
const QString &formula1,
|
||||||
|
const QString &formula2,
|
||||||
|
const Format &format,
|
||||||
|
bool stopIfTrue)
|
||||||
{
|
{
|
||||||
if (format.isEmpty())
|
if (format.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@ -167,68 +174,90 @@ bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const
|
|||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("cellIs");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("cellIs");
|
||||||
QString op;
|
QString op;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Highlight_Between: op = QStringLiteral("between"); break;
|
case Highlight_Between:
|
||||||
case Highlight_Equal: op = QStringLiteral("equal"); break;
|
op = QStringLiteral("between");
|
||||||
case Highlight_GreaterThan: op = QStringLiteral("greaterThan"); break;
|
break;
|
||||||
case Highlight_GreaterThanOrEqual: op = QStringLiteral("greaterThanOrEqual"); break;
|
case Highlight_Equal:
|
||||||
case Highlight_LessThan: op = QStringLiteral("lessThan"); break;
|
op = QStringLiteral("equal");
|
||||||
case Highlight_LessThanOrEqual: op = QStringLiteral("lessThanOrEqual"); break;
|
break;
|
||||||
case Highlight_NotBetween: op = QStringLiteral("notBetween"); break;
|
case Highlight_GreaterThan:
|
||||||
case Highlight_NotEqual: op = QStringLiteral("notEqual"); break;
|
op = QStringLiteral("greaterThan");
|
||||||
default: break;
|
break;
|
||||||
|
case Highlight_GreaterThanOrEqual:
|
||||||
|
op = QStringLiteral("greaterThanOrEqual");
|
||||||
|
break;
|
||||||
|
case Highlight_LessThan:
|
||||||
|
op = QStringLiteral("lessThan");
|
||||||
|
break;
|
||||||
|
case Highlight_LessThanOrEqual:
|
||||||
|
op = QStringLiteral("lessThanOrEqual");
|
||||||
|
break;
|
||||||
|
case Highlight_NotBetween:
|
||||||
|
op = QStringLiteral("notBetween");
|
||||||
|
break;
|
||||||
|
case Highlight_NotEqual:
|
||||||
|
op = QStringLiteral("notEqual");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
cfRule->attrs[XlsxCfRuleData::A_operator] = op;
|
cfRule->attrs[XlsxCfRuleData::A_operator] = op;
|
||||||
} else if (type >= Highlight_ContainsText && type <= Highlight_EndsWith) {
|
} else if (type >= Highlight_ContainsText && type <= Highlight_EndsWith) {
|
||||||
if (type == Highlight_ContainsText) {
|
if (type == Highlight_ContainsText) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsText");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsText");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("containsText");
|
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("containsText");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("NOT(ISERROR(SEARCH(\"%1\",%2)))").arg(formula1);
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] =
|
||||||
|
QStringLiteral("NOT(ISERROR(SEARCH(\"%1\",%2)))").arg(formula1);
|
||||||
} else if (type == Highlight_NotContainsText) {
|
} else if (type == Highlight_NotContainsText) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsText");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsText");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("notContains");
|
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("notContains");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("ISERROR(SEARCH(\"%2\",%1))").arg(formula1);
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] =
|
||||||
|
QStringLiteral("ISERROR(SEARCH(\"%2\",%1))").arg(formula1);
|
||||||
} else if (type == Highlight_BeginsWith) {
|
} else if (type == Highlight_BeginsWith) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("beginsWith");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("beginsWith");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("beginsWith");
|
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("beginsWith");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEFT(%2,LEN(\"%1\"))=\"%1\"").arg(formula1);
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] =
|
||||||
|
QStringLiteral("LEFT(%2,LEN(\"%1\"))=\"%1\"").arg(formula1);
|
||||||
} else {
|
} else {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("endsWith");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("endsWith");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("endsWith");
|
cfRule->attrs[XlsxCfRuleData::A_operator] = QStringLiteral("endsWith");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("RIGHT(%2,LEN(\"%1\"))=\"%1\"").arg(formula1);
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] =
|
||||||
|
QStringLiteral("RIGHT(%2,LEN(\"%1\"))=\"%1\"").arg(formula1);
|
||||||
}
|
}
|
||||||
cfRule->attrs[XlsxCfRuleData::A_text] = formula1;
|
cfRule->attrs[XlsxCfRuleData::A_text] = formula1;
|
||||||
skipFormula = true;
|
skipFormula = true;
|
||||||
} else if (type == Highlight_TimePeriod) {
|
} else if (type == Highlight_TimePeriod) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("timePeriod");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("timePeriod");
|
||||||
//:Todo
|
//: Todo
|
||||||
return false;
|
return false;
|
||||||
} else if (type == Highlight_Duplicate) {
|
} else if (type == Highlight_Duplicate) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("duplicateValues");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("duplicateValues");
|
||||||
} else if (type == Highlight_Unique) {
|
} else if (type == Highlight_Unique) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("uniqueValues");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("uniqueValues");
|
||||||
} else if (type == Highlight_Errors) {
|
} else if (type == Highlight_Errors) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsErrors");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsErrors");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("ISERROR(%1)");
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("ISERROR(%1)");
|
||||||
skipFormula = true;
|
skipFormula = true;
|
||||||
} else if (type == Highlight_NoErrors) {
|
} else if (type == Highlight_NoErrors) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsErrors");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsErrors");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("NOT(ISERROR(%1))");
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("NOT(ISERROR(%1))");
|
||||||
skipFormula = true;
|
skipFormula = true;
|
||||||
} else if (type == Highlight_Blanks) {
|
} else if (type == Highlight_Blanks) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsBlanks");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("containsBlanks");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEN(TRIM(%1))=0");
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEN(TRIM(%1))=0");
|
||||||
skipFormula = true;
|
skipFormula = true;
|
||||||
} else if (type == Highlight_NoBlanks) {
|
} else if (type == Highlight_NoBlanks) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsBlanks");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("notContainsBlanks");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEN(TRIM(%1))>0");
|
cfRule->attrs[XlsxCfRuleData::A_formula1_temp] = QStringLiteral("LEN(TRIM(%1))>0");
|
||||||
skipFormula = true;
|
skipFormula = true;
|
||||||
} else if (type >= Highlight_Top && type <= Highlight_BottomPercent) {
|
} else if (type >= Highlight_Top && type <= Highlight_BottomPercent) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("top10");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("top10");
|
||||||
if (type == Highlight_Bottom || type == Highlight_BottomPercent)
|
if (type == Highlight_Bottom || type == Highlight_BottomPercent)
|
||||||
cfRule->attrs[XlsxCfRuleData::A_bottom] = QStringLiteral("1");
|
cfRule->attrs[XlsxCfRuleData::A_bottom] = QStringLiteral("1");
|
||||||
if (type == Highlight_TopPercent || type == Highlight_BottomPercent)
|
if (type == Highlight_TopPercent || type == Highlight_BottomPercent)
|
||||||
cfRule->attrs[XlsxCfRuleData::A_percent] = QStringLiteral("1");
|
cfRule->attrs[XlsxCfRuleData::A_percent] = QStringLiteral("1");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_rank] = !formula1.isEmpty() ? formula1 : QStringLiteral("10");
|
cfRule->attrs[XlsxCfRuleData::A_rank] =
|
||||||
|
!formula1.isEmpty() ? formula1 : QStringLiteral("10");
|
||||||
skipFormula = true;
|
skipFormula = true;
|
||||||
} else if (type >= Highlight_AboveAverage && type <= Highlight_BelowStdDev3) {
|
} else if (type >= Highlight_AboveAverage && type <= Highlight_BelowStdDev3) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("aboveAverage");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("aboveAverage");
|
||||||
@ -242,7 +271,7 @@ bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const
|
|||||||
cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("2");
|
cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("2");
|
||||||
else if (type == Highlight_AboveStdDev3 || type == Highlight_BelowStdDev3)
|
else if (type == Highlight_AboveStdDev3 || type == Highlight_BelowStdDev3)
|
||||||
cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("3");
|
cfRule->attrs[XlsxCfRuleData::A_stdDev] = QStringLiteral("3");
|
||||||
} else if (type == Highlight_Expression){
|
} else if (type == Highlight_Expression) {
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("expression");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("expression");
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -253,9 +282,11 @@ bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const
|
|||||||
cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
|
cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
|
||||||
if (!skipFormula) {
|
if (!skipFormula) {
|
||||||
if (!formula1.isEmpty())
|
if (!formula1.isEmpty())
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula1] = formula1.startsWith(QLatin1String("=")) ? formula1.mid(1) : formula1;
|
cfRule->attrs[XlsxCfRuleData::A_formula1] =
|
||||||
|
formula1.startsWith(QLatin1String("=")) ? formula1.mid(1) : formula1;
|
||||||
if (!formula2.isEmpty())
|
if (!formula2.isEmpty())
|
||||||
cfRule->attrs[XlsxCfRuleData::A_formula2] = formula2.startsWith(QLatin1String("=")) ? formula2.mid(1) : formula2;
|
cfRule->attrs[XlsxCfRuleData::A_formula2] =
|
||||||
|
formula2.startsWith(QLatin1String("=")) ? formula2.mid(1) : formula2;
|
||||||
}
|
}
|
||||||
d->cfRules.append(cfRule);
|
d->cfRules.append(cfRule);
|
||||||
return true;
|
return true;
|
||||||
@ -266,10 +297,12 @@ bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const
|
|||||||
*
|
*
|
||||||
* Add a hightlight rule with the given \a type \a format and \a stopIfTrue.
|
* Add a hightlight rule with the given \a type \a format and \a stopIfTrue.
|
||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const Format &format, bool stopIfTrue)
|
bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type,
|
||||||
|
const Format &format,
|
||||||
|
bool stopIfTrue)
|
||||||
{
|
{
|
||||||
if ((type >= Highlight_AboveAverage && type <= Highlight_BelowStdDev3)
|
if ((type >= Highlight_AboveAverage && type <= Highlight_BelowStdDev3) ||
|
||||||
|| (type >= Highlight_Duplicate && type <= Highlight_NoErrors)) {
|
(type >= Highlight_Duplicate && type <= Highlight_NoErrors)) {
|
||||||
return addHighlightCellsRule(type, QString(), QString(), format, stopIfTrue);
|
return addHighlightCellsRule(type, QString(), QString(), format, stopIfTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +315,10 @@ bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const
|
|||||||
* Add a hightlight rule with the given \a type, \a formula, \a format and \a stopIfTrue.
|
* Add a hightlight rule with the given \a type, \a formula, \a format and \a stopIfTrue.
|
||||||
* Return false if failed.
|
* Return false if failed.
|
||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const QString &formula, const Format &format, bool stopIfTrue)
|
bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type,
|
||||||
|
const QString &formula,
|
||||||
|
const Format &format,
|
||||||
|
bool stopIfTrue)
|
||||||
{
|
{
|
||||||
if (type == Highlight_Between || type == Highlight_NotBetween)
|
if (type == Highlight_Between || type == Highlight_NotBetween)
|
||||||
return false;
|
return false;
|
||||||
@ -295,11 +331,17 @@ bool ConditionalFormatting::addHighlightCellsRule(HighlightRuleType type, const
|
|||||||
* , \a type2, \a val2, \a showData and \a stopIfTrue.
|
* , \a type2, \a val2, \a showData and \a stopIfTrue.
|
||||||
* Return false if failed.
|
* Return false if failed.
|
||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::addDataBarRule(const QColor &color, ValueObjectType type1, const QString &val1, ValueObjectType type2, const QString &val2, bool showData, bool stopIfTrue)
|
bool ConditionalFormatting::addDataBarRule(const QColor &color,
|
||||||
|
ValueObjectType type1,
|
||||||
|
const QString &val1,
|
||||||
|
ValueObjectType type2,
|
||||||
|
const QString &val2,
|
||||||
|
bool showData,
|
||||||
|
bool stopIfTrue)
|
||||||
{
|
{
|
||||||
auto cfRule = std::make_shared<XlsxCfRuleData>();
|
auto cfRule = std::make_shared<XlsxCfRuleData>();
|
||||||
|
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("dataBar");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("dataBar");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(color);
|
cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(color);
|
||||||
if (stopIfTrue)
|
if (stopIfTrue)
|
||||||
cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
|
cfRule->attrs[XlsxCfRuleData::A_stopIfTrue] = true;
|
||||||
@ -321,23 +363,26 @@ bool ConditionalFormatting::addDataBarRule(const QColor &color, ValueObjectType
|
|||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::addDataBarRule(const QColor &color, bool showData, bool stopIfTrue)
|
bool ConditionalFormatting::addDataBarRule(const QColor &color, bool showData, bool stopIfTrue)
|
||||||
{
|
{
|
||||||
return addDataBarRule(color, VOT_Min, QStringLiteral("0"), VOT_Max, QStringLiteral("0"), showData, stopIfTrue);
|
return addDataBarRule(
|
||||||
|
color, VOT_Min, QStringLiteral("0"), VOT_Max, QStringLiteral("0"), showData, stopIfTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Add a colorScale rule with the given \a minColor, \a maxColor and \a stopIfTrue.
|
* Add a colorScale rule with the given \a minColor, \a maxColor and \a stopIfTrue.
|
||||||
* Return false if failed.
|
* Return false if failed.
|
||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue)
|
bool ConditionalFormatting::add2ColorScaleRule(const QColor &minColor,
|
||||||
|
const QColor &maxColor,
|
||||||
|
bool stopIfTrue)
|
||||||
{
|
{
|
||||||
ValueObjectType type1 = VOT_Min;
|
ValueObjectType type1 = VOT_Min;
|
||||||
ValueObjectType type2 = VOT_Max;
|
ValueObjectType type2 = VOT_Max;
|
||||||
QString val1 = QStringLiteral("0");
|
QString val1 = QStringLiteral("0");
|
||||||
QString val2 = QStringLiteral("0");
|
QString val2 = QStringLiteral("0");
|
||||||
|
|
||||||
auto cfRule = std::make_shared<XlsxCfRuleData>();
|
auto cfRule = std::make_shared<XlsxCfRuleData>();
|
||||||
|
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("colorScale");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("colorScale");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(minColor);
|
cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(minColor);
|
||||||
cfRule->attrs[XlsxCfRuleData::A_color2] = XlsxColor(maxColor);
|
cfRule->attrs[XlsxCfRuleData::A_color2] = XlsxColor(maxColor);
|
||||||
if (stopIfTrue)
|
if (stopIfTrue)
|
||||||
@ -356,18 +401,21 @@ bool ConditionalFormatting::add2ColorScaleRule(const QColor &minColor, const QCo
|
|||||||
* Add a colorScale rule with the given \a minColor, \a midColor, \a maxColor and \a stopIfTrue.
|
* Add a colorScale rule with the given \a minColor, \a midColor, \a maxColor and \a stopIfTrue.
|
||||||
* Return false if failed.
|
* Return false if failed.
|
||||||
*/
|
*/
|
||||||
bool ConditionalFormatting::add3ColorScaleRule(const QColor &minColor, const QColor &midColor, const QColor &maxColor, bool stopIfTrue)
|
bool ConditionalFormatting::add3ColorScaleRule(const QColor &minColor,
|
||||||
|
const QColor &midColor,
|
||||||
|
const QColor &maxColor,
|
||||||
|
bool stopIfTrue)
|
||||||
{
|
{
|
||||||
ValueObjectType type1 = VOT_Min;
|
ValueObjectType type1 = VOT_Min;
|
||||||
ValueObjectType type2 = VOT_Percent;
|
ValueObjectType type2 = VOT_Percent;
|
||||||
ValueObjectType type3 = VOT_Max;
|
ValueObjectType type3 = VOT_Max;
|
||||||
QString val1 = QStringLiteral("0");
|
QString val1 = QStringLiteral("0");
|
||||||
QString val2 = QStringLiteral("50");
|
QString val2 = QStringLiteral("50");
|
||||||
QString val3 = QStringLiteral("0");
|
QString val3 = QStringLiteral("0");
|
||||||
|
|
||||||
auto cfRule = std::make_shared<XlsxCfRuleData>();
|
auto cfRule = std::make_shared<XlsxCfRuleData>();
|
||||||
|
|
||||||
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("colorScale");
|
cfRule->attrs[XlsxCfRuleData::A_type] = QStringLiteral("colorScale");
|
||||||
cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(minColor);
|
cfRule->attrs[XlsxCfRuleData::A_color1] = XlsxColor(minColor);
|
||||||
cfRule->attrs[XlsxCfRuleData::A_color2] = XlsxColor(midColor);
|
cfRule->attrs[XlsxCfRuleData::A_color2] = XlsxColor(midColor);
|
||||||
cfRule->attrs[XlsxCfRuleData::A_color3] = XlsxColor(maxColor);
|
cfRule->attrs[XlsxCfRuleData::A_color3] = XlsxColor(maxColor);
|
||||||
@ -429,7 +477,9 @@ void ConditionalFormatting::addRange(const CellRange &range)
|
|||||||
d->ranges.append(range);
|
d->ranges.append(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader, XlsxCfRuleData *rule, Styles *styles)
|
bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader,
|
||||||
|
XlsxCfRuleData *rule,
|
||||||
|
Styles *styles)
|
||||||
{
|
{
|
||||||
Q_ASSERT(reader.name() == QLatin1String("cfRule"));
|
Q_ASSERT(reader.name() == QLatin1String("cfRule"));
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
@ -444,19 +494,19 @@ bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader, XlsxCfRu
|
|||||||
}
|
}
|
||||||
rule->priority = attrs.value(QLatin1String("priority")).toInt();
|
rule->priority = attrs.value(QLatin1String("priority")).toInt();
|
||||||
if (attrs.value(QLatin1String("stopIfTrue")) == QLatin1String("1")) {
|
if (attrs.value(QLatin1String("stopIfTrue")) == QLatin1String("1")) {
|
||||||
//default is false
|
// default is false
|
||||||
rule->attrs[XlsxCfRuleData::A_stopIfTrue] = QLatin1String("1");
|
rule->attrs[XlsxCfRuleData::A_stopIfTrue] = QLatin1String("1");
|
||||||
}
|
}
|
||||||
if (attrs.value(QLatin1String("aboveAverage")) == QLatin1String("0")) {
|
if (attrs.value(QLatin1String("aboveAverage")) == QLatin1String("0")) {
|
||||||
//default is true
|
// default is true
|
||||||
rule->attrs[XlsxCfRuleData::A_aboveAverage] = QLatin1String("0");
|
rule->attrs[XlsxCfRuleData::A_aboveAverage] = QLatin1String("0");
|
||||||
}
|
}
|
||||||
if (attrs.value(QLatin1String("percent")) == QLatin1String("1")) {
|
if (attrs.value(QLatin1String("percent")) == QLatin1String("1")) {
|
||||||
//default is false
|
// default is false
|
||||||
rule->attrs[XlsxCfRuleData::A_percent] = QLatin1String("1");
|
rule->attrs[XlsxCfRuleData::A_percent] = QLatin1String("1");
|
||||||
}
|
}
|
||||||
if (attrs.value(QLatin1String("bottom")) == QLatin1String("1")) {
|
if (attrs.value(QLatin1String("bottom")) == QLatin1String("1")) {
|
||||||
//default is false
|
// default is false
|
||||||
rule->attrs[XlsxCfRuleData::A_bottom] = QLatin1String("1");
|
rule->attrs[XlsxCfRuleData::A_bottom] = QLatin1String("1");
|
||||||
}
|
}
|
||||||
if (attrs.hasAttribute(QLatin1String("operator")))
|
if (attrs.hasAttribute(QLatin1String("operator")))
|
||||||
@ -466,7 +516,8 @@ bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader, XlsxCfRu
|
|||||||
rule->attrs[XlsxCfRuleData::A_text] = attrs.value(QLatin1String("text")).toString();
|
rule->attrs[XlsxCfRuleData::A_text] = attrs.value(QLatin1String("text")).toString();
|
||||||
|
|
||||||
if (attrs.hasAttribute(QLatin1String("timePeriod")))
|
if (attrs.hasAttribute(QLatin1String("timePeriod")))
|
||||||
rule->attrs[XlsxCfRuleData::A_timePeriod] = attrs.value(QLatin1String("timePeriod")).toString();
|
rule->attrs[XlsxCfRuleData::A_timePeriod] =
|
||||||
|
attrs.value(QLatin1String("timePeriod")).toString();
|
||||||
|
|
||||||
if (attrs.hasAttribute(QLatin1String("rank")))
|
if (attrs.hasAttribute(QLatin1String("rank")))
|
||||||
rule->attrs[XlsxCfRuleData::A_rank] = attrs.value(QLatin1String("rank")).toString();
|
rule->attrs[XlsxCfRuleData::A_rank] = attrs.value(QLatin1String("rank")).toString();
|
||||||
@ -475,7 +526,7 @@ bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader, XlsxCfRu
|
|||||||
rule->attrs[XlsxCfRuleData::A_stdDev] = attrs.value(QLatin1String("stdDev")).toString();
|
rule->attrs[XlsxCfRuleData::A_stdDev] = attrs.value(QLatin1String("stdDev")).toString();
|
||||||
|
|
||||||
if (attrs.value(QLatin1String("equalAverage")) == QLatin1String("1")) {
|
if (attrs.value(QLatin1String("equalAverage")) == QLatin1String("1")) {
|
||||||
//default is false
|
// default is false
|
||||||
rule->attrs[XlsxCfRuleData::A_equalAverage] = QLatin1String("1");
|
rule->attrs[XlsxCfRuleData::A_equalAverage] = QLatin1String("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,8 +547,8 @@ bool ConditionalFormattingPrivate::readCfRule(QXmlStreamReader &reader, XlsxCfRu
|
|||||||
readCfColorScale(reader, rule);
|
readCfColorScale(reader, rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader.tokenType() == QXmlStreamReader::EndElement
|
if (reader.tokenType() == QXmlStreamReader::EndElement &&
|
||||||
&& reader.name() == QStringLiteral("conditionalFormatting")) {
|
reader.name() == QStringLiteral("conditionalFormatting")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,8 +578,8 @@ bool ConditionalFormattingPrivate::readCfDataBar(QXmlStreamReader &reader, XlsxC
|
|||||||
rule->attrs[XlsxCfRuleData::A_color1] = color;
|
rule->attrs[XlsxCfRuleData::A_color1] = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader.tokenType() == QXmlStreamReader::EndElement
|
if (reader.tokenType() == QXmlStreamReader::EndElement &&
|
||||||
&& reader.name() == QStringLiteral("dataBar")) {
|
reader.name() == QStringLiteral("dataBar")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,8 +614,8 @@ bool ConditionalFormattingPrivate::readCfColorScale(QXmlStreamReader &reader, Xl
|
|||||||
rule->attrs[XlsxCfRuleData::A_color3] = color;
|
rule->attrs[XlsxCfRuleData::A_color3] = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader.tokenType() == QXmlStreamReader::EndElement
|
if (reader.tokenType() == QXmlStreamReader::EndElement &&
|
||||||
&& reader.name() == QStringLiteral("colorScale")) {
|
reader.name() == QStringLiteral("colorScale")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,13 +641,13 @@ bool ConditionalFormattingPrivate::readCfVo(QXmlStreamReader &reader, XlsxCfVoDa
|
|||||||
t = ConditionalFormatting::VOT_Num;
|
t = ConditionalFormatting::VOT_Num;
|
||||||
else if (type == QLatin1String("percent"))
|
else if (type == QLatin1String("percent"))
|
||||||
t = ConditionalFormatting::VOT_Percent;
|
t = ConditionalFormatting::VOT_Percent;
|
||||||
else //if (type == QLatin1String("percentile"))
|
else // if (type == QLatin1String("percentile"))
|
||||||
t = ConditionalFormatting::VOT_Percentile;
|
t = ConditionalFormatting::VOT_Percentile;
|
||||||
|
|
||||||
cfvo.type = t;
|
cfvo.type = t;
|
||||||
cfvo.value = attrs.value(QLatin1String("val")).toString();
|
cfvo.value = attrs.value(QLatin1String("val")).toString();
|
||||||
if (attrs.value(QLatin1String("gte")) == QLatin1String("0")) {
|
if (attrs.value(QLatin1String("gte")) == QLatin1String("0")) {
|
||||||
//default is true
|
// default is true
|
||||||
cfvo.gte = false;
|
cfvo.gte = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -609,8 +660,8 @@ bool ConditionalFormatting::loadFromXml(QXmlStreamReader &reader, Styles *styles
|
|||||||
d->ranges.clear();
|
d->ranges.clear();
|
||||||
d->cfRules.clear();
|
d->cfRules.clear();
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
const QString sqref = attrs.value(QLatin1String("sqref")).toString();
|
const QString sqref = attrs.value(QLatin1String("sqref")).toString();
|
||||||
const auto sqrefParts = sqref.split(QLatin1Char(' '));
|
const auto sqrefParts = sqref.split(QLatin1Char(' '));
|
||||||
for (const QString &range : sqrefParts) {
|
for (const QString &range : sqrefParts) {
|
||||||
this->addRange(range);
|
this->addRange(range);
|
||||||
}
|
}
|
||||||
@ -624,13 +675,12 @@ bool ConditionalFormatting::loadFromXml(QXmlStreamReader &reader, Styles *styles
|
|||||||
d->cfRules.append(cfRule);
|
d->cfRules.append(cfRule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reader.tokenType() == QXmlStreamReader::EndElement
|
if (reader.tokenType() == QXmlStreamReader::EndElement &&
|
||||||
&& reader.name() == QStringLiteral("conditionalFormatting")) {
|
reader.name() == QStringLiteral("conditionalFormatting")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,12 +694,14 @@ bool ConditionalFormatting::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
}
|
}
|
||||||
writer.writeAttribute(QStringLiteral("sqref"), sqref.join(QLatin1String(" ")));
|
writer.writeAttribute(QStringLiteral("sqref"), sqref.join(QLatin1String(" ")));
|
||||||
|
|
||||||
for (int i=0; i<d->cfRules.size(); ++i) {
|
for (int i = 0; i < d->cfRules.size(); ++i) {
|
||||||
const std::shared_ptr<XlsxCfRuleData> &rule = d->cfRules[i];
|
const std::shared_ptr<XlsxCfRuleData> &rule = d->cfRules[i];
|
||||||
writer.writeStartElement(QStringLiteral("cfRule"));
|
writer.writeStartElement(QStringLiteral("cfRule"));
|
||||||
writer.writeAttribute(QStringLiteral("type"), rule->attrs[XlsxCfRuleData::A_type].toString());
|
writer.writeAttribute(QStringLiteral("type"),
|
||||||
|
rule->attrs[XlsxCfRuleData::A_type].toString());
|
||||||
if (rule->dxfFormat.dxfIndexValid())
|
if (rule->dxfFormat.dxfIndexValid())
|
||||||
writer.writeAttribute(QStringLiteral("dxfId"), QString::number(rule->dxfFormat.dxfIndex()));
|
writer.writeAttribute(QStringLiteral("dxfId"),
|
||||||
|
QString::number(rule->dxfFormat.dxfIndex()));
|
||||||
writer.writeAttribute(QStringLiteral("priority"), QString::number(rule->priority));
|
writer.writeAttribute(QStringLiteral("priority"), QString::number(rule->priority));
|
||||||
|
|
||||||
auto it = rule->attrs.constFind(XlsxCfRuleData::A_stopIfTrue);
|
auto it = rule->attrs.constFind(XlsxCfRuleData::A_stopIfTrue);
|
||||||
@ -699,7 +751,7 @@ bool ConditionalFormatting::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
|
d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
|
||||||
d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo2].value<XlsxCfVoData>());
|
d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo2].value<XlsxCfVoData>());
|
||||||
rule->attrs[XlsxCfRuleData::A_color1].value<XlsxColor>().saveToXml(writer);
|
rule->attrs[XlsxCfRuleData::A_color1].value<XlsxColor>().saveToXml(writer);
|
||||||
writer.writeEndElement();//dataBar
|
writer.writeEndElement(); // dataBar
|
||||||
} else if (rule->attrs[XlsxCfRuleData::A_type] == QLatin1String("colorScale")) {
|
} else if (rule->attrs[XlsxCfRuleData::A_type] == QLatin1String("colorScale")) {
|
||||||
writer.writeStartElement(QStringLiteral("colorScale"));
|
writer.writeStartElement(QStringLiteral("colorScale"));
|
||||||
d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
|
d->writeCfVo(writer, rule->attrs[XlsxCfRuleData::A_cfvo1].value<XlsxCfVoData>());
|
||||||
@ -716,20 +768,21 @@ bool ConditionalFormatting::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
if (it != rule->attrs.constEnd())
|
if (it != rule->attrs.constEnd())
|
||||||
it.value().value<XlsxColor>().saveToXml(writer);
|
it.value().value<XlsxColor>().saveToXml(writer);
|
||||||
|
|
||||||
writer.writeEndElement();//colorScale
|
writer.writeEndElement(); // colorScale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
it = rule->attrs.constFind(XlsxCfRuleData::A_formula1_temp);
|
it = rule->attrs.constFind(XlsxCfRuleData::A_formula1_temp);
|
||||||
if (it != rule->attrs.constEnd()) {
|
if (it != rule->attrs.constEnd()) {
|
||||||
const auto _ranges = ranges();
|
const auto _ranges = ranges();
|
||||||
const auto begin = _ranges.begin();
|
const auto begin = _ranges.begin();
|
||||||
if (begin != _ranges.end()) {
|
if (begin != _ranges.end()) {
|
||||||
QString str = begin->toString();
|
QString str = begin->toString();
|
||||||
QString startCell = str.mid(0, str.indexOf(u':'));
|
QString startCell = str.mid(0, str.indexOf(u':'));
|
||||||
writer.writeTextElement(QStringLiteral("formula"), it.value().toString().arg(startCell));
|
writer.writeTextElement(QStringLiteral("formula"),
|
||||||
|
it.value().toString().arg(startCell));
|
||||||
}
|
}
|
||||||
} else if ((it = rule->attrs.constFind(XlsxCfRuleData::A_formula1)) != rule->attrs.constEnd()) {
|
} else if ((it = rule->attrs.constFind(XlsxCfRuleData::A_formula1)) !=
|
||||||
|
rule->attrs.constEnd()) {
|
||||||
writer.writeTextElement(QStringLiteral("formula"), it.value().toString());
|
writer.writeTextElement(QStringLiteral("formula"), it.value().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,10 +794,10 @@ bool ConditionalFormatting::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
if (it != rule->attrs.constEnd())
|
if (it != rule->attrs.constEnd())
|
||||||
writer.writeTextElement(QStringLiteral("formula"), it.value().toString());
|
writer.writeTextElement(QStringLiteral("formula"), it.value().toString());
|
||||||
|
|
||||||
writer.writeEndElement(); //cfRule
|
writer.writeEndElement(); // cfRule
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeEndElement(); //conditionalFormatting
|
writer.writeEndElement(); // conditionalFormatting
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
// xlsxcontenttypes.cpp
|
// xlsxcontenttypes.cpp
|
||||||
|
|
||||||
#include <QXmlStreamWriter>
|
#include "xlsxcontenttypes_p.h"
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QMapIterator>
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
#include "xlsxcontenttypes_p.h"
|
#include <QMapIterator>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
ContentTypes::ContentTypes(CreateFlag flag)
|
ContentTypes::ContentTypes(CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag)
|
: AbstractOOXmlFile(flag)
|
||||||
{
|
{
|
||||||
m_package_prefix = QStringLiteral("application/vnd.openxmlformats-package.");
|
m_package_prefix = QStringLiteral("application/vnd.openxmlformats-package.");
|
||||||
m_document_prefix = QStringLiteral("application/vnd.openxmlformats-officedocument.");
|
m_document_prefix = QStringLiteral("application/vnd.openxmlformats-officedocument.");
|
||||||
|
|
||||||
m_defaults.insert(QStringLiteral("rels"), m_package_prefix + QLatin1String("relationships+xml"));
|
m_defaults.insert(QStringLiteral("rels"),
|
||||||
|
m_package_prefix + QLatin1String("relationships+xml"));
|
||||||
m_defaults.insert(QStringLiteral("xml"), QStringLiteral("application/xml"));
|
m_defaults.insert(QStringLiteral("xml"), QStringLiteral("application/xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,67 +34,80 @@ void ContentTypes::addOverride(const QString &key, const QString &value)
|
|||||||
|
|
||||||
void ContentTypes::addDocPropApp()
|
void ContentTypes::addDocPropApp()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/docProps/app.xml"), m_document_prefix + QLatin1String("extended-properties+xml"));
|
addOverride(QStringLiteral("/docProps/app.xml"),
|
||||||
|
m_document_prefix + QLatin1String("extended-properties+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addDocPropCore()
|
void ContentTypes::addDocPropCore()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/docProps/core.xml"), m_package_prefix + QLatin1String("core-properties+xml"));
|
addOverride(QStringLiteral("/docProps/core.xml"),
|
||||||
|
m_package_prefix + QLatin1String("core-properties+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addStyles()
|
void ContentTypes::addStyles()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/styles.xml"), m_document_prefix + QLatin1String("spreadsheetml.styles+xml"));
|
addOverride(QStringLiteral("/xl/styles.xml"),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.styles+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addTheme()
|
void ContentTypes::addTheme()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/theme/theme1.xml"), m_document_prefix + QLatin1String("theme+xml"));
|
addOverride(QStringLiteral("/xl/theme/theme1.xml"),
|
||||||
|
m_document_prefix + QLatin1String("theme+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addWorkbook()
|
void ContentTypes::addWorkbook()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/workbook.xml"), m_document_prefix + QLatin1String("spreadsheetml.sheet.main+xml"));
|
addOverride(QStringLiteral("/xl/workbook.xml"),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.sheet.main+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addWorksheetName(const QString &name)
|
void ContentTypes::addWorksheetName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/worksheets/%1.xml").arg(name), m_document_prefix + QLatin1String("spreadsheetml.worksheet+xml"));
|
addOverride(QStringLiteral("/xl/worksheets/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.worksheet+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addChartsheetName(const QString &name)
|
void ContentTypes::addChartsheetName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/chartsheets/%1.xml").arg(name), m_document_prefix + QLatin1String("spreadsheetml.chartsheet+xml"));
|
addOverride(QStringLiteral("/xl/chartsheets/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.chartsheet+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addDrawingName(const QString &name)
|
void ContentTypes::addDrawingName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/drawings/%1.xml").arg(name), m_document_prefix + QLatin1String("drawing+xml"));
|
addOverride(QStringLiteral("/xl/drawings/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("drawing+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addChartName(const QString &name)
|
void ContentTypes::addChartName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/charts/%1.xml").arg(name), m_document_prefix + QLatin1String("drawingml.chart+xml"));
|
addOverride(QStringLiteral("/xl/charts/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("drawingml.chart+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addCommentName(const QString &name)
|
void ContentTypes::addCommentName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/%1.xml").arg(name), m_document_prefix + QLatin1String("spreadsheetml.comments+xml"));
|
addOverride(QStringLiteral("/xl/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.comments+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addTableName(const QString &name)
|
void ContentTypes::addTableName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/tables/%1.xml").arg(name), m_document_prefix + QLatin1String("spreadsheetml.table+xml"));
|
addOverride(QStringLiteral("/xl/tables/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.table+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addExternalLinkName(const QString &name)
|
void ContentTypes::addExternalLinkName(const QString &name)
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/externalLinks/%1.xml").arg(name), m_document_prefix + QLatin1String("spreadsheetml.externalLink+xml"));
|
addOverride(QStringLiteral("/xl/externalLinks/%1.xml").arg(name),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.externalLink+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addSharedString()
|
void ContentTypes::addSharedString()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/sharedStrings.xml"), m_document_prefix + QLatin1String("spreadsheetml.sharedStrings+xml"));
|
addOverride(QStringLiteral("/xl/sharedStrings.xml"),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.sharedStrings+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addVmlName()
|
void ContentTypes::addVmlName()
|
||||||
@ -103,12 +117,13 @@ void ContentTypes::addVmlName()
|
|||||||
|
|
||||||
void ContentTypes::addCalcChain()
|
void ContentTypes::addCalcChain()
|
||||||
{
|
{
|
||||||
addOverride(QStringLiteral("/xl/calcChain.xml"), m_document_prefix + QLatin1String("spreadsheetml.calcChain+xml"));
|
addOverride(QStringLiteral("/xl/calcChain.xml"),
|
||||||
|
m_document_prefix + QLatin1String("spreadsheetml.calcChain+xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentTypes::addVbaProject()
|
void ContentTypes::addVbaProject()
|
||||||
{
|
{
|
||||||
//:TODO
|
//: TODO
|
||||||
addOverride(QStringLiteral("bin"), QStringLiteral("application/vnd.ms-office.vbaProject"));
|
addOverride(QStringLiteral("bin"), QStringLiteral("application/vnd.ms-office.vbaProject"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,33 +138,34 @@ void ContentTypes::saveToXmlFile(QIODevice *device) const
|
|||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("Types"));
|
writer.writeStartElement(QStringLiteral("Types"));
|
||||||
writer.writeAttribute(QStringLiteral("xmlns"), QStringLiteral("http://schemas.openxmlformats.org/package/2006/content-types"));
|
writer.writeAttribute(
|
||||||
|
QStringLiteral("xmlns"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/package/2006/content-types"));
|
||||||
|
|
||||||
{
|
{
|
||||||
QMapIterator<QString, QString> it(m_defaults);
|
QMapIterator<QString, QString> it(m_defaults);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
writer.writeStartElement(QStringLiteral("Default"));
|
writer.writeStartElement(QStringLiteral("Default"));
|
||||||
writer.writeAttribute(QStringLiteral("Extension"), it.key());
|
writer.writeAttribute(QStringLiteral("Extension"), it.key());
|
||||||
writer.writeAttribute(QStringLiteral("ContentType"), it.value());
|
writer.writeAttribute(QStringLiteral("ContentType"), it.value());
|
||||||
writer.writeEndElement();//Default
|
writer.writeEndElement(); // Default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QMapIterator<QString, QString> it(m_overrides);
|
QMapIterator<QString, QString> it(m_overrides);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
writer.writeStartElement(QStringLiteral("Override"));
|
writer.writeStartElement(QStringLiteral("Override"));
|
||||||
writer.writeAttribute(QStringLiteral("PartName"), it.key());
|
writer.writeAttribute(QStringLiteral("PartName"), it.key());
|
||||||
writer.writeAttribute(QStringLiteral("ContentType"), it.value());
|
writer.writeAttribute(QStringLiteral("ContentType"), it.value());
|
||||||
writer.writeEndElement(); //Override
|
writer.writeEndElement(); // Override
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeEndElement();//Types
|
writer.writeEndElement(); // Types
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentTypes::loadFromXmlFile(QIODevice *device)
|
bool ContentTypes::loadFromXmlFile(QIODevice *device)
|
||||||
@ -163,19 +179,19 @@ bool ContentTypes::loadFromXmlFile(QIODevice *device)
|
|||||||
if (token == QXmlStreamReader::StartElement) {
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("Default")) {
|
if (reader.name() == QLatin1String("Default")) {
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
QString extension = attrs.value(QLatin1String("Extension")).toString();
|
QString extension = attrs.value(QLatin1String("Extension")).toString();
|
||||||
QString type = attrs.value(QLatin1String("ContentType")).toString();
|
QString type = attrs.value(QLatin1String("ContentType")).toString();
|
||||||
m_defaults.insert(extension, type);
|
m_defaults.insert(extension, type);
|
||||||
} else if (reader.name() == QLatin1String("Override")) {
|
} else if (reader.name() == QLatin1String("Override")) {
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
QString partName = attrs.value(QLatin1String("PartName")).toString();
|
QString partName = attrs.value(QLatin1String("PartName")).toString();
|
||||||
QString type = attrs.value(QLatin1String("ContentType")).toString();
|
QString type = attrs.value(QLatin1String("ContentType")).toString();
|
||||||
m_overrides.insert(partName, type);
|
m_overrides.insert(partName, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.hasError()) {
|
if (reader.hasError()) {
|
||||||
qDebug()<<reader.errorString();
|
qDebug() << reader.errorString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,45 +1,55 @@
|
|||||||
// xlsxdatavalidation.cpp
|
// xlsxdatavalidation.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
|
|
||||||
#include "xlsxdatavalidation.h"
|
#include "xlsxdatavalidation.h"
|
||||||
|
|
||||||
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxdatavalidation_p.h"
|
#include "xlsxdatavalidation_p.h"
|
||||||
#include "xlsxworksheet.h"
|
#include "xlsxworksheet.h"
|
||||||
#include "xlsxcellrange.h"
|
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
DataValidationPrivate::DataValidationPrivate()
|
DataValidationPrivate::DataValidationPrivate()
|
||||||
:validationType(DataValidation::None), validationOperator(DataValidation::Between)
|
: validationType(DataValidation::None)
|
||||||
, errorStyle(DataValidation::Stop), allowBlank(false), isPromptMessageVisible(true)
|
, validationOperator(DataValidation::Between)
|
||||||
|
, errorStyle(DataValidation::Stop)
|
||||||
|
, allowBlank(false)
|
||||||
|
, isPromptMessageVisible(true)
|
||||||
, isErrorMessageVisible(true)
|
, isErrorMessageVisible(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataValidationPrivate::DataValidationPrivate(DataValidation::ValidationType type, DataValidation::ValidationOperator op, const QString &formula1, const QString &formula2, bool allowBlank)
|
DataValidationPrivate::DataValidationPrivate(DataValidation::ValidationType type,
|
||||||
:validationType(type), validationOperator(op)
|
DataValidation::ValidationOperator op,
|
||||||
, errorStyle(DataValidation::Stop), allowBlank(allowBlank), isPromptMessageVisible(true)
|
const QString &formula1,
|
||||||
, isErrorMessageVisible(true), formula1(formula1), formula2(formula2)
|
const QString &formula2,
|
||||||
|
bool allowBlank)
|
||||||
|
: validationType(type)
|
||||||
|
, validationOperator(op)
|
||||||
|
, errorStyle(DataValidation::Stop)
|
||||||
|
, allowBlank(allowBlank)
|
||||||
|
, isPromptMessageVisible(true)
|
||||||
|
, isErrorMessageVisible(true)
|
||||||
|
, formula1(formula1)
|
||||||
|
, formula2(formula2)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataValidationPrivate::DataValidationPrivate(const DataValidationPrivate &other)
|
DataValidationPrivate::DataValidationPrivate(const DataValidationPrivate &other)
|
||||||
:QSharedData(other)
|
: QSharedData(other)
|
||||||
, validationType(DataValidation::None), validationOperator(DataValidation::Between)
|
, validationType(DataValidation::None)
|
||||||
, errorStyle(DataValidation::Stop), allowBlank(false), isPromptMessageVisible(true)
|
, validationOperator(DataValidation::Between)
|
||||||
|
, errorStyle(DataValidation::Stop)
|
||||||
|
, allowBlank(false)
|
||||||
|
, isPromptMessageVisible(true)
|
||||||
, isErrorMessageVisible(true)
|
, isErrorMessageVisible(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataValidationPrivate::~DataValidationPrivate()
|
DataValidationPrivate::~DataValidationPrivate() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class DataValidation
|
* \class DataValidation
|
||||||
@ -61,7 +71,8 @@ DataValidationPrivate::~DataValidationPrivate()
|
|||||||
* \value Date restricts the cell to date values.
|
* \value Date restricts the cell to date values.
|
||||||
* \value Time restricts the cell to time values.
|
* \value Time restricts the cell to time values.
|
||||||
* \value TextLength restricts the cell data based on an integer string length.
|
* \value TextLength restricts the cell data based on an integer string length.
|
||||||
* \value Custom restricts the cell based on an external Excel formula that returns a true/false value.
|
* \value Custom restricts the cell based on an external Excel formula that returns a true/false
|
||||||
|
* value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -95,28 +106,29 @@ DataValidationPrivate::~DataValidationPrivate()
|
|||||||
* Construct a data validation object with the given \a type, \a op, \a formula1
|
* Construct a data validation object with the given \a type, \a op, \a formula1
|
||||||
* \a formula2, and \a allowBlank.
|
* \a formula2, and \a allowBlank.
|
||||||
*/
|
*/
|
||||||
DataValidation::DataValidation(ValidationType type, ValidationOperator op, const QString &formula1, const QString &formula2, bool allowBlank)
|
DataValidation::DataValidation(ValidationType type,
|
||||||
:d(new DataValidationPrivate(type, op, formula1, formula2, allowBlank))
|
ValidationOperator op,
|
||||||
|
const QString &formula1,
|
||||||
|
const QString &formula2,
|
||||||
|
bool allowBlank)
|
||||||
|
: d(new DataValidationPrivate(type, op, formula1, formula2, allowBlank))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Construct a data validation object
|
Construct a data validation object
|
||||||
*/
|
*/
|
||||||
DataValidation::DataValidation()
|
DataValidation::DataValidation()
|
||||||
:d(new DataValidationPrivate())
|
: d(new DataValidationPrivate())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a copy of \a other.
|
Constructs a copy of \a other.
|
||||||
*/
|
*/
|
||||||
DataValidation::DataValidation(const DataValidation &other)
|
DataValidation::DataValidation(const DataValidation &other)
|
||||||
:d(other.d)
|
: d(other.d)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -128,13 +140,10 @@ DataValidation &DataValidation::operator=(const DataValidation &other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroy the object.
|
* Destroy the object.
|
||||||
*/
|
*/
|
||||||
DataValidation::~DataValidation()
|
DataValidation::~DataValidation() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the validation type.
|
Returns the validation type.
|
||||||
@ -291,7 +300,7 @@ void DataValidation::setFormula2(const QString &formula)
|
|||||||
*/
|
*/
|
||||||
void DataValidation::setErrorMessage(const QString &error, const QString &title)
|
void DataValidation::setErrorMessage(const QString &error, const QString &title)
|
||||||
{
|
{
|
||||||
d->errorMessage = error;
|
d->errorMessage = error;
|
||||||
d->errorMessageTitle = title;
|
d->errorMessageTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +309,7 @@ void DataValidation::setErrorMessage(const QString &error, const QString &title)
|
|||||||
*/
|
*/
|
||||||
void DataValidation::setPromptMessage(const QString &prompt, const QString &title)
|
void DataValidation::setPromptMessage(const QString &prompt, const QString &title)
|
||||||
{
|
{
|
||||||
d->promptMessage = prompt;
|
d->promptMessage = prompt;
|
||||||
d->promptMessageTitle = title;
|
d->promptMessageTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,8 +385,7 @@ bool DataValidation::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
{DataValidation::Date, QStringLiteral("date")},
|
{DataValidation::Date, QStringLiteral("date")},
|
||||||
{DataValidation::Time, QStringLiteral("time")},
|
{DataValidation::Time, QStringLiteral("time")},
|
||||||
{DataValidation::TextLength, QStringLiteral("textLength")},
|
{DataValidation::TextLength, QStringLiteral("textLength")},
|
||||||
{DataValidation::Custom, QStringLiteral("custom")}
|
{DataValidation::Custom, QStringLiteral("custom")}};
|
||||||
};
|
|
||||||
|
|
||||||
static const QMap<DataValidation::ValidationOperator, QString> opMap = {
|
static const QMap<DataValidation::ValidationOperator, QString> opMap = {
|
||||||
{DataValidation::Between, QStringLiteral("between")},
|
{DataValidation::Between, QStringLiteral("between")},
|
||||||
@ -387,14 +395,12 @@ bool DataValidation::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
{DataValidation::LessThan, QStringLiteral("lessThan")},
|
{DataValidation::LessThan, QStringLiteral("lessThan")},
|
||||||
{DataValidation::LessThanOrEqual, QStringLiteral("lessThanOrEqual")},
|
{DataValidation::LessThanOrEqual, QStringLiteral("lessThanOrEqual")},
|
||||||
{DataValidation::GreaterThan, QStringLiteral("greaterThan")},
|
{DataValidation::GreaterThan, QStringLiteral("greaterThan")},
|
||||||
{DataValidation::GreaterThanOrEqual, QStringLiteral("greaterThanOrEqual")}
|
{DataValidation::GreaterThanOrEqual, QStringLiteral("greaterThanOrEqual")}};
|
||||||
};
|
|
||||||
|
|
||||||
static const QMap<DataValidation::ErrorStyle, QString> esMap = {
|
static const QMap<DataValidation::ErrorStyle, QString> esMap = {
|
||||||
{DataValidation::Stop, QStringLiteral("stop")},
|
{DataValidation::Stop, QStringLiteral("stop")},
|
||||||
{DataValidation::Warning, QStringLiteral("warning")},
|
{DataValidation::Warning, QStringLiteral("warning")},
|
||||||
{DataValidation::Information, QStringLiteral("information")}
|
{DataValidation::Information, QStringLiteral("information")}};
|
||||||
};
|
|
||||||
|
|
||||||
writer.writeStartElement(QStringLiteral("dataValidation"));
|
writer.writeStartElement(QStringLiteral("dataValidation"));
|
||||||
if (validationType() != DataValidation::None)
|
if (validationType() != DataValidation::None)
|
||||||
@ -431,7 +437,7 @@ bool DataValidation::saveToXml(QXmlStreamWriter &writer) const
|
|||||||
if (!formula2().isEmpty())
|
if (!formula2().isEmpty())
|
||||||
writer.writeTextElement(QStringLiteral("formula2"), formula2());
|
writer.writeTextElement(QStringLiteral("formula2"), formula2());
|
||||||
|
|
||||||
writer.writeEndElement(); //dataValidation
|
writer.writeEndElement(); // dataValidation
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -451,8 +457,7 @@ DataValidation DataValidation::loadFromXml(QXmlStreamReader &reader)
|
|||||||
{QStringLiteral("date"), DataValidation::Date},
|
{QStringLiteral("date"), DataValidation::Date},
|
||||||
{QStringLiteral("time"), DataValidation::Time},
|
{QStringLiteral("time"), DataValidation::Time},
|
||||||
{QStringLiteral("textLength"), DataValidation::TextLength},
|
{QStringLiteral("textLength"), DataValidation::TextLength},
|
||||||
{QStringLiteral("custom"), DataValidation::Custom}
|
{QStringLiteral("custom"), DataValidation::Custom}};
|
||||||
};
|
|
||||||
|
|
||||||
static const QMap<QString, DataValidation::ValidationOperator> opMap = {
|
static const QMap<QString, DataValidation::ValidationOperator> opMap = {
|
||||||
{QStringLiteral("between"), DataValidation::Between},
|
{QStringLiteral("between"), DataValidation::Between},
|
||||||
@ -462,37 +467,36 @@ DataValidation DataValidation::loadFromXml(QXmlStreamReader &reader)
|
|||||||
{QStringLiteral("lessThan"), DataValidation::LessThan},
|
{QStringLiteral("lessThan"), DataValidation::LessThan},
|
||||||
{QStringLiteral("lessThanOrEqual"), DataValidation::LessThanOrEqual},
|
{QStringLiteral("lessThanOrEqual"), DataValidation::LessThanOrEqual},
|
||||||
{QStringLiteral("greaterThan"), DataValidation::GreaterThan},
|
{QStringLiteral("greaterThan"), DataValidation::GreaterThan},
|
||||||
{QStringLiteral("greaterThanOrEqual"), DataValidation::GreaterThanOrEqual}
|
{QStringLiteral("greaterThanOrEqual"), DataValidation::GreaterThanOrEqual}};
|
||||||
};
|
|
||||||
|
|
||||||
static const QMap<QString, DataValidation::ErrorStyle> esMap = {
|
static const QMap<QString, DataValidation::ErrorStyle> esMap = {
|
||||||
{QStringLiteral("stop"), DataValidation::Stop},
|
{QStringLiteral("stop"), DataValidation::Stop},
|
||||||
{QStringLiteral("warning"), DataValidation::Warning},
|
{QStringLiteral("warning"), DataValidation::Warning},
|
||||||
{QStringLiteral("information"), DataValidation::Information}
|
{QStringLiteral("information"), DataValidation::Information}};
|
||||||
};
|
|
||||||
|
|
||||||
DataValidation validation;
|
DataValidation validation;
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
|
|
||||||
QString sqref = attrs.value(QLatin1String("sqref")).toString();
|
QString sqref = attrs.value(QLatin1String("sqref")).toString();
|
||||||
const auto sqrefParts = sqref.split(QLatin1Char(' '));
|
const auto sqrefParts = sqref.split(QLatin1Char(' '));
|
||||||
for (const QString &range : sqrefParts)
|
for (const QString &range : sqrefParts)
|
||||||
validation.addRange(range);
|
validation.addRange(range);
|
||||||
|
|
||||||
if (attrs.hasAttribute(QLatin1String("type"))) {
|
if (attrs.hasAttribute(QLatin1String("type"))) {
|
||||||
QString t = attrs.value(QLatin1String("type")).toString();
|
QString t = attrs.value(QLatin1String("type")).toString();
|
||||||
auto it = typeMap.constFind(t);
|
auto it = typeMap.constFind(t);
|
||||||
validation.setValidationType(it != typeMap.constEnd() ? it.value() : DataValidation::None);
|
validation.setValidationType(it != typeMap.constEnd() ? it.value() : DataValidation::None);
|
||||||
}
|
}
|
||||||
if (attrs.hasAttribute(QLatin1String("errorStyle"))) {
|
if (attrs.hasAttribute(QLatin1String("errorStyle"))) {
|
||||||
QString es = attrs.value(QLatin1String("errorStyle")).toString();
|
QString es = attrs.value(QLatin1String("errorStyle")).toString();
|
||||||
auto it = esMap.constFind(es);
|
auto it = esMap.constFind(es);
|
||||||
validation.setErrorStyle(it != esMap.constEnd() ? it.value() : DataValidation::Stop);
|
validation.setErrorStyle(it != esMap.constEnd() ? it.value() : DataValidation::Stop);
|
||||||
}
|
}
|
||||||
if (attrs.hasAttribute(QLatin1String("operator"))) {
|
if (attrs.hasAttribute(QLatin1String("operator"))) {
|
||||||
QString op = attrs.value(QLatin1String("operator")).toString();
|
QString op = attrs.value(QLatin1String("operator")).toString();
|
||||||
auto it = opMap.constFind(op);
|
auto it = opMap.constFind(op);
|
||||||
validation.setValidationOperator(it != opMap.constEnd() ? it.value() : DataValidation::Between);
|
validation.setValidationOperator(it != opMap.constEnd() ? it.value()
|
||||||
|
: DataValidation::Between);
|
||||||
}
|
}
|
||||||
if (attrs.hasAttribute(QLatin1String("allowBlank"))) {
|
if (attrs.hasAttribute(QLatin1String("allowBlank"))) {
|
||||||
validation.setAllowBlank(true);
|
validation.setAllowBlank(true);
|
||||||
@ -511,17 +515,18 @@ DataValidation DataValidation::loadFromXml(QXmlStreamReader &reader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString et = attrs.value(QLatin1String("errorTitle")).toString();
|
QString et = attrs.value(QLatin1String("errorTitle")).toString();
|
||||||
QString e = attrs.value(QLatin1String("error")).toString();
|
QString e = attrs.value(QLatin1String("error")).toString();
|
||||||
if (!e.isEmpty() || !et.isEmpty())
|
if (!e.isEmpty() || !et.isEmpty())
|
||||||
validation.setErrorMessage(e, et);
|
validation.setErrorMessage(e, et);
|
||||||
|
|
||||||
QString pt = attrs.value(QLatin1String("promptTitle")).toString();
|
QString pt = attrs.value(QLatin1String("promptTitle")).toString();
|
||||||
QString p = attrs.value(QLatin1String("prompt")).toString();
|
QString p = attrs.value(QLatin1String("prompt")).toString();
|
||||||
if (!p.isEmpty() || !pt.isEmpty())
|
if (!p.isEmpty() || !pt.isEmpty())
|
||||||
validation.setPromptMessage(p, pt);
|
validation.setPromptMessage(p, pt);
|
||||||
|
|
||||||
//find the end
|
// find the end
|
||||||
while(!(reader.name() == QLatin1String("dataValidation") && reader.tokenType() == QXmlStreamReader::EndElement)) {
|
while (!(reader.name() == QLatin1String("dataValidation") &&
|
||||||
|
reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("formula1")) {
|
if (reader.name() == QLatin1String("formula1")) {
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
// xlsxdatetype.cpp
|
// xlsxdatetype.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxdatetype.h"
|
||||||
|
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
#include "xlsxutility_p.h"
|
#include "xlsxutility_p.h"
|
||||||
#include "xlsxdatetype.h"
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
DateType::DateType()
|
DateType::DateType() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DateType::DateType(bool is1904)
|
DateType::DateType(bool is1904)
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
#include "xlsxdocpropsapp_p.h"
|
#include "xlsxdocpropsapp_p.h"
|
||||||
|
|
||||||
#include <QXmlStreamWriter>
|
#include <QBuffer>
|
||||||
#include <QXmlStreamReader>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDateTime>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QBuffer>
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
DocPropsApp::DocPropsApp(CreateFlag flag)
|
DocPropsApp::DocPropsApp(CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag)
|
: AbstractOOXmlFile(flag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,14 +24,12 @@ void DocPropsApp::addPartTitle(const QString &title)
|
|||||||
|
|
||||||
void DocPropsApp::addHeadingPair(const QString &name, int value)
|
void DocPropsApp::addHeadingPair(const QString &name, int value)
|
||||||
{
|
{
|
||||||
m_headingPairsList.append({ name, value });
|
m_headingPairsList.append({name, value});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocPropsApp::setProperty(const QString &name, const QString &value)
|
bool DocPropsApp::setProperty(const QString &name, const QString &value)
|
||||||
{
|
{
|
||||||
static const QStringList validKeys = {
|
static const QStringList validKeys = {QStringLiteral("manager"), QStringLiteral("company")};
|
||||||
QStringLiteral("manager"), QStringLiteral("company")
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!validKeys.contains(name))
|
if (!validKeys.contains(name))
|
||||||
return false;
|
return false;
|
||||||
@ -61,11 +59,13 @@ QStringList DocPropsApp::propertyNames() const
|
|||||||
void DocPropsApp::saveToXmlFile(QIODevice *device) const
|
void DocPropsApp::saveToXmlFile(QIODevice *device) const
|
||||||
{
|
{
|
||||||
QXmlStreamWriter writer(device);
|
QXmlStreamWriter writer(device);
|
||||||
QString vt = QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
QString vt =
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("Properties"));
|
writer.writeStartElement(QStringLiteral("Properties"));
|
||||||
writer.writeDefaultNamespace(QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"));
|
writer.writeDefaultNamespace(QStringLiteral(
|
||||||
|
"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"));
|
||||||
writer.writeNamespace(vt, QStringLiteral("vt"));
|
writer.writeNamespace(vt, QStringLiteral("vt"));
|
||||||
writer.writeTextElement(QStringLiteral("Application"), QStringLiteral("Microsoft Excel"));
|
writer.writeTextElement(QStringLiteral("Application"), QStringLiteral("Microsoft Excel"));
|
||||||
writer.writeTextElement(QStringLiteral("DocSecurity"), QStringLiteral("0"));
|
writer.writeTextElement(QStringLiteral("DocSecurity"), QStringLiteral("0"));
|
||||||
@ -73,19 +73,19 @@ void DocPropsApp::saveToXmlFile(QIODevice *device) const
|
|||||||
|
|
||||||
writer.writeStartElement(QStringLiteral("HeadingPairs"));
|
writer.writeStartElement(QStringLiteral("HeadingPairs"));
|
||||||
writer.writeStartElement(vt, QStringLiteral("vector"));
|
writer.writeStartElement(vt, QStringLiteral("vector"));
|
||||||
writer.writeAttribute(QStringLiteral("size"), QString::number(m_headingPairsList.size()*2));
|
writer.writeAttribute(QStringLiteral("size"), QString::number(m_headingPairsList.size() * 2));
|
||||||
writer.writeAttribute(QStringLiteral("baseType"), QStringLiteral("variant"));
|
writer.writeAttribute(QStringLiteral("baseType"), QStringLiteral("variant"));
|
||||||
|
|
||||||
for (const auto &pair : m_headingPairsList) {
|
for (const auto &pair : m_headingPairsList) {
|
||||||
writer.writeStartElement(vt, QStringLiteral("variant"));
|
writer.writeStartElement(vt, QStringLiteral("variant"));
|
||||||
writer.writeTextElement(vt, QStringLiteral("lpstr"), pair.first);
|
writer.writeTextElement(vt, QStringLiteral("lpstr"), pair.first);
|
||||||
writer.writeEndElement(); //vt:variant
|
writer.writeEndElement(); // vt:variant
|
||||||
writer.writeStartElement(vt, QStringLiteral("variant"));
|
writer.writeStartElement(vt, QStringLiteral("variant"));
|
||||||
writer.writeTextElement(vt, QStringLiteral("i4"), QString::number(pair.second));
|
writer.writeTextElement(vt, QStringLiteral("i4"), QString::number(pair.second));
|
||||||
writer.writeEndElement(); //vt:variant
|
writer.writeEndElement(); // vt:variant
|
||||||
}
|
}
|
||||||
writer.writeEndElement();//vt:vector
|
writer.writeEndElement(); // vt:vector
|
||||||
writer.writeEndElement();//HeadingPairs
|
writer.writeEndElement(); // HeadingPairs
|
||||||
|
|
||||||
writer.writeStartElement(QStringLiteral("TitlesOfParts"));
|
writer.writeStartElement(QStringLiteral("TitlesOfParts"));
|
||||||
writer.writeStartElement(vt, QStringLiteral("vector"));
|
writer.writeStartElement(vt, QStringLiteral("vector"));
|
||||||
@ -93,22 +93,23 @@ void DocPropsApp::saveToXmlFile(QIODevice *device) const
|
|||||||
writer.writeAttribute(QStringLiteral("baseType"), QStringLiteral("lpstr"));
|
writer.writeAttribute(QStringLiteral("baseType"), QStringLiteral("lpstr"));
|
||||||
for (const QString &title : m_titlesOfPartsList)
|
for (const QString &title : m_titlesOfPartsList)
|
||||||
writer.writeTextElement(vt, QStringLiteral("lpstr"), title);
|
writer.writeTextElement(vt, QStringLiteral("lpstr"), title);
|
||||||
writer.writeEndElement();//vt:vector
|
writer.writeEndElement(); // vt:vector
|
||||||
writer.writeEndElement();//TitlesOfParts
|
writer.writeEndElement(); // TitlesOfParts
|
||||||
|
|
||||||
auto it = m_properties.constFind(QStringLiteral("manager"));
|
auto it = m_properties.constFind(QStringLiteral("manager"));
|
||||||
if (it != m_properties.constEnd())
|
if (it != m_properties.constEnd())
|
||||||
writer.writeTextElement(QStringLiteral("Manager"), it.value());
|
writer.writeTextElement(QStringLiteral("Manager"), it.value());
|
||||||
//Not like "manager", "company" always exists for Excel generated file.
|
// Not like "manager", "company" always exists for Excel generated file.
|
||||||
|
|
||||||
it = m_properties.constFind(QStringLiteral("company"));
|
it = m_properties.constFind(QStringLiteral("company"));
|
||||||
writer.writeTextElement(QStringLiteral("Company"), it != m_properties.constEnd() ? it.value() : QString());
|
writer.writeTextElement(QStringLiteral("Company"),
|
||||||
|
it != m_properties.constEnd() ? it.value() : QString());
|
||||||
writer.writeTextElement(QStringLiteral("LinksUpToDate"), QStringLiteral("false"));
|
writer.writeTextElement(QStringLiteral("LinksUpToDate"), QStringLiteral("false"));
|
||||||
writer.writeTextElement(QStringLiteral("SharedDoc"), QStringLiteral("false"));
|
writer.writeTextElement(QStringLiteral("SharedDoc"), QStringLiteral("false"));
|
||||||
writer.writeTextElement(QStringLiteral("HyperlinksChanged"), QStringLiteral("false"));
|
writer.writeTextElement(QStringLiteral("HyperlinksChanged"), QStringLiteral("false"));
|
||||||
writer.writeTextElement(QStringLiteral("AppVersion"), QStringLiteral("12.0000"));
|
writer.writeTextElement(QStringLiteral("AppVersion"), QStringLiteral("12.0000"));
|
||||||
|
|
||||||
writer.writeEndElement(); //Properties
|
writer.writeEndElement(); // Properties
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,21 +117,21 @@ bool DocPropsApp::loadFromXmlFile(QIODevice *device)
|
|||||||
{
|
{
|
||||||
QXmlStreamReader reader(device);
|
QXmlStreamReader reader(device);
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
if (token == QXmlStreamReader::StartElement) {
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("Properties"))
|
if (reader.name() == QLatin1String("Properties"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (reader.name() == QStringLiteral("Manager")) {
|
if (reader.name() == QStringLiteral("Manager")) {
|
||||||
setProperty(QStringLiteral("manager"), reader.readElementText());
|
setProperty(QStringLiteral("manager"), reader.readElementText());
|
||||||
} else if (reader.name() == QStringLiteral("Company")) {
|
} else if (reader.name() == QStringLiteral("Company")) {
|
||||||
setProperty(QStringLiteral("company"), reader.readElementText());
|
setProperty(QStringLiteral("company"), reader.readElementText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.hasError()) {
|
if (reader.hasError()) {
|
||||||
qDebug("Error when read doc props app file.");
|
qDebug("Error when read doc props app file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,33 @@
|
|||||||
// xlsxdocpropscore.cpp
|
// xlsxdocpropscore.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxdocpropscore_p.h"
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
#include <QBuffer>
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QBuffer>
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
#include "xlsxdocpropscore_p.h"
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
DocPropsCore::DocPropsCore(CreateFlag flag)
|
DocPropsCore::DocPropsCore(CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag)
|
: AbstractOOXmlFile(flag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocPropsCore::setProperty(const QString &name, const QString &value)
|
bool DocPropsCore::setProperty(const QString &name, const QString &value)
|
||||||
{
|
{
|
||||||
static const QStringList validKeys = {
|
static const QStringList validKeys = {QStringLiteral("title"),
|
||||||
QStringLiteral("title"), QStringLiteral("subject"),
|
QStringLiteral("subject"),
|
||||||
QStringLiteral("keywords"), QStringLiteral("description"),
|
QStringLiteral("keywords"),
|
||||||
QStringLiteral("category"), QStringLiteral("status"),
|
QStringLiteral("description"),
|
||||||
QStringLiteral("created"), QStringLiteral("creator")
|
QStringLiteral("category"),
|
||||||
};
|
QStringLiteral("status"),
|
||||||
|
QStringLiteral("created"),
|
||||||
|
QStringLiteral("creator")};
|
||||||
|
|
||||||
if (!validKeys.contains(name))
|
if (!validKeys.contains(name))
|
||||||
return false;
|
return false;
|
||||||
@ -55,11 +57,12 @@ QStringList DocPropsCore::propertyNames() const
|
|||||||
void DocPropsCore::saveToXmlFile(QIODevice *device) const
|
void DocPropsCore::saveToXmlFile(QIODevice *device) const
|
||||||
{
|
{
|
||||||
QXmlStreamWriter writer(device);
|
QXmlStreamWriter writer(device);
|
||||||
const QString cp = QStringLiteral("http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
const QString cp =
|
||||||
const QString dc = QStringLiteral("http://purl.org/dc/elements/1.1/");
|
QStringLiteral("http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
||||||
const QString dcterms = QStringLiteral("http://purl.org/dc/terms/");
|
const QString dc = QStringLiteral("http://purl.org/dc/elements/1.1/");
|
||||||
|
const QString dcterms = QStringLiteral("http://purl.org/dc/terms/");
|
||||||
const QString dcmitype = QStringLiteral("http://purl.org/dc/dcmitype/");
|
const QString dcmitype = QStringLiteral("http://purl.org/dc/dcmitype/");
|
||||||
const QString xsi = QStringLiteral("http://www.w3.org/2001/XMLSchema-instance");
|
const QString xsi = QStringLiteral("http://www.w3.org/2001/XMLSchema-instance");
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("cp:coreProperties"));
|
writer.writeStartElement(QStringLiteral("cp:coreProperties"));
|
||||||
writer.writeNamespace(cp, QStringLiteral("cp"));
|
writer.writeNamespace(cp, QStringLiteral("cp"));
|
||||||
@ -77,7 +80,10 @@ void DocPropsCore::saveToXmlFile(QIODevice *device) const
|
|||||||
writer.writeTextElement(dc, QStringLiteral("subject"), it.value());
|
writer.writeTextElement(dc, QStringLiteral("subject"), it.value());
|
||||||
|
|
||||||
it = m_properties.constFind(QStringLiteral("creator"));
|
it = m_properties.constFind(QStringLiteral("creator"));
|
||||||
writer.writeTextElement(dc, QStringLiteral("creator"), it != m_properties.constEnd() ? it.value() : QStringLiteral("Qt Xlsx Library"));
|
writer.writeTextElement(dc,
|
||||||
|
QStringLiteral("creator"),
|
||||||
|
it != m_properties.constEnd() ? it.value()
|
||||||
|
: QStringLiteral("Qt Xlsx Library"));
|
||||||
|
|
||||||
it = m_properties.constFind(QStringLiteral("keywords"));
|
it = m_properties.constFind(QStringLiteral("keywords"));
|
||||||
if (it != m_properties.constEnd())
|
if (it != m_properties.constEnd())
|
||||||
@ -88,18 +94,23 @@ void DocPropsCore::saveToXmlFile(QIODevice *device) const
|
|||||||
writer.writeTextElement(dc, QStringLiteral("description"), it.value());
|
writer.writeTextElement(dc, QStringLiteral("description"), it.value());
|
||||||
|
|
||||||
it = m_properties.constFind(QStringLiteral("creator"));
|
it = m_properties.constFind(QStringLiteral("creator"));
|
||||||
writer.writeTextElement(cp, QStringLiteral("lastModifiedBy"), it != m_properties.constEnd() ? it.value() : QStringLiteral("Qt Xlsx Library"));
|
writer.writeTextElement(cp,
|
||||||
|
QStringLiteral("lastModifiedBy"),
|
||||||
|
it != m_properties.constEnd() ? it.value()
|
||||||
|
: QStringLiteral("Qt Xlsx Library"));
|
||||||
|
|
||||||
writer.writeStartElement(dcterms, QStringLiteral("created"));
|
writer.writeStartElement(dcterms, QStringLiteral("created"));
|
||||||
writer.writeAttribute(xsi, QStringLiteral("type"), QStringLiteral("dcterms:W3CDTF"));
|
writer.writeAttribute(xsi, QStringLiteral("type"), QStringLiteral("dcterms:W3CDTF"));
|
||||||
it = m_properties.constFind(QStringLiteral("created"));
|
it = m_properties.constFind(QStringLiteral("created"));
|
||||||
writer.writeCharacters(it != m_properties.constEnd() ? it.value() : QDateTime::currentDateTime().toString(Qt::ISODate));
|
writer.writeCharacters(it != m_properties.constEnd()
|
||||||
writer.writeEndElement();//dcterms:created
|
? it.value()
|
||||||
|
: QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||||
|
writer.writeEndElement(); // dcterms:created
|
||||||
|
|
||||||
writer.writeStartElement(dcterms, QStringLiteral("modified"));
|
writer.writeStartElement(dcterms, QStringLiteral("modified"));
|
||||||
writer.writeAttribute(xsi, QStringLiteral("type"), QStringLiteral("dcterms:W3CDTF"));
|
writer.writeAttribute(xsi, QStringLiteral("type"), QStringLiteral("dcterms:W3CDTF"));
|
||||||
writer.writeCharacters(QDateTime::currentDateTime().toString(Qt::ISODate));
|
writer.writeCharacters(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||||
writer.writeEndElement();//dcterms:created
|
writer.writeEndElement(); // dcterms:created
|
||||||
|
|
||||||
it = m_properties.constFind(QStringLiteral("category"));
|
it = m_properties.constFind(QStringLiteral("category"));
|
||||||
if (it != m_properties.constEnd())
|
if (it != m_properties.constEnd())
|
||||||
@ -109,7 +120,7 @@ void DocPropsCore::saveToXmlFile(QIODevice *device) const
|
|||||||
if (it != m_properties.constEnd())
|
if (it != m_properties.constEnd())
|
||||||
writer.writeTextElement(cp, QStringLiteral("contentStatus"), it.value());
|
writer.writeTextElement(cp, QStringLiteral("contentStatus"), it.value());
|
||||||
|
|
||||||
writer.writeEndElement(); //cp:coreProperties
|
writer.writeEndElement(); // cp:coreProperties
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,58 +128,41 @@ bool DocPropsCore::loadFromXmlFile(QIODevice *device)
|
|||||||
{
|
{
|
||||||
QXmlStreamReader reader(device);
|
QXmlStreamReader reader(device);
|
||||||
|
|
||||||
const QString cp = QStringLiteral("http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
const QString cp =
|
||||||
const QString dc = QStringLiteral("http://purl.org/dc/elements/1.1/");
|
QStringLiteral("http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
||||||
|
const QString dc = QStringLiteral("http://purl.org/dc/elements/1.1/");
|
||||||
const QString dcterms = QStringLiteral("http://purl.org/dc/terms/");
|
const QString dcterms = QStringLiteral("http://purl.org/dc/terms/");
|
||||||
|
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd()) {
|
||||||
{
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
|
||||||
|
|
||||||
if (token == QXmlStreamReader::StartElement)
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
{
|
|
||||||
|
|
||||||
const auto& nsUri = reader.namespaceUri();
|
const auto &nsUri = reader.namespaceUri();
|
||||||
const auto& name = reader.name();
|
const auto &name = reader.name();
|
||||||
|
|
||||||
if (name == QStringLiteral("subject") && nsUri == dc)
|
if (name == QStringLiteral("subject") && nsUri == dc) {
|
||||||
{
|
setProperty(QStringLiteral("subject"), reader.readElementText());
|
||||||
setProperty(QStringLiteral("subject"), reader.readElementText());
|
} else if (name == QStringLiteral("title") && nsUri == dc) {
|
||||||
}
|
setProperty(QStringLiteral("title"), reader.readElementText());
|
||||||
else if (name == QStringLiteral("title") && nsUri == dc)
|
} else if (name == QStringLiteral("creator") && nsUri == dc) {
|
||||||
{
|
setProperty(QStringLiteral("creator"), reader.readElementText());
|
||||||
setProperty(QStringLiteral("title"), reader.readElementText());
|
} else if (name == QStringLiteral("description") && nsUri == dc) {
|
||||||
}
|
setProperty(QStringLiteral("description"), reader.readElementText());
|
||||||
else if (name == QStringLiteral("creator") && nsUri == dc)
|
} else if (name == QStringLiteral("keywords") && nsUri == cp) {
|
||||||
{
|
setProperty(QStringLiteral("keywords"), reader.readElementText());
|
||||||
setProperty(QStringLiteral("creator"), reader.readElementText());
|
} else if (name == QStringLiteral("created") && nsUri == dcterms) {
|
||||||
}
|
setProperty(QStringLiteral("created"), reader.readElementText());
|
||||||
else if (name == QStringLiteral("description") && nsUri == dc)
|
} else if (name == QStringLiteral("category") && nsUri == cp) {
|
||||||
{
|
setProperty(QStringLiteral("category"), reader.readElementText());
|
||||||
setProperty(QStringLiteral("description"), reader.readElementText());
|
} else if (name == QStringLiteral("contentStatus") && nsUri == cp) {
|
||||||
}
|
setProperty(QStringLiteral("status"), reader.readElementText());
|
||||||
else if (name == QStringLiteral("keywords") && nsUri == cp)
|
}
|
||||||
{
|
}
|
||||||
setProperty(QStringLiteral("keywords"), reader.readElementText());
|
|
||||||
}
|
|
||||||
else if (name == QStringLiteral("created") && nsUri == dcterms)
|
|
||||||
{
|
|
||||||
setProperty(QStringLiteral("created"), reader.readElementText());
|
|
||||||
}
|
|
||||||
else if (name == QStringLiteral("category") && nsUri == cp)
|
|
||||||
{
|
|
||||||
setProperty(QStringLiteral("category"), reader.readElementText());
|
|
||||||
}
|
|
||||||
else if (name == QStringLiteral("contentStatus") && nsUri == cp)
|
|
||||||
{
|
|
||||||
setProperty(QStringLiteral("status"), reader.readElementText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reader.hasError())
|
if (reader.hasError()) {
|
||||||
{
|
qDebug() << "Error when read doc props core file." << reader.errorString();
|
||||||
qDebug() << "Error when read doc props core file." << reader.errorString();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,19 @@
|
|||||||
// xlsxdrawing.cpp
|
// xlsxdrawing.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxabstractsheet.h"
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QBuffer>
|
|
||||||
|
|
||||||
#include "xlsxdrawing_p.h"
|
#include "xlsxdrawing_p.h"
|
||||||
#include "xlsxdrawinganchor_p.h"
|
#include "xlsxdrawinganchor_p.h"
|
||||||
#include "xlsxabstractsheet.h"
|
|
||||||
|
#include <QBuffer>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
Drawing::Drawing(AbstractSheet *sheet, CreateFlag flag)
|
Drawing::Drawing(AbstractSheet *sheet, CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag), sheet(sheet)
|
: AbstractOOXmlFile(flag)
|
||||||
|
, sheet(sheet)
|
||||||
{
|
{
|
||||||
workbook = sheet->workbook();
|
workbook = sheet->workbook();
|
||||||
}
|
}
|
||||||
@ -30,13 +31,16 @@ void Drawing::saveToXmlFile(QIODevice *device) const
|
|||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("xdr:wsDr"));
|
writer.writeStartElement(QStringLiteral("xdr:wsDr"));
|
||||||
writer.writeAttribute(QStringLiteral("xmlns:xdr"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"));
|
writer.writeAttribute(
|
||||||
writer.writeAttribute(QStringLiteral("xmlns:a"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/main"));
|
QStringLiteral("xmlns:xdr"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"));
|
||||||
|
writer.writeAttribute(QStringLiteral("xmlns:a"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/main"));
|
||||||
|
|
||||||
for (DrawingAnchor *anchor : anchors)
|
for (DrawingAnchor *anchor : anchors)
|
||||||
anchor->saveToXml(writer);
|
anchor->saveToXml(writer);
|
||||||
|
|
||||||
writer.writeEndElement();//xdr:wsDr
|
writer.writeEndElement(); // xdr:wsDr
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,24 +59,20 @@ bool Drawing::loadFromXmlFile(QIODevice *device)
|
|||||||
|
|
||||||
QXmlStreamReader reader(device);
|
QXmlStreamReader reader(device);
|
||||||
|
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd()) {
|
||||||
{
|
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement)
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
{
|
|
||||||
if (reader.name() == QLatin1String("absoluteAnchor")) // CT_AbsoluteAnchor
|
if (reader.name() == QLatin1String("absoluteAnchor")) // CT_AbsoluteAnchor
|
||||||
{
|
{
|
||||||
DrawingAbsoluteAnchor * anchor = new DrawingAbsoluteAnchor(this);
|
DrawingAbsoluteAnchor *anchor = new DrawingAbsoluteAnchor(this);
|
||||||
anchor->loadFromXml(reader);
|
anchor->loadFromXml(reader);
|
||||||
}
|
} else if (reader.name() == QLatin1String("oneCellAnchor")) // CT_OneCellAnchor
|
||||||
else if (reader.name() == QLatin1String("oneCellAnchor")) // CT_OneCellAnchor
|
|
||||||
{
|
{
|
||||||
DrawingOneCellAnchor * anchor = new DrawingOneCellAnchor(this);
|
DrawingOneCellAnchor *anchor = new DrawingOneCellAnchor(this);
|
||||||
anchor->loadFromXml(reader);
|
anchor->loadFromXml(reader);
|
||||||
}
|
} else if (reader.name() == QLatin1String("twoCellAnchor")) // CT_TwoCellAnchor
|
||||||
else if (reader.name() == QLatin1String("twoCellAnchor")) // CT_TwoCellAnchor
|
|
||||||
{
|
{
|
||||||
DrawingTwoCellAnchor * anchor = new DrawingTwoCellAnchor(this);
|
DrawingTwoCellAnchor *anchor = new DrawingTwoCellAnchor(this);
|
||||||
anchor->loadFromXml(reader);
|
anchor->loadFromXml(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,35 @@
|
|||||||
// xlsxmediafile.cpp
|
// xlsxmediafile.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
|
|
||||||
#include "xlsxmediafile_p.h"
|
#include "xlsxmediafile_p.h"
|
||||||
|
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
|
MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
|
||||||
: m_contents(bytes), m_suffix(suffix), m_mimeType(mimeType)
|
: m_contents(bytes)
|
||||||
, m_index(0), m_indexValid(false)
|
, m_suffix(suffix)
|
||||||
|
, m_mimeType(mimeType)
|
||||||
|
, m_index(0)
|
||||||
|
, m_indexValid(false)
|
||||||
{
|
{
|
||||||
m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
|
m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaFile::MediaFile(const QString &fileName)
|
MediaFile::MediaFile(const QString &fileName)
|
||||||
:m_fileName(fileName), m_index(0), m_indexValid(false)
|
: m_fileName(fileName)
|
||||||
|
, m_index(0)
|
||||||
|
, m_indexValid(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaFile::set(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
|
void MediaFile::set(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
|
||||||
{
|
{
|
||||||
m_contents = bytes;
|
m_contents = bytes;
|
||||||
m_suffix = suffix;
|
m_suffix = suffix;
|
||||||
m_mimeType = mimeType;
|
m_mimeType = mimeType;
|
||||||
m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
|
m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5);
|
||||||
m_indexValid = false;
|
m_indexValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +70,7 @@ bool MediaFile::isIndexValid() const
|
|||||||
|
|
||||||
void MediaFile::setIndex(int idx)
|
void MediaFile::setIndex(int idx)
|
||||||
{
|
{
|
||||||
m_index = idx;
|
m_index = idx;
|
||||||
m_indexValid = true;
|
m_indexValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "xlsxnumformatparser_p.h"
|
#include "xlsxnumformatparser_p.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -15,11 +15,11 @@ bool NumFormatParser::isDateTime(const QString &formatCode)
|
|||||||
switch (c.unicode()) {
|
switch (c.unicode()) {
|
||||||
case '[':
|
case '[':
|
||||||
// [h], [m], [s] are valid format for time
|
// [h], [m], [s] are valid format for time
|
||||||
if (i < formatCode.length()-2 && formatCode[i+2] == QLatin1Char(']')) {
|
if (i < formatCode.length() - 2 && formatCode[i + 2] == QLatin1Char(']')) {
|
||||||
const QChar cc = formatCode[i+1].toLower();
|
const QChar cc = formatCode[i + 1].toLower();
|
||||||
if (cc == QLatin1Char('h') || cc == QLatin1Char('m') || cc == QLatin1Char('s'))
|
if (cc == QLatin1Char('h') || cc == QLatin1Char('m') || cc == QLatin1Char('s'))
|
||||||
return true;
|
return true;
|
||||||
i+=2;
|
i += 2;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// condition or color: don't care, ignore
|
// condition or color: don't care, ignore
|
||||||
@ -30,7 +30,7 @@ bool NumFormatParser::isDateTime(const QString &formatCode)
|
|||||||
|
|
||||||
// quoted plain text block: don't care, ignore
|
// quoted plain text block: don't care, ignore
|
||||||
case '"':
|
case '"':
|
||||||
while (i < formatCode.length()-1 && formatCode[++i] != QLatin1Char('"'))
|
while (i < formatCode.length() - 1 && formatCode[++i] != QLatin1Char('"'))
|
||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
// xlsxrelationships.cpp
|
// xlsxrelationships.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QBuffer>
|
|
||||||
|
|
||||||
#include "xlsxrelationships_p.h"
|
#include "xlsxrelationships_p.h"
|
||||||
|
|
||||||
|
#include <QBuffer>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
const QLatin1String schema_doc("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
const QLatin1String
|
||||||
|
schema_doc("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||||
const QLatin1String schema_msPackage("http://schemas.microsoft.com/office/2006/relationships");
|
const QLatin1String schema_msPackage("http://schemas.microsoft.com/office/2006/relationships");
|
||||||
const QLatin1String schema_package("http://schemas.openxmlformats.org/package/2006/relationships");
|
const QLatin1String schema_package("http://schemas.openxmlformats.org/package/2006/relationships");
|
||||||
//const QString schema_worksheet = QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
// const QString schema_worksheet =
|
||||||
Relationships::Relationships()
|
// QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||||
{
|
Relationships::Relationships() {}
|
||||||
}
|
|
||||||
|
|
||||||
QList<XlsxRelationship> Relationships::documentRelationships(const QString &relativeType) const
|
QList<XlsxRelationship> Relationships::documentRelationships(const QString &relativeType) const
|
||||||
{
|
{
|
||||||
@ -54,7 +54,9 @@ QList<XlsxRelationship> Relationships::worksheetRelationships(const QString &rel
|
|||||||
return relationships(schema_doc + relativeType);
|
return relationships(schema_doc + relativeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Relationships::addWorksheetRelationship(const QString &relativeType, const QString &target, const QString &targetMode)
|
void Relationships::addWorksheetRelationship(const QString &relativeType,
|
||||||
|
const QString &target,
|
||||||
|
const QString &targetMode)
|
||||||
{
|
{
|
||||||
addRelationship(schema_doc + relativeType, target, targetMode);
|
addRelationship(schema_doc + relativeType, target, targetMode);
|
||||||
}
|
}
|
||||||
@ -69,12 +71,14 @@ QList<XlsxRelationship> Relationships::relationships(const QString &type) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Relationships::addRelationship(const QString &type, const QString &target, const QString &targetMode)
|
void Relationships::addRelationship(const QString &type,
|
||||||
|
const QString &target,
|
||||||
|
const QString &targetMode)
|
||||||
{
|
{
|
||||||
XlsxRelationship relation;
|
XlsxRelationship relation;
|
||||||
relation.id = QStringLiteral("rId%1").arg(m_relationships.size()+1);
|
relation.id = QStringLiteral("rId%1").arg(m_relationships.size() + 1);
|
||||||
relation.type = type;
|
relation.type = type;
|
||||||
relation.target = target;
|
relation.target = target;
|
||||||
relation.targetMode = targetMode;
|
relation.targetMode = targetMode;
|
||||||
|
|
||||||
m_relationships.append(relation);
|
m_relationships.append(relation);
|
||||||
@ -86,7 +90,9 @@ void Relationships::saveToXmlFile(QIODevice *device) const
|
|||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("Relationships"));
|
writer.writeStartElement(QStringLiteral("Relationships"));
|
||||||
writer.writeAttribute(QStringLiteral("xmlns"), QStringLiteral("http://schemas.openxmlformats.org/package/2006/relationships"));
|
writer.writeAttribute(
|
||||||
|
QStringLiteral("xmlns"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/package/2006/relationships"));
|
||||||
for (const XlsxRelationship &relation : m_relationships) {
|
for (const XlsxRelationship &relation : m_relationships) {
|
||||||
writer.writeStartElement(QStringLiteral("Relationship"));
|
writer.writeStartElement(QStringLiteral("Relationship"));
|
||||||
writer.writeAttribute(QStringLiteral("Id"), relation.id);
|
writer.writeAttribute(QStringLiteral("Id"), relation.id);
|
||||||
@ -96,7 +102,7 @@ void Relationships::saveToXmlFile(QIODevice *device) const
|
|||||||
writer.writeAttribute(QStringLiteral("TargetMode"), relation.targetMode);
|
writer.writeAttribute(QStringLiteral("TargetMode"), relation.targetMode);
|
||||||
writer.writeEndElement();
|
writer.writeEndElement();
|
||||||
}
|
}
|
||||||
writer.writeEndElement();//Relationships
|
writer.writeEndElement(); // Relationships
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,20 +121,20 @@ bool Relationships::loadFromXmlFile(QIODevice *device)
|
|||||||
clear();
|
clear();
|
||||||
QXmlStreamReader reader(device);
|
QXmlStreamReader reader(device);
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
if (token == QXmlStreamReader::StartElement) {
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QStringLiteral("Relationship")) {
|
if (reader.name() == QStringLiteral("Relationship")) {
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
XlsxRelationship relationship;
|
XlsxRelationship relationship;
|
||||||
relationship.id = attributes.value(QLatin1String("Id")).toString();
|
relationship.id = attributes.value(QLatin1String("Id")).toString();
|
||||||
relationship.type = attributes.value(QLatin1String("Type")).toString();
|
relationship.type = attributes.value(QLatin1String("Type")).toString();
|
||||||
relationship.target = attributes.value(QLatin1String("Target")).toString();
|
relationship.target = attributes.value(QLatin1String("Target")).toString();
|
||||||
relationship.targetMode = attributes.value(QLatin1String("TargetMode")).toString();
|
relationship.targetMode = attributes.value(QLatin1String("TargetMode")).toString();
|
||||||
m_relationships.append(relationship);
|
m_relationships.append(relationship);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.hasError())
|
if (reader.hasError())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,34 +1,32 @@
|
|||||||
// xlsxrichstring.cpp
|
// xlsxrichstring.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxrichstring.h"
|
||||||
|
|
||||||
|
#include "xlsxformat_p.h"
|
||||||
|
#include "xlsxrichstring_p.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QTextFragment>
|
#include <QTextFragment>
|
||||||
|
#include <QtGlobal>
|
||||||
#include "xlsxrichstring.h"
|
|
||||||
#include "xlsxrichstring_p.h"
|
|
||||||
#include "xlsxformat_p.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
RichStringPrivate::RichStringPrivate()
|
RichStringPrivate::RichStringPrivate()
|
||||||
:_dirty(true)
|
: _dirty(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RichStringPrivate::RichStringPrivate(const RichStringPrivate &other)
|
RichStringPrivate::RichStringPrivate(const RichStringPrivate &other)
|
||||||
:QSharedData(other), fragmentTexts(other.fragmentTexts)
|
: QSharedData(other)
|
||||||
,fragmentFormats(other.fragmentFormats)
|
, fragmentTexts(other.fragmentTexts)
|
||||||
, _idKey(other.idKey()), _dirty(other._dirty)
|
, fragmentFormats(other.fragmentFormats)
|
||||||
|
, _idKey(other.idKey())
|
||||||
|
, _dirty(other._dirty)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RichStringPrivate::~RichStringPrivate()
|
RichStringPrivate::~RichStringPrivate() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class RichString
|
\class RichString
|
||||||
@ -40,15 +38,15 @@ RichStringPrivate::~RichStringPrivate()
|
|||||||
Constructs a null string.
|
Constructs a null string.
|
||||||
*/
|
*/
|
||||||
RichString::RichString()
|
RichString::RichString()
|
||||||
:d(new RichStringPrivate)
|
: d(new RichStringPrivate)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a plain string with the given \a text.
|
Constructs a plain string with the given \a text.
|
||||||
*/
|
*/
|
||||||
RichString::RichString(const QString& text)
|
RichString::RichString(const QString &text)
|
||||||
:d(new RichStringPrivate)
|
: d(new RichStringPrivate)
|
||||||
{
|
{
|
||||||
addFragment(text, Format());
|
addFragment(text, Format());
|
||||||
}
|
}
|
||||||
@ -57,23 +55,19 @@ RichString::RichString(const QString& text)
|
|||||||
Constructs a copy of \a other.
|
Constructs a copy of \a other.
|
||||||
*/
|
*/
|
||||||
RichString::RichString(const RichString &other)
|
RichString::RichString(const RichString &other)
|
||||||
:d(other.d)
|
: d(other.d)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Destructs the string.
|
Destructs the string.
|
||||||
*/
|
*/
|
||||||
RichString::~RichString()
|
RichString::~RichString() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Assigns \a other to this string and returns a reference to this string
|
Assigns \a other to this string and returns a reference to this string
|
||||||
*/
|
*/
|
||||||
RichString &RichString::operator =(const RichString &other)
|
RichString &RichString::operator=(const RichString &other)
|
||||||
{
|
{
|
||||||
this->d = other.d;
|
this->d = other.d;
|
||||||
return *this;
|
return *this;
|
||||||
@ -84,11 +78,11 @@ RichString &RichString::operator =(const RichString &other)
|
|||||||
*/
|
*/
|
||||||
RichString::operator QVariant() const
|
RichString::operator QVariant() const
|
||||||
{
|
{
|
||||||
const auto& cref
|
const auto &cref
|
||||||
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
||||||
= QMetaType::fromType<RichString>();
|
= QMetaType::fromType<RichString>();
|
||||||
#else
|
#else
|
||||||
= qMetaTypeId<RichString>() ;
|
= qMetaTypeId<RichString>();
|
||||||
#endif
|
#endif
|
||||||
return QVariant(cref, this);
|
return QVariant(cref, this);
|
||||||
}
|
}
|
||||||
@ -98,7 +92,7 @@ RichString::operator QVariant() const
|
|||||||
*/
|
*/
|
||||||
bool RichString::isRichString() const
|
bool RichString::isRichString() const
|
||||||
{
|
{
|
||||||
if (fragmentCount() > 1) //Is this enough??
|
if (fragmentCount() > 1) // Is this enough??
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -116,7 +110,7 @@ bool RichString::isNull() const
|
|||||||
*/
|
*/
|
||||||
bool RichString::isEmtpy() const
|
bool RichString::isEmtpy() const
|
||||||
{
|
{
|
||||||
for (const auto& str : d->fragmentTexts) {
|
for (const auto &str : d->fragmentTexts) {
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -218,9 +212,9 @@ QByteArray RichStringPrivate::idKey() const
|
|||||||
if (fragmentTexts.size() == 1) {
|
if (fragmentTexts.size() == 1) {
|
||||||
bytes = fragmentTexts[0].toUtf8();
|
bytes = fragmentTexts[0].toUtf8();
|
||||||
} else {
|
} else {
|
||||||
//Generate a hash value base on QByteArray ?
|
// Generate a hash value base on QByteArray ?
|
||||||
bytes.append("@@QtXlsxRichString=");
|
bytes.append("@@QtXlsxRichString=");
|
||||||
for (int i=0; i<fragmentTexts.size(); ++i) {
|
for (int i = 0; i < fragmentTexts.size(); ++i) {
|
||||||
bytes.append("@Text");
|
bytes.append("@Text");
|
||||||
bytes.append(fragmentTexts[i].toUtf8());
|
bytes.append(fragmentTexts[i].toUtf8());
|
||||||
bytes.append("@Format");
|
bytes.append("@Format");
|
||||||
@ -272,9 +266,9 @@ bool operator<(const RichString &rs1, const RichString &rs2)
|
|||||||
Returns true if this string \a rs1 is equal to string \a rs2;
|
Returns true if this string \a rs1 is equal to string \a rs2;
|
||||||
otherwise returns false.
|
otherwise returns false.
|
||||||
*/
|
*/
|
||||||
bool operator ==(const RichString &rs1, const QString &rs2)
|
bool operator==(const RichString &rs1, const QString &rs2)
|
||||||
{
|
{
|
||||||
if (rs1.fragmentCount() == 1 && rs1.fragmentText(0) == rs2) //format == 0
|
if (rs1.fragmentCount() == 1 && rs1.fragmentText(0) == rs2) // format == 0
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -285,9 +279,9 @@ bool operator ==(const RichString &rs1, const QString &rs2)
|
|||||||
Returns true if this string \a rs1 is not equal to string \a rs2;
|
Returns true if this string \a rs1 is not equal to string \a rs2;
|
||||||
otherwise returns false.
|
otherwise returns false.
|
||||||
*/
|
*/
|
||||||
bool operator !=(const RichString &rs1, const QString &rs2)
|
bool operator!=(const RichString &rs1, const QString &rs2)
|
||||||
{
|
{
|
||||||
if (rs1.fragmentCount() == 1 && rs1.fragmentText(0) == rs2) //format == 0
|
if (rs1.fragmentCount() == 1 && rs1.fragmentText(0) == rs2) // format == 0
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -298,7 +292,7 @@ bool operator !=(const RichString &rs1, const QString &rs2)
|
|||||||
Returns true if this string \a rs1 is equal to string \a rs2;
|
Returns true if this string \a rs1 is equal to string \a rs2;
|
||||||
otherwise returns false.
|
otherwise returns false.
|
||||||
*/
|
*/
|
||||||
bool operator ==(const QString &rs1, const RichString &rs2)
|
bool operator==(const QString &rs1, const RichString &rs2)
|
||||||
{
|
{
|
||||||
return rs2 == rs1;
|
return rs2 == rs1;
|
||||||
}
|
}
|
||||||
@ -308,14 +302,14 @@ bool operator ==(const QString &rs1, const RichString &rs2)
|
|||||||
Returns true if this string \a rs1 is not equal to string \a rs2;
|
Returns true if this string \a rs1 is not equal to string \a rs2;
|
||||||
otherwise returns false.
|
otherwise returns false.
|
||||||
*/
|
*/
|
||||||
bool operator !=(const QString &rs1, const RichString &rs2)
|
bool operator!=(const QString &rs1, const RichString &rs2)
|
||||||
{
|
{
|
||||||
return rs2 != rs1;
|
return rs2 != rs1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW
|
uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW
|
||||||
{
|
{
|
||||||
return qHash(rs.d->idKey(), seed);
|
return qHash(rs.d->idKey(), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
// xlsxsharedstrings.cpp
|
// xlsxsharedstrings.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxcolor_p.h"
|
||||||
#include <QXmlStreamWriter>
|
#include "xlsxformat_p.h"
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QBuffer>
|
|
||||||
|
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxsharedstrings_p.h"
|
#include "xlsxsharedstrings_p.h"
|
||||||
#include "xlsxutility_p.h"
|
#include "xlsxutility_p.h"
|
||||||
#include "xlsxformat_p.h"
|
|
||||||
#include "xlsxcolor_p.h"
|
#include <QBuffer>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ QT_BEGIN_NAMESPACE_XLSX
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SharedStrings::SharedStrings(CreateFlag flag)
|
SharedStrings::SharedStrings(CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag)
|
: AbstractOOXmlFile(flag)
|
||||||
{
|
{
|
||||||
m_stringCount = 0;
|
m_stringCount = 0;
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ int SharedStrings::addSharedString(const RichString &string)
|
|||||||
return it->index;
|
return it->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = m_stringList.size();
|
int index = m_stringList.size();
|
||||||
m_stringTable[string] = XlsxSharedStringInfo(index);
|
m_stringTable[string] = XlsxSharedStringInfo(index);
|
||||||
m_stringList.append(string);
|
m_stringList.append(string);
|
||||||
return index;
|
return index;
|
||||||
@ -63,7 +63,7 @@ int SharedStrings::addSharedString(const RichString &string)
|
|||||||
|
|
||||||
void SharedStrings::incRefByStringIndex(int idx)
|
void SharedStrings::incRefByStringIndex(int idx)
|
||||||
{
|
{
|
||||||
if (idx <0 || idx >= m_stringList.size()) {
|
if (idx < 0 || idx >= m_stringList.size()) {
|
||||||
qDebug("SharedStrings: invlid index");
|
qDebug("SharedStrings: invlid index");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ void SharedStrings::removeSharedString(const RichString &string)
|
|||||||
it->count -= 1;
|
it->count -= 1;
|
||||||
|
|
||||||
if (it->count <= 0) {
|
if (it->count <= 0) {
|
||||||
for (int i=it->index+1; i<m_stringList.size(); ++i)
|
for (int i = it->index + 1; i < m_stringList.size(); ++i)
|
||||||
m_stringTable[m_stringList[i]].index -= 1;
|
m_stringTable[m_stringList[i]].index -= 1;
|
||||||
|
|
||||||
m_stringList.removeAt(it->index);
|
m_stringList.removeAt(it->index);
|
||||||
@ -145,7 +145,7 @@ void SharedStrings::writeRichStringPart_rPr(QXmlStreamWriter &writer, const Form
|
|||||||
Format::FontUnderline u = format.fontUnderline();
|
Format::FontUnderline u = format.fontUnderline();
|
||||||
if (u != Format::FontUnderlineNone) {
|
if (u != Format::FontUnderlineNone) {
|
||||||
writer.writeEmptyElement(QStringLiteral("u"));
|
writer.writeEmptyElement(QStringLiteral("u"));
|
||||||
if (u== Format::FontUnderlineDouble)
|
if (u == Format::FontUnderlineDouble)
|
||||||
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("double"));
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("double"));
|
||||||
else if (u == Format::FontUnderlineSingleAccounting)
|
else if (u == Format::FontUnderlineSingleAccounting)
|
||||||
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("singleAccounting"));
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("singleAccounting"));
|
||||||
@ -180,12 +180,14 @@ void SharedStrings::writeRichStringPart_rPr(QXmlStreamWriter &writer, const Form
|
|||||||
}
|
}
|
||||||
if (format.hasProperty(FormatPrivate::P_Font_Family)) {
|
if (format.hasProperty(FormatPrivate::P_Font_Family)) {
|
||||||
writer.writeEmptyElement(QStringLiteral("family"));
|
writer.writeEmptyElement(QStringLiteral("family"));
|
||||||
writer.writeAttribute(QStringLiteral("val"), QString::number(format.intProperty(FormatPrivate::P_Font_Family)));
|
writer.writeAttribute(QStringLiteral("val"),
|
||||||
|
QString::number(format.intProperty(FormatPrivate::P_Font_Family)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.hasProperty(FormatPrivate::P_Font_Scheme)) {
|
if (format.hasProperty(FormatPrivate::P_Font_Scheme)) {
|
||||||
writer.writeEmptyElement(QStringLiteral("scheme"));
|
writer.writeEmptyElement(QStringLiteral("scheme"));
|
||||||
writer.writeAttribute(QStringLiteral("val"), format.stringProperty(FormatPrivate::P_Font_Scheme));
|
writer.writeAttribute(QStringLiteral("val"),
|
||||||
|
format.stringProperty(FormatPrivate::P_Font_Scheme));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,35 +196,37 @@ void SharedStrings::saveToXmlFile(QIODevice *device) const
|
|||||||
QXmlStreamWriter writer(device);
|
QXmlStreamWriter writer(device);
|
||||||
|
|
||||||
if (m_stringList.size() != m_stringTable.size()) {
|
if (m_stringList.size() != m_stringTable.size()) {
|
||||||
//Duplicated string items exist in m_stringList
|
// Duplicated string items exist in m_stringList
|
||||||
//Clean up can not be done here, as the indices
|
// Clean up can not be done here, as the indices
|
||||||
//have been used when we save the worksheets part.
|
// have been used when we save the worksheets part.
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("sst"));
|
writer.writeStartElement(QStringLiteral("sst"));
|
||||||
writer.writeAttribute(QStringLiteral("xmlns"), QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
|
writer.writeAttribute(
|
||||||
|
QStringLiteral("xmlns"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
|
||||||
writer.writeAttribute(QStringLiteral("count"), QString::number(m_stringCount));
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_stringCount));
|
||||||
writer.writeAttribute(QStringLiteral("uniqueCount"), QString::number(m_stringList.size()));
|
writer.writeAttribute(QStringLiteral("uniqueCount"), QString::number(m_stringList.size()));
|
||||||
|
|
||||||
for (const RichString &string : m_stringList) {
|
for (const RichString &string : m_stringList) {
|
||||||
writer.writeStartElement(QStringLiteral("si"));
|
writer.writeStartElement(QStringLiteral("si"));
|
||||||
if (string.isRichString()) {
|
if (string.isRichString()) {
|
||||||
//Rich text string
|
// Rich text string
|
||||||
for (int i=0; i<string.fragmentCount(); ++i) {
|
for (int i = 0; i < string.fragmentCount(); ++i) {
|
||||||
writer.writeStartElement(QStringLiteral("r"));
|
writer.writeStartElement(QStringLiteral("r"));
|
||||||
if (string.fragmentFormat(i).hasFontData()) {
|
if (string.fragmentFormat(i).hasFontData()) {
|
||||||
writer.writeStartElement(QStringLiteral("rPr"));
|
writer.writeStartElement(QStringLiteral("rPr"));
|
||||||
writeRichStringPart_rPr(writer, string.fragmentFormat(i));
|
writeRichStringPart_rPr(writer, string.fragmentFormat(i));
|
||||||
writer.writeEndElement();// rPr
|
writer.writeEndElement(); // rPr
|
||||||
}
|
}
|
||||||
writer.writeStartElement(QStringLiteral("t"));
|
writer.writeStartElement(QStringLiteral("t"));
|
||||||
if (isSpaceReserveNeeded(string.fragmentText(i)))
|
if (isSpaceReserveNeeded(string.fragmentText(i)))
|
||||||
writer.writeAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
|
writer.writeAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
|
||||||
writer.writeCharacters(string.fragmentText(i));
|
writer.writeCharacters(string.fragmentText(i));
|
||||||
writer.writeEndElement();// t
|
writer.writeEndElement(); // t
|
||||||
|
|
||||||
writer.writeEndElement(); //r
|
writer.writeEndElement(); // r
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
writer.writeStartElement(QStringLiteral("t"));
|
writer.writeStartElement(QStringLiteral("t"));
|
||||||
@ -230,12 +234,12 @@ void SharedStrings::saveToXmlFile(QIODevice *device) const
|
|||||||
if (isSpaceReserveNeeded(pString))
|
if (isSpaceReserveNeeded(pString))
|
||||||
writer.writeAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
|
writer.writeAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
|
||||||
writer.writeCharacters(pString);
|
writer.writeCharacters(pString);
|
||||||
writer.writeEndElement();//t
|
writer.writeEndElement(); // t
|
||||||
}
|
}
|
||||||
writer.writeEndElement();//si
|
writer.writeEndElement(); // si
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeEndElement(); //sst
|
writer.writeEndElement(); // sst
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +249,8 @@ void SharedStrings::readString(QXmlStreamReader &reader)
|
|||||||
|
|
||||||
RichString richString;
|
RichString richString;
|
||||||
|
|
||||||
while (!reader.atEnd() && !(reader.name() == QLatin1String("si") && reader.tokenType() == QXmlStreamReader::EndElement)) {
|
while (!reader.atEnd() && !(reader.name() == QLatin1String("si") &&
|
||||||
|
reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("r"))
|
if (reader.name() == QLatin1String("r"))
|
||||||
@ -255,7 +260,7 @@ void SharedStrings::readString(QXmlStreamReader &reader)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = m_stringList.size();
|
int idx = m_stringList.size();
|
||||||
m_stringTable[richString] = XlsxSharedStringInfo(idx, 0);
|
m_stringTable[richString] = XlsxSharedStringInfo(idx, 0);
|
||||||
m_stringList.append(richString);
|
m_stringList.append(richString);
|
||||||
}
|
}
|
||||||
@ -266,7 +271,8 @@ void SharedStrings::readRichStringPart(QXmlStreamReader &reader, RichString &ric
|
|||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
Format format;
|
Format format;
|
||||||
while (!reader.atEnd() && !(reader.name() == QLatin1String("r") && reader.tokenType() == QXmlStreamReader::EndElement)) {
|
while (!reader.atEnd() && !(reader.name() == QLatin1String("r") &&
|
||||||
|
reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("rPr")) {
|
if (reader.name() == QLatin1String("rPr")) {
|
||||||
@ -283,9 +289,9 @@ void SharedStrings::readPlainStringPart(QXmlStreamReader &reader, RichString &ri
|
|||||||
{
|
{
|
||||||
Q_ASSERT(reader.name() == QLatin1String("t"));
|
Q_ASSERT(reader.name() == QLatin1String("t"));
|
||||||
|
|
||||||
//QXmlStreamAttributes attributes = reader.attributes();
|
// QXmlStreamAttributes attributes = reader.attributes();
|
||||||
|
|
||||||
// NOTICE: CHECK POINT
|
// NOTICE: CHECK POINT
|
||||||
QString text = reader.readElementText();
|
QString text = reader.readElementText();
|
||||||
richString.addFragment(text, Format());
|
richString.addFragment(text, Format());
|
||||||
}
|
}
|
||||||
@ -294,16 +300,19 @@ Format SharedStrings::readRichStringPart_rPr(QXmlStreamReader &reader)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(reader.name() == QLatin1String("rPr"));
|
Q_ASSERT(reader.name() == QLatin1String("rPr"));
|
||||||
Format format;
|
Format format;
|
||||||
while (!reader.atEnd() && !(reader.name() == QLatin1String("rPr") && reader.tokenType() == QXmlStreamReader::EndElement)) {
|
while (!reader.atEnd() && !(reader.name() == QLatin1String("rPr") &&
|
||||||
|
reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
if (reader.name() == QLatin1String("rFont")) {
|
if (reader.name() == QLatin1String("rFont")) {
|
||||||
format.setFontName(attributes.value(QLatin1String("val")).toString());
|
format.setFontName(attributes.value(QLatin1String("val")).toString());
|
||||||
} else if (reader.name() == QLatin1String("charset")) {
|
} else if (reader.name() == QLatin1String("charset")) {
|
||||||
format.setProperty(FormatPrivate::P_Font_Charset, attributes.value(QLatin1String("val")).toInt());
|
format.setProperty(FormatPrivate::P_Font_Charset,
|
||||||
|
attributes.value(QLatin1String("val")).toInt());
|
||||||
} else if (reader.name() == QLatin1String("family")) {
|
} else if (reader.name() == QLatin1String("family")) {
|
||||||
format.setProperty(FormatPrivate::P_Font_Family, attributes.value(QLatin1String("val")).toInt());
|
format.setProperty(FormatPrivate::P_Font_Family,
|
||||||
|
attributes.value(QLatin1String("val")).toInt());
|
||||||
} else if (reader.name() == QLatin1String("b")) {
|
} else if (reader.name() == QLatin1String("b")) {
|
||||||
format.setFontBold(true);
|
format.setFontBold(true);
|
||||||
} else if (reader.name() == QLatin1String("i")) {
|
} else if (reader.name() == QLatin1String("i")) {
|
||||||
@ -315,9 +324,11 @@ Format SharedStrings::readRichStringPart_rPr(QXmlStreamReader &reader)
|
|||||||
} else if (reader.name() == QLatin1String("shadow")) {
|
} else if (reader.name() == QLatin1String("shadow")) {
|
||||||
format.setProperty(FormatPrivate::P_Font_Shadow, true);
|
format.setProperty(FormatPrivate::P_Font_Shadow, true);
|
||||||
} else if (reader.name() == QLatin1String("condense")) {
|
} else if (reader.name() == QLatin1String("condense")) {
|
||||||
format.setProperty(FormatPrivate::P_Font_Condense, attributes.value(QLatin1String("val")).toInt());
|
format.setProperty(FormatPrivate::P_Font_Condense,
|
||||||
|
attributes.value(QLatin1String("val")).toInt());
|
||||||
} else if (reader.name() == QLatin1String("extend")) {
|
} else if (reader.name() == QLatin1String("extend")) {
|
||||||
format.setProperty(FormatPrivate::P_Font_Extend, attributes.value(QLatin1String("val")).toInt());
|
format.setProperty(FormatPrivate::P_Font_Extend,
|
||||||
|
attributes.value(QLatin1String("val")).toInt());
|
||||||
} else if (reader.name() == QLatin1String("color")) {
|
} else if (reader.name() == QLatin1String("color")) {
|
||||||
XlsxColor color;
|
XlsxColor color;
|
||||||
color.loadFromXml(reader);
|
color.loadFromXml(reader);
|
||||||
@ -341,7 +352,8 @@ Format SharedStrings::readRichStringPart_rPr(QXmlStreamReader &reader)
|
|||||||
else if (value == QLatin1String("subscript"))
|
else if (value == QLatin1String("subscript"))
|
||||||
format.setFontScript(Format::FontScriptSub);
|
format.setFontScript(Format::FontScriptSub);
|
||||||
} else if (reader.name() == QLatin1String("scheme")) {
|
} else if (reader.name() == QLatin1String("scheme")) {
|
||||||
format.setProperty(FormatPrivate::P_Font_Scheme, attributes.value(QLatin1String("val")).toString());
|
format.setProperty(FormatPrivate::P_Font_Scheme,
|
||||||
|
attributes.value(QLatin1String("val")).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,19 +363,19 @@ Format SharedStrings::readRichStringPart_rPr(QXmlStreamReader &reader)
|
|||||||
bool SharedStrings::loadFromXmlFile(QIODevice *device)
|
bool SharedStrings::loadFromXmlFile(QIODevice *device)
|
||||||
{
|
{
|
||||||
QXmlStreamReader reader(device);
|
QXmlStreamReader reader(device);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool hasUniqueCountAttr=true;
|
bool hasUniqueCountAttr = true;
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
if (token == QXmlStreamReader::StartElement) {
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("sst")) {
|
if (reader.name() == QLatin1String("sst")) {
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
if ((hasUniqueCountAttr = attributes.hasAttribute(QLatin1String("uniqueCount"))))
|
if ((hasUniqueCountAttr = attributes.hasAttribute(QLatin1String("uniqueCount"))))
|
||||||
count = attributes.value(QLatin1String("uniqueCount")).toInt();
|
count = attributes.value(QLatin1String("uniqueCount")).toInt();
|
||||||
} else if (reader.name() == QLatin1String("si")) {
|
} else if (reader.name() == QLatin1String("si")) {
|
||||||
readString(reader);
|
readString(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasUniqueCountAttr && m_stringList.size() != count) {
|
if (hasUniqueCountAttr && m_stringList.size() != count) {
|
||||||
@ -372,8 +384,8 @@ bool SharedStrings::loadFromXmlFile(QIODevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_stringList.size() != m_stringTable.size()) {
|
if (m_stringList.size() != m_stringTable.size()) {
|
||||||
//qDebug("Warning: Duplicated items exist in shared string table.");
|
// qDebug("Warning: Duplicated items exist in shared string table.");
|
||||||
//Nothing we can do here, as indices of the strings will be used when loading sheets.
|
// Nothing we can do here, as indices of the strings will be used when loading sheets.
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
#include "xlsxsimpleooxmlfile_p.h"
|
#include "xlsxsimpleooxmlfile_p.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
SimpleOOXmlFile::SimpleOOXmlFile(CreateFlag flag)
|
SimpleOOXmlFile::SimpleOOXmlFile(CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag)
|
: AbstractOOXmlFile(flag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,181 +7,198 @@
|
|||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
const char *defaultXmlData =
|
const char *defaultXmlData =
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||||
"<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office \xe4\xb8\xbb\xe9\xa2\x98\">"
|
"<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office "
|
||||||
"<a:themeElements>"
|
"\xe4\xb8\xbb\xe9\xa2\x98\">"
|
||||||
"<a:clrScheme name=\"Office\">"
|
"<a:themeElements>"
|
||||||
"<a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1>"
|
"<a:clrScheme name=\"Office\">"
|
||||||
"<a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1>"
|
"<a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1>"
|
||||||
"<a:dk2><a:srgbClr val=\"1F497D\"/></a:dk2>"
|
"<a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1>"
|
||||||
"<a:lt2><a:srgbClr val=\"EEECE1\"/></a:lt2>"
|
"<a:dk2><a:srgbClr val=\"1F497D\"/></a:dk2>"
|
||||||
"<a:accent1><a:srgbClr val=\"4F81BD\"/></a:accent1>"
|
"<a:lt2><a:srgbClr val=\"EEECE1\"/></a:lt2>"
|
||||||
"<a:accent2><a:srgbClr val=\"C0504D\"/></a:accent2>"
|
"<a:accent1><a:srgbClr val=\"4F81BD\"/></a:accent1>"
|
||||||
"<a:accent3><a:srgbClr val=\"9BBB59\"/></a:accent3>"
|
"<a:accent2><a:srgbClr val=\"C0504D\"/></a:accent2>"
|
||||||
"<a:accent4><a:srgbClr val=\"8064A2\"/></a:accent4>"
|
"<a:accent3><a:srgbClr val=\"9BBB59\"/></a:accent3>"
|
||||||
"<a:accent5><a:srgbClr val=\"4BACC6\"/></a:accent5>"
|
"<a:accent4><a:srgbClr val=\"8064A2\"/></a:accent4>"
|
||||||
"<a:accent6><a:srgbClr val=\"F79646\"/></a:accent6>"
|
"<a:accent5><a:srgbClr val=\"4BACC6\"/></a:accent5>"
|
||||||
"<a:hlink><a:srgbClr val=\"0000FF\"/></a:hlink>"
|
"<a:accent6><a:srgbClr val=\"F79646\"/></a:accent6>"
|
||||||
"<a:folHlink><a:srgbClr val=\"800080\"/></a:folHlink>"
|
"<a:hlink><a:srgbClr val=\"0000FF\"/></a:hlink>"
|
||||||
"</a:clrScheme>"
|
"<a:folHlink><a:srgbClr val=\"800080\"/></a:folHlink>"
|
||||||
"<a:fontScheme name=\"Office\">"
|
"</a:clrScheme>"
|
||||||
"<a:majorFont>"
|
"<a:fontScheme name=\"Office\">"
|
||||||
"<a:latin typeface=\"Cambria\"/>"
|
"<a:majorFont>"
|
||||||
"<a:ea typeface=\"\"/>"
|
"<a:latin typeface=\"Cambria\"/>"
|
||||||
"<a:cs typeface=\"\"/>"
|
"<a:ea typeface=\"\"/>"
|
||||||
"<a:font script=\"Jpan\" typeface=\"\xef\xbc\xad\xef\xbc\xb3 \xef\xbc\xb0\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf\"/>"
|
"<a:cs typeface=\"\"/>"
|
||||||
"<a:font script=\"Hang\" typeface=\"\xeb\xa7\x91\xec\x9d\x80 \xea\xb3\xa0\xeb\x94\x95\"/>"
|
"<a:font script=\"Jpan\" typeface=\"\xef\xbc\xad\xef\xbc\xb3 "
|
||||||
"<a:font script=\"Hans\" typeface=\"\xe5\xae\x8b\xe4\xbd\x93\"/>"
|
"\xef\xbc\xb0\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf\"/>"
|
||||||
"<a:font script=\"Hant\" typeface=\"\xe6\x96\xb0\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94\"/>"
|
"<a:font script=\"Hang\" typeface=\"\xeb\xa7\x91\xec\x9d\x80 \xea\xb3\xa0\xeb\x94\x95\"/>"
|
||||||
"<a:font script=\"Arab\" typeface=\"Times New Roman\"/>"
|
"<a:font script=\"Hans\" typeface=\"\xe5\xae\x8b\xe4\xbd\x93\"/>"
|
||||||
"<a:font script=\"Hebr\" typeface=\"Times New Roman\"/>"
|
"<a:font script=\"Hant\" typeface=\"\xe6\x96\xb0\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94\"/>"
|
||||||
"<a:font script=\"Thai\" typeface=\"Tahoma\"/>"
|
"<a:font script=\"Arab\" typeface=\"Times New Roman\"/>"
|
||||||
"<a:font script=\"Ethi\" typeface=\"Nyala\"/>"
|
"<a:font script=\"Hebr\" typeface=\"Times New Roman\"/>"
|
||||||
"<a:font script=\"Beng\" typeface=\"Vrinda\"/>"
|
"<a:font script=\"Thai\" typeface=\"Tahoma\"/>"
|
||||||
"<a:font script=\"Gujr\" typeface=\"Shruti\"/>"
|
"<a:font script=\"Ethi\" typeface=\"Nyala\"/>"
|
||||||
"<a:font script=\"Khmr\" typeface=\"MoolBoran\"/>"
|
"<a:font script=\"Beng\" typeface=\"Vrinda\"/>"
|
||||||
"<a:font script=\"Knda\" typeface=\"Tunga\"/>"
|
"<a:font script=\"Gujr\" typeface=\"Shruti\"/>"
|
||||||
"<a:font script=\"Guru\" typeface=\"Raavi\"/>"
|
"<a:font script=\"Khmr\" typeface=\"MoolBoran\"/>"
|
||||||
"<a:font script=\"Cans\" typeface=\"Euphemia\"/>"
|
"<a:font script=\"Knda\" typeface=\"Tunga\"/>"
|
||||||
"<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>"
|
"<a:font script=\"Guru\" typeface=\"Raavi\"/>"
|
||||||
"<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>"
|
"<a:font script=\"Cans\" typeface=\"Euphemia\"/>"
|
||||||
"<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>"
|
"<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>"
|
||||||
"<a:font script=\"Thaa\" typeface=\"MV Boli\"/>"
|
"<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>"
|
||||||
"<a:font script=\"Deva\" typeface=\"Mangal\"/>"
|
"<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>"
|
||||||
"<a:font script=\"Telu\" typeface=\"Gautami\"/>"
|
"<a:font script=\"Thaa\" typeface=\"MV Boli\"/>"
|
||||||
"<a:font script=\"Taml\" typeface=\"Latha\"/>"
|
"<a:font script=\"Deva\" typeface=\"Mangal\"/>"
|
||||||
"<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>"
|
"<a:font script=\"Telu\" typeface=\"Gautami\"/>"
|
||||||
"<a:font script=\"Orya\" typeface=\"Kalinga\"/>"
|
"<a:font script=\"Taml\" typeface=\"Latha\"/>"
|
||||||
"<a:font script=\"Mlym\" typeface=\"Kartika\"/>"
|
"<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>"
|
||||||
"<a:font script=\"Laoo\" typeface=\"DokChampa\"/>"
|
"<a:font script=\"Orya\" typeface=\"Kalinga\"/>"
|
||||||
"<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>"
|
"<a:font script=\"Mlym\" typeface=\"Kartika\"/>"
|
||||||
"<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>"
|
"<a:font script=\"Laoo\" typeface=\"DokChampa\"/>"
|
||||||
"<a:font script=\"Viet\" typeface=\"Times New Roman\"/>"
|
"<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>"
|
||||||
"<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>"
|
"<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>"
|
||||||
"</a:majorFont>"
|
"<a:font script=\"Viet\" typeface=\"Times New Roman\"/>"
|
||||||
"<a:minorFont>"
|
"<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>"
|
||||||
"<a:latin typeface=\"Calibri\"/>"
|
"</a:majorFont>"
|
||||||
"<a:ea typeface=\"\"/>"
|
"<a:minorFont>"
|
||||||
"<a:cs typeface=\"\"/>"
|
"<a:latin typeface=\"Calibri\"/>"
|
||||||
"<a:font script=\"Jpan\" typeface=\"\xef\xbc\xad\xef\xbc\xb3 \xef\xbc\xb0\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf\"/>"
|
"<a:ea typeface=\"\"/>"
|
||||||
"<a:font script=\"Hang\" typeface=\"\xeb\xa7\x91\xec\x9d\x80 \xea\xb3\xa0\xeb\x94\x95\"/>"
|
"<a:cs typeface=\"\"/>"
|
||||||
"<a:font script=\"Hans\" typeface=\"\xe5\xae\x8b\xe4\xbd\x93\"/>"
|
"<a:font script=\"Jpan\" typeface=\"\xef\xbc\xad\xef\xbc\xb3 "
|
||||||
"<a:font script=\"Hant\" typeface=\"\xe6\x96\xb0\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94\"/>"
|
"\xef\xbc\xb0\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf\"/>"
|
||||||
"<a:font script=\"Arab\" typeface=\"Arial\"/>"
|
"<a:font script=\"Hang\" typeface=\"\xeb\xa7\x91\xec\x9d\x80 \xea\xb3\xa0\xeb\x94\x95\"/>"
|
||||||
"<a:font script=\"Hebr\" typeface=\"Arial\"/>"
|
"<a:font script=\"Hans\" typeface=\"\xe5\xae\x8b\xe4\xbd\x93\"/>"
|
||||||
"<a:font script=\"Thai\" typeface=\"Tahoma\"/>"
|
"<a:font script=\"Hant\" typeface=\"\xe6\x96\xb0\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94\"/>"
|
||||||
"<a:font script=\"Ethi\" typeface=\"Nyala\"/>"
|
"<a:font script=\"Arab\" typeface=\"Arial\"/>"
|
||||||
"<a:font script=\"Beng\" typeface=\"Vrinda\"/>"
|
"<a:font script=\"Hebr\" typeface=\"Arial\"/>"
|
||||||
"<a:font script=\"Gujr\" typeface=\"Shruti\"/>"
|
"<a:font script=\"Thai\" typeface=\"Tahoma\"/>"
|
||||||
"<a:font script=\"Khmr\" typeface=\"DaunPenh\"/>"
|
"<a:font script=\"Ethi\" typeface=\"Nyala\"/>"
|
||||||
"<a:font script=\"Knda\" typeface=\"Tunga\"/>"
|
"<a:font script=\"Beng\" typeface=\"Vrinda\"/>"
|
||||||
"<a:font script=\"Guru\" typeface=\"Raavi\"/>"
|
"<a:font script=\"Gujr\" typeface=\"Shruti\"/>"
|
||||||
"<a:font script=\"Cans\" typeface=\"Euphemia\"/>"
|
"<a:font script=\"Khmr\" typeface=\"DaunPenh\"/>"
|
||||||
"<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>"
|
"<a:font script=\"Knda\" typeface=\"Tunga\"/>"
|
||||||
"<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>"
|
"<a:font script=\"Guru\" typeface=\"Raavi\"/>"
|
||||||
"<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>"
|
"<a:font script=\"Cans\" typeface=\"Euphemia\"/>"
|
||||||
"<a:font script=\"Thaa\" typeface=\"MV Boli\"/>"
|
"<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>"
|
||||||
"<a:font script=\"Deva\" typeface=\"Mangal\"/>"
|
"<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>"
|
||||||
"<a:font script=\"Telu\" typeface=\"Gautami\"/>"
|
"<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>"
|
||||||
"<a:font script=\"Taml\" typeface=\"Latha\"/>"
|
"<a:font script=\"Thaa\" typeface=\"MV Boli\"/>"
|
||||||
"<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>"
|
"<a:font script=\"Deva\" typeface=\"Mangal\"/>"
|
||||||
"<a:font script=\"Orya\" typeface=\"Kalinga\"/>"
|
"<a:font script=\"Telu\" typeface=\"Gautami\"/>"
|
||||||
"<a:font script=\"Mlym\" typeface=\"Kartika\"/>"
|
"<a:font script=\"Taml\" typeface=\"Latha\"/>"
|
||||||
"<a:font script=\"Laoo\" typeface=\"DokChampa\"/>"
|
"<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>"
|
||||||
"<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>"
|
"<a:font script=\"Orya\" typeface=\"Kalinga\"/>"
|
||||||
"<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>"
|
"<a:font script=\"Mlym\" typeface=\"Kartika\"/>"
|
||||||
"<a:font script=\"Viet\" typeface=\"Arial\"/>"
|
"<a:font script=\"Laoo\" typeface=\"DokChampa\"/>"
|
||||||
"<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>"
|
"<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>"
|
||||||
"</a:minorFont>"
|
"<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>"
|
||||||
"</a:fontScheme>"
|
"<a:font script=\"Viet\" typeface=\"Arial\"/>"
|
||||||
"<a:fmtScheme name=\"Office\">"
|
"<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>"
|
||||||
"<a:fillStyleLst>"
|
"</a:minorFont>"
|
||||||
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
"</a:fontScheme>"
|
||||||
"<a:gradFill rotWithShape=\"1\">"
|
"<a:fmtScheme name=\"Office\">"
|
||||||
"<a:gsLst>"
|
"<a:fillStyleLst>"
|
||||||
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"50000\"/><a:satMod val=\"300000\"/></a:schemeClr></a:gs>"
|
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
||||||
"<a:gs pos=\"35000\"><a:schemeClr val=\"phClr\"><a:tint val=\"37000\"/><a:satMod val=\"300000\"/></a:schemeClr></a:gs>"
|
"<a:gradFill rotWithShape=\"1\">"
|
||||||
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:tint val=\"15000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs>"
|
"<a:gsLst>"
|
||||||
"</a:gsLst>"
|
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"50000\"/><a:satMod "
|
||||||
"<a:lin ang=\"16200000\" scaled=\"1\"/>"
|
"val=\"300000\"/></a:schemeClr></a:gs>"
|
||||||
"</a:gradFill>"
|
"<a:gs pos=\"35000\"><a:schemeClr val=\"phClr\"><a:tint val=\"37000\"/><a:satMod "
|
||||||
"<a:gradFill rotWithShape=\"1\">"
|
"val=\"300000\"/></a:schemeClr></a:gs>"
|
||||||
"<a:gsLst>"
|
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:tint val=\"15000\"/><a:satMod "
|
||||||
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:shade val=\"51000\"/><a:satMod val=\"130000\"/></a:schemeClr></a:gs>"
|
"val=\"350000\"/></a:schemeClr></a:gs>"
|
||||||
"<a:gs pos=\"80000\"><a:schemeClr val=\"phClr\"><a:shade val=\"93000\"/><a:satMod val=\"130000\"/></a:schemeClr></a:gs>"
|
"</a:gsLst>"
|
||||||
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"94000\"/><a:satMod val=\"135000\"/></a:schemeClr></a:gs>"
|
"<a:lin ang=\"16200000\" scaled=\"1\"/>"
|
||||||
"</a:gsLst>"
|
"</a:gradFill>"
|
||||||
"<a:lin ang=\"16200000\" scaled=\"0\"/>"
|
"<a:gradFill rotWithShape=\"1\">"
|
||||||
"</a:gradFill>"
|
"<a:gsLst>"
|
||||||
"</a:fillStyleLst>"
|
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:shade val=\"51000\"/><a:satMod "
|
||||||
"<a:lnStyleLst>"
|
"val=\"130000\"/></a:schemeClr></a:gs>"
|
||||||
"<a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">"
|
"<a:gs pos=\"80000\"><a:schemeClr val=\"phClr\"><a:shade val=\"93000\"/><a:satMod "
|
||||||
"<a:solidFill><a:schemeClr val=\"phClr\"><a:shade val=\"95000\"/><a:satMod val=\"105000\"/></a:schemeClr></a:solidFill>"
|
"val=\"130000\"/></a:schemeClr></a:gs>"
|
||||||
"<a:prstDash val=\"solid\"/>"
|
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"94000\"/><a:satMod "
|
||||||
"</a:ln>"
|
"val=\"135000\"/></a:schemeClr></a:gs>"
|
||||||
"<a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">"
|
"</a:gsLst>"
|
||||||
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
"<a:lin ang=\"16200000\" scaled=\"0\"/>"
|
||||||
"<a:prstDash val=\"solid\"/>"
|
"</a:gradFill>"
|
||||||
"</a:ln>"
|
"</a:fillStyleLst>"
|
||||||
"<a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">"
|
"<a:lnStyleLst>"
|
||||||
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
"<a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">"
|
||||||
"<a:prstDash val=\"solid\"/>"
|
"<a:solidFill><a:schemeClr val=\"phClr\"><a:shade val=\"95000\"/><a:satMod "
|
||||||
"</a:ln>"
|
"val=\"105000\"/></a:schemeClr></a:solidFill>"
|
||||||
"</a:lnStyleLst>"
|
"<a:prstDash val=\"solid\"/>"
|
||||||
"<a:effectStyleLst>"
|
"</a:ln>"
|
||||||
"<a:effectStyle>"
|
"<a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">"
|
||||||
"<a:effectLst>"
|
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
||||||
"<a:outerShdw blurRad=\"40000\" dist=\"20000\" dir=\"5400000\" rotWithShape=\"0\">"
|
"<a:prstDash val=\"solid\"/>"
|
||||||
"<a:srgbClr val=\"000000\"><a:alpha val=\"38000\"/></a:srgbClr>"
|
"</a:ln>"
|
||||||
"</a:outerShdw>"
|
"<a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">"
|
||||||
"</a:effectLst>"
|
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
||||||
"</a:effectStyle>"
|
"<a:prstDash val=\"solid\"/>"
|
||||||
"<a:effectStyle>"
|
"</a:ln>"
|
||||||
"<a:effectLst>"
|
"</a:lnStyleLst>"
|
||||||
"<a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">"
|
"<a:effectStyleLst>"
|
||||||
"<a:srgbClr val=\"000000\"><a:alpha val=\"35000\"/></a:srgbClr>"
|
"<a:effectStyle>"
|
||||||
"</a:outerShdw>"
|
"<a:effectLst>"
|
||||||
"</a:effectLst>"
|
"<a:outerShdw blurRad=\"40000\" dist=\"20000\" dir=\"5400000\" rotWithShape=\"0\">"
|
||||||
"</a:effectStyle>"
|
"<a:srgbClr val=\"000000\"><a:alpha val=\"38000\"/></a:srgbClr>"
|
||||||
"<a:effectStyle>"
|
"</a:outerShdw>"
|
||||||
"<a:effectLst>"
|
"</a:effectLst>"
|
||||||
"<a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">"
|
"</a:effectStyle>"
|
||||||
"<a:srgbClr val=\"000000\"><a:alpha val=\"35000\"/></a:srgbClr>"
|
"<a:effectStyle>"
|
||||||
"</a:outerShdw>"
|
"<a:effectLst>"
|
||||||
"</a:effectLst>"
|
"<a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">"
|
||||||
"<a:scene3d>"
|
"<a:srgbClr val=\"000000\"><a:alpha val=\"35000\"/></a:srgbClr>"
|
||||||
"<a:camera prst=\"orthographicFront\"><a:rot lat=\"0\" lon=\"0\" rev=\"0\"/></a:camera>"
|
"</a:outerShdw>"
|
||||||
"<a:lightRig rig=\"threePt\" dir=\"t\"><a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/></a:lightRig>"
|
"</a:effectLst>"
|
||||||
"</a:scene3d>"
|
"</a:effectStyle>"
|
||||||
"<a:sp3d><a:bevelT w=\"63500\" h=\"25400\"/></a:sp3d>"
|
"<a:effectStyle>"
|
||||||
"</a:effectStyle>"
|
"<a:effectLst>"
|
||||||
"</a:effectStyleLst>"
|
"<a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\">"
|
||||||
"<a:bgFillStyleLst>"
|
"<a:srgbClr val=\"000000\"><a:alpha val=\"35000\"/></a:srgbClr>"
|
||||||
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
"</a:outerShdw>"
|
||||||
"<a:gradFill rotWithShape=\"1\">"
|
"</a:effectLst>"
|
||||||
"<a:gsLst>"
|
"<a:scene3d>"
|
||||||
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"40000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs>"
|
"<a:camera prst=\"orthographicFront\"><a:rot lat=\"0\" lon=\"0\" rev=\"0\"/></a:camera>"
|
||||||
"<a:gs pos=\"40000\"><a:schemeClr val=\"phClr\"><a:tint val=\"45000\"/><a:shade val=\"99000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs>"
|
"<a:lightRig rig=\"threePt\" dir=\"t\"><a:rot lat=\"0\" lon=\"0\" "
|
||||||
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"20000\"/><a:satMod val=\"255000\"/></a:schemeClr></a:gs></a:gsLst>"
|
"rev=\"1200000\"/></a:lightRig>"
|
||||||
"<a:path path=\"circle\"><a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/></a:path>"
|
"</a:scene3d>"
|
||||||
"</a:gradFill>"
|
"<a:sp3d><a:bevelT w=\"63500\" h=\"25400\"/></a:sp3d>"
|
||||||
"<a:gradFill rotWithShape=\"1\">"
|
"</a:effectStyle>"
|
||||||
"<a:gsLst>"
|
"</a:effectStyleLst>"
|
||||||
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"80000\"/><a:satMod val=\"300000\"/></a:schemeClr></a:gs>"
|
"<a:bgFillStyleLst>"
|
||||||
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"30000\"/><a:satMod val=\"200000\"/></a:schemeClr></a:gs>"
|
"<a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill>"
|
||||||
"</a:gsLst>"
|
"<a:gradFill rotWithShape=\"1\">"
|
||||||
"<a:path path=\"circle\"><a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/></a:path>"
|
"<a:gsLst>"
|
||||||
"</a:gradFill>"
|
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"40000\"/><a:satMod "
|
||||||
"</a:bgFillStyleLst>"
|
"val=\"350000\"/></a:schemeClr></a:gs>"
|
||||||
"</a:fmtScheme>"
|
"<a:gs pos=\"40000\"><a:schemeClr val=\"phClr\"><a:tint val=\"45000\"/><a:shade "
|
||||||
"</a:themeElements>"
|
"val=\"99000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs>"
|
||||||
"<a:objectDefaults/>"
|
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"20000\"/><a:satMod "
|
||||||
"<a:extraClrSchemeLst/>"
|
"val=\"255000\"/></a:schemeClr></a:gs></a:gsLst>"
|
||||||
"</a:theme>"
|
"<a:path path=\"circle\"><a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" "
|
||||||
;
|
"b=\"180000\"/></a:path>"
|
||||||
|
"</a:gradFill>"
|
||||||
|
"<a:gradFill rotWithShape=\"1\">"
|
||||||
|
"<a:gsLst>"
|
||||||
|
"<a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"80000\"/><a:satMod "
|
||||||
|
"val=\"300000\"/></a:schemeClr></a:gs>"
|
||||||
|
"<a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"30000\"/><a:satMod "
|
||||||
|
"val=\"200000\"/></a:schemeClr></a:gs>"
|
||||||
|
"</a:gsLst>"
|
||||||
|
"<a:path path=\"circle\"><a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" "
|
||||||
|
"b=\"50000\"/></a:path>"
|
||||||
|
"</a:gradFill>"
|
||||||
|
"</a:bgFillStyleLst>"
|
||||||
|
"</a:fmtScheme>"
|
||||||
|
"</a:themeElements>"
|
||||||
|
"<a:objectDefaults/>"
|
||||||
|
"<a:extraClrSchemeLst/>"
|
||||||
|
"</a:theme>";
|
||||||
|
|
||||||
Theme::Theme(CreateFlag flag)
|
Theme::Theme(CreateFlag flag)
|
||||||
:AbstractOOXmlFile(flag)
|
: AbstractOOXmlFile(flag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
// xlsxutility.cpp
|
// xlsxutility.cpp
|
||||||
|
|
||||||
#include "xlsxutility_p.h"
|
|
||||||
#include "xlsxcellreference.h"
|
#include "xlsxcellreference.h"
|
||||||
|
#include "xlsxutility_p.h"
|
||||||
#include <QString>
|
|
||||||
#include <QPoint>
|
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QPoint>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
bool parseXsdBoolean(const QString &value, bool defaultValue)
|
bool parseXsdBoolean(const QString &value, bool defaultValue)
|
||||||
@ -30,9 +30,9 @@ QStringList splitPath(const QString &path)
|
|||||||
{
|
{
|
||||||
int idx = path.lastIndexOf(QLatin1Char('/'));
|
int idx = path.lastIndexOf(QLatin1Char('/'));
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return { QStringLiteral("."), path };
|
return {QStringLiteral("."), path};
|
||||||
|
|
||||||
return { path.left(idx), path.mid(idx+1) };
|
return {path.left(idx), path.mid(idx + 1)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -52,22 +52,23 @@ QString getRelFilePath(const QString &filePath)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = QString( filePath.left(idx) + QLatin1String("/_rels/") + filePath.mid(idx+1) + QLatin1String(".rels"));
|
ret = QString(filePath.left(idx) + QLatin1String("/_rels/") + filePath.mid(idx + 1) +
|
||||||
|
QLatin1String(".rels"));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
double datetimeToNumber(const QDateTime &dt, bool is1904)
|
double datetimeToNumber(const QDateTime &dt, bool is1904)
|
||||||
{
|
{
|
||||||
//Note, for number 0, Excel2007 shown as 1900-1-0, which should be 1899-12-31
|
// Note, for number 0, Excel2007 shown as 1900-1-0, which should be 1899-12-31
|
||||||
QDateTime epoch(is1904 ? QDate(1904, 1, 1): QDate(1899, 12, 31), QTime(0,0));
|
QDateTime epoch(is1904 ? QDate(1904, 1, 1) : QDate(1899, 12, 31), QTime(0, 0));
|
||||||
|
|
||||||
double excel_time = epoch.msecsTo(dt) / (1000*60*60*24.0);
|
double excel_time = epoch.msecsTo(dt) / (1000 * 60 * 60 * 24.0);
|
||||||
|
|
||||||
if (dt.isDaylightTime()) // Add one hour if the date is Daylight
|
if (dt.isDaylightTime()) // Add one hour if the date is Daylight
|
||||||
excel_time += 1.0 / 24.0;
|
excel_time += 1.0 / 24.0;
|
||||||
|
|
||||||
if (!is1904 && excel_time > 59) {//31+28
|
if (!is1904 && excel_time > 59) { // 31+28
|
||||||
//Account for Excel erroneously treating 1900 as a leap year.
|
// Account for Excel erroneously treating 1900 as a leap year.
|
||||||
excel_time += 1;
|
excel_time += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ double datetimeToNumber(const QDateTime &dt, bool is1904)
|
|||||||
|
|
||||||
double timeToNumber(const QTime &time)
|
double timeToNumber(const QTime &time)
|
||||||
{
|
{
|
||||||
return QTime(0,0).msecsTo(time) / (1000*60*60*24.0);
|
return QTime(0, 0).msecsTo(time) / (1000 * 60 * 60 * 24.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant datetimeFromNumber(double num, bool is1904)
|
QVariant datetimeFromNumber(double num, bool is1904)
|
||||||
@ -88,30 +89,27 @@ QVariant datetimeFromNumber(double num, bool is1904)
|
|||||||
num = num - 1;
|
num = num - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 msecs = static_cast<qint64>(num * 1000*60*60*24.0 + 0.5);
|
qint64 msecs = static_cast<qint64>(num * 1000 * 60 * 60 * 24.0 + 0.5);
|
||||||
QDateTime epoch(is1904 ? QDate(1904, 1, 1): QDate(1899, 12, 31), QTime(0,0));
|
QDateTime epoch(is1904 ? QDate(1904, 1, 1) : QDate(1899, 12, 31), QTime(0, 0));
|
||||||
QDateTime dtOld = epoch.addMSecs(msecs);
|
QDateTime dtOld = epoch.addMSecs(msecs);
|
||||||
dtRet = dtOld;
|
dtRet = dtOld;
|
||||||
|
|
||||||
// Remove one hour to see whether the date is Daylight
|
// Remove one hour to see whether the date is Daylight
|
||||||
QDateTime dtNew = dtRet.addMSecs( -3600000 ); // issue102
|
QDateTime dtNew = dtRet.addMSecs(-3600000); // issue102
|
||||||
if ( dtNew.isDaylightTime() )
|
if (dtNew.isDaylightTime()) {
|
||||||
{
|
|
||||||
dtRet = dtNew;
|
dtRet = dtNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
double whole = 0;
|
double whole = 0;
|
||||||
double fractional = std::modf(num, &whole);
|
double fractional = std::modf(num, &whole);
|
||||||
|
|
||||||
if ( num < double(1) )
|
if (num < double(1)) {
|
||||||
{
|
|
||||||
// only time
|
// only time
|
||||||
QTime t = dtRet.time();
|
QTime t = dtRet.time();
|
||||||
return QVariant(t);
|
return QVariant(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fractional == 0.0 )
|
if (fractional == 0.0) {
|
||||||
{
|
|
||||||
// only date
|
// only date
|
||||||
QDate onlyDT = dtRet.date();
|
QDate onlyDT = dtRet.date();
|
||||||
return QVariant(onlyDT);
|
return QVariant(onlyDT);
|
||||||
@ -135,10 +133,11 @@ QString createSafeSheetName(const QString &nameProposal)
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString ret = nameProposal;
|
QString ret = nameProposal;
|
||||||
if (nameProposal.length() > 2 && nameProposal.startsWith(QLatin1Char('\'')) && nameProposal.endsWith(QLatin1Char('\'')))
|
if (nameProposal.length() > 2 && nameProposal.startsWith(QLatin1Char('\'')) &&
|
||||||
|
nameProposal.endsWith(QLatin1Char('\'')))
|
||||||
ret = unescapeSheetName(ret);
|
ret = unescapeSheetName(ret);
|
||||||
|
|
||||||
//Replace invalid chars with space.
|
// Replace invalid chars with space.
|
||||||
static QRegularExpression invalidChars(QStringLiteral("[/\\\\?*\\][:]"));
|
static QRegularExpression invalidChars(QStringLiteral("[/\\\\?*\\][:]"));
|
||||||
if (nameProposal.contains(invalidChars)) {
|
if (nameProposal.contains(invalidChars)) {
|
||||||
static QRegularExpression validChars(QStringLiteral("[/\\\\?*\\][:]"));
|
static QRegularExpression validChars(QStringLiteral("[/\\\\?*\\][:]"));
|
||||||
@ -149,7 +148,7 @@ QString createSafeSheetName(const QString &nameProposal)
|
|||||||
ret[0] = QLatin1Char(' ');
|
ret[0] = QLatin1Char(' ');
|
||||||
|
|
||||||
if (ret.endsWith(QLatin1Char('\'')))
|
if (ret.endsWith(QLatin1Char('\'')))
|
||||||
ret[ret.size()-1] = QLatin1Char(' ');
|
ret[ret.size() - 1] = QLatin1Char(' ');
|
||||||
|
|
||||||
if (ret.size() > 31)
|
if (ret.size() > 31)
|
||||||
ret = ret.left(31);
|
ret = ret.left(31);
|
||||||
@ -157,19 +156,20 @@ QString createSafeSheetName(const QString &nameProposal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When sheetName contains space or apostrophe, escaped is needed by cellFormula/definedName/chartSerials.
|
* When sheetName contains space or apostrophe, escaped is needed by
|
||||||
|
* cellFormula/definedName/chartSerials.
|
||||||
*/
|
*/
|
||||||
QString escapeSheetName(const QString &sheetName)
|
QString escapeSheetName(const QString &sheetName)
|
||||||
{
|
{
|
||||||
//Already escaped.
|
// Already escaped.
|
||||||
Q_ASSERT(!sheetName.startsWith(QLatin1Char('\'')) && !sheetName.endsWith(QLatin1Char('\'')));
|
Q_ASSERT(!sheetName.startsWith(QLatin1Char('\'')) && !sheetName.endsWith(QLatin1Char('\'')));
|
||||||
|
|
||||||
//These is no need to escape
|
// These is no need to escape
|
||||||
static const auto escape = QRegularExpression(QStringLiteral("[ +\\-,%^=<>'&]"));
|
static const auto escape = QRegularExpression(QStringLiteral("[ +\\-,%^=<>'&]"));
|
||||||
if (!sheetName.contains(escape))
|
if (!sheetName.contains(escape))
|
||||||
return sheetName;
|
return sheetName;
|
||||||
|
|
||||||
//OK, escape is needed.
|
// OK, escape is needed.
|
||||||
QString name = sheetName;
|
QString name = sheetName;
|
||||||
name.replace(QLatin1Char('\''), QLatin1String("\'\'"));
|
name.replace(QLatin1Char('\''), QLatin1String("\'\'"));
|
||||||
return QLatin1Char('\'') + name + QLatin1Char('\'');
|
return QLatin1Char('\'') + name + QLatin1Char('\'');
|
||||||
@ -179,9 +179,10 @@ QString escapeSheetName(const QString &sheetName)
|
|||||||
*/
|
*/
|
||||||
QString unescapeSheetName(const QString &sheetName)
|
QString unescapeSheetName(const QString &sheetName)
|
||||||
{
|
{
|
||||||
Q_ASSERT(sheetName.length() > 2 && sheetName.startsWith(QLatin1Char('\'')) && sheetName.endsWith(QLatin1Char('\'')));
|
Q_ASSERT(sheetName.length() > 2 && sheetName.startsWith(QLatin1Char('\'')) &&
|
||||||
|
sheetName.endsWith(QLatin1Char('\'')));
|
||||||
|
|
||||||
QString name = sheetName.mid(1, sheetName.length()-2);
|
QString name = sheetName.mid(1, sheetName.length() - 2);
|
||||||
name.replace(QLatin1String("\'\'"), QLatin1String("\'"));
|
name.replace(QLatin1String("\'\'"), QLatin1String("\'"));
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -192,7 +193,7 @@ QString unescapeSheetName(const QString &sheetName)
|
|||||||
bool isSpaceReserveNeeded(const QString &s)
|
bool isSpaceReserveNeeded(const QString &s)
|
||||||
{
|
{
|
||||||
QString spaces(QStringLiteral(" \t\n\r"));
|
QString spaces(QStringLiteral(" \t\n\r"));
|
||||||
return !s.isEmpty() && (spaces.contains(s.at(0))||spaces.contains(s.at(s.length()-1)));
|
return !s.isEmpty() && (spaces.contains(s.at(0)) || spaces.contains(s.at(s.length() - 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -206,18 +207,20 @@ bool isSpaceReserveNeeded(const QString &s)
|
|||||||
*
|
*
|
||||||
* For long run, we need a formula parser.
|
* For long run, we need a formula parser.
|
||||||
*/
|
*/
|
||||||
QString convertSharedFormula(const QString &rootFormula, const CellReference &rootCell, const CellReference &cell)
|
QString convertSharedFormula(const QString &rootFormula,
|
||||||
|
const CellReference &rootCell,
|
||||||
|
const CellReference &cell)
|
||||||
{
|
{
|
||||||
Q_UNUSED(rootCell)
|
Q_UNUSED(rootCell)
|
||||||
Q_UNUSED(cell)
|
Q_UNUSED(cell)
|
||||||
//Find all the "$?[A-Z]+$?[0-9]+" patterns in the rootFormula.
|
// Find all the "$?[A-Z]+$?[0-9]+" patterns in the rootFormula.
|
||||||
QVector<std::pair<QString, int> > segments;
|
QVector<std::pair<QString, int>> segments;
|
||||||
|
|
||||||
QString segment;
|
QString segment;
|
||||||
bool inQuote = false;
|
bool inQuote = false;
|
||||||
enum RefState{INVALID, PRE_AZ, AZ, PRE_09, _09};
|
enum RefState { INVALID, PRE_AZ, AZ, PRE_09, _09 };
|
||||||
RefState refState = INVALID;
|
RefState refState = INVALID;
|
||||||
int refFlag = 0; // 0x00, 0x01, 0x02, 0x03 ==> A1, $A1, A$1, $A$1
|
int refFlag = 0; // 0x00, 0x01, 0x02, 0x03 ==> A1, $A1, A$1, $A$1
|
||||||
for (QChar ch : rootFormula) {
|
for (QChar ch : rootFormula) {
|
||||||
if (inQuote) {
|
if (inQuote) {
|
||||||
segment.append(ch);
|
segment.append(ch);
|
||||||
@ -225,7 +228,7 @@ QString convertSharedFormula(const QString &rootFormula, const CellReference &ro
|
|||||||
inQuote = false;
|
inQuote = false;
|
||||||
} else {
|
} else {
|
||||||
if (ch == QLatin1Char('"')) {
|
if (ch == QLatin1Char('"')) {
|
||||||
inQuote = true;
|
inQuote = true;
|
||||||
refState = INVALID;
|
refState = INVALID;
|
||||||
segment.append(ch);
|
segment.append(ch);
|
||||||
} else if (ch == QLatin1Char('$')) {
|
} else if (ch == QLatin1Char('$')) {
|
||||||
@ -234,21 +237,21 @@ QString convertSharedFormula(const QString &rootFormula, const CellReference &ro
|
|||||||
refState = PRE_09;
|
refState = PRE_09;
|
||||||
refFlag |= 0x02;
|
refFlag |= 0x02;
|
||||||
} else {
|
} else {
|
||||||
segments.append(std::make_pair(segment, refState==_09 ? refFlag : -1 ));
|
segments.append(std::make_pair(segment, refState == _09 ? refFlag : -1));
|
||||||
segment = QString(ch); //Start new segment.
|
segment = QString(ch); // Start new segment.
|
||||||
refState = PRE_AZ;
|
refState = PRE_AZ;
|
||||||
refFlag = 0x01;
|
refFlag = 0x01;
|
||||||
}
|
}
|
||||||
} else if (ch >= QLatin1Char('A') && ch <=QLatin1Char('Z')) {
|
} else if (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')) {
|
||||||
if (refState == PRE_AZ || refState == AZ) {
|
if (refState == PRE_AZ || refState == AZ) {
|
||||||
segment.append(ch);
|
segment.append(ch);
|
||||||
} else {
|
} else {
|
||||||
segments.append(std::make_pair(segment, refState==_09 ? refFlag : -1 ));
|
segments.append(std::make_pair(segment, refState == _09 ? refFlag : -1));
|
||||||
segment = QString(ch); //Start new segment.
|
segment = QString(ch); // Start new segment.
|
||||||
refFlag = 0x00;
|
refFlag = 0x00;
|
||||||
}
|
}
|
||||||
refState = AZ;
|
refState = AZ;
|
||||||
} else if (ch >= QLatin1Char('0') && ch <=QLatin1Char('9')) {
|
} else if (ch >= QLatin1Char('0') && ch <= QLatin1Char('9')) {
|
||||||
segment.append(ch);
|
segment.append(ch);
|
||||||
|
|
||||||
if (refState == AZ || refState == PRE_09 || refState == _09)
|
if (refState == AZ || refState == PRE_09 || refState == _09)
|
||||||
@ -257,8 +260,8 @@ QString convertSharedFormula(const QString &rootFormula, const CellReference &ro
|
|||||||
refState = INVALID;
|
refState = INVALID;
|
||||||
} else {
|
} else {
|
||||||
if (refState == _09) {
|
if (refState == _09) {
|
||||||
segments.append(std::make_pair(segment, refFlag ));
|
segments.append(std::make_pair(segment, refFlag));
|
||||||
segment = QString(ch); //Start new segment.
|
segment = QString(ch); // Start new segment.
|
||||||
} else {
|
} else {
|
||||||
segment.append(ch);
|
segment.append(ch);
|
||||||
}
|
}
|
||||||
@ -268,23 +271,24 @@ QString convertSharedFormula(const QString &rootFormula, const CellReference &ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!segment.isEmpty())
|
if (!segment.isEmpty())
|
||||||
segments.append(std::make_pair(segment, refState==_09 ? refFlag : -1 ));
|
segments.append(std::make_pair(segment, refState == _09 ? refFlag : -1));
|
||||||
|
|
||||||
//Replace "A1", "$A1", "A$1" segment with proper one.
|
// Replace "A1", "$A1", "A$1" segment with proper one.
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (const auto &p : segments) {
|
for (const auto &p : segments) {
|
||||||
//qDebug()<<p.first<<p.second;
|
// qDebug()<<p.first<<p.second;
|
||||||
if (p.second != -1 && p.second != 3) {
|
if (p.second != -1 && p.second != 3) {
|
||||||
CellReference oldRef(p.first);
|
CellReference oldRef(p.first);
|
||||||
int row = p.second & 0x02 ? oldRef.row() : oldRef.row()-rootCell.row()+cell.row();
|
int row = p.second & 0x02 ? oldRef.row() : oldRef.row() - rootCell.row() + cell.row();
|
||||||
int col = p.second & 0x01 ? oldRef.column() : oldRef.column()-rootCell.column()+cell.column();
|
int col = p.second & 0x01 ? oldRef.column()
|
||||||
|
: oldRef.column() - rootCell.column() + cell.column();
|
||||||
result.append(CellReference(row, col).toString(p.second & 0x02, p.second & 0x01));
|
result.append(CellReference(row, col).toString(p.second & 0x02, p.second & 0x01));
|
||||||
} else {
|
} else {
|
||||||
result.append(p.first);
|
result.append(p.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//OK
|
// OK
|
||||||
return result.join(QString());
|
return result.join(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,63 +1,61 @@
|
|||||||
// xlsxworkbook.cpp
|
// xlsxworkbook.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QXmlStreamWriter>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QBuffer>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
#include "xlsxworkbook_p.h"
|
|
||||||
#include "xlsxsharedstrings_p.h"
|
#include "xlsxchart.h"
|
||||||
#include "xlsxworksheet.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
#include "xlsxchartsheet.h"
|
||||||
#include "xlsxstyles_p.h"
|
|
||||||
#include "xlsxformat.h"
|
#include "xlsxformat.h"
|
||||||
#include "xlsxworksheet_p.h"
|
|
||||||
#include "xlsxformat_p.h"
|
#include "xlsxformat_p.h"
|
||||||
#include "xlsxmediafile_p.h"
|
#include "xlsxmediafile_p.h"
|
||||||
|
#include "xlsxsharedstrings_p.h"
|
||||||
|
#include "xlsxstyles_p.h"
|
||||||
#include "xlsxutility_p.h"
|
#include "xlsxutility_p.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxworkbook_p.h"
|
||||||
|
#include "xlsxworksheet.h"
|
||||||
|
#include "xlsxworksheet_p.h"
|
||||||
|
|
||||||
|
#include <QBuffer>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
WorkbookPrivate::WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag) :
|
WorkbookPrivate::WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag)
|
||||||
AbstractOOXmlFilePrivate(q, flag)
|
: AbstractOOXmlFilePrivate(q, flag)
|
||||||
{
|
{
|
||||||
sharedStrings = QSharedPointer<SharedStrings> (new SharedStrings(flag));
|
sharedStrings = QSharedPointer<SharedStrings>(new SharedStrings(flag));
|
||||||
styles = QSharedPointer<Styles>(new Styles(flag));
|
styles = QSharedPointer<Styles>(new Styles(flag));
|
||||||
theme = QSharedPointer<Theme>(new Theme(flag));
|
theme = QSharedPointer<Theme>(new Theme(flag));
|
||||||
|
|
||||||
x_window = 240;
|
x_window = 240;
|
||||||
y_window = 15;
|
y_window = 15;
|
||||||
window_width = 16095;
|
window_width = 16095;
|
||||||
window_height = 9660;
|
window_height = 9660;
|
||||||
|
|
||||||
strings_to_numbers_enabled = false;
|
strings_to_numbers_enabled = false;
|
||||||
strings_to_hyperlinks_enabled = true;
|
strings_to_hyperlinks_enabled = true;
|
||||||
html_to_richstring_enabled = false;
|
html_to_richstring_enabled = false;
|
||||||
date1904 = false;
|
date1904 = false;
|
||||||
defaultDateFormat = QStringLiteral("yyyy-mm-dd");
|
defaultDateFormat = QStringLiteral("yyyy-mm-dd");
|
||||||
activesheetIndex = 0;
|
activesheetIndex = 0;
|
||||||
firstsheet = 0;
|
firstsheet = 0;
|
||||||
table_count = 0;
|
table_count = 0;
|
||||||
|
|
||||||
last_worksheet_index = 0;
|
last_worksheet_index = 0;
|
||||||
last_chartsheet_index = 0;
|
last_chartsheet_index = 0;
|
||||||
last_sheet_id = 0;
|
last_sheet_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Workbook::Workbook(CreateFlag flag)
|
Workbook::Workbook(CreateFlag flag)
|
||||||
: AbstractOOXmlFile(new WorkbookPrivate(this, flag))
|
: AbstractOOXmlFile(new WorkbookPrivate(this, flag))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Workbook::~Workbook()
|
Workbook::~Workbook() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Workbook::isDate1904() const
|
bool Workbook::isDate1904() const
|
||||||
{
|
{
|
||||||
@ -144,18 +142,21 @@ void Workbook::setDefaultDateFormat(const QString &format)
|
|||||||
* \param scope The name of one worksheet, or empty which means golbal scope.
|
* \param scope The name of one worksheet, or empty which means golbal scope.
|
||||||
* \return Return false if the name invalid.
|
* \return Return false if the name invalid.
|
||||||
*/
|
*/
|
||||||
bool Workbook::defineName(const QString &name, const QString &formula, const QString &comment, const QString &scope)
|
bool Workbook::defineName(const QString &name,
|
||||||
|
const QString &formula,
|
||||||
|
const QString &comment,
|
||||||
|
const QString &scope)
|
||||||
{
|
{
|
||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
|
|
||||||
//Remove the = sign from the formula if it exists.
|
// Remove the = sign from the formula if it exists.
|
||||||
QString formulaString = formula;
|
QString formulaString = formula;
|
||||||
if (formulaString.startsWith(QLatin1Char('=')))
|
if (formulaString.startsWith(QLatin1Char('=')))
|
||||||
formulaString = formula.mid(1);
|
formulaString = formula.mid(1);
|
||||||
|
|
||||||
int id=-1;
|
int id = -1;
|
||||||
if (!scope.isEmpty()) {
|
if (!scope.isEmpty()) {
|
||||||
for (int i=0; i<d->sheets.size(); ++i) {
|
for (int i = 0; i < d->sheets.size(); ++i) {
|
||||||
if (d->sheets[i]->sheetName() == scope) {
|
if (d->sheets[i]->sheetName() == scope) {
|
||||||
id = d->sheets[i]->sheetId();
|
id = d->sheets[i]->sheetId();
|
||||||
break;
|
break;
|
||||||
@ -193,18 +194,13 @@ AbstractSheet *Workbook::addSheet(const QString &name, int sheetId, AbstractShee
|
|||||||
d->last_sheet_id = sheetId;
|
d->last_sheet_id = sheetId;
|
||||||
|
|
||||||
AbstractSheet *sheet = NULL;
|
AbstractSheet *sheet = NULL;
|
||||||
if (type == AbstractSheet::ST_WorkSheet)
|
if (type == AbstractSheet::ST_WorkSheet) {
|
||||||
{
|
|
||||||
// create work sheet (value sheet)
|
// create work sheet (value sheet)
|
||||||
sheet = new Worksheet(name, sheetId, this, F_LoadFromExists);
|
sheet = new Worksheet(name, sheetId, this, F_LoadFromExists);
|
||||||
}
|
} else if (type == AbstractSheet::ST_ChartSheet) {
|
||||||
else if (type == AbstractSheet::ST_ChartSheet)
|
|
||||||
{
|
|
||||||
// create chart sheet
|
// create chart sheet
|
||||||
sheet = new Chartsheet(name, sheetId, this, F_LoadFromExists);
|
sheet = new Chartsheet(name, sheetId, this, F_LoadFromExists);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning("unsupported sheet type.");
|
qWarning("unsupported sheet type.");
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
@ -219,12 +215,12 @@ AbstractSheet *Workbook::insertSheet(int index, const QString &name, AbstractShe
|
|||||||
{
|
{
|
||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
QString sheetName = createSafeSheetName(name);
|
QString sheetName = createSafeSheetName(name);
|
||||||
if(index > d->last_sheet_id){
|
if (index > d->last_sheet_id) {
|
||||||
//User tries to insert, where no sheet has gone before.
|
// User tries to insert, where no sheet has gone before.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!sheetName.isEmpty()) {
|
if (!sheetName.isEmpty()) {
|
||||||
//If user given an already in-used name, we should not continue any more!
|
// If user given an already in-used name, we should not continue any more!
|
||||||
if (d->sheetNames.contains(sheetName))
|
if (d->sheetNames.contains(sheetName))
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -247,16 +243,11 @@ AbstractSheet *Workbook::insertSheet(int index, const QString &name, AbstractShe
|
|||||||
++d->last_sheet_id;
|
++d->last_sheet_id;
|
||||||
|
|
||||||
AbstractSheet *sheet = NULL;
|
AbstractSheet *sheet = NULL;
|
||||||
if ( type == AbstractSheet::ST_WorkSheet )
|
if (type == AbstractSheet::ST_WorkSheet) {
|
||||||
{
|
|
||||||
sheet = new Worksheet(sheetName, d->last_sheet_id, this, F_NewFromScratch);
|
sheet = new Worksheet(sheetName, d->last_sheet_id, this, F_NewFromScratch);
|
||||||
}
|
} else if (type == AbstractSheet::ST_ChartSheet) {
|
||||||
else if ( type == AbstractSheet::ST_ChartSheet )
|
|
||||||
{
|
|
||||||
sheet = new Chartsheet(sheetName, d->last_sheet_id, this, F_NewFromScratch);
|
sheet = new Chartsheet(sheetName, d->last_sheet_id, this, F_NewFromScratch);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning("unsupported sheet type.");
|
qWarning("unsupported sheet type.");
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
@ -275,7 +266,7 @@ AbstractSheet *Workbook::activeSheet() const
|
|||||||
{
|
{
|
||||||
Q_D(const Workbook);
|
Q_D(const Workbook);
|
||||||
if (d->sheets.isEmpty())
|
if (d->sheets.isEmpty())
|
||||||
const_cast<Workbook*>(this)->addSheet();
|
const_cast<Workbook *>(this)->addSheet();
|
||||||
return d->sheets[d->activesheetIndex].data();
|
return d->sheets[d->activesheetIndex].data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +274,7 @@ bool Workbook::setActiveSheet(int index)
|
|||||||
{
|
{
|
||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
if (index < 0 || index >= d->sheets.size()) {
|
if (index < 0 || index >= d->sheets.size()) {
|
||||||
//warning
|
// warning
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
d->activesheetIndex = index;
|
d->activesheetIndex = index;
|
||||||
@ -300,8 +291,8 @@ bool Workbook::renameSheet(int index, const QString &newName)
|
|||||||
if (index < 0 || index >= d->sheets.size())
|
if (index < 0 || index >= d->sheets.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//If user given an already in-used name, return false
|
// If user given an already in-used name, return false
|
||||||
for (int i=0; i<d->sheets.size(); ++i) {
|
for (int i = 0; i < d->sheets.size(); ++i) {
|
||||||
if (d->sheets[i]->sheetName() == name)
|
if (d->sheets[i]->sheetName() == name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -358,20 +349,21 @@ bool Workbook::copySheet(int index, const QString &newName)
|
|||||||
|
|
||||||
QString worksheetName = createSafeSheetName(newName);
|
QString worksheetName = createSafeSheetName(newName);
|
||||||
if (!newName.isEmpty()) {
|
if (!newName.isEmpty()) {
|
||||||
//If user given an already in-used name, we should not continue any more!
|
// If user given an already in-used name, we should not continue any more!
|
||||||
if (d->sheetNames.contains(newName))
|
if (d->sheetNames.contains(newName))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
int copy_index = 1;
|
int copy_index = 1;
|
||||||
do {
|
do {
|
||||||
++copy_index;
|
++copy_index;
|
||||||
worksheetName = QStringLiteral("%1(%2)").arg(d->sheets[index]->sheetName()).arg(copy_index);
|
worksheetName =
|
||||||
|
QStringLiteral("%1(%2)").arg(d->sheets[index]->sheetName()).arg(copy_index);
|
||||||
} while (d->sheetNames.contains(worksheetName));
|
} while (d->sheetNames.contains(worksheetName));
|
||||||
}
|
}
|
||||||
|
|
||||||
++d->last_sheet_id;
|
++d->last_sheet_id;
|
||||||
AbstractSheet *sheet = d->sheets[index]->copy(worksheetName, d->last_sheet_id);
|
AbstractSheet *sheet = d->sheets[index]->copy(worksheetName, d->last_sheet_id);
|
||||||
d->sheets.append(QSharedPointer<AbstractSheet> (sheet));
|
d->sheets.append(QSharedPointer<AbstractSheet>(sheet));
|
||||||
d->sheetNames.append(sheet->sheetName());
|
d->sheetNames.append(sheet->sheetName());
|
||||||
|
|
||||||
return true; // #162
|
return true; // #162
|
||||||
@ -424,10 +416,10 @@ QList<Drawing *> Workbook::drawings()
|
|||||||
{
|
{
|
||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
QList<Drawing *> ds;
|
QList<Drawing *> ds;
|
||||||
for (int i=0; i<d->sheets.size(); ++i) {
|
for (int i = 0; i < d->sheets.size(); ++i) {
|
||||||
QSharedPointer<AbstractSheet> sheet = d->sheets[i];
|
QSharedPointer<AbstractSheet> sheet = d->sheets[i];
|
||||||
if (sheet->drawing())
|
if (sheet->drawing())
|
||||||
ds.append(sheet->drawing());
|
ds.append(sheet->drawing());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ds;
|
return ds;
|
||||||
@ -436,11 +428,11 @@ QList<Drawing *> Workbook::drawings()
|
|||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
QList<QSharedPointer<AbstractSheet> > Workbook::getSheetsByTypes(AbstractSheet::SheetType type) const
|
QList<QSharedPointer<AbstractSheet>> Workbook::getSheetsByTypes(AbstractSheet::SheetType type) const
|
||||||
{
|
{
|
||||||
Q_D(const Workbook);
|
Q_D(const Workbook);
|
||||||
QList<QSharedPointer<AbstractSheet> > list;
|
QList<QSharedPointer<AbstractSheet>> list;
|
||||||
for (int i=0; i<d->sheets.size(); ++i) {
|
for (int i = 0; i < d->sheets.size(); ++i) {
|
||||||
if (d->sheets[i]->sheetType() == type)
|
if (d->sheets[i]->sheetType() == type)
|
||||||
list.append(d->sheets[i]);
|
list.append(d->sheets[i]);
|
||||||
}
|
}
|
||||||
@ -458,15 +450,20 @@ void Workbook::saveToXmlFile(QIODevice *device) const
|
|||||||
|
|
||||||
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
writer.writeStartDocument(QStringLiteral("1.0"), true);
|
||||||
writer.writeStartElement(QStringLiteral("workbook"));
|
writer.writeStartElement(QStringLiteral("workbook"));
|
||||||
writer.writeAttribute(QStringLiteral("xmlns"), QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
|
writer.writeAttribute(
|
||||||
writer.writeAttribute(QStringLiteral("xmlns:r"), QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"));
|
QStringLiteral("xmlns"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
|
||||||
|
writer.writeAttribute(
|
||||||
|
QStringLiteral("xmlns:r"),
|
||||||
|
QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"));
|
||||||
|
|
||||||
writer.writeEmptyElement(QStringLiteral("fileVersion"));
|
writer.writeEmptyElement(QStringLiteral("fileVersion"));
|
||||||
writer.writeAttribute(QStringLiteral("appName"), QStringLiteral("xl"));
|
writer.writeAttribute(QStringLiteral("appName"), QStringLiteral("xl"));
|
||||||
writer.writeAttribute(QStringLiteral("lastEdited"), QStringLiteral("4"));
|
writer.writeAttribute(QStringLiteral("lastEdited"), QStringLiteral("4"));
|
||||||
writer.writeAttribute(QStringLiteral("lowestEdited"), QStringLiteral("4"));
|
writer.writeAttribute(QStringLiteral("lowestEdited"), QStringLiteral("4"));
|
||||||
writer.writeAttribute(QStringLiteral("rupBuild"), QStringLiteral("4505"));
|
writer.writeAttribute(QStringLiteral("rupBuild"), QStringLiteral("4505"));
|
||||||
// writer.writeAttribute(QStringLiteral("codeName"), QStringLiteral("{37E998C4-C9E5-D4B9-71C8-EB1FF731991C}"));
|
// writer.writeAttribute(QStringLiteral("codeName"),
|
||||||
|
// QStringLiteral("{37E998C4-C9E5-D4B9-71C8-EB1FF731991C}"));
|
||||||
|
|
||||||
writer.writeEmptyElement(QStringLiteral("workbookPr"));
|
writer.writeEmptyElement(QStringLiteral("workbookPr"));
|
||||||
if (d->date1904)
|
if (d->date1904)
|
||||||
@ -479,19 +476,19 @@ void Workbook::saveToXmlFile(QIODevice *device) const
|
|||||||
writer.writeAttribute(QStringLiteral("yWindow"), QString::number(d->y_window));
|
writer.writeAttribute(QStringLiteral("yWindow"), QString::number(d->y_window));
|
||||||
writer.writeAttribute(QStringLiteral("windowWidth"), QString::number(d->window_width));
|
writer.writeAttribute(QStringLiteral("windowWidth"), QString::number(d->window_width));
|
||||||
writer.writeAttribute(QStringLiteral("windowHeight"), QString::number(d->window_height));
|
writer.writeAttribute(QStringLiteral("windowHeight"), QString::number(d->window_height));
|
||||||
//Store the firstSheet when it isn't the default
|
// Store the firstSheet when it isn't the default
|
||||||
//For example, when "the first sheet 0 is hidden", the first sheet will be 1
|
// For example, when "the first sheet 0 is hidden", the first sheet will be 1
|
||||||
if (d->firstsheet > 0)
|
if (d->firstsheet > 0)
|
||||||
writer.writeAttribute(QStringLiteral("firstSheet"), QString::number(d->firstsheet + 1));
|
writer.writeAttribute(QStringLiteral("firstSheet"), QString::number(d->firstsheet + 1));
|
||||||
//Store the activeTab when it isn't the first sheet
|
// Store the activeTab when it isn't the first sheet
|
||||||
if (d->activesheetIndex > 0)
|
if (d->activesheetIndex > 0)
|
||||||
writer.writeAttribute(QStringLiteral("activeTab"), QString::number(d->activesheetIndex));
|
writer.writeAttribute(QStringLiteral("activeTab"), QString::number(d->activesheetIndex));
|
||||||
writer.writeEndElement();//bookViews
|
writer.writeEndElement(); // bookViews
|
||||||
|
|
||||||
writer.writeStartElement(QStringLiteral("sheets"));
|
writer.writeStartElement(QStringLiteral("sheets"));
|
||||||
int worksheetIndex = 0;
|
int worksheetIndex = 0;
|
||||||
int chartsheetIndex = 0;
|
int chartsheetIndex = 0;
|
||||||
for (int i=0; i<d->sheets.size(); ++i) {
|
for (int i = 0; i < d->sheets.size(); ++i) {
|
||||||
QSharedPointer<AbstractSheet> sheet = d->sheets[i];
|
QSharedPointer<AbstractSheet> sheet = d->sheets[i];
|
||||||
writer.writeEmptyElement(QStringLiteral("sheet"));
|
writer.writeEmptyElement(QStringLiteral("sheet"));
|
||||||
writer.writeAttribute(QStringLiteral("name"), sheet->sheetName());
|
writer.writeAttribute(QStringLiteral("name"), sheet->sheetName());
|
||||||
@ -502,22 +499,30 @@ void Workbook::saveToXmlFile(QIODevice *device) const
|
|||||||
writer.writeAttribute(QStringLiteral("state"), QStringLiteral("veryHidden"));
|
writer.writeAttribute(QStringLiteral("state"), QStringLiteral("veryHidden"));
|
||||||
|
|
||||||
if (sheet->sheetType() == AbstractSheet::ST_WorkSheet)
|
if (sheet->sheetType() == AbstractSheet::ST_WorkSheet)
|
||||||
d->relationships->addDocumentRelationship(QStringLiteral("/worksheet"), QStringLiteral("worksheets/sheet%1.xml").arg(++worksheetIndex));
|
d->relationships->addDocumentRelationship(
|
||||||
|
QStringLiteral("/worksheet"),
|
||||||
|
QStringLiteral("worksheets/sheet%1.xml").arg(++worksheetIndex));
|
||||||
else
|
else
|
||||||
d->relationships->addDocumentRelationship(QStringLiteral("/chartsheet"), QStringLiteral("chartsheets/sheet%1.xml").arg(++chartsheetIndex));
|
d->relationships->addDocumentRelationship(
|
||||||
|
QStringLiteral("/chartsheet"),
|
||||||
|
QStringLiteral("chartsheets/sheet%1.xml").arg(++chartsheetIndex));
|
||||||
|
|
||||||
writer.writeAttribute(QStringLiteral("r:id"), QStringLiteral("rId%1").arg(d->relationships->count()));
|
writer.writeAttribute(QStringLiteral("r:id"),
|
||||||
|
QStringLiteral("rId%1").arg(d->relationships->count()));
|
||||||
}
|
}
|
||||||
writer.writeEndElement();//sheets
|
writer.writeEndElement(); // sheets
|
||||||
|
|
||||||
if (d->externalLinks.size() > 0) {
|
if (d->externalLinks.size() > 0) {
|
||||||
writer.writeStartElement(QStringLiteral("externalReferences"));
|
writer.writeStartElement(QStringLiteral("externalReferences"));
|
||||||
for (int i=0; i<d->externalLinks.size(); ++i) {
|
for (int i = 0; i < d->externalLinks.size(); ++i) {
|
||||||
writer.writeEmptyElement(QStringLiteral("externalReference"));
|
writer.writeEmptyElement(QStringLiteral("externalReference"));
|
||||||
d->relationships->addDocumentRelationship(QStringLiteral("/externalLink"), QStringLiteral("externalLinks/externalLink%1.xml").arg(i+1));
|
d->relationships->addDocumentRelationship(
|
||||||
writer.writeAttribute(QStringLiteral("r:id"), QStringLiteral("rId%1").arg(d->relationships->count()));
|
QStringLiteral("/externalLink"),
|
||||||
|
QStringLiteral("externalLinks/externalLink%1.xml").arg(i + 1));
|
||||||
|
writer.writeAttribute(QStringLiteral("r:id"),
|
||||||
|
QStringLiteral("rId%1").arg(d->relationships->count()));
|
||||||
}
|
}
|
||||||
writer.writeEndElement();//externalReferences
|
writer.writeEndElement(); // externalReferences
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->definedNamesList.isEmpty()) {
|
if (!d->definedNamesList.isEmpty()) {
|
||||||
@ -528,8 +533,8 @@ void Workbook::saveToXmlFile(QIODevice *device) const
|
|||||||
if (!data.comment.isEmpty())
|
if (!data.comment.isEmpty())
|
||||||
writer.writeAttribute(QStringLiteral("comment"), data.comment);
|
writer.writeAttribute(QStringLiteral("comment"), data.comment);
|
||||||
if (data.sheetId != -1) {
|
if (data.sheetId != -1) {
|
||||||
//find the local index of the sheet.
|
// find the local index of the sheet.
|
||||||
for (int i=0; i<d->sheets.size(); ++i) {
|
for (int i = 0; i < d->sheets.size(); ++i) {
|
||||||
if (d->sheets[i]->sheetId() == data.sheetId) {
|
if (d->sheets[i]->sheetId() == data.sheetId) {
|
||||||
writer.writeAttribute(QStringLiteral("localSheetId"), QString::number(i));
|
writer.writeAttribute(QStringLiteral("localSheetId"), QString::number(i));
|
||||||
break;
|
break;
|
||||||
@ -537,22 +542,25 @@ void Workbook::saveToXmlFile(QIODevice *device) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.writeCharacters(data.formula);
|
writer.writeCharacters(data.formula);
|
||||||
writer.writeEndElement();//definedName
|
writer.writeEndElement(); // definedName
|
||||||
}
|
}
|
||||||
writer.writeEndElement();//definedNames
|
writer.writeEndElement(); // definedNames
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeStartElement(QStringLiteral("calcPr"));
|
writer.writeStartElement(QStringLiteral("calcPr"));
|
||||||
writer.writeAttribute(QStringLiteral("calcId"), QStringLiteral("124519"));
|
writer.writeAttribute(QStringLiteral("calcId"), QStringLiteral("124519"));
|
||||||
writer.writeEndElement(); //calcPr
|
writer.writeEndElement(); // calcPr
|
||||||
|
|
||||||
writer.writeEndElement();//workbook
|
writer.writeEndElement(); // workbook
|
||||||
writer.writeEndDocument();
|
writer.writeEndDocument();
|
||||||
|
|
||||||
d->relationships->addDocumentRelationship(QStringLiteral("/theme"), QStringLiteral("theme/theme1.xml"));
|
d->relationships->addDocumentRelationship(QStringLiteral("/theme"),
|
||||||
d->relationships->addDocumentRelationship(QStringLiteral("/styles"), QStringLiteral("styles.xml"));
|
QStringLiteral("theme/theme1.xml"));
|
||||||
|
d->relationships->addDocumentRelationship(QStringLiteral("/styles"),
|
||||||
|
QStringLiteral("styles.xml"));
|
||||||
if (!sharedStrings()->isEmpty())
|
if (!sharedStrings()->isEmpty())
|
||||||
d->relationships->addDocumentRelationship(QStringLiteral("/sharedStrings"), QStringLiteral("sharedStrings.xml"));
|
d->relationships->addDocumentRelationship(QStringLiteral("/sharedStrings"),
|
||||||
|
QStringLiteral("sharedStrings.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Workbook::loadFromXmlFile(QIODevice *device)
|
bool Workbook::loadFromXmlFile(QIODevice *device)
|
||||||
@ -560,79 +568,62 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
|
|||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
|
|
||||||
QXmlStreamReader reader(device);
|
QXmlStreamReader reader(device);
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd()) {
|
||||||
{
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
if (token == QXmlStreamReader::StartElement)
|
if (reader.name() == QLatin1String("sheet")) {
|
||||||
{
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
if (reader.name() == QLatin1String("sheet"))
|
|
||||||
{
|
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
|
||||||
|
|
||||||
const auto& name = attributes.value(QLatin1String("name")).toString();
|
const auto &name = attributes.value(QLatin1String("name")).toString();
|
||||||
|
|
||||||
int sheetId = attributes.value(QLatin1String("sheetId")).toInt();
|
int sheetId = attributes.value(QLatin1String("sheetId")).toInt();
|
||||||
|
|
||||||
const auto& rId = attributes.value(QLatin1String("r:id")).toString();
|
const auto &rId = attributes.value(QLatin1String("r:id")).toString();
|
||||||
|
|
||||||
const auto& stateString = attributes.value(QLatin1String("state"));
|
const auto &stateString = attributes.value(QLatin1String("state"));
|
||||||
|
|
||||||
AbstractSheet::SheetState state = AbstractSheet::SS_Visible;
|
AbstractSheet::SheetState state = AbstractSheet::SS_Visible;
|
||||||
if (stateString == QLatin1String("hidden"))
|
if (stateString == QLatin1String("hidden"))
|
||||||
state = AbstractSheet::SS_Hidden;
|
state = AbstractSheet::SS_Hidden;
|
||||||
else if (stateString == QLatin1String("veryHidden"))
|
else if (stateString == QLatin1String("veryHidden"))
|
||||||
state = AbstractSheet::SS_VeryHidden;
|
state = AbstractSheet::SS_VeryHidden;
|
||||||
|
|
||||||
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
|
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
|
||||||
|
|
||||||
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet;
|
AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet;
|
||||||
if (relationship.type.endsWith(QLatin1String("/worksheet")))
|
if (relationship.type.endsWith(QLatin1String("/worksheet"))) {
|
||||||
{
|
type = AbstractSheet::ST_WorkSheet;
|
||||||
type = AbstractSheet::ST_WorkSheet;
|
} else if (relationship.type.endsWith(QLatin1String("/chartsheet"))) {
|
||||||
}
|
type = AbstractSheet::ST_ChartSheet;
|
||||||
else if (relationship.type.endsWith(QLatin1String("/chartsheet")))
|
} else if (relationship.type.endsWith(QLatin1String("/dialogsheet"))) {
|
||||||
{
|
type = AbstractSheet::ST_DialogSheet;
|
||||||
type = AbstractSheet::ST_ChartSheet;
|
} else if (relationship.type.endsWith(QLatin1String("/xlMacrosheet"))) {
|
||||||
}
|
type = AbstractSheet::ST_MacroSheet;
|
||||||
else if (relationship.type.endsWith(QLatin1String("/dialogsheet")))
|
} else {
|
||||||
{
|
qWarning() << "unknown sheet type : " << relationship.type;
|
||||||
type = AbstractSheet::ST_DialogSheet;
|
}
|
||||||
}
|
|
||||||
else if (relationship.type.endsWith(QLatin1String("/xlMacrosheet")))
|
|
||||||
{
|
|
||||||
type = AbstractSheet::ST_MacroSheet;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << "unknown sheet type : " << relationship.type ;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractSheet *sheet = addSheet(name, sheetId, type);
|
AbstractSheet *sheet = addSheet(name, sheetId, type);
|
||||||
sheet->setSheetState(state);
|
sheet->setSheetState(state);
|
||||||
QString strFilePath = filePath();
|
QString strFilePath = filePath();
|
||||||
|
|
||||||
// const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() + QLatin1String("/") + relationship.target);
|
// const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() +
|
||||||
const auto parts = splitPath(strFilePath);
|
// QLatin1String("/") + relationship.target);
|
||||||
QString fullPath = QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
|
const auto parts = splitPath(strFilePath);
|
||||||
|
QString fullPath =
|
||||||
|
QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
|
||||||
|
|
||||||
sheet->setFilePath(fullPath);
|
sheet->setFilePath(fullPath);
|
||||||
}
|
} else if (reader.name() == QLatin1String("workbookPr")) {
|
||||||
else if (reader.name() == QLatin1String("workbookPr"))
|
|
||||||
{
|
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
if (attrs.hasAttribute(QLatin1String("date1904")))
|
if (attrs.hasAttribute(QLatin1String("date1904")))
|
||||||
d->date1904 = true;
|
d->date1904 = true;
|
||||||
}
|
} else if (reader.name() == QLatin1String("bookviews")) {
|
||||||
else if (reader.name() == QLatin1String("bookviews"))
|
|
||||||
{
|
|
||||||
while (!(reader.name() == QLatin1String("bookviews") &&
|
while (!(reader.name() == QLatin1String("bookviews") &&
|
||||||
reader.tokenType() == QXmlStreamReader::EndElement))
|
reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||||
{
|
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement)
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
{
|
if (reader.name() == QLatin1String("workbookView")) {
|
||||||
if (reader.name() == QLatin1String("workbookView"))
|
|
||||||
{
|
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
if (attrs.hasAttribute(QLatin1String("xWindow")))
|
if (attrs.hasAttribute(QLatin1String("xWindow")))
|
||||||
d->x_window = attrs.value(QLatin1String("xWindow")).toInt();
|
d->x_window = attrs.value(QLatin1String("xWindow")).toInt();
|
||||||
@ -641,44 +632,45 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
|
|||||||
if (attrs.hasAttribute(QLatin1String("windowWidth")))
|
if (attrs.hasAttribute(QLatin1String("windowWidth")))
|
||||||
d->window_width = attrs.value(QLatin1String("windowWidth")).toInt();
|
d->window_width = attrs.value(QLatin1String("windowWidth")).toInt();
|
||||||
if (attrs.hasAttribute(QLatin1String("windowHeight")))
|
if (attrs.hasAttribute(QLatin1String("windowHeight")))
|
||||||
d->window_height = attrs.value(QLatin1String("windowHeight")).toInt();
|
d->window_height =
|
||||||
|
attrs.value(QLatin1String("windowHeight")).toInt();
|
||||||
if (attrs.hasAttribute(QLatin1String("firstSheet")))
|
if (attrs.hasAttribute(QLatin1String("firstSheet")))
|
||||||
d->firstsheet = attrs.value(QLatin1String("firstSheet")).toInt();
|
d->firstsheet = attrs.value(QLatin1String("firstSheet")).toInt();
|
||||||
if (attrs.hasAttribute(QLatin1String("activeTab")))
|
if (attrs.hasAttribute(QLatin1String("activeTab")))
|
||||||
d->activesheetIndex = attrs.value(QLatin1String("activeTab")).toInt();
|
d->activesheetIndex =
|
||||||
|
attrs.value(QLatin1String("activeTab")).toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (reader.name() == QLatin1String("externalReference")) {
|
||||||
else if (reader.name() == QLatin1String("externalReference"))
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
{
|
const QString rId = attributes.value(QLatin1String("r:id")).toString();
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
|
||||||
const QString rId = attributes.value(QLatin1String("r:id")).toString();
|
|
||||||
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
|
|
||||||
|
|
||||||
QSharedPointer<SimpleOOXmlFile> link(new SimpleOOXmlFile(F_LoadFromExists));
|
QSharedPointer<SimpleOOXmlFile> link(new SimpleOOXmlFile(F_LoadFromExists));
|
||||||
|
|
||||||
const auto parts = splitPath(filePath());
|
const auto parts = splitPath(filePath());
|
||||||
QString fullPath = QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
|
QString fullPath =
|
||||||
|
QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
|
||||||
|
|
||||||
link->setFilePath(fullPath);
|
link->setFilePath(fullPath);
|
||||||
d->externalLinks.append(link);
|
d->externalLinks.append(link);
|
||||||
} else if (reader.name() == QLatin1String("definedName")) {
|
} else if (reader.name() == QLatin1String("definedName")) {
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
XlsxDefineNameData data;
|
XlsxDefineNameData data;
|
||||||
|
|
||||||
data.name = attrs.value(QLatin1String("name")).toString();
|
data.name = attrs.value(QLatin1String("name")).toString();
|
||||||
if (attrs.hasAttribute(QLatin1String("comment")))
|
if (attrs.hasAttribute(QLatin1String("comment")))
|
||||||
data.comment = attrs.value(QLatin1String("comment")).toString();
|
data.comment = attrs.value(QLatin1String("comment")).toString();
|
||||||
if (attrs.hasAttribute(QLatin1String("localSheetId"))) {
|
if (attrs.hasAttribute(QLatin1String("localSheetId"))) {
|
||||||
int localId = attrs.value(QLatin1String("localSheetId")).toInt();
|
int localId = attrs.value(QLatin1String("localSheetId")).toInt();
|
||||||
int sheetId = d->sheets.at(localId)->sheetId();
|
int sheetId = d->sheets.at(localId)->sheetId();
|
||||||
data.sheetId = sheetId;
|
data.sheetId = sheetId;
|
||||||
}
|
}
|
||||||
data.formula = reader.readElementText();
|
data.formula = reader.readElementText();
|
||||||
d->definedNamesList.append(data);
|
d->definedNamesList.append(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -686,7 +678,7 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
|
|||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
QList<std::shared_ptr<MediaFile> > Workbook::mediaFiles() const
|
QList<std::shared_ptr<MediaFile>> Workbook::mediaFiles() const
|
||||||
{
|
{
|
||||||
Q_D(const Workbook);
|
Q_D(const Workbook);
|
||||||
|
|
||||||
@ -700,12 +692,9 @@ void Workbook::addMediaFile(std::shared_ptr<MediaFile> media, bool force)
|
|||||||
{
|
{
|
||||||
Q_D(Workbook);
|
Q_D(Workbook);
|
||||||
|
|
||||||
if (!force)
|
if (!force) {
|
||||||
{
|
for (int i = 0; i < d->mediaFiles.size(); ++i) {
|
||||||
for (int i=0; i<d->mediaFiles.size(); ++i)
|
if (d->mediaFiles[i]->hashKey() == media->hashKey()) {
|
||||||
{
|
|
||||||
if (d->mediaFiles[i]->hashKey() == media->hashKey())
|
|
||||||
{
|
|
||||||
media->setIndex(i);
|
media->setIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -719,7 +708,7 @@ void Workbook::addMediaFile(std::shared_ptr<MediaFile> media, bool force)
|
|||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
QList<QSharedPointer<Chart> > Workbook::chartFiles() const
|
QList<QSharedPointer<Chart>> Workbook::chartFiles() const
|
||||||
{
|
{
|
||||||
Q_D(const Workbook);
|
Q_D(const Workbook);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,26 +6,23 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
ZipReader::ZipReader(const QString &filePath) :
|
ZipReader::ZipReader(const QString &filePath)
|
||||||
m_reader(new QZipReader(filePath))
|
: m_reader(new QZipReader(filePath))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipReader::ZipReader(QIODevice *device) :
|
ZipReader::ZipReader(QIODevice *device)
|
||||||
m_reader(new QZipReader(device))
|
: m_reader(new QZipReader(device))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipReader::~ZipReader()
|
ZipReader::~ZipReader() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZipReader::init()
|
void ZipReader::init()
|
||||||
{
|
{
|
||||||
const auto& allFiles = m_reader->fileInfoList();
|
const auto &allFiles = m_reader->fileInfoList();
|
||||||
for (const auto &fi : allFiles) {
|
for (const auto &fi : allFiles) {
|
||||||
if (fi.isFile || (!fi.isDir && !fi.isFile && !fi.isSymLink))
|
if (fi.isFile || (!fi.isDir && !fi.isFile && !fi.isSymLink))
|
||||||
m_filePaths.append(fi.filePath);
|
m_filePaths.append(fi.filePath);
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
#include "xlsxzipwriter_p.h"
|
#include "xlsxzipwriter_p.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <private/qzipwriter_p.h>
|
#include <private/qzipwriter_p.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
ZipWriter::ZipWriter(const QString &filePath)
|
ZipWriter::ZipWriter(const QString &filePath)
|
||||||
|
@ -1,67 +1,63 @@
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QColor>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
|
|
||||||
void printColor(Cell* cell);
|
void printColor(Cell *cell);
|
||||||
void saveColor(Cell* cell);
|
void saveColor(Cell *cell);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
Document xlsxR(":/color.xlsx");
|
Document xlsxR(":/color.xlsx");
|
||||||
if ( !xlsxR.load() )
|
if (!xlsxR.load()) {
|
||||||
{
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printColor( xlsxR.cellAt(1, 1) );
|
printColor(xlsxR.cellAt(1, 1));
|
||||||
printColor( xlsxR.cellAt(1, 2) );
|
printColor(xlsxR.cellAt(1, 2));
|
||||||
printColor( xlsxR.cellAt(2, 1) );
|
printColor(xlsxR.cellAt(2, 1));
|
||||||
printColor( xlsxR.cellAt(2, 2) );
|
printColor(xlsxR.cellAt(2, 2));
|
||||||
|
|
||||||
xlsxR.write( 3, 3, QVariant("HELLO") );
|
xlsxR.write(3, 3, QVariant("HELLO"));
|
||||||
saveColor( xlsxR.cellAt(3, 3) );
|
saveColor(xlsxR.cellAt(3, 3));
|
||||||
|
|
||||||
xlsxR.saveAs("color2.xlsx");
|
xlsxR.saveAs("color2.xlsx");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printColor(Cell* cell)
|
void printColor(Cell *cell)
|
||||||
{
|
{
|
||||||
if ( NULL == cell )
|
if (NULL == cell)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QColor clrForeGround = cell->format().patternForegroundColor();
|
QColor clrForeGround = cell->format().patternForegroundColor();
|
||||||
QColor clrBackGround = cell->format().patternBackgroundColor();
|
QColor clrBackGround = cell->format().patternBackgroundColor();
|
||||||
|
|
||||||
if ( clrForeGround.isValid() &&
|
|
||||||
clrBackGround.isValid() )
|
|
||||||
{
|
|
||||||
qDebug() << "[debug] color : " << clrForeGround << clrBackGround;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (clrForeGround.isValid() && clrBackGround.isValid()) {
|
||||||
|
qDebug() << "[debug] color : " << clrForeGround << clrBackGround;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveColor(Cell* cell)
|
void saveColor(Cell *cell)
|
||||||
{
|
{
|
||||||
|
|
||||||
cell->format().setVerticalAlignment(QXlsx::Format::AlignVCenter);
|
cell->format().setVerticalAlignment(QXlsx::Format::AlignVCenter);
|
||||||
@ -70,6 +66,4 @@ void saveColor(Cell* cell)
|
|||||||
// fmt->setTextWarp(false);
|
// fmt->setTextWarp(false);
|
||||||
cell->format().setPatternBackgroundColor(Qt::blue);
|
cell->format().setPatternBackgroundColor(Qt::blue);
|
||||||
cell->format().setPatternForegroundColor(Qt::white);
|
cell->format().setPatternForegroundColor(Qt::white);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ SOFTWARE.
|
|||||||
#ifndef LIBFORT_H
|
#ifndef LIBFORT_H
|
||||||
#define LIBFORT_H
|
#define LIBFORT_H
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* VERSION
|
* VERSION
|
||||||
@ -49,7 +49,6 @@ SOFTWARE.
|
|||||||
#define LIBFORT_REVISION 6
|
#define LIBFORT_REVISION 6
|
||||||
#define LIBFORT_VERSION_STR "0.1.6"
|
#define LIBFORT_VERSION_STR "0.1.6"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Configuration
|
* Configuration
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -60,24 +59,20 @@ SOFTWARE.
|
|||||||
/** #define FT_CONGIG_HAVE_WCHAR */
|
/** #define FT_CONGIG_HAVE_WCHAR */
|
||||||
|
|
||||||
#if defined(FT_CONGIG_HAVE_WCHAR)
|
#if defined(FT_CONGIG_HAVE_WCHAR)
|
||||||
#define FT_HAVE_WCHAR
|
# define FT_HAVE_WCHAR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* RETURN CODES
|
* RETURN CODES
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef int fort_status_t;
|
typedef int fort_status_t;
|
||||||
#define FT_SUCCESS 0
|
#define FT_SUCCESS 0
|
||||||
#define FT_MEMORY_ERROR -1
|
#define FT_MEMORY_ERROR -1
|
||||||
#define FT_ERROR -2
|
#define FT_ERROR -2
|
||||||
#define FT_EINVAL -3
|
#define FT_EINVAL -3
|
||||||
#define FT_IS_SUCCESS(arg) ((arg) >= 0)
|
#define FT_IS_SUCCESS(arg) ((arg) >= 0)
|
||||||
#define FT_IS_ERROR(arg) ((arg) < 0)
|
#define FT_IS_ERROR(arg) ((arg) < 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cond HELPER_MACROS
|
* @cond HELPER_MACROS
|
||||||
*/
|
*/
|
||||||
@ -87,55 +82,50 @@ typedef int fort_status_t;
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#define FT_CLANG_COMPILER
|
# define FT_CLANG_COMPILER
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#define FT_GCC_COMPILER
|
# define FT_GCC_COMPILER
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define FT_MICROSOFT_COMPILER
|
# define FT_MICROSOFT_COMPILER
|
||||||
#else
|
#else
|
||||||
#define FT_UNDEFINED_COMPILER
|
# define FT_UNDEFINED_COMPILER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Declare inline
|
* Declare inline
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define FT_INLINE inline
|
# define FT_INLINE inline
|
||||||
#else
|
#else
|
||||||
#define FT_INLINE __inline
|
# define FT_INLINE __inline
|
||||||
#endif /* if defined(__cplusplus) */
|
#endif /* if defined(__cplusplus) */
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* C++ needs to know that types and declarations are C, not C++.
|
* C++ needs to know that types and declarations are C, not C++.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# define FT_BEGIN_DECLS extern "C" {
|
# define FT_BEGIN_DECLS extern "C" {
|
||||||
# define FT_END_DECLS }
|
# define FT_END_DECLS }
|
||||||
#else
|
#else
|
||||||
# define FT_BEGIN_DECLS
|
# define FT_BEGIN_DECLS
|
||||||
# define FT_END_DECLS
|
# define FT_END_DECLS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Helper macros
|
* Helper macros
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#define FT_STR_2_CAT_(arg1, arg2) \
|
#define FT_STR_2_CAT_(arg1, arg2) arg1##arg2
|
||||||
arg1##arg2
|
#define FT_STR_2_CAT(arg1, arg2) FT_STR_2_CAT_(arg1, arg2)
|
||||||
#define FT_STR_2_CAT(arg1, arg2) \
|
|
||||||
FT_STR_2_CAT_(arg1, arg2)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interanl
|
* @interanl
|
||||||
*/
|
*/
|
||||||
static FT_INLINE int ft_check_if_string_helper(const char *str)
|
static FT_INLINE int ft_check_if_string_helper(const char *str)
|
||||||
{
|
{
|
||||||
(void)str;
|
(void) str;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,77 +134,107 @@ static FT_INLINE int ft_check_if_string_helper(const char *str)
|
|||||||
*/
|
*/
|
||||||
static FT_INLINE int ft_check_if_wstring_helper(const wchar_t *str)
|
static FT_INLINE int ft_check_if_wstring_helper(const wchar_t *str)
|
||||||
{
|
{
|
||||||
(void)str;
|
(void) str;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FT_NARGS_IMPL_(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,N,...) N
|
#define FT_NARGS_IMPL_(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, N, ...) N
|
||||||
#define FT_EXPAND_(x) x
|
#define FT_EXPAND_(x) x
|
||||||
#define FT_PP_NARG_(...) \
|
#define FT_PP_NARG_(...) \
|
||||||
FT_EXPAND_(FT_NARGS_IMPL_(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0))
|
FT_EXPAND_(FT_NARGS_IMPL_(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
|
||||||
|
|
||||||
#define FT_CHECK_IF_STR_32(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_31(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_32(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_31(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_30(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_31(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_30(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_29(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_31(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_29(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_28(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_30(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_28(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_27(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_30(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_27(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_26(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_29(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_26(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_25(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_29(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_25(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_24(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_28(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_24(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_23(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_28(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_23(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_22(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_27(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_22(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_21(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_27(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_21(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_20(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_26(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_20(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_19(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_26(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_19(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_18(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_25(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_18(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_17(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_25(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_17(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_16(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_24(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_16(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_15(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_24(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_15(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_14(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_23(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_14(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_13(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_23(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_13(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_12(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_22(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_12(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_11(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_22(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_11(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_10(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_21(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_10(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_9(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_21(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_9(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_8(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_20(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_8(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_7(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_20(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_7(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_6(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_19(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_6(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_5(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_19(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_5(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_4(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_18(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_4(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_3(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_18(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_3(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_2(checker,__VA_ARGS__)))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_17(checker, __VA_ARGS__)))
|
||||||
#define FT_CHECK_IF_STR_2(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_1(checker,__VA_ARGS__)))
|
#define FT_CHECK_IF_STR_17(checker, arg, ...) \
|
||||||
#define FT_CHECK_IF_STR_1(checker,arg) (checker(arg))
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_16(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_16(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_15(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_15(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_14(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_14(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_13(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_13(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_12(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_12(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_11(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_11(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_10(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_10(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_9(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_9(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_8(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_8(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_7(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_7(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_6(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_6(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_5(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_5(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_4(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_4(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_3(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_3(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_2(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_2(checker, arg, ...) \
|
||||||
|
(checker(arg), FT_EXPAND_(FT_CHECK_IF_STR_1(checker, __VA_ARGS__)))
|
||||||
|
#define FT_CHECK_IF_STR_1(checker, arg) (checker(arg))
|
||||||
|
|
||||||
#define FT_CHECK_IF_ARGS_ARE_STRINGS__(checker,func, ...) \
|
#define FT_CHECK_IF_ARGS_ARE_STRINGS__(checker, func, ...) FT_EXPAND_(func(checker, __VA_ARGS__))
|
||||||
FT_EXPAND_(func(checker,__VA_ARGS__))
|
#define FT_CHECK_IF_ARGS_ARE_STRINGS_(checker, basis, n, ...) \
|
||||||
#define FT_CHECK_IF_ARGS_ARE_STRINGS_(checker,basis, n, ...) \
|
FT_CHECK_IF_ARGS_ARE_STRINGS__(checker, FT_STR_2_CAT_(basis, n), __VA_ARGS__)
|
||||||
FT_CHECK_IF_ARGS_ARE_STRINGS__(checker,FT_STR_2_CAT_(basis, n), __VA_ARGS__)
|
|
||||||
#define FT_CHECK_IF_ARGS_ARE_STRINGS(...) \
|
#define FT_CHECK_IF_ARGS_ARE_STRINGS(...) \
|
||||||
FT_CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_string_helper,FT_CHECK_IF_STR_,FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)
|
FT_CHECK_IF_ARGS_ARE_STRINGS_( \
|
||||||
|
ft_check_if_string_helper, FT_CHECK_IF_STR_, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
|
||||||
#ifdef FT_HAVE_WCHAR
|
#ifdef FT_HAVE_WCHAR
|
||||||
#define CHECK_IF_ARGS_ARE_WSTRINGS(...) \
|
# define CHECK_IF_ARGS_ARE_WSTRINGS(...) \
|
||||||
FT_CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_wstring_helper,FT_CHECK_IF_STR_,FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)
|
FT_CHECK_IF_ARGS_ARE_STRINGS_( \
|
||||||
|
ft_check_if_wstring_helper, FT_CHECK_IF_STR_, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @endcond
|
* @endcond
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Attribute format for argument checking
|
* Attribute format for argument checking
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
|
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
|
||||||
#define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) \
|
# define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) \
|
||||||
__attribute__ ((format (printf, string_index, first_to_check)))
|
__attribute__((format(printf, string_index, first_to_check)))
|
||||||
#else
|
#else
|
||||||
#define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check)
|
# define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check)
|
||||||
#endif /* defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) */
|
#endif /* defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) */
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* libfort API
|
* libfort API
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -308,8 +328,6 @@ size_t ft_cur_col(ft_table_t *table);
|
|||||||
*/
|
*/
|
||||||
void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col);
|
void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
|
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -375,10 +393,10 @@ int ft_printf_ln(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FO
|
|||||||
int ft_printf_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
|
int ft_printf_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
|
||||||
int ft_printf_ln_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
|
int ft_printf_ln_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
|
||||||
|
|
||||||
#define ft_printf(table, ...) \
|
# define ft_printf(table, ...) \
|
||||||
(( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_impl(table, __VA_ARGS__))
|
((0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_impl(table, __VA_ARGS__))
|
||||||
#define ft_printf_ln(table, ...) \
|
# define ft_printf_ln(table, ...) \
|
||||||
(( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_ln_impl(table, __VA_ARGS__))
|
((0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_ln_impl(table, __VA_ARGS__))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @endcond
|
* @endcond
|
||||||
@ -394,7 +412,6 @@ int ft_printf_ln_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBU
|
|||||||
*/
|
*/
|
||||||
void ft_set_default_printf_field_separator(char separator);
|
void ft_set_default_printf_field_separator(char separator);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write strings to the table.
|
* Write strings to the table.
|
||||||
*
|
*
|
||||||
@ -409,8 +426,9 @@ void ft_set_default_printf_field_separator(char separator);
|
|||||||
* - 0: Success; data were written
|
* - 0: Success; data were written
|
||||||
* - (<0): In case of error
|
* - (<0): In case of error
|
||||||
*/
|
*/
|
||||||
#define ft_write(table, ...)\
|
#define ft_write(table, ...) \
|
||||||
(0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
(0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) \
|
||||||
|
: ft_nwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write strings to the table and go to the next line.
|
* Write strings to the table and go to the next line.
|
||||||
@ -427,8 +445,9 @@ void ft_set_default_printf_field_separator(char separator);
|
|||||||
* - 0: Success; data were written
|
* - 0: Success; data were written
|
||||||
* - (<0): In case of error
|
* - (<0): In case of error
|
||||||
*/
|
*/
|
||||||
#define ft_write_ln(table, ...)\
|
#define ft_write_ln(table, ...) \
|
||||||
(0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
(0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) \
|
||||||
|
: ft_nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write specified number of strings to the table.
|
* Write specified number of strings to the table.
|
||||||
@ -481,10 +500,6 @@ int ft_nwrite(ft_table_t *table, size_t count, const char *cell_content, ...);
|
|||||||
*/
|
*/
|
||||||
int ft_nwrite_ln(ft_table_t *table, size_t count, const char *cell_content, ...);
|
int ft_nwrite_ln(ft_table_t *table, size_t count, const char *cell_content, ...);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write strings from the array to the table.
|
* Write strings from the array to the table.
|
||||||
*
|
*
|
||||||
@ -522,7 +537,6 @@ int ft_row_write(ft_table_t *table, size_t cols, const char *row_cells[]);
|
|||||||
*/
|
*/
|
||||||
int ft_row_write_ln(ft_table_t *table, size_t cols, const char *row_cells[]);
|
int ft_row_write_ln(ft_table_t *table, size_t cols, const char *row_cells[]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write strings from the 2D array to the table.
|
* Write strings from the 2D array to the table.
|
||||||
*
|
*
|
||||||
@ -562,7 +576,6 @@ int ft_table_write(ft_table_t *table, size_t rows, size_t cols, const char *tabl
|
|||||||
*/
|
*/
|
||||||
int ft_table_write_ln(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[]);
|
int ft_table_write_ln(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[]);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add separator after the current row.
|
* Add separator after the current row.
|
||||||
*
|
*
|
||||||
@ -574,7 +587,6 @@ int ft_table_write_ln(ft_table_t *table, size_t rows, size_t cols, const char *t
|
|||||||
*/
|
*/
|
||||||
int ft_add_separator(ft_table_t *table);
|
int ft_add_separator(ft_table_t *table);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert table to string representation.
|
* Convert table to string representation.
|
||||||
*
|
*
|
||||||
@ -594,12 +606,6 @@ int ft_add_separator(ft_table_t *table);
|
|||||||
*/
|
*/
|
||||||
const char *ft_to_string(const ft_table_t *table);
|
const char *ft_to_string(const ft_table_t *table);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure describing border appearance.
|
* Structure describing border appearance.
|
||||||
*/
|
*/
|
||||||
@ -648,8 +654,6 @@ extern const struct ft_border_style *const FT_BOLD2_STYLE;
|
|||||||
extern const struct ft_border_style *const FT_FRAME_STYLE;
|
extern const struct ft_border_style *const FT_FRAME_STYLE;
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default border style for all new formatted tables.
|
* Set default border style for all new formatted tables.
|
||||||
*
|
*
|
||||||
@ -674,61 +678,56 @@ int ft_set_default_border_style(const struct ft_border_style *style);
|
|||||||
*/
|
*/
|
||||||
int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style);
|
int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Special macros to define cell position (row and column).
|
* @name Special macros to define cell position (row and column).
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define FT_ANY_COLUMN (UINT_MAX) /**< Any column (can be used to refer to all cells in a row)*/
|
#define FT_ANY_COLUMN (UINT_MAX) /**< Any column (can be used to refer to all cells in a row)*/
|
||||||
#define FT_CUR_COLUMN (UINT_MAX - 1) /**< Current column */
|
#define FT_CUR_COLUMN (UINT_MAX - 1) /**< Current column */
|
||||||
#define FT_ANY_ROW (UINT_MAX) /**< Any row (can be used to refer to all cells in a column)*/
|
#define FT_ANY_ROW (UINT_MAX) /**< Any row (can be used to refer to all cells in a column)*/
|
||||||
#define FT_CUR_ROW (UINT_MAX - 1) /**< Current row */
|
#define FT_CUR_ROW (UINT_MAX - 1) /**< Current row */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Cell properties identifiers.
|
* @name Cell properties identifiers.
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define FT_CPROP_MIN_WIDTH (0x01U << 0) /**< Minimum width */
|
#define FT_CPROP_MIN_WIDTH (0x01U << 0) /**< Minimum width */
|
||||||
#define FT_CPROP_TEXT_ALIGN (0x01U << 1) /**< Text alignment */
|
#define FT_CPROP_TEXT_ALIGN (0x01U << 1) /**< Text alignment */
|
||||||
#define FT_CPROP_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */
|
#define FT_CPROP_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */
|
||||||
#define FT_CPROP_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */
|
#define FT_CPROP_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */
|
||||||
#define FT_CPROP_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */
|
#define FT_CPROP_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */
|
||||||
#define FT_CPROP_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */
|
#define FT_CPROP_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */
|
||||||
#define FT_CPROP_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */
|
#define FT_CPROP_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */
|
||||||
#define FT_CPROP_ROW_TYPE (0x01U << 7) /**< Row type */
|
#define FT_CPROP_ROW_TYPE (0x01U << 7) /**< Row type */
|
||||||
#define FT_CPROP_CONT_FG_COLOR (0x01U << 8) /**< Cell content foreground text color */
|
#define FT_CPROP_CONT_FG_COLOR (0x01U << 8) /**< Cell content foreground text color */
|
||||||
#define FT_CPROP_CELL_BG_COLOR (0x01U << 9) /**< Cell background color */
|
#define FT_CPROP_CELL_BG_COLOR (0x01U << 9) /**< Cell background color */
|
||||||
#define FT_CPROP_CONT_BG_COLOR (0x01U << 10) /**< Cell content background color */
|
#define FT_CPROP_CONT_BG_COLOR (0x01U << 10) /**< Cell content background color */
|
||||||
#define FT_CPROP_CELL_TEXT_STYLE (0x01U << 11) /**< Cell text style */
|
#define FT_CPROP_CELL_TEXT_STYLE (0x01U << 11) /**< Cell text style */
|
||||||
#define FT_CPROP_CONT_TEXT_STYLE (0x01U << 12) /**< Cell content text style */
|
#define FT_CPROP_CONT_TEXT_STYLE (0x01U << 12) /**< Cell content text style */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colors.
|
* Colors.
|
||||||
*/
|
*/
|
||||||
enum ft_color {
|
enum ft_color {
|
||||||
FT_COLOR_DEFAULT = 0, /**< Default color */
|
FT_COLOR_DEFAULT = 0, /**< Default color */
|
||||||
FT_COLOR_BLACK = 1, /**< Black color*/
|
FT_COLOR_BLACK = 1, /**< Black color*/
|
||||||
FT_COLOR_RED = 2, /**< Red color */
|
FT_COLOR_RED = 2, /**< Red color */
|
||||||
FT_COLOR_GREEN = 3, /**< Green color */
|
FT_COLOR_GREEN = 3, /**< Green color */
|
||||||
FT_COLOR_YELLOW = 4, /**< Yellow color */
|
FT_COLOR_YELLOW = 4, /**< Yellow color */
|
||||||
FT_COLOR_BLUE = 5, /**< Blue color */
|
FT_COLOR_BLUE = 5, /**< Blue color */
|
||||||
FT_COLOR_MAGENTA = 6, /**< Magenta color */
|
FT_COLOR_MAGENTA = 6, /**< Magenta color */
|
||||||
FT_COLOR_CYAN = 7, /**< Cyan color */
|
FT_COLOR_CYAN = 7, /**< Cyan color */
|
||||||
FT_COLOR_LIGHT_GRAY = 8, /**< Light gray color */
|
FT_COLOR_LIGHT_GRAY = 8, /**< Light gray color */
|
||||||
FT_COLOR_DARK_GRAY = 9, /**< Dark gray color */
|
FT_COLOR_DARK_GRAY = 9, /**< Dark gray color */
|
||||||
FT_COLOR_LIGHT_RED = 10, /**< Light red color */
|
FT_COLOR_LIGHT_RED = 10, /**< Light red color */
|
||||||
FT_COLOR_LIGHT_GREEN = 11, /**< Light green color */
|
FT_COLOR_LIGHT_GREEN = 11, /**< Light green color */
|
||||||
FT_COLOR_LIGHT_YELLOW = 12, /**< Light yellow color */
|
FT_COLOR_LIGHT_YELLOW = 12, /**< Light yellow color */
|
||||||
FT_COLOR_LIGHT_BLUE = 13, /**< Light blue color */
|
FT_COLOR_LIGHT_BLUE = 13, /**< Light blue color */
|
||||||
FT_COLOR_LIGHT_MAGENTA = 15, /**< Light magenta color */
|
FT_COLOR_LIGHT_MAGENTA = 15, /**< Light magenta color */
|
||||||
FT_COLOR_LIGHT_CYAN = 16, /**< Light cyan color */
|
FT_COLOR_LIGHT_CYAN = 16, /**< Light cyan color */
|
||||||
FT_COLOR_LIGHT_WHYTE = 17 /**< Light whyte color */
|
FT_COLOR_LIGHT_WHYTE = 17 /**< Light whyte color */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -745,22 +744,21 @@ enum ft_text_style {
|
|||||||
FT_TSTYLE_HIDDEN = (1U << 7) /**< Hidden (useful for passwords) */
|
FT_TSTYLE_HIDDEN = (1U << 7) /**< Hidden (useful for passwords) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alignment of cell content.
|
* Alignment of cell content.
|
||||||
*/
|
*/
|
||||||
enum ft_text_alignment {
|
enum ft_text_alignment {
|
||||||
FT_ALIGNED_LEFT = 0, /**< Align left */
|
FT_ALIGNED_LEFT = 0, /**< Align left */
|
||||||
FT_ALIGNED_CENTER, /**< Align center */
|
FT_ALIGNED_CENTER, /**< Align center */
|
||||||
FT_ALIGNED_RIGHT /**< Align right */
|
FT_ALIGNED_RIGHT /**< Align right */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of table row. Determines appearance of row.
|
* Type of table row. Determines appearance of row.
|
||||||
*/
|
*/
|
||||||
enum ft_row_type {
|
enum ft_row_type {
|
||||||
FT_ROW_COMMON = 0, /**< Common row */
|
FT_ROW_COMMON = 0, /**< Common row */
|
||||||
FT_ROW_HEADER /**< Header row */
|
FT_ROW_HEADER /**< Header row */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -795,19 +793,16 @@ int ft_set_default_cell_prop(uint32_t property, int value);
|
|||||||
*/
|
*/
|
||||||
int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value);
|
int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Table properties identifiers.
|
* @name Table properties identifiers.
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define FT_TPROP_LEFT_MARGIN (0x01U << 0)
|
#define FT_TPROP_LEFT_MARGIN (0x01U << 0)
|
||||||
#define FT_TPROP_TOP_MARGIN (0x01U << 1)
|
#define FT_TPROP_TOP_MARGIN (0x01U << 1)
|
||||||
#define FT_TPROP_RIGHT_MARGIN (0x01U << 2)
|
#define FT_TPROP_RIGHT_MARGIN (0x01U << 2)
|
||||||
#define FT_TPROP_BOTTOM_MARGIN (0x01U << 3)
|
#define FT_TPROP_BOTTOM_MARGIN (0x01U << 3)
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default table property.
|
* Set default table property.
|
||||||
*
|
*
|
||||||
@ -836,7 +831,6 @@ int ft_set_default_tbl_prop(uint32_t property, int value);
|
|||||||
*/
|
*/
|
||||||
int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value);
|
int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set column span for the specified cell of the table.
|
* Set column span for the specified cell of the table.
|
||||||
*
|
*
|
||||||
@ -854,7 +848,6 @@ int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value);
|
|||||||
*/
|
*/
|
||||||
int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span);
|
int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set functions for memory allocation and deallocation to be used instead of
|
* Set functions for memory allocation and deallocation to be used instead of
|
||||||
* standard ones.
|
* standard ones.
|
||||||
@ -871,20 +864,17 @@ int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span)
|
|||||||
*/
|
*/
|
||||||
void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr));
|
void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FT_HAVE_WCHAR
|
#ifdef FT_HAVE_WCHAR
|
||||||
|
|
||||||
|
|
||||||
int ft_wprintf(ft_table_t *table, const wchar_t *fmt, ...);
|
int ft_wprintf(ft_table_t *table, const wchar_t *fmt, ...);
|
||||||
int ft_wprintf_ln(ft_table_t *table, const wchar_t *fmt, ...);
|
int ft_wprintf_ln(ft_table_t *table, const wchar_t *fmt, ...);
|
||||||
|
|
||||||
|
# define ft_wwrite(table, ...) \
|
||||||
#define ft_wwrite(table, ...)\
|
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) \
|
||||||
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
: ft_nwwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
||||||
#define ft_wwrite_ln(table, ...)\
|
# define ft_wwrite_ln(table, ...) \
|
||||||
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) \
|
||||||
|
: ft_nwwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
|
||||||
int ft_nwwrite(ft_table_t *table, size_t n, const wchar_t *cell_content, ...);
|
int ft_nwwrite(ft_table_t *table, size_t n, const wchar_t *cell_content, ...);
|
||||||
int ft_nwwrite_ln(ft_table_t *table, size_t n, const wchar_t *cell_content, ...);
|
int ft_nwwrite_ln(ft_table_t *table, size_t n, const wchar_t *cell_content, ...);
|
||||||
|
|
||||||
@ -897,8 +887,6 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
|
|||||||
const wchar_t *ft_to_wstring(const ft_table_t *table);
|
const wchar_t *ft_to_wstring(const ft_table_t *table);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FT_END_DECLS
|
FT_END_DECLS
|
||||||
|
|
||||||
#endif /* LIBFORT_H */
|
#endif /* LIBFORT_H */
|
||||||
|
@ -3,21 +3,19 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QtCore>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <iostream>
|
#include <QVariant>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// [0] include QXlsx headers
|
// [0] include QXlsx headers
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxrichstring.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
using namespace QXlsx;
|
using namespace QXlsx;
|
||||||
@ -28,8 +26,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
if ( argc != 2 )
|
if (argc != 2) {
|
||||||
{
|
|
||||||
std::cout << "[Usage] ShowConsole *.xlsx" << std::endl;
|
std::cout << "[Usage] ShowConsole *.xlsx" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -39,54 +36,47 @@ int main(int argc, char *argv[])
|
|||||||
qDebug() << xlsxFileName;
|
qDebug() << xlsxFileName;
|
||||||
|
|
||||||
// tried to load xlsx using temporary document
|
// tried to load xlsx using temporary document
|
||||||
QXlsx::Document xlsxTmp( xlsxFileName );
|
QXlsx::Document xlsxTmp(xlsxFileName);
|
||||||
if ( !xlsxTmp.isLoadPackage() )
|
if (!xlsxTmp.isLoadPackage()) {
|
||||||
{
|
|
||||||
qCritical() << "Failed to load" << xlsxFileName;
|
qCritical() << "Failed to load" << xlsxFileName;
|
||||||
return (-1); // failed to load
|
return (-1); // failed to load
|
||||||
}
|
}
|
||||||
|
|
||||||
// load new xlsx using new document
|
// load new xlsx using new document
|
||||||
QXlsx::Document xlsxDoc( xlsxFileName );
|
QXlsx::Document xlsxDoc(xlsxFileName);
|
||||||
xlsxDoc.isLoadPackage();
|
xlsxDoc.isLoadPackage();
|
||||||
|
|
||||||
int sheetIndexNumber = 0;
|
int sheetIndexNumber = 0;
|
||||||
foreach( QString curretnSheetName, xlsxDoc.sheetNames() )
|
foreach (QString curretnSheetName, xlsxDoc.sheetNames()) {
|
||||||
{
|
QXlsx::AbstractSheet *currentSheet = xlsxDoc.sheet(curretnSheetName);
|
||||||
QXlsx::AbstractSheet* currentSheet = xlsxDoc.sheet( curretnSheetName );
|
if (NULL == currentSheet)
|
||||||
if ( NULL == currentSheet )
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// get full cells of sheet
|
// get full cells of sheet
|
||||||
int maxRow = -1;
|
int maxRow = -1;
|
||||||
int maxCol = -1;
|
int maxCol = -1;
|
||||||
currentSheet->workbook()->setActiveSheet( sheetIndexNumber );
|
currentSheet->workbook()->setActiveSheet(sheetIndexNumber);
|
||||||
Worksheet* wsheet = (Worksheet*) currentSheet->workbook()->activeSheet();
|
Worksheet *wsheet = (Worksheet *) currentSheet->workbook()->activeSheet();
|
||||||
if ( NULL == wsheet )
|
if (NULL == wsheet)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString strSheetName = wsheet->sheetName(); // sheet name
|
QString strSheetName = wsheet->sheetName(); // sheet name
|
||||||
|
|
||||||
// display sheet name
|
// display sheet name
|
||||||
std::cout
|
std::cout << std::string(strSheetName.toLocal8Bit()) << std::endl;
|
||||||
<< std::string( strSheetName.toLocal8Bit() )
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
QVector<CellLocation> clList = wsheet->getFullCells( &maxRow, &maxCol );
|
QVector<CellLocation> clList = wsheet->getFullCells(&maxRow, &maxCol);
|
||||||
|
|
||||||
QVector< QVector<QString> > cellValues;
|
QVector<QVector<QString>> cellValues;
|
||||||
for (int rc = 0; rc < maxRow; rc++)
|
for (int rc = 0; rc < maxRow; rc++) {
|
||||||
{
|
|
||||||
QVector<QString> tempValue;
|
QVector<QString> tempValue;
|
||||||
for (int cc = 0; cc < maxCol; cc++)
|
for (int cc = 0; cc < maxCol; cc++) {
|
||||||
{
|
|
||||||
tempValue.push_back(QString(""));
|
tempValue.push_back(QString(""));
|
||||||
}
|
}
|
||||||
cellValues.push_back(tempValue);
|
cellValues.push_back(tempValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int ic = 0; ic < clList.size(); ++ic )
|
for (int ic = 0; ic < clList.size(); ++ic) {
|
||||||
{
|
|
||||||
// cell location
|
// cell location
|
||||||
CellLocation cl = clList.at(ic);
|
CellLocation cl = clList.at(ic);
|
||||||
|
|
||||||
@ -109,12 +99,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
fort::table fortTable;
|
fort::table fortTable;
|
||||||
for (int rc = 0; rc < maxRow; rc++)
|
for (int rc = 0; rc < maxRow; rc++) {
|
||||||
{
|
for (int cc = 0; cc < maxCol; cc++) {
|
||||||
for (int cc = 0; cc < maxCol; cc++)
|
|
||||||
{
|
|
||||||
QString strTemp = cellValues[rc][cc];
|
QString strTemp = cellValues[rc][cc];
|
||||||
fortTable << std::string( strTemp.toLocal8Bit() ); // display value
|
fortTable << std::string(strTemp.toLocal8Bit()); // display value
|
||||||
}
|
}
|
||||||
fortTable << fort::endr; // change to new row
|
fortTable << fort::endr; // change to new row
|
||||||
}
|
}
|
||||||
@ -124,6 +112,5 @@ int main(int argc, char *argv[])
|
|||||||
sheetIndexNumber++;
|
sheetIndexNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
// calendar.cpp
|
// calendar.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include "xlsxcellrange.h"
|
||||||
#include <QtCore>
|
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxformat.h"
|
#include "xlsxformat.h"
|
||||||
#include "xlsxcellrange.h"
|
|
||||||
#include "xlsxworksheet.h"
|
#include "xlsxworksheet.h"
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QXLSX_USE_NAMESPACE
|
QXLSX_USE_NAMESPACE
|
||||||
|
|
||||||
int calendar()
|
int calendar()
|
||||||
{
|
{
|
||||||
Document xlsx;
|
Document xlsx;
|
||||||
QDate today(QDate::currentDate());
|
QDate today(QDate::currentDate());
|
||||||
for (int month=1; month<=12; ++month)
|
for (int month = 1; month <= 12; ++month) {
|
||||||
{
|
|
||||||
xlsx.addSheet(QLocale().monthName(month));
|
xlsx.addSheet(QLocale().monthName(month));
|
||||||
xlsx.currentWorksheet()->setGridLinesVisible(false);
|
xlsx.currentWorksheet()->setGridLinesVisible(false);
|
||||||
|
|
||||||
//the header row
|
// the header row
|
||||||
Format headerStyle;
|
Format headerStyle;
|
||||||
headerStyle.setFontSize(48);
|
headerStyle.setFontSize(48);
|
||||||
headerStyle.setFontColor(Qt::darkBlue);
|
headerStyle.setFontColor(Qt::darkBlue);
|
||||||
@ -29,8 +28,8 @@ int calendar()
|
|||||||
xlsx.write("A1", QString("%1 %2").arg(QLocale().monthName(month)).arg(today.year()));
|
xlsx.write("A1", QString("%1 %2").arg(QLocale().monthName(month)).arg(today.year()));
|
||||||
xlsx.mergeCells("A1:N1", headerStyle);
|
xlsx.mergeCells("A1:N1", headerStyle);
|
||||||
|
|
||||||
//header with month titles
|
// header with month titles
|
||||||
for (int day=1; day<=7; ++day) {
|
for (int day = 1; day <= 7; ++day) {
|
||||||
Format monthStyle;
|
Format monthStyle;
|
||||||
monthStyle.setFontSize(12);
|
monthStyle.setFontSize(12);
|
||||||
monthStyle.setFontColor(Qt::white);
|
monthStyle.setFontColor(Qt::white);
|
||||||
@ -40,10 +39,10 @@ int calendar()
|
|||||||
monthStyle.setFillPattern(Format::PatternSolid);
|
monthStyle.setFillPattern(Format::PatternSolid);
|
||||||
monthStyle.setPatternBackgroundColor(Qt::darkBlue);
|
monthStyle.setPatternBackgroundColor(Qt::darkBlue);
|
||||||
|
|
||||||
xlsx.setColumnWidth(day*2-1, day*2-1, 5);
|
xlsx.setColumnWidth(day * 2 - 1, day * 2 - 1, 5);
|
||||||
xlsx.setColumnWidth(day*2, day*2, 13);
|
xlsx.setColumnWidth(day * 2, day * 2, 13);
|
||||||
xlsx.write(2, day*2-1, QLocale().dayName(day));
|
xlsx.write(2, day * 2 - 1, QLocale().dayName(day));
|
||||||
xlsx.mergeCells(CellRange(2, day*2-1, 2, day*2), monthStyle);
|
xlsx.mergeCells(CellRange(2, day * 2 - 1, 2, day * 2), monthStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor borderColor = QColor(Qt::gray);
|
QColor borderColor = QColor(Qt::gray);
|
||||||
@ -68,25 +67,25 @@ int calendar()
|
|||||||
weekendRightStyle.setBottomBorderStyle(Format::BorderThin);
|
weekendRightStyle.setBottomBorderStyle(Format::BorderThin);
|
||||||
weekendRightStyle.setBottomBorderColor(borderColor);
|
weekendRightStyle.setBottomBorderColor(borderColor);
|
||||||
|
|
||||||
Format holidayLeftStyle;
|
Format holidayLeftStyle;
|
||||||
holidayLeftStyle.setFontSize(14);
|
holidayLeftStyle.setFontSize(14);
|
||||||
holidayLeftStyle.setFontBold(true);
|
holidayLeftStyle.setFontBold(true);
|
||||||
holidayLeftStyle.setHorizontalAlignment(Format::AlignLeft);
|
holidayLeftStyle.setHorizontalAlignment(Format::AlignLeft);
|
||||||
holidayLeftStyle.setVerticalAlignment(Format::AlignTop);
|
holidayLeftStyle.setVerticalAlignment(Format::AlignTop);
|
||||||
holidayLeftStyle.setPatternBackgroundColor(QColor("#EACC93"));
|
holidayLeftStyle.setPatternBackgroundColor(QColor("#EACC93"));
|
||||||
holidayLeftStyle.setLeftBorderStyle(Format::BorderThin);
|
holidayLeftStyle.setLeftBorderStyle(Format::BorderThin);
|
||||||
holidayLeftStyle.setLeftBorderColor(borderColor);
|
holidayLeftStyle.setLeftBorderColor(borderColor);
|
||||||
holidayLeftStyle.setBottomBorderStyle(Format::BorderThin);
|
holidayLeftStyle.setBottomBorderStyle(Format::BorderThin);
|
||||||
holidayLeftStyle.setBottomBorderColor(borderColor);
|
holidayLeftStyle.setBottomBorderColor(borderColor);
|
||||||
|
|
||||||
Format holidayRightStyle;
|
Format holidayRightStyle;
|
||||||
holidayRightStyle.setHorizontalAlignment(Format::AlignHCenter);
|
holidayRightStyle.setHorizontalAlignment(Format::AlignHCenter);
|
||||||
holidayRightStyle.setVerticalAlignment(Format::AlignTop);
|
holidayRightStyle.setVerticalAlignment(Format::AlignTop);
|
||||||
holidayRightStyle.setPatternBackgroundColor(QColor("#EACC93"));
|
holidayRightStyle.setPatternBackgroundColor(QColor("#EACC93"));
|
||||||
holidayRightStyle.setRightBorderStyle(Format::BorderThin);
|
holidayRightStyle.setRightBorderStyle(Format::BorderThin);
|
||||||
holidayRightStyle.setRightBorderColor(borderColor);
|
holidayRightStyle.setRightBorderColor(borderColor);
|
||||||
holidayRightStyle.setBottomBorderStyle(Format::BorderThin);
|
holidayRightStyle.setBottomBorderStyle(Format::BorderThin);
|
||||||
holidayRightStyle.setBottomBorderColor(borderColor);
|
holidayRightStyle.setBottomBorderColor(borderColor);
|
||||||
|
|
||||||
Format workdayLeftStyle;
|
Format workdayLeftStyle;
|
||||||
workdayLeftStyle.setHorizontalAlignment(Format::AlignLeft);
|
workdayLeftStyle.setHorizontalAlignment(Format::AlignLeft);
|
||||||
@ -121,46 +120,45 @@ int calendar()
|
|||||||
greyRightStyle.setBottomBorderColor(borderColor);
|
greyRightStyle.setBottomBorderColor(borderColor);
|
||||||
|
|
||||||
int rownum = 3;
|
int rownum = 3;
|
||||||
for (int day=1; day<=31; ++day) {
|
for (int day = 1; day <= 31; ++day) {
|
||||||
QDate date(today.year(), month, day);
|
QDate date(today.year(), month, day);
|
||||||
if (!date.isValid())
|
if (!date.isValid())
|
||||||
break;
|
break;
|
||||||
xlsx.setRowHeight(rownum, 100);
|
xlsx.setRowHeight(rownum, 100);
|
||||||
int dow = date.dayOfWeek(); // 1 = Monday to 7 = Sunday
|
int dow = date.dayOfWeek(); // 1 = Monday to 7 = Sunday
|
||||||
int colnum = dow*2-1;
|
int colnum = dow * 2 - 1;
|
||||||
|
|
||||||
if (dow <= 5) { // 1,2,3,4,5
|
if (dow <= 5) { // 1,2,3,4,5
|
||||||
xlsx.write(rownum, colnum, day, workdayLeftStyle);
|
xlsx.write(rownum, colnum, day, workdayLeftStyle);
|
||||||
xlsx.write(rownum, colnum+1, QVariant(), workdayRightStyle);
|
xlsx.write(rownum, colnum + 1, QVariant(), workdayRightStyle);
|
||||||
} else if (dow == 6) {
|
} else if (dow == 6) {
|
||||||
xlsx.write(rownum, colnum, day, weekendLeftStyle);
|
xlsx.write(rownum, colnum, day, weekendLeftStyle);
|
||||||
xlsx.write(rownum, colnum+1, QVariant(), weekendRightStyle);
|
xlsx.write(rownum, colnum + 1, QVariant(), weekendRightStyle);
|
||||||
} else {
|
} else {
|
||||||
xlsx.write(rownum, colnum, day, holidayLeftStyle);
|
xlsx.write(rownum, colnum, day, holidayLeftStyle);
|
||||||
xlsx.write(rownum, colnum + 1, QVariant(), holidayRightStyle);
|
xlsx.write(rownum, colnum + 1, QVariant(), holidayRightStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (day == 1 && dow != 1) {//First day
|
if (day == 1 && dow != 1) { // First day
|
||||||
for (int i=1; i<dow; ++i) {
|
for (int i = 1; i < dow; ++i) {
|
||||||
xlsx.write(rownum, i*2-1, QVariant(), greyLeftStyle);
|
xlsx.write(rownum, i * 2 - 1, QVariant(), greyLeftStyle);
|
||||||
xlsx.write(rownum, i*2, QVariant(), greyRightStyle);
|
xlsx.write(rownum, i * 2, QVariant(), greyRightStyle);
|
||||||
}
|
}
|
||||||
} else if (day == date.daysInMonth() && dow != 7) {//Last day
|
} else if (day == date.daysInMonth() && dow != 7) { // Last day
|
||||||
for (int i=dow+1; i<=7; ++i) {
|
for (int i = dow + 1; i <= 7; ++i) {
|
||||||
xlsx.write(rownum, i*2-1, QVariant(), greyLeftStyle);
|
xlsx.write(rownum, i * 2 - 1, QVariant(), greyLeftStyle);
|
||||||
xlsx.write(rownum, i*2, QVariant(), greyRightStyle);
|
xlsx.write(rownum, i * 2, QVariant(), greyRightStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dow == 7)
|
if (dow == 7)
|
||||||
rownum++;
|
rownum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xlsx.saveAs("calendar1.xlsx");
|
xlsx.saveAs("calendar1.xlsx");
|
||||||
|
|
||||||
//Make sure that read/write works well.
|
// Make sure that read/write works well.
|
||||||
Document xlsx2("calendar1.xlsx");
|
Document xlsx2("calendar1.xlsx");
|
||||||
xlsx2.saveAs("calendar2.xlsx");
|
xlsx2.saveAs("calendar2.xlsx");
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// chart.cpp
|
// chart.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QXLSX_USE_NAMESPACE
|
QXLSX_USE_NAMESPACE
|
||||||
|
|
||||||
@ -14,11 +14,10 @@ int chart()
|
|||||||
{
|
{
|
||||||
//![0]
|
//![0]
|
||||||
Document xlsx;
|
Document xlsx;
|
||||||
for (int i=1; i<10; ++i)
|
for (int i = 1; i < 10; ++i) {
|
||||||
{
|
xlsx.write(i, 1, i * i * i); // A1:A9
|
||||||
xlsx.write(i, 1, i*i*i); //A1:A9
|
xlsx.write(i, 2, i * i); // B1:B9
|
||||||
xlsx.write(i, 2, i*i); //B1:B9
|
xlsx.write(i, 3, i * i - 1); // C1:C9
|
||||||
xlsx.write(i, 3, i*i-1); //C1:C9
|
|
||||||
}
|
}
|
||||||
//![0]
|
//![0]
|
||||||
|
|
||||||
@ -62,14 +61,14 @@ int chart()
|
|||||||
|
|
||||||
Chart *scatterChart = xlsx.insertChart(83, 3, QSize(300, 300));
|
Chart *scatterChart = xlsx.insertChart(83, 3, QSize(300, 300));
|
||||||
scatterChart->setChartType(Chart::CT_ScatterChart);
|
scatterChart->setChartType(Chart::CT_ScatterChart);
|
||||||
//Will generate three lines.
|
// Will generate three lines.
|
||||||
scatterChart->addSeries(CellRange("A1:A9"));
|
scatterChart->addSeries(CellRange("A1:A9"));
|
||||||
scatterChart->addSeries(CellRange("B1:B9"));
|
scatterChart->addSeries(CellRange("B1:B9"));
|
||||||
scatterChart->addSeries(CellRange("C1:C9"));
|
scatterChart->addSeries(CellRange("C1:C9"));
|
||||||
|
|
||||||
Chart *scatterChart_2 = xlsx.insertChart(83, 9, QSize(300, 300));
|
Chart *scatterChart_2 = xlsx.insertChart(83, 9, QSize(300, 300));
|
||||||
scatterChart_2->setChartType(Chart::CT_ScatterChart);
|
scatterChart_2->setChartType(Chart::CT_ScatterChart);
|
||||||
//Will generate two lines.
|
// Will generate two lines.
|
||||||
scatterChart_2->addSeries(CellRange("A1:C9"));
|
scatterChart_2->addSeries(CellRange("A1:C9"));
|
||||||
|
|
||||||
Chart *doughnutChart = xlsx.insertChart(103, 3, QSize(300, 300));
|
Chart *doughnutChart = xlsx.insertChart(103, 3, QSize(300, 300));
|
||||||
@ -82,8 +81,7 @@ int chart()
|
|||||||
//![2]
|
//![2]
|
||||||
|
|
||||||
Document xlsx2("chart1.xlsx");
|
Document xlsx2("chart1.xlsx");
|
||||||
if ( xlsx2.load() )
|
if (xlsx2.load()) {
|
||||||
{
|
|
||||||
xlsx2.saveAs("chart2.xlsx");
|
xlsx2.saveAs("chart2.xlsx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// chartextended.cpp
|
// chartextended.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QXLSX_USE_NAMESPACE
|
QXLSX_USE_NAMESPACE
|
||||||
|
|
||||||
@ -18,27 +18,24 @@ QXLSX_USE_NAMESPACE
|
|||||||
int chartExtended()
|
int chartExtended()
|
||||||
{
|
{
|
||||||
Document xlsx;
|
Document xlsx;
|
||||||
for (int i=1; i<10; ++i)
|
for (int i = 1; i < 10; ++i) {
|
||||||
{
|
xlsx.write(1, i + 1, "Pos " + QString::number(i));
|
||||||
xlsx.write(1, i+1, "Pos " + QString::number(i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xlsx.write(2, 1, "Set 1");
|
xlsx.write(2, 1, "Set 1");
|
||||||
xlsx.write(3, 1, "Set 2");
|
xlsx.write(3, 1, "Set 2");
|
||||||
|
|
||||||
for (int i=1; i<10; ++i)
|
for (int i = 1; i < 10; ++i) {
|
||||||
{
|
xlsx.write(2, i + 1, i * i * i); // A2:A10
|
||||||
xlsx.write(2, i+1, i*i*i); //A2:A10
|
xlsx.write(3, i + 1, i * i); // B2:B10
|
||||||
xlsx.write(3, i+1, i*i); //B2:B10
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Chart *barChart1 = xlsx.insertChart(4, 3, QSize(300, 300));
|
Chart *barChart1 = xlsx.insertChart(4, 3, QSize(300, 300));
|
||||||
barChart1->setChartType(Chart::CT_BarChart);
|
barChart1->setChartType(Chart::CT_BarChart);
|
||||||
barChart1->setChartLegend(Chart::Right);
|
barChart1->setChartLegend(Chart::Right);
|
||||||
barChart1->setChartTitle("Test1");
|
barChart1->setChartTitle("Test1");
|
||||||
// Messreihen
|
// Messreihen
|
||||||
barChart1->addSeries(CellRange(1,1,3,10), NULL, true, true, false);
|
barChart1->addSeries(CellRange(1, 1, 3, 10), NULL, true, true, false);
|
||||||
|
|
||||||
Chart *barChart2 = xlsx.insertChart(4, 9, QSize(300, 300));
|
Chart *barChart2 = xlsx.insertChart(4, 9, QSize(300, 300));
|
||||||
barChart2->setChartType(Chart::CT_BarChart);
|
barChart2->setChartType(Chart::CT_BarChart);
|
||||||
@ -46,37 +43,35 @@ int chartExtended()
|
|||||||
barChart2->setChartTitle("Test2");
|
barChart2->setChartTitle("Test2");
|
||||||
barChart2->setGridlinesEnable(true);
|
barChart2->setGridlinesEnable(true);
|
||||||
// Messreihen
|
// Messreihen
|
||||||
barChart2->addSeries(CellRange(1,1,3,10), NULL, true, true, true);
|
barChart2->addSeries(CellRange(1, 1, 3, 10), NULL, true, true, true);
|
||||||
|
|
||||||
Chart *barChart3 = xlsx.insertChart(24, 3, QSize(300, 300));
|
Chart *barChart3 = xlsx.insertChart(24, 3, QSize(300, 300));
|
||||||
barChart3->setChartType(Chart::CT_BarChart);
|
barChart3->setChartType(Chart::CT_BarChart);
|
||||||
barChart3->setChartLegend(Chart::Left);
|
barChart3->setChartLegend(Chart::Left);
|
||||||
barChart3->setChartTitle("Test3");
|
barChart3->setChartTitle("Test3");
|
||||||
// Messreihen
|
// Messreihen
|
||||||
barChart3->addSeries(CellRange(1,1,3,10));
|
barChart3->addSeries(CellRange(1, 1, 3, 10));
|
||||||
|
|
||||||
Chart *barChart4 = xlsx.insertChart(24, 9, QSize(300, 300));
|
Chart *barChart4 = xlsx.insertChart(24, 9, QSize(300, 300));
|
||||||
barChart4->setChartType(Chart::CT_BarChart);
|
barChart4->setChartType(Chart::CT_BarChart);
|
||||||
barChart4->setChartLegend(Chart::Top);
|
barChart4->setChartLegend(Chart::Top);
|
||||||
barChart4->setChartTitle("Test4");
|
barChart4->setChartTitle("Test4");
|
||||||
// Messreihen
|
// Messreihen
|
||||||
barChart4->addSeries(CellRange(1,1,3,10));
|
barChart4->addSeries(CellRange(1, 1, 3, 10));
|
||||||
|
|
||||||
Chart *barChart5 = xlsx.insertChart(44, 9, QSize(300, 300));
|
Chart *barChart5 = xlsx.insertChart(44, 9, QSize(300, 300));
|
||||||
barChart5->setChartType(Chart::CT_BarChart);
|
barChart5->setChartType(Chart::CT_BarChart);
|
||||||
barChart5->setChartLegend(Chart::Bottom);
|
barChart5->setChartLegend(Chart::Bottom);
|
||||||
barChart5->setChartTitle("Test5");
|
barChart5->setChartTitle("Test5");
|
||||||
// Messreihen
|
// Messreihen
|
||||||
barChart5->addSeries(CellRange(1,1,3,10));
|
barChart5->addSeries(CellRange(1, 1, 3, 10));
|
||||||
|
|
||||||
|
|
||||||
//![2]
|
//![2]
|
||||||
xlsx.saveAs("chartExtended1.xlsx");
|
xlsx.saveAs("chartExtended1.xlsx");
|
||||||
//![2]
|
//![2]
|
||||||
|
|
||||||
Document xlsx2("chartExtended1.xlsx");
|
Document xlsx2("chartExtended1.xlsx");
|
||||||
if ( xlsx2.load() )
|
if (xlsx2.load()) {
|
||||||
{
|
|
||||||
xlsx2.saveAs("chartExtended2.xlsx");
|
xlsx2.saveAs("chartExtended2.xlsx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// chartsheet.cpp
|
// chartsheet.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxchartsheet.h"
|
|
||||||
#include "xlsxcellrange.h"
|
#include "xlsxcellrange.h"
|
||||||
#include "xlsxchart.h"
|
#include "xlsxchart.h"
|
||||||
|
#include "xlsxchartsheet.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QXLSX_USE_NAMESPACE
|
QXLSX_USE_NAMESPACE
|
||||||
|
|
||||||
@ -13,16 +13,15 @@ int chartsheet()
|
|||||||
{
|
{
|
||||||
//![0]
|
//![0]
|
||||||
Document xlsx;
|
Document xlsx;
|
||||||
for (int i=1; i<10; ++i)
|
for (int i = 1; i < 10; ++i) {
|
||||||
{
|
xlsx.write(i, 1, i * i);
|
||||||
xlsx.write(i, 1, i*i);
|
|
||||||
}
|
}
|
||||||
//![0]
|
//![0]
|
||||||
|
|
||||||
//![1]
|
//![1]
|
||||||
xlsx.addSheet("Chart1", AbstractSheet::ST_ChartSheet);
|
xlsx.addSheet("Chart1", AbstractSheet::ST_ChartSheet);
|
||||||
Chartsheet *sheet = static_cast<Chartsheet*>(xlsx.currentSheet());
|
Chartsheet *sheet = static_cast<Chartsheet *>(xlsx.currentSheet());
|
||||||
Chart *barChart = sheet->chart();
|
Chart *barChart = sheet->chart();
|
||||||
barChart->setChartType(Chart::CT_BarChart);
|
barChart->setChartType(Chart::CT_BarChart);
|
||||||
barChart->addSeries(CellRange("A1:A9"), xlsx.sheet("Sheet1"));
|
barChart->addSeries(CellRange("A1:A9"), xlsx.sheet("Sheet1"));
|
||||||
//![1]
|
//![1]
|
||||||
@ -32,8 +31,7 @@ int chartsheet()
|
|||||||
//![2]
|
//![2]
|
||||||
|
|
||||||
Document xlsx2("chartsheet1.xlsx");
|
Document xlsx2("chartsheet1.xlsx");
|
||||||
if ( xlsx2.load() )
|
if (xlsx2.load()) {
|
||||||
{
|
|
||||||
xlsx2.saveAs("chartsheet2.xlsx");
|
xlsx2.saveAs("chartsheet2.xlsx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// datavalidation.cpp
|
// datavalidation.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
|
||||||
#include "xlsxdatavalidation.h"
|
#include "xlsxdatavalidation.h"
|
||||||
|
#include "xlsxdocument.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QXLSX_USE_NAMESPACE
|
QXLSX_USE_NAMESPACE
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ int datavalidation()
|
|||||||
xlsx.addDataValidation(validation);
|
xlsx.addDataValidation(validation);
|
||||||
//![1]
|
//![1]
|
||||||
|
|
||||||
xlsx.saveAs("datavalidation.xlsx");
|
xlsx.saveAs("datavalidation.xlsx");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
// definename.cpp
|
// definename.cpp
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "xlsxdocument.h"
|
#include "xlsxdocument.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
QXLSX_USE_NAMESPACE
|
QXLSX_USE_NAMESPACE
|
||||||
|
|
||||||
int definename()
|
int definename()
|
||||||
{
|
{
|
||||||
//![0]
|
//![0]
|
||||||
Document xlsx;
|
Document xlsx;
|
||||||
for (int i=1; i<=10; ++i) {
|
for (int i = 1; i <= 10; ++i) {
|
||||||
xlsx.write(i, 1, i);
|
xlsx.write(i, 1, i);
|
||||||
xlsx.write(i, 2, i*i);
|
xlsx.write(i, 2, i * i);
|
||||||
xlsx.write(i, 3, i*i*i);
|
xlsx.write(i, 3, i * i * i);
|
||||||
}
|
}
|
||||||
//![0]
|
//![0]
|
||||||
|
|
||||||
@ -38,8 +38,7 @@ int definename()
|
|||||||
xlsx.saveAs("definename1.xlsx");
|
xlsx.saveAs("definename1.xlsx");
|
||||||
|
|
||||||
Document xlsx2("definename1.xlsx");
|
Document xlsx2("definename1.xlsx");
|
||||||
if ( xlsx2.load() )
|
if (xlsx2.load()) {
|
||||||
{
|
|
||||||
xlsx2.saveAs("definename2.xlsx");
|
xlsx2.saveAs("definename2.xlsx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user