Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-flowtext.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors: see git history
6 *
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10#ifndef SEEN_SP_ITEM_FLOWTEXT_H
11#define SEEN_SP_ITEM_FLOWTEXT_H
12
13/*
14 */
15
16#include <2geom/forward.h>
17
20#include "sp-item.h"
21#include "desktop.h"
22
23#include <memory>
24
25namespace Inkscape {
26
27class DrawingGroup;
28
29} // namespace Inkscape
30
31class SPFlowtext final : public SPItem {
32public:
33 SPFlowtext();
34 ~SPFlowtext() override;
35 int tag() const override { return tag_of<decltype(*this)>; }
36
38 void rebuildLayout();
39
43
44 // TODO check if these should return SPRect instead of SPItem
45
46 SPItem *get_frame(SPItem const *after);
47
48 SPItem const *get_frame(SPItem const *after) const;
49
50 std::optional<Geom::Point> getBaselinePoint() const;
51
52 bool has_internal_frame() const;
53
54//semiprivate: (need to be accessed by the C-style functions still)
56 std::unordered_map<unsigned, Inkscape::Text::StyleAttachments> view_style_attachments;
57
59 void _clearFlow(Inkscape::DrawingGroup* in_arena);
60
61 double par_indent;
62
64
67
70
71private:
73 void _buildLayoutInput(SPObject *root, std::unique_ptr<Shape> exclusion_shape,
74 SPObject **pending_line_break_object);
75
78 std::unique_ptr<Shape> _buildExclusionShape() const;
79
80public:
81 void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
82 void release() override;
83
86
87 void set(SPAttr key, const char* value) override;
88 Geom::Affine set_transform(Geom::Affine const& xform) override;
89
90 void update(SPCtx* ctx, unsigned int flags) override;
91 void modified(unsigned int flags) override;
92 void fix_overflow_flowregion(bool inverse);
93
94 Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags) override;
95
96 Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override;
97 void print(SPPrintContext *ctx) override;
98 const char* typeName() const override;
99 const char* displayName() const override;
100 char* description() const override;
101 Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override;
102 void hide(unsigned int key) override;
103 void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override;
104};
105
107
108#endif // SEEN_SP_ITEM_FLOWTEXT_H
109
110/*
111 Local Variables:
112 mode:c++
113 c-file-style:"stroustrup"
114 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
115 indent-tabs-mode:nil
116 fill-column:99
117 End:
118*/
119// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Sequence of subpaths.
Definition pathvector.h:122
Two-dimensional point that doubles as a vector.
Definition point.h:66
SVG drawing item for display.
Storing of snapping preferences.
Generates the layout for either wrapped or non-wrapped text and stores the result.
Definition Layout-TNG.h:144
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
void modified(unsigned int flags) override
std::optional< Geom::Point > getBaselinePoint() const
Get the position of the baseline point for this text object.
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
char * description() const override
void release() override
Inkscape::Text::Layout layout
Definition sp-flowtext.h:55
bool _optimizeScaledText
Definition sp-flowtext.h:63
~SPFlowtext() override
const char * displayName() const override
The item's type name as a translated human string.
std::unique_ptr< Shape > _buildExclusionShape() const
calculates the union of all the <flowregionexclude> children of this flowroot.
void _clearFlow(Inkscape::DrawingGroup *in_arena)
discards the drawing objects representing this text.
bool has_internal_frame() const
void fix_overflow_flowregion(bool inverse)
Geom::PathVector getNormalizedBpath() const
Converts the text object to its component curves.
const char * typeName() const override
The item's type name, not node tag name.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Inkscape::XML::Node * getAsText()
Converts the flowroot in into a <text> tree, keeping all the formatting and positioning,...
void hide(unsigned int key) override
void _buildLayoutInput(SPObject *root, std::unique_ptr< Shape > exclusion_shape, SPObject **pending_line_break_object)
Recursively walks the xml tree adding tags and their contents.
void optimizeScaledText()
Optimize scaled flow text on next set_transform.
Definition sp-flowtext.h:69
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
int tag() const override
Definition sp-flowtext.h:35
void remove_child(Inkscape::XML::Node *child) override
std::unordered_map< unsigned, Inkscape::Text::StyleAttachments > view_style_attachments
Definition sp-flowtext.h:56
void print(SPPrintContext *ctx) override
void rebuildLayout()
Completely recalculates the layout.
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override
void update(SPCtx *ctx, unsigned int flags) override
Geom::Affine set_transform(Geom::Affine const &xform) override
SPItem * get_frame(SPItem const *after)
double par_indent
Definition sp-flowtext.h:61
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
Base class for visual SVG elements.
Definition sp-item.h:109
Geom::Affine transform
Definition sp-item.h:138
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
RootCluster root
Editable view implementation.
Contains forward declarations of 2geom types.
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
SPItem * create_flowtext_with_internal_frame(SPDesktop *desktop, Geom::Point p1, Geom::Point p2)
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
Creates and maintains display tree needed for text styling.
SPDesktop * desktop