LibreOffice Module editeng (master) 1
bulitem.cxx
Go to the documentation of this file.
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
23
24SvxBulletItem::SvxBulletItem( sal_uInt16 _nWhich )
25 : SfxPoolItem(_nWhich)
27 , nStart(1)
28 , nStyle(SvxBulletStyle::N123)
29 , nWidth(1200) // 1.2cm
30 , nScale(75)
31 , cSymbol(' ')
32{
34 aFont.SetTransparent( true );
35}
36
37
39 : SfxPoolItem(rItem)
40 , aFont(rItem.aFont)
41 , pGraphicObject(rItem.pGraphicObject ? new GraphicObject( *rItem.pGraphicObject ) : nullptr)
42 , aPrevText(rItem.aPrevText)
43 , aFollowText(rItem.aFollowText)
44 , nStart(rItem.nStart)
45 , nStyle(rItem.nStyle)
46 , nWidth(rItem.nWidth)
47 , nScale(rItem.nScale)
48 , cSymbol(rItem.cSymbol)
49{
50}
51
52
54{
55}
56
58{
59 return new SvxBulletItem( *this );
60}
61
63{
64 vcl::Font _aFont = GetFont();
65 vcl::Font aNewFont = rCopyFrom.GetFont();
66 _aFont.SetFamilyName( aNewFont.GetFamilyName() );
67 _aFont.SetFamily( aNewFont.GetFamilyType() );
68 _aFont.SetStyleName( aNewFont.GetStyleName() );
69 _aFont.SetColor( aNewFont.GetColor() );
70 SetSymbol( rCopyFrom.cSymbol );
72 SetScale( rCopyFrom.nScale );
73 SetStart( rCopyFrom.nStart );
74 SetStyle( rCopyFrom.nStyle );
75 aPrevText = rCopyFrom.aPrevText;
76 aFollowText = rCopyFrom.aFollowText;
77 SetFont( _aFont );
78}
79
80
81bool SvxBulletItem::operator==( const SfxPoolItem& rItem ) const
82{
83 assert(SfxPoolItem::operator==(rItem));
84 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 if( nStyle != rBullet.nStyle ||
88 nScale != rBullet.nScale ||
89 nWidth != rBullet.nWidth ||
90 nStart != rBullet.nStart ||
91 cSymbol != rBullet.cSymbol ||
92 aPrevText != rBullet.aPrevText ||
93 aFollowText != rBullet.aFollowText )
94 return false;
95
96 if( ( nStyle != SvxBulletStyle::BMP ) && ( aFont != rBullet.aFont ) )
97 return false;
98
100 {
101 if( ( pGraphicObject && !rBullet.pGraphicObject ) || ( !pGraphicObject && rBullet.pGraphicObject ) )
102 return false;
103
104 if( ( pGraphicObject && rBullet.pGraphicObject ) &&
105 ( ( *pGraphicObject != *rBullet.pGraphicObject ) ||
106 ( pGraphicObject->GetPrefSize() != rBullet.pGraphicObject->GetPrefSize() ) ) )
107 {
108 return false;
109 }
110 }
111
112 return true;
113}
114
115
117{
118 return aPrevText + OUStringChar(cSymbol) + aFollowText;
119}
120
121
123(
124 SfxItemPresentation /*ePres*/,
125 MapUnit /*eCoreUnit*/,
126 MapUnit /*ePresUnit*/,
127 OUString& rText, const IntlWrapper&
128) const
129{
130 rText = GetFullText();
131 return true;
132}
133
134
136{
137 if( pGraphicObject )
138 return *pGraphicObject;
139 else
140 {
141 static const GraphicObject aDefaultObject;
142 return aDefaultObject;
143 }
144}
145
146
148{
149 if( ( GraphicType::NONE == rGraphicObject.GetType() ) || ( GraphicType::Default == rGraphicObject.GetType() ) )
150 {
151 pGraphicObject.reset();
152 }
153 else
154 {
155 pGraphicObject.reset( new GraphicObject( rGraphicObject ) );
156 }
157}
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
GetDefaultFontFlags
SvxBulletStyle
these must match the values in css::style::NumberingType
Definition: bulletitem.hxx:33
GraphicType GetType() const
vcl::Font aFont
Definition: bulletitem.hxx:48
const vcl::Font & GetFont() const
Definition: bulletitem.hxx:69
void SetStart(sal_uInt16 nNew)
Definition: bulletitem.hxx:76
virtual ~SvxBulletItem() override
Definition: bulitem.cxx:53
SvxBulletItem(sal_uInt16 nWhich)
Definition: bulitem.cxx:24
virtual SvxBulletItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: bulitem.cxx:57
void SetStyle(SvxBulletStyle nNew)
Definition: bulletitem.hxx:78
void SetFont(const vcl::Font &rNew)
Definition: bulletitem.hxx:79
std::unique_ptr< GraphicObject > pGraphicObject
Definition: bulletitem.hxx:50
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &) const override
Definition: bulitem.cxx:123
void SetGraphicObject(const GraphicObject &rGraphicObject)
Definition: bulitem.cxx:147
sal_Unicode cSymbol
Definition: bulletitem.hxx:57
sal_uInt16 nScale
Definition: bulletitem.hxx:56
OUString GetFullText() const
Definition: bulitem.cxx:116
virtual bool operator==(const SfxPoolItem &) const override
Definition: bulitem.cxx:81
tools::Long nWidth
Definition: bulletitem.hxx:55
void CopyValidProperties(const SvxBulletItem &rCopyFrom)
Definition: bulitem.cxx:62
void SetScale(sal_uInt16 nNew)
Definition: bulletitem.hxx:80
OUString aPrevText
Definition: bulletitem.hxx:51
const GraphicObject & GetGraphicObject() const
Definition: bulitem.cxx:135
sal_uInt16 nStart
Definition: bulletitem.hxx:53
SvxBulletStyle nStyle
Definition: bulletitem.hxx:54
OUString aFollowText
Definition: bulletitem.hxx:52
void SetSymbol(sal_Unicode c)
Definition: bulletitem.hxx:74
FontFamily GetFamilyType()
void SetStyleName(const OUString &rStyleName)
void SetTransparent(bool bTransparent)
void SetColor(const Color &)
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
void SetFamily(FontFamily)
const Color & GetColor() const
void SetAlignment(TextAlign)
void SetFamilyName(const OUString &rFamilyName)
DefaultFontType
ALIGN_BOTTOM
#define LANGUAGE_SYSTEM
MapUnit
NONE
SfxItemPresentation