Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / SwPortionHandler.hxx
blob29625efbca840e7598e27eb20816cb934cca1448
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 virtual ~SwPortionHandler() {} /// (empty) destructor
51 /** text portion. A run of nLength characters from the view
52 * string, that contains no special characters like embedded
53 * fields, etc. Thus, the on-screen text of this portion
54 * corresponds exactly to the corresponding characters in the
55 * view string.
57 virtual void Text(
58 TextFrameIndex nLength, ///< length of this portion in the view string
59 PortionType nType /// type of this portion
60 ) = 0;
62 /** special portion. This method is called for every non-text
63 * portion. The parameters describe the length of the
64 * corresponding characters in the view string (often 0 or 1),
65 * the text which is displayed, and the type of the portion.
67 virtual void Special(
68 TextFrameIndex nLength, ///< length of this portion in the view string
69 const OUString& rText, /// text which is painted on-screen
70 PortionType nType /// type of this portion
71 ) = 0;
73 /** line break. This method is called whenever a line break in the
74 * layout occurs.
76 virtual void LineBreak() = 0;
78 /** skip characters. The SwTextFrame may only display partially
79 * display a certain paragraph (e.g. when the paragraph is split
80 * across multiple pages). In this case, the Skip() method must be
81 * called to inform the portion handler to ignore a certain run of
82 * characters in the 'view string'. Skip(), if used at all, must
83 * be called before any of the other methods is called. Calling
84 * Skip() between portions is not allowed.
86 virtual void Skip(
87 TextFrameIndex nLength /// number of 'view string' characters to be skipped
88 ) = 0;
90 /** end of paragraph. This method is to be called when all the
91 * paragraph's portions have been processed.
93 virtual void Finish() = 0;
96 #endif
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */