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 OOX_VML_VMLTEXTBOX_HXX
21 : #define OOX_VML_VMLTEXTBOX_HXX
22 :
23 : #include <vector>
24 : #include <rtl/ustring.hxx>
25 : #include "oox/helper/helper.hxx"
26 : #include "oox/dllapi.h"
27 : #include <com/sun/star/uno/Reference.h>
28 :
29 : namespace com { namespace sun { namespace star {
30 : namespace drawing { class XShape; }
31 : } } }
32 :
33 : namespace oox {
34 : namespace vml {
35 :
36 : struct ShapeTypeModel;
37 :
38 : // ============================================================================
39 :
40 : /** Font settings for a text portion in a textbox. */
41 978 : struct OOX_DLLPUBLIC TextFontModel
42 : {
43 : OptValue< ::rtl::OUString > moName; ///< Font name.
44 : OptValue< ::rtl::OUString > moColor; ///< Font color, HTML encoded, sort of.
45 : OptValue< sal_Int32 > monSize; ///< Font size in twips.
46 : OptValue< sal_Int32 > monUnderline; ///< Single or double underline.
47 : OptValue< sal_Int32 > monEscapement; ///< Subscript or superscript.
48 : OptValue< bool > mobBold;
49 : OptValue< bool > mobItalic;
50 : OptValue< bool > mobStrikeout;
51 :
52 : explicit TextFontModel();
53 : };
54 :
55 : // ============================================================================
56 :
57 : /** A text portion in a textbox with the same formatting for all characters. */
58 665 : struct TextPortionModel
59 : {
60 : TextFontModel maFont;
61 : ::rtl::OUString maText;
62 :
63 : explicit TextPortionModel( const TextFontModel& rFont, const ::rtl::OUString& rText );
64 : };
65 :
66 : // ============================================================================
67 :
68 : /** The textbox contains all text contents and properties. */
69 15 : class OOX_DLLPUBLIC TextBox
70 : {
71 : public:
72 : explicit TextBox(ShapeTypeModel& rTypeModel);
73 :
74 : /** Appends a new text portion to the textbox. */
75 : void appendPortion( const TextFontModel& rFont, const ::rtl::OUString& rText );
76 :
77 : /** Returns the current number of text portions. */
78 144 : inline size_t getPortionCount() const { return maPortions.size(); }
79 : /** Returns the font settings of the first text portion. */
80 : const TextFontModel* getFirstFont() const;
81 : /** Returns the entire text of all text portions. */
82 : ::rtl::OUString getText() const;
83 : void convert(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape) const;
84 :
85 : ShapeTypeModel& mrTypeModel;
86 : /// Text distance from the border (inset attribute of v:textbox), valid only if set.
87 : bool borderDistanceSet;
88 : int borderDistanceLeft, borderDistanceTop, borderDistanceRight, borderDistanceBottom;
89 :
90 : private:
91 : typedef ::std::vector< TextPortionModel > PortionVector;
92 :
93 : PortionVector maPortions;
94 : };
95 :
96 : // ============================================================================
97 :
98 : } // namespace vml
99 : } // namespace oox
100 :
101 : #endif
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|