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 com { namespace sun { namespace star { namespace util { 37 class URL; 38 class XURLTransformer; 39 } } } } 40 41 namespace sfx2 42 { 43 // Damit der Link ueber den Status der zu ladenen Grafik informierten werden 44 // verschickt das FileObject ein SvData, mit der FormatId 45 // "RegisterStatusInfoId" und ein einem String als Datentraeger. Dieser 46 // enthaelt den folgenden enum. 47 48 class SvBaseLink; 49 class SvBaseLinkRef; 50 51 typedef SvBaseLinkRef* SvBaseLinkRefPtr; 52 SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1, 1 ) 53 54 typedef SvLinkSource* SvLinkSourcePtr; 55 SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1, 1 ) 56 57 class SFX2_DLLPUBLIC LinkManager 58 { 59 SvBaseLinks aLinkTbl; 60 SvLinkSources aServerTbl; 61 62 SfxObjectShell *pPersist; // LinkMgr muss vor SfxObjectShell freigegeben werden 63 64 sal_Bool mAutoAskUpdateAllLinks; 65 sal_Bool mUpdateAsked; 66 sal_Bool mAllowUpdate; 67 68 com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > xURLTransformer; 69 70 void SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows); 71 protected: 72 sal_Bool InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType, 73 const String* pName = 0 ); 74 public: 75 76 enum LinkState 77 { 78 STATE_LOAD_OK, 79 STATE_LOAD_ERROR, 80 STATE_LOAD_ABORT 81 }; 82 83 LinkManager( SfxObjectShell * pCacheCont ); 84 ~LinkManager(); 85 GetPersist() const86 SfxObjectShell* GetPersist() const { return pPersist; } SetPersist(SfxObjectShell * p)87 void SetPersist( SfxObjectShell * p ) { pPersist = p; } 88 89 void Remove( SvBaseLink *pLink ); 90 void Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 ); 91 sal_Bool Insert( SvBaseLink* pLink ); 92 93 // den Link mit einem SvLinkSource verbinden und in die Liste eintragen 94 sal_Bool InsertDDELink( SvBaseLink*, 95 const String& rServer, 96 const String& rTopic, 97 const String& rItem ); 98 99 // falls am Link schon alles eingestellt ist ! 100 sal_Bool InsertDDELink( SvBaseLink* ); 101 102 // den Link mit einem PseudoObject verbinden und in die Liste eintragen 103 sal_Bool InsertFileLink( sfx2::SvBaseLink&, 104 sal_uInt16 nFileType, 105 const String& rTxt, 106 const String* pFilterNm = 0, 107 const String* pRange = 0 ); 108 109 // falls am Link schon alles eingestellt ist ! 110 sal_Bool InsertFileLink( sfx2::SvBaseLink& ); 111 112 // erfrage die Strings fuer den Dialog 113 sal_Bool GetDisplayNames( const SvBaseLink *, 114 String* pType, 115 String* pFile = 0, 116 String* pLink = 0, 117 String* pFilter = 0 ) const; 118 119 SvLinkSourceRef CreateObj( SvBaseLink* ); 120 121 /// Ask (once) to allow updating links 122 sal_Bool GetUserAllowsLinkUpdate(Window *pParent); 123 124 // Automatically ask user about update all links, on first insert 125 // If we already asked the user, we forget about it and will ask again. 126 void SetAutoAskUpdateAllLinks(); 127 // Never ask the user: just update all links 128 void SetNeverAskUpdateAllLinks(); 129 130 void UpdateAllLinks( sal_Bool bAskUpdate = sal_True, 131 sal_Bool bCallErrHdl = sal_True, 132 sal_Bool bUpdateGrfLinks = sal_False, 133 Window* pParentWin = 0 ); 134 135 // Liste aller Links erfragen (z.B. fuer Verknuepfungs-Dialog) GetLinks() const136 const SvBaseLinks& GetLinks() const { return aLinkTbl; } 137 138 // ----------------- Serverseitige Verwaltung -------------------- 139 140 // Liste der zu serviereden Links erfragen GetServers() const141 const SvLinkSources& GetServers() const { return aServerTbl; } 142 // einen zu servierenden Link eintragen/loeschen 143 sal_Bool InsertServer( SvLinkSource* rObj ); 144 void RemoveServer( SvLinkSource* rObj ); RemoveServer(sal_uInt16 nPos,sal_uInt16 nCnt=1)145 void RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 ) 146 { aServerTbl.Remove( nPos, nCnt ); } 147 148 // eine Uebertragung wird abgebrochen, also alle DownloadMedien canceln 149 // (ist zur Zeit nur fuer die FileLinks interressant!) 150 void CancelTransfers(); 151 152 // um Status Informationen aus dem FileObject an den BaseLink zu 153 // senden, gibt es eine eigene ClipBoardId. Das SvData-Object hat 154 // dann die entsprechenden Informationen als String. 155 // Wird zur Zeit fuer FileObject in Verbindung mit JavaScript benoetigt 156 // - das braucht Informationen ueber Load/Abort/Error 157 static sal_uIntPtr RegisterStatusInfoId(); 158 159 // if the mimetype says graphic/bitmap/gdimetafile then get the 160 // graphic from the Any. Return says no errors 161 static sal_Bool GetGraphicFromAny( const String& rMimeType, 162 const ::com::sun::star::uno::Any & rValue, 163 Graphic& rGrf ); 164 165 // Check whether a link URL must be subject to authorization 166 // 167 // An empty url is considered unsafe 168 sal_Bool urlIsSafe( const ::rtl::OUString &url ); 169 170 // Check whether a link URL must be subject to authorization 171 sal_Bool urlIsSafe( const ::com::sun::star::util::URL &url ); 172 173 // Check whether a link URL is using a ``strange'' scheme 174 sal_Bool urlIsVendor( const ::rtl::OUString &url ); 175 176 private: 177 LinkManager( const LinkManager& ); 178 LinkManager& operator=( const LinkManager& ); 179 }; 180 181 // Trenner im LinkName fuer die DDE-/File-/Grafik- Links 182 // (nur wer es braucht, um einen SvLinkName zusammenzubasteln) 183 const sal_Unicode cTokenSeperator = 0xFFFF; 184 185 // erzeuge einen String fuer den SvLinkName. Fuer 186 // - DDE die ersten 3 Strings, (Server, Topic, Item) 187 // - File-/Grf-LinkNms die letzen 3 Strings (FileName, Bereich, Filter) 188 SFX2_DLLPUBLIC void MakeLnkName( String& rName, 189 const String* pType, // kann auch 0 sein !! 190 const String& rFile, 191 const String& rLink, 192 const String* pFilter = 0 ); 193 194 } 195 196 #endif 197 198