File indexing completed on 2025-01-12 13:05:53

0001 /* This file is part of the KDE project
0002    Copyright (C) 2002 Laurent Montel <lmontel@mandrakesoft.com>
0003    Copyright (c) 2003 Lukas Tinkl <lukas@kde.org>
0004    Copyright (c) 2003 David Faure <faure@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef OOUTILS_H
0023 #define OOUTILS_H
0024 
0025 #include <QString>
0026 #include <KoFilterChain.h>
0027 #include <KoXmlReader.h>
0028 class QColor;
0029 class QDomElement;
0030 class KoStyleStack;
0031 class QDomDocument;
0032 class KZip;
0033 
0034 class ooNS
0035 {
0036 public:
0037     static const char office[];
0038     static const char style[];
0039     static const char text[];
0040     static const char table[];
0041     static const char draw[];
0042     static const char presentation[];
0043     static const char fo[];
0044     static const char xlink[];
0045     static const char number[];
0046     static const char svg[];
0047     static const char dc[];
0048     static const char meta[];
0049     static const char config[];
0050 };
0051 
0052 namespace OoUtils
0053 {
0054 QString expandWhitespace(const KoXmlElement& tag);
0055 
0056 bool parseBorder(const QString & tag, double * width, int * style, QColor * color);
0057 
0058 ///////// Paragraph properties /////////
0059 
0060 // Convert fo:margin-left, fo:margin-right and fo:text-indent to <INDENTS>
0061 void importIndents(QDomElement& parentElement, const KoStyleStack& styleStack);
0062 
0063 // Convert fo:line-height, style:line-height-at-least and style:line-spacing to <LINESPACING>
0064 void importLineSpacing(QDomElement& parentElement, const KoStyleStack& styleStack);
0065 
0066 // Convert fo:margin-top and fo:margin-bottom to <OFFSETS>
0067 void importTopBottomMargin(QDomElement& parentElement, const KoStyleStack& styleStack);
0068 
0069 // Convert style:tab-stops to <TABULATORS>
0070 void importTabulators(QDomElement& parentElement, const KoStyleStack& styleStack);
0071 
0072 // Convert fo:border* to <*BORDER>
0073 void importBorders(QDomElement& parentElement, const KoStyleStack& styleStack);
0074 
0075 /////////// Text properties ///////////
0076 
0077 // From style:text-underline to Words/Stage's underline/underlinestyleline
0078 void importUnderline(const QString& text_underline, QString& underline, QString& styleline);
0079 
0080 // From style:text-position (for subscript/superscript)
0081 // to Words/Stage's value/relativetextsize
0082 void importTextPosition(const QString& text_position, QString& value, QString& relativetextsize);
0083 
0084 void createDocumentInfo(KoXmlDocument &_meta, QDomDocument & docinfo);
0085 KoFilter::ConversionStatus loadAndParse(const QString& filename, KoXmlDocument& doc, KZip* zip);
0086 KoFilter::ConversionStatus loadAndParse(const QString& filename, KoXmlDocument& doc, KoStore* store);
0087 
0088 /// Load an OASIS thumbnail
0089 KoFilter::ConversionStatus loadThumbnail(QImage& thumbnail, KZip* zip);
0090 
0091 // Internal
0092 KoFilter::ConversionStatus loadAndParse(QIODevice* io, KoXmlDocument& doc, const QString & fileName);
0093 }
0094 
0095 #endif /* OOUTILS_H */