fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / linkmgr.hxx
blob27b84b69e13acad22909041aef986ac399f19cb0
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 #ifndef _LINKMGR_HXX
20 #define _LINKMGR_HXX
22 #include "sal/config.h"
23 #include "sfx2/dllapi.h"
24 #include <sfx2/linksrc.hxx>
25 #include <tools/string.hxx>
27 #include <vector>
28 #include <set>
30 class SfxObjectShell;
31 class Graphic;
32 class Size;
34 namespace com { namespace sun { namespace star {
35 namespace lang {
36 class XComponent;
38 }}}
40 namespace sfx2
42 // For the link to receive information about the status of graphics that
43 // will be loaded the FileObject sends a SvData, which contains the
44 // FormatID "RegisterStatusInfoId" and a string as the data container.
45 // This contains the following enum.
47 class SvBaseLink;
48 class SvBaseLinkRef;
50 typedef std::vector<SvBaseLinkRef*> SvBaseLinks;
52 typedef std::set<SvLinkSource*> SvLinkSources;
54 class SFX2_DLLPUBLIC LinkManager
56 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > >
57 CompVector;
58 CompVector maCachedComps;
60 SvBaseLinks aLinkTbl;
61 SvLinkSources aServerTbl;
63 SfxObjectShell *pPersist; // LinkMgr must be release before SfxObjectShell
64 protected:
65 sal_Bool InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType,
66 const String* pName = 0 );
67 public:
69 enum LinkState
71 STATE_LOAD_OK,
72 STATE_LOAD_ERROR,
73 STATE_LOAD_ABORT
76 LinkManager( SfxObjectShell * pCacheCont );
77 ~LinkManager();
79 /**
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 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComp);
87 void CloseCachedComps();
89 SfxObjectShell* GetPersist() const { return pPersist; }
90 void SetPersist( SfxObjectShell * p ) { pPersist = p; }
92 void Remove( SvBaseLink *pLink );
93 void Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 );
94 sal_Bool Insert( SvBaseLink* pLink );
96 // the links connect to a SvLinkSource and adds to the list
97 sal_Bool InsertDDELink( SvBaseLink*,
98 const String& rServer,
99 const String& rTopic,
100 const String& rItem );
102 // if everything is already set at the link!
103 sal_Bool InsertDDELink( SvBaseLink* );
105 // Connect the links to a pseudo-object and add to the list
106 bool InsertFileLink( sfx2::SvBaseLink&,
107 sal_uInt16 nFileType,
108 const String& rFileNm,
109 const String* pFilterNm = 0,
110 const String* pRange = 0 );
112 bool InsertFileLink(
113 sfx2::SvBaseLink& rLink, sal_uInt16 nFileType, const OUString& rFileNm,
114 const OUString* pFilterNm = NULL, const OUString* pRange = NULL);
116 void ReconnectDdeLink(SfxObjectShell& rServer);
119 * Reconnect the server document shell to a DDE link object.
121 * @param rPath path to the server document
122 * @param rServer server document shell instance
123 * @param rLink link object of the client document
125 void LinkServerShell(const OUString& rPath, SfxObjectShell& rServer, ::sfx2::SvBaseLink& rLink) const;
127 // Obtain the string for the dialog
128 bool GetDisplayNames( const SvBaseLink *,
129 String* pType,
130 String* pFile = 0,
131 String* pLink = 0,
132 String* pFilter = 0 ) const;
134 bool GetDisplayNames(
135 const SvBaseLink* pLink, OUString* pType, OUString* pFile = NULL,
136 OUString* pLinkStr = NULL, OUString* pFilter = NULL) const;
138 SvLinkSourceRef CreateObj( SvBaseLink* );
140 void UpdateAllLinks( bool bAskUpdate = true,
141 bool bCallErrHdl = true,
142 bool bUpdateGrfLinks = false,
143 Window* pParentWin = 0 );
145 // Call for list of links (eg for link-dialog)
146 const SvBaseLinks& GetLinks() const { return aLinkTbl; }
148 // ----------------- Server-side management --------------------
150 // Call with list of links to server
151 const SvLinkSources& GetServers() const { return aServerTbl; }
152 // Link register/delete
153 sal_Bool InsertServer( SvLinkSource* rObj );
154 void RemoveServer( SvLinkSource* rObj );
156 // A transfer is aborted, so cancel all download media
157 // (for the time beeing this is only of interest for the FileLinks!)
158 void CancelTransfers();
160 // To send status information from the FileObject to the Baselink,
161 // for this there exist a separate ClipBoardId. The SvData-object has
162 // got the appropriate information as a string.
163 // Is now required for FileObject in conjunction with JavaScript
164 // this needs information about Load/Abort/Error
165 static sal_uIntPtr RegisterStatusInfoId();
167 // if the mimetype says graphic/bitmap/gdimetafile then get the
168 // graphic from the Any. Return says no errors
169 static sal_Bool GetGraphicFromAny( const String& rMimeType,
170 const ::com::sun::star::uno::Any & rValue,
171 Graphic& rGrf );
173 private:
174 LinkManager( const LinkManager& );
175 LinkManager& operator=( const LinkManager& );
178 // Separator in the link name for the DDE-/File-/Graphics- links
179 // (only those who need to construct a SvLinkName)
180 const sal_Unicode cTokenSeparator = 0xFFFF;
182 // create a string for the SvLinkName. For:
183 // - DDE the first 3 Strings, (Server, Topic, Item)
184 // - File-/Graphics-LinkNames the last 3 Strings (FileName, Region, Filter)
185 SFX2_DLLPUBLIC void MakeLnkName( String& rName,
186 const String* pType, // Can also be null!!
187 const String& rFile,
188 const String& rLink,
189 const String* pFilter = 0 );
193 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */