diff options
author | Bjoern Michaelsen <b_michaelsen@openoffice.org> | 2010-07-13 14:36:24 +0200 |
---|---|---|
committer | Bjoern Michaelsen <b_michaelsen@openoffice.org> | 2010-07-13 14:36:24 +0200 |
commit | fd90f23f3a727dc80e4fa0be1a2a967feee8cb43 (patch) | |
tree | d5dd671ec5249774c3efdd741a0964181b802c49 /svx/source/svdraw/svdomedia.cxx | |
parent | e8ec11b41233376724acd0f58bf3f6439c0e21d8 (diff) | |
parent | a2e7c2e0d002d75a6b77a629a4e904ab54bf8375 (diff) |
CWS gnumake2: resync to DEV300_m84
Diffstat (limited to 'svx/source/svdraw/svdomedia.cxx')
-rw-r--r-- | svx/source/svdraw/svdomedia.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index fbce08fdfaa8..8d360e67bed0 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -28,6 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" +#include <vcl/svapp.hxx> + #include <svx/svdomedia.hxx> #include "svx/svdglob.hxx" #include "svx/svdstr.hrc" @@ -147,6 +149,53 @@ void SdrMediaObj::operator=(const SdrObject& rObj) // ------------------------------------------------------------------------------ +void SdrMediaObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly /* = false */ ) +{ + Size aSize( Application::GetDefaultDevice()->PixelToLogic( getPreferredSize(), MAP_100TH_MM ) ); + Size aMaxSize( rMaxRect.GetSize() ); + + if( aSize.Height() != 0 && aSize.Width() != 0 ) + { + Point aPos( rMaxRect.TopLeft() ); + + // Falls Grafik zu gross, wird die Grafik + // in die Seite eingepasst + if ( (!bShrinkOnly || + ( aSize.Height() > aMaxSize.Height() ) || + ( aSize.Width() > aMaxSize.Width() ) )&& + aSize.Height() && aMaxSize.Height() ) + { + float fGrfWH = (float)aSize.Width() / + (float)aSize.Height(); + float fWinWH = (float)aMaxSize.Width() / + (float)aMaxSize.Height(); + + // Grafik an Pagesize anpassen (skaliert) + if ( fGrfWH < fWinWH ) + { + aSize.Width() = (long)(aMaxSize.Height() * fGrfWH); + aSize.Height()= aMaxSize.Height(); + } + else if ( fGrfWH > 0.F ) + { + aSize.Width() = aMaxSize.Width(); + aSize.Height()= (long)(aMaxSize.Width() / fGrfWH); + } + + aPos = rMaxRect.Center(); + } + + if( bShrinkOnly ) + aPos = aRect.TopLeft(); + + aPos.X() -= aSize.Width() / 2; + aPos.Y() -= aSize.Height() / 2; + SetLogicRect( Rectangle( aPos, aSize ) ); + } +} + +// ------------------------------------------------------------------------------ + void SdrMediaObj::setURL( const ::rtl::OUString& rURL ) { ::avmedia::MediaItem aURLItem; |