1 /* This file is part of the KDE project
2    Copyright (C) 2010 by Nokia
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8 
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13 
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef MSO_WRITER_H
21 #define MSO_WRITER_H
22 
23 #include <QRectF>
24 
25 class KoGenStyles;
26 class KoGenStyle;
27 class KoXmlWriter;
28 
29 /**
30  * Helper class that for writing xml.
31  *
32  * Besides containing KoXmlWriter, this class keeps track of the coordinate
33  * system. It has convenience functions for writing lengths in physical
34  * dimensions (currently only mm).
35  */
36 class Writer
37 {
38 public:
39     qreal xOffset;
40     qreal yOffset;
41     qreal scaleX;
42     qreal scaleY;
43 
44     /**
45      * Rotation of the group shape.
46      */
47     qreal g_rotation;
48 
49     /**
50      * Flip the group shape horizontally.
51      */
52     bool g_flipH;
53 
54     /**
55      * Flip the group shape vertically.
56      */
57     bool g_flipV;
58 
59     /**
60      * Xml writer that writes into content.xml.
61      */
62     KoXmlWriter& xml;
63     /**
64      * Styles for the document that is being created.
65      **/
66     KoGenStyles& styles;
67     /**
68      * Tells if the current output is for styles.xml or content.xml
69      **/
70     bool stylesxml;
71 
72     /**
73      * Construct a new Writer.
74      *
75      * @param xmlWriter The xml writer that writes content.xml
76      * @param kostyles The styles for the writer.
77      * @param stylexml Defines whether the style is an XML style.
78      */
79     Writer(KoXmlWriter& xmlWriter, KoGenStyles& kostyles,
80            bool stylexml = false);
81     /**
82      * Create a new writer with a new coordinate system.
83      *
84      * In different contexts in drawings in PPT files, different coordinate
85      * systems are used.  These are defined by specifying a rectangle in the
86      * old coordinate system and the equivalent in the new coordinate system.
87      */
88     Writer transform(const QRectF& oldCoords, const QRectF &newCoords) const;
89     /**
90      * Convert local length to global length.
91      *
92      * A length without unit in the local coordinate system is converted to a
93      * global length without a unit.
94      *
95      * @param length a local length.
96      * @return the global length.
97      */
98     qreal vLength(qreal length) const;
99     /**
100      * @see vLength
101      */
102     qreal hLength(qreal length) const;
103     /**
104      * @see vLength
105      */
106     qreal vOffset(qreal offset) const;
107     /**
108      * @see vLength
109      */
110     qreal hOffset(qreal offset) const;
111 };
112 
113 #endif //MSO_WRITER_H
114