xref: /aoo41x/main/sw/source/ui/wrtsh/wrtsh2.cxx (revision 69a74367)
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 
77cdf0e10cSrcweir void SwWrtShell::Insert(SwField &rFld)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	ResetCursorStack();
80cdf0e10cSrcweir 	if(!_CanInsert())
81cdf0e10cSrcweir 		return;
82cdf0e10cSrcweir 	StartAllAction();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     SwRewriter aRewriter;
85cdf0e10cSrcweir     aRewriter.AddRule(UNDO_ARG1, rFld.GetDescription());
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	StartUndo(UNDO_INSERT, &aRewriter);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     bool bDeleted = false;
90cdf0e10cSrcweir 	if( HasSelection() )
91cdf0e10cSrcweir     {
92cdf0e10cSrcweir         bDeleted = DelRight() != 0;
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     SwEditShell::Insert2(rFld, bDeleted);
96cdf0e10cSrcweir     EndUndo();
97cdf0e10cSrcweir 	EndAllAction();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir /*--------------------------------------------------------------------
101cdf0e10cSrcweir 	Beschreibung: Felder Update anschmeissen
102cdf0e10cSrcweir  --------------------------------------------------------------------*/
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106*69a74367SOliver-Rainer Wittmann void SwWrtShell::UpdateInputFlds( SwInputFieldList* pLst )
107cdf0e10cSrcweir {
108*69a74367SOliver-Rainer Wittmann     // ueber die Liste der Eingabefelder gehen und Updaten
109*69a74367SOliver-Rainer Wittmann     SwInputFieldList* pTmp = pLst;
110*69a74367SOliver-Rainer Wittmann     if( !pTmp )
111*69a74367SOliver-Rainer Wittmann         pTmp = new SwInputFieldList( this );
112cdf0e10cSrcweir 
113*69a74367SOliver-Rainer Wittmann     const sal_uInt16 nCnt = pTmp->Count();
114*69a74367SOliver-Rainer Wittmann     if(nCnt)
115*69a74367SOliver-Rainer Wittmann     {
116*69a74367SOliver-Rainer Wittmann         pTmp->PushCrsr();
117cdf0e10cSrcweir 
118*69a74367SOliver-Rainer Wittmann         sal_Bool bCancel = sal_False;
119cdf0e10cSrcweir         ByteString aDlgPos;
120*69a74367SOliver-Rainer Wittmann         for( sal_uInt16 i = 0; i < nCnt && !bCancel; ++i )
121*69a74367SOliver-Rainer Wittmann         {
122*69a74367SOliver-Rainer Wittmann             pTmp->GotoFieldPos( i );
123cdf0e10cSrcweir             SwField* pField = pTmp->GetField( i );
124cdf0e10cSrcweir             if(pField->GetTyp()->Which() == RES_DROPDOWN)
125cdf0e10cSrcweir                 bCancel = StartDropDownFldDlg( pField, sal_True, &aDlgPos );
126cdf0e10cSrcweir             else
127cdf0e10cSrcweir                 bCancel = StartInputFldDlg( pField, sal_True, 0, &aDlgPos);
128cdf0e10cSrcweir 
129*69a74367SOliver-Rainer Wittmann             // Sonst Updatefehler bei Multiselektion:
130*69a74367SOliver-Rainer Wittmann             pTmp->GetField( i )->GetTyp()->UpdateFlds();
131*69a74367SOliver-Rainer Wittmann         }
132*69a74367SOliver-Rainer Wittmann         pTmp->PopCrsr();
133*69a74367SOliver-Rainer Wittmann     }
134cdf0e10cSrcweir 
135*69a74367SOliver-Rainer Wittmann     if( !pLst )
136*69a74367SOliver-Rainer Wittmann         delete pTmp;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 
140cdf0e10cSrcweir /*--------------------------------------------------------------------
141cdf0e10cSrcweir 	Beschreibung: EingabeDialog fuer ein bestimmtes Feld starten
142cdf0e10cSrcweir  --------------------------------------------------------------------*/
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir sal_Bool SwWrtShell::StartInputFldDlg( SwField* pFld, sal_Bool bNextButton,
147cdf0e10cSrcweir                                     Window* pParentWin, ByteString* pWindowState )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir //JP 14.08.96: Bug 30332 - nach Umbau der modularietaet im SFX, muss jetzt
150cdf0e10cSrcweir //				das TopWindow der Application benutzt werden.
151cdf0e10cSrcweir //	SwFldInputDlg* pDlg = new SwFldInputDlg( GetWin(), *this, pFld );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
154cdf0e10cSrcweir     DBG_ASSERT(pFact, "Dialogdiet fail!");
155cdf0e10cSrcweir     AbstractFldInputDlg* pDlg = pFact->CreateFldInputDlg( DLG_FLD_INPUT,
156cdf0e10cSrcweir                                                         pParentWin, *this, pFld, bNextButton);
157cdf0e10cSrcweir     DBG_ASSERT(pDlg, "Dialogdiet fail!");
158cdf0e10cSrcweir 	if(pWindowState && pWindowState->Len())
159cdf0e10cSrcweir         pDlg->SetWindowState(*pWindowState);
160cdf0e10cSrcweir 	sal_Bool bRet = RET_CANCEL == pDlg->Execute();
161cdf0e10cSrcweir     if(pWindowState)
162cdf0e10cSrcweir         *pWindowState = pDlg->GetWindowState();
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	delete pDlg;
165cdf0e10cSrcweir 	GetWin()->Update();
166cdf0e10cSrcweir 	return bRet;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir /* -----------------17.06.2003 10:18-----------------
169cdf0e10cSrcweir 
170cdf0e10cSrcweir  --------------------------------------------------*/
171cdf0e10cSrcweir sal_Bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, sal_Bool bNextButton, ByteString* pWindowState)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
174cdf0e10cSrcweir     DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     AbstractDropDownFieldDialog* pDlg = pFact->CreateDropDownFieldDialog( NULL, *this, pFld, DLG_FLD_DROPDOWN ,bNextButton );
177cdf0e10cSrcweir     DBG_ASSERT(pDlg, "Dialogdiet fail!");
178cdf0e10cSrcweir     if(pWindowState && pWindowState->Len())
179cdf0e10cSrcweir         pDlg->SetWindowState(*pWindowState);
180cdf0e10cSrcweir     sal_uInt16 nRet = pDlg->Execute();
181cdf0e10cSrcweir     if(pWindowState)
182cdf0e10cSrcweir         *pWindowState = pDlg->GetWindowState();
183cdf0e10cSrcweir     delete pDlg;
184cdf0e10cSrcweir     sal_Bool bRet = RET_CANCEL == nRet;
185cdf0e10cSrcweir     GetWin()->Update();
186cdf0e10cSrcweir     if(RET_YES == nRet)
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir         GetView().GetViewFrame()->GetDispatcher()->Execute(FN_EDIT_FIELD, SFX_CALLMODE_SYNCHRON);
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir     return bRet;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir /*--------------------------------------------------------------------
194cdf0e10cSrcweir 	Beschreibung: Verzeichnis einfuegen Selektion loeschen
195cdf0e10cSrcweir  --------------------------------------------------------------------*/
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir void SwWrtShell::InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir 	if(!_CanInsert())
202cdf0e10cSrcweir 		return;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	if(HasSelection())
205cdf0e10cSrcweir 		DelRight();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	SwEditShell::InsertTableOf(rTOX, pSet);
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
211cdf0e10cSrcweir /*--------------------------------------------------------------------
212cdf0e10cSrcweir 	Beschreibung: Verzeichnis Updaten Selektion loeschen
213cdf0e10cSrcweir  --------------------------------------------------------------------*/
214cdf0e10cSrcweir 
215cdf0e10cSrcweir sal_Bool SwWrtShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir     sal_Bool bResult = sal_False;
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	if(_CanInsert())
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         bResult = SwEditShell::UpdateTableOf(rTOX, pSet);
222cdf0e10cSrcweir 
223cdf0e10cSrcweir         if (pSet == NULL)
224cdf0e10cSrcweir         {
225cdf0e10cSrcweir             SwDoc *const pDoc_ = GetDoc();
226cdf0e10cSrcweir             if (pDoc_)
227cdf0e10cSrcweir             {
228cdf0e10cSrcweir                 pDoc_->GetIDocumentUndoRedo().DelAllUndoObj();
229cdf0e10cSrcweir             }
230cdf0e10cSrcweir         }
231cdf0e10cSrcweir     }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     return bResult;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir // handler for click on the field given as parameter.
237cdf0e10cSrcweir // the cursor is positioned on the field.
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 
240cdf0e10cSrcweir void SwWrtShell::ClickToField( const SwField& rFld )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir 	bIsInClickToEdit = sal_True;
243cdf0e10cSrcweir 	switch( rFld.GetTyp()->Which() )
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 	case RES_JUMPEDITFLD:
246cdf0e10cSrcweir 		{
247cdf0e10cSrcweir 			sal_uInt16 nSlotId = 0;
248cdf0e10cSrcweir 			switch( rFld.GetFormat() )
249cdf0e10cSrcweir 			{
250cdf0e10cSrcweir 			case JE_FMT_TABLE:
251cdf0e10cSrcweir 				nSlotId = FN_INSERT_TABLE;
252cdf0e10cSrcweir 				break;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 			case JE_FMT_FRAME:
255cdf0e10cSrcweir 				nSlotId = FN_INSERT_FRAME;
256cdf0e10cSrcweir 				break;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 			case JE_FMT_GRAPHIC:	nSlotId = SID_INSERT_GRAPHIC;		break;
259cdf0e10cSrcweir 			case JE_FMT_OLE:        nSlotId = SID_INSERT_OBJECT;		break;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir //			case JE_FMT_TEXT:
262cdf0e10cSrcweir 			}
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 			Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False );		// Feld selektieren
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 			if( nSlotId )
267cdf0e10cSrcweir 			{
268cdf0e10cSrcweir 				StartUndo( UNDO_START );
269cdf0e10cSrcweir 				//#97295# immediately select the right shell
270cdf0e10cSrcweir                 GetView().StopShellTimer();
271cdf0e10cSrcweir                 GetView().GetViewFrame()->GetDispatcher()->Execute( nSlotId,
272cdf0e10cSrcweir 							SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
273cdf0e10cSrcweir 				EndUndo( UNDO_END );
274cdf0e10cSrcweir 			}
275cdf0e10cSrcweir 		}
276cdf0e10cSrcweir 		break;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 	case RES_MACROFLD:
279cdf0e10cSrcweir 		{
280cdf0e10cSrcweir 			const SwMacroField *pFld = (const SwMacroField*)&rFld;
281cdf0e10cSrcweir 			String sText( rFld.GetPar2() );
282cdf0e10cSrcweir 			String sRet( sText );
283cdf0e10cSrcweir 			ExecMacro( pFld->GetSvxMacro(), &sRet );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 			// return Wert veraendert?
286cdf0e10cSrcweir 			if( sRet != sText )
287cdf0e10cSrcweir 			{
288cdf0e10cSrcweir 				StartAllAction();
289cdf0e10cSrcweir 				((SwField&)rFld).SetPar2( sRet );
290cdf0e10cSrcweir 				((SwField&)rFld).GetTyp()->UpdateFlds();
291cdf0e10cSrcweir 				EndAllAction();
292cdf0e10cSrcweir 			}
293cdf0e10cSrcweir 		}
294cdf0e10cSrcweir 		break;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	case RES_GETREFFLD:
297cdf0e10cSrcweir 		StartAllAction();
298cdf0e10cSrcweir 		SwCrsrShell::GotoRefMark( ((SwGetRefField&)rFld).GetSetRefName(),
299cdf0e10cSrcweir 									((SwGetRefField&)rFld).GetSubType(),
300cdf0e10cSrcweir 									((SwGetRefField&)rFld).GetSeqNo() );
301cdf0e10cSrcweir 		EndAllAction();
302cdf0e10cSrcweir 		break;
303cdf0e10cSrcweir 
304*69a74367SOliver-Rainer Wittmann     case RES_INPUTFLD:
305*69a74367SOliver-Rainer Wittmann         {
306*69a74367SOliver-Rainer Wittmann             const SwInputField* pInputField = dynamic_cast<const SwInputField*>(&rFld);
307*69a74367SOliver-Rainer Wittmann             if ( pInputField == NULL )
308*69a74367SOliver-Rainer Wittmann             {
309*69a74367SOliver-Rainer Wittmann                 StartInputFldDlg( (SwField*)&rFld, sal_False );
310*69a74367SOliver-Rainer Wittmann             }
311*69a74367SOliver-Rainer Wittmann         }
312*69a74367SOliver-Rainer Wittmann         break;
313cdf0e10cSrcweir 
314*69a74367SOliver-Rainer Wittmann     case RES_SETEXPFLD:
315*69a74367SOliver-Rainer Wittmann         if( ((SwSetExpField&)rFld).GetInputFlag() )
316*69a74367SOliver-Rainer Wittmann             StartInputFldDlg( (SwField*)&rFld, sal_False );
317*69a74367SOliver-Rainer Wittmann         break;
318cdf0e10cSrcweir     case RES_DROPDOWN :
319cdf0e10cSrcweir         StartDropDownFldDlg( (SwField*)&rFld, sal_False );
320cdf0e10cSrcweir     break;
321*69a74367SOliver-Rainer Wittmann     }
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	bIsInClickToEdit = sal_False;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 
327cdf0e10cSrcweir void SwWrtShell::ClickToINetAttr( const SwFmtINetFmt& rItem, sal_uInt16 nFilter )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	if( !rItem.GetValue().Len() )
330cdf0e10cSrcweir 		return ;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	bIsInClickToEdit = sal_True;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	// erstmal das evt. gesetzte ObjectSelect Macro ausfuehren
335cdf0e10cSrcweir 	const SvxMacro* pMac = rItem.GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
336cdf0e10cSrcweir 	if( pMac )
337cdf0e10cSrcweir 	{
338cdf0e10cSrcweir 		SwCallMouseEvent aCallEvent;
339cdf0e10cSrcweir 		aCallEvent.Set( &rItem );
340cdf0e10cSrcweir 		GetDoc()->CallEvent( SFX_EVENT_MOUSECLICK_OBJECT, aCallEvent, sal_False );
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	// damit die Vorlagenumsetzung sofort angezeigt wird
344cdf0e10cSrcweir 	::LoadURL( rItem.GetValue(), this, nFilter, &rItem.GetTargetFrame() );
345cdf0e10cSrcweir     const SwTxtINetFmt* pTxtAttr = rItem.GetTxtINetFmt();
346cdf0e10cSrcweir     if( pTxtAttr )
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisited( true );
349cdf0e10cSrcweir         const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( true );
350cdf0e10cSrcweir     }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	bIsInClickToEdit = sal_False;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 
357cdf0e10cSrcweir sal_Bool SwWrtShell::ClickToINetGrf( const Point& rDocPt, sal_uInt16 nFilter )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
360cdf0e10cSrcweir 	String sURL;
361cdf0e10cSrcweir 	String sTargetFrameName;
362cdf0e10cSrcweir 	const SwFrmFmt* pFnd = IsURLGrfAtPos( rDocPt, &sURL, &sTargetFrameName );
363cdf0e10cSrcweir 	if( pFnd && sURL.Len() )
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		bRet = sal_True;
366cdf0e10cSrcweir 		// erstmal das evt. gesetzte ObjectSelect Macro ausfuehren
367cdf0e10cSrcweir 		const SvxMacro* pMac = &pFnd->GetMacro().GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
368cdf0e10cSrcweir 		if( pMac )
369cdf0e10cSrcweir 		{
370cdf0e10cSrcweir 			SwCallMouseEvent aCallEvent;
371cdf0e10cSrcweir 			aCallEvent.Set( EVENT_OBJECT_URLITEM, pFnd );
372cdf0e10cSrcweir 			GetDoc()->CallEvent( SFX_EVENT_MOUSECLICK_OBJECT, aCallEvent, sal_False );
373cdf0e10cSrcweir 		}
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 		::LoadURL( sURL, this, nFilter, &sTargetFrameName);
376cdf0e10cSrcweir 	}
377cdf0e10cSrcweir 	return bRet;
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 
381cdf0e10cSrcweir void LoadURL( const String& rURL, ViewShell* pVSh, sal_uInt16 nFilter,
382cdf0e10cSrcweir 			  const String *pTargetFrameName )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir 	ASSERT( rURL.Len() && pVSh, "was soll hier geladen werden?" );
385cdf0e10cSrcweir 	if( !rURL.Len() || !pVSh )
386cdf0e10cSrcweir 		return ;
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	// die Shell kann auch 0 sein !!!!!
389cdf0e10cSrcweir 	SwWrtShell *pSh = 0;
390cdf0e10cSrcweir 	if ( pVSh && pVSh->ISA(SwCrsrShell) )
391cdf0e10cSrcweir 	{
392cdf0e10cSrcweir 		//Eine CrsrShell ist auch immer eine WrtShell
393cdf0e10cSrcweir 		pSh = (SwWrtShell*)pVSh;
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 	else
396cdf0e10cSrcweir 		return;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 	SwDocShell* pDShell = pSh->GetView().GetDocShell();
399cdf0e10cSrcweir 	DBG_ASSERT( pDShell, "No DocShell?!");
400cdf0e10cSrcweir 	String sTargetFrame;
401cdf0e10cSrcweir 	if( pTargetFrameName && pTargetFrameName->Len() )
402cdf0e10cSrcweir 		sTargetFrame = *pTargetFrameName;
403cdf0e10cSrcweir 	else if( pDShell ) {
404cdf0e10cSrcweir         using namespace ::com::sun::star;
405cdf0e10cSrcweir         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
406cdf0e10cSrcweir             pDShell->GetModel(), uno::UNO_QUERY_THROW);
407cdf0e10cSrcweir         uno::Reference<document::XDocumentProperties> xDocProps
408cdf0e10cSrcweir             = xDPS->getDocumentProperties();
409cdf0e10cSrcweir         sTargetFrame = xDocProps->getDefaultTarget();
410cdf0e10cSrcweir     }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	String sReferer;
413cdf0e10cSrcweir 	if( pDShell && pDShell->GetMedium() )
414cdf0e10cSrcweir 		sReferer = pDShell->GetMedium()->GetName();
415cdf0e10cSrcweir 	SfxViewFrame* pViewFrm = pSh->GetView().GetViewFrame();
416cdf0e10cSrcweir 	SfxFrameItem aView( SID_DOCFRAME, pViewFrm );
417cdf0e10cSrcweir 	SfxStringItem aName( SID_FILE_NAME, rURL );
418cdf0e10cSrcweir 	SfxStringItem aTargetFrameName( SID_TARGETNAME, sTargetFrame );
419cdf0e10cSrcweir 	SfxStringItem aReferer( SID_REFERER, sReferer );
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_False );
422cdf0e10cSrcweir 	//#39076# Silent kann lt. SFX entfernt werden.
423cdf0e10cSrcweir //	SfxBoolItem aSilent( SID_SILENT, sal_True );
424cdf0e10cSrcweir 	SfxBoolItem aBrowse( SID_BROWSE, sal_True );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	if( nFilter & URLLOAD_NEWVIEW )
427cdf0e10cSrcweir 		aTargetFrameName.SetValue( String::CreateFromAscii("_blank") );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	const SfxPoolItem* aArr[] = {
430cdf0e10cSrcweir 				&aName,
431cdf0e10cSrcweir                 &aNewView, /*&aSilent,*/
432cdf0e10cSrcweir 				&aReferer,
433cdf0e10cSrcweir 				&aView, &aTargetFrameName,
434cdf0e10cSrcweir 				&aBrowse,
435cdf0e10cSrcweir 				0L
436cdf0e10cSrcweir 	};
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 	pViewFrm->GetDispatcher()->GetBindings()->Execute( SID_OPENDOC, aArr,
439cdf0e10cSrcweir 			SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD );
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk,
443cdf0e10cSrcweir 									const sal_uInt16 nAction )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	if( EXCHG_IN_ACTION_COPY == nAction )
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		// Einfuegen
448cdf0e10cSrcweir 		String sURL = rBkmk.GetURL();
449cdf0e10cSrcweir 		//handelt es sich um ein Sprung innerhalb des akt. Docs?
450cdf0e10cSrcweir 		const SwDocShell* pDocShell = GetView().GetDocShell();
451cdf0e10cSrcweir 		if(pDocShell->HasName())
452cdf0e10cSrcweir 		{
453cdf0e10cSrcweir             const String rName = pDocShell->GetMedium()->GetURLObject().GetURLNoMark();
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 			if(COMPARE_EQUAL == sURL.CompareTo(rName, rName.Len()))
456cdf0e10cSrcweir 				sURL.Erase(0, rName.Len());
457cdf0e10cSrcweir 		}
458cdf0e10cSrcweir 		SwFmtINetFmt aFmt( sURL, aEmptyStr );
459cdf0e10cSrcweir 		InsertURL( aFmt, rBkmk.GetDescription() );
460cdf0e10cSrcweir 	}
461cdf0e10cSrcweir 	else
462cdf0e10cSrcweir 	{
463cdf0e10cSrcweir         SwSectionData aSection( FILE_LINK_SECTION, GetUniqueSectionName( 0 ) );
464cdf0e10cSrcweir 		String aLinkFile( rBkmk.GetURL().GetToken(0, '#') );
465cdf0e10cSrcweir         aLinkFile += sfx2::cTokenSeperator;
466cdf0e10cSrcweir         aLinkFile += sfx2::cTokenSeperator;
467cdf0e10cSrcweir 		aLinkFile += rBkmk.GetURL().GetToken(1, '#');
468cdf0e10cSrcweir 		aSection.SetLinkFileName( aLinkFile );
469cdf0e10cSrcweir         aSection.SetProtectFlag( true );
470cdf0e10cSrcweir 		const SwSection* pIns = InsertSection( aSection );
471cdf0e10cSrcweir 		if( EXCHG_IN_ACTION_MOVE == nAction && pIns )
472cdf0e10cSrcweir 		{
473cdf0e10cSrcweir             aSection = SwSectionData(*pIns);
474cdf0e10cSrcweir 			aSection.SetLinkFileName( aEmptyStr );
475cdf0e10cSrcweir 			aSection.SetType( CONTENT_SECTION );
476cdf0e10cSrcweir             aSection.SetProtectFlag( false );
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 			// the update of content from linked section at time delete
479cdf0e10cSrcweir 			// the undostack. Then the change of the section dont create
480cdf0e10cSrcweir 			// any undoobject. -  BUG 69145
481cdf0e10cSrcweir 			sal_Bool bDoesUndo = DoesUndo();
482cdf0e10cSrcweir             SwUndoId nLastUndoId(UNDO_EMPTY);
483cdf0e10cSrcweir             if (GetLastUndoInfo(0, & nLastUndoId))
484cdf0e10cSrcweir             {
485cdf0e10cSrcweir                 if (UNDO_INSSECTION != nLastUndoId)
486cdf0e10cSrcweir                 {
487cdf0e10cSrcweir                     DoUndo(false);
488cdf0e10cSrcweir                 }
489cdf0e10cSrcweir             }
490cdf0e10cSrcweir             UpdateSection( GetSectionFmtPos( *pIns->GetFmt() ), aSection );
491cdf0e10cSrcweir 			DoUndo( bDoesUndo );
492cdf0e10cSrcweir 		}
493cdf0e10cSrcweir 	}
494cdf0e10cSrcweir }
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
497