1
// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
2
/* This file is part of the KDE project
3
Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#include "kpobjectproperties.h"
24
#include "kpcubicbeziercurveobject.h"
25
#include "kpgroupobject.h"
26
#include "kplineobject.h"
27
#include "kprectobject.h"
28
#include "kppolygonobject.h"
29
#include "kppieobject.h"
30
#include "kppixmapobject.h"
31
#include "kppointobject.h"
32
#include "kpquadricbeziercurveobject.h"
33
#include "kptextobject.h"
35
KPObjectProperties::KPObjectProperties( const QPtrList<KPObject> &objects )
36
: m_objects( objects )
38
, m_pen( QPen( Qt::black, 1, Qt::SolidLine ), L_NORMAL, L_NORMAL )
39
, m_protectContent( STATE_UNDEF )
41
getProperties( m_objects );
45
KPObjectProperties::~KPObjectProperties()
50
void KPObjectProperties::getProperties( const QPtrList<KPObject> &objects )
52
QPtrListIterator<KPObject> it( objects );
53
for ( ; it.current() ; ++it )
55
switch ( it.current()->getType() )
58
getPenProperties( it.current() );
59
getLineEndsProperties( it.current() );
64
getPenProperties( it.current() );
65
if( !static_cast<KPPointObject*>( it.current() )->isClosed() )
66
getLineEndsProperties( it.current() );
69
case OT_QUADRICBEZIERCURVE:
70
getPenProperties( it.current() );
71
if ( !static_cast<KPQuadricBezierCurveObject*>( it.current() )->isClosed() )
72
getLineEndsProperties( it.current() );
75
case OT_CUBICBEZIERCURVE:
76
getPenProperties( it.current() );
77
if ( !static_cast<KPCubicBezierCurveObject*>( it.current() )->isClosed() )
78
getLineEndsProperties( it.current() );
82
getPieProperties( it.current() );
85
getRectProperties( it.current() );
88
getPolygonSettings( it.current() );
91
getTextProperties( it.current() );
97
getPenProperties( it.current() );
98
getBrushProperties( it.current() );
103
getPictureProperties( it.current() );
107
KPGroupObject *obj = dynamic_cast<KPGroupObject*>( it.current() );
110
getProperties( obj->objectList() );
121
void KPObjectProperties::getPenProperties( KPObject *object )
123
if ( !( m_flags & PtPen ) )
125
KPShadowObject *obj = dynamic_cast<KPShadowObject*>( object );
128
m_pen.pen = obj->getPen();
136
void KPObjectProperties::getLineEndsProperties( KPObject *object )
138
if ( !( m_flags & PtLineEnds ) )
140
switch ( object->getType() )
144
KPLineObject *obj = dynamic_cast<KPLineObject*>( object );
147
m_pen.lineBegin = obj->getLineBegin();
148
m_pen.lineEnd = obj->getLineEnd();
150
m_flags |= PtLineEnds;
156
case OT_QUADRICBEZIERCURVE:
157
case OT_CUBICBEZIERCURVE:
159
KPPointObject *obj = dynamic_cast<KPPointObject*>( object );
162
m_pen.lineBegin = obj->getLineBegin();
163
m_pen.lineEnd = obj->getLineEnd();
165
m_flags |= PtLineEnds;
176
void KPObjectProperties::getBrushProperties( KPObject *object )
178
if ( !( m_flags & PtBrush ) )
180
KP2DObject * obj = dynamic_cast<KP2DObject*>( object );
183
m_brush.brush = obj->getBrush();
184
m_brush.fillType = obj->getFillType();
185
m_brush.gColor1 = obj->getGColor1();
186
m_brush.gColor2 = obj->getGColor2();
187
m_brush.gType = obj->getGType();
188
m_brush.unbalanced = obj->getGUnbalanced();
189
m_brush.xfactor = obj->getGXFactor();
190
m_brush.yfactor = obj->getGYFactor();
198
void KPObjectProperties::getRectProperties( KPObject *object )
200
if ( !( m_flags & PtRectangle ) )
202
KPRectObject *obj = dynamic_cast<KPRectObject*>( object );
205
obj->getRnds( m_rectValues.xRnd, m_rectValues.yRnd );
207
getPenProperties( object );
208
getBrushProperties( object );
209
m_flags |= PtRectangle;
215
void KPObjectProperties::getPolygonSettings( KPObject *object )
217
if ( !( m_flags & PtPolygon ) )
219
KPPolygonObject *obj = dynamic_cast<KPPolygonObject*>( object );
222
m_polygonSettings.checkConcavePolygon = obj->getCheckConcavePolygon();
223
m_polygonSettings.cornersValue = obj->getCornersValue();
224
m_polygonSettings.sharpnessValue = obj->getSharpnessValue();
226
getPenProperties( object );
227
getBrushProperties( object );
228
m_flags |= PtPolygon;
234
void KPObjectProperties::getPieProperties( KPObject *object )
236
if ( !( m_flags & PtPie ) )
238
KPPieObject *obj = dynamic_cast<KPPieObject*>( object );
241
m_pieValues.pieType = obj->getPieType();
242
m_pieValues.pieAngle = obj->getPieAngle();
243
m_pieValues.pieLength = obj->getPieLength();
245
getPenProperties( object );
246
if ( obj->getPieType() != PT_ARC )
247
getBrushProperties( object );
255
void KPObjectProperties::getPictureProperties( KPObject *object )
257
if ( !( m_flags & PtPicture ) )
259
KPPixmapObject *obj = dynamic_cast<KPPixmapObject*>( object );
262
m_pictureSettings.mirrorType = obj->getPictureMirrorType();
263
m_pictureSettings.depth = obj->getPictureDepth();
264
m_pictureSettings.swapRGB = obj->getPictureSwapRGB();
265
m_pictureSettings.grayscal = obj->getPictureGrayscal();
266
m_pictureSettings.bright = obj->getPictureBright();
267
m_pixmap = obj->getOriginalPixmap();
269
getPenProperties( object );
270
getBrushProperties( object );
271
m_flags |= PtPicture;
277
void KPObjectProperties::getTextProperties( KPObject *object )
279
KPTextObject *obj = dynamic_cast<KPTextObject*>( object );
282
if ( !( m_flags & PtText ) )
284
m_marginsStruct = MarginsStruct( obj );
285
m_protectContent = obj->isProtectContent() ? STATE_ON : STATE_OFF;
287
getPenProperties( object );
288
getBrushProperties( object );
293
PropValue pv = obj->isProtectContent() ? STATE_ON : STATE_OFF;
294
if ( pv != m_protectContent )
296
m_protectContent = STATE_UNDEF;