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 22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 23cdf0e10cSrcweir #include "precompiled_sw.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <crsskip.hxx> 26cdf0e10cSrcweir #include <hintids.hxx> //_immer_ vor den solar-Items 27cdf0e10cSrcweir #include <sfx2/lnkbase.hxx> 28cdf0e10cSrcweir #include <fmtfld.hxx> 29cdf0e10cSrcweir #include <tools/urlobj.hxx> 30cdf0e10cSrcweir #include <vcl/msgbox.hxx> 31cdf0e10cSrcweir #include <svl/itempool.hxx> 32cdf0e10cSrcweir #include <unotools/useroptions.hxx> 33cdf0e10cSrcweir #include <svl/whiter.hxx> 34cdf0e10cSrcweir #include <svl/eitem.hxx> 35cdf0e10cSrcweir #include <svl/macitem.hxx> 36cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 37cdf0e10cSrcweir #include <sfx2/request.hxx> 38cdf0e10cSrcweir #include <svx/postattr.hxx> 39cdf0e10cSrcweir #include <svx/hlnkitem.hxx> 40cdf0e10cSrcweir #include <svx/svxdlg.hxx> 41cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 42cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx> 43cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 44cdf0e10cSrcweir #include <fmtinfmt.hxx> 45cdf0e10cSrcweir #include <fldwrap.hxx> 46cdf0e10cSrcweir #include <redline.hxx> 47cdf0e10cSrcweir #include <view.hxx> 48cdf0e10cSrcweir #include <wrtsh.hxx> 49cdf0e10cSrcweir #include <basesh.hxx> 50cdf0e10cSrcweir #include <wrtsh.hxx> 51cdf0e10cSrcweir #include <flddat.hxx> 52cdf0e10cSrcweir #include <numrule.hxx> 53cdf0e10cSrcweir #include <textsh.hxx> 54cdf0e10cSrcweir #include <docsh.hxx> 55cdf0e10cSrcweir #include <docufld.hxx> 56cdf0e10cSrcweir #include <usrfld.hxx> 57cdf0e10cSrcweir #include <ddefld.hxx> 58cdf0e10cSrcweir #include <expfld.hxx> 59cdf0e10cSrcweir #include <fldmgr.hxx> 60cdf0e10cSrcweir #include <uitool.hxx> 61cdf0e10cSrcweir #include <cmdid.h> 62cdf0e10cSrcweir #include <shells.hrc> 63cdf0e10cSrcweir #include <sfx2/app.hxx> 64cdf0e10cSrcweir #include <svx/svxdlg.hxx> 65cdf0e10cSrcweir #include <svx/dialogs.hrc> 66cdf0e10cSrcweir #include "swabstdlg.hxx" 67cdf0e10cSrcweir #include "dialog.hrc" 68cdf0e10cSrcweir #include <fldui.hrc> 69cdf0e10cSrcweir #include <doc.hxx> 70cdf0e10cSrcweir #include <app.hrc> 71*4e0030b2SArmin Le Grand #include <edtwin.hxx> 72cdf0e10cSrcweir #include <PostItMgr.hxx> 73cdf0e10cSrcweir #include <switerator.hxx> 74cdf0e10cSrcweir 75cdf0e10cSrcweir using namespace nsSwDocInfoSubType; 76cdf0e10cSrcweir 77cdf0e10cSrcweir extern sal_Bool bNoInterrupt; // in mainwn.cxx 78cdf0e10cSrcweir 79cdf0e10cSrcweir String& lcl_AppendRedlineStr( String& rStr, sal_uInt16 nRedlId ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir sal_uInt16 nResId = 0; 82cdf0e10cSrcweir switch( nRedlId ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir case nsRedlineType_t::REDLINE_INSERT: nResId = STR_REDLINE_INSERTED; break; 85cdf0e10cSrcweir case nsRedlineType_t::REDLINE_DELETE: nResId = STR_REDLINE_DELETED; break; 86cdf0e10cSrcweir case nsRedlineType_t::REDLINE_FORMAT: nResId = STR_REDLINE_FORMATED; break; 87cdf0e10cSrcweir case nsRedlineType_t::REDLINE_TABLE: nResId = STR_REDLINE_TABLECHG; break; 88cdf0e10cSrcweir case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLLSET; break; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir if( nResId ) 91cdf0e10cSrcweir rStr += SW_RESSTR( nResId ); 92cdf0e10cSrcweir return rStr; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir // STATIC DATA ----------------------------------------------------------- 96cdf0e10cSrcweir 97cdf0e10cSrcweir void SwTextShell::ExecField(SfxRequest &rReq) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 100cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 101cdf0e10cSrcweir 102cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 103cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 104cdf0e10cSrcweir if(pArgs) 105cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem); 106cdf0e10cSrcweir 107cdf0e10cSrcweir Window *pMDI = &GetView().GetViewFrame()->GetWindow(); 108cdf0e10cSrcweir sal_Bool bMore = sal_False; 109cdf0e10cSrcweir sal_Bool bIsText = sal_True; 110cdf0e10cSrcweir sal_uInt16 nInsertType = 0; 111cdf0e10cSrcweir sal_uInt16 nInsertSubType = 0; 112cdf0e10cSrcweir sal_uLong nInsertFormat = 0; 113cdf0e10cSrcweir 114cdf0e10cSrcweir switch(nSlot) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir case FN_EDIT_FIELD: 117cdf0e10cSrcweir { 118cdf0e10cSrcweir SwField* pFld = rSh.GetCurFld(); 119cdf0e10cSrcweir if( pFld ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir switch ( pFld->GetTypeId() ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir case TYP_DDEFLD: 124cdf0e10cSrcweir { 125cdf0e10cSrcweir ::sfx2::SvBaseLink& rLink = ((SwDDEFieldType*)pFld->GetTyp())-> 126cdf0e10cSrcweir GetBaseLink(); 127cdf0e10cSrcweir if(rLink.IsVisible()) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 130cdf0e10cSrcweir SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pMDI, &rSh.GetLinkManager(), sal_False, &rLink ); 131cdf0e10cSrcweir if ( pDlg ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir pDlg->Execute(); 134cdf0e10cSrcweir delete pDlg; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir } 137cdf0e10cSrcweir break; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir default: 140cdf0e10cSrcweir { 141cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 142cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 143cdf0e10cSrcweir 144cdf0e10cSrcweir SfxAbstractDialog* pDlg = pFact->CreateSwFldEditDlg( GetView(),RC_DLG_SWFLDEDITDLG ); 145cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 146cdf0e10cSrcweir pDlg->Execute(); 147cdf0e10cSrcweir delete pDlg; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir } 151cdf0e10cSrcweir break; 152cdf0e10cSrcweir } 153cdf0e10cSrcweir case FN_EXECUTE_MACROFIELD: 154cdf0e10cSrcweir { 155cdf0e10cSrcweir SwField* pFld = rSh.GetCurFld(); 156cdf0e10cSrcweir if(pFld && pFld->GetTyp()->Which() == RES_MACROFLD) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir 159cdf0e10cSrcweir const String& rMacro = ((SwMacroField*)pFld)->GetMacro(); 160cdf0e10cSrcweir sal_uInt16 nPos = rMacro.Search('.', 0); 161cdf0e10cSrcweir if(nPos != STRING_NOTFOUND) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir SvxMacro aMacro( rMacro.Copy(nPos + 1), rMacro.Copy(0,nPos), STARBASIC ); 164cdf0e10cSrcweir rSh.ExecMacro(aMacro); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir } 167cdf0e10cSrcweir } 168cdf0e10cSrcweir break; 169cdf0e10cSrcweir 170cdf0e10cSrcweir case FN_GOTO_NEXT_INPUTFLD: 171cdf0e10cSrcweir case FN_GOTO_PREV_INPUTFLD: 172cdf0e10cSrcweir { 173cdf0e10cSrcweir sal_Bool bRet = sal_False; 174cdf0e10cSrcweir SwFieldType* pFld = rSh.GetFldType( 0, RES_INPUTFLD ); 175cdf0e10cSrcweir if( pFld && rSh.MoveFldType( pFld, 176cdf0e10cSrcweir FN_GOTO_NEXT_INPUTFLD == nSlot )) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir rSh.ClearMark(); 179cdf0e10cSrcweir rSh.StartInputFldDlg( rSh.GetCurFld(), sal_False ); 180cdf0e10cSrcweir bRet = sal_True; 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir rReq.SetReturnValue( SfxBoolItem( nSlot, bRet )); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir break; 186cdf0e10cSrcweir 187cdf0e10cSrcweir default: 188cdf0e10cSrcweir bMore = sal_True; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir if(bMore) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir // hier kommen die Slots mit FldMgr 193cdf0e10cSrcweir SwFldMgr aFldMgr(GetShellPtr()); 194cdf0e10cSrcweir switch(nSlot) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir case FN_INSERT_DBFIELD: 197cdf0e10cSrcweir { 198cdf0e10cSrcweir sal_Bool bRes = sal_False; 199cdf0e10cSrcweir if( pItem ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir sal_uLong nFormat = 0; 202cdf0e10cSrcweir sal_uInt16 nType = 0; 203cdf0e10cSrcweir String aPar1 = ((SfxStringItem *)pItem)->GetValue(); 204cdf0e10cSrcweir String aPar2; 205cdf0e10cSrcweir sal_Int32 nCommand = 0; 206cdf0e10cSrcweir 207cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, 208cdf0e10cSrcweir sal_False, &pItem )) 209cdf0e10cSrcweir nType = ((SfxUInt16Item *)pItem)->GetValue(); 210cdf0e10cSrcweir aPar1 += DB_DELIM; 211cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 212cdf0e10cSrcweir FN_PARAM_1, sal_False, &pItem )) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir aPar1 += ((SfxStringItem *)pItem)->GetValue(); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 217cdf0e10cSrcweir FN_PARAM_3, sal_False, &pItem )) 218cdf0e10cSrcweir nCommand = ((SfxInt32Item*)pItem)->GetValue(); 219cdf0e10cSrcweir aPar1 += DB_DELIM; 220cdf0e10cSrcweir aPar1 += String::CreateFromInt32(nCommand); 221cdf0e10cSrcweir aPar1 += DB_DELIM; 222cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 223cdf0e10cSrcweir FN_PARAM_2, sal_False, &pItem )) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir aPar1 += ((SfxStringItem *)pItem)->GetValue(); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 228cdf0e10cSrcweir FN_PARAM_FIELD_CONTENT, sal_False, &pItem )) 229cdf0e10cSrcweir aPar2 = ((SfxStringItem *)pItem)->GetValue(); 230cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 231cdf0e10cSrcweir FN_PARAM_FIELD_FORMAT, sal_False, &pItem )) 232cdf0e10cSrcweir nFormat = ((SfxUInt32Item *)pItem)->GetValue(); 233cdf0e10cSrcweir DBG_WARNING("Command is not yet used"); 234cdf0e10cSrcweir sal_Unicode cSeparator = ' '; 235cdf0e10cSrcweir SwInsertFld_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator ); 236cdf0e10cSrcweir bRes = aFldMgr.InsertFld(aData); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir break; 241cdf0e10cSrcweir case FN_INSERT_FIELD_CTRL: 242cdf0e10cSrcweir case FN_INSERT_FIELD: 243cdf0e10cSrcweir { 244cdf0e10cSrcweir sal_Bool bRes = sal_False; 245cdf0e10cSrcweir if( pItem && nSlot != FN_INSERT_FIELD_CTRL) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir sal_uLong nFormat = 0; 248cdf0e10cSrcweir sal_uInt16 nType = 0; 249cdf0e10cSrcweir sal_uInt16 nSubType = 0; 250cdf0e10cSrcweir String aPar1 = ((SfxStringItem *)pItem)->GetValue(); 251cdf0e10cSrcweir String aPar2; 252cdf0e10cSrcweir sal_Unicode cSeparator = ' '; 253cdf0e10cSrcweir 254cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, 255cdf0e10cSrcweir sal_False, &pItem )) 256cdf0e10cSrcweir nType = ((SfxUInt16Item *)pItem)->GetValue(); 257cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE, 258cdf0e10cSrcweir sal_False, &pItem )) 259cdf0e10cSrcweir nSubType = ((SfxUInt16Item *)pItem)->GetValue(); 260cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 261cdf0e10cSrcweir FN_PARAM_FIELD_CONTENT, sal_False, &pItem )) 262cdf0e10cSrcweir aPar2 = ((SfxStringItem *)pItem)->GetValue(); 263cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 264cdf0e10cSrcweir FN_PARAM_FIELD_FORMAT, sal_False, &pItem )) 265cdf0e10cSrcweir nFormat = ((SfxUInt32Item *)pItem)->GetValue(); 266cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( 267cdf0e10cSrcweir FN_PARAM_3, sal_False, &pItem )) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir String sTmp = ((SfxStringItem *)pItem)->GetValue(); 270cdf0e10cSrcweir if(sTmp.Len()) 271cdf0e10cSrcweir cSeparator = sTmp.GetChar(0); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir SwInsertFld_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator ); 274cdf0e10cSrcweir bRes = aFldMgr.InsertFld( aData ); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir else 277cdf0e10cSrcweir //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active 278cdf0e10cSrcweir if(!GetView().GetViewFrame()->IsInModalMode()) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 281cdf0e10cSrcweir pVFrame->ToggleChildWindow(FN_INSERT_FIELD); 282cdf0e10cSrcweir bRes = pVFrame->GetChildWindow( nSlot ) != 0; 283cdf0e10cSrcweir Invalidate(rReq.GetSlot()); 284cdf0e10cSrcweir Invalidate(FN_INSERT_FIELD_CTRL); 285cdf0e10cSrcweir rReq.Ignore(); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir break; 290cdf0e10cSrcweir 291cdf0e10cSrcweir case FN_INSERT_REF_FIELD: 292cdf0e10cSrcweir { 293cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 294cdf0e10cSrcweir if (!pVFrame->HasChildWindow(FN_INSERT_FIELD)) 295cdf0e10cSrcweir pVFrame->ToggleChildWindow(FN_INSERT_FIELD); // Dialog anzeigen 296cdf0e10cSrcweir 297cdf0e10cSrcweir // Flddlg auf neue TabPage umschalten 298cdf0e10cSrcweir sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId(); 299cdf0e10cSrcweir SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId); 300cdf0e10cSrcweir if (pWrp) 301cdf0e10cSrcweir pWrp->ShowPage(); 302cdf0e10cSrcweir rReq.Ignore(); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir break; 305cdf0e10cSrcweir case FN_DELETE_COMMENT: 306cdf0e10cSrcweir if ( GetView().GetPostItMgr() && 307cdf0e10cSrcweir GetView().GetPostItMgr()->HasActiveSidebarWin() ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir GetView().GetPostItMgr()->DeleteActiveSidebarWin(); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir break; 312cdf0e10cSrcweir case FN_DELETE_ALL_NOTES: 313cdf0e10cSrcweir if ( GetView().GetPostItMgr() ) 314cdf0e10cSrcweir GetView().GetPostItMgr()->Delete(); 315cdf0e10cSrcweir break; 316cdf0e10cSrcweir case FN_DELETE_NOTE_AUTHOR: 317cdf0e10cSrcweir { 318cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, sal_False); 319cdf0e10cSrcweir if ( pNoteItem && GetView().GetPostItMgr() ) 320cdf0e10cSrcweir GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() ); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir break; 323cdf0e10cSrcweir case FN_HIDE_NOTE: 324cdf0e10cSrcweir if ( GetView().GetPostItMgr() && 325cdf0e10cSrcweir GetView().GetPostItMgr()->HasActiveSidebarWin() ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir GetView().GetPostItMgr()->HideActiveSidebarWin(); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir break; 330cdf0e10cSrcweir case FN_HIDE_ALL_NOTES: 331cdf0e10cSrcweir if ( GetView().GetPostItMgr() ) 332cdf0e10cSrcweir GetView().GetPostItMgr()->Hide(); 333cdf0e10cSrcweir break; 334cdf0e10cSrcweir case FN_HIDE_NOTE_AUTHOR: 335cdf0e10cSrcweir { 336cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, sal_False); 337cdf0e10cSrcweir if ( pNoteItem && GetView().GetPostItMgr() ) 338cdf0e10cSrcweir GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() ); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir break; 341cdf0e10cSrcweir case FN_POSTIT: 342cdf0e10cSrcweir { 343cdf0e10cSrcweir SwPostItField* pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); 344cdf0e10cSrcweir sal_Bool bNew = !(pPostIt && pPostIt->GetTyp()->Which() == RES_POSTITFLD); 345cdf0e10cSrcweir if (bNew || GetView().GetPostItMgr()->IsAnswer()) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir SvtUserOptions aUserOpt; 348cdf0e10cSrcweir String sAuthor; 349cdf0e10cSrcweir if( !(sAuthor = aUserOpt.GetFullName()).Len()) 350cdf0e10cSrcweir if( !(sAuthor = aUserOpt.GetID()).Len() ) 351cdf0e10cSrcweir sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); 352cdf0e10cSrcweir if( rSh.HasSelection() ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir rSh.NormalizePam(true); 355cdf0e10cSrcweir rSh.KillPams(); 356cdf0e10cSrcweir rSh.ClearMark(); 357cdf0e10cSrcweir } 358*4e0030b2SArmin Le Grand 359*4e0030b2SArmin Le Grand // #120513# Inserting a comment into an autocompletion crashes 360*4e0030b2SArmin Le Grand // --> suggestion has to be removed before 361*4e0030b2SArmin Le Grand GetView().GetEditWin().StopQuickHelp(); 362*4e0030b2SArmin Le Grand 363cdf0e10cSrcweir SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0); 364cdf0e10cSrcweir aFldMgr.InsertFld(aData); 365cdf0e10cSrcweir rSh.Push(); 366cdf0e10cSrcweir rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False); 367cdf0e10cSrcweir pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); 368cdf0e10cSrcweir rSh.Pop(sal_False); // Cursorpos restaurieren 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir if (pPostIt) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir SwFieldType* pType = rSh.GetDoc()->GetFldType(RES_POSTITFLD, aEmptyStr,false); 374cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *pType ); 375cdf0e10cSrcweir SwFmtFld* pSwFmtFld = aIter.First(); 376cdf0e10cSrcweir while( pSwFmtFld ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir if ( pSwFmtFld->GetFld() == pPostIt ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) ); 381cdf0e10cSrcweir break; 382cdf0e10cSrcweir } 383cdf0e10cSrcweir pSwFmtFld = aIter.Next(); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir } 387cdf0e10cSrcweir break; 388cdf0e10cSrcweir case FN_REDLINE_COMMENT: 389cdf0e10cSrcweir { 390cdf0e10cSrcweir /* this code can be used once we want redline comments in the margin, all other stuff can 391cdf0e10cSrcweir then be deleted 392cdf0e10cSrcweir String sComment; 393cdf0e10cSrcweir const SwRedline *pRedline = rSh.GetCurrRedline(); 394cdf0e10cSrcweir 395cdf0e10cSrcweir if (pRedline) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir sComment = pRedline->GetComment(); 398cdf0e10cSrcweir if ( sComment == String(rtl::OUString::createFromAscii("")) ) 399cdf0e10cSrcweir GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); 400cdf0e10cSrcweir const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir */ 403cdf0e10cSrcweir 404cdf0e10cSrcweir String sComment; 405cdf0e10cSrcweir const SwRedline *pRedline = rSh.GetCurrRedline(); 406cdf0e10cSrcweir 407cdf0e10cSrcweir if (pRedline) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir sComment = pRedline->GetComment(); 410cdf0e10cSrcweir 411cdf0e10cSrcweir 412cdf0e10cSrcweir sal_Bool bTravel = sal_False; 413cdf0e10cSrcweir 414cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 415cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 416cdf0e10cSrcweir ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT ); 417cdf0e10cSrcweir DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()"); 418cdf0e10cSrcweir SfxItemSet aSet(GetPool(), fnGetRange()); 419cdf0e10cSrcweir aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT)); 420cdf0e10cSrcweir aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); 421cdf0e10cSrcweir 422cdf0e10cSrcweir aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString( 423cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() ), 424cdf0e10cSrcweir SID_ATTR_POSTIT_DATE )); 425cdf0e10cSrcweir 426cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 427cdf0e10cSrcweir rSh.StartAction(); 428cdf0e10cSrcweir 429cdf0e10cSrcweir rSh.Push(); 430cdf0e10cSrcweir const SwRedline *pActRed = rSh.SelPrevRedline(); 431cdf0e10cSrcweir 432cdf0e10cSrcweir if (pActRed == pRedline) 433cdf0e10cSrcweir { // Neuer Cursor steht am Anfang des Current Redlines 434cdf0e10cSrcweir rSh.Pop(); // Alten Cursor wegwerfen 435cdf0e10cSrcweir rSh.Push(); 436cdf0e10cSrcweir pActRed = rSh.SelPrevRedline(); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir 439cdf0e10cSrcweir sal_Bool bPrev = pActRed != 0; 440cdf0e10cSrcweir rSh.Pop(sal_False); 441cdf0e10cSrcweir rSh.EndAction(); 442cdf0e10cSrcweir 443cdf0e10cSrcweir rSh.ClearMark(); 444cdf0e10cSrcweir rSh.SelNextRedline(); // Aktueller Redline wird selektiert 445cdf0e10cSrcweir 446cdf0e10cSrcweir rSh.StartAction(); 447cdf0e10cSrcweir rSh.Push(); 448cdf0e10cSrcweir pActRed = rSh.SelNextRedline(); 449cdf0e10cSrcweir sal_Bool bNext = pActRed != 0; 450cdf0e10cSrcweir rSh.Pop(sal_False); // Cursorpos restaurieren 451cdf0e10cSrcweir 452cdf0e10cSrcweir if( rSh.IsCrsrPtAtEnd() ) 453cdf0e10cSrcweir rSh.SwapPam(); 454cdf0e10cSrcweir 455cdf0e10cSrcweir rSh.EndAction(); 456cdf0e10cSrcweir 457cdf0e10cSrcweir bTravel |= bNext|bPrev; 458cdf0e10cSrcweir 459cdf0e10cSrcweir SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create(); 460cdf0e10cSrcweir DBG_ASSERT(pFact2, "Dialogdiet fail!"); 461cdf0e10cSrcweir AbstractSvxPostItDialog* pDlg = pFact2->CreateSvxPostItDialog( pMDI, aSet, bTravel, sal_True ); 462cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 463cdf0e10cSrcweir pDlg->HideAuthor(); 464cdf0e10cSrcweir 465cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT)); 466cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); 467cdf0e10cSrcweir 468cdf0e10cSrcweir pDlg->SetText(sTitle); 469cdf0e10cSrcweir 470cdf0e10cSrcweir if (bTravel) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir pDlg->EnableTravel(bNext, bPrev); 473cdf0e10cSrcweir pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl)); 474cdf0e10cSrcweir pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl)); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir rSh.SetCareWin(pDlg->GetWindow()); 478cdf0e10cSrcweir bNoInterrupt = sal_True; 479cdf0e10cSrcweir 480cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 483cdf0e10cSrcweir String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); 484cdf0e10cSrcweir 485cdf0e10cSrcweir // Kommentar einfuegen bzw aendern 486cdf0e10cSrcweir rSh.SetRedlineComment(sMsg); 487cdf0e10cSrcweir } 488cdf0e10cSrcweir 489cdf0e10cSrcweir delete pDlg; 490cdf0e10cSrcweir rSh.SetCareWin(NULL); 491cdf0e10cSrcweir bNoInterrupt = sal_False; 492cdf0e10cSrcweir rSh.ClearMark(); 493cdf0e10cSrcweir GetView().AttrChangedNotify(GetShellPtr()); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir } 496cdf0e10cSrcweir break; 497cdf0e10cSrcweir 498cdf0e10cSrcweir case FN_JAVAEDIT: 499cdf0e10cSrcweir { 500cdf0e10cSrcweir String aType, aText; 501cdf0e10cSrcweir sal_Bool bIsUrl=sal_False; 502cdf0e10cSrcweir sal_Bool bNew=sal_False, bUpdate=sal_False; 503cdf0e10cSrcweir SwFldMgr* pMgr = new SwFldMgr; 504cdf0e10cSrcweir if ( pItem ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir aText = ((SfxStringItem*)pItem)->GetValue(); 507cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pType, SfxStringItem, FN_PARAM_2 , sal_False ); 508cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pIsUrl, SfxBoolItem, FN_PARAM_1 , sal_False ); 509cdf0e10cSrcweir if ( pType ) 510cdf0e10cSrcweir aType = pType->GetValue(); 511cdf0e10cSrcweir if ( pIsUrl ) 512cdf0e10cSrcweir bIsUrl = pIsUrl->GetValue(); 513cdf0e10cSrcweir 514cdf0e10cSrcweir SwScriptField* pFld = (SwScriptField*)pMgr->GetCurFld(); 515cdf0e10cSrcweir bNew = !pFld || !(pFld->GetTyp()->Which() == RES_SCRIPTFLD); 516cdf0e10cSrcweir bUpdate = pFld && ( bIsUrl != pFld->GetFormat() || pFld->GetPar2() != aType || pFld->GetPar1() != aText ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir else 519cdf0e10cSrcweir { 520cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 521cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 522cdf0e10cSrcweir AbstractJavaEditDialog* pDlg = pFact->CreateJavaEditDialog( DLG_JAVAEDIT, 523cdf0e10cSrcweir pMDI, &rSh); 524cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 525cdf0e10cSrcweir if ( pDlg->Execute() ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir aType = pDlg->GetType(); 528cdf0e10cSrcweir aText = pDlg->GetText(); 529cdf0e10cSrcweir bIsUrl = pDlg->IsUrl(); 530cdf0e10cSrcweir bNew = pDlg->IsNew(); 531cdf0e10cSrcweir bUpdate = pDlg->IsUpdate(); 532cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) ); 533cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) ); 534cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) ); 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir delete pDlg; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir if( bNew ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir SwInsertFld_Data aData(TYP_SCRIPTFLD, 0, aType, aText, bIsUrl); 543cdf0e10cSrcweir pMgr->InsertFld(aData); 544cdf0e10cSrcweir rReq.Done(); 545cdf0e10cSrcweir } 546cdf0e10cSrcweir else if( bUpdate ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir pMgr->UpdateCurFld( bIsUrl, aType, aText ); 549cdf0e10cSrcweir rSh.SetUndoNoResetModified(); 550cdf0e10cSrcweir rReq.Done(); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir else 553cdf0e10cSrcweir rReq.Ignore(); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir break; 556cdf0e10cSrcweir 557cdf0e10cSrcweir case FN_INSERT_FLD_DATE : 558cdf0e10cSrcweir nInsertType = TYP_DATEFLD; 559cdf0e10cSrcweir bIsText = sal_False; 560cdf0e10cSrcweir goto FIELD_INSERT; 561cdf0e10cSrcweir case FN_INSERT_FLD_TIME : 562cdf0e10cSrcweir nInsertType = TYP_TIMEFLD; 563cdf0e10cSrcweir bIsText = sal_False; 564cdf0e10cSrcweir goto FIELD_INSERT; 565cdf0e10cSrcweir case FN_INSERT_FLD_PGNUMBER: 566cdf0e10cSrcweir nInsertType = TYP_PAGENUMBERFLD; 567cdf0e10cSrcweir nInsertFormat = SVX_NUM_PAGEDESC; // wie Seitenvorlage 568cdf0e10cSrcweir bIsText = sal_False; 569cdf0e10cSrcweir goto FIELD_INSERT; 570cdf0e10cSrcweir case FN_INSERT_FLD_PGCOUNT : 571cdf0e10cSrcweir nInsertType = TYP_DOCSTATFLD; 572cdf0e10cSrcweir nInsertSubType = 0; 573cdf0e10cSrcweir bIsText = sal_False; 574cdf0e10cSrcweir nInsertFormat = SVX_NUM_PAGEDESC; 575cdf0e10cSrcweir goto FIELD_INSERT; 576cdf0e10cSrcweir case FN_INSERT_FLD_TOPIC : 577cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD; 578cdf0e10cSrcweir nInsertSubType = DI_THEMA; 579cdf0e10cSrcweir goto FIELD_INSERT; 580cdf0e10cSrcweir case FN_INSERT_FLD_TITLE : 581cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD; 582cdf0e10cSrcweir nInsertSubType = DI_TITEL; 583cdf0e10cSrcweir goto FIELD_INSERT; 584cdf0e10cSrcweir case FN_INSERT_FLD_AUTHOR : 585cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD; 586cdf0e10cSrcweir nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; 587cdf0e10cSrcweir 588cdf0e10cSrcweir FIELD_INSERT: 589cdf0e10cSrcweir { 590cdf0e10cSrcweir //format conversion should only be done for number formatter formats 591cdf0e10cSrcweir if(!nInsertFormat) 592cdf0e10cSrcweir nInsertFormat = aFldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter()); 593cdf0e10cSrcweir SwInsertFld_Data aData(nInsertType, nInsertSubType, 594cdf0e10cSrcweir aEmptyStr, aEmptyStr, nInsertFormat); 595cdf0e10cSrcweir aFldMgr.InsertFld(aData); 596cdf0e10cSrcweir rReq.Done(); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir break; 599cdf0e10cSrcweir default: 600cdf0e10cSrcweir ASSERT(sal_False, falscher Dispatcher); 601cdf0e10cSrcweir return; 602cdf0e10cSrcweir } 603cdf0e10cSrcweir } 604cdf0e10cSrcweir } 605cdf0e10cSrcweir 606cdf0e10cSrcweir void SwTextShell::StateField( SfxItemSet &rSet ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 609cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 610cdf0e10cSrcweir const SwField* pField = 0; 611cdf0e10cSrcweir int bGetField = sal_False; 612cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 613cdf0e10cSrcweir 614cdf0e10cSrcweir while (nWhich) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir switch (nWhich) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir case FN_DELETE_COMMENT: 619cdf0e10cSrcweir case FN_DELETE_NOTE_AUTHOR: 620cdf0e10cSrcweir case FN_DELETE_ALL_NOTES: 621cdf0e10cSrcweir case FN_HIDE_NOTE: 622cdf0e10cSrcweir case FN_HIDE_NOTE_AUTHOR: 623cdf0e10cSrcweir case FN_HIDE_ALL_NOTES: 624cdf0e10cSrcweir { 625cdf0e10cSrcweir SwPostItMgr* pPostItMgr = GetView().GetPostItMgr(); 626cdf0e10cSrcweir if ( !pPostItMgr ) 627cdf0e10cSrcweir rSet.InvalidateItem( nWhich ); 628cdf0e10cSrcweir else if ( !pPostItMgr->HasActiveSidebarWin() ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir rSet.InvalidateItem( FN_DELETE_COMMENT ); 631cdf0e10cSrcweir rSet.InvalidateItem( FN_HIDE_NOTE ); 632cdf0e10cSrcweir } 633cdf0e10cSrcweir } 634cdf0e10cSrcweir break; 635cdf0e10cSrcweir case FN_EDIT_FIELD: 636cdf0e10cSrcweir { 637cdf0e10cSrcweir /* #108536# Fields can be selected, too now. Removed 638cdf0e10cSrcweir 639cdf0e10cSrcweir if( rSh.HasSelection() ) 640cdf0e10cSrcweir rSet.DisableItem(nWhich); 641cdf0e10cSrcweir else ... 642cdf0e10cSrcweir */ 643cdf0e10cSrcweir 644cdf0e10cSrcweir if( !bGetField ) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir pField = rSh.GetCurFld(); 647cdf0e10cSrcweir bGetField = sal_True; 648cdf0e10cSrcweir } 649cdf0e10cSrcweir 650cdf0e10cSrcweir sal_uInt16 nTempWhich = pField ? pField->GetTyp()->Which() : USHRT_MAX; 651cdf0e10cSrcweir if( USHRT_MAX == nTempWhich || 652cdf0e10cSrcweir RES_POSTITFLD == nTempWhich || 653cdf0e10cSrcweir RES_SCRIPTFLD == nTempWhich || 654cdf0e10cSrcweir RES_AUTHORITY == nTempWhich ) 655cdf0e10cSrcweir rSet.DisableItem( nWhich ); 656cdf0e10cSrcweir else if( RES_DDEFLD == nTempWhich && 657cdf0e10cSrcweir !((SwDDEFieldType*)pField->GetTyp())->GetBaseLink().IsVisible()) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir // nested links cannot be edited 660cdf0e10cSrcweir rSet.DisableItem( nWhich ); 661cdf0e10cSrcweir } 662cdf0e10cSrcweir } 663cdf0e10cSrcweir break; 664cdf0e10cSrcweir case FN_EXECUTE_MACROFIELD: 665cdf0e10cSrcweir { 666cdf0e10cSrcweir if(!bGetField) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir pField = rSh.GetCurFld(); 669cdf0e10cSrcweir bGetField = sal_True; 670cdf0e10cSrcweir } 671cdf0e10cSrcweir if(!pField || pField->GetTyp()->Which() != RES_MACROFLD) 672cdf0e10cSrcweir rSet.DisableItem(nWhich); 673cdf0e10cSrcweir } 674cdf0e10cSrcweir break; 675cdf0e10cSrcweir 676cdf0e10cSrcweir case FN_INSERT_FIELD: 677cdf0e10cSrcweir { 678cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 679cdf0e10cSrcweir //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active 680cdf0e10cSrcweir if(!pVFrame->IsInModalMode() && 681cdf0e10cSrcweir pVFrame->KnowsChildWindow(FN_INSERT_FIELD) && !pVFrame->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY) ) 682cdf0e10cSrcweir rSet.Put(SfxBoolItem( FN_INSERT_FIELD, pVFrame->HasChildWindow(nWhich))); 683cdf0e10cSrcweir else 684cdf0e10cSrcweir rSet.DisableItem(FN_INSERT_FIELD); 685cdf0e10cSrcweir } 686cdf0e10cSrcweir break; 687cdf0e10cSrcweir case FN_INSERT_REF_FIELD: 688cdf0e10cSrcweir { 689cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 690cdf0e10cSrcweir if (!pVFrame->KnowsChildWindow(FN_INSERT_FIELD)) 691cdf0e10cSrcweir rSet.DisableItem(FN_INSERT_REF_FIELD); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir break; 694cdf0e10cSrcweir case FN_INSERT_FIELD_CTRL: 695cdf0e10cSrcweir rSet.Put(SfxBoolItem( nWhich, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD))); 696cdf0e10cSrcweir break; 697cdf0e10cSrcweir case FN_REDLINE_COMMENT: 698cdf0e10cSrcweir if (!rSh.GetCurrRedline()) 699cdf0e10cSrcweir rSet.DisableItem(nWhich); 700cdf0e10cSrcweir break; 701cdf0e10cSrcweir case FN_POSTIT : 702cdf0e10cSrcweir case FN_JAVAEDIT : 703cdf0e10cSrcweir sal_Bool bCurField = sal_False; 704cdf0e10cSrcweir pField = rSh.GetCurFld(); 705cdf0e10cSrcweir if(nWhich == FN_POSTIT) 706cdf0e10cSrcweir bCurField = pField && pField->GetTyp()->Which() == RES_POSTITFLD; 707cdf0e10cSrcweir else 708cdf0e10cSrcweir bCurField = pField && pField->GetTyp()->Which() == RES_SCRIPTFLD; 709cdf0e10cSrcweir 710cdf0e10cSrcweir if(!bCurField && rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() ) 711cdf0e10cSrcweir rSet.DisableItem(nWhich); 712cdf0e10cSrcweir break; 713cdf0e10cSrcweir } 714cdf0e10cSrcweir nWhich = aIter.NextWhich(); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir /*--------------------------------------------------------------------------- 719cdf0e10cSrcweir Beschreibung: 720cdf0e10cSrcweir ----------------------------------------------------------------------------*/ 721cdf0e10cSrcweir 722cdf0e10cSrcweir 723cdf0e10cSrcweir void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem) 724cdf0e10cSrcweir { 725cdf0e10cSrcweir const String& rName = rHlnkItem.GetName(); 726cdf0e10cSrcweir const String& rURL = rHlnkItem.GetURL(); 727cdf0e10cSrcweir const String& rTarget = rHlnkItem.GetTargetFrame(); 728cdf0e10cSrcweir sal_uInt16 nType = (sal_uInt16)rHlnkItem.GetInsertMode(); 729cdf0e10cSrcweir nType &= ~HLINK_HTMLMODE; 730cdf0e10cSrcweir const SvxMacroTableDtor* pMacroTbl = rHlnkItem.GetMacroTbl(); 731cdf0e10cSrcweir 732cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 733cdf0e10cSrcweir 734cdf0e10cSrcweir if( rSh.GetSelectionType() & nsSelectionType::SEL_TXT ) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir rSh.StartAction(); 737cdf0e10cSrcweir SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); 738cdf0e10cSrcweir rSh.GetCurAttr( aSet ); 739cdf0e10cSrcweir 740cdf0e10cSrcweir const SfxPoolItem* pItem; 741cdf0e10cSrcweir if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False, &pItem)) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir // Links selektieren 744cdf0e10cSrcweir rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT, sal_False); 745cdf0e10cSrcweir } 746cdf0e10cSrcweir switch (nType) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir case HLINK_DEFAULT: 749cdf0e10cSrcweir case HLINK_FIELD: 750cdf0e10cSrcweir { 751cdf0e10cSrcweir SwFmtINetFmt aINetFmt( rURL, rTarget ); 752cdf0e10cSrcweir aINetFmt.SetName(rHlnkItem.GetIntName()); 753cdf0e10cSrcweir if(pMacroTbl) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir SvxMacro *pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOVER_OBJECT ); 756cdf0e10cSrcweir if( pMacro ) 757cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT, *pMacro); 758cdf0e10cSrcweir pMacro = pMacroTbl->Get( SFX_EVENT_MOUSECLICK_OBJECT ); 759cdf0e10cSrcweir if( pMacro ) 760cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT, *pMacro); 761cdf0e10cSrcweir pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOUT_OBJECT ); 762cdf0e10cSrcweir if( pMacro ) 763cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT, *pMacro); 764cdf0e10cSrcweir } 765cdf0e10cSrcweir rSh.SttSelect(); 766cdf0e10cSrcweir rSh.InsertURL( aINetFmt, rName, sal_True ); 767cdf0e10cSrcweir rSh.EndSelect(); 768cdf0e10cSrcweir } 769cdf0e10cSrcweir break; 770cdf0e10cSrcweir 771cdf0e10cSrcweir case HLINK_BUTTON: 772cdf0e10cSrcweir sal_Bool bSel = rSh.HasSelection(); 773cdf0e10cSrcweir if(bSel) 774cdf0e10cSrcweir rSh.DelRight(); 775cdf0e10cSrcweir InsertURLButton( rURL, rTarget, rName ); 776cdf0e10cSrcweir rSh.EnterStdMode(); 777cdf0e10cSrcweir break; 778cdf0e10cSrcweir } 779cdf0e10cSrcweir rSh.EndAction(); 780cdf0e10cSrcweir } 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog *, pBtn ) 784cdf0e10cSrcweir { 785cdf0e10cSrcweir SwWrtShell* pSh = GetShellPtr(); 786cdf0e10cSrcweir AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn; 787cdf0e10cSrcweir 788cdf0e10cSrcweir // Kommentar einfuegen bzw aendern 789cdf0e10cSrcweir pSh->SetRedlineComment(pDlg->GetNote()); 790cdf0e10cSrcweir 791cdf0e10cSrcweir const SwRedline *pRedline = pSh->GetCurrRedline(); 792cdf0e10cSrcweir 793cdf0e10cSrcweir String sComment; 794cdf0e10cSrcweir 795cdf0e10cSrcweir if (pRedline) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 798cdf0e10cSrcweir if( !pSh->IsCrsrPtAtEnd() ) 799cdf0e10cSrcweir pSh->SwapPam(); // Cursor hinter den Redline stellen 800cdf0e10cSrcweir 801cdf0e10cSrcweir pSh->Push(); 802cdf0e10cSrcweir const SwRedline *pActRed = pSh->SelNextRedline(); 803cdf0e10cSrcweir pSh->Pop(pActRed != 0); 804cdf0e10cSrcweir 805cdf0e10cSrcweir sal_Bool bEnable = sal_False; 806cdf0e10cSrcweir 807cdf0e10cSrcweir if (pActRed) 808cdf0e10cSrcweir { 809cdf0e10cSrcweir pSh->StartAction(); 810cdf0e10cSrcweir pSh->Push(); 811cdf0e10cSrcweir bEnable = pSh->SelNextRedline() != 0; 812cdf0e10cSrcweir pSh->Pop(sal_False); 813cdf0e10cSrcweir pSh->EndAction(); 814cdf0e10cSrcweir } 815cdf0e10cSrcweir 816cdf0e10cSrcweir pDlg->EnableTravel(bEnable, sal_True); 817cdf0e10cSrcweir 818cdf0e10cSrcweir if( pSh->IsCrsrPtAtEnd() ) 819cdf0e10cSrcweir pSh->SwapPam(); 820cdf0e10cSrcweir 821cdf0e10cSrcweir pRedline = pSh->GetCurrRedline(); 822cdf0e10cSrcweir sComment = pRedline->GetComment(); 823cdf0e10cSrcweir 824cdf0e10cSrcweir pDlg->SetNote( sComment.ConvertLineEnd() ); 825cdf0e10cSrcweir pDlg->ShowLastAuthor( pRedline->GetAuthorString(), 826cdf0e10cSrcweir GetAppLangDateTimeString( 827cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() )); 828cdf0e10cSrcweir 829cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT)); 830cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); 831cdf0e10cSrcweir 832cdf0e10cSrcweir pDlg->SetText(sTitle); 833cdf0e10cSrcweir } 834cdf0e10cSrcweir 835cdf0e10cSrcweir return 0; 836cdf0e10cSrcweir } 837cdf0e10cSrcweir 838cdf0e10cSrcweir IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn ) 839cdf0e10cSrcweir { 840cdf0e10cSrcweir SwWrtShell* pSh = GetShellPtr(); 841cdf0e10cSrcweir AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn; 842cdf0e10cSrcweir 843cdf0e10cSrcweir // Kommentar einfuegen bzw aendern 844cdf0e10cSrcweir pSh->SetRedlineComment(pDlg->GetNote()); 845cdf0e10cSrcweir 846cdf0e10cSrcweir const SwRedline *pRedline = pSh->GetCurrRedline(); 847cdf0e10cSrcweir 848cdf0e10cSrcweir String sComment; 849cdf0e10cSrcweir 850cdf0e10cSrcweir if (pRedline) 851cdf0e10cSrcweir { 852cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 853cdf0e10cSrcweir pSh->Push(); 854cdf0e10cSrcweir const SwRedline *pActRed = pSh->SelPrevRedline(); 855cdf0e10cSrcweir pSh->Pop(pActRed != 0); 856cdf0e10cSrcweir 857cdf0e10cSrcweir sal_Bool bEnable = sal_False; 858cdf0e10cSrcweir 859cdf0e10cSrcweir if (pActRed) 860cdf0e10cSrcweir { 861cdf0e10cSrcweir pSh->StartAction(); 862cdf0e10cSrcweir pSh->Push(); 863cdf0e10cSrcweir bEnable = pSh->SelPrevRedline() != 0; 864cdf0e10cSrcweir pSh->Pop(sal_False); 865cdf0e10cSrcweir pSh->EndAction(); 866cdf0e10cSrcweir } 867cdf0e10cSrcweir 868cdf0e10cSrcweir pDlg->EnableTravel(sal_True, bEnable); 869cdf0e10cSrcweir 870cdf0e10cSrcweir pRedline = pSh->GetCurrRedline(); 871cdf0e10cSrcweir sComment = pRedline->GetComment(); 872cdf0e10cSrcweir 873cdf0e10cSrcweir pDlg->SetNote(sComment.ConvertLineEnd()); 874cdf0e10cSrcweir pDlg->ShowLastAuthor(pRedline->GetAuthorString(), 875cdf0e10cSrcweir GetAppLangDateTimeString( 876cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() )); 877cdf0e10cSrcweir 878cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT)); 879cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); 880cdf0e10cSrcweir 881cdf0e10cSrcweir pDlg->SetText(sTitle); 882cdf0e10cSrcweir } 883cdf0e10cSrcweir 884cdf0e10cSrcweir return 0; 885cdf0e10cSrcweir } 886cdf0e10cSrcweir 887cdf0e10cSrcweir 888