1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: workctrl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
37 #include <svtools/eitem.hxx>
38 #include <svx/htmlmode.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/bindings.hxx>
41 #ifndef _SFX_IMAGEMGR_HXX
42 #include <sfx2/imagemgr.hxx>
44 #include <swmodule.hxx>
49 #include <viewopt.hxx>
53 #include <gloshdl.hxx>
54 #include <glosdoc.hxx>
55 #include <gloslst.hxx>
57 #include <workctrl.hxx>
59 #include <workctrl.hrc>
68 #include <svtools/imageitm.hxx>
69 #include <vcl/lstbox.hxx>
70 #include <rtl/ustring.hxx>
71 #include "swabstdlg.hxx"
74 #include <vcl/svapp.hxx>
76 //JP 14.01.99: Size Abpruefung
77 #define NAVI_ENTRIES 20
78 #if NAVI_ENTRIES != NID_COUNT
79 #error SwScrollNaviPopup-CTOR static Array falsche Size. Wurden neue IDs zugefuegt ??
82 using ::rtl::OUString
;
83 using namespace ::com::sun::star
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::beans
;
86 using namespace ::com::sun::star::frame
;
88 SFX_IMPL_TOOLBOX_CONTROL( SwTbxInsertCtrl
, SfxImageItem
);
89 SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl
, SfxBoolItem
);
91 /**********************************************************************
93 **********************************************************************/
94 SwTbxInsertCtrl::SwTbxInsertCtrl(
98 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
99 nLastSlotId(FN_INSERT_CTRL
== nSlotId
? FN_INSERT_TABLE
: SID_INSERT_DIAGRAM
)
101 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
103 /**********************************************************************
105 **********************************************************************/
106 SwTbxInsertCtrl::~SwTbxInsertCtrl()
110 void SAL_CALL
SwTbxInsertCtrl::update() throw (uno::RuntimeException
)
112 ToolBox
& rTbx
= GetToolBox();
113 rtl::OUString
aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
114 aSlotURL
+= rtl::OUString::valueOf( sal_Int32( nLastSlotId
));
115 Image aImage
= GetImage( m_xFrame
,
118 rTbx
.GetDisplayBackground().GetColor().IsDark() );
120 rTbx
.SetItemImage(GetId(), aImage
);
123 SfxToolBoxControl::update();
126 /**********************************************************************
128 **********************************************************************/
131 void SwTbxInsertCtrl::StateChanged( USHORT
/*nSID*/,
133 const SfxPoolItem
* pState
)
135 USHORT nId
= GetId();
136 GetToolBox().EnableItem( nId
, (GetItemState(pState
) != SFX_ITEM_DISABLED
) );
138 if( eState
== SFX_ITEM_AVAILABLE
)
140 const SfxImageItem
* pItem
= PTR_CAST( SfxImageItem
, pState
);
143 nLastSlotId
= pItem
->GetValue();
147 rtl::OUString
aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
148 aSlotURL
+= rtl::OUString::valueOf( sal_Int32( nId
));
149 Image aImage
= GetImage( m_xFrame
,
152 GetToolBox().GetDisplayBackground().GetColor().IsDark() );
153 ToolBox
& rBox
= GetToolBox();
154 rBox
.SetItemImage(GetId(), aImage
);
155 rBox
.SetItemImageMirrorMode( GetId(), FALSE
);
156 rBox
.SetItemImageAngle( GetId(), pItem
->GetRotation() );
157 rBox
.SetItemImageMirrorMode( GetId(), pItem
->IsMirrored() );
162 /**********************************************************************
164 **********************************************************************/
167 SfxPopupWindow
* SwTbxInsertCtrl::CreatePopupWindow()
169 if(GetSlotId() == FN_INSERT_CTRL
)
171 OUString
aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertbar" ));
172 createAndPositionSubToolBar( aToolBarResStr
);
174 else /* FN_INSERT_OBJ_CTRL */
176 OUString
aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertobjectbar" ));
177 createAndPositionSubToolBar( aToolBarResStr
);
182 /**********************************************************************
184 **********************************************************************/
187 SfxPopupWindowType
SwTbxInsertCtrl::GetPopupWindowType() const
189 return nLastSlotId
? SFX_POPUPWINDOW_ONTIMEOUT
: SFX_POPUPWINDOW_ONCLICK
;
193 /**********************************************************************
195 **********************************************************************/
198 void SwTbxInsertCtrl::Select( BOOL
/*bMod1*/ )
202 SfxViewShell
* pCurSh( SfxViewShell::Current() );
203 SfxDispatcher
* pDispatch( 0 );
207 SfxViewFrame
* pViewFrame
= pCurSh
->GetViewFrame();
209 pDispatch
= pViewFrame
->GetDispatcher();
213 pDispatch
->Execute(nLastSlotId
);
217 /**********************************************************************
219 **********************************************************************/
222 SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
226 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
230 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
232 /**********************************************************************
234 **********************************************************************/
237 SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl()
242 /**********************************************************************
244 **********************************************************************/
247 SfxPopupWindow
* SwTbxAutoTextCtrl::CreatePopupWindow()
249 pView
= ::GetActiveView();
250 if(pView
&& !pView
->GetDocShell()->IsReadOnly() &&
251 !pView
->GetWrtShell().HasReadonlySel() )
253 ToolBox
& rBox
= GetToolBox();
255 Rectangle
aItemRect( rBox
.GetItemRect( GetId() ) );
256 Point
aPt(rBox
.OutputToScreenPixel(aItemRect
.TopLeft()));
257 aPt
.X() += aItemRect
.GetWidth()/2;
258 aPt
.Y() += aItemRect
.GetHeight()/2;
261 Link aLnk
= LINK(this, SwTbxAutoTextCtrl
, PopupHdl
);
263 if (GetSlotId() == FN_INSERT_FIELD_CTRL
)
265 pPopup
= new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL
));
266 pPopup
->SetSelectHdl(aLnk
);
268 if (::GetHtmlMode(pView
->GetDocShell()) & HTMLMODE_ON
)
270 pPopup
->RemoveItem(pPopup
->GetItemPos(FN_INSERT_FLD_PGCOUNT
));
271 pPopup
->RemoveItem(pPopup
->GetItemPos(FN_INSERT_FLD_TOPIC
));
276 pPopup
= new PopupMenu
;
277 SwGlossaryList
* pGlossaryList
= ::GetGlossaryList();
278 USHORT nGroupCount
= pGlossaryList
->GetGroupCount();
279 for(USHORT i
= 1; i
<= nGroupCount
; i
++)
281 // Gruppenname mit Pfad-Extension besorgen
283 String sGroupName
= pGlossaryList
->GetGroupName(i
- 1, FALSE
, &sTitle
);
284 USHORT nBlockCount
= pGlossaryList
->GetBlockCount(i
-1);
287 USHORT nIndex
= 100 * (i
);
288 // aber ohne extension einfuegen
289 pPopup
->InsertItem( i
, sTitle
);//sGroupName.GetToken(0, GLOS_DELIM));
290 PopupMenu
* pSub
= new PopupMenu
;
291 pSub
->SetSelectHdl(aLnk
);
292 pPopup
->SetPopupMenu(i
, pSub
);
293 for(USHORT j
= 0; j
< nBlockCount
; j
++)
296 String
sLongName(pGlossaryList
->GetBlockName(i
- 1, j
, sEntry
));
297 sEntry
.AppendAscii(" - ");
299 pSub
->InsertItem(++nIndex
, sEntry
);
305 ToolBox
* pToolBox
= &GetToolBox();
306 USHORT nId
= GetId();
307 pToolBox
->SetItemDown( nId
, TRUE
);
309 pPopup
->Execute( pToolBox
, pToolBox
->GetItemRect( nId
),
310 (pToolBox
->GetAlign() == WINDOWALIGN_TOP
|| pToolBox
->GetAlign() == WINDOWALIGN_BOTTOM
) ?
311 POPUPMENU_EXECUTE_DOWN
: POPUPMENU_EXECUTE_RIGHT
);
313 pToolBox
->SetItemDown( nId
, FALSE
);
315 GetToolBox().EndSelection();
322 /**********************************************************************
324 **********************************************************************/
327 SfxPopupWindowType
SwTbxAutoTextCtrl::GetPopupWindowType() const
329 return SFX_POPUPWINDOW_ONTIMEOUT
;
332 /**********************************************************************
334 **********************************************************************/
337 void SwTbxAutoTextCtrl::StateChanged( USHORT nSID
,
339 const SfxPoolItem
* pState
)
341 GetToolBox().EnableItem( GetId(), (GetItemState(pState
) != SFX_ITEM_DISABLED
) );
342 if(FN_INSERT_FIELD_CTRL
== nSID
&& eState
>= SFX_ITEM_DEFAULT
)
344 GetToolBox().CheckItem( GetId(), ((SfxBoolItem
*)pState
)->GetValue() );
348 /**********************************************************************
350 **********************************************************************/
353 IMPL_LINK(SwTbxAutoTextCtrl
, PopupHdl
, PopupMenu
*, pMenu
)
355 USHORT nId
= pMenu
->GetCurItemId();
357 if ( GetSlotId() == FN_INSERT_FIELD_CTRL
)
359 Sequence
< PropertyValue
> aArgs
;
360 const char* pChar
= 0;
363 case FN_INSERT_FLD_DATE
:
364 pChar
= ".uno:InsertDateField";
366 case FN_INSERT_FLD_TIME
:
367 pChar
= ".uno:InsertTimeField";
369 case FN_INSERT_FLD_PGNUMBER
:
370 pChar
= ".uno:InsertPageNumberField";
372 case FN_INSERT_FLD_PGCOUNT
:
373 pChar
= ".uno:InsertPageCountField";
375 case FN_INSERT_FLD_TOPIC
:
376 pChar
= ".uno:InsertTopicField";
378 case FN_INSERT_FLD_TITLE
:
379 pChar
= ".uno:InsertTitleField";
381 case FN_INSERT_FLD_AUTHOR
:
382 pChar
= ".uno:InsertAuthorField";
385 pChar
= ".uno:InsertFieldCtrl";
387 Dispatch( rtl::OUString::createFromAscii( pChar
),aArgs
);
391 USHORT nBlock
= nId
/ 100;
393 SwGlossaryList
* pGlossaryList
= ::GetGlossaryList();
395 String sGroup
= pGlossaryList
->GetGroupName(nBlock
- 1, FALSE
);
396 String
sLongName(pGlossaryList
->GetBlockName(nBlock
- 1, nId
- (100 * nBlock
) - 1, sShortName
));
398 SwGlossaryHdl
* pGlosHdl
= pView
->GetGlosHdl();
399 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
400 DBG_ASSERT(pFact
, "Dialogdiet fail!");
401 ::GlossarySetActGroup fnSetActGroup
= pFact
->SetGlossaryActGroupFunc( DLG_RENAME_GLOS
);
403 (*fnSetActGroup
)( sGroup
);
404 pGlosHdl
->SetCurGroup(sGroup
, TRUE
);
405 pGlosHdl
->InsertGlossary(sShortName
);
410 /**********************************************************************
412 **********************************************************************/
415 void SwTbxAutoTextCtrl::DelPopup()
419 if (GetSlotId() != FN_INSERT_FIELD_CTRL
)
421 for( USHORT i
= 0; i
< pPopup
->GetItemCount(); i
++ )
423 PopupMenu
* pSubPopup
= pPopup
->GetPopupMenu(pPopup
->GetItemId(i
));
432 /*-----------------19.02.97 10.52-------------------
434 --------------------------------------------------*/
435 // determine the order of the toolbox items
436 static USHORT __READONLY_DATA aNavigationInsertIds
[ NAVI_ENTRIES
] =
458 NID_TABLE_FORMULA_ERROR
,
461 static USHORT __READONLY_DATA aNavigationHelpIds
[ NAVI_ENTRIES
] =
482 HID_NID_TABLE_FORMULA
,
483 HID_NID_TABLE_FORMULA_ERROR
,
487 SwScrollNaviPopup::SwScrollNaviPopup( USHORT nId
, const Reference
< XFrame
>& rFrame
)
488 : SfxPopupWindow(nId
, rFrame
, SW_RES(RID_SCROLL_NAVIGATION_WIN
) ),
490 aSeparator(this, SW_RES(FL_SEP
)),
491 aInfoField(this, SW_RES(FI_INFO
)),
492 aIList(SW_RES(IL_VALUES
)),
493 aIListH(SW_RES(ILH_VALUES
)),
494 nFwdId(FN_START_OF_NEXT_PAGE
),
495 nBackId(FN_START_OF_PREV_PAGE
)
499 aToolBox
.SetHelpId(HID_NAVI_VS
);
500 aToolBox
.SetLineCount( 2 );
501 aToolBox
.SetOutStyle(TOOLBOX_STYLE_FLAT
);
502 for( i
= 0; i
< NID_COUNT
; i
++)
504 USHORT nNaviId
= aNavigationInsertIds
[i
];
506 ToolBoxItemBits nTbxBits
= 0;
507 if((NID_PREV
!= nNaviId
) && (NID_NEXT
!= nNaviId
))
509 // -2, there's no string for Next/Prev
510 USHORT nResStr
= ST_TBL
- 2 + nNaviId
- NID_START
;
511 sText
= String(SW_RES(nResStr
));
512 nTbxBits
= TIB_CHECKABLE
;
514 aToolBox
.InsertItem(nNaviId
, sText
, nTbxBits
);
515 aToolBox
.SetHelpId( nNaviId
, aNavigationHelpIds
[i
] );
518 aToolBox
.InsertBreak(NID_COUNT
/2);
519 // don't call it before!
522 // these are global strings
523 for( i
= 0; i
< 2 * NID_COUNT
; i
++)
525 sQuickHelp
[i
] = String(SW_RES(STR_IMGBTN_START
+ i
));
528 Size aImgSize
= aIList
.GetImageSize();
529 aImgSize
.Width() += 5;
530 aImgSize
.Height() += 5;
531 Size aSz
= aToolBox
.CalcWindowSizePixel(2);
532 aToolBox
.SetPosSizePixel( Point(), aSz
);
533 USHORT nItemId
= SwView::GetMoveType();
534 aInfoField
.SetText(aToolBox
.GetItemText(nItemId
));
535 aToolBox
.CheckItem( nItemId
, sal_True
);
536 Size
aFTSize(aInfoField
.GetSizePixel());
537 Size
aSepSize(aSeparator
.GetSizePixel());
538 aSepSize
.Width() = aSz
.Width();
540 aSz
.Height() += aFTSize
.Height() + aSepSize
.Height();
541 aInfoField
.SetPosSizePixel(
542 Point(0, aSz
.Height() - aFTSize
.Height()), Size(aSz
.Width(), aFTSize
.Height()));
544 aSeparator
.SetSizePixel(aSepSize
);
545 aSeparator
.SetPosPixel(Point(0, aSz
.Height() - aFTSize
.Height() - aSepSize
.Height()));
547 SetOutputSizePixel(aSz
);
548 aToolBox
.SetSelectHdl(LINK(this, SwScrollNaviPopup
, SelectHdl
));
549 aToolBox
.StartSelection();
552 /*-----------------19.02.97 12.45-------------------
554 --------------------------------------------------*/
556 SwScrollNaviPopup::~SwScrollNaviPopup()
559 /* -----------------------------08.05.2002 14:00------------------------------
561 ---------------------------------------------------------------------------*/
562 void SwScrollNaviPopup::DataChanged( const DataChangedEvent
& rDCEvt
)
564 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
565 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
568 Window::DataChanged( rDCEvt
);
570 /* -----------------------------08.05.2002 14:02------------------------------
572 ---------------------------------------------------------------------------*/
573 void SwScrollNaviPopup::ApplyImageList()
575 ImageList
& rImgLst
= aToolBox
.GetDisplayBackground().GetColor().IsDark() ?
577 for(USHORT i
= 0; i
< NID_COUNT
; i
++)
579 USHORT nNaviId
= aNavigationInsertIds
[i
];
580 aToolBox
.SetItemImage(nNaviId
, rImgLst
.GetImage(nNaviId
));
583 /*-----------------19.02.97 13.58-------------------
585 --------------------------------------------------*/
587 SfxPopupWindow
* SwScrollNaviPopup::Clone() const
589 return new SwScrollNaviPopup( GetId(), GetFrame() );
592 /*-----------------19.02.97 14.10-------------------
594 --------------------------------------------------*/
596 IMPL_LINK(SwScrollNaviPopup
, SelectHdl
, ToolBox
*, pSet
)
598 USHORT nSet
= pSet
->GetCurItemId();
599 if( nSet
!= NID_PREV
&& nSet
!= NID_NEXT
)
601 SwView::SetMoveType(nSet
);
602 aToolBox
.SetItemText(NID_NEXT
, sQuickHelp
[nSet
- NID_START
]);
603 aToolBox
.SetItemText(NID_PREV
, sQuickHelp
[nSet
- NID_START
+ NID_COUNT
]);
604 aInfoField
.SetText(aToolBox
.GetItemText(nSet
));
605 //check the current button only
606 for(USHORT i
= 0; i
< NID_COUNT
; i
++)
608 USHORT nItemId
= aToolBox
.GetItemId( i
);
609 aToolBox
.CheckItem( nItemId
, nItemId
== nSet
);
614 SfxBoolItem
aNext(FN_SCROLL_NEXT_PREV
, NID_NEXT
== nSet
);
616 Sequence
< PropertyValue
> aArgs( 1 );
617 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollNextPrev" ));
618 aNext
.QueryValue( a
);
620 SfxToolBoxControl::Dispatch( Reference
< XDispatchProvider
>( GetFrame()->getController(), UNO_QUERY
),
621 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ScrollNextPrev" )),
626 /*-----------------23.02.97 18.21-------------------
628 --------------------------------------------------*/
630 void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent
& rMEvt
)
632 ToolBox::MouseButtonUp(rMEvt
);
633 if ( ((SwScrollNaviPopup
*)GetParent())->IsInPopupMode() )
634 ((SwScrollNaviPopup
*)GetParent())->EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL
);
637 /*-----------------20.06.97 13:28-------------------
639 --------------------------------------------------*/
640 void SwScrollNaviToolBox::RequestHelp( const HelpEvent
& rHEvt
)
642 SetItemText(NID_NEXT
, SwScrollNaviPopup::GetQuickHelpText(TRUE
));
643 SetItemText(NID_PREV
, SwScrollNaviPopup::GetQuickHelpText(FALSE
));
644 ToolBox::RequestHelp( rHEvt
);
648 /*-----------------20.06.97 13:41-------------------
650 --------------------------------------------------*/
651 String
SwScrollNaviPopup::GetQuickHelpText(BOOL bNext
)
653 USHORT nResId
= STR_IMGBTN_START
;
654 nResId
+= SwView::GetMoveType() - NID_START
;
657 return String(SW_RES(nResId
));
659 /* -----------------------------05.09.2002 13:53------------------------------
661 ---------------------------------------------------------------------------*/
662 void SwNaviImageButton::Click()
664 // SfxBindings& rBind = SfxViewFrame::Current()->GetBindings();
665 // rBind.ENTERREGISTRATIONS();
667 SwScrollNaviPopup( FN_SCROLL_NAVIGATION
,
669 // rBind.LEAVEREGISTRATIONS();
670 Point aPos
= OutputToScreenPixel(Point(0,0));
671 Rectangle
aRect(aPos
, GetSizePixel());
672 SetPopupWindow( pPopup
);
673 pPopup
->StartPopupMode(aRect
, FLOATWIN_POPUPMODE_LEFT
|FLOATWIN_POPUPMODE_ALLOWTEAROFF
);
676 //--------------------------------------------------------------------
678 void SwNaviImageButton::SetPopupWindow( SfxPopupWindow
* pWindow
)
680 pPopupWindow
= pWindow
;
681 pPopupWindow
->SetPopupModeEndHdl( LINK( this, SwNaviImageButton
, PopupModeEndHdl
));
682 pPopupWindow
->SetDeleteLink_Impl( LINK( this, SwNaviImageButton
, ClosePopupWindow
));
685 //--------------------------------------------------------------------
687 IMPL_LINK( SwNaviImageButton
, PopupModeEndHdl
, void *, EMPTYARG
)
689 if ( pPopupWindow
->IsVisible() )
691 // Replace floating window with popup window and destroy
692 // floating window instance.
693 delete pFloatingWindow
;
694 pFloatingWindow
= pPopupWindow
;
699 // Popup window has been closed by the user. No replacement, instance
700 // will destroy itself.
707 //--------------------------------------------------------------------
708 IMPL_LINK( SwNaviImageButton
, ClosePopupWindow
, SfxPopupWindow
*, pWindow
)
710 if ( pWindow
== pFloatingWindow
)
718 /*-----------------21.02.97 09:41-------------------
720 --------------------------------------------------*/
722 void SwHlpImageButton::RequestHelp( const HelpEvent
& rHEvt
)
725 SetQuickHelpText(SwScrollNaviPopup::GetQuickHelpText(!bUp
));
727 ImageButton::RequestHelp(rHEvt
);
730 /*-----------------25.02.97 12:38-------------------
732 --------------------------------------------------*/
734 SwNaviImageButton::SwNaviImageButton(
736 const Reference
< XFrame
>& rFrame
) :
737 ImageButton(pParent
, SW_RES(BTN_NAVI
)),
739 aImage(SW_RES(IMG_BTN
)),
740 aImageH(SW_RES(IMG_BTN_H
)),
741 sQuickText(SW_RES(ST_QUICK
)),
747 SetStyle(GetStyle()|WB_NOPOINTERFOCUS
);
748 SetQuickHelpText(sQuickText
);
749 SetModeImage( GetDisplayBackground().GetColor().IsDark() ? aImageH
: aImage
);
751 /* -----------------------------2002/07/05 9:41-------------------------------
753 ---------------------------------------------------------------------------*/
754 void SwNaviImageButton::DataChanged( const DataChangedEvent
& rDCEvt
)
756 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
757 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
758 SetModeImage( GetDisplayBackground().GetColor().IsDark() ? aImageH
: aImage
);
760 Window::DataChanged( rDCEvt
);
762 /* -----------------26.11.2002 09:28-----------------
764 * --------------------------------------------------*/
765 class SwZoomBox_Impl
: public ComboBox
769 uno::Reference
< frame::XDispatchProvider
> m_xDispatchProvider
;
775 const Reference
< XDispatchProvider
>& rDispatchProvider
);
779 virtual void Select();
780 virtual long Notify( NotifyEvent
& rNEvt
);
785 /* -----------------26.11.2002 09:29-----------------
787 * --------------------------------------------------*/
788 SwZoomBox_Impl::SwZoomBox_Impl(
791 const Reference
< XDispatchProvider
>& rDispatchProvider
):
792 ComboBox( pParent
, SW_RES(RID_PVIEW_ZOOM_LB
)),
795 m_xDispatchProvider( rDispatchProvider
)
797 EnableAutocomplete( FALSE
);
798 USHORT aZoomValues
[] =
799 { 25, 50, 75, 100, 150, 200 };
800 for(USHORT i
= 0; i
< sizeof(aZoomValues
)/sizeof(USHORT
); i
++)
802 String sEntry
= String::CreateFromInt32(aZoomValues
[i
]);
807 /* -----------------26.11.2002 09:29-----------------
809 * --------------------------------------------------*/
810 SwZoomBox_Impl::~SwZoomBox_Impl()
812 /* -----------------26.11.2002 09:34-----------------
814 * --------------------------------------------------*/
815 void SwZoomBox_Impl::Select()
817 if ( !IsTravelSelect() )
819 String
sEntry(GetText());
820 sEntry
.EraseAllChars( '%' );
821 USHORT nZoom
= (USHORT
)sEntry
.ToInt32();
827 SfxUInt16Item
aItem( nSlotId
, nZoom
);
828 if ( FN_PREVIEW_ZOOM
== nSlotId
)
831 Sequence
< PropertyValue
> aArgs( 1 );
832 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreviewZoom" ));
833 aItem
.QueryValue( a
);
835 SfxToolBoxControl::Dispatch(
837 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PreviewZoom" )),
844 /* -----------------02.12.2002 07:49-----------------
846 * --------------------------------------------------*/
847 long SwZoomBox_Impl::Notify( NotifyEvent
& rNEvt
)
851 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
853 USHORT nCode
= rNEvt
.GetKeyEvent()->GetKeyCode().GetCode();
860 if ( KEY_TAB
== nCode
)
869 SetText( GetSavedValue() );
874 else if ( EVENT_LOSEFOCUS
== rNEvt
.GetType() )
876 Window
* pFocusWin
= Application::GetFocusWindow();
877 if ( !HasFocus() && GetSubEdit() != pFocusWin
)
878 SetText( GetSavedValue() );
881 return nHandled
? nHandled
: ComboBox::Notify( rNEvt
);
883 /* -----------------02.12.2002 07:51-----------------
885 * --------------------------------------------------*/
886 void SwZoomBox_Impl::ReleaseFocus()
893 SfxViewShell
* pCurSh
= SfxViewShell::Current();
897 Window
* pShellWnd
= pCurSh
->GetWindow();
900 pShellWnd
->GrabFocus();
904 /* -----------------26.11.2002 09:29-----------------
906 * --------------------------------------------------*/
907 SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl
, SfxUInt16Item
);
909 SwPreviewZoomControl::SwPreviewZoomControl(
913 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
916 /* -----------------26.11.2002 09:29-----------------
918 * --------------------------------------------------*/
919 SwPreviewZoomControl::~SwPreviewZoomControl()
922 /* -----------------26.11.2002 09:29-----------------
924 * --------------------------------------------------*/
925 void SwPreviewZoomControl::StateChanged( USHORT
/*nSID*/,
927 const SfxPoolItem
* pState
)
929 USHORT nId
= GetId();
930 GetToolBox().EnableItem( nId
, (GetItemState(pState
) != SFX_ITEM_DISABLED
) );
931 SwZoomBox_Impl
* pBox
= (SwZoomBox_Impl
*)GetToolBox().GetItemWindow( GetId() );
932 if(SFX_ITEM_AVAILABLE
<= eState
)
934 String
sZoom(String::CreateFromInt32(((const SfxUInt16Item
*)pState
)->GetValue()));
936 pBox
->SetText(sZoom
);
940 /* -----------------26.11.2002 09:29-----------------
942 * --------------------------------------------------*/
943 Window
* SwPreviewZoomControl::CreateItemWindow( Window
*pParent
)
945 SwZoomBox_Impl
* pRet
= new SwZoomBox_Impl( pParent
, GetSlotId(), Reference
< XDispatchProvider
>( m_xFrame
->getController(), UNO_QUERY
));