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