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 
30 class SwGrfFormatColl;
31 class 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 
45  bool mbChangeTwipSize :1;
46  bool mbFrameInPaint :1;
47  bool mbScaleImageMap :1;
48 
49  std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
51  css::uno::Reference<css::io::XInputStream> mxInputStream;
53 
54  SwGrfNode( const SwNodeIndex& rWhere,
55  const OUString& rGrfName, const OUString& rFltName,
56  const Graphic* pGraphic,
57  SwGrfFormatColl* pGrfColl,
58  SwAttrSet const * pAutoAttr );
60  SwGrfNode( const SwNodeIndex& rWhere,
61  const OUString& rGrfName, const OUString& rFltName,
62  SwGrfFormatColl* pGrfColl,
63  SwAttrSet const * pAutoAttr );
64  SwGrfNode( const SwNodeIndex& rWhere,
65  const GraphicObject& rGrfObj,
66  SwGrfFormatColl* pGrfColl,
67  SwAttrSet const * pAutoAttr );
68 
69  void InsertLink( const OUString& rGrfName, const OUString& rFltName );
70 
73  void onGraphicChanged();
74 
75 public:
76  virtual ~SwGrfNode() override;
77  const Graphic& GetGrf(bool bWait = false) const;
78  const GraphicObject& GetGrfObj(bool bWait = false) const;
79  const GraphicObject* GetReplacementGrfObj() const;
80 
82  void SetGraphic(const Graphic& rGraphic);
83 
85  void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData, OutputDevice* pFirstFrameOutDev)
86  { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pFirstFrameOutDev); }
87  void StopGraphicAnimation(OutputDevice* pOut, long nExtraData) { maGrfObj.StopAnimation(pOut, nExtraData); }
88 
89  virtual Size GetTwipSize() const override;
90  void SetTwipSize( const Size& rSz );
91 
92  bool IsTransparent() const;
93 
94  bool IsAnimated() const { return maGrfObj.IsAnimated(); }
95 
96  bool IsChgTwipSize() const { return mbChangeTwipSize; }
97  void SetChgTwipSize( bool b)
98  {
99  mbChangeTwipSize = b;
100  }
101 
102  bool IsFrameInPaint() const { return mbFrameInPaint; }
103  void SetFrameInPaint( bool b ) { mbFrameInPaint = b; }
104 
105  bool IsScaleImageMap() const { return mbScaleImageMap; }
106  void SetScaleImageMap( bool b ) { mbScaleImageMap = b; }
107 
109  virtual SwContentNode* MakeCopy(SwDoc*, const SwNodeIndex&, bool bNewFrames) const override;
110 
113  bool ReRead( const OUString& rGrfName, const OUString& rFltName,
114  const Graphic* pGraphic = nullptr,
115  bool bModify = true );
116 private:
118  bool SwapIn( bool bWaitForData = false );
119 
120 public:
121  bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); }
122 
124  virtual bool SavePersistentData() override;
125  virtual bool RestorePersistentData() override;
126 
128  bool IsGrfLink() const { return mxLink.is(); }
129  bool IsLinkedFile() const;
130  bool IsLinkedDDE() const;
131  const tools::SvRef<sfx2::SvBaseLink>& GetLink() const { return mxLink; }
132  bool GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const;
133  void ReleaseLink();
134 
137  void ScaleImageMap();
138 
140  GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrame* pFrame ) const;
141 
142  std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() const { return mpThreadConsumer;}
143  bool IsLinkedInputStreamReady() const { return mbLinkedInputStreamReady;}
144  void TriggerAsyncRetrieveInputStream();
145  void ApplyInputStream(
146  const css::uno::Reference<css::io::XInputStream>& xInputStream,
147  const bool bIsStreamReadOnly );
148  void UpdateLinkWithInputStream();
149  bool IsAsyncRetrieveInputStreamPossible() const;
150 };
151 
152 // Inline methods from Node.hxx - it is only now that we know TextNode!!
154 {
155  return SwNodeType::Grf == m_nNodeType ? static_cast<SwGrfNode*>(this) : nullptr;
156 }
157 
158 inline const SwGrfNode *SwNode::GetGrfNode() const
159 {
160  return SwNodeType::Grf == m_nNodeType ? static_cast<const SwGrfNode*>(this) : nullptr;
161 }
162 
163 inline bool SwGrfNode::IsLinkedFile() const
164 {
166 }
167 
168 inline bool SwGrfNode::IsLinkedDDE() const
169 {
171 }
172 
173 #endif
174 
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool is() const
Base class of the Writer layout elements.
Definition: frame.hxx:297
std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer
Definition: ndgrf.hxx:49
bool HasEmbeddedStreamName() const
Definition: ndgrf.hxx:121
const tools::SvRef< sfx2::SvBaseLink > & GetLink() const
Definition: ndgrf.hxx:131
tools::SvRef< sfx2::SvBaseLink > mxLink
If graphics only as link then pointer is set.
Definition: ndgrf.hxx:40
bool StartAnimation(OutputDevice *pOut, const Point &rPt, const Size &rSz, long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
virtual Size GetTwipSize() const =0
bool IsFrameInPaint() const
Definition: ndgrf.hxx:102
Definition: doc.hxx:186
bool IsLinkedFile() const
Definition: ndgrf.hxx:163
void StopAnimation(OutputDevice *pOut=nullptr, long nExtraData=0)
bool IsLinkedInputStreamReady() const
Definition: ndgrf.hxx:143
Size mnGrfSize
Definition: ndgrf.hxx:41
void SetChgTwipSize(bool b)
Definition: ndgrf.hxx:97
class to provide creation of a thread to retrieve an input stream given by a URL and to consume the r...
void StartGraphicAnimation(OutputDevice *pOut, const Point &rPt, const Size &rSz, long nExtraData, OutputDevice *pFirstFrameOutDev)
wrappers for non-const calls at GraphicObject
Definition: ndgrf.hxx:85
bool mbLinkedInputStreamReady
Definition: ndgrf.hxx:50
css::uno::Reference< css::io::XInputStream > mxInputStream
Definition: ndgrf.hxx:51
bool IsAnimated() const
Definition: ndgrf.hxx:94
std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() const
Definition: ndgrf.hxx:142
bool IsChgTwipSize() const
Definition: ndgrf.hxx:96
bool HasUserData() const
virtual SwContentNode * MakeCopy(SwDoc *, const SwNodeIndex &, bool bNewFrames) const =0
void StopGraphicAnimation(OutputDevice *pOut, long nExtraData)
Definition: ndgrf.hxx:87
GraphicObject maGrfObj
Definition: ndgrf.hxx:38
Marks a node in the document model.
Definition: ndindex.hxx:31
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool IsScaleImageMap() const
Definition: ndgrf.hxx:105
virtual bool RestorePersistentData()
Dummies for loading/saving of persistent data when working with graphics and OLE objects.
Definition: ndnotxt.cxx:74
SwNodeType m_nNodeType
Definition: node.hxx:84
void SetFrameInPaint(bool b)
Definition: ndgrf.hxx:103
virtual bool SavePersistentData()
Definition: ndnotxt.cxx:79
bool IsLinkedDDE() const
Definition: ndgrf.hxx:168
void SetScaleImageMap(bool b)
Definition: ndgrf.hxx:106
bool mbIsStreamReadOnly
Definition: ndgrf.hxx:52
bool IsGrfLink() const
Query link-data.
Definition: ndgrf.hxx:128
std::unique_ptr< GraphicObject > mpReplacementGraphic
Definition: ndgrf.hxx:39
bool IsAnimated() const
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:153