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>
27 #include <o3tl/sorted_vector.hxx>
29 #include <string_view>
35 namespace com::sun::star
{
41 namespace weld
{ class Window
; }
45 // For the link to receive information about the status of graphics that
46 // will be loaded the FileObject sends a SvData, which contains the
47 // FormatID "RegisterStatusInfoId" and a string as the data container.
48 // This contains the following enum.
50 typedef std::vector
<tools::SvRef
<SvBaseLink
> > SvBaseLinks
;
52 typedef o3tl::sorted_vector
<SvLinkSource
*> SvLinkSources
;
54 class SFX2_DLLPUBLIC LinkManager
56 typedef ::std::vector
< css::uno::Reference
< css::lang::XComponent
> >
58 CompVector maCachedComps
;
61 SvLinkSources aServerTbl
;
63 SfxObjectShell
*pPersist
; // LinkMgr must be release before SfxObjectShell
65 bool InsertLink( SvBaseLink
* pLink
, SvBaseLinkObjectType nObjType
, SfxLinkUpdateMode nUpdateType
,
66 const OUString
* pName
);
76 LinkManager( SfxObjectShell
* pCacheCont
);
80 * Insert a component loaded during link update, which needs to be closed
81 * when the update is complete.
83 * @param xComp component loaded during link update.
85 void InsertCachedComp(const css::uno::Reference
< css::lang::XComponent
>& xComp
);
87 void CloseCachedComps();
89 SfxObjectShell
* GetPersist() const { return pPersist
; }
90 void SetPersist( SfxObjectShell
* p
) { pPersist
= p
; }
92 void Remove( SvBaseLink
const *pLink
);
93 void Remove( size_t nPos
, size_t nCnt
= 1 );
94 bool Insert( SvBaseLink
* pLink
);
96 // the links connect to a SvLinkSource and adds to the list
97 void InsertDDELink( SvBaseLink
*,
98 const OUString
& rServer
,
99 std::u16string_view rTopic
,
100 std::u16string_view rItem
);
102 // if everything is already set at the link!
103 void InsertDDELink( SvBaseLink
* );
105 // Connect the links to a pseudo-object and add to the list
106 void InsertFileLink( sfx2::SvBaseLink
&,
107 SvBaseLinkObjectType nFileType
,
108 std::u16string_view rFileNm
,
109 const OUString
* pFilterNm
= nullptr,
110 const OUString
* pRange
= nullptr );
112 void ReconnectDdeLink(SfxObjectShell
& rServer
);
115 * Reconnect the server document shell to a DDE link object.
117 * @param rPath path to the server document
118 * @param rServer server document shell instance
119 * @param rLink link object of the client document
121 static void LinkServerShell(const OUString
& rPath
, SfxObjectShell
& rServer
, ::sfx2::SvBaseLink
& rLink
);
123 // Obtain the string for the dialog
124 static bool GetDisplayNames( const SvBaseLink
*,
126 OUString
* pFile
= nullptr,
127 OUString
* pLink
= nullptr,
128 OUString
* pFilter
= nullptr );
130 static SvLinkSourceRef
CreateObj( SvBaseLink
const * );
132 void UpdateAllLinks(bool bAskUpdate
,
133 bool bUpdateGrfLinks
,
134 weld::Window
* pParentWin
);
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 bool InsertServer( SvLinkSource
* rObj
);
145 void RemoveServer( SvLinkSource
* rObj
);
147 // A transfer is aborted, so cancel all download media
148 // (for the time being 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 SotClipboardFormatId
RegisterStatusInfoId();
158 // if the mimetype says graphic/bitmap/gdimetafile then get the
159 // graphic from the Any. Return says no errors
160 bool GetGraphicFromAny(std::u16string_view rMimeType
,
161 const css::uno::Any
& rValue
,
163 weld::Window
* pParentWin
);
166 LinkManager( const LinkManager
& ) = delete;
167 LinkManager
& operator=( const LinkManager
& ) = delete;
170 // Separator in the link name for the DDE-/File-/Graphics- links
171 // (only those who need to construct a SvLinkName)
172 const sal_Unicode cTokenSeparator
= 0xFFFF;
174 // create a string for the SvLinkName. For:
175 // - DDE the first 3 Strings, (Server, Topic, Item)
176 // - File-/Graphics-LinkNames the last 3 Strings (FileName, Region, Filter)
177 SFX2_DLLPUBLIC
void MakeLnkName( OUString
& rName
,
178 const OUString
* pType
, // Can also be null!!
179 std::u16string_view rFile
,
180 std::u16string_view rLink
,
181 const OUString
* pFilter
= nullptr );
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */