1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/shl.hxx>
22 #include <tools/color.hxx>
23 #include <svl/poolitem.hxx>
24 #include <svl/eitem.hxx>
25 #include <svl/itemset.hxx>
26 #include <vcl/toolbox.hxx>
27 #include <vcl/bmpacc.hxx>
28 #include <svtools/valueset.hxx>
29 #include <svtools/ctrlbox.hxx>
30 #include <svl/style.hxx>
31 #include <svtools/ctrltool.hxx>
32 #include <svtools/borderhelper.hxx>
33 #include <svl/stritem.hxx>
34 #include <unotools/pathoptions.hxx>
35 #include <sfx2/tplpitem.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/viewsh.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <sfx2/docfac.hxx>
40 #include <sfx2/templdlg.hxx>
41 #include <svl/isethint.hxx>
42 #include <sfx2/querystatus.hxx>
43 #include <sfx2/sfxstatuslistener.hxx>
44 #include <tools/urlobj.hxx>
45 #include <sfx2/childwin.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <unotools/fontoptions.hxx>
48 #include <vcl/mnemonic.hxx>
49 #include <vcl/svapp.hxx>
50 #include <svl/smplhint.hxx>
51 #include <svtools/colorcfg.hxx>
52 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
53 #include <com/sun/star/lang/XServiceInfo.hpp>
54 #include <com/sun/star/beans/XPropertySet.hpp>
55 #include <com/sun/star/frame/status/ItemStatus.hpp>
56 #include <svx/dialogs.hrc>
57 #include <svx/svxitems.hrc>
59 #include <sfx2/htmlmode.hxx>
60 #include <svx/xtable.hxx>
61 #include <editeng/fontitem.hxx>
62 #include <editeng/fhgtitem.hxx>
63 #include <editeng/brushitem.hxx>
64 #include <editeng/boxitem.hxx>
65 #include <editeng/charreliefitem.hxx>
66 #include <editeng/contouritem.hxx>
67 #include <editeng/colritem.hxx>
68 #include <editeng/crossedoutitem.hxx>
69 #include <editeng/emphasismarkitem.hxx>
70 #include <editeng/flstitem.hxx>
71 #include <editeng/lineitem.hxx>
72 #include <editeng/postitem.hxx>
73 #include <editeng/shdditem.hxx>
74 #include <editeng/udlnitem.hxx>
75 #include <editeng/wghtitem.hxx>
76 #include "svx/drawitem.hxx"
77 #include <svx/tbcontrl.hxx>
78 #include "svx/dlgutil.hxx"
79 #include <svx/dialmgr.hxx>
80 #include "colorwindow.hxx"
83 #include <svx/framelink.hxx>
84 #include <svx/tbxcolorupdate.hxx>
85 #include <editeng/eerdll.hxx>
86 #include <editeng/editrids.hrc>
88 // ------------------------------------------------------------------------
90 #define MAX_MRU_FONTNAME_ENTRIES 5
91 #define LOGICAL_EDIT_HEIGHT 12
93 // STATIC DATA -----------------------------------------------------------
96 #define DELETEZ(p) (delete (p), (p)=NULL)
98 // don't make more than 15 entries visible at once
99 #define MAX_STYLES_ENTRIES static_cast< sal_uInt16 >( 15 )
101 static void lcl_ResizeValueSet( Window
&rWin
, ValueSet
&rValueSet
);
102 static void lcl_CalcSizeValueSet( Window
&rWin
, ValueSet
&rValueSet
, const Size
&aItemSize
);
105 using namespace ::editeng
;
106 using namespace ::com::sun::star
;
107 using namespace ::com::sun::star::uno
;
108 using namespace ::com::sun::star::frame
;
109 using namespace ::com::sun::star::beans
;
110 using namespace ::com::sun::star::lang
;
112 SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl
, SfxTemplateItem
);
113 SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl
, SvxFontItem
);
114 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl
, SvxColorItem
);
115 SFX_IMPL_TOOLBOX_CONTROL( SvxColorExtToolBoxControl
, SvxColorItem
);
116 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl
, SvxBoxItem
);
117 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl
, SvxLineItem
);
118 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl
, SvxColorItem
);
119 SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController
, SfxStringItem
);
121 //========================================================================
122 // class SvxStyleBox_Impl -----------------------------------------------------
123 //========================================================================
126 class SvxStyleBox_Impl
: public ComboBox
128 using Window::IsVisible
;
130 SvxStyleBox_Impl( Window
* pParent
, const OUString
& rCommand
, SfxStyleFamily eFamily
, const Reference
< XDispatchProvider
>& rDispatchProvider
,
131 const Reference
< XFrame
>& _xFrame
,const String
& rClearFormatKey
, const String
& rMoreKey
, bool bInSpecialMode
);
134 void SetFamily( SfxStyleFamily eNewFamily
);
135 inline bool IsVisible() { return bVisible
; }
137 virtual long PreNotify( NotifyEvent
& rNEvt
);
138 virtual long Notify( NotifyEvent
& rNEvt
);
139 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
140 virtual void StateChanged( StateChangedType nStateChange
);
142 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
144 inline void SetVisibilityListener( const Link
& aVisListener
) { aVisibilityListener
= aVisListener
; }
145 inline void RemoveVisibilityListener() { aVisibilityListener
= Link(); }
147 void SetDefaultStyle( const OUString
& rDefault
) { sDefaultStyle
= rDefault
; }
148 DECL_STATIC_LINK( SvxStyleBox_Impl
, FocusHdl_Impl
, Control
* );
151 virtual void Select();
154 SfxStyleFamily eStyleFamily
;
158 Link aVisibilityListener
;
160 Reference
< XDispatchProvider
> m_xDispatchProvider
;
161 Reference
< XFrame
> m_xFrame
;
163 String aClearFormatKey
;
165 String sDefaultStyle
;
171 //========================================================================
172 // class SvxFontNameBox --------------------------------------------------
173 //========================================================================
175 class SvxFontNameBox_Impl
: public FontNameBox
177 using Window::Update
;
179 const FontList
* pFontList
;
180 SAL_WNODEPRECATED_DECLARATIONS_PUSH
181 ::std::auto_ptr
<FontList
> m_aOwnFontList
;
182 SAL_WNODEPRECATED_DECLARATIONS_POP
188 Reference
< XDispatchProvider
> m_xDispatchProvider
;
189 Reference
< XFrame
> m_xFrame
;
192 void ReleaseFocus_Impl();
193 void EnableControls_Impl();
197 Sequence
< PropertyValue
> aArgs
;
198 SfxToolBoxControl::Dispatch( m_xDispatchProvider
,
199 OUString( ".uno:CharEndPreviewFontName" ),
202 DECL_DLLPRIVATE_LINK( CheckAndMarkUnknownFont
, VclWindowEvent
* );
205 virtual void Select();
206 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
209 SvxFontNameBox_Impl( Window
* pParent
, const Reference
< XDispatchProvider
>& rDispatchProvider
,const Reference
< XFrame
>& _xFrame
210 , WinBits nStyle
= WB_SORT
212 virtual ~SvxFontNameBox_Impl();
215 void Update( const SvxFontItem
* pFontItem
);
216 sal_uInt16
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 void UserDraw( const UserDrawEvent
& rUDEvt
);
222 virtual long PreNotify( NotifyEvent
& rNEvt
);
223 virtual long Notify( NotifyEvent
& rNEvt
);
224 virtual Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
225 SAL_WNODEPRECATED_DECLARATIONS_PUSH
226 void SetOwnFontList(::std::auto_ptr
<FontList
> _aOwnFontList
) { m_aOwnFontList
= _aOwnFontList
; }
227 SAL_WNODEPRECATED_DECLARATIONS_POP
230 //========================================================================
231 // class SvxFrameWindow_Impl --------------------------------------------------
232 //========================================================================
234 // SelectHdl needs the Modifiers, get them in MouseButtonUp
236 class SvxFrmValueSet_Impl
: public ValueSet
238 sal_uInt16 nModifier
;
239 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
241 SvxFrmValueSet_Impl(Window
* pParent
, WinBits nWinStyle
)
242 : ValueSet(pParent
, nWinStyle
), nModifier(0) {}
243 sal_uInt16
GetModifier() const {return nModifier
;}
247 void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent
& rMEvt
)
249 nModifier
= rMEvt
.GetModifier();
250 ValueSet::MouseButtonUp(rMEvt
);
253 class SvxFrameWindow_Impl
: public SfxPopupWindow
255 using FloatingWindow::StateChanged
;
258 SvxFrmValueSet_Impl aFrameSet
;
260 sal_Bool bParagraphMode
;
262 DECL_LINK( SelectHdl
, void * );
265 virtual void Resize();
266 virtual sal_Bool
Close();
267 virtual Window
* GetPreferredKeyInputWindow();
268 virtual void GetFocus();
271 SvxFrameWindow_Impl( sal_uInt16 nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
);
272 ~SvxFrameWindow_Impl();
273 void StartSelection();
275 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
276 const SfxPoolItem
* pState
);
277 virtual SfxPopupWindow
* Clone() const;
278 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
281 //========================================================================
282 // class SvxLineWindow_Impl ---------------------------------------------------
283 //========================================================================
284 class SvxLineWindow_Impl
: public SfxPopupWindow
287 LineListBox m_aLineStyleLb
;
290 DECL_LINK( SelectHdl
, void * );
293 virtual void Resize();
294 virtual sal_Bool
Close();
295 virtual Window
* GetPreferredKeyInputWindow();
296 virtual void GetFocus();
297 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
299 SvxLineWindow_Impl( sal_uInt16 nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
);
301 virtual SfxPopupWindow
* Clone() const;
304 //########################################################################
306 //========================================================================
307 // class SfxStyleControllerItem ------------------------------------------
308 //========================================================================
309 class SvxStyleToolBoxControl
;
311 class SfxStyleControllerItem_Impl
: public SfxStatusListener
314 SfxStyleControllerItem_Impl( const Reference
< XDispatchProvider
>& rDispatchProvider
,
316 const OUString
& rCommand
,
317 SvxStyleToolBoxControl
& rTbxCtl
);
320 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
);
323 SvxStyleToolBoxControl
& rControl
;
326 //========================================================================
327 // class SvxStyleBox_Impl -----------------------------------------------------
328 //========================================================================
330 SvxStyleBox_Impl::SvxStyleBox_Impl(
332 const OUString
& rCommand
,
333 SfxStyleFamily eFamily
,
334 const Reference
< XDispatchProvider
>& rDispatchProvider
,
335 const Reference
< XFrame
>& _xFrame
,
336 const String
& rClearFormatKey
,
337 const String
& rMoreKey
,
340 ComboBox( pParent
, SVX_RES( RID_SVXTBX_STYLE
) ),
342 eStyleFamily( eFamily
),
345 m_xDispatchProvider( rDispatchProvider
),
347 m_aCommand ( rCommand
),
348 aClearFormatKey ( rClearFormatKey
),
349 aMoreKey ( rMoreKey
),
350 bInSpecialMode ( bInSpec
)
352 aLogicalSize
= PixelToLogic( GetSizePixel(), MAP_APPFONT
);
353 EnableAutocomplete( sal_True
);
354 EnableUserDraw( true );
355 SetUserItemSize( Size( 0, 30 ) );
358 SvxStyleBox_Impl::~SvxStyleBox_Impl()
362 // -----------------------------------------------------------------------
364 void SvxStyleBox_Impl::ReleaseFocus()
371 if ( m_xFrame
.is() && m_xFrame
->getContainerWindow().is() )
372 m_xFrame
->getContainerWindow()->setFocus();
375 // -----------------------------------------------------------------------
377 void SvxStyleBox_Impl::Select()
379 // Tell base class about selection so that AT get informed about it.
382 if ( !IsTravelSelect() )
384 OUString
aSearchEntry( GetText() );
385 bool bDoIt
= true, bClear
= false;
388 if( aSearchEntry
== aClearFormatKey
&& GetSelectEntryPos() == 0 )
390 aSearchEntry
= sDefaultStyle
;
392 //not only apply default style but also call 'ClearFormatting'
393 Sequence
< PropertyValue
> aEmptyVals
;
394 SfxToolBoxControl::Dispatch( m_xDispatchProvider
, OUString(".uno:ResetAttributes"),
397 else if( aSearchEntry
== aMoreKey
&& GetSelectEntryPos() == ( GetEntryCount() - 1 ) )
399 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
400 DBG_ASSERT( pViewFrm
, "SvxStyleBox_Impl::Select(): no viewframe" );
401 pViewFrm
->ShowChildWindow( SID_STYLE_DESIGNER
);
402 SfxChildWindow
* pChildWin
= pViewFrm
->GetChildWindow( SID_STYLE_DESIGNER
);
403 if ( pChildWin
&& pChildWin
->GetWindow() )
405 static_cast< SfxTemplateDialogWrapper
* >( pChildWin
)->SetParagraphFamily();
406 static_cast< SfxDockingWindow
* >( pChildWin
->GetWindow() )->AutoShow( sal_True
);
407 Application::PostUserEvent(
408 STATIC_LINK( 0, SvxStyleBox_Impl
, FocusHdl_Impl
), pChildWin
->GetWindow() );
414 //Do we need to create a new style?
415 SfxObjectShell
*pShell
= SfxObjectShell::Current();
416 SfxStyleSheetBasePool
* pPool
= pShell
->GetStyleSheetPool();
417 SfxStyleSheetBase
* pStyle
= NULL
;
423 pPool
->SetSearchMask( eStyleFamily
, SFXSTYLEBIT_ALL
);
425 pStyle
= pPool
->First();
426 while ( pStyle
&& OUString( pStyle
->GetName() ) != aSearchEntry
)
427 pStyle
= pPool
->Next();
432 // cannot find the style for whatever reason
433 // therefore create a new style
437 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
438 This instance may be deleted in the meantime (i.e. when a dialog is opened
439 while in Dispatch()), accessing members will crash in this case. */
445 SetText( aSearchEntry
);
448 Sequence
< PropertyValue
> aArgs( 2 );
449 aArgs
[0].Value
= makeAny( OUString( aSearchEntry
) );
450 aArgs
[1].Name
= OUString("Family");
451 aArgs
[1].Value
= makeAny( sal_Int16( eStyleFamily
));
454 aArgs
[0].Name
= OUString("Param");
455 SfxToolBoxControl::Dispatch( m_xDispatchProvider
, OUString(".uno:StyleNewByExample"), aArgs
);
459 aArgs
[0].Name
= OUString("Template");
460 SfxToolBoxControl::Dispatch( m_xDispatchProvider
, m_aCommand
, aArgs
);
465 // -----------------------------------------------------------------------
467 void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily
)
469 eStyleFamily
= eNewFamily
;
472 // -----------------------------------------------------------------------
474 long SvxStyleBox_Impl::PreNotify( NotifyEvent
& rNEvt
)
476 sal_uInt16 nType
= rNEvt
.GetType();
478 if ( EVENT_MOUSEBUTTONDOWN
== nType
|| EVENT_GETFOCUS
== nType
)
479 nCurSel
= GetSelectEntryPos();
480 else if ( EVENT_LOSEFOCUS
== nType
)
482 // don't handle before our Select() is called
483 if ( !HasFocus() && !HasChildPathFocus() )
484 SetText( GetSavedValue() );
486 return ComboBox::PreNotify( rNEvt
);
489 // -----------------------------------------------------------------------
491 long SvxStyleBox_Impl::Notify( NotifyEvent
& rNEvt
)
495 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
497 sal_uInt16 nCode
= rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
504 if ( KEY_TAB
== nCode
)
513 SelectEntryPos( nCurSel
);
519 return nHandled
? nHandled
: ComboBox::Notify( rNEvt
);
522 void SvxStyleBox_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
524 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
525 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
527 SetSizePixel(LogicToPixel(aLogicalSize
, MAP_APPFONT
));
528 Size
aDropSize( aLogicalSize
.Width(), LOGICAL_EDIT_HEIGHT
);
529 SetDropDownSizePixel(LogicToPixel(aDropSize
, MAP_APPFONT
));
532 ComboBox::DataChanged( rDCEvt
);
535 void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange
)
537 ComboBox::StateChanged( nStateChange
);
539 if ( nStateChange
== STATE_CHANGE_VISIBLE
)
541 bVisible
= IsReallyVisible();
542 if ( aVisibilityListener
.IsSet() )
543 aVisibilityListener
.Call( this );
545 else if ( nStateChange
== STATE_CHANGE_INITSHOW
)
548 if ( aVisibilityListener
.IsSet() )
549 aVisibilityListener
.Call( this );
553 void SvxStyleBox_Impl::UserDraw( const UserDrawEvent
& rUDEvt
)
555 sal_uInt16 nItem
= rUDEvt
.GetItemId();
557 if ( nItem
== 0 || nItem
== GetEntryCount() - 1 )
559 // draw the non-style entries, ie. "Clear Formatting" or "More..."
560 DrawEntry( rUDEvt
, true, true );
564 SfxObjectShell
*pShell
= SfxObjectShell::Current();
565 SfxStyleSheetBasePool
* pPool
= pShell
->GetStyleSheetPool();
566 SfxStyleSheetBase
* pStyle
= NULL
;
568 OUString
aStyleName( GetEntry( nItem
) );
572 pPool
->SetSearchMask( eStyleFamily
, SFXSTYLEBIT_ALL
);
574 pStyle
= pPool
->First();
575 while ( pStyle
&& OUString( pStyle
->GetName() ) != aStyleName
)
576 pStyle
= pPool
->Next();
581 // cannot find the style for whatever reason
582 DrawEntry( rUDEvt
, true, true );
586 const SfxItemSet
& aItemSet
= pStyle
->GetItemSet();
588 const SvxFontItem
*pFontItem
= static_cast< const SvxFontItem
* >( aItemSet
.GetItem( SID_ATTR_CHAR_FONT
) );
589 const SvxFontHeightItem
*pFontHeightItem
= static_cast< const SvxFontHeightItem
* >( aItemSet
.GetItem( SID_ATTR_CHAR_FONTHEIGHT
) );
591 if ( pFontItem
&& pFontHeightItem
)
593 OutputDevice
*pDevice
= rUDEvt
.GetDevice();
595 Size
aFontSize( 0, pFontHeightItem
->GetHeight() );
596 Size
aPixelSize( pDevice
->LogicToPixel( aFontSize
, pShell
->GetMapUnit() ) );
598 // setup the font properties
599 Font
aFont( pFontItem
->GetFamilyName(), pFontItem
->GetStyleName(), aPixelSize
);
601 const SfxPoolItem
*pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_WEIGHT
);
603 aFont
.SetWeight( static_cast< const SvxWeightItem
* >( pItem
)->GetWeight() );
605 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_POSTURE
);
607 aFont
.SetItalic( static_cast< const SvxPostureItem
* >( pItem
)->GetPosture() );
609 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_CONTOUR
);
611 aFont
.SetOutline( static_cast< const SvxContourItem
* >( pItem
)->GetValue() );
613 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_SHADOWED
);
615 aFont
.SetShadow( static_cast< const SvxShadowedItem
* >( pItem
)->GetValue() );
617 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_RELIEF
);
619 aFont
.SetRelief( static_cast< FontRelief
>( static_cast< const SvxCharReliefItem
* >( pItem
)->GetValue() ) );
621 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_UNDERLINE
);
623 aFont
.SetUnderline( static_cast< const SvxUnderlineItem
* >( pItem
)->GetLineStyle() );
625 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_OVERLINE
);
627 aFont
.SetOverline( static_cast< FontUnderline
>( static_cast< const SvxOverlineItem
* >( pItem
)->GetValue() ) );
629 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_STRIKEOUT
);
631 aFont
.SetStrikeout( static_cast< const SvxCrossedOutItem
* >( pItem
)->GetStrikeout() );
633 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_EMPHASISMARK
);
635 aFont
.SetEmphasisMark( static_cast< const SvxEmphasisMarkItem
* >( pItem
)->GetEmphasisMark() );
637 // setup the device & draw
638 Font
aOldFont( pDevice
->GetFont() );
639 Color
aOldColor( pDevice
->GetTextColor() );
640 Color
aOldFillColor( pDevice
->GetFillColor() );
642 pDevice
->SetFont( aFont
);
644 // text color, when we are not selected
645 pItem
= aItemSet
.GetItem( SID_ATTR_CHAR_COLOR
);
646 if ( pItem
&& rUDEvt
.GetItemId() != GetSelectEntryPos() )
648 Color
aColor( static_cast< const SvxColorItem
* >( pItem
)->GetValue() );
649 if ( aColor
!= COL_AUTO
)
650 pDevice
->SetTextColor( aColor
);
654 pItem
= aItemSet
.GetItem( SID_ATTR_BRUSH
);
655 if ( pItem
&& rUDEvt
.GetItemId() != GetSelectEntryPos() )
657 Color
aColor( static_cast< const SvxBrushItem
* >( pItem
)->GetColor() );
658 if ( aColor
!= COL_AUTO
)
660 pDevice
->SetFillColor( aColor
);
661 pDevice
->DrawRect( rUDEvt
.GetRect() );
665 // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as
666 // nBorder, and we are adding 1 in order to look better when
667 // italics is present
668 const int nLeftDistance
= 8;
671 pDevice
->GetTextBoundRect( aTextRect
, aStyleName
);
673 Point
aPos( rUDEvt
.GetRect().TopLeft() );
674 aPos
.X() += nLeftDistance
;
675 if ( aTextRect
.Bottom() > rUDEvt
.GetRect().GetHeight() )
677 // the text does not fit, adjust the font size
678 double ratio
= static_cast< double >( rUDEvt
.GetRect().GetHeight() ) / aTextRect
.Bottom();
679 aPixelSize
.Width() *= ratio
;
680 aPixelSize
.Height() *= ratio
;
681 aFont
.SetSize( aPixelSize
);
682 pDevice
->SetFont( aFont
);
685 aPos
.Y() += ( rUDEvt
.GetRect().GetHeight() - aTextRect
.Bottom() ) / 2;
687 pDevice
->DrawText( aPos
, aStyleName
);
689 pDevice
->SetFillColor( aOldFillColor
);
690 pDevice
->SetTextColor( aOldColor
);
691 pDevice
->SetFont( aOldFont
);
693 // draw separator, if present
694 DrawEntry( rUDEvt
, false, false );
697 DrawEntry( rUDEvt
, true, true );
702 //--------------------------------------------------------------------
704 IMPL_STATIC_LINK( SvxStyleBox_Impl
, FocusHdl_Impl
, Control
*, _pCtrl
)
712 // -----------------------------------------------------------------------
714 static bool lcl_GetDocFontList( const FontList
** ppFontList
, SvxFontNameBox_Impl
* pBox
)
716 bool bChanged
= false;
717 const SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
718 SvxFontListItem
* pFontListItem
= NULL
;
722 (SvxFontListItem
*)pDocSh
->GetItem( SID_ATTR_CHAR_FONTLIST
);
725 SAL_WNODEPRECATED_DECLARATIONS_PUSH
726 ::std::auto_ptr
<FontList
> aFontList(new FontList( pBox
));
727 SAL_WNODEPRECATED_DECLARATIONS_POP
728 *ppFontList
= aFontList
.get();
729 pBox
->SetOwnFontList(aFontList
);
735 const FontList
* pNewFontList
= pFontListItem
->GetFontList();
736 DBG_ASSERT( pNewFontList
, "Doc-FontList not available!" );
738 // No old list, but a new list
739 if ( !*ppFontList
&& pNewFontList
)
742 *ppFontList
= pNewFontList
;
747 // Comparing the font lists is not perfect.
748 // When you change the font list in the Doc, you can track
749 // changes here only on the Listbox, because ppFontList
750 // has already been updated.
752 ( ( *ppFontList
!= pNewFontList
) ||
753 pBox
->GetListCount() != pNewFontList
->GetFontNameCount() );
754 // HACK: Comparing is incomplete
757 *ppFontList
= pNewFontList
;
763 else if ( pBox
&& ( pDocSh
|| ( !pDocSh
&& !ppFontList
)))
765 // Disable box only when we have a SfxObjectShell and didn't get a font list OR
766 // we don't have a SfxObjectShell and no current font list.
767 // It's possible that we currently have no SfxObjectShell, but a current font list.
768 // See #i58471: When a user set the focus into the font name combo box and opens
769 // the help window with F1. After closing the help window, we disable the font name
770 // combo box. The SfxObjectShell::Current() method returns in that case zero. But the
771 // font list hasn't changed and therefore the combo box shouldn't be disabled!
775 // Fill the FontBox, also the new list if necessary
776 if ( pBox
&& bChanged
)
779 pBox
->Fill( *ppFontList
);
786 //========================================================================
787 // class SvxFontNameBox_Impl --------------------------------------------------
788 //========================================================================
790 SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window
* pParent
, const Reference
< XDispatchProvider
>& rDispatchProvider
,const Reference
< XFrame
>& _xFrame
, WinBits nStyle
) :
792 FontNameBox ( pParent
, nStyle
| WinBits( WB_DROPDOWN
| WB_AUTOHSCROLL
) ),
794 aLogicalSize ( 60,160 ),
797 m_xDispatchProvider( rDispatchProvider
),
801 SetSizePixel(LogicToPixel( aLogicalSize
, MAP_APPFONT
));
802 EnableControls_Impl();
803 GetSubEdit()->AddEventListener( LINK( this, SvxFontNameBox_Impl
, CheckAndMarkUnknownFont
));
806 SvxFontNameBox_Impl::~SvxFontNameBox_Impl()
808 GetSubEdit()->RemoveEventListener( LINK( this, SvxFontNameBox_Impl
, CheckAndMarkUnknownFont
));
811 // -----------------------------------------------------------------------
813 void SvxFontNameBox_Impl::FillList()
815 // Save old Selection, set back in the end
816 Selection aOldSel
= GetSelection();
817 // Did Doc-Fontlist change?
818 lcl_GetDocFontList( &pFontList
, this );
819 aCurText
= GetText();
820 SetSelection( aOldSel
);
823 IMPL_LINK( SvxFontNameBox_Impl
, CheckAndMarkUnknownFont
, VclWindowEvent
*, event
)
825 if( event
->GetId() != VCLEVENT_EDIT_MODIFY
)
827 OUString fontname
= GetSubEdit()->GetText();
828 lcl_GetDocFontList( &pFontList
, this );
829 // If the font is unknown, show it in italic.
830 Font font
= GetControlFont();
831 if( pFontList
!= NULL
&& pFontList
->IsAvailable( fontname
))
833 if( font
.GetItalic() != ITALIC_NONE
)
835 font
.SetItalic( ITALIC_NONE
);
836 SetControlFont( font
);
837 SetQuickHelpText( SVX_RESSTR( RID_SVXSTR_CHARFONTNAME
));
842 if( font
.GetItalic() != ITALIC_NORMAL
)
844 font
.SetItalic( ITALIC_NORMAL
);
845 SetControlFont( font
);
846 SetQuickHelpText( SVX_RESSTR( RID_SVXSTR_CHARFONTNAME_NOTAVAILABLE
));
852 // -----------------------------------------------------------------------
854 void SvxFontNameBox_Impl::Update( const SvxFontItem
* pFontItem
)
858 aCurFont
.SetName ( pFontItem
->GetFamilyName() );
859 aCurFont
.SetFamily ( pFontItem
->GetFamily() );
860 aCurFont
.SetStyleName ( pFontItem
->GetStyleName() );
861 aCurFont
.SetPitch ( pFontItem
->GetPitch() );
862 aCurFont
.SetCharSet ( pFontItem
->GetCharSet() );
864 OUString aCurName
= aCurFont
.GetName();
865 if ( GetText() != aCurName
)
869 // -----------------------------------------------------------------------
871 long SvxFontNameBox_Impl::PreNotify( NotifyEvent
& rNEvt
)
873 sal_uInt16 nType
= rNEvt
.GetType();
875 if ( EVENT_MOUSEBUTTONDOWN
== nType
|| EVENT_GETFOCUS
== nType
)
877 EnableControls_Impl();
880 return FontNameBox::PreNotify( rNEvt
);
883 // -----------------------------------------------------------------------
885 long SvxFontNameBox_Impl::Notify( NotifyEvent
& rNEvt
)
888 mbEndPreview
= false;
889 if ( rNEvt
.GetType() == EVENT_KEYUP
)
892 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
894 sal_uInt16 nCode
= rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
901 if ( KEY_TAB
== nCode
)
916 else if ( EVENT_LOSEFOCUS
== rNEvt
.GetType() )
918 Window
* pFocusWin
= Application::GetFocusWindow();
919 if ( !HasFocus() && GetSubEdit() != pFocusWin
)
920 SetText( GetSavedValue() );
925 return nHandled
? nHandled
: FontNameBox::Notify( rNEvt
);
928 // ---------------------------------------------------------------------------
929 void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
931 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
932 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
934 SetSizePixel(LogicToPixel(aLogicalSize
, MAP_APPFONT
));
935 Size
aDropSize( aLogicalSize
.Width(), LOGICAL_EDIT_HEIGHT
);
936 SetDropDownSizePixel(LogicToPixel(aDropSize
, MAP_APPFONT
));
939 FontNameBox::DataChanged( rDCEvt
);
942 // -----------------------------------------------------------------------
944 void SvxFontNameBox_Impl::ReleaseFocus_Impl()
951 if ( m_xFrame
.is() && m_xFrame
->getContainerWindow().is() )
952 m_xFrame
->getContainerWindow()->setFocus();
955 // -----------------------------------------------------------------------
957 void SvxFontNameBox_Impl::EnableControls_Impl()
959 SvtFontOptions aFontOpt
;
960 sal_Bool bEnable
= aFontOpt
.IsFontHistoryEnabled();
961 sal_uInt16 nEntries
= bEnable
? MAX_MRU_FONTNAME_ENTRIES
: 0;
962 if ( GetMaxMRUCount() != nEntries
)
964 // refill in the next GetFocus-Handler
967 SetMaxMRUCount( nEntries
);
970 bEnable
= aFontOpt
.IsFontWYSIWYGEnabled();
971 EnableWYSIWYG( bEnable
);
974 // -----------------------------------------------------------------------
976 void SvxFontNameBox_Impl::UserDraw( const UserDrawEvent
& rUDEvt
)
978 FontNameBox::UserDraw( rUDEvt
);
980 // Hack - GetStyle now contains the currently
981 // selected item in the list box
982 // ItemId contains the id of the current item to draw
984 if ( rUDEvt
.GetItemId() == rUDEvt
.GetStyle() )
986 Sequence
< PropertyValue
> aArgs( 1 );
987 FontInfo
aInfo( pFontList
->Get( GetEntry( rUDEvt
.GetItemId() ),
988 aCurFont
.GetWeight(),
989 aCurFont
.GetItalic() ) );
991 SvxFontItem
aFontItem( aInfo
.GetFamily(),
993 aInfo
.GetStyleName(),
996 SID_ATTR_CHAR_FONT
);
997 aFontItem
.QueryValue( aArgs
[0].Value
);
998 aArgs
[0].Name
= OUString( "CharPreviewFontName" );
999 SfxToolBoxControl::Dispatch( m_xDispatchProvider
,
1000 OUString( ".uno:CharPreviewFontName" ),
1005 void SvxFontNameBox_Impl::Select()
1007 FontNameBox::Select();
1009 Sequence
< PropertyValue
> aArgs( 1 );
1010 std::auto_ptr
<SvxFontItem
> pFontItem
;
1013 FontInfo
aInfo( pFontList
->Get( GetText(),
1014 aCurFont
.GetWeight(),
1015 aCurFont
.GetItalic() ) );
1018 pFontItem
.reset( new SvxFontItem( aInfo
.GetFamily(),
1020 aInfo
.GetStyleName(),
1023 SID_ATTR_CHAR_FONT
) );
1026 pFontItem
->QueryValue( a
);
1029 if ( !IsTravelSelect() )
1031 // #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1032 // This instance may be deleted in the meantime (i.e. when a dialog is opened
1033 // while in Dispatch()), accessing members will crash in this case.
1034 ReleaseFocus_Impl();
1036 if ( pFontItem
.get() )
1038 aArgs
[0].Name
= OUString( "CharFontName" );
1039 SfxToolBoxControl::Dispatch( m_xDispatchProvider
,
1040 OUString( ".uno:CharFontName" ),
1051 if ( pFontItem
.get() )
1053 aArgs
[0].Name
= OUString( "CharPreviewFontName" );
1054 SfxToolBoxControl::Dispatch( m_xDispatchProvider
,
1055 OUString( ".uno:CharPreviewFontName" ),
1061 //========================================================================
1062 // class SvxColorWindow_Impl --------------------------------------------------
1063 //========================================================================
1064 #ifndef WB_NO_DIRECTSELECT
1065 #define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
1068 SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString
& rCommand
,
1070 const Reference
< XFrame
>& rFrame
,
1071 const String
& rWndTitle
,
1072 Window
* pParentWindow
,
1073 const ::Color rLastColor
) :
1075 SfxPopupWindow( nSlotId
, rFrame
, pParentWindow
, WinBits( WB_STDPOPUP
| WB_OWNERDRAWDECORATION
) ),
1077 theSlotId( nSlotId
),
1078 aColorSet( this, WinBits( WB_ITEMBORDER
| WB_NAMEFIELD
| WB_3DLOOK
| WB_NO_DIRECTSELECT
) ),
1079 maCommand( rCommand
),
1080 mLastColor( rLastColor
)
1083 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
1084 const SfxPoolItem
* pItem
= NULL
;
1085 XColorListRef pColorList
;
1088 if ( 0 != ( pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
) ) )
1089 pColorList
= ( (SvxColorListItem
*)pItem
)->GetColorList();
1091 if ( !pColorList
.is() )
1092 pColorList
= XColorList::CreateStdColorList();
1094 if ( SID_ATTR_CHAR_COLOR_BACKGROUND
== theSlotId
|| SID_BACKGROUND_COLOR
== theSlotId
)
1096 aColorSet
.SetStyle( aColorSet
.GetStyle() | WB_NONEFIELD
);
1097 aColorSet
.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT
) );
1098 aColorSet
.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND
) );
1100 else if ( SID_ATTR_CHAR_COLOR
== theSlotId
|| SID_ATTR_CHAR_COLOR2
== theSlotId
|| SID_EXTRUSION_3D_COLOR
== theSlotId
)
1102 SfxPoolItem
* pDummy
;
1104 Reference
< XDispatchProvider
> aDisp( GetFrame()->getController(), UNO_QUERY
);
1105 SfxQueryStatus
aQueryStatus( aDisp
,
1106 SID_ATTR_AUTO_COLOR_INVALID
,
1107 OUString( ".uno:AutoColorInvalid" ));
1108 SfxItemState eState
= aQueryStatus
.QueryState( pDummy
);
1109 if( (SFX_ITEM_DEFAULT
> eState
) || ( SID_EXTRUSION_3D_COLOR
== theSlotId
) )
1111 aColorSet
.SetStyle( aColorSet
.GetStyle() | WB_NONEFIELD
);
1112 aColorSet
.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC
) );
1113 aColorSet
.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR
) );
1118 aColorSet
.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR
) );
1121 if ( pColorList
.is() )
1123 const long nColorCount(pColorList
->Count());
1124 const Size
aNewSize(aColorSet
.layoutAllVisible(nColorCount
));
1125 aColorSet
.SetOutputSizePixel(aNewSize
);
1126 static sal_Int32 nAdd
= 4;
1128 SetOutputSizePixel(Size(aNewSize
.Width() + nAdd
, aNewSize
.Height() + nAdd
));
1130 aColorSet
.addEntriesForXColorList(*pColorList
);
1133 aColorSet
.SetSelectHdl( LINK( this, SvxColorWindow_Impl
, SelectHdl
) );
1134 SetHelpId( HID_POPUP_COLOR
);
1135 aColorSet
.SetHelpId( HID_POPUP_COLOR_CTRL
);
1136 SetText( rWndTitle
);
1139 AddStatusListener( OUString( ".uno:ColorTableState" ));
1142 SvxColorWindow_Impl::~SvxColorWindow_Impl()
1146 void SvxColorWindow_Impl::KeyInput( const KeyEvent
& rKEvt
)
1148 aColorSet
.KeyInput(rKEvt
);
1151 SfxPopupWindow
* SvxColorWindow_Impl::Clone() const
1153 return new SvxColorWindow_Impl( maCommand
, theSlotId
, GetFrame(), GetText(), GetParent(), mLastColor
);
1156 // -----------------------------------------------------------------------
1158 IMPL_LINK_NOARG(SvxColorWindow_Impl
, SelectHdl
)
1160 sal_uInt16 nItemId
= aColorSet
.GetSelectItemId();
1161 SvxColorItem
aColorItem( aColorSet
.GetItemColor( nItemId
), theSlotId
);
1162 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
1163 This instance may be deleted in the meantime (i.e. when a dialog is opened
1164 while in Dispatch()), accessing members will crash in this case. */
1165 aColorSet
.SetNoSelection();
1167 if ( IsInPopupMode() )
1170 if ( !nItemId
&& ( SID_ATTR_CHAR_COLOR_BACKGROUND
== theSlotId
|| SID_BACKGROUND_COLOR
== theSlotId
) )
1172 Sequence
< PropertyValue
> aArgs
;
1173 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1177 else if ( !nItemId
&& (SID_ATTR_CHAR_COLOR
== theSlotId
|| SID_ATTR_CHAR_COLOR2
== theSlotId
|| SID_EXTRUSION_3D_COLOR
== theSlotId
) )
1179 SvxColorItem
_aColorItem( COL_AUTO
, theSlotId
);
1180 INetURLObject
aObj( maCommand
);
1183 Sequence
< PropertyValue
> aArgs( 1 );
1184 aArgs
[0].Name
= aObj
.GetURLPath();
1185 _aColorItem
.QueryValue( a
);
1187 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1193 INetURLObject
aObj( maCommand
);
1196 Sequence
< PropertyValue
> aArgs( 1 );
1197 aArgs
[0].Name
= aObj
.GetURLPath();
1198 aColorItem
.QueryValue( a
);
1200 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1208 // -----------------------------------------------------------------------
1210 void SvxColorWindow_Impl::Resize()
1212 lcl_ResizeValueSet( *this, aColorSet
);
1215 // -----------------------------------------------------------------------
1217 void SvxColorWindow_Impl::StartSelection()
1219 aColorSet
.StartSelection();
1222 // -----------------------------------------------------------------------
1224 sal_Bool
SvxColorWindow_Impl::Close()
1226 return SfxPopupWindow::Close();
1229 // -----------------------------------------------------------------------
1231 void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
1233 if (( SFX_ITEM_DISABLED
!= eState
) && pState
)
1235 if (( nSID
== SID_COLOR_TABLE
) && ( pState
->ISA( SvxColorListItem
)))
1239 XColorListRef pColorList
= ((SvxColorListItem
*)pState
)->GetColorList();
1240 const long nColorCount(pColorList
->Count());
1241 const Size
aNewSize(aColorSet
.layoutAllVisible(nColorCount
));
1242 aColorSet
.SetOutputSizePixel(aNewSize
);
1243 static sal_Int32 nAdd
= 4;
1245 SetOutputSizePixel(Size(aNewSize
.Width() + nAdd
, aNewSize
.Height() + nAdd
));
1247 aColorSet
.addEntriesForXColorList(*pColorList
);
1253 //========================================================================
1254 // class SvxFrameWindow_Impl --------------------------------------------------
1255 //========================================================================
1257 SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
) :
1259 SfxPopupWindow( nId
, rFrame
, pParentWindow
, WinBits( WB_STDPOPUP
| WB_OWNERDRAWDECORATION
) ),
1260 aFrameSet ( this, WinBits( WB_ITEMBORDER
| WB_DOUBLEBORDER
| WB_3DLOOK
| WB_NO_DIRECTSELECT
) ),
1261 bParagraphMode(sal_False
)
1265 AddStatusListener(OUString(".uno:BorderReducedMode"));
1266 aImgList
= ImageList( SVX_RES( RID_SVXIL_FRAME
) );
1270 * -------------------------------------
1271 * NONE LEFT RIGHT LEFTRIGHT
1272 * TOP BOTTOM TOPBOTTOM OUTER
1273 * -------------------------------------
1274 * HOR HORINNER VERINNER ALL <- can be switched of via bParagraphMode
1279 for ( i
=1; i
<9; i
++ )
1280 aFrameSet
.InsertItem( i
, aImgList
.GetImage(i
) );
1282 //bParagraphMode should have been set in StateChanged
1283 if ( !bParagraphMode
)
1284 for ( i
= 9; i
< 13; i
++ )
1285 aFrameSet
.InsertItem( i
, aImgList
.GetImage(i
) );
1287 aFrameSet
.SetColCount( 4 );
1288 aFrameSet
.SetSelectHdl( LINK( this, SvxFrameWindow_Impl
, SelectHdl
) );
1290 lcl_CalcSizeValueSet( *this, aFrameSet
,Size( 20, 20 ));
1292 SetHelpId( HID_POPUP_FRAME
);
1293 SetText( SVX_RESSTR(RID_SVXSTR_FRAME
) );
1294 aFrameSet
.SetAccessibleName( SVX_RESSTR(RID_SVXSTR_FRAME
) );
1298 SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
1303 SfxPopupWindow
* SvxFrameWindow_Impl::Clone() const
1305 //! HACK: How do I get the Paragraph mode?
1306 return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() );
1309 Window
* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
1314 void SvxFrameWindow_Impl::GetFocus()
1316 aFrameSet
.GrabFocus();
1319 void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
1321 SfxPopupWindow::DataChanged( rDCEvt
);
1323 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1325 aImgList
= ImageList( SVX_RES( RID_SVXIL_FRAME
) );
1327 sal_uInt16 nNumOfItems
= aFrameSet
.GetItemCount();
1329 for( sal_uInt16 i
= 1 ; i
<= nNumOfItems
; ++i
)
1330 aFrameSet
.SetItemImage( i
, aImgList
.GetImage( i
) );
1333 // -----------------------------------------------------------------------
1335 #define FRM_VALID_LEFT 0x01
1336 #define FRM_VALID_RIGHT 0x02
1337 #define FRM_VALID_TOP 0x04
1338 #define FRM_VALID_BOTTOM 0x08
1339 #define FRM_VALID_HINNER 0x10
1340 #define FRM_VALID_VINNER 0x20
1341 #define FRM_VALID_OUTER 0x0f
1342 #define FRM_VALID_ALL 0xff
1344 // By default unset lines remain unchanged.
1345 // Via Shift unset lines are reset
1347 IMPL_LINK_NOARG(SvxFrameWindow_Impl
, SelectHdl
)
1349 SvxBoxItem
aBorderOuter( SID_ATTR_BORDER_OUTER
);
1350 SvxBoxInfoItem
aBorderInner( SID_ATTR_BORDER_INNER
);
1351 SvxBorderLine theDefLine
;
1352 SvxBorderLine
*pLeft
= 0,
1356 sal_uInt16 nSel
= aFrameSet
.GetSelectItemId();
1357 sal_uInt16 nModifier
= aFrameSet
.GetModifier();
1358 sal_uInt8 nValidFlags
= 0;
1360 theDefLine
.GuessLinesWidths(theDefLine
.GetBorderLineStyle(),
1364 case 1: nValidFlags
|= FRM_VALID_ALL
;
1366 case 2: pLeft
= &theDefLine
;
1367 nValidFlags
|= FRM_VALID_LEFT
;
1369 case 3: pRight
= &theDefLine
;
1370 nValidFlags
|= FRM_VALID_RIGHT
;
1372 case 4: pLeft
= pRight
= &theDefLine
;
1373 nValidFlags
|= FRM_VALID_RIGHT
|FRM_VALID_LEFT
;
1375 case 5: pTop
= &theDefLine
;
1376 nValidFlags
|= FRM_VALID_TOP
;
1378 case 6: pBottom
= &theDefLine
;
1379 nValidFlags
|= FRM_VALID_BOTTOM
;
1381 case 7: pTop
= pBottom
= &theDefLine
;
1382 nValidFlags
|= FRM_VALID_BOTTOM
|FRM_VALID_TOP
;
1384 case 8: pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1385 nValidFlags
|= FRM_VALID_OUTER
;
1390 pTop
= pBottom
= &theDefLine
;
1391 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_HORI
);
1392 aBorderInner
.SetLine( NULL
, BOXINFO_LINE_VERT
);
1393 nValidFlags
|= FRM_VALID_HINNER
|FRM_VALID_TOP
|FRM_VALID_BOTTOM
;
1396 case 10: // HORINNER
1397 pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1398 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_HORI
);
1399 aBorderInner
.SetLine( NULL
, BOXINFO_LINE_VERT
);
1400 nValidFlags
|= FRM_VALID_RIGHT
|FRM_VALID_LEFT
|FRM_VALID_HINNER
|FRM_VALID_TOP
|FRM_VALID_BOTTOM
;
1403 case 11: // VERINNER
1404 pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1405 aBorderInner
.SetLine( NULL
, BOXINFO_LINE_HORI
);
1406 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_VERT
);
1407 nValidFlags
|= FRM_VALID_RIGHT
|FRM_VALID_LEFT
|FRM_VALID_VINNER
|FRM_VALID_TOP
|FRM_VALID_BOTTOM
;
1411 pLeft
= pRight
= pTop
= pBottom
= &theDefLine
;
1412 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_HORI
);
1413 aBorderInner
.SetLine( &theDefLine
, BOXINFO_LINE_VERT
);
1414 nValidFlags
|= FRM_VALID_ALL
;
1420 aBorderOuter
.SetLine( pLeft
, BOX_LINE_LEFT
);
1421 aBorderOuter
.SetLine( pRight
, BOX_LINE_RIGHT
);
1422 aBorderOuter
.SetLine( pTop
, BOX_LINE_TOP
);
1423 aBorderOuter
.SetLine( pBottom
, BOX_LINE_BOTTOM
);
1425 if(nModifier
== KEY_SHIFT
)
1426 nValidFlags
|= FRM_VALID_ALL
;
1427 aBorderInner
.SetValid( VALID_TOP
, 0 != (nValidFlags
&FRM_VALID_TOP
));
1428 aBorderInner
.SetValid( VALID_BOTTOM
, 0 != (nValidFlags
&FRM_VALID_BOTTOM
));
1429 aBorderInner
.SetValid( VALID_LEFT
, 0 != (nValidFlags
&FRM_VALID_LEFT
));
1430 aBorderInner
.SetValid( VALID_RIGHT
, 0 != (nValidFlags
&FRM_VALID_RIGHT
));
1431 aBorderInner
.SetValid( VALID_HORI
, 0 != (nValidFlags
&FRM_VALID_HINNER
));
1432 aBorderInner
.SetValid( VALID_VERT
, 0 != (nValidFlags
&FRM_VALID_VINNER
));
1433 aBorderInner
.SetValid( VALID_DISTANCE
, sal_True
);
1434 aBorderInner
.SetValid( VALID_DISABLE
, sal_False
);
1436 if ( IsInPopupMode() )
1440 Sequence
< PropertyValue
> aArgs( 2 );
1441 aArgs
[0].Name
= OUString( "OuterBorder" );
1442 aBorderOuter
.QueryValue( a
);
1444 aArgs
[1].Name
= OUString( "InnerBorder" );
1445 aBorderInner
.QueryValue( a
);
1448 /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
1449 This instance may be deleted in the meantime (i.e. when a dialog is opened
1450 while in Dispatch()), accessing members will crash in this case. */
1451 aFrameSet
.SetNoSelection();
1453 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1454 OUString( ".uno:SetBorderStyle" ),
1459 // -----------------------------------------------------------------------
1461 void SvxFrameWindow_Impl::Resize()
1463 lcl_ResizeValueSet( *this, aFrameSet
);
1466 // -----------------------------------------------------------------------
1468 void SvxFrameWindow_Impl::StateChanged(
1470 sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
1473 if ( pState
&& nSID
== SID_BORDER_REDUCED_MODE
)
1475 const SfxBoolItem
* pItem
= PTR_CAST( SfxBoolItem
, pState
);
1479 bParagraphMode
= (sal_Bool
)pItem
->GetValue();
1480 //initial calls mustn't insert or remove elements
1481 if(aFrameSet
.GetItemCount())
1483 bool bTableMode
= ( aFrameSet
.GetItemCount() == 12 );
1484 bool bResize
= false;
1486 if ( bTableMode
&& bParagraphMode
)
1488 for ( sal_uInt16 i
= 9; i
< 13; i
++ )
1489 aFrameSet
.RemoveItem(i
);
1492 else if ( !bTableMode
&& !bParagraphMode
)
1494 for ( sal_uInt16 i
= 9; i
< 13; i
++ )
1495 aFrameSet
.InsertItem( i
, aImgList
.GetImage(i
) );
1501 lcl_CalcSizeValueSet( *this, aFrameSet
,Size( 20, 20 ));
1506 SfxPopupWindow::StateChanged( nSID
, eState
, pState
);
1509 // -----------------------------------------------------------------------
1511 void SvxFrameWindow_Impl::StartSelection()
1513 aFrameSet
.StartSelection();
1516 // -----------------------------------------------------------------------
1518 sal_Bool
SvxFrameWindow_Impl::Close()
1520 return SfxPopupWindow::Close();
1523 //========================================================================
1524 // class SvxLineWindow_Impl --------------------------------------------------
1525 //========================================================================
1526 static Color
lcl_mediumColor( Color aMain
, Color
/*aDefault*/ )
1528 return SvxBorderLine::threeDMediumColor( aMain
);
1531 SvxLineWindow_Impl::SvxLineWindow_Impl( sal_uInt16 nId
, const Reference
< XFrame
>& rFrame
, Window
* pParentWindow
) :
1533 SfxPopupWindow( nId
, rFrame
, pParentWindow
, WinBits( WB_STDPOPUP
| WB_OWNERDRAWDECORATION
| WB_AUTOSIZE
) ),
1534 m_aLineStyleLb( this )
1538 Reference
< lang::XServiceInfo
> xServices( rFrame
->getController()->getModel(), UNO_QUERY_THROW
);
1539 m_bIsWriter
= xServices
->supportsService(OUString("com.sun.star.text.TextDocument"));
1541 catch(const uno::Exception
& )
1545 m_aLineStyleLb
.setPosSizePixel( 2, 2, 110, 140 );
1546 SetOutputSizePixel( Size( 114, 144 ) );
1548 m_aLineStyleLb
.SetSourceUnit( FUNIT_TWIP
);
1549 m_aLineStyleLb
.SetNone( SVX_RESSTR(RID_SVXSTR_NONE
) );
1551 using namespace table::BorderLineStyle
;
1552 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( SOLID
), SOLID
);
1553 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( DOTTED
), DOTTED
);
1554 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( DASHED
), DASHED
);
1557 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE
), DOUBLE
);
1558 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP
), THINTHICK_SMALLGAP
, 20 );
1559 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP
), THINTHICK_MEDIUMGAP
);
1560 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP
), THINTHICK_LARGEGAP
);
1561 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP
), THICKTHIN_SMALLGAP
, 20 );
1562 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP
), THICKTHIN_MEDIUMGAP
);
1563 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP
), THICKTHIN_LARGEGAP
);
1565 // Engraved / Embossed
1566 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED
), EMBOSSED
, 15,
1567 &SvxBorderLine::threeDLightColor
, &SvxBorderLine::threeDDarkColor
,
1569 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED
), ENGRAVED
, 15,
1570 &SvxBorderLine::threeDDarkColor
, &SvxBorderLine::threeDLightColor
,
1574 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( OUTSET
), OUTSET
, 10,
1575 &SvxBorderLine::lightColor
, &SvxBorderLine::darkColor
);
1576 m_aLineStyleLb
.InsertEntry( SvxBorderLine::getWidthImpl( INSET
), INSET
, 10,
1577 &SvxBorderLine::darkColor
, &SvxBorderLine::lightColor
);
1578 m_aLineStyleLb
.SetWidth( 20 ); // 1pt by default
1580 m_aLineStyleLb
.SetSelectHdl( LINK( this, SvxLineWindow_Impl
, SelectHdl
) );
1582 SetHelpId( HID_POPUP_LINE
);
1583 SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE
) );
1584 m_aLineStyleLb
.Show();
1587 SfxPopupWindow
* SvxLineWindow_Impl::Clone() const
1589 return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() );
1592 // -----------------------------------------------------------------------
1594 IMPL_LINK_NOARG(SvxLineWindow_Impl
, SelectHdl
)
1596 SvxLineItem
aLineItem( SID_FRAME_LINESTYLE
);
1597 SvxBorderStyle nStyle
= SvxBorderStyle( m_aLineStyleLb
.GetSelectEntryStyle() );
1599 if ( m_aLineStyleLb
.GetSelectEntryPos( ) > 0 )
1602 aTmp
.SetBorderLineStyle( nStyle
);
1603 aTmp
.SetWidth( 20 ); // TODO Make it depend on a width field
1604 aLineItem
.SetLine( &aTmp
);
1607 aLineItem
.SetLine( NULL
);
1609 if ( IsInPopupMode() )
1613 Sequence
< PropertyValue
> aArgs( 1 );
1614 aArgs
[0].Name
= OUString( "LineStyle" );
1615 aLineItem
.QueryValue( a
, m_bIsWriter
? CONVERT_TWIPS
: 0 );
1618 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
1619 OUString( ".uno:LineStyle" ),
1624 // -----------------------------------------------------------------------
1626 void SvxLineWindow_Impl::Resize()
1628 m_aLineStyleLb
.Resize();
1631 // -----------------------------------------------------------------------
1633 sal_Bool
SvxLineWindow_Impl::Close()
1635 return SfxPopupWindow::Close();
1638 // -----------------------------------------------------------------------
1640 Window
* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
1642 return &m_aLineStyleLb
;
1645 // -----------------------------------------------------------------------
1647 void SvxLineWindow_Impl::GetFocus()
1649 m_aLineStyleLb
.GrabFocus();
1652 void SvxLineWindow_Impl::DataChanged( const DataChangedEvent
& rDCEvt
)
1654 SfxPopupWindow::DataChanged( rDCEvt
);
1656 if( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1664 // -----------------------------------------------------------------------
1666 //########################################################################
1669 //========================================================================
1670 // class SfxStyleControllerItem_Impl ------------------------------------------
1671 //========================================================================
1673 SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl(
1674 const Reference
< XDispatchProvider
>& rDispatchProvider
,
1675 sal_uInt16 nSlotId
, // Family-ID
1676 const OUString
& rCommand
, // .uno: command bound to this item
1677 SvxStyleToolBoxControl
& rTbxCtl
) // Controller-Instanz, dem dieses Item zugeordnet ist.
1678 : SfxStatusListener( rDispatchProvider
, nSlotId
, rCommand
),
1683 // -----------------------------------------------------------------------
1685 void SfxStyleControllerItem_Impl::StateChanged(
1686 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
1690 case SID_STYLE_FAMILY1
:
1691 case SID_STYLE_FAMILY2
:
1692 case SID_STYLE_FAMILY3
:
1693 case SID_STYLE_FAMILY4
:
1694 case SID_STYLE_FAMILY5
:
1696 const sal_uInt16 nIdx
= GetId() - SID_STYLE_FAMILY_START
;
1698 if ( SFX_ITEM_AVAILABLE
== eState
)
1700 const SfxTemplateItem
* pStateItem
=
1701 PTR_CAST( SfxTemplateItem
, pState
);
1702 DBG_ASSERT( pStateItem
!= NULL
, "SfxTemplateItem expected" );
1703 rControl
.SetFamilyState( nIdx
, pStateItem
);
1706 rControl
.SetFamilyState( nIdx
, NULL
);
1712 //########################################################################
1714 //========================================================================
1715 // class SvxStyleToolBoxControl ------------------------------------------
1716 //========================================================================
1718 struct SvxStyleToolBoxControl::Impl
1722 ::std::vector
< OUString
> aDefaultStyles
;
1723 sal_Bool bSpecModeWriter
;
1724 sal_Bool bSpecModeCalc
;
1727 :aClearForm ( SVX_RESSTR( RID_SVXSTR_CLEARFORM
) )
1728 ,aMore ( SVX_RESSTR( RID_SVXSTR_MORE
) )
1729 ,bSpecModeWriter ( sal_False
)
1730 ,bSpecModeCalc ( sal_False
)
1735 void InitializeStyles(Reference
< frame::XModel
> xModel
)
1737 //now convert the default style names to the localized names
1740 Reference
< style::XStyleFamiliesSupplier
> xStylesSupplier( xModel
, UNO_QUERY_THROW
);
1741 Reference
< lang::XServiceInfo
> xServices( xModel
, UNO_QUERY_THROW
);
1742 bSpecModeWriter
= xServices
->supportsService(OUString("com.sun.star.text.TextDocument"));
1745 Reference
<container::XNameAccess
> xParaStyles
;
1746 xStylesSupplier
->getStyleFamilies()->getByName(OUString("ParagraphStyles")) >>=
1748 static const sal_Char
* aWriterStyles
[] =
1758 for( sal_uInt32 nStyle
= 0; nStyle
< sizeof( aWriterStyles
) / sizeof( sal_Char
*); ++nStyle
)
1762 Reference
< beans::XPropertySet
> xStyle
;
1763 xParaStyles
->getByName( OUString::createFromAscii( aWriterStyles
[nStyle
] )) >>= xStyle
;
1765 xStyle
->getPropertyValue(OUString("DisplayName")) >>= sName
;
1766 if( !sName
.isEmpty() )
1767 aDefaultStyles
.push_back(sName
);
1769 catch( const uno::Exception
& )
1775 bSpecModeCalc
= xServices
->supportsService(OUString(
1776 "com.sun.star.sheet.SpreadsheetDocument"))))
1778 static const sal_Char
* aCalcStyles
[] =
1785 Reference
<container::XNameAccess
> xCellStyles
;
1786 xStylesSupplier
->getStyleFamilies()->getByName(
1787 OUString("CellStyles")) >>=
1789 for( sal_uInt32 nStyle
= 0; nStyle
< sizeof( aCalcStyles
) / sizeof( sal_Char
*); ++nStyle
)
1793 const OUString
sStyleName( OUString::createFromAscii( aCalcStyles
[nStyle
] ) );
1794 if( xCellStyles
->hasByName( sStyleName
) )
1796 Reference
< beans::XPropertySet
> xStyle( xCellStyles
->getByName( sStyleName
), UNO_QUERY_THROW
);
1798 xStyle
->getPropertyValue(OUString("DisplayName")) >>= sName
;
1799 if( !sName
.isEmpty() )
1800 aDefaultStyles
.push_back(sName
);
1803 catch( const uno::Exception
& )
1808 catch(const uno::Exception
& )
1810 OSL_FAIL("error while initializing style names");
1816 // mapping table from bound items. BE CAREFUL this table must be in the
1817 // same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n
1818 // MAX_FAMILIES must also be correctly set!
1819 static const char* StyleSlotToStyleCommand
[MAX_FAMILIES
] =
1825 ".uno:TemplateFamily5"
1828 SvxStyleToolBoxControl::SvxStyleToolBoxControl(
1829 sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
)
1830 : SfxToolBoxControl ( nSlotId
, nId
, rTbx
),
1831 pStyleSheetPool ( NULL
),
1832 nActFamily ( 0xffff ),
1835 for ( sal_uInt16 i
=0; i
<MAX_FAMILIES
; i
++ )
1838 m_xBoundItems
[i
] = Reference
< XComponent
>();
1839 pFamilyState
[i
] = NULL
;
1843 // -----------------------------------------------------------------------
1844 SvxStyleToolBoxControl::~SvxStyleToolBoxControl()
1849 // -----------------------------------------------------------------------
1850 void SAL_CALL
SvxStyleToolBoxControl::initialize( const Sequence
< Any
>& aArguments
)
1851 throw ( Exception
, RuntimeException
)
1853 SfxToolBoxControl::initialize( aArguments
);
1855 // After initialize we should have a valid frame member where we can retrieve our
1856 // dispatch provider.
1857 if ( m_xFrame
.is() )
1859 pImpl
->InitializeStyles(m_xFrame
->getController()->getModel());
1860 Reference
< XDispatchProvider
> xDispatchProvider( m_xFrame
->getController(), UNO_QUERY
);
1861 for ( sal_uInt16 i
=0; i
<MAX_FAMILIES
; i
++ )
1863 pBoundItems
[i
] = new SfxStyleControllerItem_Impl( xDispatchProvider
,
1864 SID_STYLE_FAMILY_START
+ i
,
1865 OUString::createFromAscii( StyleSlotToStyleCommand
[i
] ),
1867 m_xBoundItems
[i
] = Reference
< XComponent
>( static_cast< OWeakObject
* >( pBoundItems
[i
] ), UNO_QUERY
);
1868 pFamilyState
[i
] = NULL
;
1874 void SAL_CALL
SvxStyleToolBoxControl::dispose()
1875 throw (::com::sun::star::uno::RuntimeException
)
1877 SfxToolBoxControl::dispose();
1879 for( sal_uInt16 i
=0; i
<MAX_FAMILIES
; i
++ )
1881 if ( m_xBoundItems
[i
].is() )
1885 m_xBoundItems
[i
]->dispose();
1887 catch ( Exception
& )
1891 m_xBoundItems
[i
].clear();
1894 DELETEZ( pFamilyState
[i
] );
1896 pStyleSheetPool
= NULL
;
1900 // -----------------------------------------------------------------------
1901 void SAL_CALL
SvxStyleToolBoxControl::update() throw (RuntimeException
)
1903 // Do nothing, we will start binding our listener when we are visible.
1904 // See link SvxStyleToolBoxControl::VisibilityNotification.
1905 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
1906 if ( pBox
->IsVisible() )
1908 for ( int i
=0; i
<MAX_FAMILIES
; i
++ )
1909 pBoundItems
[i
]->ReBind();
1915 // -----------------------------------------------------------------------
1917 SfxStyleFamily
SvxStyleToolBoxControl::GetActFamily()
1919 switch ( nActFamily
-1 + SID_STYLE_FAMILY_START
)
1921 case SID_STYLE_FAMILY1
: return SFX_STYLE_FAMILY_CHAR
;
1922 case SID_STYLE_FAMILY2
: return SFX_STYLE_FAMILY_PARA
;
1923 case SID_STYLE_FAMILY3
: return SFX_STYLE_FAMILY_FRAME
;
1924 case SID_STYLE_FAMILY4
: return SFX_STYLE_FAMILY_PAGE
;
1925 case SID_STYLE_FAMILY5
: return SFX_STYLE_FAMILY_PSEUDO
;
1927 OSL_FAIL( "unknown style family" );
1930 return SFX_STYLE_FAMILY_PARA
;
1933 // -----------------------------------------------------------------------
1935 void SvxStyleToolBoxControl::FillStyleBox()
1937 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
1939 DBG_ASSERT( pStyleSheetPool
, "StyleSheetPool not found!" );
1940 DBG_ASSERT( pBox
, "Control not found!" );
1942 if ( pStyleSheetPool
&& pBox
&& nActFamily
!=0xffff )
1944 const SfxStyleFamily eFamily
= GetActFamily();
1945 sal_uInt16 nCount
= pStyleSheetPool
->Count();
1946 SfxStyleSheetBase
* pStyle
= NULL
;
1947 bool bDoFill
= false;
1949 pStyleSheetPool
->SetSearchMask( eFamily
, SFXSTYLEBIT_USED
);
1951 // Check whether fill is necessary
1952 pStyle
= pStyleSheetPool
->First();
1953 //!!! TODO: This condition isn't right any longer, because we always show some default entries
1954 //!!! so the list doesn't show the count
1955 if ( nCount
!= pBox
->GetEntryCount() )
1962 while ( pStyle
&& !bDoFill
)
1964 bDoFill
= ( pBox
->GetEntry(i
) != pStyle
->GetName() );
1965 pStyle
= pStyleSheetPool
->Next();
1972 pBox
->SetUpdateMode( sal_False
);
1977 sal_uInt32 nCnt
= pImpl
->aDefaultStyles
.size();
1979 pStyle
= pStyleSheetPool
->First();
1981 if( pImpl
->bSpecModeWriter
|| pImpl
->bSpecModeCalc
)
1986 // sort out default styles
1988 OUString
aName( pStyle
->GetName() );
1989 for( _i
= 0 ; _i
< nCnt
; ++_i
)
1991 if( pImpl
->aDefaultStyles
[_i
] == aName
)
1999 pBox
->InsertEntry( aName
);
2000 pStyle
= pStyleSheetPool
->Next();
2007 pBox
->InsertEntry( pStyle
->GetName() );
2008 pStyle
= pStyleSheetPool
->Next();
2013 if( pImpl
->bSpecModeWriter
|| pImpl
->bSpecModeCalc
)
2015 // disable sort to preserve special order
2016 WinBits nWinBits
= pBox
->GetStyle();
2017 nWinBits
&= ~WB_SORT
;
2018 pBox
->SetStyle( nWinBits
);
2020 // insert default styles
2022 sal_uInt32 nCnt
= pImpl
->aDefaultStyles
.size();
2023 sal_uInt16 nPos
= 1;
2024 for( _i
= 0 ; _i
< nCnt
; ++_i
)
2026 pBox
->InsertEntry( pImpl
->aDefaultStyles
[_i
], nPos
);
2030 pBox
->InsertEntry( pImpl
->aClearForm
, 0 );
2031 pBox
->SetSeparatorPos( 0 );
2033 pBox
->InsertEntry( pImpl
->aMore
);
2035 // enable sort again
2036 nWinBits
|= WB_SORT
;
2037 pBox
->SetStyle( nWinBits
);
2040 pBox
->SetUpdateMode( sal_True
);
2041 pBox
->SetFamily( eFamily
);
2043 sal_uInt16 nLines
= std::min( pBox
->GetEntryCount(), MAX_STYLES_ENTRIES
);
2044 pBox
->SetDropDownLineCount( nLines
);
2049 // -----------------------------------------------------------------------
2051 void SvxStyleToolBoxControl::SelectStyle( const String
& rStyleName
)
2053 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
2054 DBG_ASSERT( pBox
, "Control not found!" );
2058 // String aStrSel( pBox->GetSelectEntry() );
2059 String
aStrSel( pBox
->GetText() );
2061 if ( rStyleName
.Len() > 0 )
2063 if ( rStyleName
!= aStrSel
)
2064 // pBox->SelectEntry( rStyleName );
2065 pBox
->SetText( rStyleName
);
2068 pBox
->SetNoSelection();
2073 // -----------------------------------------------------------------------
2075 void SvxStyleToolBoxControl::Update()
2077 SfxStyleSheetBasePool
* pPool
= NULL
;
2078 SfxObjectShell
* pDocShell
= SfxObjectShell::Current();
2081 pPool
= pDocShell
->GetStyleSheetPool();
2084 for ( i
=0; i
<MAX_FAMILIES
; i
++ )
2085 if( pFamilyState
[i
] )
2088 if ( i
==MAX_FAMILIES
|| !pPool
)
2090 pStyleSheetPool
= pPool
;
2094 //--------------------------------------------------------------------
2095 const SfxTemplateItem
* pItem
= NULL
;
2097 if ( nActFamily
== 0xffff || 0 == (pItem
= pFamilyState
[nActFamily
-1]) )
2098 // Current range not within allowed ranges or default
2100 pStyleSheetPool
= pPool
;
2103 pItem
= pFamilyState
[nActFamily
-1];
2107 pItem
= pFamilyState
[nActFamily
-1];
2112 DBG_WARNING( "Unknown Family" ); // can happen
2115 else if ( pPool
!= pStyleSheetPool
)
2116 pStyleSheetPool
= pPool
;
2118 FillStyleBox(); // Decides by itself whether Fill is needed
2121 SelectStyle( pItem
->GetStyleName() );
2124 // -----------------------------------------------------------------------
2126 void SvxStyleToolBoxControl::SetFamilyState( sal_uInt16 nIdx
,
2127 const SfxTemplateItem
* pItem
)
2129 DELETEZ( pFamilyState
[nIdx
] );
2132 pFamilyState
[nIdx
] = new SfxTemplateItem( *pItem
);
2137 // -----------------------------------------------------------------------
2139 IMPL_LINK_NOARG(SvxStyleToolBoxControl
, VisibilityNotification
)
2144 // Call ReBind() && UnBind() according to visibility
2145 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)( GetToolBox().GetItemWindow( GetId() ));
2146 if ( pBox
->IsVisible() && !isBound() )
2148 for ( i
=0; i
<MAX_FAMILIES
; i
++ )
2149 pBoundItems
[i
]->ReBind();
2153 else if ( !pBox
->IsVisible() && isBound() )
2155 for ( i
=0; i
<MAX_FAMILIES
; i
++ )
2156 pBoundItems
[i
]->UnBind();
2163 // -----------------------------------------------------------------------
2165 void SvxStyleToolBoxControl::StateChanged(
2167 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
2170 sal_uInt16 nId
= GetId();
2171 ToolBox
& rTbx
= GetToolBox();
2172 SvxStyleBox_Impl
* pBox
= (SvxStyleBox_Impl
*)(rTbx
.GetItemWindow( nId
));
2173 TriState eTri
= STATE_NOCHECK
;
2175 DBG_ASSERT( pBox
, "Control not found!" );
2177 if ( SFX_ITEM_DISABLED
== eState
)
2182 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2186 case SFX_ITEM_AVAILABLE
:
2187 eTri
= ((const SfxBoolItem
*)pState
)->GetValue()
2192 case SFX_ITEM_DONTCARE
:
2193 eTri
= STATE_DONTKNOW
;
2197 rTbx
.SetItemState( nId
, eTri
);
2199 if ( SFX_ITEM_DISABLED
!= eState
)
2203 // -----------------------------------------------------------------------
2205 Window
* SvxStyleToolBoxControl::CreateItemWindow( Window
*pParent
)
2207 SvxStyleBox_Impl
* pBox
= new SvxStyleBox_Impl( pParent
,
2208 OUString( ".uno:StyleApply" ),
2209 SFX_STYLE_FAMILY_PARA
,
2210 Reference
< XDispatchProvider
>( m_xFrame
->getController(), UNO_QUERY
),
2214 pImpl
->bSpecModeWriter
|| pImpl
->bSpecModeCalc
);
2215 if( !pImpl
->aDefaultStyles
.empty())
2216 pBox
->SetDefaultStyle( pImpl
->aDefaultStyles
[0] );
2217 // Set visibility listener to bind/unbind controller
2218 pBox
->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl
, VisibilityNotification
));
2223 //========================================================================
2224 // class SvxFontNameToolBoxControl ---------------------------------------
2225 //========================================================================
2227 SvxFontNameToolBoxControl::SvxFontNameToolBoxControl(
2232 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2236 // -----------------------------------------------------------------------
2238 void SvxFontNameToolBoxControl::StateChanged(
2240 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
2243 sal_uInt16 nId
= GetId();
2244 ToolBox
& rTbx
= GetToolBox();
2245 SvxFontNameBox_Impl
* pBox
= (SvxFontNameBox_Impl
*)(rTbx
.GetItemWindow( nId
));
2247 DBG_ASSERT( pBox
, "Control not found!" );
2249 if ( SFX_ITEM_DISABLED
== eState
)
2252 pBox
->Update( (const SvxFontItem
*)NULL
);
2258 if ( SFX_ITEM_AVAILABLE
== eState
)
2260 const SvxFontItem
* pFontItem
= dynamic_cast< const SvxFontItem
* >( pState
);
2262 DBG_ASSERT( pFontItem
, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" );
2264 pBox
->Update( pFontItem
);
2267 pBox
->SetText( String() );
2271 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2274 // -----------------------------------------------------------------------
2276 Window
* SvxFontNameToolBoxControl::CreateItemWindow( Window
*pParent
)
2278 SvxFontNameBox_Impl
* pBox
= new SvxFontNameBox_Impl( pParent
,
2279 Reference
< XDispatchProvider
>( m_xFrame
->getController(), UNO_QUERY
),
2284 //========================================================================
2285 // class SvxFontColorToolBoxControl --------------------------------------
2286 //========================================================================
2288 SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
2293 : SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2294 pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
2295 nSlotId
, nId
, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW
)),
2296 mLastColor( COL_AUTO
)
2298 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2301 // -----------------------------------------------------------------------
2303 SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl()
2308 // -----------------------------------------------------------------------
2310 SfxPopupWindowType
SvxFontColorToolBoxControl::GetPopupWindowType() const
2312 return SFX_POPUPWINDOW_ONCLICK
;
2315 // -----------------------------------------------------------------------
2317 SfxPopupWindow
* SvxFontColorToolBoxControl::CreatePopupWindow()
2319 SvxColorWindow_Impl
* pColorWin
=
2320 new SvxColorWindow_Impl(
2321 OUString( ".uno:Color" ),
2322 SID_ATTR_CHAR_COLOR
,
2324 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR
),
2328 pColorWin
->StartPopupMode( &GetToolBox(),
2329 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE
);
2330 pColorWin
->StartSelection();
2331 SetPopupWindow( pColorWin
);
2335 // -----------------------------------------------------------------------
2337 void SvxFontColorToolBoxControl::StateChanged(
2339 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
2342 sal_uInt16 nId
= GetId();
2343 ToolBox
& rTbx
= GetToolBox();
2344 const SvxColorItem
* pItem
= 0;
2346 if ( SFX_ITEM_DONTCARE
!= eState
)
2347 pItem
= PTR_CAST( SvxColorItem
, pState
);
2351 pBtnUpdater
->Update( pItem
->GetValue() );
2352 mLastColor
= pItem
->GetValue();
2355 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2356 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2359 //========================================================================
2360 // class SvxColorToolBoxControl --------------------------------
2361 //========================================================================
2363 SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
2365 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2366 mLastColor( COL_AUTO
)
2368 if ( nSlotId
== SID_BACKGROUND_COLOR
)
2369 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2371 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
2373 pBtnUpdater
= new ::svx::ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox() );
2376 // -----------------------------------------------------------------------
2378 SvxColorToolBoxControl::~SvxColorToolBoxControl()
2383 // -----------------------------------------------------------------------
2385 SfxPopupWindowType
SvxColorToolBoxControl::GetPopupWindowType() const
2387 return SFX_POPUPWINDOW_ONCLICK
;
2390 // -----------------------------------------------------------------------
2392 SfxPopupWindow
* SvxColorToolBoxControl::CreatePopupWindow()
2394 sal_uInt16 nResId
= GetSlotId() == SID_BACKGROUND_COLOR
?
2395 RID_SVXSTR_BACKGROUND
: RID_SVXSTR_COLOR
;
2396 SvxColorWindow_Impl
* pColorWin
= new SvxColorWindow_Impl(
2397 OUString( ".uno:BackgroundColor" ),
2398 SID_BACKGROUND_COLOR
,
2404 pColorWin
->StartPopupMode( &GetToolBox(),
2405 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE
);
2406 pColorWin
->StartSelection();
2407 SetPopupWindow( pColorWin
);
2411 // -----------------------------------------------------------------------
2413 void SvxColorToolBoxControl::StateChanged(
2414 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
2416 const SvxColorItem
* pItem
= 0;
2417 if ( SFX_ITEM_DONTCARE
!= eState
)
2418 pItem
= PTR_CAST( SvxColorItem
, pState
);
2421 pBtnUpdater
->Update( pItem
->GetValue() );
2422 mLastColor
= pItem
->GetValue();
2425 sal_uInt16 nId
= GetId();
2426 ToolBox
& rTbx
= GetToolBox();
2427 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2428 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2431 //========================================================================
2432 // class SvxColorExtToolBoxControl ----------------------------------------
2433 //========================================================================
2435 The initial color shown on the button is set in /core/svx/source/tbxctrls/tbxcolorupdate.cxx
2436 (ToolboxButtonColorUpdater::ToolboxButtonColorUpdater()) .
2437 The initial color used by the button is set in /core/svx/source/tbxcntrls/tbcontrl.cxx
2438 (SvxColorExtToolBoxControl::SvxColorExtToolBoxControl())
2439 and in case of writer for text(background)color also in /core/sw/source/ui/docvw/edtwin.cxx
2440 (SwEditWin::aTextBackColor and SwEditWin::aTextBackColor)
2443 SvxColorExtToolBoxControl::SvxColorExtToolBoxControl(
2448 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2450 mLastColor( COL_AUTO
)
2454 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
2455 bChoiceFromPalette
= sal_False
;
2457 // The following commands are available at the various modules
2460 case SID_ATTR_CHAR_COLOR
:
2461 addStatusListener( OUString( ".uno:Color" ));
2462 nMode
= TBX_UPDATER_MODE_CHAR_COLOR_NEW
;
2463 mLastColor
= COL_RED
;
2466 case SID_ATTR_CHAR_COLOR2
:
2467 addStatusListener( OUString( ".uno:CharColorExt" ));
2468 nMode
= TBX_UPDATER_MODE_CHAR_COLOR_NEW
;
2469 mLastColor
= COL_RED
;
2472 case SID_BACKGROUND_COLOR
:
2473 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
2475 addStatusListener( OUString( ".uno:CharBackgroundExt" ));
2476 nMode
= TBX_UPDATER_MODE_CHAR_COLOR_NEW
;
2477 mLastColor
= COL_YELLOW
;
2480 case SID_FRAME_LINECOLOR
:
2481 addStatusListener( OUString( ".uno:FrameLineColor" ));
2483 mLastColor
= COL_BLUE
;
2487 pBtnUpdater
= new ::svx::ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox(), nMode
);
2490 // -----------------------------------------------------------------------
2492 SvxColorExtToolBoxControl::~SvxColorExtToolBoxControl()
2497 // -----------------------------------------------------------------------
2499 SfxPopupWindowType
SvxColorExtToolBoxControl::GetPopupWindowType() const
2501 return SFX_POPUPWINDOW_ONTIMEOUT
;
2504 // -----------------------------------------------------------------------
2506 SfxPopupWindow
* SvxColorExtToolBoxControl::CreatePopupWindow()
2508 SvxColorWindow_Impl
* pColorWin
=
2509 new SvxColorWindow_Impl(
2513 SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR
),
2517 switch( GetSlotId() )
2519 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
2520 pColorWin
->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND
) );
2523 case SID_BACKGROUND_COLOR
:
2524 pColorWin
->SetText( SVX_RESSTR( RID_SVXSTR_BACKGROUND
) );
2527 case SID_FRAME_LINECOLOR
:
2528 pColorWin
->SetText( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR
) );
2532 pColorWin
->StartPopupMode( &GetToolBox(),
2533 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE
);
2534 pColorWin
->StartSelection();
2535 SetPopupWindow( pColorWin
);
2536 bChoiceFromPalette
= sal_True
;
2540 // -----------------------------------------------------------------------
2542 void SvxColorExtToolBoxControl::StateChanged(
2544 sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
2547 const SvxColorItem
* pItem
= 0;
2548 if ( bChoiceFromPalette
&& nSID
== GetSlotId() )
2550 bChoiceFromPalette
= sal_False
;
2553 case SID_ATTR_CHAR_COLOR
:
2554 case SID_ATTR_CHAR_COLOR2
:
2555 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
2556 case SID_BACKGROUND_COLOR
:
2557 if ( SFX_ITEM_DONTCARE
!= eState
)
2558 pItem
= PTR_CAST( SvxColorItem
, pState
);
2562 pBtnUpdater
->Update( pItem
->GetValue() );
2563 mLastColor
= pItem
->GetValue();
2567 case SID_FRAME_LINECOLOR
:
2568 ToolBox
& rTbx
= GetToolBox();
2569 rTbx
.EnableItem( nSID
, SFX_ITEM_DISABLED
!= eState
);
2570 rTbx
.SetItemState( nSID
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2572 if ( SFX_ITEM_DONTCARE
!= eState
)
2574 pItem
= PTR_CAST( SvxColorItem
, pState
);
2577 pBtnUpdater
->Update( pItem
->GetValue());
2578 mLastColor
= pItem
->GetValue();
2586 // -----------------------------------------------------------------------
2588 void SvxColorExtToolBoxControl::Select( sal_Bool
)
2591 OUString aParamName
;
2592 bool bNoArgs
= false;
2594 switch( GetSlotId() )
2596 case SID_ATTR_CHAR_COLOR2
:
2598 aCommand
= OUString( ".uno:CharColorExt" );
2599 aParamName
= OUString( "CharColorExt" );
2602 case SID_ATTR_CHAR_COLOR
:
2603 aCommand
= OUString( ".uno:Color" );
2604 aParamName
= OUString( "Color" );
2607 case SID_BACKGROUND_COLOR
:
2608 aCommand
= OUString( ".uno:BackgroundColor" );
2609 aParamName
= OUString( "BackgroundColor" );
2612 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
2614 aCommand
= OUString( ".uno:CharBackgroundExt" );
2615 aParamName
= OUString( "CharBackgroundExt" );
2618 case SID_FRAME_LINECOLOR
:
2619 aCommand
= OUString( ".uno:FrameLineColor" );
2620 aParamName
= OUString( "FrameLineColor" );
2624 Sequence
< PropertyValue
> aArgs( 1 );
2625 aArgs
[0].Name
= aParamName
;
2627 aArgs
[0].Value
= makeAny( GetToolBox().IsItemChecked( GetId() ));
2629 aArgs
[0].Value
= makeAny( (sal_uInt32
)( mLastColor
.GetColor() ));
2630 Dispatch( aCommand
, aArgs
);
2633 //========================================================================
2634 // class SvxFrameToolBoxControl ------------------------------------------
2635 //========================================================================
2637 SvxFrameToolBoxControl::SvxFrameToolBoxControl(
2642 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2644 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2647 // -----------------------------------------------------------------------
2649 SfxPopupWindowType
SvxFrameToolBoxControl::GetPopupWindowType() const
2651 return SFX_POPUPWINDOW_ONCLICK
;
2654 // -----------------------------------------------------------------------
2656 SfxPopupWindow
* SvxFrameToolBoxControl::CreatePopupWindow()
2658 SvxFrameWindow_Impl
* pFrameWin
= new SvxFrameWindow_Impl(
2659 GetSlotId(), m_xFrame
, &GetToolBox() );
2661 pFrameWin
->StartPopupMode( &GetToolBox(),
2662 FLOATWIN_POPUPMODE_GRABFOCUS
|
2663 FLOATWIN_POPUPMODE_ALLOWTEAROFF
|
2664 FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE
);
2665 pFrameWin
->StartSelection();
2666 SetPopupWindow( pFrameWin
);
2671 // -----------------------------------------------------------------------
2673 void SvxFrameToolBoxControl::StateChanged(
2675 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* )
2678 sal_uInt16 nId
= GetId();
2679 ToolBox
& rTbx
= GetToolBox();
2681 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2682 rTbx
.SetItemState( nId
, (SFX_ITEM_DONTCARE
== eState
)
2687 //========================================================================
2688 // class SvxFrameLineStyleToolBoxControl ---------------------------------
2689 //========================================================================
2691 SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
2696 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2698 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2701 // -----------------------------------------------------------------------
2703 SfxPopupWindowType
SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const
2705 return SFX_POPUPWINDOW_ONCLICK
;
2708 // -----------------------------------------------------------------------
2710 SfxPopupWindow
* SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
2712 SvxLineWindow_Impl
* pLineWin
= new SvxLineWindow_Impl( GetSlotId(), m_xFrame
, &GetToolBox() );
2713 pLineWin
->StartPopupMode( &GetToolBox(),
2714 FLOATWIN_POPUPMODE_GRABFOCUS
|
2715 FLOATWIN_POPUPMODE_ALLOWTEAROFF
|
2716 FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE
);
2717 SetPopupWindow( pLineWin
);
2722 // -----------------------------------------------------------------------
2724 void SvxFrameLineStyleToolBoxControl::StateChanged(
2726 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* )
2728 sal_uInt16 nId
= GetId();
2729 ToolBox
& rTbx
= GetToolBox();
2731 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2732 rTbx
.SetItemState( nId
, (SFX_ITEM_DONTCARE
== eState
)
2737 //========================================================================
2738 // class SvxFrameLineColorToolBoxControl ---------------------------------
2739 //========================================================================
2741 SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
2746 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
2747 pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId
, nId
, &GetToolBox() )),
2748 mLastColor( COL_AUTO
)
2750 rTbx
.SetItemBits( nId
, TIB_DROPDOWNONLY
| rTbx
.GetItemBits( nId
) );
2753 // -----------------------------------------------------------------------
2755 SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl()
2761 // -----------------------------------------------------------------------
2763 SfxPopupWindowType
SvxFrameLineColorToolBoxControl::GetPopupWindowType() const
2765 return SFX_POPUPWINDOW_ONCLICK
;
2768 // -----------------------------------------------------------------------
2770 SfxPopupWindow
* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
2772 SvxColorWindow_Impl
* pColorWin
= new SvxColorWindow_Impl(
2773 OUString( ".uno:FrameLineColor" ),
2774 SID_FRAME_LINECOLOR
,
2776 SVX_RESSTR(RID_SVXSTR_FRAME_COLOR
),
2780 pColorWin
->StartPopupMode( &GetToolBox(),
2781 FLOATWIN_POPUPMODE_GRABFOCUS
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE
);
2782 pColorWin
->StartSelection();
2783 SetPopupWindow( pColorWin
);
2787 // -----------------------------------------------------------------------
2789 void SvxFrameLineColorToolBoxControl::StateChanged(
2790 sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
2792 sal_uInt16 nId
= GetId();
2793 ToolBox
& rTbx
= GetToolBox();
2794 rTbx
.EnableItem( nId
, SFX_ITEM_DISABLED
!= eState
);
2795 rTbx
.SetItemState( nId
, ( SFX_ITEM_DONTCARE
== eState
) ? STATE_DONTKNOW
: STATE_NOCHECK
);
2797 const SvxColorItem
* pItem
= 0;
2798 if ( SFX_ITEM_DONTCARE
!= eState
)
2800 pItem
= PTR_CAST( SvxColorItem
, pState
);
2803 pBtnUpdater
->Update( pItem
->GetValue());
2804 mLastColor
= pItem
->GetValue();
2809 //========================================================================
2810 // class SvxSimpleUndoRedoController -------------------------------------
2811 //========================================================================
2813 SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
)
2814 :SfxToolBoxControl( nSlotId
, nId
, rTbx
)
2816 aDefaultText
= rTbx
.GetItemText( nId
);
2819 // -----------------------------------------------------------------------
2821 SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController()
2825 // -----------------------------------------------------------------------
2827 void SvxSimpleUndoRedoController::StateChanged( sal_uInt16
, SfxItemState eState
, const SfxPoolItem
* pState
)
2829 SfxStringItem
* pItem
= PTR_CAST( SfxStringItem
, pState
);
2830 ToolBox
& rBox
= GetToolBox();
2831 if ( pItem
&& eState
!= SFX_ITEM_DISABLED
)
2833 OUString
aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem
->GetValue() ) );
2834 rBox
.SetQuickHelpText( GetId(), aNewText
);
2836 if ( eState
== SFX_ITEM_DISABLED
)
2837 rBox
.SetQuickHelpText( GetId(), aDefaultText
);
2838 rBox
.EnableItem( GetId(), eState
!= SFX_ITEM_DISABLED
);
2841 //========================================================================
2843 static void lcl_ResizeValueSet( Window
&rWin
, ValueSet
&rValueSet
)
2845 Size aSize
= rWin
.GetOutputSizePixel();
2847 aSize
.Height() -= 4;
2848 rValueSet
.SetPosSizePixel( Point(2,2), aSize
);
2851 // -----------------------------------------------------------------------
2853 static void lcl_CalcSizeValueSet( Window
&rWin
, ValueSet
&rValueSet
, const Size
&aItemSize
)
2855 Size aSize
= rValueSet
.CalcWindowSizePixel( aItemSize
);
2857 aSize
.Height() += 4;
2858 rWin
.SetOutputSizePixel( aSize
);
2861 // -----------------------------------------------------------------------------
2862 Reference
< ::com::sun::star::accessibility::XAccessible
> SvxFontNameBox_Impl::CreateAccessible()
2865 return FontNameBox::CreateAccessible();
2868 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */