Branch data Line data Source code
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 _LINKMGR_HXX
20 : : #define _LINKMGR_HXX
21 : :
22 : : #include "sal/config.h"
23 : : #include "sfx2/dllapi.h"
24 : : #include <sfx2/linksrc.hxx>
25 : : #include <tools/string.hxx>
26 : :
27 : : #include <vector>
28 : : #include <set>
29 : :
30 : : class SfxObjectShell;
31 : : class Graphic;
32 : : class Size;
33 : :
34 : : namespace com { namespace sun { namespace star {
35 : : namespace lang {
36 : : class XComponent;
37 : : }
38 : : }}}
39 : :
40 : : namespace sfx2
41 : : {
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.
46 : :
47 : : class SvBaseLink;
48 : : class SvBaseLinkRef;
49 : :
50 : : typedef std::vector<SvBaseLinkRef*> SvBaseLinks;
51 : :
52 : : typedef std::set<SvLinkSource*> SvLinkSources;
53 : :
54 : : class SFX2_DLLPUBLIC LinkManager
55 : : {
56 : : typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > >
57 : : CompVector;
58 : : CompVector maCachedComps;
59 : :
60 : : SvBaseLinks aLinkTbl;
61 : : SvLinkSources aServerTbl;
62 : :
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:
68 : :
69 : : enum LinkState
70 : : {
71 : : STATE_LOAD_OK,
72 : : STATE_LOAD_ERROR,
73 : : STATE_LOAD_ABORT
74 : : };
75 : :
76 : : LinkManager( SfxObjectShell * pCacheCont );
77 : : ~LinkManager();
78 : :
79 : : /**
80 : : * Insert a component loaded during link update, which needs to be closed
81 : : * when the update is complete.
82 : : *
83 : : * @param xComp component loaded during link update.
84 : : */
85 : : void InsertCachedComp(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComp);
86 : :
87 : : void CloseCachedComps();
88 : :
89 : 0 : SfxObjectShell* GetPersist() const { return pPersist; }
90 : 3267 : void SetPersist( SfxObjectShell * p ) { pPersist = p; }
91 : :
92 : : void Remove( SvBaseLink *pLink );
93 : : void Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 );
94 : : sal_Bool Insert( SvBaseLink* pLink );
95 : :
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 );
101 : :
102 : : // if everything is already set at the link!
103 : : sal_Bool InsertDDELink( SvBaseLink* );
104 : :
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 );
111 : :
112 : : bool InsertFileLink(
113 : : sfx2::SvBaseLink& rLink, sal_uInt16 nFileType, const rtl::OUString& rFileNm,
114 : : const rtl::OUString* pFilterNm = NULL, const rtl::OUString* pRange = NULL);
115 : :
116 : : void ReconnectDdeLink(SfxObjectShell& rServer);
117 : :
118 : : /**
119 : : * Reconnect the server document shell to a DDE link object.
120 : : *
121 : : * @param rPath path to the server document
122 : : * @param rServer server document shell instance
123 : : * @param rLink link object of the client document
124 : : */
125 : : void LinkServerShell(const ::rtl::OUString& rPath, SfxObjectShell& rServer, ::sfx2::SvBaseLink& rLink) const;
126 : :
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;
133 : :
134 : : bool GetDisplayNames(
135 : : const SvBaseLink* pLink, rtl::OUString* pType, rtl::OUString* pFile = NULL,
136 : : rtl::OUString* pLinkStr = NULL, rtl::OUString* pFilter = NULL) const;
137 : :
138 : : SvLinkSourceRef CreateObj( SvBaseLink* );
139 : :
140 : : void UpdateAllLinks( sal_Bool bAskUpdate = sal_True,
141 : : sal_Bool bCallErrHdl = sal_True,
142 : : sal_Bool bUpdateGrfLinks = sal_False,
143 : : Window* pParentWin = 0 );
144 : :
145 : : // Call for list of links (eg for link-dialog)
146 : 6343 : const SvBaseLinks& GetLinks() const { return aLinkTbl; }
147 : :
148 : : // ----------------- Server-side management --------------------
149 : :
150 : : // Call with list of links to server
151 : 14491 : const SvLinkSources& GetServers() const { return aServerTbl; }
152 : : // Link register/delete
153 : : sal_Bool InsertServer( SvLinkSource* rObj );
154 : : void RemoveServer( SvLinkSource* rObj );
155 : :
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();
159 : :
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();
166 : :
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 );
172 : :
173 : : private:
174 : : LinkManager( const LinkManager& );
175 : : LinkManager& operator=( const LinkManager& );
176 : : };
177 : :
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 cTokenSeperator = 0xFFFF;
181 : :
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 );
190 : :
191 : : }
192 : :
193 : : #endif
194 : :
195 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|