1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tbcontrl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
37 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
38 #include <tools/shl.hxx>
39 #include <svtools/poolitem.hxx>
40 #include <svtools/eitem.hxx>
41 #include <vcl/toolbox.hxx>
42 #include <vcl/bmpacc.hxx>
43 #include <svtools/valueset.hxx>
44 #include <svtools/ctrlbox.hxx>
45 #include <svtools/style.hxx>
46 #include <svtools/ctrltool.hxx>
47 #include <svtools/stritem.hxx>
48 #include <svtools/pathoptions.hxx>
49 #include <sfx2/tplpitem.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/viewsh.hxx>
52 #include <sfx2/objsh.hxx>
53 #include <sfx2/docfac.hxx>
54 #include <sfx2/templdlg.hxx>
55 #include <svtools/isethint.hxx>
56 #include <sfx2/querystatus.hxx>
57 #include <sfx2/sfxstatuslistener.hxx>
58 #include <tools/urlobj.hxx>
59 #include <sfx2/childwin.hxx>
60 #include <sfx2/viewfrm.hxx>
61 #include <svtools/fontoptions.hxx>
62 #ifndef _VCL_MNEMONIC_HXX_
63 #include <vcl/mnemonic.hxx>
66 #include <vcl/svapp.hxx>
67 #include <svtools/smplhint.hxx>
69 #define _SVX_TBCONTRL_CXX
70 #include <svtools/colorcfg.hxx>
71 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
72 #include <com/sun/star/lang/XServiceInfo.hpp>
73 #include <com/sun/star/beans/XPropertySet.hpp>
74 #include <com/sun/star/frame/status/ItemStatus.hpp>
75 #include <com/sun/star/frame/status/FontHeight.hpp>
77 #include <svx/dialogs.hrc>
78 #include <svx/svxitems.hrc>
80 #include "htmlmode.hxx"
81 #include <svx/xtable.hxx>
82 #include "fontitem.hxx"
83 #include <svx/fhgtitem.hxx>
84 #include <svx/brshitem.hxx>
85 #include <svx/boxitem.hxx>
86 #include <svx/colritem.hxx>
87 #include "flstitem.hxx"
88 #include "bolnitem.hxx"
89 #include "drawitem.hxx"
90 #include <svx/tbcontrl.hxx>
91 #include "dlgutil.hxx"
92 #include <svx/dialmgr.hxx>
93 #include "colorwindow.hxx"
96 #include <svx/tbxcolorupdate.hxx>
98 // ------------------------------------------------------------------------
100 #define MAX_MRU_FONTNAME_ENTRIES 5
101 #define LOGICAL_EDIT_HEIGHT 12
103 // STATIC DATA -----------------------------------------------------------
106 #define DELETEZ(p) (delete (p), (p)=NULL)
108 // don't make more than 15 entries visible at once
109 #define MAX_STYLES_ENTRIES static_cast< USHORT >( 15 )
111 void lcl_ResizeValueSet( Window
&rWin
, ValueSet
&rValueSet
);
112 void lcl_CalcSizeValueSet( Window
&rWin
, ValueSet
&rValueSet
, const Size
&aItemSize
);
113 BOOL
lcl_FontChangedHint( const SfxHint
&rHint
);
116 using ::rtl::OUString
;
117 using namespace ::com::sun::star
;
118 using namespace ::com::sun::star::uno
;
119 using namespace ::com::sun::star::frame
;
120 using namespace ::com::sun::star::util
;
121 using namespace ::com::sun::star::beans
;
122 using namespace ::com::sun::star::lang
;
124 SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl
, SfxTemplateItem
);
125 SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl
, SvxFontItem
);
126 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl
, SvxColorItem
);
127 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorExtToolBoxControl
, SvxColorItem
);
128 SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl
, SvxColorItem
);
129 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl
, SvxBoxItem
);
130 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl
, SvxLineItem
);
131 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl
, SvxColorItem
);
132 SFX_IMPL_TOOLBOX_CONTROL( SvxReloadControllerItem
, SfxBoolItem
);
133 SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController
, SfxStringItem
);
135 //========================================================================
136 // class SvxStyleBox_Impl -----------------------------------------------------
137 //========================================================================
140 class SvxStyleBox_Impl
: public ComboBox
142 using Window::IsVisible
;
144 SvxStyleBox_Impl( Window
* pParent
, USHORT nSlot
, const OUString
& rCommand
, SfxStyleFamily eFamily
, const Reference
< XDispatchProvider
>& rDispatchProvider
,
145 const Reference
< XFrame
>& _xFrame
,const String
& rClearFormatKey
, const String
& rMoreKey
, BOOL bInSpecialMode
);
148 void SetFamily( SfxStyleFamily eNewFamily
);
149 inline BOOL
IsVisible() { return bVisible
; }
151 virtual long PreNotify( NotifyEvent
& rNEvt
);
152 virtual long Notify( NotifyEvent
& rNEvt
);
153 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
154 virtual void StateChanged( StateChangedType nStateChange
);
156 inline void SetVisibilityListener( const Link
& aVisListener
) { aVisibilityListener
= aVisListener
; }
157 inline void RemoveVisibilityListener() { aVisibilityListener
= Link(); }
159 void SetDefaultStyle( const ::rtl::OUString
& rDefault
) { sDefaultStyle
= rDefault
; }
160 DECL_STATIC_LINK( SvxStyleBox_Impl
, FocusHdl_Impl
, Control
* );
163 virtual void Select();
167 SfxStyleFamily eStyleFamily
;
171 Link aVisibilityListener
;
173 Reference
< XDispatchProvider
> m_xDispatchProvider
;
174 Reference
< XFrame
> m_xFrame
;
176 String aClearFormatKey
;
178 String sDefaultStyle
;
184 //========================================================================
185 // class SvxFontNameBox --------------------------------------------------
186 //========================================================================
188 class SvxFontNameBox_Impl
: public FontNameBox
190 using Window::Update
;
192 const FontList
* pFontList
;
193 ::std::auto_ptr
<FontList
> m_aOwnFontList
;
199 Reference
< XDispatchProvider
> m_xDispatchProvider
;
200 Reference
< XFrame
> m_xFrame
;
202 void ReleaseFocus_Impl();
203 void EnableControls_Impl();
206 virtual void Select();
207 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
210 SvxFontNameBox_Impl( Window
* pParent
, const Reference
< XDispatchProvider
>& rDispatchProvider
,const Reference
< XFrame
>& _xFrame
211 , WinBits nStyle
= WB_SORT
215 void Update( const SvxFontItem
* pFontItem
);
216 USHORT
GetListCount() { return nFtCount
; }
217 void Clear() { FontNameBox::Clear(); nFtCount
= 0; }
218 void Fill( const FontList
* pList
)
219 { FontNameBox::Fill( pList
);
220 nFtCount
= pList
->GetFontNameCount(); }
221 virtual long PreNotify( NotifyEvent
& rNEvt
);
222 virtual long Notify( NotifyEvent
& rNEvt
);
223 virtual Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
224 inline void SetOwnFontList(::std::auto_ptr
<FontList
> _aOwnFontList
) { m_aOwnFontList
= _aOwnFontList
; }
227 //========================================================================
228 // class SvxFrameWindow_Impl --------------------------------------------------
229 //========================================================================
231 // fuer den SelectHdl werden die Modifier gebraucht, also
232 // muss man sie im MouseButtonUp besorgen
234 class SvxFrmValueSet_Impl
: public ValueSet
237 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
239 SvxFrmValueSet_Impl(Window
* pParent
, WinBits nWinStyle
)
240 : ValueSet(pParent
, nWinStyle
), nModifier(0) {}
241 USHORT
GetModifier() const {return nModifier
;}
245 void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent
& rMEvt
)
247 nModifier
= rMEvt
.GetModifier();
248 ValueSet::MouseButtonUp(rMEvt
);
251 class SvxFrameWindow_Impl
: public SfxPopupWindow
253 using FloatingWindow::StateChanged
;
256 SvxFrmValueSet_Impl aFrameSet
;
258 sal_Bool bParagraphMode
;
261 DECL_LINK( SelectHdl
, void * );
265 virtual void Resize();
266 virtual BOOL
Close();
267 virtual Window
* GetPreferredKeyInputWindow();
268 virtual void GetFocus();
271 SvxFrameWindow_Impl( USHORT nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
);
272 ~SvxFrameWindow_Impl();
273 void StartSelection();
275 virtual void StateChanged( USHORT nSID
, SfxItemState eState
,
276 const SfxPoolItem
* pState
);
277 virtual SfxPopupWindow
* Clone() const;
278 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
280 inline BOOL
IsHighContrast( void ) const;
283 inline BOOL
SvxFrameWindow_Impl::IsHighContrast( void ) const
285 return GetDisplayBackground().GetColor().IsDark();
288 //========================================================================
289 // class SvxLineWindow_Impl ---------------------------------------------------
290 //========================================================================
291 class SvxLineWindow_Impl
: public SfxPopupWindow
298 void MakeLineBitmap( USHORT nNo
, Bitmap
& rBmp
, const Size
& rSize
, String
& rStr
,
299 const ::Color
& rLine
, const ::Color
& rBack
);
300 DECL_LINK( SelectHdl
, void * );
304 virtual void Resize();
305 virtual BOOL
Close();
306 virtual Window
* GetPreferredKeyInputWindow();
307 virtual void GetFocus();
308 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
309 void CreateBitmaps( void );
311 SvxLineWindow_Impl( USHORT nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
);
313 void StartSelection();
314 virtual SfxPopupWindow
* Clone() const;
317 //########################################################################
319 //========================================================================
320 // class SfxStyleControllerItem ------------------------------------------
321 //========================================================================
322 class SvxStyleToolBoxControl
;
324 class SfxStyleControllerItem_Impl
: public SfxStatusListener
327 SfxStyleControllerItem_Impl( const Reference
< XDispatchProvider
>& rDispatchProvider
,
329 const rtl::OUString
& rCommand
,
330 SvxStyleToolBoxControl
& rTbxCtl
);
333 virtual void StateChanged( USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
);
336 SvxStyleToolBoxControl
& rControl
;
339 //========================================================================
340 // class SvxStyleBox_Impl -----------------------------------------------------
341 //========================================================================
343 SvxStyleBox_Impl::SvxStyleBox_Impl(
346 const rtl::OUString
& rCommand
,
347 SfxStyleFamily eFamily
,
348 const Reference
< XDispatchProvider
>& rDispatchProvider
,
349 const Reference
< XFrame
>& _xFrame
,
350 const String
& rClearFormatKey
,
351 const String
& rMoreKey
,
354 ComboBox( pParent
, SVX_RES( RID_SVXTBX_STYLE
) ),
357 eStyleFamily( eFamily
),
360 m_xDispatchProvider( rDispatchProvider
),
362 m_aCommand ( rCommand
),
363 aClearFormatKey ( rClearFormatKey
),
364 aMoreKey ( rMoreKey
),
365 bInSpecialMode ( bInSpec
)
367 aLogicalSize
= PixelToLogic( GetSizePixel(), MAP_APPFONT
);
368 EnableAutocomplete( TRUE
);
371 SvxStyleBox_Impl::~SvxStyleBox_Impl()
375 // -----------------------------------------------------------------------
377 void SvxStyleBox_Impl::ReleaseFocus()
384 if ( m_xFrame
.is() && m_xFrame
->getContainerWindow().is() )
385 m_xFrame
->getContainerWindow()->setFocus();
388 // -----------------------------------------------------------------------
390 void SvxStyleBox_Impl::Select()
392 // Tell base class about selection so that AT get informed about it.
395 if ( !IsTravelSelect() )
397 String
aSelEntry( GetText() );
398 bool bDoIt
= true, bClear
= false;
401 if( aSelEntry
== aClearFormatKey
&& GetSelectEntryPos() == 0 )
403 aSelEntry
= sDefaultStyle
;
405 //not only apply default style but also call 'ClearFormatting'
406 Sequence
< PropertyValue
> aEmptyVals
;
407 SfxToolBoxControl::Dispatch( m_xDispatchProvider
, String::CreateFromAscii(".uno:ResetAttributes"),
410 else if( aSelEntry
== aMoreKey
&& GetSelectEntryPos() == ( GetEntryCount() - 1 ) )
412 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
413 DBG_ASSERT( pViewFrm
, "SvxStyleBox_Impl::Select(): no viewframe" );
414 pViewFrm
->ShowChildWindow( SID_STYLE_DESIGNER
);
415 SfxChildWindow
* pChildWin
= pViewFrm
->GetChildWindow( SID_STYLE_DESIGNER
);
416 if ( pChildWin
&& pChildWin
->GetWindow() )
418 static_cast< SfxTemplateDialogWrapper
* >( pChildWin
)->SetParagraphFamily();
419 static_cast< SfxDockingWindow
* >( pChildWin
->GetWindow() )->AutoShow( sal_True
);
420 Application::PostUserEvent(
421 STATIC_LINK( 0, SvxStyleBox_Impl
, FocusHdl_Impl
), pChildWin
->GetWindow() );
427 // #i36723# after ReleaseFocus() the new entry is included into the List
428 sal_Bool bCreateNew
= GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND
;
430 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
431 This instance may be deleted in the meantime (i.e. when a dialog is opened
432 while in Dispatch()), accessing members will crash in this case. */
438 SetText( aSelEntry
);
441 Sequence
< PropertyValue
> aArgs( 2 );
442 aArgs
[0].Value
= makeAny( OUString( aSelEntry
) );
443 aArgs
[1].Name
= OUString::createFromAscii( "Family" );
444 aArgs
[1].Value
= makeAny( sal_Int16( eStyleFamily
));
447 aArgs
[0].Name
= OUString::createFromAscii( "Param" );
448 SfxToolBoxControl::Dispatch( m_xDispatchProvider
, String::CreateFromAscii(".uno:StyleNewByExample"), aArgs
);
452 aArgs
[0].Name
= OUString::createFromAscii( "Template" );
453 SfxToolBoxControl::Dispatch( m_xDispatchProvider
, m_aCommand
, aArgs
);
458 // -----------------------------------------------------------------------
460 void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily
)
462 eStyleFamily
= eNewFamily
;
465 // -----------------------------------------------------------------------
467 long SvxStyleBox_Impl::PreNotify( NotifyEvent
& rNEvt
)
469 USHORT nType
= rNEvt
.GetType();
471 if ( EVENT_MOUSEBUTTONDOWN
== nType
|| EVENT_GETFOCUS
== nType
)
472 nCurSel
= GetSelectEntryPos();
473 else if ( EVENT_LOSEFOCUS
== nType
)
475 // don't handle before our Select() is called
476 if ( !HasFocus() && !HasChildPathFocus() )
477 SetText( GetSavedValue() );
479 return ComboBox::PreNotify( rNEvt
);
482 // -----------------------------------------------------------------------
484 long SvxStyleBox_Impl::Notify( NotifyEvent
& rNEvt
)
488 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
490 USHORT nCode
= rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
497 if ( KEY_TAB
== nCode
)
506 SelectEntryPos( nCurSel
);
512 return nHandled
? nHandled
: ComboBox::Notify( rNEvt
);
514 /* -----------------------------08.03.2002 13:03------------------------------
516 ---------------------------------------------------------------------------*/
517 void SvxStyleBox_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
519 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
520 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
522 SetSizePixel(LogicToPixel(aLogicalSize
, MAP_APPFONT
));
523 Size
aDropSize( aLogicalSize
.Width(), LOGICAL_EDIT_HEIGHT
);
524 SetDropDownSizePixel(LogicToPixel(aDropSize
, MAP_APPFONT
));
527 ComboBox::DataChanged( rDCEvt
);
530 void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange
)
532 ComboBox::StateChanged( nStateChange
);
534 if ( nStateChange
== STATE_CHANGE_VISIBLE
)
536 bVisible
= IsReallyVisible();
537 if ( aVisibilityListener
.IsSet() )
538 aVisibilityListener
.Call( this );
540 else if ( nStateChange
== STATE_CHANGE_INITSHOW
)
543 if ( aVisibilityListener
.IsSet() )
544 aVisibilityListener
.Call( this );
548 //--------------------------------------------------------------------
550 IMPL_STATIC_LINK( SvxStyleBox_Impl
, FocusHdl_Impl
, Control
*, _pCtrl
)
558 // -----------------------------------------------------------------------
560 BOOL
GetDocFontList_Impl( const FontList
** ppFontList
, SvxFontNameBox_Impl
* pBox
)
562 BOOL bChanged
= FALSE
;
563 const SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
564 SvxFontListItem
* pFontListItem
= NULL
;
568 (SvxFontListItem
*)pDocSh
->GetItem( SID_ATTR_CHAR_FONTLIST
);
571 ::std::auto_ptr
<FontList
> aFontList(new FontList( pBox
));
572 *ppFontList
= aFontList
.get();
573 pBox
->SetOwnFontList(aFontList
);
579 const FontList
* pNewFontList
= pFontListItem
->GetFontList();
580 DBG_ASSERT( pNewFontList
, "Doc-FontList not available!" );
582 // keine alte Liste, aber neue Liste
583 if ( !*ppFontList
&& pNewFontList
)
586 *ppFontList
= pNewFontList
;
591 // Vergleich der Fontlisten ist nicht vollkommen
592 // wird die Fontliste am Doc geaendert, kann man hier
593 // nur ueber die Listbox Aenderungen feststellen, weil
594 // ppFontList dabei schon upgedatet wurde
596 ( ( *ppFontList
!= pNewFontList
) ||
597 pBox
->GetListCount() != pNewFontList
->GetFontNameCount() );
598 HACK(vergleich ist unvollstaendig
)
601 *ppFontList
= pNewFontList
;
607 else if ( pBox
&& ( pDocSh
|| ( !pDocSh
&& !ppFontList
)))
609 // Disable box only when we have a SfxObjectShell and didn't get a font list OR
610 // we don't have a SfxObjectShell and no current font list.
611 // It's possible that we currently have no SfxObjectShell, but a current font list.
612 // See #i58471: When a user set the focus into the font name combo box and opens
613 // the help window with F1. After closing the help window, we disable the font name
614 // combo box. The SfxObjectShell::Current() method returns in that case zero. But the
615 // font list hasn't changed and therefore the combo box shouldn't be disabled!
619 // in die FontBox ggf. auch die neue Liste f"ullen
620 if ( pBox
&& bChanged
)
623 pBox
->Fill( *ppFontList
);
630 //========================================================================
631 // class SvxFontNameBox_Impl --------------------------------------------------
632 //========================================================================
634 SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window
* pParent
, const Reference
< XDispatchProvider
>& rDispatchProvider
,const Reference
< XFrame
>& _xFrame
, WinBits nStyle
) :
636 FontNameBox ( pParent
, nStyle
| WinBits( WB_DROPDOWN
| WB_AUTOHSCROLL
) ),
638 aLogicalSize ( 75,160 ),
641 m_xDispatchProvider( rDispatchProvider
),
644 SetSizePixel(LogicToPixel( aLogicalSize
, MAP_APPFONT
));
645 EnableControls_Impl();
647 // -----------------------------------------------------------------------
649 void SvxFontNameBox_Impl::FillList()
651 // alte Selektion merken, und am Ende wieder setzen
652 Selection aOldSel
= GetSelection();
653 // hat sich Doc-Fontlist geaendert?
654 GetDocFontList_Impl( &pFontList
, this );
655 aCurText
= GetText();
656 SetSelection( aOldSel
);
659 // -----------------------------------------------------------------------
661 void SvxFontNameBox_Impl::Update( const SvxFontItem
* pFontItem
)
665 aCurFont
.SetName ( pFontItem
->GetFamilyName() );
666 aCurFont
.SetFamily ( pFontItem
->GetFamily() );
667 aCurFont
.SetStyleName ( pFontItem
->GetStyleName() );
668 aCurFont
.SetPitch ( pFontItem
->GetPitch() );
669 aCurFont
.SetCharSet ( pFontItem
->GetCharSet() );
671 String aCurName
= aCurFont
.GetName();
672 if ( GetText() != aCurName
)
676 // -----------------------------------------------------------------------
678 long SvxFontNameBox_Impl::PreNotify( NotifyEvent
& rNEvt
)
680 USHORT nType
= rNEvt
.GetType();
682 if ( EVENT_MOUSEBUTTONDOWN
== nType
|| EVENT_GETFOCUS
== nType
)
684 EnableControls_Impl();
687 return FontNameBox::PreNotify( rNEvt
);
690 // -----------------------------------------------------------------------
692 long SvxFontNameBox_Impl::Notify( NotifyEvent
& rNEvt
)
696 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
698 USHORT nCode
= rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
705 if ( KEY_TAB
== nCode
)
719 else if ( EVENT_LOSEFOCUS
== rNEvt
.GetType() )
721 Window
* pFocusWin
= Application::GetFocusWindow();
722 if ( !HasFocus() && GetSubEdit() != pFocusWin
)
723 SetText( GetSavedValue() );
726 return nHandled
? nHandled
: FontNameBox::Notify( rNEvt
);
729 // ---------------------------------------------------------------------------
730 void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
732 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
733 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
735 SetSizePixel(LogicToPixel(aLogicalSize
, MAP_APPFONT
));
736 Size
aDropSize( aLogicalSize
.Width(), LOGICAL_EDIT_HEIGHT
);
737 SetDropDownSizePixel(LogicToPixel(aDropSize
, MAP_APPFONT
));
740 FontNameBox::DataChanged( rDCEvt
);
743 // -----------------------------------------------------------------------
745 void SvxFontNameBox_Impl::ReleaseFocus_Impl()
752 if ( m_xFrame
.is() && m_xFrame
->getContainerWindow().is() )
753 m_xFrame
->getContainerWindow()->setFocus();
756 // -----------------------------------------------------------------------
758 void SvxFontNameBox_Impl::EnableControls_Impl()
760 SvtFontOptions aFontOpt
;
761 BOOL bEnable
= aFontOpt
.IsFontHistoryEnabled();
762 USHORT nEntries
= bEnable
? MAX_MRU_FONTNAME_ENTRIES
: 0;
763 if ( GetMaxMRUCount() != nEntries
)
765 // refill in the next GetFocus-Handler
768 SetMaxMRUCount( nEntries
);
771 bEnable
= aFontOpt
.IsFontWYSIWYGEnabled();
772 EnableWYSIWYG( bEnable
);
773 EnableSymbols( bEnable
);
776 // -----------------------------------------------------------------------
778 void SvxFontNameBox_Impl::Select()
780 FontNameBox::Select();
782 if ( !IsTravelSelect() )
786 FontInfo
aInfo( pFontList
->Get( GetText(),
787 aCurFont
.GetWeight(),
788 aCurFont
.GetItalic() ) );
791 SvxFontItem
aFontItem( aInfo
.GetFamily(),
793 aInfo
.GetStyleName(),
796 SID_ATTR_CHAR_FONT
);
799 Sequence
< PropertyValue
> aArgs( 1 );
800 aArgs
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ));
801 aFontItem
.QueryValue( a
);
804 // #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
805 // This instance may be deleted in the meantime (i.e. when a dialog is opened
806 // while in Dispatch()), accessing members will crash in this case.
809 SfxToolBoxControl::Dispatch( m_xDispatchProvider
,
810 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )),
818 //========================================================================
819 // class SvxColorWindow_Impl --------------------------------------------------
820 //========================================================================
821 #ifndef WB_NO_DIRECTSELECT
822 #define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
827 #define PALETTE_SIZE (PALETTE_X * PALETTE_Y)
829 SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString
& rCommand
,
831 const Reference
< XFrame
>& rFrame
,
832 const String
& rWndTitle
,
833 Window
* pParentWindow
) :
835 SfxPopupWindow( nSlotId
, rFrame
, pParentWindow
, WinBits( WB_BORDER
| WB_STDFLOATWIN
| WB_3DLOOK
|WB_DIALOGCONTROL
) ),
837 theSlotId( nSlotId
),
838 aColorSet( this, WinBits( WB_ITEMBORDER
| WB_NAMEFIELD
| WB_3DLOOK
| WB_NO_DIRECTSELECT
) ),
839 maCommand( rCommand
)
842 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
843 const SfxPoolItem
* pItem
= NULL
;
844 XColorTable
* pColorTable
= NULL
;
845 BOOL bKillTable
= FALSE
;
846 const Size
aSize12( 13, 13 );
849 if ( 0 != ( pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
) ) )
850 pColorTable
= ( (SvxColorTableItem
*)pItem
)->GetColorTable();
854 pColorTable
= new XColorTable( SvtPathOptions().GetPalettePath() );
858 if ( SID_ATTR_CHAR_COLOR_BACKGROUND
== theSlotId
|| SID_BACKGROUND_COLOR
== theSlotId
)
860 aColorSet
.SetStyle( aColorSet
.GetStyle() | WB_NONEFIELD
);
861 aColorSet
.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT
) );
863 else if ( SID_ATTR_CHAR_COLOR
== theSlotId
|| SID_ATTR_CHAR_COLOR2
== theSlotId
|| SID_EXTRUSION_3D_COLOR
== theSlotId
)
867 Reference
< XDispatchProvider
> aDisp( GetFrame()->getController(), UNO_QUERY
);
868 SfxQueryStatus
aQueryStatus( aDisp
,
869 SID_ATTR_AUTO_COLOR_INVALID
,
870 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoColorInvalid" )));
871 SfxItemState eState
= aQueryStatus
.QueryState( pDummy
);
872 if( (SFX_ITEM_DEFAULT
> eState
) || ( SID_EXTRUSION_3D_COLOR
== theSlotId
) )
874 aColorSet
.SetStyle( aColorSet
.GetStyle() | WB_NONEFIELD
);
875 aColorSet
.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC
) );
882 long nCount
= pColorTable
->Count();
883 XColorEntry
* pEntry
= NULL
;
884 ::Color
aColWhite( COL_WHITE
);
885 String
aStrWhite( SVX_RES(RID_SVXITEMS_COLOR_WHITE
) );
887 if ( nCount
> PALETTE_SIZE
)
888 // Show scrollbar if more than PALLETTE_SIZE colors are available
889 aColorSet
.SetStyle( aColorSet
.GetStyle() | WB_VSCROLL
);
891 for ( i
= 0; i
< nCount
; i
++ )
893 pEntry
= pColorTable
->GetColor(i
);
894 aColorSet
.InsertItem( i
+1, pEntry
->GetColor(), pEntry
->GetName() );
897 while ( i
< PALETTE_SIZE
)
899 // fill empty elements if less then PALLETTE_SIZE colors are available
900 aColorSet
.InsertItem( i
+1, aColWhite
, aStrWhite
);
905 aColorSet
.SetSelectHdl( LINK( this, SvxColorWindow_Impl
, SelectHdl
) );
906 aColorSet
.SetColCount( PALETTE_X
);
907 aColorSet
.SetLineCount( PALETTE_Y
);
909 lcl_CalcSizeValueSet( *this, aColorSet
, aSize12
);
911 SetHelpId( HID_POPUP_COLOR
);
912 aColorSet
.SetHelpId( HID_POPUP_COLOR_CTRL
);
914 SetText( rWndTitle
);
917 AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
922 SvxColorWindow_Impl::~SvxColorWindow_Impl()
926 void SvxColorWindow_Impl::KeyInput( const KeyEvent
& rKEvt
)
928 aColorSet
.KeyInput(rKEvt
);
931 SfxPopupWindow
* SvxColorWindow_Impl::Clone() const
933 return new SvxColorWindow_Impl( maCommand
, theSlotId
, GetFrame(), GetText(), GetParent() );
936 // -----------------------------------------------------------------------
938 IMPL_LINK( SvxColorWindow_Impl
, SelectHdl
, void *, EMPTYARG
)
940 USHORT nItemId
= aColorSet
.GetSelectItemId();
941 SvxColorItem
aColorItem( aColorSet
.GetItemColor( nItemId
), theSlotId
);
943 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
944 This instance may be deleted in the meantime (i.e. when a dialog is opened
945 while in Dispatch()), accessing members will crash in this case. */
946 aColorSet
.SetNoSelection();
948 if ( IsInPopupMode() )
951 if ( !nItemId
&& ( SID_ATTR_CHAR_COLOR_BACKGROUND
== theSlotId
|| SID_BACKGROUND_COLOR
== theSlotId
) )
953 Sequence
< PropertyValue
> aArgs
;
954 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
958 else if ( !nItemId
&& (SID_ATTR_CHAR_COLOR
== theSlotId
|| SID_ATTR_CHAR_COLOR2
== theSlotId
|| SID_EXTRUSION_3D_COLOR
== theSlotId
) )
960 SvxColorItem
_aColorItem( COL_AUTO
, theSlotId
);
961 INetURLObject
aObj( maCommand
);
964 Sequence
< PropertyValue
> aArgs( 1 );
965 aArgs
[0].Name
= aObj
.GetURLPath();
966 _aColorItem
.QueryValue( a
);
968 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
974 INetURLObject
aObj( maCommand
);
977 Sequence
< PropertyValue
> aArgs( 1 );
978 aArgs
[0].Name
= aObj
.GetURLPath();
979 aColorItem
.QueryValue( a
);
981 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
989 // -----------------------------------------------------------------------
991 void SvxColorWindow_Impl::Resize()
993 lcl_ResizeValueSet( *this, aColorSet
);
996 // -----------------------------------------------------------------------
998 void SvxColorWindow_Impl::StartSelection()
1000 aColorSet
.StartSelection();
1003 // -----------------------------------------------------------------------
1005 BOOL
SvxColorWindow_Impl::Close()
1007 return SfxPopupWindow::Close();
1010 // -----------------------------------------------------------------------
1012 void SvxColorWindow_Impl::StateChanged( USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
1014 if (( SFX_ITEM_DISABLED
!= eState
) && pState
)
1016 if (( nSID
== SID_COLOR_TABLE
) && ( pState
->ISA( SvxColorTableItem
)))
1018 XColorTable
* pColorTable
= pState
? ((SvxColorTableItem
*)pState
)->GetColorTable() : NULL
;
1022 // Die Liste der Farben (ColorTable) hat sich ge"andert:
1024 long nCount
= pColorTable
->Count();
1025 XColorEntry
* pEntry
= NULL
;
1026 ::Color
aColWhite( COL_WHITE
);
1027 String
aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE
) );
1029 // ScrollBar an oder aus
1030 WinBits nBits
= aColorSet
.GetStyle();
1031 if ( nCount
> PALETTE_SIZE
)
1032 nBits
&= ~WB_VSCROLL
;
1034 nBits
|= WB_VSCROLL
;
1035 aColorSet
.SetStyle( nBits
);
1037 for ( i
= 0; i
< nCount
; ++i
)
1039 pEntry
= pColorTable
->GetColor(i
);
1040 aColorSet
.SetItemColor( i
+ 1, pEntry
->GetColor() );
1041 aColorSet
.SetItemText ( i
+ 1, pEntry
->GetName() );
1044 while ( i
< PALETTE_SIZE
)
1046 aColorSet
.SetItemColor( i
+ 1, aColWhite
);
1047 aColorSet
.SetItemText ( i
+ 1, aStrWhite
);
1055 //========================================================================
1056 // class SvxFrameWindow_Impl --------------------------------------------------
1057 //========================================================================
1059 SvxFrameWindow_Impl::SvxFrameWindow_Impl( USHORT nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
) :
1061 SfxPopupWindow( nId
, rFrame
, pParentWindow
, WinBits( WB_BORDER
| WB_STDFLOATWIN
| WB_3DLOOK
| WB_DIALOGCONTROL
) ),
1062 aFrameSet ( this, WinBits( WB_ITEMBORDER
| WB_DOUBLEBORDER
| WB_3DLOOK
| WB_NO_DIRECTSELECT
) ),
1063 bParagraphMode(sal_False
)
1067 String
sCommand(String::CreateFromAscii( ".uno:BorderReducedMode" ));
1068 AddStatusListener( sCommand
);
1069 aImgList
= ImageList( SVX_RES( IsHighContrast()? RID_SVXIL_FRAME_HC
: RID_SVXIL_FRAME
) );
1073 * -------------------------------------
1074 * NONE LEFT RIGHT LEFTRIGHT
1075 * TOP BOTTOM TOPBOTTOM OUTER
1076 * -------------------------------------
1077 * HOR HORINNER VERINNER ALL <- kann ueber bParagraphMode
1078 * abgeschaltet werden
1083 for ( i
=1; i
<9; i
++ )
1084 aFrameSet
.InsertItem( i
, aImgList
.GetImage(i
) );
1086 //bParagraphMode should have been set in StateChanged
1087 if ( !bParagraphMode
)
1088 for ( i
= 9; i
< 13; i
++ )
1089 aFrameSet
.InsertItem( i
, aImgList
.GetImage(i
) );
1091 aFrameSet
.SetColCount( 4 );
1092 aFrameSet
.SetSelectHdl( LINK( this, SvxFrameWindow_Impl
, SelectHdl
) );
1094 lcl_CalcSizeValueSet( *this, aFrameSet
,Size( 20, 20 ));
1096 SetHelpId( HID_POPUP_FRAME
);
1097 SetText( SVX_RESSTR(RID_SVXSTR_FRAME
) );
1100 /*-- 22.09.2004 12:27:50---------------------------------------------------
1102 -----------------------------------------------------------------------*/
1103 SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
1108 SfxPopupWindow
* SvxFrameWindow_Impl::Clone() const
1110 //! HACK: wie bekomme ich den Paragraph-Mode ??
1111 return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() );
1114 Window
* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
1119 void SvxFrameWindow_Impl::GetFocus()
1121 aFrameSet
.GrabFocus();
1124 void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
1126 SfxPopupWindow::DataChanged( rDCEvt
);
1128 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1130 aImgList
= ImageList( SVX_RES( IsHighContrast()? RID_SVXIL_FRAME_HC
: RID_SVXIL_FRAME
) );
1132 USHORT nNumOfItems
= aFrameSet
.GetItemCount();
1134 for( USHORT i
= 1 ; i
<= nNumOfItems
; ++i
)
1135 aFrameSet
.SetItemImage( i
, aImgList
.GetImage( i
) );
1138 // -----------------------------------------------------------------------
1140 #define FRM_VALID_LEFT 0x01
1141 #define FRM_VALID_RIGHT 0x02
1142 #define FRM_VALID_TOP 0x04
1143 #define FRM_VALID_BOTTOM 0x08
1144 #define FRM_VALID_HINNER 0x10
1145 #define FRM_VALID_VINNER 0x20
1146 #define FRM_VALID_OUTER 0x0f
1147 #define FRM_VALID_ALL 0xff
1150 // Per default bleiben ungesetzte Linien unveraendert
1151 // Mit Shift werden ungesetzte Linien zurueckgsetzt
1153 IMPL_LINK( SvxFrameWindow_Impl
, SelectHdl
, void *, EMPTYARG
)
1155 ::Color
aColBlack( COL_BLACK
);
1156 SvxBoxItem
aBorderOuter( SID_ATTR_BORDER_OUTER
);
1157 SvxBoxInfoItem
aBorderInner( SID_ATTR_BORDER_INNER
);
1158 SvxBorderLine theDefLine
;
1159 SvxBorderLine
*pLeft
= 0,
1163 USHORT nSel
= aFrameSet
.GetSelectItemId();
1164 USHORT nModifier
= aFrameSet
.GetModifier();
1165 BYTE nValidFlags
= 0;
1167 theDefLine
.SetOutWidth( DEF_LINE_WIDTH_0
);
1170 case 1: nValidFlags
|= FRM_VALID_ALL
;
1172 case 2: pLeft
= &theDefLine
;
1173 nValidFlags
|= FRM_VALID_LEFT
;
1175 case 3: pRight
= &theDefLine
;
1176 nValidFlags
|= FRM_VALID_RIGHT
;
1178 case 4: pLeft
= pRight
= &theDefLine
;
1179 nValidFlags
|= FRM_VALID_RIGHT
|FRM_VALID_LEFT
;
1181 case 5: pTop
= &theDefLine
;
1182 nValidFlags
|= FRM_VALID_TOP
;
1184 case 6: pBottom
= &theDefLine
;
1185 nValidFlags
|= FRM_VALID_BOTTOM
;
1187 case 7: pTop
= pBottom
= &theDefLine
;
1188 nValidFlags
|= FRM_VALID_BOTTOM
|FRM_VALID_TOP
;
1190 case 8: pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1191 nValidFlags
|= FRM_VALID_OUTER
;
1196 pTop
= pBottom
= &theDefLine
;
1197 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_HORI
);
1198 aBorderInner
.SetLine( NULL
, BOXINFO_LINE_VERT
);
1199 nValidFlags
|= FRM_VALID_HINNER
|FRM_VALID_TOP
|FRM_VALID_BOTTOM
;
1202 case 10: // HORINNER
1203 pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1204 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_HORI
);
1205 aBorderInner
.SetLine( NULL
, BOXINFO_LINE_VERT
);
1206 nValidFlags
|= FRM_VALID_RIGHT
|FRM_VALID_LEFT
|FRM_VALID_HINNER
|FRM_VALID_TOP
|FRM_VALID_BOTTOM
;
1209 case 11: // VERINNER
1210 pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1211 aBorderInner
.SetLine( NULL
, BOXINFO_LINE_HORI
);
1212 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_VERT
);
1213 nValidFlags
|= FRM_VALID_RIGHT
|FRM_VALID_LEFT
|FRM_VALID_VINNER
|FRM_VALID_TOP
|FRM_VALID_BOTTOM
;
1217 pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1218 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_HORI
);
1219 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_VERT
);
1220 nValidFlags
|= FRM_VALID_ALL
;
1226 aBorderOuter
.SetLine( pLeft
, BOX_LINE_LEFT
);
1227 aBorderOuter
.SetLine( pRight
, BOX_LINE_RIGHT
);
1228 aBorderOuter
.SetLine( pTop
, BOX_LINE_TOP
);
1229 aBorderOuter
.SetLine( pBottom
, BOX_LINE_BOTTOM
);
1231 if(nModifier
== KEY_SHIFT
)
1232 nValidFlags
|= FRM_VALID_ALL
;
1233 aBorderInner
.SetValid( VALID_TOP
, 0 != (nValidFlags
&FRM_VALID_TOP
));
1234 aBorderInner
.SetValid( VALID_BOTTOM
, 0 != (nValidFlags
&FRM_VALID_BOTTOM
));
1235 aBorderInner
.SetValid( VALID_LEFT
, 0 != (nValidFlags
&FRM_VALID_LEFT
));
1236 aBorderInner
.SetValid( VALID_RIGHT
, 0 != (nValidFlags
&FRM_VALID_RIGHT
));
1237 aBorderInner
.SetValid( VALID_HORI
, 0 != (nValidFlags
&FRM_VALID_HINNER
));
1238 aBorderInner
.SetValid( VALID_VERT
, 0 != (nValidFlags
&FRM_VALID_VINNER
));
1239 aBorderInner
.SetValid( VALID_DISTANCE
, TRUE
);
1240 aBorderInner
.SetValid( VALID_DISABLE
, FALSE
);
1242 if ( IsInPopupMode() )
1246 Sequence
< PropertyValue
> aArgs( 2 );
1247 aArgs
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "OuterBorder" ));
1248 aBorderOuter
.QueryValue( a
);
1250 aArgs
[1].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "InnerBorder" ));
1251 aBorderInner
.QueryValue( a
);
1254 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1255 This instance may be deleted in the meantime (i.e. when a dialog is opened
1256 while in Dispatch()), accessing members will crash in this case. */
1257 aFrameSet
.SetNoSelection();
1259 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1260 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SetBorderStyle" )),
1265 // -----------------------------------------------------------------------
1267 void SvxFrameWindow_Impl::Resize()
1269 lcl_ResizeValueSet( *this, aFrameSet
);
1272 // -----------------------------------------------------------------------
1274 void SvxFrameWindow_Impl::StateChanged(
1276 USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
1279 if ( pState
&& nSID
== SID_BORDER_REDUCED_MODE
)
1281 const SfxBoolItem
* pItem
= PTR_CAST( SfxBoolItem
, pState
);
1285 bParagraphMode
= (BOOL
)pItem
->GetValue();
1286 //initial calls mustn't insert or remove elements
1287 if(aFrameSet
.GetItemCount())
1289 BOOL bTableMode
= ( aFrameSet
.GetItemCount() == 12 );
1290 BOOL bResize
= FALSE
;
1292 if ( bTableMode
&& bParagraphMode
)
1294 for ( USHORT i
= 9; i
< 13; i
++ )
1295 aFrameSet
.RemoveItem(i
);
1298 else if ( !bTableMode
&& !bParagraphMode
)
1300 for ( USHORT i
= 9; i
< 13; i
++ )
1301 aFrameSet
.InsertItem( i
, aImgList
.GetImage(i
) );
1307 lcl_CalcSizeValueSet( *this, aFrameSet
,Size( 20, 20 ));
1312 SfxPopupWindow::StateChanged( nSID
, eState
, pState
);
1315 // -----------------------------------------------------------------------
1317 void SvxFrameWindow_Impl::StartSelection()
1319 aFrameSet
.StartSelection();
1322 // -----------------------------------------------------------------------
1324 BOOL
SvxFrameWindow_Impl::Close()
1326 return SfxPopupWindow::Close();
1329 //========================================================================
1330 // class SvxLineWindow_Impl --------------------------------------------------
1331 //========================================================================
1333 SvxLineWindow_Impl::SvxLineWindow_Impl( USHORT nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
) :
1335 SfxPopupWindow( nId
, rFrame
, pParentWindow
, WinBits( WB_BORDER
| WB_STDFLOATWIN
| WB_3DLOOK
| WB_DIALOGCONTROL
) ),
1337 aLineSet( this, WinBits( WB_3DLOOK
| WB_ITEMBORDER
| WB_DOUBLEBORDER
| WB_NAMEFIELD
| WB_NONEFIELD
| WB_NO_DIRECTSELECT
) )
1341 Reference
< lang::XServiceInfo
> xServices( rFrame
->getController()->getModel(), UNO_QUERY_THROW
);
1342 m_bIsWriter
= xServices
->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument")));
1344 catch(const uno::Exception
& )
1347 Size
aBmpSize( 55, 12 );
1350 aLineSet
.SetColCount( 2 );
1351 aLineSet
.SetSelectHdl( LINK( this, SvxLineWindow_Impl
, SelectHdl
) );
1352 aLineSet
.SetText( SVX_RESSTR(STR_NONE
) );
1354 lcl_CalcSizeValueSet( *this, aLineSet
, aBmpSize
);
1356 SetHelpId( HID_POPUP_LINE
);
1357 SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE
) );
1361 SfxPopupWindow
* SvxLineWindow_Impl::Clone() const
1363 return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() );
1366 // -----------------------------------------------------------------------
1368 void SvxLineWindow_Impl::MakeLineBitmap( USHORT nNo
, Bitmap
& rBmp
, const Size
& rSize
, String
& rStr
,
1369 const ::Color
& rLineCol
, const ::Color
& rBackCol
)
1371 VirtualDevice
aVirDev( *this );
1372 Rectangle
aRect( Point(2,0), Size(rSize
.Width()-4,0) );
1374 // grau einfaerben und Bitmap sichern:
1375 aVirDev
.SetOutputSizePixel( rSize
);
1376 aVirDev
.SetLineColor();
1377 aVirDev
.SetFillColor( rBackCol
);
1378 aVirDev
.DrawRect( Rectangle( Point(0,0), rSize
) );
1379 aVirDev
.SetFillColor( rLineCol
);
1381 sal_uInt16 nLineWidth
= 0;
1384 case 1: // DEF_LINE_WIDTH_0
1387 aVirDev
.DrawRect( aRect
);
1390 case 2: // DEF_LINE_WIDTH_1
1393 aVirDev
.DrawRect( aRect
);
1394 nLineWidth
= (USHORT
) DEF_LINE_WIDTH_1
/20;
1397 case 3: // DEF_LINE_WIDTH_2
1400 aVirDev
.DrawRect( aRect
);
1401 nLineWidth
= (USHORT
) DEF_LINE_WIDTH_2
/20;
1404 case 4: // DEF_LINE_WIDTH_3
1407 aVirDev
.DrawRect( aRect
);
1408 aVirDev
.DrawRect( Rectangle( Point(2,4), Point(37,7) ) );
1409 nLineWidth
= (USHORT
) DEF_LINE_WIDTH_3
/20;
1412 case 5: // DEF_LINE_WIDTH_4
1415 aVirDev
.DrawRect( aRect
);
1416 nLineWidth
= (USHORT
) DEF_LINE_WIDTH_4
/20;
1419 case 6: // DEF_DOUBLE_LINE0
1422 aVirDev
.DrawRect( aRect
);
1425 aVirDev
.DrawRect( aRect
);
1426 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE0_OUT
+DEF_DOUBLE_LINE0_IN
+DEF_DOUBLE_LINE0_DIST
)/20;
1429 case 7: // DEF_DOUBLE_LINE7
1432 aVirDev
.DrawRect( aRect
);
1435 aVirDev
.DrawRect( aRect
);
1436 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE7_OUT
+DEF_DOUBLE_LINE7_IN
+DEF_DOUBLE_LINE7_DIST
)/20;
1439 case 8: // DEF_DOUBLE_LINE1
1442 aVirDev
.DrawRect( aRect
);
1445 aVirDev
.DrawRect( aRect
);
1446 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE1_OUT
+DEF_DOUBLE_LINE1_IN
+DEF_DOUBLE_LINE1_DIST
)/20;
1449 case 9: // DEF_DOUBLE_LINE2
1452 aVirDev
.DrawRect( aRect
);
1454 aRect
.Bottom() = 10;
1455 aVirDev
.DrawRect( aRect
);
1456 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE2_OUT
+DEF_DOUBLE_LINE2_IN
+DEF_DOUBLE_LINE2_DIST
)/20;
1459 case 10: // DEF_DOUBLE_LINE8
1462 aVirDev
.DrawRect( aRect
);
1465 aVirDev
.DrawRect( aRect
);
1466 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE8_OUT
+DEF_DOUBLE_LINE8_IN
+DEF_DOUBLE_LINE8_DIST
)/20;
1469 case 11: // DEF_DOUBLE_LINE9
1472 aVirDev
.DrawRect( aRect
);
1475 aVirDev
.DrawRect( aRect
);
1476 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE9_OUT
+DEF_DOUBLE_LINE9_IN
+DEF_DOUBLE_LINE9_DIST
)/20;
1479 case 12: // DEF_DOUBLE_LINE10
1482 aVirDev
.DrawRect( aRect
);
1485 aVirDev
.DrawRect( aRect
);
1486 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE10_OUT
+DEF_DOUBLE_LINE10_IN
+DEF_DOUBLE_LINE10_DIST
)/20;
1489 case 13: // DEF_DOUBLE_LINE3
1492 aVirDev
.DrawRect( aRect
);
1495 aVirDev
.DrawRect( aRect
);
1496 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE3_OUT
+DEF_DOUBLE_LINE3_IN
+DEF_DOUBLE_LINE3_DIST
)/20;
1499 case 14: // DEF_DOUBLE_LINE4
1502 aVirDev
.DrawRect( aRect
);
1505 aVirDev
.DrawRect( aRect
);
1506 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE4_OUT
+DEF_DOUBLE_LINE4_IN
+DEF_DOUBLE_LINE4_DIST
)/20;
1509 case 15: // DEF_DOUBLE_LINE5
1512 aVirDev
.DrawRect( aRect
);
1515 aVirDev
.DrawRect( aRect
);
1516 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE5_OUT
+DEF_DOUBLE_LINE5_IN
+DEF_DOUBLE_LINE5_DIST
)/20;
1519 case 16: // DEF_DOUBLE_LINE6
1522 aVirDev
.DrawRect( aRect
);
1525 aVirDev
.DrawRect( aRect
);
1526 nLineWidth
= (USHORT
) (DEF_DOUBLE_LINE6_OUT
+DEF_DOUBLE_LINE6_IN
+DEF_DOUBLE_LINE6_DIST
)/20;
1534 rStr
= String::CreateFromInt32( nLineWidth
);
1535 rStr
.AppendAscii(" pt");
1537 rBmp
= aVirDev
.GetBitmap( Point(0,0), rSize
);
1540 // -----------------------------------------------------------------------
1542 IMPL_LINK( SvxLineWindow_Impl
, SelectHdl
, void *, EMPTYARG
)
1544 SvxLineItem
aLineItem( SID_FRAME_LINESTYLE
);
1548 BOOL bSetLine
= TRUE
;
1550 switch ( aLineSet
.GetSelectItemId() )
1552 case 1: n1
= DEF_LINE_WIDTH_0
; break;
1553 case 2: n1
= DEF_LINE_WIDTH_1
; break;
1554 case 3: n1
= DEF_LINE_WIDTH_2
; break;
1555 case 4: n1
= DEF_LINE_WIDTH_3
; break;
1556 case 5: n1
= DEF_LINE_WIDTH_4
; break;
1558 case 6: n1
= DEF_DOUBLE_LINE0_OUT
;
1559 n2
= DEF_DOUBLE_LINE0_IN
;
1560 n3
= DEF_DOUBLE_LINE0_DIST
; break;
1561 case 7: n1
= DEF_DOUBLE_LINE7_OUT
;
1562 n2
= DEF_DOUBLE_LINE7_IN
;
1563 n3
= DEF_DOUBLE_LINE7_DIST
; break;
1564 case 8: n1
= DEF_DOUBLE_LINE1_OUT
;
1565 n2
= DEF_DOUBLE_LINE1_IN
;
1566 n3
= DEF_DOUBLE_LINE1_DIST
; break;
1567 case 9: n1
= DEF_DOUBLE_LINE2_OUT
;
1568 n2
= DEF_DOUBLE_LINE2_IN
;
1569 n3
= DEF_DOUBLE_LINE2_DIST
; break;
1570 case 10: n1
= DEF_DOUBLE_LINE8_OUT
;
1571 n2
= DEF_DOUBLE_LINE8_IN
;
1572 n3
= DEF_DOUBLE_LINE8_DIST
; break;
1573 case 11: n1
= DEF_DOUBLE_LINE9_OUT
;
1574 n2
= DEF_DOUBLE_LINE9_IN
;
1575 n3
= DEF_DOUBLE_LINE9_DIST
; break;
1576 case 12: n1
= DEF_DOUBLE_LINE10_OUT
;
1577 n2
= DEF_DOUBLE_LINE10_IN
;
1578 n3
= DEF_DOUBLE_LINE10_DIST
; break;
1579 case 13: n1
= DEF_DOUBLE_LINE3_OUT
;
1580 n2
= DEF_DOUBLE_LINE3_IN
;
1581 n3
= DEF_DOUBLE_LINE3_DIST
; break;
1582 case 14: n1
= DEF_DOUBLE_LINE4_OUT
;
1583 n2
= DEF_DOUBLE_LINE4_IN
;
1584 n3
= DEF_DOUBLE_LINE4_DIST
; break;
1585 case 15: n1
= DEF_DOUBLE_LINE5_OUT
;
1586 n2
= DEF_DOUBLE_LINE5_IN
;
1587 n3
= DEF_DOUBLE_LINE5_DIST
; break;
1588 case 16: n1
= DEF_DOUBLE_LINE6_OUT
;
1589 n2
= DEF_DOUBLE_LINE6_IN
;
1590 n3
= DEF_DOUBLE_LINE6_DIST
; break;
1598 SvxBorderLine
aTmp( NULL
, n1
, n2
, n3
);
1599 aLineItem
.SetLine( &aTmp
);
1602 aLineItem
.SetLine( 0 );
1604 if ( IsInPopupMode() )
1608 Sequence
< PropertyValue
> aArgs( 1 );
1609 aArgs
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" ));
1610 aLineItem
.QueryValue( a
, m_bIsWriter
? CONVERT_TWIPS
: 0 );
1613 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1614 This instance may be deleted in the meantime (i.e. when a dialog is opened
1615 while in Dispatch()), accessing members will crash in this case. */
1616 aLineSet
.SetNoSelection();
1618 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1619 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineStyle" )),
1624 // -----------------------------------------------------------------------
1626 void SvxLineWindow_Impl::Resize()
1628 lcl_ResizeValueSet( *this, aLineSet
);
1631 // -----------------------------------------------------------------------
1633 void SvxLineWindow_Impl::StartSelection()
1635 aLineSet
.StartSelection();
1638 // -----------------------------------------------------------------------
1640 BOOL
SvxLineWindow_Impl::Close()
1642 return SfxPopupWindow::Close();
1645 // -----------------------------------------------------------------------
1647 Window
* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
1652 // -----------------------------------------------------------------------
1654 void SvxLineWindow_Impl::GetFocus()
1656 aLineSet
.GrabFocus();
1659 void SvxLineWindow_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
1661 SfxPopupWindow::DataChanged( rDCEvt
);
1663 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1670 void SvxLineWindow_Impl::CreateBitmaps( void )
1672 Size
aBmpSize( 55, 12 );
1676 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
1677 svtools::ColorConfig aColorConfig
;
1678 ::Color
aLineCol( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
1679 ::Color
aBackCol( rStyleSettings
.GetWindowColor() );
1682 for( USHORT i
= 1 ; i
< 17 ; ++i
)
1684 MakeLineBitmap( i
, aBmp
, aBmpSize
, aStr
, aLineCol
, aBackCol
);
1685 aLineSet
.InsertItem( i
, aBmp
, aStr
);
1689 // -----------------------------------------------------------------------
1691 //########################################################################
1694 //========================================================================
1695 // class SfxStyleControllerItem_Impl ------------------------------------------
1696 //========================================================================
1698 SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl(
1699 const Reference
< XDispatchProvider
>& rDispatchProvider
,
1700 USHORT nSlotId
, // Family-ID
1701 const rtl::OUString
& rCommand
, // .uno: command bound to this item
1702 SvxStyleToolBoxControl
& rTbxCtl
) // Controller-Instanz, dem dieses Item zugeordnet ist.
1703 : SfxStatusListener( rDispatchProvider
, nSlotId
, rCommand
),
1708 // -----------------------------------------------------------------------
1710 void SfxStyleControllerItem_Impl::StateChanged(
1711 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
1715 case SID_STYLE_FAMILY1
:
1716 case SID_STYLE_FAMILY2
:
1717 case SID_STYLE_FAMILY3
:
1718 case SID_STYLE_FAMILY4
:
1719 case SID_STYLE_FAMILY5
:
1721 const USHORT nIdx
= GetId() - SID_STYLE_FAMILY_START
;
1723 if ( SFX_ITEM_AVAILABLE
== eState
)
1725 const SfxTemplateItem
* pStateItem
=
1726 PTR_CAST( SfxTemplateItem
, pState
);
1727 DBG_ASSERT( pStateItem
!= NULL
, "SfxTemplateItem expected" );
1728 rControl
.SetFamilyState( nIdx
, pStateItem
);
1731 rControl
.SetFamilyState( nIdx
, NULL
);
1737 //########################################################################
1739 //========================================================================
1740 // class SvxStyleToolBoxControl ------------------------------------------
1741 //========================================================================
1743 struct SvxStyleToolBoxControl::Impl
1747 ::std::vector
< ::rtl::OUString
> aDefaultStyles
;
1749 BOOL bSpecModeWriter
;
1753 :aClearForm ( SVX_RESSTR( RID_SVXSTR_CLEARFORM
) )
1754 ,aMore ( SVX_RESSTR( RID_SVXSTR_MORE
) )
1755 ,bListening ( FALSE
)
1756 ,bSpecModeWriter ( FALSE
)
1757 ,bSpecModeCalc ( FALSE
)
1762 void InitializeStyles(Reference
< frame::XModel
> xModel
)
1764 //now convert the default style names to the localized names
1767 Reference
< style::XStyleFamiliesSupplier
> xStylesSupplier( xModel
, UNO_QUERY_THROW
);
1768 Reference
< lang::XServiceInfo
> xServices( xModel
, UNO_QUERY_THROW
);
1769 bSpecModeWriter
= xServices
->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument")));
1772 Reference
<container::XNameAccess
> xParaStyles
;
1773 xStylesSupplier
->getStyleFamilies()->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles"))) >>=
1775 static const sal_Char
* aWriterStyles
[] =
1783 for( sal_uInt32 nStyle
= 0; nStyle
< sizeof( aWriterStyles
) / sizeof( sal_Char
*); ++nStyle
)
1787 Reference
< beans::XPropertySet
> xStyle
;
1788 xParaStyles
->getByName( rtl::OUString::createFromAscii( aWriterStyles
[nStyle
] )) >>= xStyle
;
1789 ::rtl::OUString sName
;
1790 xStyle
->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName"))) >>= sName
;
1791 if( sName
.getLength() )
1792 aDefaultStyles
.push_back(sName
);
1794 catch( const uno::Exception
& )
1800 bSpecModeCalc
= xServices
->supportsService(::rtl::OUString(
1801 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument")))))
1803 static const sal_Char
* aCalcStyles
[] =
1811 Reference
<container::XNameAccess
> xCellStyles
;
1812 xStylesSupplier
->getStyleFamilies()->getByName(
1813 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))) >>=
1815 for( sal_uInt32 nStyle
= 0; nStyle
< sizeof( aCalcStyles
) / sizeof( sal_Char
*); ++nStyle
)
1819 Reference
< beans::XPropertySet
> xStyle
;
1820 xCellStyles
->getByName( rtl::OUString::createFromAscii( aCalcStyles
[nStyle
] )) >>= xStyle
;
1821 ::rtl::OUString sName
;
1822 xStyle
->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName")))>>= sName
;
1823 if( sName
.getLength() )
1824 aDefaultStyles
.push_back(sName
);
1826 catch( const uno::Exception
& )
1831 catch(const uno::Exception
& )
1833 DBG_ERROR("error while initializing style names");
1839 // mapping table from bound items. BE CAREFUL this table must be in the
1840 // same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n
1841 // MAX_FAMILIES must also be correctly set!
1842 static const char* StyleSlotToStyleCommand
[MAX_FAMILIES
] =
1848 ".uno:TemplateFamily5"
1851 SvxStyleToolBoxControl::SvxStyleToolBoxControl(
1852 USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
)
1853 : SfxToolBoxControl ( nSlotId
, nId
, rTbx
),
1854 pStyleSheetPool ( NULL
),
1855 nActFamily ( 0xffff ),
1856 bListening ( FALSE
),
1859 for ( USHORT i
=0; i
<MAX_FAMILIES
; i
++ )
1862 m_xBoundItems
[i
] = Reference
< XComponent
>();
1863 pFamilyState
[i
] = NULL
;
1867 // -----------------------------------------------------------------------
1868 SvxStyleToolBoxControl::~SvxStyleToolBoxControl()
1872 // -----------------------------------------------------------------------
1873 void SAL_CALL
SvxStyleToolBoxControl::initialize( const Sequence
< Any
>& aArguments
)
1874 throw ( Exception
, RuntimeException
)
1876 SfxToolBoxControl::initialize( aArguments
);
1878 // After initialize we should have a valid frame member where we can retrieve our
1879 // dispatch provider.
1880 if ( m_xFrame
.is() )
1882 pImpl
->InitializeStyles(m_xFrame
->getController()->getModel());
1883 Reference
< XDispatchProvider
> xDispatchProvider( m_xFrame
->getController(), UNO_QUERY
);
1884 for ( USHORT i
=0; i
<MAX_FAMILIES
; i
++ )
1886 pBoundItems
[i
] = new SfxStyleControllerItem_Impl( xDispatchProvider
,
1887 SID_STYLE_FAMILY_START
+ i
,
1888 OUString::createFromAscii( StyleSlotToStyleCommand
[i
] ),
1890 m_xBoundItems
[i
] = Reference
< XComponent
>( static_cast< OWeakObject
* >( pBoundItems
[i
] ), UNO_QUERY
);
1891 pFamilyState
[i
] = NULL
;
1897 void SAL_CALL
SvxStyleToolBoxControl::dispose()
1898 throw (::com::sun::star::uno::RuntimeException
)
1900 SfxToolBoxControl::dispose();
1902 for( USHORT i
=0; i
<MAX_FAMILIES
; i
++ )
1904 if ( m_xBoundItems
[i
].is() )
1908 m_xBoundItems
[i
]->dispose();
1910 catch ( Exception
& )
1914 m_xBoundItems
[i
].clear();
1917 DELETEZ( pFamilyState
[i
] );
1919 pStyleSheetPool
= NULL
;
1923 // -----------------------------------------------------------------------
1924 void SAL_CALL
SvxStyleToolBoxControl::update() throw (RuntimeException
)
1926 // Do nothing, we will start binding our listener when we are visible.
1927 // See link SvxStyleToolBoxControl::VisibilityNotification.
1928 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
1929 if ( pBox
->IsVisible() )
1931 for ( int i
=0; i
<MAX_FAMILIES
; i
++ )
1932 pBoundItems
[i
]->ReBind();
1938 // -----------------------------------------------------------------------
1940 SfxStyleFamily
SvxStyleToolBoxControl::GetActFamily()
1942 switch ( nActFamily
-1 + SID_STYLE_FAMILY_START
)
1944 case SID_STYLE_FAMILY1
: return SFX_STYLE_FAMILY_CHAR
;
1945 case SID_STYLE_FAMILY2
: return SFX_STYLE_FAMILY_PARA
;
1946 case SID_STYLE_FAMILY3
: return SFX_STYLE_FAMILY_FRAME
;
1947 case SID_STYLE_FAMILY4
: return SFX_STYLE_FAMILY_PAGE
;
1948 case SID_STYLE_FAMILY5
: return SFX_STYLE_FAMILY_PSEUDO
;
1950 DBG_ERROR( "unknown style family" );
1953 return SFX_STYLE_FAMILY_PARA
;
1956 // -----------------------------------------------------------------------
1958 void SvxStyleToolBoxControl::FillStyleBox()
1960 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
1962 DBG_ASSERT( pStyleSheetPool
, "StyleSheetPool not found!" );
1963 DBG_ASSERT( pBox
, "Control not found!" );
1965 if ( pStyleSheetPool
&& pBox
&& nActFamily
!=0xffff )
1967 const SfxStyleFamily eFamily
= GetActFamily();
1968 USHORT nCount
= pStyleSheetPool
->Count();
1970 SfxStyleSheetBase
* pStyle
= NULL
;
1971 BOOL bDoFill
= FALSE
;
1973 pStyleSheetPool
->SetSearchMask( eFamily
, SFXSTYLEBIT_USED
);
1975 //------------------------------
1976 // Ueberpruefen, ob Fill noetig:
1977 //------------------------------
1979 pStyle
= pStyleSheetPool
->First();
1980 //!!! TODO: This condition isn't right any longer, because we always show some default entries
1981 //!!! so the list doesn't show the count
1982 if ( nCount
!= pBox
->GetEntryCount() )
1988 while ( pStyle
&& !bDoFill
)
1990 bDoFill
= ( pBox
->GetEntry(i
) != pStyle
->GetName() );
1991 pStyle
= pStyleSheetPool
->Next();
1998 pBox
->SetUpdateMode( FALSE
);
2003 sal_uInt32 nCnt
= pImpl
->aDefaultStyles
.size();
2006 pStyle
= pStyleSheetPool
->First();
2008 if( pImpl
->bSpecModeWriter
|| pImpl
->bSpecModeCalc
)
2012 // sort out default styles
2014 ::rtl::OUString
aName( pStyle
->GetName() );
2015 for( _i
= 0 ; _i
< nCnt
; ++_i
)
2017 if( pImpl
->aDefaultStyles
[_i
] == aName
)
2025 pBox
->InsertEntry( aName
);
2026 pStyle
= pStyleSheetPool
->Next();
2033 pBox
->InsertEntry( pStyle
->GetName() );
2034 pStyle
= pStyleSheetPool
->Next();
2039 if( pImpl
->bSpecModeWriter
|| pImpl
->bSpecModeCalc
)
2041 // insert default styles
2043 sal_uInt32 nCnt
= pImpl
->aDefaultStyles
.size();
2045 for( _i
= 0 ; _i
< nCnt
; ++_i
)
2047 pBox
->InsertEntry( pImpl
->aDefaultStyles
[_i
], nPos
);
2051 // disable sort to preserve special order
2052 WinBits nWinBits
= pBox
->GetStyle();
2053 nWinBits
&= ~WB_SORT
;
2054 pBox
->SetStyle( nWinBits
);
2056 pBox
->InsertEntry( pImpl
->aClearForm
, 0 );
2057 pBox
->SetSeparatorPos( 0 );
2059 pBox
->InsertEntry( pImpl
->aMore
);
2061 // enable sort again
2062 nWinBits
|= WB_SORT
;
2063 pBox
->SetStyle( nWinBits
);
2066 pBox
->SetUpdateMode( TRUE
);
2067 pBox
->SetFamily( eFamily
);
2069 USHORT nLines
= Min( pBox
->GetEntryCount(), MAX_STYLES_ENTRIES
);
2070 pBox
->SetDropDownLineCount( nLines
);
2075 // -----------------------------------------------------------------------
2077 void SvxStyleToolBoxControl::SelectStyle( const String
& rStyleName
)
2079 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
2080 DBG_ASSERT( pBox
, "Control not found!" );
2084 // String aStrSel( pBox->GetSelectEntry() );
2085 String
aStrSel( pBox
->GetText() );
2087 if ( rStyleName
.Len() > 0 )
2089 if ( rStyleName
!= aStrSel
)
2090 // pBox->SelectEntry( rStyleName );
2091 pBox
->SetText( rStyleName
);
2094 pBox
->SetNoSelection();
2099 // -----------------------------------------------------------------------
2101 void SvxStyleToolBoxControl::Update()
2103 SfxStyleSheetBasePool
* pPool
= NULL
;
2104 SfxObjectShell
* pDocShell
= SfxObjectShell::Current();
2107 pPool
= pDocShell
->GetStyleSheetPool();
2110 for ( i
=0; i
<MAX_FAMILIES
; i
++ )
2111 if( pFamilyState
[i
] )
2114 if ( i
==MAX_FAMILIES
|| !pPool
)
2116 pStyleSheetPool
= pPool
;
2120 //--------------------------------------------------------------------
2121 const SfxTemplateItem
* pItem
= NULL
;
2123 if ( nActFamily
== 0xffff || 0 == (pItem
= pFamilyState
[nActFamily
-1]) )
2124 // aktueller Bereich nicht innerhalb der erlaubten Bereiche
2127 pStyleSheetPool
= pPool
;
2130 pItem
= pFamilyState
[nActFamily
-1];
2134 pItem
= pFamilyState
[nActFamily
-1];
2139 DBG_WARNING( "Unknown Family" ); // can happen
2142 else if ( pPool
!= pStyleSheetPool
)
2143 pStyleSheetPool
= pPool
;
2145 FillStyleBox(); // entscheidet selbst, ob gefuellt werden muss
2148 SelectStyle( pItem
->GetStyleName() );
2151 // -----------------------------------------------------------------------
2153 void SvxStyleToolBoxControl::SetFamilyState( USHORT nIdx
,
2154 const SfxTemplateItem
* pItem
)
2156 DELETEZ( pFamilyState
[nIdx
] );
2159 pFamilyState
[nIdx
] = new SfxTemplateItem( *pItem
);
2164 // -----------------------------------------------------------------------
2166 IMPL_LINK( SvxStyleToolBoxControl
, VisibilityNotification
, void*, EMPTYARG
)
2171 // Call ReBind() && UnBind() according to visibility
2172 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)( GetToolBox().GetItemWindow( GetId() ));
2173 if ( pBox
->IsVisible() && !isBound() )
2175 for ( i
=0; i
<MAX_FAMILIES
; i
++ )
2176 pBoundItems
[i
]->ReBind();
2180 else if ( !pBox
->IsVisible() && isBound() )
2182 for ( i
=0; i
<MAX_FAMILIES
; i
++ )
2183 pBoundItems
[i
]->UnBind();
2190 // -----------------------------------------------------------------------
2192 void SvxStyleToolBoxControl::StateChanged(
2194 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2197 USHORT nId
= GetId();
2198 ToolBox
& rTbx
= GetToolBox();
2199 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)(rTbx
.GetItemWindow( nId
));
2200 TriState eTri
= STATE_NOCHECK
;
2202 DBG_ASSERT( pBox
, "Control not found!" );
2204 if ( SFX_ITEM_DISABLED
== eState
)
2209 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2213 case SFX_ITEM_AVAILABLE
:
2214 eTri
= ((const SfxBoolItem
*)pState
)->GetValue()
2219 case SFX_ITEM_DONTCARE
:
2220 eTri
= STATE_DONTKNOW
;
2224 rTbx
.SetItemState( nId
, eTri
);
2226 if ( SFX_ITEM_DISABLED
!= eState
)
2230 // -----------------------------------------------------------------------
2232 Window
* SvxStyleToolBoxControl::CreateItemWindow( Window
*pParent
)
2234 SvxStyleBox_Impl
* pBox
= new SvxStyleBox_Impl( pParent
,
2236 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StyleApply" )),
2237 SFX_STYLE_FAMILY_PARA
,
2238 Reference
< XDispatchProvider
>( m_xFrame
->getController(), UNO_QUERY
),
2242 pImpl
->bSpecModeWriter
|| pImpl
->bSpecModeCalc
);
2243 if( pImpl
->aDefaultStyles
.size())
2244 pBox
->SetDefaultStyle( pImpl
->aDefaultStyles
[0] );
2245 // Set visibility listener to bind/unbind controller
2246 pBox
->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl
, VisibilityNotification
));
2251 //========================================================================
2252 // class SvxFontNameToolBoxControl ---------------------------------------
2253 //========================================================================
2255 SvxFontNameToolBoxControl::SvxFontNameToolBoxControl(
2260 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2264 // -----------------------------------------------------------------------
2266 void SvxFontNameToolBoxControl::StateChanged(
2268 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2271 USHORT nId
= GetId();
2272 ToolBox
& rTbx
= GetToolBox();
2273 SvxFontNameBox_Impl
* pBox
= (SvxFontNameBox_Impl
*)(rTbx
.GetItemWindow( nId
));
2275 DBG_ASSERT( pBox
, "Control not found!" );
2277 if ( SFX_ITEM_DISABLED
== eState
)
2280 pBox
->Update( (const SvxFontItem
*)NULL
);
2286 if ( SFX_ITEM_AVAILABLE
== eState
)
2288 const SvxFontItem
* pFontItem
= dynamic_cast< const SvxFontItem
* >( pState
);
2290 DBG_ASSERT( pFontItem
, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" );
2292 pBox
->Update( pFontItem
);
2295 pBox
->SetText( String() );
2299 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2302 // -----------------------------------------------------------------------
2304 Window
* SvxFontNameToolBoxControl::CreateItemWindow( Window
*pParent
)
2306 SvxFontNameBox_Impl
* pBox
= new SvxFontNameBox_Impl( pParent
,
2307 Reference
< XDispatchProvider
>( m_xFrame
->getController(), UNO_QUERY
),
2312 //========================================================================
2313 // class SvxFontColorToolBoxControl --------------------------------------
2314 //========================================================================
2316 SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
2321 : SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2322 pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
2323 nSlotId
, nId
, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW
))
2325 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
2328 // -----------------------------------------------------------------------
2330 SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl()
2335 // -----------------------------------------------------------------------
2337 SfxPopupWindowType
SvxFontColorToolBoxControl::GetPopupWindowType() const
2339 return SFX_POPUPWINDOW_ONCLICK
;
2342 // -----------------------------------------------------------------------
2344 SfxPopupWindow
* SvxFontColorToolBoxControl::CreatePopupWindow()
2346 SvxColorWindow_Impl
* pColorWin
=
2347 new SvxColorWindow_Impl(
2348 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Color" )),
2349 SID_ATTR_CHAR_COLOR
,
2351 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR
),
2354 pColorWin
->StartPopupMode( &GetToolBox(),
2355 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
2356 pColorWin
->StartSelection();
2357 SetPopupWindow( pColorWin
);
2361 // -----------------------------------------------------------------------
2363 void SvxFontColorToolBoxControl::StateChanged(
2365 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2368 USHORT nId
= GetId();
2369 ToolBox
& rTbx
= GetToolBox();
2370 const SvxColorItem
* pItem
= 0;
2372 if ( SFX_ITEM_DONTCARE
!= eState
)
2373 pItem
= PTR_CAST( SvxColorItem
, pState
);
2376 pBtnUpdater
->Update( pItem
->GetValue());
2378 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2379 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2382 //========================================================================
2383 // class SvxColorToolBoxControl --------------------------------
2384 //========================================================================
2386 SvxColorToolBoxControl::SvxColorToolBoxControl( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
) :
2388 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2390 if ( nSlotId
== SID_BACKGROUND_COLOR
)
2391 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2393 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
2395 pBtnUpdater
= new ::svx::ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox() );
2398 // -----------------------------------------------------------------------
2400 SvxColorToolBoxControl::~SvxColorToolBoxControl()
2405 // -----------------------------------------------------------------------
2407 SfxPopupWindowType
SvxColorToolBoxControl::GetPopupWindowType() const
2409 return SFX_POPUPWINDOW_ONCLICK
;
2412 // -----------------------------------------------------------------------
2414 SfxPopupWindow
* SvxColorToolBoxControl::CreatePopupWindow()
2416 USHORT nResId
= GetSlotId() == SID_BACKGROUND_COLOR
?
2417 RID_SVXSTR_BACKGROUND
: RID_SVXSTR_COLOR
;
2418 SvxColorWindow_Impl
* pColorWin
= new SvxColorWindow_Impl(
2419 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" )),
2420 SID_BACKGROUND_COLOR
,
2425 pColorWin
->StartPopupMode( &GetToolBox(),
2426 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
2427 pColorWin
->StartSelection();
2428 SetPopupWindow( pColorWin
);
2432 // -----------------------------------------------------------------------
2434 void SvxColorToolBoxControl::StateChanged(
2436 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2439 const SvxColorItem
* pItem
= 0;
2440 if ( SFX_ITEM_DONTCARE
!= eState
)
2441 pItem
= PTR_CAST( SvxColorItem
, pState
);
2444 pBtnUpdater
->Update( pItem
->GetValue() );
2446 USHORT nId
= GetId();
2447 ToolBox
& rTbx
= GetToolBox();
2448 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2449 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2452 //========================================================================
2453 // class SvxFontColorExtToolBoxControl --------------------------------------
2454 //========================================================================
2456 SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
2461 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2464 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
2465 // The following commands are available at the writer module.
2466 if ( SID_ATTR_CHAR_COLOR2
== nSlotId
)
2467 addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )));
2469 addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )));
2471 USHORT nMode
= SID_ATTR_CHAR_COLOR2
== nSlotId
2472 ? TBX_UPDATER_MODE_CHAR_COLOR_NEW
: TBX_UPDATER_MODE_CHAR_COLOR_NEW
;
2473 pBtnUpdater
= new ::svx::ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox(), nMode
);
2476 // -----------------------------------------------------------------------
2478 SvxFontColorExtToolBoxControl::~SvxFontColorExtToolBoxControl()
2483 // -----------------------------------------------------------------------
2485 SfxPopupWindowType
SvxFontColorExtToolBoxControl::GetPopupWindowType() const
2487 return SFX_POPUPWINDOW_ONTIMEOUT
;
2490 // -----------------------------------------------------------------------
2492 SfxPopupWindow
* SvxFontColorExtToolBoxControl::CreatePopupWindow()
2494 SvxColorWindow_Impl
* pColorWin
=
2495 new SvxColorWindow_Impl(
2499 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR
),
2502 if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND
)
2503 pColorWin
->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND
) );
2505 pColorWin
->StartPopupMode( &GetToolBox(),
2506 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
2507 pColorWin
->StartSelection();
2508 SetPopupWindow( pColorWin
);
2512 // -----------------------------------------------------------------------
2514 void SvxFontColorExtToolBoxControl::StateChanged(
2516 USHORT nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
2519 USHORT nId
= GetId();
2520 ToolBox
& rTbx
= GetToolBox();
2521 const SvxColorItem
* pItem
= 0;
2523 if ( nSID
== SID_ATTR_CHAR_COLOR_EXT
||
2524 nSID
== SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
)
2526 if ( SFX_ITEM_DONTCARE
!= eState
)
2528 const SfxBoolItem
* pBool
= PTR_CAST( SfxBoolItem
, pState
);
2529 rTbx
.CheckItem( nId
, pBool
&& pBool
->GetValue());
2531 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2535 if ( SFX_ITEM_DONTCARE
!= eState
)
2536 pItem
= PTR_CAST( SvxColorItem
, pState
);
2539 pBtnUpdater
->Update( pItem
->GetValue() );
2543 // -----------------------------------------------------------------------
2545 void SvxFontColorExtToolBoxControl::Select( BOOL
)
2548 OUString aParamName
;
2549 if ( SID_ATTR_CHAR_COLOR2
== GetSlotId() )
2551 aCommand
= OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ));
2552 aParamName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" ));
2556 aCommand
= OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ));
2557 aParamName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" ));
2560 Sequence
< PropertyValue
> aArgs( 1 );
2561 aArgs
[0].Name
= aParamName
;
2562 aArgs
[0].Value
= makeAny( GetToolBox().IsItemChecked( GetId() ));
2563 Dispatch( aCommand
, aArgs
);
2566 //========================================================================
2567 // class SvxFrameToolBoxControl ------------------------------------------
2568 //========================================================================
2570 SvxFrameToolBoxControl::SvxFrameToolBoxControl(
2575 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2577 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2580 // -----------------------------------------------------------------------
2582 SfxPopupWindowType
SvxFrameToolBoxControl::GetPopupWindowType() const
2584 return SFX_POPUPWINDOW_ONCLICK
;
2587 // -----------------------------------------------------------------------
2589 SfxPopupWindow
* SvxFrameToolBoxControl::CreatePopupWindow()
2591 SvxFrameWindow_Impl
* pFrameWin
= new SvxFrameWindow_Impl(
2592 GetSlotId(), m_xFrame
, &GetToolBox() );
2594 pFrameWin
->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS
| FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
2595 pFrameWin
->StartSelection();
2596 SetPopupWindow( pFrameWin
);
2601 // -----------------------------------------------------------------------
2603 void SvxFrameToolBoxControl::StateChanged(
2605 USHORT
, SfxItemState eState
, const SfxPoolItem
* )
2608 USHORT nId
= GetId();
2609 ToolBox
& rTbx
= GetToolBox();
2611 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2612 rTbx
.SetItemState( nId
, (SFX_ITEM_DONTCARE
== eState
)
2617 //========================================================================
2618 // class SvxFrameLineStyleToolBoxControl ---------------------------------
2619 //========================================================================
2621 SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
2626 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2628 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2631 // -----------------------------------------------------------------------
2633 SfxPopupWindowType
SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const
2635 return SFX_POPUPWINDOW_ONCLICK
;
2638 // -----------------------------------------------------------------------
2640 SfxPopupWindow
* SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
2642 SvxLineWindow_Impl
* pLineWin
= new SvxLineWindow_Impl( GetSlotId(), m_xFrame
, &GetToolBox() );
2643 pLineWin
->StartPopupMode( &GetToolBox(), TRUE
);
2644 pLineWin
->StartSelection();
2645 SetPopupWindow( pLineWin
);
2650 // -----------------------------------------------------------------------
2652 void SvxFrameLineStyleToolBoxControl::StateChanged(
2654 USHORT
, SfxItemState eState
, const SfxPoolItem
* )
2656 USHORT nId
= GetId();
2657 ToolBox
& rTbx
= GetToolBox();
2659 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2660 rTbx
.SetItemState( nId
, (SFX_ITEM_DONTCARE
== eState
)
2665 //========================================================================
2666 // class SvxFrameLineColorToolBoxControl ---------------------------------
2667 //========================================================================
2669 SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
2674 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2675 pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox() ))
2677 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2680 // -----------------------------------------------------------------------
2682 SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl()
2688 // -----------------------------------------------------------------------
2690 SfxPopupWindowType
SvxFrameLineColorToolBoxControl::GetPopupWindowType() const
2692 return SFX_POPUPWINDOW_ONCLICK
;
2695 // -----------------------------------------------------------------------
2697 SfxPopupWindow
* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
2699 SvxColorWindow_Impl
* pColorWin
= new SvxColorWindow_Impl(
2700 OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FrameLineColor" )),
2701 SID_FRAME_LINECOLOR
,
2703 SVX_RESSTR(RID_SVXSTR_FRAME_COLOR
),
2706 pColorWin
->StartPopupMode( &GetToolBox(),
2707 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
2708 pColorWin
->StartSelection();
2709 SetPopupWindow( pColorWin
);
2713 // -----------------------------------------------------------------------
2715 void SvxFrameLineColorToolBoxControl::StateChanged(
2717 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2720 USHORT nId
= GetId();
2721 ToolBox
& rTbx
= GetToolBox();
2722 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2723 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2725 const SvxColorItem
* pItem
= 0;
2726 if ( SFX_ITEM_DONTCARE
!= eState
)
2728 pItem
= PTR_CAST( SvxColorItem
, pState
);
2730 pBtnUpdater
->Update( pItem
->GetValue());
2734 // class SvxReloadControllerItem_Impl ------------------------------------
2736 class SvxReloadControllerItem_Impl
2739 Image
* pNormalImage
;
2740 Image
* pSpecialImage
;
2742 SvxReloadControllerItem_Impl() :
2743 pNormalImage( new Image( SVX_RES( RID_SVX_RELOAD_NORMAL
) ) ), pSpecialImage( 0 ) {}
2744 ~SvxReloadControllerItem_Impl() { delete pNormalImage
; delete pSpecialImage
; }
2746 Image
& GetNormalImage() { return *pNormalImage
; }
2747 Image
& GetSpecialImage()
2749 if ( !pSpecialImage
)
2750 pSpecialImage
= new Image( SVX_RES( RID_SVX_RELOAD_SPECIAL
) );
2751 return *pSpecialImage
;
2755 // -----------------------------------------------------------------------
2757 SvxReloadControllerItem::SvxReloadControllerItem( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
)
2758 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2759 , pImpl( new SvxReloadControllerItem_Impl
)
2761 rTbx
.SetItemImage( nId
, pImpl
->GetNormalImage() );
2764 // -----------------------------------------------------------------------
2766 SvxReloadControllerItem::~SvxReloadControllerItem()
2771 // -----------------------------------------------------------------------
2773 void SvxReloadControllerItem::StateChanged(
2774 USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2776 SfxBoolItem
* pItem
= PTR_CAST( SfxBoolItem
, pState
);
2777 ToolBox
& rBox
= GetToolBox();
2780 rBox
.SetItemImage( GetId(),
2781 pItem
->GetValue() ? pImpl
->GetSpecialImage() :
2782 pImpl
->GetNormalImage() );
2784 rBox
.EnableItem( GetId(), eState
!= SFX_ITEM_DISABLED
);
2787 //========================================================================
2788 // class SvxSimpleUndoRedoController -------------------------------------
2789 //========================================================================
2791 SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
)
2792 :SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2794 aDefaultText
= rTbx
.GetItemText( nId
);
2797 // -----------------------------------------------------------------------
2799 SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController()
2803 // -----------------------------------------------------------------------
2805 void SvxSimpleUndoRedoController::StateChanged( USHORT
, SfxItemState eState
, const SfxPoolItem
* pState
)
2807 SfxStringItem
* pItem
= PTR_CAST( SfxStringItem
, pState
);
2808 ToolBox
& rBox
= GetToolBox();
2809 if ( pItem
&& eState
!= SFX_ITEM_DISABLED
)
2811 ::rtl::OUString
aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem
->GetValue() ) );
2812 rBox
.SetQuickHelpText( GetId(), aNewText
);
2814 if ( eState
== SFX_ITEM_DISABLED
)
2815 rBox
.SetQuickHelpText( GetId(), aDefaultText
);
2816 rBox
.EnableItem( GetId(), eState
!= SFX_ITEM_DISABLED
);
2819 //========================================================================
2821 void lcl_ResizeValueSet( Window
&rWin
, ValueSet
&rValueSet
)
2823 Size aSize
= rWin
.GetOutputSizePixel();
2825 aSize
.Height() -= 4;
2826 rValueSet
.SetPosSizePixel( Point(2,2), aSize
);
2829 // -----------------------------------------------------------------------
2831 void lcl_CalcSizeValueSet( Window
&rWin
, ValueSet
&rValueSet
, const Size
&aItemSize
)
2833 Size aSize
= rValueSet
.CalcWindowSizePixel( aItemSize
);
2835 aSize
.Height() += 4;
2836 rWin
.SetOutputSizePixel( aSize
);
2839 // -----------------------------------------------------------------------
2841 BOOL
lcl_FontChangedHint( const SfxHint
&rHint
)
2843 SfxPoolItemHint
*pItemHint
= PTR_CAST(SfxPoolItemHint
, &rHint
);
2846 SfxPoolItem
*pItem
= pItemHint
->GetObject();
2847 return ( pItem
->Which() == SID_ATTR_CHAR_FONTLIST
);
2851 SfxSimpleHint
* pSimpleHint
= PTR_CAST(SfxSimpleHint
, &rHint
);
2852 return pSimpleHint
&& ( SFX_HINT_DATACHANGED
==
2853 ( pSimpleHint
->GetId() & SFX_HINT_DATACHANGED
) );
2856 // -----------------------------------------------------------------------------
2857 Reference
< ::com::sun::star::accessibility::XAccessible
> SvxFontNameBox_Impl::CreateAccessible()
2860 return FontNameBox::CreateAccessible();