diff options
author | Christian Lippka <cl@openoffice.org> | 2010-03-11 18:18:08 +0100 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2010-03-11 18:18:08 +0100 |
commit | 9b03159e7030963753dcc7ff82f0b49207bd42b4 (patch) | |
tree | ed11dfcd9788b7cbb2c46d24497aa4095189316e /sd/source/ui/controller | |
parent | 7531716e6f1c08977105886102dcde4e536e0a72 (diff) |
moved toolbarmenu to svtools and reworked to non sfx2 code
Diffstat (limited to 'sd/source/ui/controller')
-rw-r--r-- | sd/source/ui/controller/makefile.mk | 54 | ||||
-rw-r--r-- | sd/source/ui/controller/slidelayoutcontroller.cxx | 376 | ||||
-rw-r--r-- | sd/source/ui/controller/slidelayoutcontroller.hxx | 53 |
3 files changed, 483 insertions, 0 deletions
diff --git a/sd/source/ui/controller/makefile.mk b/sd/source/ui/controller/makefile.mk new file mode 100644 index 000000000000..4e37fbd5ea88 --- /dev/null +++ b/sd/source/ui/controller/makefile.mk @@ -0,0 +1,54 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.21 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + + +PRJ=..$/..$/.. + +PROJECTPCH=sd +PROJECTPCHSOURCE=$(PRJ)$/util$/sd +PRJNAME=sd +TARGET=controller +ENABLE_EXCEPTIONS=TRUE +AUTOSEG=true + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/slidelayoutcontroller.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk diff --git a/sd/source/ui/controller/slidelayoutcontroller.cxx b/sd/source/ui/controller/slidelayoutcontroller.cxx new file mode 100644 index 000000000000..57fafdc7c8c0 --- /dev/null +++ b/sd/source/ui/controller/slidelayoutcontroller.cxx @@ -0,0 +1,376 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/frame/status/FontHeight.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <memory> +#include <boost/scoped_ptr.hpp> + +#include <vos/mutex.hxx> + +#include <vcl/svapp.hxx> +#include <vcl/toolbox.hxx> + +#include <svl/languageoptions.hxx> + +#include <svtools/ctrltool.hxx> +#include <svtools/ctrlbox.hxx> +#include <svtools/toolbarmenu.hxx> +#include <svtools/valueset.hxx> + +#include <toolkit/helper/vclunohelper.hxx> + +#include <sfx2/imagemgr.hxx> + +#include "app.hrc" +#include "glob.hrc" +#include "strings.hrc" +#include "res_bmp.hrc" +#include "sdresid.hxx" +#include "pres.hxx" +#include "slidelayoutcontroller.hxx" + +using rtl::OUString; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; + +namespace sd +{ + +extern ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const OUString& aCmdURL ); + +// ----------------------------------------------------------------------- + +class LayoutToolbarMenu : public svtools::ToolbarMenu +{ +public: + LayoutToolbarMenu( SlideLayoutController& rController, const Reference< XFrame >& xFrame, ::Window* pParent, const bool bInsertPage ); + virtual ~LayoutToolbarMenu(); + +protected: + DECL_LINK( SelectHdl, void * ); + +private: + SlideLayoutController& mrController; + Reference< XFrame > mxFrame; + bool mbInsertPage; + ValueSet* mpLayoutSet1; + ValueSet* mpLayoutSet2; +}; + +// ----------------------------------------------------------------------- + +struct snewfoil_value_info +{ + USHORT mnBmpResId; + USHORT mnHCBmpResId; + USHORT mnStrResId; + WritingMode meWritingMode; + AutoLayout maAutoLayout; +}; +static snewfoil_value_info standard[] = +{ + {BMP_LAYOUT_EMPTY, BMP_LAYOUT_EMPTY_H, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB, AUTOLAYOUT_NONE}, + {BMP_LAYOUT_HEAD03, BMP_LAYOUT_HEAD03_H, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE}, + {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_ENUM}, + {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2TEXT}, + {BMP_LAYOUT_HEAD01, BMP_LAYOUT_HEAD01_H, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TITLE}, + {BMP_LAYOUT_TEXTONLY, BMP_LAYOUT_TEXTONLY_H, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TEXT}, + {BMP_LAYOUT_HEAD03B, BMP_LAYOUT_HEAD03B_H, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2OBJTEXT}, + {BMP_LAYOUT_HEAD03C, BMP_LAYOUT_HEAD03C_H, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TEXT2OBJ}, + {BMP_LAYOUT_HEAD03A, BMP_LAYOUT_HEAD03A_H, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_2OBJOVERTEXT}, + {BMP_LAYOUT_HEAD02B, BMP_LAYOUT_HEAD02B_H, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_OBJOVERTEXT}, + {BMP_LAYOUT_HEAD04, BMP_LAYOUT_HEAD04_H, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB, AUTOLAYOUT_4OBJ}, + {BMP_LAYOUT_HEAD06, BMP_LAYOUT_HEAD06_H, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB, AUTOLAYOUT_6CLIPART}, + {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE} +}; + +static snewfoil_value_info v_standard[] = +{ + // vertical + {BMP_LAYOUT_VERTICAL02, BMP_LAYOUT_VERTICAL02_H, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL,AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART}, + {BMP_LAYOUT_VERTICAL01, BMP_LAYOUT_VERTICAL01_H, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE}, + {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE}, + {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AL_TITLE_VERT_OUTLINE_CLIPART, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART}, + {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE} +}; + +// ----------------------------------------------------------------------- + +static void fillLayoutValueSet( ValueSet* pValue, snewfoil_value_info* pInfo, const bool bHighContrast ) +{ + Size aLayoutItemSize; + for( ; pInfo->mnBmpResId; pInfo++ ) + { + String aText( SdResId( pInfo->mnStrResId ) ); + BitmapEx aBmp( SdResId( (bHighContrast ? pInfo->mnHCBmpResId : pInfo->mnBmpResId) ) ); + + pValue->InsertItem( static_cast<USHORT>(pInfo->maAutoLayout)+1, aBmp, aText ); + + aLayoutItemSize.Width() = std::max( aLayoutItemSize.Width(), aBmp.GetSizePixel().Width() ); + aLayoutItemSize.Height() = std::max( aLayoutItemSize.Height(), aBmp.GetSizePixel().Height() ); + } + + aLayoutItemSize = pValue->CalcItemSizePixel( aLayoutItemSize ); + pValue->SetSizePixel( pValue->CalcWindowSizePixel( aLayoutItemSize ) ); +} + +// ----------------------------------------------------------------------- + +LayoutToolbarMenu::LayoutToolbarMenu( SlideLayoutController& rController, const Reference< XFrame >& xFrame, ::Window* pParent, const bool bInsertPage ) +: svtools::ToolbarMenu(xFrame, pParent, WB_CLIPCHILDREN ) +, mrController( rController ) +, mxFrame(xFrame) +, mbInsertPage( bInsertPage ) +, mpLayoutSet1( 0 ) +, mpLayoutSet2( 0 ) +{ + String aTitle1( SdResId( STR_GLUE_ESCDIR_HORZ ) ); + String aTitle2( SdResId( STR_GLUE_ESCDIR_VERT ) ); + + const Color aMenuColor( GetSettings().GetStyleSettings().GetMenuColor() ); + const Color aMenuBarColor( GetSettings().GetStyleSettings().GetMenuBarColor() ); + const Color aMenuTextColor( GetSettings().GetStyleSettings().GetMenuBarColor() ); + const Color aMenuBarTextColor( GetSettings().GetStyleSettings().GetMenuBarTextColor() ); + + const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + SvtLanguageOptions aLanguageOptions; + const bool bVerticalEnabled = aLanguageOptions.IsVerticalTextEnabled(); + + SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectHdl ) ); + + mpLayoutSet1 = new ValueSet( this, WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT ); +// mpLayoutSet1->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING ); + + mpLayoutSet1->SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectHdl ) ); + mpLayoutSet1->SetColCount( 4 ); + mpLayoutSet1->EnableFullItemMode( FALSE ); + mpLayoutSet1->SetColor( GetControlBackground() ); + + fillLayoutValueSet( mpLayoutSet1, &standard[0], bHighContrast ); + + if( bVerticalEnabled ) + appendEntry( -1, aTitle1 ); + appendEntry( 0, mpLayoutSet1 ); + + if( bVerticalEnabled ) + { + mpLayoutSet2 = new ValueSet( this, WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT ); + // mpLayoutSet2->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING ); + + mpLayoutSet2->SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectHdl ) ); + mpLayoutSet2->SetColCount( 4 ); + mpLayoutSet2->EnableFullItemMode( FALSE ); + mpLayoutSet2->SetColor( GetControlBackground() ); + + fillLayoutValueSet( mpLayoutSet2, &v_standard[0], bHighContrast ); + + appendEntry( -1, aTitle2 ); + appendEntry( 1, mpLayoutSet2 ); + } + + OUString sSlotStr; + Image aSlotImage; + if( mxFrame.is() ) + { + if( bInsertPage ) + sSlotStr = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DuplicatePage" ) ); + else + sSlotStr = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Undo" ) ); + aSlotImage = ::GetImage( mxFrame, sSlotStr, FALSE, FALSE ); + + String sSlotTitle; + if( bInsertPage ) + sSlotTitle = ImplRetrieveLabelFromCommand( mxFrame, sSlotStr ); + else + sSlotTitle = String( SdResId( STR_RESET_LAYOUT ) ); + appendEntry( 2, sSlotTitle, aSlotImage); + } + + SetOutputSizePixel( getMenuSize() ); +} + +// ----------------------------------------------------------------------- + +LayoutToolbarMenu::~LayoutToolbarMenu() +{ +} + + +// ----------------------------------------------------------------------- + + +/* +void LayoutToolbarMenu::DataChanged( const DataChangedEvent& rDCEvt ) +{ + SfxDockingWindow::DataChanged( rDCEvt ); + + if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) + { + // const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + + // todo switch images + } +} +*/ + +// ----------------------------------------------------------------------- + +IMPL_LINK( LayoutToolbarMenu, SelectHdl, void *, pControl ) +{ + if ( IsInPopupMode() ) + EndPopupMode(); + + Sequence< PropertyValue > aArgs; + + AutoLayout eLayout = AUTOLAYOUT__END; + + OUString sCommandURL( mrController.getCommandURL() ); + + if( pControl == mpLayoutSet1 ) + { + eLayout = static_cast< AutoLayout >(mpLayoutSet1->GetSelectItemId()-1); + } + else if( pControl == mpLayoutSet2 ) + { + eLayout = static_cast< AutoLayout >(mpLayoutSet2->GetSelectItemId()-1); + } + + if( eLayout != AUTOLAYOUT__END ) + { + aArgs = Sequence< PropertyValue >(1); + aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "WhatLayout" ) ); + aArgs[0].Value <<= (sal_Int32)eLayout; + } + else if( mbInsertPage ) + { + sCommandURL = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DuplicatePage" ) ); + } + + mrController.dispatchCommand( sCommandURL, aArgs ); + + return 0; +} + +// ==================================================================== + +OUString SlideLayoutController_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sd.SlideLayoutController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SlideLayoutController_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL SlideLayoutController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) +{ + return *new SlideLayoutController( rSMgr, OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AssignLayout" )), false ); +} + +// -------------------------------------------------------------------- + +OUString InsertSlideController_getImplementationName() +{ + return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sd.InsertSlideController" )); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > InsertSlideController_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL InsertSlideController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException ) +{ + return *new SlideLayoutController( rSMgr, OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPage" )), true ); +} + +//======================================================================== +// class SlideLayoutController +//======================================================================== + +SlideLayoutController::SlideLayoutController( const Reference< lang::XMultiServiceFactory >& rServiceManager, const rtl::OUString& sCommandURL, bool bInsertPage ) +: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), sCommandURL ) +, mbInsertPage( bInsertPage ) +{ +} + +// -------------------------------------------------------------------- + +::Window* SlideLayoutController::createPopupWindow( ::Window* pParent ) +{ + return new sd::LayoutToolbarMenu( *this, m_xFrame, pParent, mbInsertPage ); +} + +// -------------------------------------------------------------------- +// XServiceInfo +// -------------------------------------------------------------------- + +OUString SAL_CALL SlideLayoutController::getImplementationName() throw( RuntimeException ) +{ + if( mbInsertPage ) + return InsertSlideController_getImplementationName(); + else + return SlideLayoutController_getImplementationName(); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL SlideLayoutController::getSupportedServiceNames( ) throw( RuntimeException ) +{ + if( mbInsertPage ) + return InsertSlideController_getSupportedServiceNames(); + else + return SlideLayoutController_getSupportedServiceNames(); +} + +} diff --git a/sd/source/ui/controller/slidelayoutcontroller.hxx b/sd/source/ui/controller/slidelayoutcontroller.hxx new file mode 100644 index 000000000000..9e1c1692f953 --- /dev/null +++ b/sd/source/ui/controller/slidelayoutcontroller.hxx @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __SD_SLIDELAYOUTCONTROLLER_HXX_ +#define __SD_SLIDELAYOUTCONTROLLER_HXX_ + +#include <svtools/popupwindowcontroller.hxx> + +namespace sd +{ + +class SlideLayoutController : public svt::PopupWindowController +{ +public: + SlideLayoutController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager, const rtl::OUString& sCommandURL, bool bInsertPage ); + + virtual ::Window* createPopupWindow( ::Window* pParent ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + +private: + bool mbInsertPage; +}; + +} + +#endif // __SD_SLIDELAYOUTCONTROLLER_HXX_ |