update credits
[LibreOffice.git] / svx / source / tbxctrls / layctrl.cxx
blobba93c47f8d246a5c9847a6e9427b2cd41e629c33
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <string>
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>
35 // namespaces
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
60 private:
61 PushButton aTableButton;
62 ::Color aLineColor;
63 ::Color aFillColor;
64 ::Color aHighlightFillColor;
65 ::Color aBackgroundColor;
66 long nCol;
67 long nLine;
68 bool bInitialKeyInput;
69 bool m_bMod1;
70 ToolBox& rTbx;
71 Reference< XFrame > mxFrame;
72 OUString maCommand;
74 DECL_LINK( SelectHdl, void * );
76 public:
77 TableWindow( sal_uInt16 nSlotId,
78 const OUString& rCmd,
79 const String& rText,
80 ToolBox& rParentTbx,
81 const Reference< XFrame >& rFrame );
82 ~TableWindow();
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;
91 private:
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();
102 return 0;
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 ),
110 nCol( 0 ),
111 nLine( 0 ),
112 rTbx(rParentTbx),
113 mxFrame( rFrame ),
114 maCommand( rCmd )
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 );
129 SetFont( aFont );
131 SetText( rText );
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 ) );
137 aTableButton.Show();
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();
176 if ( !nModifier )
178 bHandled = true;
179 long nNewCol = nCol;
180 long nNewLine = nLine;
181 switch(nKey)
183 case KEY_UP:
184 if ( nNewLine > 1 )
185 nNewLine--;
186 else
187 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
188 break;
189 case KEY_DOWN:
190 if ( nNewLine < TABLE_CELLS_VERT )
191 nNewLine++;
192 else
193 CloseAndShowTableDialog();
194 break;
195 case KEY_LEFT:
196 if ( nNewCol > 1 )
197 nNewCol--;
198 else
199 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
200 break;
201 case KEY_RIGHT:
202 if ( nNewCol < TABLE_CELLS_HORIZ )
203 nNewCol++;
204 else
205 CloseAndShowTableDialog();
206 break;
207 case KEY_ESCAPE:
208 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
209 break;
210 case KEY_RETURN:
211 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
212 break;
213 case KEY_TAB:
214 CloseAndShowTableDialog();
215 break;
216 default:
217 bHandled = false;
219 if ( bHandled )
221 //make sure that a table can initially be created
222 if(bInitialKeyInput)
224 bInitialKeyInput = false;
225 if(!nNewLine)
226 nNewLine = 1;
227 if(!nNewCol)
228 nNewCol = 1;
230 Update( nNewCol, nNewLine );
233 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
235 m_bMod1 = true;
236 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
239 if(!bHandled)
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 ) );
265 // the selection
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
284 if ( nCol && nLine )
286 String aText;
287 aText += OUString::number( nCol );
288 aText.AppendAscii( " x " );
289 aText += OUString::number( nLine );
290 if(GetId() == FN_SHOW_MULTIPLE_PAGES)
292 aText += ' ';
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 )
344 nNewCol = 0;
346 if ( nNewLine < 0 || nNewLine > TABLE_CELLS_VERT )
347 nNewLine = 0;
349 if ( nNewCol != nCol || nNewLine != nLine )
351 nCol = nNewCol;
352 nLine = nNewLine;
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
394 private:
395 ::Color aLineColor;
396 ::Color aHighlightLineColor;
397 ::Color aFillColor;
398 ::Color aHighlightFillColor;
399 ::Color aFaceColor;
400 long nCol;
401 long nWidth;
402 long nMX;
403 long nTextHeight;
404 bool bInitialKeyInput;
405 bool m_bMod1;
406 ToolBox& rTbx;
407 Reference< XFrame > mxFrame;
408 OUString maCommand;
410 void UpdateSize_Impl( long nNewCol );
411 public:
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),
430 m_bMod1(false),
431 rTbx(rParentTbx),
432 mxFrame(rFrame),
433 maCommand( rCmd )
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;
444 SetBackground();
445 Font aFont( GetFont() );
446 aFont.SetColor( aLineColor );
447 aFont.SetFillColor( aFaceColor );
448 aFont.SetTransparent( sal_False );
449 SetFont( aFont );
451 nCol = 0;
452 nWidth = 4;
454 SetText( rText );
456 Size aLogicSize = LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM ) );
457 nMX = aLogicSize.Width();
458 SetOutputSizePixel( Size( nMX*nWidth-1, aLogicSize.Height()+nTextHeight ) );
459 StartCascading();
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() )
478 CaptureMouse();
479 else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 )
481 nCol = 0;
482 ReleaseMouse();
483 Invalidate();
484 return;
487 long nNewCol = 0;
488 if ( aPos.X() > 0 )
489 nNewCol = aPos.X() / nMX + 1;
490 if ( aPos.Y() < 0 )
491 nNewCol = 0;
492 if ( nNewCol > 20 )
493 nNewCol = 20;
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 )
508 nWidth = nNewCol;
509 nWidth++;
512 while ( nWidth > 0 &&
513 (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 )
514 nWidth--;
516 if ( nNewCol > nWidth )
517 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 )
534 nMinCol = nNewCol;
535 nMaxCol = nCol;
537 else
539 nMinCol = nCol;
540 nMaxCol = nNewCol;
543 Invalidate( Rectangle( nMinCol*nMX-1, 0,
544 nMaxCol*nMX+1, aWinSize.Height()-nTextHeight+2 ) );
545 nCol = nNewCol;
547 Update();
549 // -----------------------------------------------------------------------
551 void ColumnsWindow::MouseButtonDown( const MouseEvent& rMEvt )
553 SfxPopupWindow::MouseButtonDown( rMEvt );
554 CaptureMouse();
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();
562 if(!nModifier)
564 if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
565 KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
566 KEY_UP == nKey)
568 bHandled = true;
569 long nNewCol = nCol;
570 switch(nKey)
572 case KEY_LEFT :
573 if(nNewCol)
574 nNewCol--;
575 break;
576 case KEY_RIGHT :
577 nNewCol++;
578 break;
579 case KEY_RETURN :
580 if(IsMouseCaptured())
581 ReleaseMouse();
582 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
583 break;
584 case KEY_ESCAPE :
585 case KEY_UP :
586 EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL);
587 break;
589 //make sure that a table can initially be created
590 if(bInitialKeyInput)
592 bInitialKeyInput = false;
593 if(!nNewCol)
594 nNewCol = 1;
596 UpdateSize_Impl( nNewCol );
599 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
601 m_bMod1 = true;
602 if(IsMouseCaptured())
603 ReleaseMouse();
604 EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
606 if(!bHandled)
607 SfxPopupWindow::KeyInput(rKEvt);
610 // -----------------------------------------------------------------------
612 void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt )
614 SfxPopupWindow::MouseButtonUp( rMEvt );
615 ReleaseMouse();
617 if ( IsInPopupMode() )
618 EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
621 // -----------------------------------------------------------------------
623 void ColumnsWindow::Paint( const Rectangle& )
625 long i;
626 long j;
627 long nLineWidth;
628 Size aSize = GetOutputSizePixel();
630 for ( i = 0; i < nWidth; i++ )
632 if ( i < nCol )
634 SetLineColor( aHighlightLineColor );
635 SetFillColor( aHighlightFillColor );
637 else
639 SetLineColor( aLineColor );
640 SetFillColor( aFillColor );
643 DrawRect( Rectangle( i*nMX-1, -1,
644 i*nMX+nMX, aSize.Height()-nTextHeight+1 ) );
646 j = 4;
647 while ( j < aSize.Height()-nTextHeight-4 )
649 if ( !(j % 16) )
650 nLineWidth = 10;
651 else
652 nLineWidth = 4;
653 DrawLine( Point( i*nMX+4, j ), Point( i*nMX+nMX-nLineWidth-4, j ) );
654 j += 4;
658 SetLineColor();
659 SetFillColor( aFaceColor );
660 String aText;
661 if ( nCol )
662 aText = OUString::number(nCol);
663 else
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 );
673 SetFillColor();
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 ),
694 maCommand,
695 aArgs );
697 else if ( IsPopupModeCanceled() )
698 ReleaseMouse();
699 SfxPopupWindow::PopupModeEnd();
702 // class SvxTableToolBoxControl ------------------------------------------
704 SvxTableToolBoxControl::SvxTableToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
705 SfxToolBoxControl( nSlotId, nId, rTbx ),
706 bEnabled( sal_True )
708 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
709 rTbx.Invalidate();
712 // -----------------------------------------------------------------------
714 SvxTableToolBoxControl::~SvxTableToolBoxControl()
718 // -----------------------------------------------------------------------
720 SfxPopupWindowType SvxTableToolBoxControl::GetPopupWindowType() const
722 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE;
725 // -----------------------------------------------------------------------
727 SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindow()
729 if ( bEnabled )
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 );
735 return pWin;
737 return 0;
740 // -----------------------------------------------------------------------
742 SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindowCascading()
744 if ( bEnabled )
745 return new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame );
746 return 0;
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 );
758 else
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 ) );
775 rTbx.Invalidate();
778 // -----------------------------------------------------------------------
780 SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl()
784 // -----------------------------------------------------------------------
786 SfxPopupWindowType SvxColumnsToolBoxControl::GetPopupWindowType() const
788 return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE;
791 // -----------------------------------------------------------------------
793 SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindow()
795 ColumnsWindow* pWin = 0;
796 if(bEnabled)
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 );
803 return pWin;
806 // -----------------------------------------------------------------------
808 SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindowCascading()
810 ColumnsWindow* pWin = 0;
811 if(bEnabled)
813 pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame );
815 return pWin;
818 void SvxColumnsToolBoxControl::StateChanged( sal_uInt16 nSID,
819 SfxItemState eState,
820 const SfxPoolItem* pState )
822 bEnabled = SFX_ITEM_DISABLED != eState;
823 SfxToolBoxControl::StateChanged(nSID, eState, pState );
826 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */