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