1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 #include "bogus_imp.h"
21 #include <qstringlist.h>
24 #include "../misc/rect.h"
26 Coordinate
BogusImp::attachPoint( ) const
28 return Coordinate::invalidCoord();
31 void BogusImp::draw( KigPainter
& ) const
35 bool BogusImp::contains( const Coordinate
&, int, const KigWidget
& ) const
40 bool BogusImp::inRect( const Rect
&, int, const KigWidget
& ) const
45 DoubleImp::DoubleImp( const double d
)
50 IntImp::IntImp( const int d
)
55 StringImp::StringImp( const QString
& d
)
60 DoubleImp
* DoubleImp::copy() const
62 return new DoubleImp( mdata
);
65 IntImp
* IntImp::copy() const
67 return new IntImp( mdata
);
70 StringImp
* StringImp::copy() const
72 return new StringImp( mdata
);
75 ObjectImp
* BogusImp::transform( const Transformation
& ) const
80 InvalidImp
* InvalidImp::copy() const
82 return new InvalidImp();
85 InvalidImp::InvalidImp()
89 void InvalidImp::fillInNextEscape( QString
& s
, const KigDocument
& ) const
91 s
= s
.arg( "[invalid]" );
94 void DoubleImp::fillInNextEscape( QString
& s
, const KigDocument
& ) const
99 void IntImp::fillInNextEscape( QString
& s
, const KigDocument
& ) const
104 void StringImp::fillInNextEscape( QString
& s
, const KigDocument
& ) const
109 HierarchyImp::HierarchyImp( const ObjectHierarchy
& h
)
110 : BogusImp(), mdata( h
)
114 HierarchyImp
* HierarchyImp::copy() const
116 return new HierarchyImp( mdata
);
119 void InvalidImp::visit( ObjectImpVisitor
* vtor
) const
124 void DoubleImp::visit( ObjectImpVisitor
* vtor
) const
129 void IntImp::visit( ObjectImpVisitor
* vtor
) const
134 void StringImp::visit( ObjectImpVisitor
* vtor
) const
139 void HierarchyImp::visit( ObjectImpVisitor
* vtor
) const
144 TransformationImp::TransformationImp( const Transformation
& h
)
149 TransformationImp
* TransformationImp::copy() const
151 return new TransformationImp( mdata
);
154 void TransformationImp::visit( ObjectImpVisitor
* vtor
) const
159 bool InvalidImp::equals( const ObjectImp
& rhs
) const
164 bool DoubleImp::equals( const ObjectImp
& rhs
) const
166 return rhs
.inherits( DoubleImp::stype() ) &&
167 static_cast<const DoubleImp
&>( rhs
).data() == mdata
;
170 bool IntImp::equals( const ObjectImp
& rhs
) const
172 return rhs
.inherits( IntImp::stype() ) &&
173 static_cast<const IntImp
&>( rhs
).data() == mdata
;
176 bool StringImp::equals( const ObjectImp
& rhs
) const
178 return rhs
.inherits( StringImp::stype() ) &&
179 static_cast<const StringImp
&>( rhs
).data() == mdata
;
182 bool HierarchyImp::equals( const ObjectImp
& rhs
) const
184 return rhs
.inherits( HierarchyImp::stype() ) &&
185 static_cast<const HierarchyImp
&>( rhs
).data() == mdata
;
188 bool TransformationImp::equals( const ObjectImp
& rhs
) const
190 return rhs
.inherits( TransformationImp::stype() ) &&
191 static_cast<const TransformationImp
&>( rhs
).data() == mdata
;
194 bool InvalidImp::canFillInNextEscape() const
199 bool DoubleImp::canFillInNextEscape() const
204 bool IntImp::canFillInNextEscape() const
209 bool StringImp::canFillInNextEscape() const
214 const ObjectImpType
* InvalidImp::stype()
216 static const ObjectImpType
t(
217 Parent::stype(), "invalid", "", "", "", "", "", "", "", "", "" );
221 const ObjectImpType
* StringImp::stype()
223 static const ObjectImpType
t(
224 Parent::stype(), "string",
225 "string", "", "", "", "", "", "", "", "" );
228 const ObjectImpType
* HierarchyImp::stype()
230 static const ObjectImpType
t(
231 Parent::stype(), "hierarchy", "", "", "", "", "", "", "", "", "" );
234 const ObjectImpType
* TransformationImp::stype()
236 static const ObjectImpType
t(
237 Parent::stype(), "transformation", "", "", "", "", "", "", "", "", "");
241 const ObjectImpType
* InvalidImp::type() const
243 return InvalidImp::stype();
246 const ObjectImpType
* DoubleImp::type() const
248 return DoubleImp::stype();
251 const ObjectImpType
* IntImp::type() const
253 return IntImp::stype();
256 const ObjectImpType
* StringImp::type() const
258 return StringImp::stype();
261 const ObjectImpType
* HierarchyImp::type() const
263 return HierarchyImp::stype();
266 const ObjectImpType
* TransformationImp::type() const
268 return TransformationImp::stype();
271 const ObjectImpType
* DoubleImp::stype()
273 static const ObjectImpType
t(
274 Parent::stype(), "double",
275 "double", "", "", "", "", "", "", "", "" );
279 const ObjectImpType
* IntImp::stype()
281 static const ObjectImpType
t(
282 Parent::stype(), "int",
283 "int", "", "", "", "", "", "", "", "" );
287 const ObjectImpType
* BogusImp::stype()
289 static const ObjectImpType
t(
290 Parent::stype(), "bogus",
291 "", "", "", "", "", "", "", "", "" );
295 const ObjectImpType
* TestResultImp::stype()
297 static const ObjectImpType
t(
298 Parent::stype(), "testresult", "", "", "", "", "", "", "", "", "" );
303 TestResultImp::TestResultImp( const QString
& s
)
308 TestResultImp
* TestResultImp::copy() const
310 return new TestResultImp( mdata
);
313 const ObjectImpType
* TestResultImp::type() const
318 void TestResultImp::visit( ObjectImpVisitor
* vtor
) const
323 bool TestResultImp::equals( const ObjectImp
& rhs
) const
325 return rhs
.inherits( TestResultImp::stype() ) &&
326 static_cast<const TestResultImp
&>( rhs
).mdata
== mdata
;
330 const uint
TestResultImp::numberOfProperties() const
332 return Parent::numberOfProperties() + 1;
335 const QCStringList
TestResultImp::properties() const
337 QCStringList l
= Parent::properties();
338 l
<< I18N_NOOP( "Test Result" );
339 assert( l
.size() == TestResultImp::numberOfProperties() );
343 const QCStringList
TestResultImp::propertiesInternalNames() const
345 QCStringList s
= Parent::propertiesInternalNames();
347 assert( s
.size() == TestResultImp::numberOfProperties() );
351 ObjectImp
* TestResultImp::property( uint which
, const KigDocument
& d
) const
353 if ( which
< Parent::numberOfProperties() )
354 return Parent::property( which
, d
);
355 if ( which
== Parent::numberOfProperties() )
356 return new StringImp( data() );
357 else assert( false );
358 return new InvalidImp
;
361 const char* TestResultImp::iconForProperty( uint which
) const
363 if ( which
< Parent::numberOfProperties() )
364 return Parent::iconForProperty( which
);
365 if ( which
== Parent::numberOfProperties() )
366 return ""; // test-result
367 else assert( false );
371 const ObjectImpType
* TestResultImp::impRequirementForProperty( uint which
) const
373 if ( which
< Parent::numberOfProperties() )
374 return Parent::impRequirementForProperty( which
);
375 else return TestResultImp::stype();
378 bool TestResultImp::isPropertyDefinedOnOrThroughThisImp( uint which
) const
380 if ( which
< Parent::numberOfProperties() )
381 return Parent::impRequirementForProperty( which
);
385 Rect
BogusImp::surroundingRect() const
387 return Rect::invalidRect();