1 /************ *************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textfld.cxx,v $
10 * $Revision: 1.38.190.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <crsskip.hxx>
35 #include <hintids.hxx> //_immer_ vor den solar-Items
37 #include <sfx2/lnkbase.hxx>
39 #include <tools/urlobj.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <svtools/itempool.hxx>
42 #include <svtools/useroptions.hxx>
43 #include <svtools/whiter.hxx>
44 #include <svtools/eitem.hxx>
45 #include <svtools/macitem.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <sfx2/request.hxx>
48 #include <svx/postattr.hxx>
49 #include <svx/hlnkitem.hxx>
51 #include <svx/svxdlg.hxx>
52 #include <svx/linkmgr.hxx>
53 #include <unotools/localedatawrapper.hxx>
54 #include <sfx2/dispatch.hxx>
55 #include <fmtinfmt.hxx>
56 #include <fldwrap.hxx>
57 #include <redline.hxx>
63 #include <numrule.hxx>
66 #include <docufld.hxx>
76 #include <sfx2/app.hxx>
77 #include <svx/svxdlg.hxx>
78 #include <svx/dialogs.hrc>
79 #include "swabstdlg.hxx"
86 #include "PostItMgr.hxx"
89 using namespace nsSwDocInfoSubType
;
92 extern BOOL bNoInterrupt
; // in mainwn.cxx
94 String
& lcl_AppendRedlineStr( String
& rStr
, USHORT nRedlId
)
99 case nsRedlineType_t::REDLINE_INSERT
: nResId
= STR_REDLINE_INSERTED
; break;
100 case nsRedlineType_t::REDLINE_DELETE
: nResId
= STR_REDLINE_DELETED
; break;
101 case nsRedlineType_t::REDLINE_FORMAT
: nResId
= STR_REDLINE_FORMATED
; break;
102 case nsRedlineType_t::REDLINE_TABLE
: nResId
= STR_REDLINE_TABLECHG
; break;
103 case nsRedlineType_t::REDLINE_FMTCOLL
: nResId
= STR_REDLINE_FMTCOLLSET
; break;
106 rStr
+= SW_RESSTR( nResId
);
110 // STATIC DATA -----------------------------------------------------------
112 void SwTextShell::ExecField(SfxRequest
&rReq
)
114 SwWrtShell
& rSh
= GetShell();
115 const SfxPoolItem
* pItem
= 0;
117 USHORT nSlot
= rReq
.GetSlot();
118 const SfxItemSet
* pArgs
= rReq
.GetArgs();
120 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), FALSE
, &pItem
);
122 Window
*pMDI
= &GetView().GetViewFrame()->GetWindow();
125 USHORT nInsertType
= 0;
126 USHORT nInsertSubType
= 0;
127 ULONG nInsertFormat
= 0;
133 SwField
* pFld
= rSh
.GetCurFld();
136 switch ( pFld
->GetTypeId() )
140 ::sfx2::SvBaseLink
& rLink
= ((SwDDEFieldType
*)pFld
->GetTyp())->
142 if(rLink
.IsVisible())
144 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
145 SfxAbstractLinksDialog
* pDlg
= pFact
->CreateLinksDialog( pMDI
, &rSh
.GetLinkManager(), FALSE
, &rLink
);
156 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
157 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
159 SfxAbstractDialog
* pDlg
= pFact
->CreateSwFldEditDlg( GetView(),RC_DLG_SWFLDEDITDLG
);
160 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
168 case FN_EXECUTE_MACROFIELD
:
170 SwField
* pFld
= rSh
.GetCurFld();
171 if(pFld
&& pFld
->GetTyp()->Which() == RES_MACROFLD
)
174 const String
& rMacro
= ((SwMacroField
*)pFld
)->GetMacro();
175 USHORT nPos
= rMacro
.Search('.', 0);
176 if(nPos
!= STRING_NOTFOUND
)
178 SvxMacro
aMacro( rMacro
.Copy(nPos
+ 1), rMacro
.Copy(0,nPos
), STARBASIC
);
179 rSh
.ExecMacro(aMacro
);
185 case FN_GOTO_NEXT_INPUTFLD
:
186 case FN_GOTO_PREV_INPUTFLD
:
189 SwFieldType
* pFld
= rSh
.GetFldType( 0, RES_INPUTFLD
);
190 if( pFld
&& rSh
.MoveFldType( pFld
,
191 FN_GOTO_NEXT_INPUTFLD
== nSlot
))
194 rSh
.StartInputFldDlg( rSh
.GetCurFld(), FALSE
);
198 rReq
.SetReturnValue( SfxBoolItem( nSlot
, bRet
));
207 // hier kommen die Slots mit FldMgr
208 SwFldMgr
aFldMgr(GetShellPtr());
211 case FN_INSERT_DBFIELD
:
218 String aPar1
= ((SfxStringItem
*)pItem
)->GetValue();
220 sal_Int32 nCommand
= 0;
222 if( SFX_ITEM_SET
== pArgs
->GetItemState( FN_PARAM_FIELD_TYPE
,
224 nType
= ((SfxUInt16Item
*)pItem
)->GetValue();
226 if( SFX_ITEM_SET
== pArgs
->GetItemState(
227 FN_PARAM_1
, FALSE
, &pItem
))
229 aPar1
+= ((SfxStringItem
*)pItem
)->GetValue();
231 if( SFX_ITEM_SET
== pArgs
->GetItemState(
232 FN_PARAM_3
, FALSE
, &pItem
))
233 nCommand
= ((SfxInt32Item
*)pItem
)->GetValue();
235 aPar1
+= String::CreateFromInt32(nCommand
);
237 if( SFX_ITEM_SET
== pArgs
->GetItemState(
238 FN_PARAM_2
, FALSE
, &pItem
))
240 aPar1
+= ((SfxStringItem
*)pItem
)->GetValue();
242 if( SFX_ITEM_SET
== pArgs
->GetItemState(
243 FN_PARAM_FIELD_CONTENT
, FALSE
, &pItem
))
244 aPar2
= ((SfxStringItem
*)pItem
)->GetValue();
245 if( SFX_ITEM_SET
== pArgs
->GetItemState(
246 FN_PARAM_FIELD_FORMAT
, FALSE
, &pItem
))
247 nFormat
= ((SfxUInt32Item
*)pItem
)->GetValue();
248 DBG_WARNING("Command is not yet used");
249 sal_Unicode cSeparator
= ' ';
250 SwInsertFld_Data
aData(nType
, 0, aPar1
, aPar2
, nFormat
, GetShellPtr(), cSeparator
);
251 bRes
= aFldMgr
.InsertFld(aData
);
253 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRes
));
256 case FN_INSERT_FIELD_CTRL
:
257 case FN_INSERT_FIELD
:
260 if( pItem
&& nSlot
!= FN_INSERT_FIELD_CTRL
)
265 String aPar1
= ((SfxStringItem
*)pItem
)->GetValue();
267 sal_Unicode cSeparator
= ' ';
269 if( SFX_ITEM_SET
== pArgs
->GetItemState( FN_PARAM_FIELD_TYPE
,
271 nType
= ((SfxUInt16Item
*)pItem
)->GetValue();
272 if( SFX_ITEM_SET
== pArgs
->GetItemState( FN_PARAM_FIELD_SUBTYPE
,
274 nSubType
= ((SfxUInt16Item
*)pItem
)->GetValue();
275 if( SFX_ITEM_SET
== pArgs
->GetItemState(
276 FN_PARAM_FIELD_CONTENT
, FALSE
, &pItem
))
277 aPar2
= ((SfxStringItem
*)pItem
)->GetValue();
278 if( SFX_ITEM_SET
== pArgs
->GetItemState(
279 FN_PARAM_FIELD_FORMAT
, FALSE
, &pItem
))
280 nFormat
= ((SfxUInt32Item
*)pItem
)->GetValue();
281 if( SFX_ITEM_SET
== pArgs
->GetItemState(
282 FN_PARAM_3
, FALSE
, &pItem
))
284 String sTmp
= ((SfxStringItem
*)pItem
)->GetValue();
286 cSeparator
= sTmp
.GetChar(0);
288 SwInsertFld_Data
aData(nType
, nSubType
, aPar1
, aPar2
, nFormat
, GetShellPtr(), cSeparator
);
289 bRes
= aFldMgr
.InsertFld( aData
);
292 //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
293 if(!GetView().GetViewFrame()->IsInModalMode())
295 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
296 pVFrame
->ToggleChildWindow(FN_INSERT_FIELD
);
297 bRes
= pVFrame
->GetChildWindow( nSlot
) != 0;
298 Invalidate(rReq
.GetSlot());
299 Invalidate(FN_INSERT_FIELD_CTRL
);
302 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRes
));
306 case FN_INSERT_REF_FIELD
:
308 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
309 if (!pVFrame
->HasChildWindow(FN_INSERT_FIELD
))
310 pVFrame
->ToggleChildWindow(FN_INSERT_FIELD
); // Dialog anzeigen
312 // Flddlg auf neue TabPage umschalten
313 USHORT nId
= SwFldDlgWrapper::GetChildWindowId();
314 SwFldDlgWrapper
*pWrp
= (SwFldDlgWrapper
*)pVFrame
->GetChildWindow(nId
);
321 if ( GetView().GetPostItMgr() && GetView().GetPostItMgr()->GetActivePostIt() )
322 GetView().GetPostItMgr()->GetActivePostIt()->Delete();
324 case FN_DELETE_ALL_NOTES
:
325 if ( GetView().GetPostItMgr() )
326 GetView().GetPostItMgr()->Delete();
328 case FN_DELETE_NOTE_AUTHOR
:
330 SFX_REQUEST_ARG( rReq
, pNoteItem
, SfxStringItem
, nSlot
, FALSE
);
331 if ( pNoteItem
&& GetView().GetPostItMgr() )
332 GetView().GetPostItMgr()->Delete( pNoteItem
->GetValue() );
336 if ( GetView().GetPostItMgr() && GetView().GetPostItMgr()->GetActivePostIt() )
337 GetView().GetPostItMgr()->GetActivePostIt()->Hide();
339 case FN_HIDE_ALL_NOTES
:
340 if ( GetView().GetPostItMgr() )
341 GetView().GetPostItMgr()->Hide();
343 case FN_HIDE_NOTE_AUTHOR
:
345 SFX_REQUEST_ARG( rReq
, pNoteItem
, SfxStringItem
, nSlot
, FALSE
);
346 if ( pNoteItem
&& GetView().GetPostItMgr() )
347 GetView().GetPostItMgr()->Hide( pNoteItem
->GetValue() );
352 SwPostItField
* pPostIt
= (SwPostItField
*)aFldMgr
.GetCurFld();
353 BOOL bNew
= !(pPostIt
&& pPostIt
->GetTyp()->Which() == RES_POSTITFLD
);
354 if (bNew
|| GetView().GetPostItMgr()->IsAnswer())
356 SvtUserOptions aUserOpt
;
358 if( !(sAuthor
= aUserOpt
.GetFullName()).Len())
359 if( !(sAuthor
= aUserOpt
.GetID()).Len() )
360 sAuthor
= String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR
));
361 if( rSh
.HasSelection() )
363 rSh
.NormalizePam(true);
367 SwInsertFld_Data
aData(TYP_POSTITFLD
, 0, sAuthor
, aEmptyStr
, 0);
368 aFldMgr
.InsertFld(aData
);
370 rSh
.SwCrsrShell::Left(1, CRSR_SKIP_CHARS
, FALSE
);
371 pPostIt
= (SwPostItField
*)aFldMgr
.GetCurFld();
372 rSh
.Pop(FALSE
); // Cursorpos restaurieren
377 SwFieldType
* pType
= rSh
.GetDoc()->GetFldType(RES_POSTITFLD
, aEmptyStr
,false);
378 SwClientIter
aIter( *pType
);
379 SwClient
* pFirst
= aIter
.GoStart();
382 SwFmtFld
* pSwFmtFld
= static_cast<SwFmtFld
*>(pFirst
);
383 if ( pSwFmtFld
->GetFld() == pPostIt
)
385 pSwFmtFld
->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS
, &GetView() ) );
393 case FN_REDLINE_COMMENT
:
395 /* this code can be used once we want redline comments in the margin, all other stuff can
398 const SwRedline *pRedline = rSh.GetCurrRedline();
402 sComment = pRedline->GetComment();
403 if ( sComment == String(rtl::OUString::createFromAscii("")) )
404 GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED));
405 const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView()));
410 const SwRedline
*pRedline
= rSh
.GetCurrRedline();
414 sComment
= pRedline
->GetComment();
417 BOOL bTravel
= FALSE
;
419 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
420 DBG_ASSERT(pFact
, "Dialogdiet fail!");
421 ::DialogGetRanges fnGetRange
= pFact
->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT
);
422 DBG_ASSERT(fnGetRange
, "Dialogdiet fail! GetRanges()");
423 SfxItemSet
aSet(GetPool(), fnGetRange());
424 aSet
.Put(SvxPostItTextItem(sComment
.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT
));
425 aSet
.Put(SvxPostItAuthorItem(pRedline
->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR
));
427 aSet
.Put( SvxPostItDateItem( GetAppLangDateTimeString(
428 pRedline
->GetRedlineData().GetTimeStamp() ),
429 SID_ATTR_POSTIT_DATE
));
431 // Traveling nur bei mehr als einem Feld
435 const SwRedline
*pActRed
= rSh
.SelPrevRedline();
437 if (pActRed
== pRedline
)
438 { // Neuer Cursor steht am Anfang des Current Redlines
439 rSh
.Pop(); // Alten Cursor wegwerfen
441 pActRed
= rSh
.SelPrevRedline();
444 BOOL bPrev
= pActRed
!= 0;
449 rSh
.SelNextRedline(); // Aktueller Redline wird selektiert
453 pActRed
= rSh
.SelNextRedline();
454 BOOL bNext
= pActRed
!= 0;
455 rSh
.Pop(FALSE
); // Cursorpos restaurieren
457 if( rSh
.IsCrsrPtAtEnd() )
462 bTravel
|= bNext
|bPrev
;
464 SvxAbstractDialogFactory
* pFact2
= SvxAbstractDialogFactory::Create();
465 DBG_ASSERT(pFact2
, "Dialogdiet fail!");
466 AbstractSvxPostItDialog
* pDlg
= pFact2
->CreateSvxPostItDialog( pMDI
, aSet
, RID_SVXDLG_POSTIT
, bTravel
, TRUE
);
467 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
470 String
sTitle(SW_RES(STR_REDLINE_COMMENT
));
471 ::lcl_AppendRedlineStr( sTitle
, pRedline
->GetType() );
473 pDlg
->SetText(sTitle
);
477 pDlg
->EnableTravel(bNext
, bPrev
);
478 pDlg
->SetPrevHdl(LINK(this, SwTextShell
, RedlinePrevHdl
));
479 pDlg
->SetNextHdl(LINK(this, SwTextShell
, RedlineNextHdl
));
482 rSh
.SetCareWin(pDlg
->GetWindow());
485 if ( pDlg
->Execute() == RET_OK
)
487 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
488 String
sMsg(((const SvxPostItTextItem
&)pOutSet
->Get(SID_ATTR_POSTIT_TEXT
)).GetValue());
490 // Kommentar einfuegen bzw aendern
491 rSh
.SetRedlineComment(sMsg
);
495 rSh
.SetCareWin(NULL
);
496 bNoInterrupt
= FALSE
;
498 GetView().AttrChangedNotify(GetShellPtr());
507 BOOL bNew
=FALSE
, bUpdate
=FALSE
;
508 SwFldMgr
* pMgr
= new SwFldMgr
;
511 aText
= ((SfxStringItem
*)pItem
)->GetValue();
512 SFX_REQUEST_ARG( rReq
, pType
, SfxStringItem
, FN_PARAM_2
, sal_False
);
513 SFX_REQUEST_ARG( rReq
, pIsUrl
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
515 aType
= pType
->GetValue();
517 bIsUrl
= pIsUrl
->GetValue();
519 SwScriptField
* pFld
= (SwScriptField
*)pMgr
->GetCurFld();
520 bNew
= !pFld
|| !(pFld
->GetTyp()->Which() == RES_SCRIPTFLD
);
521 bUpdate
= pFld
&& ( bIsUrl
!= pFld
->GetFormat() || pFld
->GetPar2() != aType
|| pFld
->GetPar1() != aText
);
525 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
526 DBG_ASSERT(pFact
, "Dialogdiet fail!");
527 AbstractJavaEditDialog
* pDlg
= pFact
->CreateJavaEditDialog( DLG_JAVAEDIT
,
529 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
530 if ( pDlg
->Execute() )
532 aType
= pDlg
->GetType();
533 aText
= pDlg
->GetText();
534 bIsUrl
= pDlg
->IsUrl();
535 bNew
= pDlg
->IsNew();
536 bUpdate
= pDlg
->IsUpdate();
537 rReq
.AppendItem( SfxStringItem( FN_JAVAEDIT
, aText
) );
538 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, aType
) );
539 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bIsUrl
) );
547 SwInsertFld_Data
aData(TYP_SCRIPTFLD
, 0, aType
, aText
, bIsUrl
);
548 pMgr
->InsertFld(aData
);
553 pMgr
->UpdateCurFld( bIsUrl
, aType
, aText
);
554 rSh
.SetUndoNoResetModified();
562 case FN_INSERT_FLD_DATE
:
563 nInsertType
= TYP_DATEFLD
;
566 case FN_INSERT_FLD_TIME
:
567 nInsertType
= TYP_TIMEFLD
;
570 case FN_INSERT_FLD_PGNUMBER
:
571 nInsertType
= TYP_PAGENUMBERFLD
;
572 nInsertFormat
= SVX_NUM_PAGEDESC
; // wie Seitenvorlage
575 case FN_INSERT_FLD_PGCOUNT
:
576 nInsertType
= TYP_DOCSTATFLD
;
579 nInsertFormat
= SVX_NUM_PAGEDESC
;
581 case FN_INSERT_FLD_TOPIC
:
582 nInsertType
= TYP_DOCINFOFLD
;
583 nInsertSubType
= DI_THEMA
;
585 case FN_INSERT_FLD_TITLE
:
586 nInsertType
= TYP_DOCINFOFLD
;
587 nInsertSubType
= DI_TITEL
;
589 case FN_INSERT_FLD_AUTHOR
:
590 nInsertType
= TYP_DOCINFOFLD
;
591 nInsertSubType
= DI_CREATE
|DI_SUB_AUTHOR
;
595 //format conversion should only be done for number formatter formats
597 nInsertFormat
= aFldMgr
.GetDefaultFormat(nInsertType
, bIsText
, rSh
.GetNumberFormatter());
598 SwInsertFld_Data
aData(nInsertType
, nInsertSubType
,
599 aEmptyStr
, aEmptyStr
, nInsertFormat
);
600 aFldMgr
.InsertFld(aData
);
605 ASSERT(FALSE
, falscher Dispatcher
);
611 void SwTextShell::StateField( SfxItemSet
&rSet
)
613 SwWrtShell
& rSh
= GetShell();
614 SfxWhichIter
aIter( rSet
);
615 const SwField
* pField
= 0;
616 int bGetField
= FALSE
;
617 USHORT nWhich
= aIter
.FirstWhich();
624 case FN_DELETE_NOTE_AUTHOR
:
625 case FN_DELETE_ALL_NOTES
:
627 case FN_HIDE_NOTE_AUTHOR
:
628 case FN_HIDE_ALL_NOTES
:
630 SwPostItMgr
* pPostItMgr
= GetView().GetPostItMgr();
632 rSet
.InvalidateItem( nWhich
);
633 else if ( !pPostItMgr
->GetActivePostIt() )
635 rSet
.InvalidateItem( FN_DELETE_NOTE
);
636 rSet
.InvalidateItem( FN_HIDE_NOTE
);
642 /* #108536# Fields can be selected, too now. Removed
644 if( rSh.HasSelection() )
645 rSet.DisableItem(nWhich);
651 pField
= rSh
.GetCurFld();
655 USHORT nTempWhich
= pField
? pField
->GetTyp()->Which() : USHRT_MAX
;
656 if( USHRT_MAX
== nTempWhich
||
657 RES_POSTITFLD
== nTempWhich
||
658 RES_SCRIPTFLD
== nTempWhich
||
659 RES_AUTHORITY
== nTempWhich
)
660 rSet
.DisableItem( nWhich
);
661 else if( RES_DDEFLD
== nTempWhich
&&
662 !((SwDDEFieldType
*)pField
->GetTyp())->GetBaseLink().IsVisible())
664 // nested links cannot be edited
665 rSet
.DisableItem( nWhich
);
669 case FN_EXECUTE_MACROFIELD
:
673 pField
= rSh
.GetCurFld();
676 if(!pField
|| pField
->GetTyp()->Which() != RES_MACROFLD
)
677 rSet
.DisableItem(nWhich
);
681 case FN_INSERT_FIELD
:
683 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
684 //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
685 if(!pVFrame
->IsInModalMode() &&
686 pVFrame
->KnowsChildWindow(FN_INSERT_FIELD
) && !pVFrame
->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY
) )
687 rSet
.Put(SfxBoolItem( FN_INSERT_FIELD
, pVFrame
->HasChildWindow(nWhich
)));
689 rSet
.DisableItem(FN_INSERT_FIELD
);
692 case FN_INSERT_REF_FIELD
:
694 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
695 if (!pVFrame
->KnowsChildWindow(FN_INSERT_FIELD
))
696 rSet
.DisableItem(FN_INSERT_REF_FIELD
);
699 case FN_INSERT_FIELD_CTRL
:
700 rSet
.Put(SfxBoolItem( nWhich
, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD
)));
702 case FN_REDLINE_COMMENT
:
703 if (!rSh
.GetCurrRedline())
704 rSet
.DisableItem(nWhich
);
708 BOOL bCurField
= FALSE
;
709 pField
= rSh
.GetCurFld();
710 if(nWhich
== FN_POSTIT
)
711 bCurField
= pField
&& pField
->GetTyp()->Which() == RES_POSTITFLD
;
713 bCurField
= pField
&& pField
->GetTyp()->Which() == RES_SCRIPTFLD
;
715 if(!bCurField
&& rSh
.IsReadOnlyAvailable() && rSh
.HasReadonlySel() )
716 rSet
.DisableItem(nWhich
);
719 nWhich
= aIter
.NextWhich();
723 /*---------------------------------------------------------------------------
725 ----------------------------------------------------------------------------*/
728 void SwTextShell::InsertHyperlink(const SvxHyperlinkItem
& rHlnkItem
)
730 const String
& rName
= rHlnkItem
.GetName();
731 const String
& rURL
= rHlnkItem
.GetURL();
732 const String
& rTarget
= rHlnkItem
.GetTargetFrame();
733 USHORT nType
= (USHORT
)rHlnkItem
.GetInsertMode();
734 nType
&= ~HLINK_HTMLMODE
;
735 const SvxMacroTableDtor
* pMacroTbl
= rHlnkItem
.GetMacroTbl();
737 SwWrtShell
& rSh
= GetShell();
739 if( rSh
.GetSelectionType() & nsSelectionType::SEL_TXT
)
742 SfxItemSet
aSet(GetPool(), RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
);
743 rSh
.GetCurAttr( aSet
);
745 const SfxPoolItem
* pItem
;
746 if(SFX_ITEM_SET
== aSet
.GetItemState(RES_TXTATR_INETFMT
, FALSE
, &pItem
))
749 rSh
.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT
, FALSE
);
756 SwFmtINetFmt
aINetFmt( rURL
, rTarget
);
757 aINetFmt
.SetName(rHlnkItem
.GetIntName());
760 SvxMacro
*pMacro
= pMacroTbl
->Get( SFX_EVENT_MOUSEOVER_OBJECT
);
762 aINetFmt
.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT
, *pMacro
);
763 pMacro
= pMacroTbl
->Get( SFX_EVENT_MOUSECLICK_OBJECT
);
765 aINetFmt
.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT
, *pMacro
);
766 pMacro
= pMacroTbl
->Get( SFX_EVENT_MOUSEOUT_OBJECT
);
768 aINetFmt
.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT
, *pMacro
);
771 rSh
.InsertURL( aINetFmt
, rName
, TRUE
);
777 BOOL bSel
= rSh
.HasSelection();
780 InsertURLButton( rURL
, rTarget
, rName
);
788 IMPL_LINK( SwTextShell
, RedlineNextHdl
, AbstractSvxPostItDialog
*, pBtn
)
790 SwWrtShell
* pSh
= GetShellPtr();
791 AbstractSvxPostItDialog
*pDlg
= (AbstractSvxPostItDialog
*)pBtn
;
793 // Kommentar einfuegen bzw aendern
794 pSh
->SetRedlineComment(pDlg
->GetNote());
796 const SwRedline
*pRedline
= pSh
->GetCurrRedline();
802 // Traveling nur bei mehr als einem Feld
803 if( !pSh
->IsCrsrPtAtEnd() )
804 pSh
->SwapPam(); // Cursor hinter den Redline stellen
807 const SwRedline
*pActRed
= pSh
->SelNextRedline();
808 pSh
->Pop(pActRed
!= 0);
810 BOOL bEnable
= FALSE
;
816 bEnable
= pSh
->SelNextRedline() != 0;
821 pDlg
->EnableTravel(bEnable
, TRUE
);
823 if( pSh
->IsCrsrPtAtEnd() )
826 pRedline
= pSh
->GetCurrRedline();
827 sComment
= pRedline
->GetComment();
829 pDlg
->SetNote( sComment
.ConvertLineEnd() );
830 pDlg
->ShowLastAuthor( pRedline
->GetAuthorString(),
831 GetAppLangDateTimeString(
832 pRedline
->GetRedlineData().GetTimeStamp() ));
834 String
sTitle(SW_RES(STR_REDLINE_COMMENT
));
835 ::lcl_AppendRedlineStr( sTitle
, pRedline
->GetType() );
837 pDlg
->SetText(sTitle
);
843 IMPL_LINK( SwTextShell
, RedlinePrevHdl
, AbstractSvxPostItDialog
*, pBtn
)
845 SwWrtShell
* pSh
= GetShellPtr();
846 AbstractSvxPostItDialog
*pDlg
= (AbstractSvxPostItDialog
*)pBtn
;
848 // Kommentar einfuegen bzw aendern
849 pSh
->SetRedlineComment(pDlg
->GetNote());
851 const SwRedline
*pRedline
= pSh
->GetCurrRedline();
857 // Traveling nur bei mehr als einem Feld
859 const SwRedline
*pActRed
= pSh
->SelPrevRedline();
860 pSh
->Pop(pActRed
!= 0);
862 BOOL bEnable
= FALSE
;
868 bEnable
= pSh
->SelPrevRedline() != 0;
873 pDlg
->EnableTravel(TRUE
, bEnable
);
875 pRedline
= pSh
->GetCurrRedline();
876 sComment
= pRedline
->GetComment();
878 pDlg
->SetNote(sComment
.ConvertLineEnd());
879 pDlg
->ShowLastAuthor(pRedline
->GetAuthorString(),
880 GetAppLangDateTimeString(
881 pRedline
->GetRedlineData().GetTimeStamp() ));
883 String
sTitle(SW_RES(STR_REDLINE_COMMENT
));
884 ::lcl_AppendRedlineStr( sTitle
, pRedline
->GetType() );
886 pDlg
->SetText(sTitle
);