Update ooo320-m1
[ooovba.git] / svx / source / svdraw / svdomedia.cxx
blobee8352b6cedbc598e451599fc673fcf754d98c37
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdomedia.cxx,v $
10 * $Revision: 1.10 $
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_svx.hxx"
34 #include <svx/svdomedia.hxx>
35 #include "svdglob.hxx"
36 #include "svdstr.hrc"
37 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
38 #include <avmedia/mediawindow.hxx>
40 // ---------------
41 // - SdrMediaObj -
42 // ---------------
44 TYPEINIT1( SdrMediaObj, SdrRectObj );
46 // ------------------------------------------------------------------------------
48 SdrMediaObj::SdrMediaObj()
52 // ------------------------------------------------------------------------------
54 SdrMediaObj::SdrMediaObj( const Rectangle& rRect ) :
55 SdrRectObj( rRect )
59 // ------------------------------------------------------------------------------
61 SdrMediaObj::~SdrMediaObj()
65 // ------------------------------------------------------------------------------
67 FASTBOOL SdrMediaObj::HasTextEdit() const
69 return FALSE;
72 // ------------------------------------------------------------------------------
74 sdr::contact::ViewContact* SdrMediaObj::CreateObjectSpecificViewContact()
76 return new ::sdr::contact::ViewContactOfSdrMediaObj( *this );
79 // ------------------------------------------------------------------------------
81 void SdrMediaObj::TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const
83 rInfo.bSelectAllowed = true;
84 rInfo.bMoveAllowed = true;
85 rInfo.bResizeFreeAllowed = true;
86 rInfo.bResizePropAllowed = true;
87 rInfo.bRotateFreeAllowed = false;
88 rInfo.bRotate90Allowed = false;
89 rInfo.bMirrorFreeAllowed = false;
90 rInfo.bMirror45Allowed = false;
91 rInfo.bMirror90Allowed = false;
92 rInfo.bTransparenceAllowed = false;
93 rInfo.bGradientAllowed = false;
94 rInfo.bShearAllowed = false;
95 rInfo.bEdgeRadiusAllowed = false;
96 rInfo.bNoOrthoDesired = false;
97 rInfo.bNoContortion = false;
98 rInfo.bCanConvToPath = false;
99 rInfo.bCanConvToPoly = false;
100 rInfo.bCanConvToContour = false;
101 rInfo.bCanConvToPathLineToArea = false;
102 rInfo.bCanConvToPolyLineToArea = false;
105 // ------------------------------------------------------------------------------
107 UINT16 SdrMediaObj::GetObjIdentifier() const
109 return UINT16( OBJ_MEDIA );
112 // ------------------------------------------------------------------------------
114 void SdrMediaObj::TakeObjNameSingul(XubString& rName) const
116 rName=ImpGetResStr(STR_ObjNameSingulMEDIA);
118 String aName( GetName() );
120 if(aName.Len())
122 rName += sal_Unicode(' ');
123 rName += sal_Unicode('\'');
124 rName += aName;
125 rName += sal_Unicode('\'');
129 // ------------------------------------------------------------------------------
131 void SdrMediaObj::TakeObjNamePlural(XubString& rName) const
133 rName=ImpGetResStr(STR_ObjNamePluralMEDIA);
136 // ------------------------------------------------------------------------------
138 void SdrMediaObj::operator=(const SdrObject& rObj)
140 SdrRectObj::operator=( rObj );
142 if( rObj.ISA( SdrMediaObj ) )
144 const SdrMediaObj& rMediaObj = static_cast< const SdrMediaObj& >( rObj );
146 setMediaProperties( rMediaObj.getMediaProperties() );
147 setGraphic( rMediaObj.mapGraphic.get() );
151 // ------------------------------------------------------------------------------
153 void SdrMediaObj::setURL( const ::rtl::OUString& rURL )
155 ::avmedia::MediaItem aURLItem;
157 aURLItem.setURL( rURL );
158 setMediaProperties( aURLItem );
161 // ------------------------------------------------------------------------------
163 const ::rtl::OUString& SdrMediaObj::getURL() const
165 return getMediaProperties().getURL();
168 // ------------------------------------------------------------------------------
170 void SdrMediaObj::setMediaProperties( const ::avmedia::MediaItem& rState )
172 mediaPropertiesChanged( rState );
173 static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).executeMediaItem( getMediaProperties() );
176 // ------------------------------------------------------------------------------
178 const ::avmedia::MediaItem& SdrMediaObj::getMediaProperties() const
180 return maMediaProperties;
183 // ------------------------------------------------------------------------------
185 bool SdrMediaObj::hasPreferredSize() const
187 return static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).hasPreferredSize();
190 // ------------------------------------------------------------------------------
192 Size SdrMediaObj::getPreferredSize() const
194 return static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).getPreferredSize();
197 // ------------------------------------------------------------------------------
199 const Graphic& SdrMediaObj::getGraphic() const
201 if( !mapGraphic.get() )
202 const_cast< SdrMediaObj* >( this )->mapGraphic.reset( new Graphic( ::avmedia::MediaWindow::grabFrame( getURL(), true ) ) );
204 return *mapGraphic;
207 // ------------------------------------------------------------------------------
209 void SdrMediaObj::setGraphic( const Graphic* pGraphic )
211 mapGraphic.reset( pGraphic ? new Graphic( *pGraphic ) : NULL );
214 // ------------------------------------------------------------------------------
216 void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProperties )
218 const sal_uInt32 nMaskSet = rNewProperties.getMaskSet();
220 // use only a subset of MediaItem properties for own own properties
221 if( ( AVMEDIA_SETMASK_URL & nMaskSet ) &&
222 ( rNewProperties.getURL() != getURL() ) )
224 setGraphic();
225 maMediaProperties.setURL( rNewProperties.getURL() );
228 if( AVMEDIA_SETMASK_LOOP & nMaskSet )
229 maMediaProperties.setLoop( rNewProperties.isLoop() );
231 if( AVMEDIA_SETMASK_MUTE & nMaskSet )
232 maMediaProperties.setMute( rNewProperties.isMute() );
234 if( AVMEDIA_SETMASK_VOLUMEDB & nMaskSet )
235 maMediaProperties.setVolumeDB( rNewProperties.getVolumeDB() );
237 if( AVMEDIA_SETMASK_ZOOM & nMaskSet )
238 maMediaProperties.setZoom( rNewProperties.getZoom() );