cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / sfx2 / source / doc / watermarkitem.cxx
blob3e11ef6e569d6931d88d3828c78f78c548c19a38
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.
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 */
10 #include <sfx2/watermarkitem.hxx>
11 #include <sfx2/sfxsids.hrc>
12 #include <comphelper/propertysequence.hxx>
14 SfxWatermarkItem::SfxWatermarkItem()
15 : SfxPoolItem( SID_WATERMARK, SfxItemType::SfxWatermarkItemType )
16 , m_aText( u""_ustr )
17 , m_aFont( u"Liberation Sans"_ustr )
18 , m_nAngle( 45 )
19 , m_nTransparency( 50 )
20 , m_nColor( 0xc0c0c0 )
24 SfxPoolItem* SfxWatermarkItem::CreateDefault()
26 return new SfxWatermarkItem();
29 bool SfxWatermarkItem::operator==( const SfxPoolItem& rCmp ) const
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 );
39 SfxWatermarkItem* SfxWatermarkItem::Clone( SfxItemPool *) const
41 return new SfxWatermarkItem(*this);
44 bool SfxWatermarkItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
46 rVal <<= comphelper::InitPropertySequence( {
47 { "Text", css::uno::Any( m_aText ) },
48 { "Font", css::uno::Any( m_aFont ) },
49 { "Angle", css::uno::Any( m_nAngle ) },
50 { "Transparency", css::uno::Any( m_nTransparency ) },
51 { "Color", css::uno::Any( m_nColor ) },
52 } );
54 return true;
57 bool SfxWatermarkItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
59 css::uno::Sequence<css::beans::PropertyValue> aSequence;
61 if ( rVal >>= aSequence )
63 for (const auto& aEntry : aSequence)
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;
76 return true;
79 return false;
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */