xref: /trunk/main/svx/source/tbxctrls/linectrl.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _TOOLBOX_HXX //autogen
36*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include <sfx2/app.hxx>
39*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
40*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <svx/dialogs.hrc>
43*cdf0e10cSrcweir #include "helpid.hrc"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include "svx/drawitem.hxx"
46*cdf0e10cSrcweir #include "svx/xattr.hxx"
47*cdf0e10cSrcweir #include <svx/xtable.hxx>
48*cdf0e10cSrcweir #include "svx/linectrl.hxx"
49*cdf0e10cSrcweir #include <svx/itemwin.hxx>
50*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
53*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
54*cdf0e10cSrcweir using namespace ::com::sun::star::util;
55*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
56*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir // Fuer Linienenden-Controller
59*cdf0e10cSrcweir #define MAX_LINES 12
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir #define RESIZE_VALUE_POPUP(value_set)   \
64*cdf0e10cSrcweir {                                                       \
65*cdf0e10cSrcweir     Size aSize = GetOutputSizePixel();                  \
66*cdf0e10cSrcweir     aSize.Width()  -= 4;                                \
67*cdf0e10cSrcweir     aSize.Height() -= 4;                                \
68*cdf0e10cSrcweir     (value_set).SetPosSizePixel( Point(2,2), aSize );   \
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir #define CALCSIZE_VALUE_POPUP(value_set,item_size) \
72*cdf0e10cSrcweir {                                                                   \
73*cdf0e10cSrcweir     Size aSize = (value_set).CalcWindowSizePixel( (item_size) );    \
74*cdf0e10cSrcweir     aSize.Width()  += 4;                                            \
75*cdf0e10cSrcweir     aSize.Height() += 4;                                            \
76*cdf0e10cSrcweir     SetOutputSizePixel( aSize );                                    \
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem );
81*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem );
82*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem );
83*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl,   SfxBoolItem );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir /*************************************************************************
86*cdf0e10cSrcweir |*
87*cdf0e10cSrcweir |* SvxLineStyleToolBoxControl
88*cdf0e10cSrcweir |*
89*cdf0e10cSrcweir \************************************************************************/
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( sal_uInt16 nSlotId,
92*cdf0e10cSrcweir                                                         sal_uInt16 nId,
93*cdf0e10cSrcweir                                                         ToolBox& rTbx ) :
94*cdf0e10cSrcweir     SfxToolBoxControl( nSlotId, nId, rTbx ),
95*cdf0e10cSrcweir     pStyleItem      ( NULL ),
96*cdf0e10cSrcweir     pDashItem       ( NULL ),
97*cdf0e10cSrcweir     bUpdate         ( sal_False )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir     addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )));
100*cdf0e10cSrcweir     addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DashListState" )));
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir //========================================================================
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl()
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir     delete pStyleItem;
108*cdf0e10cSrcweir     delete pDashItem;
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir //========================================================================
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir void SvxLineStyleToolBoxControl::StateChanged (
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir     SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
119*cdf0e10cSrcweir     DBG_ASSERT( pBox, "Window not found!" );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     if( eState == SFX_ITEM_DISABLED )
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         pBox->Disable();
124*cdf0e10cSrcweir         pBox->SetNoSelection();
125*cdf0e10cSrcweir     }
126*cdf0e10cSrcweir     else
127*cdf0e10cSrcweir     {
128*cdf0e10cSrcweir         pBox->Enable();
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir         if ( eState == SFX_ITEM_AVAILABLE )
131*cdf0e10cSrcweir         {
132*cdf0e10cSrcweir             if( nSID == SID_ATTR_LINE_STYLE )
133*cdf0e10cSrcweir             {
134*cdf0e10cSrcweir                 delete pStyleItem;
135*cdf0e10cSrcweir                 pStyleItem = (XLineStyleItem*)pState->Clone();
136*cdf0e10cSrcweir             }
137*cdf0e10cSrcweir             else if( nSID == SID_ATTR_LINE_DASH )
138*cdf0e10cSrcweir             {
139*cdf0e10cSrcweir                 delete pDashItem;
140*cdf0e10cSrcweir                 pDashItem = (XLineDashItem*)pState->Clone();
141*cdf0e10cSrcweir             }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir             bUpdate = sal_True;
144*cdf0e10cSrcweir             Update( pState );
145*cdf0e10cSrcweir         }
146*cdf0e10cSrcweir         else if ( nSID != SID_DASH_LIST )
147*cdf0e10cSrcweir         {
148*cdf0e10cSrcweir             // kein oder uneindeutiger Status
149*cdf0e10cSrcweir             pBox->SetNoSelection();
150*cdf0e10cSrcweir         }
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir //========================================================================
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir void SvxLineStyleToolBoxControl::Update( const SfxPoolItem* pState )
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir     if ( pState && bUpdate )
159*cdf0e10cSrcweir     {
160*cdf0e10cSrcweir         bUpdate = sal_False;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
163*cdf0e10cSrcweir         DBG_ASSERT( pBox, "Window not found!" );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         // Da der Timer unerwartet zuschlagen kann, kann es vorkommen, dass
166*cdf0e10cSrcweir         // die LB noch nicht gefuellt ist. Ein ClearCache() am Control im
167*cdf0e10cSrcweir         // DelayHdl() blieb ohne Erfolg.
168*cdf0e10cSrcweir         if( pBox->GetEntryCount() == 0 )
169*cdf0e10cSrcweir             pBox->FillControl();
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         XLineStyle eXLS;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         if ( pStyleItem )
174*cdf0e10cSrcweir             eXLS = ( XLineStyle )pStyleItem->GetValue();
175*cdf0e10cSrcweir         else
176*cdf0e10cSrcweir             eXLS = XLINE_NONE;
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         switch( eXLS )
179*cdf0e10cSrcweir         {
180*cdf0e10cSrcweir             case XLINE_NONE:
181*cdf0e10cSrcweir                 pBox->SelectEntryPos( 0 );
182*cdf0e10cSrcweir                 break;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir             case XLINE_SOLID:
185*cdf0e10cSrcweir                 pBox->SelectEntryPos( 1 );
186*cdf0e10cSrcweir                 break;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir             case XLINE_DASH:
189*cdf0e10cSrcweir             {
190*cdf0e10cSrcweir                 if( pDashItem )
191*cdf0e10cSrcweir                 {
192*cdf0e10cSrcweir                     String aString( pDashItem->GetName() );
193*cdf0e10cSrcweir                     pBox->SelectEntry( aString );
194*cdf0e10cSrcweir                 }
195*cdf0e10cSrcweir                 else
196*cdf0e10cSrcweir                     pBox->SetNoSelection();
197*cdf0e10cSrcweir             }
198*cdf0e10cSrcweir             break;
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir             default:
201*cdf0e10cSrcweir                 DBG_ERROR( "Nicht unterstuetzter Linientyp" );
202*cdf0e10cSrcweir                 break;
203*cdf0e10cSrcweir         }
204*cdf0e10cSrcweir     }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     if ( pState && ( pState->ISA( SvxDashListItem ) ) )
207*cdf0e10cSrcweir     {
208*cdf0e10cSrcweir         // Die Liste der Linienstile hat sich geaendert
209*cdf0e10cSrcweir         SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
210*cdf0e10cSrcweir         DBG_ASSERT( pBox, "Window not found!" );
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         String aString( pBox->GetSelectEntry() );
213*cdf0e10cSrcweir         pBox->Clear();
214*cdf0e10cSrcweir         pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) );
215*cdf0e10cSrcweir         pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_SOLID) );
216*cdf0e10cSrcweir         pBox->Fill( ((SvxDashListItem*)pState )->GetDashList() );
217*cdf0e10cSrcweir         pBox->SelectEntry( aString );
218*cdf0e10cSrcweir     }
219*cdf0e10cSrcweir }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir //========================================================================
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir Window* SvxLineStyleToolBoxControl::CreateItemWindow( Window *pParent )
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir     return new SvxLineBox( pParent, m_xFrame );
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir /*************************************************************************
229*cdf0e10cSrcweir |*
230*cdf0e10cSrcweir |* SvxLineWidthToolBoxControl
231*cdf0e10cSrcweir |*
232*cdf0e10cSrcweir \************************************************************************/
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl(
235*cdf0e10cSrcweir     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
236*cdf0e10cSrcweir     SfxToolBoxControl( nSlotId, nId, rTbx )
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" )));
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir //========================================================================
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl()
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir //========================================================================
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir void SvxLineWidthToolBoxControl::StateChanged(
250*cdf0e10cSrcweir     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     SvxMetricField* pFld = (SvxMetricField*)
253*cdf0e10cSrcweir                            GetToolBox().GetItemWindow( GetId() );
254*cdf0e10cSrcweir     DBG_ASSERT( pFld, "Window not found" );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     if ( nSID == SID_ATTR_METRIC )
257*cdf0e10cSrcweir     {
258*cdf0e10cSrcweir         pFld->RefreshDlgUnit();
259*cdf0e10cSrcweir     }
260*cdf0e10cSrcweir     else
261*cdf0e10cSrcweir     {
262*cdf0e10cSrcweir         if ( eState == SFX_ITEM_DISABLED )
263*cdf0e10cSrcweir         {
264*cdf0e10cSrcweir             pFld->Disable();
265*cdf0e10cSrcweir             pFld->SetText( String() );
266*cdf0e10cSrcweir         }
267*cdf0e10cSrcweir         else
268*cdf0e10cSrcweir         {
269*cdf0e10cSrcweir             pFld->Enable();
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir             if ( eState == SFX_ITEM_AVAILABLE )
272*cdf0e10cSrcweir             {
273*cdf0e10cSrcweir                 DBG_ASSERT( pState->ISA(XLineWidthItem), "falscher ItemType" );
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir                 // Core-Unit an MetricField uebergeben
276*cdf0e10cSrcweir                 // Darf nicht in CreateItemWin() geschehen!
277*cdf0e10cSrcweir                 SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; // CD!!! GetCoreMetric();
278*cdf0e10cSrcweir                 pFld->SetCoreUnit( eUnit );
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir                 pFld->Update( (const XLineWidthItem*)pState );
281*cdf0e10cSrcweir             }
282*cdf0e10cSrcweir             else
283*cdf0e10cSrcweir                 pFld->Update( NULL );
284*cdf0e10cSrcweir         }
285*cdf0e10cSrcweir     }
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir //========================================================================
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir Window* SvxLineWidthToolBoxControl::CreateItemWindow( Window *pParent )
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     return( new SvxMetricField( pParent, m_xFrame ) );
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir /*************************************************************************
296*cdf0e10cSrcweir |*
297*cdf0e10cSrcweir |* SvxLineColorToolBoxControl
298*cdf0e10cSrcweir |*
299*cdf0e10cSrcweir \************************************************************************/
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
302*cdf0e10cSrcweir     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
303*cdf0e10cSrcweir     SfxToolBoxControl( nSlotId, nId, rTbx )
304*cdf0e10cSrcweir {
305*cdf0e10cSrcweir     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
306*cdf0e10cSrcweir }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir //========================================================================
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
311*cdf0e10cSrcweir {
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir //========================================================================
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir void SvxLineColorToolBoxControl::StateChanged(
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir {
321*cdf0e10cSrcweir     SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
322*cdf0e10cSrcweir     DBG_ASSERT( pBox, "Window not found" );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     if ( nSID != SID_COLOR_TABLE )
325*cdf0e10cSrcweir     {
326*cdf0e10cSrcweir         if ( eState == SFX_ITEM_DISABLED )
327*cdf0e10cSrcweir         {
328*cdf0e10cSrcweir             pBox->Disable();
329*cdf0e10cSrcweir             pBox->SetNoSelection();
330*cdf0e10cSrcweir         }
331*cdf0e10cSrcweir         else
332*cdf0e10cSrcweir         {
333*cdf0e10cSrcweir             pBox->Enable();
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir             if ( eState == SFX_ITEM_AVAILABLE )
336*cdf0e10cSrcweir             {
337*cdf0e10cSrcweir                 DBG_ASSERT( pState->ISA(XLineColorItem), "falscher ItemTyoe" );
338*cdf0e10cSrcweir                 pBox->Update( (const XLineColorItem*) pState );
339*cdf0e10cSrcweir             }
340*cdf0e10cSrcweir             else
341*cdf0e10cSrcweir                 pBox->Update( NULL );
342*cdf0e10cSrcweir         }
343*cdf0e10cSrcweir     }
344*cdf0e10cSrcweir     else
345*cdf0e10cSrcweir         Update( pState );
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir //========================================================================
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir void SvxLineColorToolBoxControl::Update( const SfxPoolItem* pState )
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir     if ( pState && ( pState->ISA( SvxColorTableItem ) ) )
353*cdf0e10cSrcweir     {
354*cdf0e10cSrcweir         SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir         DBG_ASSERT( pBox, "Window not found" );
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir         // Die Liste der Farben (ColorTable) hat sich geaendert:
359*cdf0e10cSrcweir         ::Color aTmpColor( pBox->GetSelectEntryColor() );
360*cdf0e10cSrcweir         pBox->Clear();
361*cdf0e10cSrcweir         pBox->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() );
362*cdf0e10cSrcweir         pBox->SelectEntry( aTmpColor );
363*cdf0e10cSrcweir     }
364*cdf0e10cSrcweir }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir //========================================================================
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir Window* SvxLineColorToolBoxControl::CreateItemWindow( Window *pParent )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     return new SvxColorBox( pParent, m_aCommandURL, m_xFrame );
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir /*************************************************************************
374*cdf0e10cSrcweir |*
375*cdf0e10cSrcweir |* SvxLineEndWindow
376*cdf0e10cSrcweir |*
377*cdf0e10cSrcweir \************************************************************************/
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir SvxLineEndWindow::SvxLineEndWindow(
380*cdf0e10cSrcweir     sal_uInt16 nSlotId,
381*cdf0e10cSrcweir     const Reference< XFrame >& rFrame,
382*cdf0e10cSrcweir     const String& rWndTitle ) :
383*cdf0e10cSrcweir     SfxPopupWindow( nSlotId,
384*cdf0e10cSrcweir                     rFrame,
385*cdf0e10cSrcweir                     WinBits( WB_BORDER | WB_STDFLOATWIN | WB_SIZEABLE | WB_3DLOOK ) ),
386*cdf0e10cSrcweir     pLineEndList    ( NULL ),
387*cdf0e10cSrcweir     aLineEndSet     ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
388*cdf0e10cSrcweir     nCols           ( 2 ),
389*cdf0e10cSrcweir     nLines          ( 12 ),
390*cdf0e10cSrcweir     nLineEndWidth   ( 400 ),
391*cdf0e10cSrcweir     bPopupMode      ( sal_True ),
392*cdf0e10cSrcweir     mbInResize      ( false ),
393*cdf0e10cSrcweir     mxFrame         ( rFrame )
394*cdf0e10cSrcweir {
395*cdf0e10cSrcweir     SetText( rWndTitle );
396*cdf0e10cSrcweir     implInit();
397*cdf0e10cSrcweir }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir SvxLineEndWindow::SvxLineEndWindow(
400*cdf0e10cSrcweir     sal_uInt16 nSlotId,
401*cdf0e10cSrcweir     const Reference< XFrame >& rFrame,
402*cdf0e10cSrcweir     Window* pParentWindow,
403*cdf0e10cSrcweir     const String& rWndTitle ) :
404*cdf0e10cSrcweir     SfxPopupWindow( nSlotId,
405*cdf0e10cSrcweir                     rFrame,
406*cdf0e10cSrcweir                     pParentWindow,
407*cdf0e10cSrcweir                     WinBits( WB_BORDER | WB_STDFLOATWIN | WB_SIZEABLE | WB_3DLOOK ) ),
408*cdf0e10cSrcweir     pLineEndList    ( NULL ),
409*cdf0e10cSrcweir     aLineEndSet     ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
410*cdf0e10cSrcweir     nCols           ( 2 ),
411*cdf0e10cSrcweir     nLines          ( 12 ),
412*cdf0e10cSrcweir     nLineEndWidth   ( 400 ),
413*cdf0e10cSrcweir     bPopupMode      ( sal_True ),
414*cdf0e10cSrcweir     mbInResize      ( false ),
415*cdf0e10cSrcweir     mxFrame         ( rFrame )
416*cdf0e10cSrcweir {
417*cdf0e10cSrcweir     SetText( rWndTitle );
418*cdf0e10cSrcweir     implInit();
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir void SvxLineEndWindow::implInit()
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir     SfxObjectShell*     pDocSh  = SfxObjectShell::Current();
424*cdf0e10cSrcweir     const SfxPoolItem*  pItem   = NULL;
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir     SetHelpId( HID_POPUP_LINEEND );
427*cdf0e10cSrcweir     aLineEndSet.SetHelpId( HID_POPUP_LINEEND_CTRL );
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir     if ( pDocSh )
430*cdf0e10cSrcweir     {
431*cdf0e10cSrcweir         pItem = pDocSh->GetItem( SID_LINEEND_LIST );
432*cdf0e10cSrcweir         if( pItem )
433*cdf0e10cSrcweir             pLineEndList = ( (SvxLineEndListItem*) pItem )->GetLineEndList();
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir         pItem = pDocSh->GetItem( SID_ATTR_LINEEND_WIDTH_DEFAULT );
436*cdf0e10cSrcweir         if( pItem )
437*cdf0e10cSrcweir             nLineEndWidth = ( (SfxUInt16Item*) pItem )->GetValue();
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir     DBG_ASSERT( pLineEndList, "LineEndList wurde nicht gefunden" );
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     aLineEndSet.SetSelectHdl( LINK( this, SvxLineEndWindow, SelectHdl ) );
442*cdf0e10cSrcweir     aLineEndSet.SetColCount( nCols );
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir     // ValueSet mit Eintraegen der LineEndList fuellen
445*cdf0e10cSrcweir     FillValueSet();
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir     AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndListState" )));
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir     //ChangeHelpId( HID_POPUP_LINEENDSTYLE );
450*cdf0e10cSrcweir     aLineEndSet.Show();
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir SfxPopupWindow* SvxLineEndWindow::Clone() const
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir     return new SvxLineEndWindow( GetId(), mxFrame, GetText() );
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir // -----------------------------------------------------------------------
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir SvxLineEndWindow::~SvxLineEndWindow()
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir }
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir // -----------------------------------------------------------------------
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir IMPL_LINK( SvxLineEndWindow, SelectHdl, void *, EMPTYARG )
467*cdf0e10cSrcweir {
468*cdf0e10cSrcweir     XLineEndItem*           pLineEndItem = NULL;
469*cdf0e10cSrcweir     XLineStartItem*         pLineStartItem = NULL;
470*cdf0e10cSrcweir     sal_uInt16                  nId = aLineEndSet.GetSelectItemId();
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir     if( nId == 1 )
473*cdf0e10cSrcweir     {
474*cdf0e10cSrcweir         pLineStartItem  = new XLineStartItem();
475*cdf0e10cSrcweir     }
476*cdf0e10cSrcweir     else if( nId == 2 )
477*cdf0e10cSrcweir     {
478*cdf0e10cSrcweir         pLineEndItem    = new XLineEndItem();
479*cdf0e10cSrcweir     }
480*cdf0e10cSrcweir     else if( nId % 2 ) // LinienAnfang
481*cdf0e10cSrcweir     {
482*cdf0e10cSrcweir         XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
483*cdf0e10cSrcweir         pLineStartItem  = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() );
484*cdf0e10cSrcweir     }
485*cdf0e10cSrcweir     else // LinienEnde
486*cdf0e10cSrcweir     {
487*cdf0e10cSrcweir         XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
488*cdf0e10cSrcweir         pLineEndItem    = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() );
489*cdf0e10cSrcweir     }
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir     if ( IsInPopupMode() )
492*cdf0e10cSrcweir         EndPopupMode();
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir     Sequence< PropertyValue > aArgs( 1 );
495*cdf0e10cSrcweir     Any a;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir     if ( pLineStartItem )
498*cdf0e10cSrcweir     {
499*cdf0e10cSrcweir         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStart" ));
500*cdf0e10cSrcweir         pLineStartItem->QueryValue( a );
501*cdf0e10cSrcweir         aArgs[0].Value = a;
502*cdf0e10cSrcweir     }
503*cdf0e10cSrcweir     else
504*cdf0e10cSrcweir     {
505*cdf0e10cSrcweir         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" ));
506*cdf0e10cSrcweir         pLineEndItem->QueryValue( a );
507*cdf0e10cSrcweir         aArgs[0].Value = a;
508*cdf0e10cSrcweir     }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir     /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
511*cdf0e10cSrcweir         This instance may be deleted in the meantime (i.e. when a dialog is opened
512*cdf0e10cSrcweir         while in Dispatch()), accessing members will crash in this case. */
513*cdf0e10cSrcweir     aLineEndSet.SetNoSelection();
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir     SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
516*cdf0e10cSrcweir                                  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndStyle" )),
517*cdf0e10cSrcweir                                  aArgs );
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir     delete pLineEndItem;
520*cdf0e10cSrcweir     delete pLineStartItem;
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir     return 0;
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir // -----------------------------------------------------------------------
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir void SvxLineEndWindow::FillValueSet()
528*cdf0e10cSrcweir {
529*cdf0e10cSrcweir     if( pLineEndList )
530*cdf0e10cSrcweir     {
531*cdf0e10cSrcweir         XLineEndEntry*      pEntry  = NULL;
532*cdf0e10cSrcweir         Bitmap*             pBmp    = NULL;
533*cdf0e10cSrcweir         VirtualDevice       aVD;
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir         long nCount = pLineEndList->Count();
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir         // Erster Eintrag: kein LinienEnde
538*cdf0e10cSrcweir         // Temporaer wird ein Eintrag hinzugefuegt, um die UI-Bitmap zu erhalten
539*cdf0e10cSrcweir         basegfx::B2DPolyPolygon aNothing;
540*cdf0e10cSrcweir         pLineEndList->Insert( new XLineEndEntry( aNothing, SVX_RESSTR( RID_SVXSTR_NONE ) ) );
541*cdf0e10cSrcweir         pEntry = pLineEndList->GetLineEnd( nCount );
542*cdf0e10cSrcweir         pBmp = pLineEndList->GetBitmap( nCount );
543*cdf0e10cSrcweir         DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" );
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir         aBmpSize = pBmp->GetSizePixel();
546*cdf0e10cSrcweir         aVD.SetOutputSizePixel( aBmpSize, sal_False );
547*cdf0e10cSrcweir         aBmpSize.Width() = aBmpSize.Width() / 2;
548*cdf0e10cSrcweir         Point aPt0( 0, 0 );
549*cdf0e10cSrcweir         Point aPt1( aBmpSize.Width(), 0 );
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir         aVD.DrawBitmap( Point(), *pBmp );
552*cdf0e10cSrcweir         aLineEndSet.InsertItem( 1, aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() );
553*cdf0e10cSrcweir         aLineEndSet.InsertItem( 2, aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() );
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir         delete pLineEndList->Remove( nCount );
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir         for( long i = 0; i < nCount; i++ )
558*cdf0e10cSrcweir         {
559*cdf0e10cSrcweir             pEntry = pLineEndList->GetLineEnd( i );
560*cdf0e10cSrcweir             DBG_ASSERT( pEntry, "Konnte auf LineEndEntry nicht zugreifen" );
561*cdf0e10cSrcweir             pBmp = pLineEndList->GetBitmap( i );
562*cdf0e10cSrcweir             DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" );
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir             aVD.DrawBitmap( aPt0, *pBmp );
565*cdf0e10cSrcweir             aLineEndSet.InsertItem( (sal_uInt16)((i+1L)*2L+1L), aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() );
566*cdf0e10cSrcweir             aLineEndSet.InsertItem( (sal_uInt16)((i+2L)*2L),    aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() );
567*cdf0e10cSrcweir         }
568*cdf0e10cSrcweir         nLines = Min( (sal_uInt16)(nCount + 1), (sal_uInt16) MAX_LINES );
569*cdf0e10cSrcweir         aLineEndSet.SetLineCount( nLines );
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir         SetSize();
572*cdf0e10cSrcweir     }
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir // -----------------------------------------------------------------------
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir void SvxLineEndWindow::Resize()
578*cdf0e10cSrcweir {
579*cdf0e10cSrcweir     // since we change the size inside this call, check if we
580*cdf0e10cSrcweir     // are called recursive
581*cdf0e10cSrcweir     if( !mbInResize )
582*cdf0e10cSrcweir     {
583*cdf0e10cSrcweir         mbInResize = true;
584*cdf0e10cSrcweir         if ( !IsRollUp() )
585*cdf0e10cSrcweir         {
586*cdf0e10cSrcweir             aLineEndSet.SetColCount( nCols );
587*cdf0e10cSrcweir             aLineEndSet.SetLineCount( nLines );
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir             SetSize();
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir             Size aSize = GetOutputSizePixel();
592*cdf0e10cSrcweir             aSize.Width()  -= 4;
593*cdf0e10cSrcweir             aSize.Height() -= 4;
594*cdf0e10cSrcweir             aLineEndSet.SetPosSizePixel( Point( 2, 2 ), aSize );
595*cdf0e10cSrcweir         }
596*cdf0e10cSrcweir         //SfxPopupWindow::Resize();
597*cdf0e10cSrcweir         mbInResize = false;
598*cdf0e10cSrcweir     }
599*cdf0e10cSrcweir }
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir // -----------------------------------------------------------------------
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir void __EXPORT SvxLineEndWindow::Resizing( Size& rNewSize )
604*cdf0e10cSrcweir {
605*cdf0e10cSrcweir     Size aBitmapSize = aBmpSize; // -> Member
606*cdf0e10cSrcweir     aBitmapSize.Width()  += 6; //
607*cdf0e10cSrcweir     aBitmapSize.Height() += 6; //
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir     Size aItemSize = aLineEndSet.CalcItemSizePixel( aBitmapSize );  // -> Member
610*cdf0e10cSrcweir     //Size aOldSize = GetOutputSizePixel(); // fuer Breite
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir     sal_uInt16 nItemCount = aLineEndSet.GetItemCount(); // -> Member
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir     // Spalten ermitteln
615*cdf0e10cSrcweir     long nItemW = aItemSize.Width();
616*cdf0e10cSrcweir     long nW = rNewSize.Width();
617*cdf0e10cSrcweir     nCols = (sal_uInt16) Max( ( (sal_uIntPtr)(( nW + nItemW ) / ( nItemW * 2 ) )),
618*cdf0e10cSrcweir                                             (sal_uIntPtr) 1L );
619*cdf0e10cSrcweir     nCols *= 2;
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir     // Reihen ermitteln
622*cdf0e10cSrcweir     long nItemH = aItemSize.Height();
623*cdf0e10cSrcweir     long nH = rNewSize.Height();
624*cdf0e10cSrcweir     nLines = (sal_uInt16) Max( ( ( nH + nItemH / 2 ) / nItemH ), 1L );
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir     sal_uInt16 nMaxCols  = nItemCount / nLines;
627*cdf0e10cSrcweir     if( nItemCount % nLines )
628*cdf0e10cSrcweir         nMaxCols++;
629*cdf0e10cSrcweir     if( nCols > nMaxCols )
630*cdf0e10cSrcweir         nCols = nMaxCols;
631*cdf0e10cSrcweir     nW = nItemW * nCols;
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir     // Keine ungerade Anzahl von Spalten
634*cdf0e10cSrcweir     if( nCols % 2 )
635*cdf0e10cSrcweir         nCols--;
636*cdf0e10cSrcweir     nCols = Max( nCols, (sal_uInt16) 2 );
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     sal_uInt16 nMaxLines  = nItemCount / nCols;
639*cdf0e10cSrcweir     if( nItemCount % nCols )
640*cdf0e10cSrcweir         nMaxLines++;
641*cdf0e10cSrcweir     if( nLines > nMaxLines )
642*cdf0e10cSrcweir         nLines = nMaxLines;
643*cdf0e10cSrcweir     nH = nItemH * nLines;
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir     rNewSize.Width() = nW;
646*cdf0e10cSrcweir     rNewSize.Height() = nH;
647*cdf0e10cSrcweir }
648*cdf0e10cSrcweir // -----------------------------------------------------------------------
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir void SvxLineEndWindow::StartSelection()
651*cdf0e10cSrcweir {
652*cdf0e10cSrcweir     aLineEndSet.StartSelection();
653*cdf0e10cSrcweir }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir // -----------------------------------------------------------------------
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir sal_Bool SvxLineEndWindow::Close()
658*cdf0e10cSrcweir {
659*cdf0e10cSrcweir     return SfxPopupWindow::Close();
660*cdf0e10cSrcweir }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir // -----------------------------------------------------------------------
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir void SvxLineEndWindow::StateChanged(
665*cdf0e10cSrcweir     sal_uInt16 nSID, SfxItemState, const SfxPoolItem* pState )
666*cdf0e10cSrcweir {
667*cdf0e10cSrcweir     if ( nSID == SID_LINEEND_LIST )
668*cdf0e10cSrcweir     {
669*cdf0e10cSrcweir         // Die Liste der LinienEnden (LineEndList) hat sich geaendert:
670*cdf0e10cSrcweir         if ( pState && pState->ISA( SvxLineEndListItem ))
671*cdf0e10cSrcweir         {
672*cdf0e10cSrcweir             pLineEndList = ((SvxLineEndListItem*)pState)->GetLineEndList();
673*cdf0e10cSrcweir             DBG_ASSERT( pLineEndList, "LineEndList nicht gefunden" );
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir             aLineEndSet.Clear();
676*cdf0e10cSrcweir             FillValueSet();
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir             Size aSize = GetOutputSizePixel();
679*cdf0e10cSrcweir             Resizing( aSize );
680*cdf0e10cSrcweir             Resize();
681*cdf0e10cSrcweir         }
682*cdf0e10cSrcweir     }
683*cdf0e10cSrcweir }
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir // -----------------------------------------------------------------------
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir void SvxLineEndWindow::PopupModeEnd()
688*cdf0e10cSrcweir {
689*cdf0e10cSrcweir     if ( IsVisible() )
690*cdf0e10cSrcweir     {
691*cdf0e10cSrcweir         bPopupMode = sal_False;
692*cdf0e10cSrcweir         SetSize();
693*cdf0e10cSrcweir     }
694*cdf0e10cSrcweir     SfxPopupWindow::PopupModeEnd();
695*cdf0e10cSrcweir }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir // -----------------------------------------------------------------------
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir void SvxLineEndWindow::SetSize()
700*cdf0e10cSrcweir {
701*cdf0e10cSrcweir     //if( !bPopupMode )
702*cdf0e10cSrcweir     if( !IsInPopupMode() )
703*cdf0e10cSrcweir     {
704*cdf0e10cSrcweir         sal_uInt16 nItemCount = aLineEndSet.GetItemCount(); // -> Member
705*cdf0e10cSrcweir         sal_uInt16 nMaxLines  = nItemCount / nCols; // -> Member ?
706*cdf0e10cSrcweir         if( nItemCount % nCols )
707*cdf0e10cSrcweir             nMaxLines++;
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir         WinBits nBits = aLineEndSet.GetStyle();
710*cdf0e10cSrcweir         if ( nLines == nMaxLines )
711*cdf0e10cSrcweir             nBits &= ~WB_VSCROLL;
712*cdf0e10cSrcweir         else
713*cdf0e10cSrcweir             nBits |= WB_VSCROLL;
714*cdf0e10cSrcweir         aLineEndSet.SetStyle( nBits );
715*cdf0e10cSrcweir     }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir     Size aSize( aBmpSize );
718*cdf0e10cSrcweir     aSize.Width()  += 6;
719*cdf0e10cSrcweir     aSize.Height() += 6;
720*cdf0e10cSrcweir     aSize = aLineEndSet.CalcWindowSizePixel( aSize );
721*cdf0e10cSrcweir     aSize.Width()  += 4;
722*cdf0e10cSrcweir     aSize.Height() += 4;
723*cdf0e10cSrcweir     SetOutputSizePixel( aSize );
724*cdf0e10cSrcweir     aSize.Height() = aBmpSize.Height();
725*cdf0e10cSrcweir     aSize.Height() += 14;
726*cdf0e10cSrcweir     //SetMinOutputSizePixel( aSize );
727*cdf0e10cSrcweir }
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir void SvxLineEndWindow::GetFocus (void)
730*cdf0e10cSrcweir {
731*cdf0e10cSrcweir     SfxPopupWindow::GetFocus();
732*cdf0e10cSrcweir     // Grab the focus to the line ends value set so that it can be controlled
733*cdf0e10cSrcweir     // with the keyboard.
734*cdf0e10cSrcweir     aLineEndSet.GrabFocus();
735*cdf0e10cSrcweir }
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir /*************************************************************************
738*cdf0e10cSrcweir |*
739*cdf0e10cSrcweir |* SvxLineEndToolBoxControl
740*cdf0e10cSrcweir |*
741*cdf0e10cSrcweir \************************************************************************/
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox &rTbx ) :
744*cdf0e10cSrcweir     SfxToolBoxControl( nSlotId, nId, rTbx )
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir     rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
747*cdf0e10cSrcweir     rTbx.Invalidate();
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir // -----------------------------------------------------------------------
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl()
753*cdf0e10cSrcweir {
754*cdf0e10cSrcweir }
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir // -----------------------------------------------------------------------
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir SfxPopupWindowType SvxLineEndToolBoxControl::GetPopupWindowType() const
759*cdf0e10cSrcweir {
760*cdf0e10cSrcweir     return SFX_POPUPWINDOW_ONCLICK;
761*cdf0e10cSrcweir }
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir // -----------------------------------------------------------------------
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir SfxPopupWindow* SvxLineEndToolBoxControl::CreatePopupWindow()
766*cdf0e10cSrcweir {
767*cdf0e10cSrcweir     SvxLineEndWindow* pLineEndWin =
768*cdf0e10cSrcweir         new SvxLineEndWindow( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) );
769*cdf0e10cSrcweir     pLineEndWin->StartPopupMode( &GetToolBox(), sal_True );
770*cdf0e10cSrcweir     pLineEndWin->StartSelection();
771*cdf0e10cSrcweir     SetPopupWindow( pLineEndWin );
772*cdf0e10cSrcweir     return pLineEndWin;
773*cdf0e10cSrcweir }
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir // -----------------------------------------------------------------------
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir void SvxLineEndToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* )
778*cdf0e10cSrcweir {
779*cdf0e10cSrcweir     sal_uInt16 nId = GetId();
780*cdf0e10cSrcweir     ToolBox& rTbx = GetToolBox();
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir     rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
783*cdf0e10cSrcweir     rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
784*cdf0e10cSrcweir }
785