xref: /aoo41x/main/sfx2/inc/sfx2/linkmgr.hxx (revision 8d6615f2)
1353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5353d8f4dSAndrew Rist  * distributed with this work for additional information
6353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10353d8f4dSAndrew Rist  *
11353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12353d8f4dSAndrew Rist  *
13353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18353d8f4dSAndrew Rist  * under the License.
19353d8f4dSAndrew Rist  *
20353d8f4dSAndrew Rist  *************************************************************/
21353d8f4dSAndrew Rist 
22353d8f4dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _LINKMGR_HXX
24cdf0e10cSrcweir #define _LINKMGR_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "sal/config.h"
27cdf0e10cSrcweir #include "sfx2/dllapi.h"
28cdf0e10cSrcweir #include <sfx2/linksrc.hxx>
29cdf0e10cSrcweir #include <tools/string.hxx>
30cdf0e10cSrcweir #include <svl/svarray.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class SfxObjectShell;
33cdf0e10cSrcweir class Graphic;
34cdf0e10cSrcweir class Size;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace sfx2
37cdf0e10cSrcweir {
38cdf0e10cSrcweir     // Damit der Link ueber den Status der zu ladenen Grafik informierten werden
39cdf0e10cSrcweir     // verschickt das FileObject ein SvData, mit der FormatId
40cdf0e10cSrcweir     // "RegisterStatusInfoId" und ein einem String als Datentraeger. Dieser
41cdf0e10cSrcweir     // enthaelt den folgenden enum.
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class SvBaseLink;
44cdf0e10cSrcweir class SvBaseLinkRef;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir typedef SvBaseLinkRef* SvBaseLinkRefPtr;
47cdf0e10cSrcweir SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1, 1 )
48cdf0e10cSrcweir 
49cdf0e10cSrcweir typedef SvLinkSource* SvLinkSourcePtr;
50cdf0e10cSrcweir SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1, 1 )
51cdf0e10cSrcweir 
52cdf0e10cSrcweir class SFX2_DLLPUBLIC LinkManager
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	SvBaseLinks		aLinkTbl;
55cdf0e10cSrcweir 	SvLinkSources aServerTbl;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     SfxObjectShell *pPersist; // LinkMgr muss vor SfxObjectShell freigegeben werden
58611fcdabSJim Jagielski 
59611fcdabSJim Jagielski 	sal_Bool mAutoAskUpdateAllLinks;
60611fcdabSJim Jagielski 	sal_Bool mUpdateAsked;
61611fcdabSJim Jagielski 	sal_Bool mAllowUpdate;
62611fcdabSJim Jagielski 
63611fcdabSJim Jagielski 	void SetUserAllowsLinkUpdate(SvBaseLink *pLink, sal_Bool allows);
64cdf0e10cSrcweir protected:
65cdf0e10cSrcweir 	sal_Bool 		InsertLink( SvBaseLink* pLink, sal_uInt16 nObjType, sal_uInt16 nUpdateType,
66cdf0e10cSrcweir 							const String* pName = 0 );
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     enum LinkState
70cdf0e10cSrcweir     {
71cdf0e10cSrcweir         STATE_LOAD_OK,
72cdf0e10cSrcweir         STATE_LOAD_ERROR,
73cdf0e10cSrcweir         STATE_LOAD_ABORT
74cdf0e10cSrcweir     };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	            LinkManager( SfxObjectShell * pCacheCont );
77cdf0e10cSrcweir 	            ~LinkManager();
78cdf0e10cSrcweir 
GetPersist() const79cdf0e10cSrcweir     SfxObjectShell*    GetPersist() const              { return pPersist; }
SetPersist(SfxObjectShell * p)80cdf0e10cSrcweir     void        SetPersist( SfxObjectShell * p )   { pPersist = p; }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	void		Remove( SvBaseLink *pLink );
83cdf0e10cSrcweir 	void		Remove( sal_uInt16 nPos, sal_uInt16 nCnt = 1 );
84cdf0e10cSrcweir 	sal_Bool		Insert( SvBaseLink* pLink );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 				// den Link mit einem SvLinkSource verbinden und in die Liste eintragen
87cdf0e10cSrcweir 	sal_Bool 		InsertDDELink( SvBaseLink*,
88cdf0e10cSrcweir 						const String& rServer,
89cdf0e10cSrcweir 						const String& rTopic,
90cdf0e10cSrcweir 						const String& rItem );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 				// falls am Link schon alles eingestellt ist !
93cdf0e10cSrcweir 	sal_Bool 		InsertDDELink( SvBaseLink* );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	// den Link mit einem PseudoObject verbinden und in die Liste eintragen
96cdf0e10cSrcweir 	sal_Bool InsertFileLink( sfx2::SvBaseLink&,
97cdf0e10cSrcweir 						sal_uInt16 nFileType,
98cdf0e10cSrcweir 						const String& rTxt,
99cdf0e10cSrcweir 						const String* pFilterNm = 0,
100cdf0e10cSrcweir 						const String* pRange = 0 );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 			// falls am Link schon alles eingestellt ist !
103cdf0e10cSrcweir 	sal_Bool InsertFileLink( sfx2::SvBaseLink& );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 				// erfrage die Strings fuer den Dialog
106cdf0e10cSrcweir 	sal_Bool GetDisplayNames( const SvBaseLink *,
107cdf0e10cSrcweir 									String* pType,
108cdf0e10cSrcweir 									String* pFile = 0,
109cdf0e10cSrcweir 									String* pLink = 0,
110cdf0e10cSrcweir 									String* pFilter = 0 ) const;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     SvLinkSourceRef CreateObj( SvBaseLink* );
113cdf0e10cSrcweir 
114f92f29d1SArrigo Marchiori     /// Ask (once) to allow updating links
115f92f29d1SArrigo Marchiori 	sal_Bool GetUserAllowsLinkUpdate(Window *pParent);
116611fcdabSJim Jagielski 
117611fcdabSJim Jagielski 	// Automatically ask user about update all links, on first insert
118*8d6615f2SArrigo Marchiori     // If we already asked the user, we forget about it and will ask again.
119611fcdabSJim Jagielski 	void SetAutoAskUpdateAllLinks();
120*8d6615f2SArrigo Marchiori     // Never ask the user: just update all links
121*8d6615f2SArrigo Marchiori     void SetNeverAskUpdateAllLinks();
122611fcdabSJim Jagielski 
123cdf0e10cSrcweir 	void 		UpdateAllLinks( sal_Bool bAskUpdate = sal_True,
124cdf0e10cSrcweir 								sal_Bool bCallErrHdl = sal_True,
125cdf0e10cSrcweir                                 sal_Bool bUpdateGrfLinks = sal_False,
126cdf0e10cSrcweir                                 Window* pParentWin = 0 );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 				// Liste aller Links erfragen (z.B. fuer Verknuepfungs-Dialog)
GetLinks() const129cdf0e10cSrcweir 	const 		SvBaseLinks& GetLinks() const { return aLinkTbl; }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	// ----------------- Serverseitige Verwaltung --------------------
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 				// Liste der zu serviereden Links erfragen
GetServers() const134cdf0e10cSrcweir 	const SvLinkSources& GetServers() const { return aServerTbl; }
135cdf0e10cSrcweir 				// einen zu servierenden Link eintragen/loeschen
136cdf0e10cSrcweir 	sal_Bool 		InsertServer( SvLinkSource* rObj );
137cdf0e10cSrcweir 	void 		RemoveServer( SvLinkSource* rObj );
RemoveServer(sal_uInt16 nPos,sal_uInt16 nCnt=1)138cdf0e10cSrcweir 	void 		RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 )
139cdf0e10cSrcweir 				{	aServerTbl.Remove( nPos, nCnt ); }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	// eine Uebertragung wird abgebrochen, also alle DownloadMedien canceln
142cdf0e10cSrcweir 	// (ist zur Zeit nur fuer die FileLinks interressant!)
143cdf0e10cSrcweir 	void CancelTransfers();
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	// um Status Informationen aus dem FileObject an den BaseLink zu
146cdf0e10cSrcweir 	// senden, gibt es eine eigene ClipBoardId. Das SvData-Object hat
147cdf0e10cSrcweir 	// dann die entsprechenden Informationen als String.
148cdf0e10cSrcweir 	// Wird zur Zeit fuer FileObject in Verbindung mit JavaScript benoetigt
149cdf0e10cSrcweir 	// - das braucht Informationen ueber Load/Abort/Error
150cdf0e10cSrcweir 	static sal_uIntPtr  RegisterStatusInfoId();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	// if the mimetype says graphic/bitmap/gdimetafile then get the
153cdf0e10cSrcweir 	// graphic from the Any. Return says no errors
154cdf0e10cSrcweir 	static sal_Bool GetGraphicFromAny( const String& rMimeType,
155cdf0e10cSrcweir 								const ::com::sun::star::uno::Any & rValue,
156cdf0e10cSrcweir 								Graphic& rGrf );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir private:
159cdf0e10cSrcweir 				LinkManager( const LinkManager& );
160cdf0e10cSrcweir 				LinkManager& operator=( const LinkManager& );
161cdf0e10cSrcweir };
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // Trenner im LinkName fuer die DDE-/File-/Grafik- Links
164cdf0e10cSrcweir // (nur wer es braucht, um einen SvLinkName zusammenzubasteln)
165cdf0e10cSrcweir const sal_Unicode cTokenSeperator = 0xFFFF;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir // erzeuge einen String fuer den SvLinkName. Fuer
168cdf0e10cSrcweir // - DDE die ersten 3 Strings, (Server, Topic, Item)
169cdf0e10cSrcweir // - File-/Grf-LinkNms die letzen 3 Strings (FileName, Bereich, Filter)
170cdf0e10cSrcweir SFX2_DLLPUBLIC void MakeLnkName( String& rName,
171cdf0e10cSrcweir 				 const String* pType,		// kann auch 0 sein !!
172cdf0e10cSrcweir 				 const String& rFile,
173cdf0e10cSrcweir 				 const String& rLink,
174cdf0e10cSrcweir 				 const String* pFilter = 0 );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir #endif
179cdf0e10cSrcweir 
180