Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
28 :
29 : #include "sddll.hxx"
30 : #include "GraphicDocShell.hxx"
31 :
32 : #include <vcl/toolbox.hxx>
33 :
34 : #include "app.hxx"
35 : #include "app.hrc"
36 : #include "res_bmp.hrc"
37 : #include "sdresid.hxx"
38 : #include "tbx_ww.hxx"
39 :
40 36 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxControl, TbxImageItem )
41 :
42 : /*************************************************************************
43 : |*
44 : |* Klasse fuer Toolbox
45 : |*
46 : \************************************************************************/
47 :
48 0 : SdTbxControl::SdTbxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
49 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
50 : {
51 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
52 0 : rTbx.Invalidate();
53 0 : }
54 :
55 : /*-------------------------------------------------------------------------*/
56 :
57 0 : SfxPopupWindowType SdTbxControl::GetPopupWindowType() const
58 : {
59 0 : return( SFX_POPUPWINDOW_ONTIMEOUT );
60 : }
61 :
62 : /*************************************************************************
63 : |*
64 : |* Hier wird das Fenster erzeugt
65 : |* Lage der Toolbox mit GetToolBox() abfragbar
66 : |* rItemRect sind die Screen-Koordinaten
67 : |*
68 : \************************************************************************/
69 :
70 0 : SfxPopupWindow* SdTbxControl::CreatePopupWindow()
71 : {
72 0 : SfxPopupWindow *pWin = NULL;
73 0 : rtl::OUString aToolBarResStr;
74 0 : rtl::OUStringBuffer aTbxResName( "private:resource/toolbar/" );
75 0 : switch( GetSlotId() )
76 : {
77 : case SID_OBJECT_ALIGN:
78 0 : aTbxResName.appendAscii( "alignmentbar" );
79 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
80 0 : break;
81 : case SID_ZOOM_TOOLBOX:
82 0 : aTbxResName.appendAscii( "zoombar" );
83 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
84 0 : break;
85 : case SID_OBJECT_CHOOSE_MODE:
86 0 : aTbxResName.appendAscii( "choosemodebar" );
87 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
88 0 : break;
89 : case SID_POSITION:
90 0 : aTbxResName.appendAscii( "positionbar" );
91 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
92 0 : break;
93 : case SID_DRAWTBX_TEXT:
94 0 : aTbxResName.appendAscii( "textbar" );
95 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
96 0 : break;
97 : case SID_DRAWTBX_RECTANGLES:
98 0 : aTbxResName.appendAscii( "rectanglesbar" );
99 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
100 0 : break;
101 : case SID_DRAWTBX_ELLIPSES:
102 0 : aTbxResName.appendAscii( "ellipsesbar" );
103 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
104 0 : break;
105 : case SID_DRAWTBX_LINES:
106 0 : aTbxResName.appendAscii( "linesbar" );
107 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
108 0 : break;
109 : case SID_DRAWTBX_ARROWS:
110 0 : aTbxResName.appendAscii( "arrowsbar" );
111 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
112 0 : break;
113 : case SID_DRAWTBX_3D_OBJECTS:
114 0 : aTbxResName.appendAscii( "3dobjectsbar" );
115 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
116 0 : break;
117 : case SID_DRAWTBX_CONNECTORS:
118 0 : aTbxResName.appendAscii( "connectorsbar" );
119 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
120 0 : break;
121 : case SID_DRAWTBX_INSERT:
122 0 : aTbxResName.appendAscii( "insertbar" );
123 0 : aToolBarResStr = aTbxResName.makeStringAndClear();
124 0 : break;
125 : }
126 :
127 0 : if ( !aToolBarResStr.isEmpty() )
128 0 : createAndPositionSubToolBar( aToolBarResStr );
129 :
130 0 : return( pWin );
131 : }
132 :
133 : /*-------------------------------------------------------------------------*/
134 :
135 0 : void SdTbxControl::StateChanged( sal_uInt16 nSId,
136 : SfxItemState eState, const SfxPoolItem* pState )
137 : {
138 0 : SfxToolBoxControl::StateChanged( nSId, eState, pState );
139 :
140 0 : if( eState == SFX_ITEM_AVAILABLE )
141 : {
142 0 : TbxImageItem* pItem = PTR_CAST( TbxImageItem, pState );
143 : // Im StarDesktop kann jetzt auch ein anderes Item ankommen,
144 : // das nicht ausgewertet werden darf
145 0 : if( pItem )
146 : {
147 0 : ToolBox& rTbx = GetToolBox();
148 0 : sal_uInt16 nImage = pItem->GetValue();
149 0 : if( nImage == 0 )
150 : {
151 0 : if( rTbx.IsItemChecked( nSId ) )
152 0 : rTbx.CheckItem( nSId, sal_False );
153 : }
154 : else
155 : {
156 0 : rtl::OUString aSlotURL( "slot:" );
157 0 : aSlotURL += rtl::OUString::valueOf( sal_Int32( nImage ));
158 : Image aImage = GetImage( m_xFrame,
159 : aSlotURL,
160 0 : hasBigImages()
161 0 : );
162 :
163 : // !-Operator prueft, ob Image nicht vorhanden ist
164 0 : if( !!aImage )
165 : {
166 0 : rTbx.SetItemImage( GetId(), aImage );
167 0 : rTbx.CheckItem( GetId(), IsCheckable( nImage ) );
168 :
169 0 : if( nSId != SID_ZOOM_TOOLBOX &&
170 : nSId != SID_DRAWTBX_INSERT &&
171 : nSId != SID_POSITION &&
172 : nSId != SID_OBJECT_ALIGN )
173 : {
174 0 : if( nSId != SID_OBJECT_CHOOSE_MODE &&
175 0 : rTbx.IsItemChecked( SID_OBJECT_CHOOSE_MODE ) )
176 0 : rTbx.CheckItem( SID_OBJECT_CHOOSE_MODE, sal_False );
177 0 : if( nSId != SID_DRAWTBX_TEXT &&
178 0 : rTbx.IsItemChecked( SID_DRAWTBX_TEXT ) )
179 0 : rTbx.CheckItem( SID_DRAWTBX_TEXT, sal_False );
180 0 : if( nSId != SID_DRAWTBX_RECTANGLES &&
181 0 : rTbx.IsItemChecked( SID_DRAWTBX_RECTANGLES ) )
182 0 : rTbx.CheckItem( SID_DRAWTBX_RECTANGLES, sal_False );
183 0 : if( nSId != SID_DRAWTBX_ELLIPSES &&
184 0 : rTbx.IsItemChecked( SID_DRAWTBX_ELLIPSES ) )
185 0 : rTbx.CheckItem( SID_DRAWTBX_ELLIPSES, sal_False );
186 0 : if( nSId != SID_DRAWTBX_LINES &&
187 0 : rTbx.IsItemChecked( SID_DRAWTBX_LINES ) )
188 0 : rTbx.CheckItem( SID_DRAWTBX_LINES, sal_False );
189 0 : if( nSId != SID_DRAWTBX_ARROWS &&
190 0 : rTbx.IsItemChecked( SID_DRAWTBX_ARROWS ) )
191 0 : rTbx.CheckItem( SID_DRAWTBX_ARROWS, sal_False );
192 0 : if( nSId != SID_DRAWTBX_3D_OBJECTS &&
193 0 : rTbx.IsItemChecked( SID_DRAWTBX_3D_OBJECTS ) )
194 0 : rTbx.CheckItem( SID_DRAWTBX_3D_OBJECTS, sal_False );
195 0 : if( nSId != SID_DRAWTBX_CONNECTORS &&
196 0 : rTbx.IsItemChecked( SID_DRAWTBX_CONNECTORS ) )
197 0 : rTbx.CheckItem( SID_DRAWTBX_CONNECTORS, sal_False );
198 : }
199 0 : }
200 : }
201 : }
202 : }
203 0 : }
204 :
205 : /*-------------------------------------------------------------------------*/
206 :
207 0 : sal_Bool SdTbxControl::IsCheckable( sal_uInt16 nSId )
208 : {
209 0 : switch( nSId )
210 : {
211 : case SID_OBJECT_ROTATE:
212 : case SID_OBJECT_MIRROR:
213 : case SID_OBJECT_CROP:
214 : case SID_OBJECT_TRANSPARENCE:
215 : case SID_OBJECT_GRADIENT:
216 : case SID_OBJECT_SHEAR:
217 : case SID_OBJECT_CROOK_ROTATE:
218 : case SID_OBJECT_CROOK_SLANT:
219 : case SID_OBJECT_CROOK_STRETCH:
220 : case SID_CONVERT_TO_3D_LATHE:
221 :
222 : case SID_ATTR_CHAR:
223 : case SID_ATTR_CHAR_VERTICAL:
224 : case SID_TEXT_FITTOSIZE:
225 : case SID_TEXT_FITTOSIZE_VERTICAL:
226 : case SID_DRAW_CAPTION:
227 : case SID_DRAW_CAPTION_VERTICAL:
228 : case SID_DRAW_FONTWORK:
229 : case SID_DRAW_FONTWORK_VERTICAL:
230 :
231 : case SID_DRAW_RECT:
232 : case SID_DRAW_SQUARE:
233 : case SID_DRAW_RECT_ROUND:
234 : case SID_DRAW_SQUARE_ROUND:
235 : case SID_DRAW_RECT_NOFILL:
236 : case SID_DRAW_SQUARE_NOFILL:
237 : case SID_DRAW_RECT_ROUND_NOFILL:
238 : case SID_DRAW_SQUARE_ROUND_NOFILL:
239 :
240 : case SID_DRAW_ELLIPSE:
241 : case SID_DRAW_CIRCLE:
242 : case SID_DRAW_PIE:
243 : case SID_DRAW_CIRCLEPIE:
244 : case SID_DRAW_ELLIPSECUT:
245 : case SID_DRAW_CIRCLECUT:
246 : case SID_DRAW_ARC:
247 : case SID_DRAW_CIRCLEARC:
248 : case SID_DRAW_ELLIPSE_NOFILL:
249 : case SID_DRAW_CIRCLE_NOFILL:
250 : case SID_DRAW_PIE_NOFILL:
251 : case SID_DRAW_CIRCLEPIE_NOFILL:
252 : case SID_DRAW_ELLIPSECUT_NOFILL:
253 : case SID_DRAW_CIRCLECUT_NOFILL:
254 :
255 : case SID_DRAW_BEZIER_NOFILL:
256 : case SID_DRAW_POLYGON_NOFILL:
257 : case SID_DRAW_XPOLYGON_NOFILL:
258 : case SID_DRAW_BEZIER_FILL:
259 : case SID_DRAW_POLYGON:
260 : case SID_DRAW_XPOLYGON:
261 : case SID_DRAW_FREELINE:
262 : case SID_DRAW_FREELINE_NOFILL:
263 :
264 : case SID_DRAW_LINE:
265 : case SID_DRAW_XLINE:
266 : case SID_DRAW_MEASURELINE:
267 : case SID_LINE_ARROW_START:
268 : case SID_LINE_ARROW_END:
269 : case SID_LINE_ARROWS:
270 : case SID_LINE_ARROW_CIRCLE:
271 : case SID_LINE_CIRCLE_ARROW:
272 : case SID_LINE_ARROW_SQUARE:
273 : case SID_LINE_SQUARE_ARROW:
274 :
275 : case SID_3D_CUBE:
276 : case SID_3D_SPHERE:
277 : case SID_3D_CYLINDER:
278 : case SID_3D_CONE:
279 : case SID_3D_PYRAMID:
280 : case SID_3D_TORUS:
281 : case SID_3D_SHELL:
282 : case SID_3D_HALF_SPHERE:
283 :
284 : case SID_TOOL_CONNECTOR:
285 : case SID_CONNECTOR_ARROW_START:
286 : case SID_CONNECTOR_ARROW_END:
287 : case SID_CONNECTOR_ARROWS:
288 : case SID_CONNECTOR_CIRCLE_START:
289 : case SID_CONNECTOR_CIRCLE_END:
290 : case SID_CONNECTOR_CIRCLES:
291 : case SID_CONNECTOR_LINE:
292 : case SID_CONNECTOR_LINE_ARROW_START:
293 : case SID_CONNECTOR_LINE_ARROW_END:
294 : case SID_CONNECTOR_LINE_ARROWS:
295 : case SID_CONNECTOR_LINE_CIRCLE_START:
296 : case SID_CONNECTOR_LINE_CIRCLE_END:
297 : case SID_CONNECTOR_LINE_CIRCLES:
298 : case SID_CONNECTOR_CURVE:
299 : case SID_CONNECTOR_CURVE_ARROW_START:
300 : case SID_CONNECTOR_CURVE_ARROW_END:
301 : case SID_CONNECTOR_CURVE_ARROWS:
302 : case SID_CONNECTOR_CURVE_CIRCLE_START:
303 : case SID_CONNECTOR_CURVE_CIRCLE_END:
304 : case SID_CONNECTOR_CURVE_CIRCLES:
305 : case SID_CONNECTOR_LINES:
306 : case SID_CONNECTOR_LINES_ARROW_START:
307 : case SID_CONNECTOR_LINES_ARROW_END:
308 : case SID_CONNECTOR_LINES_ARROWS:
309 : case SID_CONNECTOR_LINES_CIRCLE_START:
310 : case SID_CONNECTOR_LINES_CIRCLE_END:
311 : case SID_CONNECTOR_LINES_CIRCLES:
312 :
313 0 : return( sal_True );
314 : }
315 0 : return( sal_False );
316 : }
317 :
318 :
319 :
320 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|