Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / include / sfx2 / linkmgr.hxx
blob1af8e726319786e98d756a77eb42141c447e33f4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
21 #include <rtl/ustring.hxx>
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sfx2/linksrc.hxx>
25 #include <sfx2/lnkbase.hxx>
26 #include <o3tl/sorted_vector.hxx>
28 #include <string_view>
29 #include <vector>
31 class SfxObjectShell;
32 class Graphic;
34 namespace com::sun::star {
35 namespace lang {
36 class XComponent;
40 namespace weld { class Window; }
42 namespace sfx2
44 // For the link to receive information about the status of graphics that
45 // will be loaded the FileObject sends a SvData, which contains the
46 // FormatID "RegisterStatusInfoId" and a string as the data container.
47 // This contains the following enum.
49 typedef std::vector<tools::SvRef<SvBaseLink> > SvBaseLinks;
51 typedef o3tl::sorted_vector<SvLinkSource*> SvLinkSources;
53 class SFX2_DLLPUBLIC LinkManager
55 typedef ::std::vector< css::uno::Reference< css::lang::XComponent > >
56 CompVector;
57 CompVector maCachedComps;
59 SvBaseLinks aLinkTbl;
60 SvLinkSources aServerTbl;
62 SfxObjectShell *pPersist; // LinkMgr must be release before SfxObjectShell
64 bool InsertLink( SvBaseLink* pLink, SvBaseLinkObjectType nObjType, SfxLinkUpdateMode nUpdateType,
65 const OUString* pName );
66 public:
68 enum LinkState
70 STATE_LOAD_OK,
71 STATE_LOAD_ERROR,
72 STATE_LOAD_ABORT
75 LinkManager( SfxObjectShell * pCacheCont );
76 ~LinkManager();
78 /**
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 css::uno::Reference< css::lang::XComponent >& xComp);
86 void CloseCachedComps();
88 SfxObjectShell* GetPersist() const { return pPersist; }
89 void SetPersist( SfxObjectShell * p ) { pPersist = p; }
91 void Remove( SvBaseLink const *pLink );
92 void Remove( size_t nPos, size_t nCnt = 1 );
93 bool Insert( SvBaseLink* pLink );
95 // the links connect to a SvLinkSource and adds to the list
96 void InsertDDELink( SvBaseLink*,
97 const OUString& rServer,
98 std::u16string_view rTopic,
99 std::u16string_view rItem );
101 // if everything is already set at the link!
102 void InsertDDELink( SvBaseLink* );
104 // Connect the links to a pseudo-object and add to the list
105 void InsertFileLink( sfx2::SvBaseLink&,
106 SvBaseLinkObjectType nFileType,
107 std::u16string_view rFileNm,
108 const OUString* pFilterNm = nullptr,
109 const OUString* pRange = nullptr );
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 static void LinkServerShell(const OUString& rPath, SfxObjectShell& rServer, ::sfx2::SvBaseLink& rLink);
122 // Obtain the string for the dialog
123 static bool GetDisplayNames( const SvBaseLink *,
124 OUString* pType,
125 OUString* pFile = nullptr,
126 OUString* pLink = nullptr,
127 OUString* pFilter = nullptr );
129 static SvLinkSourceRef CreateObj( SvBaseLink const * );
131 void UpdateAllLinks(bool bAskUpdate,
132 bool bUpdateGrfLinks,
133 weld::Window* pParentWin,
134 OUString const & referer);
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,
162 Graphic& rGrf,
163 weld::Window* pParentWin);
165 private:
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 );
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */