File indexing completed on 2024-05-26 16:15:50

0001 /* This file is part of the  KDE project
0002  * Copyright (C) 2011 Smit Patel <smitpatel24@gmail.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #include "KoInlineCite.h"
0020 
0021 #include "KoInlineTextObjectManager.h"
0022 #include <KoXmlWriter.h>
0023 #include <KoXmlNS.h>
0024 #include <KoShapeSavingContext.h>
0025 #include <KoTextDocument.h>
0026 #include <KoOdfBibliographyConfiguration.h>
0027 #include <KoStyleManager.h>
0028 #include "TextDebug.h"
0029 
0030 #include <QTextDocument>
0031 #include <QTextInlineObject>
0032 #include <QFontMetricsF>
0033 #include <QTextOption>
0034 
0035 // Include Q_UNSUSED classes, for building on Windows
0036 #include <KoShapeLoadingContext.h>
0037 
0038 class Q_DECL_HIDDEN KoInlineCite::Private
0039 {
0040 public:
0041     Private(KoInlineCite::Type t)
0042         : type(t)
0043     {
0044     }
0045 
0046     KoInlineCite::Type type;
0047     int posInDocument;
0048     QString label;
0049 
0050     QString bibliographyType;
0051     QString identifier;
0052     QString address;
0053     QString annote;
0054     QString author;
0055     QString booktitle;
0056     QString chapter;
0057     QString edition;
0058     QString editor;
0059     QString publicationType;
0060     QString institution;
0061     QString journal;
0062     QString month;
0063     QString note;
0064     QString number;
0065     QString organisation;
0066     QString pages;
0067     QString publisher;
0068     QString school;             //university in UI and saved under text:school tag in XML format
0069     QString series;
0070     QString title;
0071     QString reportType;
0072     QString volume;
0073     QString year;
0074     QString url;
0075     QString isbn;
0076     QString issn;
0077     QString custom1;
0078     QString custom2;
0079     QString custom3;
0080     QString custom4;
0081     QString custom5;
0082 };
0083 
0084 KoInlineCite::KoInlineCite(Type type)
0085     :KoInlineObject(true)
0086     ,d(new Private(type))
0087 {
0088 }
0089 
0090 KoInlineCite::~KoInlineCite()
0091 {
0092     delete d;
0093 }
0094 
0095 KoInlineCite::Type KoInlineCite::type() const
0096 {
0097     return d->type;
0098 }
0099 
0100 void KoInlineCite::setType(Type t)
0101 {
0102     d->type = t;
0103 }
0104 
0105 QString KoInlineCite::dataField(const QString &fieldName) const
0106 {
0107     if ( fieldName == "address" ) {
0108         return d->address;
0109     } else if ( fieldName == "annote" ) {
0110         return d->annote;
0111     } else if ( fieldName == "author" ) {
0112         return d->author;
0113     } else if ( fieldName == "bibliography-type" ) {
0114         return d->bibliographyType;
0115     } else if ( fieldName == "booktitle" ) {
0116         return d->booktitle;
0117     } else if ( fieldName == "chapter" ) {
0118         return d->chapter;
0119     } else if ( fieldName == "custom1" ) {
0120         return d->custom1;
0121     } else if ( fieldName == "custom2" ) {
0122         return d->custom2;
0123     } else if ( fieldName == "custom3" ) {
0124         return d->custom3;
0125     } else if ( fieldName == "custom4" ) {
0126         return d->custom4;
0127     } else if ( fieldName == "custom5" ) {
0128         return d->custom5;
0129     } else if ( fieldName == "edition" ) {
0130         return d->edition;
0131     } else if ( fieldName == "editor" ) {
0132         return d->editor;
0133     } else if ( fieldName == "howpublished" ) {
0134         return d->publicationType;
0135     } else if ( fieldName == "identifier" ) {
0136         return d->identifier;
0137     } else if ( fieldName == "institution" ) {
0138         return d->institution;
0139     } else if ( fieldName == "isbn" ) {
0140         return d->isbn;
0141     } else if ( fieldName == "issn" ) {
0142         return d->issn;
0143     } else if ( fieldName == "journal" ) {
0144         return d->journal;
0145     } else if ( fieldName == "month" ) {
0146         return d->month;
0147     } else if ( fieldName == "note" ) {
0148         return d->note;
0149     } else if ( fieldName == "number" ) {
0150         return d->number;
0151     } else if ( fieldName == "organisations" ) {
0152         return d->organisation;
0153     } else if ( fieldName == "pages" ) {
0154         return d->pages;
0155     } else if ( fieldName == "publisher" ) {
0156         return d->publisher;
0157     } else if ( fieldName == "report-type" ) {
0158         return d->reportType;
0159     } else if ( fieldName == "school" ) {
0160         return d->school;
0161     } else if ( fieldName == "series" ) {
0162         return d->series;
0163     } else if ( fieldName == "title" ) {
0164         return d->title;
0165     } else if ( fieldName == "url" ) {
0166         return d->url;
0167     } else if ( fieldName == "volume" ) {
0168         return d->volume;
0169     } else if ( fieldName == "year" ) {
0170         return d->year;
0171     } else {
0172         return QString();
0173     }
0174 }
0175 
0176 void KoInlineCite::setIdentifier(const QString &identifier)
0177 {
0178     d->identifier = identifier;
0179 }
0180 
0181 void KoInlineCite::setAddress(const QString &addr)
0182 {
0183     d->address = addr;
0184 }
0185 
0186 void KoInlineCite::setAnnotation(const QString &annotation)
0187 {
0188     d->annote = annotation;
0189 }
0190 
0191 void KoInlineCite::setAuthor(const QString &author)
0192 {
0193     d->author = author;
0194 }
0195 
0196 void KoInlineCite::setBibliographyType(const QString &bibliographyType)
0197 {
0198     d->bibliographyType = bibliographyType;
0199 }
0200 
0201 void KoInlineCite::setBookTitle(const QString &booktitle)
0202 {
0203     d->booktitle = booktitle;
0204 }
0205 
0206 void KoInlineCite::setChapter(const QString &chapter)
0207 {
0208     d->chapter = chapter;
0209 }
0210 
0211 void KoInlineCite::setCustom1(const QString &custom1)
0212 {
0213     d->custom1 = custom1;
0214 }
0215 
0216 void KoInlineCite::setCustom2(const QString &custom2)
0217 {
0218     d->custom2 = custom2;
0219 }
0220 
0221 void KoInlineCite::setCustom3(const QString &custom3)
0222 {
0223     d->custom3 = custom3;
0224 }
0225 
0226 void KoInlineCite::setCustom4(const QString &custom4)
0227 {
0228     d->custom4 = custom4;
0229 }
0230 
0231 void KoInlineCite::setCustom5(const QString &custom5)
0232 {
0233     d->custom5 = custom5;
0234 }
0235 
0236 void KoInlineCite::setEdition(const QString &edition)
0237 {
0238     d->edition = edition;
0239 }
0240 
0241 void KoInlineCite::setEditor(const QString &editor)
0242 {
0243     d->editor = editor;
0244 }
0245 
0246 void KoInlineCite::setInstitution(const QString &institution)
0247 {
0248     d->institution = institution;
0249 }
0250 
0251 void KoInlineCite::setISBN(const QString &isbn)
0252 {
0253     d->isbn = isbn;
0254 }
0255 
0256 void KoInlineCite::setISSN(const QString &issn)
0257 {
0258     d->issn = issn;
0259 }
0260 
0261 void KoInlineCite::setJournal(const QString &journal)
0262 {
0263     d->journal = journal;
0264 }
0265 
0266 void KoInlineCite::setLabel(const QString &label)
0267 {
0268     d->label = label;
0269 }
0270 
0271 void KoInlineCite::setMonth(const QString &month)
0272 {
0273     d->month = month;
0274 }
0275 
0276 void KoInlineCite::setNote(const QString &note)
0277 {
0278     d->note = note;
0279 }
0280 
0281 void KoInlineCite::setNumber(const QString &number)
0282 {
0283     d->number = number;
0284 }
0285 
0286 void KoInlineCite::setOrganisation(const QString &organisation)
0287 {
0288     d->organisation = organisation;
0289 }
0290 
0291 void KoInlineCite::setPages(const QString &pages)
0292 {
0293     d->pages = pages;
0294 }
0295 
0296 void KoInlineCite::setPublicationType(const QString &publicationType)
0297 {
0298     d->publicationType = publicationType;
0299 }
0300 
0301 void KoInlineCite::setPublisher(const QString &publisher)
0302 {
0303     d->publisher = publisher;
0304 }
0305 
0306 void KoInlineCite::setReportType(const QString &reportType)
0307 {
0308     d->reportType = reportType;
0309 }
0310 
0311 void KoInlineCite::setSchool(const QString &school)
0312 {
0313     d->school = school;
0314 }
0315 
0316 void KoInlineCite::setSeries(const QString &series)
0317 {
0318     d->series = series;
0319 }
0320 
0321 void KoInlineCite::setTitle(const QString &title)
0322 {
0323     d->title = title;
0324 }
0325 
0326 void KoInlineCite::setURL(const QString &url)
0327 {
0328     d->url = url;
0329 }
0330 
0331 void KoInlineCite::setVolume(const QString &volume)
0332 {
0333     d->volume = volume;
0334 }
0335 
0336 void KoInlineCite::setYear(const QString &year)
0337 {
0338     d->year = year;
0339 }
0340 
0341 QString KoInlineCite::identifier() const
0342 {
0343     return d->identifier;
0344 }
0345 
0346 QString KoInlineCite::address() const
0347 {
0348     return d->address;
0349 }
0350 
0351 QString KoInlineCite::annotation() const
0352 {
0353     return d->annote;
0354 }
0355 
0356 QString KoInlineCite::author() const
0357 {
0358     return d->author;
0359 }
0360 
0361 QString KoInlineCite::bibliographyType() const
0362 {
0363     return d->bibliographyType;
0364 }
0365 
0366 QString KoInlineCite::bookTitle() const
0367 {
0368     return d->booktitle;
0369 }
0370 
0371 QString KoInlineCite::chapter() const
0372 {
0373     return d->chapter;
0374 }
0375 
0376 QString KoInlineCite::custom1() const
0377 {
0378     return d->custom1;
0379 }
0380 
0381 QString KoInlineCite::custom2() const
0382 {
0383     return d->custom2;
0384 }
0385 
0386 QString KoInlineCite::custom3() const
0387 {
0388     return d->custom3;
0389 }
0390 
0391 QString KoInlineCite::custom4() const
0392 {
0393     return d->custom4;
0394 }
0395 
0396 QString KoInlineCite::custom5() const
0397 {
0398     return d->custom5;
0399 }
0400 
0401 QString KoInlineCite::edition() const
0402 {
0403     return d->edition;
0404 }
0405 
0406 QString KoInlineCite::editor() const
0407 {
0408     return d->editor;
0409 }
0410 
0411 QString KoInlineCite::institution() const
0412 {
0413     return d->institution;
0414 }
0415 
0416 QString KoInlineCite::isbn() const
0417 {
0418     return d->isbn;
0419 }
0420 
0421 QString KoInlineCite::issn() const
0422 {
0423     return d->issn;
0424 }
0425 
0426 QString KoInlineCite::journal() const
0427 {
0428     return d->journal;
0429 }
0430 
0431 QString KoInlineCite::month() const
0432 {
0433     return d->month;
0434 }
0435 
0436 QString KoInlineCite::note() const
0437 {
0438     return d->note;
0439 }
0440 
0441 QString KoInlineCite::number() const
0442 {
0443     return d->number;
0444 }
0445 
0446 QString KoInlineCite::organisations() const
0447 {
0448     return d->organisation;
0449 }
0450 
0451 QString KoInlineCite::pages() const
0452 {
0453     return d->pages;
0454 }
0455 
0456 QString KoInlineCite::publisher() const
0457 {
0458     return d->publisher;
0459 }
0460 
0461 QString KoInlineCite::publicationType() const
0462 {
0463     return d->publicationType;
0464 }
0465 
0466 QString KoInlineCite::reportType() const
0467 {
0468     return d->reportType;
0469 }
0470 
0471 QString KoInlineCite::school() const
0472 {
0473     return d->school;
0474 }
0475 
0476 QString KoInlineCite::series() const
0477 {
0478     return d->series;
0479 }
0480 
0481 QString KoInlineCite::title() const
0482 {
0483     return d->title;
0484 }
0485 
0486 QString KoInlineCite::volume() const
0487 {
0488     return d->volume;
0489 }
0490 
0491 QString KoInlineCite::year() const
0492 {
0493     return d->year;
0494 }
0495 
0496 QString KoInlineCite::url() const
0497 {
0498     return d->url;
0499 }
0500 
0501 int KoInlineCite::posInDocument() const
0502 {
0503     return d->posInDocument;
0504 }
0505 
0506 bool KoInlineCite::operator!= ( const KoInlineCite &cite ) const
0507 {
0508     return !(d->address == cite.address() && d->annote == cite.annotation() && d->author == cite.author() &&
0509             d->bibliographyType == cite.bibliographyType() && d->booktitle == cite.bookTitle() &&
0510             d->chapter == cite.chapter() && d->custom1 == cite.custom1() && d->custom2 == cite.custom2() &&
0511             d->custom3 == cite.custom3() && d->custom4 == cite.custom4() && d->custom5 == cite.custom5() &&
0512             d->edition == cite.edition() && d->editor == cite.editor() && d->identifier == cite.identifier() &&
0513             d->institution == cite.institution() && d->isbn == cite.isbn() && d->issn == cite.issn() &&
0514             d->journal == cite.journal() && d->month == cite.month() && d->note == cite.note() &&
0515             d->number == cite.number() && d->organisation == cite.organisations() && d->pages == cite.pages() &&
0516             d->publicationType == cite.publicationType() && d->publisher == cite.publisher() &&
0517             d->reportType == cite.reportType() && d->school == cite.school() && d->series == cite.series() &&
0518             d->title == cite.title() && d->url == cite.url() && d->volume == cite.volume() && d->year == cite.year());
0519 }
0520 
0521 KoInlineCite &KoInlineCite::operator =(const  KoInlineCite &cite)
0522 {
0523     d->address = cite.address();
0524     d->annote = cite.annotation();
0525     d->author = cite.author();
0526     d->bibliographyType = cite.bibliographyType();
0527     d->booktitle = cite.bookTitle();
0528     d->chapter = cite.chapter();
0529     d->custom1 = cite.custom1();
0530     d->custom2 = cite.custom2();
0531     d->custom3 = cite.custom3();
0532     d->custom4 = cite.custom4();
0533     d->custom5 = cite.custom5();
0534     d->edition = cite.edition();
0535     d->editor = cite.editor();
0536     d->identifier = cite.identifier();
0537     d->institution = cite.institution();
0538     d->isbn = cite.isbn();
0539     d->issn = cite.issn();
0540     d->journal = cite.journal();
0541     d->month = cite.month();
0542     d->note = cite.note();
0543     d->number = cite.number();
0544     d->organisation = cite.organisations();
0545     d->pages = cite.pages();
0546     d->publicationType = cite.publicationType();
0547     d->publisher = cite.publisher();
0548     d->reportType = cite.reportType();
0549     d->school = cite.school();
0550     d->series = cite.series();
0551     d->title = cite.title();
0552     d->url = cite.url();
0553     d->volume = cite.volume();
0554     d->year = cite.year();
0555 
0556     return *this;
0557 }
0558 
0559 void KoInlineCite::updatePosition(const QTextDocument *document, int posInDocument, const QTextCharFormat &format)
0560 {
0561     Q_UNUSED(document);
0562     Q_UNUSED(format);
0563     d->posInDocument = posInDocument;
0564 }
0565 
0566 void KoInlineCite::resize(const QTextDocument *document, QTextInlineObject &object, int posInDocument, const QTextCharFormat &format, QPaintDevice *pd)
0567 {
0568     Q_UNUSED(document);
0569     Q_UNUSED(posInDocument);
0570     if (d->identifier.isEmpty())
0571         return;
0572 
0573     KoOdfBibliographyConfiguration *bibConfiguration = KoTextDocument(document).styleManager()->bibliographyConfiguration();
0574 
0575     if (!bibConfiguration->numberedEntries()) {
0576         d->label = QString("%1%2%3").arg(bibConfiguration->prefix(),
0577                                          d->identifier,
0578                                          bibConfiguration->suffix());
0579     } else {
0580         d->label = QString("%1%2%3").arg(bibConfiguration->prefix(),
0581                          QString::number(manager()->citationsSortedByPosition(true).indexOf(this) + 1),
0582                          bibConfiguration->suffix());
0583     }
0584 
0585     Q_ASSERT(format.isCharFormat());
0586     QFontMetricsF fm(format.font(), pd);
0587     object.setWidth(fm.width(d->label));
0588     object.setAscent(fm.ascent());
0589     object.setDescent(fm.descent());
0590 }
0591 
0592 void KoInlineCite::paint(QPainter &painter, QPaintDevice *pd, const QTextDocument *document, const QRectF &rect, const QTextInlineObject &object, int posInDocument, const QTextCharFormat &format)
0593 {
0594     Q_UNUSED(document);
0595     Q_UNUSED(object);
0596     Q_UNUSED(posInDocument);
0597 
0598     if (d->identifier.isEmpty())
0599         return;
0600 
0601     KoOdfBibliographyConfiguration *bibConfiguration = KoTextDocument(document).styleManager()->bibliographyConfiguration();
0602 
0603     if (!bibConfiguration->numberedEntries()) {
0604         d->label = QString("%1%2%3").arg(bibConfiguration->prefix(),
0605                                          d->identifier,
0606                                          bibConfiguration->suffix());
0607     } else {
0608         d->label = QString("%1%2%3").arg(bibConfiguration->prefix(),
0609                          QString::number(manager()->citationsSortedByPosition(true, document->firstBlock()).indexOf(this) + 1),
0610                          bibConfiguration->suffix());
0611     }
0612 
0613     QFont font(format.font(), pd);
0614     QTextLayout layout(d->label, font, pd);
0615     layout.setCacheEnabled(true);
0616     QList<QTextLayout::FormatRange> layouts;
0617     QTextLayout::FormatRange range;
0618     range.start = 0;
0619     range.length = d->label.length();
0620     range.format = format;
0621     range.format.setVerticalAlignment(QTextCharFormat::AlignNormal);
0622     layouts.append(range);
0623     layout.setAdditionalFormats(layouts);
0624 
0625     QTextOption option(Qt::AlignLeft | Qt::AlignAbsolute);
0626     option.setTextDirection(object.textDirection());
0627     layout.setTextOption(option);
0628     layout.beginLayout();
0629     layout.createLine();
0630     layout.endLayout();
0631     layout.draw(&painter, rect.topLeft());
0632 }
0633 
0634 bool KoInlineCite::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context)
0635 {
0636     Q_UNUSED(context);
0637     //KoTextLoader loader(context);
0638     if (element.namespaceURI() == KoXmlNS::text && element.localName() == "bibliography-mark") {
0639         d->identifier = element.attributeNS(KoXmlNS::text, "identifier");
0640         d->bibliographyType = element.attributeNS(KoXmlNS::text, "bibliography-type");
0641         d->address = element.attributeNS(KoXmlNS::text, "address");
0642         d->annote = element.attributeNS(KoXmlNS::text, "annote");
0643         d->author = element.attributeNS(KoXmlNS::text, "author");
0644         d->booktitle = element.attributeNS(KoXmlNS::text, "booktitle");
0645         d->chapter = element.attributeNS(KoXmlNS::text, "chapter");
0646         d->edition = element.attributeNS(KoXmlNS::text, "edition");
0647         d->editor = element.attributeNS(KoXmlNS::text, "editor");
0648         d->publicationType = element.attributeNS(KoXmlNS::text, "howpublished");
0649         d->institution = element.attributeNS(KoXmlNS::text, "institution");
0650         d->journal = element.attributeNS(KoXmlNS::text, "journal");
0651         d->month = element.attributeNS(KoXmlNS::text, "month");
0652         d->note = element.attributeNS(KoXmlNS::text, "note");
0653         d->number = element.attributeNS(KoXmlNS::text, "number");
0654         d->organisation = element.attributeNS(KoXmlNS::text, "organisations");
0655         d->pages = element.attributeNS(KoXmlNS::text, "pages");
0656         d->publisher = element.attributeNS(KoXmlNS::text, "publisher");
0657         d->school = element.attributeNS(KoXmlNS::text, "school");
0658         d->series = element.attributeNS(KoXmlNS::text, "series");
0659         d->title = element.attributeNS(KoXmlNS::text, "title");
0660         d->reportType = element.attributeNS(KoXmlNS::text, "report-type");
0661         d->volume = element.attributeNS(KoXmlNS::text, "volume");
0662         d->year = element.attributeNS(KoXmlNS::text, "year");
0663         d->url = element.attributeNS(KoXmlNS::text, "url");
0664         d->isbn = element.attributeNS(KoXmlNS::text, "isbn");
0665         d->issn = element.attributeNS(KoXmlNS::text, "issn");
0666         d->custom1 = element.attributeNS(KoXmlNS::text, "custom1");
0667         d->custom2 = element.attributeNS(KoXmlNS::text, "custom2");
0668         d->custom3 = element.attributeNS(KoXmlNS::text, "custom3");
0669         d->custom4 = element.attributeNS(KoXmlNS::text, "custom4");
0670         d->custom5 = element.attributeNS(KoXmlNS::text, "custom5");
0671 
0672         //Now checking for cloned citation (with same identifier)
0673         if (manager()->citations(true).keys().count(d->identifier) > 1) {
0674             this->setType(KoInlineCite::ClonedCitation);
0675         }
0676     }
0677     else {
0678         return false;
0679     }
0680     return true;
0681 }
0682 
0683 void KoInlineCite::saveOdf(KoShapeSavingContext &context)
0684 {
0685     KoXmlWriter *writer = &context.xmlWriter();
0686     writer->startElement("text:bibliography-mark", false);
0687 
0688     if (!d->identifier.isEmpty())
0689         writer->addAttribute("text:identifier", d->identifier);     //can't be "" //to be changed later
0690     if (!d->bibliographyType.isEmpty())
0691         writer->addAttribute("text:bibliography-type", d->bibliographyType);
0692     if (!d->address.isEmpty())
0693         writer->addAttribute("text:address",d->identifier);
0694     if (!d->annote.isEmpty())
0695         writer->addAttribute("text:annote",d->annote);
0696     if (!d->author.isEmpty())
0697         writer->addAttribute("text:author",d->author);
0698     if (!d->booktitle.isEmpty())
0699         writer->addAttribute("text:booktitle",d->booktitle);
0700     if (!d->chapter.isEmpty())
0701         writer->addAttribute("text:chapter",d->chapter);
0702     if (!d->edition.isEmpty())
0703         writer->addAttribute("text:edition",d->edition);
0704     if (!d->editor.isEmpty())
0705         writer->addAttribute("text:editor",d->editor);
0706     if (!d->publicationType.isEmpty())
0707         writer->addAttribute("text:howpublished",d->publicationType);
0708     if (!d->institution.isEmpty())
0709         writer->addAttribute("text:institution",d->institution);
0710     if (!d->journal.isEmpty())
0711         writer->addAttribute("text:journal",d->journal);
0712     if (!d->month.isEmpty())
0713         writer->addAttribute("text:month",d->month);
0714     if (!d->note.isEmpty())
0715         writer->addAttribute("text:note",d->note);
0716     if (!d->number.isEmpty())
0717         writer->addAttribute("text:number",d->number);
0718     if (!d->pages.isEmpty())
0719         writer->addAttribute("text:pages",d->pages);
0720     if (!d->publisher.isEmpty())
0721         writer->addAttribute("text:publisher",d->publisher);
0722     if (!d->school.isEmpty())
0723         writer->addAttribute("text:school",d->school);
0724     if (!d->series.isEmpty())
0725         writer->addAttribute("text:series",d->series);
0726     if (!d->title.isEmpty())
0727         writer->addAttribute("text:title",d->title);
0728     if (!d->reportType.isEmpty())
0729         writer->addAttribute("text:report-type",d->reportType);
0730     if (!d->volume.isEmpty())
0731         writer->addAttribute("text:volume",d->volume);
0732     if (!d->year.isEmpty())
0733         writer->addAttribute("text:year",d->year);
0734     if (!d->url.isEmpty())
0735         writer->addAttribute("text:url",d->url);
0736     if (!d->isbn.isEmpty())
0737         writer->addAttribute("text:isbn",d->isbn);
0738     if (!d->issn.isEmpty())
0739         writer->addAttribute("text:issn",d->issn);
0740     if (!d->custom1.isEmpty())
0741         writer->addAttribute("text:custom1",d->custom1);
0742     if (!d->custom2.isEmpty())
0743         writer->addAttribute("text:custom2",d->custom2);
0744     if (!d->custom3.isEmpty())
0745         writer->addAttribute("text:custom3",d->custom3);
0746     if (!d->custom4.isEmpty())
0747         writer->addAttribute("text:custom4",d->custom4);
0748     if (!d->custom5.isEmpty())
0749         writer->addAttribute("text:custom5",d->custom5);
0750 
0751     writer->addTextNode(QString("[%1]").arg(d->identifier));
0752     writer->endElement();
0753 }