Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <string>
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>
58 : #include "helpid.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"
81 : #include <memory>
82 :
83 : #include <svx/framelink.hxx>
84 : #include <svx/tbxcolorupdate.hxx>
85 : #include <editeng/eerdll.hxx>
86 : #include <editeng/editrids.hrc>
87 :
88 : // ------------------------------------------------------------------------
89 :
90 : #define MAX_MRU_FONTNAME_ENTRIES 5
91 : #define LOGICAL_EDIT_HEIGHT 12
92 :
93 : // STATIC DATA -----------------------------------------------------------
94 :
95 : #ifndef DELETEZ
96 : #define DELETEZ(p) (delete (p), (p)=NULL)
97 : #endif
98 : // don't make more than 15 entries visible at once
99 : #define MAX_STYLES_ENTRIES static_cast< sal_uInt16 >( 15 )
100 :
101 : static void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet );
102 : static void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize );
103 :
104 : // namespaces
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;
111 :
112 607 : SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
113 607 : SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
114 44 : SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem );
115 1825 : SFX_IMPL_TOOLBOX_CONTROL( SvxColorExtToolBoxControl, SvxColorItem );
116 232 : SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
117 232 : SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
118 11 : SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl, SvxColorItem );
119 0 : SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
120 :
121 : //========================================================================
122 : // class SvxStyleBox_Impl -----------------------------------------------------
123 : //========================================================================
124 :
125 :
126 : class SvxStyleBox_Impl : public ComboBox
127 : {
128 : using Window::IsVisible;
129 : public:
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 );
132 : ~SvxStyleBox_Impl();
133 :
134 : void SetFamily( SfxStyleFamily eNewFamily );
135 1648 : inline bool IsVisible() { return bVisible; }
136 :
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 );
141 :
142 : virtual void UserDraw( const UserDrawEvent& rUDEvt );
143 :
144 532 : inline void SetVisibilityListener( const Link& aVisListener ) { aVisibilityListener = aVisListener; }
145 : inline void RemoveVisibilityListener() { aVisibilityListener = Link(); }
146 :
147 530 : void SetDefaultStyle( const OUString& rDefault ) { sDefaultStyle = rDefault; }
148 : DECL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control* );
149 :
150 : protected:
151 : virtual void Select();
152 :
153 : private:
154 : SfxStyleFamily eStyleFamily;
155 : sal_uInt16 nCurSel;
156 : bool bRelease;
157 : Size aLogicalSize;
158 : Link aVisibilityListener;
159 : bool bVisible;
160 : Reference< XDispatchProvider > m_xDispatchProvider;
161 : Reference< XFrame > m_xFrame;
162 : OUString m_aCommand;
163 : String aClearFormatKey;
164 : String aMoreKey;
165 : String sDefaultStyle;
166 : bool bInSpecialMode;
167 :
168 : void ReleaseFocus();
169 : };
170 :
171 : //========================================================================
172 : // class SvxFontNameBox --------------------------------------------------
173 : //========================================================================
174 :
175 : class SvxFontNameBox_Impl : public FontNameBox
176 : {
177 : using Window::Update;
178 : private:
179 : const FontList* pFontList;
180 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
181 : ::std::auto_ptr<FontList> m_aOwnFontList;
182 : SAL_WNODEPRECATED_DECLARATIONS_POP
183 : Font aCurFont;
184 : Size aLogicalSize;
185 : String aCurText;
186 : sal_uInt16 nFtCount;
187 : bool bRelease;
188 : Reference< XDispatchProvider > m_xDispatchProvider;
189 : Reference< XFrame > m_xFrame;
190 : bool mbEndPreview;
191 :
192 : void ReleaseFocus_Impl();
193 : void EnableControls_Impl();
194 :
195 0 : void EndPreview()
196 : {
197 0 : Sequence< PropertyValue > aArgs;
198 : SfxToolBoxControl::Dispatch( m_xDispatchProvider,
199 : OUString( ".uno:CharEndPreviewFontName" ),
200 0 : aArgs );
201 0 : }
202 : DECL_DLLPRIVATE_LINK( CheckAndMarkUnknownFont, VclWindowEvent* );
203 :
204 : protected:
205 : virtual void Select();
206 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
207 :
208 : public:
209 : SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame
210 : , WinBits nStyle = WB_SORT
211 : );
212 : virtual ~SvxFontNameBox_Impl();
213 :
214 : void FillList();
215 : void Update( const SvxFontItem* pFontItem );
216 3 : sal_uInt16 GetListCount() { return nFtCount; }
217 532 : void Clear() { FontNameBox::Clear(); nFtCount = 0; }
218 517 : void Fill( const FontList* pList )
219 517 : { FontNameBox::Fill( pList );
220 517 : 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 0 : void SetOwnFontList(::std::auto_ptr<FontList> _aOwnFontList) { m_aOwnFontList = _aOwnFontList; }
227 : SAL_WNODEPRECATED_DECLARATIONS_POP
228 : };
229 :
230 : //========================================================================
231 : // class SvxFrameWindow_Impl --------------------------------------------------
232 : //========================================================================
233 :
234 : // SelectHdl needs the Modifiers, get them in MouseButtonUp
235 :
236 0 : class SvxFrmValueSet_Impl : public ValueSet
237 : {
238 : sal_uInt16 nModifier;
239 : virtual void MouseButtonUp( const MouseEvent& rMEvt );
240 : public:
241 0 : SvxFrmValueSet_Impl(Window* pParent, WinBits nWinStyle)
242 0 : : ValueSet(pParent, nWinStyle), nModifier(0) {}
243 0 : sal_uInt16 GetModifier() const {return nModifier;}
244 :
245 : };
246 :
247 0 : void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent& rMEvt )
248 : {
249 0 : nModifier = rMEvt.GetModifier();
250 0 : ValueSet::MouseButtonUp(rMEvt);
251 0 : }
252 :
253 : class SvxFrameWindow_Impl : public SfxPopupWindow
254 : {
255 : using FloatingWindow::StateChanged;
256 :
257 : private:
258 : SvxFrmValueSet_Impl aFrameSet;
259 : ImageList aImgList;
260 : sal_Bool bParagraphMode;
261 :
262 : DECL_LINK( SelectHdl, void * );
263 :
264 : protected:
265 : virtual void Resize();
266 : virtual sal_Bool Close();
267 : virtual Window* GetPreferredKeyInputWindow();
268 : virtual void GetFocus();
269 :
270 : public:
271 : SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
272 : ~SvxFrameWindow_Impl();
273 : void StartSelection();
274 :
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 );
279 : };
280 :
281 : //========================================================================
282 : // class SvxLineWindow_Impl ---------------------------------------------------
283 : //========================================================================
284 0 : class SvxLineWindow_Impl : public SfxPopupWindow
285 : {
286 : private:
287 : LineListBox m_aLineStyleLb;
288 : bool m_bIsWriter;
289 :
290 : DECL_LINK( SelectHdl, void * );
291 :
292 : protected:
293 : virtual void Resize();
294 : virtual sal_Bool Close();
295 : virtual Window* GetPreferredKeyInputWindow();
296 : virtual void GetFocus();
297 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
298 : public:
299 : SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
300 :
301 : virtual SfxPopupWindow* Clone() const;
302 : };
303 :
304 : //########################################################################
305 : // Helper classes:
306 : //========================================================================
307 : // class SfxStyleControllerItem ------------------------------------------
308 : //========================================================================
309 : class SvxStyleToolBoxControl;
310 :
311 5320 : class SfxStyleControllerItem_Impl : public SfxStatusListener
312 : {
313 : public:
314 : SfxStyleControllerItem_Impl( const Reference< XDispatchProvider >& rDispatchProvider,
315 : sal_uInt16 nSlotId,
316 : const OUString& rCommand,
317 : SvxStyleToolBoxControl& rTbxCtl );
318 :
319 : protected:
320 : virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
321 :
322 : private:
323 : SvxStyleToolBoxControl& rControl;
324 : };
325 :
326 : //========================================================================
327 : // class SvxStyleBox_Impl -----------------------------------------------------
328 : //========================================================================
329 :
330 532 : SvxStyleBox_Impl::SvxStyleBox_Impl(
331 : Window* pParent,
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,
338 : bool bInSpec) :
339 :
340 532 : ComboBox( pParent, SVX_RES( RID_SVXTBX_STYLE ) ),
341 :
342 : eStyleFamily( eFamily ),
343 : bRelease ( true ),
344 : bVisible(false),
345 : m_xDispatchProvider( rDispatchProvider ),
346 : m_xFrame(_xFrame),
347 : m_aCommand ( rCommand ),
348 : aClearFormatKey ( rClearFormatKey ),
349 : aMoreKey ( rMoreKey ),
350 532 : bInSpecialMode ( bInSpec )
351 : {
352 532 : aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT );
353 532 : EnableAutocomplete( sal_True );
354 532 : EnableUserDraw( true );
355 532 : SetUserItemSize( Size( 0, 30 ) );
356 532 : }
357 :
358 1064 : SvxStyleBox_Impl::~SvxStyleBox_Impl()
359 : {
360 1064 : }
361 :
362 : // -----------------------------------------------------------------------
363 :
364 0 : void SvxStyleBox_Impl::ReleaseFocus()
365 : {
366 0 : if ( !bRelease )
367 : {
368 0 : bRelease = true;
369 0 : return;
370 : }
371 0 : if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
372 0 : m_xFrame->getContainerWindow()->setFocus();
373 : }
374 :
375 : // -----------------------------------------------------------------------
376 :
377 0 : void SvxStyleBox_Impl::Select()
378 : {
379 : // Tell base class about selection so that AT get informed about it.
380 0 : ComboBox::Select();
381 :
382 0 : if ( !IsTravelSelect() )
383 : {
384 0 : OUString aSearchEntry( GetText() );
385 0 : bool bDoIt = true, bClear = false;
386 0 : if( bInSpecialMode )
387 : {
388 0 : if( aSearchEntry == aClearFormatKey && GetSelectEntryPos() == 0 )
389 : {
390 0 : aSearchEntry = sDefaultStyle;
391 0 : bClear = true;
392 : //not only apply default style but also call 'ClearFormatting'
393 0 : Sequence< PropertyValue > aEmptyVals;
394 : SfxToolBoxControl::Dispatch( m_xDispatchProvider, OUString(".uno:ResetAttributes"),
395 0 : aEmptyVals);
396 : }
397 0 : else if( aSearchEntry == aMoreKey && GetSelectEntryPos() == ( GetEntryCount() - 1 ) )
398 : {
399 0 : SfxViewFrame* pViewFrm = SfxViewFrame::Current();
400 : DBG_ASSERT( pViewFrm, "SvxStyleBox_Impl::Select(): no viewframe" );
401 0 : pViewFrm->ShowChildWindow( SID_STYLE_DESIGNER );
402 0 : SfxChildWindow* pChildWin = pViewFrm->GetChildWindow( SID_STYLE_DESIGNER );
403 0 : if ( pChildWin && pChildWin->GetWindow() )
404 : {
405 0 : static_cast< SfxTemplateDialogWrapper* >( pChildWin )->SetParagraphFamily();
406 0 : static_cast< SfxDockingWindow* >( pChildWin->GetWindow() )->AutoShow( sal_True );
407 : Application::PostUserEvent(
408 0 : STATIC_LINK( 0, SvxStyleBox_Impl, FocusHdl_Impl ), pChildWin->GetWindow() );
409 : }
410 0 : bDoIt = false;
411 : }
412 : }
413 :
414 : //Do we need to create a new style?
415 0 : SfxObjectShell *pShell = SfxObjectShell::Current();
416 0 : SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
417 0 : SfxStyleSheetBase* pStyle = NULL;
418 :
419 0 : bool bCreateNew = 0;
420 :
421 0 : if ( pPool )
422 : {
423 0 : pPool->SetSearchMask( eStyleFamily, SFXSTYLEBIT_ALL );
424 :
425 0 : pStyle = pPool->First();
426 0 : while ( pStyle && OUString( pStyle->GetName() ) != aSearchEntry )
427 0 : pStyle = pPool->Next();
428 : }
429 :
430 0 : if ( !pStyle )
431 : {
432 : // cannot find the style for whatever reason
433 : // therefore create a new style
434 0 : bCreateNew = 1;
435 : }
436 :
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. */
440 0 : ReleaseFocus();
441 :
442 0 : if( bDoIt )
443 : {
444 0 : if ( bClear )
445 0 : SetText( aSearchEntry );
446 0 : SaveValue();
447 :
448 0 : Sequence< PropertyValue > aArgs( 2 );
449 0 : aArgs[0].Value = makeAny( OUString( aSearchEntry ) );
450 0 : aArgs[1].Name = OUString("Family");
451 0 : aArgs[1].Value = makeAny( sal_Int16( eStyleFamily ));
452 0 : if( bCreateNew )
453 : {
454 0 : aArgs[0].Name = OUString("Param");
455 0 : SfxToolBoxControl::Dispatch( m_xDispatchProvider, OUString(".uno:StyleNewByExample"), aArgs);
456 : }
457 : else
458 : {
459 0 : aArgs[0].Name = OUString("Template");
460 0 : SfxToolBoxControl::Dispatch( m_xDispatchProvider, m_aCommand, aArgs );
461 0 : }
462 0 : }
463 : }
464 0 : }
465 : // -----------------------------------------------------------------------
466 :
467 4881 : void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily )
468 : {
469 4881 : eStyleFamily = eNewFamily;
470 4881 : }
471 :
472 : // -----------------------------------------------------------------------
473 :
474 1 : long SvxStyleBox_Impl::PreNotify( NotifyEvent& rNEvt )
475 : {
476 1 : sal_uInt16 nType = rNEvt.GetType();
477 :
478 1 : if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
479 1 : nCurSel = GetSelectEntryPos();
480 0 : else if ( EVENT_LOSEFOCUS == nType )
481 : {
482 : // don't handle before our Select() is called
483 0 : if ( !HasFocus() && !HasChildPathFocus() )
484 0 : SetText( GetSavedValue() );
485 : }
486 1 : return ComboBox::PreNotify( rNEvt );
487 : }
488 :
489 : // -----------------------------------------------------------------------
490 :
491 1 : long SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt )
492 : {
493 1 : long nHandled = 0;
494 :
495 1 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
496 : {
497 0 : sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
498 :
499 0 : switch ( nCode )
500 : {
501 : case KEY_RETURN:
502 : case KEY_TAB:
503 : {
504 0 : if ( KEY_TAB == nCode )
505 0 : bRelease = false;
506 : else
507 0 : nHandled = 1;
508 0 : Select();
509 0 : break;
510 : }
511 :
512 : case KEY_ESCAPE:
513 0 : SelectEntryPos( nCurSel );
514 0 : ReleaseFocus();
515 0 : nHandled = 1;
516 0 : break;
517 : }
518 : }
519 1 : return nHandled ? nHandled : ComboBox::Notify( rNEvt );
520 : }
521 :
522 0 : void SvxStyleBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
523 : {
524 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
525 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
526 : {
527 0 : SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
528 0 : Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
529 0 : SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
530 : }
531 :
532 0 : ComboBox::DataChanged( rDCEvt );
533 0 : }
534 :
535 20243 : void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange )
536 : {
537 20243 : ComboBox::StateChanged( nStateChange );
538 :
539 20243 : if ( nStateChange == STATE_CHANGE_VISIBLE )
540 : {
541 377 : bVisible = IsReallyVisible();
542 377 : if ( aVisibilityListener.IsSet() )
543 377 : aVisibilityListener.Call( this );
544 : }
545 19866 : else if ( nStateChange == STATE_CHANGE_INITSHOW )
546 : {
547 377 : bVisible = true;
548 377 : if ( aVisibilityListener.IsSet() )
549 377 : aVisibilityListener.Call( this );
550 : }
551 20243 : }
552 :
553 394 : void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
554 : {
555 394 : sal_uInt16 nItem = rUDEvt.GetItemId();
556 :
557 394 : if ( nItem == 0 || nItem == GetEntryCount() - 1 )
558 : {
559 : // draw the non-style entries, ie. "Clear Formatting" or "More..."
560 4 : DrawEntry( rUDEvt, true, true );
561 : }
562 : else
563 : {
564 390 : SfxObjectShell *pShell = SfxObjectShell::Current();
565 390 : SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
566 390 : SfxStyleSheetBase* pStyle = NULL;
567 :
568 390 : OUString aStyleName( GetEntry( nItem ) );
569 :
570 390 : if ( pPool )
571 : {
572 390 : pPool->SetSearchMask( eStyleFamily, SFXSTYLEBIT_ALL );
573 :
574 390 : pStyle = pPool->First();
575 1033 : while ( pStyle && OUString( pStyle->GetName() ) != aStyleName )
576 253 : pStyle = pPool->Next();
577 : }
578 :
579 390 : if ( !pStyle )
580 : {
581 : // cannot find the style for whatever reason
582 0 : DrawEntry( rUDEvt, true, true );
583 : }
584 : else
585 : {
586 390 : const SfxItemSet& aItemSet = pStyle->GetItemSet();
587 :
588 390 : const SvxFontItem *pFontItem = static_cast< const SvxFontItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONT ) );
589 390 : const SvxFontHeightItem *pFontHeightItem = static_cast< const SvxFontHeightItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONTHEIGHT ) );
590 :
591 390 : if ( pFontItem && pFontHeightItem )
592 : {
593 390 : OutputDevice *pDevice = rUDEvt.GetDevice();
594 :
595 390 : Size aFontSize( 0, pFontHeightItem->GetHeight() );
596 390 : Size aPixelSize( pDevice->LogicToPixel( aFontSize, pShell->GetMapUnit() ) );
597 :
598 : // setup the font properties
599 390 : Font aFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), aPixelSize );
600 :
601 390 : const SfxPoolItem *pItem = aItemSet.GetItem( SID_ATTR_CHAR_WEIGHT );
602 390 : if ( pItem )
603 390 : aFont.SetWeight( static_cast< const SvxWeightItem* >( pItem )->GetWeight() );
604 :
605 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_POSTURE );
606 390 : if ( pItem )
607 390 : aFont.SetItalic( static_cast< const SvxPostureItem* >( pItem )->GetPosture() );
608 :
609 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_CONTOUR );
610 390 : if ( pItem )
611 390 : aFont.SetOutline( static_cast< const SvxContourItem* >( pItem )->GetValue() );
612 :
613 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_SHADOWED );
614 390 : if ( pItem )
615 390 : aFont.SetShadow( static_cast< const SvxShadowedItem* >( pItem )->GetValue() );
616 :
617 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_RELIEF );
618 390 : if ( pItem )
619 390 : aFont.SetRelief( static_cast< FontRelief >( static_cast< const SvxCharReliefItem* >( pItem )->GetValue() ) );
620 :
621 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_UNDERLINE );
622 390 : if ( pItem )
623 390 : aFont.SetUnderline( static_cast< const SvxUnderlineItem* >( pItem )->GetLineStyle() );
624 :
625 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_OVERLINE );
626 390 : if ( pItem )
627 390 : aFont.SetOverline( static_cast< FontUnderline >( static_cast< const SvxOverlineItem* >( pItem )->GetValue() ) );
628 :
629 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_STRIKEOUT );
630 390 : if ( pItem )
631 390 : aFont.SetStrikeout( static_cast< const SvxCrossedOutItem* >( pItem )->GetStrikeout() );
632 :
633 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_EMPHASISMARK );
634 390 : if ( pItem )
635 390 : aFont.SetEmphasisMark( static_cast< const SvxEmphasisMarkItem* >( pItem )->GetEmphasisMark() );
636 :
637 : // setup the device & draw
638 780 : Font aOldFont( pDevice->GetFont() );
639 390 : Color aOldColor( pDevice->GetTextColor() );
640 390 : Color aOldFillColor( pDevice->GetFillColor() );
641 :
642 390 : pDevice->SetFont( aFont );
643 :
644 : // text color, when we are not selected
645 390 : pItem = aItemSet.GetItem( SID_ATTR_CHAR_COLOR );
646 390 : if ( pItem && rUDEvt.GetItemId() != GetSelectEntryPos() )
647 : {
648 7 : Color aColor( static_cast< const SvxColorItem* >( pItem )->GetValue() );
649 7 : if ( aColor != COL_AUTO )
650 0 : pDevice->SetTextColor( aColor );
651 : }
652 :
653 : // background color
654 390 : pItem = aItemSet.GetItem( SID_ATTR_BRUSH );
655 390 : if ( pItem && rUDEvt.GetItemId() != GetSelectEntryPos() )
656 : {
657 7 : Color aColor( static_cast< const SvxBrushItem* >( pItem )->GetColor() );
658 7 : if ( aColor != COL_AUTO )
659 : {
660 0 : pDevice->SetFillColor( aColor );
661 0 : pDevice->DrawRect( rUDEvt.GetRect() );
662 : }
663 : }
664 :
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 390 : const int nLeftDistance = 8;
669 :
670 390 : Rectangle aTextRect;
671 390 : pDevice->GetTextBoundRect( aTextRect, aStyleName );
672 :
673 390 : Point aPos( rUDEvt.GetRect().TopLeft() );
674 390 : aPos.X() += nLeftDistance;
675 390 : if ( aTextRect.Bottom() > rUDEvt.GetRect().GetHeight() )
676 : {
677 : // the text does not fit, adjust the font size
678 0 : double ratio = static_cast< double >( rUDEvt.GetRect().GetHeight() ) / aTextRect.Bottom();
679 0 : aPixelSize.Width() *= ratio;
680 0 : aPixelSize.Height() *= ratio;
681 0 : aFont.SetSize( aPixelSize );
682 0 : pDevice->SetFont( aFont );
683 : }
684 : else
685 390 : aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aTextRect.Bottom() ) / 2;
686 :
687 390 : pDevice->DrawText( aPos, aStyleName );
688 :
689 390 : pDevice->SetFillColor( aOldFillColor );
690 390 : pDevice->SetTextColor( aOldColor );
691 390 : pDevice->SetFont( aOldFont );
692 :
693 : // draw separator, if present
694 780 : DrawEntry( rUDEvt, false, false );
695 : }
696 : else
697 0 : DrawEntry( rUDEvt, true, true );
698 390 : }
699 : }
700 394 : }
701 :
702 : //--------------------------------------------------------------------
703 :
704 0 : IMPL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control*, _pCtrl )
705 : {
706 : (void)pThis;
707 0 : if ( _pCtrl )
708 0 : _pCtrl->GrabFocus();
709 0 : return 0;
710 : }
711 :
712 : // -----------------------------------------------------------------------
713 :
714 520 : static bool lcl_GetDocFontList( const FontList** ppFontList, SvxFontNameBox_Impl* pBox )
715 : {
716 520 : bool bChanged = false;
717 520 : const SfxObjectShell* pDocSh = SfxObjectShell::Current();
718 520 : SvxFontListItem* pFontListItem = NULL;
719 :
720 520 : if ( pDocSh )
721 : pFontListItem =
722 520 : (SvxFontListItem*)pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
723 : else
724 : {
725 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
726 0 : ::std::auto_ptr<FontList> aFontList(new FontList( pBox ));
727 : SAL_WNODEPRECATED_DECLARATIONS_POP
728 0 : *ppFontList = aFontList.get();
729 0 : pBox->SetOwnFontList(aFontList);
730 0 : bChanged = true;
731 : }
732 :
733 520 : if ( pFontListItem )
734 : {
735 520 : const FontList* pNewFontList = pFontListItem->GetFontList();
736 : DBG_ASSERT( pNewFontList, "Doc-FontList not available!" );
737 :
738 : // No old list, but a new list
739 520 : if ( !*ppFontList && pNewFontList )
740 : {
741 : // => take over
742 517 : *ppFontList = pNewFontList;
743 517 : bChanged = true;
744 : }
745 : else
746 : {
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.
751 : bChanged =
752 6 : ( ( *ppFontList != pNewFontList ) ||
753 6 : pBox->GetListCount() != pNewFontList->GetFontNameCount() );
754 : // HACK: Comparing is incomplete
755 :
756 3 : if ( bChanged )
757 0 : *ppFontList = pNewFontList;
758 : }
759 :
760 520 : if ( pBox )
761 520 : pBox->Enable();
762 : }
763 0 : else if ( pBox && ( pDocSh || ( !pDocSh && !ppFontList )))
764 : {
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!
772 0 : pBox->Disable();
773 : }
774 :
775 : // Fill the FontBox, also the new list if necessary
776 520 : if ( pBox && bChanged )
777 : {
778 517 : if ( *ppFontList )
779 517 : pBox->Fill( *ppFontList );
780 : else
781 0 : pBox->Clear();
782 : }
783 520 : return bChanged;
784 : }
785 :
786 : //========================================================================
787 : // class SvxFontNameBox_Impl --------------------------------------------------
788 : //========================================================================
789 :
790 532 : SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame, WinBits nStyle ) :
791 :
792 : FontNameBox ( pParent, nStyle | WinBits( WB_DROPDOWN | WB_AUTOHSCROLL ) ),
793 : pFontList ( NULL ),
794 : aLogicalSize ( 60,160 ),
795 : nFtCount ( 0 ),
796 : bRelease ( true ),
797 : m_xDispatchProvider( rDispatchProvider ),
798 : m_xFrame (_xFrame),
799 532 : mbEndPreview(false)
800 : {
801 532 : SetSizePixel(LogicToPixel( aLogicalSize, MAP_APPFONT ));
802 532 : EnableControls_Impl();
803 532 : GetSubEdit()->AddEventListener( LINK( this, SvxFontNameBox_Impl, CheckAndMarkUnknownFont ));
804 532 : }
805 :
806 1596 : SvxFontNameBox_Impl::~SvxFontNameBox_Impl()
807 : {
808 532 : GetSubEdit()->RemoveEventListener( LINK( this, SvxFontNameBox_Impl, CheckAndMarkUnknownFont ));
809 1064 : }
810 :
811 : // -----------------------------------------------------------------------
812 :
813 1 : void SvxFontNameBox_Impl::FillList()
814 : {
815 : // Save old Selection, set back in the end
816 1 : Selection aOldSel = GetSelection();
817 : // Did Doc-Fontlist change?
818 1 : lcl_GetDocFontList( &pFontList, this );
819 1 : aCurText = GetText();
820 1 : SetSelection( aOldSel );
821 1 : }
822 :
823 4260 : IMPL_LINK( SvxFontNameBox_Impl, CheckAndMarkUnknownFont, VclWindowEvent*, event )
824 : {
825 2130 : if( event->GetId() != VCLEVENT_EDIT_MODIFY )
826 1611 : return 0;
827 519 : OUString fontname = GetSubEdit()->GetText();
828 519 : lcl_GetDocFontList( &pFontList, this );
829 : // If the font is unknown, show it in italic.
830 1038 : Font font = GetControlFont();
831 519 : if( pFontList != NULL && pFontList->IsAvailable( fontname ))
832 : {
833 515 : if( font.GetItalic() != ITALIC_NONE )
834 : {
835 0 : font.SetItalic( ITALIC_NONE );
836 0 : SetControlFont( font );
837 0 : SetQuickHelpText( SVX_RESSTR( RID_SVXSTR_CHARFONTNAME ));
838 : }
839 : }
840 : else
841 : {
842 4 : if( font.GetItalic() != ITALIC_NORMAL )
843 : {
844 4 : font.SetItalic( ITALIC_NORMAL );
845 4 : SetControlFont( font );
846 4 : SetQuickHelpText( SVX_RESSTR( RID_SVXSTR_CHARFONTNAME_NOTAVAILABLE ));
847 : }
848 : }
849 1038 : return 0;
850 : }
851 :
852 : // -----------------------------------------------------------------------
853 :
854 777 : void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem )
855 : {
856 777 : if ( pFontItem )
857 : {
858 777 : aCurFont.SetName ( pFontItem->GetFamilyName() );
859 777 : aCurFont.SetFamily ( pFontItem->GetFamily() );
860 777 : aCurFont.SetStyleName ( pFontItem->GetStyleName() );
861 777 : aCurFont.SetPitch ( pFontItem->GetPitch() );
862 777 : aCurFont.SetCharSet ( pFontItem->GetCharSet() );
863 : }
864 777 : OUString aCurName = aCurFont.GetName();
865 777 : if ( GetText() != aCurName )
866 519 : SetText( aCurName );
867 777 : }
868 :
869 : // -----------------------------------------------------------------------
870 :
871 0 : long SvxFontNameBox_Impl::PreNotify( NotifyEvent& rNEvt )
872 : {
873 0 : sal_uInt16 nType = rNEvt.GetType();
874 :
875 0 : if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
876 : {
877 0 : EnableControls_Impl();
878 0 : FillList();
879 : }
880 0 : return FontNameBox::PreNotify( rNEvt );
881 : }
882 :
883 : // -----------------------------------------------------------------------
884 :
885 0 : long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
886 : {
887 0 : long nHandled = 0;
888 0 : mbEndPreview = false;
889 0 : if ( rNEvt.GetType() == EVENT_KEYUP )
890 0 : mbEndPreview = true;
891 :
892 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
893 : {
894 0 : sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
895 :
896 0 : switch ( nCode )
897 : {
898 : case KEY_RETURN:
899 : case KEY_TAB:
900 : {
901 0 : if ( KEY_TAB == nCode )
902 0 : bRelease = false;
903 : else
904 0 : nHandled = 1;
905 0 : Select();
906 0 : break;
907 : }
908 :
909 : case KEY_ESCAPE:
910 0 : SetText( aCurText );
911 0 : ReleaseFocus_Impl();
912 0 : EndPreview();
913 0 : break;
914 : }
915 : }
916 0 : else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
917 : {
918 0 : Window* pFocusWin = Application::GetFocusWindow();
919 0 : if ( !HasFocus() && GetSubEdit() != pFocusWin )
920 0 : SetText( GetSavedValue() );
921 : // send EndPreview
922 0 : EndPreview();
923 : }
924 :
925 0 : return nHandled ? nHandled : FontNameBox::Notify( rNEvt );
926 : }
927 :
928 : // ---------------------------------------------------------------------------
929 0 : void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
930 : {
931 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
932 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
933 : {
934 0 : SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
935 0 : Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
936 0 : SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
937 : }
938 :
939 0 : FontNameBox::DataChanged( rDCEvt );
940 0 : }
941 :
942 : // -----------------------------------------------------------------------
943 :
944 0 : void SvxFontNameBox_Impl::ReleaseFocus_Impl()
945 : {
946 0 : if ( !bRelease )
947 : {
948 0 : bRelease = true;
949 0 : return;
950 : }
951 0 : if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
952 0 : m_xFrame->getContainerWindow()->setFocus();
953 : }
954 :
955 : // -----------------------------------------------------------------------
956 :
957 532 : void SvxFontNameBox_Impl::EnableControls_Impl()
958 : {
959 532 : SvtFontOptions aFontOpt;
960 532 : sal_Bool bEnable = aFontOpt.IsFontHistoryEnabled();
961 532 : sal_uInt16 nEntries = bEnable ? MAX_MRU_FONTNAME_ENTRIES : 0;
962 532 : if ( GetMaxMRUCount() != nEntries )
963 : {
964 : // refill in the next GetFocus-Handler
965 532 : pFontList = NULL;
966 532 : Clear();
967 532 : SetMaxMRUCount( nEntries );
968 : }
969 :
970 532 : bEnable = aFontOpt.IsFontWYSIWYGEnabled();
971 532 : EnableWYSIWYG( bEnable );
972 532 : }
973 :
974 : // -----------------------------------------------------------------------
975 :
976 517 : void SvxFontNameBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
977 : {
978 517 : FontNameBox::UserDraw( rUDEvt );
979 :
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
983 : // or select
984 517 : if ( rUDEvt.GetItemId() == rUDEvt.GetStyle() )
985 : {
986 517 : Sequence< PropertyValue > aArgs( 1 );
987 517 : FontInfo aInfo( pFontList->Get( GetEntry( rUDEvt.GetItemId() ),
988 : aCurFont.GetWeight(),
989 1551 : aCurFont.GetItalic() ) );
990 :
991 : SvxFontItem aFontItem( aInfo.GetFamily(),
992 517 : aInfo.GetName(),
993 517 : aInfo.GetStyleName(),
994 : aInfo.GetPitch(),
995 517 : aInfo.GetCharSet(),
996 1551 : SID_ATTR_CHAR_FONT );
997 517 : aFontItem.QueryValue( aArgs[0].Value );
998 517 : aArgs[0].Name = OUString( "CharPreviewFontName" );
999 : SfxToolBoxControl::Dispatch( m_xDispatchProvider,
1000 : OUString( ".uno:CharPreviewFontName" ),
1001 1034 : aArgs );
1002 : }
1003 517 : }
1004 :
1005 0 : void SvxFontNameBox_Impl::Select()
1006 : {
1007 0 : FontNameBox::Select();
1008 :
1009 0 : Sequence< PropertyValue > aArgs( 1 );
1010 0 : std::auto_ptr<SvxFontItem> pFontItem;
1011 0 : if ( pFontList )
1012 : {
1013 0 : FontInfo aInfo( pFontList->Get( GetText(),
1014 : aCurFont.GetWeight(),
1015 0 : aCurFont.GetItalic() ) );
1016 0 : aCurFont = aInfo;
1017 :
1018 : pFontItem.reset( new SvxFontItem( aInfo.GetFamily(),
1019 : aInfo.GetName(),
1020 : aInfo.GetStyleName(),
1021 : aInfo.GetPitch(),
1022 0 : aInfo.GetCharSet(),
1023 0 : SID_ATTR_CHAR_FONT ) );
1024 :
1025 0 : Any a;
1026 0 : pFontItem->QueryValue( a );
1027 0 : aArgs[0].Value = a;
1028 : }
1029 0 : if ( !IsTravelSelect() )
1030 : {
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 0 : ReleaseFocus_Impl();
1035 0 : EndPreview();
1036 0 : if ( pFontItem.get() )
1037 : {
1038 0 : aArgs[0].Name = OUString( "CharFontName" );
1039 : SfxToolBoxControl::Dispatch( m_xDispatchProvider,
1040 : OUString( ".uno:CharFontName" ),
1041 0 : aArgs );
1042 : }
1043 : }
1044 : else
1045 : {
1046 0 : if ( mbEndPreview )
1047 : {
1048 0 : EndPreview();
1049 0 : return;
1050 : }
1051 0 : if ( pFontItem.get() )
1052 : {
1053 0 : aArgs[0].Name = OUString( "CharPreviewFontName" );
1054 : SfxToolBoxControl::Dispatch( m_xDispatchProvider,
1055 : OUString( ".uno:CharPreviewFontName" ),
1056 0 : aArgs );
1057 : }
1058 0 : }
1059 : }
1060 :
1061 : //========================================================================
1062 : // class SvxColorWindow_Impl --------------------------------------------------
1063 : //========================================================================
1064 : #ifndef WB_NO_DIRECTSELECT
1065 : #define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
1066 : #endif
1067 :
1068 0 : SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
1069 : sal_uInt16 nSlotId,
1070 : const Reference< XFrame >& rFrame,
1071 : const String& rWndTitle,
1072 : Window* pParentWindow,
1073 : const ::Color rLastColor ) :
1074 :
1075 : SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
1076 :
1077 : theSlotId( nSlotId ),
1078 : aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
1079 : maCommand( rCommand ),
1080 0 : mLastColor( rLastColor )
1081 :
1082 : {
1083 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
1084 0 : const SfxPoolItem* pItem = NULL;
1085 0 : XColorListRef pColorList;
1086 :
1087 0 : if ( pDocSh )
1088 0 : if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
1089 0 : pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
1090 :
1091 0 : if ( !pColorList.is() )
1092 0 : pColorList = XColorList::CreateStdColorList();
1093 :
1094 0 : if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
1095 : {
1096 0 : aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
1097 0 : aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
1098 0 : aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
1099 : }
1100 0 : else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId )
1101 : {
1102 : SfxPoolItem* pDummy;
1103 :
1104 0 : Reference< XDispatchProvider > aDisp( GetFrame()->getController(), UNO_QUERY );
1105 : SfxQueryStatus aQueryStatus( aDisp,
1106 : SID_ATTR_AUTO_COLOR_INVALID,
1107 0 : OUString( ".uno:AutoColorInvalid" ));
1108 0 : SfxItemState eState = aQueryStatus.QueryState( pDummy );
1109 0 : if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
1110 : {
1111 0 : aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
1112 0 : aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
1113 0 : aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
1114 0 : }
1115 : }
1116 : else
1117 : {
1118 0 : aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
1119 : }
1120 :
1121 0 : if ( pColorList.is() )
1122 : {
1123 0 : const long nColorCount(pColorList->Count());
1124 0 : const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
1125 0 : aColorSet.SetOutputSizePixel(aNewSize);
1126 : static sal_Int32 nAdd = 4;
1127 :
1128 0 : SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
1129 0 : aColorSet.Clear();
1130 0 : aColorSet.addEntriesForXColorList(*pColorList);
1131 : }
1132 :
1133 0 : aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
1134 0 : SetHelpId( HID_POPUP_COLOR );
1135 0 : aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
1136 0 : SetText( rWndTitle );
1137 0 : aColorSet.Show();
1138 :
1139 0 : AddStatusListener( OUString( ".uno:ColorTableState" ));
1140 0 : }
1141 :
1142 0 : SvxColorWindow_Impl::~SvxColorWindow_Impl()
1143 : {
1144 0 : }
1145 :
1146 0 : void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
1147 : {
1148 0 : aColorSet.KeyInput(rKEvt);
1149 0 : }
1150 :
1151 0 : SfxPopupWindow* SvxColorWindow_Impl::Clone() const
1152 : {
1153 0 : return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent(), mLastColor );
1154 : }
1155 :
1156 : // -----------------------------------------------------------------------
1157 :
1158 0 : IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
1159 : {
1160 0 : sal_uInt16 nItemId = aColorSet.GetSelectItemId();
1161 0 : 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 0 : aColorSet.SetNoSelection();
1166 :
1167 0 : if ( IsInPopupMode() )
1168 0 : EndPopupMode();
1169 :
1170 0 : if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) )
1171 : {
1172 0 : Sequence< PropertyValue > aArgs;
1173 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1174 : maCommand,
1175 0 : aArgs );
1176 : }
1177 0 : else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) )
1178 : {
1179 0 : SvxColorItem _aColorItem( COL_AUTO, theSlotId );
1180 0 : INetURLObject aObj( maCommand );
1181 :
1182 0 : Any a;
1183 0 : Sequence< PropertyValue > aArgs( 1 );
1184 0 : aArgs[0].Name = aObj.GetURLPath();
1185 0 : _aColorItem.QueryValue( a );
1186 0 : aArgs[0].Value = a;
1187 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1188 : maCommand,
1189 0 : aArgs );
1190 : }
1191 : else
1192 : {
1193 0 : INetURLObject aObj( maCommand );
1194 :
1195 0 : Any a;
1196 0 : Sequence< PropertyValue > aArgs( 1 );
1197 0 : aArgs[0].Name = aObj.GetURLPath();
1198 0 : aColorItem.QueryValue( a );
1199 0 : aArgs[0].Value = a;
1200 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1201 : maCommand,
1202 0 : aArgs );
1203 : }
1204 :
1205 0 : return 0;
1206 : }
1207 :
1208 : // -----------------------------------------------------------------------
1209 :
1210 0 : void SvxColorWindow_Impl::Resize()
1211 : {
1212 0 : lcl_ResizeValueSet( *this, aColorSet);
1213 0 : }
1214 :
1215 : // -----------------------------------------------------------------------
1216 :
1217 0 : void SvxColorWindow_Impl::StartSelection()
1218 : {
1219 0 : aColorSet.StartSelection();
1220 0 : }
1221 :
1222 : // -----------------------------------------------------------------------
1223 :
1224 0 : sal_Bool SvxColorWindow_Impl::Close()
1225 : {
1226 0 : return SfxPopupWindow::Close();
1227 : }
1228 :
1229 : // -----------------------------------------------------------------------
1230 :
1231 0 : void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1232 : {
1233 0 : if (( SFX_ITEM_DISABLED != eState ) && pState )
1234 : {
1235 0 : if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
1236 : {
1237 0 : if ( pState )
1238 : {
1239 0 : XColorListRef pColorList = ((SvxColorListItem *)pState)->GetColorList();
1240 0 : const long nColorCount(pColorList->Count());
1241 0 : const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
1242 0 : aColorSet.SetOutputSizePixel(aNewSize);
1243 : static sal_Int32 nAdd = 4;
1244 :
1245 0 : SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
1246 0 : aColorSet.Clear();
1247 0 : aColorSet.addEntriesForXColorList(*pColorList);
1248 : }
1249 : }
1250 : }
1251 0 : }
1252 :
1253 : //========================================================================
1254 : // class SvxFrameWindow_Impl --------------------------------------------------
1255 : //========================================================================
1256 :
1257 0 : SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
1258 :
1259 : SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
1260 : aFrameSet ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
1261 0 : bParagraphMode(sal_False)
1262 :
1263 : {
1264 0 : BindListener();
1265 0 : AddStatusListener(OUString(".uno:BorderReducedMode"));
1266 0 : aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
1267 :
1268 : /*
1269 : * 1 2 3 4
1270 : * -------------------------------------
1271 : * NONE LEFT RIGHT LEFTRIGHT
1272 : * TOP BOTTOM TOPBOTTOM OUTER
1273 : * -------------------------------------
1274 : * HOR HORINNER VERINNER ALL <- can be switched of via bParagraphMode
1275 : */
1276 :
1277 0 : sal_uInt16 i = 0;
1278 :
1279 0 : for ( i=1; i<9; i++ )
1280 0 : aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1281 :
1282 : //bParagraphMode should have been set in StateChanged
1283 0 : if ( !bParagraphMode )
1284 0 : for ( i = 9; i < 13; i++ )
1285 0 : aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1286 :
1287 0 : aFrameSet.SetColCount( 4 );
1288 0 : aFrameSet.SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) );
1289 :
1290 0 : lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
1291 :
1292 0 : SetHelpId( HID_POPUP_FRAME );
1293 0 : SetText( SVX_RESSTR(RID_SVXSTR_FRAME) );
1294 0 : aFrameSet.SetAccessibleName( SVX_RESSTR(RID_SVXSTR_FRAME) );
1295 0 : aFrameSet.Show();
1296 0 : }
1297 :
1298 0 : SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
1299 : {
1300 0 : UnbindListener();
1301 0 : }
1302 :
1303 0 : SfxPopupWindow* SvxFrameWindow_Impl::Clone() const
1304 : {
1305 : //! HACK: How do I get the Paragraph mode?
1306 0 : return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() );
1307 : }
1308 :
1309 0 : Window* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
1310 : {
1311 0 : return &aFrameSet;
1312 : }
1313 :
1314 0 : void SvxFrameWindow_Impl::GetFocus()
1315 : {
1316 0 : aFrameSet.GrabFocus();
1317 0 : }
1318 :
1319 0 : void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1320 : {
1321 0 : SfxPopupWindow::DataChanged( rDCEvt );
1322 :
1323 0 : if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1324 : {
1325 0 : aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
1326 :
1327 0 : sal_uInt16 nNumOfItems = aFrameSet.GetItemCount();
1328 :
1329 0 : for( sal_uInt16 i = 1 ; i <= nNumOfItems ; ++i )
1330 0 : aFrameSet.SetItemImage( i, aImgList.GetImage( i ) );
1331 : }
1332 0 : }
1333 : // -----------------------------------------------------------------------
1334 :
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
1343 :
1344 : // By default unset lines remain unchanged.
1345 : // Via Shift unset lines are reset
1346 :
1347 0 : IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl)
1348 : {
1349 0 : SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER );
1350 0 : SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER );
1351 0 : SvxBorderLine theDefLine;
1352 0 : SvxBorderLine *pLeft = 0,
1353 0 : *pRight = 0,
1354 0 : *pTop = 0,
1355 0 : *pBottom = 0;
1356 0 : sal_uInt16 nSel = aFrameSet.GetSelectItemId();
1357 0 : sal_uInt16 nModifier = aFrameSet.GetModifier();
1358 0 : sal_uInt8 nValidFlags = 0;
1359 :
1360 0 : theDefLine.GuessLinesWidths(theDefLine.GetBorderLineStyle(),
1361 0 : DEF_LINE_WIDTH_0);
1362 0 : switch ( nSel )
1363 : {
1364 0 : case 1: nValidFlags |= FRM_VALID_ALL;
1365 0 : break; // NONE
1366 0 : case 2: pLeft = &theDefLine;
1367 0 : nValidFlags |= FRM_VALID_LEFT;
1368 0 : break; // LEFT
1369 0 : case 3: pRight = &theDefLine;
1370 0 : nValidFlags |= FRM_VALID_RIGHT;
1371 0 : break; // RIGHT
1372 0 : case 4: pLeft = pRight = &theDefLine;
1373 0 : nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT;
1374 0 : break; // LEFTRIGHT
1375 0 : case 5: pTop = &theDefLine;
1376 0 : nValidFlags |= FRM_VALID_TOP;
1377 0 : break; // TOP
1378 0 : case 6: pBottom = &theDefLine;
1379 0 : nValidFlags |= FRM_VALID_BOTTOM;
1380 0 : break; // BOTTOM
1381 0 : case 7: pTop = pBottom = &theDefLine;
1382 0 : nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP;
1383 0 : break; // TOPBOTTOM
1384 0 : case 8: pLeft = pRight = pTop = pBottom = &theDefLine;
1385 0 : nValidFlags |= FRM_VALID_OUTER;
1386 0 : break; // OUTER
1387 :
1388 : // Inner Table:
1389 : case 9: // HOR
1390 0 : pTop = pBottom = &theDefLine;
1391 0 : aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1392 0 : aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
1393 0 : nValidFlags |= FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1394 0 : break;
1395 :
1396 : case 10: // HORINNER
1397 0 : pLeft = pRight = pTop = pBottom = &theDefLine;
1398 0 : aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1399 0 : aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
1400 0 : nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1401 0 : break;
1402 :
1403 : case 11: // VERINNER
1404 0 : pLeft = pRight = pTop = pBottom = &theDefLine;
1405 0 : aBorderInner.SetLine( NULL, BOXINFO_LINE_HORI );
1406 0 : aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
1407 0 : nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_VINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
1408 0 : break;
1409 :
1410 : case 12: // ALL
1411 0 : pLeft = pRight = pTop = pBottom = &theDefLine;
1412 0 : aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
1413 0 : aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
1414 0 : nValidFlags |= FRM_VALID_ALL;
1415 0 : break;
1416 :
1417 : default:
1418 0 : break;
1419 : }
1420 0 : aBorderOuter.SetLine( pLeft, BOX_LINE_LEFT );
1421 0 : aBorderOuter.SetLine( pRight, BOX_LINE_RIGHT );
1422 0 : aBorderOuter.SetLine( pTop, BOX_LINE_TOP );
1423 0 : aBorderOuter.SetLine( pBottom, BOX_LINE_BOTTOM );
1424 :
1425 0 : if(nModifier == KEY_SHIFT)
1426 0 : nValidFlags |= FRM_VALID_ALL;
1427 0 : aBorderInner.SetValid( VALID_TOP, 0 != (nValidFlags&FRM_VALID_TOP ));
1428 0 : aBorderInner.SetValid( VALID_BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM ));
1429 0 : aBorderInner.SetValid( VALID_LEFT, 0 != (nValidFlags&FRM_VALID_LEFT));
1430 0 : aBorderInner.SetValid( VALID_RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT ));
1431 0 : aBorderInner.SetValid( VALID_HORI, 0 != (nValidFlags&FRM_VALID_HINNER ));
1432 0 : aBorderInner.SetValid( VALID_VERT, 0 != (nValidFlags&FRM_VALID_VINNER));
1433 0 : aBorderInner.SetValid( VALID_DISTANCE, sal_True );
1434 0 : aBorderInner.SetValid( VALID_DISABLE, sal_False );
1435 :
1436 0 : if ( IsInPopupMode() )
1437 0 : EndPopupMode();
1438 :
1439 0 : Any a;
1440 0 : Sequence< PropertyValue > aArgs( 2 );
1441 0 : aArgs[0].Name = OUString( "OuterBorder" );
1442 0 : aBorderOuter.QueryValue( a );
1443 0 : aArgs[0].Value = a;
1444 0 : aArgs[1].Name = OUString( "InnerBorder" );
1445 0 : aBorderInner.QueryValue( a );
1446 0 : aArgs[1].Value = a;
1447 :
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 0 : aFrameSet.SetNoSelection();
1452 :
1453 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1454 : OUString( ".uno:SetBorderStyle" ),
1455 0 : aArgs );
1456 0 : return 0;
1457 : }
1458 :
1459 : // -----------------------------------------------------------------------
1460 :
1461 0 : void SvxFrameWindow_Impl::Resize()
1462 : {
1463 0 : lcl_ResizeValueSet( *this, aFrameSet);
1464 0 : }
1465 :
1466 : // -----------------------------------------------------------------------
1467 :
1468 0 : void SvxFrameWindow_Impl::StateChanged(
1469 :
1470 : sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
1471 :
1472 : {
1473 0 : if ( pState && nSID == SID_BORDER_REDUCED_MODE)
1474 : {
1475 0 : const SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState );
1476 :
1477 0 : if ( pItem )
1478 : {
1479 0 : bParagraphMode = (sal_Bool)pItem->GetValue();
1480 : //initial calls mustn't insert or remove elements
1481 0 : if(aFrameSet.GetItemCount())
1482 : {
1483 0 : bool bTableMode = ( aFrameSet.GetItemCount() == 12 );
1484 0 : bool bResize = false;
1485 :
1486 0 : if ( bTableMode && bParagraphMode )
1487 : {
1488 0 : for ( sal_uInt16 i = 9; i < 13; i++ )
1489 0 : aFrameSet.RemoveItem(i);
1490 0 : bResize = true;
1491 : }
1492 0 : else if ( !bTableMode && !bParagraphMode )
1493 : {
1494 0 : for ( sal_uInt16 i = 9; i < 13; i++ )
1495 0 : aFrameSet.InsertItem( i, aImgList.GetImage(i) );
1496 0 : bResize = true;
1497 : }
1498 :
1499 0 : if ( bResize )
1500 : {
1501 0 : lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
1502 : }
1503 : }
1504 : }
1505 : }
1506 0 : SfxPopupWindow::StateChanged( nSID, eState, pState );
1507 0 : }
1508 :
1509 : // -----------------------------------------------------------------------
1510 :
1511 0 : void SvxFrameWindow_Impl::StartSelection()
1512 : {
1513 0 : aFrameSet.StartSelection();
1514 0 : }
1515 :
1516 : // -----------------------------------------------------------------------
1517 :
1518 0 : sal_Bool SvxFrameWindow_Impl::Close()
1519 : {
1520 0 : return SfxPopupWindow::Close();
1521 : }
1522 :
1523 : //========================================================================
1524 : // class SvxLineWindow_Impl --------------------------------------------------
1525 : //========================================================================
1526 0 : static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1527 : {
1528 0 : return SvxBorderLine::threeDMediumColor( aMain );
1529 : }
1530 :
1531 0 : SvxLineWindow_Impl::SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
1532 :
1533 : SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION | WB_AUTOSIZE ) ),
1534 0 : m_aLineStyleLb( this )
1535 : {
1536 : try
1537 : {
1538 0 : Reference< lang::XServiceInfo > xServices( rFrame->getController()->getModel(), UNO_QUERY_THROW );
1539 0 : m_bIsWriter = xServices->supportsService("com.sun.star.text.TextDocument");
1540 : }
1541 0 : catch(const uno::Exception& )
1542 : {
1543 : }
1544 :
1545 0 : m_aLineStyleLb.setPosSizePixel( 2, 2, 110, 140 );
1546 0 : SetOutputSizePixel( Size( 114, 144 ) );
1547 :
1548 0 : m_aLineStyleLb.SetSourceUnit( FUNIT_TWIP );
1549 0 : m_aLineStyleLb.SetNone( SVX_RESSTR(RID_SVXSTR_NONE) );
1550 :
1551 : using namespace table::BorderLineStyle;
1552 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( SOLID ), SOLID );
1553 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( DOTTED ), DOTTED );
1554 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( DASHED ), DASHED );
1555 :
1556 : // Double lines
1557 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE ), DOUBLE );
1558 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP ), THINTHICK_SMALLGAP, 20 );
1559 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP ), THINTHICK_MEDIUMGAP );
1560 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP ), THINTHICK_LARGEGAP );
1561 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP ), THICKTHIN_SMALLGAP, 20 );
1562 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP ), THICKTHIN_MEDIUMGAP );
1563 0 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP ), THICKTHIN_LARGEGAP );
1564 :
1565 : // Engraved / Embossed
1566 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED ), EMBOSSED, 15,
1567 : &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor,
1568 0 : &lcl_mediumColor );
1569 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED ), ENGRAVED, 15,
1570 : &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor,
1571 0 : &lcl_mediumColor );
1572 :
1573 : // Inset / Outset
1574 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( OUTSET ), OUTSET, 10,
1575 0 : &SvxBorderLine::lightColor, &SvxBorderLine::darkColor );
1576 : m_aLineStyleLb.InsertEntry( SvxBorderLine::getWidthImpl( INSET ), INSET, 10,
1577 0 : &SvxBorderLine::darkColor, &SvxBorderLine::lightColor );
1578 0 : m_aLineStyleLb.SetWidth( 20 ); // 1pt by default
1579 :
1580 0 : m_aLineStyleLb.SetSelectHdl( LINK( this, SvxLineWindow_Impl, SelectHdl ) );
1581 :
1582 0 : SetHelpId( HID_POPUP_LINE );
1583 0 : SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE) );
1584 0 : m_aLineStyleLb.Show();
1585 0 : }
1586 :
1587 0 : SfxPopupWindow* SvxLineWindow_Impl::Clone() const
1588 : {
1589 0 : return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() );
1590 : }
1591 :
1592 : // -----------------------------------------------------------------------
1593 :
1594 0 : IMPL_LINK_NOARG(SvxLineWindow_Impl, SelectHdl)
1595 : {
1596 0 : SvxLineItem aLineItem( SID_FRAME_LINESTYLE );
1597 0 : SvxBorderStyle nStyle = SvxBorderStyle( m_aLineStyleLb.GetSelectEntryStyle() );
1598 :
1599 0 : if ( m_aLineStyleLb.GetSelectEntryPos( ) > 0 )
1600 : {
1601 0 : SvxBorderLine aTmp;
1602 0 : aTmp.SetBorderLineStyle( nStyle );
1603 0 : aTmp.SetWidth( 20 ); // TODO Make it depend on a width field
1604 0 : aLineItem.SetLine( &aTmp );
1605 : }
1606 : else
1607 0 : aLineItem.SetLine( NULL );
1608 :
1609 0 : if ( IsInPopupMode() )
1610 0 : EndPopupMode();
1611 :
1612 0 : Any a;
1613 0 : Sequence< PropertyValue > aArgs( 1 );
1614 0 : aArgs[0].Name = OUString( "LineStyle" );
1615 0 : aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 );
1616 0 : aArgs[0].Value = a;
1617 :
1618 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
1619 : OUString( ".uno:LineStyle" ),
1620 0 : aArgs );
1621 0 : return 0;
1622 : }
1623 :
1624 : // -----------------------------------------------------------------------
1625 :
1626 0 : void SvxLineWindow_Impl::Resize()
1627 : {
1628 0 : m_aLineStyleLb.Resize();
1629 0 : }
1630 :
1631 : // -----------------------------------------------------------------------
1632 :
1633 0 : sal_Bool SvxLineWindow_Impl::Close()
1634 : {
1635 0 : return SfxPopupWindow::Close();
1636 : }
1637 :
1638 : // -----------------------------------------------------------------------
1639 :
1640 0 : Window* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
1641 : {
1642 0 : return &m_aLineStyleLb;
1643 : }
1644 :
1645 : // -----------------------------------------------------------------------
1646 :
1647 0 : void SvxLineWindow_Impl::GetFocus()
1648 : {
1649 0 : m_aLineStyleLb.GrabFocus();
1650 0 : }
1651 :
1652 0 : void SvxLineWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1653 : {
1654 0 : SfxPopupWindow::DataChanged( rDCEvt );
1655 : #if 0
1656 : if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1657 : {
1658 : CreateBitmaps();
1659 : Invalidate();
1660 : }
1661 : #endif
1662 0 : }
1663 :
1664 : // -----------------------------------------------------------------------
1665 :
1666 : //########################################################################
1667 : // Hilfsklassen
1668 :
1669 : //========================================================================
1670 : // class SfxStyleControllerItem_Impl ------------------------------------------
1671 : //========================================================================
1672 :
1673 2660 : 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 ),
1679 2660 : rControl( rTbxCtl )
1680 : {
1681 2660 : }
1682 :
1683 : // -----------------------------------------------------------------------
1684 :
1685 3873 : void SfxStyleControllerItem_Impl::StateChanged(
1686 : sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
1687 : {
1688 3873 : switch ( GetId() )
1689 : {
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:
1695 : {
1696 3873 : const sal_uInt16 nIdx = GetId() - SID_STYLE_FAMILY_START;
1697 :
1698 3873 : if ( SFX_ITEM_AVAILABLE == eState )
1699 : {
1700 : const SfxTemplateItem* pStateItem =
1701 2901 : PTR_CAST( SfxTemplateItem, pState );
1702 : DBG_ASSERT( pStateItem != NULL, "SfxTemplateItem expected" );
1703 2901 : rControl.SetFamilyState( nIdx, pStateItem );
1704 : }
1705 : else
1706 972 : rControl.SetFamilyState( nIdx, NULL );
1707 3873 : break;
1708 : }
1709 : }
1710 3873 : }
1711 :
1712 : //########################################################################
1713 :
1714 : //========================================================================
1715 : // class SvxStyleToolBoxControl ------------------------------------------
1716 : //========================================================================
1717 :
1718 532 : struct SvxStyleToolBoxControl::Impl
1719 : {
1720 : String aClearForm;
1721 : String aMore;
1722 : ::std::vector< OUString > aDefaultStyles;
1723 : sal_Bool bSpecModeWriter;
1724 : sal_Bool bSpecModeCalc;
1725 :
1726 532 : inline Impl( void )
1727 532 : :aClearForm ( SVX_RESSTR( RID_SVXSTR_CLEARFORM ) )
1728 532 : ,aMore ( SVX_RESSTR( RID_SVXSTR_MORE ) )
1729 : ,bSpecModeWriter ( sal_False )
1730 1064 : ,bSpecModeCalc ( sal_False )
1731 : {
1732 :
1733 :
1734 532 : }
1735 532 : void InitializeStyles(Reference < frame::XModel > xModel)
1736 : {
1737 : //now convert the default style names to the localized names
1738 : try
1739 : {
1740 532 : Reference< style::XStyleFamiliesSupplier > xStylesSupplier( xModel, UNO_QUERY_THROW );
1741 1064 : Reference< lang::XServiceInfo > xServices( xModel, UNO_QUERY_THROW );
1742 532 : bSpecModeWriter = xServices->supportsService("com.sun.star.text.TextDocument");
1743 532 : if(bSpecModeWriter)
1744 : {
1745 375 : Reference<container::XNameAccess> xParaStyles;
1746 750 : xStylesSupplier->getStyleFamilies()->getByName("ParagraphStyles") >>=
1747 375 : xParaStyles;
1748 : static const sal_Char* aWriterStyles[] =
1749 : {
1750 : "Text body",
1751 : "Quotations",
1752 : "Title",
1753 : "Subtitle",
1754 : "Heading 1",
1755 : "Heading 2",
1756 : "Heading 3"
1757 : };
1758 3000 : for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
1759 : {
1760 : try
1761 : {
1762 2625 : Reference< beans::XPropertySet > xStyle;
1763 2625 : xParaStyles->getByName( OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
1764 5250 : OUString sName;
1765 2625 : xStyle->getPropertyValue("DisplayName") >>= sName;
1766 2625 : if( !sName.isEmpty() )
1767 5250 : aDefaultStyles.push_back(sName);
1768 : }
1769 0 : catch( const uno::Exception& )
1770 : {}
1771 375 : }
1772 :
1773 : }
1774 314 : else if( 0 != (
1775 157 : bSpecModeCalc = xServices->supportsService(OUString(
1776 314 : "com.sun.star.sheet.SpreadsheetDocument"))))
1777 : {
1778 : static const sal_Char* aCalcStyles[] =
1779 : {
1780 : "Default",
1781 : "Heading1",
1782 : "Result",
1783 : "Result2"
1784 : };
1785 155 : Reference<container::XNameAccess> xCellStyles;
1786 310 : xStylesSupplier->getStyleFamilies()->getByName(
1787 310 : OUString("CellStyles")) >>=
1788 155 : xCellStyles;
1789 775 : for( sal_uInt32 nStyle = 0; nStyle < sizeof( aCalcStyles ) / sizeof( sal_Char*); ++nStyle )
1790 : {
1791 : try
1792 : {
1793 620 : const OUString sStyleName( OUString::createFromAscii( aCalcStyles[nStyle] ) );
1794 620 : if( xCellStyles->hasByName( sStyleName ) )
1795 : {
1796 620 : Reference< beans::XPropertySet > xStyle( xCellStyles->getByName( sStyleName), UNO_QUERY_THROW );
1797 1240 : OUString sName;
1798 620 : xStyle->getPropertyValue("DisplayName") >>= sName;
1799 620 : if( !sName.isEmpty() )
1800 1240 : aDefaultStyles.push_back(sName);
1801 620 : }
1802 : }
1803 0 : catch( const uno::Exception& )
1804 : {}
1805 155 : }
1806 532 : }
1807 : }
1808 0 : catch(const uno::Exception& )
1809 : {
1810 : OSL_FAIL("error while initializing style names");
1811 : }
1812 532 : }
1813 : };
1814 :
1815 :
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] =
1820 : {
1821 : ".uno:CharStyle",
1822 : ".uno:ParaStyle",
1823 : ".uno:FrameStyle",
1824 : ".uno:PageStyle",
1825 : ".uno:TemplateFamily5"
1826 : };
1827 :
1828 532 : SvxStyleToolBoxControl::SvxStyleToolBoxControl(
1829 : sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
1830 : : SfxToolBoxControl ( nSlotId, nId, rTbx ),
1831 : pStyleSheetPool ( NULL ),
1832 : nActFamily ( 0xffff ),
1833 532 : pImpl ( new Impl )
1834 : {
1835 3192 : for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1836 : {
1837 2660 : pBoundItems[i] = 0;
1838 2660 : m_xBoundItems[i].clear();
1839 2660 : pFamilyState[i] = NULL;
1840 : }
1841 532 : }
1842 :
1843 : // -----------------------------------------------------------------------
1844 1596 : SvxStyleToolBoxControl::~SvxStyleToolBoxControl()
1845 : {
1846 532 : delete pImpl;
1847 1064 : }
1848 :
1849 : // -----------------------------------------------------------------------
1850 532 : void SAL_CALL SvxStyleToolBoxControl::initialize( const Sequence< Any >& aArguments )
1851 : throw ( Exception, RuntimeException)
1852 : {
1853 532 : SfxToolBoxControl::initialize( aArguments );
1854 :
1855 : // After initialize we should have a valid frame member where we can retrieve our
1856 : // dispatch provider.
1857 532 : if ( m_xFrame.is() )
1858 : {
1859 532 : pImpl->InitializeStyles(m_xFrame->getController()->getModel());
1860 532 : Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY );
1861 3192 : for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1862 : {
1863 2660 : pBoundItems[i] = new SfxStyleControllerItem_Impl( xDispatchProvider,
1864 : SID_STYLE_FAMILY_START + i,
1865 : OUString::createFromAscii( StyleSlotToStyleCommand[i] ),
1866 5320 : *this );
1867 2660 : m_xBoundItems[i] = Reference< XComponent >( static_cast< OWeakObject* >( pBoundItems[i] ), UNO_QUERY );
1868 2660 : pFamilyState[i] = NULL;
1869 532 : }
1870 : }
1871 532 : }
1872 :
1873 : // XComponent
1874 532 : void SAL_CALL SvxStyleToolBoxControl::dispose()
1875 : throw (::com::sun::star::uno::RuntimeException)
1876 : {
1877 532 : SfxToolBoxControl::dispose();
1878 :
1879 3192 : for( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
1880 : {
1881 2660 : if ( m_xBoundItems[i].is() )
1882 : {
1883 : try
1884 : {
1885 2660 : m_xBoundItems[i]->dispose();
1886 : }
1887 0 : catch ( Exception& )
1888 : {
1889 : }
1890 :
1891 2660 : m_xBoundItems[i].clear();
1892 2660 : pBoundItems[i] = 0;
1893 : }
1894 2660 : DELETEZ( pFamilyState[i] );
1895 : }
1896 532 : pStyleSheetPool = NULL;
1897 532 : DELETEZ( pImpl );
1898 532 : }
1899 :
1900 : // -----------------------------------------------------------------------
1901 517 : void SAL_CALL SvxStyleToolBoxControl::update() throw (RuntimeException)
1902 : {
1903 : // Do nothing, we will start binding our listener when we are visible.
1904 : // See link SvxStyleToolBoxControl::VisibilityNotification.
1905 517 : SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1906 517 : if ( pBox->IsVisible() )
1907 : {
1908 2202 : for ( int i=0; i<MAX_FAMILIES; i++ )
1909 1835 : pBoundItems [i]->ReBind();
1910 :
1911 367 : bindListener();
1912 : }
1913 517 : }
1914 :
1915 : // -----------------------------------------------------------------------
1916 :
1917 4881 : SfxStyleFamily SvxStyleToolBoxControl::GetActFamily()
1918 : {
1919 4881 : switch ( nActFamily-1 + SID_STYLE_FAMILY_START )
1920 : {
1921 0 : case SID_STYLE_FAMILY1: return SFX_STYLE_FAMILY_CHAR;
1922 4504 : case SID_STYLE_FAMILY2: return SFX_STYLE_FAMILY_PARA;
1923 377 : case SID_STYLE_FAMILY3: return SFX_STYLE_FAMILY_FRAME;
1924 0 : case SID_STYLE_FAMILY4: return SFX_STYLE_FAMILY_PAGE;
1925 0 : case SID_STYLE_FAMILY5: return SFX_STYLE_FAMILY_PSEUDO;
1926 : default:
1927 : OSL_FAIL( "unknown style family" );
1928 0 : break;
1929 : }
1930 0 : return SFX_STYLE_FAMILY_PARA;
1931 : }
1932 :
1933 : // -----------------------------------------------------------------------
1934 :
1935 4881 : void SvxStyleToolBoxControl::FillStyleBox()
1936 : {
1937 4881 : SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
1938 :
1939 : DBG_ASSERT( pStyleSheetPool, "StyleSheetPool not found!" );
1940 : DBG_ASSERT( pBox, "Control not found!" );
1941 :
1942 4881 : if ( pStyleSheetPool && pBox && nActFamily!=0xffff )
1943 : {
1944 4881 : const SfxStyleFamily eFamily = GetActFamily();
1945 4881 : sal_uInt16 nCount = pStyleSheetPool->Count();
1946 4881 : SfxStyleSheetBase* pStyle = NULL;
1947 4881 : bool bDoFill = false;
1948 :
1949 4881 : pStyleSheetPool->SetSearchMask( eFamily, SFXSTYLEBIT_USED );
1950 :
1951 : // Check whether fill is necessary
1952 4881 : 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 4881 : if ( nCount != pBox->GetEntryCount() )
1956 : {
1957 4855 : bDoFill = true;
1958 : }
1959 : else
1960 : {
1961 26 : sal_uInt16 i= 0;
1962 99 : while ( pStyle && !bDoFill )
1963 : {
1964 47 : bDoFill = ( pBox->GetEntry(i) != pStyle->GetName() );
1965 47 : pStyle = pStyleSheetPool->Next();
1966 47 : i++;
1967 : }
1968 : }
1969 :
1970 4881 : if ( bDoFill )
1971 : {
1972 4881 : pBox->SetUpdateMode( sal_False );
1973 4881 : pBox->Clear();
1974 :
1975 : {
1976 : sal_uInt16 _i;
1977 4881 : sal_uInt32 nCnt = pImpl->aDefaultStyles.size();
1978 :
1979 4881 : pStyle = pStyleSheetPool->First();
1980 :
1981 4881 : if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
1982 : {
1983 : bool bInsert;
1984 14515 : while ( pStyle )
1985 : {
1986 : // sort out default styles
1987 4803 : bInsert = true;
1988 4803 : OUString aName( pStyle->GetName() );
1989 38300 : for( _i = 0 ; _i < nCnt ; ++_i )
1990 : {
1991 33517 : if( pImpl->aDefaultStyles[_i] == aName )
1992 : {
1993 20 : bInsert = false;
1994 20 : break;
1995 : }
1996 : }
1997 :
1998 4803 : if( bInsert )
1999 4783 : pBox->InsertEntry( aName );
2000 4803 : pStyle = pStyleSheetPool->Next();
2001 9659 : }
2002 : }
2003 : else
2004 : {
2005 211 : while ( pStyle )
2006 : {
2007 161 : pBox->InsertEntry( pStyle->GetName() );
2008 161 : pStyle = pStyleSheetPool->Next();
2009 : }
2010 : }
2011 : }
2012 :
2013 4881 : if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
2014 : {
2015 : // disable sort to preserve special order
2016 4856 : WinBits nWinBits = pBox->GetStyle();
2017 4856 : nWinBits &= ~WB_SORT;
2018 4856 : pBox->SetStyle( nWinBits );
2019 :
2020 : // insert default styles
2021 : sal_uInt16 _i;
2022 4856 : sal_uInt32 nCnt = pImpl->aDefaultStyles.size();
2023 4856 : sal_uInt16 nPos = 1;
2024 38848 : for( _i = 0 ; _i < nCnt ; ++_i )
2025 : {
2026 33992 : pBox->InsertEntry( pImpl->aDefaultStyles[_i], nPos );
2027 33992 : ++nPos;
2028 : }
2029 :
2030 4856 : pBox->InsertEntry( pImpl->aClearForm, 0 );
2031 4856 : pBox->SetSeparatorPos( 0 );
2032 :
2033 4856 : pBox->InsertEntry( pImpl->aMore );
2034 :
2035 : // enable sort again
2036 4856 : nWinBits |= WB_SORT;
2037 4856 : pBox->SetStyle( nWinBits );
2038 : }
2039 :
2040 4881 : pBox->SetUpdateMode( sal_True );
2041 4881 : pBox->SetFamily( eFamily );
2042 :
2043 4881 : sal_uInt16 nLines = std::min( pBox->GetEntryCount(), MAX_STYLES_ENTRIES );
2044 4881 : pBox->SetDropDownLineCount( nLines );
2045 : }
2046 : }
2047 4881 : }
2048 :
2049 : // -----------------------------------------------------------------------
2050 :
2051 4504 : void SvxStyleToolBoxControl::SelectStyle( const String& rStyleName )
2052 : {
2053 4504 : SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
2054 : DBG_ASSERT( pBox, "Control not found!" );
2055 :
2056 4504 : if ( pBox )
2057 : {
2058 : // String aStrSel( pBox->GetSelectEntry() );
2059 4504 : String aStrSel( pBox->GetText() );
2060 :
2061 4504 : if ( rStyleName.Len() > 0 )
2062 : {
2063 4504 : if ( rStyleName != aStrSel )
2064 : // pBox->SelectEntry( rStyleName );
2065 384 : pBox->SetText( rStyleName );
2066 : }
2067 : else
2068 0 : pBox->SetNoSelection();
2069 4504 : pBox->SaveValue();
2070 : }
2071 4504 : }
2072 :
2073 : // -----------------------------------------------------------------------
2074 :
2075 4881 : void SvxStyleToolBoxControl::Update()
2076 : {
2077 4881 : SfxStyleSheetBasePool* pPool = NULL;
2078 4881 : SfxObjectShell* pDocShell = SfxObjectShell::Current();
2079 :
2080 4881 : if ( pDocShell )
2081 4881 : pPool = pDocShell->GetStyleSheetPool();
2082 :
2083 : sal_uInt16 i;
2084 4881 : for ( i=0; i<MAX_FAMILIES; i++ )
2085 4881 : if( pFamilyState[i] )
2086 4881 : break;
2087 :
2088 4881 : if ( i==MAX_FAMILIES || !pPool )
2089 : {
2090 0 : pStyleSheetPool = pPool;
2091 4881 : return;
2092 : }
2093 :
2094 : //--------------------------------------------------------------------
2095 4881 : const SfxTemplateItem* pItem = NULL;
2096 :
2097 4881 : if ( nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1]) )
2098 : // Current range not within allowed ranges or default
2099 : {
2100 754 : pStyleSheetPool = pPool;
2101 754 : nActFamily = 2;
2102 :
2103 754 : pItem = pFamilyState[nActFamily-1];
2104 754 : if ( !pItem )
2105 : {
2106 377 : nActFamily++;
2107 377 : pItem = pFamilyState[nActFamily-1];
2108 : }
2109 :
2110 : if ( !pItem )
2111 : {
2112 : DBG_WARNING( "Unknown Family" ); // can happen
2113 : }
2114 : }
2115 4127 : else if ( pPool != pStyleSheetPool )
2116 6 : pStyleSheetPool = pPool;
2117 :
2118 4881 : FillStyleBox(); // Decides by itself whether Fill is needed
2119 :
2120 4881 : if ( pItem )
2121 4504 : SelectStyle( pItem->GetStyleName() );
2122 : }
2123 :
2124 : // -----------------------------------------------------------------------
2125 :
2126 3873 : void SvxStyleToolBoxControl::SetFamilyState( sal_uInt16 nIdx,
2127 : const SfxTemplateItem* pItem )
2128 : {
2129 3873 : DELETEZ( pFamilyState[nIdx] );
2130 :
2131 3873 : if ( pItem )
2132 2901 : pFamilyState[nIdx] = new SfxTemplateItem( *pItem );
2133 :
2134 3873 : Update();
2135 3873 : }
2136 :
2137 : // -----------------------------------------------------------------------
2138 :
2139 1508 : IMPL_LINK_NOARG(SvxStyleToolBoxControl, VisibilityNotification)
2140 : {
2141 :
2142 : sal_uInt16 i;
2143 :
2144 : // Call ReBind() && UnBind() according to visibility
2145 754 : SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)( GetToolBox().GetItemWindow( GetId() ));
2146 754 : if ( pBox->IsVisible() && !isBound() )
2147 : {
2148 2262 : for ( i=0; i<MAX_FAMILIES; i++ )
2149 1885 : pBoundItems [i]->ReBind();
2150 :
2151 377 : bindListener();
2152 : }
2153 377 : else if ( !pBox->IsVisible() && isBound() )
2154 : {
2155 0 : for ( i=0; i<MAX_FAMILIES; i++ )
2156 0 : pBoundItems[i]->UnBind();
2157 0 : unbindListener();
2158 : }
2159 :
2160 754 : return 0;
2161 : }
2162 :
2163 : // -----------------------------------------------------------------------
2164 :
2165 1008 : void SvxStyleToolBoxControl::StateChanged(
2166 :
2167 : sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2168 :
2169 : {
2170 1008 : sal_uInt16 nId = GetId();
2171 1008 : ToolBox& rTbx = GetToolBox();
2172 1008 : SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)(rTbx.GetItemWindow( nId ));
2173 1008 : TriState eTri = STATE_NOCHECK;
2174 :
2175 : DBG_ASSERT( pBox, "Control not found!" );
2176 :
2177 1008 : if ( SFX_ITEM_DISABLED == eState )
2178 0 : pBox->Disable();
2179 : else
2180 1008 : pBox->Enable();
2181 :
2182 1008 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2183 :
2184 1008 : switch ( eState )
2185 : {
2186 : case SFX_ITEM_AVAILABLE:
2187 1008 : eTri = ((const SfxBoolItem*)pState)->GetValue()
2188 : ? STATE_CHECK
2189 1008 : : STATE_NOCHECK;
2190 1008 : break;
2191 :
2192 : case SFX_ITEM_DONTCARE:
2193 0 : eTri = STATE_DONTKNOW;
2194 0 : break;
2195 : }
2196 :
2197 1008 : rTbx.SetItemState( nId, eTri );
2198 :
2199 1008 : if ( SFX_ITEM_DISABLED != eState )
2200 1008 : Update();
2201 1008 : }
2202 :
2203 : // -----------------------------------------------------------------------
2204 :
2205 532 : Window* SvxStyleToolBoxControl::CreateItemWindow( Window *pParent )
2206 : {
2207 : SvxStyleBox_Impl* pBox = new SvxStyleBox_Impl( pParent,
2208 : OUString( ".uno:StyleApply" ),
2209 : SFX_STYLE_FAMILY_PARA,
2210 532 : Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
2211 : m_xFrame,
2212 : pImpl->aClearForm,
2213 : pImpl->aMore,
2214 1064 : pImpl->bSpecModeWriter || pImpl->bSpecModeCalc );
2215 532 : if( !pImpl->aDefaultStyles.empty())
2216 530 : pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] );
2217 : // Set visibility listener to bind/unbind controller
2218 532 : pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, VisibilityNotification ));
2219 :
2220 532 : return pBox;
2221 : }
2222 :
2223 : //========================================================================
2224 : // class SvxFontNameToolBoxControl ---------------------------------------
2225 : //========================================================================
2226 :
2227 532 : SvxFontNameToolBoxControl::SvxFontNameToolBoxControl(
2228 : sal_uInt16 nSlotId,
2229 : sal_uInt16 nId,
2230 : ToolBox& rTbx )
2231 :
2232 532 : : SfxToolBoxControl( nSlotId, nId, rTbx )
2233 : {
2234 532 : }
2235 :
2236 : // -----------------------------------------------------------------------
2237 :
2238 777 : void SvxFontNameToolBoxControl::StateChanged(
2239 :
2240 : sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2241 :
2242 : {
2243 777 : sal_uInt16 nId = GetId();
2244 777 : ToolBox& rTbx = GetToolBox();
2245 777 : SvxFontNameBox_Impl* pBox = (SvxFontNameBox_Impl*)(rTbx.GetItemWindow( nId ));
2246 :
2247 : DBG_ASSERT( pBox, "Control not found!" );
2248 :
2249 777 : if ( SFX_ITEM_DISABLED == eState )
2250 : {
2251 0 : pBox->Disable();
2252 0 : pBox->Update( (const SvxFontItem*)NULL );
2253 : }
2254 : else
2255 : {
2256 777 : pBox->Enable();
2257 :
2258 777 : if ( SFX_ITEM_AVAILABLE == eState )
2259 : {
2260 777 : const SvxFontItem* pFontItem = dynamic_cast< const SvxFontItem* >( pState );
2261 :
2262 : DBG_ASSERT( pFontItem, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" );
2263 777 : if( pFontItem )
2264 777 : pBox->Update( pFontItem );
2265 : }
2266 : else
2267 0 : pBox->SetText( String() );
2268 777 : pBox->SaveValue();
2269 : }
2270 :
2271 777 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2272 777 : }
2273 :
2274 : // -----------------------------------------------------------------------
2275 :
2276 532 : Window* SvxFontNameToolBoxControl::CreateItemWindow( Window *pParent )
2277 : {
2278 : SvxFontNameBox_Impl* pBox = new SvxFontNameBox_Impl( pParent,
2279 532 : Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
2280 532 : m_xFrame,0);
2281 532 : return pBox;
2282 : }
2283 :
2284 : //========================================================================
2285 : // class SvxFontColorToolBoxControl --------------------------------------
2286 : //========================================================================
2287 :
2288 0 : SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
2289 : sal_uInt16 nSlotId,
2290 : sal_uInt16 nId,
2291 : ToolBox& rTbx )
2292 :
2293 : : SfxToolBoxControl( nSlotId, nId, rTbx ),
2294 : pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
2295 0 : nSlotId, nId, &GetToolBox() )),
2296 0 : mLastColor( COL_AUTO )
2297 : {
2298 0 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2299 0 : }
2300 :
2301 : // -----------------------------------------------------------------------
2302 :
2303 0 : SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl()
2304 : {
2305 0 : delete pBtnUpdater;
2306 0 : }
2307 :
2308 : // -----------------------------------------------------------------------
2309 :
2310 0 : SfxPopupWindowType SvxFontColorToolBoxControl::GetPopupWindowType() const
2311 : {
2312 0 : return SFX_POPUPWINDOW_ONCLICK;
2313 : }
2314 :
2315 : // -----------------------------------------------------------------------
2316 :
2317 0 : SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow()
2318 : {
2319 : SvxColorWindow_Impl* pColorWin =
2320 : new SvxColorWindow_Impl(
2321 : OUString( ".uno:Color" ),
2322 : SID_ATTR_CHAR_COLOR,
2323 : m_xFrame,
2324 0 : SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
2325 0 : &GetToolBox(),
2326 0 : mLastColor);
2327 :
2328 0 : pColorWin->StartPopupMode( &GetToolBox(),
2329 0 : FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
2330 0 : pColorWin->StartSelection();
2331 0 : SetPopupWindow( pColorWin );
2332 0 : return pColorWin;
2333 : }
2334 :
2335 : // -----------------------------------------------------------------------
2336 :
2337 0 : void SvxFontColorToolBoxControl::StateChanged(
2338 :
2339 : sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2340 :
2341 : {
2342 0 : sal_uInt16 nId = GetId();
2343 0 : ToolBox& rTbx = GetToolBox();
2344 0 : const SvxColorItem* pItem = 0;
2345 :
2346 0 : if ( SFX_ITEM_DONTCARE != eState )
2347 0 : pItem = PTR_CAST( SvxColorItem, pState );
2348 :
2349 0 : if ( pItem )
2350 : {
2351 0 : pBtnUpdater->Update( pItem->GetValue() );
2352 0 : mLastColor= pItem->GetValue();
2353 : }
2354 :
2355 0 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2356 0 : rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2357 0 : }
2358 :
2359 : //========================================================================
2360 : // class SvxColorToolBoxControl --------------------------------
2361 : //========================================================================
2362 :
2363 0 : SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
2364 :
2365 : SfxToolBoxControl( nSlotId, nId, rTbx ),
2366 0 : mLastColor( COL_AUTO )
2367 : {
2368 0 : if ( nSlotId == SID_BACKGROUND_COLOR )
2369 0 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2370 : else
2371 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2372 0 : rTbx.Invalidate();
2373 0 : pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() );
2374 0 : }
2375 :
2376 : // -----------------------------------------------------------------------
2377 :
2378 0 : SvxColorToolBoxControl::~SvxColorToolBoxControl()
2379 : {
2380 0 : delete pBtnUpdater;
2381 0 : }
2382 :
2383 : // -----------------------------------------------------------------------
2384 :
2385 0 : SfxPopupWindowType SvxColorToolBoxControl::GetPopupWindowType() const
2386 : {
2387 0 : return SFX_POPUPWINDOW_ONCLICK;
2388 : }
2389 :
2390 : // -----------------------------------------------------------------------
2391 :
2392 0 : SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
2393 : {
2394 0 : sal_uInt16 nResId = GetSlotId() == SID_BACKGROUND_COLOR ?
2395 0 : RID_SVXSTR_BACKGROUND : RID_SVXSTR_COLOR;
2396 : SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
2397 : OUString( ".uno:BackgroundColor" ),
2398 : SID_BACKGROUND_COLOR,
2399 : m_xFrame,
2400 0 : SVX_RESSTR(nResId),
2401 0 : &GetToolBox(),
2402 0 : mLastColor);
2403 :
2404 0 : pColorWin->StartPopupMode( &GetToolBox(),
2405 0 : FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
2406 0 : pColorWin->StartSelection();
2407 0 : SetPopupWindow( pColorWin );
2408 0 : return pColorWin;
2409 : }
2410 :
2411 : // -----------------------------------------------------------------------
2412 :
2413 0 : void SvxColorToolBoxControl::StateChanged(
2414 : sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2415 : {
2416 0 : const SvxColorItem* pItem = 0;
2417 0 : if ( SFX_ITEM_DONTCARE != eState )
2418 0 : pItem = PTR_CAST( SvxColorItem, pState );
2419 :
2420 0 : if ( pItem ) {
2421 0 : pBtnUpdater->Update( pItem->GetValue() );
2422 0 : mLastColor= pItem->GetValue();
2423 : }
2424 :
2425 0 : sal_uInt16 nId = GetId();
2426 0 : ToolBox& rTbx = GetToolBox();
2427 0 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2428 0 : rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2429 0 : }
2430 :
2431 : //========================================================================
2432 : // class SvxColorExtToolBoxControl ----------------------------------------
2433 : //========================================================================
2434 : /* Note:
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)
2441 : */
2442 :
2443 1600 : SvxColorExtToolBoxControl::SvxColorExtToolBoxControl(
2444 : sal_uInt16 nSlotId,
2445 : sal_uInt16 nId,
2446 : ToolBox& rTbx ) :
2447 :
2448 : SfxToolBoxControl( nSlotId, nId, rTbx ),
2449 : pBtnUpdater(0),
2450 1600 : mLastColor( COL_AUTO )
2451 : {
2452 1600 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
2453 1600 : bChoiceFromPalette = sal_False;
2454 :
2455 : // The following commands are available at the various modules
2456 1600 : switch( nSlotId )
2457 : {
2458 : case SID_ATTR_CHAR_COLOR:
2459 155 : addStatusListener( OUString( ".uno:Color" ));
2460 155 : mLastColor = COL_RED;
2461 155 : break;
2462 :
2463 : case SID_ATTR_CHAR_COLOR2:
2464 377 : addStatusListener( OUString( ".uno:CharColorExt" ));
2465 377 : mLastColor = COL_RED;
2466 377 : break;
2467 :
2468 : case SID_BACKGROUND_COLOR:
2469 : case SID_ATTR_CHAR_COLOR_BACKGROUND:
2470 : default:
2471 911 : addStatusListener( OUString( ".uno:CharBackgroundExt" ));
2472 911 : mLastColor = COL_YELLOW;
2473 911 : break;
2474 :
2475 : case SID_FRAME_LINECOLOR:
2476 157 : addStatusListener( OUString( ".uno:FrameLineColor" ));
2477 157 : mLastColor = COL_BLUE;
2478 157 : break;
2479 : }
2480 :
2481 1600 : pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() );
2482 1600 : }
2483 :
2484 : // -----------------------------------------------------------------------
2485 :
2486 4800 : SvxColorExtToolBoxControl::~SvxColorExtToolBoxControl()
2487 : {
2488 1600 : delete pBtnUpdater;
2489 3200 : }
2490 :
2491 : // -----------------------------------------------------------------------
2492 :
2493 0 : SfxPopupWindowType SvxColorExtToolBoxControl::GetPopupWindowType() const
2494 : {
2495 0 : return SFX_POPUPWINDOW_ONTIMEOUT;
2496 : }
2497 :
2498 : // -----------------------------------------------------------------------
2499 :
2500 0 : SfxPopupWindow* SvxColorExtToolBoxControl::CreatePopupWindow()
2501 : {
2502 : SvxColorWindow_Impl* pColorWin =
2503 : new SvxColorWindow_Impl(
2504 : m_aCommandURL,
2505 0 : GetSlotId(),
2506 : m_xFrame,
2507 0 : SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
2508 0 : &GetToolBox(),
2509 0 : mLastColor );
2510 :
2511 0 : switch( GetSlotId() )
2512 : {
2513 : case SID_ATTR_CHAR_COLOR_BACKGROUND :
2514 0 : pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
2515 0 : break;
2516 :
2517 : case SID_BACKGROUND_COLOR :
2518 0 : pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
2519 0 : break;
2520 :
2521 : case SID_FRAME_LINECOLOR:
2522 0 : pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
2523 0 : break;
2524 : }
2525 :
2526 0 : pColorWin->StartPopupMode( &GetToolBox(),
2527 0 : FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
2528 0 : pColorWin->StartSelection();
2529 0 : SetPopupWindow( pColorWin );
2530 0 : bChoiceFromPalette = sal_True;
2531 0 : return pColorWin;
2532 : }
2533 :
2534 : // -----------------------------------------------------------------------
2535 :
2536 4104 : void SvxColorExtToolBoxControl::StateChanged(
2537 :
2538 : sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
2539 :
2540 : {
2541 4104 : const SvxColorItem* pItem = 0;
2542 4104 : if ( bChoiceFromPalette )
2543 : {
2544 0 : bChoiceFromPalette = sal_False;
2545 0 : switch( nSID )
2546 : {
2547 : case SID_ATTR_CHAR_COLOR :
2548 : case SID_ATTR_CHAR_COLOR2 :
2549 : case SID_ATTR_CHAR_COLOR_BACKGROUND :
2550 : case SID_BACKGROUND_COLOR :
2551 0 : if ( SFX_ITEM_DONTCARE != eState )
2552 0 : pItem = PTR_CAST( SvxColorItem, pState );
2553 :
2554 0 : if ( pItem )
2555 : {
2556 0 : pBtnUpdater->Update( pItem->GetValue() );
2557 0 : mLastColor = pItem->GetValue();
2558 : }
2559 0 : break;
2560 :
2561 : case SID_FRAME_LINECOLOR :
2562 0 : ToolBox& rTbx = GetToolBox();
2563 0 : rTbx.EnableItem( nSID, SFX_ITEM_DISABLED != eState );
2564 0 : rTbx.SetItemState( nSID, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2565 :
2566 0 : if ( SFX_ITEM_DONTCARE != eState )
2567 : {
2568 0 : pItem = PTR_CAST( SvxColorItem, pState );
2569 0 : if ( pItem )
2570 : {
2571 0 : pBtnUpdater->Update( pItem->GetValue());
2572 0 : mLastColor = pItem->GetValue();
2573 : }
2574 : }
2575 0 : break;
2576 : }
2577 : }
2578 4104 : }
2579 :
2580 : // -----------------------------------------------------------------------
2581 :
2582 0 : void SvxColorExtToolBoxControl::Select( sal_Bool )
2583 : {
2584 0 : OUString aCommand;
2585 0 : OUString aParamName;
2586 0 : bool bNoArgs = false;
2587 :
2588 0 : switch( GetSlotId() )
2589 : {
2590 : case SID_ATTR_CHAR_COLOR2 :
2591 0 : bNoArgs = true;
2592 0 : aCommand = OUString( ".uno:CharColorExt" );
2593 0 : aParamName = OUString( "CharColorExt" );
2594 0 : break;
2595 :
2596 : case SID_ATTR_CHAR_COLOR :
2597 0 : aCommand = OUString( ".uno:Color" );
2598 0 : aParamName = OUString( "Color" );
2599 0 : break;
2600 :
2601 : case SID_BACKGROUND_COLOR :
2602 0 : aCommand = OUString( ".uno:BackgroundColor" );
2603 0 : aParamName = OUString( "BackgroundColor" );
2604 0 : break;
2605 :
2606 : case SID_ATTR_CHAR_COLOR_BACKGROUND :
2607 0 : bNoArgs = true;
2608 0 : aCommand = OUString( ".uno:CharBackgroundExt" );
2609 0 : aParamName = OUString( "CharBackgroundExt" );
2610 0 : break;
2611 :
2612 : case SID_FRAME_LINECOLOR :
2613 0 : aCommand = OUString( ".uno:FrameLineColor" );
2614 0 : aParamName = OUString( "FrameLineColor" );
2615 0 : break;
2616 : }
2617 :
2618 0 : Sequence< PropertyValue > aArgs( 1 );
2619 0 : aArgs[0].Name = aParamName;
2620 0 : if ( bNoArgs )
2621 0 : aArgs[0].Value = makeAny( GetToolBox().IsItemChecked( GetId() ));
2622 : else
2623 0 : aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() ));
2624 0 : Dispatch( aCommand, aArgs );
2625 0 : }
2626 :
2627 : //========================================================================
2628 : // class SvxFrameToolBoxControl ------------------------------------------
2629 : //========================================================================
2630 :
2631 157 : SvxFrameToolBoxControl::SvxFrameToolBoxControl(
2632 : sal_uInt16 nSlotId,
2633 : sal_uInt16 nId,
2634 : ToolBox& rTbx )
2635 :
2636 157 : : SfxToolBoxControl( nSlotId, nId, rTbx )
2637 : {
2638 157 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2639 157 : }
2640 :
2641 : // -----------------------------------------------------------------------
2642 :
2643 0 : SfxPopupWindowType SvxFrameToolBoxControl::GetPopupWindowType() const
2644 : {
2645 0 : return SFX_POPUPWINDOW_ONCLICK;
2646 : }
2647 :
2648 : // -----------------------------------------------------------------------
2649 :
2650 0 : SfxPopupWindow* SvxFrameToolBoxControl::CreatePopupWindow()
2651 : {
2652 : SvxFrameWindow_Impl* pFrameWin = new SvxFrameWindow_Impl(
2653 0 : GetSlotId(), m_xFrame, &GetToolBox() );
2654 :
2655 0 : pFrameWin->StartPopupMode( &GetToolBox(),
2656 : FLOATWIN_POPUPMODE_GRABFOCUS |
2657 : FLOATWIN_POPUPMODE_ALLOWTEAROFF |
2658 0 : FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
2659 0 : pFrameWin->StartSelection();
2660 0 : SetPopupWindow( pFrameWin );
2661 :
2662 0 : return pFrameWin;
2663 : }
2664 :
2665 : // -----------------------------------------------------------------------
2666 :
2667 186 : void SvxFrameToolBoxControl::StateChanged(
2668 :
2669 : sal_uInt16, SfxItemState eState, const SfxPoolItem* )
2670 :
2671 : {
2672 186 : sal_uInt16 nId = GetId();
2673 186 : ToolBox& rTbx = GetToolBox();
2674 :
2675 186 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2676 : rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
2677 : ? STATE_DONTKNOW
2678 186 : : STATE_NOCHECK );
2679 186 : }
2680 :
2681 : //========================================================================
2682 : // class SvxFrameLineStyleToolBoxControl ---------------------------------
2683 : //========================================================================
2684 :
2685 157 : SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
2686 : sal_uInt16 nSlotId,
2687 : sal_uInt16 nId,
2688 : ToolBox& rTbx )
2689 :
2690 157 : : SfxToolBoxControl( nSlotId, nId, rTbx )
2691 : {
2692 157 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2693 157 : }
2694 :
2695 : // -----------------------------------------------------------------------
2696 :
2697 0 : SfxPopupWindowType SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const
2698 : {
2699 0 : return SFX_POPUPWINDOW_ONCLICK;
2700 : }
2701 :
2702 : // -----------------------------------------------------------------------
2703 :
2704 0 : SfxPopupWindow* SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
2705 : {
2706 0 : SvxLineWindow_Impl* pLineWin = new SvxLineWindow_Impl( GetSlotId(), m_xFrame, &GetToolBox() );
2707 0 : pLineWin->StartPopupMode( &GetToolBox(),
2708 : FLOATWIN_POPUPMODE_GRABFOCUS |
2709 : FLOATWIN_POPUPMODE_ALLOWTEAROFF |
2710 0 : FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
2711 0 : SetPopupWindow( pLineWin );
2712 :
2713 0 : return pLineWin;
2714 : }
2715 :
2716 : // -----------------------------------------------------------------------
2717 :
2718 186 : void SvxFrameLineStyleToolBoxControl::StateChanged(
2719 :
2720 : sal_uInt16 , SfxItemState eState, const SfxPoolItem* )
2721 : {
2722 186 : sal_uInt16 nId = GetId();
2723 186 : ToolBox& rTbx = GetToolBox();
2724 :
2725 186 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2726 : rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
2727 : ? STATE_DONTKNOW
2728 186 : : STATE_NOCHECK );
2729 186 : }
2730 :
2731 : //========================================================================
2732 : // class SvxFrameLineColorToolBoxControl ---------------------------------
2733 : //========================================================================
2734 :
2735 0 : SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
2736 : sal_uInt16 nSlotId,
2737 : sal_uInt16 nId,
2738 : ToolBox& rTbx ) :
2739 :
2740 : SfxToolBoxControl( nSlotId, nId, rTbx ),
2741 0 : pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() )),
2742 0 : mLastColor( COL_AUTO )
2743 : {
2744 0 : rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
2745 0 : }
2746 :
2747 : // -----------------------------------------------------------------------
2748 :
2749 0 : SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl()
2750 : {
2751 :
2752 0 : delete pBtnUpdater;
2753 0 : }
2754 :
2755 : // -----------------------------------------------------------------------
2756 :
2757 0 : SfxPopupWindowType SvxFrameLineColorToolBoxControl::GetPopupWindowType() const
2758 : {
2759 0 : return SFX_POPUPWINDOW_ONCLICK;
2760 : }
2761 :
2762 : // -----------------------------------------------------------------------
2763 :
2764 0 : SfxPopupWindow* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
2765 : {
2766 : SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
2767 : OUString( ".uno:FrameLineColor" ),
2768 : SID_FRAME_LINECOLOR,
2769 : m_xFrame,
2770 0 : SVX_RESSTR(RID_SVXSTR_FRAME_COLOR),
2771 0 : &GetToolBox(),
2772 0 : mLastColor);
2773 :
2774 0 : pColorWin->StartPopupMode( &GetToolBox(),
2775 0 : FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE );
2776 0 : pColorWin->StartSelection();
2777 0 : SetPopupWindow( pColorWin );
2778 0 : return pColorWin;
2779 : }
2780 :
2781 : // -----------------------------------------------------------------------
2782 :
2783 0 : void SvxFrameLineColorToolBoxControl::StateChanged(
2784 : sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState )
2785 : {
2786 0 : sal_uInt16 nId = GetId();
2787 0 : ToolBox& rTbx = GetToolBox();
2788 0 : rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
2789 0 : rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
2790 :
2791 0 : const SvxColorItem* pItem = 0;
2792 0 : if ( SFX_ITEM_DONTCARE != eState )
2793 : {
2794 0 : pItem = PTR_CAST( SvxColorItem, pState );
2795 0 : if ( pItem )
2796 : {
2797 0 : pBtnUpdater->Update( pItem->GetValue());
2798 0 : mLastColor = pItem->GetValue();
2799 : }
2800 : }
2801 0 : }
2802 :
2803 : //========================================================================
2804 : // class SvxSimpleUndoRedoController -------------------------------------
2805 : //========================================================================
2806 :
2807 0 : SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
2808 0 : :SfxToolBoxControl( nSlotId, nId, rTbx )
2809 : {
2810 0 : aDefaultText = rTbx.GetItemText( nId );
2811 0 : }
2812 :
2813 : // -----------------------------------------------------------------------
2814 :
2815 0 : SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController()
2816 : {
2817 0 : }
2818 :
2819 : // -----------------------------------------------------------------------
2820 :
2821 0 : void SvxSimpleUndoRedoController::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
2822 : {
2823 0 : SfxStringItem* pItem = PTR_CAST( SfxStringItem, pState );
2824 0 : ToolBox& rBox = GetToolBox();
2825 0 : if ( pItem && eState != SFX_ITEM_DISABLED )
2826 : {
2827 0 : OUString aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem->GetValue() ) );
2828 0 : rBox.SetQuickHelpText( GetId(), aNewText );
2829 : }
2830 0 : if ( eState == SFX_ITEM_DISABLED )
2831 0 : rBox.SetQuickHelpText( GetId(), aDefaultText );
2832 0 : rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
2833 0 : }
2834 :
2835 : //========================================================================
2836 :
2837 0 : static void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet )
2838 : {
2839 0 : Size aSize = rWin.GetOutputSizePixel();
2840 0 : aSize.Width() -= 4;
2841 0 : aSize.Height() -= 4;
2842 0 : rValueSet.SetPosSizePixel( Point(2,2), aSize );
2843 0 : }
2844 :
2845 : // -----------------------------------------------------------------------
2846 :
2847 0 : static void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize )
2848 : {
2849 0 : Size aSize = rValueSet.CalcWindowSizePixel( aItemSize );
2850 0 : aSize.Width() += 4;
2851 0 : aSize.Height() += 4;
2852 0 : rWin.SetOutputSizePixel( aSize );
2853 0 : }
2854 :
2855 : // -----------------------------------------------------------------------------
2856 1 : Reference< ::com::sun::star::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
2857 : {
2858 1 : FillList();
2859 1 : return FontNameBox::CreateAccessible();
2860 258 : }
2861 :
2862 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|