Branch data Line data Source code
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 _SW_PORTIONHANDLER_HXX
21 : : #define _SW_PORTIONHANDLER_HXX
22 : :
23 : : #include <tools/solar.h>
24 : :
25 : : class String;
26 : :
27 : : /** The SwPortionHandler interface implements a visitor for the layout
28 : : * engine's text portions. This can be used to gather information of
29 : : * the on-screen representation of a single paragraph.
30 : : *
31 : : * For each text portion, one of the methods text(...) or special(...)
32 : : * is called, depending on whether it is a 'normal' run of text, or
33 : : * any other portion. Additionally, the linebreak() method is called
34 : : * once at the end of every on-screen line.
35 : : *
36 : : * All parameters relate to the 'model string', which is the text string
37 : : * held by the corresponding SwTxtNode.
38 : : *
39 : : * The SwPortionHandler can be used with the
40 : : * SwTextFrame::VisitPortions(...) method.
41 : : */
42 : : class SwPortionHandler
43 : : {
44 : : public:
45 : :
46 : 82 : SwPortionHandler() {} /// (emtpy) constructor
47 : :
48 [ - + ]: 82 : virtual ~SwPortionHandler() {} /// (empty) destructor
49 : :
50 : : /** text portion. A run of nLength characters from the model
51 : : * string, that contains no special characters like embedded
52 : : * fields, etc. Thus, the on-screen text of this portion
53 : : * corresponds exactly to the corresponding characters in the
54 : : * model string.
55 : : */
56 : : virtual void Text(
57 : : sal_uInt16 nLength, /// length of this portion in the model string
58 : : sal_uInt16 nType, /// type of this portion
59 : : sal_Int32 nHeight = 0, /// height of this portion
60 : : sal_Int32 nWidth = 0 /// width of this portion
61 : : ) = 0;
62 : :
63 : : /** special portion. This method is called for every non-text
64 : : * portion. The parameters describe the length of the
65 : : * corresponding characters in the model string (often 0 or 1),
66 : : * the text which is displayed, and the type of the portion.
67 : : */
68 : : virtual void Special(
69 : : sal_uInt16 nLength, /// length of this portion in the model string
70 : : const String& rText, /// text which is painted on-screen
71 : : sal_uInt16 nType, /// type of this portion
72 : : sal_Int32 nHeight = 0, /// font height of the painted text
73 : : sal_Int32 nWidth = 0 /// width of this portion
74 : : ) = 0;
75 : :
76 : : /** line break. This method is called whenever a line break in the
77 : : * layout occurs.
78 : : */
79 : : virtual void LineBreak() = 0;
80 : :
81 : : /** skip characters. The SwTxtFrame may only display partially
82 : : * display a certain paragraph (e.g. when the paragaph is split
83 : : * across multiple pages). In this case, the Skip() method must be
84 : : * called to inform the portion handler to ignore a certain run of
85 : : * characters in the 'model string'. Skip(), if used at all, must
86 : : * be called before any of the other methods is called. Calling
87 : : * Skip() between portions is not allowed.
88 : : */
89 : : virtual void Skip(
90 : : sal_uInt16 nLength /// number of 'model string' characters to be skipped
91 : : ) = 0;
92 : :
93 : : /** end of paragraph. This method is to be called when all the
94 : : * paragraph's portions have been processed.
95 : : */
96 : : virtual void Finish() = 0;
97 : : };
98 : :
99 : : #endif
100 : :
101 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|