xref: /AOO41X/main/svx/source/tbxctrls/tbxalign.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svl/aeitem.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <svx/dialmgr.hxx>
29cdf0e10cSrcweir #include <svx/dialogs.hrc>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "svx/tbxalign.hxx"
32cdf0e10cSrcweir #include "svx/tbxdraw.hxx"
33cdf0e10cSrcweir #include "tbxdraw.hrc"
34cdf0e10cSrcweir #include <tools/shl.hxx>
35cdf0e10cSrcweir #ifndef	_SFX_IMAGEMGR_HXX
36cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <vcl/svapp.hxx>
39cdf0e10cSrcweir #include <vos/mutex.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <sfx2/app.hxx>
42cdf0e10cSrcweir #include <vcl/toolbox.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign, SfxAllEnumItem);
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /*************************************************************************
47cdf0e10cSrcweir |*
48cdf0e10cSrcweir |* Klasse fuer SwToolbox
49cdf0e10cSrcweir |*
50cdf0e10cSrcweir \************************************************************************/
51cdf0e10cSrcweir 
SvxTbxCtlAlign(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)52cdf0e10cSrcweir SvxTbxCtlAlign::SvxTbxCtlAlign( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
53cdf0e10cSrcweir 	SfxToolBoxControl( nSlotId, nId, rTbx )
54cdf0e10cSrcweir     ,   m_aSubTbName( RTL_CONSTASCII_USTRINGPARAM( "alignmentbar" ))
55cdf0e10cSrcweir     ,   m_aSubTbResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/alignmentbar" ))
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
58cdf0e10cSrcweir 	rTbx.Invalidate();
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     m_aCommand = m_aCommandURL;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir /*************************************************************************
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir |* Wenn man ein PopupWindow erzeugen will
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir \************************************************************************/
68cdf0e10cSrcweir 
GetPopupWindowType() const69cdf0e10cSrcweir SfxPopupWindowType SvxTbxCtlAlign::GetPopupWindowType() const
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	return(SFX_POPUPWINDOW_ONCLICK);
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir /*************************************************************************
75cdf0e10cSrcweir |*
76cdf0e10cSrcweir |* Hier wird das Fenster erzeugt
77cdf0e10cSrcweir |* Lage der Toolbox mit GetToolBox() abfragbar
78cdf0e10cSrcweir |* rItemRect sind die Screen-Koordinaten
79cdf0e10cSrcweir |*
80cdf0e10cSrcweir \************************************************************************/
81cdf0e10cSrcweir 
CreatePopupWindow()82cdf0e10cSrcweir SfxPopupWindow*	SvxTbxCtlAlign::CreatePopupWindow()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
85cdf0e10cSrcweir 	if ( GetSlotId() == SID_OBJECT_ALIGN )
86cdf0e10cSrcweir         createAndPositionSubToolBar( m_aSubTbResName );
87cdf0e10cSrcweir 	return NULL;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir //========================================================================
91cdf0e10cSrcweir // XSubToolbarController
92cdf0e10cSrcweir //========================================================================
93cdf0e10cSrcweir 
opensSubToolbar()94cdf0e10cSrcweir ::sal_Bool SAL_CALL SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     // We control a sub-toolbar therefor, we have to return true.
97cdf0e10cSrcweir     return sal_True;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
getSubToolbarName()100cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir     // Provide the controlled sub-toolbar name, so we are notified whenever
103cdf0e10cSrcweir     // this toolbar executes a function.
104cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
105cdf0e10cSrcweir     return m_aSubTbName;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
functionSelected(const::rtl::OUString & aCommand)108cdf0e10cSrcweir void SAL_CALL SvxTbxCtlAlign::functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     // Our sub-toolbar wants to executes a function. We have to change
111cdf0e10cSrcweir     // the image of our toolbar button to reflect the new function.
112cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
113cdf0e10cSrcweir     if ( !m_bDisposed )
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         if ( aCommand.getLength() > 0 )
116cdf0e10cSrcweir         {
117cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
118cdf0e10cSrcweir             Image aImage = GetImage( xFrame, aCommand, hasBigImages(), isHighContrast() );
119cdf0e10cSrcweir             if ( !!aImage )
120cdf0e10cSrcweir                 GetToolBox().SetItemImage( GetId(), aImage );
121cdf0e10cSrcweir         }
122cdf0e10cSrcweir     }
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
updateImage()125cdf0e10cSrcweir void SAL_CALL SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     // We should update the button image of our parent (toolbar). Use the stored
128cdf0e10cSrcweir     // command to set the correct current image.
129cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
130cdf0e10cSrcweir     if ( m_aCommand.getLength() > 0 )
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
133cdf0e10cSrcweir         Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() );
134cdf0e10cSrcweir         if ( !!aImage )
135cdf0e10cSrcweir             GetToolBox().SetItemImage( GetId(), aImage );
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir }
138