/src/libreoffice/editeng/source/items/bulitem.cxx
Line | Count | Source (jump to first uncovered line) |
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 | | #include <vcl/outdev.hxx> |
21 | | |
22 | | #include <editeng/bulletitem.hxx> |
23 | | |
24 | | SvxBulletItem::SvxBulletItem( sal_uInt16 _nWhich ) |
25 | 73.6k | : SfxPoolItem(_nWhich) |
26 | 73.6k | , aFont(OutputDevice::GetDefaultFont( DefaultFontType::FIXED, LANGUAGE_SYSTEM, GetDefaultFontFlags::NONE )) |
27 | 73.6k | , nStart(1) |
28 | 73.6k | , nStyle(SvxBulletStyle::N123) |
29 | 73.6k | , nWidth(1200) // 1.2cm |
30 | 73.6k | , nScale(75) |
31 | 73.6k | , cSymbol(' ') |
32 | 73.6k | { |
33 | 73.6k | aFont.SetAlignment(ALIGN_BOTTOM); |
34 | 73.6k | aFont.SetTransparent( true ); |
35 | 73.6k | } |
36 | | |
37 | | |
38 | | SvxBulletItem::SvxBulletItem( const SvxBulletItem& rItem ) |
39 | 73.6k | : SfxPoolItem(rItem) |
40 | 73.6k | , aFont(rItem.aFont) |
41 | 73.6k | , pGraphicObject(rItem.pGraphicObject ? new GraphicObject( *rItem.pGraphicObject ) : nullptr) |
42 | 73.6k | , aPrevText(rItem.aPrevText) |
43 | 73.6k | , aFollowText(rItem.aFollowText) |
44 | 73.6k | , nStart(rItem.nStart) |
45 | 73.6k | , nStyle(rItem.nStyle) |
46 | 73.6k | , nWidth(rItem.nWidth) |
47 | 73.6k | , nScale(rItem.nScale) |
48 | 73.6k | , cSymbol(rItem.cSymbol) |
49 | 73.6k | { |
50 | 73.6k | } |
51 | | |
52 | | |
53 | | SvxBulletItem::~SvxBulletItem() |
54 | 147k | { |
55 | 147k | } |
56 | | |
57 | | SvxBulletItem* SvxBulletItem::Clone( SfxItemPool * /*pPool*/ ) const |
58 | 73.6k | { |
59 | 73.6k | return new SvxBulletItem( *this ); |
60 | 73.6k | } |
61 | | |
62 | | void SvxBulletItem::CopyValidProperties( const SvxBulletItem& rCopyFrom ) |
63 | 0 | { |
64 | 0 | vcl::Font _aFont = GetFont(); |
65 | 0 | vcl::Font aNewFont = rCopyFrom.GetFont(); |
66 | 0 | _aFont.SetFamilyName( aNewFont.GetFamilyName() ); |
67 | 0 | _aFont.SetFamily( aNewFont.GetFamilyTypeMaybeAskConfig() ); |
68 | 0 | _aFont.SetStyleName( aNewFont.GetStyleName() ); |
69 | 0 | _aFont.SetColor( aNewFont.GetColor() ); |
70 | 0 | SetSymbol( rCopyFrom.cSymbol ); |
71 | 0 | SetGraphicObject( rCopyFrom.GetGraphicObject() ); |
72 | 0 | SetScale( rCopyFrom.nScale ); |
73 | 0 | SetStart( rCopyFrom.nStart ); |
74 | 0 | SetStyle( rCopyFrom.nStyle ); |
75 | 0 | aPrevText = rCopyFrom.aPrevText; |
76 | 0 | aFollowText = rCopyFrom.aFollowText; |
77 | 0 | SetFont( _aFont ); |
78 | 0 | } |
79 | | |
80 | | |
81 | | bool SvxBulletItem::operator==( const SfxPoolItem& rItem ) const |
82 | 207k | { |
83 | 207k | assert(SfxPoolItem::operator==(rItem)); |
84 | 207k | const SvxBulletItem& rBullet = static_cast<const SvxBulletItem&>(rItem); |
85 | | // Compare with ValidMask, otherwise no put possible in an AttrSet if the |
86 | | // item differs only in terms of the ValidMask from an existing one. |
87 | 207k | if( nStyle != rBullet.nStyle || |
88 | 207k | nScale != rBullet.nScale || |
89 | 207k | nWidth != rBullet.nWidth || |
90 | 207k | nStart != rBullet.nStart || |
91 | 207k | cSymbol != rBullet.cSymbol || |
92 | 207k | aPrevText != rBullet.aPrevText || |
93 | 207k | aFollowText != rBullet.aFollowText ) |
94 | 0 | return false; |
95 | | |
96 | 207k | if( ( nStyle != SvxBulletStyle::BMP ) && ( aFont != rBullet.aFont ) ) |
97 | 0 | return false; |
98 | | |
99 | 207k | if( nStyle == SvxBulletStyle::BMP ) |
100 | 0 | { |
101 | 0 | if( ( pGraphicObject && !rBullet.pGraphicObject ) || ( !pGraphicObject && rBullet.pGraphicObject ) ) |
102 | 0 | return false; |
103 | | |
104 | 0 | if( ( pGraphicObject && rBullet.pGraphicObject ) && |
105 | 0 | ( ( *pGraphicObject != *rBullet.pGraphicObject ) || |
106 | 0 | ( pGraphicObject->GetPrefSize() != rBullet.pGraphicObject->GetPrefSize() ) ) ) |
107 | 0 | { |
108 | 0 | return false; |
109 | 0 | } |
110 | 0 | } |
111 | | |
112 | 207k | return true; |
113 | 207k | } |
114 | | |
115 | | |
116 | | OUString SvxBulletItem::GetFullText() const |
117 | 0 | { |
118 | 0 | return aPrevText + OUStringChar(cSymbol) + aFollowText; |
119 | 0 | } |
120 | | |
121 | | |
122 | | bool SvxBulletItem::GetPresentation |
123 | | ( |
124 | | SfxItemPresentation /*ePres*/, |
125 | | MapUnit /*eCoreUnit*/, |
126 | | MapUnit /*ePresUnit*/, |
127 | | OUString& rText, const IntlWrapper& |
128 | | ) const |
129 | 0 | { |
130 | 0 | rText = GetFullText(); |
131 | 0 | return true; |
132 | 0 | } |
133 | | |
134 | | |
135 | | const GraphicObject& SvxBulletItem::GetGraphicObject() const |
136 | 0 | { |
137 | 0 | if( pGraphicObject ) |
138 | 0 | return *pGraphicObject; |
139 | 0 | else |
140 | 0 | { |
141 | 0 | static const GraphicObject aDefaultObject; |
142 | 0 | return aDefaultObject; |
143 | 0 | } |
144 | 0 | } |
145 | | |
146 | | |
147 | | void SvxBulletItem::SetGraphicObject( const GraphicObject& rGraphicObject ) |
148 | 0 | { |
149 | 0 | if( ( GraphicType::NONE == rGraphicObject.GetType() ) || ( GraphicType::Default == rGraphicObject.GetType() ) ) |
150 | 0 | { |
151 | 0 | pGraphicObject.reset(); |
152 | 0 | } |
153 | 0 | else |
154 | 0 | { |
155 | 0 | pGraphicObject.reset( new GraphicObject( rGraphicObject ) ); |
156 | 0 | } |
157 | 0 | } |
158 | | |
159 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |