cui/source/dialogs/about.cxx | 91 ----------------------------- sd/source/ui/slideshow/slideshowimpl.cxx | 9 ++ sfx2/inc/sfx2/app.hxx | 8 +- sfx2/source/appl/appmisc.cxx | 95 ++++++++++++++++++++++++++++++- tools/qa/cppunit/test_stream.cxx | 12 +-- 5 files changed, 111 insertions(+), 104 deletions(-)
New commits: commit 918f8ed91e325606a44d088da5fbbf8c463dffba Author: Caolán McNamara <[email protected]> Date: Sat Mar 16 17:30:29 2013 +0000 "show logo" in slideshow settings doesn't do anything This wants to load about.png which doesn't exist anymore. "about.svg" does, but is a rather abstract background image for the about dialog these days, so use "flat_logo.svg" instead. Which requires moving the svg loader out of cui into sfx2 for re-use. Change-Id: I8654f0f93766556ef4ed4b87eff35b45d8189761 diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index e904d0f..d40e452 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -20,7 +20,6 @@ #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> -#include <osl/process.h> #include <tools/stream.hxx> #include <rtl/bootstrap.hxx> #include <unotools/configmgr.hxx> @@ -36,13 +35,8 @@ #include "comphelper/anytostring.hxx" #include "cppuhelper/exc_hlp.hxx" #include "cppuhelper/bootstrap.hxx" -#include <com/sun/star/graphic/XPrimitive2DRenderer.hpp> #include <basegfx/numeric/ftools.hxx> -#include <vcl/canvastools.hxx> #include <com/sun/star/geometry/RealRectangle2D.hpp> -#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp> -#include <basegfx/matrix/b2dhommatrixtools.hxx> -#include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <sfx2/sfxuno.hxx> #include <sfx2/sfxcommands.h> @@ -191,87 +185,6 @@ void AboutDialog::StyleControls() aCancelButton.GrabFocus(); } -static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth ) -{ - // Load from disk - // --------------------------------------------------------------------- - rtl::OUString aBaseName = ( rtl::OUString("/") + - rtl::OUString::createFromAscii( pName ) ); - rtl::OUString aSvg( ".svg" ); - - rtl_Locale *pLoc = NULL; - osl_getProcessLocale (&pLoc); - LanguageTag aLanguageTag( *pLoc); - - rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program" ) + aBaseName+aSvg; - rtl::Bootstrap::expandMacros( uri ); - INetURLObject aObj( uri ); - SvgData aSvgData(aObj.PathToFileName()); - - // transform into [0,0,width,width*aspect] std dimensions - // --------------------------------------------------------------------- - basegfx::B2DRange aRange(aSvgData.getRange()); - const double fAspectRatio(aRange.getWidth()/aRange.getHeight()); - basegfx::B2DHomMatrix aTransform( - basegfx::tools::createTranslateB2DHomMatrix( - -aRange.getMinX(), - -aRange.getMinY())); - aTransform.scale( - nWidth / aRange.getWidth(), - nWidth / fAspectRatio / aRange.getHeight()); - const drawinglayer::primitive2d::Primitive2DReference xTransformRef( - new drawinglayer::primitive2d::TransformPrimitive2D( - aTransform, - aSvgData.getPrimitive2DSequence())); - - // UNO dance to render from drawinglayer - // --------------------------------------------------------------------- - uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory()); - const rtl::OUString aServiceName("com.sun.star.graphic.Primitive2DTools"); - - try - { - const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer( - xFactory->createInstance(aServiceName), - uno::UNO_QUERY_THROW); - - if(xPrimitive2DRenderer.is()) - { - // cancel out rasterize's mm2pixel conversion - const double fFakeDPI=1000.0/2.54; - - geometry::RealRectangle2D aRealRect( - 0, 0, - nWidth, nWidth / fAspectRatio); - - const uno::Reference< rendering::XBitmap > xBitmap( - xPrimitive2DRenderer->rasterize( - drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1), - uno::Sequence< beans::PropertyValue >(), - fFakeDPI, - fFakeDPI, - aRealRect, - 500000)); - - if(xBitmap.is()) - { - const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW); - - if(xIntBmp.is()) - { - rBitmap = vcl::unotools::bitmapExFromXBitmap(xIntBmp); - return true; - } - } - } - } - catch(const uno::Exception&) - { - OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" ); - } - return false; -} - void AboutDialog::LayoutControls() { // Get the size of the screen @@ -297,7 +210,7 @@ void AboutDialog::LayoutControls() Point aLogoPos( 0, 0 ); // load svg logo, specify desired width, scale height isotrophically - if( loadBrandSvg("flat_logo", + if( SfxApplication::loadBrandSvg("flat_logo", aLogoBitmap, aDialogSize.Width()) && !aLogoBitmap.IsEmpty() ) @@ -364,7 +277,7 @@ void AboutDialog::LayoutControls() // Layout background image if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) ) - loadBrandSvg("shell/about", + SfxApplication::loadBrandSvg("shell/about", aBackgroundBitmap, aDialogSize.Width()); SetOutputSizePixel( aDialogSize ); diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index b21e085..88f282a 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -3221,7 +3221,7 @@ void SAL_CALL SlideshowImpl::gotoNextSlide( ) throw (RuntimeException) { if ( maPresSettings.mbShowPauseLogo ) { - Graphic aGraphic( SfxApplication::GetApplicationLogo().GetBitmapEx() ); + Graphic aGraphic(SfxApplication::GetApplicationLogo(360)); mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout, &aGraphic ); } else diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 24c0294..ab88440 100644 --- a/sfx2/inc/sfx2/app.hxx +++ b/sfx2/inc/sfx2/app.hxx @@ -257,10 +257,10 @@ public: SAL_DLLPRIVATE SfxModule* GetModule_Impl(); SAL_DLLPRIVATE ResMgr* GetOffResManager_Impl(); - /* loads a branded bitmap - that can be overridden per locale */ - static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap); - /** loads the application logo as used in the about dialog and impress slideshow pause screen */ - static Image GetApplicationLogo(); + static bool loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth); + + /** loads the application logo as used in the impress slideshow pause screen */ + static BitmapEx GetApplicationLogo(long nWidth); }; #define SFX_APP() SfxGetpApp() diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index a134957..7e016ef 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <vcl/canvastools.hxx> #include <vcl/status.hxx> #include <vcl/msgbox.hxx> #include <svl/whiter.hxx> @@ -27,8 +28,10 @@ #include <unotools/internaloptions.hxx> #include <unotools/pathoptions.hxx> #include <com/sun/star/registry/InvalidRegistryException.hpp> +#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/graphic/XPrimitive2DRenderer.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/uno/Reference.h> @@ -43,6 +46,7 @@ #include <unotools/bootstrap.hxx> #include <unotools/moduleoptions.hxx> #include <osl/file.hxx> +#include <osl/process.h> #include <rtl/bootstrap.hxx> #include "sfx2/sfxresid.hxx" @@ -71,7 +75,10 @@ #include <sfx2/viewsh.hxx> #include <sfx2/objface.hxx> #include "helper.hxx" // SfxContentHelper::Kill() +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; @@ -259,12 +266,94 @@ sal_Bool SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; } SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; } SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; } -/** loads the application logo as used in the about dialog and impress slideshow pause screen */ -Image SfxApplication::GetApplicationLogo() +bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth) +{ + // Load from disk + // --------------------------------------------------------------------- + rtl::OUString aBaseName = ( rtl::OUString("/") + + rtl::OUString::createFromAscii( pName ) ); + rtl::OUString aSvg( ".svg" ); + + rtl_Locale *pLoc = NULL; + osl_getProcessLocale (&pLoc); + LanguageTag aLanguageTag( *pLoc); + + rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program" ) + aBaseName+aSvg; + rtl::Bootstrap::expandMacros( uri ); + INetURLObject aObj( uri ); + SvgData aSvgData(aObj.PathToFileName()); + + // transform into [0,0,width,width*aspect] std dimensions + // --------------------------------------------------------------------- + basegfx::B2DRange aRange(aSvgData.getRange()); + const double fAspectRatio(aRange.getWidth()/aRange.getHeight()); + basegfx::B2DHomMatrix aTransform( + basegfx::tools::createTranslateB2DHomMatrix( + -aRange.getMinX(), + -aRange.getMinY())); + aTransform.scale( + nWidth / aRange.getWidth(), + nWidth / fAspectRatio / aRange.getHeight()); + const drawinglayer::primitive2d::Primitive2DReference xTransformRef( + new drawinglayer::primitive2d::TransformPrimitive2D( + aTransform, + aSvgData.getPrimitive2DSequence())); + + // UNO dance to render from drawinglayer + // --------------------------------------------------------------------- + uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory()); + const rtl::OUString aServiceName("com.sun.star.graphic.Primitive2DTools"); + + try + { + const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer( + xFactory->createInstance(aServiceName), + uno::UNO_QUERY_THROW); + + if(xPrimitive2DRenderer.is()) + { + // cancel out rasterize's mm2pixel conversion + const double fFakeDPI=1000.0/2.54; + + geometry::RealRectangle2D aRealRect( + 0, 0, + nWidth, nWidth / fAspectRatio); + + const uno::Reference< rendering::XBitmap > xBitmap( + xPrimitive2DRenderer->rasterize( + drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1), + uno::Sequence< beans::PropertyValue >(), + fFakeDPI, + fFakeDPI, + aRealRect, + 500000)); + + if(xBitmap.is()) + { + const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW); + + if(xIntBmp.is()) + { + rBitmap = vcl::unotools::bitmapExFromXBitmap(xIntBmp); + return true; + } + } + } + } + catch(const uno::Exception&) + { + OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" ); + } + return false; +} + +/** loads the application logo as used in the impress slideshow pause screen */ +BitmapEx SfxApplication::GetApplicationLogo(long nWidth) { BitmapEx aBitmap; + SfxApplication::loadBrandSvg("flat_logo", aBitmap, nWidth); Application::LoadBrandBitmap ("about", aBitmap); - return Image( aBitmap ); + return aBitmap; } SfxChildWinFactArr_Impl::~SfxChildWinFactArr_Impl() commit 4d362d2362661670579c03bdccf0063ee6569604 Author: Ariel Constenla-Haile <[email protected]> Date: Mon May 28 15:23:23 2012 +0000 i53749 - Show Pause logo according to presentation settings Original author: Tsutomu Uchino <hanya.runo at gmail.com> diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index 15d2cc5..b21e085 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -3219,8 +3219,13 @@ void SAL_CALL SlideshowImpl::gotoNextSlide( ) throw (RuntimeException) { if( mpShowWindow ) { - Graphic aGraphic( SfxApplication::GetApplicationLogo().GetBitmapEx() ); - mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout, &aGraphic ); + if ( maPresSettings.mbShowPauseLogo ) + { + Graphic aGraphic( SfxApplication::GetApplicationLogo().GetBitmapEx() ); + mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout, &aGraphic ); + } + else + mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout ); } } else commit 67bdb8f14b30f4af03676d11dab4bfe3cfb536a2 Author: Caolán McNamara <[email protected]> Date: Sat Mar 16 17:40:02 2013 +0000 use SAL_N_ELEMENTS Change-Id: I6610f8e888389d09b673504f1eb9387dd38fb6c1 diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index 894ad7d..a65b6be 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -61,7 +61,7 @@ namespace { char foo[] = "foo"; std::istringstream iss(foo, std::istringstream::in); - SvMemoryStream aMemStream((void *) foo, strlen(foo), STREAM_READ); + SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, STREAM_READ); char std_a(78); iss >> std_a; @@ -152,7 +152,7 @@ namespace void Test::test_fastostring() { char foo[] = "foobar"; - SvMemoryStream aMemStream((void *) foo, strlen(foo), STREAM_READ); + SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, STREAM_READ); rtl::OString aOne = read_uInt8s_ToOString(aMemStream, 3); CPPUNIT_ASSERT(aOne == "foo"); @@ -172,7 +172,7 @@ namespace void Test::test_read_cstring() { char foo[] = "foobar"; - SvMemoryStream aMemStream((void *) foo, strlen(foo), STREAM_READ); + SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, STREAM_READ); rtl::OString aOne = read_zeroTerminated_uInt8s_ToOString(aMemStream); CPPUNIT_ASSERT(aOne == "foobar"); @@ -190,7 +190,7 @@ namespace void Test::test_read_pstring() { char foo[] = "\3foobar"; - SvMemoryStream aMemStream((void *) foo, strlen(foo), STREAM_READ); + SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, STREAM_READ); rtl::OString aFoo = read_lenPrefixed_uInt8s_ToOString<sal_uInt8>(aMemStream); CPPUNIT_ASSERT(aFoo == "foo"); @@ -232,7 +232,7 @@ namespace void Test::test_readline() { char foo[] = "foo\nbar\n\n"; - SvMemoryStream aMemStream((void *) foo, strlen(foo), STREAM_READ); + SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, STREAM_READ); rtl::OString aFoo; sal_Bool bRet; @@ -291,7 +291,7 @@ namespace CPPUNIT_ASSERT(iss.eof() && !iss.bad()); char bar[] = "foo"; - SvMemoryStream aMemStreamB((void *) bar, strlen(bar), STREAM_READ); + SvMemoryStream aMemStreamB(bar, SAL_N_ELEMENTS(bar)-1, STREAM_READ); bRet = aMemStreamB.ReadLine(aFoo); CPPUNIT_ASSERT(bRet); CPPUNIT_ASSERT(aFoo == "foo");
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
