Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : // must be first
22 : : #include <canvas/debug.hxx>
23 : : #include <tools/diagnose_ex.h>
24 : : #include <shapeattributelayer.hxx>
25 : :
26 : : #include <canvas/verbosetrace.hxx>
27 : :
28 : :
29 : : #include <com/sun/star/awt/Rectangle.hpp>
30 : : #include <com/sun/star/awt/FontUnderline.hpp>
31 : : #include <com/sun/star/awt/FontWeight.hpp>
32 : : #include <com/sun/star/beans/XPropertySet.hpp>
33 : : #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
34 : :
35 : : #include <basegfx/numeric/ftools.hxx>
36 : : #include <basegfx/polygon/b2dpolygon.hxx>
37 : : #include <rtl/math.hxx>
38 : :
39 : :
40 : : using namespace ::com::sun::star;
41 : :
42 : :
43 : : namespace slideshow
44 : : {
45 : : namespace internal
46 : : {
47 : : /** Update state ids
48 : :
49 : : This method updates all state IDs from possible
50 : : children. Whenever a child's state ID changed, we
51 : : increment ours.
52 : : */
53 : 0 : void ShapeAttributeLayer::updateStateIds()
54 : : {
55 : 0 : if( haveChild() )
56 : : {
57 : 0 : if( mnTransformationState != mpChild->getTransformationState() )
58 : 0 : ++mnTransformationState;
59 : 0 : if( mnClipState != mpChild->getClipState() )
60 : 0 : ++mnClipState;
61 : 0 : if( mnAlphaState != mpChild->getAlphaState() )
62 : 0 : ++mnAlphaState;
63 : 0 : if( mnPositionState != mpChild->getPositionState() )
64 : 0 : ++mnPositionState;
65 : 0 : if( mnContentState != mpChild->getContentState() )
66 : 0 : ++mnContentState;
67 : 0 : if( mnVisibilityState != mpChild->getVisibilityState() )
68 : 0 : ++mnVisibilityState;
69 : : }
70 : 0 : }
71 : :
72 : : /** Calc attribute value.
73 : :
74 : : This method determines the current attribute value,
75 : : appropriately combining it with children values (by
76 : : evaluating the mnAdditiveMode member).
77 : : */
78 : 0 : template< typename T > T ShapeAttributeLayer::calcValue( const T& rCurrValue,
79 : : bool bThisInstanceValid,
80 : : bool (ShapeAttributeLayer::*pIsValid)() const,
81 : : T (ShapeAttributeLayer::*pGetValue)() const ) const
82 : : {
83 : : // deviated from the (*shared_ptr).*mpFuncPtr notation
84 : : // here, since gcc does not seem to parse that as a member
85 : : // function call anymore.
86 : 0 : const bool bChildInstanceValueValid( haveChild() ? (mpChild.get()->*pIsValid)() : false );
87 : :
88 : 0 : if( bThisInstanceValid )
89 : : {
90 : 0 : if( bChildInstanceValueValid )
91 : : {
92 : : // merge with child value
93 : 0 : switch( mnAdditiveMode )
94 : : {
95 : : default:
96 : : // FALTHROUGH intended
97 : : case animations::AnimationAdditiveMode::NONE:
98 : : // FALTHROUGH intended
99 : : case animations::AnimationAdditiveMode::BASE:
100 : : // FALTHROUGH intended
101 : : case animations::AnimationAdditiveMode::REPLACE:
102 : : // TODO(F2): reverse-engineer the semantics of these
103 : : // values
104 : :
105 : : // currently, treat them the same and replace
106 : : // the child value by our own
107 : 0 : return rCurrValue;
108 : :
109 : : case animations::AnimationAdditiveMode::SUM:
110 : 0 : return rCurrValue + ((*mpChild).*pGetValue)();
111 : :
112 : : case animations::AnimationAdditiveMode::MULTIPLY:
113 : 0 : return rCurrValue * ((*mpChild).*pGetValue)();
114 : : }
115 : : }
116 : : else
117 : : {
118 : : // this object is the only one defining
119 : : // the value, so take it
120 : 0 : return rCurrValue;
121 : : }
122 : : }
123 : : else
124 : : {
125 : : return bChildInstanceValueValid ?
126 : : ((*mpChild).*pGetValue)() :
127 : 0 : T(); // pass on child value, regardless
128 : : // if it's valid or not. If not, it's
129 : : // a default anyway
130 : : }
131 : : }
132 : :
133 : 0 : ShapeAttributeLayer::ShapeAttributeLayer( const ShapeAttributeLayerSharedPtr& rChildLayer ) :
134 : : mpChild( rChildLayer ),
135 : :
136 : : maSize(),
137 : : maPosition(),
138 : : maClip(),
139 : :
140 : : maFontFamily(),
141 : :
142 : : mnRotationAngle(),
143 : : mnShearXAngle(),
144 : : mnShearYAngle(),
145 : : mnAlpha(),
146 : : mnCharRotationAngle(),
147 : : mnCharScale(),
148 : : mnCharWeight(),
149 : :
150 : : meFillStyle( drawing::FillStyle_NONE ),
151 : : meLineStyle( drawing::LineStyle_NONE ),
152 : : meCharPosture( awt::FontSlant_NONE ),
153 : : mnUnderlineMode(),
154 : :
155 : : maDimColor(),
156 : : maFillColor(),
157 : : maLineColor(),
158 : : maCharColor(),
159 : :
160 : 0 : mnTransformationState( rChildLayer ? rChildLayer->getTransformationState() : 0 ),
161 : 0 : mnClipState( rChildLayer ? rChildLayer->getClipState() : 0),
162 : 0 : mnAlphaState( rChildLayer ? rChildLayer->getAlphaState() : 0),
163 : 0 : mnPositionState( rChildLayer ? rChildLayer->getPositionState() : 0 ),
164 : 0 : mnContentState( rChildLayer ? rChildLayer->getContentState() : 0 ),
165 : 0 : mnVisibilityState( rChildLayer ? rChildLayer->getVisibilityState() : 0 ),
166 : :
167 : : mnAdditiveMode( animations::AnimationAdditiveMode::BASE ),
168 : :
169 : : mbVisibility( false ),
170 : :
171 : : mbWidthValid( false ),
172 : : mbHeightValid( false ),
173 : : mbPosXValid( false ),
174 : : mbPosYValid( false ),
175 : : mbClipValid( false ),
176 : :
177 : : mbFontFamilyValid( false ),
178 : :
179 : : mbRotationAngleValid( false ),
180 : : mbShearXAngleValid( false ),
181 : : mbShearYAngleValid( false ),
182 : :
183 : : mbAlphaValid( false ),
184 : :
185 : : mbCharRotationAngleValid( false ),
186 : : mbCharScaleValid( false ),
187 : :
188 : : mbDimColorValid( false ),
189 : : mbFillColorValid( false ),
190 : : mbLineColorValid( false ),
191 : : mbCharColorValid( false ),
192 : :
193 : : mbFillStyleValid( false ),
194 : : mbLineStyleValid( false ),
195 : : mbCharWeightValid( false ),
196 : : mbUnderlineModeValid( false ),
197 : : mbCharPostureValid( false ),
198 : 0 : mbVisibilityValid( false )
199 : : {
200 : 0 : }
201 : :
202 : 0 : bool ShapeAttributeLayer::revokeChildLayer( const ShapeAttributeLayerSharedPtr& rChildLayer )
203 : : {
204 : 0 : ENSURE_OR_RETURN_FALSE( rChildLayer,
205 : : "ShapeAttributeLayer::revokeChildLayer(): Will not remove NULL child" );
206 : :
207 : 0 : if( !haveChild() )
208 : 0 : return false; // no children, nothing to revoke.
209 : :
210 : 0 : if( mpChild == rChildLayer )
211 : : {
212 : : // we have it - replace by removed child's sibling.
213 : 0 : mpChild = rChildLayer->getChildLayer();
214 : :
215 : : // if we're now the first one, defensively increment _all_
216 : : // state ids: possibly all underlying attributes have now
217 : : // changed to default
218 : 0 : if( !haveChild() )
219 : : {
220 : : // TODO(P1): Check whether it pays off to check more
221 : : // detailed, which attributes really change
222 : 0 : ++mnTransformationState;
223 : 0 : ++mnClipState;
224 : 0 : ++mnAlphaState;
225 : 0 : ++mnPositionState;
226 : 0 : ++mnContentState;
227 : 0 : ++mnVisibilityState;
228 : : }
229 : : }
230 : : else
231 : : {
232 : : // we don't have it - pass on the request
233 : 0 : if( !mpChild->revokeChildLayer( rChildLayer ) )
234 : 0 : return false; // nobody has it - bail out
235 : : }
236 : :
237 : : // something might have changed - update ids.
238 : 0 : updateStateIds();
239 : :
240 : 0 : return true;
241 : : }
242 : :
243 : 0 : ShapeAttributeLayerSharedPtr ShapeAttributeLayer::getChildLayer() const
244 : : {
245 : 0 : return mpChild;
246 : : }
247 : :
248 : 0 : void ShapeAttributeLayer::setAdditiveMode( sal_Int16 nMode )
249 : : {
250 : 0 : if( mnAdditiveMode != nMode )
251 : : {
252 : : // TODO(P1): Check whether it pays off to check more
253 : : // detailed, which attributes really change
254 : :
255 : : // defensively increment all states - possibly each of them
256 : : // will change with different additive mode
257 : 0 : ++mnTransformationState;
258 : 0 : ++mnClipState;
259 : 0 : ++mnAlphaState;
260 : 0 : ++mnPositionState;
261 : 0 : ++mnContentState;
262 : 0 : ++mnVisibilityState;
263 : : }
264 : :
265 : 0 : mnAdditiveMode = nMode;
266 : 0 : }
267 : :
268 : 0 : bool ShapeAttributeLayer::isWidthValid() const
269 : : {
270 : 0 : return mbWidthValid ? true : haveChild() ? mpChild->isWidthValid() : false;
271 : : }
272 : :
273 : 0 : double ShapeAttributeLayer::getWidth() const
274 : : {
275 : : return calcValue< double >(
276 : 0 : maSize.getX(),
277 : : mbWidthValid,
278 : : &ShapeAttributeLayer::isWidthValid,
279 : 0 : &ShapeAttributeLayer::getWidth );
280 : : }
281 : :
282 : 0 : void ShapeAttributeLayer::setWidth( const double& rNewWidth )
283 : : {
284 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewWidth),
285 : : "ShapeAttributeLayer::setWidth(): Invalid width" );
286 : :
287 : 0 : maSize.setX( rNewWidth );
288 : 0 : mbWidthValid = true;
289 : 0 : ++mnTransformationState;
290 : 0 : }
291 : :
292 : 0 : bool ShapeAttributeLayer::isHeightValid() const
293 : : {
294 : 0 : return mbHeightValid ? true : haveChild() ? mpChild->isHeightValid() : false;
295 : : }
296 : :
297 : 0 : double ShapeAttributeLayer::getHeight() const
298 : : {
299 : : return calcValue< double >(
300 : 0 : maSize.getY(),
301 : : mbHeightValid,
302 : : &ShapeAttributeLayer::isHeightValid,
303 : 0 : &ShapeAttributeLayer::getHeight );
304 : : }
305 : :
306 : 0 : void ShapeAttributeLayer::setHeight( const double& rNewHeight )
307 : : {
308 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewHeight),
309 : : "ShapeAttributeLayer::setHeight(): Invalid height" );
310 : :
311 : 0 : maSize.setY( rNewHeight );
312 : 0 : mbHeightValid = true;
313 : 0 : ++mnTransformationState;
314 : 0 : }
315 : :
316 : 0 : void ShapeAttributeLayer::setSize( const ::basegfx::B2DSize& rNewSize )
317 : : {
318 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewSize.getX()) &&
319 : : ::rtl::math::isFinite(rNewSize.getY()),
320 : : "ShapeAttributeLayer::setSize(): Invalid size" );
321 : :
322 : 0 : maSize = rNewSize;
323 : 0 : mbWidthValid = mbHeightValid = true;
324 : 0 : ++mnTransformationState;
325 : 0 : }
326 : :
327 : 0 : bool ShapeAttributeLayer::isPosXValid() const
328 : : {
329 : 0 : return mbPosXValid ? true : haveChild() ? mpChild->isPosXValid() : false;
330 : : }
331 : :
332 : 0 : double ShapeAttributeLayer::getPosX() const
333 : : {
334 : : return calcValue< double >(
335 : 0 : maPosition.getX(),
336 : : mbPosXValid,
337 : : &ShapeAttributeLayer::isPosXValid,
338 : 0 : &ShapeAttributeLayer::getPosX );
339 : : }
340 : :
341 : 0 : void ShapeAttributeLayer::setPosX( const double& rNewX )
342 : : {
343 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewX),
344 : : "ShapeAttributeLayer::setPosX(): Invalid position" );
345 : :
346 : 0 : maPosition.setX( rNewX );
347 : 0 : mbPosXValid = true;
348 : 0 : ++mnPositionState;
349 : 0 : }
350 : :
351 : 0 : bool ShapeAttributeLayer::isPosYValid() const
352 : : {
353 : 0 : return mbPosYValid ? true : haveChild() ? mpChild->isPosYValid() : false;
354 : : }
355 : :
356 : 0 : double ShapeAttributeLayer::getPosY() const
357 : : {
358 : : return calcValue< double >(
359 : 0 : maPosition.getY(),
360 : : mbPosYValid,
361 : : &ShapeAttributeLayer::isPosYValid,
362 : 0 : &ShapeAttributeLayer::getPosY );
363 : : }
364 : :
365 : 0 : void ShapeAttributeLayer::setPosY( const double& rNewY )
366 : : {
367 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewY),
368 : : "ShapeAttributeLayer::setPosY(): Invalid position" );
369 : :
370 : 0 : maPosition.setY( rNewY );
371 : 0 : mbPosYValid = true;
372 : 0 : ++mnPositionState;
373 : 0 : }
374 : :
375 : 0 : void ShapeAttributeLayer::setPosition( const ::basegfx::B2DPoint& rNewPos )
376 : : {
377 : 0 : maPosition = rNewPos;
378 : 0 : mbPosXValid = mbPosYValid = true;
379 : 0 : ++mnPositionState;
380 : 0 : }
381 : :
382 : 0 : bool ShapeAttributeLayer::isRotationAngleValid() const
383 : : {
384 : 0 : return mbRotationAngleValid ? true : haveChild() ? mpChild->isRotationAngleValid() : false;
385 : : }
386 : :
387 : 0 : double ShapeAttributeLayer::getRotationAngle() const
388 : : {
389 : : return calcValue< double >(
390 : : mnRotationAngle,
391 : : mbRotationAngleValid,
392 : : &ShapeAttributeLayer::isRotationAngleValid,
393 : 0 : &ShapeAttributeLayer::getRotationAngle );
394 : : }
395 : :
396 : 0 : void ShapeAttributeLayer::setRotationAngle( const double& rNewAngle )
397 : : {
398 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewAngle),
399 : : "ShapeAttributeLayer::setRotationAngle(): Invalid angle" );
400 : :
401 : 0 : mnRotationAngle = rNewAngle;
402 : 0 : mbRotationAngleValid = true;
403 : 0 : ++mnTransformationState;
404 : 0 : }
405 : :
406 : 0 : bool ShapeAttributeLayer::isShearXAngleValid() const
407 : : {
408 : 0 : return mbShearXAngleValid ? true : haveChild() ? mpChild->isShearXAngleValid() : false;
409 : : }
410 : :
411 : 0 : double ShapeAttributeLayer::getShearXAngle() const
412 : : {
413 : : return calcValue( mnShearXAngle,
414 : : mbShearXAngleValid,
415 : : &ShapeAttributeLayer::isShearXAngleValid,
416 : 0 : &ShapeAttributeLayer::getShearXAngle );
417 : : }
418 : :
419 : 0 : void ShapeAttributeLayer::setShearXAngle( const double& rNewAngle )
420 : : {
421 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewAngle),
422 : : "ShapeAttributeLayer::setShearXAngle(): Invalid angle" );
423 : :
424 : 0 : mnShearXAngle = rNewAngle;
425 : 0 : mbShearXAngleValid = true;
426 : 0 : ++mnTransformationState;
427 : 0 : }
428 : :
429 : 0 : bool ShapeAttributeLayer::isShearYAngleValid() const
430 : : {
431 : 0 : return mbShearYAngleValid ? true : haveChild() ? mpChild->isShearYAngleValid() : false;
432 : : }
433 : :
434 : 0 : double ShapeAttributeLayer::getShearYAngle() const
435 : : {
436 : : return calcValue( mnShearYAngle,
437 : : mbShearYAngleValid,
438 : : &ShapeAttributeLayer::isShearYAngleValid,
439 : 0 : &ShapeAttributeLayer::getShearYAngle );
440 : : }
441 : :
442 : 0 : void ShapeAttributeLayer::setShearYAngle( const double& rNewAngle )
443 : : {
444 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewAngle),
445 : : "ShapeAttributeLayer::setShearYAngle(): Invalid angle" );
446 : :
447 : 0 : mnShearYAngle = rNewAngle;
448 : 0 : mbShearYAngleValid = true;
449 : 0 : ++mnTransformationState;
450 : 0 : }
451 : :
452 : 0 : bool ShapeAttributeLayer::isAlphaValid() const
453 : : {
454 : 0 : return mbAlphaValid ? true : haveChild() ? mpChild->isAlphaValid() : false;
455 : : }
456 : :
457 : 0 : double ShapeAttributeLayer::getAlpha() const
458 : : {
459 : : return calcValue( mnAlpha,
460 : : mbAlphaValid,
461 : : &ShapeAttributeLayer::isAlphaValid,
462 : 0 : &ShapeAttributeLayer::getAlpha );
463 : : }
464 : :
465 : 0 : void ShapeAttributeLayer::setAlpha( const double& rNewValue )
466 : : {
467 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewValue),
468 : : "ShapeAttributeLayer::setAlpha(): Invalid alpha" );
469 : :
470 : 0 : mnAlpha = rNewValue;
471 : 0 : mbAlphaValid = true;
472 : 0 : ++mnAlphaState;
473 : 0 : }
474 : :
475 : 0 : bool ShapeAttributeLayer::isClipValid() const
476 : : {
477 : 0 : return mbClipValid ? true : haveChild() ? mpChild->isClipValid() : false;
478 : : }
479 : :
480 : 0 : ::basegfx::B2DPolyPolygon ShapeAttributeLayer::getClip() const
481 : : {
482 : : // TODO(F1): Implement polygon algebra for additive modes
483 : 0 : if( mbClipValid )
484 : 0 : return maClip;
485 : 0 : else if( haveChild() )
486 : 0 : return mpChild->getClip();
487 : : else
488 : 0 : return ::basegfx::B2DPolyPolygon();
489 : : }
490 : :
491 : 0 : void ShapeAttributeLayer::setClip( const ::basegfx::B2DPolyPolygon& rNewClip )
492 : : {
493 : 0 : maClip = rNewClip;
494 : 0 : mbClipValid = true;
495 : 0 : ++mnClipState;
496 : 0 : }
497 : :
498 : 0 : bool ShapeAttributeLayer::isDimColorValid() const
499 : : {
500 : 0 : return mbDimColorValid ? true : haveChild() ? mpChild->isDimColorValid() : false;
501 : : }
502 : :
503 : 0 : RGBColor ShapeAttributeLayer::getDimColor() const
504 : : {
505 : : return calcValue( maDimColor,
506 : : mbDimColorValid,
507 : : &ShapeAttributeLayer::isDimColorValid,
508 : 0 : &ShapeAttributeLayer::getDimColor );
509 : : }
510 : :
511 : 0 : void ShapeAttributeLayer::setDimColor( const RGBColor& nNewColor )
512 : : {
513 : 0 : maDimColor = nNewColor;
514 : 0 : mbDimColorValid = true;
515 : 0 : ++mnContentState;
516 : 0 : }
517 : :
518 : 0 : bool ShapeAttributeLayer::isFillColorValid() const
519 : : {
520 : 0 : return mbFillColorValid ? true : haveChild() ? mpChild->isFillColorValid() : false;
521 : : }
522 : :
523 : 0 : RGBColor ShapeAttributeLayer::getFillColor() const
524 : : {
525 : : return calcValue( maFillColor,
526 : : mbFillColorValid,
527 : : &ShapeAttributeLayer::isFillColorValid,
528 : 0 : &ShapeAttributeLayer::getFillColor );
529 : : }
530 : :
531 : 0 : void ShapeAttributeLayer::setFillColor( const RGBColor& nNewColor )
532 : : {
533 : 0 : maFillColor = nNewColor;
534 : 0 : mbFillColorValid = true;
535 : 0 : ++mnContentState;
536 : 0 : }
537 : :
538 : 0 : bool ShapeAttributeLayer::isLineColorValid() const
539 : : {
540 : 0 : return mbLineColorValid ? true : haveChild() ? mpChild->isLineColorValid() : false;
541 : : }
542 : :
543 : 0 : RGBColor ShapeAttributeLayer::getLineColor() const
544 : : {
545 : : return calcValue( maLineColor,
546 : : mbLineColorValid,
547 : : &ShapeAttributeLayer::isLineColorValid,
548 : 0 : &ShapeAttributeLayer::getLineColor );
549 : : }
550 : :
551 : 0 : void ShapeAttributeLayer::setLineColor( const RGBColor& nNewColor )
552 : : {
553 : 0 : maLineColor = nNewColor;
554 : 0 : mbLineColorValid = true;
555 : 0 : ++mnContentState;
556 : 0 : }
557 : :
558 : 0 : bool ShapeAttributeLayer::isFillStyleValid() const
559 : : {
560 : 0 : return mbFillStyleValid ? true : haveChild() ? mpChild->isFillStyleValid() : false;
561 : : }
562 : :
563 : 0 : sal_Int16 ShapeAttributeLayer::getFillStyle() const
564 : : {
565 : : // mnAdditiveMode is ignored, cannot combine strings in
566 : : // any sensible way
567 : 0 : if( mbFillStyleValid )
568 : 0 : return sal::static_int_cast<sal_Int16>(meFillStyle);
569 : 0 : else if( haveChild() )
570 : 0 : return sal::static_int_cast<sal_Int16>(mpChild->getFillStyle());
571 : : else
572 : 0 : return sal::static_int_cast<sal_Int16>(drawing::FillStyle_SOLID);
573 : : }
574 : :
575 : 0 : void ShapeAttributeLayer::setFillStyle( const sal_Int16& rStyle )
576 : : {
577 : : // TODO(Q1): Check range here.
578 : 0 : meFillStyle = (drawing::FillStyle)rStyle;
579 : 0 : mbFillStyleValid = true;
580 : 0 : ++mnContentState;
581 : 0 : }
582 : :
583 : 0 : bool ShapeAttributeLayer::isLineStyleValid() const
584 : : {
585 : 0 : return mbLineStyleValid ? true : haveChild() ? mpChild->isLineStyleValid() : false;
586 : : }
587 : :
588 : 0 : sal_Int16 ShapeAttributeLayer::getLineStyle() const
589 : : {
590 : : // mnAdditiveMode is ignored, cannot combine strings in
591 : : // any sensible way
592 : 0 : if( mbLineStyleValid )
593 : 0 : return sal::static_int_cast<sal_Int16>(meLineStyle);
594 : 0 : else if( haveChild() )
595 : 0 : return sal::static_int_cast<sal_Int16>(mpChild->getLineStyle());
596 : : else
597 : 0 : return sal::static_int_cast<sal_Int16>(drawing::LineStyle_SOLID);
598 : : }
599 : :
600 : 0 : void ShapeAttributeLayer::setLineStyle( const sal_Int16& rStyle )
601 : : {
602 : : // TODO(Q1): Check range here.
603 : 0 : meLineStyle = (drawing::LineStyle)rStyle;
604 : 0 : mbLineStyleValid = true;
605 : 0 : ++mnContentState;
606 : 0 : }
607 : :
608 : 0 : bool ShapeAttributeLayer::isVisibilityValid() const
609 : : {
610 : 0 : return mbVisibilityValid ? true : haveChild() ? mpChild->isVisibilityValid() : false;
611 : : }
612 : :
613 : 0 : bool ShapeAttributeLayer::getVisibility() const
614 : : {
615 : : // mnAdditiveMode is ignored, SMIL spec requires to not combine
616 : : // bools in any sensible way
617 : 0 : if( mbVisibilityValid )
618 : 0 : return mbVisibility;
619 : 0 : else if( haveChild() )
620 : 0 : return mpChild->getVisibility();
621 : : else
622 : 0 : return true; // default is always visible
623 : : }
624 : :
625 : 0 : void ShapeAttributeLayer::setVisibility( const bool& bVisible )
626 : : {
627 : 0 : mbVisibility = bVisible;
628 : 0 : mbVisibilityValid = true;
629 : 0 : ++mnVisibilityState;
630 : 0 : }
631 : :
632 : 0 : bool ShapeAttributeLayer::isCharColorValid() const
633 : : {
634 : 0 : return mbCharColorValid ? true : haveChild() ? mpChild->isCharColorValid() : false;
635 : : }
636 : :
637 : 0 : RGBColor ShapeAttributeLayer::getCharColor() const
638 : : {
639 : : return calcValue( maCharColor,
640 : : mbCharColorValid,
641 : : &ShapeAttributeLayer::isCharColorValid,
642 : 0 : &ShapeAttributeLayer::getCharColor );
643 : : }
644 : :
645 : 0 : void ShapeAttributeLayer::setCharColor( const RGBColor& nNewColor )
646 : : {
647 : 0 : maCharColor = nNewColor;
648 : 0 : mbCharColorValid = true;
649 : 0 : ++mnContentState;
650 : 0 : }
651 : :
652 : 0 : bool ShapeAttributeLayer::isCharRotationAngleValid() const
653 : : {
654 : 0 : return mbCharRotationAngleValid ? true : haveChild() ? mpChild->isCharRotationAngleValid() : false;
655 : : }
656 : :
657 : 0 : double ShapeAttributeLayer::getCharRotationAngle() const
658 : : {
659 : : return calcValue( mnCharRotationAngle,
660 : : mbCharRotationAngleValid,
661 : : &ShapeAttributeLayer::isCharRotationAngleValid,
662 : 0 : &ShapeAttributeLayer::getCharRotationAngle );
663 : : }
664 : :
665 : 0 : void ShapeAttributeLayer::setCharRotationAngle( const double& rNewAngle )
666 : : {
667 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewAngle),
668 : : "ShapeAttributeLayer::setCharRotationAngle(): Invalid angle" );
669 : :
670 : 0 : mnCharRotationAngle = rNewAngle;
671 : 0 : mbCharRotationAngleValid = true;
672 : 0 : ++mnContentState;
673 : 0 : }
674 : :
675 : 0 : bool ShapeAttributeLayer::isCharWeightValid() const
676 : : {
677 : 0 : return mbCharWeightValid ? true : haveChild() ? mpChild->isCharWeightValid() : false;
678 : : }
679 : :
680 : 0 : double ShapeAttributeLayer::getCharWeight() const
681 : : {
682 : : // mnAdditiveMode is ignored, cannot combine strings in
683 : : // any sensible way
684 : 0 : if( mbCharWeightValid )
685 : 0 : return mnCharWeight;
686 : 0 : else if( haveChild() )
687 : 0 : return mpChild->getCharWeight();
688 : : else
689 : 0 : return awt::FontWeight::NORMAL;
690 : : }
691 : :
692 : 0 : void ShapeAttributeLayer::setCharWeight( const double& rValue )
693 : : {
694 : : // TODO(Q1): Check range here.
695 : 0 : mnCharWeight = rValue;
696 : 0 : mbCharWeightValid = true;
697 : 0 : ++mnContentState;
698 : 0 : }
699 : :
700 : 0 : bool ShapeAttributeLayer::isUnderlineModeValid() const
701 : : {
702 : 0 : return mbUnderlineModeValid ? true : haveChild() ? mpChild->isUnderlineModeValid() : false;
703 : : }
704 : :
705 : 0 : sal_Int16 ShapeAttributeLayer::getUnderlineMode() const
706 : : {
707 : : // mnAdditiveMode is ignored, SMIL spec requires to not combine
708 : : // bools in any sensible way
709 : 0 : if( mbUnderlineModeValid )
710 : 0 : return mnUnderlineMode;
711 : 0 : else if( haveChild() )
712 : 0 : return mpChild->getUnderlineMode();
713 : : else
714 : 0 : return awt::FontUnderline::NONE; // default is no underline
715 : : }
716 : :
717 : 0 : void ShapeAttributeLayer::setUnderlineMode( const sal_Int16& rUnderlineMode )
718 : : {
719 : : // TODO(Q1): Check range here.
720 : 0 : mnUnderlineMode = rUnderlineMode;
721 : 0 : mbUnderlineModeValid = true;
722 : 0 : ++mnContentState;
723 : 0 : }
724 : :
725 : 0 : bool ShapeAttributeLayer::isFontFamilyValid() const
726 : : {
727 : 0 : return mbFontFamilyValid ? true : haveChild() ? mpChild->isFontFamilyValid() : false;
728 : : }
729 : :
730 : 0 : ::rtl::OUString ShapeAttributeLayer::getFontFamily() const
731 : : {
732 : : // mnAdditiveMode is ignored, cannot combine strings in
733 : : // any sensible way
734 : 0 : if( mbFontFamilyValid )
735 : 0 : return maFontFamily;
736 : 0 : else if( haveChild() )
737 : 0 : return mpChild->getFontFamily();
738 : : else
739 : 0 : return ::rtl::OUString();
740 : : }
741 : :
742 : 0 : void ShapeAttributeLayer::setFontFamily( const ::rtl::OUString& rName )
743 : : {
744 : 0 : maFontFamily = rName;
745 : 0 : mbFontFamilyValid = true;
746 : 0 : ++mnContentState;
747 : 0 : }
748 : :
749 : 0 : bool ShapeAttributeLayer::isCharPostureValid() const
750 : : {
751 : 0 : return mbCharPostureValid ? true : haveChild() ? mpChild->isCharPostureValid() : false;
752 : : }
753 : :
754 : 0 : sal_Int16 ShapeAttributeLayer::getCharPosture() const
755 : : {
756 : : // mnAdditiveMode is ignored, cannot combine strings in
757 : : // any sensible way
758 : 0 : if( mbCharPostureValid )
759 : 0 : return sal::static_int_cast<sal_Int16>(meCharPosture);
760 : 0 : else if( haveChild() )
761 : 0 : return sal::static_int_cast<sal_Int16>(mpChild->getCharPosture());
762 : : else
763 : 0 : return sal::static_int_cast<sal_Int16>(awt::FontSlant_NONE);
764 : : }
765 : :
766 : 0 : void ShapeAttributeLayer::setCharPosture( const sal_Int16& rStyle )
767 : : {
768 : : // TODO(Q1): Check range here.
769 : 0 : meCharPosture = (awt::FontSlant)rStyle;
770 : 0 : mbCharPostureValid = true;
771 : 0 : ++mnContentState;
772 : 0 : }
773 : :
774 : 0 : bool ShapeAttributeLayer::isCharScaleValid() const
775 : : {
776 : 0 : return mbCharScaleValid ? true : haveChild() ? mpChild->isCharScaleValid() : false;
777 : : }
778 : :
779 : 0 : double ShapeAttributeLayer::getCharScale() const
780 : : {
781 : : return calcValue( mnCharScale,
782 : : mbCharScaleValid,
783 : : &ShapeAttributeLayer::isCharScaleValid,
784 : 0 : &ShapeAttributeLayer::getCharScale );
785 : : }
786 : :
787 : 0 : void ShapeAttributeLayer::setCharScale( const double& rNewHeight )
788 : : {
789 : 0 : ENSURE_OR_THROW( ::rtl::math::isFinite(rNewHeight),
790 : : "ShapeAttributeLayer::setCharScale(): Invalid height" );
791 : :
792 : 0 : mnCharScale = rNewHeight;
793 : 0 : mbCharScaleValid = true;
794 : 0 : ++mnContentState;
795 : 0 : }
796 : :
797 : 0 : State::StateId ShapeAttributeLayer::getTransformationState() const
798 : : {
799 : 0 : return haveChild() ?
800 : : ::std::max( mnTransformationState,
801 : 0 : mpChild->getTransformationState() ) :
802 : 0 : mnTransformationState;
803 : : }
804 : :
805 : 0 : State::StateId ShapeAttributeLayer::getClipState() const
806 : : {
807 : 0 : return haveChild() ?
808 : : ::std::max( mnClipState,
809 : 0 : mpChild->getClipState() ) :
810 : 0 : mnClipState;
811 : : }
812 : :
813 : 0 : State::StateId ShapeAttributeLayer::getAlphaState() const
814 : : {
815 : 0 : return haveChild() ?
816 : : ::std::max( mnAlphaState,
817 : 0 : mpChild->getAlphaState() ) :
818 : 0 : mnAlphaState;
819 : : }
820 : :
821 : 0 : State::StateId ShapeAttributeLayer::getPositionState() const
822 : : {
823 : 0 : return haveChild() ?
824 : : ::std::max( mnPositionState,
825 : 0 : mpChild->getPositionState() ) :
826 : 0 : mnPositionState;
827 : : }
828 : :
829 : 0 : State::StateId ShapeAttributeLayer::getContentState() const
830 : : {
831 : 0 : return haveChild() ?
832 : : ::std::max( mnContentState,
833 : 0 : mpChild->getContentState() ) :
834 : 0 : mnContentState;
835 : : }
836 : :
837 : 0 : State::StateId ShapeAttributeLayer::getVisibilityState() const
838 : : {
839 : 0 : return haveChild() ?
840 : : ::std::max( mnVisibilityState,
841 : 0 : mpChild->getVisibilityState() ) :
842 : 0 : mnVisibilityState;
843 : : }
844 : :
845 : : }
846 : : }
847 : :
848 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|