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
;
74 class SFX2_DLLPUBLIC SvBaseLink
: public SvRefBase
77 friend class LinkManager
;
78 friend class SvLinkSource
;
82 std::unique_ptr
<BaseLink_Impl
> pImpl
;
83 SvBaseLinkObjectType mnObjType
;
86 bool bWasLastEditOK
: 1;
88 DECL_LINK( EndEditHdl
, const OUString
&, void );
90 bool ExecuteEdit( const OUString
& _rNewName
);
93 void SetObjType( SvBaseLinkObjectType
);
95 // Set LinkSourceName without action
96 void SetName( const OUString
& rLn
);
98 std::unique_ptr
<ImplBaseLinkData
> pImplData
;
101 css::uno::Reference
<css::io::XInputStream
>
102 m_xInputStreamToLoadFrom
;
105 SvBaseLink( SfxLinkUpdateMode nLinkType
, SotClipboardFormatId nContentType
);
106 virtual ~SvBaseLink() override
;
108 void GetRealObject_( bool bConnect
= true );
110 SvLinkSource
* GetRealObject()
119 virtual void Closed();
122 SvBaseLink( const OUString
& rNm
, SvBaseLinkObjectType nObjectType
,
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
;}
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
);
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
,
166 { m_xInputStreamToLoadFrom
= xInputStream
;
167 m_bIsReadOnly
= bIsReadOnly
; }
169 void clearStreamToLoadFrom();
171 bool WasLastEditOK() const { return bWasLastEditOK
; }
172 FileDialogHelper
& GetInsertFileDialog(const OUString
& rFactory
) const;
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */