bump product version to 5.0.4.1
[LibreOffice.git] / svl / source / items / imageitm.cxx
blobf81e7bb47869a8d3985e412830ebdc680c5b8059
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 .
21 #include <svl/imageitm.hxx>
22 #include <com/sun/star/uno/Sequence.hxx>
24 TYPEINIT1( SfxImageItem, SfxInt16Item );
26 struct SfxImageItem_Impl
28 OUString aURL;
29 long nAngle;
30 bool bMirrored;
31 bool operator == ( const SfxImageItem_Impl& rOther ) const
32 { return nAngle == rOther.nAngle && bMirrored == rOther.bMirrored; }
36 SfxImageItem::SfxImageItem( sal_uInt16 which, sal_uInt16 nImage )
37 : SfxInt16Item( which, nImage )
39 pImp = new SfxImageItem_Impl;
40 pImp->nAngle = 0;
41 pImp->bMirrored = false;
44 SfxImageItem::SfxImageItem( const SfxImageItem& rItem )
45 : SfxInt16Item( rItem )
47 pImp = new SfxImageItem_Impl( *(rItem.pImp) );
50 SfxImageItem::~SfxImageItem()
52 delete pImp;
56 SfxPoolItem* SfxImageItem::Clone( SfxItemPool* ) const
58 return new SfxImageItem( *this );
62 bool SfxImageItem::operator==( const SfxPoolItem& rItem ) const
64 return (static_cast<const SfxImageItem&>(rItem).GetValue() == GetValue()) &&
65 (*pImp == *static_cast<const SfxImageItem&>(rItem).pImp);
68 bool SfxImageItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
70 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 4 );
71 aSeq[0] = ::com::sun::star::uno::makeAny( GetValue() );
72 aSeq[1] = ::com::sun::star::uno::makeAny( pImp->nAngle );
73 aSeq[2] = ::com::sun::star::uno::makeAny( pImp->bMirrored );
74 aSeq[3] = ::com::sun::star::uno::makeAny( OUString( pImp->aURL ));
76 rVal = ::com::sun::star::uno::makeAny( aSeq );
77 return true;
80 bool SfxImageItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
82 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
83 if (( rVal >>= aSeq ) && ( aSeq.getLength() == 4 ))
85 sal_Int16 nVal = sal_Int16();
86 OUString aURL;
87 if ( aSeq[0] >>= nVal )
88 SetValue( nVal );
89 aSeq[1] >>= pImp->nAngle;
90 aSeq[2] >>= pImp->bMirrored;
91 if ( aSeq[3] >>= aURL )
92 pImp->aURL = aURL;
93 return true;
96 return false;
99 void SfxImageItem::SetRotation( long nValue )
101 pImp->nAngle = nValue;
104 long SfxImageItem::GetRotation() const
106 return pImp->nAngle;
109 void SfxImageItem::SetMirrored( bool bSet )
111 pImp->bMirrored = bSet;
114 bool SfxImageItem::IsMirrored() const
116 return pImp->bMirrored;
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */