1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: imageitm.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include <svtools/imageitm.hxx>
35 #include <com/sun/star/uno/Sequence.hxx>
37 TYPEINIT1( SfxImageItem
, SfxInt16Item
);
39 struct SfxImageItem_Impl
44 int operator == ( const SfxImageItem_Impl
& rOther
) const
45 { return nAngle
== rOther
.nAngle
&& bMirrored
== rOther
.bMirrored
; }
48 //---------------------------------------------------------
50 SfxImageItem::SfxImageItem( USHORT which
, UINT16 nImage
)
51 : SfxInt16Item( which
, nImage
)
53 pImp
= new SfxImageItem_Impl
;
55 pImp
->bMirrored
= FALSE
;
58 SfxImageItem::SfxImageItem( USHORT which
, const String
& rURL
)
59 : SfxInt16Item( which
, 0 )
61 pImp
= new SfxImageItem_Impl
;
63 pImp
->bMirrored
= FALSE
;
67 SfxImageItem::SfxImageItem( const SfxImageItem
& rItem
)
68 : SfxInt16Item( rItem
)
70 pImp
= new SfxImageItem_Impl( *(rItem
.pImp
) );
73 //---------------------------------------------------------
74 SfxImageItem::~SfxImageItem()
79 //---------------------------------------------------------
81 SfxPoolItem
* SfxImageItem::Clone( SfxItemPool
* ) const
83 return new SfxImageItem( *this );
86 //---------------------------------------------------------
88 int SfxImageItem::operator==( const SfxPoolItem
& rItem
) const
90 return( ((SfxImageItem
&) rItem
).GetValue() == GetValue() && (*pImp
== *(((SfxImageItem
&)rItem
).pImp
) ) );
93 BOOL
SfxImageItem::QueryValue( com::sun::star::uno::Any
& rVal
, BYTE
) const
95 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq( 4 );
96 aSeq
[0] = ::com::sun::star::uno::makeAny( GetValue() );
97 aSeq
[1] = ::com::sun::star::uno::makeAny( pImp
->nAngle
);
98 aSeq
[2] = ::com::sun::star::uno::makeAny( pImp
->bMirrored
);
99 aSeq
[3] = ::com::sun::star::uno::makeAny( rtl::OUString( pImp
->aURL
));
101 rVal
= ::com::sun::star::uno::makeAny( aSeq
);
105 BOOL
SfxImageItem::PutValue( const com::sun::star::uno::Any
& rVal
, BYTE
)
107 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq
;
108 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 4 ))
110 sal_Int16 nVal
= sal_Int16();
112 if ( aSeq
[0] >>= nVal
)
114 aSeq
[1] >>= pImp
->nAngle
;
115 aSeq
[2] >>= pImp
->bMirrored
;
116 if ( aSeq
[3] >>= aURL
)
124 void SfxImageItem::SetRotation( long nValue
)
126 pImp
->nAngle
= nValue
;
129 long SfxImageItem::GetRotation() const
134 void SfxImageItem::SetMirrored( BOOL bSet
)
136 pImp
->bMirrored
= bSet
;
139 BOOL
SfxImageItem::IsMirrored() const
141 return pImp
->bMirrored
;
144 String
SfxImageItem::GetURL() const