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

testing } else if(reader.name() == QLatin1String(pageSetup)){

This commit is contained in:
Jay Two 2018-11-02 17:00:28 +09:00
parent 20b64d0356
commit ca957e835f
7 changed files with 597 additions and 20 deletions

View File

@ -119,6 +119,8 @@ public:
bool isLoadPackage() const;
bool changeimage(int filenoinmidea,QString newfile); // add by liufeijin20181025
private:
Q_DISABLE_COPY(Document)
DocumentPrivate * const d_ptr;

View File

@ -76,6 +76,7 @@ public:
DrawingAnchor(Drawing *drawing, ObjectType objectType);
virtual ~DrawingAnchor();
void setObjectPicture(const QImage &img);
void setObjectGraphicFrame(QSharedPointer<Chart> chart);
virtual bool loadFromXml(QXmlStreamReader &reader) = 0;
@ -108,6 +109,30 @@ protected:
QSharedPointer<Chart> m_chartFile;
int m_id;
// liufeij {{
void setObjectShape(const QImage &img); // liufeij
QString editASName;
// below only for twocellanchor shape
QPoint posTA; // for shape liufeij 20181024
QSize extTA; // for shape liufeij 20181024
int rotWithShapeTA; //// for shape liufeij 20181024
int dpiTA; //// for shape liufeij 20181024
QString sp_textlink,sp_macro,sp_blip_cstate,sp_blip_rembed;
// BELOW only for cxnSp shape
QString cxnSp_filpV,cxnSp_macro;
// belwo for cxnsp and sp
QString xsp_cNvPR_name,xsp_cNvPR_id; //x measns shape and cxnSp together using
QString xbwMode; // same as above
QString xIn_algn,xIn_cmpd,xIn_cap,xIn_w; //cxnSp only need xIn_w
QString xprstGeom_prst;
QString x_headEnd_w,x_headEnd_len,x_headEnd_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_val,style_fillref_val,style_effectref_val,style_forntref_val;
// liufeij }}
};
class DrawingAbsoluteAnchor : public DrawingAnchor

View File

@ -135,6 +135,7 @@ public:
void setOutlineSymbolsVisible(bool visible);
bool isWhiteSpaceVisible() const;
void setWhiteSpaceVisible(bool visible);
bool setStartPage(int spagen); //add by liufeijin20181028
~Worksheet();

View File

@ -215,6 +215,18 @@ public:
int default_row_height;
bool default_row_zeroed;
// liufeijin {{
// pagesetup and print settings add by liufeijin 20181028
QString PpaperSize,Pscale,PfirstPageNumber,Porientation,PuseFirstPageNumber,PhorizontalDpi,PverticalDpi, Prid,Pcopies;
// pageMargins add by liufeijin 20181028
QString PMfooter,PMheader,PMbotton,PMtop,PMright,PMleft;
// header footer contain add by liufeijin 20181028
QString MoodFooter,ModdHeader;
// liufeijin }}
XlsxSheetFormatProps sheetFormatProps;
bool windowProtection;

View File

@ -1066,4 +1066,38 @@ Document::~Document()
delete d_ptr;
}
// add by liufeijin 20181025 {{
bool Document::changeimage(int filenoinmidea, QString newfile){
Q_D(const Document);
QImage newpic;
newpic=QImage(newfile);
QList<QSharedPointer<MediaFile> > mediaFileToLoad = d->workbook->mediaFiles();
QSharedPointer<MediaFile> mf = mediaFileToLoad[filenoinmidea];
const QString suffix = newfile.mid(newfile.lastIndexOf(QLatin1Char('.'))+1);
QString mimetypemy;
if(QString::compare("jpg", suffix, Qt::CaseInsensitive)==0)
mimetypemy="image/jpeg";
if(QString::compare("bmp", suffix, Qt::CaseInsensitive)==0)
mimetypemy="image/bmp";
if(QString::compare("gif", suffix, Qt::CaseInsensitive)==0)
mimetypemy="image/gif";
if(QString::compare("png", suffix, Qt::CaseInsensitive)==0)
mimetypemy="image/png";
QByteArray ba;
QBuffer buffer(&ba);
buffer.setBuffer(&ba);
buffer.open(QIODevice::WriteOnly);
newpic.save(&buffer,suffix.toLocal8Bit().data());
mf->set(ba,suffix,mimetypemy);
mediaFileToLoad[filenoinmidea]=mf;
return true;
}
// liufeijin }}
QT_END_NAMESPACE_XLSX

