kchart

KDFrameProfileSection.cpp
1/*
2 KDChart - a multi-platform charting engine
3 */
4
5/****************************************************************************
6 ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB. All rights reserved.
7 **
8 ** This file is part of the KDChart library.
9 **
10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file.
14 **
15 ** Licensees holding valid commercial KDChart licenses may use this file in
16 ** accordance with the KDChart Commercial License Agreement provided with
17 ** the Software.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.klaralvdalens-datakonsult.se/?page=products for
23 ** information about KDChart Commercial License Agreements.
24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you.
27 **
28 **********************************************************************/
29#include <KDFrameProfileSection.h>
30#include <KDXMLTools.h>
31
33{
34 // Intentionally left blank for now.
35}
36
37
39 TQDomNode& parent,
40 const TQString& elementName,
41 const KDFrameProfileSection* section )
42
43{
44 TQDomElement sectionElement = document.createElement( elementName );
45 parent.appendChild( sectionElement );
46 KDXML::createStringNode( document, sectionElement, "Direction",
47 KDFrameProfileSection::directionToString( section->_direction ) );
48 KDXML::createStringNode( document, sectionElement, "Curvature",
49 KDFrameProfileSection::curvatureToString( section->_curvature ) );
50 KDXML::createIntNode( document, sectionElement, "Width", section->_width );
51 KDXML::createPenNode( document, sectionElement, "Style", section->_pen );
52}
53
54
56 KDFrameProfileSection* section )
57{
58 bool ok = true;
59 Direction tempDirection = DirPlain;
60 Curvature tempCurvature = CvtPlain;
61 int tempWidth;
62 TQPen tempPen;
63 TQDomNode node = element.firstChild();
64 while( !node.isNull() ) {
65 TQDomElement element = node.toElement();
66 if( !element.isNull() ) { // was really an element
67 TQString tagName = element.tagName();
68 if( tagName == "Direction" ) {
69 TQString value;
70 ok = ok & KDXML::readStringNode( element, value );
71 tempDirection = stringToDirection( value );
72 } else if( tagName == "Curvature" ) {
73 TQString value;
74 ok = ok & KDXML::readStringNode( element, value );
75 tempCurvature = stringToCurvature( value );
76 } else if( tagName == "Width" ) {
77 ok = ok & KDXML::readIntNode( element, tempWidth );
78 } else if( tagName == "Style" || tagName == "Pen" ) {
79 ok = ok & KDXML::readPenNode( element, tempPen );
80 } else {
81 tqDebug( "Unknown tag in frame" );
82 }
83 }
84 node = node.nextSibling();
85 }
86
87 if( ok ) {
88 section->_direction = tempDirection;
89 section->_curvature = tempCurvature;
90 section->_width = tempWidth;
91 section->_pen = tempPen;
92 }
93
94 return ok;
95}
static Curvature stringToCurvature(const TQString &string)
Converts the specified string to a curvature enum value.
static void createFrameProfileSectionNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, const KDFrameProfileSection *section)
Creates a DOM element node that represents a frame profile section for use in a DOM document.
Curvature
Profile Curvature Mode: specifying the shape of a frame profile section.
static Direction stringToDirection(const TQString &string)
Converts the specified string to a direction enum value.
static TQString curvatureToString(Curvature curv)
Converts the specified curvature enum to a string representation.
KDFrameProfileSection(Direction direction, Curvature curvature, int width, TQPen pen)
Ctor of KDFrameProfileSection.
static TQString directionToString(Direction dir)
Converts the specified direction enum to a string representation.
Direction
Profile Direction Mode: specifying whether a part of a profile looks embossed or engraved in comparis...
virtual ~KDFrameProfileSection()
Destructor.
static bool readFrameProfileSectionNode(const TQDomElement &element, KDFrameProfileSection *section)
Reads data from a DOM element node that represents a frame profile section and fills a KDFrameProfile...