Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <string>
31 : :
32 : : #include <svx/svxids.hrc>
33 : : #include <tools/shl.hxx>
34 : : #include <svl/eitem.hxx>
35 : : #include <sfx2/dispatch.hxx>
36 : : #include <sfx2/viewsh.hxx>
37 : : #include <sfx2/viewfrm.hxx>
38 : : #include <vcl/toolbox.hxx>
39 : : #include <osl/mutex.hxx>
40 : :
41 : : #include <sfx2/imagemgr.hxx>
42 : : #include <vcl/svapp.hxx>
43 : : #include "svx/tbxcustomshapes.hxx"
44 : :
45 [ + - ]: 1668 : SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlCustomShapes, SfxBoolItem);
46 : :
47 : 978 : SvxTbxCtlCustomShapes::SvxTbxCtlCustomShapes( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
48 : : SfxToolBoxControl( nSlotId, nId, rTbx ),
49 [ + - ]: 978 : m_aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ) )
50 : : {
51 [ + + + + : 978 : switch( nSlotId )
+ + ]
52 : : {
53 : : default :
54 : : {
55 : : DBG_ASSERT( false, "SvxTbxCtlCustomShapes: unknown slot executed. ?" );
56 : : }
57 : : case SID_DRAWTBX_CS_BASIC :
58 : : {
59 [ + - ]: 163 : m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BasicShapes.diamond" ) );
60 [ + - ]: 163 : m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "basicshapes" ) );
61 : : }
62 : 163 : break;
63 : :
64 : : case SID_DRAWTBX_CS_SYMBOL :
65 : : {
66 [ + - ]: 163 : m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SymbolShapes.smiley" ) );
67 [ + - ]: 163 : m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "symbolshapes" ) );
68 : : }
69 : 163 : break;
70 : :
71 : : case SID_DRAWTBX_CS_ARROW :
72 : : {
73 [ + - ]: 163 : m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ArrowShapes.left-right-arrow" ) );
74 [ + - ]: 163 : m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "arrowshapes" ) );
75 : : }
76 : 163 : break;
77 : : case SID_DRAWTBX_CS_FLOWCHART :
78 : : {
79 [ + - ]: 163 : m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FlowChartShapes.flowchart-internal-storage" ) );
80 [ + - ]: 163 : m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flowchartshapes" ) );
81 : : }
82 : 163 : break;
83 : : case SID_DRAWTBX_CS_CALLOUT :
84 : : {
85 [ + - ]: 163 : m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CalloutShapes.round-rectangular-callout" ) );
86 [ + - ]: 163 : m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calloutshapes" ) );
87 : : }
88 : 163 : break;
89 : : case SID_DRAWTBX_CS_STAR :
90 : : {
91 [ + - ]: 163 : m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StarShapes.star5" ) );
92 [ + - ]: 163 : m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "starshapes" ) );
93 : : }
94 : 163 : break;
95 : : }
96 : 978 : m_aSubTbxResName += m_aSubTbName;
97 [ + - ][ + - ]: 978 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
98 [ + - ]: 978 : rTbx.Invalidate();
99 : 978 : }
100 : :
101 : : /*************************************************************************
102 : : |*
103 : : |* Notification when the application status has changed
104 : : |*
105 : : \************************************************************************/
106 : :
107 : 954 : void SvxTbxCtlCustomShapes::StateChanged( sal_uInt16 nSID, SfxItemState eState,
108 : : const SfxPoolItem* pState )
109 : : {
110 : 954 : SfxToolBoxControl::StateChanged( nSID, eState, pState );
111 : 954 : }
112 : :
113 : : /*************************************************************************
114 : : |*
115 : : |* when one wants to create a popup window
116 : : |*
117 : : \************************************************************************/
118 : :
119 : 0 : SfxPopupWindowType SvxTbxCtlCustomShapes::GetPopupWindowType() const
120 : : {
121 [ # # ]: 0 : return( m_aCommand.isEmpty() ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT);
122 : : }
123 : :
124 : : /*************************************************************************
125 : : |*
126 : : |* Here is the window created
127 : : |* The location of the Toolbox is queried through GetToolBox()
128 : : |* rItemRect are the screen coordinates
129 : : |*
130 : : \************************************************************************/
131 : :
132 : 0 : SfxPopupWindow* SvxTbxCtlCustomShapes::CreatePopupWindow()
133 : : {
134 : 0 : createAndPositionSubToolBar( m_aSubTbxResName );
135 : 0 : return NULL;
136 : : }
137 : :
138 : : // -----------------------------------------------------------------------
139 : :
140 : 0 : void SvxTbxCtlCustomShapes::Select( sal_Bool /*bMod1*/ )
141 : : {
142 [ # # ]: 0 : if ( !m_aCommand.isEmpty() )
143 : : {
144 [ # # ]: 0 : com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aParamSeq( 0 );
145 [ # # ][ # # ]: 0 : Dispatch( m_aCommand, aParamSeq );
146 : : }
147 : 0 : }
148 : :
149 : :
150 : 774 : ::sal_Bool SAL_CALL SvxTbxCtlCustomShapes::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
151 : : {
152 : : // We control a sub-toolbar therefore we have to return true.
153 : 774 : return sal_True;
154 : : }
155 : :
156 : 978 : ::rtl::OUString SAL_CALL SvxTbxCtlCustomShapes::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
157 : : {
158 : : // Provide the controlled sub-toolbar name, so we are notified whenever
159 : : // this toolbar executes a function.
160 : 978 : return m_aSubTbName;
161 : : }
162 : :
163 : 0 : void SAL_CALL SvxTbxCtlCustomShapes::functionSelected( const ::rtl::OUString& rCommand ) throw (::com::sun::star::uno::RuntimeException)
164 : : {
165 : : // remind the new command
166 : 0 : m_aCommand = rCommand;
167 : : // Our sub-toolbar wants to execute a function.
168 : : // We have to change the image of our toolbar button to reflect the new function.
169 [ # # ]: 0 : SolarMutexGuard aGuard;
170 [ # # ]: 0 : if ( !m_bDisposed )
171 : : {
172 [ # # ]: 0 : if ( !m_aCommand.isEmpty() )
173 : : {
174 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
175 [ # # ][ # # ]: 0 : Image aImage = GetImage( xFrame, m_aCommand, hasBigImages() );
176 [ # # ]: 0 : if ( !!aImage )
177 [ # # ][ # # ]: 0 : GetToolBox().SetItemImage( GetId(), aImage );
[ # # ][ # # ]
178 : : }
179 [ # # ]: 0 : }
180 : 0 : }
181 : :
182 : 0 : void SAL_CALL SvxTbxCtlCustomShapes::updateImage( ) throw (::com::sun::star::uno::RuntimeException)
183 : : {
184 : : // We should update the button image of our parent (toolbar).
185 : : // Use the stored command to set the correct current image.
186 [ # # ]: 0 : SolarMutexGuard aGuard;
187 [ # # ]: 0 : if ( !m_aCommand.isEmpty() )
188 : : {
189 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
190 [ # # ][ # # ]: 0 : Image aImage = GetImage( xFrame, m_aCommand, hasBigImages() );
191 [ # # ]: 0 : if ( !!aImage )
192 [ # # ][ # # ]: 0 : GetToolBox().SetItemImage( GetId(), aImage );
[ # # ][ # # ]
193 [ # # ]: 0 : }
194 : 0 : }
195 : :
196 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|