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