12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208 |
- // xlsxdrawinganchor.cpp
- #include <QtGlobal>
- #include <QDebug>
- #include <QXmlStreamReader>
- #include <QXmlStreamWriter>
- #include <QBuffer>
- #include <QDir>
- #include "xlsxdrawinganchor_p.h"
- #include "xlsxdrawing_p.h"
- #include "xlsxmediafile_p.h"
- #include "xlsxchart.h"
- #include "xlsxworkbook.h"
- #include "xlsxutility_p.h"
- QT_BEGIN_NAMESPACE_XLSX
- /*
- The vertices that define the position of a graphical object
- within the worksheet in pixels.
- +------------+------------+
- | A | B |
- +-----+------------+------------+
- | |(x1,y1) | |
- | 1 |(A1)._______|______ |
- | | | | |
- | | | | |
- +-----+----| OBJECT |-----+
- | | | | |
- | 2 | |______________. |
- | | | (B2)|
- | | | (x2,y2)|
- +---- +------------+------------+
- Example of an object that covers some of the area from cell A1 to B2.
- Based on the width and height of the object we need to calculate 8 vars:
- col_start, row_start, col_end, row_end, x1, y1, x2, y2.
- We also calculate the absolute x and y position of the top left vertex of
- the object. This is required for images.
- The width and height of the cells that the object occupies can be
- variable and have to be taken into account.
- */
- //anchor
- DrawingAnchor::DrawingAnchor(Drawing *drawing, ObjectType objectType)
- :m_drawing(drawing), m_objectType(objectType)
- {
- m_drawing->anchors.append(this);
- m_id = m_drawing->anchors.size();//must be unique in one drawing{x}.xml file.
- }
- DrawingAnchor::~DrawingAnchor()
- {
- }
- void DrawingAnchor::setObjectPicture(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 = Picture;
- }
- bool DrawingAnchor::getObjectPicture(QImage &img)
- {
- if ( m_pictureFile == nullptr )
- return false;
- bool ret = img.loadFromData( m_pictureFile->contents() );
- return ret;
- }
- //{{ 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;
- m_drawing->workbook->addChartFile(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"));
- QPoint pos;
- QXmlStreamAttributes attrs = reader.attributes();
- pos.setX(attrs.value(QLatin1String("x")).toString().toInt());
- pos.setY(attrs.value(QLatin1String("y")).toString().toInt());
- return pos;
- }
- QSize DrawingAnchor::loadXmlExt(QXmlStreamReader &reader)
- {
- Q_ASSERT(reader.name() == QLatin1String("ext"));
- QSize size;
- QXmlStreamAttributes attrs = reader.attributes();
- size.setWidth(attrs.value(QLatin1String("cx")).toString().toInt());
- size.setHeight(attrs.value(QLatin1String("cy")).toString().toInt());
- return size;
- }
- XlsxMarker DrawingAnchor::loadXmlMarker(QXmlStreamReader &reader, const QString &node)
- {
- Q_ASSERT(reader.name() == node);
- int col = 0;
- int colOffset = 0;
- int row = 0;
- int rowOffset = 0;
- while (!reader.atEnd())
- {
- reader.readNextStartElement();
- if (reader.tokenType() == QXmlStreamReader::StartElement)
- {
- if (reader.name() == QLatin1String("col"))
- {
- col = reader.readElementText().toInt();
- }
- else if (reader.name() == QLatin1String("colOff"))
- {
- colOffset = reader.readElementText().toInt();
- }
- else if (reader.name() == QLatin1String("row"))
- {
- row = reader.readElementText().toInt();
- }
- else if (reader.name() == QLatin1String("rowOff"))
- {
- rowOffset = reader.readElementText().toInt();
- }
- }
- else if (reader.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == node)
- {
- break;
- }
- }
- return XlsxMarker(row, col, rowOffset, colOffset);
- }
- void DrawingAnchor::loadXmlObject(QXmlStreamReader &reader)
- {
- /*
- <xsd:group name="EG_ObjectChoices">
- <xsd:sequence>
- <xsd:choice minOccurs="1" maxOccurs="1">
- <xsd:element name="sp" type="CT_Shape"/>
- <xsd:element name="grpSp" type="CT_GroupShape"/>
- <xsd:element name="graphicFrame" type="CT_GraphicalObjectFrame"/>
- <xsd:element name="cxnSp" type="CT_Connector"/>
- <xsd:element name="pic" type="CT_Picture"/>
- <xsd:element name="contentPart" type="CT_Rel"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:group>
- */
- if (reader.name() == QLatin1String("sp")) // <xsd:element name="sp" type="CT_Shape"/>
- {
- // Shape
- m_objectType = Shape;
- //{{ liufeijin
- sp_textlink = reader.attributes().value(QLatin1String("textlink")).toString();
- sp_macro = reader.attributes().value(QLatin1String("macro")).toString();
- //}}
- // <xsd:attribute name="macro" type="xsd:string" use="optional"/>
- // <xsd:attribute name="textlink" type="xsd:string" use="optional"/>
- // <xsd:attribute name="fLocksText" type="xsd:boolean" use="optional" default="true"/>
- // <xsd:attribute name="fPublished" type="xsd:boolean" use="optional" default="false"/>
- loadXmlObjectShape(reader); // CT_Shape
- }
- else if (reader.name() == QLatin1String("grpSp")) // <xsd:element name="grpSp" type="CT_GroupShape"/>
- {
- //Group Shape
- m_objectType = GroupShape;
- loadXmlObjectGroupShape(reader);
- }
- else if (reader.name() == QLatin1String("graphicFrame")) // <xsd:element name="graphicFrame" type="CT_GraphicalObjectFrame"/>
- {
- //Graphic Frame
- m_objectType = GraphicFrame;
- loadXmlObjectGraphicFrame(reader);
- }
- else if (reader.name() == QLatin1String("cxnSp")) // <xsd:element name="cxnSp" type="CT_Connector"/>
- {
- //Connection Shape
- m_objectType = ConnectionShape;
- // {{ liufeijin
- cxnSp_macro = reader.attributes().value(QLatin1String("macro")).toString();
- // }}
- loadXmlObjectConnectionShape(reader);
- }
- else if (reader.name() == QLatin1String("pic")) // <xsd:element name="pic" type="CT_Picture"/>
- {
- // Picture
- m_objectType = Picture;
- loadXmlObjectPicture(reader);
- }
- else if (reader.name() == QLatin1String("contentPart")) // <xsd:element name="contentPart" type="CT_Rel"/>
- {
- // contentPart
- /// TODO:
- }
- }
- void DrawingAnchor::loadXmlObjectConnectionShape(QXmlStreamReader &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)
- {
- Q_ASSERT(reader.name() == QLatin1String("graphicFrame"));
- while (!reader.atEnd()) {
- reader.readNextStartElement();
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == QLatin1String("chart")) {
- QString rId = reader.attributes().value(QLatin1String("r:id")).toString();
- QString name = m_drawing->relationships()->getRelationshipById(rId).target;
- QString str = *( splitPath(m_drawing->filePath()).begin() );
- str = str + QLatin1String("/");
- str = str + name;
- QString path = QDir::cleanPath(str);
- bool exist = false;
- QList<QSharedPointer<Chart> > cfs = m_drawing->workbook->chartFiles();
- for (int i=0; i<cfs.size(); ++i) {
- if (cfs[i]->filePath() == path) {
- //already exist
- exist = true;
- m_chartFile = cfs[i];
- }
- }
- if (!exist) {
- m_chartFile = QSharedPointer<Chart> (new Chart(m_drawing->sheet, Chart::F_LoadFromExists));
- m_chartFile->setFilePath(path);
- m_drawing->workbook->addChartFile(m_chartFile);
- }
- }
- } else if (reader.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == QLatin1String("graphicFrame")) {
- break;
- }
- }
- return;
- }
- void DrawingAnchor::loadXmlObjectGroupShape(QXmlStreamReader &reader)
- {
- Q_UNUSED(reader)
- }
- void DrawingAnchor::loadXmlObjectPicture(QXmlStreamReader &reader)
- {
- Q_ASSERT(reader.name() == QLatin1String("pic"));
- while (!reader.atEnd()) {
- reader.readNextStartElement();
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == QLatin1String("blip")) {
- QString rId = reader.attributes().value(QLatin1String("r:embed")).toString();
- QString name = m_drawing->relationships()->getRelationshipById(rId).target;
- QString str = *( splitPath(m_drawing->filePath()).begin() );
- str = str + QLatin1String("/");
- str = str + name;
- QString path = QDir::cleanPath( str );
- 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.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == QLatin1String("pic")) {
- break;
- }
- }
- return;
- }
- void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
- {
- /*
- <xsd:complexType name="CT_Shape">
- <xsd:sequence>
- <xsd:element name="nvSpPr" type="CT_ShapeNonVisual" minOccurs="1" maxOccurs="1"/>
- <xsd:element name="spPr" type="a:CT_ShapeProperties" minOccurs="1" maxOccurs="1"/>
- <xsd:element name="style" type="a:CT_ShapeStyle" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="txBody" type="a:CT_TextBody" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="macro" type="xsd:string" use="optional"/>
- <xsd:attribute name="textlink" type="xsd:string" use="optional"/>
- <xsd:attribute name="fLocksText" type="xsd:boolean" use="optional" default="true"/>
- <xsd:attribute name="fPublished" type="xsd:boolean" use="optional" default="false"/>
- </xsd:complexType>
- */
- /*
- <xsd:complexType name="CT_ShapeNonVisual">
- <xsd:sequence>
- <xsd:element name="cNvPr" type="a:CT_NonVisualDrawingProps" minOccurs="1" maxOccurs="1"/>
- <xsd:element name="cNvSpPr" type="a:CT_NonVisualDrawingShapeProps" minOccurs="1" maxOccurs="1"/>
- </xsd:sequence>
- </xsd:complexType>
- */
- Q_ASSERT(reader.name() == QLatin1String("sp"));
- bool hasoffext = false;
- while (!reader.atEnd())
- {
- reader.readNextStartElement();
- // qDebug() << __FUNCTION__ << reader.name().toString();
- if (reader.tokenType() == QXmlStreamReader::StartElement)
- {
- if (reader.name() == QLatin1String("nvSpPr"))
- {
- }
- else if (reader.name() == QLatin1String("spPr"))
- {
- }
- else if (reader.name() == QLatin1String("style"))
- {
- }
- else if (reader.name() == QLatin1String("txBody"))
- {
- }
- }
- else if (reader.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == QLatin1String("sp"))
- {
- break;
- }
- }
- /*
- bool hasoffext = false;
- while (!reader.atEnd())
- {
- reader.readNextStartElement();
- // qDebug() << __FUNCTION__ << reader.name().toString();
- 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"))
- {
- // dev24 : fixed for old Qt 5
- rotWithShapeTA = reader.attributes().value(QLatin1String("rotWithShape")).toString().toInt();
- dpiTA = reader.attributes().value(QLatin1String("dpi")).toString().toInt();
- // 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
- {
- writer.writeEmptyElement(QStringLiteral("xdr:pos"));
- writer.writeAttribute(QStringLiteral("x"), QString::number(pos.x()));
- writer.writeAttribute(QStringLiteral("y"), QString::number(pos.y()));
- }
- void DrawingAnchor::saveXmlExt(QXmlStreamWriter &writer, const QSize &ext) const
- {
- writer.writeStartElement(QStringLiteral("xdr:ext"));
- writer.writeAttribute(QStringLiteral("cx"), QString::number(ext.width()));
- writer.writeAttribute(QStringLiteral("cy"), QString::number(ext.height()));
- writer.writeEndElement(); //xdr:ext
- }
- void DrawingAnchor::saveXmlMarker(QXmlStreamWriter &writer, const XlsxMarker &marker, const QString &node) const
- {
- writer.writeStartElement(node); //xdr:from or xdr:to
- writer.writeTextElement(QStringLiteral("xdr:col"), QString::number(marker.col()));
- writer.writeTextElement(QStringLiteral("xdr:colOff"), QString::number(marker.colOff()));
- writer.writeTextElement(QStringLiteral("xdr:row"), QString::number(marker.row()));
- writer.writeTextElement(QStringLiteral("xdr:rowOff"), QString::number(marker.rowOff()));
- writer.writeEndElement();
- }
- void DrawingAnchor::saveXmlObject(QXmlStreamWriter &writer) const
- {
- if (m_objectType == Picture)
- saveXmlObjectPicture(writer);
- else if (m_objectType == ConnectionShape)
- saveXmlObjectConnectionShape(writer);
- else if (m_objectType == GraphicFrame)
- saveXmlObjectGraphicFrame(writer);
- else if (m_objectType == GroupShape)
- saveXmlObjectGroupShape(writer);
- else if (m_objectType == Shape)
- saveXmlObjectShape(writer);
- }
- void DrawingAnchor::saveXmlObjectConnectionShape(QXmlStreamWriter &writer) const
- {
- 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
- {
- writer.writeStartElement(QStringLiteral("xdr:graphicFrame"));
- writer.writeAttribute(QStringLiteral("macro"), QString());
- writer.writeStartElement(QStringLiteral("xdr:nvGraphicFramePr"));
- writer.writeEmptyElement(QStringLiteral("xdr:cNvPr"));
- writer.writeAttribute(QStringLiteral("id"), QString::number(m_id));
- writer.writeAttribute(QStringLiteral("name"), QStringLiteral("Chart %1").arg(m_id));
- writer.writeEmptyElement(QStringLiteral("xdr:cNvGraphicFramePr"));
- writer.writeEndElement();//xdr:nvGraphicFramePr
- writer.writeStartElement(QStringLiteral("xdr:xfrm"));
- writer.writeEndElement(); //xdr:xfrm
- writer.writeStartElement(QStringLiteral("a:graphic"));
- writer.writeStartElement(QStringLiteral("a:graphicData"));
- writer.writeAttribute(QStringLiteral("uri"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/chart"));
- int idx = m_drawing->workbook->chartFiles().indexOf(m_chartFile);
- m_drawing->relationships()->addDocumentRelationship(QStringLiteral("/chart"), QStringLiteral("../charts/chart%1.xml").arg(idx+1));
- writer.writeEmptyElement(QStringLiteral("c:chart"));
- writer.writeAttribute(QStringLiteral("xmlns:c"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/chart"));
- writer.writeAttribute(QStringLiteral("xmlns:r"), QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"));
- writer.writeAttribute(QStringLiteral("r:id"), QStringLiteral("rId%1").arg(m_drawing->relationships()->count()));
- writer.writeEndElement(); //a:graphicData
- writer.writeEndElement(); //a:graphic
- writer.writeEndElement(); //xdr:graphicFrame
- }
- void DrawingAnchor::saveXmlObjectGroupShape(QXmlStreamWriter &writer) const
- {
- Q_UNUSED(writer)
- }
- void DrawingAnchor::saveXmlObjectPicture(QXmlStreamWriter &writer) const
- {
- Q_ASSERT(m_objectType == Picture && !m_pictureFile.isNull());
- writer.writeStartElement(QStringLiteral("xdr:pic"));
- writer.writeStartElement(QStringLiteral("xdr:nvPicPr"));
- writer.writeEmptyElement(QStringLiteral("xdr:cNvPr"));
- 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"));
- writer.writeEmptyElement(QStringLiteral("a:picLocks"));
- writer.writeAttribute(QStringLiteral("noChangeAspect"), QStringLiteral("1"));
- writer.writeEndElement(); //xdr:cNvPicPr
- writer.writeEndElement(); //xdr:nvPicPr
- m_drawing->relationships()->addDocumentRelationship(QStringLiteral("/image"), QStringLiteral("../media/image%1.%2")
- .arg(m_pictureFile->index()+1)
- .arg(m_pictureFile->suffix()));
- writer.writeStartElement(QStringLiteral("xdr:blipFill"));
- writer.writeEmptyElement(QStringLiteral("a:blip"));
- writer.writeAttribute(QStringLiteral("xmlns:r"), QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships"));
- writer.writeAttribute(QStringLiteral("r:embed"), QStringLiteral("rId%1").arg(m_drawing->relationships()->count()));
- writer.writeStartElement(QStringLiteral("a:stretch"));
- writer.writeEmptyElement(QStringLiteral("a:fillRect"));
- writer.writeEndElement(); //a:stretch
- writer.writeEndElement();//xdr:blipFill
- writer.writeStartElement(QStringLiteral("xdr:spPr"));
- writer.writeStartElement(QStringLiteral("a:prstGeom"));
- writer.writeAttribute(QStringLiteral("prst"), QStringLiteral("rect"));
- writer.writeEmptyElement(QStringLiteral("a:avLst"));
- writer.writeEndElement(); //a:prstGeom
- writer.writeEndElement(); //xdr:spPr
- writer.writeEndElement(); //xdr:pic
- }
- int DrawingAnchor::getm_id()
- {
- return (this->m_id);
- }
- void DrawingAnchor::saveXmlObjectShape(QXmlStreamWriter &writer) const
- {
- //{{ 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
- DrawingAbsoluteAnchor::DrawingAbsoluteAnchor(Drawing *drawing, ObjectType objectType)
- :DrawingAnchor(drawing, objectType)
- {
- }
- // check point
- bool DrawingAbsoluteAnchor::loadFromXml(QXmlStreamReader &reader)
- {
- Q_ASSERT(reader.name() == QLatin1String("absoluteAnchor"));
- while (!reader.atEnd()) {
- reader.readNextStartElement();
- if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == QLatin1String("pos"))
- {
- pos = loadXmlPos(reader);
- }
- else if (reader.name() == QLatin1String("ext"))
- {
- ext = loadXmlExt(reader);
- }
- else
- {
- loadXmlObject(reader);
- }
- }
- else if (reader.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == QLatin1String("absoluteAnchor"))
- {
- break;
- }
- }
- return true;
- }
- void DrawingAbsoluteAnchor::saveToXml(QXmlStreamWriter &writer) const
- {
- writer.writeStartElement(QStringLiteral("xdr:absoluteAnchor"));
- saveXmlPos(writer, pos);
- saveXmlExt(writer, ext);
- saveXmlObject(writer);
- writer.writeEmptyElement(QStringLiteral("xdr:clientData"));
- writer.writeEndElement(); //xdr:absoluteAnchor
- }
- //one cell anchor
- DrawingOneCellAnchor::DrawingOneCellAnchor(Drawing *drawing, ObjectType objectType)
- :DrawingAnchor(drawing, objectType)
- {
- }
- int DrawingOneCellAnchor::row()
- {
- return from.row();
- }
- int DrawingOneCellAnchor::col()
- {
- return from.col();
- }
- // check point
- bool DrawingOneCellAnchor::loadFromXml(QXmlStreamReader &reader)
- {
- Q_ASSERT(reader.name() == QLatin1String("oneCellAnchor"));
- while (!reader.atEnd())
- {
- reader.readNextStartElement();
- if (reader.tokenType() == QXmlStreamReader::StartElement)
- {
- if (reader.name() == QLatin1String("from"))
- {
- from = loadXmlMarker(reader, QLatin1String("from"));
- }
- else if (reader.name() == QLatin1String("ext"))
- {
- ext = loadXmlExt(reader);
- }
- else
- {
- loadXmlObject(reader);
- }
- }
- else if (reader.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == QLatin1String("oneCellAnchor"))
- {
- break;
- }
- }
- return true;
- }
- void DrawingOneCellAnchor::saveToXml(QXmlStreamWriter &writer) const
- {
- writer.writeStartElement(QStringLiteral("xdr:oneCellAnchor"));
- saveXmlMarker(writer, from, QStringLiteral("xdr:from"));
- saveXmlExt(writer, ext);
- saveXmlObject(writer);
- writer.writeEmptyElement(QStringLiteral("xdr:clientData"));
- writer.writeEndElement(); //xdr:oneCellAnchor
- }
- /*
- Two cell anchor
- This class specifies a two cell anchor placeholder for a group
- , a shape, or a drawing element. It moves with
- cells and its extents are in EMU units.
- */
- DrawingTwoCellAnchor::DrawingTwoCellAnchor(Drawing *drawing, ObjectType objectType)
- :DrawingAnchor(drawing, objectType)
- {
- }
- int DrawingTwoCellAnchor::row()
- {
- return from.row();
- }
- int DrawingTwoCellAnchor::col()
- {
- return from.col();
- }
- // check point
- bool DrawingTwoCellAnchor::loadFromXml(QXmlStreamReader &reader)
- {
- Q_ASSERT(reader.name() == QLatin1String("twoCellAnchor"));
- /*
- <xsd:complexType name="CT_TwoCellAnchor">
- <xsd:sequence>
- <xsd:element name="from" type="CT_Marker"/>
- <xsd:element name="to" type="CT_Marker"/>
- <xsd:group ref="EG_ObjectChoices"/>
- <xsd:element name="clientData" type="CT_AnchorClientData" minOccurs="1" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="editAs" type="ST_EditAs" use="optional" default="twoCell"/>
- </xsd:complexType>
- */
- //{{ 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)
- {
- if (reader.name() == QLatin1String("from"))
- {
- from = loadXmlMarker(reader, QLatin1String("from"));
- }
- else if (reader.name() == QLatin1String("to"))
- {
- to = loadXmlMarker(reader, QLatin1String("to"));
- }
- else if (reader.name() == QLatin1String("clientData"))
- {
- // clientData
- }
- else
- {
- /*
- <xsd:group name="EG_ObjectChoices">
- <xsd:sequence>
- <xsd:choice minOccurs="1" maxOccurs="1">
- <xsd:element name="sp" type="CT_Shape"/>
- <xsd:element name="grpSp" type="CT_GroupShape"/>
- <xsd:element name="graphicFrame" type="CT_GraphicalObjectFrame"/>
- <xsd:element name="cxnSp" type="CT_Connector"/>
- <xsd:element name="pic" type="CT_Picture"/>
- <xsd:element name="contentPart" type="CT_Rel"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:group>
- */
- loadXmlObject(reader);
- }
- }
- else if (reader.tokenType() == QXmlStreamReader::EndElement
- && reader.name() == QLatin1String("twoCellAnchor"))
- {
- break;
- }
- }
- return true;
- }
- void DrawingTwoCellAnchor::saveToXml(QXmlStreamWriter &writer) const
- {
- writer.writeStartElement(QStringLiteral("xdr:twoCellAnchor"));
- //{{ 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.writeEmptyElement(QStringLiteral("xdr:clientData"));
- writer.writeEndElement(); //xdr:twoCellAnchor
- }
- QT_END_NAMESPACE_XLSX
|