/src/libreoffice/svx/source/tbxctrls/grafctrl.cxx
Line | Count | Source |
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 <sal/config.h> |
21 | | |
22 | | #include <comphelper/propertyvalue.hxx> |
23 | | #include <o3tl/string_view.hxx> |
24 | | #include <vcl/toolbox.hxx> |
25 | | #include <vcl/weld/MetricSpinButton.hxx> |
26 | | #include <svl/intitem.hxx> |
27 | | #include <svl/itempool.hxx> |
28 | | #include <svl/eitem.hxx> |
29 | | #include <svl/whiter.hxx> |
30 | | #include <sfx2/viewsh.hxx> |
31 | | #include <sfx2/request.hxx> |
32 | | #include <sfx2/basedlgs.hxx> |
33 | | #include <vcl/InterimItemWindow.hxx> |
34 | | #include <sfx2/sfxdlg.hxx> |
35 | | #include <tools/debug.hxx> |
36 | | #include <tools/urlobj.hxx> |
37 | | |
38 | | #include <svx/dialogs.hrc> |
39 | | #include <svx/svxids.hrc> |
40 | | #include <svx/strings.hrc> |
41 | | #include <editeng/brushitem.hxx> |
42 | | #include <editeng/sizeitem.hxx> |
43 | | #include <svx/sdgcpitm.hxx> |
44 | | |
45 | | #include <svx/dialmgr.hxx> |
46 | | #include <svx/svdview.hxx> |
47 | | #include <svx/svdmodel.hxx> |
48 | | #include <svx/svdograf.hxx> |
49 | | #include <svx/svdundo.hxx> |
50 | | #include <svx/svdtrans.hxx> |
51 | | #include <svx/grafctrl.hxx> |
52 | | #include <svx/tbxcolor.hxx> |
53 | | #include <sdgcoitm.hxx> |
54 | | #include <svx/sdggaitm.hxx> |
55 | | #include <svx/sdgluitm.hxx> |
56 | | #include <svx/sdgmoitm.hxx> |
57 | | #include <sdgtritm.hxx> |
58 | | #include <bitmaps.hlst> |
59 | | |
60 | | #include <com/sun/star/frame/XDispatchProvider.hpp> |
61 | | |
62 | | using namespace ::com::sun::star::uno; |
63 | | using namespace ::com::sun::star::frame; |
64 | | using namespace ::com::sun::star::beans; |
65 | | |
66 | | constexpr OUString TOOLBOX_NAME = u"colorbar"_ustr; |
67 | 0 | #define RID_SVXSTR_UNDO_GRAFCROP RID_SVXSTR_GRAFCROP |
68 | | |
69 | | namespace { |
70 | | |
71 | | class ImplGrafControl final : public InterimItemWindow |
72 | | { |
73 | | private: |
74 | | OUString maCommand; |
75 | | Reference<XFrame> mxFrame; |
76 | | std::unique_ptr<weld::Image> mxImage; |
77 | | std::unique_ptr<weld::MetricSpinButton> mxField; |
78 | | |
79 | | DECL_LINK(ValueChangedHdl, weld::MetricSpinButton&, void); |
80 | | DECL_LINK(KeyInputHdl, const KeyEvent&, bool); |
81 | | void ImplModify(); |
82 | | |
83 | | public: |
84 | | ImplGrafControl( vcl::Window* pParent, const OUString& rCmd, const Reference< XFrame >& rFrame ); |
85 | | virtual ~ImplGrafControl() override; |
86 | | virtual void dispose() override; |
87 | | |
88 | | void Update( const SfxPoolItem* pItem ); |
89 | 0 | void set_field_text(const OUString& rStr) { mxField->set_text(rStr); } |
90 | | void set_sensitive(bool bSensitive) |
91 | 0 | { |
92 | 0 | Enable(bSensitive); |
93 | 0 | mxImage->set_sensitive(bSensitive); |
94 | 0 | mxField->set_sensitive(bSensitive); |
95 | 0 | } |
96 | | }; |
97 | | |
98 | | } |
99 | | |
100 | | IMPL_LINK_NOARG(ImplGrafControl, ValueChangedHdl, weld::MetricSpinButton&, void) |
101 | 0 | { |
102 | 0 | ImplModify(); |
103 | 0 | } |
104 | | |
105 | | void ImplGrafControl::ImplModify() |
106 | 0 | { |
107 | 0 | const sal_Int64 nVal = mxField->get_value(FieldUnit::NONE); |
108 | | |
109 | | // Convert value to an any to be usable with dispatch API |
110 | 0 | Any a; |
111 | 0 | if ( maCommand == ".uno:GrafRed" || |
112 | 0 | maCommand == ".uno:GrafGreen" || |
113 | 0 | maCommand == ".uno:GrafBlue" || |
114 | 0 | maCommand == ".uno:GrafLuminance" || |
115 | 0 | maCommand == ".uno:GrafContrast" ) |
116 | 0 | a <<= sal_Int16(std::clamp<sal_Int64>(nVal, SAL_MIN_INT16, SAL_MAX_INT16)); |
117 | 0 | else if ( maCommand == ".uno:GrafGamma" || |
118 | 0 | maCommand == ".uno:GrafTransparence" ) |
119 | 0 | a <<= sal_Int32(std::clamp<sal_Int64>(nVal, SAL_MIN_INT32, SAL_MAX_INT32)); |
120 | |
|
121 | 0 | if ( !a.hasValue() ) |
122 | 0 | return; |
123 | | |
124 | 0 | INetURLObject aObj( maCommand ); |
125 | | |
126 | | // Map command to SDI FN_PARAM_1 names where applicable; else use URL path |
127 | 0 | OUString aParamName = aObj.GetURLPath(); |
128 | 0 | if ( maCommand == ".uno:GrafLuminance" ) |
129 | 0 | aParamName = u"Brightness"_ustr; |
130 | 0 | else if ( maCommand == ".uno:GrafContrast" ) |
131 | 0 | aParamName = u"Contrast"_ustr; |
132 | 0 | else if ( maCommand == ".uno:GrafTransparence" ) |
133 | 0 | aParamName = u"Transparency"_ustr; |
134 | |
|
135 | 0 | Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(aParamName, a) }; |
136 | |
|
137 | 0 | SfxToolBoxControl::Dispatch( |
138 | 0 | Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), |
139 | 0 | maCommand, |
140 | 0 | aArgs ); |
141 | 0 | } |
142 | | |
143 | | void ImplGrafControl::Update( const SfxPoolItem* pItem ) |
144 | 0 | { |
145 | 0 | if( pItem ) |
146 | 0 | { |
147 | 0 | tools::Long nValue; |
148 | |
|
149 | 0 | if ( maCommand == ".uno:GrafTransparence" ) |
150 | 0 | nValue = static_cast<const SfxUInt16Item*>( pItem )->GetValue(); |
151 | 0 | else if ( maCommand == ".uno:GrafGamma" ) |
152 | 0 | nValue = static_cast<const SfxUInt32Item*>( pItem )->GetValue(); |
153 | 0 | else |
154 | 0 | nValue = static_cast<const SfxInt16Item*>( pItem )->GetValue(); |
155 | |
|
156 | 0 | mxField->set_value(nValue, FieldUnit::NONE); |
157 | 0 | } |
158 | 0 | else |
159 | 0 | mxField->set_text(OUString()); |
160 | 0 | } |
161 | | |
162 | | namespace { |
163 | | |
164 | | struct CommandToRID |
165 | | { |
166 | | const char* pCommand; |
167 | | OUString sResId; |
168 | | }; |
169 | | |
170 | | } |
171 | | |
172 | | static OUString ImplGetRID( std::u16string_view aCommand ) |
173 | 0 | { |
174 | 0 | static constexpr CommandToRID aImplCommandToResMap[] = |
175 | 0 | { |
176 | 0 | { ".uno:GrafRed", RID_SVXBMP_GRAF_RED }, |
177 | 0 | { ".uno:GrafGreen", RID_SVXBMP_GRAF_GREEN }, |
178 | 0 | { ".uno:GrafBlue", RID_SVXBMP_GRAF_BLUE }, |
179 | 0 | { ".uno:GrafLuminance", RID_SVXBMP_GRAF_LUMINANCE }, |
180 | 0 | { ".uno:GrafContrast", RID_SVXBMP_GRAF_CONTRAST }, |
181 | 0 | { ".uno:GrafGamma", RID_SVXBMP_GRAF_GAMMA }, |
182 | 0 | { ".uno:GrafTransparence", RID_SVXBMP_GRAF_TRANSPARENCE }, |
183 | 0 | { nullptr, EMPTY_OUSTRING } |
184 | 0 | }; |
185 | |
|
186 | 0 | OUString sRID; |
187 | |
|
188 | 0 | sal_Int32 i( 0 ); |
189 | 0 | while ( aImplCommandToResMap[ i ].pCommand ) |
190 | 0 | { |
191 | 0 | if ( o3tl::equalsAscii( aCommand, aImplCommandToResMap[ i ].pCommand )) |
192 | 0 | { |
193 | 0 | sRID = aImplCommandToResMap[i].sResId; |
194 | 0 | break; |
195 | 0 | } |
196 | 0 | ++i; |
197 | 0 | } |
198 | |
|
199 | 0 | return sRID; |
200 | 0 | } |
201 | | |
202 | | ImplGrafControl::ImplGrafControl( |
203 | | vcl::Window* pParent, |
204 | | const OUString& rCmd, |
205 | | const Reference< XFrame >& rFrame) |
206 | 0 | : InterimItemWindow(pParent, u"svx/ui/grafctrlbox.ui"_ustr, u"GrafCtrlBox"_ustr) |
207 | 0 | , maCommand(rCmd) |
208 | 0 | , mxFrame(rFrame) |
209 | 0 | , mxImage(m_xBuilder->weld_image(u"image"_ustr)) |
210 | 0 | , mxField(m_xBuilder->weld_metric_spin_button(u"spinfield"_ustr, FieldUnit::NONE)) |
211 | 0 | { |
212 | 0 | InitControlBase(&mxField->get_widget()); |
213 | |
|
214 | 0 | OUString sResId(ImplGetRID(rCmd)); |
215 | 0 | mxImage->set_from_icon_name(sResId); |
216 | 0 | mxImage->set_toolbar_background(); |
217 | |
|
218 | 0 | SetBackground( Wallpaper() ); // transparent background |
219 | |
|
220 | 0 | mxField->set_help_id(rCmd); |
221 | 0 | mxField->get_widget().connect_key_press(LINK(this, ImplGrafControl, KeyInputHdl)); |
222 | 0 | mxField->connect_value_changed(LINK(this, ImplGrafControl, ValueChangedHdl)); |
223 | |
|
224 | 0 | if (maCommand == ".uno:GrafGamma") |
225 | 0 | { |
226 | 0 | mxField->set_digits(2); |
227 | |
|
228 | 0 | mxField->set_range(10, 1000, FieldUnit::NONE); |
229 | 0 | mxField->set_increments(10, 100, FieldUnit::NONE); |
230 | 0 | } |
231 | 0 | else |
232 | 0 | { |
233 | 0 | const tools::Long nMinVal = maCommand == ".uno:GrafTransparence" ? 0 : -100; |
234 | |
|
235 | 0 | mxField->set_unit(FieldUnit::PERCENT); |
236 | 0 | mxField->set_digits(0); |
237 | |
|
238 | 0 | mxField->set_range(nMinVal, 100, FieldUnit::PERCENT); |
239 | 0 | mxField->set_increments(1, 10, FieldUnit::PERCENT); |
240 | 0 | } |
241 | |
|
242 | 0 | SetSizePixel(m_xContainer->get_preferred_size()); |
243 | 0 | } |
244 | | |
245 | | IMPL_LINK(ImplGrafControl, KeyInputHdl, const KeyEvent&, rKEvt, bool) |
246 | 0 | { |
247 | 0 | return ChildKeyInput(rKEvt); |
248 | 0 | } |
249 | | |
250 | | ImplGrafControl::~ImplGrafControl() |
251 | 0 | { |
252 | 0 | disposeOnce(); |
253 | 0 | } |
254 | | |
255 | | void ImplGrafControl::dispose() |
256 | 0 | { |
257 | 0 | mxImage.reset(); |
258 | 0 | mxField.reset(); |
259 | 0 | InterimItemWindow::dispose(); |
260 | 0 | } |
261 | | |
262 | | namespace { |
263 | | |
264 | | class ImplGrafModeControl final : public InterimItemWindow |
265 | | { |
266 | | private: |
267 | | sal_uInt16 mnCurPos; |
268 | | Reference< XFrame > mxFrame; |
269 | | std::unique_ptr<weld::ComboBox> m_xWidget; |
270 | | |
271 | | DECL_LINK(SelectHdl, weld::ComboBox&, void); |
272 | | DECL_LINK(KeyInputHdl, const KeyEvent&, bool); |
273 | | DECL_LINK(FocusInHdl, weld::Widget&, void); |
274 | | |
275 | | static void ImplReleaseFocus(); |
276 | | |
277 | | public: |
278 | | ImplGrafModeControl( vcl::Window* pParent, const Reference< XFrame >& rFrame ); |
279 | | virtual void dispose() override; |
280 | | virtual ~ImplGrafModeControl() override; |
281 | | |
282 | | void set_sensitive(bool bSensitive) |
283 | 0 | { |
284 | 0 | Enable(bSensitive); |
285 | 0 | m_xWidget->set_sensitive(true); |
286 | 0 | } |
287 | | |
288 | | void set_active(int nActive) |
289 | 0 | { |
290 | 0 | m_xWidget->set_active(nActive); |
291 | 0 | } |
292 | | |
293 | | void Update( const SfxPoolItem* pItem ); |
294 | | }; |
295 | | |
296 | | } |
297 | | |
298 | | ImplGrafModeControl::ImplGrafModeControl(vcl::Window* pParent, const Reference<XFrame>& rFrame) |
299 | 0 | : InterimItemWindow(pParent, u"svx/ui/grafmodebox.ui"_ustr, u"GrafModeBox"_ustr) |
300 | 0 | , mnCurPos(0) |
301 | 0 | , mxFrame(rFrame) |
302 | 0 | , m_xWidget(m_xBuilder->weld_combo_box(u"grafmode"_ustr)) |
303 | 0 | { |
304 | 0 | InitControlBase(m_xWidget.get()); |
305 | |
|
306 | 0 | m_xWidget->append_text( SvxResId( RID_SVXSTR_GRAFMODE_STANDARD ) ); |
307 | 0 | m_xWidget->append_text( SvxResId( RID_SVXSTR_GRAFMODE_GREYS ) ); |
308 | 0 | m_xWidget->append_text( SvxResId( RID_SVXSTR_GRAFMODE_MONO ) ); |
309 | 0 | m_xWidget->append_text( SvxResId( RID_SVXSTR_GRAFMODE_WATERMARK ) ); |
310 | |
|
311 | 0 | m_xWidget->connect_changed(LINK(this, ImplGrafModeControl, SelectHdl)); |
312 | 0 | m_xWidget->connect_key_press(LINK(this, ImplGrafModeControl, KeyInputHdl)); |
313 | 0 | m_xWidget->connect_focus_in(LINK(this, ImplGrafModeControl, FocusInHdl)); |
314 | |
|
315 | 0 | SetSizePixel(m_xWidget->get_preferred_size()); |
316 | 0 | } |
317 | | |
318 | | void ImplGrafModeControl::dispose() |
319 | 0 | { |
320 | 0 | m_xWidget.reset(); |
321 | 0 | InterimItemWindow::dispose(); |
322 | 0 | } |
323 | | |
324 | | ImplGrafModeControl::~ImplGrafModeControl() |
325 | 0 | { |
326 | 0 | disposeOnce(); |
327 | 0 | } |
328 | | |
329 | | IMPL_LINK(ImplGrafModeControl, SelectHdl, weld::ComboBox&, rBox, void) |
330 | 0 | { |
331 | 0 | Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"ColorMode"_ustr, |
332 | 0 | sal_Int16(rBox.get_active())) }; |
333 | | |
334 | | /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. |
335 | | This instance may be deleted in the meantime (i.e. when a dialog is opened |
336 | | while in Dispatch()), accessing members will crash in this case. */ |
337 | 0 | ImplReleaseFocus(); |
338 | |
|
339 | 0 | SfxToolBoxControl::Dispatch( |
340 | 0 | Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), |
341 | 0 | u".uno:GrafMode"_ustr, |
342 | 0 | aArgs ); |
343 | 0 | } |
344 | | |
345 | | IMPL_LINK(ImplGrafModeControl, KeyInputHdl, const KeyEvent&, rKEvt, bool) |
346 | 0 | { |
347 | 0 | bool bHandled(false); |
348 | |
|
349 | 0 | if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE) |
350 | 0 | { |
351 | 0 | m_xWidget->set_active(mnCurPos); |
352 | 0 | ImplReleaseFocus(); |
353 | 0 | bHandled = true; |
354 | 0 | } |
355 | |
|
356 | 0 | return bHandled || ChildKeyInput(rKEvt); |
357 | 0 | } |
358 | | |
359 | | IMPL_LINK_NOARG(ImplGrafModeControl, FocusInHdl, weld::Widget&, void) |
360 | 0 | { |
361 | 0 | mnCurPos = m_xWidget->get_active(); |
362 | 0 | } |
363 | | |
364 | | void ImplGrafModeControl::ImplReleaseFocus() |
365 | 0 | { |
366 | 0 | if (const SfxViewShell* pViewShell = SfxViewShell::Current()) |
367 | 0 | { |
368 | 0 | vcl::Window* pShellWnd = pViewShell->GetWindow(); |
369 | |
|
370 | 0 | if( pShellWnd ) |
371 | 0 | pShellWnd->GrabFocus(); |
372 | 0 | } |
373 | 0 | } |
374 | | |
375 | | void ImplGrafModeControl::Update( const SfxPoolItem* pItem ) |
376 | 0 | { |
377 | 0 | if( pItem ) |
378 | 0 | m_xWidget->set_active(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); |
379 | 0 | else |
380 | 0 | m_xWidget->set_active(-1); |
381 | 0 | } |
382 | | |
383 | | SvxGrafToolBoxControl::SvxGrafToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx) : |
384 | 0 | SfxToolBoxControl( nSlotId, nId, rTbx ) |
385 | 0 | { |
386 | 0 | rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) ); |
387 | 0 | rTbx.Invalidate(); |
388 | 0 | } |
389 | | |
390 | | SvxGrafToolBoxControl::~SvxGrafToolBoxControl() |
391 | 0 | { |
392 | 0 | } |
393 | | |
394 | | void SvxGrafToolBoxControl::StateChangedAtToolBoxControl( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) |
395 | 0 | { |
396 | 0 | ImplGrafControl* pCtrl = static_cast<ImplGrafControl*>( GetToolBox().GetItemWindow( GetId() ) ); |
397 | 0 | DBG_ASSERT( pCtrl, "Control not found" ); |
398 | |
|
399 | 0 | if( eState == SfxItemState::DISABLED ) |
400 | 0 | { |
401 | 0 | pCtrl->set_sensitive(false); |
402 | 0 | pCtrl->set_field_text( OUString() ); |
403 | 0 | } |
404 | 0 | else |
405 | 0 | { |
406 | 0 | pCtrl->set_sensitive(true); |
407 | |
|
408 | 0 | if( eState == SfxItemState::DEFAULT ) |
409 | 0 | pCtrl->Update( pState ); |
410 | 0 | else |
411 | 0 | pCtrl->Update( nullptr ); |
412 | 0 | } |
413 | 0 | } |
414 | | |
415 | | VclPtr<InterimItemWindow> SvxGrafToolBoxControl::CreateItemWindow( vcl::Window *pParent ) |
416 | 0 | { |
417 | 0 | return VclPtr<ImplGrafControl>::Create( pParent, m_aCommandURL, m_xFrame ).get(); |
418 | 0 | } |
419 | | |
420 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafRedToolBoxControl, SfxInt16Item ); |
421 | | |
422 | | SvxGrafRedToolBoxControl::SvxGrafRedToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
423 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
424 | 0 | { |
425 | 0 | } |
426 | | |
427 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGreenToolBoxControl, SfxInt16Item ); |
428 | | |
429 | | SvxGrafGreenToolBoxControl::SvxGrafGreenToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
430 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
431 | 0 | { |
432 | 0 | } |
433 | | |
434 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafBlueToolBoxControl, SfxInt16Item ); |
435 | | |
436 | | SvxGrafBlueToolBoxControl::SvxGrafBlueToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
437 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
438 | 0 | { |
439 | 0 | } |
440 | | |
441 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafLuminanceToolBoxControl, SfxInt16Item ); |
442 | | |
443 | | SvxGrafLuminanceToolBoxControl::SvxGrafLuminanceToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
444 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
445 | 0 | { |
446 | 0 | } |
447 | | |
448 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafContrastToolBoxControl, SfxInt16Item ); |
449 | | |
450 | | SvxGrafContrastToolBoxControl::SvxGrafContrastToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
451 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
452 | 0 | { |
453 | 0 | } |
454 | | |
455 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGammaToolBoxControl, SfxUInt32Item ); |
456 | | |
457 | | SvxGrafGammaToolBoxControl::SvxGrafGammaToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
458 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
459 | 0 | { |
460 | 0 | } |
461 | | |
462 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafTransparenceToolBoxControl, SfxUInt16Item ); |
463 | | |
464 | | SvxGrafTransparenceToolBoxControl::SvxGrafTransparenceToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
465 | 0 | SvxGrafToolBoxControl( nSlotId, nId, rTbx ) |
466 | 0 | { |
467 | 0 | } |
468 | | |
469 | | SFX_IMPL_TOOLBOX_CONTROL( SvxGrafModeToolBoxControl, SfxUInt16Item ); |
470 | | |
471 | | SvxGrafModeToolBoxControl::SvxGrafModeToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) : |
472 | 0 | SfxToolBoxControl( nSlotId, nId, rTbx ) |
473 | 0 | { |
474 | 0 | } |
475 | | |
476 | | SvxGrafModeToolBoxControl::~SvxGrafModeToolBoxControl() |
477 | 0 | { |
478 | 0 | } |
479 | | |
480 | | void SvxGrafModeToolBoxControl::StateChangedAtToolBoxControl( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) |
481 | | |
482 | 0 | { |
483 | 0 | ImplGrafModeControl* pCtrl = static_cast<ImplGrafModeControl*>( GetToolBox().GetItemWindow( GetId() ) ); |
484 | 0 | DBG_ASSERT( pCtrl, "Control not found" ); |
485 | |
|
486 | 0 | if( eState == SfxItemState::DISABLED ) |
487 | 0 | { |
488 | 0 | pCtrl->set_sensitive(false); |
489 | 0 | pCtrl->set_active(-1); |
490 | 0 | } |
491 | 0 | else |
492 | 0 | { |
493 | 0 | pCtrl->set_sensitive(true); |
494 | |
|
495 | 0 | if( eState == SfxItemState::DEFAULT ) |
496 | 0 | pCtrl->Update( pState ); |
497 | 0 | else |
498 | 0 | pCtrl->Update( nullptr ); |
499 | 0 | } |
500 | 0 | } |
501 | | |
502 | | VclPtr<InterimItemWindow> SvxGrafModeToolBoxControl::CreateItemWindow( vcl::Window *pParent ) |
503 | 0 | { |
504 | 0 | return VclPtr<ImplGrafModeControl>::Create( pParent, m_xFrame ).get(); |
505 | 0 | } |
506 | | |
507 | | void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) |
508 | 0 | { |
509 | 0 | SfxItemPool& rPool = rView.GetModel().GetItemPool(); |
510 | 0 | SfxItemSetFixed<SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST> aSet( rPool ); |
511 | 0 | OUString aUndoStr; |
512 | 0 | const bool bUndo = rView.IsUndoEnabled(); |
513 | |
|
514 | 0 | if( bUndo ) |
515 | 0 | { |
516 | 0 | aUndoStr = rView.GetMarkedObjectList().GetMarkDescription() + " "; |
517 | 0 | } |
518 | |
|
519 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
520 | 0 | const SfxPoolItem* pItem; |
521 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
522 | |
|
523 | 0 | if( !pArgs || SfxItemState::SET != pArgs->GetItemState( nSlot, false, &pItem )) |
524 | 0 | pItem = nullptr; |
525 | |
|
526 | 0 | switch( nSlot ) |
527 | 0 | { |
528 | 0 | case SID_ATTR_GRAF_RED: |
529 | 0 | { |
530 | 0 | if( pItem ) |
531 | 0 | { |
532 | 0 | aSet.Put( SdrGrafRedItem( static_cast<const SfxInt16Item*>(pItem)->GetValue() )); |
533 | 0 | if( bUndo ) |
534 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFRED ); |
535 | 0 | } |
536 | 0 | } |
537 | 0 | break; |
538 | | |
539 | 0 | case SID_ATTR_GRAF_GREEN: |
540 | 0 | { |
541 | 0 | if( pItem ) |
542 | 0 | { |
543 | 0 | aSet.Put( SdrGrafGreenItem( static_cast<const SfxInt16Item*>(pItem)->GetValue() )); |
544 | 0 | if( bUndo ) |
545 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFGREEN ); |
546 | 0 | } |
547 | 0 | } |
548 | 0 | break; |
549 | | |
550 | 0 | case SID_ATTR_GRAF_BLUE: |
551 | 0 | { |
552 | 0 | if( pItem ) |
553 | 0 | { |
554 | 0 | aSet.Put( SdrGrafBlueItem( static_cast<const SfxInt16Item*>(pItem)->GetValue() )); |
555 | 0 | if( bUndo ) |
556 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFBLUE ); |
557 | 0 | } |
558 | 0 | } |
559 | 0 | break; |
560 | | |
561 | 0 | case SID_ATTR_GRAF_LUMINANCE: |
562 | 0 | { |
563 | 0 | const SfxInt16Item* pBrightness = rReq.GetArg<SfxInt16Item>(FN_PARAM_1); |
564 | 0 | if (pBrightness) |
565 | 0 | aSet.Put( SdrGrafLuminanceItem( pBrightness->GetValue() ) ); |
566 | 0 | else if( pItem ) |
567 | 0 | aSet.Put( SdrGrafLuminanceItem( static_cast<const SfxInt16Item*>(pItem)->GetValue() )); |
568 | 0 | if( bUndo && (pBrightness || pItem) ) |
569 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFLUMINANCE ); |
570 | 0 | } |
571 | 0 | break; |
572 | | |
573 | 0 | case SID_ATTR_GRAF_CONTRAST: |
574 | 0 | { |
575 | 0 | const SfxInt16Item* pContrast = rReq.GetArg<SfxInt16Item>(FN_PARAM_1); |
576 | 0 | if (pContrast) |
577 | 0 | aSet.Put( SdrGrafContrastItem( pContrast->GetValue() ) ); |
578 | 0 | else if( pItem ) |
579 | 0 | aSet.Put( SdrGrafContrastItem( static_cast<const SfxInt16Item*>(pItem)->GetValue() )); |
580 | |
|
581 | 0 | if (bUndo && (pContrast || pItem)) |
582 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFCONTRAST ); |
583 | |
|
584 | 0 | } |
585 | 0 | break; |
586 | | |
587 | 0 | case SID_ATTR_GRAF_GAMMA: |
588 | 0 | { |
589 | 0 | if( pItem ) |
590 | 0 | { |
591 | 0 | aSet.Put( SdrGrafGamma100Item( static_cast<const SfxUInt32Item*>(pItem)->GetValue() )); |
592 | 0 | if( bUndo ) |
593 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFGAMMA ); |
594 | 0 | } |
595 | 0 | } |
596 | 0 | break; |
597 | | |
598 | 0 | case SID_ATTR_GRAF_TRANSPARENCE: |
599 | 0 | { |
600 | 0 | const SfxUInt16Item* pTransparency = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); |
601 | 0 | if ( pTransparency ) |
602 | 0 | aSet.Put( SdrGrafTransparenceItem( pTransparency->GetValue() )); |
603 | 0 | else if( pItem ) |
604 | 0 | aSet.Put( SdrGrafTransparenceItem( static_cast<const SfxUInt16Item*>(pItem)->GetValue() )); |
605 | 0 | if( bUndo && ( pTransparency || pItem ) ) |
606 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFTRANSPARENCY ); |
607 | 0 | } |
608 | 0 | break; |
609 | | |
610 | 0 | case SID_ATTR_GRAF_MODE: |
611 | 0 | { |
612 | 0 | const SfxUInt16Item* pMode = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); |
613 | 0 | if ( pMode ) |
614 | 0 | aSet.Put( SdrGrafModeItem( static_cast<GraphicDrawMode>( pMode->GetValue() ) ) ); |
615 | 0 | else if( pItem ) |
616 | 0 | aSet.Put( SdrGrafModeItem( static_cast<GraphicDrawMode>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()) )); |
617 | 0 | if( bUndo && ( pMode || pItem ) ) |
618 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFMODE ); |
619 | 0 | } |
620 | 0 | break; |
621 | | |
622 | 0 | case SID_ATTR_GRAF_CROP: |
623 | 0 | { |
624 | 0 | const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); |
625 | |
|
626 | 0 | if( 0 < rMarkList.GetMarkCount() ) |
627 | 0 | { |
628 | 0 | SdrGrafObj* pObj = static_cast<SdrGrafObj*>( rMarkList.GetMark( 0 )->GetMarkedSdrObj() ); |
629 | |
|
630 | 0 | if( ( pObj->GetGraphicType() != GraphicType::NONE ) && |
631 | 0 | ( pObj->GetGraphicType() != GraphicType::Default ) ) |
632 | 0 | { |
633 | 0 | SfxItemSetFixed<SDRATTR_GRAFCROP, SDRATTR_GRAFCROP> aGrfAttr( rPool ); |
634 | 0 | const MapUnit eOldMetric = rPool.GetMetric( 0 ); |
635 | |
|
636 | 0 | aGrfAttr.Put(pObj->GetMergedItemSet()); |
637 | 0 | rPool.SetDefaultMetric( MapUnit::MapTwip ); |
638 | |
|
639 | 0 | SfxItemSetFixed< |
640 | 0 | SDRATTR_GRAFCROP, SDRATTR_GRAFCROP, |
641 | 0 | SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, |
642 | 0 | SID_ATTR_GRAF_CROP, SID_ATTR_GRAF_FRMSIZE, |
643 | 0 | SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC> |
644 | 0 | aCropDlgAttr(rPool); |
645 | |
|
646 | 0 | aCropDlgAttr.Put( SvxBrushItem( pObj->GetGraphic(), GPOS_MM, SID_ATTR_GRAF_GRAPHIC ) ); |
647 | 0 | aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_PAGE_SIZE, |
648 | 0 | o3tl::convert(Size(200000, 200000), o3tl::Length::mm100, o3tl::Length::twip))); |
649 | 0 | aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_GRAF_FRMSIZE, |
650 | 0 | o3tl::convert(pObj->GetLogicRect().GetSize(), o3tl::Length::mm100, o3tl::Length::twip))); |
651 | |
|
652 | 0 | const SdrGrafCropItem& rCrop = aGrfAttr.Get( SDRATTR_GRAFCROP ); |
653 | 0 | Size aLTSize = o3tl::convert(Size(rCrop.GetLeft(), rCrop.GetTop()), o3tl::Length::mm100, o3tl::Length::twip); |
654 | 0 | Size aRBSize = o3tl::convert(Size(rCrop.GetRight(), rCrop.GetBottom()), o3tl::Length::mm100, o3tl::Length::twip); |
655 | |
|
656 | 0 | aCropDlgAttr.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(), |
657 | 0 | aRBSize.Width(), aRBSize.Height() ) ); |
658 | |
|
659 | 0 | SfxViewShell* pCurrentSh = SfxViewShell::Current(); |
660 | 0 | vcl::Window* pParent(pCurrentSh ? pCurrentSh->GetWindow() : nullptr); |
661 | 0 | SfxSingleTabDialogController aCropDialog(pParent ? pParent->GetFrameWeld() : nullptr, |
662 | 0 | &aCropDlgAttr); |
663 | 0 | const OUString aCropStr(SvxResId(RID_SVXSTR_GRAFCROP)); |
664 | |
|
665 | 0 | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); |
666 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP ); |
667 | 0 | std::unique_ptr<SfxTabPage> xTabPage = (*fnCreatePage)(aCropDialog.get_content_area(), &aCropDialog, &aCropDlgAttr); |
668 | 0 | sal_Int32 nPreferredDPI = rView.getSdrModelFromSdrView().getImagePreferredDPI(); |
669 | 0 | xTabPage->getAdditionalProperties().emplace("PreferredDPI", css::uno::Any(nPreferredDPI)); |
670 | 0 | xTabPage->SetPageTitle(aCropStr); |
671 | 0 | aCropDialog.SetTabPage(std::move(xTabPage)); |
672 | |
|
673 | 0 | if (aCropDialog.run() == RET_OK) |
674 | 0 | { |
675 | 0 | const SfxItemSet* pOutAttr = aCropDialog.GetOutputItemSet(); |
676 | |
|
677 | 0 | if( pOutAttr ) |
678 | 0 | { |
679 | 0 | aUndoStr += SvxResId( RID_SVXSTR_UNDO_GRAFCROP ); |
680 | | |
681 | | // set crop attributes |
682 | 0 | if( SfxItemState::SET <= pOutAttr->GetItemState( SDRATTR_GRAFCROP ) ) |
683 | 0 | { |
684 | 0 | const SdrGrafCropItem& rNewCrop = pOutAttr->Get( SDRATTR_GRAFCROP ); |
685 | |
|
686 | 0 | aLTSize = o3tl::convert(Size(rNewCrop.GetLeft(), rNewCrop.GetTop()), o3tl::Length::twip, o3tl::Length::mm100); |
687 | 0 | aRBSize = o3tl::convert(Size(rNewCrop.GetRight(), rNewCrop.GetBottom()), o3tl::Length::twip, o3tl::Length::mm100); |
688 | 0 | aSet.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(), aRBSize.Width(), aRBSize.Height() ) ); |
689 | 0 | } |
690 | | |
691 | | // set new logic rect |
692 | 0 | if( SfxItemState::SET <= pOutAttr->GetItemState( SID_ATTR_GRAF_FRMSIZE ) ) |
693 | 0 | { |
694 | 0 | Point aNewOrigin( pObj->GetLogicRect().TopLeft() ); |
695 | 0 | const Size& rGrfSize = pOutAttr->Get( SID_ATTR_GRAF_FRMSIZE ).GetSize(); |
696 | 0 | Size aNewGrfSize = o3tl::convert(rGrfSize, o3tl::Length::twip, o3tl::Length::mm100); |
697 | 0 | Size aOldGrfSize( pObj->GetLogicRect().GetSize() ); |
698 | |
|
699 | 0 | tools::Rectangle aNewRect( aNewOrigin, aNewGrfSize ); |
700 | 0 | Point aOffset( (aNewGrfSize.Width() - aOldGrfSize.Width()) >> 1, |
701 | 0 | (aNewGrfSize.Height() - aOldGrfSize.Height()) >> 1 ); |
702 | | |
703 | | // #106181# rotate snap rect before setting it |
704 | 0 | const GeoStat& aGeo = pObj->GetGeoStat(); |
705 | |
|
706 | 0 | if (aGeo.m_nRotationAngle || aGeo.m_nShearAngle) |
707 | 0 | { |
708 | 0 | tools::Polygon aPol(aNewRect); |
709 | | |
710 | | // also transform origin offset |
711 | 0 | if (aGeo.m_nShearAngle) |
712 | 0 | { |
713 | 0 | ShearPoly(aPol, |
714 | 0 | aNewRect.TopLeft(), |
715 | 0 | aGeo.mfTanShearAngle); |
716 | 0 | ShearPoint(aOffset, Point(0,0), aGeo.mfTanShearAngle); |
717 | 0 | } |
718 | 0 | if (aGeo.m_nRotationAngle) |
719 | 0 | { |
720 | 0 | RotatePoly(aPol, |
721 | 0 | aNewRect.TopLeft(), |
722 | 0 | aGeo.mfSinRotationAngle,aGeo.mfCosRotationAngle); |
723 | 0 | RotatePoint(aOffset, Point(0,0), aGeo.mfSinRotationAngle,aGeo.mfCosRotationAngle); |
724 | 0 | } |
725 | | |
726 | | // apply offset |
727 | 0 | aPol.Move( -aOffset.X(), -aOffset.Y() ); |
728 | 0 | aNewRect=aPol.GetBoundRect(); |
729 | 0 | } |
730 | 0 | else |
731 | 0 | { |
732 | 0 | aNewRect.Move( -aOffset.X(), -aOffset.Y() ); |
733 | 0 | } |
734 | |
|
735 | 0 | if( !aSet.Count() ) |
736 | 0 | rView.SetMarkedObjRect( aNewRect ); |
737 | 0 | else |
738 | 0 | { |
739 | 0 | if( bUndo ) |
740 | 0 | { |
741 | 0 | rView.BegUndo( aUndoStr ); |
742 | 0 | rView.AddUndo(rView.GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); |
743 | 0 | } |
744 | 0 | pObj->SetSnapRect( aNewRect ); |
745 | 0 | rView.SetAttributes( aSet ); |
746 | |
|
747 | 0 | if( bUndo ) |
748 | 0 | rView.EndUndo(); |
749 | 0 | aSet.ClearItem(); |
750 | 0 | } |
751 | 0 | } |
752 | 0 | } |
753 | 0 | } |
754 | |
|
755 | 0 | rPool.SetDefaultMetric( eOldMetric ); |
756 | 0 | } |
757 | 0 | } |
758 | 0 | } |
759 | 0 | break; |
760 | | |
761 | 0 | case SID_COLOR_SETTINGS: |
762 | 0 | { |
763 | 0 | svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); |
764 | 0 | aToolboxAccess.toggleToolbox(); |
765 | 0 | rReq.Done(); |
766 | 0 | break; |
767 | 0 | } |
768 | | |
769 | 0 | default: |
770 | 0 | break; |
771 | 0 | } |
772 | | |
773 | 0 | if( aSet.Count() ) |
774 | 0 | { |
775 | 0 | if( bUndo ) |
776 | 0 | rView.BegUndo( aUndoStr ); |
777 | |
|
778 | 0 | rView.SetAttributes( aSet ); |
779 | |
|
780 | 0 | if( bUndo ) |
781 | 0 | rView.EndUndo(); |
782 | 0 | } |
783 | 0 | } |
784 | | |
785 | | void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView const & rView ) |
786 | 0 | { |
787 | 0 | SfxItemPool& rPool = rView.GetModel().GetItemPool(); |
788 | 0 | SfxItemSet aAttrSet( rPool ); |
789 | 0 | SfxWhichIter aIter( rSet ); |
790 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
791 | 0 | const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); |
792 | 0 | bool bEnableColors = true; |
793 | 0 | bool bEnableTransparency = true; |
794 | 0 | bool bEnableCrop = ( 1 == rMarkList.GetMarkCount() ); |
795 | |
|
796 | 0 | for( size_t i = 0, nCount = rMarkList.GetMarkCount(); i < nCount; ++i ) |
797 | 0 | { |
798 | 0 | SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( i )->GetMarkedSdrObj() ); |
799 | |
|
800 | 0 | if( !pGrafObj || |
801 | 0 | ( pGrafObj->GetGraphicType() == GraphicType::NONE ) || |
802 | 0 | ( pGrafObj->GetGraphicType() == GraphicType::Default )) |
803 | 0 | { |
804 | 0 | bEnableColors = bEnableTransparency = bEnableCrop = false; |
805 | 0 | break; |
806 | 0 | } |
807 | 0 | else if( bEnableTransparency && ( pGrafObj->HasGDIMetaFile() || pGrafObj->IsAnimated() ) ) |
808 | 0 | { |
809 | 0 | bEnableTransparency = false; |
810 | 0 | } |
811 | 0 | } |
812 | |
|
813 | 0 | rView.GetAttributes( aAttrSet ); |
814 | |
|
815 | 0 | while( nWhich ) |
816 | 0 | { |
817 | 0 | sal_uInt16 nSlotId = SfxItemPool::IsWhich( nWhich ) ? rPool.GetSlotId( nWhich ) : nWhich; |
818 | |
|
819 | 0 | switch( nSlotId ) |
820 | 0 | { |
821 | 0 | case SID_ATTR_GRAF_MODE: |
822 | 0 | { |
823 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) ) |
824 | 0 | { |
825 | 0 | if( bEnableColors ) |
826 | 0 | { |
827 | 0 | rSet.Put( SfxUInt16Item( nSlotId, |
828 | 0 | sal::static_int_cast< sal_uInt16 >( aAttrSet.Get(SDRATTR_GRAFMODE).GetValue() ) ) ); |
829 | 0 | } |
830 | 0 | else |
831 | 0 | { |
832 | 0 | rSet.DisableItem( SID_ATTR_GRAF_MODE ); |
833 | 0 | } |
834 | 0 | } |
835 | 0 | } |
836 | 0 | break; |
837 | | |
838 | 0 | case SID_ATTR_GRAF_RED: |
839 | 0 | { |
840 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) ) |
841 | 0 | { |
842 | 0 | if( bEnableColors ) |
843 | 0 | { |
844 | 0 | rSet.Put( SfxInt16Item( nSlotId, aAttrSet.Get(SDRATTR_GRAFRED).GetValue() ) ); |
845 | 0 | } |
846 | 0 | else |
847 | 0 | { |
848 | 0 | rSet.DisableItem( SID_ATTR_GRAF_RED ); |
849 | 0 | } |
850 | 0 | } |
851 | 0 | } |
852 | 0 | break; |
853 | | |
854 | 0 | case SID_ATTR_GRAF_GREEN: |
855 | 0 | { |
856 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) ) |
857 | 0 | { |
858 | 0 | if( bEnableColors ) |
859 | 0 | { |
860 | 0 | rSet.Put( SfxInt16Item( nSlotId, aAttrSet.Get(SDRATTR_GRAFGREEN).GetValue()) ); |
861 | 0 | } |
862 | 0 | else |
863 | 0 | { |
864 | 0 | rSet.DisableItem( SID_ATTR_GRAF_GREEN ); |
865 | 0 | } |
866 | 0 | } |
867 | 0 | } |
868 | 0 | break; |
869 | | |
870 | 0 | case SID_ATTR_GRAF_BLUE: |
871 | 0 | { |
872 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) ) |
873 | 0 | { |
874 | 0 | if( bEnableColors ) |
875 | 0 | { |
876 | 0 | rSet.Put( SfxInt16Item( nSlotId, aAttrSet.Get(SDRATTR_GRAFBLUE).GetValue()) ); |
877 | 0 | } |
878 | 0 | else |
879 | 0 | { |
880 | 0 | rSet.DisableItem( SID_ATTR_GRAF_BLUE ); |
881 | 0 | } |
882 | 0 | } |
883 | 0 | } |
884 | 0 | break; |
885 | | |
886 | 0 | case SID_ATTR_GRAF_LUMINANCE: |
887 | 0 | { |
888 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) ) |
889 | 0 | { |
890 | 0 | if( bEnableColors ) |
891 | 0 | { |
892 | 0 | rSet.Put( SfxInt16Item( nSlotId, aAttrSet.Get(SDRATTR_GRAFLUMINANCE).GetValue()) ); |
893 | 0 | } |
894 | 0 | else |
895 | 0 | { |
896 | 0 | rSet.DisableItem( SID_ATTR_GRAF_LUMINANCE ); |
897 | 0 | } |
898 | 0 | } |
899 | 0 | } |
900 | 0 | break; |
901 | | |
902 | 0 | case SID_ATTR_GRAF_CONTRAST: |
903 | 0 | { |
904 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) ) |
905 | 0 | { |
906 | 0 | if( bEnableColors ) |
907 | 0 | { |
908 | 0 | rSet.Put( SfxInt16Item( nSlotId, |
909 | 0 | aAttrSet.Get(SDRATTR_GRAFCONTRAST).GetValue()) ); |
910 | 0 | } |
911 | 0 | else |
912 | 0 | { |
913 | 0 | rSet.DisableItem( SID_ATTR_GRAF_CONTRAST ); |
914 | 0 | } |
915 | 0 | } |
916 | 0 | } |
917 | 0 | break; |
918 | | |
919 | 0 | case SID_ATTR_GRAF_GAMMA: |
920 | 0 | { |
921 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) ) |
922 | 0 | { |
923 | 0 | if( bEnableColors ) |
924 | 0 | { |
925 | 0 | rSet.Put( SfxUInt32Item( nSlotId, |
926 | 0 | aAttrSet.Get(SDRATTR_GRAFGAMMA).GetValue() ) ); |
927 | 0 | } |
928 | 0 | else |
929 | 0 | { |
930 | 0 | rSet.DisableItem( SID_ATTR_GRAF_GAMMA ); |
931 | 0 | } |
932 | 0 | } |
933 | 0 | } |
934 | 0 | break; |
935 | | |
936 | 0 | case SID_ATTR_GRAF_TRANSPARENCE: |
937 | 0 | { |
938 | 0 | if( SfxItemState::DEFAULT <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) ) |
939 | 0 | { |
940 | 0 | if( bEnableTransparency ) |
941 | 0 | { |
942 | 0 | rSet.Put( SfxUInt16Item( nSlotId, |
943 | 0 | aAttrSet.Get(SDRATTR_GRAFTRANSPARENCE).GetValue() ) ); |
944 | 0 | } |
945 | 0 | else |
946 | 0 | { |
947 | 0 | rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE ); |
948 | 0 | } |
949 | 0 | } |
950 | 0 | } |
951 | 0 | break; |
952 | | |
953 | 0 | case SID_ATTR_GRAF_CROP: |
954 | 0 | { |
955 | 0 | if( !bEnableCrop ) |
956 | 0 | rSet.DisableItem( nSlotId ); |
957 | 0 | } |
958 | 0 | break; |
959 | | |
960 | 0 | case SID_COLOR_SETTINGS : |
961 | 0 | { |
962 | 0 | svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME ); |
963 | 0 | rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) ); |
964 | 0 | break; |
965 | 0 | } |
966 | | |
967 | 0 | default: |
968 | 0 | break; |
969 | 0 | } |
970 | | |
971 | 0 | nWhich = aIter.NextWhich(); |
972 | 0 | } |
973 | 0 | } |
974 | | |
975 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |