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