Warning, file /office/calligra/libs/text/KoTextMeta.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.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 0020 #include "KoTextMeta.h" 0021 0022 #include <KoShapeSavingContext.h> 0023 #include <KoXmlReader.h> 0024 #include <KoXmlWriter.h> 0025 #include <KoTextInlineRdf.h> 0026 0027 #include <QTextDocument> 0028 #include <QTextInlineObject> 0029 #include <QPointer> 0030 0031 #include "TextDebug.h" 0032 0033 // Include Q_UNSUSED classes, for building on Windows 0034 #include <KoShapeLoadingContext.h> 0035 0036 class Q_DECL_HIDDEN KoTextMeta::Private 0037 { 0038 public: 0039 Private(const QTextDocument *doc) 0040 : document(doc), 0041 posInDocument(0) { } 0042 const QTextDocument *document; 0043 int posInDocument; 0044 QPointer<KoTextMeta> endBookmark; 0045 BookmarkType type; 0046 }; 0047 0048 KoTextMeta::KoTextMeta(const QTextDocument *document) 0049 : KoInlineObject(false), 0050 d(new Private(document)) 0051 { 0052 d->endBookmark.clear(); 0053 } 0054 0055 KoTextMeta::~KoTextMeta() 0056 { 0057 delete d; 0058 } 0059 0060 void KoTextMeta::saveOdf(KoShapeSavingContext &context) 0061 { 0062 KoXmlWriter &writer = context.xmlWriter(); 0063 0064 debugText << "kom.save() this:" << (void*)this << " d->type:" << d->type; 0065 if (inlineRdf()) { 0066 debugText << "kom.save() have inline Rdf"; 0067 } 0068 0069 if (d->type == StartBookmark) { 0070 writer.startElement("text:meta", false); 0071 writer.addAttribute("text:name", "foo"); 0072 0073 if (inlineRdf()) { 0074 inlineRdf()->saveOdf(context, &writer); 0075 } 0076 } else { 0077 debugText << "adding endelement."; 0078 writer.endElement(); 0079 } 0080 debugText << "kom.save() done this:" << (void*)this << " d->type:" << d->type; 0081 } 0082 0083 bool KoTextMeta::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) 0084 { 0085 Q_UNUSED(element); 0086 Q_UNUSED(context); 0087 debugText << "kom.load()"; 0088 return true; 0089 } 0090 0091 void KoTextMeta::updatePosition(const QTextDocument *document, int posInDocument, const QTextCharFormat &format) 0092 { 0093 Q_UNUSED(format); 0094 d->document = document; 0095 d->posInDocument = posInDocument; 0096 } 0097 0098 void KoTextMeta::resize(const QTextDocument *document, QTextInlineObject &object, int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) 0099 { 0100 Q_UNUSED(document); 0101 Q_UNUSED(posInDocument); 0102 Q_UNUSED(format); 0103 Q_UNUSED(pd); 0104 object.setWidth(0); 0105 object.setAscent(0); 0106 object.setDescent(0); 0107 } 0108 0109 void KoTextMeta::paint(QPainter &, QPaintDevice *, const QTextDocument *, const QRectF &, const QTextInlineObject &, int , const QTextCharFormat &) 0110 { 0111 // nothing to paint. 0112 } 0113 0114 void KoTextMeta::setType(BookmarkType type) 0115 { 0116 d->type = type; 0117 } 0118 0119 KoTextMeta::BookmarkType KoTextMeta::type() const 0120 { 0121 return d->type; 0122 } 0123 0124 void KoTextMeta::setEndBookmark(KoTextMeta *bookmark) 0125 { 0126 d->type = StartBookmark; 0127 bookmark->d->type = EndBookmark; 0128 d->endBookmark = bookmark; 0129 } 0130 0131 KoTextMeta *KoTextMeta::endBookmark() const 0132 { 0133 return d->endBookmark.data(); 0134 } 0135 0136 int KoTextMeta::position() const 0137 { 0138 return d->posInDocument; 0139 }