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: modelobjecthelper.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/helper/modelobjecthelper.hxx"
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/awt/Gradient.hpp>
34 #include <com/sun/star/drawing/LineDash.hpp>
35 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
36 #include "oox/helper/helper.hxx"
38 using ::rtl::OUString
;
39 using ::com::sun::star::uno::Any
;
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::lang::XMultiServiceFactory
;
42 using ::com::sun::star::awt::Gradient
;
43 using ::com::sun::star::drawing::LineDash
;
44 using ::com::sun::star::drawing::PolyPolygonBezierCoords
;
48 // ============================================================================
50 ModelObjectHelper::ModelObjectHelper( const Reference
< XMultiServiceFactory
>& rxFactory
) :
51 maMarkerContainer( rxFactory
, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ),
52 maDashContainer( rxFactory
, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ),
53 maGradientContainer( rxFactory
, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ),
54 maBitmapContainer( rxFactory
, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ),
55 maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ),
56 maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ),
57 maBitmapNameBase( CREATE_OUSTRING( "msFillBitmap " ) )
61 bool ModelObjectHelper::hasLineMarker( const OUString
& rMarkerName
) const
63 return maMarkerContainer
.hasObject( rMarkerName
);
66 bool ModelObjectHelper::insertLineMarker( const OUString
& rMarkerName
, const PolyPolygonBezierCoords
& rMarker
)
68 OSL_ENSURE( rMarker
.Coordinates
.hasElements(), "ModelObjectHelper::insertLineMarker - line marker without coordinates" );
69 if( rMarker
.Coordinates
.hasElements() )
70 return maMarkerContainer
.insertObject( rMarkerName
, Any( rMarker
), false ).getLength() > 0;
74 OUString
ModelObjectHelper::insertLineDash( const LineDash
& rDash
)
76 return maDashContainer
.insertObject( maDashNameBase
, Any( rDash
), true );
79 OUString
ModelObjectHelper::insertFillGradient( const Gradient
& rGradient
)
81 return maGradientContainer
.insertObject( maGradientNameBase
, Any( rGradient
), true );
84 OUString
ModelObjectHelper::insertFillBitmap( const OUString
& rGraphicUrl
)
86 if( rGraphicUrl
.getLength() > 0 )
87 return maBitmapContainer
.insertObject( maBitmapNameBase
, Any( rGraphicUrl
), true );
91 // ============================================================================