xref: /aoo42x/main/svx/source/tbxctrls/tbcontrl.cxx (revision d205bed2)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 // include ---------------------------------------------------------------
32 
33 
34 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
35 #include <tools/shl.hxx>
36 #include <svl/poolitem.hxx>
37 #include <svl/eitem.hxx>
38 #include <vcl/toolbox.hxx>
39 #include <vcl/bmpacc.hxx>
40 #include <svtools/valueset.hxx>
41 #include <svtools/ctrlbox.hxx>
42 #include <svl/style.hxx>
43 #include <svtools/ctrltool.hxx>
44 #include <svl/stritem.hxx>
45 #include <unotools/pathoptions.hxx>
46 #include <sfx2/tplpitem.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <sfx2/viewsh.hxx>
49 #include <sfx2/objsh.hxx>
50 #include <sfx2/docfac.hxx>
51 #include <sfx2/templdlg.hxx>
52 #include <svl/isethint.hxx>
53 #include <sfx2/querystatus.hxx>
54 #include <sfx2/sfxstatuslistener.hxx>
55 #include <tools/urlobj.hxx>
56 #include <sfx2/childwin.hxx>
57 #include <sfx2/viewfrm.hxx>
58 #include <unotools/fontoptions.hxx>
59 #include <vcl/mnemonic.hxx>
60 
61 #include <vcl/svapp.hxx>
62 #include <svl/smplhint.hxx>
63 
64 #define _SVX_TBCONTRL_CXX
65 #include <svtools/colorcfg.hxx>
66 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
67 #include <com/sun/star/lang/XServiceInfo.hpp>
68 #include <com/sun/star/beans/XPropertySet.hpp>
69 #include <com/sun/star/frame/status/ItemStatus.hpp>
70 #include <com/sun/star/frame/status/FontHeight.hpp>
71 
72 #include <svx/dialogs.hrc>
73 #include <svx/svxitems.hrc>
74 #include "helpid.hrc"
75 #include "svx/htmlmode.hxx"
76 #include <svx/xtable.hxx>
77 #include "editeng/fontitem.hxx"
78 #include <editeng/fhgtitem.hxx>
79 #include <editeng/brshitem.hxx>
80 #include <editeng/boxitem.hxx>
81 #include <editeng/colritem.hxx>
82 #include "editeng/flstitem.hxx"
83 #include "editeng/bolnitem.hxx"
84 #include "svx/drawitem.hxx"
85 #include <svx/tbcontrl.hxx>
86 #include "svx/dlgutil.hxx"
87 #include <svx/dialmgr.hxx>
88 #include "colorwindow.hxx"
89 #include <memory>
90 
91 #include <svx/tbxcolorupdate.hxx>
92 #include <editeng/eerdll.hxx>
93 #include <editeng/editrids.hrc>
94 
95 // ------------------------------------------------------------------------
96 
97 #define MAX_MRU_FONTNAME_ENTRIES	5
98 #define LOGICAL_EDIT_HEIGHT         12
99 
100 // STATIC DATA -----------------------------------------------------------
101 
102 #ifndef DELETEZ
103 #define DELETEZ(p) (delete (p), (p)=NULL)
104 #endif
105 // don't make more than 15 entries visible at once
106 #define MAX_STYLES_ENTRIES          static_cast< sal_uInt16 >( 15 )
107 
108 void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet );
109 void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize );
110 sal_Bool lcl_FontChangedHint( const SfxHint &rHint );
111 
112 // namespaces
113 using ::rtl::OUString;
114 using namespace ::com::sun::star;
115 using namespace ::com::sun::star::uno;
116 using namespace ::com::sun::star::frame;
117 using namespace ::com::sun::star::util;
118 using namespace ::com::sun::star::beans;
119 using namespace ::com::sun::star::lang;
120 
121 SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
122 SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
123 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem );
124 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorExtToolBoxControl, SvxColorItem );
125 SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl, SvxColorItem );
126 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
127 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
128 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl, SvxColorItem );
129 SFX_IMPL_TOOLBOX_CONTROL( SvxReloadControllerItem,	SfxBoolItem );
130 SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
131 
132 //========================================================================
133 // class SvxStyleBox_Impl -----------------------------------------------------
134 //========================================================================
135 
136 
137 class SvxStyleBox_Impl : public ComboBox
138 {
139 	using Window::IsVisible;
140 public:
141     SvxStyleBox_Impl( Window* pParent, sal_uInt16 nSlot, const OUString& rCommand, SfxStyleFamily eFamily, const Reference< XDispatchProvider >& rDispatchProvider,
142 						const Reference< XFrame >& _xFrame,const String& rClearFormatKey, const String& rMoreKey, sal_Bool bInSpecialMode );
143 	~SvxStyleBox_Impl();
144 
145 	void 			SetFamily( SfxStyleFamily eNewFamily );
146     inline sal_Bool     IsVisible() { return bVisible; }
147 
148 	virtual long	PreNotify( NotifyEvent& rNEvt );
149 	virtual long	Notify( NotifyEvent& rNEvt );
150     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
151     virtual void	StateChanged( StateChangedType nStateChange );
152 
153     inline void     SetVisibilityListener( const Link& aVisListener ) { aVisibilityListener = aVisListener; }
154     inline void     RemoveVisibilityListener() { aVisibilityListener = Link(); }
155 
156     void            SetDefaultStyle( const ::rtl::OUString& rDefault ) { sDefaultStyle = rDefault; }
157     DECL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control* );
158 
159 protected:
160 	virtual void	Select();
161 
162 private:
163 	sal_uInt16			                nSlotId;
164 	SfxStyleFamily	                eStyleFamily;
165 	sal_uInt16			                nCurSel;
166 	sal_Bool			                bRelease;
167     Size                            aLogicalSize;
168 	Link			                aVisibilityListener;
169 	sal_Bool			                bVisible;
170     Reference< XDispatchProvider >  m_xDispatchProvider;
171     Reference< XFrame >             m_xFrame;
172     OUString                        m_aCommand;
173 	String							aClearFormatKey;
174 	String							aMoreKey;
175 	String                          sDefaultStyle;
176     sal_Bool							bInSpecialMode;
177 
178 	void			ReleaseFocus();
179 };
180 
181 //========================================================================
182 // class SvxFontNameBox --------------------------------------------------
183 //========================================================================
184 
185 class SvxFontNameBox_Impl : public FontNameBox
186 {
187 	using Window::Update;
188 private:
189 	const FontList*	               pFontList;
190     ::std::auto_ptr<FontList>      m_aOwnFontList;
191 	Font			               aCurFont;
192     Size                           aLogicalSize;
193 	String			               aCurText;
194 	sal_uInt16			               nFtCount;
195 	sal_Bool			               bRelease;
196     Reference< XDispatchProvider > m_xDispatchProvider;
197     Reference< XFrame >            m_xFrame;
198 
199 	void			ReleaseFocus_Impl();
200 	void			EnableControls_Impl();
201 
202 protected:
203 	virtual void 	Select();
204     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
205 
206 public:
207     SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame
208         , WinBits nStyle = WB_SORT
209         );
210 
211 	void			FillList();
212 	void			Update( const SvxFontItem* pFontItem );
213 	sal_uInt16			GetListCount() { return nFtCount; }
214 	void			Clear() { FontNameBox::Clear(); nFtCount = 0; }
215 	void			Fill( const FontList* pList )
216 						{ FontNameBox::Fill( pList );
217 						  nFtCount = pList->GetFontNameCount(); }
218 	virtual long	PreNotify( NotifyEvent& rNEvt );
219 	virtual long	Notify( NotifyEvent& rNEvt );
220 	virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
221     inline void     SetOwnFontList(::std::auto_ptr<FontList> _aOwnFontList) { m_aOwnFontList = _aOwnFontList; }
222 };
223 
224 //========================================================================
225 // class SvxFrameWindow_Impl --------------------------------------------------
226 //========================================================================
227 
228 // fuer den SelectHdl werden die Modifier gebraucht, also
229 // muss man sie im MouseButtonUp besorgen
230 
231 class SvxFrmValueSet_Impl : public ValueSet
232 {
233 	sal_uInt16			nModifier;
234     virtual void    MouseButtonUp( const MouseEvent& rMEvt );
235 public:
236     SvxFrmValueSet_Impl(Window* pParent,  WinBits nWinStyle)
237 		: ValueSet(pParent, nWinStyle), nModifier(0) {}
238 	sal_uInt16			GetModifier() const {return nModifier;}
239 
240 };
241 
242 void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent& rMEvt )
243 {
244 	nModifier = rMEvt.GetModifier();
245 	ValueSet::MouseButtonUp(rMEvt);
246 }
247 
248 class SvxFrameWindow_Impl : public SfxPopupWindow
249 {
250 	using FloatingWindow::StateChanged;
251 
252 private:
253     SvxFrmValueSet_Impl  aFrameSet;
254 	ImageList 		aImgList;
255     sal_Bool        bParagraphMode;
256 
257 #if _SOLAR__PRIVATE
258 	DECL_LINK( SelectHdl, void * );
259 #endif
260 
261 protected:
262 	virtual void    Resize();
263 	virtual sal_Bool	Close();
264 	virtual Window*	GetPreferredKeyInputWindow();
265 	virtual void	GetFocus();
266 
267 public:
268     SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
269     ~SvxFrameWindow_Impl();
270 	void            StartSelection();
271 
272 	virtual void	StateChanged( sal_uInt16 nSID, SfxItemState eState,
273 								  const SfxPoolItem* pState );
274 	virtual SfxPopupWindow* Clone() const;
275 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
276 
277 	inline sal_Bool		IsHighContrast( void ) const;
278 };
279 
280 inline sal_Bool SvxFrameWindow_Impl::IsHighContrast( void ) const
281 {
282 	return GetSettings().GetStyleSettings().GetHighContrastMode();
283 }
284 
285 //========================================================================
286 // class SvxLineWindow_Impl ---------------------------------------------------
287 //========================================================================
288 class SvxLineWindow_Impl : public SfxPopupWindow
289 {
290 private:
291 	ValueSet		    aLineSet;
292 	bool				m_bIsWriter;
293 
294 #if _SOLAR__PRIVATE
295 	void			MakeLineBitmap( sal_uInt16 nNo, Bitmap& rBmp, const Size& rSize, String& rStr,
296 									const ::Color& rLine, const ::Color& rBack );
297 	DECL_LINK( SelectHdl, void * );
298 #endif
299 
300 protected:
301 	virtual void    Resize();
302 	virtual sal_Bool	Close();
303 	virtual Window*	GetPreferredKeyInputWindow();
304 	virtual void	GetFocus();
305     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
306 	void			CreateBitmaps( void );
307 public:
308     SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
309 
310 	void					StartSelection();
311 	virtual SfxPopupWindow* Clone() const;
312 };
313 
314 //########################################################################
315 // Hilfsklassen:
316 //========================================================================
317 // class SfxStyleControllerItem ------------------------------------------
318 //========================================================================
319 class SvxStyleToolBoxControl;
320 
321 class SfxStyleControllerItem_Impl : public SfxStatusListener
322 {
323     public:
324         SfxStyleControllerItem_Impl( const Reference< XDispatchProvider >& rDispatchProvider,
325                                      sal_uInt16 nSlotId,
326                                      const rtl::OUString& rCommand,
327                                      SvxStyleToolBoxControl& rTbxCtl );
328 
329     protected:
330         virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
331 
332     private:
333         SvxStyleToolBoxControl& rControl;
334 };
335 
336 //========================================================================
337 // class SvxStyleBox_Impl -----------------------------------------------------
338 //========================================================================
339 
340 SvxStyleBox_Impl::SvxStyleBox_Impl(
341     Window*                                 pParent,
342     sal_uInt16                                  nSlot,
343     const rtl::OUString&                    rCommand,
344     SfxStyleFamily                          eFamily,
345     const Reference< XDispatchProvider >&   rDispatchProvider,
346     const Reference< XFrame >&              _xFrame,
347 	const String&							rClearFormatKey,
348 	const String&							rMoreKey,
349 	sal_Bool									bInSpec) :
350 
351 	ComboBox( pParent, SVX_RES( RID_SVXTBX_STYLE ) ),
352 
353 	nSlotId		( nSlot ),
354 	eStyleFamily( eFamily ),
355 	bRelease	( sal_True ),
356     bVisible(sal_False),
357     m_xDispatchProvider( rDispatchProvider ),
358     m_xFrame(_xFrame),
359 	m_aCommand  ( rCommand ),
360 	aClearFormatKey	( rClearFormatKey ),
361 	aMoreKey		( rMoreKey ),
362 	bInSpecialMode	( bInSpec )
363 {
364     aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT );
365 	EnableAutocomplete( sal_True );
366 }
367 
368 SvxStyleBox_Impl::~SvxStyleBox_Impl()
369 {
370 }
371 
372 // -----------------------------------------------------------------------
373 
374 void SvxStyleBox_Impl::ReleaseFocus()
375 {
376 	if ( !bRelease )
377 	{
378 		bRelease = sal_True;
379 		return;
380 	}
381     if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
382         m_xFrame->getContainerWindow()->setFocus();
383 }
384 
385 // -----------------------------------------------------------------------
386 
387 void SvxStyleBox_Impl::Select()
388 {
389     // Tell base class about selection so that AT get informed about it.
390     ComboBox::Select();
391 
392 	if ( !IsTravelSelect() )
393 	{
394         String aSelEntry( GetText() );
395 		bool bDoIt = true, bClear = false;
396 		if( bInSpecialMode )
397 		{
398 			if( aSelEntry == aClearFormatKey && GetSelectEntryPos() == 0 )
399 			{
400                 aSelEntry = sDefaultStyle;
401 				bClear = true;
402                 //not only apply default style but also call 'ClearFormatting'
403                 Sequence< PropertyValue > aEmptyVals;
404                 SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ResetAttributes"),
405                     aEmptyVals);
406 			}
407 			else if( aSelEntry == aMoreKey && GetSelectEntryPos() == ( GetEntryCount() - 1 ) )
408 			{
409 				SfxViewFrame* pViewFrm = SfxViewFrame::Current();
410 				DBG_ASSERT( pViewFrm, "SvxStyleBox_Impl::Select(): no viewframe" );
411 				pViewFrm->ShowChildWindow( SID_STYLE_DESIGNER );
412 				SfxChildWindow* pChildWin = pViewFrm->GetChildWindow( SID_STYLE_DESIGNER );
413 				if ( pChildWin && pChildWin->GetWindow() )
414                 {
415                     static_cast< SfxTemplateDialogWrapper* >( pChildWin )->SetParagraphFamily();
416                     static_cast< SfxDockingWindow* >( pChildWin->GetWindow() )->AutoShow( sal_True );
417                     Application::PostUserEvent(
418                         STATIC_LINK( 0, SvxStyleBox_Impl, FocusHdl_Impl ), pChildWin->GetWindow() );
419                 }
420 				bDoIt = false;
421 			}
422 		}
423 
424         // #i36723# after ReleaseFocus() the new entry is included into the List
425         sal_Bool bCreateNew = GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND;
426 
427         /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
428             This instance may be deleted in the meantime (i.e. when a dialog is opened
429             while in Dispatch()), accessing members will crash in this case. */
430         ReleaseFocus();
431 
432         if( bDoIt )
433 		{
434             if ( bClear )
435                 SetText( aSelEntry );
436             SaveValue();
437 
438             Sequence< PropertyValue > aArgs( 2 );
439 	        aArgs[0].Value  = makeAny( OUString( aSelEntry ) );
440 			aArgs[1].Name   = OUString::createFromAscii( "Family" );
441 			aArgs[1].Value  = makeAny( sal_Int16( eStyleFamily ));
442 			if( bCreateNew )
443             {
444                 aArgs[0].Name   = OUString::createFromAscii( "Param" );
445                 SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:StyleNewByExample"), aArgs);
446             }
447             else
448             {
449                 aArgs[0].Name   = OUString::createFromAscii( "Template" );
450 			    SfxToolBoxControl::Dispatch( m_xDispatchProvider, m_aCommand, aArgs );
451             }
452         }
453 	}
454 }
455 // -----------------------------------------------------------------------
456 
457 void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily )
458 {
459 	eStyleFamily = eNewFamily;
460 }
461 
462 // -----------------------------------------------------------------------
463 
464 long SvxStyleBox_Impl::PreNotify( NotifyEvent& rNEvt )
465 {
466 	sal_uInt16 nType = rNEvt.GetType();
467 
468 	if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
469 		nCurSel = GetSelectEntryPos();
470     else if ( EVENT_LOSEFOCUS == nType )
471 	{
472 		// don't handle before our Select() is called
473 		if ( !HasFocus() && !HasChildPathFocus() )
474 			SetText( GetSavedValue() );
475 	}
476 	return ComboBox::PreNotify( rNEvt );
477 }
478 
479 // -----------------------------------------------------------------------
480 
481 long SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt )
482 {
483 	long nHandled = 0;
484 
485 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
486 	{
487 		sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
488 
489 		switch ( nCode )
490 		{
491 			case KEY_RETURN:
492 			case KEY_TAB:
493 			{
494 				if ( KEY_TAB == nCode )
495 					bRelease = sal_False;
496 				else
497 					nHandled = 1;
498 				Select();
499 				break;
500 			}
501 
502 			case KEY_ESCAPE:
503 				SelectEntryPos( nCurSel );
504 				ReleaseFocus();
505 				nHandled = 1;
506 				break;
507 		}
508 	}
509 	return nHandled ? nHandled : ComboBox::Notify( rNEvt );
510 }
511 /* -----------------------------08.03.2002 13:03------------------------------
512 
513  ---------------------------------------------------------------------------*/
514 void SvxStyleBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
515 {
516 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
517          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
518     {
519         SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
520         Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
521         SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
522     }
523 
524     ComboBox::DataChanged( rDCEvt );
525 }
526 
527 void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange )
528 {
529 	ComboBox::StateChanged( nStateChange );
530 
531 	if ( nStateChange == STATE_CHANGE_VISIBLE )
532 	{
533 		bVisible = IsReallyVisible();
534 		if ( aVisibilityListener.IsSet() )
535 			aVisibilityListener.Call( this );
536 	}
537 	else if ( nStateChange == STATE_CHANGE_INITSHOW )
538 	{
539 		bVisible = sal_True;
540 		if ( aVisibilityListener.IsSet() )
541 			aVisibilityListener.Call( this );
542 	}
543 }
544 
545 //--------------------------------------------------------------------
546 
547 IMPL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control*, _pCtrl )
548 {
549 	(void)pThis;
550     if ( _pCtrl )
551         _pCtrl->GrabFocus();
552     return 0;
553 }
554 
555 // -----------------------------------------------------------------------
556 
557 sal_Bool GetDocFontList_Impl( const FontList** ppFontList, SvxFontNameBox_Impl* pBox )
558 {
559 	sal_Bool bChanged = sal_False;
560 	const SfxObjectShell* pDocSh = SfxObjectShell::Current();
561 	SvxFontListItem* pFontListItem = NULL;
562 
563 	if ( pDocSh )
564 		pFontListItem =
565 			(SvxFontListItem*)pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
566     else
567     {
568         ::std::auto_ptr<FontList> aFontList(new FontList( pBox ));
569         *ppFontList = aFontList.get();
570         pBox->SetOwnFontList(aFontList);
571         bChanged = sal_True;
572     }
573 
574 	if ( pFontListItem )
575 	{
576 		const FontList*	pNewFontList = pFontListItem->GetFontList();
577 		DBG_ASSERT( pNewFontList, "Doc-FontList not available!" );
578 
579 		// keine alte Liste, aber neue Liste
580 		if ( !*ppFontList && pNewFontList )
581 		{
582 			// => "ubernehmen
583 			*ppFontList = pNewFontList;
584 			bChanged = sal_True;
585 		}
586 		else
587 		{
588 			// Vergleich der Fontlisten ist nicht vollkommen
589 			// wird die Fontliste am Doc geaendert, kann man hier
590 			// nur ueber die Listbox Aenderungen feststellen, weil
591 			// ppFontList dabei schon upgedatet wurde
592 			bChanged =
593 				( ( *ppFontList != pNewFontList ) ||
594 				  pBox->GetListCount() != pNewFontList->GetFontNameCount() );
595 			HACK(vergleich ist unvollstaendig)
596 
597 			if ( bChanged )
598 				*ppFontList = pNewFontList;
599 		}
600 
601 		if ( pBox )
602 			pBox->Enable();
603 	}
604 	else if ( pBox && ( pDocSh || ( !pDocSh && !ppFontList )))
605     {
606         // Disable box only when we have a SfxObjectShell and didn't get a font list OR
607         // we don't have a SfxObjectShell and no current font list.
608         // It's possible that we currently have no SfxObjectShell, but a current font list.
609         // See #i58471: When a user set the focus into the font name combo box and opens
610         // the help window with F1. After closing the help window, we disable the font name
611         // combo box. The SfxObjectShell::Current() method returns in that case zero. But the
612         // font list hasn't changed and therefore the combo box shouldn't be disabled!
613         pBox->Disable();
614     }
615 
616 	// in die FontBox ggf. auch die neue Liste f"ullen
617 	if ( pBox && bChanged )
618 	{
619 		if ( *ppFontList )
620 			pBox->Fill( *ppFontList );
621 		else
622 			pBox->Clear();
623 	}
624 	return bChanged;
625 }
626 
627 //========================================================================
628 // class SvxFontNameBox_Impl --------------------------------------------------
629 //========================================================================
630 
631 SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame, WinBits nStyle ) :
632 
633 	FontNameBox	       ( pParent, nStyle | WinBits( WB_DROPDOWN | WB_AUTOHSCROLL ) ),
634 	pFontList	       ( NULL ),
635 	aLogicalSize       ( 75,160 ),
636 	nFtCount	       ( 0 ),
637 	bRelease	       ( sal_True ),
638     m_xDispatchProvider( rDispatchProvider ),
639     m_xFrame (_xFrame)
640 {
641     SetSizePixel(LogicToPixel( aLogicalSize, MAP_APPFONT ));
642     EnableControls_Impl();
643 }
644 // -----------------------------------------------------------------------
645 
646 void SvxFontNameBox_Impl::FillList()
647 {
648 	// alte Selektion merken, und am Ende wieder setzen
649 	Selection aOldSel = GetSelection();
650 	// hat sich Doc-Fontlist geaendert?
651 	GetDocFontList_Impl( &pFontList, this );
652 	aCurText = GetText();
653 	SetSelection( aOldSel );
654 }
655 
656 // -----------------------------------------------------------------------
657 
658 void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem )
659 {
660 	if ( pFontItem )
661 	{
662 		aCurFont.SetName		( pFontItem->GetFamilyName() );
663 		aCurFont.SetFamily		( pFontItem->GetFamily() );
664 		aCurFont.SetStyleName	( pFontItem->GetStyleName() );
665 		aCurFont.SetPitch		( pFontItem->GetPitch() );
666 		aCurFont.SetCharSet		( pFontItem->GetCharSet() );
667 	}
668 	String aCurName = aCurFont.GetName();
669 	if ( GetText() != aCurName )
670 		SetText( aCurName );
671 }
672 
673 // -----------------------------------------------------------------------
674 
675 long SvxFontNameBox_Impl::PreNotify( NotifyEvent& rNEvt )
676 {
677 	sal_uInt16 nType = rNEvt.GetType();
678 
679 	if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
680     {
681         EnableControls_Impl();
682 		FillList();
683     }
684     return FontNameBox::PreNotify( rNEvt );
685 }
686 
687 // -----------------------------------------------------------------------
688 
689 long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
690 {
691 	long nHandled = 0;
692 
693 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
694 	{
695 		sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
696 
697 		switch ( nCode )
698 		{
699 			case KEY_RETURN:
700 			case KEY_TAB:
701 			{
702 				if ( KEY_TAB == nCode )
703 					bRelease = sal_False;
704 				else
705 					nHandled = 1;
706 				Select();
707 				break;
708 			}
709 
710 			case KEY_ESCAPE:
711 				SetText( aCurText );
712 				ReleaseFocus_Impl();
713 				break;
714 		}
715 	}
716     else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
717 	{
718 		Window* pFocusWin = Application::GetFocusWindow();
719 		if ( !HasFocus() && GetSubEdit() != pFocusWin )
720 			SetText( GetSavedValue() );
721 	}
722 
723 	return nHandled ? nHandled : FontNameBox::Notify( rNEvt );
724 }
725 
726 // ---------------------------------------------------------------------------
727 void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
728 {
729 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
730          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
731     {
732         SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
733         Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
734         SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
735     }
736 
737     FontNameBox::DataChanged( rDCEvt );
738 }
739 
740 // -----------------------------------------------------------------------
741 
742 void SvxFontNameBox_Impl::ReleaseFocus_Impl()
743 {
744 	if ( !bRelease )
745 	{
746 		bRelease = sal_True;
747 		return;
748 	}
749     if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
750         m_xFrame->getContainerWindow()->setFocus();
751 }
752 
753 // -----------------------------------------------------------------------
754 
755 void SvxFontNameBox_Impl::EnableControls_Impl()
756 {
757 	SvtFontOptions aFontOpt;
758 	sal_Bool bEnable = aFontOpt.IsFontHistoryEnabled();
759 	sal_uInt16 nEntries = bEnable ? MAX_MRU_FONTNAME_ENTRIES : 0;
760 	if ( GetMaxMRUCount() != nEntries )
761 	{
762 		// refill in the next GetFocus-Handler
763 		pFontList = NULL;
764 		Clear();
765 		SetMaxMRUCount( nEntries );
766 	}
767 
768 	bEnable = aFontOpt.IsFontWYSIWYGEnabled();
769 	EnableWYSIWYG( bEnable );
770 	EnableSymbols( bEnable );
771 }
772 
773 // -----------------------------------------------------------------------
774 
775 void SvxFontNameBox_Impl::Select()
776 {
777 	FontNameBox::Select();
778 
779 	if ( !IsTravelSelect() )
780 	{
781 		if ( pFontList )
782 		{
783 			FontInfo aInfo( pFontList->Get( GetText(),
784 											aCurFont.GetWeight(),
785 											aCurFont.GetItalic() ) );
786 			aCurFont = aInfo;
787 
788 			SvxFontItem aFontItem( aInfo.GetFamily(),
789 								   aInfo.GetName(),
790 								   aInfo.GetStyleName(),
791 								   aInfo.GetPitch(),
792 								   aInfo.GetCharSet(),
793 								   SID_ATTR_CHAR_FONT );
794 
795             Any a;
796             Sequence< PropertyValue > aArgs( 1 );
797             aArgs[0].Name   = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ));
798             aFontItem.QueryValue( a );
799             aArgs[0].Value  = a;
800 
801             //  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
802             //  This instance may be deleted in the meantime (i.e. when a dialog is opened
803             //  while in Dispatch()), accessing members will crash in this case.
804             ReleaseFocus_Impl();
805 
806             SfxToolBoxControl::Dispatch( m_xDispatchProvider,
807                                          OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )),
808                                          aArgs );
809 		}
810         else
811             ReleaseFocus_Impl();
812 	}
813 }
814 
815 //========================================================================
816 // class SvxColorWindow_Impl --------------------------------------------------
817 //========================================================================
818 #ifndef WB_NO_DIRECTSELECT
819 #define WB_NO_DIRECTSELECT      ((WinBits)0x04000000)
820 #endif
821 
822 #define PALETTE_X 10
823 #define PALETTE_Y 11
824 #define PALETTE_SIZE (PALETTE_X * PALETTE_Y)
825 
826 SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
827                                           sal_uInt16                     nSlotId,
828                                           const Reference< XFrame >& rFrame,
829 								          const String&              rWndTitle,
830                                           Window*                    pParentWindow ) :
831 
832     SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK|WB_DIALOGCONTROL ) ),
833 
834 	theSlotId( nSlotId ),
835     aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
836     maCommand( rCommand )
837 
838 {
839 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
840 	const SfxPoolItem* pItem = NULL;
841 	XColorTable* pColorTable = NULL;
842 	sal_Bool bKillTable = sal_False;
843     const Size aSize12( 13, 13 );
844 
845 	if ( pDocSh )
846 		if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
847 			pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
848 
849 	if ( !pColorTable )
850 	{
851 		pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
852 		bKillTable = sal_True;
853 	}
854 
855 	if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
856 	{
857 		aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
858 		aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
859 		aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
860 	}
861     else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId )
862 	{
863         SfxPoolItem* pDummy;
864 
865 		Reference< XDispatchProvider > aDisp( GetFrame()->getController(), UNO_QUERY );
866         SfxQueryStatus aQueryStatus( aDisp,
867                                      SID_ATTR_AUTO_COLOR_INVALID,
868                                      rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoColorInvalid" )));
869         SfxItemState eState = aQueryStatus.QueryState( pDummy );
870         if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
871         {
872             aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
873             aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
874 			aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
875         }
876 	}
877 	else
878 	{
879 		aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
880 	}
881 
882 	if ( pColorTable )
883 	{
884 		short i = 0;
885 		long nCount = pColorTable->Count();
886 		XColorEntry* pEntry = NULL;
887 		::Color aColWhite( COL_WHITE );
888 		String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) );
889 
890         if ( nCount > PALETTE_SIZE )
891             // Show scrollbar if more than PALLETTE_SIZE colors are available
892 			aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL );
893 
894 		for ( i = 0; i < nCount; i++ )
895 		{
896 			pEntry = pColorTable->GetColor(i);
897 			aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
898 		}
899 
900         while ( i < PALETTE_SIZE )
901 		{
902             // fill empty elements if less then PALLETTE_SIZE colors are available
903 			aColorSet.InsertItem( i+1, aColWhite, aStrWhite );
904 			i++;
905 		}
906 	}
907 
908     aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
909     aColorSet.SetColCount( PALETTE_X );
910     aColorSet.SetLineCount( PALETTE_Y );
911 
912 	lcl_CalcSizeValueSet( *this, aColorSet, aSize12 );
913 
914 	SetHelpId( HID_POPUP_COLOR );
915 	aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
916 
917 	SetText( rWndTitle );
918 	aColorSet.Show();
919 
920     AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
921 	if ( bKillTable )
922 		delete pColorTable;
923 }
924 
925 SvxColorWindow_Impl::~SvxColorWindow_Impl()
926 {
927 }
928 
929 void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
930 {
931     aColorSet.KeyInput(rKEvt);
932 }
933 
934 SfxPopupWindow* SvxColorWindow_Impl::Clone() const
935 {
936     return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent() );
937 }
938 
939 // -----------------------------------------------------------------------
940 
941 IMPL_LINK( SvxColorWindow_Impl, SelectHdl, void *, EMPTYARG )
942 {
943 	sal_uInt16 nItemId = aColorSet.GetSelectItemId();
944     SvxColorItem aColorItem( aColorSet.GetItemColor( nItemId ), theSlotId );
945 
946     /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
947         This instance may be deleted in the meantime (i.e. when a dialog is opened
948         while in Dispatch()), accessing members will crash in this case. */
949     aColorSet.SetNoSelection();
950 
951 	if ( IsInPopupMode() )
952 		EndPopupMode();
953 
954 	if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId  || SID_BACKGROUND_COLOR == theSlotId ) )
955     {
956 		Sequence< PropertyValue > aArgs;
957         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
958                                      maCommand,
959                                      aArgs );
960     }
961     else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2  == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) )
962     {
963         SvxColorItem _aColorItem( COL_AUTO, theSlotId );
964         INetURLObject aObj( maCommand );
965 
966         Any a;
967         Sequence< PropertyValue > aArgs( 1 );
968         aArgs[0].Name = aObj.GetURLPath();
969         _aColorItem.QueryValue( a );
970         aArgs[0].Value = a;
971         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
972                                      maCommand,
973                                      aArgs );
974     }
975     else
976 	{
977         INetURLObject aObj( maCommand );
978 
979         Any a;
980         Sequence< PropertyValue > aArgs( 1 );
981         aArgs[0].Name = aObj.GetURLPath();
982         aColorItem.QueryValue( a );
983         aArgs[0].Value = a;
984         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
985                                      maCommand,
986                                      aArgs );
987 	}
988 
989 	return 0;
990 }
991 
992 // -----------------------------------------------------------------------
993 
994 void SvxColorWindow_Impl::Resize()
995 {
996 	lcl_ResizeValueSet( *this, aColorSet);
997 }
998 
999 // -----------------------------------------------------------------------
1000 
1001 void SvxColorWindow_Impl::StartSelection()
1002 {
1003 	aColorSet.StartSelection();
1004 }
1005 
1006 // -----------------------------------------------------------------------
1007 
1008 sal_Bool SvxColorWindow_Impl::Close()
1009 {
1010 	return SfxPopupWindow::Close();
1011 }
1012 
1013 // -----------------------------------------------------------------------
1014 
1015 void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1016 {
1017     if (( SFX_ITEM_DISABLED != eState ) && pState )
1018     {
1019         if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorTableItem )))
1020         {
1021 	        XColorTable* pColorTable = pState ? ((SvxColorTableItem *)pState)->GetColorTable() : NULL;
1022 
1023 			if ( pColorTable )
1024 			{
1025 				// Die Liste der Farben (ColorTable) hat sich ge"andert:
1026 				short i = 0;
1027 				long nCount = pColorTable->Count();
1028 				XColorEntry* pEntry = NULL;
1029 				::Color aColWhite( COL_WHITE );
1030 				String aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE ) );
1031 
1032 				// ScrollBar an oder aus
1033 				WinBits nBits = aColorSet.GetStyle();
1034         		if ( nCount > PALETTE_SIZE )
1035 					nBits &= ~WB_VSCROLL;
1036 				else
1037 					nBits |= WB_VSCROLL;
1038 				aColorSet.SetStyle( nBits );
1039 
1040 				for ( i = 0; i < nCount; ++i )
1041 				{
1042 					pEntry = pColorTable->GetColor(i);
1043 					aColorSet.SetItemColor( i + 1, pEntry->GetColor() );
1044 					aColorSet.SetItemText ( i + 1, pEntry->GetName() );
1045 				}
1046 
1047         		while ( i < PALETTE_SIZE )
1048 				{
1049 					aColorSet.SetItemColor( i + 1, aColWhite );
1050 					aColorSet.SetItemText ( i + 1, aStrWhite );
1051 					i++;
1052 				}
1053 			}
1054 		}
1055 	}
1056 }
1057 
1058 //========================================================================
1059 // class SvxFrameWindow_Impl --------------------------------------------------
1060 //========================================================================
1061 
1062 SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
1063 
1064 	SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL ) ),
1065     aFrameSet   ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
1066     bParagraphMode(sal_False)
1067 
1068 {
1069     BindListener();
1070     String sCommand(String::CreateFromAscii( ".uno:BorderReducedMode" ));
1071     AddStatusListener( sCommand );
1072     aImgList = ImageList( SVX_RES( IsHighContrast()? RID_SVXIL_FRAME_HC : RID_SVXIL_FRAME ) );
1073 
1074 	/*
1075 	 *  1       2        3         4
1076 	 *  -------------------------------------
1077 	 *	NONE    LEFT     RIGHT     LEFTRIGHT
1078 	 *	TOP     BOTTOM   TOPBOTTOM OUTER
1079 	 *  -------------------------------------
1080 	 *	HOR	    HORINNER VERINNER	ALL			<- kann ueber bParagraphMode
1081 	 *                                             abgeschaltet werden
1082 	 */
1083 
1084 	sal_uInt16 i = 0;
1085 
1086 	for ( i=1; i<9; i++ )
1087 		aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1088 
1089     //bParagraphMode should have been set in StateChanged
1090     if ( !bParagraphMode )
1091 		for ( i = 9; i < 13; i++ )
1092 			aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1093 
1094 	aFrameSet.SetColCount( 4 );
1095     aFrameSet.SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) );
1096 
1097 	lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
1098 
1099 	SetHelpId( HID_POPUP_FRAME );
1100 	SetText( SVX_RESSTR(RID_SVXSTR_FRAME) );
1101 	aFrameSet.SetAccessibleName( SVX_RESSTR(RID_SVXSTR_FRAME) );
1102 	aFrameSet.Show();
1103 }
1104 /*-- 22.09.2004 12:27:50---------------------------------------------------
1105 
1106   -----------------------------------------------------------------------*/
1107 SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
1108 {
1109     UnbindListener();
1110 }
1111 
1112 SfxPopupWindow* SvxFrameWindow_Impl::Clone() const
1113 {
1114 	//! HACK: wie bekomme ich den Paragraph-Mode ??
1115     return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() );
1116 }
1117 
1118 Window* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
1119 {
1120 	return &aFrameSet;
1121 }
1122 
1123 void SvxFrameWindow_Impl::GetFocus()
1124 {
1125 	aFrameSet.GrabFocus();
1126 }
1127 
1128 void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1129 {
1130 	SfxPopupWindow::DataChanged( rDCEvt );
1131 
1132 	if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1133 	{
1134 		aImgList = ImageList( SVX_RES( IsHighContrast()? RID_SVXIL_FRAME_HC : RID_SVXIL_FRAME ) );
1135 
1136 		sal_uInt16	nNumOfItems = aFrameSet.GetItemCount();
1137 
1138 		for( sal_uInt16 i = 1 ; i <= nNumOfItems ; ++i )
1139 			aFrameSet.SetItemImage( i, aImgList.GetImage( i ) );
1140 	}
1141 }
1142 // -----------------------------------------------------------------------
1143 
1144 #define FRM_VALID_LEFT 		0x01
1145 #define FRM_VALID_RIGHT 	0x02
1146 #define FRM_VALID_TOP 		0x04
1147 #define FRM_VALID_BOTTOM 	0x08
1148 #define FRM_VALID_HINNER 	0x10
1149 #define FRM_VALID_VINNER 	0x20
1150 #define FRM_VALID_OUTER		0x0f
1151 #define FRM_VALID_ALL       0xff
1152 
1153 //
1154 // Per default bleiben ungesetzte Linien unveraendert
1155 // Mit Shift werden ungesetzte Linien zurueckgsetzt
1156 //
1157 IMPL_LINK( SvxFrameWindow_Impl, SelectHdl, void *, EMPTYARG )
1158 {
1159 	::Color				aColBlack( COL_BLACK );
1160 	SvxBoxItem			aBorderOuter( SID_ATTR_BORDER_OUTER );
1161 	SvxBoxInfoItem		aBorderInner( SID_ATTR_BORDER_INNER );
1162 	SvxBorderLine		theDefLine;
1163     SvxBorderLine       *pLeft = 0,
1164 						*pRight = 0,
1165 						*pTop = 0,
1166 						*pBottom = 0;
1167 	sal_uInt16				nSel = aFrameSet.GetSelectItemId();
1168 	sal_uInt16 				nModifier = aFrameSet.GetModifier();
1169 	sal_uInt8 				nValidFlags = 0;
1170 
1171     theDefLine.SetOutWidth( DEF_LINE_WIDTH_0 );
1172 	switch ( nSel )
1173 	{
1174 		case 1: nValidFlags |= FRM_VALID_ALL;
1175 		break;	// NONE
1176 		case 2: pLeft = &theDefLine;
1177 				nValidFlags |= FRM_VALID_LEFT;
1178 		break;	// LEFT
1179 		case 3: pRight = &theDefLine;
1180 				nValidFlags |= FRM_VALID_RIGHT;
1181 		break;	// RIGHT
1182 		case 4: pLeft = pRight = &theDefLine;
1183 				nValidFlags |= 	FRM_VALID_RIGHT|FRM_VALID_LEFT;
1184 		break;	// LEFTRIGHT
1185 		case 5: pTop = &theDefLine;
1186 				nValidFlags |= FRM_VALID_TOP;
1187 		break;	// TOP
1188 		case 6: pBottom = &theDefLine;
1189 				nValidFlags |= FRM_VALID_BOTTOM;
1190 		break;	// BOTTOM
1191 		case 7: pTop =  pBottom = &theDefLine;
1192 				nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP;
1193 		break;	// TOPBOTTOM
1194 		case 8: pLeft = pRight = pTop = pBottom = &theDefLine;
1195 				nValidFlags |= FRM_VALID_OUTER;
1196 		break;	// OUTER
1197 
1198 		// Tabelle innen:
1199 		case 9: // HOR
1200 			pTop = pBottom = &theDefLine;
1201 			aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1202 			aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
1203 			nValidFlags |= FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1204 			break;
1205 
1206 		case 10: // HORINNER
1207 			pLeft = pRight = pTop = pBottom = &theDefLine;
1208 			aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1209 			aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
1210 			nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1211 			break;
1212 
1213 		case 11: // VERINNER
1214 			pLeft = pRight = pTop = pBottom = &theDefLine;
1215 			aBorderInner.SetLine( NULL, BOXINFO_LINE_HORI );
1216 			aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
1217 			nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_VINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1218 		break;
1219 
1220 		case 12: // ALL
1221 			pLeft = pRight = pTop = pBottom = &theDefLine;
1222 			aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1223 			aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
1224 			nValidFlags |= FRM_VALID_ALL;
1225 			break;
1226 
1227 		default:
1228 		break;
1229 	}
1230 	aBorderOuter.SetLine( pLeft, BOX_LINE_LEFT );
1231 	aBorderOuter.SetLine( pRight, BOX_LINE_RIGHT );
1232 	aBorderOuter.SetLine( pTop, BOX_LINE_TOP );
1233 	aBorderOuter.SetLine( pBottom, BOX_LINE_BOTTOM );
1234 
1235 	if(nModifier == KEY_SHIFT)
1236 		nValidFlags |= FRM_VALID_ALL;
1237 	aBorderInner.SetValid( VALID_TOP, 		0 != (nValidFlags&FRM_VALID_TOP ));
1238 	aBorderInner.SetValid( VALID_BOTTOM, 	0 != (nValidFlags&FRM_VALID_BOTTOM ));
1239 	aBorderInner.SetValid( VALID_LEFT, 		0 != (nValidFlags&FRM_VALID_LEFT));
1240 	aBorderInner.SetValid( VALID_RIGHT, 	0 != (nValidFlags&FRM_VALID_RIGHT ));
1241 	aBorderInner.SetValid( VALID_HORI, 		0 != (nValidFlags&FRM_VALID_HINNER ));
1242 	aBorderInner.SetValid( VALID_VERT, 		0 != (nValidFlags&FRM_VALID_VINNER));
1243 	aBorderInner.SetValid( VALID_DISTANCE, sal_True );
1244 	aBorderInner.SetValid( VALID_DISABLE, sal_False );
1245 
1246 	if ( IsInPopupMode() )
1247 		EndPopupMode();
1248 
1249     Any a;
1250     Sequence< PropertyValue > aArgs( 2 );
1251     aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OuterBorder" ));
1252     aBorderOuter.QueryValue( a );
1253     aArgs[0].Value = a;
1254     aArgs[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "InnerBorder" ));
1255     aBorderInner.QueryValue( a );
1256     aArgs[1].Value = a;
1257 
1258     /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1259         This instance may be deleted in the meantime (i.e. when a dialog is opened
1260         while in Dispatch()), accessing members will crash in this case. */
1261     aFrameSet.SetNoSelection();
1262 
1263     SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1264                                  OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SetBorderStyle" )),
1265                                  aArgs );
1266 	return 0;
1267 }
1268 
1269 // -----------------------------------------------------------------------
1270 
1271 void SvxFrameWindow_Impl::Resize()
1272 {
1273 	lcl_ResizeValueSet( *this, aFrameSet);
1274 }
1275 
1276 // -----------------------------------------------------------------------
1277 
1278 void SvxFrameWindow_Impl::StateChanged(
1279 
1280 	sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1281 
1282 {
1283     if ( pState && nSID == SID_BORDER_REDUCED_MODE)
1284 	{
1285         const SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState );
1286 
1287 		if ( pItem )
1288 		{
1289             bParagraphMode = (sal_Bool)pItem->GetValue();
1290             //initial calls mustn't insert or remove elements
1291             if(aFrameSet.GetItemCount())
1292             {
1293 			    sal_Bool bTableMode = ( aFrameSet.GetItemCount() == 12 );
1294 			    sal_Bool bResize    = sal_False;
1295 
1296                 if ( bTableMode && bParagraphMode )
1297 			    {
1298 				    for ( sal_uInt16 i = 9; i < 13; i++ )
1299 					    aFrameSet.RemoveItem(i);
1300 				    bResize = sal_True;
1301 			    }
1302                 else if ( !bTableMode && !bParagraphMode )
1303 			    {
1304 				    for ( sal_uInt16 i = 9; i < 13; i++ )
1305 					    aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1306 				    bResize = sal_True;
1307 			    }
1308 
1309 			    if ( bResize )
1310 			    {
1311 				    lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
1312 			    }
1313             }
1314 		}
1315 	}
1316 	SfxPopupWindow::StateChanged( nSID, eState, pState );
1317 }
1318 
1319 // -----------------------------------------------------------------------
1320 
1321 void SvxFrameWindow_Impl::StartSelection()
1322 {
1323 	aFrameSet.StartSelection();
1324 }
1325 
1326 // -----------------------------------------------------------------------
1327 
1328 sal_Bool SvxFrameWindow_Impl::Close()
1329 {
1330 	return SfxPopupWindow::Close();
1331 }
1332 
1333 //========================================================================
1334 // class SvxLineWindow_Impl --------------------------------------------------
1335 //========================================================================
1336 
1337 SvxLineWindow_Impl::SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
1338 
1339 	SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL ) ),
1340 
1341 	aLineSet( this, WinBits( WB_3DLOOK | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_NONEFIELD | WB_NO_DIRECTSELECT ) )
1342 {
1343     try
1344     {
1345         Reference< lang::XServiceInfo > xServices( rFrame->getController()->getModel(), UNO_QUERY_THROW );
1346         m_bIsWriter = xServices->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument")));
1347 	}
1348 	catch(const uno::Exception& )
1349 	{
1350 	}
1351 	Size	aBmpSize( 55, 12 );
1352 	CreateBitmaps();
1353 
1354 	aLineSet.SetColCount( 2 );
1355     aLineSet.SetSelectHdl( LINK( this, SvxLineWindow_Impl, SelectHdl ) );
1356 	aLineSet.SetText( SVX_RESSTR(RID_SVXSTR_NONE) );
1357 
1358 	aLineSet.SetAccessibleName( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE) );
1359 	lcl_CalcSizeValueSet( *this, aLineSet, aBmpSize );
1360 
1361 	SetHelpId( HID_POPUP_LINE );
1362 	SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE) );
1363 	aLineSet.Show();
1364 }
1365 
1366 SfxPopupWindow* SvxLineWindow_Impl::Clone() const
1367 {
1368     return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() );
1369 }
1370 
1371 // -----------------------------------------------------------------------
1372 
1373 void SvxLineWindow_Impl::MakeLineBitmap( sal_uInt16 nNo, Bitmap& rBmp, const Size& rSize, String& rStr,
1374 											const ::Color& rLineCol, const ::Color& rBackCol )
1375 {
1376 	VirtualDevice	aVirDev( *this );
1377 	Rectangle		aRect( Point(2,0), Size(rSize.Width()-4,0) );
1378 
1379 	// grau einfaerben und Bitmap sichern:
1380 	aVirDev.SetOutputSizePixel( rSize );
1381 	aVirDev.SetLineColor();
1382 	aVirDev.SetFillColor( rBackCol );
1383 	aVirDev.DrawRect( Rectangle( Point(0,0), rSize ) );
1384 	aVirDev.SetFillColor( rLineCol );
1385 
1386     sal_uInt16 nLineWidth = 0;
1387 	switch ( nNo )
1388 	{
1389 		case 1: // DEF_LINE_WIDTH_0
1390 			aRect.Top() 	= 6;
1391 			aRect.Bottom()	= 6;
1392 			aVirDev.DrawRect( aRect );
1393 			break;
1394 
1395 		case 2: // DEF_LINE_WIDTH_1
1396 			aRect.Top() 	= 5;
1397 			aRect.Bottom()	= 6;
1398 			aVirDev.DrawRect( aRect );
1399 			nLineWidth = (sal_uInt16) DEF_LINE_WIDTH_1/20;
1400 			break;
1401 
1402 		case 3: // DEF_LINE_WIDTH_2
1403 			aRect.Top() 	= 5;
1404 			aRect.Bottom()	= 7;
1405 			aVirDev.DrawRect( aRect );
1406 			nLineWidth = (sal_uInt16) DEF_LINE_WIDTH_2/20;
1407 			break;
1408 
1409 		case 4: // DEF_LINE_WIDTH_3
1410 			aRect.Top() 	= 4;
1411 			aRect.Bottom()	= 7;
1412 			aVirDev.DrawRect( aRect );
1413 			aVirDev.DrawRect( Rectangle( Point(2,4), Point(37,7) ) );
1414 			nLineWidth = (sal_uInt16) DEF_LINE_WIDTH_3/20;
1415 			break;
1416 
1417 		case 5: // DEF_LINE_WIDTH_4
1418 			aRect.Top() 	= 4;
1419 			aRect.Bottom()	= 8;
1420 			aVirDev.DrawRect( aRect );
1421 			nLineWidth = (sal_uInt16) DEF_LINE_WIDTH_4/20;
1422 			break;
1423 
1424 		case 6: // DEF_DOUBLE_LINE0
1425 			aRect.Top() 	= 5;
1426 			aRect.Bottom()	= 5;
1427 			aVirDev.DrawRect( aRect );
1428 			aRect.Top() 	= 7;
1429 			aRect.Bottom()	= 7;
1430 			aVirDev.DrawRect( aRect );
1431 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE0_OUT+DEF_DOUBLE_LINE0_IN+DEF_DOUBLE_LINE0_DIST)/20;
1432 			break;
1433 
1434 		case 7: // DEF_DOUBLE_LINE7
1435 			aRect.Top() 	= 4;
1436 			aRect.Bottom()	= 4;
1437 			aVirDev.DrawRect( aRect );
1438 			aRect.Top() 	= 7;
1439 			aRect.Bottom()	= 7;
1440 			aVirDev.DrawRect( aRect );
1441 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE7_OUT+DEF_DOUBLE_LINE7_IN+DEF_DOUBLE_LINE7_DIST)/20;
1442 			break;
1443 
1444 		case 8: // DEF_DOUBLE_LINE1
1445 			aRect.Top() 	= 4;
1446 			aRect.Bottom()	= 5;
1447 			aVirDev.DrawRect( aRect );
1448 			aRect.Top() 	= 7;
1449 			aRect.Bottom()	= 8;
1450 			aVirDev.DrawRect( aRect );
1451 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE1_OUT+DEF_DOUBLE_LINE1_IN+DEF_DOUBLE_LINE1_DIST)/20;
1452 			break;
1453 
1454 		case 9: // DEF_DOUBLE_LINE2
1455 			aRect.Top() 	= 3;
1456 			aRect.Bottom()	= 5;
1457 			aVirDev.DrawRect( aRect );
1458 			aRect.Top() 	= 8;
1459 			aRect.Bottom()	= 10;
1460 			aVirDev.DrawRect( aRect );
1461 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE2_OUT+DEF_DOUBLE_LINE2_IN+DEF_DOUBLE_LINE2_DIST)/20;
1462 			break;
1463 
1464 		case 10: // DEF_DOUBLE_LINE8
1465 			aRect.Top() 	= 3;
1466 			aRect.Bottom()	= 4;
1467 			aVirDev.DrawRect( aRect );
1468 			aRect.Top() 	= 7;
1469 			aRect.Bottom()	= 7;
1470 			aVirDev.DrawRect( aRect );
1471 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE8_OUT+DEF_DOUBLE_LINE8_IN+DEF_DOUBLE_LINE8_DIST)/20;
1472 			break;
1473 
1474 		case 11: // DEF_DOUBLE_LINE9
1475 			aRect.Top() 	= 3;
1476 			aRect.Bottom()	= 5;
1477 			aVirDev.DrawRect( aRect );
1478 			aRect.Top() 	= 8;
1479 			aRect.Bottom()	= 8;
1480 			aVirDev.DrawRect( aRect );
1481 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE9_OUT+DEF_DOUBLE_LINE9_IN+DEF_DOUBLE_LINE9_DIST)/20;
1482 			break;
1483 
1484 		case 12: // DEF_DOUBLE_LINE10
1485 			aRect.Top() 	= 2;
1486 			aRect.Bottom()	= 5;
1487 			aVirDev.DrawRect( aRect );
1488 			aRect.Top() 	= 8;
1489 			aRect.Bottom()	= 8;
1490 			aVirDev.DrawRect( aRect );
1491 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE10_OUT+DEF_DOUBLE_LINE10_IN+DEF_DOUBLE_LINE10_DIST)/20;
1492 			break;
1493 
1494 		case 13: // DEF_DOUBLE_LINE3
1495 			aRect.Top() 	= 4;
1496 			aRect.Bottom()	= 5;
1497 			aVirDev.DrawRect( aRect );
1498 			aRect.Top() 	= 7;
1499 			aRect.Bottom()	= 7;
1500 			aVirDev.DrawRect( aRect );
1501 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE3_OUT+DEF_DOUBLE_LINE3_IN+DEF_DOUBLE_LINE3_DIST)/20;
1502 			break;
1503 
1504 		case 14: // DEF_DOUBLE_LINE4
1505 			aRect.Top() 	= 4;
1506 			aRect.Bottom()	= 4;
1507 			aVirDev.DrawRect( aRect );
1508 			aRect.Top() 	= 6;
1509 			aRect.Bottom()	= 7;
1510 			aVirDev.DrawRect( aRect );
1511 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE4_OUT+DEF_DOUBLE_LINE4_IN+DEF_DOUBLE_LINE4_DIST)/20;
1512 			break;
1513 
1514 		case 15: // DEF_DOUBLE_LINE5
1515 			aRect.Top() 	= 3;
1516 			aRect.Bottom()	= 5;
1517 			aVirDev.DrawRect( aRect );
1518 			aRect.Top() 	= 8;
1519 			aRect.Bottom()	= 9;
1520 			aVirDev.DrawRect( aRect );
1521 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE5_OUT+DEF_DOUBLE_LINE5_IN+DEF_DOUBLE_LINE5_DIST)/20;
1522 			break;
1523 
1524 		case 16: // DEF_DOUBLE_LINE6
1525 			aRect.Top() 	= 3;
1526 			aRect.Bottom()	= 4;
1527 			aVirDev.DrawRect( aRect );
1528 			aRect.Top() 	= 7;
1529 			aRect.Bottom()	= 9;
1530 			aVirDev.DrawRect( aRect );
1531 			nLineWidth = (sal_uInt16) (DEF_DOUBLE_LINE6_OUT+DEF_DOUBLE_LINE6_IN+DEF_DOUBLE_LINE6_DIST)/20;
1532 			break;
1533 
1534 		default:
1535 			break;
1536 	}
1537     if ( nLineWidth )
1538     {
1539         rStr = String::CreateFromInt32( nLineWidth );
1540 	    rStr.AppendAscii(" pt");
1541     }
1542 	rBmp = aVirDev.GetBitmap( Point(0,0), rSize );
1543 }
1544 
1545 // -----------------------------------------------------------------------
1546 
1547 IMPL_LINK( SvxLineWindow_Impl, SelectHdl, void *, EMPTYARG )
1548 {
1549     SvxLineItem     aLineItem( SID_FRAME_LINESTYLE );
1550 	sal_uInt16			n1 = 0,
1551 					n2 = 0,
1552 					n3 = 0;
1553 	sal_Bool			bSetLine = sal_True;
1554 
1555 	switch ( aLineSet.GetSelectItemId() )
1556 	{
1557 		case  1: n1 = DEF_LINE_WIDTH_0; break;
1558 		case  2: n1 = DEF_LINE_WIDTH_1; break;
1559 		case  3: n1 = DEF_LINE_WIDTH_2; break;
1560 		case  4: n1 = DEF_LINE_WIDTH_3; break;
1561 		case  5: n1 = DEF_LINE_WIDTH_4; break;
1562 
1563 		case  6: n1 = DEF_DOUBLE_LINE0_OUT;
1564 				 n2 = DEF_DOUBLE_LINE0_IN;
1565 				 n3 = DEF_DOUBLE_LINE0_DIST;	 break;
1566 		case  7: n1 = DEF_DOUBLE_LINE7_OUT;
1567 				 n2 = DEF_DOUBLE_LINE7_IN;
1568 				 n3 = DEF_DOUBLE_LINE7_DIST;	 break;
1569 		case  8: n1 = DEF_DOUBLE_LINE1_OUT;
1570 				 n2 = DEF_DOUBLE_LINE1_IN;
1571 				 n3 = DEF_DOUBLE_LINE1_DIST;	 break;
1572 		case  9: n1 = DEF_DOUBLE_LINE2_OUT;
1573 				 n2 = DEF_DOUBLE_LINE2_IN;
1574 				 n3 = DEF_DOUBLE_LINE2_DIST;	 break;
1575 		case 10: n1 = DEF_DOUBLE_LINE8_OUT;
1576 				 n2 = DEF_DOUBLE_LINE8_IN;
1577 				 n3 = DEF_DOUBLE_LINE8_DIST;	 break;
1578 		case 11: n1 = DEF_DOUBLE_LINE9_OUT;
1579 				 n2 = DEF_DOUBLE_LINE9_IN;
1580 				 n3 = DEF_DOUBLE_LINE9_DIST;	 break;
1581 		case 12: n1 = DEF_DOUBLE_LINE10_OUT;
1582 				 n2 = DEF_DOUBLE_LINE10_IN;
1583 				 n3 = DEF_DOUBLE_LINE10_DIST; break;
1584 		case 13: n1 = DEF_DOUBLE_LINE3_OUT;
1585 				 n2 = DEF_DOUBLE_LINE3_IN;
1586 				 n3 = DEF_DOUBLE_LINE3_DIST;	 break;
1587 		case 14: n1 = DEF_DOUBLE_LINE4_OUT;
1588 				 n2 = DEF_DOUBLE_LINE4_IN;
1589 				 n3 = DEF_DOUBLE_LINE4_DIST;	 break;
1590 		case 15: n1 = DEF_DOUBLE_LINE5_OUT;
1591 				 n2 = DEF_DOUBLE_LINE5_IN;
1592 				 n3 = DEF_DOUBLE_LINE5_DIST;	 break;
1593 		case 16: n1 = DEF_DOUBLE_LINE6_OUT;
1594 				 n2 = DEF_DOUBLE_LINE6_IN;
1595 				 n3 = DEF_DOUBLE_LINE6_DIST;	 break;
1596 		case  0:
1597 		default:
1598 			bSetLine = sal_False;
1599 			break;
1600 	}
1601 	if ( bSetLine )
1602 	{
1603 		SvxBorderLine aTmp( NULL, n1, n2, n3 );
1604 		aLineItem.SetLine( &aTmp );
1605 	}
1606 	else
1607 		aLineItem.SetLine( 0 );
1608 
1609 	if ( IsInPopupMode() )
1610 		EndPopupMode();
1611 
1612     Any a;
1613 	Sequence< PropertyValue > aArgs( 1 );
1614     aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" ));
1615 	aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 );
1616     aArgs[0].Value = a;
1617 
1618     /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1619         This instance may be deleted in the meantime (i.e. when a dialog is opened
1620         while in Dispatch()), accessing members will crash in this case. */
1621     aLineSet.SetNoSelection();
1622 
1623     SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1624                                  OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineStyle" )),
1625                                  aArgs );
1626 	return 0;
1627 }
1628 
1629 // -----------------------------------------------------------------------
1630 
1631 void SvxLineWindow_Impl::Resize()
1632 {
1633 	lcl_ResizeValueSet( *this, aLineSet);
1634 }
1635 
1636 // -----------------------------------------------------------------------
1637 
1638 void SvxLineWindow_Impl::StartSelection()
1639 {
1640 	aLineSet.StartSelection();
1641 }
1642 
1643 // -----------------------------------------------------------------------
1644 
1645 sal_Bool SvxLineWindow_Impl::Close()
1646 {
1647 	return SfxPopupWindow::Close();
1648 }
1649 
1650 // -----------------------------------------------------------------------
1651 
1652 Window* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
1653 {
1654 	return &aLineSet;
1655 }
1656 
1657 // -----------------------------------------------------------------------
1658 
1659 void SvxLineWindow_Impl::GetFocus()
1660 {
1661 	aLineSet.GrabFocus();
1662 }
1663 
1664 void SvxLineWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1665 {
1666     SfxPopupWindow::DataChanged( rDCEvt );
1667 
1668 	if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1669 	{
1670 		CreateBitmaps();
1671 		Invalidate();
1672 	}
1673 }
1674 
1675 void SvxLineWindow_Impl::CreateBitmaps( void )
1676 {
1677 	Size					aBmpSize( 55, 12 );
1678 	Bitmap					aBmp;
1679 	String					aStr;
1680 
1681 	const StyleSettings&	rStyleSettings = Application::GetSettings().GetStyleSettings();
1682 	svtools::ColorConfig aColorConfig;
1683 	::Color					aLineCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
1684 	::Color					aBackCol( rStyleSettings.GetWindowColor() );
1685 	aLineSet.Clear();
1686 
1687 	for( sal_uInt16 i = 1 ; i < 17 ; ++i )
1688 	{
1689 		MakeLineBitmap( i, aBmp, aBmpSize, aStr, aLineCol, aBackCol );
1690 		aLineSet.InsertItem( i, aBmp, aStr );
1691 	}
1692 }
1693 
1694 // -----------------------------------------------------------------------
1695 
1696 //########################################################################
1697 // Hilfsklassen
1698 
1699 //========================================================================
1700 // class SfxStyleControllerItem_Impl ------------------------------------------
1701 //========================================================================
1702 
1703 SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl(
1704     const Reference< XDispatchProvider >& rDispatchProvider,
1705     sal_uInt16			                      nSlotId,      // Family-ID
1706     const rtl::OUString&                  rCommand,     // .uno: command bound to this item
1707     SvxStyleToolBoxControl&	              rTbxCtl )     // Controller-Instanz, dem dieses Item zugeordnet ist.
1708 	:	SfxStatusListener( rDispatchProvider, nSlotId, rCommand ),
1709 		rControl( rTbxCtl )
1710 {
1711 }
1712 
1713 // -----------------------------------------------------------------------
1714 
1715 void SfxStyleControllerItem_Impl::StateChanged(
1716 	sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
1717 {
1718 	switch ( GetId() )
1719 	{
1720 		case SID_STYLE_FAMILY1:
1721 		case SID_STYLE_FAMILY2:
1722 		case SID_STYLE_FAMILY3:
1723 		case SID_STYLE_FAMILY4:
1724 		case SID_STYLE_FAMILY5:
1725 		{
1726 			const sal_uInt16 nIdx = GetId() - SID_STYLE_FAMILY_START;
1727 
1728 			if ( SFX_ITEM_AVAILABLE == eState )
1729 			{
1730 				const SfxTemplateItem* pStateItem =
1731 					PTR_CAST( SfxTemplateItem, pState );
1732 				DBG_ASSERT( pStateItem != NULL, "SfxTemplateItem expected" );
1733 				rControl.SetFamilyState( nIdx, pStateItem );
1734 			}
1735 			else
1736 				rControl.SetFamilyState( nIdx, NULL );
1737 			break;
1738 		}
1739 	}
1740 }
1741 
1742 //########################################################################
1743 
1744 //========================================================================
1745 // class SvxStyleToolBoxControl ------------------------------------------
1746 //========================================================================
1747 
1748 struct SvxStyleToolBoxControl::Impl
1749 {
1750 	String						        aClearForm;
1751 	String						        aMore;
1752     ::std::vector< ::rtl::OUString >    aDefaultStyles;
1753 	sal_Bool						bListening;
1754 	sal_Bool						bSpecModeWriter;
1755 	sal_Bool						bSpecModeCalc;
1756 
1757 	inline Impl( void )
1758 		:aClearForm			( SVX_RESSTR( RID_SVXSTR_CLEARFORM ) )
1759 		,aMore				( SVX_RESSTR( RID_SVXSTR_MORE ) )
1760 		,bListening			( sal_False )
1761 		,bSpecModeWriter	( sal_False )
1762 		,bSpecModeCalc		( sal_False )
1763 	{
1764 
1765 
1766     }
1767     void InitializeStyles(Reference < frame::XModel > xModel)
1768     {
1769         //now convert the default style names to the localized names
1770         try
1771         {
1772             Reference< style::XStyleFamiliesSupplier > xStylesSupplier( xModel, UNO_QUERY_THROW );
1773             Reference< lang::XServiceInfo > xServices( xModel, UNO_QUERY_THROW );
1774             bSpecModeWriter = xServices->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument")));
1775             if(bSpecModeWriter)
1776             {
1777                 Reference<container::XNameAccess> xParaStyles;
1778                     xStylesSupplier->getStyleFamilies()->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles"))) >>=
1779                     xParaStyles;
1780                 static const sal_Char* aWriterStyles[] =
1781                 {
1782 		            "Standard",
1783 		            "Heading 1",
1784 		            "Heading 2",
1785 		            "Heading 3",
1786 		            "Text body"
1787                 };
1788                 for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
1789                 {
1790                     try
1791                     {
1792                         Reference< beans::XPropertySet > xStyle;
1793                         xParaStyles->getByName( rtl::OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
1794                         ::rtl::OUString sName;
1795                         xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName"))) >>= sName;
1796                         if( sName.getLength() )
1797                             aDefaultStyles.push_back(sName);
1798                     }
1799                     catch( const uno::Exception& )
1800                     {}
1801                 }
1802 
1803             }
1804             else if( 0 != (
1805                 bSpecModeCalc = xServices->supportsService(::rtl::OUString(
1806                     RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument")))))
1807             {
1808                 static const sal_Char* aCalcStyles[] =
1809                 {
1810 		            "Default",
1811 		            "Heading1",
1812 		            "Result",
1813 		            "Result2"
1814                 };
1815                 Reference<container::XNameAccess> xCellStyles;
1816                     xStylesSupplier->getStyleFamilies()->getByName(
1817                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))) >>=
1818                         xCellStyles;
1819                 for( sal_uInt32 nStyle = 0; nStyle < sizeof( aCalcStyles ) / sizeof( sal_Char*); ++nStyle )
1820                 {
1821                     try
1822                     {
1823 						const rtl::OUString sStyleName( rtl::OUString::createFromAscii( aCalcStyles[nStyle] ) );
1824 						if( xCellStyles->hasByName( sStyleName ) )
1825 						{
1826 							Reference< beans::XPropertySet > xStyle( xCellStyles->getByName( sStyleName), UNO_QUERY_THROW );
1827 		                    ::rtl::OUString sName;
1828 			                xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName"))) >>= sName;
1829 				            if( sName.getLength() )
1830 					            aDefaultStyles.push_back(sName);
1831 						}
1832                     }
1833                     catch( const uno::Exception& )
1834                     {}
1835                 }
1836             }
1837         }
1838         catch(const uno::Exception& )
1839         {
1840             DBG_ERROR("error while initializing style names");
1841         }
1842     }
1843 };
1844 
1845 
1846 // mapping table from bound items. BE CAREFUL this table must be in the
1847 // same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n
1848 // MAX_FAMILIES must also be correctly set!
1849 static const char* StyleSlotToStyleCommand[MAX_FAMILIES] =
1850 {
1851     ".uno:CharStyle",
1852     ".uno:ParaStyle",
1853     ".uno:FrameStyle",
1854     ".uno:PageStyle",
1855     ".uno:TemplateFamily5"
1856 };
1857 
1858 SvxStyleToolBoxControl::SvxStyleToolBoxControl(
1859     sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
1860 	:	SfxToolBoxControl	( nSlotId, nId, rTbx ),
1861 		pStyleSheetPool		( NULL ),
1862 		nActFamily			( 0xffff ),
1863 		bListening			( sal_False ),
1864 		pImpl				( new Impl )
1865 {
1866 	for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1867 	{
1868         pBoundItems[i] = 0;
1869         m_xBoundItems[i] = Reference< XComponent >();
1870 		pFamilyState[i]  = NULL;
1871     }
1872 }
1873 
1874 // -----------------------------------------------------------------------
1875 SvxStyleToolBoxControl::~SvxStyleToolBoxControl()
1876 {
1877 }
1878 
1879 // -----------------------------------------------------------------------
1880 void SAL_CALL SvxStyleToolBoxControl::initialize( const Sequence< Any >& aArguments )
1881 throw ( Exception, RuntimeException)
1882 {
1883     SfxToolBoxControl::initialize( aArguments );
1884 
1885     // After initialize we should have a valid frame member where we can retrieve our
1886     // dispatch provider.
1887     if ( m_xFrame.is() )
1888     {
1889         pImpl->InitializeStyles(m_xFrame->getController()->getModel());
1890         Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY );
1891         for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1892 	    {
1893             pBoundItems[i]   = new SfxStyleControllerItem_Impl( xDispatchProvider,
1894                                                                 SID_STYLE_FAMILY_START + i,
1895                                                                 OUString::createFromAscii( StyleSlotToStyleCommand[i] ),
1896                                                                 *this );
1897             m_xBoundItems[i] = Reference< XComponent >( static_cast< OWeakObject* >( pBoundItems[i] ), UNO_QUERY );
1898 	        pFamilyState[i]  = NULL;
1899         }
1900     }
1901 }
1902 
1903 // XComponent
1904 void SAL_CALL SvxStyleToolBoxControl::dispose()
1905 throw (::com::sun::star::uno::RuntimeException)
1906 {
1907     SfxToolBoxControl::dispose();
1908 
1909     for( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1910 	{
1911         if ( m_xBoundItems[i].is() )
1912         {
1913             try
1914             {
1915                 m_xBoundItems[i]->dispose();
1916             }
1917             catch ( Exception& )
1918             {
1919             }
1920 
1921             m_xBoundItems[i].clear();
1922             pBoundItems[i] = 0;
1923         }
1924 		DELETEZ( pFamilyState[i] );
1925 	}
1926 	pStyleSheetPool = NULL;
1927     DELETEZ( pImpl );
1928 }
1929 
1930 // -----------------------------------------------------------------------
1931 void SAL_CALL SvxStyleToolBoxControl::update() throw (RuntimeException)
1932 {
1933     // Do nothing, we will start binding our listener when we are visible.
1934     // See link SvxStyleToolBoxControl::VisibilityNotification.
1935     SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1936 	if ( pBox->IsVisible() )
1937 	{
1938 		for ( int i=0; i<MAX_FAMILIES; i++ )
1939 			pBoundItems	[i]->ReBind();
1940 
1941         bindListener();
1942 	}
1943 }
1944 
1945 // -----------------------------------------------------------------------
1946 
1947 SfxStyleFamily SvxStyleToolBoxControl::GetActFamily()
1948 {
1949 	switch ( nActFamily-1 + SID_STYLE_FAMILY_START )
1950 	{
1951 		case SID_STYLE_FAMILY1:	return SFX_STYLE_FAMILY_CHAR;
1952 		case SID_STYLE_FAMILY2:	return SFX_STYLE_FAMILY_PARA;
1953 		case SID_STYLE_FAMILY3:	return SFX_STYLE_FAMILY_FRAME;
1954 		case SID_STYLE_FAMILY4:	return SFX_STYLE_FAMILY_PAGE;
1955 		case SID_STYLE_FAMILY5:	return SFX_STYLE_FAMILY_PSEUDO;
1956 		default:
1957 			DBG_ERROR( "unknown style family" );
1958 			break;
1959 	}
1960 	return SFX_STYLE_FAMILY_PARA;
1961 }
1962 
1963 // -----------------------------------------------------------------------
1964 
1965 void SvxStyleToolBoxControl::FillStyleBox()
1966 {
1967     SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1968 
1969 	DBG_ASSERT( pStyleSheetPool, "StyleSheetPool not found!" );
1970 	DBG_ASSERT( pBox,			 "Control not found!" );
1971 
1972 	if ( pStyleSheetPool && pBox && nActFamily!=0xffff )
1973 	{
1974 		const SfxStyleFamily	eFamily 	= GetActFamily();
1975 		sal_uInt16					nCount  	= pStyleSheetPool->Count();
1976 		sal_uInt16 					i			= 0;
1977 		SfxStyleSheetBase*		pStyle  	= NULL;
1978 		sal_Bool 					bDoFill 	= sal_False;
1979 
1980 		pStyleSheetPool->SetSearchMask( eFamily, SFXSTYLEBIT_USED );
1981 
1982 		//------------------------------
1983 		// Ueberpruefen, ob Fill noetig:
1984 		//------------------------------
1985 
1986 		pStyle = pStyleSheetPool->First();
1987         //!!! TODO: This condition isn't right any longer, because we always show some default entries
1988         //!!! so the list doesn't show the count
1989 		if ( nCount != pBox->GetEntryCount() )
1990 		{
1991 			bDoFill = sal_True;
1992 		}
1993 		else
1994 		{
1995 			while ( pStyle && !bDoFill )
1996 			{
1997 				bDoFill = ( pBox->GetEntry(i) != pStyle->GetName() );
1998 				pStyle = pStyleSheetPool->Next();
1999 				i++;
2000 			}
2001 		}
2002 
2003 		if ( bDoFill )
2004 		{
2005 			pBox->SetUpdateMode( sal_False );
2006 			pBox->Clear();
2007 
2008 			{
2009 				sal_uInt16	_i;
2010                 sal_uInt32  nCnt = pImpl->aDefaultStyles.size();
2011 				bool	bInsert;
2012 
2013 				pStyle = pStyleSheetPool->First();
2014 
2015 				if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
2016 				{
2017 					while ( pStyle )
2018 					{
2019 						// sort out default styles
2020 						bInsert = true;
2021                         ::rtl::OUString	aName( pStyle->GetName() );
2022 						for( _i = 0 ; _i < nCnt ; ++_i )
2023 						{
2024 							if( pImpl->aDefaultStyles[_i] == aName )
2025 							{
2026 								bInsert = false;
2027 								break;
2028 							}
2029 						}
2030 
2031 						if( bInsert )
2032 							pBox->InsertEntry( aName );
2033 						pStyle = pStyleSheetPool->Next();
2034 					}
2035 				}
2036 				else
2037 				{
2038 					while ( pStyle )
2039 					{
2040 						pBox->InsertEntry( pStyle->GetName() );
2041 						pStyle = pStyleSheetPool->Next();
2042 					}
2043 				}
2044 			}
2045 
2046 			if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
2047 			{
2048 				// insert default styles
2049 				sal_uInt16	_i;
2050                 sal_uInt32  nCnt = pImpl->aDefaultStyles.size();
2051 				sal_uInt16 nPos = 1;
2052 				for( _i = 0 ; _i < nCnt ; ++_i )
2053 				{
2054 					pBox->InsertEntry( pImpl->aDefaultStyles[_i], nPos );
2055 					++nPos;
2056 				}
2057 
2058                 // disable sort to preserve special order
2059                 WinBits nWinBits = pBox->GetStyle();
2060                 nWinBits &= ~WB_SORT;
2061                 pBox->SetStyle( nWinBits );
2062 
2063                 pBox->InsertEntry( pImpl->aClearForm, 0 );
2064                 pBox->SetSeparatorPos( 0 );
2065 
2066 				pBox->InsertEntry( pImpl->aMore );
2067 
2068 				// enable sort again
2069 				nWinBits |= WB_SORT;
2070 				pBox->SetStyle( nWinBits );
2071 			}
2072 
2073 			pBox->SetUpdateMode( sal_True );
2074 			pBox->SetFamily( eFamily );
2075 
2076             sal_uInt16 nLines = Min( pBox->GetEntryCount(), MAX_STYLES_ENTRIES );
2077             pBox->SetDropDownLineCount( nLines );
2078 		}
2079 	}
2080 }
2081 
2082 // -----------------------------------------------------------------------
2083 
2084 void SvxStyleToolBoxControl::SelectStyle( const String& rStyleName )
2085 {
2086     SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
2087 	DBG_ASSERT( pBox, "Control not found!" );
2088 
2089 	if ( pBox )
2090 	{
2091 //		String aStrSel( pBox->GetSelectEntry() );
2092 		String aStrSel( pBox->GetText() );
2093 
2094 		if ( rStyleName.Len() > 0 )
2095 		{
2096 			if ( rStyleName != aStrSel )
2097 //				pBox->SelectEntry( rStyleName );
2098 				pBox->SetText( rStyleName );
2099 		}
2100 		else
2101 			pBox->SetNoSelection();
2102         pBox->SaveValue();
2103     }
2104 }
2105 
2106 // -----------------------------------------------------------------------
2107 
2108 void SvxStyleToolBoxControl::Update()
2109 {
2110 	SfxStyleSheetBasePool*	pPool	  = NULL;
2111 	SfxObjectShell*		    pDocShell = SfxObjectShell::Current();
2112 
2113 	if ( pDocShell )
2114 		pPool = pDocShell->GetStyleSheetPool();
2115 
2116 	sal_uInt16 i;
2117 	for ( i=0; i<MAX_FAMILIES; i++ )
2118 		if( pFamilyState[i] )
2119 			break;
2120 
2121 	if ( i==MAX_FAMILIES || !pPool )
2122 	{
2123 		pStyleSheetPool = pPool;
2124 		return;
2125 	}
2126 
2127 	//--------------------------------------------------------------------
2128 	const SfxTemplateItem* pItem = NULL;
2129 
2130 	if ( nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1]) )
2131 		// aktueller Bereich nicht innerhalb der erlaubten Bereiche
2132 		// oder Default
2133 	{
2134 		pStyleSheetPool = pPool;
2135 		nActFamily		= 2;
2136 
2137 		pItem = pFamilyState[nActFamily-1];
2138 		if ( !pItem )
2139 		{
2140 			nActFamily++;
2141 			pItem = pFamilyState[nActFamily-1];
2142 		}
2143 
2144 		if ( !pItem )
2145         {
2146 			DBG_WARNING( "Unknown Family" ); // can happen
2147         }
2148 	}
2149 	else if ( pPool != pStyleSheetPool )
2150 		pStyleSheetPool = pPool;
2151 
2152 	FillStyleBox(); // entscheidet selbst, ob gefuellt werden muss
2153 
2154 	if ( pItem )
2155 		SelectStyle( pItem->GetStyleName() );
2156 }
2157 
2158 // -----------------------------------------------------------------------
2159 
2160 void SvxStyleToolBoxControl::SetFamilyState( sal_uInt16 nIdx,
2161 											 const SfxTemplateItem* pItem )
2162 {
2163 	DELETEZ( pFamilyState[nIdx] );
2164 
2165 	if ( pItem )
2166 		pFamilyState[nIdx] = new SfxTemplateItem( *pItem );
2167 
2168     Update();
2169 }
2170 
2171 // -----------------------------------------------------------------------
2172 
2173 IMPL_LINK( SvxStyleToolBoxControl, VisibilityNotification, void*, EMPTYARG )
2174 {
2175 
2176     sal_uInt16 i;
2177 
2178 	// Call ReBind() && UnBind() according to visibility
2179 	SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)( GetToolBox().GetItemWindow( GetId() ));
2180 	if ( pBox->IsVisible() && !isBound() )
2181 	{
2182 		for ( i=0; i<MAX_FAMILIES; i++ )
2183 			pBoundItems	[i]->ReBind();
2184 
2185         bindListener();
2186 	}
2187     else if ( !pBox->IsVisible() && isBound() )
2188 	{
2189 		for ( i=0; i<MAX_FAMILIES; i++ )
2190 			pBoundItems[i]->UnBind();
2191 		unbindListener();
2192 	}
2193 
2194 	return 0;
2195 }
2196 
2197 // -----------------------------------------------------------------------
2198 
2199 void SvxStyleToolBoxControl::StateChanged(
2200 
2201 	sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2202 
2203 {
2204 	sal_uInt16 		 nId	= GetId();
2205 	ToolBox&	 rTbx   = GetToolBox();
2206     SvxStyleBox_Impl* pBox   = (SvxStyleBox_Impl*)(rTbx.GetItemWindow( nId ));
2207 	TriState	 eTri	= STATE_NOCHECK;
2208 
2209 	DBG_ASSERT( pBox, "Control not found!" );
2210 
2211 	if ( SFX_ITEM_DISABLED == eState )
2212 		pBox->Disable();
2213 	else
2214 		pBox->Enable();
2215 
2216 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2217 
2218 	switch ( eState )
2219 	{
2220 		case SFX_ITEM_AVAILABLE:
2221 			eTri = ((const SfxBoolItem*)pState)->GetValue()
2222 						? STATE_CHECK
2223 						: STATE_NOCHECK;
2224 			break;
2225 
2226 		case SFX_ITEM_DONTCARE:
2227 			eTri = STATE_DONTKNOW;
2228 			break;
2229 	}
2230 
2231 	rTbx.SetItemState( nId, eTri );
2232 
2233     if ( SFX_ITEM_DISABLED != eState )
2234         Update();
2235 }
2236 
2237 // -----------------------------------------------------------------------
2238 
2239 Window* SvxStyleToolBoxControl::CreateItemWindow( Window *pParent )
2240 {
2241     SvxStyleBox_Impl* pBox = new SvxStyleBox_Impl( pParent,
2242 										           SID_STYLE_APPLY,
2243                                                    OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StyleApply" )),
2244 										           SFX_STYLE_FAMILY_PARA,
2245                                                    Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
2246                                                    m_xFrame,
2247                                                    pImpl->aClearForm,
2248 												   pImpl->aMore,
2249 												   pImpl->bSpecModeWriter || pImpl->bSpecModeCalc );
2250     if( !pImpl->aDefaultStyles.empty())
2251         pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] );
2252 	// Set visibility listener to bind/unbind controller
2253 	pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, VisibilityNotification ));
2254 
2255 	return pBox;
2256 }
2257 
2258 //========================================================================
2259 // class SvxFontNameToolBoxControl ---------------------------------------
2260 //========================================================================
2261 
2262 SvxFontNameToolBoxControl::SvxFontNameToolBoxControl(
2263                                             sal_uInt16          nSlotId,
2264 											sal_uInt16			nId,
2265 											ToolBox&		rTbx )
2266 
2267 	:	SfxToolBoxControl( nSlotId, nId, rTbx )
2268 {
2269 }
2270 
2271 // -----------------------------------------------------------------------
2272 
2273 void SvxFontNameToolBoxControl::StateChanged(
2274 
2275 	sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2276 
2277 {
2278 	sal_uInt16 			     nId	= GetId();
2279 	ToolBox&		     rTbx   = GetToolBox();
2280     SvxFontNameBox_Impl* pBox   = (SvxFontNameBox_Impl*)(rTbx.GetItemWindow( nId ));
2281 
2282 	DBG_ASSERT( pBox, "Control not found!" );
2283 
2284 	if ( SFX_ITEM_DISABLED == eState )
2285 	{
2286 		pBox->Disable();
2287 		pBox->Update( (const SvxFontItem*)NULL );
2288 	}
2289 	else
2290 	{
2291 		pBox->Enable();
2292 
2293 		if ( SFX_ITEM_AVAILABLE == eState )
2294 		{
2295 			const SvxFontItem* pFontItem = dynamic_cast< const SvxFontItem* >( pState );
2296 
2297 			DBG_ASSERT( pFontItem, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" );
2298 			if( pFontItem )
2299 				pBox->Update( pFontItem );
2300 		}
2301 		else
2302 			pBox->SetText( String() );
2303         pBox->SaveValue();
2304 	}
2305 
2306 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2307 }
2308 
2309 // -----------------------------------------------------------------------
2310 
2311 Window* SvxFontNameToolBoxControl::CreateItemWindow( Window *pParent )
2312 {
2313     SvxFontNameBox_Impl* pBox = new SvxFontNameBox_Impl( pParent,
2314                                                          Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
2315                                                          m_xFrame,0);
2316 	return pBox;
2317 }
2318 
2319 //========================================================================
2320 // class SvxFontColorToolBoxControl --------------------------------------
2321 //========================================================================
2322 
2323 SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
2324     sal_uInt16          nSlotId,
2325     sal_uInt16			nId,
2326 	ToolBox&		rTbx )
2327 
2328 	:	SfxToolBoxControl( nSlotId, nId, rTbx ),
2329     pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
2330                     nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW ))
2331 {
2332 	rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2333 }
2334 
2335 // -----------------------------------------------------------------------
2336 
2337 SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl()
2338 {
2339 	delete pBtnUpdater;
2340 }
2341 
2342 // -----------------------------------------------------------------------
2343 
2344 SfxPopupWindowType SvxFontColorToolBoxControl::GetPopupWindowType() const
2345 {
2346 	return SFX_POPUPWINDOW_ONCLICK;
2347 }
2348 
2349 // -----------------------------------------------------------------------
2350 
2351 SfxPopupWindow*	SvxFontColorToolBoxControl::CreatePopupWindow()
2352 {
2353     SvxColorWindow_Impl* pColorWin =
2354         new SvxColorWindow_Impl(
2355                 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Color" )),
2356                 SID_ATTR_CHAR_COLOR,
2357                 m_xFrame,
2358                 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
2359                 &GetToolBox() );
2360 
2361     pColorWin->StartPopupMode( &GetToolBox(),
2362         FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2363 	pColorWin->StartSelection();
2364     SetPopupWindow( pColorWin );
2365 	return pColorWin;
2366 }
2367 
2368 // -----------------------------------------------------------------------
2369 
2370 void SvxFontColorToolBoxControl::StateChanged(
2371 
2372 	sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2373 
2374 {
2375 	sal_uInt16 nId = GetId();
2376 	ToolBox& rTbx = GetToolBox();
2377 	const SvxColorItem*	pItem = 0;
2378 
2379 	if ( SFX_ITEM_DONTCARE != eState )
2380 	   pItem = PTR_CAST( SvxColorItem, pState );
2381 
2382 	if ( pItem )
2383 		pBtnUpdater->Update( pItem->GetValue());
2384 
2385 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2386 	rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2387 }
2388 
2389 //========================================================================
2390 // class SvxColorToolBoxControl --------------------------------
2391 //========================================================================
2392 
2393 SvxColorToolBoxControl::SvxColorToolBoxControl(	sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
2394 
2395 	SfxToolBoxControl( nSlotId, nId, rTbx )
2396 {
2397     if ( nSlotId == SID_BACKGROUND_COLOR )
2398         rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2399     else
2400         rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2401 	rTbx.Invalidate();
2402     pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() );
2403 }
2404 
2405 // -----------------------------------------------------------------------
2406 
2407 SvxColorToolBoxControl::~SvxColorToolBoxControl()
2408 {
2409 	delete pBtnUpdater;
2410 }
2411 
2412 // -----------------------------------------------------------------------
2413 
2414 SfxPopupWindowType SvxColorToolBoxControl::GetPopupWindowType() const
2415 {
2416 	return SFX_POPUPWINDOW_ONCLICK;
2417 }
2418 
2419 // -----------------------------------------------------------------------
2420 
2421 SfxPopupWindow*	SvxColorToolBoxControl::CreatePopupWindow()
2422 {
2423 	sal_uInt16 nResId = GetSlotId() == SID_BACKGROUND_COLOR ?
2424 						RID_SVXSTR_BACKGROUND : RID_SVXSTR_COLOR;
2425     SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
2426         OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" )),
2427 									SID_BACKGROUND_COLOR,
2428                                     m_xFrame,
2429 									SVX_RESSTR(nResId),
2430                                     &GetToolBox() );
2431 
2432     pColorWin->StartPopupMode( &GetToolBox(),
2433         FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2434 	pColorWin->StartSelection();
2435     SetPopupWindow( pColorWin );
2436 	return pColorWin;
2437 }
2438 
2439 // -----------------------------------------------------------------------
2440 
2441 void SvxColorToolBoxControl::StateChanged(
2442 
2443 	sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2444 
2445 {
2446 	const SvxColorItem*	pItem	= 0;
2447 	if ( SFX_ITEM_DONTCARE != eState )
2448 		pItem = PTR_CAST( SvxColorItem, pState );
2449 
2450 	if ( pItem )
2451 		pBtnUpdater->Update( pItem->GetValue() );
2452 
2453 	sal_uInt16 nId = GetId();
2454 	ToolBox& rTbx = GetToolBox();
2455 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2456 	rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2457 }
2458 
2459 //========================================================================
2460 // class SvxFontColorExtToolBoxControl --------------------------------------
2461 //========================================================================
2462 
2463 SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
2464 	sal_uInt16 nSlotId,
2465     sal_uInt16 nId,
2466 	ToolBox& rTbx ) :
2467 
2468 	SfxToolBoxControl( nSlotId, nId, rTbx ),
2469 	pBtnUpdater(0)
2470 {
2471 	rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2472     // The following commands are available at the writer module.
2473     if ( SID_ATTR_CHAR_COLOR2 == nSlotId )
2474         addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )));
2475     else
2476         addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )));
2477 
2478     sal_uInt16 nMode =	SID_ATTR_CHAR_COLOR2 == nSlotId
2479 		? TBX_UPDATER_MODE_CHAR_COLOR_NEW :	TBX_UPDATER_MODE_CHAR_COLOR_NEW;
2480     pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode );
2481 }
2482 
2483 // -----------------------------------------------------------------------
2484 
2485 SvxFontColorExtToolBoxControl::~SvxFontColorExtToolBoxControl()
2486 {
2487 	delete pBtnUpdater;
2488 }
2489 
2490 // -----------------------------------------------------------------------
2491 
2492 SfxPopupWindowType SvxFontColorExtToolBoxControl::GetPopupWindowType() const
2493 {
2494 	return SFX_POPUPWINDOW_ONTIMEOUT;
2495 }
2496 
2497 // -----------------------------------------------------------------------
2498 
2499 SfxPopupWindow*	SvxFontColorExtToolBoxControl::CreatePopupWindow()
2500 {
2501     SvxColorWindow_Impl* pColorWin =
2502         new SvxColorWindow_Impl(
2503                             m_aCommandURL,
2504                             GetSlotId(),
2505                             m_xFrame,
2506 							SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
2507                             &GetToolBox() );
2508 
2509 	if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND )
2510 		pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
2511 
2512     pColorWin->StartPopupMode( &GetToolBox(),
2513         FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2514 	pColorWin->StartSelection();
2515     SetPopupWindow( pColorWin );
2516 	return pColorWin;
2517 }
2518 
2519 // -----------------------------------------------------------------------
2520 
2521 void SvxFontColorExtToolBoxControl::StateChanged(
2522 
2523 	sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
2524 
2525 {
2526 	sal_uInt16 nId = GetId();
2527 	ToolBox& rTbx = GetToolBox();
2528 	const SvxColorItem*	pItem = 0;
2529 
2530 	if ( nSID == SID_ATTR_CHAR_COLOR_EXT ||
2531 		 nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT )
2532 	{
2533 		if ( SFX_ITEM_DONTCARE != eState )
2534 		{
2535 			const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState );
2536 			rTbx.CheckItem( nId, pBool && pBool->GetValue());
2537 		}
2538 		rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2539 	}
2540 	else
2541 	{
2542 		if ( SFX_ITEM_DONTCARE != eState )
2543 		   pItem = PTR_CAST( SvxColorItem, pState );
2544 
2545 		if ( pItem )
2546 			pBtnUpdater->Update( pItem->GetValue() );
2547 	}
2548 }
2549 
2550 // -----------------------------------------------------------------------
2551 
2552 void SvxFontColorExtToolBoxControl::Select( sal_Bool )
2553 {
2554     OUString aCommand;
2555     OUString aParamName;
2556     if ( SID_ATTR_CHAR_COLOR2 == GetSlotId() )
2557     {
2558         aCommand    = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ));
2559         aParamName  = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" ));
2560     }
2561     else
2562     {
2563         aCommand    = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ));
2564         aParamName  = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" ));
2565     }
2566 
2567     Sequence< PropertyValue > aArgs( 1 );
2568     aArgs[0].Name  = aParamName;
2569     aArgs[0].Value = makeAny( GetToolBox().IsItemChecked( GetId() ));
2570     Dispatch( aCommand, aArgs );
2571 }
2572 
2573 //========================================================================
2574 // class SvxFrameToolBoxControl ------------------------------------------
2575 //========================================================================
2576 
2577 SvxFrameToolBoxControl::SvxFrameToolBoxControl(
2578     sal_uInt16      nSlotId,
2579     sal_uInt16      nId,
2580 	ToolBox&    rTbx )
2581 
2582     :   SfxToolBoxControl( nSlotId, nId, rTbx )
2583 {
2584 	rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2585 }
2586 
2587 // -----------------------------------------------------------------------
2588 
2589 SfxPopupWindowType SvxFrameToolBoxControl::GetPopupWindowType() const
2590 {
2591 	return SFX_POPUPWINDOW_ONCLICK;
2592 }
2593 
2594 // -----------------------------------------------------------------------
2595 
2596 SfxPopupWindow*	SvxFrameToolBoxControl::CreatePopupWindow()
2597 {
2598     SvxFrameWindow_Impl* pFrameWin = new SvxFrameWindow_Impl(
2599                                         GetSlotId(), m_xFrame, &GetToolBox() );
2600 
2601 	pFrameWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS | FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2602 	pFrameWin->StartSelection();
2603     SetPopupWindow( pFrameWin );
2604 
2605 	return pFrameWin;
2606 }
2607 
2608 // -----------------------------------------------------------------------
2609 
2610 void SvxFrameToolBoxControl::StateChanged(
2611 
2612 	sal_uInt16, SfxItemState eState, const SfxPoolItem*  )
2613 
2614 {
2615 	sal_uInt16 					nId		= GetId();
2616 	ToolBox&	 			rTbx	= GetToolBox();
2617 
2618     rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2619     rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
2620                             ? STATE_DONTKNOW
2621                             : STATE_NOCHECK );
2622 }
2623 
2624 //========================================================================
2625 // class SvxFrameLineStyleToolBoxControl ---------------------------------
2626 //========================================================================
2627 
2628 SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
2629     sal_uInt16          nSlotId,
2630     sal_uInt16   		nId,
2631 	ToolBox& 		rTbx )
2632 
2633 	:    SfxToolBoxControl( nSlotId, nId, rTbx )
2634 {
2635 	rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2636 }
2637 
2638 // -----------------------------------------------------------------------
2639 
2640 SfxPopupWindowType SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const
2641 {
2642 	return SFX_POPUPWINDOW_ONCLICK;
2643 }
2644 
2645 // -----------------------------------------------------------------------
2646 
2647 SfxPopupWindow*	SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
2648 {
2649 	SvxLineWindow_Impl* pLineWin = new SvxLineWindow_Impl( GetSlotId(), m_xFrame, &GetToolBox() );
2650 	pLineWin->StartPopupMode( &GetToolBox(), sal_True );
2651 	pLineWin->StartSelection();
2652     SetPopupWindow( pLineWin );
2653 
2654 	return pLineWin;
2655 }
2656 
2657 // -----------------------------------------------------------------------
2658 
2659 void SvxFrameLineStyleToolBoxControl::StateChanged(
2660 
2661 	sal_uInt16 , SfxItemState eState, const SfxPoolItem*  )
2662 {
2663 	sal_uInt16 		 nId	= GetId();
2664 	ToolBox&	 rTbx   = GetToolBox();
2665 
2666 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2667 	rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
2668 								? STATE_DONTKNOW
2669 								: STATE_NOCHECK );
2670 }
2671 
2672 //========================================================================
2673 // class SvxFrameLineColorToolBoxControl ---------------------------------
2674 //========================================================================
2675 
2676 SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
2677 	sal_uInt16      nSlotId,
2678     sal_uInt16      nId,
2679 	ToolBox&    rTbx ) :
2680 
2681     SfxToolBoxControl( nSlotId, nId, rTbx ),
2682     pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ))
2683 {
2684 	rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2685 }
2686 
2687 // -----------------------------------------------------------------------
2688 
2689 SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl()
2690 {
2691 
2692     delete pBtnUpdater;
2693 }
2694 
2695 // -----------------------------------------------------------------------
2696 
2697 SfxPopupWindowType SvxFrameLineColorToolBoxControl::GetPopupWindowType() const
2698 {
2699 	return SFX_POPUPWINDOW_ONCLICK;
2700 }
2701 
2702 // -----------------------------------------------------------------------
2703 
2704 SfxPopupWindow*	SvxFrameLineColorToolBoxControl::CreatePopupWindow()
2705 {
2706     SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
2707                                         OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FrameLineColor" )),
2708 									    SID_FRAME_LINECOLOR,
2709                                         m_xFrame,
2710 									    SVX_RESSTR(RID_SVXSTR_FRAME_COLOR),
2711                                         &GetToolBox() );
2712 
2713     pColorWin->StartPopupMode( &GetToolBox(),
2714         FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2715 	pColorWin->StartSelection();
2716     SetPopupWindow( pColorWin );
2717 	return pColorWin;
2718 }
2719 
2720 // -----------------------------------------------------------------------
2721 
2722 void SvxFrameLineColorToolBoxControl::StateChanged(
2723 
2724 	sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2725 
2726 {
2727 	sal_uInt16 nId = GetId();
2728 	ToolBox& rTbx = GetToolBox();
2729 	rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2730 	rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2731 
2732     const SvxColorItem* pItem = 0;
2733 	if ( SFX_ITEM_DONTCARE != eState )
2734     {
2735 	   pItem = PTR_CAST( SvxColorItem, pState );
2736         if ( pItem )
2737             pBtnUpdater->Update( pItem->GetValue());
2738     }
2739 }
2740 
2741 // class SvxReloadControllerItem_Impl ------------------------------------
2742 
2743 class SvxReloadControllerItem_Impl
2744 {
2745 public:
2746 	Image* pNormalImage;
2747 	Image* pSpecialImage;
2748 
2749 	SvxReloadControllerItem_Impl() :
2750 		pNormalImage( new Image( SVX_RES( RID_SVX_RELOAD_NORMAL ) ) ), pSpecialImage( 0 ) {}
2751 	~SvxReloadControllerItem_Impl() { delete pNormalImage; delete pSpecialImage; }
2752 
2753 	Image& GetNormalImage() { return *pNormalImage; }
2754 	Image& GetSpecialImage()
2755 		{
2756 			if ( !pSpecialImage )
2757 				pSpecialImage = new Image( SVX_RES( RID_SVX_RELOAD_SPECIAL ) );
2758 			return *pSpecialImage;
2759 		}
2760 };
2761 
2762 // -----------------------------------------------------------------------
2763 
2764 SvxReloadControllerItem::SvxReloadControllerItem( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
2765 :	SfxToolBoxControl( nSlotId, nId, rTbx )
2766 ,	pImpl( new SvxReloadControllerItem_Impl )
2767 {
2768 	rTbx.SetItemImage( nId, pImpl->GetNormalImage() );
2769 }
2770 
2771 // -----------------------------------------------------------------------
2772 
2773 SvxReloadControllerItem::~SvxReloadControllerItem()
2774 {
2775 	delete pImpl;
2776 }
2777 
2778 // -----------------------------------------------------------------------
2779 
2780 void SvxReloadControllerItem::StateChanged(
2781 	sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2782 {
2783 	SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState );
2784 	ToolBox& rBox = GetToolBox();
2785 	if( pItem )
2786 	{
2787 		rBox.SetItemImage( GetId(),
2788 				pItem->GetValue() ? pImpl->GetSpecialImage() :
2789 				pImpl->GetNormalImage() );
2790 	}
2791 	rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
2792 }
2793 
2794 //========================================================================
2795 // class SvxSimpleUndoRedoController -------------------------------------
2796 //========================================================================
2797 
2798 SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx  )
2799     :SfxToolBoxControl( nSlotId, nId, rTbx )
2800 {
2801     aDefaultText = rTbx.GetItemText( nId );
2802 }
2803 
2804 // -----------------------------------------------------------------------
2805 
2806 SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController()
2807 {
2808 }
2809 
2810 // -----------------------------------------------------------------------
2811 
2812 void SvxSimpleUndoRedoController::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
2813 {
2814     SfxStringItem* pItem = PTR_CAST( SfxStringItem, pState );
2815     ToolBox& rBox = GetToolBox();
2816     if ( pItem && eState != SFX_ITEM_DISABLED )
2817     {
2818         ::rtl::OUString aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem->GetValue() ) );
2819         rBox.SetQuickHelpText( GetId(), aNewText );
2820     }
2821     if ( eState == SFX_ITEM_DISABLED )
2822         rBox.SetQuickHelpText( GetId(), aDefaultText );
2823     rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
2824 }
2825 
2826 //========================================================================
2827 
2828 void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet )
2829 {
2830 	Size aSize = rWin.GetOutputSizePixel();
2831 	aSize.Width()  -= 4;
2832 	aSize.Height() -= 4;
2833 	rValueSet.SetPosSizePixel( Point(2,2), aSize );
2834 }
2835 
2836 // -----------------------------------------------------------------------
2837 
2838 void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize )
2839 {
2840 	Size aSize = rValueSet.CalcWindowSizePixel( aItemSize );
2841 	aSize.Width()  += 4;
2842 	aSize.Height() += 4;
2843 	rWin.SetOutputSizePixel( aSize );
2844 }
2845 
2846 // -----------------------------------------------------------------------
2847 
2848 sal_Bool lcl_FontChangedHint( const SfxHint &rHint )
2849 {
2850 	SfxPoolItemHint *pItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
2851 	if ( pItemHint )
2852 	{
2853 		SfxPoolItem *pItem = pItemHint->GetObject();
2854 		return ( pItem->Which() == SID_ATTR_CHAR_FONTLIST );
2855 	}
2856 	else
2857 	{
2858 		SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, &rHint);
2859 		return pSimpleHint && ( SFX_HINT_DATACHANGED ==
2860 							( pSimpleHint->GetId() & SFX_HINT_DATACHANGED ) );
2861 	}
2862 }
2863 // -----------------------------------------------------------------------------
2864 Reference< ::com::sun::star::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
2865 {
2866 	FillList();
2867 	return FontNameBox::CreateAccessible();
2868 }
2869