1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
33 #include <vcl/toolbox.hxx>
34 #include <vcl/button.hxx>
35 #include <svl/intitem.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/app.hxx>
39 #include <svx/dialogs.hrc>
40 #include "svx/layctrl.hxx"
41 #include <svx/dialmgr.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <comphelper/string.hxx>
44 #include <svtools/colorcfg.hxx>
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::beans
;
49 using namespace ::com::sun::star::util
;
50 using namespace ::com::sun::star::frame
;
52 SFX_IMPL_TOOLBOX_CONTROL(SvxTableToolBoxControl
,SfxUInt16Item
);
53 SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl
,SfxUInt16Item
);
55 // class TableWindow -----------------------------------------------------
57 const long TABLE_CELL_WIDTH
= 15;
58 const long TABLE_CELL_HEIGHT
= 15;
60 const long TABLE_CELLS_HORIZ
= 10;
61 const long TABLE_CELLS_VERT
= 15;
63 const long TABLE_POS_X
= 2;
64 const long TABLE_POS_Y
= 2;
66 const long TABLE_WIDTH
= TABLE_POS_X
+ TABLE_CELLS_HORIZ
*TABLE_CELL_WIDTH
;
67 const long TABLE_HEIGHT
= TABLE_POS_Y
+ TABLE_CELLS_VERT
*TABLE_CELL_HEIGHT
;
69 class TableWindow
: public SfxPopupWindow
72 PushButton aTableButton
;
75 ::Color aHighlightFillColor
;
76 ::Color aBackgroundColor
;
79 sal_Bool bInitialKeyInput
;
82 Reference
< XFrame
> mxFrame
;
83 rtl::OUString maCommand
;
85 DECL_LINK( SelectHdl
, void * );
88 TableWindow( sal_uInt16 nSlotId
,
89 const rtl::OUString
& rCmd
,
92 const Reference
< XFrame
>& rFrame
);
95 void KeyInput( const KeyEvent
& rKEvt
);
96 virtual void MouseMove( const MouseEvent
& rMEvt
);
97 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
98 virtual void Paint( const Rectangle
& );
99 virtual void PopupModeEnd();
100 virtual SfxPopupWindow
* Clone() const;
103 void Update( long nNewCol
, long nNewLine
);
104 void TableDialog( const Sequence
< PropertyValue
>& rArgs
);
105 void CloseAndShowTableDialog();
108 // -----------------------------------------------------------------------
110 IMPL_LINK_NOARG(TableWindow
, SelectHdl
)
112 CloseAndShowTableDialog();
116 // -----------------------------------------------------------------------
118 TableWindow::TableWindow( sal_uInt16 nSlotId
, const rtl::OUString
& rCmd
, const String
& rText
, ToolBox
& rParentTbx
, const Reference
< XFrame
>& rFrame
) :
119 SfxPopupWindow( nSlotId
, rFrame
, WinBits( WB_STDPOPUP
) ),
120 aTableButton( this ),
127 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
128 svtools::ColorConfig aColorConfig
;
130 aLineColor
= rStyles
.GetShadowColor();
131 aFillColor
= rStyles
.GetWindowColor();
132 aHighlightFillColor
= rStyles
.GetHighlightColor();
133 aBackgroundColor
= GetSettings().GetStyleSettings().GetFaceColor();
135 SetBackground( aBackgroundColor
);
136 Font aFont
= GetFont();
137 aFont
.SetColor( ::Color( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
) );
138 aFont
.SetFillColor( aBackgroundColor
);
139 aFont
.SetTransparent( sal_False
);
144 aTableButton
.SetPosSizePixel( Point( TABLE_POS_X
+ TABLE_CELL_WIDTH
, TABLE_HEIGHT
+ 5 ),
145 Size( TABLE_WIDTH
- TABLE_POS_X
- 2*TABLE_CELL_WIDTH
, 24 ) );
146 aTableButton
.SetText( String( SVX_RESSTR( RID_SVXSTR_MORE
) ) );
147 aTableButton
.SetClickHdl( LINK( this, TableWindow
, SelectHdl
) );
150 SetOutputSizePixel( Size( TABLE_WIDTH
+ 3, TABLE_HEIGHT
+ 33 ) );
153 // -----------------------------------------------------------------------
155 TableWindow::~TableWindow()
159 // -----------------------------------------------------------------------
161 SfxPopupWindow
* TableWindow::Clone() const
163 return new TableWindow( GetId(), maCommand
, GetText(), rTbx
, mxFrame
);
166 // -----------------------------------------------------------------------
168 void TableWindow::MouseMove( const MouseEvent
& rMEvt
)
170 SfxPopupWindow::MouseMove( rMEvt
);
171 Point aPos
= rMEvt
.GetPosPixel();
172 Point
aMousePos( aPos
);
174 long nNewCol
= ( aMousePos
.X() - TABLE_POS_X
+ TABLE_CELL_WIDTH
) / TABLE_CELL_WIDTH
;
175 long nNewLine
= ( aMousePos
.Y() - TABLE_POS_Y
+ TABLE_CELL_HEIGHT
) / TABLE_CELL_HEIGHT
;
177 Update( nNewCol
, nNewLine
);
180 // -----------------------------------------------------------------------
182 void TableWindow::KeyInput( const KeyEvent
& rKEvt
)
184 bool bHandled
= false;
185 sal_uInt16 nModifier
= rKEvt
.GetKeyCode().GetModifier();
186 sal_uInt16 nKey
= rKEvt
.GetKeyCode().GetCode();
191 long nNewLine
= nLine
;
198 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
201 if ( nNewLine
< TABLE_CELLS_VERT
)
204 CloseAndShowTableDialog();
210 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
213 if ( nNewCol
< TABLE_CELLS_HORIZ
)
216 CloseAndShowTableDialog();
219 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
222 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
225 CloseAndShowTableDialog();
232 //make sure that a table can initially be created
235 bInitialKeyInput
= sal_False
;
241 Update( nNewCol
, nNewLine
);
244 else if(KEY_MOD1
== nModifier
&& KEY_RETURN
== nKey
)
247 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
251 SfxPopupWindow::KeyInput(rKEvt
);
254 // -----------------------------------------------------------------------
256 void TableWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
258 SfxPopupWindow::MouseButtonUp( rMEvt
);
259 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
262 // -----------------------------------------------------------------------
264 void TableWindow::Paint( const Rectangle
& )
266 const long nSelectionWidth
= TABLE_POS_X
+ nCol
*TABLE_CELL_WIDTH
;
267 const long nSelectionHeight
= TABLE_POS_Y
+ nLine
*TABLE_CELL_HEIGHT
;
269 // the non-selected parts of the table
270 SetLineColor( aLineColor
);
271 SetFillColor( aFillColor
);
272 DrawRect( Rectangle( nSelectionWidth
, TABLE_POS_Y
, TABLE_WIDTH
, nSelectionHeight
) );
273 DrawRect( Rectangle( TABLE_POS_X
, nSelectionHeight
, nSelectionWidth
, TABLE_HEIGHT
) );
274 DrawRect( Rectangle( nSelectionWidth
, nSelectionHeight
, TABLE_WIDTH
, TABLE_HEIGHT
) );
277 if ( nCol
> 0 && nLine
> 0 )
279 SetFillColor( aHighlightFillColor
);
280 DrawRect( Rectangle( TABLE_POS_X
, TABLE_POS_Y
,
281 nSelectionWidth
, nSelectionHeight
) );
284 // lines inside of the table
285 SetLineColor( aLineColor
);
286 for ( long i
= 1; i
< TABLE_CELLS_VERT
; ++i
)
287 DrawLine( Point( TABLE_POS_X
, TABLE_POS_Y
+ i
*TABLE_CELL_HEIGHT
),
288 Point( TABLE_WIDTH
, TABLE_POS_Y
+ i
*TABLE_CELL_HEIGHT
) );
290 for ( long i
= 1; i
< TABLE_CELLS_HORIZ
; ++i
)
291 DrawLine( Point( TABLE_POS_X
+ i
*TABLE_CELL_WIDTH
, TABLE_POS_Y
),
292 Point( TABLE_POS_X
+ i
*TABLE_CELL_WIDTH
, TABLE_HEIGHT
) );
294 // the text near the mouse cursor telling the table dimensions
298 aText
+= String::CreateFromInt32( nCol
);
299 aText
.AppendAscii( " x " );
300 aText
+= String::CreateFromInt32( nLine
);
301 if(GetId() == FN_SHOW_MULTIPLE_PAGES
)
304 aText
+= String(SVX_RESSTR(RID_SVXSTR_PAGES
));
307 Size
aTextSize( GetTextWidth( aText
), GetTextHeight() );
309 long nTextX
= nSelectionWidth
+ TABLE_CELL_WIDTH
;
310 long nTextY
= nSelectionHeight
+ TABLE_CELL_HEIGHT
;
311 const long nTipBorder
= 2;
313 if ( aTextSize
.Width() + TABLE_POS_X
+ TABLE_CELL_WIDTH
+ 2*nTipBorder
< nSelectionWidth
)
314 nTextX
= nSelectionWidth
- TABLE_CELL_WIDTH
- aTextSize
.Width();
316 if ( aTextSize
.Height() + TABLE_POS_Y
+ TABLE_CELL_HEIGHT
+ 2*nTipBorder
< nSelectionHeight
)
317 nTextY
= nSelectionHeight
- TABLE_CELL_HEIGHT
- aTextSize
.Height();
319 SetLineColor( aLineColor
);
320 SetFillColor( aBackgroundColor
);
321 DrawRect( Rectangle ( nTextX
- 2*nTipBorder
, nTextY
- 2*nTipBorder
,
322 nTextX
+ aTextSize
.Width() + nTipBorder
, nTextY
+ aTextSize
.Height() + nTipBorder
) );
324 // #i95350# force RTL output
325 if ( IsRTLEnabled() )
326 aText
.Insert( 0x202D, 0 );
328 DrawText( Point( nTextX
, nTextY
), aText
);
332 // -----------------------------------------------------------------------
334 void TableWindow::PopupModeEnd()
336 if ( !IsPopupModeCanceled() && nCol
&& nLine
)
338 Sequence
< PropertyValue
> aArgs( 2 );
339 aArgs
[0].Name
= ::rtl::OUString( "Columns" );
340 aArgs
[0].Value
= makeAny( sal_Int16( nCol
));
341 aArgs
[1].Name
= ::rtl::OUString( "Rows" );
342 aArgs
[1].Value
= makeAny( sal_Int16( nLine
));
344 TableDialog( aArgs
);
347 SfxPopupWindow::PopupModeEnd();
350 // -----------------------------------------------------------------------
352 void TableWindow::Update( long nNewCol
, long nNewLine
)
354 if ( nNewCol
< 0 || nNewCol
> TABLE_CELLS_HORIZ
)
357 if ( nNewLine
< 0 || nNewLine
> TABLE_CELLS_VERT
)
360 if ( nNewCol
!= nCol
|| nNewLine
!= nLine
)
364 Invalidate( Rectangle( TABLE_POS_X
, TABLE_POS_Y
, TABLE_WIDTH
, TABLE_HEIGHT
) );
368 // -----------------------------------------------------------------------
370 void TableWindow::TableDialog( const Sequence
< PropertyValue
>& rArgs
)
372 Window
* pParent
= rTbx
.GetParent();
373 sal_uInt16 nId
= GetId();
374 pParent
->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE
, reinterpret_cast<void*>(nId
));
376 Reference
< XDispatchProvider
> xDispatchProvider( mxFrame
, UNO_QUERY
);
377 if ( xDispatchProvider
.is() )
379 com::sun::star::util::URL aTargetURL
;
380 Reference
< XURLTransformer
> xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
381 rtl::OUString("com.sun.star.util.URLTransformer")),
383 aTargetURL
.Complete
= maCommand
;
384 xTrans
->parseStrict( aTargetURL
);
386 Reference
< XDispatch
> xDispatch
= xDispatchProvider
->queryDispatch( aTargetURL
, rtl::OUString(), 0 );
387 if ( xDispatch
.is() )
388 xDispatch
->dispatch( aTargetURL
, rArgs
);
392 // -----------------------------------------------------------------------
394 void TableWindow::CloseAndShowTableDialog()
396 // close the toolbar tool
397 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
399 // and open the table dialog instead
400 TableDialog( Sequence
< PropertyValue
>() );
403 // class ColumnsWindow ---------------------------------------------------
405 class ColumnsWindow
: public SfxPopupWindow
409 ::Color aHighlightLineColor
;
411 ::Color aHighlightFillColor
;
417 sal_Bool bInitialKeyInput
;
420 Reference
< XFrame
> mxFrame
;
421 ::rtl::OUString maCommand
;
423 void UpdateSize_Impl( long nNewCol
);
425 ColumnsWindow( sal_uInt16 nId
, const ::rtl::OUString
& rCmd
, const String
&rText
, ToolBox
& rParentTbx
, const Reference
< XFrame
>& rFrame
);
427 void KeyInput( const KeyEvent
& rKEvt
);
428 virtual void MouseMove( const MouseEvent
& rMEvt
);
429 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
430 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
431 virtual void Paint( const Rectangle
& );
432 virtual void PopupModeEnd();
433 virtual SfxPopupWindow
* Clone() const;
435 sal_uInt16
GetColCount() const { return (sal_uInt16
)nCol
; }
438 // -----------------------------------------------------------------------
440 ColumnsWindow::ColumnsWindow( sal_uInt16 nId
, const ::rtl::OUString
& rCmd
, const String
& rText
, ToolBox
& rParentTbx
, const Reference
< XFrame
>& rFrame
) :
441 SfxPopupWindow( nId
, rFrame
, WB_STDPOPUP
),
442 bInitialKeyInput(sal_True
),
448 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
449 svtools::ColorConfig aColorConfig
;
450 aLineColor
= ::Color( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
451 aHighlightLineColor
= rStyles
.GetHighlightTextColor();
452 aFillColor
= rStyles
.GetWindowColor();
453 aHighlightFillColor
= rStyles
.GetHighlightColor();
454 aFaceColor
= rStyles
.GetFaceColor();
456 nTextHeight
= GetTextHeight()+1;
458 Font
aFont( GetFont() );
459 aFont
.SetColor( aLineColor
);
460 aFont
.SetFillColor( aFaceColor
);
461 aFont
.SetTransparent( sal_False
);
469 Size aLogicSize
= LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM
) );
470 nMX
= aLogicSize
.Width();
471 SetOutputSizePixel( Size( nMX
*nWidth
-1, aLogicSize
.Height()+nTextHeight
) );
475 // -----------------------------------------------------------------------
477 SfxPopupWindow
* ColumnsWindow::Clone() const
479 return new ColumnsWindow( GetId(), maCommand
, GetText(), rTbx
, mxFrame
);
482 // -----------------------------------------------------------------------
484 void ColumnsWindow::MouseMove( const MouseEvent
& rMEvt
)
486 SfxPopupWindow::MouseMove( rMEvt
);
487 Point aPos
= rMEvt
.GetPosPixel();
488 Point aMousePos
= aPos
;
490 if ( rMEvt
.IsEnterWindow() )
492 else if ( aMousePos
.X() < 0 || aMousePos
.Y() < 0 )
502 nNewCol
= aPos
.X() / nMX
+ 1;
507 UpdateSize_Impl( nNewCol
);
510 void ColumnsWindow::UpdateSize_Impl( long nNewCol
)
512 Size aWinSize
= GetOutputSizePixel();
513 Point aWinPos
;// = GetPosPixel();
515 if ( nWidth
<= nNewCol
)
517 Point aMaxPos
= OutputToScreenPixel( GetDesktopRectPixel().BottomRight() );
519 if ( nWidth
<= nNewCol
)
525 while ( nWidth
> 0 &&
526 (short)(aWinPos
.X()+(nMX
*nWidth
-1)) >= aMaxPos
.X()-3 )
529 if ( nNewCol
> nWidth
)
532 Invalidate( Rectangle( 0, aWinSize
.Height()-nTextHeight
+2,
533 aWinSize
.Width(), aWinSize
.Height() ) );
534 SetOutputSizePixel( Size( nMX
*nWidth
-1, aWinSize
.Height() ) );
538 if ( nNewCol
!= nCol
)
540 Invalidate( Rectangle( 0, aWinSize
.Height()-nTextHeight
+2,
541 aWinSize
.Width(), aWinSize
.Height() ) );
543 long nMinCol
= 0, nMaxCol
= 0;
545 if ( nNewCol
< nCol
)
556 Invalidate( Rectangle( nMinCol
*nMX
-1, 0,
557 nMaxCol
*nMX
+1, aWinSize
.Height()-nTextHeight
+2 ) );
562 // -----------------------------------------------------------------------
564 void ColumnsWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
566 SfxPopupWindow::MouseButtonDown( rMEvt
);
570 void ColumnsWindow::KeyInput( const KeyEvent
& rKEvt
)
572 sal_Bool bHandled
= sal_False
;
573 sal_uInt16 nModifier
= rKEvt
.GetKeyCode().GetModifier();
574 sal_uInt16 nKey
= rKEvt
.GetKeyCode().GetCode();
577 if( KEY_LEFT
== nKey
|| KEY_RIGHT
== nKey
||
578 KEY_RETURN
== nKey
||KEY_ESCAPE
== nKey
||
593 if(IsMouseCaptured())
595 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL
);
599 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
602 //make sure that a table can initially be created
605 bInitialKeyInput
= sal_False
;
609 UpdateSize_Impl( nNewCol
);
612 else if(KEY_MOD1
== nModifier
&& KEY_RETURN
== nKey
)
615 if(IsMouseCaptured())
617 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL
);
620 SfxPopupWindow::KeyInput(rKEvt
);
623 // -----------------------------------------------------------------------
625 void ColumnsWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
627 SfxPopupWindow::MouseButtonUp( rMEvt
);
630 if ( IsInPopupMode() )
631 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
634 // -----------------------------------------------------------------------
636 void ColumnsWindow::Paint( const Rectangle
& )
641 Size aSize
= GetOutputSizePixel();
643 for ( i
= 0; i
< nWidth
; i
++ )
647 SetLineColor( aHighlightLineColor
);
648 SetFillColor( aHighlightFillColor
);
652 SetLineColor( aLineColor
);
653 SetFillColor( aFillColor
);
656 DrawRect( Rectangle( i
*nMX
-1, -1,
657 i
*nMX
+nMX
, aSize
.Height()-nTextHeight
+1 ) );
660 while ( j
< aSize
.Height()-nTextHeight
-4 )
666 DrawLine( Point( i
*nMX
+4, j
), Point( i
*nMX
+nMX
-nLineWidth
-4, j
) );
672 SetFillColor( aFaceColor
);
675 aText
= String::CreateFromInt32(nCol
);
677 aText
= comphelper::string::remove(Button::GetStandardText(BUTTON_CANCEL
), '~');
679 Size
aTextSize(GetTextWidth( aText
), GetTextHeight());
680 DrawText( Point( ( aSize
.Width() - aTextSize
.Width() ) / 2, aSize
.Height() - nTextHeight
+ 2 ), aText
);
682 DrawRect( Rectangle( 0, aSize
.Height()-nTextHeight
+2, (aSize
.Width()-aTextSize
.Width())/2-1, aSize
.Height() ) );
683 DrawRect( Rectangle( (aSize
.Width()-aTextSize
.Width())/2+aTextSize
.Width(), aSize
.Height()-nTextHeight
+2, aSize
.Width(), aSize
.Height() ) );
685 SetLineColor( aLineColor
);
687 DrawRect( Rectangle( 0, 0, aSize
.Width() - 1, aSize
.Height() - nTextHeight
+ 1 ) );
690 // -----------------------------------------------------------------------
692 void ColumnsWindow::PopupModeEnd()
694 if ( !IsPopupModeCanceled() && nCol
)
696 sal_uInt16 nId
= GetId();
697 Window
* pParent
= rTbx
.GetParent();
698 pParent
->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE
, reinterpret_cast<void*>(nId
));
700 Sequence
< PropertyValue
> aArgs( 2 );
701 aArgs
[0].Name
= ::rtl::OUString( "Columns" );
702 aArgs
[0].Value
= makeAny( sal_Int16( nCol
));
703 aArgs
[1].Name
= ::rtl::OUString( "Modifier" );
704 aArgs
[1].Value
= makeAny( sal_Int16( m_bMod1
? KEY_MOD1
: 0 ));
706 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( mxFrame
->getController(), UNO_QUERY
),
710 else if ( IsPopupModeCanceled() )
712 SfxPopupWindow::PopupModeEnd();
715 // class SvxTableToolBoxControl ------------------------------------------
717 SvxTableToolBoxControl::SvxTableToolBoxControl( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
718 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
721 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
725 // -----------------------------------------------------------------------
727 SvxTableToolBoxControl::~SvxTableToolBoxControl()
731 // -----------------------------------------------------------------------
733 SfxPopupWindowType
SvxTableToolBoxControl::GetPopupWindowType() const
735 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE
;
738 // -----------------------------------------------------------------------
740 SfxPopupWindow
* SvxTableToolBoxControl::CreatePopupWindow()
744 ToolBox
& rTbx
= GetToolBox();
745 TableWindow
* pWin
= new TableWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), rTbx
, m_xFrame
);
746 pWin
->StartPopupMode( &rTbx
, FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_NOKEYCLOSE
);
747 SetPopupWindow( pWin
);
753 // -----------------------------------------------------------------------
755 SfxPopupWindow
* SvxTableToolBoxControl::CreatePopupWindowCascading()
758 return new TableWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame
);
762 // -----------------------------------------------------------------------
764 void SvxTableToolBoxControl::StateChanged( sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
766 if ( pState
&& pState
->ISA(SfxUInt16Item
) )
768 sal_Int16 nValue
= static_cast< const SfxUInt16Item
* >( pState
)->GetValue();
769 bEnabled
= ( nValue
!= 0 );
772 bEnabled
= SFX_ITEM_DISABLED
!= eState
;
774 sal_uInt16 nId
= GetId();
775 ToolBox
& rTbx
= GetToolBox();
777 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
778 rTbx
.SetItemState( nId
,
779 ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
782 // class SvxColumnsToolBoxControl ------------------------------------------
784 SvxColumnsToolBoxControl::SvxColumnsToolBoxControl( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
785 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
787 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
791 // -----------------------------------------------------------------------
793 SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl()
797 // -----------------------------------------------------------------------
799 SfxPopupWindowType
SvxColumnsToolBoxControl::GetPopupWindowType() const
801 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE
;
804 // -----------------------------------------------------------------------
806 SfxPopupWindow
* SvxColumnsToolBoxControl::CreatePopupWindow()
808 ColumnsWindow
* pWin
= 0;
811 pWin
= new ColumnsWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame
);
812 pWin
->StartPopupMode( &GetToolBox(),
813 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_NOKEYCLOSE
);
814 SetPopupWindow( pWin
);
819 // -----------------------------------------------------------------------
821 SfxPopupWindow
* SvxColumnsToolBoxControl::CreatePopupWindowCascading()
823 ColumnsWindow
* pWin
= 0;
826 pWin
= new ColumnsWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame
);
831 void SvxColumnsToolBoxControl::StateChanged( sal_uInt16 nSID
,
833 const SfxPoolItem
* pState
)
835 bEnabled
= SFX_ITEM_DISABLED
!= eState
;
836 SfxToolBoxControl::StateChanged(nSID
, eState
, pState
);
839 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */