Bump version to 21.06.18.1
[LibreOffice.git] / include / sfx2 / lnkbase.hxx
blob332702b8893fcfefcb9aee073e022ed729be5add
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 .
20 #pragma once
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::sun::star::uno
33 class Any;
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 enum class SvBaseLinkObjectType {
53 Internal = 0x00,
54 DdeExternal = 0x02,
55 ClientSo = 0x80, // a Link
56 ClientDde = 0x81,
57 ClientFile = 0x90,
58 ClientGraphic = 0x91,
59 ClientOle = 0x92 // embedded link
62 constexpr bool isClientType(SvBaseLinkObjectType t)
64 return static_cast<int>(t) & static_cast<int>(SvBaseLinkObjectType::ClientSo);
66 constexpr bool isClientFileType(SvBaseLinkObjectType t)
68 auto check = static_cast<int>(SvBaseLinkObjectType::ClientFile);
69 return (static_cast<int>(t) & check) == check;
72 struct BaseLink_Impl;
74 class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
76 private:
77 friend class LinkManager;
78 friend class SvLinkSource;
80 SvLinkSourceRef xObj;
81 OUString aLinkName;
82 std::unique_ptr<BaseLink_Impl> pImpl;
83 SvBaseLinkObjectType mnObjType;
84 bool bVisible : 1;
85 bool bSynchron : 1;
86 bool bWasLastEditOK : 1;
88 DECL_LINK( EndEditHdl, const OUString&, void );
90 bool ExecuteEdit( const OUString& _rNewName );
92 protected:
93 void SetObjType( SvBaseLinkObjectType );
95 // Set LinkSourceName without action
96 void SetName( const OUString & rLn );
98 std::unique_ptr<ImplBaseLinkData> pImplData;
100 bool m_bIsReadOnly;
101 css::uno::Reference<css::io::XInputStream>
102 m_xInputStreamToLoadFrom;
104 SvBaseLink();
105 SvBaseLink( SfxLinkUpdateMode nLinkType, SotClipboardFormatId nContentType );
106 virtual ~SvBaseLink() override;
108 void GetRealObject_( bool bConnect = true );
110 SvLinkSource* GetRealObject()
112 if( !xObj.is() )
113 GetRealObject_();
114 return xObj.get();
117 public:
119 virtual void Closed();
121 #if defined(_WIN32)
122 SvBaseLink( const OUString& rNm, SvBaseLinkObjectType nObjectType,
123 SvLinkSource* );
124 #endif
126 SvBaseLinkObjectType GetObjType() const { return mnObjType; }
128 void SetObj( SvLinkSource * pObj );
129 SvLinkSource* GetObj() const { return xObj.get(); }
131 void SetLinkSourceName( const OUString & rName );
132 const OUString& GetLinkSourceName() const { return aLinkName;}
134 enum UpdateResult {
135 SUCCESS = 0,
136 ERROR_GENERAL = 1
139 virtual UpdateResult DataChanged(
140 const OUString & rMimeType, const css::uno::Any & rValue );
142 void SetUpdateMode( SfxLinkUpdateMode );
143 SfxLinkUpdateMode GetUpdateMode() const;
144 SotClipboardFormatId GetContentType() const;
145 void SetContentType( SotClipboardFormatId nType );
147 LinkManager* GetLinkManager();
148 const LinkManager* GetLinkManager() const;
149 void SetLinkManager( LinkManager* _pMgr );
151 bool Update();
152 void Disconnect();
154 virtual void Edit(weld::Window*, const Link<SvBaseLink&,void>& rEndEditHdl);
156 // should the link appear in the dialog? (to the left in the link in the...)
157 bool IsVisible() const { return bVisible; }
158 void SetVisible( bool bFlag ) { bVisible = bFlag; }
159 // should the Link be loaded synchronous or asynchronous?
160 bool IsSynchron() const { return bSynchron; }
161 void SetSynchron( bool bFlag ) { bSynchron = bFlag; }
163 void setStreamToLoadFrom(
164 const css::uno::Reference<css::io::XInputStream>& xInputStream,
165 bool bIsReadOnly )
166 { m_xInputStreamToLoadFrom = xInputStream;
167 m_bIsReadOnly = bIsReadOnly; }
168 // #i88291#
169 void clearStreamToLoadFrom();
171 bool WasLastEditOK() const { return bWasLastEditOK; }
172 FileDialogHelper & GetInsertFileDialog(const OUString& rFactory) const;
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */