1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <vcl/toolbox.hxx>
22 #include <vcl/button.hxx>
23 #include <svl/intitem.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/app.hxx>
27 #include <svx/dialogs.hrc>
28 #include "svx/layctrl.hxx"
29 #include <svx/dialmgr.hxx>
30 #include <comphelper/processfactory.hxx>
31 #include <comphelper/string.hxx>
32 #include <svtools/colorcfg.hxx>
33 #include <com/sun/star/util/URLTransformer.hpp>
36 using namespace ::com::sun::star::uno
;
37 using namespace ::com::sun::star::beans
;
38 using namespace ::com::sun::star::util
;
39 using namespace ::com::sun::star::frame
;
41 SFX_IMPL_TOOLBOX_CONTROL(SvxTableToolBoxControl
,SfxUInt16Item
);
42 SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl
,SfxUInt16Item
);
44 // class TableWindow -----------------------------------------------------
46 const long TABLE_CELL_WIDTH
= 15;
47 const long TABLE_CELL_HEIGHT
= 15;
49 const long TABLE_CELLS_HORIZ
= 10;
50 const long TABLE_CELLS_VERT
= 15;
52 const long TABLE_POS_X
= 2;
53 const long TABLE_POS_Y
= 2;
55 const long TABLE_WIDTH
= TABLE_POS_X
+ TABLE_CELLS_HORIZ
*TABLE_CELL_WIDTH
;
56 const long TABLE_HEIGHT
= TABLE_POS_Y
+ TABLE_CELLS_VERT
*TABLE_CELL_HEIGHT
;
58 class TableWindow
: public SfxPopupWindow
61 PushButton aTableButton
;
64 ::Color aHighlightFillColor
;
65 ::Color aBackgroundColor
;
68 bool bInitialKeyInput
;
71 Reference
< XFrame
> mxFrame
;
74 DECL_LINK( SelectHdl
, void * );
77 TableWindow( sal_uInt16 nSlotId
,
81 const Reference
< XFrame
>& rFrame
);
84 void KeyInput( const KeyEvent
& rKEvt
);
85 virtual void MouseMove( const MouseEvent
& rMEvt
);
86 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
87 virtual void Paint( const Rectangle
& );
88 virtual void PopupModeEnd();
89 virtual SfxPopupWindow
* Clone() const;
92 void Update( long nNewCol
, long nNewLine
);
93 void TableDialog( const Sequence
< PropertyValue
>& rArgs
);
94 void CloseAndShowTableDialog();
97 // -----------------------------------------------------------------------
99 IMPL_LINK_NOARG(TableWindow
, SelectHdl
)
101 CloseAndShowTableDialog();
105 // -----------------------------------------------------------------------
107 TableWindow::TableWindow( sal_uInt16 nSlotId
, const OUString
& rCmd
, const String
& rText
, ToolBox
& rParentTbx
, const Reference
< XFrame
>& rFrame
) :
108 SfxPopupWindow( nSlotId
, rFrame
, WinBits( WB_STDPOPUP
) ),
109 aTableButton( this ),
116 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
117 svtools::ColorConfig aColorConfig
;
119 aLineColor
= rStyles
.GetShadowColor();
120 aFillColor
= rStyles
.GetWindowColor();
121 aHighlightFillColor
= rStyles
.GetHighlightColor();
122 aBackgroundColor
= GetSettings().GetStyleSettings().GetFaceColor();
124 SetBackground( aBackgroundColor
);
125 Font aFont
= GetFont();
126 aFont
.SetColor( ::Color( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
) );
127 aFont
.SetFillColor( aBackgroundColor
);
128 aFont
.SetTransparent( sal_False
);
133 aTableButton
.SetPosSizePixel( Point( TABLE_POS_X
+ TABLE_CELL_WIDTH
, TABLE_HEIGHT
+ 5 ),
134 Size( TABLE_WIDTH
- TABLE_POS_X
- 2*TABLE_CELL_WIDTH
, 24 ) );
135 aTableButton
.SetText( String( SVX_RESSTR( RID_SVXSTR_MORE
) ) );
136 aTableButton
.SetClickHdl( LINK( this, TableWindow
, SelectHdl
) );
139 SetOutputSizePixel( Size( TABLE_WIDTH
+ 3, TABLE_HEIGHT
+ 33 ) );
142 // -----------------------------------------------------------------------
144 TableWindow::~TableWindow()
148 // -----------------------------------------------------------------------
150 SfxPopupWindow
* TableWindow::Clone() const
152 return new TableWindow( GetId(), maCommand
, GetText(), rTbx
, mxFrame
);
155 // -----------------------------------------------------------------------
157 void TableWindow::MouseMove( const MouseEvent
& rMEvt
)
159 SfxPopupWindow::MouseMove( rMEvt
);
160 Point aPos
= rMEvt
.GetPosPixel();
161 Point
aMousePos( aPos
);
163 long nNewCol
= ( aMousePos
.X() - TABLE_POS_X
+ TABLE_CELL_WIDTH
) / TABLE_CELL_WIDTH
;
164 long nNewLine
= ( aMousePos
.Y() - TABLE_POS_Y
+ TABLE_CELL_HEIGHT
) / TABLE_CELL_HEIGHT
;
166 Update( nNewCol
, nNewLine
);
169 // -----------------------------------------------------------------------
171 void TableWindow::KeyInput( const KeyEvent
& rKEvt
)
173 bool bHandled
= false;
174 sal_uInt16 nModifier
= rKEvt
.GetKeyCode().GetModifier();
175 sal_uInt16 nKey
= rKEvt
.GetKeyCode().GetCode();
180 long nNewLine
= nLine
;
187 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
190 if ( nNewLine
< TABLE_CELLS_VERT
)
193 CloseAndShowTableDialog();
199 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
202 if ( nNewCol
< TABLE_CELLS_HORIZ
)
205 CloseAndShowTableDialog();
208 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
211 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
214 CloseAndShowTableDialog();
221 //make sure that a table can initially be created
224 bInitialKeyInput
= false;
230 Update( nNewCol
, nNewLine
);
233 else if(KEY_MOD1
== nModifier
&& KEY_RETURN
== nKey
)
236 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
240 SfxPopupWindow::KeyInput(rKEvt
);
243 // -----------------------------------------------------------------------
245 void TableWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
247 SfxPopupWindow::MouseButtonUp( rMEvt
);
248 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
251 // -----------------------------------------------------------------------
253 void TableWindow::Paint( const Rectangle
& )
255 const long nSelectionWidth
= TABLE_POS_X
+ nCol
*TABLE_CELL_WIDTH
;
256 const long nSelectionHeight
= TABLE_POS_Y
+ nLine
*TABLE_CELL_HEIGHT
;
258 // the non-selected parts of the table
259 SetLineColor( aLineColor
);
260 SetFillColor( aFillColor
);
261 DrawRect( Rectangle( nSelectionWidth
, TABLE_POS_Y
, TABLE_WIDTH
, nSelectionHeight
) );
262 DrawRect( Rectangle( TABLE_POS_X
, nSelectionHeight
, nSelectionWidth
, TABLE_HEIGHT
) );
263 DrawRect( Rectangle( nSelectionWidth
, nSelectionHeight
, TABLE_WIDTH
, TABLE_HEIGHT
) );
266 if ( nCol
> 0 && nLine
> 0 )
268 SetFillColor( aHighlightFillColor
);
269 DrawRect( Rectangle( TABLE_POS_X
, TABLE_POS_Y
,
270 nSelectionWidth
, nSelectionHeight
) );
273 // lines inside of the table
274 SetLineColor( aLineColor
);
275 for ( long i
= 1; i
< TABLE_CELLS_VERT
; ++i
)
276 DrawLine( Point( TABLE_POS_X
, TABLE_POS_Y
+ i
*TABLE_CELL_HEIGHT
),
277 Point( TABLE_WIDTH
, TABLE_POS_Y
+ i
*TABLE_CELL_HEIGHT
) );
279 for ( long i
= 1; i
< TABLE_CELLS_HORIZ
; ++i
)
280 DrawLine( Point( TABLE_POS_X
+ i
*TABLE_CELL_WIDTH
, TABLE_POS_Y
),
281 Point( TABLE_POS_X
+ i
*TABLE_CELL_WIDTH
, TABLE_HEIGHT
) );
283 // the text near the mouse cursor telling the table dimensions
287 aText
+= OUString::number( nCol
);
288 aText
.AppendAscii( " x " );
289 aText
+= OUString::number( nLine
);
290 if(GetId() == FN_SHOW_MULTIPLE_PAGES
)
293 aText
+= String(SVX_RESSTR(RID_SVXSTR_PAGES
));
296 Size
aTextSize( GetTextWidth( aText
), GetTextHeight() );
298 long nTextX
= nSelectionWidth
+ TABLE_CELL_WIDTH
;
299 long nTextY
= nSelectionHeight
+ TABLE_CELL_HEIGHT
;
300 const long nTipBorder
= 2;
302 if ( aTextSize
.Width() + TABLE_POS_X
+ TABLE_CELL_WIDTH
+ 2*nTipBorder
< nSelectionWidth
)
303 nTextX
= nSelectionWidth
- TABLE_CELL_WIDTH
- aTextSize
.Width();
305 if ( aTextSize
.Height() + TABLE_POS_Y
+ TABLE_CELL_HEIGHT
+ 2*nTipBorder
< nSelectionHeight
)
306 nTextY
= nSelectionHeight
- TABLE_CELL_HEIGHT
- aTextSize
.Height();
308 SetLineColor( aLineColor
);
309 SetFillColor( aBackgroundColor
);
310 DrawRect( Rectangle ( nTextX
- 2*nTipBorder
, nTextY
- 2*nTipBorder
,
311 nTextX
+ aTextSize
.Width() + nTipBorder
, nTextY
+ aTextSize
.Height() + nTipBorder
) );
313 // #i95350# force RTL output
314 if ( IsRTLEnabled() )
315 aText
.Insert( 0x202D, 0 );
317 DrawText( Point( nTextX
, nTextY
), aText
);
321 // -----------------------------------------------------------------------
323 void TableWindow::PopupModeEnd()
325 if ( !IsPopupModeCanceled() && nCol
&& nLine
)
327 Sequence
< PropertyValue
> aArgs( 2 );
328 aArgs
[0].Name
= OUString( "Columns" );
329 aArgs
[0].Value
= makeAny( sal_Int16( nCol
));
330 aArgs
[1].Name
= OUString( "Rows" );
331 aArgs
[1].Value
= makeAny( sal_Int16( nLine
));
333 TableDialog( aArgs
);
336 SfxPopupWindow::PopupModeEnd();
339 // -----------------------------------------------------------------------
341 void TableWindow::Update( long nNewCol
, long nNewLine
)
343 if ( nNewCol
< 0 || nNewCol
> TABLE_CELLS_HORIZ
)
346 if ( nNewLine
< 0 || nNewLine
> TABLE_CELLS_VERT
)
349 if ( nNewCol
!= nCol
|| nNewLine
!= nLine
)
353 Invalidate( Rectangle( TABLE_POS_X
, TABLE_POS_Y
, TABLE_WIDTH
, TABLE_HEIGHT
) );
357 // -----------------------------------------------------------------------
359 void TableWindow::TableDialog( const Sequence
< PropertyValue
>& rArgs
)
361 Window
* pParent
= rTbx
.GetParent();
362 sal_uInt16 nId
= GetId();
363 pParent
->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE
, reinterpret_cast<void*>(nId
));
365 Reference
< XDispatchProvider
> xDispatchProvider( mxFrame
, UNO_QUERY
);
366 if ( xDispatchProvider
.is() )
368 com::sun::star::util::URL aTargetURL
;
369 Reference
< XURLTransformer
> xTrans( URLTransformer::create(::comphelper::getProcessComponentContext()) );
370 aTargetURL
.Complete
= maCommand
;
371 xTrans
->parseStrict( aTargetURL
);
373 Reference
< XDispatch
> xDispatch
= xDispatchProvider
->queryDispatch( aTargetURL
, OUString(), 0 );
374 if ( xDispatch
.is() )
375 xDispatch
->dispatch( aTargetURL
, rArgs
);
379 // -----------------------------------------------------------------------
381 void TableWindow::CloseAndShowTableDialog()
383 // close the toolbar tool
384 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
386 // and open the table dialog instead
387 TableDialog( Sequence
< PropertyValue
>() );
390 // class ColumnsWindow ---------------------------------------------------
392 class ColumnsWindow
: public SfxPopupWindow
396 ::Color aHighlightLineColor
;
398 ::Color aHighlightFillColor
;
404 bool bInitialKeyInput
;
407 Reference
< XFrame
> mxFrame
;
410 void UpdateSize_Impl( long nNewCol
);
412 ColumnsWindow( sal_uInt16 nId
, const OUString
& rCmd
, const String
&rText
, ToolBox
& rParentTbx
, const Reference
< XFrame
>& rFrame
);
414 void KeyInput( const KeyEvent
& rKEvt
);
415 virtual void MouseMove( const MouseEvent
& rMEvt
);
416 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
417 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
418 virtual void Paint( const Rectangle
& );
419 virtual void PopupModeEnd();
420 virtual SfxPopupWindow
* Clone() const;
422 sal_uInt16
GetColCount() const { return (sal_uInt16
)nCol
; }
425 // -----------------------------------------------------------------------
427 ColumnsWindow::ColumnsWindow( sal_uInt16 nId
, const OUString
& rCmd
, const String
& rText
, ToolBox
& rParentTbx
, const Reference
< XFrame
>& rFrame
) :
428 SfxPopupWindow( nId
, rFrame
, WB_STDPOPUP
),
429 bInitialKeyInput(true),
435 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
436 svtools::ColorConfig aColorConfig
;
437 aLineColor
= ::Color( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
438 aHighlightLineColor
= rStyles
.GetHighlightTextColor();
439 aFillColor
= rStyles
.GetWindowColor();
440 aHighlightFillColor
= rStyles
.GetHighlightColor();
441 aFaceColor
= rStyles
.GetFaceColor();
443 nTextHeight
= GetTextHeight()+1;
445 Font
aFont( GetFont() );
446 aFont
.SetColor( aLineColor
);
447 aFont
.SetFillColor( aFaceColor
);
448 aFont
.SetTransparent( sal_False
);
456 Size aLogicSize
= LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM
) );
457 nMX
= aLogicSize
.Width();
458 SetOutputSizePixel( Size( nMX
*nWidth
-1, aLogicSize
.Height()+nTextHeight
) );
462 // -----------------------------------------------------------------------
464 SfxPopupWindow
* ColumnsWindow::Clone() const
466 return new ColumnsWindow( GetId(), maCommand
, GetText(), rTbx
, mxFrame
);
469 // -----------------------------------------------------------------------
471 void ColumnsWindow::MouseMove( const MouseEvent
& rMEvt
)
473 SfxPopupWindow::MouseMove( rMEvt
);
474 Point aPos
= rMEvt
.GetPosPixel();
475 Point aMousePos
= aPos
;
477 if ( rMEvt
.IsEnterWindow() )
479 else if ( aMousePos
.X() < 0 || aMousePos
.Y() < 0 )
489 nNewCol
= aPos
.X() / nMX
+ 1;
494 UpdateSize_Impl( nNewCol
);
497 void ColumnsWindow::UpdateSize_Impl( long nNewCol
)
499 Size aWinSize
= GetOutputSizePixel();
500 Point aWinPos
;// = GetPosPixel();
502 if ( nWidth
<= nNewCol
)
504 Point aMaxPos
= OutputToScreenPixel( GetDesktopRectPixel().BottomRight() );
506 if ( nWidth
<= nNewCol
)
512 while ( nWidth
> 0 &&
513 (short)(aWinPos
.X()+(nMX
*nWidth
-1)) >= aMaxPos
.X()-3 )
516 if ( nNewCol
> nWidth
)
519 Invalidate( Rectangle( 0, aWinSize
.Height()-nTextHeight
+2,
520 aWinSize
.Width(), aWinSize
.Height() ) );
521 SetOutputSizePixel( Size( nMX
*nWidth
-1, aWinSize
.Height() ) );
525 if ( nNewCol
!= nCol
)
527 Invalidate( Rectangle( 0, aWinSize
.Height()-nTextHeight
+2,
528 aWinSize
.Width(), aWinSize
.Height() ) );
530 long nMinCol
= 0, nMaxCol
= 0;
532 if ( nNewCol
< nCol
)
543 Invalidate( Rectangle( nMinCol
*nMX
-1, 0,
544 nMaxCol
*nMX
+1, aWinSize
.Height()-nTextHeight
+2 ) );
549 // -----------------------------------------------------------------------
551 void ColumnsWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
553 SfxPopupWindow::MouseButtonDown( rMEvt
);
557 void ColumnsWindow::KeyInput( const KeyEvent
& rKEvt
)
559 bool bHandled
= false;
560 sal_uInt16 nModifier
= rKEvt
.GetKeyCode().GetModifier();
561 sal_uInt16 nKey
= rKEvt
.GetKeyCode().GetCode();
564 if( KEY_LEFT
== nKey
|| KEY_RIGHT
== nKey
||
565 KEY_RETURN
== nKey
||KEY_ESCAPE
== nKey
||
580 if(IsMouseCaptured())
582 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL
);
586 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL
);
589 //make sure that a table can initially be created
592 bInitialKeyInput
= false;
596 UpdateSize_Impl( nNewCol
);
599 else if(KEY_MOD1
== nModifier
&& KEY_RETURN
== nKey
)
602 if(IsMouseCaptured())
604 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL
);
607 SfxPopupWindow::KeyInput(rKEvt
);
610 // -----------------------------------------------------------------------
612 void ColumnsWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
614 SfxPopupWindow::MouseButtonUp( rMEvt
);
617 if ( IsInPopupMode() )
618 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
621 // -----------------------------------------------------------------------
623 void ColumnsWindow::Paint( const Rectangle
& )
628 Size aSize
= GetOutputSizePixel();
630 for ( i
= 0; i
< nWidth
; i
++ )
634 SetLineColor( aHighlightLineColor
);
635 SetFillColor( aHighlightFillColor
);
639 SetLineColor( aLineColor
);
640 SetFillColor( aFillColor
);
643 DrawRect( Rectangle( i
*nMX
-1, -1,
644 i
*nMX
+nMX
, aSize
.Height()-nTextHeight
+1 ) );
647 while ( j
< aSize
.Height()-nTextHeight
-4 )
653 DrawLine( Point( i
*nMX
+4, j
), Point( i
*nMX
+nMX
-nLineWidth
-4, j
) );
659 SetFillColor( aFaceColor
);
662 aText
= OUString::number(nCol
);
664 aText
= comphelper::string::remove(Button::GetStandardText(BUTTON_CANCEL
), '~');
666 Size
aTextSize(GetTextWidth( aText
), GetTextHeight());
667 DrawText( Point( ( aSize
.Width() - aTextSize
.Width() ) / 2, aSize
.Height() - nTextHeight
+ 2 ), aText
);
669 DrawRect( Rectangle( 0, aSize
.Height()-nTextHeight
+2, (aSize
.Width()-aTextSize
.Width())/2-1, aSize
.Height() ) );
670 DrawRect( Rectangle( (aSize
.Width()-aTextSize
.Width())/2+aTextSize
.Width(), aSize
.Height()-nTextHeight
+2, aSize
.Width(), aSize
.Height() ) );
672 SetLineColor( aLineColor
);
674 DrawRect( Rectangle( 0, 0, aSize
.Width() - 1, aSize
.Height() - nTextHeight
+ 1 ) );
677 // -----------------------------------------------------------------------
679 void ColumnsWindow::PopupModeEnd()
681 if ( !IsPopupModeCanceled() && nCol
)
683 sal_uInt16 nId
= GetId();
684 Window
* pParent
= rTbx
.GetParent();
685 pParent
->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE
, reinterpret_cast<void*>(nId
));
687 Sequence
< PropertyValue
> aArgs( 2 );
688 aArgs
[0].Name
= OUString( "Columns" );
689 aArgs
[0].Value
= makeAny( sal_Int16( nCol
));
690 aArgs
[1].Name
= OUString( "Modifier" );
691 aArgs
[1].Value
= makeAny( sal_Int16( m_bMod1
? KEY_MOD1
: 0 ));
693 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( mxFrame
->getController(), UNO_QUERY
),
697 else if ( IsPopupModeCanceled() )
699 SfxPopupWindow::PopupModeEnd();
702 // class SvxTableToolBoxControl ------------------------------------------
704 SvxTableToolBoxControl::SvxTableToolBoxControl( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
705 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
708 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
712 // -----------------------------------------------------------------------
714 SvxTableToolBoxControl::~SvxTableToolBoxControl()
718 // -----------------------------------------------------------------------
720 SfxPopupWindowType
SvxTableToolBoxControl::GetPopupWindowType() const
722 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE
;
725 // -----------------------------------------------------------------------
727 SfxPopupWindow
* SvxTableToolBoxControl::CreatePopupWindow()
731 ToolBox
& rTbx
= GetToolBox();
732 TableWindow
* pWin
= new TableWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), rTbx
, m_xFrame
);
733 pWin
->StartPopupMode( &rTbx
, FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_NOKEYCLOSE
);
734 SetPopupWindow( pWin
);
740 // -----------------------------------------------------------------------
742 SfxPopupWindow
* SvxTableToolBoxControl::CreatePopupWindowCascading()
745 return new TableWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame
);
749 // -----------------------------------------------------------------------
751 void SvxTableToolBoxControl::StateChanged( sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
753 if ( pState
&& pState
->ISA(SfxUInt16Item
) )
755 sal_Int16 nValue
= static_cast< const SfxUInt16Item
* >( pState
)->GetValue();
756 bEnabled
= ( nValue
!= 0 );
759 bEnabled
= SFX_ITEM_DISABLED
!= eState
;
761 sal_uInt16 nId
= GetId();
762 ToolBox
& rTbx
= GetToolBox();
764 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
765 rTbx
.SetItemState( nId
,
766 ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
769 // class SvxColumnsToolBoxControl ------------------------------------------
771 SvxColumnsToolBoxControl::SvxColumnsToolBoxControl( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
772 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
774 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
778 // -----------------------------------------------------------------------
780 SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl()
784 // -----------------------------------------------------------------------
786 SfxPopupWindowType
SvxColumnsToolBoxControl::GetPopupWindowType() const
788 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE
;
791 // -----------------------------------------------------------------------
793 SfxPopupWindow
* SvxColumnsToolBoxControl::CreatePopupWindow()
795 ColumnsWindow
* pWin
= 0;
798 pWin
= new ColumnsWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame
);
799 pWin
->StartPopupMode( &GetToolBox(),
800 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_NOKEYCLOSE
);
801 SetPopupWindow( pWin
);
806 // -----------------------------------------------------------------------
808 SfxPopupWindow
* SvxColumnsToolBoxControl::CreatePopupWindowCascading()
810 ColumnsWindow
* pWin
= 0;
813 pWin
= new ColumnsWindow( GetSlotId(), m_aCommandURL
, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame
);
818 void SvxColumnsToolBoxControl::StateChanged( sal_uInt16 nSID
,
820 const SfxPoolItem
* pState
)
822 bEnabled
= SFX_ITEM_DISABLED
!= eState
;
823 SfxToolBoxControl::StateChanged(nSID
, eState
, pState
);
826 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */