Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SFX2_LNKBASE_HXX
20 : #define INCLUDED_SFX2_LNKBASE_HXX
21 :
22 : #include <com/sun/star/io/XInputStream.hpp>
23 : #include <rtl/ustring.hxx>
24 : #include <sal/config.h>
25 : #include <sfx2/dllapi.h>
26 : #include <sfx2/linksrc.hxx>
27 : #include <sot/exchange.hxx>
28 : #include <tools/ref.hxx>
29 :
30 : namespace com { namespace sun { namespace star { namespace uno
31 : {
32 : class Any;
33 : }}}}
34 :
35 : namespace sfx2
36 : {
37 :
38 : struct ImplBaseLinkData;
39 : class LinkManager;
40 : class SvLinkSource;
41 : class FileDialogHelper;
42 :
43 : #ifndef OBJECT_DDE_EXTERN
44 : #define OBJECT_INTERN 0x00
45 : //#define OBJECT_SO_EXTERN 0x01
46 : #define OBJECT_DDE_EXTERN 0x02
47 : #endif
48 :
49 : #define OBJECT_CLIENT_SO 0x80 // a Link
50 : #define OBJECT_CLIENT_DDE 0x81
51 : //#define OBJECT_CLIENT_OLE 0x82 // a Ole-Link
52 : //#define OBJECT_CLIENT_OLE_CACHE 0x83 // a Ole-Link with SvEmbeddedObject
53 : #define OBJECT_CLIENT_FILE 0x90
54 : #define OBJECT_CLIENT_GRF 0x91
55 : #define OBJECT_CLIENT_OLE 0x92 // embedded link
56 :
57 : enum sfxlink {
58 : // Ole2 compatibel and persistent
59 : LINKUPDATE_ALWAYS = 1,
60 : LINKUPDATE_ONCALL = 3,
61 :
62 : LINKUPDATE_END // dummy!
63 : };
64 :
65 : struct BaseLink_Impl;
66 :
67 : class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
68 : {
69 : private:
70 : friend class LinkManager;
71 : friend class SvLinkSource;
72 :
73 : SvLinkSourceRef xObj;
74 : OUString aLinkName;
75 : BaseLink_Impl* pImpl;
76 : sal_uInt16 nObjType;
77 : bool bVisible : 1;
78 : bool bSynchron : 1;
79 : bool bUseCache : 1; // for Graphics Links!
80 : bool bWasLastEditOK : 1;
81 :
82 : DECL_LINK( EndEditHdl, OUString* );
83 :
84 : bool ExecuteEdit( const OUString& _rNewName );
85 :
86 : protected:
87 : void SetObjType( sal_uInt16 );
88 :
89 : // Set LinkSourceName without action
90 : void SetName( const OUString & rLn );
91 :
92 : ImplBaseLinkData* pImplData;
93 :
94 : bool m_bIsReadOnly;
95 : com::sun::star::uno::Reference<com::sun::star::io::XInputStream>
96 : m_xInputStreamToLoadFrom;
97 :
98 : SvBaseLink();
99 : SvBaseLink( sal_uInt16 nLinkType, sal_uIntPtr nContentType = FORMAT_STRING );
100 : virtual ~SvBaseLink();
101 :
102 : void _GetRealObject( bool bConnect = true );
103 :
104 6 : SvLinkSource* GetRealObject()
105 : {
106 6 : if( !xObj.Is() )
107 6 : _GetRealObject();
108 6 : return xObj;
109 : }
110 :
111 : public:
112 : TYPEINFO();
113 :
114 : virtual void Closed();
115 : SvBaseLink( const OUString& rNm, sal_uInt16 nObjectType,
116 : SvLinkSource* );
117 :
118 1004 : sal_uInt16 GetObjType() const { return nObjType; }
119 :
120 : void SetObj( SvLinkSource * pObj );
121 196 : SvLinkSource* GetObj() const { return xObj; }
122 :
123 : void SetLinkSourceName( const OUString & rName );
124 598 : OUString GetLinkSourceName() const { return aLinkName;}
125 :
126 : enum UpdateResult {
127 : SUCCESS = 0,
128 : ERROR_GENERAL = 1
129 : };
130 :
131 : virtual UpdateResult DataChanged(
132 : const OUString & rMimeType, const ::com::sun::star::uno::Any & rValue );
133 :
134 : void SetUpdateMode( sal_uInt16 );
135 : sal_uInt16 GetUpdateMode() const;
136 : sal_uIntPtr GetContentType() const;
137 : bool SetContentType( sal_uIntPtr nType );
138 :
139 : LinkManager* GetLinkManager();
140 : const LinkManager* GetLinkManager() const;
141 : void SetLinkManager( LinkManager* _pMgr );
142 :
143 : bool Update();
144 : void Disconnect();
145 :
146 : // Link impl: DECL_LINK( MyEndDialogHdl, SvBaseLink* ); <= param is this
147 : virtual void Edit( vcl::Window*, const Link& rEndEditHdl );
148 :
149 : // should the link appear in the dialog? (to the left in the link in the...)
150 0 : bool IsVisible() const { return bVisible; }
151 34 : void SetVisible( bool bFlag ) { bVisible = bFlag; }
152 : // should the Link be loaded synchronous or asynchronous?
153 48 : bool IsSynchron() const { return bSynchron; }
154 16 : void SetSynchron( bool bFlag ) { bSynchron = bFlag; }
155 :
156 : bool IsUseCache() const { return bUseCache; }
157 0 : void SetUseCache( bool bFlag ) { bUseCache = bFlag; }
158 :
159 0 : void setStreamToLoadFrom(
160 : const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,
161 : bool bIsReadOnly )
162 0 : { m_xInputStreamToLoadFrom = xInputStream;
163 0 : m_bIsReadOnly = bIsReadOnly; }
164 : // #i88291#
165 : void clearStreamToLoadFrom();
166 :
167 0 : inline bool WasLastEditOK() const { return bWasLastEditOK; }
168 : FileDialogHelper & GetInsertFileDialog(const OUString& rFactory) const;
169 : };
170 :
171 : typedef tools::SvRef<SvBaseLink> SvBaseLinkRef;
172 :
173 : }
174 :
175 : #endif
176 :
177 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|