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