xref: /trunk/main/sfx2/source/appl/linkmgr2.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d119d52dSAndrew Rist  * distributed with this work for additional information
6d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17d119d52dSAndrew Rist  * specific language governing permissions and limitations
18d119d52dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20d119d52dSAndrew Rist  *************************************************************/
21d119d52dSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
26cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp>
2768281b3fSArrigo Marchiori #include <com/sun/star/lang/XMultiServiceFactory.hpp>
2868281b3fSArrigo Marchiori #include <com/sun/star/util/XURLTransformer.hpp>
2968281b3fSArrigo Marchiori 
30cdf0e10cSrcweir #include <sfx2/objsh.hxx>
31cdf0e10cSrcweir #include <svl/urihelper.hxx>
32cdf0e10cSrcweir #include <sot/formats.hxx>
33cdf0e10cSrcweir #include <tools/urlobj.hxx>
34cdf0e10cSrcweir #include <sot/exchange.hxx>
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir #include <vcl/msgbox.hxx>
37cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
38cdf0e10cSrcweir #include <sfx2/app.hxx>
39cdf0e10cSrcweir #include <vcl/graph.hxx>
40cdf0e10cSrcweir #include <svl/stritem.hxx>
41cdf0e10cSrcweir #include <svl/eitem.hxx>
42cdf0e10cSrcweir #include <svl/intitem.hxx>
43cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
4468281b3fSArrigo Marchiori #include <comphelper/processfactory.hxx>
45cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
46cdf0e10cSrcweir #include <sfx2/request.hxx>
4745fd3b9aSArmin Le Grand #include <vcl/dibtools.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include "fileobj.hxx"
50cdf0e10cSrcweir #include "impldde.hxx"
51cdf0e10cSrcweir #include "app.hrc"
52cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
55cdf0e10cSrcweir #include <svl/svstdarr.hxx>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace sfx2
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 
60cdf0e10cSrcweir class SvxInternalLink : public sfx2::SvLinkSource
61cdf0e10cSrcweir {
62cdf0e10cSrcweir public:
SvxInternalLink()63cdf0e10cSrcweir     SvxInternalLink() {}
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     virtual sal_Bool Connect( sfx2::SvBaseLink* );
66cdf0e10cSrcweir };
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
SV_IMPL_PTRARR(SvBaseLinks,SvBaseLinkRefPtr)69cdf0e10cSrcweir SV_IMPL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr )
70cdf0e10cSrcweir 
71cdf0e10cSrcweir LinkManager::LinkManager(SfxObjectShell* p)
72b0c1db7eSPatricia Shanahan     : pPersist(p),
733f92111aSArrigo Marchiori     mAutoAskUpdateAllLinks(sal_False),
743f92111aSArrigo Marchiori     mUpdateAsked(sal_False)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
~LinkManager()78cdf0e10cSrcweir LinkManager::~LinkManager()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     SvBaseLinkRef** ppRef = (SvBaseLinkRef**)aLinkTbl.GetData();
81cdf0e10cSrcweir     for( sal_uInt16 n = aLinkTbl.Count(); n; --n, ++ppRef )
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir         if( (*ppRef)->Is() )
84cdf0e10cSrcweir         {
85cdf0e10cSrcweir             (*(*ppRef))->Disconnect();
86cdf0e10cSrcweir             (*(*ppRef))->SetLinkManager( NULL );
87cdf0e10cSrcweir         }
88cdf0e10cSrcweir         delete *ppRef;
89cdf0e10cSrcweir     }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir /************************************************************************
94cdf0e10cSrcweir |*    LinkManager::Remove()
95cdf0e10cSrcweir |*
965799d6dbSmarcus |*    Description
97cdf0e10cSrcweir *************************************************************************/
98cdf0e10cSrcweir 
Remove(SvBaseLink * pLink)99cdf0e10cSrcweir void LinkManager::Remove( SvBaseLink *pLink )
100cdf0e10cSrcweir {
1015799d6dbSmarcus     // do not insert links double
102cdf0e10cSrcweir     int bFound = sal_False;
103cdf0e10cSrcweir     SvBaseLinkRef** ppRef = (SvBaseLinkRef**)aLinkTbl.GetData();
104cdf0e10cSrcweir     for( sal_uInt16 n = aLinkTbl.Count(); n; --n, ++ppRef )
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         if( pLink == *(*ppRef) )
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir             (*(*ppRef))->Disconnect();
109cdf0e10cSrcweir             (*(*ppRef))->SetLinkManager( NULL );
110cdf0e10cSrcweir             (*(*ppRef)).Clear();
111cdf0e10cSrcweir             bFound = sal_True;
112cdf0e10cSrcweir         }
113cdf0e10cSrcweir 
1145799d6dbSmarcus         // if there are still some empty ones, get rid of them
115cdf0e10cSrcweir         if( !(*ppRef)->Is() )
116cdf0e10cSrcweir         {
117cdf0e10cSrcweir             delete *ppRef;
118cdf0e10cSrcweir             aLinkTbl.Remove( aLinkTbl.Count() - n, 1 );
119cdf0e10cSrcweir             if( bFound )
120cdf0e10cSrcweir                 return ;
121cdf0e10cSrcweir             --ppRef;
122cdf0e10cSrcweir         }
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
Remove(sal_uInt16 nPos,sal_uInt16 nCnt)127cdf0e10cSrcweir void LinkManager::Remove( sal_uInt16 nPos, sal_uInt16 nCnt )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     if( nCnt && nPos < aLinkTbl.Count() )
130cdf0e10cSrcweir     {
131cdf0e10cSrcweir         if( nPos + nCnt > aLinkTbl.Count() )
132cdf0e10cSrcweir             nCnt = aLinkTbl.Count() - nPos;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         SvBaseLinkRef** ppRef = (SvBaseLinkRef**)aLinkTbl.GetData() + nPos;
135cdf0e10cSrcweir         for( sal_uInt16 n = nCnt; n; --n, ++ppRef )
136cdf0e10cSrcweir         {
137cdf0e10cSrcweir             if( (*ppRef)->Is() )
138cdf0e10cSrcweir             {
139cdf0e10cSrcweir                 (*(*ppRef))->Disconnect();
140cdf0e10cSrcweir                 (*(*ppRef))->SetLinkManager( NULL );
141cdf0e10cSrcweir             }
142cdf0e10cSrcweir             delete *ppRef;
143cdf0e10cSrcweir         }
144cdf0e10cSrcweir         aLinkTbl.Remove( nPos, nCnt );
145cdf0e10cSrcweir     }
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
Insert(SvBaseLink * pLink)149cdf0e10cSrcweir sal_Bool LinkManager::Insert( SvBaseLink* pLink )
150cdf0e10cSrcweir {
151b0c1db7eSPatricia Shanahan 
1525799d6dbSmarcus     // do not insert links double
153cdf0e10cSrcweir     for( sal_uInt16 n = 0; n < aLinkTbl.Count(); ++n )
154cdf0e10cSrcweir     {
155cdf0e10cSrcweir         SvBaseLinkRef* pTmp = aLinkTbl[ n ];
156cdf0e10cSrcweir         if( !pTmp->Is() )
157cdf0e10cSrcweir             aLinkTbl.DeleteAndDestroy( n-- );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir         if( pLink == *pTmp )
160cdf0e10cSrcweir             return sal_False;
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     SvBaseLinkRef* pTmp = new SvBaseLinkRef( pLink );
164cdf0e10cSrcweir     pLink->SetLinkManager( this );
165cdf0e10cSrcweir     aLinkTbl.Insert( pTmp, aLinkTbl.Count() );
166b0c1db7eSPatricia Shanahan     if (mAutoAskUpdateAllLinks)
167b0c1db7eSPatricia Shanahan     {
168789caf29SPatricia Shanahan         Window *parent = NULL;
169789caf29SPatricia Shanahan         SfxObjectShell* persist = GetPersist();
170789caf29SPatricia Shanahan         if (persist != NULL)
171789caf29SPatricia Shanahan             parent = GetPersist()->GetDialogParent();
172789caf29SPatricia Shanahan 
173b0c1db7eSPatricia Shanahan         SetUserAllowsLinkUpdate(pLink, GetUserAllowsLinkUpdate(parent));
174b0c1db7eSPatricia Shanahan     }
175b0c1db7eSPatricia Shanahan 
176cdf0e10cSrcweir     return sal_True;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
InsertLink(SvBaseLink * pLink,sal_uInt16 nObjType,sal_uInt16 nUpdateMode,const String * pName)180cdf0e10cSrcweir sal_Bool LinkManager::InsertLink( SvBaseLink * pLink,
181cdf0e10cSrcweir                                 sal_uInt16 nObjType,
182cdf0e10cSrcweir                                 sal_uInt16 nUpdateMode,
183cdf0e10cSrcweir                                 const String* pName )
184cdf0e10cSrcweir {
1855799d6dbSmarcus     // in any case: do this first
186cdf0e10cSrcweir     pLink->SetObjType( nObjType );
187cdf0e10cSrcweir     if( pName )
188cdf0e10cSrcweir         pLink->SetName( *pName );
189cdf0e10cSrcweir     pLink->SetUpdateMode( nUpdateMode );
190cdf0e10cSrcweir     return Insert( pLink );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 
InsertDDELink(SvBaseLink * pLink,const String & rServer,const String & rTopic,const String & rItem)194cdf0e10cSrcweir sal_Bool LinkManager::InsertDDELink( SvBaseLink * pLink,
195cdf0e10cSrcweir                                     const String& rServer,
196cdf0e10cSrcweir                                     const String& rTopic,
197cdf0e10cSrcweir                                     const String& rItem )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     if( !( OBJECT_CLIENT_SO & pLink->GetObjType() ) )
200cdf0e10cSrcweir         return sal_False;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     String sCmd;
203cdf0e10cSrcweir     ::sfx2::MakeLnkName( sCmd, &rServer, rTopic, rItem );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     pLink->SetObjType( OBJECT_CLIENT_DDE );
206cdf0e10cSrcweir     pLink->SetName( sCmd );
207cdf0e10cSrcweir     return Insert( pLink );
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
InsertDDELink(SvBaseLink * pLink)211cdf0e10cSrcweir sal_Bool LinkManager::InsertDDELink( SvBaseLink * pLink )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir     DBG_ASSERT( OBJECT_CLIENT_SO & pLink->GetObjType(), "no OBJECT_CLIENT_SO" );
214cdf0e10cSrcweir     if( !( OBJECT_CLIENT_SO & pLink->GetObjType() ) )
215cdf0e10cSrcweir         return sal_False;
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     if( pLink->GetObjType() == OBJECT_CLIENT_SO )
218cdf0e10cSrcweir         pLink->SetObjType( OBJECT_CLIENT_DDE );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     return Insert( pLink );
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 
2245799d6dbSmarcus // ask for the strings to be used in the dialog
GetDisplayNames(const SvBaseLink * pLink,String * pType,String * pFile,String * pLinkStr,String * pFilter) const225cdf0e10cSrcweir sal_Bool LinkManager::GetDisplayNames( const SvBaseLink * pLink,
226cdf0e10cSrcweir                                         String* pType,
227cdf0e10cSrcweir                                         String* pFile,
228cdf0e10cSrcweir                                         String* pLinkStr,
229cdf0e10cSrcweir                                         String* pFilter ) const
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     sal_Bool bRet = sal_False;
232cdf0e10cSrcweir     const String sLNm( pLink->GetLinkSourceName() );
233cdf0e10cSrcweir     if( sLNm.Len() )
234cdf0e10cSrcweir     {
235cdf0e10cSrcweir         switch( pLink->GetObjType() )
236cdf0e10cSrcweir         {
237cdf0e10cSrcweir             case OBJECT_CLIENT_FILE:
238cdf0e10cSrcweir             case OBJECT_CLIENT_GRF:
239cdf0e10cSrcweir             case OBJECT_CLIENT_OLE:
240cdf0e10cSrcweir                 {
241cdf0e10cSrcweir                     sal_uInt16 nPos = 0;
242cdf0e10cSrcweir                     String sFile( sLNm.GetToken( 0, ::sfx2::cTokenSeperator, nPos ) );
243cdf0e10cSrcweir                     String sRange( sLNm.GetToken( 0, ::sfx2::cTokenSeperator, nPos ) );
244cdf0e10cSrcweir 
245cdf0e10cSrcweir                     if( pFile )
246cdf0e10cSrcweir                         *pFile = sFile;
247cdf0e10cSrcweir                     if( pLinkStr )
248cdf0e10cSrcweir                         *pLinkStr = sRange;
249cdf0e10cSrcweir                     if( pFilter )
250cdf0e10cSrcweir                         *pFilter = sLNm.Copy( nPos );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir                     if( pType )
253cdf0e10cSrcweir                     {
254cdf0e10cSrcweir                         sal_uInt16 nObjType = pLink->GetObjType();
255cdf0e10cSrcweir                         *pType = String( SfxResId(
256cdf0e10cSrcweir                                     ( OBJECT_CLIENT_FILE == nObjType || OBJECT_CLIENT_OLE == nObjType )
257cdf0e10cSrcweir                                             ? RID_SVXSTR_FILELINK
258cdf0e10cSrcweir                                             : RID_SVXSTR_GRAFIKLINK ));
259cdf0e10cSrcweir                     }
260cdf0e10cSrcweir                     bRet = sal_True;
261cdf0e10cSrcweir                 }
262cdf0e10cSrcweir                 break;
263cdf0e10cSrcweir             case OBJECT_CLIENT_DDE:
264cdf0e10cSrcweir                 {
265cdf0e10cSrcweir                     sal_uInt16 nTmp = 0;
266cdf0e10cSrcweir                     String sCmd( sLNm );
267cdf0e10cSrcweir                     String sServer( sCmd.GetToken( 0, cTokenSeperator, nTmp ) );
268cdf0e10cSrcweir                     String sTopic( sCmd.GetToken( 0, cTokenSeperator, nTmp ) );
269cdf0e10cSrcweir 
270cdf0e10cSrcweir                     if( pType )
271cdf0e10cSrcweir                         *pType = sServer;
272cdf0e10cSrcweir                     if( pFile )
273cdf0e10cSrcweir                         *pFile = sTopic;
274cdf0e10cSrcweir                     if( pLinkStr )
275cdf0e10cSrcweir                         *pLinkStr = sCmd.Copy( nTmp );
276cdf0e10cSrcweir                     bRet = sal_True;
277cdf0e10cSrcweir                 }
278cdf0e10cSrcweir                 break;
279cdf0e10cSrcweir             default:
280cdf0e10cSrcweir                 break;
281cdf0e10cSrcweir         }
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     return bRet;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
SetAutoAskUpdateAllLinks()287b0c1db7eSPatricia Shanahan void LinkManager::SetAutoAskUpdateAllLinks()
288b0c1db7eSPatricia Shanahan {
289b0c1db7eSPatricia Shanahan     mAutoAskUpdateAllLinks = sal_True;
2903f92111aSArrigo Marchiori     mUpdateAsked = sal_False;
2913f92111aSArrigo Marchiori }
2923f92111aSArrigo Marchiori 
SetNeverAskUpdateAllLinks()2933f92111aSArrigo Marchiori void LinkManager::SetNeverAskUpdateAllLinks()
2943f92111aSArrigo Marchiori {
2953f92111aSArrigo Marchiori     mAutoAskUpdateAllLinks = sal_False;
2963f92111aSArrigo Marchiori     mAllowUpdate = sal_True;
2973f92111aSArrigo Marchiori     mUpdateAsked = sal_True;
298b0c1db7eSPatricia Shanahan }
299b0c1db7eSPatricia Shanahan 
GetUserAllowsLinkUpdate(Window * pParentWin)300b0c1db7eSPatricia Shanahan sal_Bool LinkManager::GetUserAllowsLinkUpdate(Window *pParentWin)
301b0c1db7eSPatricia Shanahan {
302b0c1db7eSPatricia Shanahan     if (!mUpdateAsked)
303b0c1db7eSPatricia Shanahan     {
304b0c1db7eSPatricia Shanahan         if (QueryBox(pParentWin, WB_YES_NO | WB_DEF_NO, SfxResId(STR_QUERY_UPDATE_LINKS)).Execute() == RET_YES)
305b0c1db7eSPatricia Shanahan             mAllowUpdate = sal_True;
306b0c1db7eSPatricia Shanahan         else
307b0c1db7eSPatricia Shanahan             mAllowUpdate = sal_False;
308b0c1db7eSPatricia Shanahan         mUpdateAsked = sal_True;
309b0c1db7eSPatricia Shanahan     }
310b0c1db7eSPatricia Shanahan     return mAllowUpdate;
311b0c1db7eSPatricia Shanahan }
312b0c1db7eSPatricia Shanahan 
SetUserAllowsLinkUpdate(SvBaseLink * pLink,sal_Bool allows)313b0c1db7eSPatricia Shanahan void LinkManager::SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows)
314b0c1db7eSPatricia Shanahan {
315b0c1db7eSPatricia Shanahan     SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
316b0c1db7eSPatricia Shanahan 
317b0c1db7eSPatricia Shanahan     if (pShell)
318b0c1db7eSPatricia Shanahan     {
319b0c1db7eSPatricia Shanahan         comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
320b0c1db7eSPatricia Shanahan         rEmbeddedObjectContainer.setUserAllowsLinkUpdate(allows);
321b0c1db7eSPatricia Shanahan     }
322b0c1db7eSPatricia Shanahan }
323b0c1db7eSPatricia Shanahan 
324cdf0e10cSrcweir 
UpdateAllLinks(sal_Bool bAskUpdate,sal_Bool,sal_Bool bUpdateGrfLinks,Window * pParentWin)325cdf0e10cSrcweir void LinkManager::UpdateAllLinks(
326cdf0e10cSrcweir     sal_Bool bAskUpdate,
327cdf0e10cSrcweir     sal_Bool /*bCallErrHdl*/,
328cdf0e10cSrcweir     sal_Bool bUpdateGrfLinks,
329cdf0e10cSrcweir     Window* pParentWin )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir     SvStringsDtor aApps, aTopics, aItems;
332cdf0e10cSrcweir     String sApp, sTopic, sItem;
333cdf0e10cSrcweir 
3345799d6dbSmarcus     // first create a copy of the array, so that updated links to not interfere with ... in between!!
335cdf0e10cSrcweir     SvPtrarr aTmpArr( 255, 50 );
336cdf0e10cSrcweir     sal_uInt16 n;
337cdf0e10cSrcweir     for( n = 0; n < aLinkTbl.Count(); ++n )
338cdf0e10cSrcweir     {
339cdf0e10cSrcweir         SvBaseLink* pLink = *aLinkTbl[ n ];
340cdf0e10cSrcweir         if( !pLink )
341cdf0e10cSrcweir         {
342cdf0e10cSrcweir             Remove( n-- );
343cdf0e10cSrcweir             continue;
344cdf0e10cSrcweir         }
345cdf0e10cSrcweir         aTmpArr.Insert( pLink, aTmpArr.Count() );
346cdf0e10cSrcweir     }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir     for( n = 0; n < aTmpArr.Count(); ++n )
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         SvBaseLink* pLink = (SvBaseLink*)aTmpArr[ n ];
351cdf0e10cSrcweir 
3525799d6dbSmarcus         // first search the entry in the array
353cdf0e10cSrcweir         sal_uInt16 nFndPos = USHRT_MAX;
354cdf0e10cSrcweir         for( sal_uInt16 i = 0; i < aLinkTbl.Count(); ++i )
355cdf0e10cSrcweir             if( pLink == *aLinkTbl[ i ] )
356cdf0e10cSrcweir             {
357cdf0e10cSrcweir                 nFndPos = i;
358cdf0e10cSrcweir                 break;
359cdf0e10cSrcweir             }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         if( USHRT_MAX == nFndPos )
3625799d6dbSmarcus             continue;                   // was not already existing!
363cdf0e10cSrcweir 
3645799d6dbSmarcus         // do not update graphic links yet
365cdf0e10cSrcweir         if( !pLink->IsVisible() ||
366cdf0e10cSrcweir             ( !bUpdateGrfLinks && OBJECT_CLIENT_GRF == pLink->GetObjType() ))
367cdf0e10cSrcweir             continue;
368cdf0e10cSrcweir 
369b0c1db7eSPatricia Shanahan         sal_Bool allows = sal_True;
370b0c1db7eSPatricia Shanahan 
371cdf0e10cSrcweir         if (bAskUpdate)
372cdf0e10cSrcweir         {
373b0c1db7eSPatricia Shanahan             allows = GetUserAllowsLinkUpdate(pParentWin);
374963c6022SArmin Le Grand         }
375963c6022SArmin Le Grand 
376b0c1db7eSPatricia Shanahan         SetUserAllowsLinkUpdate(pLink, allows);
3775799d6dbSmarcus         bAskUpdate = sal_False;     // one time is OK
378cdf0e10cSrcweir 
379b0c1db7eSPatricia Shanahan         if (allows)
380cdf0e10cSrcweir             pLink->Update();
381cdf0e10cSrcweir     }
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir /************************************************************************
385cdf0e10cSrcweir |*    SvBaseLink::CreateObject()
386cdf0e10cSrcweir |*
3875799d6dbSmarcus |*    Description
388cdf0e10cSrcweir *************************************************************************/
389cdf0e10cSrcweir 
CreateObj(SvBaseLink * pLink)390cdf0e10cSrcweir SvLinkSourceRef LinkManager::CreateObj( SvBaseLink * pLink )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir     switch( pLink->GetObjType() )
393cdf0e10cSrcweir     {
394cdf0e10cSrcweir         case OBJECT_CLIENT_FILE:
395cdf0e10cSrcweir         case OBJECT_CLIENT_GRF:
396cdf0e10cSrcweir         case OBJECT_CLIENT_OLE:
397cdf0e10cSrcweir             return new SvFileObject;
398cdf0e10cSrcweir         case OBJECT_INTERN:
399cdf0e10cSrcweir             return new SvxInternalLink;
400cdf0e10cSrcweir         case OBJECT_CLIENT_DDE:
401cdf0e10cSrcweir             return new SvDDEObject;
402cdf0e10cSrcweir         default:
403cdf0e10cSrcweir             return SvLinkSourceRef();
404cdf0e10cSrcweir     }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir 
InsertServer(SvLinkSource * pObj)407cdf0e10cSrcweir sal_Bool LinkManager::InsertServer( SvLinkSource* pObj )
408cdf0e10cSrcweir {
4095799d6dbSmarcus     // do not insert double
410cdf0e10cSrcweir     if( !pObj || USHRT_MAX != aServerTbl.GetPos( pObj ) )
411cdf0e10cSrcweir         return sal_False;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir     aServerTbl.Insert( pObj, aServerTbl.Count() );
414cdf0e10cSrcweir     return sal_True;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 
RemoveServer(SvLinkSource * pObj)418cdf0e10cSrcweir void LinkManager::RemoveServer( SvLinkSource* pObj )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir     sal_uInt16 nPos = aServerTbl.GetPos( pObj );
421cdf0e10cSrcweir     if( USHRT_MAX != nPos )
422cdf0e10cSrcweir         aServerTbl.Remove( nPos, 1 );
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 
MakeLnkName(String & rName,const String * pType,const String & rFile,const String & rLink,const String * pFilter)426cdf0e10cSrcweir void MakeLnkName( String& rName, const String* pType, const String& rFile,
427cdf0e10cSrcweir                     const String& rLink, const String* pFilter )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     if( pType )
430cdf0e10cSrcweir         (rName = *pType).EraseLeadingChars().EraseTrailingChars() += cTokenSeperator;
431cdf0e10cSrcweir     else if( rName.Len() )
432cdf0e10cSrcweir         rName.Erase();
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     ((rName += rFile).EraseLeadingChars().EraseTrailingChars() +=
435cdf0e10cSrcweir         cTokenSeperator ).EraseLeadingChars().EraseTrailingChars() += rLink;
436cdf0e10cSrcweir     if( pFilter )
437cdf0e10cSrcweir         ((rName += cTokenSeperator ) += *pFilter).EraseLeadingChars().EraseTrailingChars();
438cdf0e10cSrcweir }
439cdf0e10cSrcweir 
InsertFileLink(sfx2::SvBaseLink & rLink,sal_uInt16 nFileType,const String & rFileNm,const String * pFilterNm,const String * pRange)440cdf0e10cSrcweir sal_Bool LinkManager::InsertFileLink( sfx2::SvBaseLink& rLink,
441cdf0e10cSrcweir                                     sal_uInt16 nFileType,
442cdf0e10cSrcweir                                     const String& rFileNm,
443cdf0e10cSrcweir                                     const String* pFilterNm,
444cdf0e10cSrcweir                                     const String* pRange )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir     if( !( OBJECT_CLIENT_SO & rLink.GetObjType() ))
447cdf0e10cSrcweir         return sal_False;
448cdf0e10cSrcweir 
449cdf0e10cSrcweir     String sCmd( rFileNm );
450cdf0e10cSrcweir     sCmd += ::sfx2::cTokenSeperator;
451cdf0e10cSrcweir     if( pRange )
452cdf0e10cSrcweir         sCmd += *pRange;
453cdf0e10cSrcweir     if( pFilterNm )
454cdf0e10cSrcweir         ( sCmd += ::sfx2::cTokenSeperator ) += *pFilterNm;
455cdf0e10cSrcweir 
456cdf0e10cSrcweir     return InsertLink( &rLink, nFileType, sfx2::LINKUPDATE_ONCALL, &sCmd );
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
InsertFileLink(sfx2::SvBaseLink & rLink)459cdf0e10cSrcweir sal_Bool LinkManager::InsertFileLink( sfx2::SvBaseLink& rLink )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir     if( OBJECT_CLIENT_FILE == ( OBJECT_CLIENT_FILE & rLink.GetObjType() ))
462cdf0e10cSrcweir         return InsertLink( &rLink, rLink.GetObjType(), sfx2::LINKUPDATE_ONCALL );
463cdf0e10cSrcweir     return sal_False;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
4665799d6dbSmarcus // a transfer will be discontinued, therefore cancel all DownloadMedia
4675799d6dbSmarcus // (at the moment only interesting for the FileLinks!)
CancelTransfers()468cdf0e10cSrcweir void LinkManager::CancelTransfers()
469cdf0e10cSrcweir {
470cdf0e10cSrcweir     SvFileObject* pFileObj;
471cdf0e10cSrcweir     sfx2::SvBaseLink* pLnk;
472cdf0e10cSrcweir 
473cdf0e10cSrcweir     const sfx2::SvBaseLinks& rLnks = GetLinks();
474cdf0e10cSrcweir     for( sal_uInt16 n = rLnks.Count(); n; )
475cdf0e10cSrcweir         if( 0 != ( pLnk = &(*rLnks[ --n ])) &&
476cdf0e10cSrcweir             OBJECT_CLIENT_FILE == (OBJECT_CLIENT_FILE & pLnk->GetObjType()) &&
477cdf0e10cSrcweir             0 != ( pFileObj = (SvFileObject*)pLnk->GetObj() ) )
478cdf0e10cSrcweir //          0 != ( pFileObj = (SvFileObject*)SvFileObject::ClassFactory()->
479cdf0e10cSrcweir //                                  CastAndAddRef( pLnk->GetObj() )) )
480cdf0e10cSrcweir             pFileObj->CancelTransfers();
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
4835799d6dbSmarcus     // to send status information from the FileObject to the BaseLink, there is an own ClipboardId.
4845799d6dbSmarcus     // The SvData object has then the respective information as string.
4855799d6dbSmarcus     // Currently this will be used for FileObject in connection with JavaScript
4865799d6dbSmarcus     // - that needs information about Load/Abort/Error
RegisterStatusInfoId()487cdf0e10cSrcweir sal_uIntPtr LinkManager::RegisterStatusInfoId()
488cdf0e10cSrcweir {
489cdf0e10cSrcweir     static sal_uIntPtr nFormat = 0;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     if( !nFormat )
492cdf0e10cSrcweir     {
4935799d6dbSmarcus // how does the new interface look like?
494cdf0e10cSrcweir //      nFormat = Exchange::RegisterFormatName( "StatusInfo vom SvxInternalLink" );
495cdf0e10cSrcweir         nFormat = SotExchange::RegisterFormatName(
496cdf0e10cSrcweir                     String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(
497cdf0e10cSrcweir                                 "StatusInfo vom SvxInternalLink" )));
498cdf0e10cSrcweir     }
499cdf0e10cSrcweir     return nFormat;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir // ----------------------------------------------------------------------
503cdf0e10cSrcweir 
GetGraphicFromAny(const String & rMimeType,const::com::sun::star::uno::Any & rValue,Graphic & rGrf)504cdf0e10cSrcweir sal_Bool LinkManager::GetGraphicFromAny( const String& rMimeType,
505cdf0e10cSrcweir                                 const ::com::sun::star::uno::Any & rValue,
506cdf0e10cSrcweir                                 Graphic& rGrf )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir     sal_Bool bRet = sal_False;
509cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
510cdf0e10cSrcweir     if( rValue.hasValue() && ( rValue >>= aSeq ) )
511cdf0e10cSrcweir     {
512cdf0e10cSrcweir         SvMemoryStream aMemStm( (void*)aSeq.getConstArray(), aSeq.getLength(),
513cdf0e10cSrcweir                                 STREAM_READ );
514cdf0e10cSrcweir         aMemStm.Seek( 0 );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir         switch( SotExchange::GetFormatIdFromMimeType( rMimeType ) )
517cdf0e10cSrcweir         {
518cdf0e10cSrcweir         case SOT_FORMATSTR_ID_SVXB:
519cdf0e10cSrcweir             {
520cdf0e10cSrcweir                 aMemStm >> rGrf;
521cdf0e10cSrcweir                 bRet = sal_True;
522cdf0e10cSrcweir             }
523cdf0e10cSrcweir             break;
524cdf0e10cSrcweir         case FORMAT_GDIMETAFILE:
525cdf0e10cSrcweir             {
526cdf0e10cSrcweir                 GDIMetaFile aMtf;
527cdf0e10cSrcweir                 aMtf.Read( aMemStm );
528cdf0e10cSrcweir                 rGrf = aMtf;
529cdf0e10cSrcweir                 bRet = sal_True;
530cdf0e10cSrcweir             }
531cdf0e10cSrcweir             break;
532cdf0e10cSrcweir         case FORMAT_BITMAP:
533cdf0e10cSrcweir             {
534cdf0e10cSrcweir                 Bitmap aBmp;
53545fd3b9aSArmin Le Grand                 ReadDIB(aBmp, aMemStm, true);
536cdf0e10cSrcweir                 rGrf = aBmp;
537cdf0e10cSrcweir                 bRet = sal_True;
538cdf0e10cSrcweir             }
539cdf0e10cSrcweir             break;
540cdf0e10cSrcweir         }
541cdf0e10cSrcweir     }
542cdf0e10cSrcweir     return bRet;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir 
urlIsSafe(const::rtl::OUString & url)54568281b3fSArrigo Marchiori sal_Bool LinkManager::urlIsSafe( const ::rtl::OUString &url )
54668281b3fSArrigo Marchiori {
54768281b3fSArrigo Marchiori     if ( url.getLength() == 0 ) {
54868281b3fSArrigo Marchiori         return sal_False;
54968281b3fSArrigo Marchiori     }
55068281b3fSArrigo Marchiori     if ( !xURLTransformer.is() ) {
55168281b3fSArrigo Marchiori         const com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext ( ::comphelper::getProcessComponentContext() );
55268281b3fSArrigo Marchiori         com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > xFactory ( xContext->getServiceManager(), ::com::sun::star::uno::UNO_QUERY );
55368281b3fSArrigo Marchiori         if ( !xFactory.is() ) {
55468281b3fSArrigo Marchiori             return sal_False;
55568281b3fSArrigo Marchiori         }
55668281b3fSArrigo Marchiori         xURLTransformer.set( xFactory->createInstanceWithContext( rtl::OUString::createFromAscii( "com.sun.star.util.URLTransformer" ), xContext), com::sun::star::uno::UNO_QUERY );
55768281b3fSArrigo Marchiori         if ( !xURLTransformer.is() ) {
55868281b3fSArrigo Marchiori             return sal_False;
55968281b3fSArrigo Marchiori         }
56068281b3fSArrigo Marchiori     }
56168281b3fSArrigo Marchiori     com::sun::star::util::URL aURL;
56268281b3fSArrigo Marchiori     aURL.Complete = url;
56368281b3fSArrigo Marchiori     sal_Bool b = xURLTransformer->parseSmart( aURL, ::rtl::OUString() );
56468281b3fSArrigo Marchiori     if ( !b ) {
56568281b3fSArrigo Marchiori         return sal_False;
56668281b3fSArrigo Marchiori     }
56768281b3fSArrigo Marchiori     return urlIsSafe( aURL );
56868281b3fSArrigo Marchiori }
56968281b3fSArrigo Marchiori 
urlIsSafe(const::com::sun::star::util::URL & url)57068281b3fSArrigo Marchiori sal_Bool LinkManager::urlIsSafe( const ::com::sun::star::util::URL &url )
57168281b3fSArrigo Marchiori {
57268281b3fSArrigo Marchiori     sal_Bool result = ( url.Path.getLength() == 0 ) &&
57368281b3fSArrigo Marchiori         ( url.Server.getLength() == 0);
57468281b3fSArrigo Marchiori     return result;
57568281b3fSArrigo Marchiori }
57668281b3fSArrigo Marchiori 
577cdf0e10cSrcweir 
urlIsVendor(const::rtl::OUString & url)578*671443b4SArrigo Marchiori sal_Bool LinkManager::urlIsVendor( const ::rtl::OUString &url )
579*671443b4SArrigo Marchiori {
580*671443b4SArrigo Marchiori     if ( url.matchIgnoreAsciiCaseAsciiL( "vnd.sun.star.", 13, 0 ) ) {
581*671443b4SArrigo Marchiori         return url.matchIgnoreAsciiCaseAsciiL ( "expand", 6, 13 ) ||
582*671443b4SArrigo Marchiori             url.matchIgnoreAsciiCaseAsciiL ( "script", 6, 13 ) ||
583*671443b4SArrigo Marchiori             url.matchIgnoreAsciiCaseAsciiL ( "tdoc", 4, 13 ) ||
584*671443b4SArrigo Marchiori             url.matchIgnoreAsciiCaseAsciiL ( "uno", 3, 13 );
585*671443b4SArrigo Marchiori     }
586*671443b4SArrigo Marchiori     return sal_False;
587*671443b4SArrigo Marchiori }
588*671443b4SArrigo Marchiori 
589*671443b4SArrigo Marchiori 
590cdf0e10cSrcweir // ----------------------------------------------------------------------
lcl_DDE_RelToAbs(const String & rTopic,const String & rBaseURL)591cdf0e10cSrcweir String lcl_DDE_RelToAbs( const String& rTopic, const String& rBaseURL )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir     String sRet;
594cdf0e10cSrcweir     INetURLObject aURL( rTopic );
595cdf0e10cSrcweir     if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
596cdf0e10cSrcweir         utl::LocalFileHelper::ConvertSystemPathToURL( rTopic, rBaseURL, sRet );
597cdf0e10cSrcweir     if( !sRet.Len() )
598cdf0e10cSrcweir         sRet = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), rTopic, URIHelper::GetMaybeFileHdl(), true );
599cdf0e10cSrcweir     return sRet;
600cdf0e10cSrcweir }
601cdf0e10cSrcweir 
Connect(sfx2::SvBaseLink * pLink)602cdf0e10cSrcweir sal_Bool SvxInternalLink::Connect( sfx2::SvBaseLink* pLink )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir     SfxObjectShell* pFndShell = 0;
605cdf0e10cSrcweir     sal_uInt16 nUpdateMode = com::sun::star::document::UpdateDocMode::NO_UPDATE;
606cdf0e10cSrcweir     String sTopic, sItem, sReferer;
607cdf0e10cSrcweir     if( pLink->GetLinkManager() &&
608cdf0e10cSrcweir         pLink->GetLinkManager()->GetDisplayNames( pLink, 0, &sTopic, &sItem )
609cdf0e10cSrcweir         && sTopic.Len() )
610cdf0e10cSrcweir     {
6115799d6dbSmarcus         // for the moment run through the DocumentShells and search for the ones with names:
612cdf0e10cSrcweir 
613cdf0e10cSrcweir         com::sun::star::lang::Locale aLocale;
614cdf0e10cSrcweir         MsLangId::convertLanguageToLocale( LANGUAGE_SYSTEM, aLocale );
615cdf0e10cSrcweir         CharClass aCC( aLocale );
616cdf0e10cSrcweir 
617cdf0e10cSrcweir         String sNm( sTopic ), sTmp;
618cdf0e10cSrcweir         aCC.toLower( sNm );
619cdf0e10cSrcweir 
620cdf0e10cSrcweir         TypeId aType( TYPE(SfxObjectShell) );
621cdf0e10cSrcweir 
622cdf0e10cSrcweir         sal_Bool bFirst = sal_True;
623cdf0e10cSrcweir         SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
624cdf0e10cSrcweir         if( pShell && pShell->GetMedium() )
625cdf0e10cSrcweir         {
626cdf0e10cSrcweir             sReferer = pShell->GetMedium()->GetBaseURL();
627cdf0e10cSrcweir             SFX_ITEMSET_ARG( pShell->GetMedium()->GetItemSet(), pItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False );
628cdf0e10cSrcweir             if ( pItem )
629cdf0e10cSrcweir                 nUpdateMode = pItem->GetValue();
630cdf0e10cSrcweir         }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir         String sNmURL( lcl_DDE_RelToAbs( sTopic, sReferer ) );
633cdf0e10cSrcweir         aCC.toLower( sNmURL );
634cdf0e10cSrcweir 
635cdf0e10cSrcweir         if ( !pShell )
636cdf0e10cSrcweir         {
637cdf0e10cSrcweir             bFirst = sal_False;
638cdf0e10cSrcweir             pShell = SfxObjectShell::GetFirst( &aType, sal_False );
639cdf0e10cSrcweir         }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir         while( pShell )
642cdf0e10cSrcweir         {
643cdf0e10cSrcweir             if( !sTmp.Len() )
644cdf0e10cSrcweir             {
645cdf0e10cSrcweir                 sTmp = pShell->GetTitle( SFX_TITLE_FULLNAME );
646cdf0e10cSrcweir                 sTmp = lcl_DDE_RelToAbs(sTmp, sReferer );
647cdf0e10cSrcweir             }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir 
650cdf0e10cSrcweir             aCC.toLower( sTmp );
6515799d6dbSmarcus             if( sTmp == sNmURL )        // these we want to have
652cdf0e10cSrcweir             {
653cdf0e10cSrcweir                 pFndShell = pShell;
654cdf0e10cSrcweir                 break;
655cdf0e10cSrcweir             }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir             if( bFirst )
658cdf0e10cSrcweir             {
659cdf0e10cSrcweir                 bFirst = sal_False;
660cdf0e10cSrcweir                 pShell = SfxObjectShell::GetFirst( &aType, sal_False );
661cdf0e10cSrcweir             }
662cdf0e10cSrcweir             else
663cdf0e10cSrcweir                 pShell = SfxObjectShell::GetNext( *pShell, &aType, sal_False );
664cdf0e10cSrcweir 
665cdf0e10cSrcweir             sTmp.Erase();
666cdf0e10cSrcweir         }
667cdf0e10cSrcweir     }
668cdf0e10cSrcweir 
669cdf0e10cSrcweir     // empty topics are not allowed - which document is it
670cdf0e10cSrcweir     if( !sTopic.Len() )
671cdf0e10cSrcweir         return sal_False;
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     if( !pFndShell )
674cdf0e10cSrcweir     {
6755799d6dbSmarcus         // try to load the file:
676cdf0e10cSrcweir         INetURLObject aURL( sTopic );
677cdf0e10cSrcweir         INetProtocol eOld = aURL.GetProtocol();
678cdf0e10cSrcweir         aURL.SetURL( sTopic = lcl_DDE_RelToAbs( sTopic, sReferer ) );
679cdf0e10cSrcweir         if( INET_PROT_NOT_VALID != eOld ||
680cdf0e10cSrcweir             INET_PROT_HTTP != aURL.GetProtocol() )
681cdf0e10cSrcweir         {
682cdf0e10cSrcweir             SfxStringItem aName( SID_FILE_NAME, sTopic );
683cdf0e10cSrcweir             SfxBoolItem aMinimized(SID_MINIMIZED, sal_True);
684cdf0e10cSrcweir             SfxBoolItem aHidden(SID_HIDDEN, sal_True);
685cdf0e10cSrcweir             SfxStringItem aTarget( SID_TARGETNAME, String::CreateFromAscii("_blank") );
686cdf0e10cSrcweir             SfxStringItem aReferer( SID_REFERER, sReferer );
687cdf0e10cSrcweir             SfxUInt16Item aUpdate( SID_UPDATEDOCMODE, nUpdateMode );
688cdf0e10cSrcweir             SfxBoolItem aReadOnly(SID_DOC_READONLY, sal_True);
689cdf0e10cSrcweir 
690cdf0e10cSrcweir             // #i14200# (DDE-link crashes wordprocessor)
691cdf0e10cSrcweir             SfxAllItemSet aArgs( SFX_APP()->GetPool() );
692cdf0e10cSrcweir             aArgs.Put(aReferer);
693cdf0e10cSrcweir             aArgs.Put(aTarget);
694cdf0e10cSrcweir             aArgs.Put(aHidden);
695cdf0e10cSrcweir             aArgs.Put(aMinimized);
696cdf0e10cSrcweir             aArgs.Put(aName);
697cdf0e10cSrcweir             aArgs.Put(aUpdate);
698cdf0e10cSrcweir             aArgs.Put(aReadOnly);
699cdf0e10cSrcweir             pFndShell = SfxObjectShell::CreateAndLoadObject( aArgs );
700cdf0e10cSrcweir         }
701cdf0e10cSrcweir     }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     sal_Bool bRet = sal_False;
704cdf0e10cSrcweir     if( pFndShell )
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir         sfx2::SvLinkSource* pNewSrc = pFndShell->DdeCreateLinkSource( sItem );
707cdf0e10cSrcweir         if( pNewSrc )
708cdf0e10cSrcweir         {
709cdf0e10cSrcweir             bRet = sal_True;
710cdf0e10cSrcweir 
711cdf0e10cSrcweir             ::com::sun::star::datatransfer::DataFlavor aFl;
712cdf0e10cSrcweir             SotExchange::GetFormatDataFlavor( pLink->GetContentType(), aFl );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir             pLink->SetObj( pNewSrc );
715cdf0e10cSrcweir             pNewSrc->AddDataAdvise( pLink, aFl.MimeType,
716cdf0e10cSrcweir                                 sfx2::LINKUPDATE_ONCALL == pLink->GetUpdateMode()
717cdf0e10cSrcweir                                     ? ADVISEMODE_ONLYONCE
718cdf0e10cSrcweir                                     : 0 );
719cdf0e10cSrcweir         }
720cdf0e10cSrcweir     }
721cdf0e10cSrcweir     return bRet;
722cdf0e10cSrcweir }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 
725cdf0e10cSrcweir }
726