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 <svx/dialogs.hrc> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <tools/list.hxx> 35*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 36*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 37*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 38*cdf0e10cSrcweir #include <vcl/image.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <svx/colrctrl.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <svx/svdview.hxx> 43*cdf0e10cSrcweir #include "svx/drawitem.hxx" 44*cdf0e10cSrcweir #include <editeng/colritem.hxx> 45*cdf0e10cSrcweir #include "svx/xattr.hxx" 46*cdf0e10cSrcweir #include <svx/xtable.hxx> 47*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 48*cdf0e10cSrcweir #include "svx/xexch.hxx" 49*cdf0e10cSrcweir #include <vcl/svapp.hxx> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW( SvxColorChildWindow, SID_COLOR_CONTROL ) 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // ------------------------ 54*cdf0e10cSrcweir // - SvxColorValueSetData - 55*cdf0e10cSrcweir // ------------------------ 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir class SvxColorValueSetData : public TransferableHelper 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir private: 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir XFillExchangeData maData; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir protected: 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir virtual void AddSupportedFormats(); 66*cdf0e10cSrcweir virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); 67*cdf0e10cSrcweir virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir public: 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir SvxColorValueSetData( const XFillAttrSetItem& rSetItem ) : 72*cdf0e10cSrcweir maData( rSetItem ) {} 73*cdf0e10cSrcweir }; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void SvxColorValueSetData::AddSupportedFormats() 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_XFA ); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir sal_Bool SvxColorValueSetData::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir sal_Bool bRet = sal_False; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if( SotExchange::GetFormat( rFlavor ) == SOT_FORMATSTR_ID_XFA ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SetObject( &maData, 0, rFlavor ); 91*cdf0e10cSrcweir bRet = sal_True; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir return bRet; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir sal_Bool SvxColorValueSetData::WriteObject( SotStorageStreamRef& rxOStm, void*, sal_uInt32 , const ::com::sun::star::datatransfer::DataFlavor& ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir *rxOStm << maData; 102*cdf0e10cSrcweir return( rxOStm->GetError() == ERRCODE_NONE ); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir /************************************************************************* 106*cdf0e10cSrcweir |* 107*cdf0e10cSrcweir |* SvxColorValueSet: Ctor 108*cdf0e10cSrcweir |* 109*cdf0e10cSrcweir \************************************************************************/ 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir SvxColorValueSet::SvxColorValueSet( Window* _pParent, WinBits nWinStyle ) : 112*cdf0e10cSrcweir ValueSet( _pParent, nWinStyle ), 113*cdf0e10cSrcweir DragSourceHelper( this ), 114*cdf0e10cSrcweir bLeft (sal_True) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir SetAccessibleName(String( SVX_RES( STR_COLORTABLE ) ) ); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir /************************************************************************* 120*cdf0e10cSrcweir |* 121*cdf0e10cSrcweir |* SvxColorValueSet: Ctor 122*cdf0e10cSrcweir |* 123*cdf0e10cSrcweir \************************************************************************/ 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) : 126*cdf0e10cSrcweir ValueSet( _pParent, rResId ), 127*cdf0e10cSrcweir DragSourceHelper( this ), 128*cdf0e10cSrcweir bLeft (sal_True) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir SetAccessibleName(String( SVX_RES( STR_COLORTABLE ) )); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir /************************************************************************* 134*cdf0e10cSrcweir |* 135*cdf0e10cSrcweir |* SvxColorValueSet: MouseButtonDown 136*cdf0e10cSrcweir |* 137*cdf0e10cSrcweir \************************************************************************/ 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir // Fuer Mac noch anders handlen ! 142*cdf0e10cSrcweir if( rMEvt.IsLeft() ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir bLeft = sal_True; 145*cdf0e10cSrcweir ValueSet::MouseButtonDown( rMEvt ); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir else 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir bLeft = sal_False; 150*cdf0e10cSrcweir MouseEvent aMEvt( rMEvt.GetPosPixel(), 151*cdf0e10cSrcweir rMEvt.GetClicks(), 152*cdf0e10cSrcweir rMEvt.GetMode(), 153*cdf0e10cSrcweir MOUSE_LEFT, 154*cdf0e10cSrcweir rMEvt.GetModifier() ); 155*cdf0e10cSrcweir ValueSet::MouseButtonDown( aMEvt ); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir aDragPosPixel = GetPointerPosPixel(); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir /************************************************************************* 162*cdf0e10cSrcweir |* 163*cdf0e10cSrcweir |* SvxColorValueSet: MouseButtonUp 164*cdf0e10cSrcweir |* 165*cdf0e10cSrcweir \************************************************************************/ 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir // Fuer Mac noch anders handlen ! 170*cdf0e10cSrcweir if( rMEvt.IsLeft() ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir bLeft = sal_True; 173*cdf0e10cSrcweir ValueSet::MouseButtonUp( rMEvt ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir else 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir bLeft = sal_False; 178*cdf0e10cSrcweir MouseEvent aMEvt( rMEvt.GetPosPixel(), 179*cdf0e10cSrcweir rMEvt.GetClicks(), 180*cdf0e10cSrcweir rMEvt.GetMode(), 181*cdf0e10cSrcweir MOUSE_LEFT, 182*cdf0e10cSrcweir rMEvt.GetModifier() ); 183*cdf0e10cSrcweir ValueSet::MouseButtonUp( aMEvt ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir SetNoSelection(); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir /************************************************************************* 189*cdf0e10cSrcweir |* 190*cdf0e10cSrcweir |* Command-Event 191*cdf0e10cSrcweir |* 192*cdf0e10cSrcweir \************************************************************************/ 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir void SvxColorValueSet::Command(const CommandEvent& rCEvt) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir // Basisklasse 197*cdf0e10cSrcweir ValueSet::Command(rCEvt); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir /************************************************************************* 201*cdf0e10cSrcweir |* 202*cdf0e10cSrcweir |* StartDrag 203*cdf0e10cSrcweir |* 204*cdf0e10cSrcweir \************************************************************************/ 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir void SvxColorValueSet::StartDrag( sal_Int8 , const Point& ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl)); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir /************************************************************************* 212*cdf0e10cSrcweir |* 213*cdf0e10cSrcweir |* Drag&Drop asynchron ausfuehren 214*cdf0e10cSrcweir |* 215*cdf0e10cSrcweir \************************************************************************/ 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir void SvxColorValueSet::DoDrag() 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir SfxObjectShell* pDocSh = SfxObjectShell::Current(); 220*cdf0e10cSrcweir sal_uInt16 nItemId = GetItemId( aDragPosPixel ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir if( pDocSh && nItemId ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir XFillAttrSetItem aXFillSetItem( &pDocSh->GetPool() ); 225*cdf0e10cSrcweir SfxItemSet& rSet = aXFillSetItem.GetItemSet(); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir rSet.Put( XFillColorItem( GetItemText( nItemId ), GetItemColor( nItemId ) ) ); 228*cdf0e10cSrcweir rSet.Put(XFillStyleItem( ( 1 == nItemId ) ? XFILL_NONE : XFILL_SOLID ) ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir EndSelection(); 231*cdf0e10cSrcweir ( new SvxColorValueSetData( aXFillSetItem ) )->StartDrag( this, DND_ACTION_COPY ); 232*cdf0e10cSrcweir ReleaseMouse(); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir /************************************************************************* 237*cdf0e10cSrcweir |* 238*cdf0e10cSrcweir |* 239*cdf0e10cSrcweir |* 240*cdf0e10cSrcweir \************************************************************************/ 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir // Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die 245*cdf0e10cSrcweir // Farbleiste geloescht werden darf 246*cdf0e10cSrcweir pThis->DoDrag(); 247*cdf0e10cSrcweir return(0); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir /************************************************************************* 251*cdf0e10cSrcweir |* 252*cdf0e10cSrcweir |* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator 253*cdf0e10cSrcweir |* 254*cdf0e10cSrcweir \************************************************************************/ 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir SvxColorChildWindow::SvxColorChildWindow( Window* _pParent, 257*cdf0e10cSrcweir sal_uInt16 nId, 258*cdf0e10cSrcweir SfxBindings* pBindings, 259*cdf0e10cSrcweir SfxChildWinInfo* pInfo ) : 260*cdf0e10cSrcweir SfxChildWindow( _pParent, nId ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this, 263*cdf0e10cSrcweir _pParent, SVX_RES( RID_SVXCTRL_COLOR ) ); 264*cdf0e10cSrcweir pWindow = pWin; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_BOTTOM; 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir pWin->Initialize( pInfo ); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir /************************************************************************* 274*cdf0e10cSrcweir |* 275*cdf0e10cSrcweir |* Ctor: SvxColorDockingWindow 276*cdf0e10cSrcweir |* 277*cdf0e10cSrcweir \************************************************************************/ 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir SvxColorDockingWindow::SvxColorDockingWindow 280*cdf0e10cSrcweir ( 281*cdf0e10cSrcweir SfxBindings* _pBindings, 282*cdf0e10cSrcweir SfxChildWindow* pCW, 283*cdf0e10cSrcweir Window* _pParent, 284*cdf0e10cSrcweir const ResId& rResId 285*cdf0e10cSrcweir ) : 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir SfxDockingWindow( _pBindings, pCW, _pParent, rResId ), 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir pColorTable ( NULL ), 290*cdf0e10cSrcweir aColorSet ( this, ResId( 1, *rResId.GetResMgr() ) ), 291*cdf0e10cSrcweir nLeftSlot ( SID_ATTR_FILL_COLOR ), 292*cdf0e10cSrcweir nRightSlot ( SID_ATTR_LINE_COLOR ), 293*cdf0e10cSrcweir nCols ( 20 ), 294*cdf0e10cSrcweir nLines ( 1 ), 295*cdf0e10cSrcweir aColorSize ( 14, 14 ) 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir FreeResource(); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir aColorSet.SetStyle( aColorSet.GetStyle() | WB_ITEMBORDER ); 301*cdf0e10cSrcweir aColorSet.SetSelectHdl( LINK( this, SvxColorDockingWindow, SelectHdl ) ); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir // Get the model from the view shell. Using SfxObjectShell::Current() 304*cdf0e10cSrcweir // is unreliable when called at the wrong times. 305*cdf0e10cSrcweir SfxObjectShell* pDocSh = NULL; 306*cdf0e10cSrcweir if (_pBindings != NULL) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir SfxDispatcher* pDispatcher = _pBindings->GetDispatcher(); 309*cdf0e10cSrcweir if (pDispatcher != NULL) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir SfxViewFrame* pFrame = pDispatcher->GetFrame(); 312*cdf0e10cSrcweir if (pFrame != NULL) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir SfxViewShell* pViewShell = pFrame->GetViewShell(); 315*cdf0e10cSrcweir if (pViewShell != NULL) 316*cdf0e10cSrcweir pDocSh = pViewShell->GetObjectShell(); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir if ( pDocSh ) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); 324*cdf0e10cSrcweir if( pItem ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir pColorTable = ( (SvxColorTableItem*) pItem )->GetColorTable(); 327*cdf0e10cSrcweir FillValueSet(); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir aItemSize = aColorSet.CalcItemSizePixel( aColorSize ); 331*cdf0e10cSrcweir aItemSize.Width() = aItemSize.Width() + aColorSize.Width(); 332*cdf0e10cSrcweir aItemSize.Width() /= 2; 333*cdf0e10cSrcweir aItemSize.Height() = aItemSize.Height() + aColorSize.Height(); 334*cdf0e10cSrcweir aItemSize.Height() /= 2; 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir SetSize(); 337*cdf0e10cSrcweir aColorSet.Show(); 338*cdf0e10cSrcweir StartListening( *_pBindings, sal_True ); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir /************************************************************************* 343*cdf0e10cSrcweir |* 344*cdf0e10cSrcweir |* Dtor: SvxColorDockingWindow 345*cdf0e10cSrcweir |* 346*cdf0e10cSrcweir \************************************************************************/ 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir SvxColorDockingWindow::~SvxColorDockingWindow() 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir EndListening( GetBindings() ); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir /************************************************************************* 354*cdf0e10cSrcweir |* 355*cdf0e10cSrcweir |* Notify 356*cdf0e10cSrcweir |* 357*cdf0e10cSrcweir \************************************************************************/ 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir void SvxColorDockingWindow::Notify( SfxBroadcaster& , const SfxHint& rHint ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint); 362*cdf0e10cSrcweir if ( pPoolItemHint 363*cdf0e10cSrcweir && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir // Die Liste der Farben hat sich geaendert 366*cdf0e10cSrcweir pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable(); 367*cdf0e10cSrcweir FillValueSet(); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir /************************************************************************* 372*cdf0e10cSrcweir |* 373*cdf0e10cSrcweir |* FillValueSet 374*cdf0e10cSrcweir |* 375*cdf0e10cSrcweir \************************************************************************/ 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir void SvxColorDockingWindow::FillValueSet() 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir if( pColorTable ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir aColorSet.Clear(); 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir // Erster Eintrag: unsichtbar 384*cdf0e10cSrcweir long nPtX = aColorSize.Width() - 1; 385*cdf0e10cSrcweir long nPtY = aColorSize.Height() - 1; 386*cdf0e10cSrcweir VirtualDevice aVD; 387*cdf0e10cSrcweir aVD.SetOutputSizePixel( aColorSize ); 388*cdf0e10cSrcweir aVD.SetLineColor( Color( COL_BLACK ) ); 389*cdf0e10cSrcweir aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) ); 390*cdf0e10cSrcweir aVD.DrawLine( Point(), Point( nPtX, nPtY ) ); 391*cdf0e10cSrcweir aVD.DrawLine( Point( 0, nPtY ), Point( nPtX, 0 ) ); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir Bitmap aBmp( aVD.GetBitmap( Point(), aColorSize ) ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir aColorSet.InsertItem( (sal_uInt16)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir XColorEntry* pEntry; 398*cdf0e10cSrcweir nCount = pColorTable->Count(); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir for( long i = 0; i < nCount; i++ ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir pEntry = pColorTable->GetColor( i ); 403*cdf0e10cSrcweir aColorSet.InsertItem( (sal_uInt16)i+2, 404*cdf0e10cSrcweir pEntry->GetColor(), pEntry->GetName() ); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir /************************************************************************* 410*cdf0e10cSrcweir |* 411*cdf0e10cSrcweir |* SetSize 412*cdf0e10cSrcweir |* 413*cdf0e10cSrcweir \************************************************************************/ 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir void SvxColorDockingWindow::SetSize() 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir // Groesse fuer ValueSet berechnen 418*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 419*cdf0e10cSrcweir aSize.Width() -= 4; 420*cdf0e10cSrcweir aSize.Height() -= 4; 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir // Zeilen und Spalten berechnen 423*cdf0e10cSrcweir nCols = (sal_uInt16) ( aSize.Width() / aItemSize.Width() ); 424*cdf0e10cSrcweir nLines = (sal_uInt16) ( (float) aSize.Height() / (float) aItemSize.Height() /*+ 0.35*/ ); 425*cdf0e10cSrcweir if( nLines == 0 ) 426*cdf0e10cSrcweir nLines++; 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir // Scrollbar setzen/entfernen 429*cdf0e10cSrcweir WinBits nBits = aColorSet.GetStyle(); 430*cdf0e10cSrcweir if ( nLines * nCols >= nCount ) 431*cdf0e10cSrcweir nBits &= ~WB_VSCROLL; 432*cdf0e10cSrcweir else 433*cdf0e10cSrcweir nBits |= WB_VSCROLL; 434*cdf0e10cSrcweir aColorSet.SetStyle( nBits ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir // ScrollBar ? 437*cdf0e10cSrcweir long nScrollWidth = aColorSet.GetScrollWidth(); 438*cdf0e10cSrcweir if( nScrollWidth > 0 ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir // Spalten mit ScrollBar berechnen 441*cdf0e10cSrcweir nCols = (sal_uInt16) ( ( aSize.Width() - nScrollWidth ) / aItemSize.Width() ); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir aColorSet.SetColCount( nCols ); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if( IsFloatingMode() ) 446*cdf0e10cSrcweir aColorSet.SetLineCount( nLines ); 447*cdf0e10cSrcweir else 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir aColorSet.SetLineCount( 0 ); // sonst wird LineHeight ignoriert 450*cdf0e10cSrcweir aColorSet.SetItemHeight( aItemSize.Height() ); 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir aColorSet.SetPosSizePixel( Point( 2, 2 ), aSize ); 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir /************************************************************************* 457*cdf0e10cSrcweir |* 458*cdf0e10cSrcweir |* SvxColorDockingWindow: Close 459*cdf0e10cSrcweir |* 460*cdf0e10cSrcweir \************************************************************************/ 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir sal_Bool SvxColorDockingWindow::Close() 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir SfxBoolItem aItem( SID_COLOR_CONTROL, sal_False ); 465*cdf0e10cSrcweir GetBindings().GetDispatcher()->Execute( 466*cdf0e10cSrcweir SID_COLOR_CONTROL, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L ); 467*cdf0e10cSrcweir SfxDockingWindow::Close(); 468*cdf0e10cSrcweir return( sal_True ); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir /************************************************************************* 472*cdf0e10cSrcweir |* 473*cdf0e10cSrcweir |* SelectHdl 474*cdf0e10cSrcweir |* 475*cdf0e10cSrcweir \************************************************************************/ 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir IMPL_LINK( SvxColorDockingWindow, SelectHdl, void *, EMPTYARG ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir SfxDispatcher* pDispatcher = GetBindings().GetDispatcher(); 480*cdf0e10cSrcweir sal_uInt16 nPos = aColorSet.GetSelectItemId(); 481*cdf0e10cSrcweir Color aColor( aColorSet.GetItemColor( nPos ) ); 482*cdf0e10cSrcweir String aStr( aColorSet.GetItemText( nPos ) ); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if (aColorSet.IsLeftButton()) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir if ( nLeftSlot == SID_ATTR_FILL_COLOR ) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir if ( nPos == 1 ) // unsichtbar 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir XFillStyleItem aXFillStyleItem( XFILL_NONE ); 491*cdf0e10cSrcweir pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L ); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir else 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir sal_Bool bDone = sal_False; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir // Wenn wir eine DrawView haben und uns im TextEdit-Modus befinden, 498*cdf0e10cSrcweir // wird nicht die Flaechen-, sondern die Textfarbe zugewiesen 499*cdf0e10cSrcweir SfxViewShell* pViewSh = SfxViewShell::Current(); 500*cdf0e10cSrcweir if ( pViewSh ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir SdrView* pView = pViewSh->GetDrawView(); 503*cdf0e10cSrcweir if ( pView && pView->IsTextEdit() ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir SvxColorItem aTextColorItem( aColor, SID_ATTR_CHAR_COLOR ); 506*cdf0e10cSrcweir pDispatcher->Execute( 507*cdf0e10cSrcweir SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aTextColorItem, 0L ); 508*cdf0e10cSrcweir bDone = sal_True; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir if ( !bDone ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir XFillStyleItem aXFillStyleItem( XFILL_SOLID ); 514*cdf0e10cSrcweir XFillColorItem aXFillColorItem( aStr, aColor ); 515*cdf0e10cSrcweir pDispatcher->Execute( 516*cdf0e10cSrcweir nLeftSlot, SFX_CALLMODE_RECORD, &aXFillColorItem, &aXFillStyleItem, 0L ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir else if ( nPos != 1 ) // unsichtbar 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir SvxColorItem aLeftColorItem( aColor, nLeftSlot ); 523*cdf0e10cSrcweir pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aLeftColorItem, 0L ); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir else 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir if ( nRightSlot == SID_ATTR_LINE_COLOR ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir if( nPos == 1 ) // unsichtbar 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir XLineStyleItem aXLineStyleItem( XLINE_NONE ); 533*cdf0e10cSrcweir pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L ); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir else 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir // Sollte der LineStyle unsichtbar sein, so wird er auf SOLID gesetzt 538*cdf0e10cSrcweir SfxViewShell* pViewSh = SfxViewShell::Current(); 539*cdf0e10cSrcweir if ( pViewSh ) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir SdrView* pView = pViewSh->GetDrawView(); 542*cdf0e10cSrcweir if ( pView ) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir SfxItemSet aAttrSet( pView->GetModel()->GetItemPool() ); 545*cdf0e10cSrcweir pView->GetAttributes( aAttrSet ); 546*cdf0e10cSrcweir if ( aAttrSet.GetItemState( XATTR_LINESTYLE ) != SFX_ITEM_DONTCARE ) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir XLineStyle eXLS = (XLineStyle) 549*cdf0e10cSrcweir ( (const XLineStyleItem&)aAttrSet.Get( XATTR_LINESTYLE ) ).GetValue(); 550*cdf0e10cSrcweir if ( eXLS == XLINE_NONE ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir XLineStyleItem aXLineStyleItem( XLINE_SOLID ); 553*cdf0e10cSrcweir pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L ); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir XLineColorItem aXLineColorItem( aStr, aColor ); 560*cdf0e10cSrcweir pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineColorItem, 0L ); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir else if ( nPos != 1 ) // unsichtbar 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir SvxColorItem aRightColorItem( aColor, nRightSlot ); 566*cdf0e10cSrcweir pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aRightColorItem, 0L ); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir return 0; 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir /************************************************************************* 574*cdf0e10cSrcweir |* 575*cdf0e10cSrcweir |* Resizing 576*cdf0e10cSrcweir |* 577*cdf0e10cSrcweir \************************************************************************/ 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir void SvxColorDockingWindow::Resizing( Size& rNewSize ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir rNewSize.Width() -= 4; 583*cdf0e10cSrcweir rNewSize.Height() -= 4; 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir // Spalten und Reihen ermitteln 586*cdf0e10cSrcweir nCols = (sal_uInt16) ( (float) rNewSize.Width() / (float) aItemSize.Width() + 0.5 ); 587*cdf0e10cSrcweir nLines = (sal_uInt16) ( (float) rNewSize.Height() / (float) aItemSize.Height() + 0.5 ); 588*cdf0e10cSrcweir if( nLines == 0 ) 589*cdf0e10cSrcweir nLines = 1; 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir // Scrollbar setzen/entfernen 592*cdf0e10cSrcweir WinBits nBits = aColorSet.GetStyle(); 593*cdf0e10cSrcweir if ( nLines * nCols >= nCount ) 594*cdf0e10cSrcweir nBits &= ~WB_VSCROLL; 595*cdf0e10cSrcweir else 596*cdf0e10cSrcweir nBits |= WB_VSCROLL; 597*cdf0e10cSrcweir aColorSet.SetStyle( nBits ); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir // ScrollBar ? 600*cdf0e10cSrcweir long nScrollWidth = aColorSet.GetScrollWidth(); 601*cdf0e10cSrcweir if( nScrollWidth > 0 ) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir // Spalten mit ScrollBar berechnen 604*cdf0e10cSrcweir nCols = (sal_uInt16) ( ( ( (float) rNewSize.Width() - (float) nScrollWidth ) ) 605*cdf0e10cSrcweir / (float) aItemSize.Width() + 0.5 ); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir if( nCols <= 1 ) 608*cdf0e10cSrcweir nCols = 2; 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir // Max. Reihen anhand der gegebenen Spalten berechnen 611*cdf0e10cSrcweir long nMaxLines = nCount / nCols; 612*cdf0e10cSrcweir if( nCount % nCols ) 613*cdf0e10cSrcweir nMaxLines++; 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir nLines = sal::static_int_cast< sal_uInt16 >( 616*cdf0e10cSrcweir std::min< long >( nLines, nMaxLines ) ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir // Groesse des Windows setzen 619*cdf0e10cSrcweir rNewSize.Width() = nCols * aItemSize.Width() + nScrollWidth + 4; 620*cdf0e10cSrcweir rNewSize.Height() = nLines * aItemSize.Height() + 4; 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir /************************************************************************* 624*cdf0e10cSrcweir |* 625*cdf0e10cSrcweir |* Resize 626*cdf0e10cSrcweir |* 627*cdf0e10cSrcweir \************************************************************************/ 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir void SvxColorDockingWindow::Resize() 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir if ( !IsFloatingMode() || !GetFloatingWindow()->IsRollUp() ) 632*cdf0e10cSrcweir SetSize(); 633*cdf0e10cSrcweir SfxDockingWindow::Resize(); 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir void SvxColorDockingWindow::GetFocus (void) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir SfxDockingWindow::GetFocus(); 641*cdf0e10cSrcweir // Grab the focus to the color value set so that it can be controlled 642*cdf0e10cSrcweir // with the keyboard. 643*cdf0e10cSrcweir aColorSet.GrabFocus(); 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir long SvxColorDockingWindow::Notify( NotifyEvent& rNEvt ) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir long nRet = 0; 649*cdf0e10cSrcweir if( ( rNEvt.GetType() == EVENT_KEYINPUT ) ) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); 652*cdf0e10cSrcweir sal_uInt16 nKeyCode = aKeyEvt.GetKeyCode().GetCode(); 653*cdf0e10cSrcweir switch( nKeyCode ) 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir case KEY_ESCAPE: 656*cdf0e10cSrcweir GrabFocusToDocument(); 657*cdf0e10cSrcweir nRet = 1; 658*cdf0e10cSrcweir break; 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir return nRet ? nRet : SfxDockingWindow::Notify( rNEvt ); 663*cdf0e10cSrcweir } 664