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 #ifndef INCLUDED_SW_INC_NDNOTXT_HXX
20 #define INCLUDED_SW_INC_NDNOTXT_HXX
21 
22 #include <memory>
23 #include "node.hxx"
24 
25 class Size;
26 namespace tools { class PolyPolygon; }
27 
28 // SwNoTextNode
29 
30 class SW_DLLPUBLIC SwNoTextNode : public SwContentNode
31 {
32     friend class SwNodes;
33     friend class SwNoTextFrame;
34 
35     std::unique_ptr<tools::PolyPolygon> m_pContour;
36     bool m_bAutomaticContour : 1; // automatic contour polygon, not manipulated
37     bool m_bContourMapModeValid : 1; // contour map mode is not the graphics's
38                                    // preferred map mode, but either
39                                       // MM100 or pixel
40     bool m_bPixelContour : 1;     // contour map mode is invalid and pixel.
41 
42     // Creates for all derivations an AttrSet with ranges for frame- and
43     // graphics-attributes (only called by SwContentNode).
44     virtual void NewAttrSet( SwAttrPool& ) override;
45 
46     SwNoTextNode( const SwNoTextNode& ) = delete;
47     SwNoTextNode &operator=( const SwNoTextNode& ) = delete;
48 
49 protected:
50     SwNoTextNode( const SwNodeIndex &rWhere, const SwNodeType nNdType,
51                 SwGrfFormatColl *pGrColl, SwAttrSet const * pAutoAttr );
52 
53 public:
54     virtual ~SwNoTextNode() override;
55 
56     virtual SwContentFrame *MakeFrame( SwFrame* ) override;
57 
GetGrfColl() const58     SwGrfFormatColl *GetGrfColl() const { return const_cast<SwGrfFormatColl*>(static_cast<const SwGrfFormatColl*>(GetRegisteredIn())); }
59 
60     virtual Size GetTwipSize() const = 0;
61 
62     virtual bool SavePersistentData();
63     virtual bool RestorePersistentData();
64 
65     OUString GetTitle() const;
66     void SetTitle( const OUString& rTitle );
67     OUString GetDescription() const;
68     void SetDescription( const OUString& rDescription );
69 
70     void               SetContour( const tools::PolyPolygon *pPoly,
71                                    bool bAutomatic = false );
72     const tools::PolyPolygon *HasContour() const;
HasContour_() const73     bool               HasContour_() const { return m_pContour!=nullptr; };
74     void               GetContour( tools::PolyPolygon &rPoly ) const;
75     void               CreateContour();
76 
SetAutomaticContour(bool bSet)77     void               SetAutomaticContour( bool bSet ) { m_bAutomaticContour = bSet; }
HasAutomaticContour() const78     bool               HasAutomaticContour() const { return m_bAutomaticContour; }
79 
80     // set either a MM100 or pixel contour
81     void               SetContourAPI( const tools::PolyPolygon *pPoly );
82 
83     // get either a MM100 or pixel contour, return false if no contour is set.
84     bool               GetContourAPI( tools::PolyPolygon &rPoly ) const;
85 
SetPixelContour(bool bSet)86     void               SetPixelContour( bool bSet ) { m_bPixelContour = bSet; }
87     bool               IsPixelContour() const;
88 
IsContourMapModeValid() const89     bool               IsContourMapModeValid() const { return m_bContourMapModeValid; }
90 
91     // Obtains the graphic with SwapIn for GrfNode via GetData for OLE.
92     Graphic GetGraphic() const;
93 };
94 
95 // Inline methods from Node.hxx - we know TextNode only here!!
GetNoTextNode()96 inline SwNoTextNode *SwNode::GetNoTextNode()
97 {
98     return SwNodeType::NoTextMask & m_nNodeType ? static_cast<SwNoTextNode*>(this) : nullptr;
99 }
GetNoTextNode() const100 inline const SwNoTextNode *SwNode::GetNoTextNode() const
101 {
102     return SwNodeType::NoTextMask & m_nNodeType ? static_cast<const SwNoTextNode*>(this) : nullptr;
103 }
104 
105 #endif // INCLUDED_SW_INC_NDNOTXT_HXX
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
108