Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / include / sfx2 / lnkbase.hxx
blob535a6bcf9292106c4ede438ed036c84fba281270
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_LNKBASE_HXX
20 #define INCLUDED_SFX2_LNKBASE_HXX
22 #include <rtl/ustring.hxx>
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <sfx2/linksrc.hxx>
26 #include <sot/formats.hxx>
27 #include <tools/ref.hxx>
28 #include <tools/link.hxx>
29 #include <memory>
31 namespace com { namespace sun { namespace star { namespace uno
33 class Any;
34 }}}}
36 namespace com::sun::star::io { class XInputStream; }
38 enum class SfxLinkUpdateMode {
39 NONE = 0,
40 // Ole2 compatible and persistent
41 ALWAYS = 1,
42 ONCALL = 3
45 namespace sfx2
48 struct ImplBaseLinkData;
49 class LinkManager;
50 class FileDialogHelper;
52 #ifndef OBJECT_DDE_EXTERN
53 #define OBJECT_INTERN 0x00
54 //#define OBJECT_SO_EXTERN 0x01
55 #define OBJECT_DDE_EXTERN 0x02
56 #endif
58 #define OBJECT_CLIENT_SO 0x80 // a Link
59 #define OBJECT_CLIENT_DDE 0x81
60 //#define OBJECT_CLIENT_OLE 0x82 // an Ole-Link
61 //#define OBJECT_CLIENT_OLE_CACHE 0x83 // an Ole-Link with SvEmbeddedObject
62 #define OBJECT_CLIENT_FILE 0x90
63 #define OBJECT_CLIENT_GRF 0x91
64 #define OBJECT_CLIENT_OLE 0x92 // embedded link
66 struct BaseLink_Impl;
68 class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
70 private:
71 friend class LinkManager;
72 friend class SvLinkSource;
74 SvLinkSourceRef xObj;
75 OUString aLinkName;
76 std::unique_ptr<BaseLink_Impl> pImpl;
77 sal_uInt16 nObjType;
78 bool bVisible : 1;
79 bool bSynchron : 1;
80 bool bWasLastEditOK : 1;
82 DECL_LINK( EndEditHdl, const OUString&, void );
84 bool ExecuteEdit( const OUString& _rNewName );
86 protected:
87 void SetObjType( sal_uInt16 );
89 // Set LinkSourceName without action
90 void SetName( const OUString & rLn );
92 std::unique_ptr<ImplBaseLinkData> pImplData;
94 bool m_bIsReadOnly;
95 css::uno::Reference<css::io::XInputStream>
96 m_xInputStreamToLoadFrom;
98 SvBaseLink();
99 SvBaseLink( SfxLinkUpdateMode nLinkType, SotClipboardFormatId nContentType );
100 virtual ~SvBaseLink() override;
102 void GetRealObject_( bool bConnect = true );
104 SvLinkSource* GetRealObject()
106 if( !xObj.is() )
107 GetRealObject_();
108 return xObj.get();
111 public:
113 virtual void Closed();
115 #if defined(_WIN32)
116 SvBaseLink( const OUString& rNm, sal_uInt16 nObjectType,
117 SvLinkSource* );
118 #endif
120 sal_uInt16 GetObjType() const { return nObjType; }
122 void SetObj( SvLinkSource * pObj );
123 SvLinkSource* GetObj() const { return xObj.get(); }
125 void SetLinkSourceName( const OUString & rName );
126 const OUString& GetLinkSourceName() const { return aLinkName;}
128 enum UpdateResult {
129 SUCCESS = 0,
130 ERROR_GENERAL = 1
133 virtual UpdateResult DataChanged(
134 const OUString & rMimeType, const css::uno::Any & rValue );
136 void SetUpdateMode( SfxLinkUpdateMode );
137 SfxLinkUpdateMode GetUpdateMode() const;
138 SotClipboardFormatId GetContentType() const;
139 void SetContentType( SotClipboardFormatId nType );
141 LinkManager* GetLinkManager();
142 const LinkManager* GetLinkManager() const;
143 void SetLinkManager( LinkManager* _pMgr );
145 bool Update();
146 void Disconnect();
148 virtual void Edit(weld::Window*, const Link<SvBaseLink&,void>& rEndEditHdl);
150 // should the link appear in the dialog? (to the left in the link in the...)
151 bool IsVisible() const { return bVisible; }
152 void SetVisible( bool bFlag ) { bVisible = bFlag; }
153 // should the Link be loaded synchronous or asynchronous?
154 bool IsSynchron() const { return bSynchron; }
155 void SetSynchron( bool bFlag ) { bSynchron = bFlag; }
157 void setStreamToLoadFrom(
158 const css::uno::Reference<css::io::XInputStream>& xInputStream,
159 bool bIsReadOnly )
160 { m_xInputStreamToLoadFrom = xInputStream;
161 m_bIsReadOnly = bIsReadOnly; }
162 // #i88291#
163 void clearStreamToLoadFrom();
165 bool WasLastEditOK() const { return bWasLastEditOK; }
166 FileDialogHelper & GetInsertFileDialog(const OUString& rFactory) const;
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */