nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / SwPortionHandler.hxx
blob2036b0a66d5f9687b8715e9dba6f1677f918b594
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX
23 #include <swdllapi.h>
24 #include <rtl/ustring.hxx>
25 #include "TextFrameIndex.hxx"
27 class SwFont;
28 enum class PortionType;
30 /** The SwPortionHandler interface implements a visitor for the layout
31 * engine's text portions. This can be used to gather information of
32 * the on-screen representation of a single paragraph.
34 * For each text portion, one of the methods text(...) or special(...)
35 * is called, depending on whether it is a 'normal' run of text, or
36 * any other portion. Additionally, the linebreak() method is called
37 * once at the end of every on-screen line.
39 * All parameters relate to the 'view string', which is the text string
40 * held by the sequence of all corresponding SwTextFrames.
42 * The SwPortionHandler can be used with the
43 * SwTextFrame::VisitPortions(...) method.
45 class SW_DLLPUBLIC SwPortionHandler
47 public:
49 SwPortionHandler() {} /// (empty) constructor
51 virtual ~SwPortionHandler() {} /// (empty) destructor
53 /** text portion. A run of nLength characters from the view
54 * string, that contains no special characters like embedded
55 * fields, etc. Thus, the on-screen text of this portion
56 * corresponds exactly to the corresponding characters in the
57 * view string.
59 virtual void Text(
60 TextFrameIndex nLength, ///< length of this portion in the view string
61 PortionType nType, /// type of this portion
62 sal_Int32 nHeight = 0, /// height of this portion
63 sal_Int32 nWidth = 0 /// width of this portion
64 ) = 0;
66 /** special portion. This method is called for every non-text
67 * portion. The parameters describe the length of the
68 * corresponding characters in the view string (often 0 or 1),
69 * the text which is displayed, and the type of the portion.
71 virtual void Special(
72 TextFrameIndex nLength, ///< length of this portion in the view string
73 const OUString& rText, /// text which is painted on-screen
74 PortionType nType, /// type of this portion
75 sal_Int32 nHeight = 0, /// font height of the painted text
76 sal_Int32 nWidth = 0, /// width of this portion
77 const SwFont* pFont = nullptr /// font of this portion
78 ) = 0;
80 /** line break. This method is called whenever a line break in the
81 * layout occurs.
83 virtual void LineBreak(sal_Int32 nWidth) = 0;
85 /** skip characters. The SwTextFrame may only display partially
86 * display a certain paragraph (e.g. when the paragraph is split
87 * across multiple pages). In this case, the Skip() method must be
88 * called to inform the portion handler to ignore a certain run of
89 * characters in the 'view string'. Skip(), if used at all, must
90 * be called before any of the other methods is called. Calling
91 * Skip() between portions is not allowed.
93 virtual void Skip(
94 TextFrameIndex nLength /// number of 'view string' characters to be skipped
95 ) = 0;
97 /** end of paragraph. This method is to be called when all the
98 * paragraph's portions have been processed.
100 virtual void Finish() = 0;
103 #endif
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */