bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / app / tbxww.cxx
blob2aed6b89c96e6c349cca01ab4149420e1c4970ff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/bindings.hxx>
21 #include <svx/svxids.hrc>
22 #include <svx/grafctrl.hxx>
23 #include <svl/cjkoptions.hxx>
24 #include <sfx2/viewsh.hxx>
25 #include <sfx2/imagemgr.hxx>
26 #include <rtl/ustring.hxx>
27 #include <rtl/ustrbuf.hxx>
29 #include "sddll.hxx"
30 #include "GraphicDocShell.hxx"
32 #include <vcl/toolbox.hxx>
34 #include "sdmod.hxx"
35 #include "app.hrc"
36 #include "res_bmp.hrc"
37 #include "sdresid.hxx"
38 #include "tbx_ww.hxx"
40 SFX_IMPL_TOOLBOX_CONTROL( SdTbxControl, TbxImageItem )
42 /**
43 * Class for toolbox
45 SdTbxControl::SdTbxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
46 SfxToolBoxControl( nSlotId, nId, rTbx )
48 rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
49 rTbx.Invalidate();
52 /*-------------------------------------------------------------------------*/
54 SfxPopupWindowType SdTbxControl::GetPopupWindowType() const
56 return SfxPopupWindowType::ONTIMEOUT;
59 /**
60 * We create the window here
61 * You can get the position of the toolbox with GetToolBox()
62 * rItemRect are screen coordinates
65 VclPtr<SfxPopupWindow> SdTbxControl::CreatePopupWindow()
67 SfxPopupWindow *pWin = NULL;
68 OUString aToolBarResStr;
69 OUStringBuffer aTbxResName( "private:resource/toolbar/" );
70 switch( GetSlotId() )
72 case SID_OBJECT_ALIGN:
73 aTbxResName.appendAscii( "alignmentbar" );
74 aToolBarResStr = aTbxResName.makeStringAndClear();
75 break;
76 case SID_ZOOM_TOOLBOX:
77 aTbxResName.appendAscii( "zoombar" );
78 aToolBarResStr = aTbxResName.makeStringAndClear();
79 break;
80 case SID_OBJECT_CHOOSE_MODE:
81 aTbxResName.appendAscii( "choosemodebar" );
82 aToolBarResStr = aTbxResName.makeStringAndClear();
83 break;
84 case SID_POSITION:
85 aTbxResName.appendAscii( "positionbar" );
86 aToolBarResStr = aTbxResName.makeStringAndClear();
87 break;
88 case SID_DRAWTBX_TEXT:
89 aTbxResName.appendAscii( "textbar" );
90 aToolBarResStr = aTbxResName.makeStringAndClear();
91 break;
92 case SID_DRAWTBX_RECTANGLES:
93 aTbxResName.appendAscii( "rectanglesbar" );
94 aToolBarResStr = aTbxResName.makeStringAndClear();
95 break;
96 case SID_DRAWTBX_ELLIPSES:
97 aTbxResName.appendAscii( "ellipsesbar" );
98 aToolBarResStr = aTbxResName.makeStringAndClear();
99 break;
100 case SID_DRAWTBX_LINES:
101 aTbxResName.appendAscii( "linesbar" );
102 aToolBarResStr = aTbxResName.makeStringAndClear();
103 break;
104 case SID_DRAWTBX_ARROWS:
105 aTbxResName.appendAscii( "arrowsbar" );
106 aToolBarResStr = aTbxResName.makeStringAndClear();
107 break;
108 case SID_DRAWTBX_3D_OBJECTS:
109 aTbxResName.appendAscii( "3dobjectsbar" );
110 aToolBarResStr = aTbxResName.makeStringAndClear();
111 break;
112 case SID_DRAWTBX_CONNECTORS:
113 aTbxResName.appendAscii( "connectorsbar" );
114 aToolBarResStr = aTbxResName.makeStringAndClear();
115 break;
116 case SID_DRAWTBX_INSERT:
117 aTbxResName.appendAscii( "insertbar" );
118 aToolBarResStr = aTbxResName.makeStringAndClear();
119 break;
122 if ( !aToolBarResStr.isEmpty() )
123 createAndPositionSubToolBar( aToolBarResStr );
125 return pWin;
128 /*-------------------------------------------------------------------------*/
130 void SdTbxControl::StateChanged( sal_uInt16 nSId,
131 SfxItemState eState, const SfxPoolItem* pState )
133 SfxToolBoxControl::StateChanged( nSId, eState, pState );
135 if( eState == SfxItemState::DEFAULT )
137 const TbxImageItem* pItem = PTR_CAST( TbxImageItem, pState );
138 // StarDesktop can also receive another item,
139 // but it is not allowed to evaluate it
140 if( pItem )
142 ToolBox& rTbx = GetToolBox();
143 sal_uInt16 nImage = pItem->GetValue();
144 if( nImage == 0 )
146 if( rTbx.IsItemChecked( nSId ) )
147 rTbx.CheckItem( nSId, false );
149 else
151 OUString aSlotURL( "slot:" );
152 aSlotURL += OUString::number( nImage);
153 Image aImage = GetImage( m_xFrame,
154 aSlotURL,
155 hasBigImages()
158 // !-operator checks if image is not present
159 if( !!aImage )
161 rTbx.SetItemImage( GetId(), aImage );
162 rTbx.CheckItem( GetId(), IsCheckable( nImage ) );
164 if( nSId != SID_ZOOM_TOOLBOX &&
165 nSId != SID_DRAWTBX_INSERT &&
166 nSId != SID_POSITION &&
167 nSId != SID_OBJECT_ALIGN )
169 if( nSId != SID_OBJECT_CHOOSE_MODE &&
170 rTbx.IsItemChecked( SID_OBJECT_CHOOSE_MODE ) )
171 rTbx.CheckItem( SID_OBJECT_CHOOSE_MODE, false );
172 if( nSId != SID_DRAWTBX_TEXT &&
173 rTbx.IsItemChecked( SID_DRAWTBX_TEXT ) )
174 rTbx.CheckItem( SID_DRAWTBX_TEXT, false );
175 if( nSId != SID_DRAWTBX_RECTANGLES &&
176 rTbx.IsItemChecked( SID_DRAWTBX_RECTANGLES ) )
177 rTbx.CheckItem( SID_DRAWTBX_RECTANGLES, false );
178 if( nSId != SID_DRAWTBX_ELLIPSES &&
179 rTbx.IsItemChecked( SID_DRAWTBX_ELLIPSES ) )
180 rTbx.CheckItem( SID_DRAWTBX_ELLIPSES, false );
181 if( nSId != SID_DRAWTBX_LINES &&
182 rTbx.IsItemChecked( SID_DRAWTBX_LINES ) )
183 rTbx.CheckItem( SID_DRAWTBX_LINES, false );
184 if( nSId != SID_DRAWTBX_ARROWS &&
185 rTbx.IsItemChecked( SID_DRAWTBX_ARROWS ) )
186 rTbx.CheckItem( SID_DRAWTBX_ARROWS, false );
187 if( nSId != SID_DRAWTBX_3D_OBJECTS &&
188 rTbx.IsItemChecked( SID_DRAWTBX_3D_OBJECTS ) )
189 rTbx.CheckItem( SID_DRAWTBX_3D_OBJECTS, false );
190 if( nSId != SID_DRAWTBX_CONNECTORS &&
191 rTbx.IsItemChecked( SID_DRAWTBX_CONNECTORS ) )
192 rTbx.CheckItem( SID_DRAWTBX_CONNECTORS, false );
200 /*-------------------------------------------------------------------------*/
202 bool SdTbxControl::IsCheckable( sal_uInt16 nSId )
204 switch( nSId )
206 case SID_OBJECT_ROTATE:
207 case SID_OBJECT_MIRROR:
208 case SID_OBJECT_CROP:
209 case SID_OBJECT_TRANSPARENCE:
210 case SID_OBJECT_GRADIENT:
211 case SID_OBJECT_SHEAR:
212 case SID_OBJECT_CROOK_ROTATE:
213 case SID_OBJECT_CROOK_SLANT:
214 case SID_OBJECT_CROOK_STRETCH:
215 case SID_CONVERT_TO_3D_LATHE:
217 case SID_ATTR_CHAR:
218 case SID_ATTR_CHAR_VERTICAL:
219 case SID_TEXT_FITTOSIZE:
220 case SID_TEXT_FITTOSIZE_VERTICAL:
221 case SID_DRAW_CAPTION:
222 case SID_DRAW_CAPTION_VERTICAL:
223 case SID_DRAW_FONTWORK:
224 case SID_DRAW_FONTWORK_VERTICAL:
226 case SID_DRAW_RECT:
227 case SID_DRAW_SQUARE:
228 case SID_DRAW_RECT_ROUND:
229 case SID_DRAW_SQUARE_ROUND:
230 case SID_DRAW_RECT_NOFILL:
231 case SID_DRAW_SQUARE_NOFILL:
232 case SID_DRAW_RECT_ROUND_NOFILL:
233 case SID_DRAW_SQUARE_ROUND_NOFILL:
235 case SID_DRAW_ELLIPSE:
236 case SID_DRAW_CIRCLE:
237 case SID_DRAW_PIE:
238 case SID_DRAW_CIRCLEPIE:
239 case SID_DRAW_ELLIPSECUT:
240 case SID_DRAW_CIRCLECUT:
241 case SID_DRAW_ARC:
242 case SID_DRAW_CIRCLEARC:
243 case SID_DRAW_ELLIPSE_NOFILL:
244 case SID_DRAW_CIRCLE_NOFILL:
245 case SID_DRAW_PIE_NOFILL:
246 case SID_DRAW_CIRCLEPIE_NOFILL:
247 case SID_DRAW_ELLIPSECUT_NOFILL:
248 case SID_DRAW_CIRCLECUT_NOFILL:
250 case SID_DRAW_BEZIER_NOFILL:
251 case SID_DRAW_POLYGON_NOFILL:
252 case SID_DRAW_XPOLYGON_NOFILL:
253 case SID_DRAW_BEZIER_FILL:
254 case SID_DRAW_POLYGON:
255 case SID_DRAW_XPOLYGON:
256 case SID_DRAW_FREELINE:
257 case SID_DRAW_FREELINE_NOFILL:
259 case SID_DRAW_LINE:
260 case SID_DRAW_XLINE:
261 case SID_DRAW_MEASURELINE:
262 case SID_LINE_ARROW_START:
263 case SID_LINE_ARROW_END:
264 case SID_LINE_ARROWS:
265 case SID_LINE_ARROW_CIRCLE:
266 case SID_LINE_CIRCLE_ARROW:
267 case SID_LINE_ARROW_SQUARE:
268 case SID_LINE_SQUARE_ARROW:
270 case SID_3D_CUBE:
271 case SID_3D_SPHERE:
272 case SID_3D_CYLINDER:
273 case SID_3D_CONE:
274 case SID_3D_PYRAMID:
275 case SID_3D_TORUS:
276 case SID_3D_SHELL:
277 case SID_3D_HALF_SPHERE:
279 case SID_TOOL_CONNECTOR:
280 case SID_CONNECTOR_ARROW_START:
281 case SID_CONNECTOR_ARROW_END:
282 case SID_CONNECTOR_ARROWS:
283 case SID_CONNECTOR_CIRCLE_START:
284 case SID_CONNECTOR_CIRCLE_END:
285 case SID_CONNECTOR_CIRCLES:
286 case SID_CONNECTOR_LINE:
287 case SID_CONNECTOR_LINE_ARROW_START:
288 case SID_CONNECTOR_LINE_ARROW_END:
289 case SID_CONNECTOR_LINE_ARROWS:
290 case SID_CONNECTOR_LINE_CIRCLE_START:
291 case SID_CONNECTOR_LINE_CIRCLE_END:
292 case SID_CONNECTOR_LINE_CIRCLES:
293 case SID_CONNECTOR_CURVE:
294 case SID_CONNECTOR_CURVE_ARROW_START:
295 case SID_CONNECTOR_CURVE_ARROW_END:
296 case SID_CONNECTOR_CURVE_ARROWS:
297 case SID_CONNECTOR_CURVE_CIRCLE_START:
298 case SID_CONNECTOR_CURVE_CIRCLE_END:
299 case SID_CONNECTOR_CURVE_CIRCLES:
300 case SID_CONNECTOR_LINES:
301 case SID_CONNECTOR_LINES_ARROW_START:
302 case SID_CONNECTOR_LINES_ARROW_END:
303 case SID_CONNECTOR_LINES_ARROWS:
304 case SID_CONNECTOR_LINES_CIRCLE_START:
305 case SID_CONNECTOR_LINES_CIRCLE_END:
306 case SID_CONNECTOR_LINES_CIRCLES:
308 return true;
310 return false;
313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */