1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _LINKMGR_HXX 24 #define _LINKMGR_HXX 25 26 #include "sal/config.h" 27 #include "sfx2/dllapi.h" 28 #include <sfx2/linksrc.hxx> 29 #include <tools/string.hxx> 30 #include <svl/svarray.hxx> 31 32 class SfxObjectShell; 33 class Graphic; 34 class Size; 35 36 namespace sfx2 37 { 38 // The FileObject sends a SvData with the FormatId to notify the link about 39 // the status of the to be loaded graphic "RegisterStatusInfoId" and a string 40 // as data carrier. This contains the following enum. 41 42 class SvBaseLink; 43 class SvBaseLinkRef; 44 45 typedef SvBaseLinkRef* SvBaseLinkRefPtr; 46 SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1, 1 ) 47 48 typedef SvLinkSource* SvLinkSourcePtr; 49 SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1, 1 ) 50 51 class SFX2_DLLPUBLIC LinkManager 52 { 53 SvBaseLinks aLinkTbl; 54 SvLinkSources aServerTbl; 55 56 SfxObjectShell *pPersist; // LinkMgr has to be deallocated before SfxObjectShell 57 58 sal_Bool mAutoAskUpdateAllLinks; 59 sal_Bool mUpdateAsked; 60 sal_Bool mAllowUpdate; 61 62 void SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows); 63 protected: 64 sal_Bool InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType, 65 const String* pName = 0 ); 66 public: 67 68 enum LinkState 69 { 70 STATE_LOAD_OK, 71 STATE_LOAD_ERROR, 72 STATE_LOAD_ABORT 73 }; 74 75 LinkManager( SfxObjectShell * pCacheCont ); 76 ~LinkManager(); 77 GetPersist() const78 SfxObjectShell* GetPersist() const { return pPersist; } SetPersist(SfxObjectShell * p)79 void SetPersist( SfxObjectShell * p ) { pPersist = p; } 80 81 void Remove( SvBaseLink *pLink ); 82 void Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 ); 83 sal_Bool Insert( SvBaseLink* pLink ); 84 85 // connect the link with a SvLinkSource and insert into the list 86 sal_Bool InsertDDELink( SvBaseLink*, 87 const String& rServer, 88 const String& rTopic, 89 const String& rItem ); 90 91 // in case that all was already adjusted at the link! 92 sal_Bool InsertDDELink( SvBaseLink* ); 93 94 // connect the link with a PseudoObject and insert into the list 95 sal_Bool InsertFileLink( sfx2::SvBaseLink&, 96 sal_uInt16 nFileType, 97 const String& rTxt, 98 const String* pFilterNm = 0, 99 const String* pRange = 0 ); 100 101 // in case that all was already adjusted at the link! 102 sal_Bool InsertFileLink( sfx2::SvBaseLink& ); 103 104 // ask for the strings to be used in the dialog 105 sal_Bool GetDisplayNames( const SvBaseLink *, 106 String* pType, 107 String* pFile = 0, 108 String* pLink = 0, 109 String* pFilter = 0 ) const; 110 111 SvLinkSourceRef CreateObj( SvBaseLink* ); 112 113 /// Ask (once) to allow updating links 114 sal_Bool GetUserAllowsLinkUpdate(Window *pParent); 115 116 // Automatically ask user about update all links, on first insert 117 // If we already asked the user, we forget about it and will ask again. 118 void SetAutoAskUpdateAllLinks(); 119 // Never ask the user: just update all links 120 void SetNeverAskUpdateAllLinks(); 121 122 void UpdateAllLinks( sal_Bool bAskUpdate = sal_True, 123 sal_Bool bCallErrHdl = sal_True, 124 sal_Bool bUpdateGrfLinks = sal_False, 125 Window* pParentWin = 0 ); 126 127 // ask for the list of all links (e.g, for the link dialog) GetLinks() const128 const SvBaseLinks& GetLinks() const { return aLinkTbl; } 129 130 // ----------------- Server-side Management -------------------- 131 132 // ask for the list of all links that get served GetServers() const133 const SvLinkSources& GetServers() const { return aServerTbl; } 134 // insert/delete a served link 135 sal_Bool InsertServer( SvLinkSource* rObj ); 136 void RemoveServer( SvLinkSource* rObj ); RemoveServer(sal_uInt16 nPos,sal_uInt16 nCnt=1)137 void RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 ) 138 { aServerTbl.Remove( nPos, nCnt ); } 139 140 // a transfer will be discontinued, therefore cancel all DownloadMedia 141 // (at the moment only interesting for the FileLinks!) 142 143 void CancelTransfers(); 144 145 // to send status information from the FileObject to the BaseLink, there is an own ClipboardId. 146 // The SvData object has then the respective information as string. 147 // Currently this will be used for FileObject in connection with JavaScript 148 // - that needs information about Load/Abort/Error 149 150 static sal_uIntPtr RegisterStatusInfoId(); 151 152 // if the mimetype says graphic/bitmap/gdimetafile then get the 153 // graphic from the Any. Return says no errors 154 static sal_Bool GetGraphicFromAny( const String& rMimeType, 155 const ::com::sun::star::uno::Any & rValue, 156 Graphic& rGrf ); 157 158 private: 159 LinkManager( const LinkManager& ); 160 LinkManager& operator=( const LinkManager& ); 161 }; 162 163 // separator in the LinkName for the DDE/File/Graphic links 164 // (only who needs it, in order to assemble a SvLinkName) 165 const sal_Unicode cTokenSeperator = 0xFFFF; 166 167 // erzeuge einen String fuer den SvLinkName. Fuer 168 // - DDE die ersten 3 Strings, (Server, Topic, Item) 169 // - File-/Grf-LinkNms die letzen 3 Strings (FileName, Bereich, Filter) 170 // create a string for the SvLinkName. For: 171 // - DDE the first 3 strings, (Server, Topic, Item) 172 // - File/Graphic LinkNames the last 3 strings (FileName, Area, Filter) 173 SFX2_DLLPUBLIC void MakeLnkName( String& rName, 174 const String* pType, // can also be 0! 175 const String& rFile, 176 const String& rLink, 177 const String* pFilter = 0 ); 178 179 } 180 181 #endif 182 183