1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <crsskip.hxx>
26cdf0e10cSrcweir #include <hintids.hxx> //_immer_ vor den solar-Items
27cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
28cdf0e10cSrcweir #include <fmtfld.hxx>
29cdf0e10cSrcweir #include <tools/urlobj.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <svl/itempool.hxx>
32cdf0e10cSrcweir #include <unotools/useroptions.hxx>
33cdf0e10cSrcweir #include <svl/whiter.hxx>
34cdf0e10cSrcweir #include <svl/eitem.hxx>
35cdf0e10cSrcweir #include <svl/macitem.hxx>
36cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
37cdf0e10cSrcweir #include <sfx2/request.hxx>
38cdf0e10cSrcweir #include <svx/postattr.hxx>
39cdf0e10cSrcweir #include <svx/hlnkitem.hxx>
40cdf0e10cSrcweir #include <svx/svxdlg.hxx>
41cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
42cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
43cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
44cdf0e10cSrcweir #include <fmtinfmt.hxx>
45cdf0e10cSrcweir #include <fldwrap.hxx>
46cdf0e10cSrcweir #include <redline.hxx>
47cdf0e10cSrcweir #include <view.hxx>
4869a74367SOliver-Rainer Wittmann #include <viewopt.hxx>
49cdf0e10cSrcweir #include <wrtsh.hxx>
50cdf0e10cSrcweir #include <basesh.hxx>
51cdf0e10cSrcweir #include <wrtsh.hxx>
52cdf0e10cSrcweir #include <flddat.hxx>
53cdf0e10cSrcweir #include <numrule.hxx>
54cdf0e10cSrcweir #include <textsh.hxx>
55cdf0e10cSrcweir #include <docsh.hxx>
56cdf0e10cSrcweir #include <docufld.hxx>
57cdf0e10cSrcweir #include <usrfld.hxx>
58cdf0e10cSrcweir #include <ddefld.hxx>
59cdf0e10cSrcweir #include <expfld.hxx>
60cdf0e10cSrcweir #include <fldmgr.hxx>
61cdf0e10cSrcweir #include <uitool.hxx>
62cdf0e10cSrcweir #include <cmdid.h>
63cdf0e10cSrcweir #include <shells.hrc>
64cdf0e10cSrcweir #include <sfx2/app.hxx>
65cdf0e10cSrcweir #include <svx/svxdlg.hxx>
66cdf0e10cSrcweir #include <svx/dialogs.hrc>
67cdf0e10cSrcweir #include "swabstdlg.hxx"
68cdf0e10cSrcweir #include "dialog.hrc"
69cdf0e10cSrcweir #include <fldui.hrc>
70cdf0e10cSrcweir #include <doc.hxx>
71cdf0e10cSrcweir #include <app.hrc>
724e0030b2SArmin Le Grand #include <edtwin.hxx>
73cdf0e10cSrcweir #include <PostItMgr.hxx>
74cdf0e10cSrcweir #include <switerator.hxx>
75cdf0e10cSrcweir
76cdf0e10cSrcweir using namespace nsSwDocInfoSubType;
77cdf0e10cSrcweir
78cdf0e10cSrcweir extern sal_Bool bNoInterrupt; // in mainwn.cxx
79cdf0e10cSrcweir
lcl_AppendRedlineStr(String & rStr,sal_uInt16 nRedlId)80cdf0e10cSrcweir String& lcl_AppendRedlineStr( String& rStr, sal_uInt16 nRedlId )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir sal_uInt16 nResId = 0;
83cdf0e10cSrcweir switch( nRedlId )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir case nsRedlineType_t::REDLINE_INSERT: nResId = STR_REDLINE_INSERTED; break;
86cdf0e10cSrcweir case nsRedlineType_t::REDLINE_DELETE: nResId = STR_REDLINE_DELETED; break;
87cdf0e10cSrcweir case nsRedlineType_t::REDLINE_FORMAT: nResId = STR_REDLINE_FORMATED; break;
88cdf0e10cSrcweir case nsRedlineType_t::REDLINE_TABLE: nResId = STR_REDLINE_TABLECHG; break;
89cdf0e10cSrcweir case nsRedlineType_t::REDLINE_FMTCOLL: nResId = STR_REDLINE_FMTCOLLSET; break;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir if( nResId )
92cdf0e10cSrcweir rStr += SW_RESSTR( nResId );
93cdf0e10cSrcweir return rStr;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
97cdf0e10cSrcweir
ExecField(SfxRequest & rReq)98cdf0e10cSrcweir void SwTextShell::ExecField(SfxRequest &rReq)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir SwWrtShell& rSh = GetShell();
101cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
102cdf0e10cSrcweir
103cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
104cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
105cdf0e10cSrcweir if(pArgs)
106cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
107cdf0e10cSrcweir
108cdf0e10cSrcweir Window *pMDI = &GetView().GetViewFrame()->GetWindow();
109cdf0e10cSrcweir sal_Bool bMore = sal_False;
110cdf0e10cSrcweir sal_Bool bIsText = sal_True;
111cdf0e10cSrcweir sal_uInt16 nInsertType = 0;
112cdf0e10cSrcweir sal_uInt16 nInsertSubType = 0;
113cdf0e10cSrcweir sal_uLong nInsertFormat = 0;
114cdf0e10cSrcweir
115cdf0e10cSrcweir switch(nSlot)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir case FN_EDIT_FIELD:
118cdf0e10cSrcweir {
119cdf0e10cSrcweir SwField* pFld = rSh.GetCurFld();
120cdf0e10cSrcweir if( pFld )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir switch ( pFld->GetTypeId() )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir case TYP_DDEFLD:
125cdf0e10cSrcweir {
126cdf0e10cSrcweir ::sfx2::SvBaseLink& rLink = ((SwDDEFieldType*)pFld->GetTyp())->
127cdf0e10cSrcweir GetBaseLink();
128cdf0e10cSrcweir if(rLink.IsVisible())
129cdf0e10cSrcweir {
130cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
131cdf0e10cSrcweir SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pMDI, &rSh.GetLinkManager(), sal_False, &rLink );
132cdf0e10cSrcweir if ( pDlg )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir pDlg->Execute();
135cdf0e10cSrcweir delete pDlg;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir }
138cdf0e10cSrcweir break;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir default:
141cdf0e10cSrcweir {
142cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
143cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
144cdf0e10cSrcweir
145cdf0e10cSrcweir SfxAbstractDialog* pDlg = pFact->CreateSwFldEditDlg( GetView(),RC_DLG_SWFLDEDITDLG );
146cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
147cdf0e10cSrcweir pDlg->Execute();
148cdf0e10cSrcweir delete pDlg;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir case FN_EXECUTE_MACROFIELD:
155cdf0e10cSrcweir {
156cdf0e10cSrcweir SwField* pFld = rSh.GetCurFld();
157cdf0e10cSrcweir if(pFld && pFld->GetTyp()->Which() == RES_MACROFLD)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir
160cdf0e10cSrcweir const String& rMacro = ((SwMacroField*)pFld)->GetMacro();
161cdf0e10cSrcweir sal_uInt16 nPos = rMacro.Search('.', 0);
162cdf0e10cSrcweir if(nPos != STRING_NOTFOUND)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir SvxMacro aMacro( rMacro.Copy(nPos + 1), rMacro.Copy(0,nPos), STARBASIC );
165cdf0e10cSrcweir rSh.ExecMacro(aMacro);
166cdf0e10cSrcweir }
167cdf0e10cSrcweir }
168cdf0e10cSrcweir }
169cdf0e10cSrcweir break;
170cdf0e10cSrcweir
17169a74367SOliver-Rainer Wittmann case FN_GOTO_NEXT_INPUTFLD:
17269a74367SOliver-Rainer Wittmann case FN_GOTO_PREV_INPUTFLD:
17369a74367SOliver-Rainer Wittmann {
17469a74367SOliver-Rainer Wittmann sal_Bool bRet = sal_False;
17569a74367SOliver-Rainer Wittmann SwFieldType* pFld = rSh.GetFldType( 0, RES_INPUTFLD );
17669a74367SOliver-Rainer Wittmann const bool bAddSetExpressionFlds = !( rSh.GetViewOptions()->IsReadonly() );
17769a74367SOliver-Rainer Wittmann if ( pFld != NULL
17869a74367SOliver-Rainer Wittmann && rSh.MoveFldType(
17969a74367SOliver-Rainer Wittmann pFld,
18069a74367SOliver-Rainer Wittmann FN_GOTO_NEXT_INPUTFLD == nSlot,
18169a74367SOliver-Rainer Wittmann USHRT_MAX,
18269a74367SOliver-Rainer Wittmann bAddSetExpressionFlds ) )
18369a74367SOliver-Rainer Wittmann {
18469a74367SOliver-Rainer Wittmann rSh.ClearMark();
18569a74367SOliver-Rainer Wittmann if ( dynamic_cast<SwInputField*>(rSh.GetCurFld( true )) != NULL )
18669a74367SOliver-Rainer Wittmann {
18769a74367SOliver-Rainer Wittmann rSh.SttSelect();
18869a74367SOliver-Rainer Wittmann rSh.SelectTxt(
18969a74367SOliver-Rainer Wittmann rSh.StartOfInputFldAtPos( *(rSh.GetCrsr()->Start()) ) + 1,
19069a74367SOliver-Rainer Wittmann rSh.EndOfInputFldAtPos( *(rSh.GetCrsr()->Start()) ) - 1 );
19169a74367SOliver-Rainer Wittmann }
19269a74367SOliver-Rainer Wittmann else
19369a74367SOliver-Rainer Wittmann {
19469a74367SOliver-Rainer Wittmann rSh.StartInputFldDlg( rSh.GetCurFld( true ), sal_False );
19569a74367SOliver-Rainer Wittmann }
19669a74367SOliver-Rainer Wittmann bRet = sal_True;
19769a74367SOliver-Rainer Wittmann }
198cdf0e10cSrcweir
19969a74367SOliver-Rainer Wittmann rReq.SetReturnValue( SfxBoolItem( nSlot, bRet ));
20069a74367SOliver-Rainer Wittmann }
20169a74367SOliver-Rainer Wittmann break;
202cdf0e10cSrcweir
203cdf0e10cSrcweir default:
204cdf0e10cSrcweir bMore = sal_True;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir if(bMore)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir // hier kommen die Slots mit FldMgr
209cdf0e10cSrcweir SwFldMgr aFldMgr(GetShellPtr());
210cdf0e10cSrcweir switch(nSlot)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir case FN_INSERT_DBFIELD:
213cdf0e10cSrcweir {
214cdf0e10cSrcweir sal_Bool bRes = sal_False;
215cdf0e10cSrcweir if( pItem )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir sal_uLong nFormat = 0;
218cdf0e10cSrcweir sal_uInt16 nType = 0;
219cdf0e10cSrcweir String aPar1 = ((SfxStringItem *)pItem)->GetValue();
220cdf0e10cSrcweir String aPar2;
221cdf0e10cSrcweir sal_Int32 nCommand = 0;
222cdf0e10cSrcweir
223cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE,
224cdf0e10cSrcweir sal_False, &pItem ))
225cdf0e10cSrcweir nType = ((SfxUInt16Item *)pItem)->GetValue();
226cdf0e10cSrcweir aPar1 += DB_DELIM;
227cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
228cdf0e10cSrcweir FN_PARAM_1, sal_False, &pItem ))
229cdf0e10cSrcweir {
230cdf0e10cSrcweir aPar1 += ((SfxStringItem *)pItem)->GetValue();
231cdf0e10cSrcweir }
232cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
233cdf0e10cSrcweir FN_PARAM_3, sal_False, &pItem ))
234cdf0e10cSrcweir nCommand = ((SfxInt32Item*)pItem)->GetValue();
235cdf0e10cSrcweir aPar1 += DB_DELIM;
236cdf0e10cSrcweir aPar1 += String::CreateFromInt32(nCommand);
237cdf0e10cSrcweir aPar1 += DB_DELIM;
238cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
239cdf0e10cSrcweir FN_PARAM_2, sal_False, &pItem ))
240cdf0e10cSrcweir {
241cdf0e10cSrcweir aPar1 += ((SfxStringItem *)pItem)->GetValue();
242cdf0e10cSrcweir }
243cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
244cdf0e10cSrcweir FN_PARAM_FIELD_CONTENT, sal_False, &pItem ))
245cdf0e10cSrcweir aPar2 = ((SfxStringItem *)pItem)->GetValue();
246cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
247cdf0e10cSrcweir FN_PARAM_FIELD_FORMAT, sal_False, &pItem ))
248cdf0e10cSrcweir nFormat = ((SfxUInt32Item *)pItem)->GetValue();
249cdf0e10cSrcweir DBG_WARNING("Command is not yet used");
250cdf0e10cSrcweir sal_Unicode cSeparator = ' ';
251cdf0e10cSrcweir SwInsertFld_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator );
252cdf0e10cSrcweir bRes = aFldMgr.InsertFld(aData);
253cdf0e10cSrcweir }
254cdf0e10cSrcweir rReq.SetReturnValue(SfxBoolItem( nSlot, bRes ));
255cdf0e10cSrcweir }
256cdf0e10cSrcweir break;
257cdf0e10cSrcweir case FN_INSERT_FIELD_CTRL:
258cdf0e10cSrcweir case FN_INSERT_FIELD:
259cdf0e10cSrcweir {
260cdf0e10cSrcweir sal_Bool bRes = sal_False;
261cdf0e10cSrcweir if( pItem && nSlot != FN_INSERT_FIELD_CTRL)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir sal_uLong nFormat = 0;
264cdf0e10cSrcweir sal_uInt16 nType = 0;
265cdf0e10cSrcweir sal_uInt16 nSubType = 0;
266cdf0e10cSrcweir String aPar1 = ((SfxStringItem *)pItem)->GetValue();
267cdf0e10cSrcweir String aPar2;
268cdf0e10cSrcweir sal_Unicode cSeparator = ' ';
269cdf0e10cSrcweir
270cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE,
271cdf0e10cSrcweir sal_False, &pItem ))
272cdf0e10cSrcweir nType = ((SfxUInt16Item *)pItem)->GetValue();
273cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE,
274cdf0e10cSrcweir sal_False, &pItem ))
275cdf0e10cSrcweir nSubType = ((SfxUInt16Item *)pItem)->GetValue();
276cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
277cdf0e10cSrcweir FN_PARAM_FIELD_CONTENT, sal_False, &pItem ))
278cdf0e10cSrcweir aPar2 = ((SfxStringItem *)pItem)->GetValue();
279cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
280cdf0e10cSrcweir FN_PARAM_FIELD_FORMAT, sal_False, &pItem ))
281cdf0e10cSrcweir nFormat = ((SfxUInt32Item *)pItem)->GetValue();
282cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState(
283cdf0e10cSrcweir FN_PARAM_3, sal_False, &pItem ))
284cdf0e10cSrcweir {
285cdf0e10cSrcweir String sTmp = ((SfxStringItem *)pItem)->GetValue();
286cdf0e10cSrcweir if(sTmp.Len())
287cdf0e10cSrcweir cSeparator = sTmp.GetChar(0);
288cdf0e10cSrcweir }
289cdf0e10cSrcweir SwInsertFld_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator );
290cdf0e10cSrcweir bRes = aFldMgr.InsertFld( aData );
291cdf0e10cSrcweir }
292cdf0e10cSrcweir else
293cdf0e10cSrcweir //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
294cdf0e10cSrcweir if(!GetView().GetViewFrame()->IsInModalMode())
295cdf0e10cSrcweir {
296cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame();
297cdf0e10cSrcweir pVFrame->ToggleChildWindow(FN_INSERT_FIELD);
298cdf0e10cSrcweir bRes = pVFrame->GetChildWindow( nSlot ) != 0;
299cdf0e10cSrcweir Invalidate(rReq.GetSlot());
300cdf0e10cSrcweir Invalidate(FN_INSERT_FIELD_CTRL);
301cdf0e10cSrcweir rReq.Ignore();
302cdf0e10cSrcweir }
303cdf0e10cSrcweir rReq.SetReturnValue(SfxBoolItem( nSlot, bRes ));
304cdf0e10cSrcweir }
305cdf0e10cSrcweir break;
306cdf0e10cSrcweir
307cdf0e10cSrcweir case FN_INSERT_REF_FIELD:
308cdf0e10cSrcweir {
309cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame();
310cdf0e10cSrcweir if (!pVFrame->HasChildWindow(FN_INSERT_FIELD))
311cdf0e10cSrcweir pVFrame->ToggleChildWindow(FN_INSERT_FIELD); // Dialog anzeigen
312cdf0e10cSrcweir
313cdf0e10cSrcweir // Flddlg auf neue TabPage umschalten
314cdf0e10cSrcweir sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
315cdf0e10cSrcweir SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
316cdf0e10cSrcweir if (pWrp)
317cdf0e10cSrcweir pWrp->ShowPage();
318cdf0e10cSrcweir rReq.Ignore();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir break;
321cdf0e10cSrcweir case FN_DELETE_COMMENT:
322cdf0e10cSrcweir if ( GetView().GetPostItMgr() &&
323cdf0e10cSrcweir GetView().GetPostItMgr()->HasActiveSidebarWin() )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir GetView().GetPostItMgr()->DeleteActiveSidebarWin();
326cdf0e10cSrcweir }
327cdf0e10cSrcweir break;
328cdf0e10cSrcweir case FN_DELETE_ALL_NOTES:
329cdf0e10cSrcweir if ( GetView().GetPostItMgr() )
330cdf0e10cSrcweir GetView().GetPostItMgr()->Delete();
331cdf0e10cSrcweir break;
332cdf0e10cSrcweir case FN_DELETE_NOTE_AUTHOR:
333cdf0e10cSrcweir {
334cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, sal_False);
335cdf0e10cSrcweir if ( pNoteItem && GetView().GetPostItMgr() )
336cdf0e10cSrcweir GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() );
337cdf0e10cSrcweir }
338cdf0e10cSrcweir break;
339cdf0e10cSrcweir case FN_HIDE_NOTE:
340cdf0e10cSrcweir if ( GetView().GetPostItMgr() &&
341cdf0e10cSrcweir GetView().GetPostItMgr()->HasActiveSidebarWin() )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir GetView().GetPostItMgr()->HideActiveSidebarWin();
344cdf0e10cSrcweir }
345cdf0e10cSrcweir break;
346cdf0e10cSrcweir case FN_HIDE_ALL_NOTES:
347cdf0e10cSrcweir if ( GetView().GetPostItMgr() )
348cdf0e10cSrcweir GetView().GetPostItMgr()->Hide();
349cdf0e10cSrcweir break;
350cdf0e10cSrcweir case FN_HIDE_NOTE_AUTHOR:
351cdf0e10cSrcweir {
352cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNoteItem, SfxStringItem, nSlot, sal_False);
353cdf0e10cSrcweir if ( pNoteItem && GetView().GetPostItMgr() )
354cdf0e10cSrcweir GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir break;
357cdf0e10cSrcweir
3583b32dd21SOliver-Rainer Wittmann case FN_POSTIT:
3593b32dd21SOliver-Rainer Wittmann {
3603b32dd21SOliver-Rainer Wittmann SwPostItField* pPostIt = dynamic_cast<SwPostItField*>(aFldMgr.GetCurFld());
3613b32dd21SOliver-Rainer Wittmann sal_Bool bNew = !(pPostIt && pPostIt->GetTyp()->Which() == RES_POSTITFLD);
3623b32dd21SOliver-Rainer Wittmann if (bNew || GetView().GetPostItMgr()->IsAnswer())
3633b32dd21SOliver-Rainer Wittmann {
3643b32dd21SOliver-Rainer Wittmann SvtUserOptions aUserOpt;
3653b32dd21SOliver-Rainer Wittmann String sAuthor;
3663b32dd21SOliver-Rainer Wittmann if( !(sAuthor = aUserOpt.GetFullName()).Len())
3673b32dd21SOliver-Rainer Wittmann if( !(sAuthor = aUserOpt.GetID()).Len() )
3683b32dd21SOliver-Rainer Wittmann sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
3693b32dd21SOliver-Rainer Wittmann
370*332f371aSOliver-Rainer Wittmann if ( rSh.HasSelection() && !rSh.IsTableMode() )
3713b32dd21SOliver-Rainer Wittmann {
3723b32dd21SOliver-Rainer Wittmann rSh.KillPams();
3733b32dd21SOliver-Rainer Wittmann }
3743b32dd21SOliver-Rainer Wittmann
3753b32dd21SOliver-Rainer Wittmann // #120513# Inserting a comment into an autocompletion crashes
3763b32dd21SOliver-Rainer Wittmann // --> suggestion has to be removed before
3773b32dd21SOliver-Rainer Wittmann GetView().GetEditWin().StopQuickHelp();
3783b32dd21SOliver-Rainer Wittmann
3793b32dd21SOliver-Rainer Wittmann SwInsertFld_Data aData(TYP_POSTITFLD, 0, sAuthor, aEmptyStr, 0);
380dec99bbdSOliver-Rainer Wittmann aFldMgr.InsertFld( aData );
3813b32dd21SOliver-Rainer Wittmann
3823b32dd21SOliver-Rainer Wittmann rSh.Push();
3833b32dd21SOliver-Rainer Wittmann rSh.SwCrsrShell::Left(1, CRSR_SKIP_CHARS, sal_False);
3843b32dd21SOliver-Rainer Wittmann pPostIt = (SwPostItField*)aFldMgr.GetCurFld();
3853b32dd21SOliver-Rainer Wittmann rSh.Pop(sal_False); // Cursorpos restaurieren
3863b32dd21SOliver-Rainer Wittmann }
3873b32dd21SOliver-Rainer Wittmann
3883b32dd21SOliver-Rainer Wittmann if (pPostIt)
3893b32dd21SOliver-Rainer Wittmann {
3903b32dd21SOliver-Rainer Wittmann SwFieldType* pType = rSh.GetDoc()->GetFldType(RES_POSTITFLD, aEmptyStr,false);
3913b32dd21SOliver-Rainer Wittmann SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
3923b32dd21SOliver-Rainer Wittmann SwFmtFld* pSwFmtFld = aIter.First();
3933b32dd21SOliver-Rainer Wittmann while( pSwFmtFld )
3943b32dd21SOliver-Rainer Wittmann {
3953b32dd21SOliver-Rainer Wittmann if ( pSwFmtFld->GetField() == pPostIt )
3963b32dd21SOliver-Rainer Wittmann {
3973b32dd21SOliver-Rainer Wittmann pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) );
3983b32dd21SOliver-Rainer Wittmann break;
3993b32dd21SOliver-Rainer Wittmann }
4003b32dd21SOliver-Rainer Wittmann pSwFmtFld = aIter.Next();
4013b32dd21SOliver-Rainer Wittmann }
4023b32dd21SOliver-Rainer Wittmann }
4033b32dd21SOliver-Rainer Wittmann }
4043b32dd21SOliver-Rainer Wittmann break;
4053b32dd21SOliver-Rainer Wittmann
406cdf0e10cSrcweir case FN_REDLINE_COMMENT:
407cdf0e10cSrcweir {
408cdf0e10cSrcweir /* this code can be used once we want redline comments in the margin, all other stuff can
409cdf0e10cSrcweir then be deleted
410cdf0e10cSrcweir String sComment;
411cdf0e10cSrcweir const SwRedline *pRedline = rSh.GetCurrRedline();
412cdf0e10cSrcweir
413cdf0e10cSrcweir if (pRedline)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir sComment = pRedline->GetComment();
416cdf0e10cSrcweir if ( sComment == String(rtl::OUString::createFromAscii("")) )
417cdf0e10cSrcweir GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED));
418cdf0e10cSrcweir const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView()));
419cdf0e10cSrcweir }
420cdf0e10cSrcweir */
421cdf0e10cSrcweir
422cdf0e10cSrcweir String sComment;
423cdf0e10cSrcweir const SwRedline *pRedline = rSh.GetCurrRedline();
424cdf0e10cSrcweir
425cdf0e10cSrcweir if (pRedline)
426cdf0e10cSrcweir {
427cdf0e10cSrcweir sComment = pRedline->GetComment();
428cdf0e10cSrcweir
429cdf0e10cSrcweir
430cdf0e10cSrcweir sal_Bool bTravel = sal_False;
431cdf0e10cSrcweir
432cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
433cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");
434cdf0e10cSrcweir ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT );
435cdf0e10cSrcweir DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()");
436cdf0e10cSrcweir SfxItemSet aSet(GetPool(), fnGetRange());
437cdf0e10cSrcweir aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT));
438cdf0e10cSrcweir aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR));
439cdf0e10cSrcweir
440cdf0e10cSrcweir aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString(
441cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() ),
442cdf0e10cSrcweir SID_ATTR_POSTIT_DATE ));
443cdf0e10cSrcweir
444cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld
445cdf0e10cSrcweir rSh.StartAction();
446cdf0e10cSrcweir
447cdf0e10cSrcweir rSh.Push();
448cdf0e10cSrcweir const SwRedline *pActRed = rSh.SelPrevRedline();
449cdf0e10cSrcweir
450cdf0e10cSrcweir if (pActRed == pRedline)
451cdf0e10cSrcweir { // Neuer Cursor steht am Anfang des Current Redlines
452cdf0e10cSrcweir rSh.Pop(); // Alten Cursor wegwerfen
453cdf0e10cSrcweir rSh.Push();
454cdf0e10cSrcweir pActRed = rSh.SelPrevRedline();
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir sal_Bool bPrev = pActRed != 0;
458cdf0e10cSrcweir rSh.Pop(sal_False);
459cdf0e10cSrcweir rSh.EndAction();
460cdf0e10cSrcweir
461cdf0e10cSrcweir rSh.ClearMark();
462cdf0e10cSrcweir rSh.SelNextRedline(); // Aktueller Redline wird selektiert
463cdf0e10cSrcweir
464cdf0e10cSrcweir rSh.StartAction();
465cdf0e10cSrcweir rSh.Push();
466cdf0e10cSrcweir pActRed = rSh.SelNextRedline();
467cdf0e10cSrcweir sal_Bool bNext = pActRed != 0;
468cdf0e10cSrcweir rSh.Pop(sal_False); // Cursorpos restaurieren
469cdf0e10cSrcweir
470cdf0e10cSrcweir if( rSh.IsCrsrPtAtEnd() )
471cdf0e10cSrcweir rSh.SwapPam();
472cdf0e10cSrcweir
473cdf0e10cSrcweir rSh.EndAction();
474cdf0e10cSrcweir
475cdf0e10cSrcweir bTravel |= bNext|bPrev;
476cdf0e10cSrcweir
477cdf0e10cSrcweir SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create();
478cdf0e10cSrcweir DBG_ASSERT(pFact2, "Dialogdiet fail!");
479cdf0e10cSrcweir AbstractSvxPostItDialog* pDlg = pFact2->CreateSvxPostItDialog( pMDI, aSet, bTravel, sal_True );
480cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
481cdf0e10cSrcweir pDlg->HideAuthor();
482cdf0e10cSrcweir
483cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT));
484cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() );
485cdf0e10cSrcweir
486cdf0e10cSrcweir pDlg->SetText(sTitle);
487cdf0e10cSrcweir
488cdf0e10cSrcweir if (bTravel)
489cdf0e10cSrcweir {
490cdf0e10cSrcweir pDlg->EnableTravel(bNext, bPrev);
491cdf0e10cSrcweir pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl));
492cdf0e10cSrcweir pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl));
493cdf0e10cSrcweir }
494cdf0e10cSrcweir
495cdf0e10cSrcweir rSh.SetCareWin(pDlg->GetWindow());
496cdf0e10cSrcweir bNoInterrupt = sal_True;
497cdf0e10cSrcweir
498cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK )
499cdf0e10cSrcweir {
500cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
501cdf0e10cSrcweir String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue());
502cdf0e10cSrcweir
503cdf0e10cSrcweir // Kommentar einfuegen bzw aendern
504cdf0e10cSrcweir rSh.SetRedlineComment(sMsg);
505cdf0e10cSrcweir }
506cdf0e10cSrcweir
507cdf0e10cSrcweir delete pDlg;
508cdf0e10cSrcweir rSh.SetCareWin(NULL);
509cdf0e10cSrcweir bNoInterrupt = sal_False;
510cdf0e10cSrcweir rSh.ClearMark();
511cdf0e10cSrcweir GetView().AttrChangedNotify(GetShellPtr());
512cdf0e10cSrcweir }
513cdf0e10cSrcweir }
514cdf0e10cSrcweir break;
515cdf0e10cSrcweir
516cdf0e10cSrcweir case FN_JAVAEDIT:
517cdf0e10cSrcweir {
518cdf0e10cSrcweir String aType, aText;
519cdf0e10cSrcweir sal_Bool bIsUrl=sal_False;
520cdf0e10cSrcweir sal_Bool bNew=sal_False, bUpdate=sal_False;
521cdf0e10cSrcweir SwFldMgr* pMgr = new SwFldMgr;
522cdf0e10cSrcweir if ( pItem )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir aText = ((SfxStringItem*)pItem)->GetValue();
525cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pType, SfxStringItem, FN_PARAM_2 , sal_False );
526cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pIsUrl, SfxBoolItem, FN_PARAM_1 , sal_False );
527cdf0e10cSrcweir if ( pType )
528cdf0e10cSrcweir aType = pType->GetValue();
529cdf0e10cSrcweir if ( pIsUrl )
530cdf0e10cSrcweir bIsUrl = pIsUrl->GetValue();
531cdf0e10cSrcweir
532cdf0e10cSrcweir SwScriptField* pFld = (SwScriptField*)pMgr->GetCurFld();
533cdf0e10cSrcweir bNew = !pFld || !(pFld->GetTyp()->Which() == RES_SCRIPTFLD);
534cdf0e10cSrcweir bUpdate = pFld && ( bIsUrl != pFld->GetFormat() || pFld->GetPar2() != aType || pFld->GetPar1() != aText );
535cdf0e10cSrcweir }
536cdf0e10cSrcweir else
537cdf0e10cSrcweir {
538cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
539cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");
540cdf0e10cSrcweir AbstractJavaEditDialog* pDlg = pFact->CreateJavaEditDialog( DLG_JAVAEDIT,
541cdf0e10cSrcweir pMDI, &rSh);
542cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
543cdf0e10cSrcweir if ( pDlg->Execute() )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir aType = pDlg->GetType();
546cdf0e10cSrcweir aText = pDlg->GetText();
547cdf0e10cSrcweir bIsUrl = pDlg->IsUrl();
548cdf0e10cSrcweir bNew = pDlg->IsNew();
549cdf0e10cSrcweir bUpdate = pDlg->IsUpdate();
550cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) );
551cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) );
552cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) );
553cdf0e10cSrcweir }
554cdf0e10cSrcweir
555cdf0e10cSrcweir delete pDlg;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
558cdf0e10cSrcweir if( bNew )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir SwInsertFld_Data aData(TYP_SCRIPTFLD, 0, aType, aText, bIsUrl);
561cdf0e10cSrcweir pMgr->InsertFld(aData);
562cdf0e10cSrcweir rReq.Done();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir else if( bUpdate )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir pMgr->UpdateCurFld( bIsUrl, aType, aText );
567cdf0e10cSrcweir rSh.SetUndoNoResetModified();
568cdf0e10cSrcweir rReq.Done();
569cdf0e10cSrcweir }
570cdf0e10cSrcweir else
571cdf0e10cSrcweir rReq.Ignore();
572cdf0e10cSrcweir }
573cdf0e10cSrcweir break;
574cdf0e10cSrcweir
575cdf0e10cSrcweir case FN_INSERT_FLD_DATE :
576cdf0e10cSrcweir nInsertType = TYP_DATEFLD;
577cdf0e10cSrcweir bIsText = sal_False;
578cdf0e10cSrcweir goto FIELD_INSERT;
579cdf0e10cSrcweir case FN_INSERT_FLD_TIME :
580cdf0e10cSrcweir nInsertType = TYP_TIMEFLD;
581cdf0e10cSrcweir bIsText = sal_False;
582cdf0e10cSrcweir goto FIELD_INSERT;
583cdf0e10cSrcweir case FN_INSERT_FLD_PGNUMBER:
584cdf0e10cSrcweir nInsertType = TYP_PAGENUMBERFLD;
585cdf0e10cSrcweir nInsertFormat = SVX_NUM_PAGEDESC; // wie Seitenvorlage
586cdf0e10cSrcweir bIsText = sal_False;
587cdf0e10cSrcweir goto FIELD_INSERT;
588cdf0e10cSrcweir case FN_INSERT_FLD_PGCOUNT :
589cdf0e10cSrcweir nInsertType = TYP_DOCSTATFLD;
590cdf0e10cSrcweir nInsertSubType = 0;
591cdf0e10cSrcweir bIsText = sal_False;
592cdf0e10cSrcweir nInsertFormat = SVX_NUM_PAGEDESC;
593cdf0e10cSrcweir goto FIELD_INSERT;
594cdf0e10cSrcweir case FN_INSERT_FLD_TOPIC :
595cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD;
596cdf0e10cSrcweir nInsertSubType = DI_THEMA;
597cdf0e10cSrcweir goto FIELD_INSERT;
598cdf0e10cSrcweir case FN_INSERT_FLD_TITLE :
599cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD;
600cdf0e10cSrcweir nInsertSubType = DI_TITEL;
601cdf0e10cSrcweir goto FIELD_INSERT;
602cdf0e10cSrcweir case FN_INSERT_FLD_AUTHOR :
603cdf0e10cSrcweir nInsertType = TYP_DOCINFOFLD;
604cdf0e10cSrcweir nInsertSubType = DI_CREATE|DI_SUB_AUTHOR;
605cdf0e10cSrcweir
606cdf0e10cSrcweir FIELD_INSERT:
607cdf0e10cSrcweir {
608cdf0e10cSrcweir //format conversion should only be done for number formatter formats
609cdf0e10cSrcweir if(!nInsertFormat)
610cdf0e10cSrcweir nInsertFormat = aFldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter());
611cdf0e10cSrcweir SwInsertFld_Data aData(nInsertType, nInsertSubType,
612cdf0e10cSrcweir aEmptyStr, aEmptyStr, nInsertFormat);
613cdf0e10cSrcweir aFldMgr.InsertFld(aData);
614cdf0e10cSrcweir rReq.Done();
615cdf0e10cSrcweir }
616cdf0e10cSrcweir break;
617cdf0e10cSrcweir default:
618cdf0e10cSrcweir ASSERT(sal_False, falscher Dispatcher);
619cdf0e10cSrcweir return;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir }
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
StateField(SfxItemSet & rSet)624cdf0e10cSrcweir void SwTextShell::StateField( SfxItemSet &rSet )
625cdf0e10cSrcweir {
62669a74367SOliver-Rainer Wittmann SwWrtShell& rSh = GetShell();
62769a74367SOliver-Rainer Wittmann SfxWhichIter aIter( rSet );
62869a74367SOliver-Rainer Wittmann const SwField* pField = 0;
62969a74367SOliver-Rainer Wittmann int bGetField = sal_False;
63069a74367SOliver-Rainer Wittmann sal_uInt16 nWhich = aIter.FirstWhich();
63169a74367SOliver-Rainer Wittmann
63269a74367SOliver-Rainer Wittmann while (nWhich)
63369a74367SOliver-Rainer Wittmann {
63469a74367SOliver-Rainer Wittmann switch (nWhich)
63569a74367SOliver-Rainer Wittmann {
63669a74367SOliver-Rainer Wittmann case FN_DELETE_COMMENT:
63769a74367SOliver-Rainer Wittmann case FN_DELETE_NOTE_AUTHOR:
63869a74367SOliver-Rainer Wittmann case FN_DELETE_ALL_NOTES:
63969a74367SOliver-Rainer Wittmann case FN_HIDE_NOTE:
64069a74367SOliver-Rainer Wittmann case FN_HIDE_NOTE_AUTHOR:
64169a74367SOliver-Rainer Wittmann case FN_HIDE_ALL_NOTES:
64269a74367SOliver-Rainer Wittmann {
64369a74367SOliver-Rainer Wittmann SwPostItMgr* pPostItMgr = GetView().GetPostItMgr();
64469a74367SOliver-Rainer Wittmann if ( !pPostItMgr )
64569a74367SOliver-Rainer Wittmann rSet.InvalidateItem( nWhich );
64669a74367SOliver-Rainer Wittmann else if ( !pPostItMgr->HasActiveSidebarWin() )
64769a74367SOliver-Rainer Wittmann {
64869a74367SOliver-Rainer Wittmann rSet.InvalidateItem( FN_DELETE_COMMENT );
64969a74367SOliver-Rainer Wittmann rSet.InvalidateItem( FN_HIDE_NOTE );
65069a74367SOliver-Rainer Wittmann }
65169a74367SOliver-Rainer Wittmann }
65269a74367SOliver-Rainer Wittmann break;
653cdf0e10cSrcweir
65469a74367SOliver-Rainer Wittmann case FN_EDIT_FIELD:
65569a74367SOliver-Rainer Wittmann {
656cdf0e10cSrcweir if( !bGetField )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir pField = rSh.GetCurFld();
659cdf0e10cSrcweir bGetField = sal_True;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir
662cdf0e10cSrcweir sal_uInt16 nTempWhich = pField ? pField->GetTyp()->Which() : USHRT_MAX;
663cdf0e10cSrcweir if( USHRT_MAX == nTempWhich ||
664cdf0e10cSrcweir RES_POSTITFLD == nTempWhich ||
665cdf0e10cSrcweir RES_SCRIPTFLD == nTempWhich ||
666cdf0e10cSrcweir RES_AUTHORITY == nTempWhich )
667cdf0e10cSrcweir rSet.DisableItem( nWhich );
668cdf0e10cSrcweir else if( RES_DDEFLD == nTempWhich &&
66969a74367SOliver-Rainer Wittmann !((SwDDEFieldType*)pField->GetTyp())->GetBaseLink().IsVisible())
670cdf0e10cSrcweir {
671cdf0e10cSrcweir // nested links cannot be edited
672cdf0e10cSrcweir rSet.DisableItem( nWhich );
673cdf0e10cSrcweir }
67469a74367SOliver-Rainer Wittmann }
67569a74367SOliver-Rainer Wittmann break;
676cdf0e10cSrcweir
67769a74367SOliver-Rainer Wittmann case FN_EXECUTE_MACROFIELD:
67869a74367SOliver-Rainer Wittmann {
67969a74367SOliver-Rainer Wittmann if(!bGetField)
68069a74367SOliver-Rainer Wittmann {
68169a74367SOliver-Rainer Wittmann pField = rSh.GetCurFld();
68269a74367SOliver-Rainer Wittmann bGetField = sal_True;
68369a74367SOliver-Rainer Wittmann }
68469a74367SOliver-Rainer Wittmann if(!pField || pField->GetTyp()->Which() != RES_MACROFLD)
68569a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
68669a74367SOliver-Rainer Wittmann }
68769a74367SOliver-Rainer Wittmann break;
68869a74367SOliver-Rainer Wittmann
68969a74367SOliver-Rainer Wittmann case FN_INSERT_FIELD:
69069a74367SOliver-Rainer Wittmann {
69169a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() )
69269a74367SOliver-Rainer Wittmann {
69369a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
69469a74367SOliver-Rainer Wittmann }
69569a74367SOliver-Rainer Wittmann else
69669a74367SOliver-Rainer Wittmann {
69769a74367SOliver-Rainer Wittmann SfxViewFrame* pVFrame = GetView().GetViewFrame();
69869a74367SOliver-Rainer Wittmann //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active
69969a74367SOliver-Rainer Wittmann if(!pVFrame->IsInModalMode() &&
700cdf0e10cSrcweir pVFrame->KnowsChildWindow(FN_INSERT_FIELD) && !pVFrame->HasChildWindow(FN_INSERT_FIELD_DATA_ONLY) )
70169a74367SOliver-Rainer Wittmann rSet.Put(SfxBoolItem( FN_INSERT_FIELD, pVFrame->HasChildWindow(nWhich)));
70269a74367SOliver-Rainer Wittmann else
70369a74367SOliver-Rainer Wittmann rSet.DisableItem(FN_INSERT_FIELD);
70469a74367SOliver-Rainer Wittmann }
70569a74367SOliver-Rainer Wittmann }
70669a74367SOliver-Rainer Wittmann break;
70769a74367SOliver-Rainer Wittmann
70869a74367SOliver-Rainer Wittmann case FN_INSERT_REF_FIELD:
70969a74367SOliver-Rainer Wittmann {
71069a74367SOliver-Rainer Wittmann SfxViewFrame* pVFrame = GetView().GetViewFrame();
71169a74367SOliver-Rainer Wittmann if ( !pVFrame->KnowsChildWindow(FN_INSERT_FIELD)
71269a74367SOliver-Rainer Wittmann || rSh.CrsrInsideInputFld() )
71369a74367SOliver-Rainer Wittmann {
71469a74367SOliver-Rainer Wittmann rSet.DisableItem(FN_INSERT_REF_FIELD);
71569a74367SOliver-Rainer Wittmann }
71669a74367SOliver-Rainer Wittmann }
71769a74367SOliver-Rainer Wittmann break;
71869a74367SOliver-Rainer Wittmann
71969a74367SOliver-Rainer Wittmann case FN_INSERT_FIELD_CTRL:
72069a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() )
72169a74367SOliver-Rainer Wittmann {
72269a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
72369a74367SOliver-Rainer Wittmann }
72469a74367SOliver-Rainer Wittmann else
72569a74367SOliver-Rainer Wittmann {
72669a74367SOliver-Rainer Wittmann rSet.Put(SfxBoolItem( nWhich, GetView().GetViewFrame()->HasChildWindow(FN_INSERT_FIELD)));
72769a74367SOliver-Rainer Wittmann }
72869a74367SOliver-Rainer Wittmann break;
72969a74367SOliver-Rainer Wittmann
73069a74367SOliver-Rainer Wittmann case FN_REDLINE_COMMENT:
73169a74367SOliver-Rainer Wittmann if (!rSh.GetCurrRedline())
73269a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
73369a74367SOliver-Rainer Wittmann break;
73469a74367SOliver-Rainer Wittmann
73569a74367SOliver-Rainer Wittmann case FN_POSTIT :
73669a74367SOliver-Rainer Wittmann case FN_JAVAEDIT :
73769a74367SOliver-Rainer Wittmann {
73869a74367SOliver-Rainer Wittmann sal_Bool bCurField = sal_False;
739cdf0e10cSrcweir pField = rSh.GetCurFld();
74069a74367SOliver-Rainer Wittmann if(nWhich == FN_POSTIT)
74169a74367SOliver-Rainer Wittmann bCurField = pField && pField->GetTyp()->Which() == RES_POSTITFLD;
74269a74367SOliver-Rainer Wittmann else
74369a74367SOliver-Rainer Wittmann bCurField = pField && pField->GetTyp()->Which() == RES_SCRIPTFLD;
744cdf0e10cSrcweir
74569a74367SOliver-Rainer Wittmann if( !bCurField && rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() )
74669a74367SOliver-Rainer Wittmann {
74769a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
74869a74367SOliver-Rainer Wittmann }
74969a74367SOliver-Rainer Wittmann else if ( rSh.CrsrInsideInputFld() )
75069a74367SOliver-Rainer Wittmann {
75169a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
75269a74367SOliver-Rainer Wittmann }
75369a74367SOliver-Rainer Wittmann }
75469a74367SOliver-Rainer Wittmann
75569a74367SOliver-Rainer Wittmann break;
75669a74367SOliver-Rainer Wittmann
75769a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_AUTHOR:
75869a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_DATE:
75969a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_PGCOUNT:
76069a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_PGNUMBER:
76169a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_TIME:
76269a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_TITLE:
76369a74367SOliver-Rainer Wittmann case FN_INSERT_FLD_TOPIC:
76469a74367SOliver-Rainer Wittmann case FN_INSERT_DBFIELD:
76569a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() )
76669a74367SOliver-Rainer Wittmann {
76769a74367SOliver-Rainer Wittmann rSet.DisableItem(nWhich);
76869a74367SOliver-Rainer Wittmann }
76969a74367SOliver-Rainer Wittmann break;
77069a74367SOliver-Rainer Wittmann
77169a74367SOliver-Rainer Wittmann }
77269a74367SOliver-Rainer Wittmann nWhich = aIter.NextWhich();
77369a74367SOliver-Rainer Wittmann }
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
776cdf0e10cSrcweir /*---------------------------------------------------------------------------
777cdf0e10cSrcweir Beschreibung:
778cdf0e10cSrcweir ----------------------------------------------------------------------------*/
779cdf0e10cSrcweir
780cdf0e10cSrcweir
InsertHyperlink(const SvxHyperlinkItem & rHlnkItem)781cdf0e10cSrcweir void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem)
782cdf0e10cSrcweir {
783cdf0e10cSrcweir const String& rName = rHlnkItem.GetName();
784cdf0e10cSrcweir const String& rURL = rHlnkItem.GetURL();
785cdf0e10cSrcweir const String& rTarget = rHlnkItem.GetTargetFrame();
786cdf0e10cSrcweir sal_uInt16 nType = (sal_uInt16)rHlnkItem.GetInsertMode();
787cdf0e10cSrcweir nType &= ~HLINK_HTMLMODE;
788cdf0e10cSrcweir const SvxMacroTableDtor* pMacroTbl = rHlnkItem.GetMacroTbl();
789cdf0e10cSrcweir
790cdf0e10cSrcweir SwWrtShell& rSh = GetShell();
791cdf0e10cSrcweir
792cdf0e10cSrcweir if( rSh.GetSelectionType() & nsSelectionType::SEL_TXT )
793cdf0e10cSrcweir {
794cdf0e10cSrcweir rSh.StartAction();
795cdf0e10cSrcweir SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
796cdf0e10cSrcweir rSh.GetCurAttr( aSet );
797cdf0e10cSrcweir
798cdf0e10cSrcweir const SfxPoolItem* pItem;
799cdf0e10cSrcweir if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False, &pItem))
800cdf0e10cSrcweir {
801cdf0e10cSrcweir // Links selektieren
802cdf0e10cSrcweir rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT, sal_False);
803cdf0e10cSrcweir }
804cdf0e10cSrcweir switch (nType)
805cdf0e10cSrcweir {
806cdf0e10cSrcweir case HLINK_DEFAULT:
807cdf0e10cSrcweir case HLINK_FIELD:
808cdf0e10cSrcweir {
809cdf0e10cSrcweir SwFmtINetFmt aINetFmt( rURL, rTarget );
810cdf0e10cSrcweir aINetFmt.SetName(rHlnkItem.GetIntName());
811cdf0e10cSrcweir if(pMacroTbl)
812cdf0e10cSrcweir {
813cdf0e10cSrcweir SvxMacro *pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOVER_OBJECT );
814cdf0e10cSrcweir if( pMacro )
815cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSEOVER_OBJECT, *pMacro);
816cdf0e10cSrcweir pMacro = pMacroTbl->Get( SFX_EVENT_MOUSECLICK_OBJECT );
817cdf0e10cSrcweir if( pMacro )
818cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSECLICK_OBJECT, *pMacro);
819cdf0e10cSrcweir pMacro = pMacroTbl->Get( SFX_EVENT_MOUSEOUT_OBJECT );
820cdf0e10cSrcweir if( pMacro )
821cdf0e10cSrcweir aINetFmt.SetMacro(SFX_EVENT_MOUSEOUT_OBJECT, *pMacro);
822cdf0e10cSrcweir }
823cdf0e10cSrcweir rSh.SttSelect();
824cdf0e10cSrcweir rSh.InsertURL( aINetFmt, rName, sal_True );
825cdf0e10cSrcweir rSh.EndSelect();
826cdf0e10cSrcweir }
827cdf0e10cSrcweir break;
828cdf0e10cSrcweir
829cdf0e10cSrcweir case HLINK_BUTTON:
830cdf0e10cSrcweir sal_Bool bSel = rSh.HasSelection();
831cdf0e10cSrcweir if(bSel)
832cdf0e10cSrcweir rSh.DelRight();
833cdf0e10cSrcweir InsertURLButton( rURL, rTarget, rName );
834cdf0e10cSrcweir rSh.EnterStdMode();
835cdf0e10cSrcweir break;
836cdf0e10cSrcweir }
837cdf0e10cSrcweir rSh.EndAction();
838cdf0e10cSrcweir }
839cdf0e10cSrcweir }
840cdf0e10cSrcweir
IMPL_LINK(SwTextShell,RedlineNextHdl,AbstractSvxPostItDialog *,pBtn)841cdf0e10cSrcweir IMPL_LINK( SwTextShell, RedlineNextHdl, 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 if( !pSh->IsCrsrPtAtEnd() )
857cdf0e10cSrcweir pSh->SwapPam(); // Cursor hinter den Redline stellen
858cdf0e10cSrcweir
859cdf0e10cSrcweir pSh->Push();
860cdf0e10cSrcweir const SwRedline *pActRed = pSh->SelNextRedline();
861cdf0e10cSrcweir pSh->Pop(pActRed != 0);
862cdf0e10cSrcweir
863cdf0e10cSrcweir sal_Bool bEnable = sal_False;
864cdf0e10cSrcweir
865cdf0e10cSrcweir if (pActRed)
866cdf0e10cSrcweir {
867cdf0e10cSrcweir pSh->StartAction();
868cdf0e10cSrcweir pSh->Push();
869cdf0e10cSrcweir bEnable = pSh->SelNextRedline() != 0;
870cdf0e10cSrcweir pSh->Pop(sal_False);
871cdf0e10cSrcweir pSh->EndAction();
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
874cdf0e10cSrcweir pDlg->EnableTravel(bEnable, sal_True);
875cdf0e10cSrcweir
876cdf0e10cSrcweir if( pSh->IsCrsrPtAtEnd() )
877cdf0e10cSrcweir pSh->SwapPam();
878cdf0e10cSrcweir
879cdf0e10cSrcweir pRedline = pSh->GetCurrRedline();
880cdf0e10cSrcweir sComment = pRedline->GetComment();
881cdf0e10cSrcweir
882cdf0e10cSrcweir pDlg->SetNote( sComment.ConvertLineEnd() );
883cdf0e10cSrcweir pDlg->ShowLastAuthor( pRedline->GetAuthorString(),
884cdf0e10cSrcweir GetAppLangDateTimeString(
885cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() ));
886cdf0e10cSrcweir
887cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT));
888cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() );
889cdf0e10cSrcweir
890cdf0e10cSrcweir pDlg->SetText(sTitle);
891cdf0e10cSrcweir }
892cdf0e10cSrcweir
893cdf0e10cSrcweir return 0;
894cdf0e10cSrcweir }
895cdf0e10cSrcweir
IMPL_LINK(SwTextShell,RedlinePrevHdl,AbstractSvxPostItDialog *,pBtn)896cdf0e10cSrcweir IMPL_LINK( SwTextShell, RedlinePrevHdl, AbstractSvxPostItDialog *, pBtn )
897cdf0e10cSrcweir {
898cdf0e10cSrcweir SwWrtShell* pSh = GetShellPtr();
899cdf0e10cSrcweir AbstractSvxPostItDialog *pDlg = (AbstractSvxPostItDialog*)pBtn;
900cdf0e10cSrcweir
901cdf0e10cSrcweir // Kommentar einfuegen bzw aendern
902cdf0e10cSrcweir pSh->SetRedlineComment(pDlg->GetNote());
903cdf0e10cSrcweir
904cdf0e10cSrcweir const SwRedline *pRedline = pSh->GetCurrRedline();
905cdf0e10cSrcweir
906cdf0e10cSrcweir String sComment;
907cdf0e10cSrcweir
908cdf0e10cSrcweir if (pRedline)
909cdf0e10cSrcweir {
910cdf0e10cSrcweir // Traveling nur bei mehr als einem Feld
911cdf0e10cSrcweir pSh->Push();
912cdf0e10cSrcweir const SwRedline *pActRed = pSh->SelPrevRedline();
913cdf0e10cSrcweir pSh->Pop(pActRed != 0);
914cdf0e10cSrcweir
915cdf0e10cSrcweir sal_Bool bEnable = sal_False;
916cdf0e10cSrcweir
917cdf0e10cSrcweir if (pActRed)
918cdf0e10cSrcweir {
919cdf0e10cSrcweir pSh->StartAction();
920cdf0e10cSrcweir pSh->Push();
921cdf0e10cSrcweir bEnable = pSh->SelPrevRedline() != 0;
922cdf0e10cSrcweir pSh->Pop(sal_False);
923cdf0e10cSrcweir pSh->EndAction();
924cdf0e10cSrcweir }
925cdf0e10cSrcweir
926cdf0e10cSrcweir pDlg->EnableTravel(sal_True, bEnable);
927cdf0e10cSrcweir
928cdf0e10cSrcweir pRedline = pSh->GetCurrRedline();
929cdf0e10cSrcweir sComment = pRedline->GetComment();
930cdf0e10cSrcweir
931cdf0e10cSrcweir pDlg->SetNote(sComment.ConvertLineEnd());
932cdf0e10cSrcweir pDlg->ShowLastAuthor(pRedline->GetAuthorString(),
933cdf0e10cSrcweir GetAppLangDateTimeString(
934cdf0e10cSrcweir pRedline->GetRedlineData().GetTimeStamp() ));
935cdf0e10cSrcweir
936cdf0e10cSrcweir String sTitle(SW_RES(STR_REDLINE_COMMENT));
937cdf0e10cSrcweir ::lcl_AppendRedlineStr( sTitle, pRedline->GetType() );
938cdf0e10cSrcweir
939cdf0e10cSrcweir pDlg->SetText(sTitle);
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
942cdf0e10cSrcweir return 0;
943cdf0e10cSrcweir }
944cdf0e10cSrcweir
945cdf0e10cSrcweir
946