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 bInSwapIn :1;
43 
44  bool bChgTwipSize :1;
45  bool bFrameInPaint :1;
46  bool bScaleImageMap :1;
47 
48  std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
50  css::uno::Reference<css::io::XInputStream> mxInputStream;
52 
53  SwGrfNode( const SwNodeIndex& rWhere,
54  const OUString& rGrfName, const OUString& rFltName,
55  const Graphic* pGraphic,
56  SwGrfFormatColl* pGrfColl,
57  SwAttrSet const * pAutoAttr );
59  SwGrfNode( const SwNodeIndex& rWhere,
60  const OUString& rGrfName, const OUString& rFltName,
61  SwGrfFormatColl* pGrfColl,
62  SwAttrSet const * pAutoAttr );
63  SwGrfNode( const SwNodeIndex& rWhere,
64  const GraphicObject& rGrfObj,
65  SwGrfFormatColl* pGrfColl,
66  SwAttrSet const * pAutoAttr );
67 
68  void InsertLink( const OUString& rGrfName, const OUString& rFltName );
69 
70  DECL_LINK( SwapGraphic, const GraphicObject*, SvStream* );
71  DECL_STATIC_LINK( SwGrfNode, SwapReplacement, const GraphicObject*, SvStream* );
72 
75  void onGraphicChanged();
76 
77 public:
78  virtual ~SwGrfNode() override;
79  const Graphic& GetGrf(bool bWait = false) const;
80  const GraphicObject& GetGrfObj(bool bWait = false) const;
81  const GraphicObject* GetReplacementGrfObj() const;
82 
84  void SetGraphic(const Graphic& rGraphic);
85 
87  void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData, OutputDevice* pFirstFrameOutDev)
88  { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pFirstFrameOutDev); }
89  void StopGraphicAnimation(OutputDevice* pOut, long nExtraData) { maGrfObj.StopAnimation(pOut, nExtraData); }
90 
91  virtual Size GetTwipSize() const override;
92  void SetTwipSize( const Size& rSz );
93 
94  bool IsTransparent() const;
95 
96  bool IsAnimated() const { return maGrfObj.IsAnimated(); }
97 
98  bool IsChgTwipSize() const { return bChgTwipSize; }
99  void SetChgTwipSize( bool b)
100  {
101  bChgTwipSize = b;
102  }
103 
104  bool IsFrameInPaint() const { return bFrameInPaint; }
105  void SetFrameInPaint( bool b ) { bFrameInPaint = b; }
106 
107  bool IsScaleImageMap() const { return bScaleImageMap; }
108  void SetScaleImageMap( bool b ) { bScaleImageMap = b; }
109 
111  virtual SwContentNode* MakeCopy(SwDoc*, const SwNodeIndex&, bool bNewFrames) const override;
112 
115  bool ReRead( const OUString& rGrfName, const OUString& rFltName,
116  const Graphic* pGraphic = nullptr,
117  bool bModify = true );
118 private:
120  bool SwapIn( bool bWaitForData = false );
121 
122 public:
123  bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); }
124 
126  virtual bool SavePersistentData() override;
127  virtual bool RestorePersistentData() override;
128 
130  bool IsGrfLink() const { return refLink.is(); }
131  bool IsLinkedFile() const;
132  bool IsLinkedDDE() const;
133  const tools::SvRef<sfx2::SvBaseLink>& GetLink() const { return refLink; }
134  bool GetFileFilterNms( OUString* pFileNm, OUString* pFilterNm ) const;
135  void ReleaseLink();
136 
139  void ScaleImageMap();
140 
142  GraphicAttr& GetGraphicAttr( GraphicAttr&, const SwFrame* pFrame ) const;
143 
144  std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer() { return mpThreadConsumer;}
145  bool IsLinkedInputStreamReady() const { return mbLinkedInputStreamReady;}
146  void TriggerAsyncRetrieveInputStream();
147  void ApplyInputStream(
148  const css::uno::Reference<css::io::XInputStream>& xInputStream,
149  const bool bIsStreamReadOnly );
150  void UpdateLinkWithInputStream();
151  bool IsAsyncRetrieveInputStreamPossible() const;
152 };
153 
154 // Inline methods from Node.hxx - it is only now that we know TextNode!!
156 {
157  return SwNodeType::Grf == m_nNodeType ? static_cast<SwGrfNode*>(this) : nullptr;
158 }
159 
160 inline const SwGrfNode *SwNode::GetGrfNode() const
161 {
162  return SwNodeType::Grf == m_nNodeType ? static_cast<const SwGrfNode*>(this) : nullptr;
163 }
164 
165 inline bool SwGrfNode::IsLinkedFile() const
166 {
167  return refLink.is() && OBJECT_CLIENT_GRF == refLink->GetObjType();
168 }
169 
170 inline bool SwGrfNode::IsLinkedDDE() const
171 {
172  return refLink.is() && OBJECT_CLIENT_DDE == refLink->GetObjType();
173 }
174 
175 #endif
176 
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool is() const
Base class of the Writer layout elements.
Definition: frame.hxx:295
std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer
Definition: ndgrf.hxx:48
bool HasEmbeddedStreamName() const
Definition: ndgrf.hxx:123
const tools::SvRef< sfx2::SvBaseLink > & GetLink() const
Definition: ndgrf.hxx:133
bool StartAnimation(OutputDevice *pOut, const Point &rPt, const Size &rSz, long nExtraData=0, OutputDevice *pFirstFrameOutDev=nullptr)
virtual Size GetTwipSize() const =0
std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > GetThreadConsumer()
Definition: ndgrf.hxx:144
bool IsFrameInPaint() const
Definition: ndgrf.hxx:104
Definition: doc.hxx:185
bool IsLinkedFile() const
Definition: ndgrf.hxx:165
tools::SvRef< sfx2::SvBaseLink > refLink
If graphics only as link then pointer is set.
Definition: ndgrf.hxx:40
void StopAnimation(OutputDevice *pOut=nullptr, long nExtraData=0)
Size nGrfSize
Definition: ndgrf.hxx:41
bool IsLinkedInputStreamReady() const
Definition: ndgrf.hxx:145
#define OBJECT_CLIENT_GRF
void SetChgTwipSize(bool b)
Definition: ndgrf.hxx:99
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:87
bool mbLinkedInputStreamReady
Definition: ndgrf.hxx:49
css::uno::Reference< css::io::XInputStream > mxInputStream
Definition: ndgrf.hxx:50
bool IsAnimated() const
Definition: ndgrf.hxx:96
bool IsChgTwipSize() const
Definition: ndgrf.hxx:98
bool HasUserData() const
virtual SwContentNode * MakeCopy(SwDoc *, const SwNodeIndex &, bool bNewFrames) const =0
void StopGraphicAnimation(OutputDevice *pOut, long nExtraData)
Definition: ndgrf.hxx:89
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:107
virtual bool RestorePersistentData()
Dummies for loading/saving of persistent data when working with graphics and OLE objects.
Definition: ndnotxt.cxx:77
void SetFrameInPaint(bool b)
Definition: ndgrf.hxx:105
virtual bool SavePersistentData()
Definition: ndnotxt.cxx:82
bool IsLinkedDDE() const
Definition: ndgrf.hxx:170
void SetScaleImageMap(bool b)
Definition: ndgrf.hxx:108
#define OBJECT_CLIENT_DDE
bool mbIsStreamReadOnly
Definition: ndgrf.hxx:51
bool IsGrfLink() const
Query link-data.
Definition: ndgrf.hxx:130
std::unique_ptr< GraphicObject > mpReplacementGraphic
Definition: ndgrf.hxx:39
SwNodeType const m_nNodeType
Definition: node.hxx:84
bool IsAnimated() const
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:155