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 INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_SWPORTIONHANDLER_HXX
22 :
23 : #include <swtypes.hxx>
24 :
25 : class SwFont;
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 SwTextNode.
38 : *
39 : * The SwPortionHandler can be used with the
40 : * SwTextFrm::VisitPortions(...) method.
41 : */
42 : class SwPortionHandler
43 : {
44 : public:
45 :
46 1062 : SwPortionHandler() {} /// (emtpy) constructor
47 :
48 1062 : 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_Int32 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_Int32 nLength, /// length of this portion in the model string
70 : const OUString& 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 : const SwFont* pFont = 0 /// font of this portion
75 : ) = 0;
76 :
77 : /** line break. This method is called whenever a line break in the
78 : * layout occurs.
79 : */
80 : virtual void LineBreak(sal_Int32 nWidth) = 0;
81 :
82 : /** skip characters. The SwTextFrame may only display partially
83 : * display a certain paragraph (e.g. when the paragraph is split
84 : * across multiple pages). In this case, the Skip() method must be
85 : * called to inform the portion handler to ignore a certain run of
86 : * characters in the 'model string'. Skip(), if used at all, must
87 : * be called before any of the other methods is called. Calling
88 : * Skip() between portions is not allowed.
89 : */
90 : virtual void Skip(
91 : sal_Int32 nLength /// number of 'model string' characters to be skipped
92 : ) = 0;
93 :
94 : /** end of paragraph. This method is to be called when all the
95 : * paragraph's portions have been processed.
96 : */
97 : virtual void Finish() = 0;
98 36 : virtual void SetAttrFieldType( sal_uInt16 )
99 36 : { return; }
100 : };
101 :
102 : #endif
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|