Kaydet (Commit) db535876 authored tarafından Philippe Jung's avatar Philippe Jung

Code cleanup for gerrit change 16723

Simple code clean-up taking into account Maxim Monastirsky remarks.

Change-Id: If6393851c3eb6fd8a460ef95ef88ccf3aed82e3e
Reviewed-on: https://gerrit.libreoffice.org/20047Reviewed-by: 's avatarPhilippe Jung <phil.jung@free.fr>
Tested-by: 's avatarPhilippe Jung <phil.jung@free.fr>
üst f08d0142
...@@ -239,22 +239,8 @@ void DisplayModeToolbarMenu::SelectHdl(void * pControl) ...@@ -239,22 +239,8 @@ void DisplayModeToolbarMenu::SelectHdl(void * pControl)
mrController.setToolboxItemImage( nImage ); mrController.setToolboxItemImage( nImage );
} }
OUString DisplayModeController_getImplementationName() throw (css::uno::RuntimeException) DisplayModeController::DisplayModeController( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext )
{ : svt::PopupWindowController( rxContext, Reference< frame::XFrame >(), OUString() )
return OUString( "com.sun.star.comp.sd.DisplayModeController" );
}
Sequence< OUString > DisplayModeController_getSupportedServiceNames() throw( RuntimeException )
{
Sequence< OUString > aSNS( 1 );
aSNS.getArray()[0] = "com.sun.star.frame.ToolbarController";
return aSNS;
}
// class SlideLayoutController
DisplayModeController::DisplayModeController( const Reference< uno::XComponentContext >& rxContext, const OUString& sCommandURL )
: svt::PopupWindowController( rxContext, Reference< frame::XFrame >(), sCommandURL )
{ {
} }
...@@ -262,6 +248,10 @@ void SAL_CALL DisplayModeController::initialize( const css::uno::Sequence< css:: ...@@ -262,6 +248,10 @@ void SAL_CALL DisplayModeController::initialize( const css::uno::Sequence< css::
throw ( css::uno::Exception, css::uno::RuntimeException, std::exception ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
{ {
svt::PopupWindowController::initialize( aArguments ); svt::PopupWindowController::initialize( aArguments );
ToolBox* pToolBox = nullptr;
sal_uInt16 nId = 0;
if ( getToolboxId( nId, &pToolBox ) )
pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
setToolboxItemImage( BMP_DISPLAYMODE_SLIDE ); setToolboxItemImage( BMP_DISPLAYMODE_SLIDE );
} }
...@@ -273,33 +263,33 @@ VclPtr<vcl::Window> DisplayModeController::createPopupWindow( vcl::Window* pPare ...@@ -273,33 +263,33 @@ VclPtr<vcl::Window> DisplayModeController::createPopupWindow( vcl::Window* pPare
void DisplayModeController::setToolboxItemImage( sal_uInt16 nImage ) void DisplayModeController::setToolboxItemImage( sal_uInt16 nImage )
{ {
sal_uInt16 nId; sal_uInt16 nId;
ToolBox* pToolBox; ToolBox* pToolBox = nullptr;
getToolboxId( nId, &pToolBox ); if (getToolboxId( nId, &pToolBox )) {
SdResId resId( nImage );
SdResId resId( nImage ); BitmapEx aBmp( resId );
BitmapEx aBmp( resId ); int targetSize = (pToolBox->GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE) ? 32 : 16;
int targetSize = (pToolBox->GetToolboxButtonSize() == TOOLBOX_BUTTONSIZE_LARGE) ? 32 : 16; double scale = 1.0f;
double scale = 1.0f; Size size = aBmp.GetSizePixel();
Size size = aBmp.GetSizePixel(); if (size.Width() > targetSize)
if (size.Width() > targetSize) scale = (double)targetSize / (double)size.Width();
scale = (double)targetSize / (double)size.Width(); if (size.Height() > targetSize)
if (size.Height() > targetSize) scale = ::std::min( scale, (double)targetSize / (double)size.Height() );
scale = ::std::min( scale, (double)targetSize / (double)size.Height() ); aBmp.Scale( scale, scale );
aBmp.Scale( scale, scale ); pToolBox->SetItemImage( nId, Image( aBmp ) );
pToolBox->SetItemImage( nId, Image( aBmp ) ); }
} }
// XServiceInfo // XServiceInfo
OUString SAL_CALL DisplayModeController::getImplementationName() throw( RuntimeException, std::exception ) OUString SAL_CALL DisplayModeController::getImplementationName() throw( RuntimeException, std::exception )
{ {
return DisplayModeController_getImplementationName(); return OUString( "com.sun.star.comp.sd.DisplayModeController" );;
} }
Sequence< OUString > SAL_CALL DisplayModeController::getSupportedServiceNames( ) throw( RuntimeException, std::exception ) Sequence< OUString > SAL_CALL DisplayModeController::getSupportedServiceNames( ) throw( RuntimeException, std::exception )
{ {
return DisplayModeController_getSupportedServiceNames(); css::uno::Sequence<OUString> aRet { "com.sun.star.frame.ToolbarController" };
return aRet;
} }
} }
...@@ -309,7 +299,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL ...@@ -309,7 +299,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
com_sun_star_comp_sd_DisplayModeController_get_implementation(::com::sun::star::uno::XComponentContext* context, com_sun_star_comp_sd_DisplayModeController_get_implementation(::com::sun::star::uno::XComponentContext* context,
::com::sun::star::uno::Sequence<css::uno::Any> const &) ::com::sun::star::uno::Sequence<css::uno::Any> const &)
{ {
return cppu::acquire(new sd::DisplayModeController(context, ".uno:DisplayMode")); return cppu::acquire(new sd::DisplayModeController(context));
} }
......
...@@ -28,8 +28,7 @@ namespace sd ...@@ -28,8 +28,7 @@ namespace sd
class DisplayModeController : public svt::PopupWindowController class DisplayModeController : public svt::PopupWindowController
{ {
public: public:
DisplayModeController( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, DisplayModeController( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext );
const OUString& sCommandURL );
virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) SAL_OVERRIDE; virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) SAL_OVERRIDE;
......
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <svl/slstitm.hxx> #include <svl/slstitm.hxx>
#include <sfx2/ipclient.hxx> #include <sfx2/ipclient.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
#include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/vclunohelper.hxx>
#include <avmedia/mediawindow.hxx> #include <avmedia/mediawindow.hxx>
#include <svl/urihelper.hxx> #include <svl/urihelper.hxx>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment