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