1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SW_PORTIONHANDLER_HXX 24 #define _SW_PORTIONHANDLER_HXX 25 26 #include <tools/solar.h> 27 class String; 28 29 /** The SwPortionHandler interface implements a visitor for the layout 30 * engine's text portions. This can be used to gather information of 31 * the on-screen representation of a single paragraph. 32 * 33 * For each text portion, one of the methods text(...) or special(...) 34 * is called, depending on whether it is a 'normal' run of text, or 35 * any other portion. Additionally, the linebreak() method is called 36 * once at the end of every on-screen line. 37 * 38 * All parameters relate to the 'model string', which is the text string 39 * held by the corresponding SwTxtNode. 40 * 41 * The SwPortionHandler can be used with the 42 * SwTextFrame::VisitPortions(...) method. 43 */ 44 class SwPortionHandler 45 { 46 public: 47 SwPortionHandler()48 SwPortionHandler() {} /// (emtpy) constructor 49 ~SwPortionHandler()50 virtual ~SwPortionHandler() {} /// (empty) destructor 51 52 /** text portion. A run of nLength characters from the model 53 * string, that contains no special characters like embedded 54 * fields, etc. Thus, the on-screen text of this portion 55 * corresponds exactly to the corresponding characters in the 56 * model string. 57 */ 58 virtual void Text( 59 sal_uInt16 nLength, /// length of this portion in the model string 60 sal_uInt16 nType /// type 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 ) = 0; 73 74 /** line break. This method is called whenever a line break in the 75 * layout occurs. 76 */ 77 virtual void LineBreak() = 0; 78 79 /** skip characters. The SwTxtFrame may only display partially 80 * display a certain paragraph (e.g. when the paragaph is split 81 * across multiple pages). In this case, the Skip() method must be 82 * called to inform the portion handler to ignore a certain run of 83 * characters in the 'model string'. Skip(), if used at all, must 84 * be called before any of the other methods is called. Calling 85 * Skip() between portions is not allowed. 86 */ 87 virtual void Skip( 88 sal_uInt16 nLength /// number of 'model string' characters to be skipped 89 ) = 0; 90 91 /** end of paragraph. This method is to be called when all the 92 * paragraph's portions have been processed. 93 */ 94 virtual void Finish() = 0; SetAttrFieldType(sal_uInt16)95 virtual void SetAttrFieldType( sal_uInt16 ) 96 { return; } 97 }; 98 99 #endif 100