1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-01-16 04:42:53 +08:00

Return std::shared_ptr for Cell

This commit is contained in:
Daniel Nicoletti 2024-09-02 17:11:10 -03:00
parent 81284da693
commit 35c6d274cb
17 changed files with 165 additions and 164 deletions

View File

@ -81,8 +81,8 @@ public:
bool addDataValidation(const DataValidation &validation);
bool addConditionalFormatting(const ConditionalFormatting &cf);
Cell *cellAt(const CellReference &cell) const;
Cell *cellAt(int row, int col) const;
std::shared_ptr<Cell> cellAt(const CellReference &cell) const;
std::shared_ptr<Cell> cellAt(int row, int col) const;
bool defineName(const QString &name,
const QString &formula,

View File

@ -32,7 +32,7 @@ public:
QString packageName; // name of the .xlsx file
QMap<QString, QString> documentProperties; // core, app and custom properties
QSharedPointer<Workbook> workbook;
std::shared_ptr<Workbook> workbook;
std::shared_ptr<ContentTypes> contentTypes;
bool isLoad;
};

View File

@ -8,7 +8,6 @@
#include <memory>
#include <QPoint>
#include <QSharedPointer>
#include <QSize>
#include <QString>
#include <QXmlStreamReader>
@ -49,7 +48,7 @@ public:
void setObjectPicture(const QImage &img);
bool getObjectPicture(QImage &img);
void setObjectGraphicFrame(QSharedPointer<Chart> chart);
void setObjectGraphicFrame(std::shared_ptr<QXlsx::Chart> chart);
virtual bool loadFromXml(QXmlStreamReader &reader) = 0;
virtual void saveToXml(QXmlStreamWriter &writer) const = 0;
@ -83,7 +82,7 @@ protected:
Drawing *m_drawing;
ObjectType m_objectType;
std::shared_ptr<MediaFile> m_pictureFile;
QSharedPointer<Chart> m_chartFile;
std::shared_ptr<Chart> m_chartFile;
int m_id;

View File

@ -36,11 +36,12 @@
// We mean it.
//
#include <memory>
#include <QHash>
#include <QIODevice>
#include <QList>
#include <QMap>
#include <QSharedPointer>
#include <QStringList>
#include <QVector>
#include <QXmlStreamReader>
@ -124,8 +125,8 @@ private:
bool readCellStyleXfs(QXmlStreamReader &reader);
QHash<QString, int> m_builtinNumFmtsHash;
QMap<int, QSharedPointer<XlsxFormatNumberData>> m_customNumFmtIdMap;
QHash<QString, QSharedPointer<XlsxFormatNumberData>> m_customNumFmtsHash;
QMap<int, std::shared_ptr<XlsxFormatNumberData>> m_customNumFmtIdMap;
QHash<QString, std::shared_ptr<XlsxFormatNumberData>> m_customNumFmtsHash;
int m_nextCustomNumFmtId;
QList<Format> m_fontsList;
QList<Format> m_fillsList;

View File

@ -12,7 +12,6 @@
#include <QIODevice>
#include <QImage>
#include <QList>
#include <QSharedPointer>
QT_BEGIN_NAMESPACE_XLSX
@ -70,8 +69,8 @@ public:
// internal used member
void addMediaFile(std::shared_ptr<MediaFile> media, bool force = false);
QList<std::shared_ptr<MediaFile>> mediaFiles() const;
void addChartFile(QSharedPointer<Chart> chartFile);
QList<QSharedPointer<Chart>> chartFiles() const;
void addChartFile(std::shared_ptr<Chart> chartFile);
QList<std::shared_ptr<Chart>> chartFiles() const;
private:
friend class Worksheet;
@ -90,7 +89,7 @@ private:
Theme *theme();
QList<QImage> images();
QList<Drawing *> drawings();
QList<QSharedPointer<AbstractSheet>> getSheetsByTypes(AbstractSheet::SheetType type) const;
QList<std::shared_ptr<AbstractSheet>> getSheetsByTypes(AbstractSheet::SheetType type) const;
QStringList worksheetNames() const;
AbstractSheet *addSheet(const QString &name,
int sheetId,

View File

@ -9,7 +9,6 @@
#include "xlsxtheme_p.h"
#include "xlsxworkbook.h"
#include <QSharedPointer>
#include <QStringList>
QT_BEGIN_NAMESPACE_XLSX
@ -42,14 +41,14 @@ class WorkbookPrivate : public AbstractOOXmlFilePrivate
public:
WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag);
QSharedPointer<SharedStrings> sharedStrings;
QList<QSharedPointer<AbstractSheet>> sheets;
QList<QSharedPointer<SimpleOOXmlFile>> externalLinks;
std::shared_ptr<SharedStrings> sharedStrings;
QList<std::shared_ptr<AbstractSheet>> sheets;
QList<std::shared_ptr<SimpleOOXmlFile>> externalLinks;
QStringList sheetNames;
QSharedPointer<Styles> styles;
QSharedPointer<Theme> theme;
std::shared_ptr<Styles> styles;
std::shared_ptr<Theme> theme;
QList<std::shared_ptr<MediaFile>> mediaFiles;
QList<QSharedPointer<Chart>> chartFiles;
QList<std::shared_ptr<Chart>> chartFiles;
QList<XlsxDefineNameData> definedNamesList;
bool strings_to_numbers_enabled;

View File

@ -126,8 +126,8 @@ public:
bool addDataValidation(const DataValidation &validation);
bool addConditionalFormatting(const ConditionalFormatting &cf);
Cell *cellAt(const CellReference &row_column) const;
Cell *cellAt(int row, int column) const;
std::shared_ptr<Cell> cellAt(const CellReference &row_column) const;
std::shared_ptr<Cell> cellAt(int row, int column) const;
int insertImage(int row, int column, const QImage &image);
bool getImage(int imageIndex, QImage &img);

View File

