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 --------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 34*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 35*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX //autogen 36*cdf0e10cSrcweir #include <vcl/button.hxx> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir #include <svl/intitem.hxx> 39*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 40*cdf0e10cSrcweir #include <sfx2/app.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <svx/dialogs.hrc> 43*cdf0e10cSrcweir #include "svx/layctrl.hxx" 44*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 45*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 46*cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // namespaces 49*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 50*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 51*cdf0e10cSrcweir using namespace ::com::sun::star::util; 52*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL(SvxTableToolBoxControl,SfxUInt16Item); 55*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl,SfxUInt16Item); 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir // class TableWindow ----------------------------------------------------- 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir class TableWindow : public SfxPopupWindow 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir private: 62*cdf0e10cSrcweir ::Color aLineColor; 63*cdf0e10cSrcweir ::Color aHighlightLineColor; 64*cdf0e10cSrcweir ::Color aFillColor; 65*cdf0e10cSrcweir ::Color aHighlightFillColor; 66*cdf0e10cSrcweir long nCol; 67*cdf0e10cSrcweir long nLine; 68*cdf0e10cSrcweir long nWidth; 69*cdf0e10cSrcweir long nHeight; 70*cdf0e10cSrcweir long nMX; 71*cdf0e10cSrcweir long nMY; 72*cdf0e10cSrcweir long nTextHeight; 73*cdf0e10cSrcweir sal_Bool bInitialKeyInput; 74*cdf0e10cSrcweir sal_Bool m_bMod1; 75*cdf0e10cSrcweir ToolBox& rTbx; 76*cdf0e10cSrcweir Reference< XFrame > mxFrame; 77*cdf0e10cSrcweir rtl::OUString maCommand; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir void UpdateSize_Impl( long nNewCol, long nNewLine); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir public: 82*cdf0e10cSrcweir TableWindow( sal_uInt16 nSlotId, 83*cdf0e10cSrcweir const rtl::OUString& rCmd, 84*cdf0e10cSrcweir ToolBox& rParentTbx, 85*cdf0e10cSrcweir const Reference< XFrame >& rFrame ); 86*cdf0e10cSrcweir ~TableWindow(); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir void KeyInput( const KeyEvent& rKEvt ); 89*cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& rMEvt ); 90*cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 91*cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& rMEvt ); 92*cdf0e10cSrcweir virtual void Paint( const Rectangle& ); 93*cdf0e10cSrcweir virtual void PopupModeEnd(); 94*cdf0e10cSrcweir virtual SfxPopupWindow* Clone() const; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir sal_uInt16 GetColCount() const { return (sal_uInt16)nCol; } 97*cdf0e10cSrcweir sal_uInt16 GetLineCount() const { return (sal_uInt16)nLine; } 98*cdf0e10cSrcweir }; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir // ----------------------------------------------------------------------- 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir TableWindow::TableWindow( sal_uInt16 nSlotId, const rtl::OUString& rCmd, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) : 103*cdf0e10cSrcweir SfxPopupWindow( nSlotId, rFrame, WB_SYSTEMWINDOW ), 104*cdf0e10cSrcweir bInitialKeyInput(sal_True), 105*cdf0e10cSrcweir m_bMod1(sal_False), 106*cdf0e10cSrcweir rTbx(rParentTbx), 107*cdf0e10cSrcweir mxFrame( rFrame ), 108*cdf0e10cSrcweir maCommand( rCmd ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 111*cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 112*cdf0e10cSrcweir aLineColor = ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 113*cdf0e10cSrcweir aHighlightLineColor = rStyles.GetHighlightTextColor(); 114*cdf0e10cSrcweir aFillColor = rStyles.GetWindowColor(); 115*cdf0e10cSrcweir aHighlightFillColor = rStyles.GetHighlightColor(); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir nTextHeight = GetTextHeight()+1; 118*cdf0e10cSrcweir SetBackground(); 119*cdf0e10cSrcweir Font aFont = GetFont(); 120*cdf0e10cSrcweir aFont.SetColor( aLineColor ); 121*cdf0e10cSrcweir aFont.SetFillColor( aFillColor ); 122*cdf0e10cSrcweir aFont.SetTransparent( sal_False ); 123*cdf0e10cSrcweir SetFont( aFont ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir nCol = 0; 126*cdf0e10cSrcweir nLine = 0; 127*cdf0e10cSrcweir nWidth = 5; 128*cdf0e10cSrcweir nHeight = 5; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir Size aLogicSize = LogicToPixel( Size( 55, 35 ), MapMode( MAP_10TH_MM ) ); 131*cdf0e10cSrcweir nMX = aLogicSize.Width(); 132*cdf0e10cSrcweir nMY = aLogicSize.Height(); 133*cdf0e10cSrcweir SetOutputSizePixel( Size( nMX*nWidth-1, nMY*nHeight-1+nTextHeight ) ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir // ----------------------------------------------------------------------- 136*cdf0e10cSrcweir TableWindow::~TableWindow() 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir // ----------------------------------------------------------------------- 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir SfxPopupWindow* TableWindow::Clone() const 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir return new TableWindow( GetId(), maCommand, rTbx, mxFrame ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir // ----------------------------------------------------------------------- 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir void TableWindow::MouseMove( const MouseEvent& rMEvt ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir SfxPopupWindow::MouseMove( rMEvt ); 151*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 152*cdf0e10cSrcweir Point aMousePos( aPos ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir if ( rMEvt.IsEnterWindow() ) 155*cdf0e10cSrcweir CaptureMouse(); 156*cdf0e10cSrcweir else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir nCol = 0; 159*cdf0e10cSrcweir nLine = 0; 160*cdf0e10cSrcweir ReleaseMouse(); 161*cdf0e10cSrcweir Invalidate(); 162*cdf0e10cSrcweir return; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir long nNewCol = 0; 166*cdf0e10cSrcweir long nNewLine = 0; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir if ( aPos.X() > 0 ) 169*cdf0e10cSrcweir nNewCol = aPos.X() / nMX + 1; 170*cdf0e10cSrcweir if ( aPos.Y() > 0 ) 171*cdf0e10cSrcweir nNewLine = aPos.Y() / nMY + 1; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if ( nNewCol > 500 ) 174*cdf0e10cSrcweir nNewCol = 500; 175*cdf0e10cSrcweir if ( nNewLine > 1000 ) 176*cdf0e10cSrcweir nNewLine = 1000; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir UpdateSize_Impl( nNewCol, nNewLine); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir /* -----------------------------15.05.2002 17:14------------------------------ 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 184*cdf0e10cSrcweir void TableWindow::UpdateSize_Impl( long nNewCol, long nNewLine) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir Size aWinSize = GetOutputSizePixel(); 187*cdf0e10cSrcweir Point aWinPos = GetPosPixel(); 188*cdf0e10cSrcweir Point aMaxPos = OutputToScreenPixel( GetDesktopRectPixel().BottomRight() ); 189*cdf0e10cSrcweir if ( (nWidth <= nNewCol) || (nHeight < nNewLine) ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir long nOff = 0; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if ( nWidth <= nNewCol ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir nWidth = nNewCol; 196*cdf0e10cSrcweir nWidth++; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir if ( nHeight <= nNewLine ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir nHeight = nNewLine; 201*cdf0e10cSrcweir nOff = 1; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir while ( nWidth > 0 && 204*cdf0e10cSrcweir (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 ) 205*cdf0e10cSrcweir nWidth--; 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir while ( nHeight > 0 && 208*cdf0e10cSrcweir (short)(aWinPos.Y()+(nMY*nHeight-1+nTextHeight)) >= 209*cdf0e10cSrcweir aMaxPos.Y()-3 ) 210*cdf0e10cSrcweir nHeight--; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir if ( nNewCol > nWidth ) 213*cdf0e10cSrcweir nNewCol = nWidth; 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir if ( nNewLine > nHeight ) 216*cdf0e10cSrcweir nNewLine = nHeight; 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir Size _aWinSize = GetOutputSizePixel(); 219*cdf0e10cSrcweir Invalidate( Rectangle( 0, _aWinSize.Height()-nTextHeight+2-nOff, 220*cdf0e10cSrcweir _aWinSize.Width(), _aWinSize.Height() ) ); 221*cdf0e10cSrcweir SetOutputSizePixel( Size( nMX*nWidth-1, nMY*nHeight-1+nTextHeight ) ); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir long nMinCol = 0; 224*cdf0e10cSrcweir long nMaxCol = 0; 225*cdf0e10cSrcweir long nMinLine = 0; 226*cdf0e10cSrcweir long nMaxLine = 0; 227*cdf0e10cSrcweir if ( nNewCol < nCol ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir nMinCol = nNewCol; 230*cdf0e10cSrcweir nMaxCol = nCol; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir else 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir nMinCol = nCol; 235*cdf0e10cSrcweir nMaxCol = nNewCol; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir if ( nNewLine < nLine ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir nMinLine = nNewLine; 240*cdf0e10cSrcweir nMaxLine = nLine; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir else 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir nMinLine = nLine; 245*cdf0e10cSrcweir nMaxLine = nNewLine; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if ( (nNewCol != nCol) || (nNewLine != nLine) ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2, 251*cdf0e10cSrcweir aWinSize.Width(), aWinSize.Height() ) ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir if ( nNewCol != nCol ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir Invalidate( Rectangle( nMinCol*nMX-1, 0, nMaxCol*nMX+1, nMaxLine*nMY ) ); 256*cdf0e10cSrcweir nCol = nNewCol; 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir if ( nNewLine != nLine ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir Invalidate( Rectangle( 0, nMinLine*nMY-2, nMaxCol*nMX, nMaxLine*nMY+1 ) ); 261*cdf0e10cSrcweir nLine = nNewLine; 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir Update(); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir /* -----------------------------15.05.2002 14:22------------------------------ 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 269*cdf0e10cSrcweir void TableWindow::KeyInput( const KeyEvent& rKEvt ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir sal_Bool bHandled = sal_False; 272*cdf0e10cSrcweir sal_uInt16 nModifier = rKEvt.GetKeyCode().GetModifier(); 273*cdf0e10cSrcweir sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode(); 274*cdf0e10cSrcweir if(!nModifier) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir if( KEY_UP == nKey || KEY_DOWN == nKey || 277*cdf0e10cSrcweir KEY_LEFT == nKey || KEY_RIGHT == nKey || 278*cdf0e10cSrcweir KEY_ESCAPE == nKey ||KEY_RETURN == nKey ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir bHandled = sal_True; 281*cdf0e10cSrcweir long nNewCol = nCol; 282*cdf0e10cSrcweir long nNewLine = nLine; 283*cdf0e10cSrcweir switch(nKey) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir case KEY_UP : 286*cdf0e10cSrcweir if(nNewLine > 1) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir nNewLine--; 289*cdf0e10cSrcweir break; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir //no break; 292*cdf0e10cSrcweir case KEY_ESCAPE: 293*cdf0e10cSrcweir EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL); 294*cdf0e10cSrcweir break; 295*cdf0e10cSrcweir case KEY_DOWN : 296*cdf0e10cSrcweir nNewLine++; 297*cdf0e10cSrcweir break; 298*cdf0e10cSrcweir case KEY_LEFT : 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if(nNewCol) 301*cdf0e10cSrcweir nNewCol--; 302*cdf0e10cSrcweir break; 303*cdf0e10cSrcweir case KEY_RIGHT : 304*cdf0e10cSrcweir nNewCol++; 305*cdf0e10cSrcweir break; 306*cdf0e10cSrcweir case KEY_RETURN : 307*cdf0e10cSrcweir if(IsMouseCaptured()) 308*cdf0e10cSrcweir ReleaseMouse(); 309*cdf0e10cSrcweir EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL ); 310*cdf0e10cSrcweir break; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir //make sure that a table can initially be created 313*cdf0e10cSrcweir if(bInitialKeyInput) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir bInitialKeyInput = sal_False; 316*cdf0e10cSrcweir if(!nNewLine) 317*cdf0e10cSrcweir nNewLine = 1; 318*cdf0e10cSrcweir if(!nNewCol) 319*cdf0e10cSrcweir nNewCol = 1; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir UpdateSize_Impl( nNewCol, nNewLine); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir m_bMod1 = sal_True; 327*cdf0e10cSrcweir if(IsMouseCaptured()) 328*cdf0e10cSrcweir ReleaseMouse(); 329*cdf0e10cSrcweir EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL ); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir if(!bHandled) 333*cdf0e10cSrcweir SfxPopupWindow::KeyInput(rKEvt); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir // ----------------------------------------------------------------------- 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir void TableWindow::MouseButtonDown( const MouseEvent& rMEvt ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir SfxPopupWindow::MouseButtonDown( rMEvt ); 341*cdf0e10cSrcweir CaptureMouse(); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // ----------------------------------------------------------------------- 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir void TableWindow::MouseButtonUp( const MouseEvent& rMEvt ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir SfxPopupWindow::MouseButtonUp( rMEvt ); 349*cdf0e10cSrcweir ReleaseMouse(); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir if ( IsInPopupMode() ) 352*cdf0e10cSrcweir EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir // ----------------------------------------------------------------------- 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir void TableWindow::Paint( const Rectangle& ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir long i; 360*cdf0e10cSrcweir long nStart; 361*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir SetLineColor(); 364*cdf0e10cSrcweir SetFillColor( aHighlightFillColor ); 365*cdf0e10cSrcweir DrawRect( Rectangle( 0, 0, nCol*nMX-1, nLine*nMY-1 ) ); 366*cdf0e10cSrcweir SetFillColor( aFillColor ); 367*cdf0e10cSrcweir DrawRect( Rectangle( nCol*nMX-1, 0, 368*cdf0e10cSrcweir aSize.Width(), aSize.Height()-nTextHeight+1 ) ); 369*cdf0e10cSrcweir DrawRect( Rectangle( 0, nLine*nMY-1, 370*cdf0e10cSrcweir aSize.Width(), aSize.Height()-nTextHeight+1 ) ); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir SetLineColor( aHighlightLineColor ); 373*cdf0e10cSrcweir for ( i = 1; i < nCol; i++ ) 374*cdf0e10cSrcweir DrawLine( Point( i*nMX-1, 0 ), Point( i*nMX-1, nLine*nMY-1 ) ); 375*cdf0e10cSrcweir for ( i = 1; i < nLine; i++ ) 376*cdf0e10cSrcweir DrawLine( Point( 0, i*nMY-1 ), Point( nCol*nMX-1, i*nMY-1 ) ); 377*cdf0e10cSrcweir SetLineColor( aLineColor ); 378*cdf0e10cSrcweir for ( i = 1; i <= nWidth; i++ ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir if ( i < nCol ) 381*cdf0e10cSrcweir nStart = nLine*nMY-1; 382*cdf0e10cSrcweir else 383*cdf0e10cSrcweir nStart = 0; 384*cdf0e10cSrcweir DrawLine( Point( i*nMX-1, nStart ), Point( i*nMX-1, nHeight*nMY-1 ) ); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir for ( i = 1; i <= nHeight; i++ ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir if ( i < nLine ) 389*cdf0e10cSrcweir nStart = nCol*nMX-1; 390*cdf0e10cSrcweir else 391*cdf0e10cSrcweir nStart = 0; 392*cdf0e10cSrcweir DrawLine( Point( nStart, i*nMY-1 ), Point( nWidth*nMX-1, i*nMY-1 ) ); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir SetLineColor(); 396*cdf0e10cSrcweir String aText; 397*cdf0e10cSrcweir if ( nCol && nLine ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir aText += String::CreateFromInt32( nCol ); 400*cdf0e10cSrcweir aText.AppendAscii( " x " ); 401*cdf0e10cSrcweir aText += String::CreateFromInt32( nLine ); 402*cdf0e10cSrcweir if(GetId() == FN_SHOW_MULTIPLE_PAGES) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir aText += ' '; 405*cdf0e10cSrcweir aText += String(SVX_RESSTR(RID_SVXSTR_PAGES)); 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir else 410*cdf0e10cSrcweir aText = Button::GetStandardText( BUTTON_CANCEL ); 411*cdf0e10cSrcweir Size aTextSize( GetTextWidth( aText ), GetTextHeight() ); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir Rectangle aClearRect( 0, aSize.Height()-nTextHeight+2, (aSize.Width()), aSize.Height() ); 414*cdf0e10cSrcweir DrawRect( aClearRect ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir // #i95350# force RTL output 417*cdf0e10cSrcweir if( IsRTLEnabled() && nCol && nLine ) 418*cdf0e10cSrcweir aText.Insert(0x202D, 0); 419*cdf0e10cSrcweir DrawText( Point( (aSize.Width() - aTextSize.Width()) / 2, aSize.Height() - nTextHeight + 2 ), aText ); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir SetLineColor( aLineColor ); 422*cdf0e10cSrcweir SetFillColor(); 423*cdf0e10cSrcweir DrawRect( Rectangle( Point(0,0), aSize ) ); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir // ----------------------------------------------------------------------- 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir void TableWindow::PopupModeEnd() 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir if ( !IsPopupModeCanceled() && nCol && nLine ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir Window* pParent = rTbx.GetParent(); 433*cdf0e10cSrcweir sal_uInt16 nId = GetId(); 434*cdf0e10cSrcweir pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId)); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir Reference< XDispatchProvider > xDispatchProvider( mxFrame, UNO_QUERY ); 437*cdf0e10cSrcweir if ( xDispatchProvider.is() ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir com::sun::star::util::URL aTargetURL; 440*cdf0e10cSrcweir Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( 441*cdf0e10cSrcweir rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), 442*cdf0e10cSrcweir UNO_QUERY ); 443*cdf0e10cSrcweir aTargetURL.Complete = maCommand; 444*cdf0e10cSrcweir xTrans->parseStrict( aTargetURL ); 445*cdf0e10cSrcweir Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); 446*cdf0e10cSrcweir if ( xDispatch.is() ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 2 ); 449*cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" )); 450*cdf0e10cSrcweir aArgs[0].Value = makeAny( sal_Int16( nCol )); 451*cdf0e10cSrcweir aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rows" )); 452*cdf0e10cSrcweir aArgs[1].Value = makeAny( sal_Int16( nLine )); 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir xDispatch->dispatch( aTargetURL, aArgs ); 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir else if ( IsPopupModeCanceled() ) 459*cdf0e10cSrcweir ReleaseMouse(); 460*cdf0e10cSrcweir SfxPopupWindow::PopupModeEnd(); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir // class ColumnsWindow --------------------------------------------------- 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir class ColumnsWindow : public SfxPopupWindow 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir private: 468*cdf0e10cSrcweir ::Color aLineColor; 469*cdf0e10cSrcweir ::Color aHighlightLineColor; 470*cdf0e10cSrcweir ::Color aFillColor; 471*cdf0e10cSrcweir ::Color aHighlightFillColor; 472*cdf0e10cSrcweir long nCol; 473*cdf0e10cSrcweir long nWidth; 474*cdf0e10cSrcweir long nMX; 475*cdf0e10cSrcweir long nTextHeight; 476*cdf0e10cSrcweir sal_Bool bInitialKeyInput; 477*cdf0e10cSrcweir sal_Bool m_bMod1; 478*cdf0e10cSrcweir ToolBox& rTbx; 479*cdf0e10cSrcweir Reference< XFrame > mxFrame; 480*cdf0e10cSrcweir ::rtl::OUString maCommand; 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir void UpdateSize_Impl( long nNewCol ); 483*cdf0e10cSrcweir public: 484*cdf0e10cSrcweir ColumnsWindow( sal_uInt16 nId, const ::rtl::OUString& rCmd, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir void KeyInput( const KeyEvent& rKEvt ); 487*cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& rMEvt ); 488*cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 489*cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& rMEvt ); 490*cdf0e10cSrcweir virtual void Paint( const Rectangle& ); 491*cdf0e10cSrcweir virtual void PopupModeEnd(); 492*cdf0e10cSrcweir virtual SfxPopupWindow* Clone() const; 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir sal_uInt16 GetColCount() const { return (sal_uInt16)nCol; } 495*cdf0e10cSrcweir }; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir // ----------------------------------------------------------------------- 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir ColumnsWindow::ColumnsWindow( sal_uInt16 nId, const ::rtl::OUString& rCmd, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) : 500*cdf0e10cSrcweir SfxPopupWindow( nId, rFrame, WB_SYSTEMWINDOW ), 501*cdf0e10cSrcweir bInitialKeyInput(sal_True), 502*cdf0e10cSrcweir m_bMod1(sal_False), 503*cdf0e10cSrcweir rTbx(rParentTbx), 504*cdf0e10cSrcweir mxFrame(rFrame), 505*cdf0e10cSrcweir maCommand( rCmd ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 508*cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 509*cdf0e10cSrcweir aLineColor = ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 510*cdf0e10cSrcweir aHighlightLineColor = rStyles.GetHighlightTextColor(); 511*cdf0e10cSrcweir aFillColor = rStyles.GetWindowColor(); 512*cdf0e10cSrcweir aHighlightFillColor = rStyles.GetHighlightColor(); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir nTextHeight = GetTextHeight()+1; 515*cdf0e10cSrcweir SetBackground(); 516*cdf0e10cSrcweir Font aFont( GetFont() ); 517*cdf0e10cSrcweir aFont.SetColor( aLineColor ); 518*cdf0e10cSrcweir aFont.SetFillColor( aFillColor ); 519*cdf0e10cSrcweir aFont.SetTransparent( sal_False ); 520*cdf0e10cSrcweir SetFont( aFont ); 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir nCol = 0; 523*cdf0e10cSrcweir nWidth = 4; 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir Size aLogicSize = LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM ) ); 526*cdf0e10cSrcweir nMX = aLogicSize.Width(); 527*cdf0e10cSrcweir SetOutputSizePixel( Size( nMX*nWidth-1, aLogicSize.Height()+nTextHeight ) ); 528*cdf0e10cSrcweir StartCascading(); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // ----------------------------------------------------------------------- 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir SfxPopupWindow* ColumnsWindow::Clone() const 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir return new ColumnsWindow( GetId(), maCommand, rTbx, mxFrame ); 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir // ----------------------------------------------------------------------- 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir void ColumnsWindow::MouseMove( const MouseEvent& rMEvt ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir SfxPopupWindow::MouseMove( rMEvt ); 543*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 544*cdf0e10cSrcweir Point aMousePos = aPos; 545*cdf0e10cSrcweir Point aWinPos = GetPosPixel(); 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir if ( rMEvt.IsEnterWindow() ) 548*cdf0e10cSrcweir CaptureMouse(); 549*cdf0e10cSrcweir else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir nCol = 0; 552*cdf0e10cSrcweir ReleaseMouse(); 553*cdf0e10cSrcweir Invalidate(); 554*cdf0e10cSrcweir return; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir long nNewCol = 0; 558*cdf0e10cSrcweir if ( aPos.X() > 0 ) 559*cdf0e10cSrcweir nNewCol = aPos.X() / nMX + 1; 560*cdf0e10cSrcweir if ( aPos.Y() < 0 ) 561*cdf0e10cSrcweir nNewCol = 0; 562*cdf0e10cSrcweir if ( nNewCol > 20 ) 563*cdf0e10cSrcweir nNewCol = 20; 564*cdf0e10cSrcweir UpdateSize_Impl( nNewCol ); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir /* -----------------------------21.05.2002 16:16------------------------------ 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 569*cdf0e10cSrcweir void ColumnsWindow::UpdateSize_Impl( long nNewCol ) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir Size aWinSize = GetOutputSizePixel(); 572*cdf0e10cSrcweir long nMinCol = 0; 573*cdf0e10cSrcweir long nMaxCol = 0; 574*cdf0e10cSrcweir Point aWinPos;// = GetPosPixel(); 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir if ( nWidth <= nNewCol ) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir Point aMaxPos = OutputToScreenPixel( GetDesktopRectPixel().BottomRight() ); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir if ( nWidth <= nNewCol ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir nWidth = nNewCol; 583*cdf0e10cSrcweir nWidth++; 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir while ( nWidth > 0 && 587*cdf0e10cSrcweir (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 ) 588*cdf0e10cSrcweir nWidth--; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir if ( nNewCol > nWidth ) 591*cdf0e10cSrcweir nNewCol = nWidth; 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2, 594*cdf0e10cSrcweir aWinSize.Width(), aWinSize.Height() ) ); 595*cdf0e10cSrcweir SetOutputSizePixel( Size( nMX*nWidth-1, aWinSize.Height() ) ); 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir if ( nNewCol != nCol ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2, 602*cdf0e10cSrcweir aWinSize.Width(), aWinSize.Height() ) ); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir if ( nNewCol < nCol ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir nMinCol = nNewCol; 607*cdf0e10cSrcweir nMaxCol = nCol; 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir else 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir nMinCol = nCol; 612*cdf0e10cSrcweir nMaxCol = nNewCol; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir Invalidate( Rectangle( nMinCol*nMX-1, 0, 616*cdf0e10cSrcweir nMaxCol*nMX+1, aWinSize.Height()-nTextHeight+2 ) ); 617*cdf0e10cSrcweir nCol = nNewCol; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir Update(); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir // ----------------------------------------------------------------------- 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir void ColumnsWindow::MouseButtonDown( const MouseEvent& rMEvt ) 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir SfxPopupWindow::MouseButtonDown( rMEvt ); 626*cdf0e10cSrcweir CaptureMouse(); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir /* -----------------------------21.05.2002 16:11------------------------------ 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 631*cdf0e10cSrcweir void ColumnsWindow::KeyInput( const KeyEvent& rKEvt ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir sal_Bool bHandled = sal_False; 634*cdf0e10cSrcweir sal_uInt16 nModifier = rKEvt.GetKeyCode().GetModifier(); 635*cdf0e10cSrcweir sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode(); 636*cdf0e10cSrcweir if(!nModifier) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir if( KEY_LEFT == nKey || KEY_RIGHT == nKey || 639*cdf0e10cSrcweir KEY_RETURN == nKey ||KEY_ESCAPE == nKey || 640*cdf0e10cSrcweir KEY_UP == nKey) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir bHandled = sal_True; 643*cdf0e10cSrcweir long nNewCol = nCol; 644*cdf0e10cSrcweir switch(nKey) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir case KEY_LEFT : 647*cdf0e10cSrcweir if(nNewCol) 648*cdf0e10cSrcweir nNewCol--; 649*cdf0e10cSrcweir break; 650*cdf0e10cSrcweir case KEY_RIGHT : 651*cdf0e10cSrcweir nNewCol++; 652*cdf0e10cSrcweir break; 653*cdf0e10cSrcweir case KEY_RETURN : 654*cdf0e10cSrcweir if(IsMouseCaptured()) 655*cdf0e10cSrcweir ReleaseMouse(); 656*cdf0e10cSrcweir EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL ); 657*cdf0e10cSrcweir break; 658*cdf0e10cSrcweir case KEY_ESCAPE : 659*cdf0e10cSrcweir case KEY_UP : 660*cdf0e10cSrcweir EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL); 661*cdf0e10cSrcweir break; 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir //make sure that a table can initially be created 664*cdf0e10cSrcweir if(bInitialKeyInput) 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir bInitialKeyInput = sal_False; 667*cdf0e10cSrcweir if(!nNewCol) 668*cdf0e10cSrcweir nNewCol = 1; 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir UpdateSize_Impl( nNewCol ); 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir m_bMod1 = sal_True; 676*cdf0e10cSrcweir if(IsMouseCaptured()) 677*cdf0e10cSrcweir ReleaseMouse(); 678*cdf0e10cSrcweir EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL ); 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir if(!bHandled) 681*cdf0e10cSrcweir SfxPopupWindow::KeyInput(rKEvt); 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // ----------------------------------------------------------------------- 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir SfxPopupWindow::MouseButtonUp( rMEvt ); 689*cdf0e10cSrcweir ReleaseMouse(); 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir if ( IsInPopupMode() ) 692*cdf0e10cSrcweir EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir // ----------------------------------------------------------------------- 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir void ColumnsWindow::Paint( const Rectangle& ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir long i; 700*cdf0e10cSrcweir long j; 701*cdf0e10cSrcweir long nLineWidth; 702*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir for ( i = 0; i < nWidth; i++ ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir if ( i < nCol ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir SetLineColor( aHighlightLineColor ); 709*cdf0e10cSrcweir SetFillColor( aHighlightFillColor ); 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir else 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir SetLineColor( aLineColor ); 714*cdf0e10cSrcweir SetFillColor( aFillColor ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir DrawRect( Rectangle( i*nMX-1, -1, 718*cdf0e10cSrcweir i*nMX+nMX, aSize.Height()-nTextHeight+1 ) ); 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir j = 4; 721*cdf0e10cSrcweir while ( j < aSize.Height()-nTextHeight-4 ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir if ( !(j % 16) ) 724*cdf0e10cSrcweir nLineWidth = 10; 725*cdf0e10cSrcweir else 726*cdf0e10cSrcweir nLineWidth = 4; 727*cdf0e10cSrcweir DrawLine( Point( i*nMX+4, j ), Point( i*nMX+nMX-nLineWidth-4, j ) ); 728*cdf0e10cSrcweir j += 4; 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir SetLineColor(); 733*cdf0e10cSrcweir SetFillColor( aFillColor ); 734*cdf0e10cSrcweir String aText; 735*cdf0e10cSrcweir if ( nCol ) 736*cdf0e10cSrcweir aText = String( String::CreateFromInt32(nCol) ); 737*cdf0e10cSrcweir else 738*cdf0e10cSrcweir aText = Button::GetStandardText( BUTTON_CANCEL ); 739*cdf0e10cSrcweir Size aTextSize(GetTextWidth( aText ), GetTextHeight()); 740*cdf0e10cSrcweir DrawText( Point( ( aSize.Width() - aTextSize.Width() ) / 2, aSize.Height() - nTextHeight + 2 ), aText ); 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir DrawRect( Rectangle( 0, aSize.Height()-nTextHeight+2, (aSize.Width()-aTextSize.Width())/2-1, aSize.Height() ) ); 743*cdf0e10cSrcweir DrawRect( Rectangle( (aSize.Width()-aTextSize.Width())/2+aTextSize.Width(), aSize.Height()-nTextHeight+2, aSize.Width(), aSize.Height() ) ); 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir SetLineColor( aLineColor ); 746*cdf0e10cSrcweir SetFillColor(); 747*cdf0e10cSrcweir DrawRect( Rectangle( Point(0,0), aSize ) ); 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir // ----------------------------------------------------------------------- 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir void ColumnsWindow::PopupModeEnd() 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir if ( !IsPopupModeCanceled() && nCol ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir sal_uInt16 nId = GetId(); 757*cdf0e10cSrcweir Window* pParent = rTbx.GetParent(); 758*cdf0e10cSrcweir pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId)); 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 2 ); 761*cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" )); 762*cdf0e10cSrcweir aArgs[0].Value = makeAny( sal_Int16( nCol )); 763*cdf0e10cSrcweir aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Modifier" )); 764*cdf0e10cSrcweir aArgs[1].Value = makeAny( sal_Int16( m_bMod1 ? KEY_MOD1 : 0 )); 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), 767*cdf0e10cSrcweir maCommand, 768*cdf0e10cSrcweir aArgs ); 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir else if ( IsPopupModeCanceled() ) 771*cdf0e10cSrcweir ReleaseMouse(); 772*cdf0e10cSrcweir SfxPopupWindow::PopupModeEnd(); 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir // class SvxTableToolBoxControl ------------------------------------------ 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir SvxTableToolBoxControl::SvxTableToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 778*cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ), 779*cdf0e10cSrcweir bEnabled( sal_True ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 782*cdf0e10cSrcweir rTbx.Invalidate(); 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir // ----------------------------------------------------------------------- 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir SvxTableToolBoxControl::~SvxTableToolBoxControl() 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir // ----------------------------------------------------------------------- 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir SfxPopupWindowType SvxTableToolBoxControl::GetPopupWindowType() const 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE; 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir // ----------------------------------------------------------------------- 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindow() 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir if ( bEnabled ) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir ToolBox& rTbx = GetToolBox(); 805*cdf0e10cSrcweir TableWindow* pWin = new TableWindow( GetSlotId(), m_aCommandURL, rTbx, m_xFrame ); 806*cdf0e10cSrcweir pWin->StartPopupMode( &rTbx, FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE ); 807*cdf0e10cSrcweir SetPopupWindow( pWin ); 808*cdf0e10cSrcweir return pWin; 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir return 0; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir // ----------------------------------------------------------------------- 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindowCascading() 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir if ( bEnabled ) 818*cdf0e10cSrcweir return new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox(), m_xFrame ); 819*cdf0e10cSrcweir return 0; 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir // ----------------------------------------------------------------------- 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir void SvxTableToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir if ( pState && pState->ISA(SfxUInt16Item) ) 827*cdf0e10cSrcweir { 828*cdf0e10cSrcweir sal_Int16 nValue = static_cast< const SfxUInt16Item* >( pState )->GetValue(); 829*cdf0e10cSrcweir bEnabled = ( nValue != 0 ); 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir else 832*cdf0e10cSrcweir bEnabled = SFX_ITEM_DISABLED != eState; 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir sal_uInt16 nId = GetId(); 835*cdf0e10cSrcweir ToolBox& rTbx = GetToolBox(); 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState ); 838*cdf0e10cSrcweir rTbx.SetItemState( nId, 839*cdf0e10cSrcweir ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK ); 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir // class SvxColumnsToolBoxControl ------------------------------------------ 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir SvxColumnsToolBoxControl::SvxColumnsToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 845*cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 848*cdf0e10cSrcweir rTbx.Invalidate(); 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir // ----------------------------------------------------------------------- 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl() 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // ----------------------------------------------------------------------- 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir SfxPopupWindowType SvxColumnsToolBoxControl::GetPopupWindowType() const 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE; 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir // ----------------------------------------------------------------------- 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindow() 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir ColumnsWindow* pWin = 0; 869*cdf0e10cSrcweir if(bEnabled) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox(), m_xFrame ); 872*cdf0e10cSrcweir pWin->StartPopupMode( &GetToolBox(), 873*cdf0e10cSrcweir FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE ); 874*cdf0e10cSrcweir SetPopupWindow( pWin ); 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir return pWin; 877*cdf0e10cSrcweir } 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir // ----------------------------------------------------------------------- 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindowCascading() 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir ColumnsWindow* pWin = 0; 884*cdf0e10cSrcweir if(bEnabled) 885*cdf0e10cSrcweir { 886*cdf0e10cSrcweir pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox(), m_xFrame ); 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir return pWin; 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir /* -----------------18.11.99 16:38------------------- 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir --------------------------------------------------*/ 893*cdf0e10cSrcweir void SvxColumnsToolBoxControl::StateChanged( sal_uInt16 nSID, 894*cdf0e10cSrcweir SfxItemState eState, 895*cdf0e10cSrcweir const SfxPoolItem* pState ) 896*cdf0e10cSrcweir { 897*cdf0e10cSrcweir bEnabled = SFX_ITEM_DISABLED != eState; 898*cdf0e10cSrcweir SfxToolBoxControl::StateChanged(nSID, eState, pState ); 899*cdf0e10cSrcweir } 900