View File

@ -95,6 +95,21 @@ void DrawingAnchor::setObjectPicture(const QImage &img)
m_objectType = Picture;
}
//{{ liufeijin
void DrawingAnchor::setObjectShape(const QImage &img)
{
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
img.save(&buffer, "PNG");
m_pictureFile = QSharedPointer<MediaFile>(new MediaFile(ba, QStringLiteral("png"), QStringLiteral("image/png")));
m_drawing->workbook->addMediaFile(m_pictureFile);
m_objectType = Shape;
}
//}}
void DrawingAnchor::setObjectGraphicFrame(QSharedPointer<Chart> chart)
{
m_chartFile = chart;
@ -159,6 +174,12 @@ void DrawingAnchor::loadXmlObject(QXmlStreamReader &reader)
if (reader.name() == QLatin1String("sp")) {
//Shape
m_objectType = Shape;
//{{ liufeijin
sp_textlink=reader.attributes().value(QLatin1String("textlink")).toString();
sp_macro=reader.attributes().value(QLatin1String("macro")).toString();
//}}
loadXmlObjectShape(reader);
} else if (reader.name() == QLatin1String("grpSp")) {
//Group Shape
@ -171,6 +192,11 @@ void DrawingAnchor::loadXmlObject(QXmlStreamReader &reader)
} else if (reader.name() == QLatin1String("cxnSp")) {
//Connection Shape
m_objectType = ConnectionShape;
// {{ liufeijin
cxnSp_macro=reader.attributes().value(QLatin1String("macro")).toString();
// }}
loadXmlObjectConnectionShape(reader);
} else if (reader.name() == QLatin1String("pic")) {
//Picture
@ -181,7 +207,81 @@ void DrawingAnchor::loadXmlObject(QXmlStreamReader &reader)
void DrawingAnchor::loadXmlObjectConnectionShape(QXmlStreamReader &reader)
{
Q_UNUSED(reader)
Q_ASSERT(reader.name() == QLatin1String("cxnSp"));
bool hasoffext=false;
while (!reader.atEnd()) {
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if (reader.name() == QLatin1String("cNvPr")){
xsp_cNvPR_name= reader.attributes().value(QLatin1String("name")).toString();
xsp_cNvPR_id= reader.attributes().value(QLatin1String("id")).toString();
}else if(reader.name() == QLatin1String("spPr")){
xbwMode= reader.attributes().value(QLatin1String("bwMode")).toString();
}else if(reader.name() == QLatin1String("xfrm")){
cxnSp_filpV= reader.attributes().value(QLatin1String("flipV")).toString();
}else if (reader.name() == QLatin1String("off")) {
posTA = loadXmlPos(reader);
hasoffext=true;
} else if (reader.name() == QLatin1String("ext")&&hasoffext) {
extTA = loadXmlExt(reader);
hasoffext=false;
}else if(reader.name() == QLatin1String("prstGeom")){
xprstGeom_prst= reader.attributes().value(QLatin1String("prst")).toString().trimmed();
}else if(reader.name() == QLatin1String("ln")){
xIn_algn= reader.attributes().value(QLatin1String("algn")).toString().trimmed();
xIn_cmpd= reader.attributes().value(QLatin1String("cmpd")).toString().trimmed();
xIn_cap= reader.attributes().value(QLatin1String("cap")).toString().trimmed();
xIn_w= reader.attributes().value(QLatin1String("w")).toString().trimmed();
}else if(reader.name() == QLatin1String("headEnd")){
x_headEnd_w= reader.attributes().value(QLatin1String("w")).toString().trimmed();
x_headEnd_len= reader.attributes().value(QLatin1String("len")).toString().trimmed();
x_headEnd_tyep= reader.attributes().value(QLatin1String("type")).toString().trimmed();
}else if(reader.name() == QLatin1String("tailEnd")){
x_tailEnd_w= reader.attributes().value(QLatin1String("w")).toString().trimmed();
x_tailEnd_len= reader.attributes().value(QLatin1String("len")).toString().trimmed();
x_tailEnd_tyep= reader.attributes().value(QLatin1String("type")).toString().trimmed();
}else if(reader.name() == QLatin1String("lnRef")){
Style_inref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
Style_inref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}else if(reader.name() == QLatin1String("fillRef")){
style_fillref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
style_fillref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}else if(reader.name() == QLatin1String("effectRef")){
style_effectref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
style_effectref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}else if(reader.name() == QLatin1String("fontRef")){
style_forntref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
style_forntref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}
} else if (reader.tokenType() == QXmlStreamReader::EndElement
&& reader.name() == QLatin1String("cxnSp")) {
break;
}
}
return;
}
void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader)
@ -262,7 +362,101 @@ void DrawingAnchor::loadXmlObjectPicture(QXmlStreamReader &reader)
void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
{
Q_UNUSED(reader)
Q_ASSERT(reader.name() == QLatin1String("sp"));
bool hasoffext=false;
while (!reader.atEnd()) {
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if (reader.name() == QLatin1String("blip")) {
QString rId;
sp_blip_rembed= reader.attributes().value(QLatin1String("r:embed")).toString();
sp_blip_cstate=reader.attributes().value(QLatin1String("cstate")).toString();
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 = m_drawing->workbook->mediaFiles();
for (int i=0; i<mfs.size(); ++i) {
if (mfs[i]->fileName() == path) {
//already exist
exist = true;
m_pictureFile = mfs[i];
}
}
if (!exist) {
m_pictureFile = QSharedPointer<MediaFile> (new MediaFile(path));
m_drawing->workbook->addMediaFile(m_pictureFile, true);
}
}else if (reader.name() == QLatin1String("off")) {
posTA = loadXmlPos(reader);
hasoffext=true;
} else if (reader.name() == QLatin1String("ext")&&hasoffext) {
extTA = loadXmlExt(reader);
hasoffext=false;
}else if(reader.name() == QLatin1String("blipFill")){
rotWithShapeTA= reader.attributes().value(QLatin1String("rotWithShape")).toInt();
dpiTA= reader.attributes().value(QLatin1String("dpi")).toInt();
}else if(reader.name() == QLatin1String("cNvPr")){
xsp_cNvPR_name= reader.attributes().value(QLatin1String("name")).toString();
xsp_cNvPR_id= reader.attributes().value(QLatin1String("id")).toString();
}else if(reader.name() == QLatin1String("spPr")){
xbwMode= reader.attributes().value(QLatin1String("bwMode")).toString();
}else if(reader.name() == QLatin1String("prstGeom")){
xprstGeom_prst= reader.attributes().value(QLatin1String("prst")).toString();
}else if(reader.name() == QLatin1String("ln")){
xIn_algn= reader.attributes().value(QLatin1String("algn")).toString();
xIn_cmpd= reader.attributes().value(QLatin1String("cmpd")).toString();
xIn_cap= reader.attributes().value(QLatin1String("cap")).toString();
xIn_w= reader.attributes().value(QLatin1String("w")).toString();
}else if(reader.name() == QLatin1String("headEnd")){
x_headEnd_w= reader.attributes().value(QLatin1String("w")).toString();
x_headEnd_len= reader.attributes().value(QLatin1String("len")).toString();
x_headEnd_tyep= reader.attributes().value(QLatin1String("type")).toString();
}else if(reader.name() == QLatin1String("tailEnd")){
x_tailEnd_w= reader.attributes().value(QLatin1String("w")).toString();
x_tailEnd_len= reader.attributes().value(QLatin1String("len")).toString();
x_tailEnd_tyep= reader.attributes().value(QLatin1String("type")).toString();
}else if(reader.name() == QLatin1String("lnRef")){
Style_inref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
Style_inref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}else if(reader.name() == QLatin1String("fillRef")){
style_fillref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
style_fillref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}else if(reader.name() == QLatin1String("effectRef")){
style_effectref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
style_effectref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}else if(reader.name() == QLatin1String("fontRef")){
style_forntref_idx= reader.attributes().value(QLatin1String("idx")).toString().trimmed();
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
if(reader.name() == QLatin1String("schemeClr")){
style_forntref_val=reader.attributes().value(QLatin1String("val")).toString().trimmed();
}
}
}
} else if (reader.tokenType() == QXmlStreamReader::EndElement
&& reader.name() == QLatin1String("sp")) {
break;
}
}
return;
}
void DrawingAnchor::saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const
@ -306,7 +500,109 @@ void DrawingAnchor::saveXmlObject(QXmlStreamWriter &writer) const
void DrawingAnchor::saveXmlObjectConnectionShape(QXmlStreamWriter &writer) const
{
Q_UNUSED(writer)
writer.writeStartElement(QStringLiteral("xdr:cxnSp")); ///?
writer.writeAttribute(QStringLiteral("macro"), cxnSp_macro);
writer.writeStartElement(QStringLiteral("xdr:nvCxnSpPr"));
writer.writeEmptyElement(QStringLiteral("xdr:cNvPr"));
writer.writeAttribute(QStringLiteral("id"), xsp_cNvPR_id);
writer.writeAttribute(QStringLiteral("name"), xsp_cNvPR_name);
writer.writeEmptyElement(QStringLiteral("xdr:cNvCxnSpPr"));
writer.writeEndElement(); //xdr:nvCxnSpPr
writer.writeStartElement(QStringLiteral("xdr:spPr"));
if(!xbwMode.isNull()){
writer.writeAttribute(QStringLiteral("bwMode"), xbwMode);
}
writer.writeStartElement(QStringLiteral("a:xfrm"));
if(!cxnSp_filpV.isEmpty()){
writer.writeAttribute(QStringLiteral("flipV"), cxnSp_filpV);}
writer.writeEmptyElement(QStringLiteral("a:off"));
writer.writeAttribute(QStringLiteral("x"), QString::number(posTA.x()));
writer.writeAttribute(QStringLiteral("y"), QString::number(posTA.y()));
writer.writeEmptyElement(QStringLiteral("a:ext"));
writer.writeAttribute(QStringLiteral("cx"), QString::number(extTA.width()));
writer.writeAttribute(QStringLiteral("cy"), QString::number(extTA.height()));
writer.writeEndElement(); //a:xfrm
writer.writeStartElement(QStringLiteral("a:prstGeom"));
writer.writeAttribute(QStringLiteral("prst"), xprstGeom_prst);
writer.writeEmptyElement(QStringLiteral("a:avLst"));
writer.writeEndElement(); //a:prstGeom
writer.writeStartElement(QStringLiteral("a:ln"));
if(!xIn_w.isEmpty()&&!xIn_cap.isEmpty()){
if(!xIn_w.isEmpty()){
writer.writeAttribute(QStringLiteral("w"), xIn_w);
}
if(!xIn_cap.isEmpty()){
writer.writeAttribute(QStringLiteral("cap"), xIn_cap);
}
if(!xIn_cmpd.isEmpty()){
writer.writeAttribute(QStringLiteral("cmpd"), xIn_cmpd);
}
if(!xIn_algn.isEmpty()){
writer.writeAttribute(QStringLiteral("algn"), xIn_algn);
}
}
if((!x_headEnd_tyep.isEmpty())||(!x_headEnd_w.isEmpty())||(!x_headEnd_len.isEmpty())){
writer.writeEmptyElement(QStringLiteral("a:headEnd"));
if(!x_headEnd_tyep.isEmpty()){
writer.writeAttribute(QStringLiteral("type"),x_headEnd_tyep);
}
if(!x_headEnd_w.isEmpty()){
writer.writeAttribute(QStringLiteral("w"),x_headEnd_w);
}
if(!x_headEnd_len.isEmpty()){
writer.writeAttribute(QStringLiteral("len"),x_headEnd_len);
}
}
if((!x_tailEnd_tyep.isEmpty())||(!x_tailEnd_w.isEmpty())||(!x_tailEnd_len.isEmpty())){
writer.writeEmptyElement(QStringLiteral("a:tailEnd"));
if(!x_tailEnd_tyep.isEmpty()){
writer.writeAttribute(QStringLiteral("type"),x_tailEnd_tyep);}
if(!x_tailEnd_w.isEmpty()){
writer.writeAttribute(QStringLiteral("w"),x_tailEnd_w);}
if(!x_tailEnd_len.isEmpty()){
writer.writeAttribute(QStringLiteral("len"),x_tailEnd_len);}
}
writer.writeEndElement();//a:ln
writer.writeEndElement(); //xdr:spPr
// writer style
writer.writeStartElement(QStringLiteral("xdr:style"));// style
writer.writeStartElement(QStringLiteral("a:lnRef"));//lnRef
writer.writeAttribute(QStringLiteral("idx"),Style_inref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),Style_inref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // lnRef
writer.writeStartElement(QStringLiteral("a:fillRef"));//fillRef
writer.writeAttribute(QStringLiteral("idx"),style_fillref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),style_fillref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // fillRef
writer.writeStartElement(QStringLiteral("a:effectRef"));//effectRef
writer.writeAttribute(QStringLiteral("idx"),style_effectref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),style_effectref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // effectRef
writer.writeStartElement(QStringLiteral("a:fontRef"));//fontRef
writer.writeAttribute(QStringLiteral("idx"),style_forntref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),style_forntref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // fontRef
writer.writeEndElement(); // style
writer.writeEndElement(); //xdr:sp
}
void DrawingAnchor::saveXmlObjectGraphicFrame(QXmlStreamWriter &writer) const
@ -354,7 +650,7 @@ void DrawingAnchor::saveXmlObjectPicture(QXmlStreamWriter &writer) const
writer.writeStartElement(QStringLiteral("xdr:nvPicPr"));
writer.writeEmptyElement(QStringLiteral("xdr:cNvPr"));
writer.writeAttribute(QStringLiteral("id"), QString::number(m_id));
writer.writeAttribute(QStringLiteral("id"), QString::number(m_id+1)); // liufeijin
writer.writeAttribute(QStringLiteral("name"), QStringLiteral("Picture %1").arg(m_id));
writer.writeStartElement(QStringLiteral("xdr:cNvPicPr"));
@ -391,7 +687,134 @@ void DrawingAnchor::saveXmlObjectPicture(QXmlStreamWriter &writer) const
void DrawingAnchor::saveXmlObjectShape(QXmlStreamWriter &writer) const
{
Q_UNUSED(writer)
//{{ liufeijin
writer.writeStartElement(QStringLiteral("xdr:sp")); //xdr:sp
writer.writeAttribute(QStringLiteral("macro"), sp_macro);
writer.writeAttribute(QStringLiteral("textlink"),sp_textlink);
writer.writeStartElement(QStringLiteral("xdr:nvSpPr"));//xdr:nvSpPr
writer.writeStartElement(QStringLiteral("xdr:cNvPr"));
writer.writeAttribute(QStringLiteral("id"), xsp_cNvPR_id);
writer.writeAttribute(QStringLiteral("name"), xsp_cNvPR_name);
writer.writeStartElement(QStringLiteral("a:extLst"));
writer.writeEndElement();
writer.writeEndElement();//xdr:cNvPr
writer.writeEmptyElement(QStringLiteral("xdr:cNvSpPr"));
writer.writeEndElement(); //xdr:nvSpPr
writer.writeStartElement(QStringLiteral("xdr:spPr"));
if(!xbwMode.isNull()){
writer.writeAttribute(QStringLiteral("bwMode"), xbwMode);
}
writer.writeStartElement(QStringLiteral("a:xfrm"));
writer.writeEmptyElement(QStringLiteral("a:off"));
writer.writeAttribute(QStringLiteral("x"), QString::number(posTA.x()));
writer.writeAttribute(QStringLiteral("y"), QString::number(posTA.y()));
writer.writeEmptyElement(QStringLiteral("a:ext"));
writer.writeAttribute(QStringLiteral("cx"), QString::number(extTA.width()));
writer.writeAttribute(QStringLiteral("cy"), QString::number(extTA.height()));
writer.writeEndElement(); //a:xfrm
writer.writeStartElement(QStringLiteral("a:prstGeom"));
writer.writeAttribute(QStringLiteral("prst"), xprstGeom_prst);
writer.writeEmptyElement(QStringLiteral("a:avLst"));
writer.writeEndElement(); //a:prstGeom
if(!m_pictureFile.isNull()){
m_drawing->relationships()->addDocumentRelationship(QStringLiteral("/image"), QStringLiteral("../media/image%1.%2").arg(m_pictureFile->index()+1).arg(m_pictureFile->suffix()));
writer.writeStartElement(QStringLiteral("a:blipFill"));
writer.writeAttribute(QStringLiteral("dpi"), QString::number(dpiTA));
writer.writeAttribute(QStringLiteral("rotWithShape"),QString::number(rotWithShapeTA));
writer.writeStartElement(QStringLiteral("a:blip"));
writer.writeAttribute(QStringLiteral("r:embed"),QStringLiteral("rId%1").arg(m_drawing->relationships()->count())); //sp_blip_rembed QStringLiteral("rId%1").arg(m_drawing->relationships()->count()) can't made new pic
writer.writeAttribute(QStringLiteral("xmlns:r"), QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"));
if(!sp_blip_cstate.isNull()){
writer.writeAttribute(QStringLiteral("cstate"), sp_blip_cstate);
}
writer.writeEndElement();//a:blip
writer.writeEmptyElement(QStringLiteral("a:srcRect"));
writer.writeStartElement(QStringLiteral("a:stretch"));
writer.writeEmptyElement(QStringLiteral("a:fillRect"));
writer.writeEndElement(); //a:stretch
writer.writeEndElement();//a:blipFill
}
writer.writeStartElement(QStringLiteral("a:ln"));
if(!xIn_w.isEmpty()&&!xIn_cap.isEmpty()){
if(!xIn_w.isEmpty()){
writer.writeAttribute(QStringLiteral("w"), xIn_w);
}
if(!xIn_cap.isEmpty()){
writer.writeAttribute(QStringLiteral("cap"), xIn_cap);
}
if(!xIn_cmpd.isEmpty()){
writer.writeAttribute(QStringLiteral("cmpd"), xIn_cmpd);
}
if(!xIn_algn.isEmpty()){
writer.writeAttribute(QStringLiteral("algn"), xIn_algn);
}
}
if((!x_headEnd_tyep.isEmpty())||(!x_headEnd_w.isEmpty())||(!x_headEnd_len.isEmpty())){
writer.writeEmptyElement(QStringLiteral("a:headEnd"));
if(!x_headEnd_tyep.isEmpty()){
writer.writeAttribute(QStringLiteral("type"),x_headEnd_tyep);
}
if(!x_headEnd_w.isEmpty()){
writer.writeAttribute(QStringLiteral("w"),x_headEnd_w);
}
if(!x_headEnd_len.isEmpty()){
writer.writeAttribute(QStringLiteral("len"),x_headEnd_len);
}
}
if((!x_tailEnd_tyep.isEmpty())||(!x_tailEnd_w.isEmpty())||(!x_tailEnd_len.isEmpty())){
writer.writeEmptyElement(QStringLiteral("a:tailEnd"));
if(!x_tailEnd_tyep.isEmpty()){
writer.writeAttribute(QStringLiteral("type"),x_tailEnd_tyep);}
if(!x_tailEnd_w.isEmpty()){
writer.writeAttribute(QStringLiteral("w"),x_tailEnd_w);}
if(!x_tailEnd_len.isEmpty()){
writer.writeAttribute(QStringLiteral("len"),x_tailEnd_len);}
}
writer.writeEndElement();//a:ln
writer.writeEndElement(); //xdr:spPr
// writer style
writer.writeStartElement(QStringLiteral("xdr:style"));// style
writer.writeStartElement(QStringLiteral("a:lnRef"));//lnRef
writer.writeAttribute(QStringLiteral("idx"),Style_inref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),Style_inref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // lnRef
writer.writeStartElement(QStringLiteral("a:fillRef"));//fillRef
writer.writeAttribute(QStringLiteral("idx"),style_fillref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),style_fillref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // fillRef
writer.writeStartElement(QStringLiteral("a:effectRef"));//effectRef
writer.writeAttribute(QStringLiteral("idx"),style_effectref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),style_effectref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // effectRef
writer.writeStartElement(QStringLiteral("a:fontRef"));//fontRef
writer.writeAttribute(QStringLiteral("idx"),style_forntref_idx);
writer.writeStartElement(QStringLiteral("a:schemeClr"));//val
writer.writeAttribute(QStringLiteral("val"),style_forntref_val);
writer.writeEndElement(); // val
writer.writeEndElement(); // fontRef
writer.writeEndElement(); // style
writer.writeEndElement(); //xdr:sp
//}} liufeijin
}
//absolute anchor
@ -494,6 +917,12 @@ DrawingTwoCellAnchor::DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectTy
bool DrawingTwoCellAnchor::loadFromXml(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("twoCellAnchor"));
//{{ liufeijin
QXmlStreamAttributes attrs = reader.attributes(); // for absolute twocell aadd by liufeijin 20181024
editASName=attrs.value(QLatin1String("editAs")).toString();
//}}
while (!reader.atEnd()) {
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
@ -516,27 +945,19 @@ bool DrawingTwoCellAnchor::loadFromXml(QXmlStreamReader &reader)
void DrawingTwoCellAnchor::saveToXml(QXmlStreamWriter &writer) const
{
writer.writeStartElement(QStringLiteral("xdr:twoCellAnchor"));
writer.writeAttribute(QStringLiteral("editAs"), QStringLiteral("oneCell"));
//{{ liufeijin
// writer.writeAttribute(QStringLiteral("editAs"), QStringLiteral("oneCell"));
if(!editASName.isNull()){
writer.writeAttribute(QStringLiteral("editAs"), editASName ); //QStringLiteral("oneCell")
}
// }}
saveXmlMarker(writer, from, QStringLiteral("xdr:from"));
saveXmlMarker(writer, to, QStringLiteral("xdr:to"));
saveXmlObject(writer);
writer.writeStartElement(QStringLiteral("xdr:sp"));
writer.writeAttribute(QStringLiteral("textlink"), QStringLiteral(""));
writer.writeAttribute(QStringLiteral("macro"), QStringLiteral(""));
writer.writeStartElement(QStringLiteral("xdr:nvSpPr"));
writer.writeEmptyElement(QStringLiteral("xdr:cNvPr"));
writer.writeAttribute(QStringLiteral("id"), QStringLiteral("2")); //QStringLiteral("id"), QString::number(m_id)
writer.writeAttribute(QStringLiteral("name"), QStringLiteral("1")); //QStringLiteral("name"), QStringLiteral("Picture %1").arg(m_id)
writer.writeEmptyElement(QStringLiteral("xdr:cNvSpPr"));
writer.writeEndElement();// //xdr:nvSpPr
writer.writeEmptyElement(QStringLiteral("xdr:spPr"));
writer.writeEndElement();//xdr:sp add by liufeijin 20181018
writer.writeEmptyElement(QStringLiteral("xdr:clientData"));
writer.writeEndElement(); //xdr:twoCellAnchor

View File

@ -1224,6 +1224,54 @@ void Worksheet::saveToXmlFile(QIODevice *device) const
foreach (const ConditionalFormatting cf, d->conditionalFormattingList)
cf.saveToXml(writer);
d->saveXmlDataValidations(writer);
//{{ liufeijin
// write pagesettings add by liufeijin 20181028
writer.writeEmptyElement(QStringLiteral("pageMargins"));
if(!d->PMleft.isEmpty()){
writer.writeAttribute(QStringLiteral("left"), d->PMleft);}
if(!d->PMright.isEmpty()){
writer.writeAttribute(QStringLiteral("right"), d->PMright);}
if(!d->PMtop.isEmpty()){
writer.writeAttribute(QStringLiteral("top"),d->PMtop);}
if(!d->PMbotton.isEmpty()){
writer.writeAttribute(QStringLiteral("bottom"), d->PMbotton);}
if(!d->PMheader.isEmpty()){
writer.writeAttribute(QStringLiteral("header"), d->PMheader);}
if(!d->PMfooter.isEmpty()){
writer.writeAttribute(QStringLiteral("footer"), d->PMfooter);}
writer.writeEmptyElement(QStringLiteral("pageSetup"));
if(!d->PverticalDpi.isEmpty()){
writer.writeAttribute(QStringLiteral("verticalDpi"), d->PverticalDpi);}
if(!d->PhorizontalDpi.isEmpty()){
writer.writeAttribute(QStringLiteral("horizontalDpi"), d->PhorizontalDpi);}
if(!d->PuseFirstPageNumber.isEmpty()){
writer.writeAttribute(QStringLiteral("useFirstPageNumber"), d->PuseFirstPageNumber);}
if(!d->PfirstPageNumber.isEmpty()){
writer.writeAttribute(QStringLiteral("firstPageNumber"), d->PfirstPageNumber);}
if(!d->Pscale.isEmpty()){
writer.writeAttribute(QStringLiteral("scale"), d->Pscale);}
if(!d->PpaperSize.isEmpty()){
writer.writeAttribute(QStringLiteral("paperSize"), d->PpaperSize);}
if(!d->Porientation.isEmpty()){
writer.writeAttribute(QStringLiteral("orientation"), d->Porientation);}
if(!d->Pcopies.isEmpty()){
writer.writeAttribute(QStringLiteral("copies"), d->Pcopies);}
// if(!d->Prid.isEmpty()){
// writer.writeAttribute(QStringLiteral("r:id"), d->Prid);}
if((!d->MoodFooter.isNull())||!(d->MoodFooter.isNull())){
writer.writeStartElement(QStringLiteral("headerFooter")); // headerFooter
if (!d->ModdHeader.isNull()){
writer.writeTextElement(QStringLiteral("oddHeader"), d->ModdHeader);}
if(!d->MoodFooter.isNull()){
writer.writeTextElement(QStringLiteral("oddFooter"), d->MoodFooter);}
writer.writeEndElement();// headerFooter
}
//}}
d->saveXmlHyperlinks(writer);
d->saveXmlDrawings(writer);
@ -1231,6 +1279,14 @@ void Worksheet::saveToXmlFile(QIODevice *device) const
writer.writeEndDocument();
}
//{{ liufeijin
bool Worksheet::setStartPage(int spagen){
Q_D(Worksheet);
d->PfirstPageNumber=QString::number(spagen);
return true;
}
//}}
void WorksheetPrivate::saveXmlSheetData(QXmlStreamWriter &writer) const
{
calculateSpans();
@ -2314,6 +2370,32 @@ bool Worksheet::loadFromXmlFile(QIODevice *device)
d->conditionalFormattingList.append(cf);
} else if (reader.name() == QLatin1String("hyperlinks")) {
d->loadXmlHyperlinks(reader);
//{{
} else if(reader.name() == QLatin1String("pageSetup")){
QXmlStreamAttributes attributes = reader.attributes();
d->PpaperSize = attributes.value(QLatin1String("paperSize")).toString().trimmed();
d->Pscale = attributes.value(QLatin1String("scale")).toString().trimmed();
d->PfirstPageNumber = attributes.value(QLatin1String("firstPageNumber")).toString().trimmed();
d->Porientation = attributes.value(QLatin1String("orientation")).toString().trimmed();
d->PuseFirstPageNumber = attributes.value(QLatin1String("useFirstPageNumber")).toString().trimmed();
d->PhorizontalDpi = attributes.value(QLatin1String("horizontalDpi")).toString().trimmed();
d->PverticalDpi = attributes.value(QLatin1String("verticalDpi")).toString().trimmed();
d->Prid=attributes.value(QLatin1String("r:id")).toString().trimmed();
d->Pcopies=attributes.value(QLatin1String("copies")).toString().trimmed();
} else if(reader.name() == QLatin1String("pageMargins")){
QXmlStreamAttributes attributes = reader.attributes();
d->PMfooter= attributes.value(QLatin1String("footer")).toString().trimmed();
d->PMheader = attributes.value(QLatin1String("header")).toString().trimmed();
d->PMbotton = attributes.value(QLatin1String("bottom")).toString().trimmed();
d->PMtop = attributes.value(QLatin1String("top")).toString().trimmed();
d->PMright = attributes.value(QLatin1String("right")).toString().trimmed();
d->PMleft = attributes.value(QLatin1String("left")).toString().trimmed();
} else if(reader.name() == QLatin1String("headerFooter")){
reader.readNextStartElement();
if ((reader.tokenType() == QXmlStreamReader::StartElement)&&\
reader.name() == QLatin1String("oddHeader")) {
d->ModdHeader=reader.readElementText();
//}}
} else if (reader.name() == QLatin1String("drawing")) {
QString rId = reader.attributes().value(QStringLiteral("r:id")).toString();
QString name = d->relationships->getRelationshipById(rId).target;