xref: /aoo42x/main/sw/source/ui/ribbar/workctrl.cxx (revision 6db34107)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
30cdf0e10cSrcweir #include <svl/eitem.hxx>
31cdf0e10cSrcweir #include <svx/htmlmode.hxx>
32cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33cdf0e10cSrcweir #include <sfx2/bindings.hxx>
34cdf0e10cSrcweir #ifndef _SFX_IMAGEMGR_HXX
35cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <swmodule.hxx>
38cdf0e10cSrcweir #ifndef _VIEW_HXX
39cdf0e10cSrcweir #include <view.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <initui.hxx>
42cdf0e10cSrcweir #include <viewopt.hxx>
43cdf0e10cSrcweir #ifndef _DOCSH_HXX
44cdf0e10cSrcweir #include <docsh.hxx>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #include <gloshdl.hxx>
47cdf0e10cSrcweir #include <glosdoc.hxx>
48cdf0e10cSrcweir #include <gloslst.hxx>
49cdf0e10cSrcweir #include <workctrl.hxx>
50cdf0e10cSrcweir #ifndef _WORKCTRL_HRC
51cdf0e10cSrcweir #include <workctrl.hrc>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _CMDID_H
54cdf0e10cSrcweir #include <cmdid.h>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _HELPID_H
57cdf0e10cSrcweir #include <helpid.h>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #include <wrtsh.hxx>
60cdf0e10cSrcweir #include <svl/imageitm.hxx>
61cdf0e10cSrcweir #include <vcl/lstbox.hxx>
62cdf0e10cSrcweir #include <rtl/ustring.hxx>
63cdf0e10cSrcweir #include "swabstdlg.hxx"
64cdf0e10cSrcweir #include <misc.hrc>
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #include <vcl/svapp.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir //JP 14.01.99: Size Abpruefung
69cdf0e10cSrcweir #define NAVI_ENTRIES 20
70cdf0e10cSrcweir #if NAVI_ENTRIES != NID_COUNT
71cdf0e10cSrcweir #error SwScrollNaviPopup-CTOR static Array falsche Size. Wurden neue IDs zugefuegt ??
72cdf0e10cSrcweir #endif
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using ::rtl::OUString;
75cdf0e10cSrcweir using namespace ::com::sun::star;
76cdf0e10cSrcweir using namespace ::com::sun::star::uno;
77cdf0e10cSrcweir using namespace ::com::sun::star::beans;
78cdf0e10cSrcweir using namespace ::com::sun::star::frame;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SwTbxInsertCtrl, SfxImageItem);
81cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl, SfxBoolItem );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir /**********************************************************************
84cdf0e10cSrcweir 
85cdf0e10cSrcweir **********************************************************************/
SwTbxInsertCtrl(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)86cdf0e10cSrcweir SwTbxInsertCtrl::SwTbxInsertCtrl(
87cdf0e10cSrcweir     sal_uInt16 nSlotId,
88cdf0e10cSrcweir     sal_uInt16 nId,
89cdf0e10cSrcweir 	ToolBox& rTbx ) :
90cdf0e10cSrcweir         SfxToolBoxControl( nSlotId, nId, rTbx ),
91cdf0e10cSrcweir 		nLastSlotId(FN_INSERT_CTRL == nSlotId ? FN_INSERT_TABLE : SID_INSERT_DIAGRAM)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir /**********************************************************************
96cdf0e10cSrcweir 
97cdf0e10cSrcweir **********************************************************************/
~SwTbxInsertCtrl()98cdf0e10cSrcweir SwTbxInsertCtrl::~SwTbxInsertCtrl()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
update()102cdf0e10cSrcweir void SAL_CALL SwTbxInsertCtrl::update() throw (uno::RuntimeException)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     ToolBox& rTbx = GetToolBox();
105cdf0e10cSrcweir     rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
106cdf0e10cSrcweir     aSlotURL += rtl::OUString::valueOf( sal_Int32( nLastSlotId ));
107cdf0e10cSrcweir     Image aImage = GetImage( m_xFrame,
108cdf0e10cSrcweir                              aSlotURL,
109cdf0e10cSrcweir                              hasBigImages(),
110cdf0e10cSrcweir                              rTbx.GetSettings().GetStyleSettings().GetHighContrastMode() );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	rTbx.SetItemImage(GetId(), aImage);
113cdf0e10cSrcweir     rTbx.Invalidate();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     SfxToolBoxControl::update();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir /**********************************************************************
119cdf0e10cSrcweir 
120cdf0e10cSrcweir **********************************************************************/
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
StateChanged(sal_uInt16,SfxItemState eState,const SfxPoolItem * pState)123cdf0e10cSrcweir void SwTbxInsertCtrl::StateChanged( sal_uInt16 /*nSID*/,
124cdf0e10cSrcweir 									  SfxItemState eState,
125cdf0e10cSrcweir 									  const SfxPoolItem* pState )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	sal_uInt16 nId = GetId();
128cdf0e10cSrcweir 	GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	if( eState == SFX_ITEM_AVAILABLE )
131cdf0e10cSrcweir 	{
132cdf0e10cSrcweir         const SfxImageItem* pItem = PTR_CAST( SfxImageItem, pState );
133cdf0e10cSrcweir         if(pItem)
134cdf0e10cSrcweir 		{
135cdf0e10cSrcweir 			nLastSlotId = pItem->GetValue();
136cdf0e10cSrcweir 			if( nLastSlotId )
137cdf0e10cSrcweir 				nId = nLastSlotId;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir             rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
140cdf0e10cSrcweir             aSlotURL += rtl::OUString::valueOf( sal_Int32( nId ));
141cdf0e10cSrcweir             ToolBox& rBox = GetToolBox();
142cdf0e10cSrcweir             Image aImage = GetImage( m_xFrame,
143cdf0e10cSrcweir                                      aSlotURL,
144cdf0e10cSrcweir                                      hasBigImages(),
145cdf0e10cSrcweir                                      rBox.GetSettings().GetStyleSettings().GetHighContrastMode() );
146cdf0e10cSrcweir             rBox.SetItemImage(GetId(), aImage);
147cdf0e10cSrcweir             rBox.SetItemImageMirrorMode( GetId(), sal_False );
148cdf0e10cSrcweir 			rBox.SetItemImageAngle( GetId(), pItem->GetRotation() );
149cdf0e10cSrcweir             rBox.SetItemImageMirrorMode( GetId(), pItem->IsMirrored() );
150cdf0e10cSrcweir         }
151cdf0e10cSrcweir 	}
152cdf0e10cSrcweir 
153cdf0e10cSrcweir }
154cdf0e10cSrcweir /**********************************************************************
155cdf0e10cSrcweir 
156cdf0e10cSrcweir **********************************************************************/
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
CreatePopupWindow()159cdf0e10cSrcweir SfxPopupWindow* SwTbxInsertCtrl::CreatePopupWindow()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	if(GetSlotId() == FN_INSERT_CTRL)
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir         OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertbar" ));
164cdf0e10cSrcweir         createAndPositionSubToolBar( aToolBarResStr );
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir 	else /* FN_INSERT_OBJ_CTRL */
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir         OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertobjectbar" ));
169cdf0e10cSrcweir         createAndPositionSubToolBar( aToolBarResStr );
170cdf0e10cSrcweir 	}
171cdf0e10cSrcweir     return NULL;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir /**********************************************************************
175cdf0e10cSrcweir 
176cdf0e10cSrcweir **********************************************************************/
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
GetPopupWindowType() const179cdf0e10cSrcweir SfxPopupWindowType	SwTbxInsertCtrl::GetPopupWindowType() const
180cdf0e10cSrcweir {
181cdf0e10cSrcweir 	return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
185cdf0e10cSrcweir /**********************************************************************
186cdf0e10cSrcweir 
187cdf0e10cSrcweir **********************************************************************/
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
Select(sal_Bool)190cdf0e10cSrcweir void SwTbxInsertCtrl::Select( sal_Bool /*bMod1*/ )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	if( nLastSlotId )
193cdf0e10cSrcweir     {
194cdf0e10cSrcweir         SfxViewShell*   pCurSh( SfxViewShell::Current() );
195cdf0e10cSrcweir         SfxDispatcher*  pDispatch( 0 );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         if ( pCurSh )
198cdf0e10cSrcweir         {
199cdf0e10cSrcweir             SfxViewFrame*   pViewFrame = pCurSh->GetViewFrame();
200cdf0e10cSrcweir             if ( pViewFrame )
201cdf0e10cSrcweir                 pDispatch = pViewFrame->GetDispatcher();
202cdf0e10cSrcweir         }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir         if ( pDispatch )
205cdf0e10cSrcweir             pDispatch->Execute(nLastSlotId);
206cdf0e10cSrcweir     }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir /**********************************************************************
210cdf0e10cSrcweir 
211cdf0e10cSrcweir **********************************************************************/
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 
SwTbxAutoTextCtrl(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)214cdf0e10cSrcweir SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
215cdf0e10cSrcweir     sal_uInt16 nSlotId,
216cdf0e10cSrcweir     sal_uInt16 nId,
217cdf0e10cSrcweir 	ToolBox& rTbx ) :
218cdf0e10cSrcweir 	SfxToolBoxControl( nSlotId, nId, rTbx ),
219cdf0e10cSrcweir     pPopup(0),
220cdf0e10cSrcweir     pView(0)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir /**********************************************************************
225cdf0e10cSrcweir 
226cdf0e10cSrcweir **********************************************************************/
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 
~SwTbxAutoTextCtrl()229cdf0e10cSrcweir SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl()
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	DelPopup();
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir /**********************************************************************
235cdf0e10cSrcweir 
236cdf0e10cSrcweir **********************************************************************/
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
CreatePopupWindow()239cdf0e10cSrcweir SfxPopupWindow* SwTbxAutoTextCtrl::CreatePopupWindow()
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	pView = ::GetActiveView();
242cdf0e10cSrcweir 	if(pView && !pView->GetDocShell()->IsReadOnly() &&
243cdf0e10cSrcweir 	   !pView->GetWrtShell().HasReadonlySel() )
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		ToolBox& rBox = GetToolBox();
246cdf0e10cSrcweir 
247cdf0e10cSrcweir         Rectangle aItemRect( rBox.GetItemRect( GetId() ) );
248cdf0e10cSrcweir         Point aPt(rBox.OutputToScreenPixel(aItemRect.TopLeft()));
249cdf0e10cSrcweir         aPt.X() += aItemRect.GetWidth()/2;
250cdf0e10cSrcweir         aPt.Y() += aItemRect.GetHeight()/2;
251cdf0e10cSrcweir         if(pView)
252cdf0e10cSrcweir 		{
253cdf0e10cSrcweir 			Link aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl);
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 			if (GetSlotId() == FN_INSERT_FIELD_CTRL)
256cdf0e10cSrcweir 			{
257cdf0e10cSrcweir 				pPopup = new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL));
258cdf0e10cSrcweir 				pPopup->SetSelectHdl(aLnk);
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 				if (::GetHtmlMode(pView->GetDocShell()) & HTMLMODE_ON)
261cdf0e10cSrcweir 				{
262cdf0e10cSrcweir 					pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_PGCOUNT));
263cdf0e10cSrcweir 					pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_TOPIC));
264cdf0e10cSrcweir 				}
265cdf0e10cSrcweir 			}
266cdf0e10cSrcweir 			else
267cdf0e10cSrcweir 			{
268cdf0e10cSrcweir 				pPopup = new PopupMenu;
269cdf0e10cSrcweir 				SwGlossaryList* pGlossaryList = ::GetGlossaryList();
270cdf0e10cSrcweir 				sal_uInt16 nGroupCount = pGlossaryList->GetGroupCount();
271cdf0e10cSrcweir 				for(sal_uInt16 i = 1; i <= nGroupCount; i++)
272cdf0e10cSrcweir 				{
273cdf0e10cSrcweir 					// Gruppenname mit Pfad-Extension besorgen
274cdf0e10cSrcweir 					String sTitle;
275cdf0e10cSrcweir 					String sGroupName = pGlossaryList->GetGroupName(i - 1, sal_False, &sTitle);
276cdf0e10cSrcweir 					sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1);
277cdf0e10cSrcweir 					if(nBlockCount)
278cdf0e10cSrcweir 					{
279cdf0e10cSrcweir 						sal_uInt16 nIndex = 100 * (i);
280cdf0e10cSrcweir 						// aber ohne extension einfuegen
281cdf0e10cSrcweir 						pPopup->InsertItem( i, sTitle);//sGroupName.GetToken(0, GLOS_DELIM));
282cdf0e10cSrcweir 						PopupMenu* pSub = new PopupMenu;
283cdf0e10cSrcweir 						pSub->SetSelectHdl(aLnk);
284cdf0e10cSrcweir 						pPopup->SetPopupMenu(i, pSub);
285cdf0e10cSrcweir 						for(sal_uInt16 j = 0; j < nBlockCount; j++)
286cdf0e10cSrcweir 						{
287cdf0e10cSrcweir 							String sEntry;
288cdf0e10cSrcweir 							String sLongName(pGlossaryList->GetBlockName(i - 1, j, sEntry));
289cdf0e10cSrcweir 							sEntry.AppendAscii(" - ");
290cdf0e10cSrcweir 							sEntry += sLongName;
291cdf0e10cSrcweir 							pSub->InsertItem(++nIndex, sEntry);
292cdf0e10cSrcweir 						}
293cdf0e10cSrcweir 					}
294cdf0e10cSrcweir 				}
295cdf0e10cSrcweir 			}
296cdf0e10cSrcweir 		}
297cdf0e10cSrcweir 		ToolBox* pToolBox = &GetToolBox();
298cdf0e10cSrcweir 		sal_uInt16 nId = GetId();
299cdf0e10cSrcweir 		pToolBox->SetItemDown( nId, sal_True );
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 		pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ),
302cdf0e10cSrcweir             (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ?
303cdf0e10cSrcweir                 POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 		pToolBox->SetItemDown( nId, sal_False );
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir 	GetToolBox().EndSelection();
308cdf0e10cSrcweir 	DelPopup();
309cdf0e10cSrcweir 	return 0;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 
314cdf0e10cSrcweir /**********************************************************************
315cdf0e10cSrcweir 
316cdf0e10cSrcweir **********************************************************************/
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 
GetPopupWindowType() const319cdf0e10cSrcweir SfxPopupWindowType SwTbxAutoTextCtrl::GetPopupWindowType() const
320cdf0e10cSrcweir {
321cdf0e10cSrcweir 	return SFX_POPUPWINDOW_ONTIMEOUT;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir /**********************************************************************
325cdf0e10cSrcweir 
326cdf0e10cSrcweir **********************************************************************/
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)329cdf0e10cSrcweir void SwTbxAutoTextCtrl::StateChanged( sal_uInt16 nSID,
330cdf0e10cSrcweir 											  SfxItemState eState,
331cdf0e10cSrcweir 											  const SfxPoolItem* pState )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
334cdf0e10cSrcweir 	if(FN_INSERT_FIELD_CTRL == nSID && eState >= SFX_ITEM_DEFAULT)
335cdf0e10cSrcweir 	{
336cdf0e10cSrcweir 		GetToolBox().CheckItem( GetId(), ((SfxBoolItem*)pState)->GetValue() );
337cdf0e10cSrcweir 	}
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir /**********************************************************************
341cdf0e10cSrcweir 
342cdf0e10cSrcweir **********************************************************************/
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 
IMPL_LINK(SwTbxAutoTextCtrl,PopupHdl,PopupMenu *,pMenu)345cdf0e10cSrcweir IMPL_LINK(SwTbxAutoTextCtrl, PopupHdl, PopupMenu*, pMenu)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir     sal_uInt16 nId = pMenu->GetCurItemId();
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	if ( GetSlotId() == FN_INSERT_FIELD_CTRL)
350cdf0e10cSrcweir 	{
351cdf0e10cSrcweir 		Sequence< PropertyValue > aArgs;
352cdf0e10cSrcweir         const char* pChar = 0;
353cdf0e10cSrcweir         switch(nId)
354cdf0e10cSrcweir         {
355cdf0e10cSrcweir             case FN_INSERT_FLD_DATE:
356cdf0e10cSrcweir                 pChar = ".uno:InsertDateField";
357cdf0e10cSrcweir             break;
358cdf0e10cSrcweir             case FN_INSERT_FLD_TIME:
359cdf0e10cSrcweir                 pChar = ".uno:InsertTimeField";
360cdf0e10cSrcweir             break;
361cdf0e10cSrcweir             case FN_INSERT_FLD_PGNUMBER:
362cdf0e10cSrcweir                 pChar = ".uno:InsertPageNumberField";
363cdf0e10cSrcweir             break;
364cdf0e10cSrcweir             case FN_INSERT_FLD_PGCOUNT:
365cdf0e10cSrcweir                 pChar = ".uno:InsertPageCountField";
366cdf0e10cSrcweir             break;
367cdf0e10cSrcweir             case FN_INSERT_FLD_TOPIC:
368cdf0e10cSrcweir                 pChar = ".uno:InsertTopicField";
369cdf0e10cSrcweir             break;
370cdf0e10cSrcweir             case FN_INSERT_FLD_TITLE:
371cdf0e10cSrcweir                 pChar = ".uno:InsertTitleField";
372cdf0e10cSrcweir             break;
373cdf0e10cSrcweir             case FN_INSERT_FLD_AUTHOR:
374cdf0e10cSrcweir                 pChar = ".uno:InsertAuthorField";
375cdf0e10cSrcweir             break;
376cdf0e10cSrcweir             default:
377cdf0e10cSrcweir                 pChar = ".uno:InsertFieldCtrl";
378cdf0e10cSrcweir         }
379cdf0e10cSrcweir         Dispatch( rtl::OUString::createFromAscii( pChar ),aArgs );
380cdf0e10cSrcweir 	}
381cdf0e10cSrcweir 	else
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir         sal_uInt16 nBlock = nId / 100;
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 		SwGlossaryList* pGlossaryList = ::GetGlossaryList();
386cdf0e10cSrcweir 		String sShortName;
387cdf0e10cSrcweir 		String sGroup = pGlossaryList->GetGroupName(nBlock - 1, sal_False);
388cdf0e10cSrcweir 		String sLongName(pGlossaryList->GetBlockName(nBlock - 1, nId - (100 * nBlock) - 1, sShortName));
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 		SwGlossaryHdl* pGlosHdl = pView->GetGlosHdl();
391cdf0e10cSrcweir 		SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
392cdf0e10cSrcweir 		DBG_ASSERT(pFact, "Dialogdiet fail!");
393cdf0e10cSrcweir 		::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
394cdf0e10cSrcweir 		if ( fnSetActGroup )
395cdf0e10cSrcweir 			(*fnSetActGroup)( sGroup );
396cdf0e10cSrcweir 		pGlosHdl->SetCurGroup(sGroup, sal_True);
397cdf0e10cSrcweir 		pGlosHdl->InsertGlossary(sShortName);
398cdf0e10cSrcweir 	}
399cdf0e10cSrcweir 	return 0;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir /**********************************************************************
403cdf0e10cSrcweir 
404cdf0e10cSrcweir **********************************************************************/
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 
DelPopup()407cdf0e10cSrcweir void SwTbxAutoTextCtrl::DelPopup()
408cdf0e10cSrcweir {
409cdf0e10cSrcweir 	if(pPopup)
410cdf0e10cSrcweir 	{
411cdf0e10cSrcweir 		if (GetSlotId() != FN_INSERT_FIELD_CTRL)
412cdf0e10cSrcweir 		{
413cdf0e10cSrcweir 			for( sal_uInt16 i = 0; i < pPopup->GetItemCount(); i ++ )
414cdf0e10cSrcweir 			{
415cdf0e10cSrcweir 				PopupMenu* pSubPopup = pPopup->GetPopupMenu(pPopup->GetItemId(i));
416cdf0e10cSrcweir 				delete pSubPopup;
417cdf0e10cSrcweir 			}
418cdf0e10cSrcweir 		}
419cdf0e10cSrcweir 		delete pPopup;
420cdf0e10cSrcweir 		pPopup = 0;
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir /*-----------------19.02.97 10.52-------------------
425cdf0e10cSrcweir 	Navigations-Popup
426cdf0e10cSrcweir --------------------------------------------------*/
427cdf0e10cSrcweir // determine the order of the toolbox items
428cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aNavigationInsertIds[ NAVI_ENTRIES ] =
429cdf0e10cSrcweir {
430cdf0e10cSrcweir     // -- first line
431cdf0e10cSrcweir     NID_TBL,
432cdf0e10cSrcweir     NID_FRM,
433cdf0e10cSrcweir     NID_GRF,
434cdf0e10cSrcweir     NID_OLE,
435cdf0e10cSrcweir     NID_PGE,
436cdf0e10cSrcweir     NID_OUTL,
437cdf0e10cSrcweir     NID_MARK,
438cdf0e10cSrcweir     NID_DRW,
439cdf0e10cSrcweir     NID_CTRL,
440cdf0e10cSrcweir     NID_PREV,
441cdf0e10cSrcweir     // -- second line
442cdf0e10cSrcweir     NID_REG,
443cdf0e10cSrcweir     NID_BKM,
444cdf0e10cSrcweir     NID_SEL,
445cdf0e10cSrcweir     NID_FTN,
446cdf0e10cSrcweir     NID_POSTIT,
447cdf0e10cSrcweir     NID_SRCH_REP,
448cdf0e10cSrcweir     NID_INDEX_ENTRY,
449cdf0e10cSrcweir     NID_TABLE_FORMULA,
450cdf0e10cSrcweir     NID_TABLE_FORMULA_ERROR,
451cdf0e10cSrcweir     NID_NEXT
452cdf0e10cSrcweir };
453cdf0e10cSrcweir static const char* __READONLY_DATA aNavigationHelpIds[ NAVI_ENTRIES ] =
454cdf0e10cSrcweir {
455cdf0e10cSrcweir     // -- first line
456cdf0e10cSrcweir     HID_NID_TBL,
457cdf0e10cSrcweir     HID_NID_FRM,
458cdf0e10cSrcweir     HID_NID_GRF,
459cdf0e10cSrcweir     HID_NID_OLE,
460cdf0e10cSrcweir     HID_NID_PGE,
461cdf0e10cSrcweir     HID_NID_OUTL,
462cdf0e10cSrcweir     HID_NID_MARK,
463cdf0e10cSrcweir     HID_NID_DRW,
464cdf0e10cSrcweir     HID_NID_CTRL,
465cdf0e10cSrcweir     HID_NID_PREV,
466cdf0e10cSrcweir     // -- second line
467cdf0e10cSrcweir     HID_NID_REG,
468cdf0e10cSrcweir     HID_NID_BKM,
469cdf0e10cSrcweir     HID_NID_SEL,
470cdf0e10cSrcweir     HID_NID_FTN,
471cdf0e10cSrcweir     HID_NID_POSTIT,
472cdf0e10cSrcweir     HID_NID_SRCH_REP,
473cdf0e10cSrcweir     HID_NID_INDEX_ENTRY,
474cdf0e10cSrcweir     HID_NID_TABLE_FORMULA,
475cdf0e10cSrcweir     HID_NID_TABLE_FORMULA_ERROR,
476cdf0e10cSrcweir     HID_NID_NEXT
477cdf0e10cSrcweir };
478cdf0e10cSrcweir 
SwScrollNaviPopup(sal_uInt16 nId,const Reference<XFrame> & rFrame)479cdf0e10cSrcweir SwScrollNaviPopup::SwScrollNaviPopup( sal_uInt16 nId, const Reference< XFrame >& rFrame )
480cdf0e10cSrcweir     : SfxPopupWindow(nId, rFrame, SW_RES(RID_SCROLL_NAVIGATION_WIN) ),
481cdf0e10cSrcweir     aToolBox(this, 0),
482cdf0e10cSrcweir     aSeparator(this, SW_RES(FL_SEP)),
483cdf0e10cSrcweir     aInfoField(this, SW_RES(FI_INFO)),
484cdf0e10cSrcweir 	aIList(SW_RES(IL_VALUES)),
485cdf0e10cSrcweir     aIListH(SW_RES(ILH_VALUES)),
486cdf0e10cSrcweir 	nFwdId(FN_START_OF_NEXT_PAGE),
487cdf0e10cSrcweir 	nBackId(FN_START_OF_PREV_PAGE)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir     sal_uInt16 i;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     aToolBox.SetHelpId(HID_NAVI_VS);
492cdf0e10cSrcweir     aToolBox.SetLineCount( 2 );
493cdf0e10cSrcweir     aToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
494cdf0e10cSrcweir     for( i = 0; i < NID_COUNT; i++)
495cdf0e10cSrcweir 	{
496cdf0e10cSrcweir         sal_uInt16 nNaviId = aNavigationInsertIds[i];
497cdf0e10cSrcweir         String sText;
498cdf0e10cSrcweir         ToolBoxItemBits  nTbxBits = 0;
499cdf0e10cSrcweir         if((NID_PREV != nNaviId) && (NID_NEXT != nNaviId))
500cdf0e10cSrcweir         {
501cdf0e10cSrcweir             // -2, there's no string for Next/Prev
502cdf0e10cSrcweir             sal_uInt16 nResStr = ST_TBL - 2 + nNaviId - NID_START;
503cdf0e10cSrcweir             sText = String(SW_RES(nResStr));
504cdf0e10cSrcweir             nTbxBits = TIB_CHECKABLE;
505cdf0e10cSrcweir         }
506ca62e2c2SSteve Yin 		else
507ca62e2c2SSteve Yin 		{
508ca62e2c2SSteve Yin 			if (nNaviId == NID_PREV)
509ca62e2c2SSteve Yin 				sText = String(SW_RES(STR_IMGBTN_PGE_UP));
510ca62e2c2SSteve Yin 			else if (nNaviId == NID_NEXT)
511ca62e2c2SSteve Yin 				sText = String(SW_RES(STR_IMGBTN_PGE_DOWN));
512ca62e2c2SSteve Yin 		}
513cdf0e10cSrcweir         aToolBox.InsertItem(nNaviId, sText, nTbxBits);
514cdf0e10cSrcweir         aToolBox.SetHelpId( nNaviId, aNavigationHelpIds[i] );
515cdf0e10cSrcweir     }
516cdf0e10cSrcweir     ApplyImageList();
517cdf0e10cSrcweir     aToolBox.InsertBreak(NID_COUNT/2);
518cdf0e10cSrcweir     // don't call it before!
519cdf0e10cSrcweir 	FreeResource();
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     // these are global strings
522cdf0e10cSrcweir 	for( i = 0; i < 2 * NID_COUNT; i++)
523cdf0e10cSrcweir 	{
524cdf0e10cSrcweir 		sQuickHelp[i] = String(SW_RES(STR_IMGBTN_START + i));
525cdf0e10cSrcweir 	}
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	Size aImgSize = aIList.GetImageSize();
528cdf0e10cSrcweir 	aImgSize.Width() += 5;
529cdf0e10cSrcweir 	aImgSize.Height() += 5;
530cdf0e10cSrcweir     Size aSz = aToolBox.CalcWindowSizePixel(2);
531cdf0e10cSrcweir     aToolBox.SetPosSizePixel( Point(), aSz );
532cdf0e10cSrcweir     sal_uInt16 nItemId = SwView::GetMoveType();
533cdf0e10cSrcweir     aInfoField.SetText(aToolBox.GetItemText(nItemId));
534cdf0e10cSrcweir     aToolBox.CheckItem( nItemId, sal_True );
535cdf0e10cSrcweir     Size aFTSize(aInfoField.GetSizePixel());
536cdf0e10cSrcweir     Size aSepSize(aSeparator.GetSizePixel());
537cdf0e10cSrcweir     aSepSize.Width() = aSz.Width();
538cdf0e10cSrcweir 
539cdf0e10cSrcweir     aSz.Height() += aFTSize.Height() + aSepSize.Height();
540cdf0e10cSrcweir     aInfoField.SetPosSizePixel(
541cdf0e10cSrcweir         Point(0, aSz.Height() - aFTSize.Height()), Size(aSz.Width(), aFTSize.Height()));
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     aSeparator.SetSizePixel(aSepSize);
544cdf0e10cSrcweir     aSeparator.SetPosPixel(Point(0, aSz.Height() - aFTSize.Height() - aSepSize.Height()));
545cdf0e10cSrcweir 
546cdf0e10cSrcweir     SetOutputSizePixel(aSz);
547cdf0e10cSrcweir     aToolBox.SetSelectHdl(LINK(this, SwScrollNaviPopup, SelectHdl));
548cdf0e10cSrcweir     aToolBox.StartSelection();
549cdf0e10cSrcweir     aToolBox.Show();
550cdf0e10cSrcweir }
551cdf0e10cSrcweir /*-----------------19.02.97 12.45-------------------
552cdf0e10cSrcweir 
553cdf0e10cSrcweir --------------------------------------------------*/
554cdf0e10cSrcweir 
~SwScrollNaviPopup()555cdf0e10cSrcweir SwScrollNaviPopup::~SwScrollNaviPopup()
556cdf0e10cSrcweir {
557cdf0e10cSrcweir }
558cdf0e10cSrcweir /* -----------------------------08.05.2002 14:00------------------------------
559cdf0e10cSrcweir 
560cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
DataChanged(const DataChangedEvent & rDCEvt)561cdf0e10cSrcweir void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
564cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
565cdf0e10cSrcweir             ApplyImageList();
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     Window::DataChanged( rDCEvt );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir /* -----------------------------08.05.2002 14:02------------------------------
570cdf0e10cSrcweir 
571cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
ApplyImageList()572cdf0e10cSrcweir void SwScrollNaviPopup::ApplyImageList()
573cdf0e10cSrcweir {
574cdf0e10cSrcweir     ImageList& rImgLst = aToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ?
575cdf0e10cSrcweir         aIListH : aIList;
576cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < NID_COUNT; i++)
577cdf0e10cSrcweir 	{
578cdf0e10cSrcweir         sal_uInt16 nNaviId = aNavigationInsertIds[i];
579cdf0e10cSrcweir         aToolBox.SetItemImage(nNaviId, rImgLst.GetImage(nNaviId));
580cdf0e10cSrcweir     }
581cdf0e10cSrcweir }
582cdf0e10cSrcweir /*-----------------19.02.97 13.58-------------------
583cdf0e10cSrcweir 
584cdf0e10cSrcweir --------------------------------------------------*/
585cdf0e10cSrcweir 
Clone() const586cdf0e10cSrcweir SfxPopupWindow* SwScrollNaviPopup::Clone() const
587cdf0e10cSrcweir {
588cdf0e10cSrcweir     return new SwScrollNaviPopup( GetId(), GetFrame() );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir /*-----------------19.02.97 14.10-------------------
592cdf0e10cSrcweir 
593cdf0e10cSrcweir --------------------------------------------------*/
594cdf0e10cSrcweir 
IMPL_LINK(SwScrollNaviPopup,SelectHdl,ToolBox *,pSet)595cdf0e10cSrcweir IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet)
596cdf0e10cSrcweir {
597cdf0e10cSrcweir     sal_uInt16 nSet = pSet->GetCurItemId();
598cdf0e10cSrcweir 	if( nSet != NID_PREV && nSet != NID_NEXT )
599cdf0e10cSrcweir 	{
600cdf0e10cSrcweir 		SwView::SetMoveType(nSet);
601cdf0e10cSrcweir         aToolBox.SetItemText(NID_NEXT, sQuickHelp[nSet - NID_START]);
602cdf0e10cSrcweir         aToolBox.SetItemText(NID_PREV, sQuickHelp[nSet - NID_START + NID_COUNT]);
603cdf0e10cSrcweir         aInfoField.SetText(aToolBox.GetItemText(nSet));
604cdf0e10cSrcweir         //check the current button only
605cdf0e10cSrcweir         for(sal_uInt16 i = 0; i < NID_COUNT; i++)
606cdf0e10cSrcweir         {
607cdf0e10cSrcweir             sal_uInt16 nItemId = aToolBox.GetItemId( i );
608cdf0e10cSrcweir             aToolBox.CheckItem( nItemId, nItemId == nSet );
609cdf0e10cSrcweir         }
610cdf0e10cSrcweir     }
611cdf0e10cSrcweir 	else
612cdf0e10cSrcweir 	{
613cdf0e10cSrcweir         SfxBoolItem aNext(FN_SCROLL_NEXT_PREV, NID_NEXT == nSet);
614cdf0e10cSrcweir         Any a;
615cdf0e10cSrcweir         Sequence< PropertyValue > aArgs( 1 );
616cdf0e10cSrcweir         aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollNextPrev" ));
617cdf0e10cSrcweir         aNext.QueryValue( a );
618cdf0e10cSrcweir         aArgs[0].Value = a;
619cdf0e10cSrcweir         SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
620cdf0e10cSrcweir                                      rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ScrollNextPrev" )),
621cdf0e10cSrcweir                                      aArgs );
622cdf0e10cSrcweir     }
623cdf0e10cSrcweir 	return 0;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir /*-----------------23.02.97 18.21-------------------
626cdf0e10cSrcweir 
627cdf0e10cSrcweir --------------------------------------------------*/
628cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)629cdf0e10cSrcweir void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent& rMEvt )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir     ToolBox::MouseButtonUp(rMEvt);
632cdf0e10cSrcweir 	if ( ((SwScrollNaviPopup*)GetParent())->IsInPopupMode() )
633cdf0e10cSrcweir 		((SwScrollNaviPopup*)GetParent())->EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
634cdf0e10cSrcweir }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir /*-----------------20.06.97 13:28-------------------
637cdf0e10cSrcweir 
638cdf0e10cSrcweir --------------------------------------------------*/
RequestHelp(const HelpEvent & rHEvt)639cdf0e10cSrcweir void  SwScrollNaviToolBox::RequestHelp( const HelpEvent& rHEvt )
640cdf0e10cSrcweir {
641cdf0e10cSrcweir 	SetItemText(NID_NEXT, SwScrollNaviPopup::GetQuickHelpText(sal_True));
642cdf0e10cSrcweir 	SetItemText(NID_PREV, SwScrollNaviPopup::GetQuickHelpText(sal_False));
643cdf0e10cSrcweir     ToolBox::RequestHelp( rHEvt );
644cdf0e10cSrcweir 
645cdf0e10cSrcweir }
646cdf0e10cSrcweir 
647cdf0e10cSrcweir /*-----------------20.06.97 13:41-------------------
648cdf0e10cSrcweir 
649cdf0e10cSrcweir --------------------------------------------------*/
GetQuickHelpText(sal_Bool bNext)650cdf0e10cSrcweir String	SwScrollNaviPopup::GetQuickHelpText(sal_Bool bNext)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir 	sal_uInt16 nResId = STR_IMGBTN_START;
653cdf0e10cSrcweir 	nResId += SwView::GetMoveType() - NID_START;
654cdf0e10cSrcweir 	if(!bNext)
655cdf0e10cSrcweir 		nResId += NID_COUNT;
656cdf0e10cSrcweir 	return String(SW_RES(nResId));
657cdf0e10cSrcweir }
658cdf0e10cSrcweir /* -----------------------------05.09.2002 13:53------------------------------
659cdf0e10cSrcweir 
660cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Click()661cdf0e10cSrcweir void SwNaviImageButton::Click()
662cdf0e10cSrcweir {
663cdf0e10cSrcweir //    SfxBindings& rBind = SfxViewFrame::Current()->GetBindings();
664cdf0e10cSrcweir //    rBind.ENTERREGISTRATIONS();
665cdf0e10cSrcweir     pPopup = new
666cdf0e10cSrcweir         SwScrollNaviPopup( FN_SCROLL_NAVIGATION,
667cdf0e10cSrcweir                            m_xFrame );
668cdf0e10cSrcweir //    rBind.LEAVEREGISTRATIONS();
669cdf0e10cSrcweir     Point aPos = OutputToScreenPixel(Point(0,0));
670cdf0e10cSrcweir     Rectangle aRect(aPos, GetSizePixel());
671cdf0e10cSrcweir     SetPopupWindow( pPopup );
672cdf0e10cSrcweir     pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_LEFT|FLOATWIN_POPUPMODE_ALLOWTEAROFF);
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir //--------------------------------------------------------------------
676cdf0e10cSrcweir 
SetPopupWindow(SfxPopupWindow * pWindow)677cdf0e10cSrcweir void SwNaviImageButton::SetPopupWindow( SfxPopupWindow* pWindow )
678cdf0e10cSrcweir {
679cdf0e10cSrcweir     pPopupWindow = pWindow;
680cdf0e10cSrcweir     pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNaviImageButton, PopupModeEndHdl ));
681cdf0e10cSrcweir     pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNaviImageButton, ClosePopupWindow ));
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir //--------------------------------------------------------------------
685cdf0e10cSrcweir 
IMPL_LINK(SwNaviImageButton,PopupModeEndHdl,void *,EMPTYARG)686cdf0e10cSrcweir IMPL_LINK( SwNaviImageButton, PopupModeEndHdl, void *, EMPTYARG )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir 	if ( pPopupWindow->IsVisible() )
689cdf0e10cSrcweir     {
690cdf0e10cSrcweir         // Replace floating window with popup window and destroy
691cdf0e10cSrcweir         // floating window instance.
692cdf0e10cSrcweir         delete pFloatingWindow;
693cdf0e10cSrcweir         pFloatingWindow = pPopupWindow;
694cdf0e10cSrcweir         pPopupWindow    = 0;
695cdf0e10cSrcweir     }
696cdf0e10cSrcweir     else
697cdf0e10cSrcweir     {
698cdf0e10cSrcweir         // Popup window has been closed by the user. No replacement, instance
699cdf0e10cSrcweir         // will destroy itself.
700cdf0e10cSrcweir         pPopupWindow = 0;
701cdf0e10cSrcweir     }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     return 1;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir 
706cdf0e10cSrcweir //--------------------------------------------------------------------
IMPL_LINK(SwNaviImageButton,ClosePopupWindow,SfxPopupWindow *,pWindow)707cdf0e10cSrcweir IMPL_LINK( SwNaviImageButton, ClosePopupWindow, SfxPopupWindow *, pWindow )
708cdf0e10cSrcweir {
709cdf0e10cSrcweir     if ( pWindow == pFloatingWindow )
710cdf0e10cSrcweir         pFloatingWindow = 0;
711cdf0e10cSrcweir     else
712cdf0e10cSrcweir         pPopupWindow = 0;
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     return 1;
715cdf0e10cSrcweir }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir /*-----------------21.02.97 09:41-------------------
718cdf0e10cSrcweir 
719cdf0e10cSrcweir --------------------------------------------------*/
720cdf0e10cSrcweir 
RequestHelp(const HelpEvent & rHEvt)721cdf0e10cSrcweir void SwHlpImageButton::RequestHelp( const HelpEvent& rHEvt )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 	SetQuickHelpText(SwScrollNaviPopup::GetQuickHelpText(!bUp));
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 	ImageButton::RequestHelp(rHEvt);
727cdf0e10cSrcweir }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir /*-----------------25.02.97 12:38-------------------
730cdf0e10cSrcweir 
731cdf0e10cSrcweir --------------------------------------------------*/
732cdf0e10cSrcweir 
SwNaviImageButton(Window * pParent,const Reference<XFrame> & rFrame)733cdf0e10cSrcweir SwNaviImageButton::SwNaviImageButton(
734cdf0e10cSrcweir     Window* pParent,
735cdf0e10cSrcweir     const Reference< XFrame >& rFrame ) :
736cdf0e10cSrcweir     ImageButton(pParent, SW_RES(BTN_NAVI)),
737cdf0e10cSrcweir         pPopup(0),
738cdf0e10cSrcweir         aImage(SW_RES(IMG_BTN)),
739cdf0e10cSrcweir         aImageH(SW_RES(IMG_BTN_H)),
740cdf0e10cSrcweir         sQuickText(SW_RES(ST_QUICK)),
741cdf0e10cSrcweir         pPopupWindow(0),
742cdf0e10cSrcweir         pFloatingWindow(0),
743cdf0e10cSrcweir         m_xFrame( rFrame )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 	FreeResource();
746cdf0e10cSrcweir 	SetStyle(GetStyle()|WB_NOPOINTERFOCUS);
747cdf0e10cSrcweir 	SetQuickHelpText(sQuickText);
748cdf0e10cSrcweir     SetModeImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImageH : aImage);
749cdf0e10cSrcweir }
750cdf0e10cSrcweir /* -----------------------------2002/07/05 9:41-------------------------------
751cdf0e10cSrcweir 
752cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
DataChanged(const DataChangedEvent & rDCEvt)753cdf0e10cSrcweir void SwNaviImageButton::DataChanged( const DataChangedEvent& rDCEvt )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
756cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
757cdf0e10cSrcweir             SetModeImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImageH : aImage);
758cdf0e10cSrcweir 
759cdf0e10cSrcweir     Window::DataChanged( rDCEvt );
760cdf0e10cSrcweir }
761cdf0e10cSrcweir /* -----------------26.11.2002 09:28-----------------
762cdf0e10cSrcweir  *
763cdf0e10cSrcweir  * --------------------------------------------------*/
764cdf0e10cSrcweir class SwZoomBox_Impl : public ComboBox
765cdf0e10cSrcweir {
766cdf0e10cSrcweir     sal_uInt16          nSlotId;
767cdf0e10cSrcweir     sal_Bool            bRelease;
768cdf0e10cSrcweir     uno::Reference< frame::XDispatchProvider > m_xDispatchProvider;
769cdf0e10cSrcweir 
770cdf0e10cSrcweir public:
771cdf0e10cSrcweir     SwZoomBox_Impl(
772cdf0e10cSrcweir         Window* pParent,
773cdf0e10cSrcweir         sal_uInt16 nSlot,
774cdf0e10cSrcweir         const Reference< XDispatchProvider >& rDispatchProvider );
775cdf0e10cSrcweir     ~SwZoomBox_Impl();
776cdf0e10cSrcweir 
777cdf0e10cSrcweir protected:
778cdf0e10cSrcweir     virtual void    Select();
779cdf0e10cSrcweir     virtual long    Notify( NotifyEvent& rNEvt );
780cdf0e10cSrcweir 
781cdf0e10cSrcweir     void ReleaseFocus();
782cdf0e10cSrcweir 
783cdf0e10cSrcweir };
784cdf0e10cSrcweir /* -----------------26.11.2002 09:29-----------------
785cdf0e10cSrcweir  *
786cdf0e10cSrcweir  * --------------------------------------------------*/
SwZoomBox_Impl(Window * pParent,sal_uInt16 nSlot,const Reference<XDispatchProvider> & rDispatchProvider)787cdf0e10cSrcweir SwZoomBox_Impl::SwZoomBox_Impl(
788cdf0e10cSrcweir     Window* pParent,
789cdf0e10cSrcweir     sal_uInt16 nSlot,
790cdf0e10cSrcweir     const Reference< XDispatchProvider >& rDispatchProvider ):
791cdf0e10cSrcweir     ComboBox( pParent, SW_RES(RID_PVIEW_ZOOM_LB)),
792cdf0e10cSrcweir     nSlotId(nSlot),
793cdf0e10cSrcweir     bRelease(sal_True),
794cdf0e10cSrcweir     m_xDispatchProvider( rDispatchProvider )
795cdf0e10cSrcweir {
796cdf0e10cSrcweir     EnableAutocomplete( sal_False );
797cdf0e10cSrcweir     sal_uInt16 aZoomValues[] =
798cdf0e10cSrcweir     {   25, 50, 75, 100, 150, 200 };
799cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < sizeof(aZoomValues)/sizeof(sal_uInt16); i++)
800cdf0e10cSrcweir     {
801cdf0e10cSrcweir         String sEntry = String::CreateFromInt32(aZoomValues[i]);
802bfbfb838STsutomu Uchino         sEntry.AppendAscii( " %" );
803cdf0e10cSrcweir         InsertEntry(sEntry);
804cdf0e10cSrcweir     }
805cdf0e10cSrcweir }
806cdf0e10cSrcweir /* -----------------26.11.2002 09:29-----------------
807cdf0e10cSrcweir  *
808cdf0e10cSrcweir  * --------------------------------------------------*/
~SwZoomBox_Impl()809cdf0e10cSrcweir SwZoomBox_Impl::~SwZoomBox_Impl()
810cdf0e10cSrcweir {}
811cdf0e10cSrcweir /* -----------------26.11.2002 09:34-----------------
812cdf0e10cSrcweir  *
813cdf0e10cSrcweir  * --------------------------------------------------*/
Select()814cdf0e10cSrcweir void    SwZoomBox_Impl::Select()
815cdf0e10cSrcweir {
816cdf0e10cSrcweir     if ( !IsTravelSelect() )
817cdf0e10cSrcweir     {
818cdf0e10cSrcweir         String sEntry(GetText());
819cdf0e10cSrcweir         sEntry.EraseAllChars( '%' );
820*6db34107SArrigo Marchiori         sal_Int32 nZoom = sEntry.ToInt32();
821cdf0e10cSrcweir         if(nZoom < MINZOOM)
822cdf0e10cSrcweir             nZoom = MINZOOM;
823cdf0e10cSrcweir         if(nZoom > MAXZOOM)
824cdf0e10cSrcweir             nZoom = MAXZOOM;
825cdf0e10cSrcweir 
826*6db34107SArrigo Marchiori         SfxUInt16Item aItem( nSlotId, (sal_uInt16)nZoom );
827cdf0e10cSrcweir         if ( FN_PREVIEW_ZOOM == nSlotId )
828cdf0e10cSrcweir         {
829cdf0e10cSrcweir             Any a;
830cdf0e10cSrcweir             Sequence< PropertyValue > aArgs( 1 );
831cdf0e10cSrcweir             aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreviewZoom" ));
832cdf0e10cSrcweir             aItem.QueryValue( a );
833cdf0e10cSrcweir             aArgs[0].Value = a;
834cdf0e10cSrcweir             SfxToolBoxControl::Dispatch(
835cdf0e10cSrcweir                 m_xDispatchProvider,
836cdf0e10cSrcweir                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PreviewZoom" )),
837cdf0e10cSrcweir                 aArgs );
838cdf0e10cSrcweir         }
839cdf0e10cSrcweir 
840cdf0e10cSrcweir         ReleaseFocus();
841cdf0e10cSrcweir     }
842cdf0e10cSrcweir }
843cdf0e10cSrcweir /* -----------------02.12.2002 07:49-----------------
844cdf0e10cSrcweir  *
845cdf0e10cSrcweir  * --------------------------------------------------*/
Notify(NotifyEvent & rNEvt)846cdf0e10cSrcweir long SwZoomBox_Impl::Notify( NotifyEvent& rNEvt )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir     long nHandled = 0;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir     if ( rNEvt.GetType() == EVENT_KEYINPUT )
851cdf0e10cSrcweir     {
852cdf0e10cSrcweir         sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
853cdf0e10cSrcweir 
854cdf0e10cSrcweir         switch ( nCode )
855cdf0e10cSrcweir         {
856cdf0e10cSrcweir             case KEY_RETURN:
857cdf0e10cSrcweir             case KEY_TAB:
858cdf0e10cSrcweir             {
859cdf0e10cSrcweir                 if ( KEY_TAB == nCode )
860cdf0e10cSrcweir                     bRelease = sal_False;
861cdf0e10cSrcweir                 else
862cdf0e10cSrcweir                     nHandled = 1;
863cdf0e10cSrcweir                 Select();
864cdf0e10cSrcweir                 break;
865cdf0e10cSrcweir             }
866cdf0e10cSrcweir 
867cdf0e10cSrcweir             case KEY_ESCAPE:
868cdf0e10cSrcweir                 SetText( GetSavedValue() );
869cdf0e10cSrcweir                 ReleaseFocus();
870cdf0e10cSrcweir                 break;
871cdf0e10cSrcweir         }
872cdf0e10cSrcweir     }
873cdf0e10cSrcweir     else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
874cdf0e10cSrcweir     {
875cdf0e10cSrcweir         Window* pFocusWin = Application::GetFocusWindow();
876cdf0e10cSrcweir         if ( !HasFocus() && GetSubEdit() != pFocusWin )
877cdf0e10cSrcweir             SetText( GetSavedValue() );
878cdf0e10cSrcweir     }
879cdf0e10cSrcweir 
880cdf0e10cSrcweir     return nHandled ? nHandled : ComboBox::Notify( rNEvt );
881cdf0e10cSrcweir }
882cdf0e10cSrcweir /* -----------------02.12.2002 07:51-----------------
883cdf0e10cSrcweir  *
884cdf0e10cSrcweir  * --------------------------------------------------*/
ReleaseFocus()885cdf0e10cSrcweir void SwZoomBox_Impl::ReleaseFocus()
886cdf0e10cSrcweir {
887cdf0e10cSrcweir     if ( !bRelease )
888cdf0e10cSrcweir     {
889cdf0e10cSrcweir         bRelease = sal_True;
890cdf0e10cSrcweir         return;
891cdf0e10cSrcweir     }
892cdf0e10cSrcweir     SfxViewShell* pCurSh = SfxViewShell::Current();
893cdf0e10cSrcweir 
894cdf0e10cSrcweir     if ( pCurSh )
895cdf0e10cSrcweir     {
896cdf0e10cSrcweir         Window* pShellWnd = pCurSh->GetWindow();
897cdf0e10cSrcweir 
898cdf0e10cSrcweir         if ( pShellWnd )
899cdf0e10cSrcweir             pShellWnd->GrabFocus();
900cdf0e10cSrcweir     }
901cdf0e10cSrcweir }
902cdf0e10cSrcweir 
903cdf0e10cSrcweir /* -----------------26.11.2002 09:29-----------------
904cdf0e10cSrcweir  *
905cdf0e10cSrcweir  * --------------------------------------------------*/
906cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl, SfxUInt16Item);
907cdf0e10cSrcweir 
SwPreviewZoomControl(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)908cdf0e10cSrcweir SwPreviewZoomControl::SwPreviewZoomControl(
909cdf0e10cSrcweir     sal_uInt16 nSlotId,
910cdf0e10cSrcweir     sal_uInt16 nId,
911cdf0e10cSrcweir     ToolBox& rTbx) :
912cdf0e10cSrcweir     SfxToolBoxControl( nSlotId, nId, rTbx )
913cdf0e10cSrcweir {
914cdf0e10cSrcweir }
915cdf0e10cSrcweir /* -----------------26.11.2002 09:29-----------------
916cdf0e10cSrcweir  *
917cdf0e10cSrcweir  * --------------------------------------------------*/
~SwPreviewZoomControl()918cdf0e10cSrcweir SwPreviewZoomControl::~SwPreviewZoomControl()
919cdf0e10cSrcweir {
920cdf0e10cSrcweir }
921cdf0e10cSrcweir /* -----------------26.11.2002 09:29-----------------
922cdf0e10cSrcweir  *
923cdf0e10cSrcweir  * --------------------------------------------------*/
StateChanged(sal_uInt16,SfxItemState eState,const SfxPoolItem * pState)924cdf0e10cSrcweir void SwPreviewZoomControl::StateChanged( sal_uInt16 /*nSID*/,
925cdf0e10cSrcweir                                          SfxItemState eState,
926cdf0e10cSrcweir                                          const SfxPoolItem* pState )
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     sal_uInt16 nId = GetId();
929cdf0e10cSrcweir     GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) );
930cdf0e10cSrcweir     SwZoomBox_Impl* pBox = (SwZoomBox_Impl*)GetToolBox().GetItemWindow( GetId() );
931cdf0e10cSrcweir     if(SFX_ITEM_AVAILABLE <= eState)
932cdf0e10cSrcweir     {
933cdf0e10cSrcweir         String sZoom(String::CreateFromInt32(((const SfxUInt16Item*)pState)->GetValue()));
934bfbfb838STsutomu Uchino         sZoom.AppendAscii( " %" );
935cdf0e10cSrcweir         pBox->SetText(sZoom);
936cdf0e10cSrcweir         pBox->SaveValue();
937cdf0e10cSrcweir     }
938cdf0e10cSrcweir }
939cdf0e10cSrcweir /* -----------------26.11.2002 09:29-----------------
940cdf0e10cSrcweir  *
941cdf0e10cSrcweir  * --------------------------------------------------*/
CreateItemWindow(Window * pParent)942cdf0e10cSrcweir Window* SwPreviewZoomControl::CreateItemWindow( Window *pParent )
943cdf0e10cSrcweir {
944cdf0e10cSrcweir     SwZoomBox_Impl* pRet = new SwZoomBox_Impl( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ));
945cdf0e10cSrcweir     return pRet;
946cdf0e10cSrcweir }
947