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