1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _LINKMGR_HXX 28 #define _LINKMGR_HXX 29 30 #include "sal/config.h" 31 #include "sfx2/dllapi.h" 32 #include <sfx2/linksrc.hxx> 33 #include <tools/string.hxx> 34 #include <svl/svarray.hxx> 35 36 class SfxObjectShell; 37 class Graphic; 38 class Size; 39 40 namespace sfx2 41 { 42 // Damit der Link ueber den Status der zu ladenen Grafik informierten werden 43 // verschickt das FileObject ein SvData, mit der FormatId 44 // "RegisterStatusInfoId" und ein einem String als Datentraeger. Dieser 45 // enthaelt den folgenden enum. 46 47 class SvBaseLink; 48 class SvBaseLinkRef; 49 50 typedef SvBaseLinkRef* SvBaseLinkRefPtr; 51 SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1, 1 ) 52 53 typedef SvLinkSource* SvLinkSourcePtr; 54 SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1, 1 ) 55 56 class SFX2_DLLPUBLIC LinkManager 57 { 58 SvBaseLinks aLinkTbl; 59 SvLinkSources aServerTbl; 60 61 SfxObjectShell *pPersist; // LinkMgr muss vor SfxObjectShell freigegeben werden 62 protected: 63 sal_Bool InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType, 64 const String* pName = 0 ); 65 public: 66 67 enum LinkState 68 { 69 STATE_LOAD_OK, 70 STATE_LOAD_ERROR, 71 STATE_LOAD_ABORT 72 }; 73 74 LinkManager( SfxObjectShell * pCacheCont ); 75 ~LinkManager(); 76 77 SfxObjectShell* GetPersist() const { return pPersist; } 78 void SetPersist( SfxObjectShell * p ) { pPersist = p; } 79 80 void Remove( SvBaseLink *pLink ); 81 void Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 ); 82 sal_Bool Insert( SvBaseLink* pLink ); 83 84 // den Link mit einem SvLinkSource verbinden und in die Liste eintragen 85 sal_Bool InsertDDELink( SvBaseLink*, 86 const String& rServer, 87 const String& rTopic, 88 const String& rItem ); 89 90 // falls am Link schon alles eingestellt ist ! 91 sal_Bool InsertDDELink( SvBaseLink* ); 92 93 // den Link mit einem PseudoObject verbinden und in die Liste eintragen 94 sal_Bool InsertFileLink( sfx2::SvBaseLink&, 95 sal_uInt16 nFileType, 96 const String& rTxt, 97 const String* pFilterNm = 0, 98 const String* pRange = 0 ); 99 100 // falls am Link schon alles eingestellt ist ! 101 sal_Bool InsertFileLink( sfx2::SvBaseLink& ); 102 103 // erfrage die Strings fuer den Dialog 104 sal_Bool GetDisplayNames( const SvBaseLink *, 105 String* pType, 106 String* pFile = 0, 107 String* pLink = 0, 108 String* pFilter = 0 ) const; 109 110 SvLinkSourceRef CreateObj( SvBaseLink* ); 111 112 void UpdateAllLinks( sal_Bool bAskUpdate = sal_True, 113 sal_Bool bCallErrHdl = sal_True, 114 sal_Bool bUpdateGrfLinks = sal_False, 115 Window* pParentWin = 0 ); 116 117 // Liste aller Links erfragen (z.B. fuer Verknuepfungs-Dialog) 118 const SvBaseLinks& GetLinks() const { return aLinkTbl; } 119 120 // ----------------- Serverseitige Verwaltung -------------------- 121 122 // Liste der zu serviereden Links erfragen 123 const SvLinkSources& GetServers() const { return aServerTbl; } 124 // einen zu servierenden Link eintragen/loeschen 125 sal_Bool InsertServer( SvLinkSource* rObj ); 126 void RemoveServer( SvLinkSource* rObj ); 127 void RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 ) 128 { aServerTbl.Remove( nPos, nCnt ); } 129 130 // eine Uebertragung wird abgebrochen, also alle DownloadMedien canceln 131 // (ist zur Zeit nur fuer die FileLinks interressant!) 132 void CancelTransfers(); 133 134 // um Status Informationen aus dem FileObject an den BaseLink zu 135 // senden, gibt es eine eigene ClipBoardId. Das SvData-Object hat 136 // dann die entsprechenden Informationen als String. 137 // Wird zur Zeit fuer FileObject in Verbindung mit JavaScript benoetigt 138 // - das braucht Informationen ueber Load/Abort/Error 139 static sal_uIntPtr RegisterStatusInfoId(); 140 141 // if the mimetype says graphic/bitmap/gdimetafile then get the 142 // graphic from the Any. Return says no errors 143 static sal_Bool GetGraphicFromAny( const String& rMimeType, 144 const ::com::sun::star::uno::Any & rValue, 145 Graphic& rGrf ); 146 147 private: 148 LinkManager( const LinkManager& ); 149 LinkManager& operator=( const LinkManager& ); 150 }; 151 152 // Trenner im LinkName fuer die DDE-/File-/Grafik- Links 153 // (nur wer es braucht, um einen SvLinkName zusammenzubasteln) 154 const sal_Unicode cTokenSeperator = 0xFFFF; 155 156 // erzeuge einen String fuer den SvLinkName. Fuer 157 // - DDE die ersten 3 Strings, (Server, Topic, Item) 158 // - File-/Grf-LinkNms die letzen 3 Strings (FileName, Bereich, Filter) 159 SFX2_DLLPUBLIC void MakeLnkName( String& rName, 160 const String* pType, // kann auch 0 sein !! 161 const String& rFile, 162 const String& rLink, 163 const String* pFilter = 0 ); 164 165 } 166 167 #endif 168 169