1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SFX2_LINKMGR_HXX
20 #define INCLUDED_SFX2_LINKMGR_HXX
22 #include <rtl/ustring.hxx>
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <sfx2/linksrc.hxx>
33 namespace com
{ namespace sun
{ namespace star
{
41 // For the link to receive information about the status of graphics that
42 // will be loaded the FileObject sends a SvData, which contains the
43 // FormatID "RegisterStatusInfoId" and a string as the data container.
44 // This contains the following enum.
49 typedef std::vector
<SvBaseLinkRef
*> SvBaseLinks
;
51 typedef std::set
<SvLinkSource
*> SvLinkSources
;
53 class SFX2_DLLPUBLIC LinkManager
55 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> >
57 CompVector maCachedComps
;
60 SvLinkSources aServerTbl
;
62 SfxObjectShell
*pPersist
; // LinkMgr must be release before SfxObjectShell
64 sal_Bool
InsertLink( SvBaseLink
* pLink
, sal_uInt16 nObjType
, sal_uInt16 nUpdateType
,
65 const OUString
* pName
= 0 );
75 LinkManager( SfxObjectShell
* pCacheCont
);
79 * Insert a component loaded during link update, which needs to be closed
80 * when the update is complete.
82 * @param xComp component loaded during link update.
84 void InsertCachedComp(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& xComp
);
86 void CloseCachedComps();
88 SfxObjectShell
* GetPersist() const { return pPersist
; }
89 void SetPersist( SfxObjectShell
* p
) { pPersist
= p
; }
91 void Remove( SvBaseLink
*pLink
);
92 void Remove( size_t nPos
, size_t nCnt
= 1 );
93 sal_Bool
Insert( SvBaseLink
* pLink
);
95 // the links connect to a SvLinkSource and adds to the list
96 sal_Bool
InsertDDELink( SvBaseLink
*,
97 const OUString
& rServer
,
98 const OUString
& rTopic
,
99 const OUString
& rItem
);
101 // if everything is already set at the link!
102 sal_Bool
InsertDDELink( SvBaseLink
* );
104 // Connect the links to a pseudo-object and add to the list
105 bool InsertFileLink( sfx2::SvBaseLink
&,
106 sal_uInt16 nFileType
,
107 const OUString
& rFileNm
,
108 const OUString
* pFilterNm
= NULL
,
109 const OUString
* pRange
= NULL
);
111 void ReconnectDdeLink(SfxObjectShell
& rServer
);
114 * Reconnect the server document shell to a DDE link object.
116 * @param rPath path to the server document
117 * @param rServer server document shell instance
118 * @param rLink link object of the client document
120 void LinkServerShell(const OUString
& rPath
, SfxObjectShell
& rServer
, ::sfx2::SvBaseLink
& rLink
) const;
122 // Obtain the string for the dialog
123 bool GetDisplayNames( const SvBaseLink
*,
125 OUString
* pFile
= NULL
,
126 OUString
* pLink
= NULL
,
127 OUString
* pFilter
= NULL
) const;
129 SvLinkSourceRef
CreateObj( SvBaseLink
* );
131 void UpdateAllLinks( bool bAskUpdate
= true,
132 bool bCallErrHdl
= true,
133 bool bUpdateGrfLinks
= false,
134 Window
* pParentWin
= 0 );
136 // Call for list of links (eg for link-dialog)
137 const SvBaseLinks
& GetLinks() const { return aLinkTbl
; }
139 // ----------------- Server-side management --------------------
141 // Call with list of links to server
142 const SvLinkSources
& GetServers() const { return aServerTbl
; }
143 // Link register/delete
144 sal_Bool
InsertServer( SvLinkSource
* rObj
);
145 void RemoveServer( SvLinkSource
* rObj
);
147 // A transfer is aborted, so cancel all download media
148 // (for the time beeing this is only of interest for the FileLinks!)
149 void CancelTransfers();
151 // To send status information from the FileObject to the Baselink,
152 // for this there exist a separate ClipBoardId. The SvData-object has
153 // got the appropriate information as a string.
154 // Is now required for FileObject in conjunction with JavaScript
155 // this needs information about Load/Abort/Error
156 static sal_uIntPtr
RegisterStatusInfoId();
158 // if the mimetype says graphic/bitmap/gdimetafile then get the
159 // graphic from the Any. Return says no errors
160 static sal_Bool
GetGraphicFromAny( const OUString
& rMimeType
,
161 const ::com::sun::star::uno::Any
& rValue
,
165 LinkManager( const LinkManager
& );
166 LinkManager
& operator=( const LinkManager
& );
169 // Separator in the link name for the DDE-/File-/Graphics- links
170 // (only those who need to construct a SvLinkName)
171 const sal_Unicode cTokenSeparator
= 0xFFFF;
173 // create a string for the SvLinkName. For:
174 // - DDE the first 3 Strings, (Server, Topic, Item)
175 // - File-/Graphics-LinkNames the last 3 Strings (FileName, Region, Filter)
176 SFX2_DLLPUBLIC
void MakeLnkName( OUString
& rName
,
177 const OUString
* pType
, // Can also be null!!
178 const OUString
& rFile
,
179 const OUString
& rLink
,
180 const OUString
* pFilter
= 0 );
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */