1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
31 namespace com::sun::star::uno
36 namespace com::sun::star::io
{ class XInputStream
; }
38 enum class SfxLinkUpdateMode
{
40 // Ole2 compatible and persistent
48 struct ImplBaseLinkData
;
50 class FileDialogHelper
;
52 enum class SvBaseLinkObjectType
{
55 ClientSo
= 0x80, // a Link
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 class SFX2_DLLPUBLIC SvBaseLink
: public SvRefBase
75 friend class LinkManager
;
76 friend class SvLinkSource
;
78 Link
<SvBaseLink
&,void> m_aEndEditLink
;
79 LinkManager
* m_pLinkMgr
;
80 weld::Window
* m_pParentWin
;
81 std::unique_ptr
<FileDialogHelper
>
85 std::unique_ptr
<ImplBaseLinkData
> pImplData
;
86 SvBaseLinkObjectType mnObjType
;
89 bool bWasLastEditOK
: 1;
90 bool m_bIsConnect
: 1;
92 css::uno::Reference
<css::io::XInputStream
>
93 m_xInputStreamToLoadFrom
;
95 DECL_DLLPRIVATE_LINK( EndEditHdl
, const OUString
&, void );
97 bool ExecuteEdit( const OUString
& _rNewName
);
100 void SetObjType( SvBaseLinkObjectType
);
102 // Set LinkSourceName without action
103 void SetName( const OUString
& rLn
);
106 SvBaseLink( SfxLinkUpdateMode nLinkType
, SotClipboardFormatId nContentType
);
107 virtual ~SvBaseLink() override
;
109 void GetRealObject_( bool bConnect
= true );
111 SvLinkSource
* GetRealObject()
120 virtual void Closed();
123 SvBaseLink( const OUString
& rNm
, SvBaseLinkObjectType nObjectType
,
127 SvBaseLinkObjectType
GetObjType() const { return mnObjType
; }
129 void SetObj( SvLinkSource
* pObj
);
130 SvLinkSource
* GetObj() const { return xObj
.get(); }
132 void SetLinkSourceName( const OUString
& rName
);
133 const OUString
& GetLinkSourceName() const { return aLinkName
;}
140 virtual UpdateResult
DataChanged(
141 const OUString
& rMimeType
, const css::uno::Any
& rValue
);
143 void SetUpdateMode( SfxLinkUpdateMode
);
144 SfxLinkUpdateMode
GetUpdateMode() const;
145 SotClipboardFormatId
GetContentType() const;
146 void SetContentType( SotClipboardFormatId nType
);
148 LinkManager
* GetLinkManager();
149 const LinkManager
* GetLinkManager() const;
150 void SetLinkManager( LinkManager
* _pMgr
);
155 virtual void Edit(weld::Window
*, const Link
<SvBaseLink
&,void>& rEndEditHdl
);
157 // should the link appear in the dialog? (to the left in the link in the...)
158 bool IsVisible() const { return bVisible
; }
159 void SetVisible( bool bFlag
) { bVisible
= bFlag
; }
160 // should the Link be loaded synchronous or asynchronous?
161 bool IsSynchron() const { return bSynchron
; }
162 void SetSynchron( bool bFlag
) { bSynchron
= bFlag
; }
164 void setStreamToLoadFrom(
165 const css::uno::Reference
<css::io::XInputStream
>& xInputStream
,
167 { m_xInputStreamToLoadFrom
= xInputStream
;
168 m_bIsReadOnly
= bIsReadOnly
; }
170 void clearStreamToLoadFrom();
172 bool WasLastEditOK() const { return bWasLastEditOK
; }
173 FileDialogHelper
& GetInsertFileDialog(const OUString
& rFactory
);
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */