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