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