xref: /AOO41X/main/sw/source/core/inc/SwPortionHandler.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SW_PORTIONHANDLER_HXX
28 #define _SW_PORTIONHANDLER_HXX
29 
30 #include <tools/solar.h>
31 class String;
32 
33 /** The SwPortionHandler interface implements a visitor for the layout
34  * engine's text portions. This can be used to gather information of
35  * the on-screen representation of a single paragraph.
36  *
37  * For each text portion, one of the methods text(...) or special(...)
38  * is called, depending on whether it is a 'normal' run of text, or
39  * any other portion. Additionally, the linebreak() method is called
40  * once at the end of every on-screen line.
41  *
42  * All parameters relate to the 'model string', which is the text string
43  * held by the corresponding SwTxtNode.
44  *
45  * The SwPortionHandler can be used with the
46  * SwTextFrame::VisitPortions(...) method.
47  */
48 class SwPortionHandler
49 {
50 public:
51 
52     SwPortionHandler() {}           /// (emtpy) constructor
53 
54     virtual ~SwPortionHandler() {}  /// (empty) destructor
55 
56     /** text portion. A run of nLength characters from the model
57      * string, that contains no special characters like embedded
58      * fields, etc. Thus, the on-screen text of this portion
59      * corresponds exactly to the corresponding characters in the
60      * model string.
61      */
62     virtual void Text(
63         sal_uInt16 nLength,      /// length of this portion in the model string
64         sal_uInt16 nType         /// type of this portion
65         ) = 0;
66 
67     /** special portion. This method is called for every non-text
68      * portion. The parameters describe the length of the
69      * corresponding characters in the model string (often 0 or 1),
70      * the text which is displayed, and the type of the portion.
71      */
72     virtual void Special(
73         sal_uInt16 nLength,      /// length of this portion in the model string
74         const String& rText, /// text which is painted on-screen
75         sal_uInt16 nType         /// type of this portion
76         ) = 0;
77 
78     /** line break. This method is called whenever a line break in the
79      * layout occurs.
80      */
81     virtual void LineBreak() = 0;
82 
83     /** skip characters. The SwTxtFrame may only display partially
84      * display a certain paragraph (e.g. when the paragaph is split
85      * across multiple pages). In this case, the Skip() method must be
86      * called to inform the portion handler to ignore a certain run of
87      * characters in the 'model string'. Skip(), if used at all, must
88      * be called before any of the other methods is called. Calling
89      * Skip() between portions is not allowed.
90      */
91     virtual void Skip(
92         sal_uInt16 nLength   /// number of 'model string' characters to be skipped
93         ) = 0;
94 
95     /** end of paragraph. This method is to be called when all the
96      * paragraph's portions have been processed.
97      */
98     virtual void Finish() = 0;
99 };
100 
101 #endif
102