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