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: vmldrawing.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 #include "oox/vml/vmldrawing.hxx"
32 #include <com/sun/star/drawing/XShapes.hpp>
34 #include "oox/core/xmlfilterbase.hxx"
35 #include "oox/ole/axcontrolhelper.hxx"
36 #include "oox/vml/vmlshape.hxx"
37 #include "oox/vml/vmlshapecontainer.hxx"
39 using ::rtl::OUString
;
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::uno::UNO_QUERY
;
42 using ::com::sun::star::awt::Rectangle
;
43 using ::com::sun::star::awt::XControlModel
;
44 using ::com::sun::star::drawing::XDrawPage
;
45 using ::com::sun::star::drawing::XShapes
;
46 using ::oox::core::XmlFilterBase
;
51 // ============================================================================
55 /** Returns the textual representation of a numeric VML shape identifier. */
56 OUString
lclGetShapeId( sal_Int32 nShapeId
)
58 // identifier consists of a literal NUL character, a lowercase 's', and the id
59 return CREATE_OUSTRING( "\0s" ) + OUString::valueOf( nShapeId
);
64 // ============================================================================
66 OleObjectInfo::OleObjectInfo( bool bDmlShape
) :
68 mbDmlShape( bDmlShape
)
72 void OleObjectInfo::setShapeId( sal_Int32 nShapeId
)
74 maShapeId
= lclGetShapeId( nShapeId
);
77 // ============================================================================
79 ControlInfo::ControlInfo()
83 void ControlInfo::setShapeId( sal_Int32 nShapeId
)
85 maShapeId
= lclGetShapeId( nShapeId
);
88 // ============================================================================
90 Drawing::Drawing( XmlFilterBase
& rFilter
, const Reference
< XDrawPage
>& rxDrawPage
, DrawingType eType
) :
92 mxDrawPage( rxDrawPage
),
93 mxShapes( new ShapeContainer( *this ) ),
96 OSL_ENSURE( mxDrawPage
.is(), "Drawing::Drawing - missing UNO draw page" );
103 ::oox::ole::AxControlHelper
& Drawing::getControlHelper() const
105 // create the helper object on demand
106 if( !mxCtrlHelper
.get() )
108 mxCtrlHelper
.reset( createControlHelper() );
109 OSL_ENSURE( mxCtrlHelper
.get(), "Drawing::getControlHelper - cannot create form controls helper" );
111 return *mxCtrlHelper
;
114 void Drawing::registerOleObject( const OleObjectInfo
& rOleObject
)
116 OSL_ENSURE( rOleObject
.maShapeId
.getLength() > 0, "Drawing::registerOleObject - missing OLE object shape id" );
117 OSL_ENSURE( maOleObjects
.count( rOleObject
.maShapeId
) == 0, "Drawing::registerOleObject - OLE object already registered" );
118 maOleObjects
.insert( OleObjectInfoMap::value_type( rOleObject
.maShapeId
, rOleObject
) );
121 void Drawing::registerControl( const ControlInfo
& rControl
)
123 OSL_ENSURE( rControl
.maShapeId
.getLength() > 0, "Drawing::registerControl - missing form control shape id" );
124 OSL_ENSURE( rControl
.maName
.getLength() > 0, "Drawing::registerControl - missing form control name" );
125 OSL_ENSURE( maControls
.count( rControl
.maShapeId
) == 0, "Drawing::registerControl - form control already registered" );
126 maControls
.insert( ControlInfoMap::value_type( rControl
.maShapeId
, rControl
) );
129 void Drawing::finalizeFragmentImport()
131 mxShapes
->finalizeFragmentImport();
134 void Drawing::convertAndInsert() const
136 Reference
< XShapes
> xShapes( mxDrawPage
, UNO_QUERY
);
137 mxShapes
->convertAndInsert( xShapes
);
140 const OleObjectInfo
* Drawing::getOleObjectInfo( const OUString
& rShapeId
) const
142 return ContainerHelper::getMapElement( maOleObjects
, rShapeId
);
145 const ControlInfo
* Drawing::getControlInfo( const OUString
& rShapeId
) const
147 return ContainerHelper::getMapElement( maControls
, rShapeId
);
150 bool Drawing::isShapeSupported( const ShapeBase
& /*rShape*/ ) const
155 bool Drawing::convertShapeClientAnchor( Rectangle
& /*orShapeRect*/, const OUString
& /*rShapeAnchor*/ ) const
160 void Drawing::convertControlClientData( const Reference
< XControlModel
>& /*rxCtrlModel*/, const ShapeClientData
& /*rClientData*/ ) const
164 ::oox::ole::AxControlHelper
* Drawing::createControlHelper() const
166 return new ::oox::ole::AxEmbeddedControlHelper( mrFilter
, mxDrawPage
);
169 // ============================================================================