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 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTBREAKUPHELPER_HXX 23 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTBREAKUPHELPER_HXX 24 25 #include <drawinglayer/drawinglayerdllapi.h> 26 #include <drawinglayer/primitive2d/textprimitive2d.hxx> 27 #include <drawinglayer/primitive2d/textlayoutdevice.hxx> 28 #include <basegfx/matrix/b2dhommatrixtools.hxx> 29 30 ////////////////////////////////////////////////////////////////////////////// 31 32 namespace drawinglayer 33 { 34 namespace primitive2d 35 { 36 enum BreakupUnit 37 { 38 BreakupUnit_character, 39 BreakupUnit_word, 40 BreakupUnit_sentence 41 }; 42 43 class DRAWINGLAYER_DLLPUBLIC TextBreakupHelper 44 { 45 private: 46 const TextSimplePortionPrimitive2D& mrSource; 47 Primitive2DSequence mxResult; 48 TextLayouterDevice maTextLayouter; 49 basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose maDecTrans; 50 51 /// bitfield 52 bool mbNoDXArray : 1; 53 54 /// create a portion from nIndex to nLength and append to rTempResult 55 void breakupPortion(Primitive2DVector& rTempResult, sal_uInt32 nIndex, sal_uInt32 nLength, bool bWordLineMode); 56 57 /// breakup complete primitive 58 void breakup(BreakupUnit aBreakupUnit); 59 60 protected: 61 /// allow user callback to allow changes to the new TextTransformation. Default 62 /// does nothing. Retval defines if a primitive gets created, e.g. return false 63 /// to suppress creation 64 virtual bool allowChange(sal_uInt32 nCount, basegfx::B2DHomMatrix& rNewTransform, sal_uInt32 nIndex, sal_uInt32 nLength); 65 66 /// allow read access to evtl. useful local parts getTextLayouter() const67 const TextLayouterDevice& getTextLayouter() const { return maTextLayouter; } getDecTrans() const68 const basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& getDecTrans() const { return maDecTrans; } getSource() const69 const TextSimplePortionPrimitive2D& getSource() const { return mrSource; } 70 71 public: 72 TextBreakupHelper(const TextSimplePortionPrimitive2D& rSource); 73 virtual ~TextBreakupHelper(); 74 75 /// get result 76 const Primitive2DSequence& getResult(BreakupUnit aBreakupUnit = BreakupUnit_character) const; 77 }; 78 79 } // end of namespace primitive2d 80 } // end of namespace drawinglayer 81 82 ////////////////////////////////////////////////////////////////////////////// 83 84 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTBREAKUPHELPER_HXX 85 86 ////////////////////////////////////////////////////////////////////////////// 87 // eof 88