@ -10,13 +10,12 @@
#include "xlsxdatavalidation.h"
#include "xlsxworksheet.h"
#include <QHash>
#include <QImage>
#include <QObject>
#include <QRegularExpression>
#include <QSharedPointer>
#include <QString>
#include <QVector>
#include <QHash>
class QXmlStreamWriter;
class QXmlStreamReader;
@ -136,30 +135,35 @@ struct XlsxColumnInfo {
class CellTable
{
public:
static QList<int> sorteIntList(QList<int> &&keys) {
static QList<int> sorteIntList(QList<int> &&keys)
{
std::sort(keys.begin(), keys.end());
return keys;
}
inline QList<int> sortedRows() const {
inline QList<int> sortedRows() const
{
QList<int> keys = cells.keys();
std::sort(keys.begin(), keys.end());
return keys;
}
void setValue(int row, int column, const std::shared_ptr<Cell> &cell) {
void setValue(int row, int column, const std::shared_ptr<Cell> &cell)
{
cells[row].insert(column, cell);
firstRow = qMin(firstRow, row);
firstRow = qMin(firstRow, row);
firstColumn = qMin(firstColumn, column);
lastRow = qMin(lastRow, row);
lastColumn = qMin(lastColumn, column);
lastRow = qMin(lastRow, row);
lastColumn = qMin(lastColumn, column);
}
std::shared_ptr<Cell> cellAt(int row, int column) const{
std::shared_ptr<Cell> cellAt(int row, int column) const
{
return cells.value(row).value(column);
}
bool contains(int row, int column) const{
bool contains(int row, int column) const
{
auto it = cells.find(row);
if (it != cells.end()) {
return it->contains(column);
@ -167,17 +171,15 @@ public:
return false;
}
bool isEmpty() const {
return cells.isEmpty();
}
bool isEmpty() const { return cells.isEmpty(); }
// It's faster with a single QHash, but in Qt5 it's capacity limits
// how much cells we can hold
QHash<int, QHash<int, std::shared_ptr<Cell>>> cells;
int firstRow = -1;
int firstRow = -1;
int firstColumn = -1;
int lastRow = -1;
int lastColumn = -1;
int lastRow = -1;
int lastColumn = -1;
};
class WorksheetPrivate : public AbstractSheetPrivate
@ -217,8 +219,8 @@ public:
void loadXmlSheetViews(QXmlStreamReader &reader);
void loadXmlHyperlinks(QXmlStreamReader &reader);
QList<QSharedPointer<XlsxRowInfo>> getRowInfoList(int rowFirst, int rowLast);
QList<QSharedPointer<XlsxColumnInfo>> getColumnInfoList(int colFirst, int colLast);
QList<std::shared_ptr<XlsxRowInfo>> getRowInfoList(int rowFirst, int rowLast);
QList<std::shared_ptr<XlsxColumnInfo>> getColumnInfoList(int colFirst, int colLast);
QList<int> getColumnIndexes(int colFirst, int colLast);
bool isColumnRangeValid(int colFirst, int colLast);
@ -228,11 +230,11 @@ public:
CellTable cellTable;
QHash<int, QHash<int, QString>> comments;
QHash<int, QHash<int, QSharedPointer<XlsxHyperlinkData>>> urlTable;
QHash<int, QHash<int, std::shared_ptr<XlsxHyperlinkData>>> urlTable;
QList<CellRange> merges;
QHash<int, QSharedPointer<XlsxRowInfo>> rowsInfo;
QHash<int, QSharedPointer<XlsxColumnInfo>> colsInfo;
QHash<int, QSharedPointer<XlsxColumnInfo>> colsInfoHelper;
QHash<int, std::shared_ptr<XlsxRowInfo>> rowsInfo;
QHash<int, std::shared_ptr<XlsxColumnInfo>> colsInfo;
QHash<int, std::shared_ptr<XlsxColumnInfo>> colsInfoHelper;
QList<DataValidation> dataValidationsList;
QList<ConditionalFormatting> conditionalFormattingList;

View File

@ -48,11 +48,11 @@ Chartsheet::Chartsheet(const QString &name, int id, Workbook *workbook, CreateFl
anchor->pos = QPoint(0, 0);
anchor->ext = QSize(9293679, 6068786);
QSharedPointer<Chart> chart = QSharedPointer<Chart>(new Chart(this, flag));
auto chart = std::shared_ptr<Chart>(new Chart(this, flag));
chart->setChartType(Chart::CT_BarChart);
anchor->setObjectGraphicFrame(chart);
d_func()->chart = chart.data();
d_func()->chart = chart.get();
}
}

View File

@ -25,7 +25,6 @@
#include <QDir>
#include <QFile>
#include <QPointF>
#include <QSharedPointer>
#include <QTemporaryFile>
/*
@ -163,8 +162,8 @@ void DocumentPrivate::init()
if (!contentTypes)
contentTypes = std::make_shared<ContentTypes>(ContentTypes::F_NewFromScratch);
if (workbook.isNull())
workbook = QSharedPointer<Workbook>(new Workbook(Workbook::F_NewFromScratch));
if (!workbook)
workbook = std::shared_ptr<Workbook>(new Workbook(Workbook::F_NewFromScratch));
}
bool DocumentPrivate::loadPackage(QIODevice *device)
@ -217,7 +216,7 @@ bool DocumentPrivate::loadPackage(QIODevice *device)
// load workbook now, Get the workbook file path from the root rels file
// In normal case, this should be "xl/workbook.xml"
workbook = QSharedPointer<Workbook>(new Workbook(Workbook::F_LoadFromExists));
workbook = std::shared_ptr<Workbook>(new Workbook(Workbook::F_LoadFromExists));
QList<XlsxRelationship> rels_xl =
rootRels.documentRelationships(QStringLiteral("/officeDocument"));
if (rels_xl.isEmpty())
@ -247,7 +246,7 @@ bool DocumentPrivate::loadPackage(QIODevice *device)
path = xlworkbook_Dir + QLatin1String("/") + name;
}
QSharedPointer<Styles> styles(new Styles(Styles::F_LoadFromExists));
std::shared_ptr<Styles> styles(new Styles(Styles::F_LoadFromExists));
styles->loadFromXmlData(zipReader.fileData(path));
workbook->d_func()->styles = styles;
}
@ -285,7 +284,7 @@ bool DocumentPrivate::loadPackage(QIODevice *device)
// load external links
for (int i = 0; i < workbook->d_func()->externalLinks.count(); ++i) {
SimpleOOXmlFile *link = workbook->d_func()->externalLinks[i].data();
SimpleOOXmlFile *link = workbook->d_func()->externalLinks[i].get();
QString rel_path = getRelFilePath(link->filePath());
// If the .rel file exists, load it.
if (zipReader.filePaths().contains(rel_path))
@ -303,9 +302,9 @@ bool DocumentPrivate::loadPackage(QIODevice *device)
}
// load charts
QList<QSharedPointer<Chart>> chartFileToLoad = workbook->chartFiles();
QList<std::shared_ptr<Chart>> chartFileToLoad = workbook->chartFiles();
for (int i = 0; i < chartFileToLoad.size(); ++i) {
QSharedPointer<Chart> cf = chartFileToLoad[i];
std::shared_ptr<Chart> cf = chartFileToLoad[i];
cf->loadFromXmlData(zipReader.fileData(cf->filePath()));
}
@ -335,13 +334,13 @@ bool DocumentPrivate::savePackage(QIODevice *device) const
DocPropsCore docPropsCore(DocPropsCore::F_NewFromScratch);
// save worksheet xml files
QList<QSharedPointer<AbstractSheet>> worksheets =
QList<std::shared_ptr<AbstractSheet>> worksheets =
workbook->getSheetsByTypes(AbstractSheet::ST_WorkSheet);
if (!worksheets.isEmpty())
docPropsApp.addHeadingPair(QStringLiteral("Worksheets"), worksheets.size());
for (int i = 0; i < worksheets.size(); ++i) {
QSharedPointer<AbstractSheet> sheet = worksheets[i];
std::shared_ptr<AbstractSheet> sheet = worksheets[i];
contentTypes->addWorksheetName(QStringLiteral("sheet%1").arg(i + 1));
docPropsApp.addPartTitle(sheet->sheetName());
@ -355,12 +354,12 @@ bool DocumentPrivate::savePackage(QIODevice *device) const
}
// save chartsheet xml files
QList<QSharedPointer<AbstractSheet>> chartsheets =
QList<std::shared_ptr<AbstractSheet>> chartsheets =
workbook->getSheetsByTypes(AbstractSheet::ST_ChartSheet);
if (!chartsheets.isEmpty())
docPropsApp.addHeadingPair(QStringLiteral("Chartsheets"), chartsheets.size());
for (int i = 0; i < chartsheets.size(); ++i) {
QSharedPointer<AbstractSheet> sheet = chartsheets[i];
std::shared_ptr<AbstractSheet> sheet = chartsheets[i];
contentTypes->addWorksheetName(QStringLiteral("sheet%1").arg(i + 1));
docPropsApp.addPartTitle(sheet->sheetName());
@ -374,7 +373,7 @@ bool DocumentPrivate::savePackage(QIODevice *device) const
// save external links xml files
for (int i = 0; i < workbook->d_func()->externalLinks.count(); ++i) {
SimpleOOXmlFile *link = workbook->d_func()->externalLinks[i].data();
SimpleOOXmlFile *link = workbook->d_func()->externalLinks[i].get();
contentTypes->addExternalLinkName(QStringLiteral("externalLink%1").arg(i + 1));
zipWriter.addFile(QStringLiteral("xl/externalLinks/externalLink%1.xml").arg(i + 1),
@ -437,7 +436,7 @@ bool DocumentPrivate::savePackage(QIODevice *device) const
// save chart xml files
for (int i = 0; i < workbook->chartFiles().size(); ++i) {
contentTypes->addChartName(QStringLiteral("chart%1").arg(i + 1));
QSharedPointer<Chart> cf = workbook->chartFiles()[i];
std::shared_ptr<Chart> cf = workbook->chartFiles()[i];
zipWriter.addFile(QStringLiteral("xl/charts/chart%1.xml").arg(i + 1), cf->saveToXmlData());
}
@ -573,7 +572,7 @@ bool DocumentPrivate::copyStyle(const QString &from, const QString &to)
ZipReader zipReader(from);
QStringList filePaths = zipReader.filePaths();
QSharedPointer<ZipReader> toReader = QSharedPointer<ZipReader>(new ZipReader(to));
std::shared_ptr<ZipReader> toReader = std::shared_ptr<ZipReader>(new ZipReader(to));
QStringList toFilePaths = toReader->filePaths();
@ -628,7 +627,7 @@ bool DocumentPrivate::copyStyle(const QString &from, const QString &to)
temporalZip.close();
toReader.clear();
toReader.reset();
tempFile.close();
@ -1098,7 +1097,7 @@ bool Document::addConditionalFormatting(const ConditionalFormatting &cf)
*
* \sa read()
*/
Cell *Document::cellAt(const CellReference &pos) const
std::shared_ptr<Cell> Document::cellAt(const CellReference &pos) const
{
if (Worksheet *sheet = currentWorksheet())
return sheet->cellAt(pos);
@ -1111,11 +1110,11 @@ Cell *Document::cellAt(const CellReference &pos) const
*
* \sa read()
*/
Cell *Document::cellAt(int row, int col) const
std::shared_ptr<Cell> Document::cellAt(int row, int col) const
{
if (Worksheet *sheet = currentWorksheet())
return sheet->cellAt(row, col);
return nullptr;
return {};
}
/*!
@ -1203,7 +1202,7 @@ QStringList Document::documentPropertyNames() const
Workbook *Document::workbook() const
{
Q_D(const Document);
return d->workbook.data();
return d->workbook.get();
}
/*!

View File

@ -99,7 +99,7 @@ void DrawingAnchor::setObjectShape(const QImage &img)
}
//}}
void DrawingAnchor::setObjectGraphicFrame(QSharedPointer<Chart> chart)
void DrawingAnchor::setObjectGraphicFrame(std::shared_ptr<Chart> chart)
{
m_chartFile = chart;
m_drawing->workbook->addChartFile(chart);
@ -341,8 +341,8 @@ void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader)
const auto parts = splitPath(m_drawing->filePath());
QString path = QDir::cleanPath(parts.first() + QLatin1String("/") + name);
bool exist = false;
QList<QSharedPointer<Chart>> cfs = m_drawing->workbook->chartFiles();
bool exist = false;
QList<std::shared_ptr<Chart>> cfs = m_drawing->workbook->chartFiles();
for (int i = 0; i < cfs.size(); ++i) {
if (cfs[i]->filePath() == path) {
// already exist
@ -351,8 +351,8 @@ void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader)
}
}
if (!exist) {
m_chartFile =
QSharedPointer<Chart>(new Chart(m_drawing->sheet, Chart::F_LoadFromExists));
m_chartFile = std::shared_ptr<Chart>(
new Chart(m_drawing->sheet, Chart::F_LoadFromExists));
m_chartFile->setFilePath(path);
m_drawing->workbook->addChartFile(m_chartFile);
}
@ -475,7 +475,7 @@ void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
rId=sp_blip_rembed;
QString name = m_drawing->relationships()->getRelationshipById(rId).target;
QString path = QDir::cleanPath(splitPath(m_drawing->filePath())[0] +
QLatin1String("/") + name); bool exist = false; QList<QSharedPointer<MediaFile> > mfs =
QLatin1String("/") + name); bool exist = false; QList<std::shared_ptr<MediaFile> > mfs =
m_drawing->workbook->mediaFiles(); for (int i=0; i<mfs.size(); ++i)
{
if (mfs[i]->fileName() == path)
@ -486,7 +486,7 @@ void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
}
}
if (!exist) {
m_pictureFile = QSharedPointer<MediaFile> (new MediaFile(path));
m_pictureFile = std::shared_ptr<MediaFile> (new MediaFile(path));
m_drawing->workbook->addMediaFile(m_pictureFile, true);
}
}

View File

@ -148,7 +148,7 @@ void Styles::fixNumFmt(const Format &format)
const auto &str = format.numberFormat();
if (!str.isEmpty()) {
QHash<QString, QSharedPointer<XlsxFormatNumberData>>::ConstIterator cIt;
QHash<QString, std::shared_ptr<XlsxFormatNumberData>>::ConstIterator cIt;
// Assign proper number format index
const auto &it = m_builtinNumFmtsHash.constFind(str);
if (it != m_builtinNumFmtsHash.constEnd()) {
@ -159,7 +159,7 @@ void Styles::fixNumFmt(const Format &format)
// Assign a new fmt Id.
const_cast<Format *>(&format)->fixNumberFormat(m_nextCustomNumFmtId, str);
QSharedPointer<XlsxFormatNumberData> fmt(new XlsxFormatNumberData);
auto fmt = std::make_shared<XlsxFormatNumberData>();
fmt->formatIndex = m_nextCustomNumFmtId;
fmt->formatString = str;
m_customNumFmtIdMap.insert(m_nextCustomNumFmtId, fmt);
@ -356,7 +356,7 @@ void Styles::writeNumFmts(QXmlStreamWriter &writer) const
writer.writeStartElement(QStringLiteral("numFmts"));
writer.writeAttribute(QStringLiteral("count"), QString::number(m_customNumFmtIdMap.count()));
QMapIterator<int, QSharedPointer<XlsxFormatNumberData>> it(m_customNumFmtIdMap);
QMapIterator<int, std::shared_ptr<XlsxFormatNumberData>> it(m_customNumFmtIdMap);
while (it.hasNext()) {
it.next();
writer.writeEmptyElement(QStringLiteral("numFmt"));
@ -779,9 +779,9 @@ bool Styles::readNumFmts(QXmlStreamReader &reader)
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if (reader.name() == QLatin1String("numFmt")) {
const auto &attributes = reader.attributes();
QSharedPointer<XlsxFormatNumberData> fmt(new XlsxFormatNumberData);
fmt->formatIndex = attributes.value(QLatin1String("numFmtId")).toInt();
fmt->formatString = attributes.value(QLatin1String("formatCode")).toString();
auto fmt = std::make_shared<XlsxFormatNumberData>();
fmt->formatIndex = attributes.value(QLatin1String("numFmtId")).toInt();
fmt->formatString = attributes.value(QLatin1String("formatCode")).toString();
if (fmt->formatIndex >= m_nextCustomNumFmtId)
m_nextCustomNumFmtId = fmt->formatIndex + 1;
m_customNumFmtIdMap.insert(fmt->formatIndex, fmt);

View File

@ -26,9 +26,9 @@ QT_BEGIN_NAMESPACE_XLSX
WorkbookPrivate::WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag)
: AbstractOOXmlFilePrivate(q, flag)
{
sharedStrings = QSharedPointer<SharedStrings>(new SharedStrings(flag));
styles = QSharedPointer<Styles>(new Styles(flag));
theme = QSharedPointer<Theme>(new Theme(flag));
sharedStrings = std::make_shared<SharedStrings>(flag);
styles = std::make_shared<Styles>(flag);
theme = std::make_shared<Theme>(flag);
x_window = 240;
y_window = 15;
@ -206,7 +206,7 @@ AbstractSheet *Workbook::addSheet(const QString &name, int sheetId, AbstractShee
Q_ASSERT(false);
}
d->sheets.append(QSharedPointer<AbstractSheet>(sheet));
d->sheets.append(std::shared_ptr<AbstractSheet>(sheet));
d->sheetNames.append(name);
return sheet;
@ -253,7 +253,7 @@ AbstractSheet *Workbook::insertSheet(int index, const QString &name, AbstractShe
Q_ASSERT(false);
}
d->sheets.insert(index, QSharedPointer<AbstractSheet>(sheet));
d->sheets.insert(index, std::shared_ptr<AbstractSheet>(sheet));
d->sheetNames.insert(index, sheetName);
d->activesheetIndex = index;
@ -268,7 +268,7 @@ AbstractSheet *Workbook::activeSheet() const
Q_D(const Workbook);
if (d->sheets.isEmpty())
const_cast<Workbook *>(this)->addSheet();
return d->sheets[d->activesheetIndex].data();
return d->sheets[d->activesheetIndex].get();
}
bool Workbook::setActiveSheet(int index)
@ -330,7 +330,7 @@ bool Workbook::moveSheet(int srcIndex, int distIndex)
if (srcIndex < 0 || srcIndex >= d->sheets.size())
return false;
QSharedPointer<AbstractSheet> sheet = d->sheets.takeAt(srcIndex);
std::shared_ptr<AbstractSheet> sheet = d->sheets.takeAt(srcIndex);
d->sheetNames.takeAt(srcIndex);
if (distIndex >= 0 || distIndex <= d->sheets.size()) {
d->sheets.insert(distIndex, sheet);
@ -364,7 +364,7 @@ bool Workbook::copySheet(int index, const QString &newName)
++d->last_sheet_id;
AbstractSheet *sheet = d->sheets[index]->copy(worksheetName, d->last_sheet_id);
d->sheets.append(QSharedPointer<AbstractSheet>(sheet));
d->sheets.append(std::shared_ptr<AbstractSheet>(sheet));
d->sheetNames.append(sheet->sheetName());
return true; // #162
@ -387,25 +387,25 @@ AbstractSheet *Workbook::sheet(int index) const
Q_D(const Workbook);
if (index < 0 || index >= d->sheets.size())
return nullptr;
return d->sheets.at(index).data();
return d->sheets.at(index).get();
}
SharedStrings *Workbook::sharedStrings() const
{
Q_D(const Workbook);
return d->sharedStrings.data();
return d->sharedStrings.get();
}
Styles *Workbook::styles()
{
Q_D(Workbook);
return d->styles.data();
return d->styles.get();
}
Theme *Workbook::theme()
{
Q_D(Workbook);
return d->theme.data();
return d->theme.get();
}
/*!
@ -418,7 +418,7 @@ QList<Drawing *> Workbook::drawings()
Q_D(Workbook);
QList<Drawing *> ds;
for (int i = 0; i < d->sheets.size(); ++i) {
QSharedPointer<AbstractSheet> sheet = d->sheets[i];
std::shared_ptr<AbstractSheet> sheet = d->sheets[i];
if (sheet->drawing())
ds.append(sheet->drawing());
}
@ -429,10 +429,11 @@ QList<Drawing *> Workbook::drawings()
/*!
* \internal
*/
QList<QSharedPointer<AbstractSheet>> Workbook::getSheetsByTypes(AbstractSheet::SheetType type) const
QList<std::shared_ptr<AbstractSheet>>
Workbook::getSheetsByTypes(AbstractSheet::SheetType type) const
{
Q_D(const Workbook);
QList<QSharedPointer<AbstractSheet>> list;
QList<std::shared_ptr<AbstractSheet>> list;
for (int i = 0; i < d->sheets.size(); ++i) {
if (d->sheets[i]->sheetType() == type)
list.append(d->sheets[i]);
@ -490,7 +491,7 @@ void Workbook::saveToXmlFile(QIODevice *device) const
int worksheetIndex = 0;
int chartsheetIndex = 0;
for (int i = 0; i < d->sheets.size(); ++i) {
QSharedPointer<AbstractSheet> sheet = d->sheets[i];
std::shared_ptr<AbstractSheet> sheet = d->sheets[i];
writer.writeEmptyElement(QStringLiteral("sheet"));
writer.writeAttribute(QStringLiteral("name"), sheet->sheetName());
writer.writeAttribute(QStringLiteral("sheetId"), QString::number(sheet->sheetId()));
@ -653,7 +654,7 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
const QString rId = attributes.value(QLatin1String("r:id")).toString();
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
QSharedPointer<SimpleOOXmlFile> link(new SimpleOOXmlFile(F_LoadFromExists));
std::shared_ptr<SimpleOOXmlFile> link(new SimpleOOXmlFile(F_LoadFromExists));
const auto parts = splitPath(filePath());
QString fullPath =
@ -714,7 +715,7 @@ void Workbook::addMediaFile(std::shared_ptr<MediaFile> media, bool force)
/*!
* \internal
*/
QList<QSharedPointer<Chart>> Workbook::chartFiles() const
QList<std::shared_ptr<Chart>> Workbook::chartFiles() const
{
Q_D(const Workbook);
@ -724,7 +725,7 @@ QList<QSharedPointer<Chart>> Workbook::chartFiles() const
/*!
* \internal
*/
void Workbook::addChartFile(QSharedPointer<Chart> chart)
void Workbook::addChartFile(std::shared_ptr<Chart> chart)
{
Q_D(Workbook);

View File

@ -75,8 +75,7 @@ void WorksheetPrivate::calculateSpans() const
int span_max = -1;
for (int row_num = dimension.firstRow(); row_num <= dimension.lastRow(); row_num++) {
for (int col_num = dimension.firstColumn(); col_num <= dimension.lastColumn();
col_num++) {
for (int col_num = dimension.firstColumn(); col_num <= dimension.lastColumn(); col_num++) {
if (cellTable.contains(row_num, col_num)) {
if (span_max == -1) {
span_min = col_num;
@ -511,7 +510,7 @@ QVariant Worksheet::read(int row, int column) const
{
Q_D(const Worksheet);
Cell *cell = cellAt(row, column);
auto cell = cellAt(row, column);
if (!cell)
return QVariant();
@ -545,10 +544,10 @@ QVariant Worksheet::read(int row, int column) const
* Returns the cell at the given \a row_column. If there
* is no cell at the specified position, the function returns 0.
*/
Cell *Worksheet::cellAt(const CellReference &row_column) const
std::shared_ptr<Cell> Worksheet::cellAt(const CellReference &row_column) const
{
if (!row_column.isValid())
return nullptr;
return {};
return cellAt(row_column.row(), row_column.column());
}
@ -557,10 +556,10 @@ Cell *Worksheet::cellAt(const CellReference &row_column) const
* Returns the cell at the given \a row and \a column. If there
* is no cell at the specified position, the function returns 0.
*/
Cell *Worksheet::cellAt(int row, int col) const
std::shared_ptr<Cell> Worksheet::cellAt(int row, int col) const
{
Q_D(const Worksheet);
return d->cellTable.cellAt(row, col).get();
return d->cellTable.cellAt(row, col);
}
Format WorksheetPrivate::cellFormat(int row, int col) const
@ -611,7 +610,7 @@ bool Worksheet::writeString(int row, int column, const RichString &value, const
fmt.mergeFormat(value.fragmentFormat(0));
d->workbook->styles()->addXfFormat(fmt);
auto cell = std::make_shared<Cell>(value.toPlainString(), Cell::SharedStringType, fmt, this);
cell->d_ptr->richString = value;
cell->d_ptr->richString = value;
d->cellTable.setValue(row, column, cell);
return true;
}
@ -767,8 +766,8 @@ bool Worksheet::writeFormula(int row,
d->sharedFormulaMap[si] = formula;
}
auto data = std::make_shared<Cell>(result, Cell::NumberType, fmt, this);
data->d_ptr->formula = formula;
auto data = std::make_shared<Cell>(result, Cell::NumberType, fmt, this);
data->d_ptr->formula = formula;
d->cellTable.setValue(row, column, data);
CellRange range = formula.reference();
@ -778,7 +777,7 @@ bool Worksheet::writeFormula(int row,
for (int r = range.firstRow(); r <= range.lastRow(); ++r) {
for (int c = range.firstColumn(); c <= range.lastColumn(); ++c) {
if (!(r == row && c == column)) {
if (Cell *cell = cellAt(r, c)) {
if (auto cell = cellAt(r, c)) {
cell->d_ptr->formula = sf;
} else {
auto newCell = std::make_shared<Cell>(result, Cell::NumberType, fmt, this);
@ -1032,7 +1031,7 @@ bool Worksheet::writeHyperlink(int row,
d->cellTable.setValue(row, column, cell);
// Store the hyperlink data in a separate table
d->urlTable[row][column] = QSharedPointer<XlsxHyperlinkData>(new XlsxHyperlinkData(
d->urlTable[row][column] = std::shared_ptr<XlsxHyperlinkData>(new XlsxHyperlinkData(
XlsxHyperlinkData::External, urlString, locationString, QString(), tip));
return true;
@ -1123,7 +1122,7 @@ bool Worksheet::getImage(int imageIndex, QImage &img)
int realImageIndex = imageIndex - 1; // minus one
DrawingAnchor *danchor = d->drawing->anchors.at(realImageIndex);
// QSharedPointer<Drawing> // for multithread
// std::shared_ptr<Drawing> // for multithread
if (danchor == nullptr) {
return false;
}
@ -1190,10 +1189,10 @@ Chart *Worksheet::insertChart(int row, int column, const QSize &size)
anchor->from = XlsxMarker(row, column, 0, 0);
anchor->ext = size * 9525;
QSharedPointer<Chart> chart = QSharedPointer<Chart>(new Chart(this, F_NewFromScratch));
auto chart = std::shared_ptr<Chart>(new Chart(this, F_NewFromScratch));
anchor->setObjectGraphicFrame(chart);
return chart.data();
return chart.get();
}
/*!
@ -1219,7 +1218,7 @@ bool Worksheet::mergeCells(const CellRange &range, const Format &format)
for (int row = range.firstRow(); row <= range.lastRow(); ++row) {
for (int col = range.firstColumn(); col <= range.lastColumn(); ++col) {
if (row == range.firstRow() && col == range.firstColumn()) {
Cell *cell = cellAt(row, col);
auto cell = cellAt(row, col);
if (cell) {
if (format.isValid())
cell->d_ptr->format = format;
@ -1342,7 +1341,7 @@ void Worksheet::saveToXmlFile(QIODevice *device) const
writer.writeStartElement(QStringLiteral("cols"));
for (auto it = d->colsInfo.begin(); it != d->colsInfo.end(); ++it) {
QSharedPointer<XlsxColumnInfo> col_info = it.value();
std::shared_ptr<XlsxColumnInfo> col_info = it.value();
writer.writeStartElement(QStringLiteral("col"));
writer.writeAttribute(QStringLiteral("min"), QString::number(col_info->firstColumn));
writer.writeAttribute(QStringLiteral("max"), QString::number(col_info->lastColumn));
@ -1504,7 +1503,7 @@ void WorksheetPrivate::saveXmlSheetData(QXmlStreamWriter &writer) const
writer.writeAttribute(QStringLiteral("spans"), span);
if (riIt != rowsInfo.constEnd()) {
QSharedPointer<XlsxRowInfo> rowInfo = riIt.value();
std::shared_ptr<XlsxRowInfo> rowInfo = riIt.value();
if (!rowInfo->format.isEmpty()) {
writer.writeAttribute(QStringLiteral("s"),
QString::number(rowInfo->format.xfIndex()));
@ -1566,7 +1565,8 @@ void WorksheetPrivate::saveXmlCellData(QXmlStreamWriter &writer,
} else {
auto cIt = colsInfoHelper.constFind(col);
if (cIt != colsInfoHelper.constEnd() && !(*cIt)->format.isEmpty()) {
writer.writeAttribute(QStringLiteral("s"), QString::number((*cIt)->format.xfIndex()));
writer.writeAttribute(QStringLiteral("s"),
QString::number((*cIt)->format.xfIndex()));
}
}
}
@ -1724,9 +1724,9 @@ void WorksheetPrivate::saveXmlHyperlinks(QXmlStreamWriter &writer) const
int row = it.key();
for (auto it2 = it.value().begin(); it2 != it.value().end(); ++it2) {
int col = it2.key();
QSharedPointer<XlsxHyperlinkData> data = it2.value();
QString ref = CellReference(row, col).toString();
int col = it2.key();
std::shared_ptr<XlsxHyperlinkData> data = it2.value();
QString ref = CellReference(row, col).toString();
// dev57
// writer.writeEmptyElement(QStringLiteral("hyperlink"));
@ -1784,10 +1784,10 @@ void WorksheetPrivate::splitColsInfo(int colFirst, int colLast)
// This will be more complex if we try to set "C:F" after "B:D".
{
for (auto it = colsInfo.begin(); it != colsInfo.end(); ++it) {
QSharedPointer<XlsxColumnInfo> info = it.value();
std::shared_ptr<XlsxColumnInfo> info = it.value();
if (colFirst > info->firstColumn && colFirst <= info->lastColumn) {
// split the range,
QSharedPointer<XlsxColumnInfo> info2(new XlsxColumnInfo(*info));
std::shared_ptr<XlsxColumnInfo> info2(new XlsxColumnInfo(*info));
info->lastColumn = colFirst - 1;
info2->firstColumn = colFirst;
colsInfo.insert(colFirst, info2);
@ -1800,9 +1800,9 @@ void WorksheetPrivate::splitColsInfo(int colFirst, int colLast)
}
{
for (auto it = colsInfo.begin(); it != colsInfo.end(); ++it) {
QSharedPointer<XlsxColumnInfo> info = it.value();
std::shared_ptr<XlsxColumnInfo> info = it.value();
if (colLast >= info->firstColumn && colLast < info->lastColumn) {
QSharedPointer<XlsxColumnInfo> info2(new XlsxColumnInfo(*info));
std::shared_ptr<XlsxColumnInfo> info2(new XlsxColumnInfo(*info));
info->lastColumn = colLast;
info2->firstColumn = colLast + 1;
colsInfo.insert(colLast + 1, info2);
@ -1898,9 +1898,9 @@ bool Worksheet::setColumnWidth(int colFirst, int colLast, double width)
{
Q_D(Worksheet);
const QList<QSharedPointer<XlsxColumnInfo>> columnInfoList =
const QList<std::shared_ptr<XlsxColumnInfo>> columnInfoList =
d->getColumnInfoList(colFirst, colLast);
for (const QSharedPointer<XlsxColumnInfo> &columnInfo : columnInfoList) {
for (const std::shared_ptr<XlsxColumnInfo> &columnInfo : columnInfoList) {
columnInfo->width = width;
}
@ -1916,9 +1916,9 @@ bool Worksheet::setColumnFormat(int colFirst, int colLast, const Format &format)
{
Q_D(Worksheet);
const QList<QSharedPointer<XlsxColumnInfo>> columnInfoList =
const QList<std::shared_ptr<XlsxColumnInfo>> columnInfoList =
d->getColumnInfoList(colFirst, colLast);
for (const QSharedPointer<XlsxColumnInfo> &columnInfo : columnInfoList)
for (const std::shared_ptr<XlsxColumnInfo> &columnInfo : columnInfoList)
columnInfo->format = format;
if (columnInfoList.count() > 0) {
@ -1937,9 +1937,9 @@ bool Worksheet::setColumnHidden(int colFirst, int colLast, bool hidden)
{
Q_D(Worksheet);
const QList<QSharedPointer<XlsxColumnInfo>> columnInfoList =
const QList<std::shared_ptr<XlsxColumnInfo>> columnInfoList =
d->getColumnInfoList(colFirst, colLast);
for (const QSharedPointer<XlsxColumnInfo> &columnInfo : columnInfoList)
for (const std::shared_ptr<XlsxColumnInfo> &columnInfo : columnInfoList)
columnInfo->hidden = hidden;
return (columnInfoList.count() > 0);
@ -1952,7 +1952,7 @@ double Worksheet::columnWidth(int column)
{
Q_D(Worksheet);
QList<QSharedPointer<XlsxColumnInfo>> columnInfoList = d->getColumnInfoList(column, column);
QList<std::shared_ptr<XlsxColumnInfo>> columnInfoList = d->getColumnInfoList(column, column);
// [dev54]
if (columnInfoList.size() == 0) {
@ -1983,7 +1983,7 @@ Format Worksheet::columnFormat(int column)
{
Q_D(Worksheet);
QList<QSharedPointer<XlsxColumnInfo>> columnInfoList = d->getColumnInfoList(column, column);
QList<std::shared_ptr<XlsxColumnInfo>> columnInfoList = d->getColumnInfoList(column, column);
if (columnInfoList.count() == 1)
return columnInfoList.at(0)->format;
@ -1997,7 +1997,7 @@ bool Worksheet::isColumnHidden(int column)
{
Q_D(Worksheet);
QList<QSharedPointer<XlsxColumnInfo>> columnInfoList = d->getColumnInfoList(column, column);
QList<std::shared_ptr<XlsxColumnInfo>> columnInfoList = d->getColumnInfoList(column, column);
if (columnInfoList.count() == 1)
return columnInfoList.at(0)->hidden;
@ -2015,8 +2015,8 @@ bool Worksheet::setRowHeight(int rowFirst, int rowLast, double height)
{
Q_D(Worksheet);
const QList<QSharedPointer<XlsxRowInfo>> rowInfoList = d->getRowInfoList(rowFirst, rowLast);
for (const QSharedPointer<XlsxRowInfo> &rowInfo : rowInfoList) {
const QList<std::shared_ptr<XlsxRowInfo>> rowInfoList = d->getRowInfoList(rowFirst, rowLast);
for (const std::shared_ptr<XlsxRowInfo> &rowInfo : rowInfoList) {
rowInfo->height = height;
rowInfo->customHeight = true;
}
@ -2034,8 +2034,8 @@ bool Worksheet::setRowFormat(int rowFirst, int rowLast, const Format &format)
{
Q_D(Worksheet);
const QList<QSharedPointer<XlsxRowInfo>> rowInfoList = d->getRowInfoList(rowFirst, rowLast);
for (const QSharedPointer<XlsxRowInfo> &rowInfo : rowInfoList)
const QList<std::shared_ptr<XlsxRowInfo>> rowInfoList = d->getRowInfoList(rowFirst, rowLast);
for (const std::shared_ptr<XlsxRowInfo> &rowInfo : rowInfoList)
rowInfo->format = format;
d->workbook->styles()->addXfFormat(format);
@ -2052,8 +2052,8 @@ bool Worksheet::setRowHidden(int rowFirst, int rowLast, bool hidden)
{
Q_D(Worksheet);
const QList<QSharedPointer<XlsxRowInfo>> rowInfoList = d->getRowInfoList(rowFirst, rowLast);
for (const QSharedPointer<XlsxRowInfo> &rowInfo : rowInfoList)
const QList<std::shared_ptr<XlsxRowInfo>> rowInfoList = d->getRowInfoList(rowFirst, rowLast);
for (const std::shared_ptr<XlsxRowInfo> &rowInfo : rowInfoList)
rowInfo->hidden = hidden;
return rowInfoList.count() > 0;
@ -2117,7 +2117,7 @@ bool Worksheet::groupRows(int rowFirst, int rowLast, bool collapsed)
if (it != d->rowsInfo.end()) {
(*it)->outlineLevel += 1;
} else {
QSharedPointer<XlsxRowInfo> info(new XlsxRowInfo);
std::shared_ptr<XlsxRowInfo> info(new XlsxRowInfo);
info->outlineLevel += 1;
it = d->rowsInfo.insert(row, info);
}
@ -2127,7 +2127,7 @@ bool Worksheet::groupRows(int rowFirst, int rowLast, bool collapsed)
if (collapsed) {
auto it = d->rowsInfo.find(rowLast + 1);
if (it == d->rowsInfo.end())
it = d->rowsInfo.insert(rowLast + 1, QSharedPointer<XlsxRowInfo>(new XlsxRowInfo));
it = d->rowsInfo.insert(rowLast + 1, std::shared_ptr<XlsxRowInfo>(new XlsxRowInfo));
(*it)->collapsed = true;
}
return true;
@ -2178,7 +2178,7 @@ bool Worksheet::groupColumns(int colFirst, int colLast, bool collapsed)
(*it)->hidden = true;
} else {
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx + 1] - 1;
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd, false));
std::shared_ptr<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd, false));
info->outlineLevel += 1;
d->colsInfo.insert(colFirst, info);
if (collapsed)
@ -2195,7 +2195,7 @@ bool Worksheet::groupColumns(int colFirst, int colLast, bool collapsed)
if (it != d->colsInfo.constEnd())
(*it)->collapsed = true;
else {
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(col, col, false));
std::shared_ptr<XlsxColumnInfo> info(new XlsxColumnInfo(col, col, false));
info->collapsed = true;
d->colsInfo.insert(col, info);
d->colsInfoHelper[col] = info;
@ -2276,7 +2276,7 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
attributes.hasAttribute(QLatin1String("outlineLevel")) ||
attributes.hasAttribute(QLatin1String("collapsed"))) {
QSharedPointer<XlsxRowInfo> info(new XlsxRowInfo);
std::shared_ptr<XlsxRowInfo> info(new XlsxRowInfo);
if (attributes.hasAttribute(QLatin1String("customFormat")) &&
attributes.hasAttribute(QLatin1String("s"))) {
int idx = attributes.value(QLatin1String("s")).toInt();
@ -2321,8 +2321,7 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
QXmlStreamAttributes attributes = reader.attributes();
QString r = attributes.value(QLatin1String("r")).toString();
CellReference pos(r);
if (r.isEmpty())
{
if (r.isEmpty()) {
pos.setRow(row_num);
pos.setColumn(++col_num);
}
@ -2464,7 +2463,7 @@ void WorksheetPrivate::loadXmlColumnsInfo(QXmlStreamReader &reader)
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if (reader.name() == QLatin1String("col")) {
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(0, 1, false));
std::shared_ptr<XlsxColumnInfo> info(new XlsxColumnInfo(0, 1, false));
QXmlStreamAttributes colAttrs = reader.attributes();
int min = colAttrs.value(QLatin1String("min")).toInt();
@ -2658,7 +2657,7 @@ void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader)
QXmlStreamAttributes attrs = reader.attributes();
CellReference pos(attrs.value(QLatin1String("ref")).toString());
if (pos.isValid()) { // Valid
QSharedPointer<XlsxHyperlinkData> link(new XlsxHyperlinkData);
std::shared_ptr<XlsxHyperlinkData> link(new XlsxHyperlinkData);
link->display = attrs.value(QLatin1String("display")).toString();
link->tooltip = attrs.value(QLatin1String("tooltip")).toString();
link->location = attrs.value(QLatin1String("location")).toString();
@ -2678,9 +2677,10 @@ void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader)
}
}
QList<QSharedPointer<XlsxColumnInfo>> WorksheetPrivate::getColumnInfoList(int colFirst, int colLast)
QList<std::shared_ptr<XlsxColumnInfo>> WorksheetPrivate::getColumnInfoList(int colFirst,
int colLast)
{
QList<QSharedPointer<XlsxColumnInfo>> columnsInfoList;
QList<std::shared_ptr<XlsxColumnInfo>> columnsInfoList;
if (isColumnRangeValid(colFirst, colLast)) {
QList<int> nodes = getColumnIndexes(colFirst, colLast);
@ -2691,7 +2691,7 @@ QList<QSharedPointer<XlsxColumnInfo>> WorksheetPrivate::getColumnInfoList(int co
columnsInfoList.append(*it);
} else {
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx + 1] - 1;
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd, false));
std::shared_ptr<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd, false));
colsInfo.insert(colFirst, info);
columnsInfoList.append(info);
for (int c = colStart; c <= colEnd; ++c) {
@ -2704,9 +2704,9 @@ QList<QSharedPointer<XlsxColumnInfo>> WorksheetPrivate::getColumnInfoList(int co
return columnsInfoList;
}
QList<QSharedPointer<XlsxRowInfo>> WorksheetPrivate::getRowInfoList(int rowFirst, int rowLast)
QList<std::shared_ptr<XlsxRowInfo>> WorksheetPrivate::getRowInfoList(int rowFirst, int rowLast)
{
QList<QSharedPointer<XlsxRowInfo>> rowInfoList;
QList<std::shared_ptr<XlsxRowInfo>> rowInfoList;
int min_col = dimension.firstColumn() < 1 ? 1 : dimension.firstColumn();
@ -2714,9 +2714,9 @@ QList<QSharedPointer<XlsxRowInfo>> WorksheetPrivate::getRowInfoList(int rowFirst
if (checkDimensions(row, min_col, false, true))
continue;
QSharedPointer<XlsxRowInfo> rowInfo;
if ((rowsInfo[row]).isNull()) {
rowsInfo[row] = QSharedPointer<XlsxRowInfo>(new XlsxRowInfo());
std::shared_ptr<XlsxRowInfo> rowInfo;
if (!(rowsInfo[row])) {
rowsInfo[row] = std::make_shared<XlsxRowInfo>();
}
rowInfoList.append(rowsInfo[row]);
}
@ -2820,7 +2820,8 @@ void WorksheetPrivate::validateDimension()
if (dimension.isValid() || cellTable.isEmpty())
return;
CellRange cr(cellTable.firstRow, cellTable.firstColumn, cellTable.lastRow, cellTable.lastColumn);
CellRange cr(
cellTable.firstRow, cellTable.firstColumn, cellTable.lastRow, cellTable.lastColumn);
if (cr.isValid())
dimension = cr;
@ -2858,11 +2859,11 @@ QVector<CellLocation> Worksheet::getFullCells(int *maxRow, int *maxCol)
}
for (const auto row : d->cellTable.sortedRows()) {
auto &columns = d->cellTable.cells[row];
auto &columns = d->cellTable.cells[row];
auto columnsSorted = CellTable::sorteIntList(columns.keys());
for (const auto col : columnsSorted) {
// It's faster to iterate but cellTable is unordered which might not
// be what callers want?
// It's faster to iterate but cellTable is unordered which might not
// be what callers want?
auto cell = std::make_shared<Cell>(columns.value(col).get());
CellLocation cl;

View File

@ -39,7 +39,7 @@ int extractdata()
//![2]
qDebug() << "extractdata.xlsx - QXlsx::Cell.value()";
for (int row = 1; row < 10; ++row) {
if (QXlsx::Cell *cell = xlsx.cellAt(row, 1)) {
if (auto cell = xlsx.cellAt(row, 1)) {
qDebug() << cell->value();
}
}

View File

@ -126,7 +126,7 @@ int ReadExcel(bool isTest)
//![2]
qDebug() << " QXlsx::Cell.cellAt()";
for (int row = 1; row < 20; ++row) {
Cell *cell = xlsx.cellAt(row, 1);
auto cell = xlsx.cellAt(row, 1);
if (cell == NULL)
continue;
QVariant var = cell->readValue();

View File

@ -41,7 +41,7 @@ int readGoogleSpreadsheet()
// current sheet is default sheet. (Sheet1)
for (int row = 1; row < 20; ++row) {
Cell *cell = xlsx.cellAt(row, 1);
auto cell = xlsx.cellAt(row, 1);
if (cell == NULL)
continue;
QVariant var = cell->readValue();
@ -145,7 +145,7 @@ int readMSExcel201xNumber(QXlsx::Document *pXlsx)
return (-1);
for (int row = 1; row < 10; ++row) {
Cell *cell = pXlsx->cellAt(row, 1);
auto cell = pXlsx->cellAt(row, 1);
if (cell == NULL)
continue;