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