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 <vcl/toolbox.hxx>
33 : : #include <vcl/field.hxx>
34 : : #include <vcl/fixed.hxx>
35 : : #include <vcl/msgbox.hxx>
36 : : #include <svl/intitem.hxx>
37 : : #include <svl/eitem.hxx>
38 : : #include <svl/whiter.hxx>
39 : : #include <sfx2/app.hxx>
40 : : #include <sfx2/dispatch.hxx>
41 : : #include <sfx2/objsh.hxx>
42 : : #include <sfx2/viewsh.hxx>
43 : : #include <sfx2/request.hxx>
44 : : #include <sfx2/basedlgs.hxx>
45 : : #include <tools/urlobj.hxx>
46 : : #include <comphelper/processfactory.hxx>
47 : :
48 : : #include <svx/svxids.hrc>
49 : : #include "grafctrl.hrc"
50 : : #include <svx/dialogs.hrc>
51 : : #include <editeng/brshitem.hxx>
52 : : #include <editeng/sizeitem.hxx>
53 : : #include <svx/sdgcpitm.hxx>
54 : :
55 : : #include <svx/itemwin.hxx>
56 : : #include <svx/dialmgr.hxx>
57 : : #include <svx/svdview.hxx>
58 : : #include <svx/svdmodel.hxx>
59 : : #include <svx/svdograf.hxx>
60 : : #include <svx/svdundo.hxx>
61 : : #include <svx/svdtrans.hxx>
62 : : #include "svx/grafctrl.hxx"
63 : : #include "svx/tbxcolor.hxx"
64 : :
65 : : // namespaces
66 : : using ::rtl::OUString;
67 : : using namespace ::com::sun::star::uno;
68 : : using namespace ::com::sun::star::frame;
69 : : using namespace ::com::sun::star::util;
70 : : using namespace ::com::sun::star::beans;
71 : : using namespace ::com::sun::star::lang;
72 : :
73 : : #include <svx/svxdlg.hxx>
74 : : // -----------
75 : : // - Defines -
76 : : // -----------
77 : :
78 : : #define SYMBOL_TO_FIELD_OFFSET 4
79 : : #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
80 : : #define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) )
81 : :
82 : : // ----------------
83 : : // - TbxImageItem -
84 : : // ----------------
85 : :
86 [ + + ][ - + ]: 24589 : TYPEINIT1_AUTOFACTORY( TbxImageItem, SfxUInt16Item );
[ + - ]
87 : :
88 : : //---------------------------------------------------------
89 : :
90 : 154689 : TbxImageItem::TbxImageItem( sal_uInt16 _nWhich, sal_uInt16 nImage ) :
91 : 154689 : SfxUInt16Item( _nWhich, nImage )
92 : : {
93 : 154689 : }
94 : :
95 : : //---------------------------------------------------------
96 : :
97 : 4541 : SfxPoolItem* TbxImageItem::Clone( SfxItemPool* ) const
98 : : {
99 [ + - ]: 4541 : return new TbxImageItem( *this );
100 : : }
101 : :
102 : : //---------------------------------------------------------
103 : :
104 : 1919 : int TbxImageItem::operator==( const SfxPoolItem& rItem ) const
105 : : {
106 : 1919 : return( ( (TbxImageItem&) rItem ).GetValue() == GetValue() );
107 : : }
108 : :
109 : : // -----------------------
110 : : // - ImplGrafMetricField -
111 : : // -----------------------
112 : :
113 : : class ImplGrafMetricField : public MetricField
114 : : {
115 : : using Window::Update;
116 : :
117 : : private:
118 : : Timer maTimer;
119 : : OUString maCommand;
120 : : Reference< XFrame > mxFrame;
121 : :
122 : : DECL_LINK(ImplModifyHdl, void *);
123 : :
124 : : protected:
125 : :
126 : : virtual void Modify();
127 : :
128 : : public:
129 : :
130 : : ImplGrafMetricField( Window* pParent, const rtl::OUString& aCmd, const Reference< XFrame >& rFrame );
131 : : ~ImplGrafMetricField();
132 : :
133 : : void Update( const SfxPoolItem* pItem );
134 : : const OUString& GetCommand() const { return maCommand; }
135 : : };
136 : :
137 : : // -----------------------------------------------------------------------------
138 : :
139 : 0 : ImplGrafMetricField::ImplGrafMetricField( Window* pParent, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame ) :
140 : : MetricField( pParent, WB_BORDER | WB_SPIN | WB_REPEAT | WB_3DLOOK ),
141 : : maCommand( rCmd ),
142 [ # # ]: 0 : mxFrame( rFrame )
143 : : {
144 [ # # ][ # # ]: 0 : Size aSize( GetTextWidth( rtl::OUString("-100 %") ), GetTextHeight() );
[ # # ][ # # ]
145 : :
146 : 0 : aSize.Width() += 20, aSize.Height() += 6;
147 [ # # ]: 0 : SetSizePixel( aSize );
148 : :
149 [ # # ]: 0 : if ( maCommand == ".uno:GrafGamma" )
150 : : {
151 [ # # ]: 0 : SetDecimalDigits( 2 );
152 : :
153 [ # # ]: 0 : SetMin( 10 );
154 [ # # ]: 0 : SetFirst( 10 );
155 [ # # ]: 0 : SetMax( 1000 );
156 [ # # ]: 0 : SetLast( 1000 );
157 : 0 : SetSpinSize( 10 );
158 : : }
159 : : else
160 : : {
161 [ # # ]: 0 : const long nMinVal = ( maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafTransparence" ) )) ? 0 : -100;
162 : :
163 [ # # ]: 0 : SetUnit( FUNIT_CUSTOM );
164 [ # # ][ # # ]: 0 : SetCustomUnitText( rtl::OUString(" %") );
[ # # ]
165 [ # # ]: 0 : SetDecimalDigits( 0 );
166 : :
167 [ # # ]: 0 : SetMin( nMinVal );
168 [ # # ]: 0 : SetFirst( nMinVal );
169 [ # # ]: 0 : SetMax( 100 );
170 [ # # ]: 0 : SetLast( 100 );
171 : 0 : SetSpinSize( 1 );
172 : : }
173 : :
174 [ # # ]: 0 : maTimer.SetTimeout( 100 );
175 [ # # ]: 0 : maTimer.SetTimeoutHdl( LINK( this, ImplGrafMetricField, ImplModifyHdl ) );
176 : 0 : }
177 : :
178 : : // -----------------------------------------------------------------------------
179 : :
180 [ # # ]: 0 : ImplGrafMetricField::~ImplGrafMetricField()
181 : : {
182 [ # # ]: 0 : }
183 : :
184 : : // -----------------------------------------------------------------------------
185 : :
186 : 0 : void ImplGrafMetricField::Modify()
187 : : {
188 : 0 : maTimer.Start();
189 : 0 : }
190 : :
191 : : // -----------------------------------------------------------------------------
192 : :
193 : 0 : IMPL_LINK_NOARG(ImplGrafMetricField, ImplModifyHdl)
194 : : {
195 [ # # ]: 0 : const sal_Int64 nVal = GetValue();
196 : :
197 : : // Convert value to an any to be usable with dispatch API
198 : 0 : Any a;
199 [ # # ][ # # : 0 : if ( maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafRed" ) ) ||
# # # # #
# # # ]
200 : 0 : maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafGreen" ) ) ||
201 : 0 : maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafBlue" ) ) ||
202 : 0 : maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafLuminance" ) ) ||
203 : 0 : maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafContrast" ) ))
204 [ # # ]: 0 : a = makeAny( sal_Int16( nVal ));
205 [ # # # # ]: 0 : else if ( maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafGamma" ) ) ||
[ # # ]
206 : 0 : maCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GrafTransparence" ) ))
207 [ # # ]: 0 : a = makeAny( sal_Int32( nVal ));
208 : :
209 [ # # ]: 0 : if ( a.hasValue() )
210 : : {
211 [ # # ]: 0 : INetURLObject aObj( maCommand );
212 : :
213 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
214 [ # # ][ # # ]: 0 : aArgs[0].Name = aObj.GetURLPath();
215 [ # # ]: 0 : aArgs[0].Value = a;
216 : :
217 : : SfxToolBoxControl::Dispatch(
218 [ # # ]: 0 : Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
219 : : maCommand,
220 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
[ # # ]
221 : : }
222 : 0 : return 0L;
223 : : }
224 : :
225 : : // -----------------------------------------------------------------------------
226 : :
227 : 0 : void ImplGrafMetricField::Update( const SfxPoolItem* pItem )
228 : : {
229 [ # # ]: 0 : if( pItem )
230 : : {
231 : : long nValue;
232 : :
233 [ # # ]: 0 : if ( maCommand == ".uno:GrafTransparence" )
234 : 0 : nValue = ( (SfxUInt16Item*) pItem )->GetValue();
235 [ # # ]: 0 : else if ( maCommand == ".uno:GrafGamma" )
236 : 0 : nValue = ( (SfxUInt32Item*) pItem )->GetValue();
237 : : else
238 : 0 : nValue = ( (SfxInt16Item*) pItem )->GetValue();
239 : :
240 : 0 : SetValue( nValue );
241 : : }
242 : : else
243 [ # # ]: 0 : SetText( String() );
244 : 0 : }
245 : :
246 : : // --------------------
247 : : // - ImplGrafControl -
248 : : // --------------------
249 : :
250 : : struct CommandToRID
251 : : {
252 : : const char* pCommand;
253 : : sal_uInt16 nResId;
254 : : };
255 : :
256 : 0 : static sal_uInt16 ImplGetRID( const OUString& aCommand )
257 : : {
258 : : static const CommandToRID aImplCommandToResMap[] =
259 : : {
260 : : { ".uno:GrafRed", RID_SVXIMG_GRAF_RED },
261 : : { ".uno:GrafGreen", RID_SVXIMG_GRAF_GREEN },
262 : : { ".uno:GrafBlue", RID_SVXIMG_GRAF_BLUE },
263 : : { ".uno:GrafLuminance", RID_SVXIMG_GRAF_LUMINANCE },
264 : : { ".uno:GrafContrast", RID_SVXIMG_GRAF_CONTRAST },
265 : : { ".uno:GrafGamma", RID_SVXIMG_GRAF_GAMMA },
266 : : { ".uno:GrafTransparence", RID_SVXIMG_GRAF_TRANSPARENCE },
267 : : { 0, 0 }
268 : : };
269 : :
270 : 0 : sal_uInt16 nRID = 0;
271 : :
272 : 0 : sal_Int32 i( 0 );
273 [ # # ]: 0 : while ( aImplCommandToResMap[ i ].pCommand )
274 : : {
275 [ # # ]: 0 : if ( aCommand.equalsAscii( aImplCommandToResMap[ i ].pCommand ))
276 : : {
277 : 0 : nRID = aImplCommandToResMap[ i ].nResId;
278 : 0 : break;
279 : : }
280 : 0 : ++i;
281 : : }
282 : :
283 : 0 : return nRID;
284 : : }
285 : :
286 : : // -----------------------------------------------------------------------------
287 : :
288 : : class ImplGrafControl : public Control
289 : : {
290 : : using Window::Update;
291 : : private:
292 : : FixedImage maImage;
293 : : ImplGrafMetricField maField;
294 : :
295 : : protected:
296 : :
297 : : virtual void GetFocus();
298 : :
299 : : public:
300 : :
301 : : ImplGrafControl( Window* pParent, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame );
302 : : ~ImplGrafControl();
303 : :
304 : 0 : void Update( const SfxPoolItem* pItem ) { maField.Update( pItem ); }
305 : 0 : void SetText( const String& rStr ) { maField.SetText( rStr ); }
306 : : };
307 : :
308 : : // -----------------------------------------------------------------------------
309 : :
310 : 0 : ImplGrafControl::ImplGrafControl(
311 : : Window* pParent,
312 : : const rtl::OUString& rCmd,
313 : : const Reference< XFrame >& rFrame
314 : : ) : Control( pParent, WB_TABSTOP )
315 : : , maImage( this )
316 [ # # ][ # # ]: 0 : , maField( this, rCmd, rFrame )
317 : : {
318 [ # # ]: 0 : ResId aResId( ImplGetRID( rCmd ), DIALOG_MGR() ) ;
319 [ # # ]: 0 : Image aImage( aResId );
320 : :
321 [ # # ]: 0 : Size aImgSize( aImage.GetSizePixel() );
322 [ # # ]: 0 : Size aFldSize( maField.GetSizePixel() );
323 : : long nFldY, nImgY;
324 : :
325 [ # # ]: 0 : maImage.SetImage( aImage );
326 [ # # ]: 0 : maImage.SetSizePixel( aImgSize );
327 : : // we want to see the backbround of the toolbox, not of the FixedImage or Control
328 [ # # ][ # # ]: 0 : maImage.SetBackground( Wallpaper( COL_TRANSPARENT ) );
[ # # ]
329 [ # # ][ # # ]: 0 : SetBackground( Wallpaper( COL_TRANSPARENT ) );
[ # # ]
330 : :
331 [ # # ]: 0 : if( aImgSize.Height() > aFldSize.Height() )
332 : 0 : nImgY = 0, nFldY = ( aImgSize.Height() - aFldSize.Height() ) >> 1;
333 : : else
334 : 0 : nFldY = 0, nImgY = ( aFldSize.Height() - aImgSize.Height() ) >> 1;
335 : :
336 : 0 : long nOffset = SYMBOL_TO_FIELD_OFFSET / 2;
337 [ # # ]: 0 : maImage.SetPosPixel( Point( nOffset, nImgY ) );
338 [ # # ]: 0 : maField.SetPosPixel( Point( aImgSize.Width() + SYMBOL_TO_FIELD_OFFSET, nFldY ) );
339 : 0 : SetSizePixel( Size( aImgSize.Width() + aFldSize.Width() + SYMBOL_TO_FIELD_OFFSET + nOffset,
340 [ # # ]: 0 : Max( aImgSize.Height(), aFldSize.Height() ) ) );
341 : :
342 [ # # ][ # # ]: 0 : SetBackground( Wallpaper() ); // transparent background
[ # # ]
343 : :
344 [ # # ]: 0 : maImage.Show();
345 : :
346 [ # # ][ # # ]: 0 : maField.SetHelpId( rtl::OUStringToOString( rCmd, RTL_TEXTENCODING_UTF8 ) );
347 [ # # ][ # # ]: 0 : maField.Show();
348 : 0 : }
349 : :
350 : : // -----------------------------------------------------------------------------
351 : :
352 [ # # ][ # # ]: 0 : ImplGrafControl::~ImplGrafControl()
353 : : {
354 [ # # ]: 0 : }
355 : :
356 : : // -----------------------------------------------------------------------------
357 : :
358 : 0 : void ImplGrafControl::GetFocus()
359 : : {
360 : 0 : maField.GrabFocus();
361 : 0 : }
362 : :
363 : : // -----------------------
364 : : // - ImplGrafModeControl -
365 : : // -----------------------
366 : :
367 : : class ImplGrafModeControl : public ListBox
368 : : {
369 : : using Window::Update;
370 : : private:
371 : : sal_uInt16 mnCurPos;
372 : : Reference< XFrame > mxFrame;
373 : :
374 : : virtual void Select();
375 : : virtual long PreNotify( NotifyEvent& rNEvt );
376 : : virtual long Notify( NotifyEvent& rNEvt );
377 : : void ImplReleaseFocus();
378 : :
379 : : public:
380 : :
381 : : ImplGrafModeControl( Window* pParent, const Reference< XFrame >& rFrame );
382 : : ~ImplGrafModeControl();
383 : :
384 : : void Update( const SfxPoolItem* pItem );
385 : : };
386 : :
387 : : // -----------------------------------------------------------------------------
388 : :
389 : 0 : ImplGrafModeControl::ImplGrafModeControl( Window* pParent, const Reference< XFrame >& rFrame ) :
390 : : ListBox( pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL ),
391 : : mnCurPos( 0 ),
392 : 0 : mxFrame( rFrame )
393 : : {
394 [ # # ]: 0 : SetSizePixel( Size( 100, 260 ) );
395 : :
396 [ # # ][ # # ]: 0 : InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_STANDARD ) );
[ # # ][ # # ]
[ # # ]
397 [ # # ][ # # ]: 0 : InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_GREYS ) );
[ # # ][ # # ]
[ # # ]
398 [ # # ][ # # ]: 0 : InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_MONO ) );
[ # # ][ # # ]
[ # # ]
399 [ # # ][ # # ]: 0 : InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_WATERMARK ) );
[ # # ][ # # ]
[ # # ]
400 : :
401 [ # # ]: 0 : Show();
402 : 0 : }
403 : :
404 : : // -----------------------------------------------------------------------
405 : :
406 : 0 : ImplGrafModeControl::~ImplGrafModeControl()
407 : : {
408 [ # # ]: 0 : }
409 : :
410 : : // -----------------------------------------------------------------------
411 : :
412 : 0 : void ImplGrafModeControl::Select()
413 : : {
414 [ # # ]: 0 : if ( !IsTravelSelect() )
415 : : {
416 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
417 [ # # ][ # # ]: 0 : aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GrafMode" ));
418 [ # # ][ # # ]: 0 : aArgs[0].Value = makeAny( sal_Int16( GetSelectEntryPos() ));
[ # # ]
419 : :
420 : : /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
421 : : This instance may be deleted in the meantime (i.e. when a dialog is opened
422 : : while in Dispatch()), accessing members will crash in this case. */
423 [ # # ]: 0 : ImplReleaseFocus();
424 : :
425 : : SfxToolBoxControl::Dispatch(
426 [ # # ]: 0 : Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
427 : : OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GrafMode" )),
428 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
[ # # ]
429 : : }
430 : 0 : }
431 : :
432 : : // -----------------------------------------------------------------------
433 : :
434 : 0 : long ImplGrafModeControl::PreNotify( NotifyEvent& rNEvt )
435 : : {
436 : 0 : sal_uInt16 nType = rNEvt.GetType();
437 : :
438 [ # # ][ # # ]: 0 : if( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
439 : 0 : mnCurPos = GetSelectEntryPos();
440 : :
441 : 0 : return ListBox::PreNotify( rNEvt );
442 : : }
443 : :
444 : : // -----------------------------------------------------------------------
445 : :
446 : 0 : long ImplGrafModeControl::Notify( NotifyEvent& rNEvt )
447 : : {
448 : 0 : long nHandled = ListBox::Notify( rNEvt );
449 : :
450 [ # # ]: 0 : if( rNEvt.GetType() == EVENT_KEYINPUT )
451 : : {
452 : 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
453 : :
454 [ # # # ]: 0 : switch( pKEvt->GetKeyCode().GetCode() )
455 : : {
456 : : case KEY_RETURN:
457 : : {
458 : 0 : Select();
459 : 0 : nHandled = 1;
460 : : }
461 : 0 : break;
462 : :
463 : : case KEY_ESCAPE:
464 : : {
465 : 0 : SelectEntryPos( mnCurPos );
466 : 0 : ImplReleaseFocus();
467 : 0 : nHandled = 1;
468 : : }
469 : 0 : break;
470 : : }
471 : : }
472 : :
473 : 0 : return nHandled;
474 : : }
475 : :
476 : : // -----------------------------------------------------------------------
477 : :
478 : 0 : void ImplGrafModeControl::ImplReleaseFocus()
479 : : {
480 [ # # ]: 0 : if( SfxViewShell::Current() )
481 : : {
482 : 0 : Window* pShellWnd = SfxViewShell::Current()->GetWindow();
483 : :
484 [ # # ]: 0 : if( pShellWnd )
485 : 0 : pShellWnd->GrabFocus();
486 : : }
487 : 0 : }
488 : :
489 : : // -----------------------------------------------------------------------
490 : :
491 : 0 : void ImplGrafModeControl::Update( const SfxPoolItem* pItem )
492 : : {
493 [ # # ]: 0 : if( pItem )
494 : 0 : SelectEntryPos( ((SfxUInt16Item*)pItem)->GetValue() );
495 : : else
496 : 0 : SetNoSelection();
497 : 0 : }
498 : :
499 : : // -------------------------------
500 : : // - SvxGrafFilterToolBoxControl -
501 : : // -------------------------------
502 : :
503 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafFilterToolBoxControl, TbxImageItem );
504 : :
505 : : // -----------------------------------------------------------------------------
506 : :
507 : 0 : SvxGrafFilterToolBoxControl::SvxGrafFilterToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
508 : 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
509 : : {
510 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
511 [ # # ]: 0 : rTbx.Invalidate();
512 : 0 : }
513 : :
514 : : // -----------------------------------------------------------------------------
515 : :
516 : 0 : SvxGrafFilterToolBoxControl::~SvxGrafFilterToolBoxControl()
517 : : {
518 [ # # ]: 0 : }
519 : :
520 : : // -----------------------------------------------------------------------------
521 : :
522 : 0 : void SvxGrafFilterToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* )
523 : : {
524 : 0 : GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) );
525 : 0 : }
526 : :
527 : : // -----------------------------------------------------------------------------
528 : :
529 : 0 : SfxPopupWindowType SvxGrafFilterToolBoxControl::GetPopupWindowType() const
530 : : {
531 : 0 : return SFX_POPUPWINDOW_ONCLICK;
532 : : }
533 : :
534 : : // -----------------------------------------------------------------------------
535 : :
536 : 0 : SfxPopupWindow* SvxGrafFilterToolBoxControl::CreatePopupWindow()
537 : : {
538 : : rtl::OUString aSubTbxResName(
539 [ # # ]: 0 : RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/graffilterbar" ) );
540 [ # # ]: 0 : createAndPositionSubToolBar( aSubTbxResName );
541 : :
542 : 0 : return NULL;
543 : : }
544 : :
545 : : // -------------------------
546 : : // - SvxGrafToolBoxControl -
547 : : // -------------------------
548 : :
549 : : // -----------------------------------------------------------------------------
550 : :
551 : 0 : SvxGrafToolBoxControl::SvxGrafToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) :
552 : 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
553 : : {
554 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
555 [ # # ]: 0 : rTbx.Invalidate();
556 : 0 : }
557 : :
558 : : // -----------------------------------------------------------------------------
559 : :
560 : 0 : SvxGrafToolBoxControl::~SvxGrafToolBoxControl()
561 : : {
562 [ # # ]: 0 : }
563 : :
564 : : // -----------------------------------------------------------------------------
565 : :
566 : 0 : void SvxGrafToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
567 : :
568 : : {
569 : 0 : ImplGrafControl* pCtrl = (ImplGrafControl*) GetToolBox().GetItemWindow( GetId() );
570 : : DBG_ASSERT( pCtrl, "Control not found" );
571 : :
572 [ # # ]: 0 : if( eState == SFX_ITEM_DISABLED )
573 : : {
574 : 0 : pCtrl->Disable();
575 [ # # ]: 0 : pCtrl->SetText( String() );
576 : : }
577 : : else
578 : : {
579 : 0 : pCtrl->Enable();
580 : :
581 [ # # ]: 0 : if( eState == SFX_ITEM_AVAILABLE )
582 : 0 : pCtrl->Update( pState );
583 : : else
584 : 0 : pCtrl->Update( NULL );
585 : : }
586 : 0 : }
587 : :
588 : : // -----------------------------------------------------------------------------
589 : :
590 : 0 : Window* SvxGrafToolBoxControl::CreateItemWindow( Window *pParent )
591 : : {
592 [ # # ]: 0 : return( new ImplGrafControl( pParent, m_aCommandURL, m_xFrame ) );
593 : : }
594 : :
595 : : // ----------------------------
596 : : // - SvxGrafRedToolBoxControl -
597 : : // ----------------------------
598 : :
599 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafRedToolBoxControl, SfxInt16Item );
600 : :
601 : : // -----------------------------------------------------------------------------
602 : :
603 : 0 : SvxGrafRedToolBoxControl::SvxGrafRedToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
604 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
605 : : {
606 : 0 : }
607 : :
608 : : // ------------------------------
609 : : // - SvxGrafGreenToolBoxControl -
610 : : // ------------------------------
611 : :
612 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGreenToolBoxControl, SfxInt16Item );
613 : :
614 : : // -----------------------------------------------------------------------------
615 : :
616 : 0 : SvxGrafGreenToolBoxControl::SvxGrafGreenToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
617 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
618 : : {
619 : 0 : }
620 : :
621 : : // -----------------------------
622 : : // - SvxGrafBlueToolBoxControl -
623 : : // -----------------------------
624 : :
625 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafBlueToolBoxControl, SfxInt16Item );
626 : :
627 : : // -----------------------------------------------------------------------------
628 : :
629 : 0 : SvxGrafBlueToolBoxControl::SvxGrafBlueToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
630 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
631 : : {
632 : 0 : }
633 : :
634 : : // ----------------------------------
635 : : // - SvxGrafLuminanceToolBoxControl -
636 : : // ----------------------------------
637 : :
638 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafLuminanceToolBoxControl, SfxInt16Item );
639 : :
640 : : // -----------------------------------------------------------------------------
641 : :
642 : 0 : SvxGrafLuminanceToolBoxControl::SvxGrafLuminanceToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
643 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
644 : : {
645 : 0 : }
646 : :
647 : : // ----------------------------------
648 : : // - SvxGrafContrastToolBoxControl -
649 : : // ----------------------------------
650 : :
651 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafContrastToolBoxControl, SfxInt16Item );
652 : :
653 : : // -----------------------------------------------------------------------------
654 : :
655 : 0 : SvxGrafContrastToolBoxControl::SvxGrafContrastToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
656 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
657 : : {
658 : 0 : }
659 : :
660 : : // ------------------------------
661 : : // - SvxGrafGammaToolBoxControl -
662 : : // ------------------------------
663 : :
664 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGammaToolBoxControl, SfxUInt32Item );
665 : :
666 : : // -----------------------------------------------------------------------------
667 : :
668 : 0 : SvxGrafGammaToolBoxControl::SvxGrafGammaToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
669 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
670 : : {
671 : 0 : }
672 : :
673 : : // -------------------------------------
674 : : // - SvxGrafTransparenceToolBoxControl -
675 : : // -------------------------------------
676 : :
677 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafTransparenceToolBoxControl, SfxUInt16Item );
678 : :
679 : : // -----------------------------------------------------------------------------
680 : :
681 : 0 : SvxGrafTransparenceToolBoxControl::SvxGrafTransparenceToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
682 : 0 : SvxGrafToolBoxControl( nSlotId, nId, rTbx )
683 : : {
684 : 0 : }
685 : :
686 : : // -----------------------------
687 : : // - SvxGrafModeToolBoxControl -
688 : : // -----------------------------
689 : :
690 [ # # ]: 149 : SFX_IMPL_TOOLBOX_CONTROL( SvxGrafModeToolBoxControl, SfxUInt16Item );
691 : :
692 : : // -----------------------------------------------------------------------------
693 : :
694 : 0 : SvxGrafModeToolBoxControl::SvxGrafModeToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
695 [ # # ]: 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
696 : : {
697 : 0 : }
698 : :
699 : : // -----------------------------------------------------------------------------
700 : :
701 [ # # ]: 0 : SvxGrafModeToolBoxControl::~SvxGrafModeToolBoxControl()
702 : : {
703 [ # # ]: 0 : }
704 : :
705 : : // -----------------------------------------------------------------------------
706 : :
707 : 0 : void SvxGrafModeToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
708 : :
709 : : {
710 : 0 : ImplGrafModeControl* pCtrl = (ImplGrafModeControl*) GetToolBox().GetItemWindow( GetId() );
711 : : DBG_ASSERT( pCtrl, "Control not found" );
712 : :
713 [ # # ]: 0 : if( eState == SFX_ITEM_DISABLED )
714 : : {
715 : 0 : pCtrl->Disable();
716 [ # # ]: 0 : pCtrl->SetText( String() );
717 : : }
718 : : else
719 : : {
720 : 0 : pCtrl->Enable();
721 : :
722 [ # # ]: 0 : if( eState == SFX_ITEM_AVAILABLE )
723 : 0 : pCtrl->Update( pState );
724 : : else
725 : 0 : pCtrl->Update( NULL );
726 : : }
727 : 0 : }
728 : :
729 : : // -----------------------------------------------------------------------------
730 : :
731 : 0 : Window* SvxGrafModeToolBoxControl::CreateItemWindow( Window *pParent )
732 : : {
733 [ # # ]: 0 : return( new ImplGrafModeControl( pParent, m_xFrame ) );
734 : : }
735 : :
736 : : // ---------------------
737 : : // - SvxGrafAttrHelper -
738 : : // ---------------------
739 : :
740 : 0 : void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
741 : : {
742 : 0 : SfxItemPool& rPool = rView.GetModel()->GetItemPool();
743 [ # # ]: 0 : SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST );
744 [ # # ]: 0 : String aUndoStr;
745 [ # # ]: 0 : const bool bUndo = rView.IsUndoEnabled();
746 : :
747 [ # # ]: 0 : if( bUndo )
748 : : {
749 [ # # ][ # # ]: 0 : aUndoStr = rView.GetDescriptionOfMarkedObjects();
[ # # ]
750 [ # # ]: 0 : aUndoStr.Append( sal_Unicode(' ') );
751 : : }
752 : :
753 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
754 : : const SfxPoolItem* pItem;
755 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
756 : :
757 [ # # ][ # # ]: 0 : if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, sal_False, &pItem ))
[ # # ][ # # ]
758 : 0 : pItem = 0;
759 : :
760 [ # # # # : 0 : switch( nSlot )
# # # # #
# # ]
761 : : {
762 : : case SID_ATTR_GRAF_RED:
763 : : {
764 [ # # ]: 0 : if( pItem )
765 : : {
766 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafRedItem( ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
767 [ # # ]: 0 : if( bUndo )
768 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFRED ) ) );
[ # # ][ # # ]
[ # # ]
769 : : }
770 : : }
771 : 0 : break;
772 : :
773 : : case SID_ATTR_GRAF_GREEN:
774 : : {
775 [ # # ]: 0 : if( pItem )
776 : : {
777 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafGreenItem( ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
778 [ # # ]: 0 : if( bUndo )
779 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGREEN ) ) );
[ # # ][ # # ]
[ # # ]
780 : : }
781 : : }
782 : 0 : break;
783 : :
784 : : case SID_ATTR_GRAF_BLUE:
785 : : {
786 [ # # ]: 0 : if( pItem )
787 : : {
788 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafBlueItem( ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
789 [ # # ]: 0 : if( bUndo )
790 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFBLUE ) ) );
[ # # ][ # # ]
[ # # ]
791 : : }
792 : : }
793 : 0 : break;
794 : :
795 : : case SID_ATTR_GRAF_LUMINANCE:
796 : : {
797 [ # # ]: 0 : if( pItem )
798 : : {
799 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafLuminanceItem( ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
800 [ # # ]: 0 : if( bUndo )
801 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFLUMINANCE ) ) );
[ # # ][ # # ]
[ # # ]
802 : : }
803 : : }
804 : 0 : break;
805 : :
806 : : case SID_ATTR_GRAF_CONTRAST:
807 : : {
808 [ # # ]: 0 : if( pItem )
809 : : {
810 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafContrastItem( ((SfxInt16Item*)pItem)->GetValue() ));
[ # # ]
811 [ # # ]: 0 : if( bUndo )
812 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCONTRAST ) ) );
[ # # ][ # # ]
[ # # ]
813 : : }
814 : : }
815 : 0 : break;
816 : :
817 : : case SID_ATTR_GRAF_GAMMA:
818 : : {
819 [ # # ]: 0 : if( pItem )
820 : : {
821 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafGamma100Item( ((SfxUInt32Item*)pItem)->GetValue() ));
[ # # ]
822 [ # # ]: 0 : if( bUndo )
823 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGAMMA ) ) );
[ # # ][ # # ]
[ # # ]
824 : : }
825 : : }
826 : 0 : break;
827 : :
828 : : case SID_ATTR_GRAF_TRANSPARENCE:
829 : : {
830 [ # # ]: 0 : if( pItem )
831 : : {
832 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafTransparenceItem( ((SfxUInt16Item*)pItem)->GetValue() ));
[ # # ]
833 [ # # ]: 0 : if( bUndo )
834 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFTRANSPARENCY ) ) );
[ # # ][ # # ]
[ # # ]
835 : : }
836 : : }
837 : 0 : break;
838 : :
839 : : case SID_ATTR_GRAF_MODE:
840 : : {
841 [ # # ]: 0 : if( pItem )
842 : : {
843 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafModeItem( (GraphicDrawMode) ((SfxUInt16Item*)pItem)->GetValue() ));
[ # # ]
844 [ # # ]: 0 : if( bUndo )
845 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFMODE ) ) );
[ # # ][ # # ]
[ # # ]
846 : : }
847 : : }
848 : 0 : break;
849 : :
850 : : case( SID_ATTR_GRAF_CROP ):
851 : : {
852 : 0 : const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
853 : :
854 [ # # ]: 0 : if( 0 < rMarkList.GetMarkCount() )
855 : : {
856 [ # # ][ # # ]: 0 : SdrGrafObj* pObj = (SdrGrafObj*) rMarkList.GetMark( 0 )->GetMarkedSdrObj();
857 : :
858 [ # # ][ # # ]: 0 : if( pObj && pObj->ISA( SdrGrafObj ) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
859 [ # # ]: 0 : ( pObj->GetGraphicType() != GRAPHIC_NONE ) &&
860 [ # # ]: 0 : ( pObj->GetGraphicType() != GRAPHIC_DEFAULT ) )
861 : : {
862 [ # # ]: 0 : SfxItemSet aGrfAttr( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP, 0 );
863 [ # # ]: 0 : const SfxMapUnit eOldMetric = rPool.GetMetric( 0 );
864 [ # # ]: 0 : const MapMode aMap100( MAP_100TH_MM );
865 [ # # ]: 0 : const MapMode aMapTwip( MAP_TWIP );
866 : :
867 [ # # ][ # # ]: 0 : aGrfAttr.Put(pObj->GetMergedItemSet());
868 [ # # ]: 0 : rPool.SetDefaultMetric( SFX_MAPUNIT_TWIP );
869 : :
870 : : SfxItemSet aCropDlgAttr( rPool,
871 : : SDRATTR_GRAFCROP, SDRATTR_GRAFCROP,
872 : : SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC,
873 : : SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
874 : : SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE,
875 [ # # ]: 0 : SID_ATTR_GRAF_CROP, SID_ATTR_GRAF_CROP, 0 );
876 : :
877 [ # # ][ # # ]: 0 : aCropDlgAttr.Put( SvxBrushItem( pObj->GetGraphic(), GPOS_MM, SID_ATTR_GRAF_GRAPHIC ) );
[ # # ][ # # ]
878 : : aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_PAGE_SIZE,
879 : : Size( OutputDevice::LogicToLogic(
880 [ # # ][ # # ]: 0 : Size( 200000, 200000 ), aMap100, aMapTwip ) ) ) );
[ # # ][ # # ]
881 : : aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_GRAF_FRMSIZE, OutputDevice::LogicToLogic(
882 [ # # ][ # # ]: 0 : pObj->GetLogicRect().GetSize(), aMap100, aMapTwip ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
883 : :
884 [ # # ]: 0 : const SdrGrafCropItem& rCrop = (const SdrGrafCropItem&) aGrfAttr.Get( SDRATTR_GRAFCROP );
885 : : Size aLTSize( OutputDevice::LogicToLogic(
886 [ # # ]: 0 : Size( rCrop.GetLeft(), rCrop.GetTop() ), aMap100, aMapTwip ) );
887 : : Size aRBSize( OutputDevice::LogicToLogic(
888 [ # # ]: 0 : Size( rCrop.GetRight(), rCrop.GetBottom() ), aMap100, aMapTwip ) );
889 : :
890 : 0 : aCropDlgAttr.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(),
891 [ # # ][ # # ]: 0 : aRBSize.Width(), aRBSize.Height() ) );
[ # # ]
892 : :
893 [ # # ][ # # ]: 0 : SfxSingleTabDialog aCropDialog( SfxViewShell::Current() ? SfxViewShell::Current()->GetWindow() : NULL,
894 [ # # ][ # # ]: 0 : aCropDlgAttr, 950 );
895 [ # # ][ # # ]: 0 : const String aCropStr = SVX_RESSTR( RID_SVXSTR_GRAFCROP );
[ # # ]
896 : :
897 [ # # ]: 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
898 : : DBG_ASSERT(pFact, "Dialogdiet error!");
899 [ # # ]: 0 : ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP );
900 : : DBG_ASSERT(fnCreatePage, "Dialogdiet error!");
901 [ # # ]: 0 : SfxTabPage* pTabPage = (*fnCreatePage)( &aCropDialog, aCropDlgAttr );
902 : :
903 [ # # ]: 0 : pTabPage->SetText( aCropStr );
904 [ # # ]: 0 : aCropDialog.SetTabPage( pTabPage );
905 : :
906 [ # # ][ # # ]: 0 : if( aCropDialog.Execute() == RET_OK )
907 : : {
908 : 0 : const SfxItemSet* pOutAttr = aCropDialog.GetOutputItemSet();
909 : :
910 [ # # ]: 0 : if( pOutAttr )
911 : : {
912 [ # # ][ # # ]: 0 : aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCROP ) ) );
[ # # ][ # # ]
[ # # ]
913 : :
914 : : // set crop attributes
915 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET <= pOutAttr->GetItemState( SDRATTR_GRAFCROP ) )
916 : : {
917 [ # # ]: 0 : const SdrGrafCropItem& rNewCrop = (const SdrGrafCropItem&) pOutAttr->Get( SDRATTR_GRAFCROP );
918 : :
919 [ # # ]: 0 : aLTSize = OutputDevice::LogicToLogic( Size( rNewCrop.GetLeft(), rNewCrop.GetTop() ), aMapTwip, aMap100 );
920 [ # # ]: 0 : aRBSize = OutputDevice::LogicToLogic( Size( rNewCrop.GetRight(), rNewCrop.GetBottom() ), aMapTwip, aMap100 );
921 [ # # ][ # # ]: 0 : aSet.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(), aRBSize.Width(), aRBSize.Height() ) );
[ # # ]
922 : : }
923 : :
924 : : // set new logic rect
925 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET <= pOutAttr->GetItemState( SID_ATTR_GRAF_FRMSIZE ) )
926 : : {
927 [ # # ]: 0 : Point aNewOrigin( pObj->GetLogicRect().TopLeft() );
928 [ # # ]: 0 : const Size& rGrfSize = ( (const SvxSizeItem&) pOutAttr->Get( SID_ATTR_GRAF_FRMSIZE ) ).GetSize();
929 [ # # ]: 0 : Size aNewGrfSize( OutputDevice::LogicToLogic( rGrfSize, aMapTwip, aMap100 ) );
930 [ # # ][ # # ]: 0 : Size aOldGrfSize( pObj->GetLogicRect().GetSize() );
931 : :
932 [ # # ]: 0 : Rectangle aNewRect( aNewOrigin, aNewGrfSize );
933 : 0 : Point aOffset( (aNewGrfSize.Width() - aOldGrfSize.Width()) >> 1,
934 : 0 : (aNewGrfSize.Height() - aOldGrfSize.Height()) >> 1 );
935 : :
936 : : // #106181# rotate snap rect before setting it
937 : 0 : const GeoStat& aGeo = pObj->GetGeoStat();
938 : :
939 [ # # ][ # # ]: 0 : if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0)
940 : : {
941 [ # # ]: 0 : Polygon aPol(aNewRect);
942 : :
943 : : // also transform origin offset
944 [ # # ]: 0 : if (aGeo.nShearWink!=0)
945 : : {
946 : : ShearPoly(aPol,
947 : : aNewRect.TopLeft(),
948 [ # # ]: 0 : aGeo.nTan);
949 : 0 : ShearPoint(aOffset, Point(0,0), aGeo.nTan);
950 : : }
951 [ # # ]: 0 : if (aGeo.nDrehWink!=0)
952 : : {
953 : : RotatePoly(aPol,
954 : : aNewRect.TopLeft(),
955 [ # # ]: 0 : aGeo.nSin,aGeo.nCos);
956 : 0 : RotatePoint(aOffset, Point(0,0), aGeo.nSin,aGeo.nCos);
957 : : }
958 : :
959 : : // apply offset
960 [ # # ]: 0 : aPol.Move( -aOffset.X(), -aOffset.Y() );
961 [ # # ][ # # ]: 0 : aNewRect=aPol.GetBoundRect();
962 : : }
963 : : else
964 : : {
965 [ # # ]: 0 : aNewRect.Move( -aOffset.X(), -aOffset.Y() );
966 : : }
967 : :
968 [ # # ]: 0 : if( !aSet.Count() )
969 [ # # ]: 0 : rView.SetMarkedObjRect( aNewRect );
970 : : else
971 : : {
972 [ # # ]: 0 : if( bUndo )
973 : : {
974 [ # # ]: 0 : rView.BegUndo( aUndoStr );
975 [ # # ][ # # ]: 0 : rView.AddUndo( rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
[ # # ]
976 : : }
977 [ # # ]: 0 : pObj->SetSnapRect( aNewRect );
978 [ # # ]: 0 : rView.SetAttributes( aSet );
979 : :
980 [ # # ]: 0 : if( bUndo )
981 [ # # ]: 0 : rView.EndUndo();
982 [ # # ]: 0 : aSet.ClearItem();
983 : : }
984 : : }
985 : : }
986 : : }
987 : :
988 [ # # ][ # # ]: 0 : rPool.SetDefaultMetric( eOldMetric );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
989 : : }
990 : : }
991 : : }
992 : 0 : break;
993 : :
994 : : case SID_COLOR_SETTINGS:
995 : : {
996 [ # # ][ # # ]: 0 : svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
997 [ # # ]: 0 : aToolboxAccess.toggleToolbox();
998 [ # # ]: 0 : rReq.Done();
999 [ # # ]: 0 : break;
1000 : : }
1001 : :
1002 : : default:
1003 : 0 : break;
1004 : : }
1005 : :
1006 [ # # ]: 0 : if( aSet.Count() )
1007 : : {
1008 [ # # ]: 0 : if( bUndo )
1009 [ # # ]: 0 : rView.BegUndo( aUndoStr );
1010 : :
1011 [ # # ]: 0 : rView.SetAttributes( aSet );
1012 : :
1013 [ # # ]: 0 : if( bUndo )
1014 [ # # ]: 0 : rView.EndUndo();
1015 [ # # ][ # # ]: 0 : }
1016 : 0 : }
1017 : :
1018 : : // -----------------------------------------------------------------------------
1019 : :
1020 : 0 : void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView )
1021 : : {
1022 : 0 : SfxItemPool& rPool = rView.GetModel()->GetItemPool();
1023 [ # # ]: 0 : SfxItemSet aAttrSet( rPool );
1024 [ # # ]: 0 : SfxWhichIter aIter( rSet );
1025 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
1026 : 0 : const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
1027 : 0 : bool bEnableColors = true;
1028 : 0 : bool bEnableTransparency = true;
1029 : 0 : bool bEnableCrop = ( 1 == rMarkList.GetMarkCount() );
1030 : :
1031 [ # # ]: 0 : for( int i = 0, nCount = rMarkList.GetMarkCount(); i < nCount; ++i )
1032 : : {
1033 [ # # ][ # # ]: 0 : SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( i )->GetMarkedSdrObj() );
[ # # ]
1034 : :
1035 [ # # ][ # # ]: 0 : if( !pGrafObj ||
[ # # ][ # # ]
[ # # ]
1036 [ # # ]: 0 : ( pGrafObj->GetGraphicType() == GRAPHIC_NONE ) ||
1037 [ # # ]: 0 : ( pGrafObj->GetGraphicType() == GRAPHIC_DEFAULT ) ||
1038 [ # # ]: 0 : pGrafObj->HasRenderGraphic() )
1039 : : {
1040 : 0 : bEnableColors = bEnableTransparency = bEnableCrop = false;
1041 : 0 : break;
1042 : : }
1043 [ # # ][ # # ]: 0 : else if( bEnableTransparency && ( pGrafObj->HasGDIMetaFile() || pGrafObj->IsAnimated() ) )
[ # # ][ # # ]
[ # # ][ # # ]
1044 : : {
1045 : 0 : bEnableTransparency = false;
1046 : : }
1047 : : }
1048 : :
1049 [ # # ]: 0 : rView.GetAttributes( aAttrSet );
1050 : :
1051 [ # # ]: 0 : while( nWhich )
1052 : : {
1053 [ # # ][ # # ]: 0 : sal_uInt16 nSlotId = SfxItemPool::IsWhich( nWhich ) ? rPool.GetSlotId( nWhich ) : nWhich;
1054 : :
1055 [ # # # # : 0 : switch( nSlotId )
# # # # #
# # ]
1056 : : {
1057 : : case( SID_ATTR_GRAF_MODE ):
1058 : : {
1059 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) )
1060 : : {
1061 [ # # ]: 0 : if( bEnableColors )
1062 : : {
1063 : : rSet.Put( SfxUInt16Item( nSlotId,
1064 [ # # ][ # # ]: 0 : sal::static_int_cast< sal_uInt16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) );
[ # # ][ # # ]
1065 : : }
1066 : : else
1067 : : {
1068 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_MODE );
1069 : : }
1070 : : }
1071 : : }
1072 : 0 : break;
1073 : :
1074 : : case( SID_ATTR_GRAF_RED ):
1075 : : {
1076 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) )
1077 : : {
1078 [ # # ]: 0 : if( bEnableColors )
1079 : : {
1080 : : rSet.Put( SfxInt16Item( nSlotId,
1081 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) );
[ # # ][ # # ]
1082 : : }
1083 : : else
1084 : : {
1085 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_RED );
1086 : : }
1087 : : }
1088 : : }
1089 : 0 : break;
1090 : :
1091 : : case( SID_ATTR_GRAF_GREEN ):
1092 : : {
1093 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) )
1094 : : {
1095 [ # # ]: 0 : if( bEnableColors )
1096 : : {
1097 : : rSet.Put( SfxInt16Item( nSlotId,
1098 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) );
[ # # ][ # # ]
1099 : : }
1100 : : else
1101 : : {
1102 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_GREEN );
1103 : : }
1104 : : }
1105 : : }
1106 : 0 : break;
1107 : :
1108 : : case( SID_ATTR_GRAF_BLUE ):
1109 : : {
1110 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) )
1111 : : {
1112 [ # # ]: 0 : if( bEnableColors )
1113 : : {
1114 : : rSet.Put( SfxInt16Item( nSlotId,
1115 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) );
[ # # ][ # # ]
1116 : : }
1117 : : else
1118 : : {
1119 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_BLUE );
1120 : : }
1121 : : }
1122 : : }
1123 : 0 : break;
1124 : :
1125 : : case( SID_ATTR_GRAF_LUMINANCE ):
1126 : : {
1127 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) )
1128 : : {
1129 [ # # ]: 0 : if( bEnableColors )
1130 : : {
1131 : : rSet.Put( SfxInt16Item( nSlotId,
1132 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) );
[ # # ][ # # ]
1133 : : }
1134 : : else
1135 : : {
1136 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_LUMINANCE );
1137 : : }
1138 : : }
1139 : : }
1140 : 0 : break;
1141 : :
1142 : : case( SID_ATTR_GRAF_CONTRAST ):
1143 : : {
1144 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) )
1145 : : {
1146 [ # # ]: 0 : if( bEnableColors )
1147 : : {
1148 : : rSet.Put( SfxInt16Item( nSlotId,
1149 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) );
[ # # ][ # # ]
1150 : : }
1151 : : else
1152 : : {
1153 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_CONTRAST );
1154 : : }
1155 : : }
1156 : : }
1157 : 0 : break;
1158 : :
1159 : : case( SID_ATTR_GRAF_GAMMA ):
1160 : : {
1161 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) )
1162 : : {
1163 [ # # ]: 0 : if( bEnableColors )
1164 : : {
1165 : : rSet.Put( SfxUInt32Item( nSlotId,
1166 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) );
[ # # ][ # # ]
1167 : : }
1168 : : else
1169 : : {
1170 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_GAMMA );
1171 : : }
1172 : : }
1173 : : }
1174 : 0 : break;
1175 : :
1176 : : case( SID_ATTR_GRAF_TRANSPARENCE ):
1177 : : {
1178 [ # # ][ # # ]: 0 : if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) )
1179 : : {
1180 [ # # ]: 0 : if( bEnableTransparency )
1181 : : {
1182 : : rSet.Put( SfxUInt16Item( nSlotId,
1183 [ # # ][ # # ]: 0 : ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) );
[ # # ][ # # ]
1184 : : }
1185 : : else
1186 : : {
1187 [ # # ]: 0 : rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE );
1188 : : }
1189 : : }
1190 : : }
1191 : 0 : break;
1192 : :
1193 : : case( SID_ATTR_GRAF_CROP ):
1194 : : {
1195 [ # # ]: 0 : if( !bEnableCrop )
1196 [ # # ]: 0 : rSet.DisableItem( nSlotId );
1197 : : }
1198 : 0 : break;
1199 : :
1200 : : case SID_COLOR_SETTINGS :
1201 : : {
1202 [ # # ][ # # ]: 0 : svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
1203 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) );
[ # # ][ # # ]
1204 [ # # ]: 0 : break;
1205 : : }
1206 : :
1207 : : default:
1208 : 0 : break;
1209 : : }
1210 : :
1211 [ # # ]: 0 : nWhich = aIter.NextWhich();
1212 [ # # ][ # # ]: 0 : }
1213 : 0 : }
1214 : :
1215 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|