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