xref: /aoo41x/main/sfx2/inc/sfx2/lnkbase.hxx (revision cdf0e10c)
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 _LNKBASE_HXX
28 #define _LNKBASE_HXX
29 
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include "sal/config.h"
32 #include "sfx2/dllapi.h"
33 #include <sot/exchange.hxx>
34 #ifndef _TOOLS_REF_HXX
35 #include <tools/ref.hxx>
36 #endif
37 #ifndef _LINKSOURCE_HXX
38 #include <sfx2/linksrc.hxx>
39 #endif
40 
41 namespace com { namespace sun { namespace star { namespace uno
42 {
43 	class Any;
44 	//class Type;
45 }}}}
46 
47 namespace sfx2
48 {
49 
50 struct ImplBaseLinkData;
51 class LinkManager;
52 class SvLinkSource;
53 class FileDialogHelper;
54 
55 #ifndef OBJECT_DDE_EXTERN
56 #define	OBJECT_INTERN		0x00
57 //#define	OBJECT_SO_EXTERN	0x01
58 #define	OBJECT_DDE_EXTERN	0x02
59 #endif
60 
61 #define	OBJECT_CLIENT_SO			0x80 // ein Link
62 #define	OBJECT_CLIENT_DDE			0x81
63 //#define	OBJECT_CLIENT_OLE			0x82 // ein Ole-Link
64 //#define	OBJECT_CLIENT_OLE_CACHE  	0x83 // ein Ole-Link mit SvEmbeddedObject
65 #define	OBJECT_CLIENT_FILE			0x90
66 #define	OBJECT_CLIENT_GRF			0x91
67 #define	OBJECT_CLIENT_OLE			0x92 // embedded link
68 
69 enum sfxlink {
70 	// Ole2 compatibel und persistent
71 	LINKUPDATE_ALWAYS = 1,
72 	LINKUPDATE_ONCALL = 3,
73 
74 	LINKUPDATE_END		// dummy!
75 };
76 
77 struct BaseLink_Impl;
78 
79 class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
80 {
81 private:
82 	friend class LinkManager;
83 	friend class SvLinkSource;
84 
85 	SvLinkSourceRef			xObj;
86 	String					aLinkName;
87     BaseLink_Impl*          pImpl;
88 	sal_uInt16 					nObjType;
89 	sal_Bool					bVisible : 1;
90 	sal_Bool					bSynchron : 1;
91 	sal_Bool					bUseCache : 1;		// fuer GrafikLinks!
92     sal_Bool                    bWasLastEditOK : 1;
93 
94     DECL_LINK( EndEditHdl, String* );
95 
96     bool                    ExecuteEdit( const String& _rNewName );
97 
98 protected:
99 	void			SetObjType( sal_uInt16 );
100 
101 					// setzen des LinkSourceName ohne aktion
102 	void			SetName( const String & rLn );
103 					// LinkSourceName der im SvLinkBase steht
104 	String		 	GetName() const;
105 
106 	ImplBaseLinkData* pImplData;
107 
108     sal_Bool            m_bIsReadOnly;
109     com::sun::star::uno::Reference<com::sun::star::io::XInputStream>
110                         m_xInputStreamToLoadFrom;
111 
112 					SvBaseLink();
113                     SvBaseLink( sal_uInt16 nLinkType, sal_uIntPtr nContentType = FORMAT_STRING );
114 	virtual 		~SvBaseLink();
115 
116     void            _GetRealObject( sal_Bool bConnect = sal_True );
117 
118     SvLinkSource*   GetRealObject()
119 					{
120 						if( !xObj.Is() )
121                             _GetRealObject();
122 						return xObj;
123 					}
124 
125 public:
126 					TYPEINFO();
127 					// ask JP
128 	virtual void    Closed();
129                     SvBaseLink( const String& rNm, sal_uInt16 nObjectType,
130                                  SvLinkSource* );
131 
132 	sal_uInt16			GetObjType() const { return nObjType; }
133 
134 	void			SetObj( SvLinkSource * pObj );
135 	SvLinkSource*	GetObj() const	{ return xObj; }
136 
137 	void    		SetLinkSourceName( const String & rName );
138 	String		 	GetLinkSourceName() const;
139 
140 	virtual void 	DataChanged( const String & rMimeType,
141 								const ::com::sun::star::uno::Any & rValue );
142 
143 	void			SetUpdateMode( sal_uInt16 );
144 	sal_uInt16 			GetUpdateMode() const;
145 	sal_uIntPtr  			GetContentType() const;
146 	sal_Bool 			SetContentType( sal_uIntPtr nType );
147 
148     LinkManager*          GetLinkManager();
149     const LinkManager*    GetLinkManager() const;
150     void                    SetLinkManager( LinkManager* _pMgr );
151 
152 	sal_Bool			Update();
153 	void			Disconnect();
154 
155     // Link impl: DECL_LINK( MyEndDialogHdl, SvBaseLink* ); <= param is this
156     virtual void    Edit( Window*, const Link& rEndEditHdl );
157 
158 		// soll der Link im Dialog angezeigt werden ? (Links im Link im ...)
159 	sal_Bool 	        IsVisible() const   		{ return bVisible; }
160 	void 	        SetVisible( sal_Bool bFlag )	{ bVisible = bFlag; }
161 		// soll der Link synchron oder asynchron geladen werden?
162 	sal_Bool 	        IsSynchron() const   		{ return bSynchron; }
163 	void 	        SetSynchron( sal_Bool bFlag )	{ bSynchron = bFlag; }
164 
165 	sal_Bool 	        IsUseCache() const   		{ return bUseCache; }
166 	void 			SetUseCache( sal_Bool bFlag )	{ bUseCache = bFlag; }
167 
168     void            setStreamToLoadFrom(
169                         const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,
170                         sal_Bool bIsReadOnly )
171                             { m_xInputStreamToLoadFrom = xInputStream;
172                               m_bIsReadOnly = bIsReadOnly; }
173     // --> OD 2008-06-18 #i88291#
174     void            clearStreamToLoadFrom();
175     // <--
176 
177     inline sal_Bool         WasLastEditOK() const       { return bWasLastEditOK; }
178     FileDialogHelper*   GetFileDialog( sal_uInt32 nFlags, const String& rFactory ) const;
179 };
180 
181 SV_DECL_IMPL_REF(SvBaseLink);
182 
183 }
184 
185 #endif
186