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