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

Merge branch '210620'

This commit is contained in:
Jay Two 2021-06-21 21:06:08 +09:00
commit 560e52d84c
6 changed files with 76 additions and 0 deletions

View File

@ -43,6 +43,7 @@ public:
int insertImage(int row, int col, const QImage &image);
bool getImage(int imageIndex, QImage& img);
bool getImage(int row, int col, QImage& img);
uint getImageCount();
Chart *insertChart(int row, int col, const QSize &size);

View File

@ -60,6 +60,9 @@ public:
virtual bool loadFromXml(QXmlStreamReader &reader) = 0;
virtual void saveToXml(QXmlStreamWriter &writer) const = 0;
virtual int row();
virtual int col();
protected:
QPoint loadXmlPos(QXmlStreamReader &reader);
QSize loadXmlExt(QXmlStreamReader &reader);
@ -137,6 +140,9 @@ public:
XlsxMarker from;
QSize ext;
virtual int row();
virtual int col();
bool loadFromXml(QXmlStreamReader &reader);
void saveToXml(QXmlStreamWriter &writer) const;
};
@ -149,6 +155,9 @@ public:
XlsxMarker from;
XlsxMarker to;
virtual int row();
virtual int col();
bool loadFromXml(QXmlStreamReader &reader);
void saveToXml(QXmlStreamWriter &writer) const;
};

View File

@ -99,6 +99,7 @@ public:
int insertImage(int row, int column, const QImage &image);
bool getImage(int imageIndex, QImage& img);
bool getImage(int row, int column, QImage& img);
uint getImageCount();
Chart *insertChart(int row, int column, const QSize &size);

View File

@ -657,6 +657,14 @@ bool Document::getImage(int imageIndex, QImage& img)
return false;
}
bool Document::getImage(int row, int col, QImage &img)
{
if (Worksheet *sheet = currentWorksheet())
return sheet->getImage(row, col, img);
return false;
}
uint Document::getImageCount()
{
if (Worksheet *sheet = currentWorksheet())

View File

@ -106,6 +106,16 @@ void DrawingAnchor::setObjectGraphicFrame(QSharedPointer<Chart> chart)
m_objectType = GraphicFrame;
}
int DrawingAnchor::row()
{
return -1;
}
int DrawingAnchor::col()
{
return -1;
}
QPoint DrawingAnchor::loadXmlPos(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("pos"));
@ -1025,6 +1035,16 @@ DrawingOneCellAnchor::DrawingOneCellAnchor(Drawing *drawing, ObjectType objectTy
}
int DrawingOneCellAnchor::row()
{
return from.row();
}
int DrawingOneCellAnchor::col()
{
return from.col();
}
// check point
bool DrawingOneCellAnchor::loadFromXml(QXmlStreamReader &reader)
{
@ -1083,6 +1103,16 @@ DrawingTwoCellAnchor::DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectTy
}
int DrawingTwoCellAnchor::row()
{
return from.row();
}
int DrawingTwoCellAnchor::col()
{
return from.col();
}
// check point
bool DrawingTwoCellAnchor::loadFromXml(QXmlStreamReader &reader)
{

View File

@ -1144,6 +1144,33 @@ bool Worksheet::getImage(int imageIndex, QImage& img)
return ret;
}
bool Worksheet::getImage(int row, int column, QImage &img)
{
Q_D(Worksheet);
if ( d->drawing == nullptr )
{
return false;
}
for(int i = 0; i < d->drawing->anchors.size(); i++)
{
if(d->drawing->anchors[i]->row() == row && d->drawing->anchors[i]->col() == column)
{
DrawingAnchor* danchor = d->drawing->anchors.at( i );
if ( danchor == nullptr )
{
return false;
}
bool ret= danchor->getObjectPicture(img);
return ret;
}
}
return false;
}
uint Worksheet::getImageCount()
{
Q_D(Worksheet);