1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <tools/stream.hxx>
21 #include <vcl/outdev.hxx>
23 #include <editeng/bulletitem.hxx>
25 #include <tools/tenccvt.hxx>
26 #include <tools/debug.hxx>
27 #include <vcl/dibtools.hxx>
29 SvxBulletItem::SvxBulletItem( sal_uInt16 _nWhich
)
30 : SfxPoolItem(_nWhich
)
31 , aFont(OutputDevice::GetDefaultFont( DefaultFontType::FIXED
, LANGUAGE_SYSTEM
, GetDefaultFontFlags::NONE
))
33 , nStyle(SvxBulletStyle::N123
)
34 , nWidth(1200) // 1.2cm
38 aFont
.SetAlignment(ALIGN_BOTTOM
);
39 aFont
.SetTransparent( true );
43 SvxBulletItem::SvxBulletItem( const SvxBulletItem
& rItem
)
46 , pGraphicObject(rItem
.pGraphicObject
? new GraphicObject( *rItem
.pGraphicObject
) : nullptr)
47 , aPrevText(rItem
.aPrevText
)
48 , aFollowText(rItem
.aFollowText
)
49 , nStart(rItem
.nStart
)
50 , nStyle(rItem
.nStyle
)
51 , nWidth(rItem
.nWidth
)
52 , nScale(rItem
.nScale
)
53 , cSymbol(rItem
.cSymbol
)
58 SvxBulletItem::~SvxBulletItem()
63 SfxPoolItem
* SvxBulletItem::Clone( SfxItemPool
* /*pPool*/ ) const
65 return new SvxBulletItem( *this );
69 void SvxBulletItem::CopyValidProperties( const SvxBulletItem
& rCopyFrom
)
71 vcl::Font _aFont
= GetFont();
72 vcl::Font aNewFont
= rCopyFrom
.GetFont();
73 _aFont
.SetFamilyName( aNewFont
.GetFamilyName() );
74 _aFont
.SetFamily( aNewFont
.GetFamilyType() );
75 _aFont
.SetStyleName( aNewFont
.GetStyleName() );
76 _aFont
.SetColor( aNewFont
.GetColor() );
77 SetSymbol( rCopyFrom
.cSymbol
);
78 SetGraphicObject( rCopyFrom
.GetGraphicObject() );
79 SetScale( rCopyFrom
.nScale
);
80 SetStart( rCopyFrom
.nStart
);
81 SetStyle( rCopyFrom
.nStyle
);
82 aPrevText
= rCopyFrom
.aPrevText
;
83 aFollowText
= rCopyFrom
.aFollowText
;
88 bool SvxBulletItem::operator==( const SfxPoolItem
& rItem
) const
90 DBG_ASSERT(dynamic_cast< const SvxBulletItem
* >(&rItem
) != nullptr,"operator==Types not matching");
91 const SvxBulletItem
& rBullet
= static_cast<const SvxBulletItem
&>(rItem
);
92 // Compare with ValidMask, otherwise no put possible in an AttrSet if the
93 // item differs only in terms of the ValidMask from an existing one.
94 if( nStyle
!= rBullet
.nStyle
||
95 nScale
!= rBullet
.nScale
||
96 nWidth
!= rBullet
.nWidth
||
97 nStart
!= rBullet
.nStart
||
98 cSymbol
!= rBullet
.cSymbol
||
99 aPrevText
!= rBullet
.aPrevText
||
100 aFollowText
!= rBullet
.aFollowText
)
103 if( ( nStyle
!= SvxBulletStyle::BMP
) && ( aFont
!= rBullet
.aFont
) )
106 if( nStyle
== SvxBulletStyle::BMP
)
108 if( ( pGraphicObject
&& !rBullet
.pGraphicObject
) || ( !pGraphicObject
&& rBullet
.pGraphicObject
) )
111 if( ( pGraphicObject
&& rBullet
.pGraphicObject
) &&
112 ( ( *pGraphicObject
!= *rBullet
.pGraphicObject
) ||
113 ( pGraphicObject
->GetPrefSize() != rBullet
.pGraphicObject
->GetPrefSize() ) ) )
123 OUString
SvxBulletItem::GetFullText() const
125 OUStringBuffer
aStr(aPrevText
);
126 aStr
.append(cSymbol
);
127 aStr
.append(aFollowText
);
128 return aStr
.makeStringAndClear();
132 bool SvxBulletItem::GetPresentation
134 SfxItemPresentation
/*ePres*/,
135 MapUnit
/*eCoreUnit*/,
136 MapUnit
/*ePresUnit*/,
137 OUString
& rText
, const IntlWrapper
&
140 rText
= GetFullText();
145 const GraphicObject
& SvxBulletItem::GetGraphicObject() const
148 return *pGraphicObject
;
151 static const GraphicObject aDefaultObject
;
152 return aDefaultObject
;
157 void SvxBulletItem::SetGraphicObject( const GraphicObject
& rGraphicObject
)
159 if( ( GraphicType::NONE
== rGraphicObject
.GetType() ) || ( GraphicType::Default
== rGraphicObject
.GetType() ) )
161 pGraphicObject
.reset();
165 pGraphicObject
.reset( new GraphicObject( rGraphicObject
) );
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */