File indexing completed on 2024-12-08 12:55:59
0001 /* This file is part of the KDE project 0002 Copyright (C) 2010 by Nokia 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 #ifndef MSO_WRITER_H 0021 #define MSO_WRITER_H 0022 0023 #include <QRectF> 0024 0025 class KoGenStyles; 0026 class KoGenStyle; 0027 class KoXmlWriter; 0028 0029 /** 0030 * Helper class that for writing xml. 0031 * 0032 * Besides containing KoXmlWriter, this class keeps track of the coordinate 0033 * system. It has convenience functions for writing lengths in physical 0034 * dimensions (currently only mm). 0035 */ 0036 class Writer 0037 { 0038 public: 0039 qreal xOffset; 0040 qreal yOffset; 0041 qreal scaleX; 0042 qreal scaleY; 0043 0044 /** 0045 * Rotation of the group shape. 0046 */ 0047 qreal g_rotation; 0048 0049 /** 0050 * Flip the group shape horizontally. 0051 */ 0052 bool g_flipH; 0053 0054 /** 0055 * Flip the group shape vertically. 0056 */ 0057 bool g_flipV; 0058 0059 /** 0060 * Xml writer that writes into content.xml. 0061 */ 0062 KoXmlWriter& xml; 0063 /** 0064 * Styles for the document that is being created. 0065 **/ 0066 KoGenStyles& styles; 0067 /** 0068 * Tells if the current output is for styles.xml or content.xml 0069 **/ 0070 bool stylesxml; 0071 0072 /** 0073 * Construct a new Writer. 0074 * 0075 * @param xmlWriter The xml writer that writes content.xml 0076 * @param kostyles The styles for the writer. 0077 * @param stylexml Defines whether the style is an XML style. 0078 */ 0079 Writer(KoXmlWriter& xmlWriter, KoGenStyles& kostyles, 0080 bool stylexml = false); 0081 /** 0082 * Create a new writer with a new coordinate system. 0083 * 0084 * In different contexts in drawings in PPT files, different coordinate 0085 * systems are used. These are defined by specifying a rectangle in the 0086 * old coordinate system and the equivalent in the new coordinate system. 0087 */ 0088 Writer transform(const QRectF& oldCoords, const QRectF &newCoords) const; 0089 /** 0090 * Convert local length to global length. 0091 * 0092 * A length without unit in the local coordinate system is converted to a 0093 * global length without a unit. 0094 * 0095 * @param length a local length. 0096 * @return the global length. 0097 */ 0098 qreal vLength(qreal length) const; 0099 /** 0100 * @see vLength 0101 */ 0102 qreal hLength(qreal length) const; 0103 /** 0104 * @see vLength 0105 */ 0106 qreal vOffset(qreal offset) const; 0107 /** 0108 * @see vLength 0109 */ 0110 qreal hOffset(qreal offset) const; 0111 }; 0112 0113 #endif //MSO_WRITER_H