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