merge the formfield patch from ooo-build
[ooovba.git] / svx / source / tbxctrls / layctrl.cxx
blob18101465bcf94a8132557262c9f4cc9f186080eb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: layctrl.cxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
36 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
37 #include <vcl/toolbox.hxx>
38 #ifndef _SV_BUTTON_HXX //autogen
39 #include <vcl/button.hxx>
40 #endif
41 #include <svtools/intitem.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/app.hxx>
45 #include <svx/dialogs.hrc>
46 #include "layctrl.hxx"
47 #include <svx/dialmgr.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include <svtools/colorcfg.hxx>
51 // namespaces
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::beans;
54 using namespace ::com::sun::star::util;
55 using namespace ::com::sun::star::frame;
57 SFX_IMPL_TOOLBOX_CONTROL(SvxTableToolBoxControl,SfxUInt16Item);
58 SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl,SfxUInt16Item);
60 // class TableWindow -----------------------------------------------------
62 class TableWindow : public SfxPopupWindow
64 private:
65 ::Color aLineColor;
66 ::Color aHighlightLineColor;
67 ::Color aFillColor;
68 ::Color aHighlightFillColor;
69 long nCol;
70 long nLine;
71 long nWidth;
72 long nHeight;
73 long nMX;
74 long nMY;
75 long nTextHeight;
76 BOOL bInitialKeyInput;
77 BOOL m_bMod1;
78 ToolBox& rTbx;
79 Reference< XFrame > mxFrame;
80 rtl::OUString maCommand;
82 void UpdateSize_Impl( long nNewCol, long nNewLine);
84 public:
85 TableWindow( USHORT nSlotId,
86 const rtl::OUString& rCmd,
87 ToolBox& rParentTbx,
88 const Reference< XFrame >& rFrame );
89 ~TableWindow();
91 void KeyInput( const KeyEvent& rKEvt );
92 virtual void MouseMove( const MouseEvent& rMEvt );
93 virtual void MouseButtonDown( const MouseEvent& rMEvt );
94 virtual void MouseButtonUp( const MouseEvent& rMEvt );
95 virtual void Paint( const Rectangle& );
96 virtual void PopupModeEnd();
97 virtual SfxPopupWindow* Clone() const;
99 USHORT GetColCount() const { return (USHORT)nCol; }
100 USHORT GetLineCount() const { return (USHORT)nLine; }
103 // -----------------------------------------------------------------------
105 TableWindow::TableWindow( USHORT nSlotId, const rtl::OUString& rCmd, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) :
106 SfxPopupWindow( nSlotId, rFrame, WB_SYSTEMWINDOW ),
107 bInitialKeyInput(TRUE),
108 m_bMod1(FALSE),
109 rTbx(rParentTbx),
110 mxFrame( rFrame ),
111 maCommand( rCmd )
113 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
114 svtools::ColorConfig aColorConfig;
115 aLineColor = ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
116 aHighlightLineColor = rStyles.GetHighlightTextColor();
117 aFillColor = rStyles.GetWindowColor();
118 aHighlightFillColor = rStyles.GetHighlightColor();
120 nTextHeight = GetTextHeight()+1;
121 SetBackground();
122 Font aFont = GetFont();
123 aFont.SetColor( aLineColor );
124 aFont.SetFillColor( aFillColor );
125 aFont.SetTransparent( FALSE );
126 SetFont( aFont );
128 nCol = 0;
129 nLine = 0;
130 nWidth = 5;
131 nHeight = 5;
133 Size aLogicSize = LogicToPixel( Size( 55, 35 ), MapMode( MAP_10TH_MM ) );
134 nMX = aLogicSize.Width();
135 nMY = aLogicSize.Height();
136 SetOutputSizePixel( Size( nMX*nWidth-1, nMY*nHeight-1+nTextHeight ) );
138 // -----------------------------------------------------------------------
139 TableWindow::~TableWindow()
142 // -----------------------------------------------------------------------
144 SfxPopupWindow* TableWindow::Clone() const
146 return new TableWindow( GetId(), maCommand, rTbx, mxFrame );
149 // -----------------------------------------------------------------------
151 void TableWindow::MouseMove( const MouseEvent& rMEvt )
153 SfxPopupWindow::MouseMove( rMEvt );
154 Point aPos = rMEvt.GetPosPixel();
155 Point aMousePos( aPos );
157 if ( rMEvt.IsEnterWindow() )
158 CaptureMouse();
159 else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 )
161 nCol = 0;
162 nLine = 0;
163 ReleaseMouse();
164 Invalidate();
165 return;
168 long nNewCol = 0;
169 long nNewLine = 0;
171 if ( aPos.X() > 0 )
172 nNewCol = aPos.X() / nMX + 1;
173 if ( aPos.Y() > 0 )
174 nNewLine = aPos.Y() / nMY + 1;
176 if ( nNewCol > 500 )
177 nNewCol = 500;
178 if ( nNewLine > 1000 )
179 nNewLine = 1000;
181 UpdateSize_Impl( nNewCol, nNewLine);
184 /* -----------------------------15.05.2002 17:14------------------------------
186 ---------------------------------------------------------------------------*/
187 void TableWindow::UpdateSize_Impl( long nNewCol, long nNewLine)
189 Size aWinSize = GetOutputSizePixel();
190 Point aWinPos = GetPosPixel();
191 Point aMaxPos = OutputToScreenPixel( GetDesktopRectPixel().BottomRight() );
192 if ( (nWidth <= nNewCol) || (nHeight < nNewLine) )
194 long nOff = 0;
196 if ( nWidth <= nNewCol )
198 nWidth = nNewCol;
199 nWidth++;
201 if ( nHeight <= nNewLine )
203 nHeight = nNewLine;
204 nOff = 1;
206 while ( nWidth > 0 &&
207 (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 )
208 nWidth--;
210 while ( nHeight > 0 &&
211 (short)(aWinPos.Y()+(nMY*nHeight-1+nTextHeight)) >=
212 aMaxPos.Y()-3 )
213 nHeight--;
215 if ( nNewCol > nWidth )
216 nNewCol = nWidth;
218 if ( nNewLine > nHeight )
219 nNewLine = nHeight;
221 Size _aWinSize = GetOutputSizePixel();
222 Invalidate( Rectangle( 0, _aWinSize.Height()-nTextHeight+2-nOff,
223 _aWinSize.Width(), _aWinSize.Height() ) );
224 SetOutputSizePixel( Size( nMX*nWidth-1, nMY*nHeight-1+nTextHeight ) );
226 long nMinCol = 0;
227 long nMaxCol = 0;
228 long nMinLine = 0;
229 long nMaxLine = 0;
230 if ( nNewCol < nCol )
232 nMinCol = nNewCol;
233 nMaxCol = nCol;
235 else
237 nMinCol = nCol;
238 nMaxCol = nNewCol;
240 if ( nNewLine < nLine )
242 nMinLine = nNewLine;
243 nMaxLine = nLine;
245 else
247 nMinLine = nLine;
248 nMaxLine = nNewLine;
251 if ( (nNewCol != nCol) || (nNewLine != nLine) )
253 Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2,
254 aWinSize.Width(), aWinSize.Height() ) );
256 if ( nNewCol != nCol )
258 Invalidate( Rectangle( nMinCol*nMX-1, 0, nMaxCol*nMX+1, nMaxLine*nMY ) );
259 nCol = nNewCol;
261 if ( nNewLine != nLine )
263 Invalidate( Rectangle( 0, nMinLine*nMY-2, nMaxCol*nMX, nMaxLine*nMY+1 ) );
264 nLine = nNewLine;
267 Update();
269 /* -----------------------------15.05.2002 14:22------------------------------
271 ---------------------------------------------------------------------------*/
272 void TableWindow::KeyInput( const KeyEvent& rKEvt )
274 BOOL bHandled = FALSE;
275 USHORT nModifier = rKEvt.GetKeyCode().GetModifier();
276 USHORT nKey = rKEvt.GetKeyCode().GetCode();
277 if(!nModifier)
279 if( KEY_UP == nKey || KEY_DOWN == nKey ||
280 KEY_LEFT == nKey || KEY_RIGHT == nKey ||
281 KEY_ESCAPE == nKey ||KEY_RETURN == nKey )
283 bHandled = TRUE;
284 long nNewCol = nCol;
285 long nNewLine = nLine;
286 switch(nKey)
288 case KEY_UP :
289 if(nNewLine > 1)
291 nNewLine--;
292 break;
294 //no break;
295 case KEY_ESCAPE:
296 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL);
297 break;
298 case KEY_DOWN :
299 nNewLine++;
300 break;
301 case KEY_LEFT :
303 if(nNewCol)
304 nNewCol--;
305 break;
306 case KEY_RIGHT :
307 nNewCol++;
308 break;
309 case KEY_RETURN :
310 if(IsMouseCaptured())
311 ReleaseMouse();
312 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
313 break;
315 //make sure that a table can initially be created
316 if(bInitialKeyInput)
318 bInitialKeyInput = FALSE;
319 if(!nNewLine)
320 nNewLine = 1;
321 if(!nNewCol)
322 nNewCol = 1;
324 UpdateSize_Impl( nNewCol, nNewLine);
327 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
329 m_bMod1 = TRUE;
330 if(IsMouseCaptured())
331 ReleaseMouse();
332 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
335 if(!bHandled)
336 SfxPopupWindow::KeyInput(rKEvt);
339 // -----------------------------------------------------------------------
341 void TableWindow::MouseButtonDown( const MouseEvent& rMEvt )
343 SfxPopupWindow::MouseButtonDown( rMEvt );
344 CaptureMouse();
347 // -----------------------------------------------------------------------
349 void TableWindow::MouseButtonUp( const MouseEvent& rMEvt )
351 SfxPopupWindow::MouseButtonUp( rMEvt );
352 ReleaseMouse();
354 if ( IsInPopupMode() )
355 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
358 // -----------------------------------------------------------------------
360 void TableWindow::Paint( const Rectangle& )
362 long i;
363 long nStart;
364 Size aSize = GetOutputSizePixel();
366 SetLineColor();
367 SetFillColor( aHighlightFillColor );
368 DrawRect( Rectangle( 0, 0, nCol*nMX-1, nLine*nMY-1 ) );
369 SetFillColor( aFillColor );
370 DrawRect( Rectangle( nCol*nMX-1, 0,
371 aSize.Width(), aSize.Height()-nTextHeight+1 ) );
372 DrawRect( Rectangle( 0, nLine*nMY-1,
373 aSize.Width(), aSize.Height()-nTextHeight+1 ) );
375 SetLineColor( aHighlightLineColor );
376 for ( i = 1; i < nCol; i++ )
377 DrawLine( Point( i*nMX-1, 0 ), Point( i*nMX-1, nLine*nMY-1 ) );
378 for ( i = 1; i < nLine; i++ )
379 DrawLine( Point( 0, i*nMY-1 ), Point( nCol*nMX-1, i*nMY-1 ) );
380 SetLineColor( aLineColor );
381 for ( i = 1; i <= nWidth; i++ )
383 if ( i < nCol )
384 nStart = nLine*nMY-1;
385 else
386 nStart = 0;
387 DrawLine( Point( i*nMX-1, nStart ), Point( i*nMX-1, nHeight*nMY-1 ) );
389 for ( i = 1; i <= nHeight; i++ )
391 if ( i < nLine )
392 nStart = nCol*nMX-1;
393 else
394 nStart = 0;
395 DrawLine( Point( nStart, i*nMY-1 ), Point( nWidth*nMX-1, i*nMY-1 ) );
398 SetLineColor();
399 String aText;
400 if ( nCol && nLine )
402 aText += String::CreateFromInt32( nCol );
403 aText.AppendAscii( " x " );
404 aText += String::CreateFromInt32( nLine );
405 if(GetId() == FN_SHOW_MULTIPLE_PAGES)
407 aText += ' ';
408 aText += String(SVX_RESSTR(RID_SVXSTR_PAGES));
412 else
413 aText = Button::GetStandardText( BUTTON_CANCEL );
414 Size aTextSize( GetTextWidth( aText ), GetTextHeight() );
416 Rectangle aClearRect( 0, aSize.Height()-nTextHeight+2, (aSize.Width()), aSize.Height() );
417 DrawRect( aClearRect );
419 // #i95350# force RTL output
420 if( IsRTLEnabled() && nCol && nLine )
421 aText.Insert(0x202D, 0);
422 DrawText( Point( (aSize.Width() - aTextSize.Width()) / 2, aSize.Height() - nTextHeight + 2 ), aText );
424 SetLineColor( aLineColor );
425 SetFillColor();
426 DrawRect( Rectangle( Point(0,0), aSize ) );
429 // -----------------------------------------------------------------------
431 void TableWindow::PopupModeEnd()
433 if ( !IsPopupModeCanceled() && nCol && nLine )
435 Window* pParent = rTbx.GetParent();
436 USHORT nId = GetId();
437 pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId));
439 Reference< XDispatchProvider > xDispatchProvider( mxFrame, UNO_QUERY );
440 if ( xDispatchProvider.is() )
442 com::sun::star::util::URL aTargetURL;
443 Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
444 rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )),
445 UNO_QUERY );
446 aTargetURL.Complete = maCommand;
447 xTrans->parseStrict( aTargetURL );
448 Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 );
449 if ( xDispatch.is() )
451 Sequence< PropertyValue > aArgs( 2 );
452 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" ));
453 aArgs[0].Value = makeAny( sal_Int16( nCol ));
454 aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rows" ));
455 aArgs[1].Value = makeAny( sal_Int16( nLine ));
457 xDispatch->dispatch( aTargetURL, aArgs );
461 else if ( IsPopupModeCanceled() )
462 ReleaseMouse();
463 SfxPopupWindow::PopupModeEnd();
466 // class ColumnsWindow ---------------------------------------------------
468 class ColumnsWindow : public SfxPopupWindow
470 private:
471 ::Color aLineColor;
472 ::Color aHighlightLineColor;
473 ::Color aFillColor;
474 ::Color aHighlightFillColor;
475 long nCol;
476 long nWidth;
477 long nMX;
478 long nTextHeight;
479 BOOL bInitialKeyInput;
480 BOOL m_bMod1;
481 ToolBox& rTbx;
482 Reference< XFrame > mxFrame;
483 ::rtl::OUString maCommand;
485 void UpdateSize_Impl( long nNewCol );
486 public:
487 ColumnsWindow( USHORT nId, const ::rtl::OUString& rCmd, ToolBox& rParentTbx, const Reference< XFrame >& rFrame );
489 void KeyInput( const KeyEvent& rKEvt );
490 virtual void MouseMove( const MouseEvent& rMEvt );
491 virtual void MouseButtonDown( const MouseEvent& rMEvt );
492 virtual void MouseButtonUp( const MouseEvent& rMEvt );
493 virtual void Paint( const Rectangle& );
494 virtual void PopupModeEnd();
495 virtual SfxPopupWindow* Clone() const;
497 USHORT GetColCount() const { return (USHORT)nCol; }
500 // -----------------------------------------------------------------------
502 ColumnsWindow::ColumnsWindow( USHORT nId, const ::rtl::OUString& rCmd, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) :
503 SfxPopupWindow( nId, rFrame, WB_SYSTEMWINDOW ),
504 bInitialKeyInput(TRUE),
505 m_bMod1(FALSE),
506 rTbx(rParentTbx),
507 mxFrame(rFrame),
508 maCommand( rCmd )
510 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
511 svtools::ColorConfig aColorConfig;
512 aLineColor = ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
513 aHighlightLineColor = rStyles.GetHighlightTextColor();
514 aFillColor = rStyles.GetWindowColor();
515 aHighlightFillColor = rStyles.GetHighlightColor();
517 nTextHeight = GetTextHeight()+1;
518 SetBackground();
519 Font aFont( GetFont() );
520 aFont.SetColor( aLineColor );
521 aFont.SetFillColor( aFillColor );
522 aFont.SetTransparent( FALSE );
523 SetFont( aFont );
525 nCol = 0;
526 nWidth = 4;
528 Size aLogicSize = LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM ) );
529 nMX = aLogicSize.Width();
530 SetOutputSizePixel( Size( nMX*nWidth-1, aLogicSize.Height()+nTextHeight ) );
531 StartCascading();
534 // -----------------------------------------------------------------------
536 SfxPopupWindow* ColumnsWindow::Clone() const
538 return new ColumnsWindow( GetId(), maCommand, rTbx, mxFrame );
541 // -----------------------------------------------------------------------
543 void ColumnsWindow::MouseMove( const MouseEvent& rMEvt )
545 SfxPopupWindow::MouseMove( rMEvt );
546 Point aPos = rMEvt.GetPosPixel();
547 Point aMousePos = aPos;
548 Point aWinPos = GetPosPixel();
550 if ( rMEvt.IsEnterWindow() )
551 CaptureMouse();
552 else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 )
554 nCol = 0;
555 ReleaseMouse();
556 Invalidate();
557 return;
560 long nNewCol = 0;
561 if ( aPos.X() > 0 )
562 nNewCol = aPos.X() / nMX + 1;
563 if ( aPos.Y() < 0 )
564 nNewCol = 0;
565 if ( nNewCol > 20 )
566 nNewCol = 20;
567 UpdateSize_Impl( nNewCol );
569 /* -----------------------------21.05.2002 16:16------------------------------
571 ---------------------------------------------------------------------------*/
572 void ColumnsWindow::UpdateSize_Impl( long nNewCol )
574 Size aWinSize = GetOutputSizePixel();
575 long nMinCol = 0;
576 long nMaxCol = 0;
577 Point aWinPos;// = GetPosPixel();
579 if ( nWidth <= nNewCol )
581 Point aMaxPos = OutputToScreenPixel( GetDesktopRectPixel().BottomRight() );
583 if ( nWidth <= nNewCol )
585 nWidth = nNewCol;
586 nWidth++;
589 while ( nWidth > 0 &&
590 (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 )
591 nWidth--;
593 if ( nNewCol > nWidth )
594 nNewCol = nWidth;
596 Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2,
597 aWinSize.Width(), aWinSize.Height() ) );
598 SetOutputSizePixel( Size( nMX*nWidth-1, aWinSize.Height() ) );
602 if ( nNewCol != nCol )
604 Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2,
605 aWinSize.Width(), aWinSize.Height() ) );
607 if ( nNewCol < nCol )
609 nMinCol = nNewCol;
610 nMaxCol = nCol;
612 else
614 nMinCol = nCol;
615 nMaxCol = nNewCol;
618 Invalidate( Rectangle( nMinCol*nMX-1, 0,
619 nMaxCol*nMX+1, aWinSize.Height()-nTextHeight+2 ) );
620 nCol = nNewCol;
622 Update();
624 // -----------------------------------------------------------------------
626 void ColumnsWindow::MouseButtonDown( const MouseEvent& rMEvt )
628 SfxPopupWindow::MouseButtonDown( rMEvt );
629 CaptureMouse();
631 /* -----------------------------21.05.2002 16:11------------------------------
633 ---------------------------------------------------------------------------*/
634 void ColumnsWindow::KeyInput( const KeyEvent& rKEvt )
636 BOOL bHandled = FALSE;
637 USHORT nModifier = rKEvt.GetKeyCode().GetModifier();
638 USHORT nKey = rKEvt.GetKeyCode().GetCode();
639 if(!nModifier)
641 if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
642 KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
643 KEY_UP == nKey)
645 bHandled = TRUE;
646 long nNewCol = nCol;
647 switch(nKey)
649 case KEY_LEFT :
650 if(nNewCol)
651 nNewCol--;
652 break;
653 case KEY_RIGHT :
654 nNewCol++;
655 break;
656 case KEY_RETURN :
657 if(IsMouseCaptured())
658 ReleaseMouse();
659 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
660 break;
661 case KEY_ESCAPE :
662 case KEY_UP :
663 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL);
664 break;
666 //make sure that a table can initially be created
667 if(bInitialKeyInput)
669 bInitialKeyInput = FALSE;
670 if(!nNewCol)
671 nNewCol = 1;
673 UpdateSize_Impl( nNewCol );
676 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
678 m_bMod1 = TRUE;
679 if(IsMouseCaptured())
680 ReleaseMouse();
681 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
683 if(!bHandled)
684 SfxPopupWindow::KeyInput(rKEvt);
687 // -----------------------------------------------------------------------
689 void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt )
691 SfxPopupWindow::MouseButtonUp( rMEvt );
692 ReleaseMouse();
694 if ( IsInPopupMode() )
695 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
698 // -----------------------------------------------------------------------
700 void ColumnsWindow::Paint( const Rectangle& )
702 long i;
703 long j;
704 long nLineWidth;
705 Size aSize = GetOutputSizePixel();
707 for ( i = 0; i < nWidth; i++ )
709 if ( i < nCol )
711 SetLineColor( aHighlightLineColor );
712 SetFillColor( aHighlightFillColor );
714 else
716 SetLineColor( aLineColor );
717 SetFillColor( aFillColor );
720 DrawRect( Rectangle( i*nMX-1, -1,
721 i*nMX+nMX, aSize.Height()-nTextHeight+1 ) );
723 j = 4;
724 while ( j < aSize.Height()-nTextHeight-4 )
726 if ( !(j % 16) )
727 nLineWidth = 10;
728 else
729 nLineWidth = 4;
730 DrawLine( Point( i*nMX+4, j ), Point( i*nMX+nMX-nLineWidth-4, j ) );
731 j += 4;
735 SetLineColor();
736 SetFillColor( aFillColor );
737 String aText;
738 if ( nCol )
739 aText = String( String::CreateFromInt32(nCol) );
740 else
741 aText = Button::GetStandardText( BUTTON_CANCEL );
742 Size aTextSize(GetTextWidth( aText ), GetTextHeight());
743 DrawText( Point( ( aSize.Width() - aTextSize.Width() ) / 2, aSize.Height() - nTextHeight + 2 ), aText );
745 DrawRect( Rectangle( 0, aSize.Height()-nTextHeight+2, (aSize.Width()-aTextSize.Width())/2-1, aSize.Height() ) );
746 DrawRect( Rectangle( (aSize.Width()-aTextSize.Width())/2+aTextSize.Width(), aSize.Height()-nTextHeight+2, aSize.Width(), aSize.Height() ) );
748 SetLineColor( aLineColor );
749 SetFillColor();
750 DrawRect( Rectangle( Point(0,0), aSize ) );
753 // -----------------------------------------------------------------------
755 void ColumnsWindow::PopupModeEnd()
757 if ( !IsPopupModeCanceled() && nCol )
759 USHORT nId = GetId();
760 Window* pParent = rTbx.GetParent();
761 pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId));
763 Sequence< PropertyValue > aArgs( 2 );
764 aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" ));
765 aArgs[0].Value = makeAny( sal_Int16( nCol ));
766 aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Modifier" ));
767 aArgs[1].Value = makeAny( sal_Int16( m_bMod1 ? KEY_MOD1 : 0 ));
769 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
770 maCommand,
771 aArgs );
773 else if ( IsPopupModeCanceled() )
774 ReleaseMouse();
775 SfxPopupWindow::PopupModeEnd();
778 // class SvxTableToolBoxControl ------------------------------------------
780 SvxTableToolBoxControl::SvxTableToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
781 SfxToolBoxControl( nSlotId, nId, rTbx ),
782 bEnabled( TRUE )
784 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
785 rTbx.Invalidate();
788 // -----------------------------------------------------------------------
790 SvxTableToolBoxControl::~SvxTableToolBoxControl()
794 // -----------------------------------------------------------------------
796 SfxPopupWindowType SvxTableToolBoxControl::GetPopupWindowType() const
798 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE;
801 // -----------------------------------------------------------------------
803 SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindow()
805 if ( bEnabled )
807 ToolBox& rTbx = GetToolBox();
808 TableWindow* pWin = new TableWindow( GetSlotId(), m_aCommandURL, rTbx, m_xFrame );
809 pWin->StartPopupMode( &rTbx, FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE );
810 SetPopupWindow( pWin );
811 return pWin;
813 return 0;
816 // -----------------------------------------------------------------------
818 SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindowCascading()
820 if ( bEnabled )
821 return new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox(), m_xFrame );
822 return 0;
825 // -----------------------------------------------------------------------
827 void SvxTableToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
829 if ( pState && pState->ISA(SfxUInt16Item) )
831 INT16 nValue = static_cast< const SfxUInt16Item* >( pState )->GetValue();
832 bEnabled = ( nValue != 0 );
834 else
835 bEnabled = SFX_ITEM_DISABLED != eState;
837 USHORT nId = GetId();
838 ToolBox& rTbx = GetToolBox();
840 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
841 rTbx.SetItemState( nId,
842 ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
845 // class SvxColumnsToolBoxControl ------------------------------------------
847 SvxColumnsToolBoxControl::SvxColumnsToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
848 SfxToolBoxControl( nSlotId, nId, rTbx )
850 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
851 rTbx.Invalidate();
854 // -----------------------------------------------------------------------
856 SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl()
860 // -----------------------------------------------------------------------
862 SfxPopupWindowType SvxColumnsToolBoxControl::GetPopupWindowType() const
864 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE;
867 // -----------------------------------------------------------------------
869 SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindow()
871 ColumnsWindow* pWin = 0;
872 if(bEnabled)
874 pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox(), m_xFrame );
875 pWin->StartPopupMode( &GetToolBox(),
876 FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE );
877 SetPopupWindow( pWin );
879 return pWin;
882 // -----------------------------------------------------------------------
884 SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindowCascading()
886 ColumnsWindow* pWin = 0;
887 if(bEnabled)
889 pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox(), m_xFrame );
891 return pWin;
893 /* -----------------18.11.99 16:38-------------------
895 --------------------------------------------------*/
896 void SvxColumnsToolBoxControl::StateChanged( USHORT nSID,
897 SfxItemState eState,
898 const SfxPoolItem* pState )
900 bEnabled = SFX_ITEM_DISABLED != eState;
901 SfxToolBoxControl::StateChanged(nSID, eState, pState );