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(); |