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