1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*40df464eSAndrew Rist * distributed with this work for additional information
6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist * software distributed under the License is distributed on an
15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the
17*40df464eSAndrew Rist * specific language governing permissions and limitations
18*40df464eSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*40df464eSAndrew Rist *************************************************************/
21*40df464eSAndrew Rist
22*40df464eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svl/imageitm.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir TYPEINIT1( SfxImageItem, SfxInt16Item );
31cdf0e10cSrcweir
32cdf0e10cSrcweir struct SfxImageItem_Impl
33cdf0e10cSrcweir {
34cdf0e10cSrcweir String aURL;
35cdf0e10cSrcweir long nAngle;
36cdf0e10cSrcweir sal_Bool bMirrored;
operator ==SfxImageItem_Impl37cdf0e10cSrcweir int operator == ( const SfxImageItem_Impl& rOther ) const
38cdf0e10cSrcweir { return nAngle == rOther.nAngle && bMirrored == rOther.bMirrored; }
39cdf0e10cSrcweir };
40cdf0e10cSrcweir
41cdf0e10cSrcweir //---------------------------------------------------------
42cdf0e10cSrcweir
SfxImageItem(sal_uInt16 which,sal_uInt16 nImage)43cdf0e10cSrcweir SfxImageItem::SfxImageItem( sal_uInt16 which, sal_uInt16 nImage )
44cdf0e10cSrcweir : SfxInt16Item( which, nImage )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir pImp = new SfxImageItem_Impl;
47cdf0e10cSrcweir pImp->nAngle = 0;
48cdf0e10cSrcweir pImp->bMirrored = sal_False;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
SfxImageItem(sal_uInt16 which,const String & rURL)51cdf0e10cSrcweir SfxImageItem::SfxImageItem( sal_uInt16 which, const String& rURL )
52cdf0e10cSrcweir : SfxInt16Item( which, 0 )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir pImp = new SfxImageItem_Impl;
55cdf0e10cSrcweir pImp->nAngle = 0;
56cdf0e10cSrcweir pImp->bMirrored = sal_False;
57cdf0e10cSrcweir pImp->aURL = rURL;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
SfxImageItem(const SfxImageItem & rItem)60cdf0e10cSrcweir SfxImageItem::SfxImageItem( const SfxImageItem& rItem )
61cdf0e10cSrcweir : SfxInt16Item( rItem )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir pImp = new SfxImageItem_Impl( *(rItem.pImp) );
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
66cdf0e10cSrcweir //---------------------------------------------------------
~SfxImageItem()67cdf0e10cSrcweir SfxImageItem::~SfxImageItem()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir delete pImp;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
72cdf0e10cSrcweir //---------------------------------------------------------
73cdf0e10cSrcweir
Clone(SfxItemPool *) const74cdf0e10cSrcweir SfxPoolItem* SfxImageItem::Clone( SfxItemPool* ) const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir return new SfxImageItem( *this );
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir //---------------------------------------------------------
80cdf0e10cSrcweir
operator ==(const SfxPoolItem & rItem) const81cdf0e10cSrcweir int SfxImageItem::operator==( const SfxPoolItem& rItem ) const
82cdf0e10cSrcweir {
83cdf0e10cSrcweir return( ((SfxImageItem&) rItem).GetValue() == GetValue() && (*pImp == *(((SfxImageItem&)rItem).pImp) ) );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const86cdf0e10cSrcweir sal_Bool SfxImageItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
87cdf0e10cSrcweir {
88cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 4 );
89cdf0e10cSrcweir aSeq[0] = ::com::sun::star::uno::makeAny( GetValue() );
90cdf0e10cSrcweir aSeq[1] = ::com::sun::star::uno::makeAny( pImp->nAngle );
91cdf0e10cSrcweir aSeq[2] = ::com::sun::star::uno::makeAny( pImp->bMirrored );
92cdf0e10cSrcweir aSeq[3] = ::com::sun::star::uno::makeAny( rtl::OUString( pImp->aURL ));
93cdf0e10cSrcweir
94cdf0e10cSrcweir rVal = ::com::sun::star::uno::makeAny( aSeq );
95cdf0e10cSrcweir return sal_True;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)98cdf0e10cSrcweir sal_Bool SfxImageItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
101cdf0e10cSrcweir if (( rVal >>= aSeq ) && ( aSeq.getLength() == 4 ))
102cdf0e10cSrcweir {
103cdf0e10cSrcweir sal_Int16 nVal = sal_Int16();
104cdf0e10cSrcweir rtl::OUString aURL;
105cdf0e10cSrcweir if ( aSeq[0] >>= nVal )
106cdf0e10cSrcweir SetValue( nVal );
107cdf0e10cSrcweir aSeq[1] >>= pImp->nAngle;
108cdf0e10cSrcweir aSeq[2] >>= pImp->bMirrored;
109cdf0e10cSrcweir if ( aSeq[3] >>= aURL )
110cdf0e10cSrcweir pImp->aURL = aURL;
111cdf0e10cSrcweir return sal_True;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir return sal_False;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
SetRotation(long nValue)117cdf0e10cSrcweir void SfxImageItem::SetRotation( long nValue )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir pImp->nAngle = nValue;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
GetRotation() const122cdf0e10cSrcweir long SfxImageItem::GetRotation() const
123cdf0e10cSrcweir {
124cdf0e10cSrcweir return pImp->nAngle;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
SetMirrored(sal_Bool bSet)127cdf0e10cSrcweir void SfxImageItem::SetMirrored( sal_Bool bSet )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir pImp->bMirrored = bSet;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
IsMirrored() const132cdf0e10cSrcweir sal_Bool SfxImageItem::IsMirrored() const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir return pImp->bMirrored;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
GetURL() const137cdf0e10cSrcweir String SfxImageItem::GetURL() const
138cdf0e10cSrcweir {
139cdf0e10cSrcweir return pImp->aURL;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142