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> 48*69a74367SOliver-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 ); 176*69a74367SOliver-Rainer Wittmann const bool bAddSetExpressionFlds = !( rSh.GetViewOptions()->IsReadonly() ); 177*69a74367SOliver-Rainer Wittmann if ( pFld != NULL 178*69a74367SOliver-Rainer Wittmann && rSh.MoveFldType( 179*69a74367SOliver-Rainer Wittmann pFld, 180*69a74367SOliver-Rainer Wittmann FN_GOTO_NEXT_INPUTFLD == nSlot, 181*69a74367SOliver-Rainer Wittmann USHRT_MAX, 182*69a74367SOliver-Rainer Wittmann bAddSetExpressionFlds ) ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir rSh.ClearMark(); 185*69a74367SOliver-Rainer Wittmann if ( dynamic_cast<SwInputField*>(rSh.GetCurFld( true )) != NULL ) 186*69a74367SOliver-Rainer Wittmann { 187*69a74367SOliver-Rainer Wittmann rSh.SttSelect(); 188*69a74367SOliver-Rainer Wittmann rSh.SelectTxt( 189*69a74367SOliver-Rainer Wittmann rSh.StartOfInputFldAtPos( *(rSh.GetCrsr()->Start()) ) + 1, 190*69a74367SOliver-Rainer Wittmann rSh.EndOfInputFldAtPos( *(rSh.GetCrsr()->Start()) ) - 1 ); 191*69a74367SOliver-Rainer Wittmann } 192*69a74367SOliver-Rainer Wittmann else 193*69a74367SOliver-Rainer Wittmann { 194*69a74367SOliver-Rainer Wittmann rSh.StartInputFldDlg( rSh.GetCurFld( true ), sal_False ); 195*69a74367SOliver-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; 357cdf0e10cSrcweir case FN_POSTIT: 358cdf0e10cSrcweir { 359*69a74367SOliver-Rainer Wittmann SwPostItField* pPostIt = dynamic_cast<SwPostItField*>(aFldMgr.GetCurFld()); 360cdf0e10cSrcweir sal_Bool bNew = !(pPostIt && pPostIt->GetTyp()->Which() == RES_POSTITFLD); 361cdf0e10cSrcweir if (bNew || GetView().GetPostItMgr()->IsAnswer()) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir SvtUserOptions aUserOpt; 364cdf0e10cSrcweir String sAuthor; 365cdf0e10cSrcweir if( !(sAuthor = aUserOpt.GetFullName()).Len()) 366cdf0e10cSrcweir if( !(sAuthor = aUserOpt.GetID()).Len() ) 367cdf0e10cSrcweir sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); 368cdf0e10cSrcweir if( rSh.HasSelection() ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir rSh.NormalizePam(true); 371cdf0e10cSrcweir rSh.KillPams(); 372cdf0e10cSrcweir rSh.ClearMark(); 373cdf0e10cSrcweir } 3744e0030b2SArmin Le Grand 3754e0030b2SArmin Le Grand // #120513# Inserting a comment into an autocompletion crashes 3764e0030b2SArmin Le Grand // --> suggestion has to be removed before 3774e0030b2SArmin Le Grand GetView().GetEditWin().StopQuickHelp(); 3784e0030b2SArmin Le Grand 379cdf0e10cSrcweir SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0); 380cdf0e10cSrcweir aFldMgr.InsertFld(aData); 381cdf0e10cSrcweir rSh.Push(); 382cdf0e10cSrcweir rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False); 383cdf0e10cSrcweir pPostIt = (SwPostItField*)aFldMgr.GetCurFld(); 384cdf0e10cSrcweir rSh.Pop(sal_False); // Cursorpos restaurieren 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir if (pPostIt) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir SwFieldType* pType = rSh.GetDoc()->GetFldType(RES_POSTITFLD, aEmptyStr,false); 390cdf0e10cSrcweir SwIterator<SwFmtFld,SwFieldType> aIter( *pType ); 391cdf0e10cSrcweir SwFmtFld* pSwFmtFld = aIter.First(); 392cdf0e10cSrcweir while( pSwFmtFld ) 393cdf0e10cSrcweir { 394c0286415SOliver-Rainer Wittmann if ( pSwFmtFld->GetField() == pPostIt ) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) ); 397cdf0e10cSrcweir break; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir pSwFmtFld = aIter.Next(); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir } 402cdf0e10cSrcweir } 403cdf0e10cSrcweir break; 404cdf0e10cSrcweir case FN_REDLINE_COMMENT: 405cdf0e10cSrcweir { 406cdf0e10cSrcweir /* this code can be used once we want redline comments in the margin, all other stuff can 407cdf0e10cSrcweir then be deleted 408cdf0e10cSrcweir String sComment; 409cdf0e10cSrcweir const SwRedline *pRedline = rSh.GetCurrRedline(); 410cdf0e10cSrcweir 411cdf0e10cSrcweir if (pRedline) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir sComment = pRedline->GetComment(); 414cdf0e10cSrcweir if ( sComment == String(rtl::OUString::createFromAscii("")) ) 415cdf0e10cSrcweir GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); 416cdf0e10cSrcweir const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir */ 419cdf0e10cSrcweir 420cdf0e10cSrcweir String sComment; 421cdf0e10cSrcweir const SwRedline *pRedline = rSh.GetCurrRedline(); 422cdf0e10cSrcweir 423cdf0e10cSrcweir if (pRedline) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir sComment = pRedline->GetComment(); 426cdf0e10cSrcweir 427cdf0e10cSrcweir 428cdf0e10cSrcweir sal_Bool bTravel = sal_False; 429cdf0e10cSrcweir 430cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 431cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 432cdf0e10cSrcweir ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT ); 433cdf0e10cSrcweir DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()"); 434cdf0e10cSrcweir SfxItemSet aSet(GetPool(), fnGetRange()); 435cdf0e10cSrcweir aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT)); 436cdf0e10cSrcweir aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); 437cdf0e10cSrcweir 438cdf0e10cSrcweir aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString( 439cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() ), 440cdf0e10cSrcweir SID_ATTR_POSTIT_DATE )); 441cdf0e10cSrcweir 442cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 443cdf0e10cSrcweir rSh.StartAction(); 444cdf0e10cSrcweir 445cdf0e10cSrcweir rSh.Push(); 446cdf0e10cSrcweir const SwRedline *pActRed = rSh.SelPrevRedline(); 447cdf0e10cSrcweir 448cdf0e10cSrcweir if (pActRed == pRedline) 449cdf0e10cSrcweir { // Neuer Cursor steht am Anfang des Current Redlines 450cdf0e10cSrcweir rSh.Pop(); // Alten Cursor wegwerfen 451cdf0e10cSrcweir rSh.Push(); 452cdf0e10cSrcweir pActRed = rSh.SelPrevRedline(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir sal_Bool bPrev = pActRed != 0; 456cdf0e10cSrcweir rSh.Pop(sal_False); 457cdf0e10cSrcweir rSh.EndAction(); 458cdf0e10cSrcweir 459cdf0e10cSrcweir rSh.ClearMark(); 460cdf0e10cSrcweir rSh.SelNextRedline(); // Aktueller Redline wird selektiert 461cdf0e10cSrcweir 462cdf0e10cSrcweir rSh.StartAction(); 463cdf0e10cSrcweir rSh.Push(); 464cdf0e10cSrcweir pActRed = rSh.SelNextRedline(); 465cdf0e10cSrcweir sal_Bool bNext = pActRed != 0; 466cdf0e10cSrcweir rSh.Pop(sal_False); // Cursorpos restaurieren 467cdf0e10cSrcweir 468cdf0e10cSrcweir if( rSh.IsCrsrPtAtEnd() ) 469cdf0e10cSrcweir rSh.SwapPam(); 470cdf0e10cSrcweir 471cdf0e10cSrcweir rSh.EndAction(); 472cdf0e10cSrcweir 473cdf0e10cSrcweir bTravel |= bNext|bPrev; 474cdf0e10cSrcweir 475cdf0e10cSrcweir SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create(); 476cdf0e10cSrcweir DBG_ASSERT(pFact2, "Dialogdiet fail!"); 477cdf0e10cSrcweir AbstractSvxPostItDialog* pDlg = pFact2->CreateSvxPostItDialog( pMDI, aSet, bTravel, sal_True ); 478cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 479cdf0e10cSrcweir pDlg->HideAuthor(); 480cdf0e10cSrcweir 481cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT)); 482cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); 483cdf0e10cSrcweir 484cdf0e10cSrcweir pDlg->SetText(sTitle); 485cdf0e10cSrcweir 486cdf0e10cSrcweir if (bTravel) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir pDlg->EnableTravel(bNext, bPrev); 489cdf0e10cSrcweir pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl)); 490cdf0e10cSrcweir pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl)); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir rSh.SetCareWin(pDlg->GetWindow()); 494cdf0e10cSrcweir bNoInterrupt = sal_True; 495cdf0e10cSrcweir 496cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 499cdf0e10cSrcweir String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); 500cdf0e10cSrcweir 501cdf0e10cSrcweir // Kommentar einfuegen bzw aendern 502cdf0e10cSrcweir rSh.SetRedlineComment(sMsg); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir delete pDlg; 506cdf0e10cSrcweir rSh.SetCareWin(NULL); 507cdf0e10cSrcweir bNoInterrupt = sal_False; 508cdf0e10cSrcweir rSh.ClearMark(); 509cdf0e10cSrcweir GetView().AttrChangedNotify(GetShellPtr()); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir } 512cdf0e10cSrcweir break; 513cdf0e10cSrcweir 514cdf0e10cSrcweir case FN_JAVAEDIT: 515cdf0e10cSrcweir { 516cdf0e10cSrcweir String aType, aText; 517cdf0e10cSrcweir sal_Bool bIsUrl=sal_False; 518cdf0e10cSrcweir sal_Bool bNew=sal_False, bUpdate=sal_False; 519cdf0e10cSrcweir SwFldMgr* pMgr = new SwFldMgr; 520cdf0e10cSrcweir if ( pItem ) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir aText = ((SfxStringItem*)pItem)->GetValue(); 523cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pType, SfxStringItem, FN_PARAM_2 , sal_False ); 524cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pIsUrl, SfxBoolItem, FN_PARAM_1 , sal_False ); 525cdf0e10cSrcweir if ( pType ) 526cdf0e10cSrcweir aType = pType->GetValue(); 527cdf0e10cSrcweir if ( pIsUrl ) 528cdf0e10cSrcweir bIsUrl = pIsUrl->GetValue(); 529cdf0e10cSrcweir 530cdf0e10cSrcweir SwScriptField* pFld = (SwScriptField*)pMgr->GetCurFld(); 531cdf0e10cSrcweir bNew = !pFld || !(pFld->GetTyp()->Which() == RES_SCRIPTFLD); 532cdf0e10cSrcweir bUpdate = pFld && ( bIsUrl != pFld->GetFormat() || pFld->GetPar2() != aType || pFld->GetPar1() != aText ); 533cdf0e10cSrcweir } 534cdf0e10cSrcweir else 535cdf0e10cSrcweir { 536cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 537cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 538cdf0e10cSrcweir AbstractJavaEditDialog* pDlg = pFact->CreateJavaEditDialog( DLG_JAVAEDIT, 539cdf0e10cSrcweir pMDI, &rSh); 540cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 541cdf0e10cSrcweir if ( pDlg->Execute() ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir aType = pDlg->GetType(); 544cdf0e10cSrcweir aText = pDlg->GetText(); 545cdf0e10cSrcweir bIsUrl = pDlg->IsUrl(); 546cdf0e10cSrcweir bNew = pDlg->IsNew(); 547cdf0e10cSrcweir bUpdate = pDlg->IsUpdate(); 548cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) ); 549cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) ); 550cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) ); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir delete pDlg; 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir if( bNew ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir SwInsertFld_Data aData(TYP_SCRIPTFLD, 0, aType, aText, bIsUrl); 559cdf0e10cSrcweir pMgr->InsertFld(aData); 560cdf0e10cSrcweir rReq.Done(); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir else if( bUpdate ) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir pMgr->UpdateCurFld( bIsUrl, aType, aText ); 565cdf0e10cSrcweir rSh.SetUndoNoResetModified(); 566cdf0e10cSrcweir rReq.Done(); 567cdf0e10cSrcweir } 568cdf0e10cSrcweir else 569cdf0e10cSrcweir rReq.Ignore(); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir break; 572cdf0e10cSrcweir 573cdf0e10cSrcweir case FN_INSERT_FLD_DATE : 574cdf0e10cSrcweir nInsertType = TYP_DATEFLD; 575cdf0e10cSrcweir bIsText = sal_False; 576cdf0e10cSrcweir goto FIELD_INSERT; 577cdf0e10cSrcweir case FN_INSERT_FLD_TIME : 578cdf0e10cSrcweir nInsertType = TYP_TIMEFLD; 579cdf0e10cSrcweir bIsText = sal_False; 580cdf0e10cSrcweir goto FIELD_INSERT; 581cdf0e10cSrcweir case FN_INSERT_FLD_PGNUMBER: 582cdf0e10cSrcweir nInsertType = TYP_PAGENUMBERFLD; 583cdf0e10cSrcweir nInsertFormat = SVX_NUM_PAGEDESC; // wie Seitenvorlage 584cdf0e10cSrcweir bIsText = sal_False; 585cdf0e10cSrcweir goto FIELD_INSERT; 586cdf0e10cSrcweir case FN_INSERT_FLD_PGCOUNT : 587cdf0e10cSrcweir nInsertType = TYP_DOCSTATFLD; 588cdf0e10cSrcweir nInsertSubType = 0; 589cdf0e10cSrcweir bIsText = sal_False; 590cdf0e10cSrcweir nInsertFormat = SVX_NUM_PAGEDESC; 591cdf0e10cSrcweir goto FIELD_INSERT; 592cdf0e10cSrcweir case FN_INSERT_FLD_TOPIC : 593cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD; 594cdf0e10cSrcweir nInsertSubType = DI_THEMA; 595cdf0e10cSrcweir goto FIELD_INSERT; 596cdf0e10cSrcweir case FN_INSERT_FLD_TITLE : 597cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD; 598cdf0e10cSrcweir nInsertSubType = DI_TITEL; 599cdf0e10cSrcweir goto FIELD_INSERT; 600cdf0e10cSrcweir case FN_INSERT_FLD_AUTHOR : 601cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD; 602cdf0e10cSrcweir nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; 603cdf0e10cSrcweir 604cdf0e10cSrcweir FIELD_INSERT: 605cdf0e10cSrcweir { 606cdf0e10cSrcweir //format conversion should only be done for number formatter formats 607cdf0e10cSrcweir if(!nInsertFormat) 608cdf0e10cSrcweir nInsertFormat = aFldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter()); 609cdf0e10cSrcweir SwInsertFld_Data aData(nInsertType, nInsertSubType, 610cdf0e10cSrcweir aEmptyStr, aEmptyStr, nInsertFormat); 611cdf0e10cSrcweir aFldMgr.InsertFld(aData); 612cdf0e10cSrcweir rReq.Done(); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir break; 615cdf0e10cSrcweir default: 616cdf0e10cSrcweir ASSERT(sal_False, falscher Dispatcher); 617cdf0e10cSrcweir return; 618cdf0e10cSrcweir } 619cdf0e10cSrcweir } 620cdf0e10cSrcweir } 621cdf0e10cSrcweir 622cdf0e10cSrcweir void SwTextShell::StateField( SfxItemSet &rSet ) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 625cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 626cdf0e10cSrcweir const SwField* pField = 0; 627cdf0e10cSrcweir int bGetField = sal_False; 628cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 629cdf0e10cSrcweir 630cdf0e10cSrcweir while (nWhich) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir switch (nWhich) 633cdf0e10cSrcweir { 634cdf0e10cSrcweir case FN_DELETE_COMMENT: 635cdf0e10cSrcweir case FN_DELETE_NOTE_AUTHOR: 636cdf0e10cSrcweir case FN_DELETE_ALL_NOTES: 637cdf0e10cSrcweir case FN_HIDE_NOTE: 638cdf0e10cSrcweir case FN_HIDE_NOTE_AUTHOR: 639cdf0e10cSrcweir case FN_HIDE_ALL_NOTES: 640cdf0e10cSrcweir { 641cdf0e10cSrcweir SwPostItMgr* pPostItMgr = GetView().GetPostItMgr(); 642cdf0e10cSrcweir if ( !pPostItMgr ) 643cdf0e10cSrcweir rSet.InvalidateItem( nWhich ); 644cdf0e10cSrcweir else if ( !pPostItMgr->HasActiveSidebarWin() ) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir rSet.InvalidateItem( FN_DELETE_COMMENT ); 647cdf0e10cSrcweir rSet.InvalidateItem( FN_HIDE_NOTE ); 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir break; 651*69a74367SOliver-Rainer Wittmann 652cdf0e10cSrcweir case FN_EDIT_FIELD: 653cdf0e10cSrcweir { 654cdf0e10cSrcweir if( !bGetField ) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir pField = rSh.GetCurFld(); 657cdf0e10cSrcweir bGetField = sal_True; 658cdf0e10cSrcweir } 659cdf0e10cSrcweir 660cdf0e10cSrcweir sal_uInt16 nTempWhich = pField ? pField->GetTyp()->Which() : USHRT_MAX; 661cdf0e10cSrcweir if( USHRT_MAX == nTempWhich || 662cdf0e10cSrcweir RES_POSTITFLD == nTempWhich || 663cdf0e10cSrcweir RES_SCRIPTFLD == nTempWhich || 664cdf0e10cSrcweir RES_AUTHORITY == nTempWhich ) 665cdf0e10cSrcweir rSet.DisableItem( nWhich ); 666cdf0e10cSrcweir else if( RES_DDEFLD == nTempWhich && 667cdf0e10cSrcweir !((SwDDEFieldType*)pField->GetTyp())->GetBaseLink().IsVisible()) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir // nested links cannot be edited 670cdf0e10cSrcweir rSet.DisableItem( nWhich ); 671cdf0e10cSrcweir } 672cdf0e10cSrcweir } 673cdf0e10cSrcweir break; 674*69a74367SOliver-Rainer Wittmann 675cdf0e10cSrcweir case FN_EXECUTE_MACROFIELD: 676cdf0e10cSrcweir { 677cdf0e10cSrcweir if(!bGetField) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir pField = rSh.GetCurFld(); 680cdf0e10cSrcweir bGetField = sal_True; 681cdf0e10cSrcweir } 682cdf0e10cSrcweir if(!pField || pField->GetTyp()->Which() != RES_MACROFLD) 683cdf0e10cSrcweir rSet.DisableItem(nWhich); 684cdf0e10cSrcweir } 685cdf0e10cSrcweir break; 686cdf0e10cSrcweir 687cdf0e10cSrcweir case FN_INSERT_FIELD: 688cdf0e10cSrcweir { 689*69a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() ) 690*69a74367SOliver-Rainer Wittmann { 691*69a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich); 692*69a74367SOliver-Rainer Wittmann } 693*69a74367SOliver-Rainer Wittmann else 694*69a74367SOliver-Rainer Wittmann { 695cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 696cdf0e10cSrcweir //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active 697cdf0e10cSrcweir if(!pVFrame->IsInModalMode() && 698cdf0e10cSrcweir pVFrame->KnowsChildWindow(FN_INSERT_FIELD) && !pVFrame->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY) ) 699cdf0e10cSrcweir rSet.Put(SfxBoolItem( FN_INSERT_FIELD, pVFrame->HasChildWindow(nWhich))); 700cdf0e10cSrcweir else 701cdf0e10cSrcweir rSet.DisableItem(FN_INSERT_FIELD); 702cdf0e10cSrcweir } 703*69a74367SOliver-Rainer Wittmann } 704cdf0e10cSrcweir break; 705*69a74367SOliver-Rainer Wittmann 706cdf0e10cSrcweir case FN_INSERT_REF_FIELD: 707cdf0e10cSrcweir { 708cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame(); 709*69a74367SOliver-Rainer Wittmann if ( !pVFrame->KnowsChildWindow(FN_INSERT_FIELD) 710*69a74367SOliver-Rainer Wittmann || rSh.CrsrInsideInputFld() ) 711*69a74367SOliver-Rainer Wittmann { 712cdf0e10cSrcweir rSet.DisableItem(FN_INSERT_REF_FIELD); 713cdf0e10cSrcweir } 714*69a74367SOliver-Rainer Wittmann } 715cdf0e10cSrcweir break; 716*69a74367SOliver-Rainer Wittmann 717cdf0e10cSrcweir case FN_INSERT_FIELD_CTRL: 718*69a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() ) 719*69a74367SOliver-Rainer Wittmann { 720*69a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich); 721*69a74367SOliver-Rainer Wittmann } 722*69a74367SOliver-Rainer Wittmann else 723*69a74367SOliver-Rainer Wittmann { 724cdf0e10cSrcweir rSet.Put(SfxBoolItem( nWhich, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD))); 725*69a74367SOliver-Rainer Wittmann } 726cdf0e10cSrcweir break; 727*69a74367SOliver-Rainer Wittmann 728cdf0e10cSrcweir case FN_REDLINE_COMMENT: 729cdf0e10cSrcweir if (!rSh.GetCurrRedline()) 730cdf0e10cSrcweir rSet.DisableItem(nWhich); 731cdf0e10cSrcweir break; 732*69a74367SOliver-Rainer Wittmann 733cdf0e10cSrcweir case FN_POSTIT : 734cdf0e10cSrcweir case FN_JAVAEDIT : 735*69a74367SOliver-Rainer Wittmann { 736cdf0e10cSrcweir sal_Bool bCurField = sal_False; 737cdf0e10cSrcweir pField = rSh.GetCurFld(); 738cdf0e10cSrcweir if(nWhich == FN_POSTIT) 739cdf0e10cSrcweir bCurField = pField && pField->GetTyp()->Which() == RES_POSTITFLD; 740cdf0e10cSrcweir else 741cdf0e10cSrcweir bCurField = pField && pField->GetTyp()->Which() == RES_SCRIPTFLD; 742cdf0e10cSrcweir 743cdf0e10cSrcweir if( !bCurField && rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() ) 744*69a74367SOliver-Rainer Wittmann { 745cdf0e10cSrcweir rSet.DisableItem(nWhich); 746*69a74367SOliver-Rainer Wittmann } 747*69a74367SOliver-Rainer Wittmann else if ( rSh.CrsrInsideInputFld() ) 748*69a74367SOliver-Rainer Wittmann { 749*69a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich); 750*69a74367SOliver-Rainer Wittmann } 751*69a74367SOliver-Rainer Wittmann } 752*69a74367SOliver-Rainer Wittmann 753cdf0e10cSrcweir break; 754*69a74367SOliver-Rainer Wittmann 755*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_AUTHOR: 756*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_DATE: 757*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_PGCOUNT: 758*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_PGNUMBER: 759*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_TIME: 760*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_TITLE: 761*69a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_TOPIC: 762*69a74367SOliver-Rainer Wittmann case FN_INSERT_DBFIELD: 763*69a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() ) 764*69a74367SOliver-Rainer Wittmann { 765*69a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich); 766*69a74367SOliver-Rainer Wittmann } 767*69a74367SOliver-Rainer Wittmann break; 768*69a74367SOliver-Rainer Wittmann 769cdf0e10cSrcweir } 770cdf0e10cSrcweir nWhich = aIter.NextWhich(); 771cdf0e10cSrcweir } 772cdf0e10cSrcweir } 773cdf0e10cSrcweir 774cdf0e10cSrcweir /*--------------------------------------------------------------------------- 775cdf0e10cSrcweir Beschreibung: 776cdf0e10cSrcweir ----------------------------------------------------------------------------*/ 777cdf0e10cSrcweir 778cdf0e10cSrcweir 779cdf0e10cSrcweir void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir const String& rName = rHlnkItem.GetName(); 782cdf0e10cSrcweir const String& rURL = rHlnkItem.GetURL(); 783cdf0e10cSrcweir const String& rTarget = rHlnkItem.GetTargetFrame(); 784cdf0e10cSrcweir sal_uInt16 nType = (sal_uInt16)rHlnkItem.GetInsertMode(); 785cdf0e10cSrcweir nType &= ~HLINK_HTMLMODE; 786cdf0e10cSrcweir const SvxMacroTableDtor* pMacroTbl = rHlnkItem.GetMacroTbl(); 787cdf0e10cSrcweir 788cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 789cdf0e10cSrcweir 790cdf0e10cSrcweir if( rSh.GetSelectionType() & nsSelectionType::SEL_TXT ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir rSh.StartAction(); 793cdf0e10cSrcweir SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); 794cdf0e10cSrcweir rSh.GetCurAttr( aSet ); 795cdf0e10cSrcweir 796cdf0e10cSrcweir const SfxPoolItem* pItem; 797cdf0e10cSrcweir if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False, &pItem)) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir // Links selektieren 800cdf0e10cSrcweir rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT, sal_False); 801cdf0e10cSrcweir } 802cdf0e10cSrcweir switch (nType) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir case HLINK_DEFAULT: 805cdf0e10cSrcweir case HLINK_FIELD: 806cdf0e10cSrcweir { 807cdf0e10cSrcweir SwFmtINetFmt aINetFmt( rURL, rTarget ); 808cdf0e10cSrcweir aINetFmt.SetName(rHlnkItem.GetIntName()); 809cdf0e10cSrcweir if(pMacroTbl) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir SvxMacro *pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOVER_OBJECT ); 812cdf0e10cSrcweir if( pMacro ) 813cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT, *pMacro); 814cdf0e10cSrcweir pMacro = pMacroTbl->Get( SFX_EVENT_MOUSECLICK_OBJECT ); 815cdf0e10cSrcweir if( pMacro ) 816cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT, *pMacro); 817cdf0e10cSrcweir pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOUT_OBJECT ); 818cdf0e10cSrcweir if( pMacro ) 819cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT, *pMacro); 820cdf0e10cSrcweir } 821cdf0e10cSrcweir rSh.SttSelect(); 822cdf0e10cSrcweir rSh.InsertURL( aINetFmt, rName, sal_True ); 823cdf0e10cSrcweir rSh.EndSelect(); 824cdf0e10cSrcweir } 825cdf0e10cSrcweir break; 826cdf0e10cSrcweir 827cdf0e10cSrcweir case HLINK_BUTTON: 828cdf0e10cSrcweir sal_Bool bSel = rSh.HasSelection(); 829cdf0e10cSrcweir if(bSel) 830cdf0e10cSrcweir rSh.DelRight(); 831cdf0e10cSrcweir InsertURLButton( rURL, rTarget, rName ); 832cdf0e10cSrcweir rSh.EnterStdMode(); 833cdf0e10cSrcweir break; 834cdf0e10cSrcweir } 835cdf0e10cSrcweir rSh.EndAction(); 836cdf0e10cSrcweir } 837cdf0e10cSrcweir } 838cdf0e10cSrcweir 839cdf0e10cSrcweir IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog *, pBtn ) 840cdf0e10cSrcweir { 841cdf0e10cSrcweir SwWrtShell* pSh = GetShellPtr(); 842cdf0e10cSrcweir AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn; 843cdf0e10cSrcweir 844cdf0e10cSrcweir // Kommentar einfuegen bzw aendern 845cdf0e10cSrcweir pSh->SetRedlineComment(pDlg->GetNote()); 846cdf0e10cSrcweir 847cdf0e10cSrcweir const SwRedline *pRedline = pSh->GetCurrRedline(); 848cdf0e10cSrcweir 849cdf0e10cSrcweir String sComment; 850cdf0e10cSrcweir 851cdf0e10cSrcweir if (pRedline) 852cdf0e10cSrcweir { 853cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 854cdf0e10cSrcweir if( !pSh->IsCrsrPtAtEnd() ) 855cdf0e10cSrcweir pSh->SwapPam(); // Cursor hinter den Redline stellen 856cdf0e10cSrcweir 857cdf0e10cSrcweir pSh->Push(); 858cdf0e10cSrcweir const SwRedline *pActRed = pSh->SelNextRedline(); 859cdf0e10cSrcweir pSh->Pop(pActRed != 0); 860cdf0e10cSrcweir 861cdf0e10cSrcweir sal_Bool bEnable = sal_False; 862cdf0e10cSrcweir 863cdf0e10cSrcweir if (pActRed) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir pSh->StartAction(); 866cdf0e10cSrcweir pSh->Push(); 867cdf0e10cSrcweir bEnable = pSh->SelNextRedline() != 0; 868cdf0e10cSrcweir pSh->Pop(sal_False); 869cdf0e10cSrcweir pSh->EndAction(); 870cdf0e10cSrcweir } 871cdf0e10cSrcweir 872cdf0e10cSrcweir pDlg->EnableTravel(bEnable, sal_True); 873cdf0e10cSrcweir 874cdf0e10cSrcweir if( pSh->IsCrsrPtAtEnd() ) 875cdf0e10cSrcweir pSh->SwapPam(); 876cdf0e10cSrcweir 877cdf0e10cSrcweir pRedline = pSh->GetCurrRedline(); 878cdf0e10cSrcweir sComment = pRedline->GetComment(); 879cdf0e10cSrcweir 880cdf0e10cSrcweir pDlg->SetNote( sComment.ConvertLineEnd() ); 881cdf0e10cSrcweir pDlg->ShowLastAuthor( pRedline->GetAuthorString(), 882cdf0e10cSrcweir GetAppLangDateTimeString( 883cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() )); 884cdf0e10cSrcweir 885cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT)); 886cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); 887cdf0e10cSrcweir 888cdf0e10cSrcweir pDlg->SetText(sTitle); 889cdf0e10cSrcweir } 890cdf0e10cSrcweir 891cdf0e10cSrcweir return 0; 892cdf0e10cSrcweir } 893cdf0e10cSrcweir 894cdf0e10cSrcweir IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn ) 895cdf0e10cSrcweir { 896cdf0e10cSrcweir SwWrtShell* pSh = GetShellPtr(); 897cdf0e10cSrcweir AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn; 898cdf0e10cSrcweir 899cdf0e10cSrcweir // Kommentar einfuegen bzw aendern 900cdf0e10cSrcweir pSh->SetRedlineComment(pDlg->GetNote()); 901cdf0e10cSrcweir 902cdf0e10cSrcweir const SwRedline *pRedline = pSh->GetCurrRedline(); 903cdf0e10cSrcweir 904cdf0e10cSrcweir String sComment; 905cdf0e10cSrcweir 906cdf0e10cSrcweir if (pRedline) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld 909cdf0e10cSrcweir pSh->Push(); 910cdf0e10cSrcweir const SwRedline *pActRed = pSh->SelPrevRedline(); 911cdf0e10cSrcweir pSh->Pop(pActRed != 0); 912cdf0e10cSrcweir 913cdf0e10cSrcweir sal_Bool bEnable = sal_False; 914cdf0e10cSrcweir 915cdf0e10cSrcweir if (pActRed) 916cdf0e10cSrcweir { 917cdf0e10cSrcweir pSh->StartAction(); 918cdf0e10cSrcweir pSh->Push(); 919cdf0e10cSrcweir bEnable = pSh->SelPrevRedline() != 0; 920cdf0e10cSrcweir pSh->Pop(sal_False); 921cdf0e10cSrcweir pSh->EndAction(); 922cdf0e10cSrcweir } 923cdf0e10cSrcweir 924cdf0e10cSrcweir pDlg->EnableTravel(sal_True, bEnable); 925cdf0e10cSrcweir 926cdf0e10cSrcweir pRedline = pSh->GetCurrRedline(); 927cdf0e10cSrcweir sComment = pRedline->GetComment(); 928cdf0e10cSrcweir 929cdf0e10cSrcweir pDlg->SetNote(sComment.ConvertLineEnd()); 930cdf0e10cSrcweir pDlg->ShowLastAuthor(pRedline->GetAuthorString(), 931cdf0e10cSrcweir GetAppLangDateTimeString( 932cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() )); 933cdf0e10cSrcweir 934cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT)); 935cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() ); 936cdf0e10cSrcweir 937cdf0e10cSrcweir pDlg->SetText(sTitle); 938cdf0e10cSrcweir } 939cdf0e10cSrcweir 940cdf0e10cSrcweir return 0; 941cdf0e10cSrcweir } 942cdf0e10cSrcweir 943cdf0e10cSrcweir 944