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