1 /*
2  * This file is part of Office 2007 Filters for Calligra
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Suresh Chande suresh.chande@nokia.com
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23 
24 #ifndef COMPLEXSHAPEHANDLER_H
25 #define COMPLEXSHAPEHANDLER_H
26 
27 #include "komsooxml_export.h"
28 
29 #include <QXmlStreamReader>
30 #include <QString>
31 
32 // This class is meant to be used as a helper class to understand
33 // drawingML elements avLst, gdLst and pathLst and to help
34 // create a custom-shape from them
35 class KOMSOOXML_EXPORT ComplexShapeHandler {
36 
37 public:
38 
39     // Set of default equations needed in order to support all variables which are possible in drawingML
40     QString defaultEquations();
41 
42     // pathLst needs to sometimes create extra equations on the fly because arcTo is defined in a way
43     // which is not compatible with odf. The equations created are returned by this function.
44     QString pathEquationsCreated();
45 
46     // Handles avLst items and creates equations out of them
47     QString handle_avLst(QXmlStreamReader* reader);
48 
49     // Handles gdLst items and creates equations out of them
50     QString handle_gdLst(QXmlStreamReader* reader);
51 
52     // Handles rect item and creates coordinates for text-areas out of them
53     QString handle_rect(QXmlStreamReader* reader);
54 
55     // Handles pathLst and creates a value which should be used for enhanced-path attribute
56     // Note: remember to check pathEquationsCreated() after using this one
57     QString handle_pathLst(QXmlStreamReader* reader);
58 
59 private:
60 
61     QString getArgument(QString& function, bool equation = false);
62 
63     QString createEquation(QString& function);
64 
65     QString handle_gd(QXmlStreamReader* reader);
66 
67     QString handle_lnTo(QXmlStreamReader* reader);
68 
69     QString handle_close(QXmlStreamReader* reader);
70 
71     QString handle_arcTo(QXmlStreamReader* reader);
72 
73     QString handle_quadBezTo(QXmlStreamReader* reader);
74 
75     QString handle_cubicBezTo(QXmlStreamReader* reader);
76 
77     QString handle_pt(QXmlStreamReader* reader);
78 
79     QString handle_path(QXmlStreamReader* reader);
80 
81     QString handle_moveTo(QXmlStreamReader* reader);
82 
83     // Storing the latest position where we are, this is needed in order to implement arcTo
84     QString oldX, oldY;
85 
86     int pathWidth, pathHeight;
87 
88     int pathEquationIndex;
89     QString pathEquations;
90 };
91 
92 #endif
93