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>
26 #include <sfx2/lnkbase.hxx>
33 namespace com
{ namespace sun
{ namespace star
{
39 namespace weld
{ class Window
; }
43 // For the link to receive information about the status of graphics that
44 // will be loaded the FileObject sends a SvData, which contains the
45 // FormatID "RegisterStatusInfoId" and a string as the data container.
46 // This contains the following enum.
48 typedef std::vector
<tools::SvRef
<SvBaseLink
> > SvBaseLinks
;
50 typedef std::set
<SvLinkSource
*> SvLinkSources
;
52 class SFX2_DLLPUBLIC LinkManager
54 typedef ::std::vector
< css::uno::Reference
< css::lang::XComponent
> >
56 CompVector maCachedComps
;
59 SvLinkSources aServerTbl
;
61 SfxObjectShell
*pPersist
; // LinkMgr must be release before SfxObjectShell
63 bool InsertLink( SvBaseLink
* pLink
, sal_uInt16 nObjType
, SfxLinkUpdateMode nUpdateType
,
64 const OUString
* pName
);
74 LinkManager( SfxObjectShell
* pCacheCont
);
78 * Insert a component loaded during link update, which needs to be closed
79 * when the update is complete.
81 * @param xComp component loaded during link update.
83 void InsertCachedComp(const css::uno::Reference
< css::lang::XComponent
>& xComp
);
85 void CloseCachedComps();
87 SfxObjectShell
* GetPersist() const { return pPersist
; }
88 void SetPersist( SfxObjectShell
* p
) { pPersist
= p
; }
90 void Remove( SvBaseLink
const *pLink
);
91 void Remove( size_t nPos
, size_t nCnt
= 1 );
92 bool Insert( SvBaseLink
* pLink
);
94 // the links connect to a SvLinkSource and adds to the list
95 void InsertDDELink( SvBaseLink
*,
96 const OUString
& rServer
,
97 const OUString
& rTopic
,
98 const OUString
& rItem
);
100 // if everything is already set at the link!
101 void InsertDDELink( SvBaseLink
* );
103 // Connect the links to a pseudo-object and add to the list
104 void InsertFileLink( sfx2::SvBaseLink
&,
105 sal_uInt16 nFileType
,
106 const OUString
& rFileNm
,
107 const OUString
* pFilterNm
= nullptr,
108 const OUString
* pRange
= nullptr );
110 void ReconnectDdeLink(SfxObjectShell
& rServer
);
113 * Reconnect the server document shell to a DDE link object.
115 * @param rPath path to the server document
116 * @param rServer server document shell instance
117 * @param rLink link object of the client document
119 static void LinkServerShell(const OUString
& rPath
, SfxObjectShell
& rServer
, ::sfx2::SvBaseLink
& rLink
);
121 // Obtain the string for the dialog
122 static bool GetDisplayNames( const SvBaseLink
*,
124 OUString
* pFile
= nullptr,
125 OUString
* pLink
= nullptr,
126 OUString
* pFilter
= nullptr );
128 static SvLinkSourceRef
CreateObj( SvBaseLink
const * );
130 void UpdateAllLinks(bool bAskUpdate
,
131 bool bUpdateGrfLinks
,
132 weld::Window
* pParentWin
);
134 // Call for list of links (eg for link-dialog)
135 const SvBaseLinks
& GetLinks() const { return aLinkTbl
; }
137 // ----------------- Server-side management --------------------
139 // Call with list of links to server
140 const SvLinkSources
& GetServers() const { return aServerTbl
; }
141 // Link register/delete
142 bool InsertServer( SvLinkSource
* rObj
);
143 void RemoveServer( SvLinkSource
* rObj
);
145 // A transfer is aborted, so cancel all download media
146 // (for the time being this is only of interest for the FileLinks!)
147 void CancelTransfers();
149 // To send status information from the FileObject to the Baselink,
150 // for this there exist a separate ClipBoardId. The SvData-object has
151 // got the appropriate information as a string.
152 // Is now required for FileObject in conjunction with JavaScript
153 // this needs information about Load/Abort/Error
154 static SotClipboardFormatId
RegisterStatusInfoId();
156 // if the mimetype says graphic/bitmap/gdimetafile then get the
157 // graphic from the Any. Return says no errors
158 static bool GetGraphicFromAny(const OUString
& rMimeType
,
159 const css::uno::Any
& rValue
,
160 const OUString
& rReferer
,
162 weld::Window
* pParentWin
);
165 LinkManager( const LinkManager
& ) = delete;
166 LinkManager
& operator=( const LinkManager
& ) = delete;
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
= nullptr );
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */