1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
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
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <hintids.hxx> // define ITEMIDs
28cdf0e10cSrcweir #include <svl/macitem.hxx>
29cdf0e10cSrcweir #include <sfx2/frame.hxx>
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #include <svl/urihelper.hxx>
32cdf0e10cSrcweir #include <svl/eitem.hxx>
33cdf0e10cSrcweir #include <svl/stritem.hxx>
34cdf0e10cSrcweir #include <sfx2/docfile.hxx>
35cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
36cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
37cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
38cdf0e10cSrcweir #include <fmtinfmt.hxx>
39cdf0e10cSrcweir #include <frmatr.hxx>
40cdf0e10cSrcweir #include <swtypes.hxx> // SET_CURR_SHELL
41cdf0e10cSrcweir #include <wrtsh.hxx>
42cdf0e10cSrcweir #include <docsh.hxx>
43cdf0e10cSrcweir #include <fldbas.hxx> // Felder
44cdf0e10cSrcweir #include <expfld.hxx>
45cdf0e10cSrcweir #include <ddefld.hxx>
46cdf0e10cSrcweir #include <docufld.hxx>
47cdf0e10cSrcweir #include <reffld.hxx>
48cdf0e10cSrcweir #include <swundo.hxx>
49cdf0e10cSrcweir #include <doc.hxx>
50cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
51cdf0e10cSrcweir #include <viewopt.hxx> // SwViewOptions
52cdf0e10cSrcweir #include <frmfmt.hxx> // fuer UpdateTable
53cdf0e10cSrcweir #include <swtable.hxx> // fuer UpdateTable
54cdf0e10cSrcweir #include <mdiexp.hxx>
55cdf0e10cSrcweir #include <view.hxx>
56cdf0e10cSrcweir #include <swevent.hxx>
57cdf0e10cSrcweir #include <poolfmt.hxx>
58cdf0e10cSrcweir #include <section.hxx>
59cdf0e10cSrcweir #include <navicont.hxx>
60cdf0e10cSrcweir #include <navipi.hxx>
61cdf0e10cSrcweir #include <crsskip.hxx>
62cdf0e10cSrcweir #include <txtinet.hxx>
63cdf0e10cSrcweir #include <cmdid.h>
64cdf0e10cSrcweir #include <wrtsh.hrc>
65cdf0e10cSrcweir #include "swabstdlg.hxx"
66cdf0e10cSrcweir #include "fldui.hrc"
67cdf0e10cSrcweir #include <SwRewriter.hxx>
68cdf0e10cSrcweir
69cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp>
70cdf0e10cSrcweir #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
71cdf0e10cSrcweir
72cdf0e10cSrcweir
73cdf0e10cSrcweir /*------------------------------------------------------------------------
74cdf0e10cSrcweir Beschreibung:
75cdf0e10cSrcweir ------------------------------------------------------------------------*/
76cdf0e10cSrcweir
Insert(SwField & rFld)77dec99bbdSOliver-Rainer Wittmann void SwWrtShell::Insert( SwField& rFld )
78cdf0e10cSrcweir {
793b32dd21SOliver-Rainer Wittmann ResetCursorStack();
803b32dd21SOliver-Rainer Wittmann if(!_CanInsert())
813b32dd21SOliver-Rainer Wittmann return;
823b32dd21SOliver-Rainer Wittmann StartAllAction();
83cdf0e10cSrcweir
84cdf0e10cSrcweir SwRewriter aRewriter;
85cdf0e10cSrcweir aRewriter.AddRule(UNDO_ARG1, rFld.GetDescription());
86cdf0e10cSrcweir
873b32dd21SOliver-Rainer Wittmann StartUndo(UNDO_INSERT, &aRewriter);
883b32dd21SOliver-Rainer Wittmann
89dec99bbdSOliver-Rainer Wittmann bool bDeleted = false;
90dec99bbdSOliver-Rainer Wittmann const SwPaM* pAnnotationTextRange = NULL;
91dec99bbdSOliver-Rainer Wittmann if ( HasSelection() )
923b32dd21SOliver-Rainer Wittmann {
93dec99bbdSOliver-Rainer Wittmann if ( rFld.GetTyp()->Which() == RES_POSTITFLD )
94dec99bbdSOliver-Rainer Wittmann {
95dec99bbdSOliver-Rainer Wittmann // for annotation fields:
96dec99bbdSOliver-Rainer Wittmann // - keep the current selection in order to create a corresponding annotation mark
97332f371aSOliver-Rainer Wittmann // - collapse cursor to its end
98332f371aSOliver-Rainer Wittmann if ( IsTableMode() )
99332f371aSOliver-Rainer Wittmann {
100332f371aSOliver-Rainer Wittmann GetTblCrs()->Normalize( sal_False );
101332f371aSOliver-Rainer Wittmann const SwPosition rStartPos( *(GetTblCrs()->GetMark()->nNode.GetNode().GetCntntNode()), 0 );
102332f371aSOliver-Rainer Wittmann KillPams();
103*d5f1f34eSOliver-Rainer Wittmann if ( !IsEndOfPara() )
104*d5f1f34eSOliver-Rainer Wittmann {
105*d5f1f34eSOliver-Rainer Wittmann EndPara();
106*d5f1f34eSOliver-Rainer Wittmann }
107332f371aSOliver-Rainer Wittmann const SwPosition rEndPos( *GetCurrentShellCursor().GetPoint() );
108332f371aSOliver-Rainer Wittmann pAnnotationTextRange = new SwPaM( rStartPos, rEndPos );
109332f371aSOliver-Rainer Wittmann }
110332f371aSOliver-Rainer Wittmann else
111332f371aSOliver-Rainer Wittmann {
112332f371aSOliver-Rainer Wittmann NormalizePam( sal_False );
113332f371aSOliver-Rainer Wittmann const SwPaM& rCurrPaM = GetCurrentShellCursor();
114332f371aSOliver-Rainer Wittmann pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
115332f371aSOliver-Rainer Wittmann ClearMark();
116332f371aSOliver-Rainer Wittmann }
117dec99bbdSOliver-Rainer Wittmann }
118dec99bbdSOliver-Rainer Wittmann else
119dec99bbdSOliver-Rainer Wittmann {
120dec99bbdSOliver-Rainer Wittmann bDeleted = DelRight() != 0;
121dec99bbdSOliver-Rainer Wittmann }
1223b32dd21SOliver-Rainer Wittmann }
123cdf0e10cSrcweir
124dec99bbdSOliver-Rainer Wittmann SwEditShell::Insert2(rFld, bDeleted);
125dec99bbdSOliver-Rainer Wittmann
126dec99bbdSOliver-Rainer Wittmann if ( pAnnotationTextRange != NULL )
127cdf0e10cSrcweir {
128dec99bbdSOliver-Rainer Wittmann if ( GetDoc() != NULL )
129dec99bbdSOliver-Rainer Wittmann {
130dec99bbdSOliver-Rainer Wittmann IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess();
131dec99bbdSOliver-Rainer Wittmann pMarksAccess->makeAnnotationMark( *pAnnotationTextRange, ::rtl::OUString() );
132dec99bbdSOliver-Rainer Wittmann }
133dec99bbdSOliver-Rainer Wittmann delete pAnnotationTextRange;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
136cdf0e10cSrcweir EndUndo();
1373b32dd21SOliver-Rainer Wittmann EndAllAction();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir /*--------------------------------------------------------------------
141cdf0e10cSrcweir Beschreibung: Felder Update anschmeissen
142cdf0e10cSrcweir --------------------------------------------------------------------*/
143cdf0e10cSrcweir
144cdf0e10cSrcweir
145cdf0e10cSrcweir
UpdateInputFlds(SwInputFieldList * pLst)14669a74367SOliver-Rainer Wittmann void SwWrtShell::UpdateInputFlds( SwInputFieldList* pLst )
147cdf0e10cSrcweir {
14869a74367SOliver-Rainer Wittmann // ueber die Liste der Eingabefelder gehen und Updaten
14969a74367SOliver-Rainer Wittmann SwInputFieldList* pTmp = pLst;
15069a74367SOliver-Rainer Wittmann if( !pTmp )
15169a74367SOliver-Rainer Wittmann pTmp = new SwInputFieldList( this );
152cdf0e10cSrcweir
15369a74367SOliver-Rainer Wittmann const sal_uInt16 nCnt = pTmp->Count();
15469a74367SOliver-Rainer Wittmann if(nCnt)
15569a74367SOliver-Rainer Wittmann {
15669a74367SOliver-Rainer Wittmann pTmp->PushCrsr();
157cdf0e10cSrcweir
15869a74367SOliver-Rainer Wittmann sal_Bool bCancel = sal_False;
159cdf0e10cSrcweir ByteString aDlgPos;
16069a74367SOliver-Rainer Wittmann for( sal_uInt16 i = 0; i < nCnt && !bCancel; ++i )
16169a74367SOliver-Rainer Wittmann {
16269a74367SOliver-Rainer Wittmann pTmp->GotoFieldPos( i );
163cdf0e10cSrcweir SwField* pField = pTmp->GetField( i );
164cdf0e10cSrcweir if(pField->GetTyp()->Which() == RES_DROPDOWN)
165cdf0e10cSrcweir bCancel = StartDropDownFldDlg( pField, sal_True, &aDlgPos );
166cdf0e10cSrcweir else
167cdf0e10cSrcweir bCancel = StartInputFldDlg( pField, sal_True, 0, &aDlgPos);
168cdf0e10cSrcweir
16969a74367SOliver-Rainer Wittmann // Sonst Updatefehler bei Multiselektion:
17069a74367SOliver-Rainer Wittmann pTmp->GetField( i )->GetTyp()->UpdateFlds();
17169a74367SOliver-Rainer Wittmann }
17269a74367SOliver-Rainer Wittmann pTmp->PopCrsr();
17369a74367SOliver-Rainer Wittmann }
174cdf0e10cSrcweir
17569a74367SOliver-Rainer Wittmann if( !pLst )
17669a74367SOliver-Rainer Wittmann delete pTmp;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir
180cdf0e10cSrcweir /*--------------------------------------------------------------------
181cdf0e10cSrcweir Beschreibung: EingabeDialog fuer ein bestimmtes Feld starten
182cdf0e10cSrcweir --------------------------------------------------------------------*/
183cdf0e10cSrcweir
184cdf0e10cSrcweir
185cdf0e10cSrcweir
StartInputFldDlg(SwField * pFld,sal_Bool bNextButton,Window * pParentWin,ByteString * pWindowState)186cdf0e10cSrcweir sal_Bool SwWrtShell::StartInputFldDlg( SwField* pFld, sal_Bool bNextButton,
187cdf0e10cSrcweir Window* pParentWin, ByteString* pWindowState )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir //JP 14.08.96: Bug 30332 - nach Umbau der modularietaet im SFX, muss jetzt
190cdf0e10cSrcweir // das TopWindow der Application benutzt werden.
191cdf0e10cSrcweir // SwFldInputDlg* pDlg = new SwFldInputDlg( GetWin(), *this, pFld );
192cdf0e10cSrcweir
193cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
194cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");
195cdf0e10cSrcweir AbstractFldInputDlg* pDlg = pFact->CreateFldInputDlg( DLG_FLD_INPUT,
196cdf0e10cSrcweir pParentWin, *this, pFld, bNextButton);
197cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
198cdf0e10cSrcweir if(pWindowState && pWindowState->Len())
199cdf0e10cSrcweir pDlg->SetWindowState(*pWindowState);
200cdf0e10cSrcweir sal_Bool bRet = RET_CANCEL == pDlg->Execute();
201cdf0e10cSrcweir if(pWindowState)
202cdf0e10cSrcweir *pWindowState = pDlg->GetWindowState();
203cdf0e10cSrcweir
204cdf0e10cSrcweir delete pDlg;
205cdf0e10cSrcweir GetWin()->Update();
206cdf0e10cSrcweir return bRet;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir /* -----------------17.06.2003 10:18-----------------
209cdf0e10cSrcweir
210cdf0e10cSrcweir --------------------------------------------------*/
StartDropDownFldDlg(SwField * pFld,sal_Bool bNextButton,ByteString * pWindowState)211cdf0e10cSrcweir sal_Bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, sal_Bool bNextButton, ByteString* pWindowState)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
214cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
215cdf0e10cSrcweir
216cdf0e10cSrcweir AbstractDropDownFieldDialog* pDlg = pFact->CreateDropDownFieldDialog( NULL, *this, pFld, DLG_FLD_DROPDOWN ,bNextButton );
217cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
218cdf0e10cSrcweir if(pWindowState && pWindowState->Len())
219cdf0e10cSrcweir pDlg->SetWindowState(*pWindowState);
220cdf0e10cSrcweir sal_uInt16 nRet = pDlg->Execute();
221cdf0e10cSrcweir if(pWindowState)
222cdf0e10cSrcweir *pWindowState = pDlg->GetWindowState();
223cdf0e10cSrcweir delete pDlg;
224cdf0e10cSrcweir sal_Bool bRet = RET_CANCEL == nRet;
225cdf0e10cSrcweir GetWin()->Update();
226cdf0e10cSrcweir if(RET_YES == nRet)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir GetView().GetViewFrame()->GetDispatcher()->Execute(FN_EDIT_FIELD, SFX_CALLMODE_SYNCHRON);
229cdf0e10cSrcweir }
230cdf0e10cSrcweir return bRet;
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
233cdf0e10cSrcweir /*--------------------------------------------------------------------
234cdf0e10cSrcweir Beschreibung: Verzeichnis einfuegen Selektion loeschen
235cdf0e10cSrcweir --------------------------------------------------------------------*/
236cdf0e10cSrcweir
237cdf0e10cSrcweir
238cdf0e10cSrcweir
InsertTableOf(const SwTOXBase & rTOX,const SfxItemSet * pSet)239cdf0e10cSrcweir void SwWrtShell::InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir if(!_CanInsert())
242cdf0e10cSrcweir return;
243cdf0e10cSrcweir
244cdf0e10cSrcweir if(HasSelection())
245cdf0e10cSrcweir DelRight();
246cdf0e10cSrcweir
247cdf0e10cSrcweir SwEditShell::InsertTableOf(rTOX, pSet);
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir
251cdf0e10cSrcweir /*--------------------------------------------------------------------
252cdf0e10cSrcweir Beschreibung: Verzeichnis Updaten Selektion loeschen
253cdf0e10cSrcweir --------------------------------------------------------------------*/
254cdf0e10cSrcweir
UpdateTableOf(const SwTOXBase & rTOX,const SfxItemSet * pSet)255cdf0e10cSrcweir sal_Bool SwWrtShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir sal_Bool bResult = sal_False;
258cdf0e10cSrcweir
259cdf0e10cSrcweir if(_CanInsert())
260cdf0e10cSrcweir {
261cdf0e10cSrcweir bResult = SwEditShell::UpdateTableOf(rTOX, pSet);
262cdf0e10cSrcweir
263cdf0e10cSrcweir if (pSet == NULL)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir SwDoc *const pDoc_ = GetDoc();
266cdf0e10cSrcweir if (pDoc_)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir pDoc_->GetIDocumentUndoRedo().DelAllUndoObj();
269cdf0e10cSrcweir }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir return bResult;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir // handler for click on the field given as parameter.
277cdf0e10cSrcweir // the cursor is positioned on the field.
278cdf0e10cSrcweir
279cdf0e10cSrcweir
ClickToField(const SwField & rFld)280cdf0e10cSrcweir void SwWrtShell::ClickToField( const SwField& rFld )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir bIsInClickToEdit = sal_True;
283cdf0e10cSrcweir switch( rFld.GetTyp()->Which() )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir case RES_JUMPEDITFLD:
286cdf0e10cSrcweir {
287cdf0e10cSrcweir sal_uInt16 nSlotId = 0;
288cdf0e10cSrcweir switch( rFld.GetFormat() )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir case JE_FMT_TABLE:
291cdf0e10cSrcweir nSlotId = FN_INSERT_TABLE;
292cdf0e10cSrcweir break;
293cdf0e10cSrcweir
294cdf0e10cSrcweir case JE_FMT_FRAME:
295cdf0e10cSrcweir nSlotId = FN_INSERT_FRAME;
296cdf0e10cSrcweir break;
297cdf0e10cSrcweir
298cdf0e10cSrcweir case JE_FMT_GRAPHIC: nSlotId = SID_INSERT_GRAPHIC; break;
299cdf0e10cSrcweir case JE_FMT_OLE: nSlotId = SID_INSERT_OBJECT; break;
300cdf0e10cSrcweir
301cdf0e10cSrcweir // case JE_FMT_TEXT:
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False ); // Feld selektieren
305cdf0e10cSrcweir
306cdf0e10cSrcweir if( nSlotId )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir StartUndo( UNDO_START );
309cdf0e10cSrcweir //#97295# immediately select the right shell
310cdf0e10cSrcweir GetView().StopShellTimer();
311cdf0e10cSrcweir GetView().GetViewFrame()->GetDispatcher()->Execute( nSlotId,
312cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
313cdf0e10cSrcweir EndUndo( UNDO_END );
314cdf0e10cSrcweir }
315cdf0e10cSrcweir }
316cdf0e10cSrcweir break;
317cdf0e10cSrcweir
318cdf0e10cSrcweir case RES_MACROFLD:
319cdf0e10cSrcweir {
320cdf0e10cSrcweir const SwMacroField *pFld = (const SwMacroField*)&rFld;
321cdf0e10cSrcweir String sText( rFld.GetPar2() );
322cdf0e10cSrcweir String sRet( sText );
323cdf0e10cSrcweir ExecMacro( pFld->GetSvxMacro(), &sRet );
324cdf0e10cSrcweir
325cdf0e10cSrcweir // return Wert veraendert?
326cdf0e10cSrcweir if( sRet != sText )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir StartAllAction();
329cdf0e10cSrcweir ((SwField&)rFld).SetPar2( sRet );
330cdf0e10cSrcweir ((SwField&)rFld).GetTyp()->UpdateFlds();
331cdf0e10cSrcweir EndAllAction();
332cdf0e10cSrcweir }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir break;
335cdf0e10cSrcweir
336cdf0e10cSrcweir case RES_GETREFFLD:
337cdf0e10cSrcweir StartAllAction();
338cdf0e10cSrcweir SwCrsrShell::GotoRefMark( ((SwGetRefField&)rFld).GetSetRefName(),
339cdf0e10cSrcweir ((SwGetRefField&)rFld).GetSubType(),
340cdf0e10cSrcweir ((SwGetRefField&)rFld).GetSeqNo() );
341cdf0e10cSrcweir EndAllAction();
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir
34469a74367SOliver-Rainer Wittmann case RES_INPUTFLD:
34569a74367SOliver-Rainer Wittmann {
34669a74367SOliver-Rainer Wittmann const SwInputField* pInputField = dynamic_cast<const SwInputField*>(&rFld);
34769a74367SOliver-Rainer Wittmann if ( pInputField == NULL )
34869a74367SOliver-Rainer Wittmann {
34969a74367SOliver-Rainer Wittmann StartInputFldDlg( (SwField*)&rFld, sal_False );
35069a74367SOliver-Rainer Wittmann }
35169a74367SOliver-Rainer Wittmann }
35269a74367SOliver-Rainer Wittmann break;
353cdf0e10cSrcweir
35469a74367SOliver-Rainer Wittmann case RES_SETEXPFLD:
35569a74367SOliver-Rainer Wittmann if( ((SwSetExpField&)rFld).GetInputFlag() )
35669a74367SOliver-Rainer Wittmann StartInputFldDlg( (SwField*)&rFld, sal_False );
35769a74367SOliver-Rainer Wittmann break;
358cdf0e10cSrcweir case RES_DROPDOWN :
359cdf0e10cSrcweir StartDropDownFldDlg( (SwField*)&rFld, sal_False );
360cdf0e10cSrcweir break;
36169a74367SOliver-Rainer Wittmann }
362cdf0e10cSrcweir
363cdf0e10cSrcweir bIsInClickToEdit = sal_False;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir
ClickToINetAttr(const SwFmtINetFmt & rItem,sal_uInt16 nFilter)367cdf0e10cSrcweir void SwWrtShell::ClickToINetAttr( const SwFmtINetFmt& rItem, sal_uInt16 nFilter )
368cdf0e10cSrcweir {
369cdf0e10cSrcweir if( !rItem.GetValue().Len() )
370cdf0e10cSrcweir return ;
371cdf0e10cSrcweir
372cdf0e10cSrcweir bIsInClickToEdit = sal_True;
373cdf0e10cSrcweir
374cdf0e10cSrcweir // erstmal das evt. gesetzte ObjectSelect Macro ausfuehren
375cdf0e10cSrcweir const SvxMacro* pMac = rItem.GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
376cdf0e10cSrcweir if( pMac )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir SwCallMouseEvent aCallEvent;
379cdf0e10cSrcweir aCallEvent.Set( &rItem );
380cdf0e10cSrcweir GetDoc()->CallEvent( SFX_EVENT_MOUSECLICK_OBJECT, aCallEvent, sal_False );
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir // damit die Vorlagenumsetzung sofort angezeigt wird
384cdf0e10cSrcweir ::LoadURL( rItem.GetValue(), this, nFilter, &rItem.GetTargetFrame() );
385cdf0e10cSrcweir const SwTxtINetFmt* pTxtAttr = rItem.GetTxtINetFmt();
386cdf0e10cSrcweir if( pTxtAttr )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisited( true );
389cdf0e10cSrcweir const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( true );
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
392cdf0e10cSrcweir bIsInClickToEdit = sal_False;
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
395cdf0e10cSrcweir
396cdf0e10cSrcweir
ClickToINetGrf(const Point & rDocPt,sal_uInt16 nFilter)397cdf0e10cSrcweir sal_Bool SwWrtShell::ClickToINetGrf( const Point& rDocPt, sal_uInt16 nFilter )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir sal_Bool bRet = sal_False;
400cdf0e10cSrcweir String sURL;
401cdf0e10cSrcweir String sTargetFrameName;
402cdf0e10cSrcweir const SwFrmFmt* pFnd = IsURLGrfAtPos( rDocPt, &sURL, &sTargetFrameName );
403cdf0e10cSrcweir if( pFnd && sURL.Len() )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir bRet = sal_True;
406cdf0e10cSrcweir // erstmal das evt. gesetzte ObjectSelect Macro ausfuehren
407cdf0e10cSrcweir const SvxMacro* pMac = &pFnd->GetMacro().GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
408cdf0e10cSrcweir if( pMac )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir SwCallMouseEvent aCallEvent;
411cdf0e10cSrcweir aCallEvent.Set( EVENT_OBJECT_URLITEM, pFnd );
412cdf0e10cSrcweir GetDoc()->CallEvent( SFX_EVENT_MOUSECLICK_OBJECT, aCallEvent, sal_False );
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir ::LoadURL( sURL, this, nFilter, &sTargetFrameName);
416cdf0e10cSrcweir }
417cdf0e10cSrcweir return bRet;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir
LoadURL(const String & rURL,ViewShell * pVSh,sal_uInt16 nFilter,const String * pTargetFrameName)421cdf0e10cSrcweir void LoadURL( const String& rURL, ViewShell* pVSh, sal_uInt16 nFilter,
422cdf0e10cSrcweir const String *pTargetFrameName )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir ASSERT( rURL.Len() && pVSh, "was soll hier geladen werden?" );
425cdf0e10cSrcweir if( !rURL.Len() || !pVSh )
426cdf0e10cSrcweir return ;
427cdf0e10cSrcweir
428cdf0e10cSrcweir // die Shell kann auch 0 sein !!!!!
429cdf0e10cSrcweir SwWrtShell *pSh = 0;
430cdf0e10cSrcweir if ( pVSh && pVSh->ISA(SwCrsrShell) )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir //Eine CrsrShell ist auch immer eine WrtShell
433cdf0e10cSrcweir pSh = (SwWrtShell*)pVSh;
434cdf0e10cSrcweir }
435cdf0e10cSrcweir else
436cdf0e10cSrcweir return;
437cdf0e10cSrcweir
438cdf0e10cSrcweir SwDocShell* pDShell = pSh->GetView().GetDocShell();
439cdf0e10cSrcweir DBG_ASSERT( pDShell, "No DocShell?!");
440cdf0e10cSrcweir String sTargetFrame;
441cdf0e10cSrcweir if( pTargetFrameName && pTargetFrameName->Len() )
442cdf0e10cSrcweir sTargetFrame = *pTargetFrameName;
443cdf0e10cSrcweir else if( pDShell ) {
444cdf0e10cSrcweir using namespace ::com::sun::star;
445cdf0e10cSrcweir uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
446cdf0e10cSrcweir pDShell->GetModel(), uno::UNO_QUERY_THROW);
447cdf0e10cSrcweir uno::Reference<document::XDocumentProperties> xDocProps
448cdf0e10cSrcweir = xDPS->getDocumentProperties();
449cdf0e10cSrcweir sTargetFrame = xDocProps->getDefaultTarget();
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452cdf0e10cSrcweir String sReferer;
453cdf0e10cSrcweir if( pDShell && pDShell->GetMedium() )
454cdf0e10cSrcweir sReferer = pDShell->GetMedium()->GetName();
455cdf0e10cSrcweir SfxViewFrame* pViewFrm = pSh->GetView().GetViewFrame();
456cdf0e10cSrcweir SfxFrameItem aView( SID_DOCFRAME, pViewFrm );
457cdf0e10cSrcweir SfxStringItem aName( SID_FILE_NAME, rURL );
458cdf0e10cSrcweir SfxStringItem aTargetFrameName( SID_TARGETNAME, sTargetFrame );
459cdf0e10cSrcweir SfxStringItem aReferer( SID_REFERER, sReferer );
460cdf0e10cSrcweir
461cdf0e10cSrcweir SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_False );
462cdf0e10cSrcweir //#39076# Silent kann lt. SFX entfernt werden.
463cdf0e10cSrcweir // SfxBoolItem aSilent( SID_SILENT, sal_True );
464cdf0e10cSrcweir SfxBoolItem aBrowse( SID_BROWSE, sal_True );
465cdf0e10cSrcweir
466cdf0e10cSrcweir if( nFilter & URLLOAD_NEWVIEW )
467cdf0e10cSrcweir aTargetFrameName.SetValue( String::CreateFromAscii("_blank") );
468cdf0e10cSrcweir
469cdf0e10cSrcweir const SfxPoolItem* aArr[] = {
470cdf0e10cSrcweir &aName,
471cdf0e10cSrcweir &aNewView, /*&aSilent,*/
472cdf0e10cSrcweir &aReferer,
473cdf0e10cSrcweir &aView, &aTargetFrameName,
474cdf0e10cSrcweir &aBrowse,
475cdf0e10cSrcweir 0L
476cdf0e10cSrcweir };
477cdf0e10cSrcweir
478cdf0e10cSrcweir pViewFrm->GetDispatcher()->GetBindings()->Execute( SID_OPENDOC, aArr,
479cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD );
480cdf0e10cSrcweir }
481cdf0e10cSrcweir
NavigatorPaste(const NaviContentBookmark & rBkmk,const sal_uInt16 nAction)482cdf0e10cSrcweir void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk,
483cdf0e10cSrcweir const sal_uInt16 nAction )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir if( EXCHG_IN_ACTION_COPY == nAction )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir // Einfuegen
488cdf0e10cSrcweir String sURL = rBkmk.GetURL();
489cdf0e10cSrcweir //handelt es sich um ein Sprung innerhalb des akt. Docs?
490cdf0e10cSrcweir const SwDocShell* pDocShell = GetView().GetDocShell();
491cdf0e10cSrcweir if(pDocShell->HasName())
492cdf0e10cSrcweir {
493cdf0e10cSrcweir const String rName = pDocShell->GetMedium()->GetURLObject().GetURLNoMark();
494cdf0e10cSrcweir
495cdf0e10cSrcweir if(COMPARE_EQUAL == sURL.CompareTo(rName, rName.Len()))
496cdf0e10cSrcweir sURL.Erase(0, rName.Len());
497cdf0e10cSrcweir }
498cdf0e10cSrcweir SwFmtINetFmt aFmt( sURL, aEmptyStr );
499cdf0e10cSrcweir InsertURL( aFmt, rBkmk.GetDescription() );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir else
502cdf0e10cSrcweir {
503cdf0e10cSrcweir SwSectionData aSection( FILE_LINK_SECTION, GetUniqueSectionName( 0 ) );
504cdf0e10cSrcweir String aLinkFile( rBkmk.GetURL().GetToken(0, '#') );
505cdf0e10cSrcweir aLinkFile += sfx2::cTokenSeperator;
506cdf0e10cSrcweir aLinkFile += sfx2::cTokenSeperator;
507cdf0e10cSrcweir aLinkFile += rBkmk.GetURL().GetToken(1, '#');
508cdf0e10cSrcweir aSection.SetLinkFileName( aLinkFile );
509cdf0e10cSrcweir aSection.SetProtectFlag( true );
510cdf0e10cSrcweir const SwSection* pIns = InsertSection( aSection );
511cdf0e10cSrcweir if( EXCHG_IN_ACTION_MOVE == nAction && pIns )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir aSection = SwSectionData(*pIns);
514cdf0e10cSrcweir aSection.SetLinkFileName( aEmptyStr );
515cdf0e10cSrcweir aSection.SetType( CONTENT_SECTION );
516cdf0e10cSrcweir aSection.SetProtectFlag( false );
517cdf0e10cSrcweir
518cdf0e10cSrcweir // the update of content from linked section at time delete
519cdf0e10cSrcweir // the undostack. Then the change of the section dont create
520cdf0e10cSrcweir // any undoobject. - BUG 69145
521cdf0e10cSrcweir sal_Bool bDoesUndo = DoesUndo();
522cdf0e10cSrcweir SwUndoId nLastUndoId(UNDO_EMPTY);
523cdf0e10cSrcweir if (GetLastUndoInfo(0, & nLastUndoId))
524cdf0e10cSrcweir {
525cdf0e10cSrcweir if (UNDO_INSSECTION != nLastUndoId)
526cdf0e10cSrcweir {
527cdf0e10cSrcweir DoUndo(false);
528cdf0e10cSrcweir }
529cdf0e10cSrcweir }
530cdf0e10cSrcweir UpdateSection( GetSectionFmtPos( *pIns->GetFmt() ), aSection );
531cdf0e10cSrcweir DoUndo( bDoesUndo );
532cdf0e10cSrcweir }
533cdf0e10cSrcweir }
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir
537