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