LibreOffice Module sw (master) 1
ndgrf.hxx
Go to the documentation of this file.
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
20#ifndef INCLUDED_SW_INC_NDGRF_HXX
21#define INCLUDED_SW_INC_NDGRF_HXX
22
23#include <sfx2/lnkbase.hxx>
24#include <vcl/GraphicObject.hxx>
25#include "ndnotxt.hxx"
26#include <memory>
27
29
30class SwGrfFormatColl;
31class SwDoc;
32
33// SwGrfNode
35{
36 friend class SwNodes;
37
39 std::unique_ptr<GraphicObject> mpReplacementGraphic;
42 bool mbInSwapIn :1; // to avoid recursion in SwGrfNode::SwapIn
43 bool mbInBaseLinkSwapIn :1; // to avoid recursion in SwBaseLink::SwapIn
44
48
49 std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
51 css::uno::Reference<css::io::XInputStream> mxInputStream;
53
54 SwGrfNode( SwNode& rWhere,
55 const OUString& rGrfName, const OUString& rFltName,
56 const Graphic* pGraphic,
57 SwGrfFormatColl* pGrfColl,
58 SwAttrSet const * pAutoAttr );
60 SwGrfNode( SwNode& rWhere,
61 std::u16string_view rGrfName, const OUString& rFltName,
62 SwGrfFormatColl* pGrfColl,
63 SwAttrSet const * pAutoAttr );
64
65 void InsertLink( std::u16string_view rGrfName, const OUString& rFltName );
66
69 void onGraphicChanged();
70
71public:
72 virtual ~SwGrfNode() override;
73 const Graphic& GetGrf(bool bWait = false) const;
74 const GraphicObject& GetGrfObj(bool bWait = false) const;
75 const GraphicObject* GetReplacementGrfObj() const;
76
78 void SetGraphic(const Graphic& rGraphic);
79 void TriggerGraphicArrived();
80
82 void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, tools::Long nRendererId, OutputDevice* pFirstFrameOutDev)
83 { maGrfObj.StartAnimation(*pOut, rPt, rSz, nRendererId, pFirstFrameOutDev); }
84 void StopGraphicAnimation(const OutputDevice* pOut, tools::Long nRendererId) { maGrfObj.StopAnimation(pOut, nRendererId); }
85
86 virtual Size GetTwipSize() const override;
87 void SetTwipSize( const Size& rSz );
88
89 bool IsTransparent() const;
90
91 bool IsAnimated() const { return maGrfObj.IsAnimated(); }
92
93 bool IsChgTwipSize() const { return mbChangeTwipSize; }
94 void SetChgTwipSize( bool b)
95 {
96 mbChangeTwipSize = b;
97 }
98
99 bool IsFrameInPaint() const { return mbFrameInPaint; }
100 void SetFrameInPaint( bool b ) { mbFrameInPaint = b; }
101
102 bool IsScaleImageMap() const { return mbScaleImageMap; }
103 void SetScaleImageMap( bool b ) { mbScaleImageMap = b; }
104
106 virtual SwContentNode* MakeCopy(SwDoc&, SwNode&, bool bNewFrames) const override;
107
110 bool ReRead( const OUString& rGrfName, const OUString& rFltName,
111 const Graphic* pGraphic = nullptr,
112 bool bModify = true );
113private:
115 bool SwapIn( bool bWaitForData = false );
116
117public:
118 bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); }
119
121 virtual bool SavePersistentData() override;
122 virtual bool RestorePersistentData() override;
123
125 bool IsGrfLink() const { return mxLink.is(); }
126 bool IsLinkedFile() const;
127 bool IsLinkedDDE() const;
128 const tools::SvRef<sfx2::SvBaseLink>& GetLink() const { return mxLink; }
129 bool GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const;
130 void ReleaseLink();
131
134 void ScaleImageMap();
135
137 GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrame* pFrame ) const;
138
139 std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() const { return mpThreadConsumer;}
140 bool IsLinkedInputStreamReady() const { return mbLinkedInputStreamReady;}
141 void TriggerAsyncRetrieveInputStream();
142 void ApplyInputStream(
143 const css::uno::Reference<css::io::XInputStream>& xInputStream,
144 const bool bIsStreamReadOnly );
145 void UpdateLinkWithInputStream();
146 bool IsAsyncRetrieveInputStreamPossible() const;
147};
148
149// Inline methods from Node.hxx - it is only now that we know TextNode!!
151{
152 return SwNodeType::Grf == m_nNodeType ? static_cast<SwGrfNode*>(this) : nullptr;
153}
154
155inline const SwGrfNode *SwNode::GetGrfNode() const
156{
157 return SwNodeType::Grf == m_nNodeType ? static_cast<const SwGrfNode*>(this) : nullptr;
158}
159
160inline bool SwGrfNode::IsLinkedFile() const
161{
162 return mxLink.is() && sfx2::SvBaseLinkObjectType::ClientGraphic == mxLink->GetObjType();
163}
164
165inline bool SwGrfNode::IsLinkedDDE() const
166{
167 return mxLink.is() && sfx2::SvBaseLinkObjectType::ClientDde == mxLink->GetObjType();
168}
169
170#endif
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void StopAnimation(const OutputDevice *pOut=nullptr, tools::Long nExtraData=0)
bool IsAnimated() const
bool StartAnimation(OutputDevice &rOut, const Point &rPt, const Size &rSz, tools::Long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
bool HasUserData() const
class to provide creation of a thread to retrieve an input stream given by a URL and to consume the r...
virtual SwContentNode * MakeCopy(SwDoc &, SwNode &rWhere, bool bNewFrames) const =0
Definition: doc.hxx:197
Base class of the Writer layout elements.
Definition: frame.hxx:315
std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() const
Definition: ndgrf.hxx:139
void SetChgTwipSize(bool b)
Definition: ndgrf.hxx:94
std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer
Definition: ndgrf.hxx:49
Size mnGrfSize
Definition: ndgrf.hxx:41
bool IsLinkedFile() const
Definition: ndgrf.hxx:160
bool HasEmbeddedStreamName() const
Definition: ndgrf.hxx:118
bool mbInBaseLinkSwapIn
Definition: ndgrf.hxx:43
const tools::SvRef< sfx2::SvBaseLink > & GetLink() const
Definition: ndgrf.hxx:128
GraphicObject maGrfObj
Definition: ndgrf.hxx:38
bool IsLinkedDDE() const
Definition: ndgrf.hxx:165
void SetScaleImageMap(bool b)
Definition: ndgrf.hxx:103
bool mbLinkedInputStreamReady
Definition: ndgrf.hxx:50
bool IsAnimated() const
Definition: ndgrf.hxx:91
bool mbInSwapIn
Definition: ndgrf.hxx:42
bool IsScaleImageMap() const
Definition: ndgrf.hxx:102
void StopGraphicAnimation(const OutputDevice *pOut, tools::Long nRendererId)
Definition: ndgrf.hxx:84
bool mbIsStreamReadOnly
Definition: ndgrf.hxx:52
bool IsGrfLink() const
Query link-data.
Definition: ndgrf.hxx:125
void SetFrameInPaint(bool b)
Definition: ndgrf.hxx:100
css::uno::Reference< css::io::XInputStream > mxInputStream
Definition: ndgrf.hxx:51
bool IsChgTwipSize() const
Definition: ndgrf.hxx:93
bool mbScaleImageMap
Scale image map in SetTwipSize.
Definition: ndgrf.hxx:47
bool IsFrameInPaint() const
Definition: ndgrf.hxx:99
bool IsLinkedInputStreamReady() const
Definition: ndgrf.hxx:140
bool mbChangeTwipSize
Definition: ndgrf.hxx:45
std::unique_ptr< GraphicObject > mpReplacementGraphic
Definition: ndgrf.hxx:39
void StartGraphicAnimation(OutputDevice *pOut, const Point &rPt, const Size &rSz, tools::Long nRendererId, OutputDevice *pFirstFrameOutDev)
wrappers for non-const calls at GraphicObject
Definition: ndgrf.hxx:82
bool mbFrameInPaint
To avoid Start-/EndActions in Paint via SwapIn.
Definition: ndgrf.hxx:46
tools::SvRef< sfx2::SvBaseLink > mxLink
If graphics only as link then pointer is set.
Definition: ndgrf.hxx:40
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:30
virtual bool SavePersistentData()
Definition: ndnotxt.cxx:80
virtual bool RestorePersistentData()
Dummies for loading/saving of persistent data when working with graphics and OLE objects.
Definition: ndnotxt.cxx:75
virtual Size GetTwipSize() const =0
Base class of the Writer document model elements.
Definition: node.hxx:98
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:150
SwNodeType m_nNodeType
Definition: node.hxx:101
bool is() const
long Long
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
oslFileHandle & pOut