xref: /aoo41x/main/sfx2/inc/sfx2/linkmgr.hxx (revision 353d8f4d)
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     // Damit der Link ueber den Status der zu ladenen Grafik informierten werden
39     // verschickt das FileObject ein SvData, mit der FormatId
40     // "RegisterStatusInfoId" und ein einem String als Datentraeger. Dieser
41     // enthaelt den folgenden enum.
42 
43 class SvBaseLink;
44 class SvBaseLinkRef;
45 
46 typedef SvBaseLinkRef* SvBaseLinkRefPtr;
47 SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1, 1 )
48 
49 typedef SvLinkSource* SvLinkSourcePtr;
50 SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1, 1 )
51 
52 class SFX2_DLLPUBLIC LinkManager
53 {
54 	SvBaseLinks		aLinkTbl;
55 	SvLinkSources aServerTbl;
56 
57     SfxObjectShell *pPersist; // LinkMgr muss vor SfxObjectShell freigegeben werden
58 protected:
59 	sal_Bool 		InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType,
60 							const String* pName = 0 );
61 public:
62 
63     enum LinkState
64     {
65         STATE_LOAD_OK,
66         STATE_LOAD_ERROR,
67         STATE_LOAD_ABORT
68     };
69 
70 	            LinkManager( SfxObjectShell * pCacheCont );
71 	            ~LinkManager();
72 
73     SfxObjectShell*    GetPersist() const              { return pPersist; }
74     void        SetPersist( SfxObjectShell * p )   { pPersist = p; }
75 
76 	void		Remove( SvBaseLink *pLink );
77 	void		Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 );
78 	sal_Bool		Insert( SvBaseLink* pLink );
79 
80 				// den Link mit einem SvLinkSource verbinden und in die Liste eintragen
81 	sal_Bool 		InsertDDELink( SvBaseLink*,
82 						const String& rServer,
83 						const String& rTopic,
84 						const String& rItem );
85 
86 				// falls am Link schon alles eingestellt ist !
87 	sal_Bool 		InsertDDELink( SvBaseLink* );
88 
89 	// den Link mit einem PseudoObject verbinden und in die Liste eintragen
90 	sal_Bool InsertFileLink( sfx2::SvBaseLink&,
91 						sal_uInt16 nFileType,
92 						const String& rTxt,
93 						const String* pFilterNm = 0,
94 						const String* pRange = 0 );
95 
96 			// falls am Link schon alles eingestellt ist !
97 	sal_Bool InsertFileLink( sfx2::SvBaseLink& );
98 
99 				// erfrage die Strings fuer den Dialog
100 	sal_Bool GetDisplayNames( const SvBaseLink *,
101 									String* pType,
102 									String* pFile = 0,
103 									String* pLink = 0,
104 									String* pFilter = 0 ) const;
105 
106     SvLinkSourceRef CreateObj( SvBaseLink* );
107 
108 	void 		UpdateAllLinks( sal_Bool bAskUpdate = sal_True,
109 								sal_Bool bCallErrHdl = sal_True,
110                                 sal_Bool bUpdateGrfLinks = sal_False,
111                                 Window* pParentWin = 0 );
112 
113 				// Liste aller Links erfragen (z.B. fuer Verknuepfungs-Dialog)
114 	const 		SvBaseLinks& GetLinks() const { return aLinkTbl; }
115 
116 	// ----------------- Serverseitige Verwaltung --------------------
117 
118 				// Liste der zu serviereden Links erfragen
119 	const SvLinkSources& GetServers() const { return aServerTbl; }
120 				// einen zu servierenden Link eintragen/loeschen
121 	sal_Bool 		InsertServer( SvLinkSource* rObj );
122 	void 		RemoveServer( SvLinkSource* rObj );
123 	void 		RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 )
124 				{	aServerTbl.Remove( nPos, nCnt ); }
125 
126 	// eine Uebertragung wird abgebrochen, also alle DownloadMedien canceln
127 	// (ist zur Zeit nur fuer die FileLinks interressant!)
128 	void CancelTransfers();
129 
130 	// um Status Informationen aus dem FileObject an den BaseLink zu
131 	// senden, gibt es eine eigene ClipBoardId. Das SvData-Object hat
132 	// dann die entsprechenden Informationen als String.
133 	// Wird zur Zeit fuer FileObject in Verbindung mit JavaScript benoetigt
134 	// - das braucht Informationen ueber Load/Abort/Error
135 	static sal_uIntPtr  RegisterStatusInfoId();
136 
137 	// if the mimetype says graphic/bitmap/gdimetafile then get the
138 	// graphic from the Any. Return says no errors
139 	static sal_Bool GetGraphicFromAny( const String& rMimeType,
140 								const ::com::sun::star::uno::Any & rValue,
141 								Graphic& rGrf );
142 
143 private:
144 				LinkManager( const LinkManager& );
145 				LinkManager& operator=( const LinkManager& );
146 };
147 
148 // Trenner im LinkName fuer die DDE-/File-/Grafik- Links
149 // (nur wer es braucht, um einen SvLinkName zusammenzubasteln)
150 const sal_Unicode cTokenSeperator = 0xFFFF;
151 
152 // erzeuge einen String fuer den SvLinkName. Fuer
153 // - DDE die ersten 3 Strings, (Server, Topic, Item)
154 // - File-/Grf-LinkNms die letzen 3 Strings (FileName, Bereich, Filter)
155 SFX2_DLLPUBLIC void MakeLnkName( String& rName,
156 				 const String* pType,		// kann auch 0 sein !!
157 				 const String& rFile,
158 				 const String& rLink,
159 				 const String* pFilter = 0 );
160 
161 }
162 
163 #endif
164 
165