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