Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / svx / source / tbxctrls / tbcontrl.cxx
blob6ff2c513721c12faef43174eddf031637ea7f27d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
33 #include <string>
34 #include <tools/shl.hxx>
35 #include <tools/color.hxx>
36 #include <svl/poolitem.hxx>
37 #include <svl/eitem.hxx>
38 #include <vcl/toolbox.hxx>
39 #include <vcl/bmpacc.hxx>
40 #include <svtools/valueset.hxx>
41 #include <svtools/ctrlbox.hxx>
42 #include <svl/style.hxx>
43 #include <svtools/ctrltool.hxx>
44 #include <svtools/borderhelper.hxx>
45 #include <svl/stritem.hxx>
46 #include <unotools/pathoptions.hxx>
47 #include <sfx2/tplpitem.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/viewsh.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <sfx2/docfac.hxx>
52 #include <sfx2/templdlg.hxx>
53 #include <svl/isethint.hxx>
54 #include <sfx2/querystatus.hxx>
55 #include <sfx2/sfxstatuslistener.hxx>
56 #include <tools/urlobj.hxx>
57 #include <sfx2/childwin.hxx>
58 #include <sfx2/viewfrm.hxx>
59 #include <unotools/fontoptions.hxx>
60 #include <vcl/mnemonic.hxx>
62 #include <vcl/svapp.hxx>
63 #include <svl/smplhint.hxx>
65 #define _SVX_TBCONTRL_CXX
66 #include <svtools/colorcfg.hxx>
67 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
68 #include <com/sun/star/lang/XServiceInfo.hpp>
69 #include <com/sun/star/beans/XPropertySet.hpp>
70 #include <com/sun/star/frame/status/ItemStatus.hpp>
72 #include <svx/dialogs.hrc>
73 #include <svx/svxitems.hrc>
74 #include "helpid.hrc"
75 #include "svx/htmlmode.hxx"
76 #include <svx/xtable.hxx>
77 #include "editeng/fontitem.hxx"
78 #include <editeng/fhgtitem.hxx>
79 #include <editeng/brshitem.hxx>
80 #include <editeng/boxitem.hxx>
81 #include <editeng/colritem.hxx>
82 #include "editeng/flstitem.hxx"
83 #include "editeng/bolnitem.hxx"
84 #include "svx/drawitem.hxx"
85 #include <svx/tbcontrl.hxx>
86 #include "svx/dlgutil.hxx"
87 #include <svx/dialmgr.hxx>
88 #include "colorwindow.hxx"
89 #include <memory>
91 #include <svx/framelink.hxx>
92 #include <svx/tbxcolorupdate.hxx>
93 #include <editeng/eerdll.hxx>
94 #include <editeng/editrids.hrc>
96 // ------------------------------------------------------------------------
98 #define MAX_MRU_FONTNAME_ENTRIES 5
99 #define LOGICAL_EDIT_HEIGHT 12
101 // STATIC DATA -----------------------------------------------------------
103 #ifndef DELETEZ
104 #define DELETEZ(p) (delete (p), (p)=NULL)
105 #endif
106 // don't make more than 15 entries visible at once
107 #define MAX_STYLES_ENTRIES static_cast< sal_uInt16 >( 15 )
109 void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet );
110 void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize );
112 // namespaces
113 using ::rtl::OUString;
114 using namespace ::editeng;
115 using namespace ::com::sun::star;
116 using namespace ::com::sun::star::uno;
117 using namespace ::com::sun::star::frame;
118 using namespace ::com::sun::star::beans;
119 using namespace ::com::sun::star::lang;
121 SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
122 SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
123 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem );
124 SFX_IMPL_TOOLBOX_CONTROL( SvxColorExtToolBoxControl, SvxColorItem );
125 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
126 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
127 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl, SvxColorItem );
128 SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
130 //========================================================================
131 // class SvxStyleBox_Impl -----------------------------------------------------
132 //========================================================================
135 class SvxStyleBox_Impl : public ComboBox
137 using Window::IsVisible;
138 public:
139 SvxStyleBox_Impl( Window* pParent, sal_uInt16 nSlot, const OUString& rCommand, SfxStyleFamily eFamily, const Reference< XDispatchProvider >& rDispatchProvider,
140 const Reference< XFrame >& _xFrame,const String& rClearFormatKey, const String& rMoreKey, sal_Bool bInSpecialMode );
141 ~SvxStyleBox_Impl();
143 void SetFamily( SfxStyleFamily eNewFamily );
144 inline sal_Bool IsVisible() { return bVisible; }
146 virtual long PreNotify( NotifyEvent& rNEvt );
147 virtual long Notify( NotifyEvent& rNEvt );
148 virtual void DataChanged( const DataChangedEvent& rDCEvt );
149 virtual void StateChanged( StateChangedType nStateChange );
151 inline void SetVisibilityListener( const Link& aVisListener ) { aVisibilityListener = aVisListener; }
152 inline void RemoveVisibilityListener() { aVisibilityListener = Link(); }
154 void SetDefaultStyle( const ::rtl::OUString& rDefault ) { sDefaultStyle = rDefault; }
155 DECL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control* );
157 protected:
158 virtual void Select();
160 private:
161 sal_uInt16 nSlotId;
162 SfxStyleFamily eStyleFamily;
163 sal_uInt16 nCurSel;
164 sal_Bool bRelease;
165 Size aLogicalSize;
166 Link aVisibilityListener;
167 sal_Bool bVisible;
168 Reference< XDispatchProvider > m_xDispatchProvider;
169 Reference< XFrame > m_xFrame;
170 OUString m_aCommand;
171 String aClearFormatKey;
172 String aMoreKey;
173 String sDefaultStyle;
174 sal_Bool bInSpecialMode;
176 void ReleaseFocus();
179 //========================================================================
180 // class SvxFontNameBox --------------------------------------------------
181 //========================================================================
183 class SvxFontNameBox_Impl : public FontNameBox
185 using Window::Update;
186 private:
187 const FontList* pFontList;
188 SAL_WNODEPRECATED_DECLARATIONS_PUSH
189 ::std::auto_ptr<FontList> m_aOwnFontList;
190 SAL_WNODEPRECATED_DECLARATIONS_POP
191 Font aCurFont;
192 Size aLogicalSize;
193 String aCurText;
194 sal_uInt16 nFtCount;
195 sal_Bool bRelease;
196 Reference< XDispatchProvider > m_xDispatchProvider;
197 Reference< XFrame > m_xFrame;
199 void ReleaseFocus_Impl();
200 void EnableControls_Impl();
202 protected:
203 virtual void Select();
204 virtual void DataChanged( const DataChangedEvent& rDCEvt );
206 public:
207 SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame
208 , WinBits nStyle = WB_SORT
211 void FillList();
212 void Update( const SvxFontItem* pFontItem );
213 sal_uInt16 GetListCount() { return nFtCount; }
214 void Clear() { FontNameBox::Clear(); nFtCount = 0; }
215 void Fill( const FontList* pList )
216 { FontNameBox::Fill( pList );
217 nFtCount = pList->GetFontNameCount(); }
218 virtual long PreNotify( NotifyEvent& rNEvt );
219 virtual long Notify( NotifyEvent& rNEvt );
220 virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
221 SAL_WNODEPRECATED_DECLARATIONS_PUSH
222 void SetOwnFontList(::std::auto_ptr<FontList> _aOwnFontList) { m_aOwnFontList = _aOwnFontList; }
223 SAL_WNODEPRECATED_DECLARATIONS_POP
226 //========================================================================
227 // class SvxFrameWindow_Impl --------------------------------------------------
228 //========================================================================
230 // fuer den SelectHdl werden die Modifier gebraucht, also
231 // muss man sie im MouseButtonUp besorgen
233 class SvxFrmValueSet_Impl : public ValueSet
235 sal_uInt16 nModifier;
236 virtual void MouseButtonUp( const MouseEvent& rMEvt );
237 public:
238 SvxFrmValueSet_Impl(Window* pParent, WinBits nWinStyle)
239 : ValueSet(pParent, nWinStyle), nModifier(0) {}
240 sal_uInt16 GetModifier() const {return nModifier;}
244 void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent& rMEvt )
246 nModifier = rMEvt.GetModifier();
247 ValueSet::MouseButtonUp(rMEvt);
250 class SvxFrameWindow_Impl : public SfxPopupWindow
252 using FloatingWindow::StateChanged;
254 private:
255 SvxFrmValueSet_Impl aFrameSet;
256 ImageList aImgList;
257 sal_Bool bParagraphMode;
259 #if _SOLAR__PRIVATE
260 DECL_LINK( SelectHdl, void * );
261 #endif
263 protected:
264 virtual void Resize();
265 virtual sal_Bool Close();
266 virtual Window* GetPreferredKeyInputWindow();
267 virtual void GetFocus();
269 public:
270 SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
271 ~SvxFrameWindow_Impl();
272 void StartSelection();
274 virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
275 const SfxPoolItem* pState );
276 virtual SfxPopupWindow* Clone() const;
277 virtual void DataChanged( const DataChangedEvent& rDCEvt );
280 //========================================================================
281 // class SvxLineWindow_Impl ---------------------------------------------------
282 //========================================================================
283 class SvxLineWindow_Impl : public SfxPopupWindow
285 private:
286 LineListBox m_aLineStyleLb;
287 bool m_bIsWriter;
289 #if _SOLAR__PRIVATE
290 DECL_LINK( SelectHdl, void * );
291 #endif
293 protected:
294 virtual void Resize();
295 virtual sal_Bool Close();
296 virtual Window* GetPreferredKeyInputWindow();
297 virtual void GetFocus();
298 virtual void DataChanged( const DataChangedEvent& rDCEvt );
299 public:
300 SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
302 virtual SfxPopupWindow* Clone() const;
305 //########################################################################
306 // Hilfsklassen:
307 //========================================================================
308 // class SfxStyleControllerItem ------------------------------------------
309 //========================================================================
310 class SvxStyleToolBoxControl;
312 class SfxStyleControllerItem_Impl : public SfxStatusListener
314 public:
315 SfxStyleControllerItem_Impl( const Reference< XDispatchProvider >& rDispatchProvider,
316 sal_uInt16 nSlotId,
317 const rtl::OUString& rCommand,
318 SvxStyleToolBoxControl& rTbxCtl );
320 protected:
321 virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
323 private:
324 SvxStyleToolBoxControl& rControl;
327 //========================================================================
328 // class SvxStyleBox_Impl -----------------------------------------------------
329 //========================================================================
331 SvxStyleBox_Impl::SvxStyleBox_Impl(
332 Window* pParent,
333 sal_uInt16 nSlot,
334 const rtl::OUString& rCommand,
335 SfxStyleFamily eFamily,
336 const Reference< XDispatchProvider >& rDispatchProvider,
337 const Reference< XFrame >& _xFrame,
338 const String& rClearFormatKey,
339 const String& rMoreKey,
340 sal_Bool bInSpec) :
342 ComboBox( pParent, SVX_RES( RID_SVXTBX_STYLE ) ),
344 nSlotId ( nSlot ),
345 eStyleFamily( eFamily ),
346 bRelease ( sal_True ),
347 bVisible(sal_False),
348 m_xDispatchProvider( rDispatchProvider ),
349 m_xFrame(_xFrame),
350 m_aCommand ( rCommand ),
351 aClearFormatKey ( rClearFormatKey ),
352 aMoreKey ( rMoreKey ),
353 bInSpecialMode ( bInSpec )
355 aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT );
356 EnableAutocomplete( sal_True );
359 SvxStyleBox_Impl::~SvxStyleBox_Impl()
363 // -----------------------------------------------------------------------
365 void SvxStyleBox_Impl::ReleaseFocus()
367 if ( !bRelease )
369 bRelease = sal_True;
370 return;
372 if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
373 m_xFrame->getContainerWindow()->setFocus();
376 // -----------------------------------------------------------------------
378 void SvxStyleBox_Impl::Select()
380 // Tell base class about selection so that AT get informed about it.
381 ComboBox::Select();
383 if ( !IsTravelSelect() )
385 String aSelEntry( GetText() );
386 bool bDoIt = true, bClear = false;
387 if( bInSpecialMode )
389 if( aSelEntry == aClearFormatKey && GetSelectEntryPos() == 0 )
391 aSelEntry = sDefaultStyle;
392 bClear = true;
393 //not only apply default style but also call 'ClearFormatting'
394 Sequence< PropertyValue > aEmptyVals;
395 SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ResetAttributes"),
396 aEmptyVals);
398 else if( aSelEntry == aMoreKey && GetSelectEntryPos() == ( GetEntryCount() - 1 ) )
400 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
401 DBG_ASSERT( pViewFrm, "SvxStyleBox_Impl::Select(): no viewframe" );
402 pViewFrm->ShowChildWindow( SID_STYLE_DESIGNER );
403 SfxChildWindow* pChildWin = pViewFrm->GetChildWindow( SID_STYLE_DESIGNER );
404 if ( pChildWin && pChildWin->GetWindow() )
406 static_cast< SfxTemplateDialogWrapper* >( pChildWin )->SetParagraphFamily();
407 static_cast< SfxDockingWindow* >( pChildWin->GetWindow() )->AutoShow( sal_True );
408 Application::PostUserEvent(
409 STATIC_LINK( 0, SvxStyleBox_Impl, FocusHdl_Impl ), pChildWin->GetWindow() );
411 bDoIt = false;
415 // #i36723# after ReleaseFocus() the new entry is included into the List
416 sal_Bool bCreateNew = GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND;
418 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
419 This instance may be deleted in the meantime (i.e. when a dialog is opened
420 while in Dispatch()), accessing members will crash in this case. */
421 ReleaseFocus();
423 if( bDoIt )
425 if ( bClear )
426 SetText( aSelEntry );
427 SaveValue();
429 Sequence< PropertyValue > aArgs( 2 );
430 aArgs[0].Value = makeAny( OUString( aSelEntry ) );
431 aArgs[1].Name = OUString("Family");
432 aArgs[1].Value = makeAny( sal_Int16( eStyleFamily ));
433 if( bCreateNew )
435 aArgs[0].Name = OUString("Param");
436 SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:StyleNewByExample"), aArgs);
438 else
440 aArgs[0].Name = OUString("Template");
441 SfxToolBoxControl::Dispatch( m_xDispatchProvider, m_aCommand, aArgs );
446 // -----------------------------------------------------------------------
448 void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily )
450 eStyleFamily = eNewFamily;
453 // -----------------------------------------------------------------------
455 long SvxStyleBox_Impl::PreNotify( NotifyEvent& rNEvt )
457 sal_uInt16 nType = rNEvt.GetType();
459 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
460 nCurSel = GetSelectEntryPos();
461 else if ( EVENT_LOSEFOCUS == nType )
463 // don't handle before our Select() is called
464 if ( !HasFocus() && !HasChildPathFocus() )
465 SetText( GetSavedValue() );
467 return ComboBox::PreNotify( rNEvt );
470 // -----------------------------------------------------------------------
472 long SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt )
474 long nHandled = 0;
476 if ( rNEvt.GetType() == EVENT_KEYINPUT )
478 sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
480 switch ( nCode )
482 case KEY_RETURN:
483 case KEY_TAB:
485 if ( KEY_TAB == nCode )
486 bRelease = sal_False;
487 else
488 nHandled = 1;
489 Select();
490 break;
493 case KEY_ESCAPE:
494 SelectEntryPos( nCurSel );
495 ReleaseFocus();
496 nHandled = 1;
497 break;
500 return nHandled ? nHandled : ComboBox::Notify( rNEvt );
503 void SvxStyleBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
505 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
506 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
508 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
509 Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
510 SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
513 ComboBox::DataChanged( rDCEvt );
516 void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange )
518 ComboBox::StateChanged( nStateChange );
520 if ( nStateChange == STATE_CHANGE_VISIBLE )
522 bVisible = IsReallyVisible();
523 if ( aVisibilityListener.IsSet() )
524 aVisibilityListener.Call( this );
526 else if ( nStateChange == STATE_CHANGE_INITSHOW )
528 bVisible = sal_True;
529 if ( aVisibilityListener.IsSet() )
530 aVisibilityListener.Call( this );
534 //--------------------------------------------------------------------
536 IMPL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control*, _pCtrl )
538 (void)pThis;
539 if ( _pCtrl )
540 _pCtrl->GrabFocus();
541 return 0;
544 // -----------------------------------------------------------------------
546 sal_Bool GetDocFontList_Impl( const FontList** ppFontList, SvxFontNameBox_Impl* pBox )
548 sal_Bool bChanged = sal_False;
549 const SfxObjectShell* pDocSh = SfxObjectShell::Current();
550 SvxFontListItem* pFontListItem = NULL;
552 if ( pDocSh )
553 pFontListItem =
554 (SvxFontListItem*)pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
555 else
557 SAL_WNODEPRECATED_DECLARATIONS_PUSH
558 ::std::auto_ptr<FontList> aFontList(new FontList( pBox ));
559 SAL_WNODEPRECATED_DECLARATIONS_POP
560 *ppFontList = aFontList.get();
561 pBox->SetOwnFontList(aFontList);
562 bChanged = sal_True;
565 if ( pFontListItem )
567 const FontList* pNewFontList = pFontListItem->GetFontList();
568 DBG_ASSERT( pNewFontList, "Doc-FontList not available!" );
570 // keine alte Liste, aber neue Liste
571 if ( !*ppFontList && pNewFontList )
573 // => "ubernehmen
574 *ppFontList = pNewFontList;
575 bChanged = sal_True;
577 else
579 // Vergleich der Fontlisten ist nicht vollkommen
580 // wird die Fontliste am Doc geaendert, kann man hier
581 // nur ueber die Listbox Aenderungen feststellen, weil
582 // ppFontList dabei schon upgedatet wurde
583 bChanged =
584 ( ( *ppFontList != pNewFontList ) ||
585 pBox->GetListCount() != pNewFontList->GetFontNameCount() );
586 HACK(vergleich ist unvollstaendig)
588 if ( bChanged )
589 *ppFontList = pNewFontList;
592 if ( pBox )
593 pBox->Enable();
595 else if ( pBox && ( pDocSh || ( !pDocSh && !ppFontList )))
597 // Disable box only when we have a SfxObjectShell and didn't get a font list OR
598 // we don't have a SfxObjectShell and no current font list.
599 // It's possible that we currently have no SfxObjectShell, but a current font list.
600 // See #i58471: When a user set the focus into the font name combo box and opens
601 // the help window with F1. After closing the help window, we disable the font name
602 // combo box. The SfxObjectShell::Current() method returns in that case zero. But the
603 // font list hasn't changed and therefore the combo box shouldn't be disabled!
604 pBox->Disable();
607 // in die FontBox ggf. auch die neue Liste f"ullen
608 if ( pBox && bChanged )
610 if ( *ppFontList )
611 pBox->Fill( *ppFontList );
612 else
613 pBox->Clear();
615 return bChanged;
618 //========================================================================
619 // class SvxFontNameBox_Impl --------------------------------------------------
620 //========================================================================
622 SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame, WinBits nStyle ) :
624 FontNameBox ( pParent, nStyle | WinBits( WB_DROPDOWN | WB_AUTOHSCROLL ) ),
625 pFontList ( NULL ),
626 aLogicalSize ( 75,160 ),
627 nFtCount ( 0 ),
628 bRelease ( sal_True ),
629 m_xDispatchProvider( rDispatchProvider ),
630 m_xFrame (_xFrame)
632 SetSizePixel(LogicToPixel( aLogicalSize, MAP_APPFONT ));
633 EnableControls_Impl();
635 // -----------------------------------------------------------------------
637 void SvxFontNameBox_Impl::FillList()
639 // alte Selektion merken, und am Ende wieder setzen
640 Selection aOldSel = GetSelection();
641 // hat sich Doc-Fontlist geaendert?
642 GetDocFontList_Impl( &pFontList, this );
643 aCurText = GetText();
644 SetSelection( aOldSel );
647 // -----------------------------------------------------------------------
649 void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem )
651 if ( pFontItem )
653 aCurFont.SetName ( pFontItem->GetFamilyName() );
654 aCurFont.SetFamily ( pFontItem->GetFamily() );
655 aCurFont.SetStyleName ( pFontItem->GetStyleName() );
656 aCurFont.SetPitch ( pFontItem->GetPitch() );
657 aCurFont.SetCharSet ( pFontItem->GetCharSet() );
659 String aCurName = aCurFont.GetName();
660 if ( GetText() != aCurName )
661 SetText( aCurName );
664 // -----------------------------------------------------------------------
666 long SvxFontNameBox_Impl::PreNotify( NotifyEvent& rNEvt )
668 sal_uInt16 nType = rNEvt.GetType();
670 if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
672 EnableControls_Impl();
673 FillList();
675 return FontNameBox::PreNotify( rNEvt );
678 // -----------------------------------------------------------------------
680 long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
682 long nHandled = 0;
684 if ( rNEvt.GetType() == EVENT_KEYINPUT )
686 sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
688 switch ( nCode )
690 case KEY_RETURN:
691 case KEY_TAB:
693 if ( KEY_TAB == nCode )
694 bRelease = sal_False;
695 else
696 nHandled = 1;
697 Select();
698 break;
701 case KEY_ESCAPE:
702 SetText( aCurText );
703 ReleaseFocus_Impl();
704 break;
707 else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
709 Window* pFocusWin = Application::GetFocusWindow();
710 if ( !HasFocus() && GetSubEdit() != pFocusWin )
711 SetText( GetSavedValue() );
714 return nHandled ? nHandled : FontNameBox::Notify( rNEvt );
717 // ---------------------------------------------------------------------------
718 void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
720 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
721 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
723 SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
724 Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
725 SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
728 FontNameBox::DataChanged( rDCEvt );
731 // -----------------------------------------------------------------------
733 void SvxFontNameBox_Impl::ReleaseFocus_Impl()
735 if ( !bRelease )
737 bRelease = sal_True;
738 return;
740 if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
741 m_xFrame->getContainerWindow()->setFocus();
744 // -----------------------------------------------------------------------
746 void SvxFontNameBox_Impl::EnableControls_Impl()
748 SvtFontOptions aFontOpt;
749 sal_Bool bEnable = aFontOpt.IsFontHistoryEnabled();
750 sal_uInt16 nEntries = bEnable ? MAX_MRU_FONTNAME_ENTRIES : 0;
751 if ( GetMaxMRUCount() != nEntries )
753 // refill in the next GetFocus-Handler
754 pFontList = NULL;
755 Clear();
756 SetMaxMRUCount( nEntries );
759 bEnable = aFontOpt.IsFontWYSIWYGEnabled();
760 EnableWYSIWYG( bEnable );
761 EnableSymbols( bEnable );
764 // -----------------------------------------------------------------------
766 void SvxFontNameBox_Impl::Select()
768 FontNameBox::Select();
770 if ( !IsTravelSelect() )
772 if ( pFontList )
774 FontInfo aInfo( pFontList->Get( GetText(),
775 aCurFont.GetWeight(),
776 aCurFont.GetItalic() ) );
777 aCurFont = aInfo;
779 SvxFontItem aFontItem( aInfo.GetFamily(),
780 aInfo.GetName(),
781 aInfo.GetStyleName(),
782 aInfo.GetPitch(),
783 aInfo.GetCharSet(),
784 SID_ATTR_CHAR_FONT );
786 Any a;
787 Sequence< PropertyValue > aArgs( 1 );
788 aArgs[0].Name = OUString( "CharFontName" );
789 aFontItem.QueryValue( a );
790 aArgs[0].Value = a;
792 // #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
793 // This instance may be deleted in the meantime (i.e. when a dialog is opened
794 // while in Dispatch()), accessing members will crash in this case.
795 ReleaseFocus_Impl();
797 SfxToolBoxControl::Dispatch( m_xDispatchProvider,
798 OUString( ".uno:CharFontName" ),
799 aArgs );
801 else
802 ReleaseFocus_Impl();
806 //========================================================================
807 // class SvxColorWindow_Impl --------------------------------------------------
808 //========================================================================
809 #ifndef WB_NO_DIRECTSELECT
810 #define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
811 #endif
813 #define PALETTE_X 8
814 #define PALETTE_Y 13
815 #define PALETTE_SIZE (PALETTE_X * PALETTE_Y)
817 SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
818 sal_uInt16 nSlotId,
819 const Reference< XFrame >& rFrame,
820 const String& rWndTitle,
821 Window* pParentWindow,
822 const ::Color rLastColor ) :
824 SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
826 theSlotId( nSlotId ),
827 aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
828 maCommand( rCommand ),
829 mLastColor( rLastColor )
832 SfxObjectShell* pDocSh = SfxObjectShell::Current();
833 const SfxPoolItem* pItem = NULL;
834 XColorListRef pColorList;
835 const Size aSize12( 13, 13 );
837 if ( pDocSh )
838 if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
839 pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
841 if ( !pColorList.is() )
842 pColorList = XColorList::CreateStdColorList();
844 if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
846 aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
847 aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
848 aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
850 else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId )
852 SfxPoolItem* pDummy;
854 Reference< XDispatchProvider > aDisp( GetFrame()->getController(), UNO_QUERY );
855 SfxQueryStatus aQueryStatus( aDisp,
856 SID_ATTR_AUTO_COLOR_INVALID,
857 rtl::OUString( ".uno:AutoColorInvalid" ));
858 SfxItemState eState = aQueryStatus.QueryState( pDummy );
859 if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
861 aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
862 aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
863 aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
866 else
868 aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
871 if ( pColorList.is() )
873 short i = 0;
874 long nCount = pColorList->Count();
875 XColorEntry* pEntry = NULL;
876 ::Color aColWhite( COL_WHITE );
877 String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) );
879 if ( nCount > PALETTE_SIZE )
880 // Show scrollbar if more than PALLETTE_SIZE colors are available
881 aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL );
883 for ( i = 0; i < nCount; i++ )
885 pEntry = pColorList->GetColor(i);
886 aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
887 if( pEntry->GetColor() == mLastColor )
888 aColorSet.SelectItem( i+1 );
891 while ( i < PALETTE_SIZE )
893 // fill empty elements if less then PALLETTE_SIZE colors are available
894 aColorSet.InsertItem( i+1, aColWhite, aStrWhite );
895 i++;
899 aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
900 aColorSet.SetColCount( PALETTE_X );
901 aColorSet.SetLineCount( PALETTE_Y );
903 lcl_CalcSizeValueSet( *this, aColorSet, aSize12 );
905 SetHelpId( HID_POPUP_COLOR );
906 aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
908 SetText( rWndTitle );
909 aColorSet.Show();
911 AddStatusListener( rtl::OUString( ".uno:ColorTableState" ));
914 SvxColorWindow_Impl::~SvxColorWindow_Impl()
918 void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
920 aColorSet.KeyInput(rKEvt);
923 SfxPopupWindow* SvxColorWindow_Impl::Clone() const
925 return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent(), mLastColor );
928 // -----------------------------------------------------------------------
930 IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
932 sal_uInt16 nItemId = aColorSet.GetSelectItemId();
933 SvxColorItem aColorItem( aColorSet.GetItemColor( nItemId ), theSlotId );
934 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
935 This instance may be deleted in the meantime (i.e. when a dialog is opened
936 while in Dispatch()), accessing members will crash in this case. */
937 aColorSet.SetNoSelection();
939 if ( IsInPopupMode() )
940 EndPopupMode();
942 if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) )
944 Sequence< PropertyValue > aArgs;
945 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
946 maCommand,
947 aArgs );
949 else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) )
951 SvxColorItem _aColorItem( COL_AUTO, theSlotId );
952 INetURLObject aObj( maCommand );
954 Any a;
955 Sequence< PropertyValue > aArgs( 1 );
956 aArgs[0].Name = aObj.GetURLPath();
957 _aColorItem.QueryValue( a );
958 aArgs[0].Value = a;
959 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
960 maCommand,
961 aArgs );
963 else
965 INetURLObject aObj( maCommand );
967 Any a;
968 Sequence< PropertyValue > aArgs( 1 );
969 aArgs[0].Name = aObj.GetURLPath();
970 aColorItem.QueryValue( a );
971 aArgs[0].Value = a;
972 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
973 maCommand,
974 aArgs );
977 return 0;
980 // -----------------------------------------------------------------------
982 void SvxColorWindow_Impl::Resize()
984 lcl_ResizeValueSet( *this, aColorSet);
987 // -----------------------------------------------------------------------
989 void SvxColorWindow_Impl::StartSelection()
991 aColorSet.StartSelection();
994 // -----------------------------------------------------------------------
996 sal_Bool SvxColorWindow_Impl::Close()
998 return SfxPopupWindow::Close();
1001 // -----------------------------------------------------------------------
1003 void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1005 if (( SFX_ITEM_DISABLED != eState ) && pState )
1007 if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
1009 if ( pState )
1011 XColorListRef pColorList = ((SvxColorListItem *)pState)->GetColorList();
1013 short i = 0;
1014 long nCount = pColorList->Count();
1015 XColorEntry* pEntry = NULL;
1016 ::Color aColWhite( COL_WHITE );
1017 String aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE ) );
1019 // ScrollBar an oder aus
1020 WinBits nBits = aColorSet.GetStyle();
1021 if ( nCount > PALETTE_SIZE )
1022 nBits &= ~WB_VSCROLL;
1023 else
1024 nBits |= WB_VSCROLL;
1025 aColorSet.SetStyle( nBits );
1027 for ( i = 0; i < nCount; ++i )
1029 pEntry = pColorList->GetColor(i);
1030 aColorSet.SetItemColor( i + 1, pEntry->GetColor() );
1031 aColorSet.SetItemText ( i + 1, pEntry->GetName() );
1034 while ( i < PALETTE_SIZE )
1036 aColorSet.SetItemColor( i + 1, aColWhite );
1037 aColorSet.SetItemText ( i + 1, aStrWhite );
1038 i++;
1045 //========================================================================
1046 // class SvxFrameWindow_Impl --------------------------------------------------
1047 //========================================================================
1049 SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
1051 SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
1052 aFrameSet ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
1053 bParagraphMode(sal_False)
1056 BindListener();
1057 String sCommand(String::CreateFromAscii( ".uno:BorderReducedMode" ));
1058 AddStatusListener( sCommand );
1059 aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
1062 * 1 2 3 4
1063 * -------------------------------------
1064 * NONE LEFT RIGHT LEFTRIGHT
1065 * TOP BOTTOM TOPBOTTOM OUTER
1066 * -------------------------------------
1067 * HOR HORINNER VERINNER ALL <- kann ueber bParagraphMode
1068 * abgeschaltet werden
1071 sal_uInt16 i = 0;
1073 for ( i=1; i<9; i++ )
1074 aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1076 //bParagraphMode should have been set in StateChanged
1077 if ( !bParagraphMode )
1078 for ( i = 9; i < 13; i++ )
1079 aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1081 aFrameSet.SetColCount( 4 );
1082 aFrameSet.SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) );
1084 lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
1086 SetHelpId( HID_POPUP_FRAME );
1087 SetText( SVX_RESSTR(RID_SVXSTR_FRAME) );
1088 aFrameSet.SetAccessibleName( SVX_RESSTR(RID_SVXSTR_FRAME) );
1089 aFrameSet.Show();
1092 SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
1094 UnbindListener();
1097 SfxPopupWindow* SvxFrameWindow_Impl::Clone() const
1099 //! HACK: wie bekomme ich den Paragraph-Mode ??
1100 return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() );
1103 Window* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
1105 return &aFrameSet;
1108 void SvxFrameWindow_Impl::GetFocus()
1110 aFrameSet.GrabFocus();
1113 void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1115 SfxPopupWindow::DataChanged( rDCEvt );
1117 if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1119 aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
1121 sal_uInt16 nNumOfItems = aFrameSet.GetItemCount();
1123 for( sal_uInt16 i = 1 ; i <= nNumOfItems ; ++i )
1124 aFrameSet.SetItemImage( i, aImgList.GetImage( i ) );
1127 // -----------------------------------------------------------------------
1129 #define FRM_VALID_LEFT 0x01
1130 #define FRM_VALID_RIGHT 0x02
1131 #define FRM_VALID_TOP 0x04
1132 #define FRM_VALID_BOTTOM 0x08
1133 #define FRM_VALID_HINNER 0x10
1134 #define FRM_VALID_VINNER 0x20
1135 #define FRM_VALID_OUTER 0x0f
1136 #define FRM_VALID_ALL 0xff
1139 // Per default bleiben ungesetzte Linien unveraendert
1140 // Mit Shift werden ungesetzte Linien zurueckgsetzt
1142 IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl)
1144 ::Color aColBlack( COL_BLACK );
1145 SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER );
1146 SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER );
1147 SvxBorderLine theDefLine;
1148 SvxBorderLine *pLeft = 0,
1149 *pRight = 0,
1150 *pTop = 0,
1151 *pBottom = 0;
1152 sal_uInt16 nSel = aFrameSet.GetSelectItemId();
1153 sal_uInt16 nModifier = aFrameSet.GetModifier();
1154 sal_uInt8 nValidFlags = 0;
1156 theDefLine.GuessLinesWidths(theDefLine.GetBorderLineStyle(),
1157 DEF_LINE_WIDTH_0);
1158 switch ( nSel )
1160 case 1: nValidFlags |= FRM_VALID_ALL;
1161 break; // NONE
1162 case 2: pLeft = &theDefLine;
1163 nValidFlags |= FRM_VALID_LEFT;
1164 break; // LEFT
1165 case 3: pRight = &theDefLine;
1166 nValidFlags |= FRM_VALID_RIGHT;
1167 break; // RIGHT
1168 case 4: pLeft = pRight = &theDefLine;
1169 nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT;
1170 break; // LEFTRIGHT
1171 case 5: pTop = &theDefLine;
1172 nValidFlags |= FRM_VALID_TOP;
1173 break; // TOP
1174 case 6: pBottom = &theDefLine;
1175 nValidFlags |= FRM_VALID_BOTTOM;
1176 break; // BOTTOM
1177 case 7: pTop = pBottom = &theDefLine;
1178 nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP;
1179 break; // TOPBOTTOM
1180 case 8: pLeft = pRight = pTop = pBottom = &theDefLine;
1181 nValidFlags |= FRM_VALID_OUTER;
1182 break; // OUTER
1184 // Tabelle innen:
1185 case 9: // HOR
1186 pTop = pBottom = &theDefLine;
1187 aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1188 aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
1189 nValidFlags |= FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1190 break;
1192 case 10: // HORINNER
1193 pLeft = pRight = pTop = pBottom = &theDefLine;
1194 aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1195 aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
1196 nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1197 break;
1199 case 11: // VERINNER
1200 pLeft = pRight = pTop = pBottom = &theDefLine;
1201 aBorderInner.SetLine( NULL, BOXINFO_LINE_HORI );
1202 aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
1203 nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_VINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1204 break;
1206 case 12: // ALL
1207 pLeft = pRight = pTop = pBottom = &theDefLine;
1208 aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1209 aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
1210 nValidFlags |= FRM_VALID_ALL;
1211 break;
1213 default:
1214 break;
1216 aBorderOuter.SetLine( pLeft, BOX_LINE_LEFT );
1217 aBorderOuter.SetLine( pRight, BOX_LINE_RIGHT );
1218 aBorderOuter.SetLine( pTop, BOX_LINE_TOP );
1219 aBorderOuter.SetLine( pBottom, BOX_LINE_BOTTOM );
1221 if(nModifier == KEY_SHIFT)
1222 nValidFlags |= FRM_VALID_ALL;
1223 aBorderInner.SetValid( VALID_TOP, 0 != (nValidFlags&FRM_VALID_TOP ));
1224 aBorderInner.SetValid( VALID_BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM ));
1225 aBorderInner.SetValid( VALID_LEFT, 0 != (nValidFlags&FRM_VALID_LEFT));
1226 aBorderInner.SetValid( VALID_RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT ));
1227 aBorderInner.SetValid( VALID_HORI, 0 != (nValidFlags&FRM_VALID_HINNER ));
1228 aBorderInner.SetValid( VALID_VERT, 0 != (nValidFlags&FRM_VALID_VINNER));
1229 aBorderInner.SetValid( VALID_DISTANCE, sal_True );
1230 aBorderInner.SetValid( VALID_DISABLE, sal_False );
1232 if ( IsInPopupMode() )
1233 EndPopupMode();
1235 Any a;
1236 Sequence< PropertyValue > aArgs( 2 );
1237 aArgs[0].Name = OUString( "OuterBorder" );
1238 aBorderOuter.QueryValue( a );
1239 aArgs[0].Value = a;
1240 aArgs[1].Name = OUString( "InnerBorder" );
1241 aBorderInner.QueryValue( a );
1242 aArgs[1].Value = a;
1244 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1245 This instance may be deleted in the meantime (i.e. when a dialog is opened
1246 while in Dispatch()), accessing members will crash in this case. */
1247 aFrameSet.SetNoSelection();
1249 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1250 OUString( ".uno:SetBorderStyle" ),
1251 aArgs );
1252 return 0;
1255 // -----------------------------------------------------------------------
1257 void SvxFrameWindow_Impl::Resize()
1259 lcl_ResizeValueSet( *this, aFrameSet);
1262 // -----------------------------------------------------------------------
1264 void SvxFrameWindow_Impl::StateChanged(
1266 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1269 if ( pState && nSID == SID_BORDER_REDUCED_MODE)
1271 const SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState );
1273 if ( pItem )
1275 bParagraphMode = (sal_Bool)pItem->GetValue();
1276 //initial calls mustn't insert or remove elements
1277 if(aFrameSet.GetItemCount())
1279 sal_Bool bTableMode = ( aFrameSet.GetItemCount() == 12 );
1280 sal_Bool bResize = sal_False;
1282 if ( bTableMode && bParagraphMode )
1284 for ( sal_uInt16 i = 9; i < 13; i++ )
1285 aFrameSet.RemoveItem(i);
1286 bResize = sal_True;
1288 else if ( !bTableMode && !bParagraphMode )
1290 for ( sal_uInt16 i = 9; i < 13; i++ )
1291 aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1292 bResize = sal_True;
1295 if ( bResize )
1297 lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
1302 SfxPopupWindow::StateChanged( nSID, eState, pState );
1305 // -----------------------------------------------------------------------
1307 void SvxFrameWindow_Impl::StartSelection()
1309 aFrameSet.StartSelection();
1312 // -----------------------------------------------------------------------
1314 sal_Bool SvxFrameWindow_Impl::Close()
1316 return SfxPopupWindow::Close();
1319 //========================================================================
1320 // class SvxLineWindow_Impl --------------------------------------------------
1321 //========================================================================
1322 Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1324 return SvxBorderLine::threeDMediumColor( aMain );
1327 SvxLineWindow_Impl::SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
1329 SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION | WB_AUTOSIZE ) ),
1330 m_aLineStyleLb( this )
1334 Reference< lang::XServiceInfo > xServices( rFrame->getController()->getModel(), UNO_QUERY_THROW );
1335 m_bIsWriter = xServices->supportsService(::rtl::OUString("com.sun.star.text.TextDocument"));
1337 catch(const uno::Exception& )
1341 m_aLineStyleLb.SetPosSizePixel( 2, 2, 110, 140 );
1342 SetOutputSizePixel( Size( 114, 144 ) );
1344 m_aLineStyleLb.SetSourceUnit( FUNIT_TWIP );
1345 m_aLineStyleLb.SetNone( SVX_RESSTR(STR_NONE) );
1347 using namespace table::BorderLineStyle;
1348 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( SOLID ), SOLID );
1349 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( DOTTED ), DOTTED );
1350 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( DASHED ), DASHED );
1352 // Double lines
1353 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE ), DOUBLE );
1354 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP ), THINTHICK_SMALLGAP, 20 );
1355 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP ), THINTHICK_MEDIUMGAP );
1356 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP ), THINTHICK_LARGEGAP );
1357 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP ), THICKTHIN_SMALLGAP, 20 );
1358 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP ), THICKTHIN_MEDIUMGAP );
1359 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP ), THICKTHIN_LARGEGAP );
1361 // Engraved / Embossed
1362 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED ), EMBOSSED, 15,
1363 &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor,
1364 &lcl_mediumColor );
1365 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED ), ENGRAVED, 15,
1366 &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor,
1367 &lcl_mediumColor );
1369 // Inset / Outset
1370 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( OUTSET ), OUTSET, 10,
1371 &SvxBorderLine::lightColor, &SvxBorderLine::darkColor );
1372 m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( INSET ), INSET, 10,
1373 &SvxBorderLine::darkColor, &SvxBorderLine::lightColor );
1374 m_aLineStyleLb.SetWidth( 20 ); // 1pt by default
1376 m_aLineStyleLb.SetSelectHdl( LINK( this, SvxLineWindow_Impl, SelectHdl ) );
1378 SetHelpId( HID_POPUP_LINE );
1379 SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE) );
1380 m_aLineStyleLb.Show();
1383 SfxPopupWindow* SvxLineWindow_Impl::Clone() const
1385 return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() );
1388 // -----------------------------------------------------------------------
1390 IMPL_LINK_NOARG(SvxLineWindow_Impl, SelectHdl)
1392 SvxLineItem aLineItem( SID_FRAME_LINESTYLE );
1393 SvxBorderStyle nStyle = SvxBorderStyle( m_aLineStyleLb.GetSelectEntryStyle() );
1395 if ( m_aLineStyleLb.GetSelectEntryPos( ) > 0 )
1397 SvxBorderLine aTmp;
1398 aTmp.SetBorderLineStyle( nStyle );
1399 aTmp.SetWidth( 20 ); // TODO Make it depend on a width field
1400 aLineItem.SetLine( &aTmp );
1402 else
1403 aLineItem.SetLine( NULL );
1405 if ( IsInPopupMode() )
1406 EndPopupMode();
1408 Any a;
1409 Sequence< PropertyValue > aArgs( 1 );
1410 aArgs[0].Name = OUString( "LineStyle" );
1411 aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 );
1412 aArgs[0].Value = a;
1414 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1415 OUString( ".uno:LineStyle" ),
1416 aArgs );
1417 return 0;
1420 // -----------------------------------------------------------------------
1422 void SvxLineWindow_Impl::Resize()
1424 m_aLineStyleLb.Resize();
1427 // -----------------------------------------------------------------------
1429 sal_Bool SvxLineWindow_Impl::Close()
1431 return SfxPopupWindow::Close();
1434 // -----------------------------------------------------------------------
1436 Window* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
1438 return &m_aLineStyleLb;
1441 // -----------------------------------------------------------------------
1443 void SvxLineWindow_Impl::GetFocus()
1445 m_aLineStyleLb.GrabFocus();
1448 void SvxLineWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1450 SfxPopupWindow::DataChanged( rDCEvt );
1451 #if 0
1452 if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1454 CreateBitmaps();
1455 Invalidate();
1457 #endif
1460 // -----------------------------------------------------------------------
1462 //########################################################################
1463 // Hilfsklassen
1465 //========================================================================
1466 // class SfxStyleControllerItem_Impl ------------------------------------------
1467 //========================================================================
1469 SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl(
1470 const Reference< XDispatchProvider >& rDispatchProvider,
1471 sal_uInt16 nSlotId, // Family-ID
1472 const rtl::OUString& rCommand, // .uno: command bound to this item
1473 SvxStyleToolBoxControl& rTbxCtl ) // Controller-Instanz, dem dieses Item zugeordnet ist.
1474 : SfxStatusListener( rDispatchProvider, nSlotId, rCommand ),
1475 rControl( rTbxCtl )
1479 // -----------------------------------------------------------------------
1481 void SfxStyleControllerItem_Impl::StateChanged(
1482 sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
1484 switch ( GetId() )
1486 case SID_STYLE_FAMILY1:
1487 case SID_STYLE_FAMILY2:
1488 case SID_STYLE_FAMILY3:
1489 case SID_STYLE_FAMILY4:
1490 case SID_STYLE_FAMILY5:
1492 const sal_uInt16 nIdx = GetId() - SID_STYLE_FAMILY_START;
1494 if ( SFX_ITEM_AVAILABLE == eState )
1496 const SfxTemplateItem* pStateItem =
1497 PTR_CAST( SfxTemplateItem, pState );
1498 DBG_ASSERT( pStateItem != NULL, "SfxTemplateItem expected" );
1499 rControl.SetFamilyState( nIdx, pStateItem );
1501 else
1502 rControl.SetFamilyState( nIdx, NULL );
1503 break;
1508 //########################################################################
1510 //========================================================================
1511 // class SvxStyleToolBoxControl ------------------------------------------
1512 //========================================================================
1514 struct SvxStyleToolBoxControl::Impl
1516 String aClearForm;
1517 String aMore;
1518 ::std::vector< ::rtl::OUString > aDefaultStyles;
1519 sal_Bool bListening;
1520 sal_Bool bSpecModeWriter;
1521 sal_Bool bSpecModeCalc;
1523 inline Impl( void )
1524 :aClearForm ( SVX_RESSTR( RID_SVXSTR_CLEARFORM ) )
1525 ,aMore ( SVX_RESSTR( RID_SVXSTR_MORE ) )
1526 ,bListening ( sal_False )
1527 ,bSpecModeWriter ( sal_False )
1528 ,bSpecModeCalc ( sal_False )
1533 void InitializeStyles(Reference < frame::XModel > xModel)
1535 //now convert the default style names to the localized names
1538 Reference< style::XStyleFamiliesSupplier > xStylesSupplier( xModel, UNO_QUERY_THROW );
1539 Reference< lang::XServiceInfo > xServices( xModel, UNO_QUERY_THROW );
1540 bSpecModeWriter = xServices->supportsService(::rtl::OUString("com.sun.star.text.TextDocument"));
1541 if(bSpecModeWriter)
1543 Reference<container::XNameAccess> xParaStyles;
1544 xStylesSupplier->getStyleFamilies()->getByName(::rtl::OUString("ParagraphStyles")) >>=
1545 xParaStyles;
1546 static const sal_Char* aWriterStyles[] =
1548 "Standard",
1549 "Heading 1",
1550 "Heading 2",
1551 "Heading 3",
1552 "Text body"
1554 for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
1558 Reference< beans::XPropertySet > xStyle;
1559 xParaStyles->getByName( rtl::OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
1560 ::rtl::OUString sName;
1561 xStyle->getPropertyValue(::rtl::OUString("DisplayName")) >>= sName;
1562 if( !sName.isEmpty() )
1563 aDefaultStyles.push_back(sName);
1565 catch( const uno::Exception& )
1570 else if( 0 != (
1571 bSpecModeCalc = xServices->supportsService(::rtl::OUString(
1572 "com.sun.star.sheet.SpreadsheetDocument"))))
1574 static const sal_Char* aCalcStyles[] =
1576 "Default",
1577 "Heading1",
1578 "Result",
1579 "Result2"
1581 Reference<container::XNameAccess> xCellStyles;
1582 xStylesSupplier->getStyleFamilies()->getByName(
1583 ::rtl::OUString("CellStyles")) >>=
1584 xCellStyles;
1585 for( sal_uInt32 nStyle = 0; nStyle < sizeof( aCalcStyles ) / sizeof( sal_Char*); ++nStyle )
1589 const rtl::OUString sStyleName( rtl::OUString::createFromAscii( aCalcStyles[nStyle] ) );
1590 if( xCellStyles->hasByName( sStyleName ) )
1592 Reference< beans::XPropertySet > xStyle( xCellStyles->getByName( sStyleName), UNO_QUERY_THROW );
1593 ::rtl::OUString sName;
1594 xStyle->getPropertyValue(::rtl::OUString("DisplayName")) >>= sName;
1595 if( !sName.isEmpty() )
1596 aDefaultStyles.push_back(sName);
1599 catch( const uno::Exception& )
1604 catch(const uno::Exception& )
1606 OSL_FAIL("error while initializing style names");
1612 // mapping table from bound items. BE CAREFUL this table must be in the
1613 // same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n
1614 // MAX_FAMILIES must also be correctly set!
1615 static const char* StyleSlotToStyleCommand[MAX_FAMILIES] =
1617 ".uno:CharStyle",
1618 ".uno:ParaStyle",
1619 ".uno:FrameStyle",
1620 ".uno:PageStyle",
1621 ".uno:TemplateFamily5"
1624 SvxStyleToolBoxControl::SvxStyleToolBoxControl(
1625 sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
1626 : SfxToolBoxControl ( nSlotId, nId, rTbx ),
1627 pStyleSheetPool ( NULL ),
1628 nActFamily ( 0xffff ),
1629 bListening ( sal_False ),
1630 pImpl ( new Impl )
1632 for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1634 pBoundItems[i] = 0;
1635 m_xBoundItems[i] = Reference< XComponent >();
1636 pFamilyState[i] = NULL;
1640 // -----------------------------------------------------------------------
1641 SvxStyleToolBoxControl::~SvxStyleToolBoxControl()
1645 // -----------------------------------------------------------------------
1646 void SAL_CALL SvxStyleToolBoxControl::initialize( const Sequence< Any >& aArguments )
1647 throw ( Exception, RuntimeException)
1649 SfxToolBoxControl::initialize( aArguments );
1651 // After initialize we should have a valid frame member where we can retrieve our
1652 // dispatch provider.
1653 if ( m_xFrame.is() )
1655 pImpl->InitializeStyles(m_xFrame->getController()->getModel());
1656 Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY );
1657 for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1659 pBoundItems[i] = new SfxStyleControllerItem_Impl( xDispatchProvider,
1660 SID_STYLE_FAMILY_START + i,
1661 OUString::createFromAscii( StyleSlotToStyleCommand[i] ),
1662 *this );
1663 m_xBoundItems[i] = Reference< XComponent >( static_cast< OWeakObject* >( pBoundItems[i] ), UNO_QUERY );
1664 pFamilyState[i] = NULL;
1669 // XComponent
1670 void SAL_CALL SvxStyleToolBoxControl::dispose()
1671 throw (::com::sun::star::uno::RuntimeException)
1673 SfxToolBoxControl::dispose();
1675 for( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1677 if ( m_xBoundItems[i].is() )
1681 m_xBoundItems[i]->dispose();
1683 catch ( Exception& )
1687 m_xBoundItems[i].clear();
1688 pBoundItems[i] = 0;
1690 DELETEZ( pFamilyState[i] );
1692 pStyleSheetPool = NULL;
1693 DELETEZ( pImpl );
1696 // -----------------------------------------------------------------------
1697 void SAL_CALL SvxStyleToolBoxControl::update() throw (RuntimeException)
1699 // Do nothing, we will start binding our listener when we are visible.
1700 // See link SvxStyleToolBoxControl::VisibilityNotification.
1701 SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1702 if ( pBox->IsVisible() )
1704 for ( int i=0; i<MAX_FAMILIES; i++ )
1705 pBoundItems [i]->ReBind();
1707 bindListener();
1711 // -----------------------------------------------------------------------
1713 SfxStyleFamily SvxStyleToolBoxControl::GetActFamily()
1715 switch ( nActFamily-1 + SID_STYLE_FAMILY_START )
1717 case SID_STYLE_FAMILY1: return SFX_STYLE_FAMILY_CHAR;
1718 case SID_STYLE_FAMILY2: return SFX_STYLE_FAMILY_PARA;
1719 case SID_STYLE_FAMILY3: return SFX_STYLE_FAMILY_FRAME;
1720 case SID_STYLE_FAMILY4: return SFX_STYLE_FAMILY_PAGE;
1721 case SID_STYLE_FAMILY5: return SFX_STYLE_FAMILY_PSEUDO;
1722 default:
1723 OSL_FAIL( "unknown style family" );
1724 break;
1726 return SFX_STYLE_FAMILY_PARA;
1729 // -----------------------------------------------------------------------
1731 void SvxStyleToolBoxControl::FillStyleBox()
1733 SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1735 DBG_ASSERT( pStyleSheetPool, "StyleSheetPool not found!" );
1736 DBG_ASSERT( pBox, "Control not found!" );
1738 if ( pStyleSheetPool && pBox && nActFamily!=0xffff )
1740 const SfxStyleFamily eFamily = GetActFamily();
1741 sal_uInt16 nCount = pStyleSheetPool->Count();
1742 SfxStyleSheetBase* pStyle = NULL;
1743 sal_Bool bDoFill = sal_False;
1745 pStyleSheetPool->SetSearchMask( eFamily, SFXSTYLEBIT_USED );
1747 //------------------------------
1748 // Ueberpruefen, ob Fill noetig:
1749 //------------------------------
1751 pStyle = pStyleSheetPool->First();
1752 //!!! TODO: This condition isn't right any longer, because we always show some default entries
1753 //!!! so the list doesn't show the count
1754 if ( nCount != pBox->GetEntryCount() )
1756 bDoFill = sal_True;
1758 else
1760 sal_uInt16 i= 0;
1761 while ( pStyle && !bDoFill )
1763 bDoFill = ( pBox->GetEntry(i) != pStyle->GetName() );
1764 pStyle = pStyleSheetPool->Next();
1765 i++;
1769 if ( bDoFill )
1771 pBox->SetUpdateMode( sal_False );
1772 pBox->Clear();
1775 sal_uInt16 _i;
1776 sal_uInt32 nCnt = pImpl->aDefaultStyles.size();
1778 pStyle = pStyleSheetPool->First();
1780 if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
1782 bool bInsert;
1783 while ( pStyle )
1785 // sort out default styles
1786 bInsert = true;
1787 ::rtl::OUString aName( pStyle->GetName() );
1788 for( _i = 0 ; _i < nCnt ; ++_i )
1790 if( pImpl->aDefaultStyles[_i] == aName )
1792 bInsert = false;
1793 break;
1797 if( bInsert )
1798 pBox->InsertEntry( aName );
1799 pStyle = pStyleSheetPool->Next();
1802 else
1804 while ( pStyle )
1806 pBox->InsertEntry( pStyle->GetName() );
1807 pStyle = pStyleSheetPool->Next();
1812 if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
1814 // insert default styles
1815 sal_uInt16 _i;
1816 sal_uInt32 nCnt = pImpl->aDefaultStyles.size();
1817 sal_uInt16 nPos = 1;
1818 for( _i = 0 ; _i < nCnt ; ++_i )
1820 pBox->InsertEntry( pImpl->aDefaultStyles[_i], nPos );
1821 ++nPos;
1824 // disable sort to preserve special order
1825 WinBits nWinBits = pBox->GetStyle();
1826 nWinBits &= ~WB_SORT;
1827 pBox->SetStyle( nWinBits );
1829 pBox->InsertEntry( pImpl->aClearForm, 0 );
1830 pBox->SetSeparatorPos( 0 );
1832 pBox->InsertEntry( pImpl->aMore );
1834 // enable sort again
1835 nWinBits |= WB_SORT;
1836 pBox->SetStyle( nWinBits );
1839 pBox->SetUpdateMode( sal_True );
1840 pBox->SetFamily( eFamily );
1842 sal_uInt16 nLines = Min( pBox->GetEntryCount(), MAX_STYLES_ENTRIES );
1843 pBox->SetDropDownLineCount( nLines );
1848 // -----------------------------------------------------------------------
1850 void SvxStyleToolBoxControl::SelectStyle( const String& rStyleName )
1852 SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1853 DBG_ASSERT( pBox, "Control not found!" );
1855 if ( pBox )
1857 // String aStrSel( pBox->GetSelectEntry() );
1858 String aStrSel( pBox->GetText() );
1860 if ( rStyleName.Len() > 0 )
1862 if ( rStyleName != aStrSel )
1863 // pBox->SelectEntry( rStyleName );
1864 pBox->SetText( rStyleName );
1866 else
1867 pBox->SetNoSelection();
1868 pBox->SaveValue();
1872 // -----------------------------------------------------------------------
1874 void SvxStyleToolBoxControl::Update()
1876 SfxStyleSheetBasePool* pPool = NULL;
1877 SfxObjectShell* pDocShell = SfxObjectShell::Current();
1879 if ( pDocShell )
1880 pPool = pDocShell->GetStyleSheetPool();
1882 sal_uInt16 i;
1883 for ( i=0; i<MAX_FAMILIES; i++ )
1884 if( pFamilyState[i] )
1885 break;
1887 if ( i==MAX_FAMILIES || !pPool )
1889 pStyleSheetPool = pPool;
1890 return;
1893 //--------------------------------------------------------------------
1894 const SfxTemplateItem* pItem = NULL;
1896 if ( nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1]) )
1897 // aktueller Bereich nicht innerhalb der erlaubten Bereiche
1898 // oder Default
1900 pStyleSheetPool = pPool;
1901 nActFamily = 2;
1903 pItem = pFamilyState[nActFamily-1];
1904 if ( !pItem )
1906 nActFamily++;
1907 pItem = pFamilyState[nActFamily-1];
1910 if ( !pItem )
1912 DBG_WARNING( "Unknown Family" ); // can happen
1915 else if ( pPool != pStyleSheetPool )
1916 pStyleSheetPool = pPool;
1918 FillStyleBox(); // entscheidet selbst, ob gefuellt werden muss
1920 if ( pItem )
1921 SelectStyle( pItem->GetStyleName() );
1924 // -----------------------------------------------------------------------
1926 void SvxStyleToolBoxControl::SetFamilyState( sal_uInt16 nIdx,
1927 const SfxTemplateItem* pItem )
1929 DELETEZ( pFamilyState[nIdx] );
1931 if ( pItem )
1932 pFamilyState[nIdx] = new SfxTemplateItem( *pItem );
1934 Update();
1937 // -----------------------------------------------------------------------
1939 IMPL_LINK_NOARG(SvxStyleToolBoxControl, VisibilityNotification)
1942 sal_uInt16 i;
1944 // Call ReBind() && UnBind() according to visibility
1945 SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)( GetToolBox().GetItemWindow( GetId() ));
1946 if ( pBox->IsVisible() && !isBound() )
1948 for ( i=0; i<MAX_FAMILIES; i++ )
1949 pBoundItems [i]->ReBind();
1951 bindListener();
1953 else if ( !pBox->IsVisible() && isBound() )
1955 for ( i=0; i<MAX_FAMILIES; i++ )
1956 pBoundItems[i]->UnBind();
1957 unbindListener();
1960 return 0;
1963 // -----------------------------------------------------------------------
1965 void SvxStyleToolBoxControl::StateChanged(
1967 sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
1970 sal_uInt16 nId = GetId();
1971 ToolBox& rTbx = GetToolBox();
1972 SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)(rTbx.GetItemWindow( nId ));
1973 TriState eTri = STATE_NOCHECK;
1975 DBG_ASSERT( pBox, "Control not found!" );
1977 if ( SFX_ITEM_DISABLED == eState )
1978 pBox->Disable();
1979 else
1980 pBox->Enable();
1982 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
1984 switch ( eState )
1986 case SFX_ITEM_AVAILABLE:
1987 eTri = ((const SfxBoolItem*)pState)->GetValue()
1988 ? STATE_CHECK
1989 : STATE_NOCHECK;
1990 break;
1992 case SFX_ITEM_DONTCARE:
1993 eTri = STATE_DONTKNOW;
1994 break;
1997 rTbx.SetItemState( nId, eTri );
1999 if ( SFX_ITEM_DISABLED != eState )
2000 Update();
2003 // -----------------------------------------------------------------------
2005 Window* SvxStyleToolBoxControl::CreateItemWindow( Window *pParent )
2007 SvxStyleBox_Impl* pBox = new SvxStyleBox_Impl( pParent,
2008 SID_STYLE_APPLY,
2009 OUString( ".uno:StyleApply" ),
2010 SFX_STYLE_FAMILY_PARA,
2011 Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
2012 m_xFrame,
2013 pImpl->aClearForm,
2014 pImpl->aMore,
2015 pImpl->bSpecModeWriter || pImpl->bSpecModeCalc );
2016 if( !pImpl->aDefaultStyles.empty())
2017 pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] );
2018 // Set visibility listener to bind/unbind controller
2019 pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, VisibilityNotification ));
2021 return pBox;
2024 //========================================================================
2025 // class SvxFontNameToolBoxControl ---------------------------------------
2026 //========================================================================
2028 SvxFontNameToolBoxControl::SvxFontNameToolBoxControl(
2029 sal_uInt16 nSlotId,
2030 sal_uInt16 nId,
2031 ToolBox& rTbx )
2033 : SfxToolBoxControl( nSlotId, nId, rTbx )
2037 // -----------------------------------------------------------------------
2039 void SvxFontNameToolBoxControl::StateChanged(
2041 sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2044 sal_uInt16 nId = GetId();
2045 ToolBox& rTbx = GetToolBox();
2046 SvxFontNameBox_Impl* pBox = (SvxFontNameBox_Impl*)(rTbx.GetItemWindow( nId ));
2048 DBG_ASSERT( pBox, "Control not found!" );
2050 if ( SFX_ITEM_DISABLED == eState )
2052 pBox->Disable();
2053 pBox->Update( (const SvxFontItem*)NULL );
2055 else
2057 pBox->Enable();
2059 if ( SFX_ITEM_AVAILABLE == eState )
2061 const SvxFontItem* pFontItem = dynamic_cast< const SvxFontItem* >( pState );
2063 DBG_ASSERT( pFontItem, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" );
2064 if( pFontItem )
2065 pBox->Update( pFontItem );
2067 else
2068 pBox->SetText( String() );
2069 pBox->SaveValue();
2072 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2075 // -----------------------------------------------------------------------
2077 Window* SvxFontNameToolBoxControl::CreateItemWindow( Window *pParent )
2079 SvxFontNameBox_Impl* pBox = new SvxFontNameBox_Impl( pParent,
2080 Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
2081 m_xFrame,0);
2082 return pBox;
2085 //========================================================================
2086 // class SvxFontColorToolBoxControl --------------------------------------
2087 //========================================================================
2089 SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
2090 sal_uInt16 nSlotId,
2091 sal_uInt16 nId,
2092 ToolBox& rTbx )
2094 : SfxToolBoxControl( nSlotId, nId, rTbx ),
2095 pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
2096 nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW )),
2097 mLastColor( COL_AUTO )
2099 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2102 // -----------------------------------------------------------------------
2104 SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl()
2106 delete pBtnUpdater;
2109 // -----------------------------------------------------------------------
2111 SfxPopupWindowType SvxFontColorToolBoxControl::GetPopupWindowType() const
2113 return SFX_POPUPWINDOW_ONCLICK;
2116 // -----------------------------------------------------------------------
2118 SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow()
2120 SvxColorWindow_Impl* pColorWin =
2121 new SvxColorWindow_Impl(
2122 OUString( ".uno:Color" ),
2123 SID_ATTR_CHAR_COLOR,
2124 m_xFrame,
2125 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
2126 &GetToolBox(),
2127 mLastColor);
2129 pColorWin->StartPopupMode( &GetToolBox(),
2130 FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2131 pColorWin->StartSelection();
2132 SetPopupWindow( pColorWin );
2133 return pColorWin;
2136 // -----------------------------------------------------------------------
2138 void SvxFontColorToolBoxControl::StateChanged(
2140 sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2143 sal_uInt16 nId = GetId();
2144 ToolBox& rTbx = GetToolBox();
2145 const SvxColorItem* pItem = 0;
2147 if ( SFX_ITEM_DONTCARE != eState )
2148 pItem = PTR_CAST( SvxColorItem, pState );
2150 if ( pItem )
2152 pBtnUpdater->Update( pItem->GetValue() );
2153 mLastColor= pItem->GetValue();
2156 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2157 rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2160 //========================================================================
2161 // class SvxColorToolBoxControl --------------------------------
2162 //========================================================================
2164 SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
2166 SfxToolBoxControl( nSlotId, nId, rTbx ),
2167 mLastColor( COL_AUTO )
2169 if ( nSlotId == SID_BACKGROUND_COLOR )
2170 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2171 else
2172 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2173 rTbx.Invalidate();
2174 pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() );
2177 // -----------------------------------------------------------------------
2179 SvxColorToolBoxControl::~SvxColorToolBoxControl()
2181 delete pBtnUpdater;
2184 // -----------------------------------------------------------------------
2186 SfxPopupWindowType SvxColorToolBoxControl::GetPopupWindowType() const
2188 return SFX_POPUPWINDOW_ONCLICK;
2191 // -----------------------------------------------------------------------
2193 SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
2195 sal_uInt16 nResId = GetSlotId() == SID_BACKGROUND_COLOR ?
2196 RID_SVXSTR_BACKGROUND : RID_SVXSTR_COLOR;
2197 SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
2198 OUString( ".uno:BackgroundColor" ),
2199 SID_BACKGROUND_COLOR,
2200 m_xFrame,
2201 SVX_RESSTR(nResId),
2202 &GetToolBox(),
2203 mLastColor);
2205 pColorWin->StartPopupMode( &GetToolBox(),
2206 FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2207 pColorWin->StartSelection();
2208 SetPopupWindow( pColorWin );
2209 return pColorWin;
2212 // -----------------------------------------------------------------------
2214 void SvxColorToolBoxControl::StateChanged(
2215 sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2217 const SvxColorItem* pItem = 0;
2218 if ( SFX_ITEM_DONTCARE != eState )
2219 pItem = PTR_CAST( SvxColorItem, pState );
2221 if ( pItem ) {
2222 pBtnUpdater->Update( pItem->GetValue() );
2223 mLastColor= pItem->GetValue();
2226 sal_uInt16 nId = GetId();
2227 ToolBox& rTbx = GetToolBox();
2228 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2229 rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2232 //========================================================================
2233 // class SvxColorExtToolBoxControl ----------------------------------------
2234 //========================================================================
2235 /* Note:
2236 The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx
2237 (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) .
2238 The initial color used by the button is set in /core/svx/source/tbxcntrls/tbcontrl.cxx
2239 (SvxColorExtToolBoxControl::SvxColorExtToolBoxControl())
2240 and in case of writer for text(background)color also in /core/sw/source/ui/docvw/edtwin.cxx
2241 (SwEditWin::aTextBackColor and SwEditWin::aTextBackColor)
2244 SvxColorExtToolBoxControl::SvxColorExtToolBoxControl(
2245 sal_uInt16 nSlotId,
2246 sal_uInt16 nId,
2247 ToolBox& rTbx ) :
2249 SfxToolBoxControl( nSlotId, nId, rTbx ),
2250 pBtnUpdater(0),
2251 mLastColor( COL_AUTO )
2253 sal_uInt16 nMode;
2255 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2256 bChoiceFromPalette = sal_False;
2258 // The following commands are available at the various modules
2259 switch( nSlotId )
2261 case SID_ATTR_CHAR_COLOR:
2262 addStatusListener( OUString( ".uno:Color" ));
2263 nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
2264 mLastColor = COL_RED;
2265 break;
2267 case SID_ATTR_CHAR_COLOR2:
2268 addStatusListener( OUString( ".uno:CharColorExt" ));
2269 nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
2270 mLastColor = COL_RED;
2271 break;
2273 case SID_BACKGROUND_COLOR:
2274 case SID_ATTR_CHAR_COLOR_BACKGROUND:
2275 default:
2276 addStatusListener( OUString( ".uno:CharBackgroundExt" ));
2277 nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
2278 mLastColor = COL_YELLOW;
2279 break;
2281 case SID_FRAME_LINECOLOR:
2282 addStatusListener( OUString( ".uno:FrameLineColor" ));
2283 nMode = 0;
2284 mLastColor = COL_BLUE;
2285 break;
2288 pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode );
2291 // -----------------------------------------------------------------------
2293 SvxColorExtToolBoxControl::~SvxColorExtToolBoxControl()
2295 delete pBtnUpdater;
2298 // -----------------------------------------------------------------------
2300 SfxPopupWindowType SvxColorExtToolBoxControl::GetPopupWindowType() const
2302 return SFX_POPUPWINDOW_ONTIMEOUT;
2305 // -----------------------------------------------------------------------
2307 SfxPopupWindow* SvxColorExtToolBoxControl::CreatePopupWindow()
2309 SvxColorWindow_Impl* pColorWin =
2310 new SvxColorWindow_Impl(
2311 m_aCommandURL,
2312 GetSlotId(),
2313 m_xFrame,
2314 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
2315 &GetToolBox(),
2316 mLastColor );
2318 switch( GetSlotId() )
2320 case SID_ATTR_CHAR_COLOR_BACKGROUND :
2321 pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
2322 break;
2324 case SID_BACKGROUND_COLOR :
2325 pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
2326 break;
2328 case SID_FRAME_LINECOLOR:
2329 pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
2330 break;
2333 pColorWin->StartPopupMode( &GetToolBox(),
2334 FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2335 pColorWin->StartSelection();
2336 SetPopupWindow( pColorWin );
2337 bChoiceFromPalette = sal_True;
2338 return pColorWin;
2341 // -----------------------------------------------------------------------
2343 void SvxColorExtToolBoxControl::StateChanged(
2345 sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
2348 const SvxColorItem* pItem = 0;
2349 if ( bChoiceFromPalette )
2351 bChoiceFromPalette = sal_False;
2352 switch( nSID )
2354 case SID_ATTR_CHAR_COLOR :
2355 case SID_ATTR_CHAR_COLOR2 :
2356 case SID_ATTR_CHAR_COLOR_BACKGROUND :
2357 case SID_BACKGROUND_COLOR :
2358 if ( SFX_ITEM_DONTCARE != eState )
2359 pItem = PTR_CAST( SvxColorItem, pState );
2361 if ( pItem )
2363 pBtnUpdater->Update( pItem->GetValue() );
2364 mLastColor = pItem->GetValue();
2366 break;
2368 case SID_FRAME_LINECOLOR :
2369 ToolBox& rTbx = GetToolBox();
2370 rTbx.EnableItem( nSID, SFX_ITEM_DISABLED != eState );
2371 rTbx.SetItemState( nSID, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2373 if ( SFX_ITEM_DONTCARE != eState )
2375 pItem = PTR_CAST( SvxColorItem, pState );
2376 if ( pItem )
2378 pBtnUpdater->Update( pItem->GetValue());
2379 mLastColor = pItem->GetValue();
2382 break;
2387 // -----------------------------------------------------------------------
2389 void SvxColorExtToolBoxControl::Select( sal_Bool )
2391 OUString aCommand;
2392 OUString aParamName;
2393 sal_Bool bNoArgs = sal_False;
2395 switch( GetSlotId() )
2397 case SID_ATTR_CHAR_COLOR2 :
2398 bNoArgs = sal_True;
2399 aCommand = OUString( ".uno:CharColorExt" );
2400 aParamName = OUString( "CharColorExt" );
2401 break;
2403 case SID_ATTR_CHAR_COLOR :
2404 aCommand = OUString( ".uno:Color" );
2405 aParamName = OUString( "Color" );
2406 break;
2408 case SID_BACKGROUND_COLOR :
2409 aCommand = OUString( ".uno:BackgroundColor" );
2410 aParamName = OUString( "BackgroundColor" );
2411 break;
2413 case SID_ATTR_CHAR_COLOR_BACKGROUND :
2414 bNoArgs = sal_True;
2415 aCommand = OUString( ".uno:CharBackgroundExt" );
2416 aParamName = OUString( "CharBackgroundExt" );
2417 break;
2419 case SID_FRAME_LINECOLOR :
2420 aCommand = OUString( ".uno:FrameLineColor" );
2421 aParamName = OUString( "FrameLineColor" );
2422 break;
2425 Sequence< PropertyValue > aArgs( 1 );
2426 aArgs[0].Name = aParamName;
2427 if ( bNoArgs )
2428 aArgs[0].Value = makeAny( GetToolBox().IsItemChecked( GetId() ));
2429 else
2430 aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() ));
2431 Dispatch( aCommand, aArgs );
2434 //========================================================================
2435 // class SvxFrameToolBoxControl ------------------------------------------
2436 //========================================================================
2438 SvxFrameToolBoxControl::SvxFrameToolBoxControl(
2439 sal_uInt16 nSlotId,
2440 sal_uInt16 nId,
2441 ToolBox& rTbx )
2443 : SfxToolBoxControl( nSlotId, nId, rTbx )
2445 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2448 // -----------------------------------------------------------------------
2450 SfxPopupWindowType SvxFrameToolBoxControl::GetPopupWindowType() const
2452 return SFX_POPUPWINDOW_ONCLICK;
2455 // -----------------------------------------------------------------------
2457 SfxPopupWindow* SvxFrameToolBoxControl::CreatePopupWindow()
2459 SvxFrameWindow_Impl* pFrameWin = new SvxFrameWindow_Impl(
2460 GetSlotId(), m_xFrame, &GetToolBox() );
2462 pFrameWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS | FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2463 pFrameWin->StartSelection();
2464 SetPopupWindow( pFrameWin );
2466 return pFrameWin;
2469 // -----------------------------------------------------------------------
2471 void SvxFrameToolBoxControl::StateChanged(
2473 sal_uInt16, SfxItemState eState, const SfxPoolItem* )
2476 sal_uInt16 nId = GetId();
2477 ToolBox& rTbx = GetToolBox();
2479 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2480 rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
2481 ? STATE_DONTKNOW
2482 : STATE_NOCHECK );
2485 //========================================================================
2486 // class SvxFrameLineStyleToolBoxControl ---------------------------------
2487 //========================================================================
2489 SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
2490 sal_uInt16 nSlotId,
2491 sal_uInt16 nId,
2492 ToolBox& rTbx )
2494 : SfxToolBoxControl( nSlotId, nId, rTbx )
2496 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2499 // -----------------------------------------------------------------------
2501 SfxPopupWindowType SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const
2503 return SFX_POPUPWINDOW_ONCLICK;
2506 // -----------------------------------------------------------------------
2508 SfxPopupWindow* SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
2510 SvxLineWindow_Impl* pLineWin = new SvxLineWindow_Impl( GetSlotId(), m_xFrame, &GetToolBox() );
2511 pLineWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS | FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2512 SetPopupWindow( pLineWin );
2514 return pLineWin;
2517 // -----------------------------------------------------------------------
2519 void SvxFrameLineStyleToolBoxControl::StateChanged(
2521 sal_uInt16 , SfxItemState eState, const SfxPoolItem* )
2523 sal_uInt16 nId = GetId();
2524 ToolBox& rTbx = GetToolBox();
2526 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2527 rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
2528 ? STATE_DONTKNOW
2529 : STATE_NOCHECK );
2532 //========================================================================
2533 // class SvxFrameLineColorToolBoxControl ---------------------------------
2534 //========================================================================
2536 SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
2537 sal_uInt16 nSlotId,
2538 sal_uInt16 nId,
2539 ToolBox& rTbx ) :
2541 SfxToolBoxControl( nSlotId, nId, rTbx ),
2542 pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() )),
2543 mLastColor( COL_AUTO )
2545 rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2548 // -----------------------------------------------------------------------
2550 SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl()
2553 delete pBtnUpdater;
2556 // -----------------------------------------------------------------------
2558 SfxPopupWindowType SvxFrameLineColorToolBoxControl::GetPopupWindowType() const
2560 return SFX_POPUPWINDOW_ONCLICK;
2563 // -----------------------------------------------------------------------
2565 SfxPopupWindow* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
2567 SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
2568 OUString( ".uno:FrameLineColor" ),
2569 SID_FRAME_LINECOLOR,
2570 m_xFrame,
2571 SVX_RESSTR(RID_SVXSTR_FRAME_COLOR),
2572 &GetToolBox(),
2573 mLastColor);
2575 pColorWin->StartPopupMode( &GetToolBox(),
2576 FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
2577 pColorWin->StartSelection();
2578 SetPopupWindow( pColorWin );
2579 return pColorWin;
2582 // -----------------------------------------------------------------------
2584 void SvxFrameLineColorToolBoxControl::StateChanged(
2585 sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2587 sal_uInt16 nId = GetId();
2588 ToolBox& rTbx = GetToolBox();
2589 rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2590 rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2592 const SvxColorItem* pItem = 0;
2593 if ( SFX_ITEM_DONTCARE != eState )
2595 pItem = PTR_CAST( SvxColorItem, pState );
2596 if ( pItem )
2598 pBtnUpdater->Update( pItem->GetValue());
2599 mLastColor = pItem->GetValue();
2604 //========================================================================
2605 // class SvxSimpleUndoRedoController -------------------------------------
2606 //========================================================================
2608 SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
2609 :SfxToolBoxControl( nSlotId, nId, rTbx )
2611 aDefaultText = rTbx.GetItemText( nId );
2614 // -----------------------------------------------------------------------
2616 SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController()
2620 // -----------------------------------------------------------------------
2622 void SvxSimpleUndoRedoController::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
2624 SfxStringItem* pItem = PTR_CAST( SfxStringItem, pState );
2625 ToolBox& rBox = GetToolBox();
2626 if ( pItem && eState != SFX_ITEM_DISABLED )
2628 ::rtl::OUString aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem->GetValue() ) );
2629 rBox.SetQuickHelpText( GetId(), aNewText );
2631 if ( eState == SFX_ITEM_DISABLED )
2632 rBox.SetQuickHelpText( GetId(), aDefaultText );
2633 rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
2636 //========================================================================
2638 void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet )
2640 Size aSize = rWin.GetOutputSizePixel();
2641 aSize.Width() -= 4;
2642 aSize.Height() -= 4;
2643 rValueSet.SetPosSizePixel( Point(2,2), aSize );
2646 // -----------------------------------------------------------------------
2648 void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize )
2650 Size aSize = rValueSet.CalcWindowSizePixel( aItemSize );
2651 aSize.Width() += 4;
2652 aSize.Height() += 4;
2653 rWin.SetOutputSizePixel( aSize );
2656 // -----------------------------------------------------------------------------
2657 Reference< ::com::sun::star::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
2659 FillList();
2660 return FontNameBox::CreateAccessible();
2663 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */