Bump version to 6.4-15
[LibreOffice.git] / slideshow / source / engine / tools.cxx
blob096715a73c905eae086d5246f479174b9e4039cd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <tools/diagnose_ex.h>
22 #include <canvas/canvastools.hxx>
24 #include <math.h>
26 #include <com/sun/star/beans/NamedValue.hpp>
27 #include <com/sun/star/awt/Rectangle.hpp>
28 #include <com/sun/star/animations/ValuePair.hpp>
29 #include <com/sun/star/drawing/FillStyle.hpp>
30 #include <com/sun/star/drawing/LineStyle.hpp>
31 #include <com/sun/star/awt/FontSlant.hpp>
33 #include <basegfx/polygon/b2dpolygon.hxx>
34 #include <basegfx/polygon/b2dpolygontools.hxx>
35 #include <basegfx/range/b2drange.hxx>
36 #include <basegfx/vector/b2dvector.hxx>
37 #include <basegfx/vector/b2ivector.hxx>
38 #include <basegfx/matrix/b2dhommatrix.hxx>
39 #include <basegfx/numeric/ftools.hxx>
40 #include <basegfx/utils/lerp.hxx>
41 #include <basegfx/matrix/b2dhommatrixtools.hxx>
43 #include <cppcanvas/basegfxfactory.hxx>
45 #include <unoview.hxx>
46 #include <smilfunctionparser.hxx>
47 #include <tools.hxx>
49 #include <limits>
52 using namespace ::com::sun::star;
54 namespace slideshow
56 namespace internal
58 namespace
60 class NamedValueComparator
62 public:
63 explicit NamedValueComparator( const beans::NamedValue& rKey ) :
64 mrKey( rKey )
68 bool operator()( const beans::NamedValue& rValue ) const
70 return rValue.Name == mrKey.Name && rValue.Value == mrKey.Value;
73 private:
74 const beans::NamedValue& mrKey;
77 ::basegfx::B2DHomMatrix getAttributedShapeTransformation( const ::basegfx::B2DRectangle& rShapeBounds,
78 const ShapeAttributeLayerSharedPtr& pAttr )
80 ::basegfx::B2DHomMatrix aTransform;
81 const ::basegfx::B2DSize& rSize( rShapeBounds.getRange() );
83 const double nShearX( pAttr->isShearXAngleValid() ?
84 pAttr->getShearXAngle() :
85 0.0 );
86 const double nShearY( pAttr->isShearYAngleValid() ?
87 pAttr->getShearYAngle() :
88 0.0 );
89 const double nRotation( pAttr->isRotationAngleValid() ?
90 basegfx::deg2rad(pAttr->getRotationAngle()) :
91 0.0 );
93 // scale, shear and rotation pivot point is the shape
94 // center - adapt origin accordingly
95 aTransform.translate( -0.5, -0.5 );
97 // ensure valid size (zero size will inevitably lead
98 // to a singular transformation matrix)
99 aTransform.scale( ::basegfx::pruneScaleValue(
100 rSize.getX() ),
101 ::basegfx::pruneScaleValue(
102 rSize.getY() ) );
104 const bool bNeedShearX( !::basegfx::fTools::equalZero(nShearX) );
105 const bool bNeedShearY( !::basegfx::fTools::equalZero(nShearY) );
106 const bool bNeedRotation( !::basegfx::fTools::equalZero(nRotation) );
108 if( bNeedRotation || bNeedShearX || bNeedShearY )
110 if( bNeedShearX )
111 aTransform.shearX( nShearX );
113 if( bNeedShearY )
114 aTransform.shearY( nShearY );
116 if( bNeedRotation )
117 aTransform.rotate( nRotation );
120 // move left, top corner back to position of the
121 // shape. Since we've already translated the
122 // center of the shape to the origin (the
123 // translate( -0.5, -0.5 ) above), translate to
124 // center of final shape position here.
125 aTransform.translate( rShapeBounds.getCenterX(),
126 rShapeBounds.getCenterY() );
128 return aTransform;
132 // Value extraction from Any
133 // =========================
135 /// extract unary double value from Any
136 bool extractValue( double& o_rValue,
137 const uno::Any& rSourceAny,
138 const ShapeSharedPtr& rShape,
139 const ::basegfx::B2DVector& rSlideBounds )
141 // try to extract numeric value (double, or smaller POD, like float or int)
142 if( rSourceAny >>= o_rValue)
144 // succeeded
145 return true;
148 // try to extract string
149 OUString aString;
150 if( !(rSourceAny >>= aString) )
151 return false; // nothing left to try
153 // parse the string into an ExpressionNode
156 // Parse string into ExpressionNode, eval node at time 0.0
157 o_rValue = (*SmilFunctionParser::parseSmilValue(
158 aString,
159 calcRelativeShapeBounds(rSlideBounds,
160 rShape->getBounds()) ))(0.0);
162 catch( ParseError& )
164 return false;
167 return true;
170 /// extract enum/constant group value from Any
171 bool extractValue( sal_Int32& o_rValue,
172 const uno::Any& rSourceAny,
173 const ShapeSharedPtr& /*rShape*/,
174 const ::basegfx::B2DVector& /*rSlideBounds*/ )
176 // try to extract numeric value (int, or smaller POD, like byte)
177 if( rSourceAny >>= o_rValue)
179 // succeeded
180 return true;
183 // okay, no plain int. Maybe one of the domain-specific enums?
184 drawing::FillStyle eFillStyle;
185 if( rSourceAny >>= eFillStyle )
187 o_rValue = sal::static_int_cast<sal_Int16>(eFillStyle);
189 // succeeded
190 return true;
193 drawing::LineStyle eLineStyle;
194 if( rSourceAny >>= eLineStyle )
196 o_rValue = sal::static_int_cast<sal_Int16>(eLineStyle);
198 // succeeded
199 return true;
202 awt::FontSlant eFontSlant;
203 if( rSourceAny >>= eFontSlant )
205 o_rValue = sal::static_int_cast<sal_Int16>(eFontSlant);
207 // succeeded
208 return true;
211 // nothing left to try. Failure
212 return false;
215 /// extract enum/constant group value from Any
216 bool extractValue( sal_Int16& o_rValue,
217 const uno::Any& rSourceAny,
218 const ShapeSharedPtr& rShape,
219 const ::basegfx::B2DVector& rSlideBounds )
221 sal_Int32 aValue;
222 if( !extractValue(aValue,rSourceAny,rShape,rSlideBounds) )
223 return false;
225 if( std::numeric_limits<sal_Int16>::max() < aValue ||
226 std::numeric_limits<sal_Int16>::min() > aValue )
228 return false;
231 o_rValue = static_cast<sal_Int16>(aValue);
233 return true;
236 /// extract color value from Any
237 bool extractValue( RGBColor& o_rValue,
238 const uno::Any& rSourceAny,
239 const ShapeSharedPtr& /*rShape*/,
240 const ::basegfx::B2DVector& /*rSlideBounds*/ )
242 // try to extract numeric value (double, or smaller POD, like float or int)
244 double nTmp = 0;
245 if( rSourceAny >>= nTmp )
247 sal_uInt32 aIntColor( static_cast< sal_uInt32 >(nTmp) );
249 // TODO(F2): Handle color values correctly, here
250 o_rValue = unoColor2RGBColor( aIntColor );
252 // succeeded
253 return true;
257 // try double sequence
259 uno::Sequence< double > aTmp;
260 if( rSourceAny >>= aTmp )
262 ENSURE_OR_THROW( aTmp.getLength() == 3,
263 "extractValue(): inappropriate length for RGB color value" );
265 o_rValue = RGBColor( aTmp[0], aTmp[1], aTmp[2] );
267 // succeeded
268 return true;
272 // try sal_Int32 sequence
274 uno::Sequence< sal_Int32 > aTmp;
275 if( rSourceAny >>= aTmp )
277 ENSURE_OR_THROW( aTmp.getLength() == 3,
278 "extractValue(): inappropriate length for RGB color value" );
280 // truncate to byte
281 o_rValue = RGBColor( ::cppcanvas::makeColor(
282 static_cast<sal_uInt8>(aTmp[0]),
283 static_cast<sal_uInt8>(aTmp[1]),
284 static_cast<sal_uInt8>(aTmp[2]),
285 255 ) );
287 // succeeded
288 return true;
292 // try sal_Int8 sequence
294 uno::Sequence< sal_Int8 > aTmp;
295 if( rSourceAny >>= aTmp )
297 ENSURE_OR_THROW( aTmp.getLength() == 3,
298 "extractValue(): inappropriate length for RGB color value" );
300 o_rValue = RGBColor( ::cppcanvas::makeColor( aTmp[0], aTmp[1], aTmp[2], 255 ) );
302 // succeeded
303 return true;
307 // try to extract string
308 OUString aString;
309 if( !(rSourceAny >>= aString) )
310 return false; // nothing left to try
312 // TODO(F2): Provide symbolic color values here
313 o_rValue = RGBColor( 0.5, 0.5, 0.5 );
315 return true;
318 /// extract color value from Any
319 bool extractValue( HSLColor& o_rValue,
320 const uno::Any& rSourceAny,
321 const ShapeSharedPtr& /*rShape*/,
322 const ::basegfx::B2DVector& /*rSlideBounds*/ )
324 // try double sequence
326 uno::Sequence< double > aTmp;
327 if( rSourceAny >>= aTmp )
329 ENSURE_OR_THROW( aTmp.getLength() == 3,
330 "extractValue(): inappropriate length for HSL color value" );
332 o_rValue = HSLColor( aTmp[0], aTmp[1], aTmp[2] );
334 // succeeded
335 return true;
339 // try sal_Int8 sequence
341 uno::Sequence< sal_Int8 > aTmp;
342 if( rSourceAny >>= aTmp )
344 ENSURE_OR_THROW( aTmp.getLength() == 3,
345 "extractValue(): inappropriate length for HSL color value" );
347 o_rValue = HSLColor( aTmp[0]*360.0/255.0, aTmp[1]/255.0, aTmp[2]/255.0 );
349 // succeeded
350 return true;
354 return false; // nothing left to try
357 /// extract plain string from Any
358 bool extractValue( OUString& o_rValue,
359 const uno::Any& rSourceAny,
360 const ShapeSharedPtr& /*rShape*/,
361 const ::basegfx::B2DVector& /*rSlideBounds*/ )
363 // try to extract string
364 return rSourceAny >>= o_rValue;
367 /// extract bool value from Any
368 bool extractValue( bool& o_rValue,
369 const uno::Any& rSourceAny,
370 const ShapeSharedPtr& /*rShape*/,
371 const ::basegfx::B2DVector& /*rSlideBounds*/ )
373 bool bTmp;
374 // try to extract bool value
375 if( rSourceAny >>= bTmp )
377 o_rValue = bTmp;
379 // succeeded
380 return true;
383 // try to extract string
384 OUString aString;
385 if( !(rSourceAny >>= aString) )
386 return false; // nothing left to try
388 // we also take the strings "true" and "false",
389 // as well as "on" and "off" here
390 if( aString.equalsIgnoreAsciiCase("true") ||
391 aString.equalsIgnoreAsciiCase("on") )
393 o_rValue = true;
394 return true;
396 if( aString.equalsIgnoreAsciiCase("false") ||
397 aString.equalsIgnoreAsciiCase("off") )
399 o_rValue = false;
400 return true;
403 // ultimately failed.
404 return false;
407 /// extract double 2-tuple from Any
408 bool extractValue( ::basegfx::B2DTuple& o_rPair,
409 const uno::Any& rSourceAny,
410 const ShapeSharedPtr& rShape,
411 const ::basegfx::B2DVector& rSlideBounds )
413 animations::ValuePair aPair;
415 if( !(rSourceAny >>= aPair) )
416 return false;
418 double nFirst;
419 if( !extractValue( nFirst, aPair.First, rShape, rSlideBounds ) )
420 return false;
422 double nSecond;
423 if( !extractValue( nSecond, aPair.Second, rShape, rSlideBounds ) )
424 return false;
426 o_rPair.setX( nFirst );
427 o_rPair.setY( nSecond );
429 return true;
432 bool findNamedValue( uno::Sequence< beans::NamedValue > const& rSequence,
433 const beans::NamedValue& rSearchKey )
435 return ::std::any_of( rSequence.begin(), rSequence.end(),
436 NamedValueComparator( rSearchKey ) );
439 basegfx::B2DRange calcRelativeShapeBounds( const basegfx::B2DVector& rPageSize,
440 const basegfx::B2DRange& rShapeBounds )
442 return basegfx::B2DRange( rShapeBounds.getMinX() / rPageSize.getX(),
443 rShapeBounds.getMinY() / rPageSize.getY(),
444 rShapeBounds.getMaxX() / rPageSize.getX(),
445 rShapeBounds.getMaxY() / rPageSize.getY() );
448 // TODO(F2): Currently, the positional attributes DO NOT mirror the XShape properties.
449 // First and foremost, this is because we must operate with the shape boundrect,
450 // not position and size (the conversion between logic rect, snap rect and boundrect
451 // are non-trivial for draw shapes, and I won't duplicate them here). Thus, shapes
452 // rotated on the page will still have 0.0 rotation angle, as the metafile
453 // representation fetched over the API is our default zero case.
455 ::basegfx::B2DHomMatrix getShapeTransformation( const ::basegfx::B2DRectangle& rShapeBounds,
456 const ShapeAttributeLayerSharedPtr& pAttr )
458 if( !pAttr )
460 const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(
461 rShapeBounds.getWidth(), rShapeBounds.getHeight(),
462 rShapeBounds.getMinX(), rShapeBounds.getMinY()));
464 return aTransform;
466 else
468 return getAttributedShapeTransformation( rShapeBounds,
469 pAttr );
473 ::basegfx::B2DHomMatrix getSpriteTransformation( const ::basegfx::B2DVector& rPixelSize,
474 const ::basegfx::B2DVector& rOrigSize,
475 const ShapeAttributeLayerSharedPtr& pAttr )
477 ::basegfx::B2DHomMatrix aTransform;
479 if( pAttr )
481 const double nShearX( pAttr->isShearXAngleValid() ?
482 pAttr->getShearXAngle() :
483 0.0 );
484 const double nShearY( pAttr->isShearYAngleValid() ?
485 pAttr->getShearYAngle() :
486 0.0 );
487 const double nRotation( pAttr->isRotationAngleValid() ?
488 basegfx::deg2rad(pAttr->getRotationAngle()) :
489 0.0 );
491 // scale, shear and rotation pivot point is the
492 // sprite's pixel center - adapt origin accordingly
493 aTransform.translate( -0.5*rPixelSize.getX(),
494 -0.5*rPixelSize.getY() );
496 const ::basegfx::B2DSize aSize(
497 pAttr->isWidthValid() ? pAttr->getWidth() : rOrigSize.getX(),
498 pAttr->isHeightValid() ? pAttr->getHeight() : rOrigSize.getY() );
500 // ensure valid size (zero size will inevitably lead
501 // to a singular transformation matrix).
502 aTransform.scale( ::basegfx::pruneScaleValue(
503 aSize.getX() /
504 ::basegfx::pruneScaleValue(
505 rOrigSize.getX() ) ),
506 ::basegfx::pruneScaleValue(
507 aSize.getY() /
508 ::basegfx::pruneScaleValue(
509 rOrigSize.getY() ) ) );
511 const bool bNeedShearX( !::basegfx::fTools::equalZero(nShearX) );
512 const bool bNeedShearY( !::basegfx::fTools::equalZero(nShearY) );
513 const bool bNeedRotation( !::basegfx::fTools::equalZero(nRotation) );
515 if( bNeedRotation || bNeedShearX || bNeedShearY )
517 if( bNeedShearX )
518 aTransform.shearX( nShearX );
520 if( bNeedShearY )
521 aTransform.shearY( nShearY );
523 if( bNeedRotation )
524 aTransform.rotate( nRotation );
527 // move left, top corner back to original position of
528 // the sprite (we've translated the center of the
529 // sprite to the origin above).
530 aTransform.translate( 0.5*rPixelSize.getX(),
531 0.5*rPixelSize.getY() );
534 // return identity transform for un-attributed
535 // shapes. This renders the sprite as-is, in its
536 // document-supplied size.
537 return aTransform;
540 ::basegfx::B2DRectangle getShapeUpdateArea( const ::basegfx::B2DRectangle& rUnitBounds,
541 const ::basegfx::B2DHomMatrix& rShapeTransform,
542 const ShapeAttributeLayerSharedPtr& pAttr )
544 ::basegfx::B2DHomMatrix aTransform;
546 if( pAttr &&
547 pAttr->isCharScaleValid() &&
548 fabs(pAttr->getCharScale()) > 1.0 )
550 // enlarge shape bounds. Have to consider the worst
551 // case here (the text fully fills the shape)
553 const double nCharScale( pAttr->getCharScale() );
555 // center of scaling is the middle of the shape
556 aTransform.translate( -0.5, -0.5 );
557 aTransform.scale( nCharScale, nCharScale );
558 aTransform.translate( 0.5, 0.5 );
561 aTransform *= rShapeTransform;
563 ::basegfx::B2DRectangle aRes;
565 // apply shape transformation to unit rect
566 return ::canvas::tools::calcTransformedRectBounds(
567 aRes,
568 rUnitBounds,
569 aTransform );
572 ::basegfx::B2DRange getShapeUpdateArea( const ::basegfx::B2DRange& rUnitBounds,
573 const ::basegfx::B2DRange& rShapeBounds )
575 return ::basegfx::B2DRectangle(
576 basegfx::utils::lerp( rShapeBounds.getMinX(),
577 rShapeBounds.getMaxX(),
578 rUnitBounds.getMinX() ),
579 basegfx::utils::lerp( rShapeBounds.getMinY(),
580 rShapeBounds.getMaxY(),
581 rUnitBounds.getMinY() ),
582 basegfx::utils::lerp( rShapeBounds.getMinX(),
583 rShapeBounds.getMaxX(),
584 rUnitBounds.getMaxX() ),
585 basegfx::utils::lerp( rShapeBounds.getMinY(),
586 rShapeBounds.getMaxY(),
587 rUnitBounds.getMaxY() ) );
590 ::basegfx::B2DRectangle getShapePosSize( const ::basegfx::B2DRectangle& rOrigBounds,
591 const ShapeAttributeLayerSharedPtr& pAttr )
593 // an already empty shape bound need no further
594 // treatment. In fact, any changes applied below would
595 // actually remove the special empty state, thus, don't
596 // change!
597 if( !pAttr ||
598 rOrigBounds.isEmpty() )
600 return rOrigBounds;
602 else
604 // cannot use maBounds anymore, attributes might have been
605 // changed by now.
606 // Have to use absolute values here, as negative sizes
607 // (aka mirrored shapes) _still_ have the same bounds,
608 // only with mirrored content.
609 ::basegfx::B2DSize aSize;
610 aSize.setX( fabs( pAttr->isWidthValid() ?
611 pAttr->getWidth() :
612 rOrigBounds.getWidth() ) );
613 aSize.setY( fabs( pAttr->isHeightValid() ?
614 pAttr->getHeight() :
615 rOrigBounds.getHeight() ) );
617 ::basegfx::B2DPoint aPos;
618 aPos.setX( pAttr->isPosXValid() ?
619 pAttr->getPosX() :
620 rOrigBounds.getCenterX() );
621 aPos.setY( pAttr->isPosYValid() ?
622 pAttr->getPosY() :
623 rOrigBounds.getCenterY() );
625 // the positional attribute retrieved from the
626 // ShapeAttributeLayer actually denotes the _middle_
627 // of the shape (do it as the PPTs do...)
628 return ::basegfx::B2DRectangle( aPos - 0.5*aSize,
629 aPos + 0.5*aSize );
633 RGBColor unoColor2RGBColor( sal_Int32 nColor )
635 return RGBColor(
636 ::cppcanvas::makeColor(
637 // convert from API color to IntSRGBA color
638 // (0xAARRGGBB -> 0xRRGGBBAA)
639 static_cast< sal_uInt8 >( nColor >> 16U ),
640 static_cast< sal_uInt8 >( nColor >> 8U ),
641 static_cast< sal_uInt8 >( nColor ),
642 static_cast< sal_uInt8 >( nColor >> 24U ) ) );
645 sal_Int32 RGBAColor2UnoColor( ::cppcanvas::IntSRGBA aColor )
647 return ::cppcanvas::makeColorARGB(
648 // convert from IntSRGBA color to API color
649 // (0xRRGGBBAA -> 0xAARRGGBB)
650 static_cast< sal_uInt8 >(0),
651 ::cppcanvas::getRed(aColor),
652 ::cppcanvas::getGreen(aColor),
653 ::cppcanvas::getBlue(aColor));
656 void fillRect( const ::cppcanvas::CanvasSharedPtr& rCanvas,
657 const ::basegfx::B2DRectangle& rRect,
658 ::cppcanvas::IntSRGBA aFillColor )
660 const ::basegfx::B2DPolygon aPoly(
661 ::basegfx::utils::createPolygonFromRect( rRect ));
663 ::cppcanvas::PolyPolygonSharedPtr pPolyPoly(
664 ::cppcanvas::BaseGfxFactory::createPolyPolygon( rCanvas, aPoly ) );
666 if( pPolyPoly )
668 pPolyPoly->setRGBAFillColor( aFillColor );
669 pPolyPoly->draw();
673 void initSlideBackground( const ::cppcanvas::CanvasSharedPtr& rCanvas,
674 const ::basegfx::B2ISize& rSize )
676 ::cppcanvas::CanvasSharedPtr pCanvas( rCanvas->clone() );
678 // set transformation to identitiy (->device pixel)
679 pCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
681 // #i42440# Fill the _full_ background in
682 // black. Since we had to extend the bitmap by one
683 // pixel, and the bitmap is initialized white,
684 // depending on the slide content a one pixel wide
685 // line will show to the bottom and the right.
686 fillRect( pCanvas,
687 ::basegfx::B2DRectangle( 0.0, 0.0,
688 rSize.getX(),
689 rSize.getY() ),
690 0x000000FFU );
692 // fill the bounds rectangle in white. Subtract one pixel
693 // from both width and height, because the slide size is
694 // chosen one pixel larger than given by the drawing
695 // layer. This is because shapes with line style, that
696 // have the size of the slide would otherwise be cut
697 // off. OTOH, every other slide background (solid fill,
698 // gradient, bitmap) render one pixel less, thus revealing
699 // ugly white pixel to the right and the bottom.
700 fillRect( pCanvas,
701 ::basegfx::B2DRectangle( 0.0, 0.0,
702 rSize.getX()-1,
703 rSize.getY()-1 ),
704 0xFFFFFFFFU );
707 ::basegfx::B2DRectangle getAPIShapeBounds( const uno::Reference< drawing::XShape >& xShape )
709 uno::Reference< beans::XPropertySet > xPropSet( xShape,
710 uno::UNO_QUERY_THROW );
711 // read bound rect
712 awt::Rectangle aTmpRect;
713 if( !(xPropSet->getPropertyValue("BoundRect") >>= aTmpRect) )
715 ENSURE_OR_THROW( false,
716 "getAPIShapeBounds(): Could not get \"BoundRect\" property from shape" );
719 return ::basegfx::B2DRectangle( aTmpRect.X,
720 aTmpRect.Y,
721 aTmpRect.X+aTmpRect.Width,
722 aTmpRect.Y+aTmpRect.Height );
726 TODO(F1): When ZOrder someday becomes usable enable this
728 double getAPIShapePrio( const uno::Reference< drawing::XShape >& xShape )
730 uno::Reference< beans::XPropertySet > xPropSet( xShape,
731 uno::UNO_QUERY_THROW );
732 // read prio
733 sal_Int32 nPrio(0);
734 if( !(xPropSet->getPropertyValue(
735 OUString("ZOrder") ) >>= nPrio) )
737 ENSURE_OR_THROW( false,
738 "getAPIShapePrio(): Could not get \"ZOrder\" property from shape" );
741 // TODO(F2): Check and adapt the range of possible values here.
742 // Maybe we can also take the total number of shapes here
743 return nPrio / 65535.0;
747 basegfx::B2IVector getSlideSizePixel( const basegfx::B2DVector& rSlideSize,
748 const UnoViewSharedPtr& pView )
750 ENSURE_OR_THROW(pView, "getSlideSizePixel(): invalid view");
752 // determine transformed page bounds
753 const basegfx::B2DRange aRect( 0,0,
754 rSlideSize.getX(),
755 rSlideSize.getY() );
756 basegfx::B2DRange aTmpRect;
757 canvas::tools::calcTransformedRectBounds( aTmpRect,
758 aRect,
759 pView->getTransformation() );
761 // #i42440# Returned slide size is one pixel too small, as
762 // rendering happens one pixel to the right and below the
763 // actual bound rect.
764 return basegfx::B2IVector(
765 basegfx::fround( aTmpRect.getRange().getX() ) + 1,
766 basegfx::fround( aTmpRect.getRange().getY() ) + 1 );
771 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */