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 : enum class SfxLinkUpdateMode {
36 : NONE = 0,
37 : // Ole2 compatible and persistent
38 : ALWAYS = 1,
39 : ONCALL = 3
40 : };
41 :
42 : namespace sfx2
43 : {
44 :
45 : struct ImplBaseLinkData;
46 : class LinkManager;
47 : class SvLinkSource;
48 : class FileDialogHelper;
49 :
50 : #ifndef OBJECT_DDE_EXTERN
51 : #define OBJECT_INTERN 0x00
52 : //#define OBJECT_SO_EXTERN 0x01
53 : #define OBJECT_DDE_EXTERN 0x02
54 : #endif
55 :
56 : #define OBJECT_CLIENT_SO 0x80 // a Link
57 : #define OBJECT_CLIENT_DDE 0x81
58 : //#define OBJECT_CLIENT_OLE 0x82 // a Ole-Link
59 : //#define OBJECT_CLIENT_OLE_CACHE 0x83 // a Ole-Link with SvEmbeddedObject
60 : #define OBJECT_CLIENT_FILE 0x90
61 : #define OBJECT_CLIENT_GRF 0x91
62 : #define OBJECT_CLIENT_OLE 0x92 // embedded link
63 :
64 : struct BaseLink_Impl;
65 :
66 : class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
67 : {
68 : private:
69 : friend class LinkManager;
70 : friend class SvLinkSource;
71 :
72 : SvLinkSourceRef xObj;
73 : OUString aLinkName;
74 : BaseLink_Impl* pImpl;
75 : sal_uInt16 nObjType;
76 : bool bVisible : 1;
77 : bool bSynchron : 1;
78 : bool bUseCache : 1; // for Graphics Links!
79 : bool bWasLastEditOK : 1;
80 :
81 : DECL_LINK( EndEditHdl, OUString* );
82 :
83 : bool ExecuteEdit( const OUString& _rNewName );
84 :
85 : protected:
86 : void SetObjType( sal_uInt16 );
87 :
88 : // Set LinkSourceName without action
89 : void SetName( const OUString & rLn );
90 :
91 : ImplBaseLinkData* pImplData;
92 :
93 : bool m_bIsReadOnly;
94 : com::sun::star::uno::Reference<com::sun::star::io::XInputStream>
95 : m_xInputStreamToLoadFrom;
96 :
97 : SvBaseLink();
98 : SvBaseLink( SfxLinkUpdateMode nLinkType, SotClipboardFormatId nContentType = SotClipboardFormatId::STRING );
99 : virtual ~SvBaseLink();
100 :
101 : void _GetRealObject( bool bConnect = true );
102 :
103 31 : SvLinkSource* GetRealObject()
104 : {
105 31 : if( !xObj.Is() )
106 31 : _GetRealObject();
107 31 : return xObj;
108 : }
109 :
110 : public:
111 : TYPEINFO();
112 :
113 : virtual void Closed();
114 :
115 : #if defined WNT
116 : SvBaseLink( const OUString& rNm, sal_uInt16 nObjectType,
117 : SvLinkSource* );
118 : #endif
119 :
120 539 : sal_uInt16 GetObjType() const { return nObjType; }
121 :
122 : void SetObj( SvLinkSource * pObj );
123 278 : SvLinkSource* GetObj() const { return xObj; }
124 :
125 : void SetLinkSourceName( const OUString & rName );
126 145 : OUString GetLinkSourceName() const { return aLinkName;}
127 :
128 : enum UpdateResult {
129 : SUCCESS = 0,
130 : ERROR_GENERAL = 1
131 : };
132 :
133 : virtual UpdateResult DataChanged(
134 : const OUString & rMimeType, const ::com::sun::star::uno::Any & rValue );
135 :
136 : void SetUpdateMode( SfxLinkUpdateMode );
137 : SfxLinkUpdateMode GetUpdateMode() const;
138 : SotClipboardFormatId GetContentType() const;
139 : bool SetContentType( SotClipboardFormatId nType );
140 :
141 : LinkManager* GetLinkManager();
142 : const LinkManager* GetLinkManager() const;
143 : void SetLinkManager( LinkManager* _pMgr );
144 :
145 : bool Update();
146 : void Disconnect();
147 :
148 : // Link impl: DECL_LINK( MyEndDialogHdl, SvBaseLink* ); <= param is this
149 : virtual void Edit( vcl::Window*, const Link<>& rEndEditHdl );
150 :
151 : // should the link appear in the dialog? (to the left in the link in the...)
152 3 : bool IsVisible() const { return bVisible; }
153 18 : void SetVisible( bool bFlag ) { bVisible = bFlag; }
154 : // should the Link be loaded synchronous or asynchronous?
155 66 : bool IsSynchron() const { return bSynchron; }
156 29 : void SetSynchron( bool bFlag ) { bSynchron = bFlag; }
157 :
158 : bool IsUseCache() const { return bUseCache; }
159 0 : void SetUseCache( bool bFlag ) { bUseCache = bFlag; }
160 :
161 0 : void setStreamToLoadFrom(
162 : const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,
163 : bool bIsReadOnly )
164 0 : { m_xInputStreamToLoadFrom = xInputStream;
165 0 : m_bIsReadOnly = bIsReadOnly; }
166 : // #i88291#
167 : void clearStreamToLoadFrom();
168 :
169 0 : inline bool WasLastEditOK() const { return bWasLastEditOK; }
170 : FileDialogHelper & GetInsertFileDialog(const OUString& rFactory) const;
171 : };
172 :
173 : typedef tools::SvRef<SvBaseLink> SvBaseLinkRef;
174 :
175 : }
176 :
177 : #endif
178 :
179 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|