LibreOffice Module sfx2 (master) 1
linkmgr.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SFX2_LINKMGR_HXX
20#define INCLUDED_SFX2_LINKMGR_HXX
21
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>
28
29#include <string_view>
30#include <vector>
31
32class SfxObjectShell;
33class Graphic;
34
35namespace com::sun::star {
36 namespace lang {
37 class XComponent;
38 }
39}
40
41namespace weld { class Window; }
42
43namespace sfx2
44{
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.
49
50typedef std::vector<tools::SvRef<SvBaseLink> > SvBaseLinks;
51
53
55{
56 typedef ::std::vector< css::uno::Reference< css::lang::XComponent > >
59
62
63 SfxObjectShell *pPersist; // LinkMgr must be release before SfxObjectShell
64
65 bool InsertLink( SvBaseLink* pLink, SvBaseLinkObjectType nObjType, SfxLinkUpdateMode nUpdateType,
66 const OUString* pName );
67public:
68
70 {
73 STATE_LOAD_ABORT
74 };
75
76 LinkManager( SfxObjectShell * pCacheCont );
78
85 void InsertCachedComp(const css::uno::Reference< css::lang::XComponent >& xComp);
86
87 void CloseCachedComps();
88
89 SfxObjectShell* GetPersist() const { return pPersist; }
90 void SetPersist( SfxObjectShell * p ) { pPersist = p; }
91
92 void Remove( SvBaseLink const *pLink );
93 void Remove( size_t nPos, size_t nCnt = 1 );
94 bool Insert( SvBaseLink* pLink );
95
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 );
101
102 // if everything is already set at the link!
103 void InsertDDELink( SvBaseLink* );
104
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 );
111
112 void ReconnectDdeLink(SfxObjectShell& rServer);
113
121 static void LinkServerShell(const OUString& rPath, SfxObjectShell& rServer, ::sfx2::SvBaseLink& rLink);
122
123 // Obtain the string for the dialog
124 static bool GetDisplayNames( const SvBaseLink *,
125 OUString* pType,
126 OUString* pFile = nullptr,
127 OUString* pLink = nullptr,
128 OUString* pFilter = nullptr );
129
130 static SvLinkSourceRef CreateObj( SvBaseLink const * );
131
132 void UpdateAllLinks(bool bAskUpdate,
133 bool bUpdateGrfLinks,
134 weld::Window* pParentWin);
135
136 // Call for list of links (eg for link-dialog)
137 const SvBaseLinks& GetLinks() const { return aLinkTbl; }
138
139 // ----------------- Server-side management --------------------
140
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 );
146
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();
150
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();
157
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);
164
165private:
166 LinkManager( const LinkManager& ) = delete;
167 LinkManager& operator=( const LinkManager& ) = delete;
168};
169
170// Separator in the link name for the DDE-/File-/Graphics- links
171// (only those who need to construct a SvLinkName)
173
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)
177SFX2_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 );
182
183}
184
185#endif
186
187/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SvLinkSources & GetServers() const
Definition: linkmgr.hxx:142
SfxObjectShell * GetPersist() const
Definition: linkmgr.hxx:89
void SetPersist(SfxObjectShell *p)
Definition: linkmgr.hxx:90
LinkManager(const LinkManager &)=delete
SfxObjectShell * pPersist
Definition: linkmgr.hxx:63
::std::vector< css::uno::Reference< css::lang::XComponent > > CompVector
Definition: linkmgr.hxx:57
SvBaseLinks aLinkTbl
Definition: linkmgr.hxx:60
CompVector maCachedComps
Definition: linkmgr.hxx:58
const SvBaseLinks & GetLinks() const
Definition: linkmgr.hxx:137
SvLinkSources aServerTbl
Definition: linkmgr.hxx:61
LinkManager & operator=(const LinkManager &)=delete
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
SotClipboardFormatId
void * p
sal_uInt16 nPos
Definition: linksrc.cxx:118
SvBaseLink * pLink
Definition: lnkbase2.cxx:81
SfxLinkUpdateMode
Definition: lnkbase.hxx:38
const sal_Unicode cTokenSeparator
Definition: linkmgr.hxx:172
SvBaseLinkObjectType
Definition: lnkbase.hxx:52
std::vector< tools::SvRef< SvBaseLink > > SvBaseLinks
Definition: linkmgr.hxx:50
void MakeLnkName(OUString &rName, const OUString *pType, std::u16string_view rFile, std::u16string_view rLink, const OUString *pFilter)
Definition: linkmgr2.cxx:379
o3tl::sorted_vector< SvLinkSource * > SvLinkSources
Definition: linkmgr.hxx:52
sal_uInt16 sal_Unicode