1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10 #include <sfx2/watermarkitem.hxx>
11 #include <sfx2/sfxsids.hrc>
12 #include <comphelper/propertysequence.hxx>
13
SfxWatermarkItem()14 SfxWatermarkItem::SfxWatermarkItem()
15 : SfxPoolItem( SID_WATERMARK )
16 , m_aText( "" )
17 , m_aFont( "Liberation Sans" )
18 , m_nAngle( 45 )
19 , m_nTransparency( 50 )
20 , m_nColor( 0xc0c0c0 )
21 {
22 }
23
CreateDefault()24 SfxPoolItem* SfxWatermarkItem::CreateDefault()
25 {
26 return new SfxWatermarkItem();
27 }
28
operator ==(const SfxPoolItem & rCmp) const29 bool SfxWatermarkItem::operator==( const SfxPoolItem& rCmp ) const
30 {
31 return ( SfxPoolItem::operator==( rCmp ) &&
32 m_aText == static_cast<const SfxWatermarkItem&>(rCmp).m_aText &&
33 m_aFont == static_cast<const SfxWatermarkItem&>(rCmp).m_aFont &&
34 m_nAngle == static_cast<const SfxWatermarkItem&>(rCmp).m_nAngle &&
35 m_nTransparency == static_cast<const SfxWatermarkItem&>(rCmp).m_nTransparency &&
36 m_nColor == static_cast<const SfxWatermarkItem&>(rCmp).m_nColor );
37 }
38
Clone(SfxItemPool *) const39 SfxPoolItem* SfxWatermarkItem::Clone( SfxItemPool *) const
40 {
41 return new SfxWatermarkItem(*this);
42 }
43
QueryValue(css::uno::Any & rVal,sal_uInt8) const44 bool SfxWatermarkItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
45 {
46 rVal <<= comphelper::InitPropertySequence( {
47 { "Text", css::uno::makeAny( m_aText ) },
48 { "Font", css::uno::makeAny( m_aFont ) },
49 { "Angle", css::uno::makeAny( m_nAngle ) },
50 { "Transparency", css::uno::makeAny( m_nTransparency ) },
51 { "Color", css::uno::makeAny( m_nColor ) },
52 } );
53
54 return true;
55 }
56
PutValue(const css::uno::Any & rVal,sal_uInt8)57 bool SfxWatermarkItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
58 {
59 css::uno::Sequence<css::beans::PropertyValue> aSequence;
60
61 if ( rVal >>= aSequence )
62 {
63 for(const auto& aEntry : std::as_const(aSequence))
64 {
65 if(aEntry.Name == "Text")
66 aEntry.Value >>= m_aText;
67 if(aEntry.Name == "Font")
68 aEntry.Value >>= m_aFont;
69 if(aEntry.Name == "Angle")
70 aEntry.Value >>= m_nAngle;
71 if(aEntry.Name == "Transparency")
72 aEntry.Value >>= m_nTransparency;
73 if(aEntry.Name == "Color")
74 aEntry.Value >>= m_nColor;
75 }
76 return true;
77 }
78
79 return false;
80 }
81
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
83