1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 #include <svl/aeitem.hxx> 31 32 #include <svx/dialmgr.hxx> 33 #include <svx/dialogs.hrc> 34 35 #include "svx/tbxalign.hxx" 36 #include "svx/tbxdraw.hxx" 37 #include "tbxdraw.hrc" 38 #include <tools/shl.hxx> 39 #ifndef _SFX_IMAGEMGR_HXX 40 #include <sfx2/imagemgr.hxx> 41 #endif 42 #include <vcl/svapp.hxx> 43 #include <vos/mutex.hxx> 44 45 #include <sfx2/app.hxx> 46 #include <vcl/toolbox.hxx> 47 48 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign, SfxAllEnumItem); 49 50 /************************************************************************* 51 |* 52 |* Klasse fuer SwToolbox 53 |* 54 \************************************************************************/ 55 56 SvxTbxCtlAlign::SvxTbxCtlAlign( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 57 SfxToolBoxControl( nSlotId, nId, rTbx ) 58 , m_aSubTbName( RTL_CONSTASCII_USTRINGPARAM( "alignmentbar" )) 59 , m_aSubTbResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/alignmentbar" )) 60 { 61 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 62 rTbx.Invalidate(); 63 64 m_aCommand = m_aCommandURL; 65 } 66 67 /************************************************************************* 68 |* 69 |* Wenn man ein PopupWindow erzeugen will 70 |* 71 \************************************************************************/ 72 73 SfxPopupWindowType SvxTbxCtlAlign::GetPopupWindowType() const 74 { 75 return(SFX_POPUPWINDOW_ONCLICK); 76 } 77 78 /************************************************************************* 79 |* 80 |* Hier wird das Fenster erzeugt 81 |* Lage der Toolbox mit GetToolBox() abfragbar 82 |* rItemRect sind die Screen-Koordinaten 83 |* 84 \************************************************************************/ 85 86 SfxPopupWindow* SvxTbxCtlAlign::CreatePopupWindow() 87 { 88 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 89 if ( GetSlotId() == SID_OBJECT_ALIGN ) 90 createAndPositionSubToolBar( m_aSubTbResName ); 91 return NULL; 92 } 93 94 //======================================================================== 95 // XSubToolbarController 96 //======================================================================== 97 98 ::sal_Bool SAL_CALL SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException) 99 { 100 // We control a sub-toolbar therefor, we have to return true. 101 return sal_True; 102 } 103 104 ::rtl::OUString SAL_CALL SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException) 105 { 106 // Provide the controlled sub-toolbar name, so we are notified whenever 107 // this toolbar executes a function. 108 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 109 return m_aSubTbName; 110 } 111 112 void SAL_CALL SvxTbxCtlAlign::functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException) 113 { 114 // Our sub-toolbar wants to executes a function. We have to change 115 // the image of our toolbar button to reflect the new function. 116 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 117 if ( !m_bDisposed ) 118 { 119 if ( aCommand.getLength() > 0 ) 120 { 121 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface()); 122 Image aImage = GetImage( xFrame, aCommand, hasBigImages(), isHighContrast() ); 123 if ( !!aImage ) 124 GetToolBox().SetItemImage( GetId(), aImage ); 125 } 126 } 127 } 128 129 void SAL_CALL SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException) 130 { 131 // We should update the button image of our parent (toolbar). Use the stored 132 // command to set the correct current image. 133 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 134 if ( m_aCommand.getLength() > 0 ) 135 { 136 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface()); 137 Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() ); 138 if ( !!aImage ) 139 GetToolBox().SetItemImage( GetId(), aImage ); 140 } 141 } 142