xref: /aoo41x/main/svl/source/items/imageitm.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svl.hxx"
30 
31 #include <svl/imageitm.hxx>
32 #include <com/sun/star/uno/Sequence.hxx>
33 
34 TYPEINIT1( SfxImageItem, SfxInt16Item );
35 
36 struct SfxImageItem_Impl
37 {
38     String  aURL;
39     long    nAngle;
40     sal_Bool    bMirrored;
41     int     operator == ( const SfxImageItem_Impl& rOther ) const
42             { return nAngle == rOther.nAngle && bMirrored == rOther.bMirrored; }
43 };
44 
45 //---------------------------------------------------------
46 
47 SfxImageItem::SfxImageItem( sal_uInt16 which, sal_uInt16 nImage )
48     : SfxInt16Item( which, nImage )
49 {
50     pImp = new SfxImageItem_Impl;
51     pImp->nAngle = 0;
52     pImp->bMirrored = sal_False;
53 }
54 
55 SfxImageItem::SfxImageItem( sal_uInt16 which, const String& rURL )
56     : SfxInt16Item( which, 0 )
57 {
58     pImp = new SfxImageItem_Impl;
59     pImp->nAngle = 0;
60     pImp->bMirrored = sal_False;
61     pImp->aURL = rURL;
62 }
63 
64 SfxImageItem::SfxImageItem( const SfxImageItem& rItem )
65     : SfxInt16Item( rItem )
66 {
67     pImp = new SfxImageItem_Impl( *(rItem.pImp) );
68 }
69 
70 //---------------------------------------------------------
71 SfxImageItem::~SfxImageItem()
72 {
73     delete pImp;
74 }
75 
76 //---------------------------------------------------------
77 
78 SfxPoolItem* SfxImageItem::Clone( SfxItemPool* ) const
79 {
80     return new SfxImageItem( *this );
81 }
82 
83 //---------------------------------------------------------
84 
85 int SfxImageItem::operator==( const SfxPoolItem& rItem ) const
86 {
87     return( ((SfxImageItem&) rItem).GetValue() == GetValue() && (*pImp == *(((SfxImageItem&)rItem).pImp) ) );
88 }
89 
90 sal_Bool SfxImageItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
91 {
92     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 4 );
93     aSeq[0] = ::com::sun::star::uno::makeAny( GetValue() );
94     aSeq[1] = ::com::sun::star::uno::makeAny( pImp->nAngle );
95     aSeq[2] = ::com::sun::star::uno::makeAny( pImp->bMirrored );
96     aSeq[3] = ::com::sun::star::uno::makeAny( rtl::OUString( pImp->aURL ));
97 
98     rVal = ::com::sun::star::uno::makeAny( aSeq );
99     return sal_True;
100 }
101 
102 sal_Bool SfxImageItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
103 {
104     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
105     if (( rVal >>= aSeq ) && ( aSeq.getLength() == 4 ))
106     {
107         sal_Int16     nVal = sal_Int16();
108         rtl::OUString aURL;
109         if ( aSeq[0] >>= nVal )
110             SetValue( nVal );
111         aSeq[1] >>= pImp->nAngle;
112         aSeq[2] >>= pImp->bMirrored;
113         if ( aSeq[3] >>= aURL )
114             pImp->aURL = aURL;
115         return sal_True;
116     }
117 
118     return sal_False;
119 }
120 
121 void SfxImageItem::SetRotation( long nValue )
122 {
123     pImp->nAngle = nValue;
124 }
125 
126 long SfxImageItem::GetRotation() const
127 {
128     return pImp->nAngle;
129 }
130 
131 void SfxImageItem::SetMirrored( sal_Bool bSet )
132 {
133     pImp->bMirrored = bSet;
134 }
135 
136 sal_Bool SfxImageItem::IsMirrored() const
137 {
138     return pImp->bMirrored;
139 }
140 
141 String SfxImageItem::GetURL() const
142 {
143     return pImp->aURL;
144 }
145 
146