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