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