File indexing completed on 2025-01-19 13:27:35
0001 /* 0002 * This file is part of Office 2007 Filters for Calligra 0003 * 0004 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 0005 * 0006 * Contact: Suresh Chande suresh.chande@nokia.com 0007 * 0008 * This library is free software; you can redistribute it and/or 0009 * modify it under the terms of the GNU Lesser General Public License 0010 * version 2.1 as published by the Free Software Foundation. 0011 * 0012 * This library is distributed in the hope that it will be useful, but 0013 * WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library; if not, write to the Free Software 0019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 0020 * 02110-1301 USA 0021 * 0022 */ 0023 0024 #ifndef XLSXXMLCOMMENTSREADER_H 0025 #define XLSXXMLCOMMENTSREADER_H 0026 0027 #include "XlsxUtils.h" 0028 #include "XlsxXmlCommonReader.h" 0029 #include <MsooXmlTheme.h> 0030 0031 class XlsxComments; 0032 class XlsxComment 0033 { 0034 public: 0035 explicit XlsxComment(uint authorId); 0036 QString texts; 0037 // QString ref; 0038 inline QString author(const XlsxComments* comments) const; 0039 private: 0040 uint m_authorId; 0041 }; 0042 0043 typedef QHash<QString, XlsxComment*> XlsxCommentsBase; 0044 0045 //! Comments mapped by cell references. Owns each comment. 0046 /*! Used by worksheet readers for putting comments into the cells. 0047 @todo many-cell references 0048 */ 0049 class XlsxComments : public XlsxCommentsBase 0050 { 0051 public: 0052 XlsxComments(); 0053 QString author(uint id) const { 0054 const QString result(id < (uint)m_authors.count() ? m_authors.at(id) : QString()); 0055 if (result.isEmpty()) { 0056 qCWarning(lcXlsxImport) << "No author for ID" << id; 0057 } 0058 return result; 0059 } 0060 private: 0061 friend class XlsxXmlCommentsReader; 0062 QList<QString> m_authors; 0063 }; 0064 0065 QString XlsxComment::author(const XlsxComments* comments) const 0066 { 0067 return comments->author(m_authorId); 0068 } 0069 0070 class XlsxXmlCommentsReaderContext : public MSOOXML::MsooXmlReaderContext 0071 { 0072 public: 0073 explicit XlsxXmlCommentsReaderContext(XlsxComments& _comments, MSOOXML::DrawingMLTheme* _themes, 0074 QVector<QString>& _colorIndices); 0075 ~XlsxXmlCommentsReaderContext() override; 0076 0077 XlsxComments* comments; 0078 MSOOXML::DrawingMLTheme* themes; 0079 QVector<QString>& colorIndices; 0080 }; 0081 0082 class XlsxXmlCommentsReader : public XlsxXmlCommonReader 0083 { 0084 public: 0085 explicit XlsxXmlCommentsReader(KoOdfWriters *writers); 0086 ~XlsxXmlCommentsReader() override; 0087 KoFilter::ConversionStatus read(MSOOXML::MsooXmlReaderContext* context = 0) override; 0088 0089 protected: 0090 KoFilter::ConversionStatus read_comments(); 0091 KoFilter::ConversionStatus read_authors(); 0092 KoFilter::ConversionStatus read_author(); 0093 KoFilter::ConversionStatus read_commentList(); 0094 KoFilter::ConversionStatus read_comment(); 0095 KoFilter::ConversionStatus read_commentPr(); 0096 KoFilter::ConversionStatus read_text(); 0097 0098 private: 0099 KoFilter::ConversionStatus readInternal(); 0100 0101 XlsxXmlCommentsReaderContext *m_context; 0102 QString m_currentCommentText; 0103 QString m_currentAuthor; 0104 }; 0105 0106 #endif