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