1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
30 #include "GraphicDocShell.hxx"
32 #include <vcl/toolbox.hxx>
36 #include "res_bmp.hrc"
37 #include "sdresid.hxx"
40 SFX_IMPL_TOOLBOX_CONTROL( SdTbxControl
, TbxImageItem
)
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
) );
52 /*-------------------------------------------------------------------------*/
54 SfxPopupWindowType
SdTbxControl::GetPopupWindowType() const
56 return SfxPopupWindowType::ONTIMEOUT
;
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/" );
72 case SID_OBJECT_ALIGN
:
73 aTbxResName
.appendAscii( "alignmentbar" );
74 aToolBarResStr
= aTbxResName
.makeStringAndClear();
76 case SID_ZOOM_TOOLBOX
:
77 aTbxResName
.appendAscii( "zoombar" );
78 aToolBarResStr
= aTbxResName
.makeStringAndClear();
80 case SID_OBJECT_CHOOSE_MODE
:
81 aTbxResName
.appendAscii( "choosemodebar" );
82 aToolBarResStr
= aTbxResName
.makeStringAndClear();
85 aTbxResName
.appendAscii( "positionbar" );
86 aToolBarResStr
= aTbxResName
.makeStringAndClear();
88 case SID_DRAWTBX_TEXT
:
89 aTbxResName
.appendAscii( "textbar" );
90 aToolBarResStr
= aTbxResName
.makeStringAndClear();
92 case SID_DRAWTBX_RECTANGLES
:
93 aTbxResName
.appendAscii( "rectanglesbar" );
94 aToolBarResStr
= aTbxResName
.makeStringAndClear();
96 case SID_DRAWTBX_ELLIPSES
:
97 aTbxResName
.appendAscii( "ellipsesbar" );
98 aToolBarResStr
= aTbxResName
.makeStringAndClear();
100 case SID_DRAWTBX_LINES
:
101 aTbxResName
.appendAscii( "linesbar" );
102 aToolBarResStr
= aTbxResName
.makeStringAndClear();
104 case SID_DRAWTBX_ARROWS
:
105 aTbxResName
.appendAscii( "arrowsbar" );
106 aToolBarResStr
= aTbxResName
.makeStringAndClear();
108 case SID_DRAWTBX_3D_OBJECTS
:
109 aTbxResName
.appendAscii( "3dobjectsbar" );
110 aToolBarResStr
= aTbxResName
.makeStringAndClear();
112 case SID_DRAWTBX_CONNECTORS
:
113 aTbxResName
.appendAscii( "connectorsbar" );
114 aToolBarResStr
= aTbxResName
.makeStringAndClear();
116 case SID_DRAWTBX_INSERT
:
117 aTbxResName
.appendAscii( "insertbar" );
118 aToolBarResStr
= aTbxResName
.makeStringAndClear();
122 if ( !aToolBarResStr
.isEmpty() )
123 createAndPositionSubToolBar( aToolBarResStr
);
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
142 ToolBox
& rTbx
= GetToolBox();
143 sal_uInt16 nImage
= pItem
->GetValue();
146 if( rTbx
.IsItemChecked( nSId
) )
147 rTbx
.CheckItem( nSId
, false );
151 OUString
aSlotURL( "slot:" );
152 aSlotURL
+= OUString::number( nImage
);
153 Image aImage
= GetImage( m_xFrame
,
158 // !-operator checks if image is not present
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
)
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
:
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
:
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
:
238 case SID_DRAW_CIRCLEPIE
:
239 case SID_DRAW_ELLIPSECUT
:
240 case SID_DRAW_CIRCLECUT
:
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
:
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
:
272 case SID_3D_CYLINDER
:
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
:
313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */