View | Details | Raw Unified | Return to issue 119536
Collapse All | Expand All

(-)filter/source/msfilter/escherex.cxx (+52 lines)
Lines 1486-1491 Link Here
1486
                    pGraphicAttr->SetRotation( nAngle );
1486
                    pGraphicAttr->SetRotation( nAngle );
1487
                    if ( nAngle && pShapeBoundRect )   // up to xp ppoint does not rotate bitmaps !
1487
                    if ( nAngle && pShapeBoundRect )   // up to xp ppoint does not rotate bitmaps !
1488
                    {
1488
                    {
1489
                        // if the graphic gets rotated, it must first be adapted to have
1490
                        // a x/y proportion equal to it's object size, else the rotation
1491
                        // will misform the graphic.
1492
                        if(pShapeBoundRect->getWidth() && pShapeBoundRect->getHeight())
1493
                        {
1494
                            // Use aGraphicObject from the outer scope, the derived UniqueID 
1495
                            // may be useless when working with a local and thus deleted GraphicObject
1496
                    	    aGraphicObject = GraphicObject(aUniqueId);
1497
                            const Size aPrefSize(aGraphicObject.GetPrefSize());
1498
1499
                            if(aPrefSize.Width() && aPrefSize.Height())
1500
                            {
1501
                                const double fPropTarget((double)pShapeBoundRect->getWidth() / (double)pShapeBoundRect->getHeight());
1502
                                const double fPropSource((double)aPrefSize.Width() / (double)aPrefSize.Height());
1503
                                const double fDiff(fabs(fPropTarget - fPropSource));
1504
1505
                                // correct it when more than 5% difference
1506
                                if(basegfx::fTools::more(fDiff, 0.05)) 
1507
                                {
1508
                                    Graphic aGraphic(aGraphicObject.GetGraphic());
1509
                                    const bool bWidthBigger(aPrefSize.Width() > aPrefSize.Height());
1510
1511
                                    // correct it and use the bigger possible variant
1512
                                    const long nNewPrefWidth(bWidthBigger ? aPrefSize.Width() : basegfx::fround(aPrefSize.Width() * (1.0 / fPropTarget)));
1513
                                    const long nNewPrefHeight(bWidthBigger ? basegfx::fround(aPrefSize.Height() * fPropTarget) : aPrefSize.Height());
1514
1515
                                    if(GRAPHIC_BITMAP == aGraphic.GetType())
1516
                                    {
1517
                                        // for bitmap graphic physical scaling has to be done, setting the
1518
                                        // PrefSize seems not to be enough
1519
                                        BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
1520
                                        const Size aSizePixel(aBitmapEx.GetSizePixel());
1521
                                        const long nNewPixWidth(bWidthBigger ? aSizePixel.Width() : basegfx::fround(aSizePixel.Width() * (1.0 / fPropTarget)));
1522
                                        const long nNewPixHeight(bWidthBigger ? basegfx::fround(aSizePixel.Height() * fPropTarget) : aSizePixel.Height());
1523
1524
                                        aBitmapEx.SetSizePixel(Size(nNewPixWidth, nNewPixHeight));
1525
                                        aBitmapEx.SetPrefSize(Size(nNewPrefWidth, nNewPrefHeight));
1526
                                        aGraphicObject = GraphicObject(aBitmapEx);
1527
                                        aUniqueId = aGraphicObject.GetUniqueID();
1528
                                    }
1529
                                    else
1530
                                    {
1531
                                        // for non-bitmap, set the corrected PrefSize
1532
                                        aGraphic.SetPrefSize(Size(nNewPrefWidth, nNewPrefHeight));
1533
                                        aGraphicObject = GraphicObject(aGraphic);
1534
                                        aUniqueId = aGraphicObject.GetUniqueID();
1535
                                    }
1536
                                }
1537
                            }
1538
                        }
1539
1540
                        // adapt BoundRect to rotation
1489
                        Polygon aPoly( *pShapeBoundRect );
1541
                        Polygon aPoly( *pShapeBoundRect );
1490
                        aPoly.Rotate( pShapeBoundRect->TopLeft(), nAngle );
1542
                        aPoly.Rotate( pShapeBoundRect->TopLeft(), nAngle );
1491
                        *pShapeBoundRect = aPoly.GetBoundRect();
1543
                        *pShapeBoundRect = aPoly.GetBoundRect();
(-)sd/source/filter/eppt/epptso.cxx (-3 / +17 lines)
Lines 4634-4642 Link Here
4634
4634
4635
                mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4635
                mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
4636
                ImplCreateShape( nSpType, nSpFlags, aSolverContainer );
4636
                ImplCreateShape( nSpType, nSpFlags, aSolverContainer );
4637
4637
4638
                // #119459# for connector shape, the start point and end point is fixed, and should not be rotated.
4638
                // #119459# for connector shape, the start point and end point is fixed, and should not be rotated.
4639
                mnAngle = 0;
4639
                mnAngle = 0;
4640
            }
4640
            }
4641
            else if ( mType == "drawing.Measure" )
4641
            else if ( mType == "drawing.Measure" )
4642
            {
4642
            {
Lines 4787-4794 Link Here
4787
                    else
4787
                    else
4788
                    {
4788
                    {
4789
                        ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
4789
                        ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer );
4790
                        const Rectangle aOldRect100thmm(aRect100thmm);
4791
4790
                        if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "GraphicURL" ) ), sal_False, sal_True ) )
4792
                        if ( aPropOpt.CreateGraphicProperties( mXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "GraphicURL" ) ), sal_False, sal_True ) )
4793
                        {
4791
                            aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
4794
                            aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
4795
							
4796
                            if(aOldRect100thmm != aRect100thmm)
4797
                            {
4798
                                // #119536# graphic has been adapted (rotated) so that it can be saved without angle,
4799
                                // adapt local values as needed
4800
                                maPosition = ImplMapPoint( ::com::sun::star::awt::Point( aRect100thmm.Left(), aRect100thmm.Top() ) );
4801
					            maSize = ImplMapSize( ::com::sun::star::awt::Size ( aRect100thmm.GetWidth(), aRect100thmm.GetHeight() ) );
4802
							    maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) );
4803
							    mnAngle = 0;
4804
                            }
4805
                        }
4792
                    }
4806
                    }
4793
                }
4807
                }
4794
            }
4808
            }

Return to issue 119536