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