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