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