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
27cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
28cdf0e10cSrcweir
29cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
30cdf0e10cSrcweir #include <svx/svxids.hrc>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <tools/shl.hxx>
33cdf0e10cSrcweir #include <svl/eitem.hxx>
34cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
35cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
36cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
37cdf0e10cSrcweir #include <vcl/toolbox.hxx>
38cdf0e10cSrcweir #include <vos/mutex.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir #include "svx/tbxcustomshapes.hxx"
43cdf0e10cSrcweir
44cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlCustomShapes, SfxBoolItem);
45cdf0e10cSrcweir
46cdf0e10cSrcweir /*************************************************************************
47cdf0e10cSrcweir |*
48cdf0e10cSrcweir \************************************************************************/
49cdf0e10cSrcweir
SvxTbxCtlCustomShapes(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)50cdf0e10cSrcweir SvxTbxCtlCustomShapes::SvxTbxCtlCustomShapes( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
51cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ),
52cdf0e10cSrcweir m_aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ) )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir switch( nSlotId )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir default :
57cdf0e10cSrcweir {
58cdf0e10cSrcweir DBG_ASSERT( false, "SvxTbxCtlCustomShapes: unknown slot executed. ?" );
59cdf0e10cSrcweir }
60cdf0e10cSrcweir case SID_DRAWTBX_CS_BASIC :
61cdf0e10cSrcweir {
62cdf0e10cSrcweir m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BasicShapes.diamond" ) );
63cdf0e10cSrcweir m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "basicshapes" ) );
64cdf0e10cSrcweir }
65cdf0e10cSrcweir break;
66cdf0e10cSrcweir
67cdf0e10cSrcweir case SID_DRAWTBX_CS_SYMBOL :
68cdf0e10cSrcweir {
69cdf0e10cSrcweir m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SymbolShapes.smiley" ) );
70cdf0e10cSrcweir m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "symbolshapes" ) );
71cdf0e10cSrcweir }
72cdf0e10cSrcweir break;
73cdf0e10cSrcweir
74cdf0e10cSrcweir case SID_DRAWTBX_CS_ARROW :
75cdf0e10cSrcweir {
76cdf0e10cSrcweir m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ArrowShapes.left-right-arrow" ) );
77cdf0e10cSrcweir m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "arrowshapes" ) );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir break;
80cdf0e10cSrcweir case SID_DRAWTBX_CS_FLOWCHART :
81cdf0e10cSrcweir {
82cdf0e10cSrcweir m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FlowChartShapes.flowchart-internal-storage" ) );
83cdf0e10cSrcweir m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flowchartshapes" ) );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir break;
86cdf0e10cSrcweir case SID_DRAWTBX_CS_CALLOUT :
87cdf0e10cSrcweir {
88cdf0e10cSrcweir m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CalloutShapes.round-rectangular-callout" ) );
89cdf0e10cSrcweir m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calloutshapes" ) );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir break;
92cdf0e10cSrcweir case SID_DRAWTBX_CS_STAR :
93cdf0e10cSrcweir {
94cdf0e10cSrcweir m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StarShapes.star5" ) );
95cdf0e10cSrcweir m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "starshapes" ) );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir m_aSubTbxResName += m_aSubTbName;
100cdf0e10cSrcweir rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
101cdf0e10cSrcweir rTbx.Invalidate();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir /*************************************************************************
105cdf0e10cSrcweir |* Benachrichtigung, wenn sich der Applikationsstatus geaendert hat
106cdf0e10cSrcweir \************************************************************************/
107cdf0e10cSrcweir
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)108cdf0e10cSrcweir void SvxTbxCtlCustomShapes::StateChanged( sal_uInt16 nSID, SfxItemState eState,
109cdf0e10cSrcweir const SfxPoolItem* pState )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir SfxToolBoxControl::StateChanged( nSID, eState, pState );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir /*************************************************************************
115cdf0e10cSrcweir |* Wenn man ein PopupWindow erzeugen will
116cdf0e10cSrcweir \************************************************************************/
117cdf0e10cSrcweir
GetPopupWindowType() const118cdf0e10cSrcweir SfxPopupWindowType SvxTbxCtlCustomShapes::GetPopupWindowType() const
119cdf0e10cSrcweir {
120cdf0e10cSrcweir return( m_aCommand.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT);
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir /*************************************************************************
124cdf0e10cSrcweir |* Hier wird das Fenster erzeugt
125cdf0e10cSrcweir |* Lage der Toolbox mit GetToolBox() abfragbar
126cdf0e10cSrcweir |* rItemRect sind die Screen-Koordinaten
127cdf0e10cSrcweir \************************************************************************/
128cdf0e10cSrcweir
CreatePopupWindow()129cdf0e10cSrcweir SfxPopupWindow* SvxTbxCtlCustomShapes::CreatePopupWindow()
130cdf0e10cSrcweir {
131cdf0e10cSrcweir createAndPositionSubToolBar( m_aSubTbxResName );
132cdf0e10cSrcweir return NULL;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir // -----------------------------------------------------------------------
136cdf0e10cSrcweir
Select(sal_Bool)137cdf0e10cSrcweir void SvxTbxCtlCustomShapes::Select( sal_Bool /*bMod1*/ )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir if ( m_aCommand.getLength() > 0 )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aParamSeq( 0 );
142cdf0e10cSrcweir Dispatch( m_aCommand, aParamSeq );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir
opensSubToolbar()147cdf0e10cSrcweir ::sal_Bool SAL_CALL SvxTbxCtlCustomShapes::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir // We control a sub-toolbar therefor, we have to return true.
150cdf0e10cSrcweir return sal_True;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
getSubToolbarName()153cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxTbxCtlCustomShapes::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir // Provide the controlled sub-toolbar name, so we are notified whenever
156cdf0e10cSrcweir // this toolbar executes a function.
157cdf0e10cSrcweir return m_aSubTbName;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
functionSelected(const::rtl::OUString & rCommand)160cdf0e10cSrcweir void SAL_CALL SvxTbxCtlCustomShapes::functionSelected( const ::rtl::OUString& rCommand ) throw (::com::sun::star::uno::RuntimeException)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir // remind the new command
163cdf0e10cSrcweir m_aCommand = rCommand;
164cdf0e10cSrcweir // Our sub-toolbar wants to execute a function.
165cdf0e10cSrcweir // We have to change the image of our toolbar button to reflect the new function.
166cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
167cdf0e10cSrcweir if ( !m_bDisposed )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir if ( m_aCommand.getLength() > 0 )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
172cdf0e10cSrcweir Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() );
173cdf0e10cSrcweir if ( !!aImage )
174cdf0e10cSrcweir GetToolBox().SetItemImage( GetId(), aImage );
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
updateImage()179cdf0e10cSrcweir void SAL_CALL SvxTbxCtlCustomShapes::updateImage( ) throw (::com::sun::star::uno::RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir // We should update the button image of our parent (toolbar).
182cdf0e10cSrcweir // Use the stored command to set the correct current image.
183cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
184cdf0e10cSrcweir if ( m_aCommand.getLength() > 0 )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
187cdf0e10cSrcweir Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() );
188cdf0e10cSrcweir if ( !!aImage )
189cdf0e10cSrcweir GetToolBox().SetItemImage( GetId(), aImage );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir }
192