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 10cdf0e10cSrcweir * 11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 **********************************************************************/ 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 **********************************************************************/ 98cdf0e10cSrcweir SwTbxInsertCtrl::~SwTbxInsertCtrl() 99cdf0e10cSrcweir { 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 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 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 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 179cdf0e10cSrcweir SfxPopupWindowType SwTbxInsertCtrl::GetPopupWindowType() const 180cdf0e10cSrcweir { 181cdf0e10cSrcweir return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir 185cdf0e10cSrcweir /********************************************************************** 186cdf0e10cSrcweir 187cdf0e10cSrcweir **********************************************************************/ 188cdf0e10cSrcweir 189cdf0e10cSrcweir 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 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 229cdf0e10cSrcweir SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl() 230cdf0e10cSrcweir { 231cdf0e10cSrcweir DelPopup(); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir /********************************************************************** 235cdf0e10cSrcweir 236cdf0e10cSrcweir **********************************************************************/ 237cdf0e10cSrcweir 238cdf0e10cSrcweir 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 319cdf0e10cSrcweir SfxPopupWindowType SwTbxAutoTextCtrl::GetPopupWindowType() const 320cdf0e10cSrcweir { 321cdf0e10cSrcweir return SFX_POPUPWINDOW_ONTIMEOUT; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir /********************************************************************** 325cdf0e10cSrcweir 326cdf0e10cSrcweir **********************************************************************/ 327cdf0e10cSrcweir 328cdf0e10cSrcweir 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 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 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 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 } 506*ca62e2c2SSteve Yin //IAccessibility2 Impplementaton 2009----- 507*ca62e2c2SSteve Yin else 508*ca62e2c2SSteve Yin { 509*ca62e2c2SSteve Yin if (nNaviId == NID_PREV) 510*ca62e2c2SSteve Yin sText = String(SW_RES(STR_IMGBTN_PGE_UP)); 511*ca62e2c2SSteve Yin else if (nNaviId == NID_NEXT) 512*ca62e2c2SSteve Yin sText = String(SW_RES(STR_IMGBTN_PGE_DOWN)); 513*ca62e2c2SSteve Yin } 514*ca62e2c2SSteve Yin //-----IAccessibility2 Impplementaton 2009 515cdf0e10cSrcweir aToolBox.InsertItem(nNaviId, sText, nTbxBits); 516cdf0e10cSrcweir aToolBox.SetHelpId( nNaviId, aNavigationHelpIds[i] ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir ApplyImageList(); 519cdf0e10cSrcweir aToolBox.InsertBreak(NID_COUNT/2); 520cdf0e10cSrcweir // don't call it before! 521cdf0e10cSrcweir FreeResource(); 522cdf0e10cSrcweir 523cdf0e10cSrcweir // these are global strings 524cdf0e10cSrcweir for( i = 0; i < 2 * NID_COUNT; i++) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir sQuickHelp[i] = String(SW_RES(STR_IMGBTN_START + i)); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir 529cdf0e10cSrcweir Size aImgSize = aIList.GetImageSize(); 530cdf0e10cSrcweir aImgSize.Width() += 5; 531cdf0e10cSrcweir aImgSize.Height() += 5; 532cdf0e10cSrcweir Size aSz = aToolBox.CalcWindowSizePixel(2); 533cdf0e10cSrcweir aToolBox.SetPosSizePixel( Point(), aSz ); 534cdf0e10cSrcweir sal_uInt16 nItemId = SwView::GetMoveType(); 535cdf0e10cSrcweir aInfoField.SetText(aToolBox.GetItemText(nItemId)); 536cdf0e10cSrcweir aToolBox.CheckItem( nItemId, sal_True ); 537cdf0e10cSrcweir Size aFTSize(aInfoField.GetSizePixel()); 538cdf0e10cSrcweir Size aSepSize(aSeparator.GetSizePixel()); 539cdf0e10cSrcweir aSepSize.Width() = aSz.Width(); 540cdf0e10cSrcweir 541cdf0e10cSrcweir aSz.Height() += aFTSize.Height() + aSepSize.Height(); 542cdf0e10cSrcweir aInfoField.SetPosSizePixel( 543cdf0e10cSrcweir Point(0, aSz.Height() - aFTSize.Height()), Size(aSz.Width(), aFTSize.Height())); 544cdf0e10cSrcweir 545cdf0e10cSrcweir aSeparator.SetSizePixel(aSepSize); 546cdf0e10cSrcweir aSeparator.SetPosPixel(Point(0, aSz.Height() - aFTSize.Height() - aSepSize.Height())); 547cdf0e10cSrcweir 548cdf0e10cSrcweir SetOutputSizePixel(aSz); 549cdf0e10cSrcweir aToolBox.SetSelectHdl(LINK(this, SwScrollNaviPopup, SelectHdl)); 550cdf0e10cSrcweir aToolBox.StartSelection(); 551cdf0e10cSrcweir aToolBox.Show(); 552cdf0e10cSrcweir } 553cdf0e10cSrcweir /*-----------------19.02.97 12.45------------------- 554cdf0e10cSrcweir 555cdf0e10cSrcweir --------------------------------------------------*/ 556cdf0e10cSrcweir 557cdf0e10cSrcweir SwScrollNaviPopup::~SwScrollNaviPopup() 558cdf0e10cSrcweir { 559cdf0e10cSrcweir } 560cdf0e10cSrcweir /* -----------------------------08.05.2002 14:00------------------------------ 561cdf0e10cSrcweir 562cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 563cdf0e10cSrcweir void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 566cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 567cdf0e10cSrcweir ApplyImageList(); 568cdf0e10cSrcweir 569cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir /* -----------------------------08.05.2002 14:02------------------------------ 572cdf0e10cSrcweir 573cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 574cdf0e10cSrcweir void SwScrollNaviPopup::ApplyImageList() 575cdf0e10cSrcweir { 576cdf0e10cSrcweir ImageList& rImgLst = aToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ? 577cdf0e10cSrcweir aIListH : aIList; 578cdf0e10cSrcweir for(sal_uInt16 i = 0; i < NID_COUNT; i++) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir sal_uInt16 nNaviId = aNavigationInsertIds[i]; 581cdf0e10cSrcweir aToolBox.SetItemImage(nNaviId, rImgLst.GetImage(nNaviId)); 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir /*-----------------19.02.97 13.58------------------- 585cdf0e10cSrcweir 586cdf0e10cSrcweir --------------------------------------------------*/ 587cdf0e10cSrcweir 588cdf0e10cSrcweir SfxPopupWindow* SwScrollNaviPopup::Clone() const 589cdf0e10cSrcweir { 590cdf0e10cSrcweir return new SwScrollNaviPopup( GetId(), GetFrame() ); 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir /*-----------------19.02.97 14.10------------------- 594cdf0e10cSrcweir 595cdf0e10cSrcweir --------------------------------------------------*/ 596cdf0e10cSrcweir 597cdf0e10cSrcweir IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir sal_uInt16 nSet = pSet->GetCurItemId(); 600cdf0e10cSrcweir if( nSet != NID_PREV && nSet != NID_NEXT ) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir SwView::SetMoveType(nSet); 603cdf0e10cSrcweir aToolBox.SetItemText(NID_NEXT, sQuickHelp[nSet - NID_START]); 604cdf0e10cSrcweir aToolBox.SetItemText(NID_PREV, sQuickHelp[nSet - NID_START + NID_COUNT]); 605cdf0e10cSrcweir aInfoField.SetText(aToolBox.GetItemText(nSet)); 606cdf0e10cSrcweir //check the current button only 607cdf0e10cSrcweir for(sal_uInt16 i = 0; i < NID_COUNT; i++) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir sal_uInt16 nItemId = aToolBox.GetItemId( i ); 610cdf0e10cSrcweir aToolBox.CheckItem( nItemId, nItemId == nSet ); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir else 614cdf0e10cSrcweir { 615cdf0e10cSrcweir SfxBoolItem aNext(FN_SCROLL_NEXT_PREV, NID_NEXT == nSet); 616cdf0e10cSrcweir Any a; 617cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 618cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollNextPrev" )); 619cdf0e10cSrcweir aNext.QueryValue( a ); 620cdf0e10cSrcweir aArgs[0].Value = a; 621cdf0e10cSrcweir SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), 622cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ScrollNextPrev" )), 623cdf0e10cSrcweir aArgs ); 624cdf0e10cSrcweir } 625cdf0e10cSrcweir return 0; 626cdf0e10cSrcweir } 627cdf0e10cSrcweir /*-----------------23.02.97 18.21------------------- 628cdf0e10cSrcweir 629cdf0e10cSrcweir --------------------------------------------------*/ 630cdf0e10cSrcweir 631cdf0e10cSrcweir void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent& rMEvt ) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir ToolBox::MouseButtonUp(rMEvt); 634cdf0e10cSrcweir if ( ((SwScrollNaviPopup*)GetParent())->IsInPopupMode() ) 635cdf0e10cSrcweir ((SwScrollNaviPopup*)GetParent())->EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir 638cdf0e10cSrcweir /*-----------------20.06.97 13:28------------------- 639cdf0e10cSrcweir 640cdf0e10cSrcweir --------------------------------------------------*/ 641cdf0e10cSrcweir void SwScrollNaviToolBox::RequestHelp( const HelpEvent& rHEvt ) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir SetItemText(NID_NEXT, SwScrollNaviPopup::GetQuickHelpText(sal_True)); 644cdf0e10cSrcweir SetItemText(NID_PREV, SwScrollNaviPopup::GetQuickHelpText(sal_False)); 645cdf0e10cSrcweir ToolBox::RequestHelp( rHEvt ); 646cdf0e10cSrcweir 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir /*-----------------20.06.97 13:41------------------- 650cdf0e10cSrcweir 651cdf0e10cSrcweir --------------------------------------------------*/ 652cdf0e10cSrcweir String SwScrollNaviPopup::GetQuickHelpText(sal_Bool bNext) 653cdf0e10cSrcweir { 654cdf0e10cSrcweir sal_uInt16 nResId = STR_IMGBTN_START; 655cdf0e10cSrcweir nResId += SwView::GetMoveType() - NID_START; 656cdf0e10cSrcweir if(!bNext) 657cdf0e10cSrcweir nResId += NID_COUNT; 658cdf0e10cSrcweir return String(SW_RES(nResId)); 659cdf0e10cSrcweir } 660cdf0e10cSrcweir /* -----------------------------05.09.2002 13:53------------------------------ 661cdf0e10cSrcweir 662cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 663cdf0e10cSrcweir void SwNaviImageButton::Click() 664cdf0e10cSrcweir { 665cdf0e10cSrcweir // SfxBindings& rBind = SfxViewFrame::Current()->GetBindings(); 666cdf0e10cSrcweir // rBind.ENTERREGISTRATIONS(); 667cdf0e10cSrcweir pPopup = new 668cdf0e10cSrcweir SwScrollNaviPopup( FN_SCROLL_NAVIGATION, 669cdf0e10cSrcweir m_xFrame ); 670cdf0e10cSrcweir // rBind.LEAVEREGISTRATIONS(); 671cdf0e10cSrcweir Point aPos = OutputToScreenPixel(Point(0,0)); 672cdf0e10cSrcweir Rectangle aRect(aPos, GetSizePixel()); 673cdf0e10cSrcweir SetPopupWindow( pPopup ); 674cdf0e10cSrcweir pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_LEFT|FLOATWIN_POPUPMODE_ALLOWTEAROFF); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir //-------------------------------------------------------------------- 678cdf0e10cSrcweir 679cdf0e10cSrcweir void SwNaviImageButton::SetPopupWindow( SfxPopupWindow* pWindow ) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir pPopupWindow = pWindow; 682cdf0e10cSrcweir pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNaviImageButton, PopupModeEndHdl )); 683cdf0e10cSrcweir pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNaviImageButton, ClosePopupWindow )); 684cdf0e10cSrcweir } 685cdf0e10cSrcweir 686cdf0e10cSrcweir //-------------------------------------------------------------------- 687cdf0e10cSrcweir 688cdf0e10cSrcweir IMPL_LINK( SwNaviImageButton, PopupModeEndHdl, void *, EMPTYARG ) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir if ( pPopupWindow->IsVisible() ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir // Replace floating window with popup window and destroy 693cdf0e10cSrcweir // floating window instance. 694cdf0e10cSrcweir delete pFloatingWindow; 695cdf0e10cSrcweir pFloatingWindow = pPopupWindow; 696cdf0e10cSrcweir pPopupWindow = 0; 697cdf0e10cSrcweir } 698cdf0e10cSrcweir else 699cdf0e10cSrcweir { 700cdf0e10cSrcweir // Popup window has been closed by the user. No replacement, instance 701cdf0e10cSrcweir // will destroy itself. 702cdf0e10cSrcweir pPopupWindow = 0; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir return 1; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir 708cdf0e10cSrcweir //-------------------------------------------------------------------- 709cdf0e10cSrcweir IMPL_LINK( SwNaviImageButton, ClosePopupWindow, SfxPopupWindow *, pWindow ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir if ( pWindow == pFloatingWindow ) 712cdf0e10cSrcweir pFloatingWindow = 0; 713cdf0e10cSrcweir else 714cdf0e10cSrcweir pPopupWindow = 0; 715cdf0e10cSrcweir 716cdf0e10cSrcweir return 1; 717cdf0e10cSrcweir } 718cdf0e10cSrcweir 719cdf0e10cSrcweir /*-----------------21.02.97 09:41------------------- 720cdf0e10cSrcweir 721cdf0e10cSrcweir --------------------------------------------------*/ 722cdf0e10cSrcweir 723cdf0e10cSrcweir void SwHlpImageButton::RequestHelp( const HelpEvent& rHEvt ) 724cdf0e10cSrcweir { 725cdf0e10cSrcweir 726cdf0e10cSrcweir SetQuickHelpText(SwScrollNaviPopup::GetQuickHelpText(!bUp)); 727cdf0e10cSrcweir 728cdf0e10cSrcweir ImageButton::RequestHelp(rHEvt); 729cdf0e10cSrcweir } 730cdf0e10cSrcweir 731cdf0e10cSrcweir /*-----------------25.02.97 12:38------------------- 732cdf0e10cSrcweir 733cdf0e10cSrcweir --------------------------------------------------*/ 734cdf0e10cSrcweir 735cdf0e10cSrcweir SwNaviImageButton::SwNaviImageButton( 736cdf0e10cSrcweir Window* pParent, 737cdf0e10cSrcweir const Reference< XFrame >& rFrame ) : 738cdf0e10cSrcweir ImageButton(pParent, SW_RES(BTN_NAVI)), 739cdf0e10cSrcweir pPopup(0), 740cdf0e10cSrcweir aImage(SW_RES(IMG_BTN)), 741cdf0e10cSrcweir aImageH(SW_RES(IMG_BTN_H)), 742cdf0e10cSrcweir sQuickText(SW_RES(ST_QUICK)), 743cdf0e10cSrcweir pPopupWindow(0), 744cdf0e10cSrcweir pFloatingWindow(0), 745cdf0e10cSrcweir m_xFrame( rFrame ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir FreeResource(); 748cdf0e10cSrcweir SetStyle(GetStyle()|WB_NOPOINTERFOCUS); 749cdf0e10cSrcweir SetQuickHelpText(sQuickText); 750cdf0e10cSrcweir SetModeImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImageH : aImage); 751cdf0e10cSrcweir } 752cdf0e10cSrcweir /* -----------------------------2002/07/05 9:41------------------------------- 753cdf0e10cSrcweir 754cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 755cdf0e10cSrcweir void SwNaviImageButton::DataChanged( const DataChangedEvent& rDCEvt ) 756cdf0e10cSrcweir { 757cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 758cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 759cdf0e10cSrcweir SetModeImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImageH : aImage); 760cdf0e10cSrcweir 761cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir /* -----------------26.11.2002 09:28----------------- 764cdf0e10cSrcweir * 765cdf0e10cSrcweir * --------------------------------------------------*/ 766cdf0e10cSrcweir class SwZoomBox_Impl : public ComboBox 767cdf0e10cSrcweir { 768cdf0e10cSrcweir sal_uInt16 nSlotId; 769cdf0e10cSrcweir sal_Bool bRelease; 770cdf0e10cSrcweir uno::Reference< frame::XDispatchProvider > m_xDispatchProvider; 771cdf0e10cSrcweir 772cdf0e10cSrcweir public: 773cdf0e10cSrcweir SwZoomBox_Impl( 774cdf0e10cSrcweir Window* pParent, 775cdf0e10cSrcweir sal_uInt16 nSlot, 776cdf0e10cSrcweir const Reference< XDispatchProvider >& rDispatchProvider ); 777cdf0e10cSrcweir ~SwZoomBox_Impl(); 778cdf0e10cSrcweir 779cdf0e10cSrcweir protected: 780cdf0e10cSrcweir virtual void Select(); 781cdf0e10cSrcweir virtual long Notify( NotifyEvent& rNEvt ); 782cdf0e10cSrcweir 783cdf0e10cSrcweir void ReleaseFocus(); 784cdf0e10cSrcweir 785cdf0e10cSrcweir }; 786cdf0e10cSrcweir /* -----------------26.11.2002 09:29----------------- 787cdf0e10cSrcweir * 788cdf0e10cSrcweir * --------------------------------------------------*/ 789cdf0e10cSrcweir SwZoomBox_Impl::SwZoomBox_Impl( 790cdf0e10cSrcweir Window* pParent, 791cdf0e10cSrcweir sal_uInt16 nSlot, 792cdf0e10cSrcweir const Reference< XDispatchProvider >& rDispatchProvider ): 793cdf0e10cSrcweir ComboBox( pParent, SW_RES(RID_PVIEW_ZOOM_LB)), 794cdf0e10cSrcweir nSlotId(nSlot), 795cdf0e10cSrcweir bRelease(sal_True), 796cdf0e10cSrcweir m_xDispatchProvider( rDispatchProvider ) 797cdf0e10cSrcweir { 798cdf0e10cSrcweir EnableAutocomplete( sal_False ); 799cdf0e10cSrcweir sal_uInt16 aZoomValues[] = 800cdf0e10cSrcweir { 25, 50, 75, 100, 150, 200 }; 801cdf0e10cSrcweir for(sal_uInt16 i = 0; i < sizeof(aZoomValues)/sizeof(sal_uInt16); i++) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir String sEntry = String::CreateFromInt32(aZoomValues[i]); 804cdf0e10cSrcweir sEntry += '%'; 805cdf0e10cSrcweir InsertEntry(sEntry); 806cdf0e10cSrcweir } 807cdf0e10cSrcweir } 808cdf0e10cSrcweir /* -----------------26.11.2002 09:29----------------- 809cdf0e10cSrcweir * 810cdf0e10cSrcweir * --------------------------------------------------*/ 811cdf0e10cSrcweir SwZoomBox_Impl::~SwZoomBox_Impl() 812cdf0e10cSrcweir {} 813cdf0e10cSrcweir /* -----------------26.11.2002 09:34----------------- 814cdf0e10cSrcweir * 815cdf0e10cSrcweir * --------------------------------------------------*/ 816cdf0e10cSrcweir void SwZoomBox_Impl::Select() 817cdf0e10cSrcweir { 818cdf0e10cSrcweir if ( !IsTravelSelect() ) 819cdf0e10cSrcweir { 820cdf0e10cSrcweir String sEntry(GetText()); 821cdf0e10cSrcweir sEntry.EraseAllChars( '%' ); 822cdf0e10cSrcweir sal_uInt16 nZoom = (sal_uInt16)sEntry.ToInt32(); 823cdf0e10cSrcweir if(nZoom < MINZOOM) 824cdf0e10cSrcweir nZoom = MINZOOM; 825cdf0e10cSrcweir if(nZoom > MAXZOOM) 826cdf0e10cSrcweir nZoom = MAXZOOM; 827cdf0e10cSrcweir 828cdf0e10cSrcweir SfxUInt16Item aItem( nSlotId, nZoom ); 829cdf0e10cSrcweir if ( FN_PREVIEW_ZOOM == nSlotId ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir Any a; 832cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 833cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreviewZoom" )); 834cdf0e10cSrcweir aItem.QueryValue( a ); 835cdf0e10cSrcweir aArgs[0].Value = a; 836cdf0e10cSrcweir SfxToolBoxControl::Dispatch( 837cdf0e10cSrcweir m_xDispatchProvider, 838cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PreviewZoom" )), 839cdf0e10cSrcweir aArgs ); 840cdf0e10cSrcweir } 841cdf0e10cSrcweir 842cdf0e10cSrcweir ReleaseFocus(); 843cdf0e10cSrcweir } 844cdf0e10cSrcweir } 845cdf0e10cSrcweir /* -----------------02.12.2002 07:49----------------- 846cdf0e10cSrcweir * 847cdf0e10cSrcweir * --------------------------------------------------*/ 848cdf0e10cSrcweir long SwZoomBox_Impl::Notify( NotifyEvent& rNEvt ) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir long nHandled = 0; 851cdf0e10cSrcweir 852cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); 855cdf0e10cSrcweir 856cdf0e10cSrcweir switch ( nCode ) 857cdf0e10cSrcweir { 858cdf0e10cSrcweir case KEY_RETURN: 859cdf0e10cSrcweir case KEY_TAB: 860cdf0e10cSrcweir { 861cdf0e10cSrcweir if ( KEY_TAB == nCode ) 862cdf0e10cSrcweir bRelease = sal_False; 863cdf0e10cSrcweir else 864cdf0e10cSrcweir nHandled = 1; 865cdf0e10cSrcweir Select(); 866cdf0e10cSrcweir break; 867cdf0e10cSrcweir } 868cdf0e10cSrcweir 869cdf0e10cSrcweir case KEY_ESCAPE: 870cdf0e10cSrcweir SetText( GetSavedValue() ); 871cdf0e10cSrcweir ReleaseFocus(); 872cdf0e10cSrcweir break; 873cdf0e10cSrcweir } 874cdf0e10cSrcweir } 875cdf0e10cSrcweir else if ( EVENT_LOSEFOCUS == rNEvt.GetType() ) 876cdf0e10cSrcweir { 877cdf0e10cSrcweir Window* pFocusWin = Application::GetFocusWindow(); 878cdf0e10cSrcweir if ( !HasFocus() && GetSubEdit() != pFocusWin ) 879cdf0e10cSrcweir SetText( GetSavedValue() ); 880cdf0e10cSrcweir } 881cdf0e10cSrcweir 882cdf0e10cSrcweir return nHandled ? nHandled : ComboBox::Notify( rNEvt ); 883cdf0e10cSrcweir } 884cdf0e10cSrcweir /* -----------------02.12.2002 07:51----------------- 885cdf0e10cSrcweir * 886cdf0e10cSrcweir * --------------------------------------------------*/ 887cdf0e10cSrcweir void SwZoomBox_Impl::ReleaseFocus() 888cdf0e10cSrcweir { 889cdf0e10cSrcweir if ( !bRelease ) 890cdf0e10cSrcweir { 891cdf0e10cSrcweir bRelease = sal_True; 892cdf0e10cSrcweir return; 893cdf0e10cSrcweir } 894cdf0e10cSrcweir SfxViewShell* pCurSh = SfxViewShell::Current(); 895cdf0e10cSrcweir 896cdf0e10cSrcweir if ( pCurSh ) 897cdf0e10cSrcweir { 898cdf0e10cSrcweir Window* pShellWnd = pCurSh->GetWindow(); 899cdf0e10cSrcweir 900cdf0e10cSrcweir if ( pShellWnd ) 901cdf0e10cSrcweir pShellWnd->GrabFocus(); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir } 904cdf0e10cSrcweir 905cdf0e10cSrcweir /* -----------------26.11.2002 09:29----------------- 906cdf0e10cSrcweir * 907cdf0e10cSrcweir * --------------------------------------------------*/ 908cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl, SfxUInt16Item); 909cdf0e10cSrcweir 910cdf0e10cSrcweir SwPreviewZoomControl::SwPreviewZoomControl( 911cdf0e10cSrcweir sal_uInt16 nSlotId, 912cdf0e10cSrcweir sal_uInt16 nId, 913cdf0e10cSrcweir ToolBox& rTbx) : 914cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ) 915cdf0e10cSrcweir { 916cdf0e10cSrcweir } 917cdf0e10cSrcweir /* -----------------26.11.2002 09:29----------------- 918cdf0e10cSrcweir * 919cdf0e10cSrcweir * --------------------------------------------------*/ 920cdf0e10cSrcweir SwPreviewZoomControl::~SwPreviewZoomControl() 921cdf0e10cSrcweir { 922cdf0e10cSrcweir } 923cdf0e10cSrcweir /* -----------------26.11.2002 09:29----------------- 924cdf0e10cSrcweir * 925cdf0e10cSrcweir * --------------------------------------------------*/ 926cdf0e10cSrcweir void SwPreviewZoomControl::StateChanged( sal_uInt16 /*nSID*/, 927cdf0e10cSrcweir SfxItemState eState, 928cdf0e10cSrcweir const SfxPoolItem* pState ) 929cdf0e10cSrcweir { 930cdf0e10cSrcweir sal_uInt16 nId = GetId(); 931cdf0e10cSrcweir GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) ); 932cdf0e10cSrcweir SwZoomBox_Impl* pBox = (SwZoomBox_Impl*)GetToolBox().GetItemWindow( GetId() ); 933cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE <= eState) 934cdf0e10cSrcweir { 935cdf0e10cSrcweir String sZoom(String::CreateFromInt32(((const SfxUInt16Item*)pState)->GetValue())); 936cdf0e10cSrcweir sZoom += '%'; 937cdf0e10cSrcweir pBox->SetText(sZoom); 938cdf0e10cSrcweir pBox->SaveValue(); 939cdf0e10cSrcweir } 940cdf0e10cSrcweir } 941cdf0e10cSrcweir /* -----------------26.11.2002 09:29----------------- 942cdf0e10cSrcweir * 943cdf0e10cSrcweir * --------------------------------------------------*/ 944cdf0e10cSrcweir Window* SwPreviewZoomControl::CreateItemWindow( Window *pParent ) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir SwZoomBox_Impl* pRet = new SwZoomBox_Impl( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY )); 947cdf0e10cSrcweir return pRet; 948cdf0e10cSrcweir } 949