1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <crsskip.hxx>
22 #include <hintids.hxx> //_always_ before the solar-items
24 #include <sfx2/lnkbase.hxx>
26 #include <vcl/msgbox.hxx>
27 #include <svl/itempool.hxx>
28 #include <unotools/useroptions.hxx>
29 #include <svl/whiter.hxx>
30 #include <svl/eitem.hxx>
31 #include <svl/macitem.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <sfx2/request.hxx>
34 #include <svx/postattr.hxx>
35 #include <svx/hlnkitem.hxx>
37 #include <svx/svxdlg.hxx>
38 #include <sfx2/linkmgr.hxx>
39 #include <unotools/localedatawrapper.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <fmtinfmt.hxx>
42 #include <fldwrap.hxx>
43 #include <redline.hxx>
48 #include <numrule.hxx>
51 #include <docufld.hxx>
61 #include <sfx2/app.hxx>
62 #include <svx/dialogs.hrc>
63 #include "swabstdlg.hxx"
70 #include <PostItMgr.hxx>
71 #include <switerator.hxx>
73 using namespace nsSwDocInfoSubType
;
75 extern bool bNoInterrupt
; // in mainwn.cxx
77 static String
& lcl_AppendRedlineStr( String
& rStr
, sal_uInt16 nRedlId
)
79 sal_uInt16 nResId
= 0;
82 case nsRedlineType_t::REDLINE_INSERT
: nResId
= STR_REDLINE_INSERTED
; break;
83 case nsRedlineType_t::REDLINE_DELETE
: nResId
= STR_REDLINE_DELETED
; break;
84 case nsRedlineType_t::REDLINE_FORMAT
: nResId
= STR_REDLINE_FORMATED
; break;
85 case nsRedlineType_t::REDLINE_TABLE
: nResId
= STR_REDLINE_TABLECHG
; break;
86 case nsRedlineType_t::REDLINE_FMTCOLL
: nResId
= STR_REDLINE_FMTCOLLSET
; break;
89 rStr
+= SW_RESSTR( nResId
);
93 void SwTextShell::ExecField(SfxRequest
&rReq
)
95 SwWrtShell
& rSh
= GetShell();
96 const SfxPoolItem
* pItem
= 0;
98 sal_uInt16 nSlot
= rReq
.GetSlot();
99 const SfxItemSet
* pArgs
= rReq
.GetArgs();
101 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), sal_False
, &pItem
);
103 Window
*pMDI
= &GetView().GetViewFrame()->GetWindow();
106 sal_uInt16 nInsertType
= 0;
107 sal_uInt16 nInsertSubType
= 0;
108 sal_uLong nInsertFormat
= 0;
114 SwField
* pFld
= rSh
.GetCurFld();
117 switch ( pFld
->GetTypeId() )
121 ::sfx2::SvBaseLink
& rLink
= ((SwDDEFieldType
*)pFld
->GetTyp())->
123 if(rLink
.IsVisible())
125 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
126 SfxAbstractLinksDialog
* pDlg
= pFact
->CreateLinksDialog( pMDI
, &rSh
.GetLinkManager(), sal_False
, &rLink
);
137 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
138 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
140 SfxAbstractDialog
* pDlg
= pFact
->CreateSwFldEditDlg( GetView(),RC_DLG_SWFLDEDITDLG
);
141 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
149 case FN_EXECUTE_MACROFIELD
:
151 SwField
* pFld
= rSh
.GetCurFld();
152 if(pFld
&& pFld
->GetTyp()->Which() == RES_MACROFLD
)
155 const String
& rMacro
= ((SwMacroField
*)pFld
)->GetMacro();
156 sal_uInt16 nPos
= rMacro
.Search('.', 0);
157 if(nPos
!= STRING_NOTFOUND
)
159 SvxMacro
aMacro( rMacro
.Copy(nPos
+ 1), rMacro
.Copy(0,nPos
), STARBASIC
);
160 rSh
.ExecMacro(aMacro
);
166 case FN_GOTO_NEXT_INPUTFLD
:
167 case FN_GOTO_PREV_INPUTFLD
:
169 sal_Bool bRet
= sal_False
;
170 SwFieldType
* pFld
= rSh
.GetFldType( 0, RES_INPUTFLD
);
171 if( pFld
&& rSh
.MoveFldType( pFld
,
172 FN_GOTO_NEXT_INPUTFLD
== nSlot
))
175 rSh
.StartInputFldDlg( rSh
.GetCurFld(), sal_False
);
179 rReq
.SetReturnValue( SfxBoolItem( nSlot
, bRet
));
188 // Here come the slots with FldMgr.
189 SwFldMgr
aFldMgr(GetShellPtr());
192 case FN_INSERT_DBFIELD
:
194 sal_Bool bRes
= sal_False
;
197 sal_uLong nFormat
= 0;
198 sal_uInt16 nType
= 0;
199 String aPar1
= ((SfxStringItem
*)pItem
)->GetValue();
201 sal_Int32 nCommand
= 0;
203 if( SFX_ITEM_SET
== pArgs
->GetItemState( FN_PARAM_FIELD_TYPE
,
205 nType
= ((SfxUInt16Item
*)pItem
)->GetValue();
207 if( SFX_ITEM_SET
== pArgs
->GetItemState(
208 FN_PARAM_1
, sal_False
, &pItem
))
210 aPar1
+= ((SfxStringItem
*)pItem
)->GetValue();
212 if( SFX_ITEM_SET
== pArgs
->GetItemState(
213 FN_PARAM_3
, sal_False
, &pItem
))
214 nCommand
= ((SfxInt32Item
*)pItem
)->GetValue();
216 aPar1
+= OUString::number(nCommand
);
218 if( SFX_ITEM_SET
== pArgs
->GetItemState(
219 FN_PARAM_2
, sal_False
, &pItem
))
221 aPar1
+= ((SfxStringItem
*)pItem
)->GetValue();
223 if( SFX_ITEM_SET
== pArgs
->GetItemState(
224 FN_PARAM_FIELD_CONTENT
, sal_False
, &pItem
))
225 aPar2
= ((SfxStringItem
*)pItem
)->GetValue();
226 if( SFX_ITEM_SET
== pArgs
->GetItemState(
227 FN_PARAM_FIELD_FORMAT
, sal_False
, &pItem
))
228 nFormat
= ((SfxUInt32Item
*)pItem
)->GetValue();
229 OSL_FAIL("Command is not yet used");
230 sal_Unicode cSeparator
= ' ';
231 SwInsertFld_Data
aData(nType
, 0, aPar1
, aPar2
, nFormat
, GetShellPtr(), cSeparator
);
232 bRes
= aFldMgr
.InsertFld(aData
);
234 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRes
));
237 case FN_INSERT_FIELD_CTRL
:
238 case FN_INSERT_FIELD
:
240 sal_Bool bRes
= sal_False
;
241 if( pItem
&& nSlot
!= FN_INSERT_FIELD_CTRL
)
243 sal_uLong nFormat
= 0;
244 sal_uInt16 nType
= 0;
245 sal_uInt16 nSubType
= 0;
246 String aPar1
= ((SfxStringItem
*)pItem
)->GetValue();
248 sal_Unicode cSeparator
= ' ';
250 if( SFX_ITEM_SET
== pArgs
->GetItemState( FN_PARAM_FIELD_TYPE
,
252 nType
= ((SfxUInt16Item
*)pItem
)->GetValue();
253 if( SFX_ITEM_SET
== pArgs
->GetItemState( FN_PARAM_FIELD_SUBTYPE
,
255 nSubType
= ((SfxUInt16Item
*)pItem
)->GetValue();
256 if( SFX_ITEM_SET
== pArgs
->GetItemState(
257 FN_PARAM_FIELD_CONTENT
, sal_False
, &pItem
))
258 aPar2
= ((SfxStringItem
*)pItem
)->GetValue();
259 if( SFX_ITEM_SET
== pArgs
->GetItemState(
260 FN_PARAM_FIELD_FORMAT
, sal_False
, &pItem
))
261 nFormat
= ((SfxUInt32Item
*)pItem
)->GetValue();
262 if( SFX_ITEM_SET
== pArgs
->GetItemState(
263 FN_PARAM_3
, sal_False
, &pItem
))
265 String sTmp
= ((SfxStringItem
*)pItem
)->GetValue();
267 cSeparator
= sTmp
.GetChar(0);
269 SwInsertFld_Data
aData(nType
, nSubType
, aPar1
, aPar2
, nFormat
, GetShellPtr(), cSeparator
);
270 bRes
= aFldMgr
.InsertFld( aData
);
273 //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
274 if(!GetView().GetViewFrame()->IsInModalMode())
276 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
277 pVFrame
->ToggleChildWindow(FN_INSERT_FIELD
);
278 bRes
= pVFrame
->GetChildWindow( nSlot
) != 0;
279 Invalidate(rReq
.GetSlot());
280 Invalidate(FN_INSERT_FIELD_CTRL
);
283 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRes
));
287 case FN_INSERT_REF_FIELD
:
289 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
290 if (!pVFrame
->HasChildWindow(FN_INSERT_FIELD
))
291 pVFrame
->ToggleChildWindow(FN_INSERT_FIELD
); // Show dialog
293 // Switch Flddlg at a new TabPage
294 sal_uInt16 nId
= SwFldDlgWrapper::GetChildWindowId();
295 SwFldDlgWrapper
*pWrp
= (SwFldDlgWrapper
*)pVFrame
->GetChildWindow(nId
);
301 case FN_DELETE_COMMENT
:
302 if ( GetView().GetPostItMgr() &&
303 GetView().GetPostItMgr()->HasActiveSidebarWin() )
305 GetView().GetPostItMgr()->DeleteActiveSidebarWin();
308 case FN_DELETE_ALL_NOTES
:
309 if ( GetView().GetPostItMgr() )
310 GetView().GetPostItMgr()->Delete();
312 case FN_DELETE_NOTE_AUTHOR
:
314 SFX_REQUEST_ARG( rReq
, pNoteItem
, SfxStringItem
, nSlot
, sal_False
);
315 if ( pNoteItem
&& GetView().GetPostItMgr() )
316 GetView().GetPostItMgr()->Delete( pNoteItem
->GetValue() );
320 if ( GetView().GetPostItMgr() &&
321 GetView().GetPostItMgr()->HasActiveSidebarWin() )
323 GetView().GetPostItMgr()->HideActiveSidebarWin();
326 case FN_HIDE_ALL_NOTES
:
327 if ( GetView().GetPostItMgr() )
328 GetView().GetPostItMgr()->Hide();
330 case FN_HIDE_NOTE_AUTHOR
:
332 SFX_REQUEST_ARG( rReq
, pNoteItem
, SfxStringItem
, nSlot
, sal_False
);
333 if ( pNoteItem
&& GetView().GetPostItMgr() )
334 GetView().GetPostItMgr()->Hide( pNoteItem
->GetValue() );
339 SwPostItField
* pPostIt
= (SwPostItField
*)aFldMgr
.GetCurFld();
340 bool bNew
= !(pPostIt
&& pPostIt
->GetTyp()->Which() == RES_POSTITFLD
);
341 if (bNew
|| GetView().GetPostItMgr()->IsAnswer())
343 SvtUserOptions aUserOpt
;
345 if( !(sAuthor
= aUserOpt
.GetFullName()).Len())
346 if( !(sAuthor
= aUserOpt
.GetID()).Len() )
347 sAuthor
= String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR
));
349 // Save the current selection, it will be required later for fieldmark insertion.
350 SwPaM
& rCurrPam
= rSh
.GetCurrentShellCursor();
351 SwPaM
aSaved(*rCurrPam
.GetPoint(), *rCurrPam
.GetMark());
352 if( rSh
.HasSelection() )
354 rSh
.NormalizePam(false);
358 SwInsertFld_Data
aData(TYP_POSTITFLD
, 0, sAuthor
, aEmptyStr
, 0);
359 aFldMgr
.InsertFld(aData
, &aSaved
);
362 rSh
.SwCrsrShell::Left(1, CRSR_SKIP_CHARS
, sal_False
);
363 pPostIt
= (SwPostItField
*)aFldMgr
.GetCurFld();
364 rSh
.Pop(sal_False
); // Restore cursor position
369 SwFieldType
* pType
= rSh
.GetDoc()->GetFldType(RES_POSTITFLD
, aEmptyStr
,false);
370 SwIterator
<SwFmtFld
,SwFieldType
> aIter( *pType
);
371 SwFmtFld
* pSwFmtFld
= aIter
.First();
374 if ( pSwFmtFld
->GetFld() == pPostIt
)
376 pSwFmtFld
->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS
, &GetView() ) );
379 pSwFmtFld
= aIter
.Next();
384 case FN_REDLINE_COMMENT
:
386 /* this code can be used once we want redline comments in the margin, all other stuff can
389 const SwRedline *pRedline = rSh.GetCurrRedline();
393 sComment = pRedline->GetComment();
394 if ( !sComment.Len() )
395 GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED));
396 const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView()));
400 const SwRedline
*pRedline
= rSh
.GetCurrRedline();
404 OUString sComment
= convertLineEnd(pRedline
->GetComment(), GetSystemLineEnd());
406 sal_Bool bTravel
= sal_False
;
408 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
409 OSL_ENSURE(pFact
, "Dialogdiet fail!");
410 ::DialogGetRanges fnGetRange
= pFact
->GetDialogGetRangesFunc();
411 OSL_ENSURE(fnGetRange
, "Dialogdiet fail! GetRanges()");
412 SfxItemSet
aSet(GetPool(), fnGetRange());
413 aSet
.Put(SvxPostItTextItem(sComment
, SID_ATTR_POSTIT_TEXT
));
414 aSet
.Put(SvxPostItAuthorItem(pRedline
->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR
));
416 aSet
.Put( SvxPostItDateItem( GetAppLangDateTimeString(
417 pRedline
->GetRedlineData().GetTimeStamp() ),
418 SID_ATTR_POSTIT_DATE
));
420 // Traveling only if more than one field.
424 const SwRedline
*pActRed
= rSh
.SelPrevRedline();
426 if (pActRed
== pRedline
)
427 { // New cursor is at the beginning of the current redlines.
428 rSh
.Pop(); // Throw old cursor away
430 pActRed
= rSh
.SelPrevRedline();
433 sal_Bool bPrev
= pActRed
!= 0;
438 rSh
.SelNextRedline(); // Select current redline.
442 pActRed
= rSh
.SelNextRedline();
443 sal_Bool bNext
= pActRed
!= 0;
444 rSh
.Pop(sal_False
); // Restore cursor position
446 if( rSh
.IsCrsrPtAtEnd() )
451 bTravel
|= bNext
|bPrev
;
453 SvxAbstractDialogFactory
* pFact2
= SvxAbstractDialogFactory::Create();
454 OSL_ENSURE(pFact2
, "Dialogdiet fail!");
455 AbstractSvxPostItDialog
* pDlg
= pFact2
->CreateSvxPostItDialog( pMDI
, aSet
, bTravel
);
456 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
459 String
sTitle(SW_RES(STR_REDLINE_COMMENT
));
460 ::lcl_AppendRedlineStr( sTitle
, pRedline
->GetType() );
462 pDlg
->SetText(sTitle
);
466 pDlg
->EnableTravel(bNext
, bPrev
);
467 pDlg
->SetPrevHdl(LINK(this, SwTextShell
, RedlinePrevHdl
));
468 pDlg
->SetNextHdl(LINK(this, SwTextShell
, RedlineNextHdl
));
471 rSh
.SetCareWin(pDlg
->GetWindow());
474 if ( pDlg
->Execute() == RET_OK
)
476 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
477 String
sMsg(((const SvxPostItTextItem
&)pOutSet
->Get(SID_ATTR_POSTIT_TEXT
)).GetValue());
479 // Insert or change a comment
480 rSh
.SetRedlineComment(sMsg
);
484 rSh
.SetCareWin(NULL
);
485 bNoInterrupt
= false;
487 GetView().AttrChangedNotify(GetShellPtr());
494 OUString aType
, aText
;
495 sal_Bool bIsUrl
=sal_False
;
496 sal_Bool bNew
=sal_False
;
497 bool bUpdate
= false;
498 SwFldMgr
* pMgr
= new SwFldMgr
;
501 aText
= ((SfxStringItem
*)pItem
)->GetValue();
502 SFX_REQUEST_ARG( rReq
, pType
, SfxStringItem
, FN_PARAM_2
, sal_False
);
503 SFX_REQUEST_ARG( rReq
, pIsUrl
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
505 aType
= pType
->GetValue();
507 bIsUrl
= pIsUrl
->GetValue();
509 SwScriptField
* pFld
= (SwScriptField
*)pMgr
->GetCurFld();
510 bNew
= !pFld
|| !(pFld
->GetTyp()->Which() == RES_SCRIPTFLD
);
511 bUpdate
= pFld
&& ( bIsUrl
!= pFld
->GetFormat() || pFld
->GetPar2() != aType
|| pFld
->GetPar1() != aText
);
515 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
516 OSL_ENSURE(pFact
, "Dialogdiet fail!");
517 AbstractJavaEditDialog
* pDlg
= pFact
->CreateJavaEditDialog(pMDI
, &rSh
);
518 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
519 if ( pDlg
->Execute() )
521 aType
= pDlg
->GetType();
522 aText
= pDlg
->GetText();
523 bIsUrl
= pDlg
->IsUrl();
524 bNew
= pDlg
->IsNew();
525 bUpdate
= pDlg
->IsUpdate();
526 rReq
.AppendItem( SfxStringItem( FN_JAVAEDIT
, aText
) );
527 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, aType
) );
528 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bIsUrl
) );
536 SwInsertFld_Data
aData(TYP_SCRIPTFLD
, 0, aType
, aText
, bIsUrl
);
537 pMgr
->InsertFld(aData
);
542 pMgr
->UpdateCurFld( bIsUrl
, aType
, aText
);
543 rSh
.SetUndoNoResetModified();
551 case FN_INSERT_FLD_DATE
:
552 nInsertType
= TYP_DATEFLD
;
555 case FN_INSERT_FLD_TIME
:
556 nInsertType
= TYP_TIMEFLD
;
559 case FN_INSERT_FLD_PGNUMBER
:
560 nInsertType
= TYP_PAGENUMBERFLD
;
561 nInsertFormat
= SVX_NUM_PAGEDESC
; // Like page template
564 case FN_INSERT_FLD_PGCOUNT
:
565 nInsertType
= TYP_DOCSTATFLD
;
568 nInsertFormat
= SVX_NUM_PAGEDESC
;
570 case FN_INSERT_FLD_TOPIC
:
571 nInsertType
= TYP_DOCINFOFLD
;
572 nInsertSubType
= DI_THEMA
;
574 case FN_INSERT_FLD_TITLE
:
575 nInsertType
= TYP_DOCINFOFLD
;
576 nInsertSubType
= DI_TITEL
;
578 case FN_INSERT_FLD_AUTHOR
:
579 nInsertType
= TYP_DOCINFOFLD
;
580 nInsertSubType
= DI_CREATE
|DI_SUB_AUTHOR
;
584 //format conversion should only be done for number formatter formats
586 nInsertFormat
= aFldMgr
.GetDefaultFormat(nInsertType
, bIsText
, rSh
.GetNumberFormatter());
587 SwInsertFld_Data
aData(nInsertType
, nInsertSubType
,
588 aEmptyStr
, aEmptyStr
, nInsertFormat
);
589 aFldMgr
.InsertFld(aData
);
594 OSL_FAIL("wrong dispatcher");
600 void SwTextShell::StateField( SfxItemSet
&rSet
)
602 SwWrtShell
& rSh
= GetShell();
603 SfxWhichIter
aIter( rSet
);
604 const SwField
* pField
= 0;
605 int bGetField
= sal_False
;
606 sal_uInt16 nWhich
= aIter
.FirstWhich();
612 case FN_DELETE_COMMENT
:
613 case FN_DELETE_NOTE_AUTHOR
:
614 case FN_DELETE_ALL_NOTES
:
616 case FN_HIDE_NOTE_AUTHOR
:
617 case FN_HIDE_ALL_NOTES
:
619 SwPostItMgr
* pPostItMgr
= GetView().GetPostItMgr();
621 rSet
.InvalidateItem( nWhich
);
622 else if ( !pPostItMgr
->HasActiveSidebarWin() )
624 rSet
.InvalidateItem( FN_DELETE_COMMENT
);
625 rSet
.InvalidateItem( FN_HIDE_NOTE
);
634 pField
= rSh
.GetCurFld();
635 bGetField
= sal_True
;
638 sal_uInt16 nTempWhich
= pField
? pField
->GetTyp()->Which() : USHRT_MAX
;
639 if( USHRT_MAX
== nTempWhich
||
640 RES_POSTITFLD
== nTempWhich
||
641 RES_SCRIPTFLD
== nTempWhich
||
642 RES_AUTHORITY
== nTempWhich
)
643 rSet
.DisableItem( nWhich
);
644 else if( RES_DDEFLD
== nTempWhich
&&
645 !((SwDDEFieldType
*)pField
->GetTyp())->GetBaseLink().IsVisible())
647 // nested links cannot be edited
648 rSet
.DisableItem( nWhich
);
652 case FN_EXECUTE_MACROFIELD
:
656 pField
= rSh
.GetCurFld();
657 bGetField
= sal_True
;
659 if(!pField
|| pField
->GetTyp()->Which() != RES_MACROFLD
)
660 rSet
.DisableItem(nWhich
);
664 case FN_INSERT_FIELD
:
666 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
667 //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
668 if(!pVFrame
->IsInModalMode() &&
669 pVFrame
->KnowsChildWindow(FN_INSERT_FIELD
) && !pVFrame
->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY
) )
670 rSet
.Put(SfxBoolItem( FN_INSERT_FIELD
, pVFrame
->HasChildWindow(nWhich
)));
672 rSet
.DisableItem(FN_INSERT_FIELD
);
675 case FN_INSERT_REF_FIELD
:
677 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
678 if (!pVFrame
->KnowsChildWindow(FN_INSERT_FIELD
))
679 rSet
.DisableItem(FN_INSERT_REF_FIELD
);
682 case FN_INSERT_FIELD_CTRL
:
683 rSet
.Put(SfxBoolItem( nWhich
, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD
)));
685 case FN_REDLINE_COMMENT
:
686 if (!rSh
.GetCurrRedline())
687 rSet
.DisableItem(nWhich
);
691 bool bCurField
= false;
692 pField
= rSh
.GetCurFld();
693 if(nWhich
== FN_POSTIT
)
694 bCurField
= pField
&& pField
->GetTyp()->Which() == RES_POSTITFLD
;
696 bCurField
= pField
&& pField
->GetTyp()->Which() == RES_SCRIPTFLD
;
698 if(!bCurField
&& rSh
.IsReadOnlyAvailable() && rSh
.HasReadonlySel() )
699 rSet
.DisableItem(nWhich
);
702 nWhich
= aIter
.NextWhich();
706 void SwTextShell::InsertHyperlink(const SvxHyperlinkItem
& rHlnkItem
)
708 const String
& rName
= rHlnkItem
.GetName();
709 const String
& rURL
= rHlnkItem
.GetURL();
710 const String
& rTarget
= rHlnkItem
.GetTargetFrame();
711 sal_uInt16 nType
= (sal_uInt16
)rHlnkItem
.GetInsertMode();
712 nType
&= ~HLINK_HTMLMODE
;
713 const SvxMacroTableDtor
* pMacroTbl
= rHlnkItem
.GetMacroTbl();
715 SwWrtShell
& rSh
= GetShell();
717 if( rSh
.GetSelectionType() & nsSelectionType::SEL_TXT
)
720 SfxItemSet
aSet(GetPool(), RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
);
721 rSh
.GetCurAttr( aSet
);
723 const SfxPoolItem
* pItem
;
724 if(SFX_ITEM_SET
== aSet
.GetItemState(RES_TXTATR_INETFMT
, sal_False
, &pItem
))
727 rSh
.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT
, sal_False
);
734 SwFmtINetFmt
aINetFmt( rURL
, rTarget
);
735 aINetFmt
.SetName(rHlnkItem
.GetIntName());
738 const SvxMacro
*pMacro
= pMacroTbl
->Get( SFX_EVENT_MOUSEOVER_OBJECT
);
740 aINetFmt
.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT
, *pMacro
);
741 pMacro
= pMacroTbl
->Get( SFX_EVENT_MOUSECLICK_OBJECT
);
743 aINetFmt
.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT
, *pMacro
);
744 pMacro
= pMacroTbl
->Get( SFX_EVENT_MOUSEOUT_OBJECT
);
746 aINetFmt
.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT
, *pMacro
);
749 rSh
.InsertURL( aINetFmt
, rName
, sal_True
);
755 sal_Bool bSel
= rSh
.HasSelection();
758 InsertURLButton( rURL
, rTarget
, rName
);
766 IMPL_LINK( SwTextShell
, RedlineNextHdl
, AbstractSvxPostItDialog
*, pBtn
)
768 SwWrtShell
* pSh
= GetShellPtr();
769 AbstractSvxPostItDialog
*pDlg
= (AbstractSvxPostItDialog
*)pBtn
;
771 // Insert or change a comment.
772 pSh
->SetRedlineComment(pDlg
->GetNote());
774 const SwRedline
*pRedline
= pSh
->GetCurrRedline();
778 // Traveling only if more than one field.
779 if( !pSh
->IsCrsrPtAtEnd() )
780 pSh
->SwapPam(); // Move the cursor behind the Redline.
783 const SwRedline
*pActRed
= pSh
->SelNextRedline();
784 pSh
->Pop(pActRed
!= 0);
786 sal_Bool bEnable
= sal_False
;
792 bEnable
= pSh
->SelNextRedline() != 0;
797 pDlg
->EnableTravel(bEnable
, sal_True
);
799 if( pSh
->IsCrsrPtAtEnd() )
802 pRedline
= pSh
->GetCurrRedline();
803 OUString sComment
= convertLineEnd(pRedline
->GetComment(), GetSystemLineEnd());
805 pDlg
->SetNote(sComment
);
806 pDlg
->ShowLastAuthor( pRedline
->GetAuthorString(),
807 GetAppLangDateTimeString(
808 pRedline
->GetRedlineData().GetTimeStamp() ));
810 String
sTitle(SW_RES(STR_REDLINE_COMMENT
));
811 ::lcl_AppendRedlineStr( sTitle
, pRedline
->GetType() );
813 pDlg
->SetText(sTitle
);
819 IMPL_LINK( SwTextShell
, RedlinePrevHdl
, AbstractSvxPostItDialog
*, pBtn
)
821 SwWrtShell
* pSh
= GetShellPtr();
822 AbstractSvxPostItDialog
*pDlg
= (AbstractSvxPostItDialog
*)pBtn
;
824 // Insert or change a comment.
825 pSh
->SetRedlineComment(pDlg
->GetNote());
827 const SwRedline
*pRedline
= pSh
->GetCurrRedline();
831 // Traveling only if more than one field.
833 const SwRedline
*pActRed
= pSh
->SelPrevRedline();
834 pSh
->Pop(pActRed
!= 0);
836 sal_Bool bEnable
= sal_False
;
842 bEnable
= pSh
->SelPrevRedline() != 0;
847 pDlg
->EnableTravel(sal_True
, bEnable
);
849 pRedline
= pSh
->GetCurrRedline();
850 OUString sComment
= convertLineEnd(pRedline
->GetComment(), GetSystemLineEnd());
852 pDlg
->SetNote(sComment
);
853 pDlg
->ShowLastAuthor(pRedline
->GetAuthorString(),
854 GetAppLangDateTimeString(
855 pRedline
->GetRedlineData().GetTimeStamp() ));
857 String
sTitle(SW_RES(STR_REDLINE_COMMENT
));
858 ::lcl_AppendRedlineStr( sTitle
, pRedline
->GetType() );
860 pDlg
->SetText(sTitle
);
866 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */