1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OOX_HELPER_MODELOBJECTHELPER_HXX
21 #define INCLUDED_OOX_HELPER_MODELOBJECTHELPER_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <oox/dllapi.h>
26 namespace com
{ namespace sun
{ namespace star
{
27 namespace awt
{ struct Gradient
; }
28 namespace container
{ class XNameContainer
; }
29 namespace drawing
{ struct LineDash
; }
30 namespace drawing
{ struct PolyPolygonBezierCoords
; }
31 namespace lang
{ class XMultiServiceFactory
; }
38 /** This helper manages named objects in a container, which is created on demand.
40 class OOX_DLLPUBLIC ObjectContainer
43 explicit ObjectContainer(
44 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& rxModelFactory
,
45 const OUString
& rServiceName
);
48 /** Returns true, if the object with the passed name exists in the container. */
49 bool hasObject( const OUString
& rObjName
) const;
51 ::com::sun::star::uno::Any
getObject( const OUString
& rObjName
) const;
53 /** Inserts the passed object into the container, returns its final name. */
54 OUString
insertObject(
55 const OUString
& rObjName
,
56 const ::com::sun::star::uno::Any
& rObj
,
57 bool bInsertByUnusedName
);
60 void createContainer() const;
63 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
64 mxModelFactory
; ///< Factory to create the container.
65 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>
66 mxContainer
; ///< Container for the objects.
67 OUString maServiceName
; ///< Service name to create the container.
68 sal_Int32 mnIndex
; ///< Index to create unique identifiers.
73 /** Contains tables for named drawing objects for a document model.
75 Contains tables for named line markers, line dashes, fill gradients, and
76 fill bitmap URLs. The class is needed to handle different document models
77 in the same filter (e.g. embedded charts) which carry their own drawing
80 class OOX_DLLPUBLIC ModelObjectHelper
83 explicit ModelObjectHelper(
84 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& rxModelFactory
);
86 /** Returns true, if the model contains a line marker with the passed name. */
87 bool hasLineMarker( const OUString
& rMarkerName
) const;
89 /** Inserts a new named line marker, overwrites an existing line marker
90 with the same name. Returns true, if the marker could be inserted. */
91 bool insertLineMarker(
92 const OUString
& rMarkerName
,
93 const ::com::sun::star::drawing::PolyPolygonBezierCoords
& rMarker
);
95 /** Inserts a new named line dash, returns the line dash name, based on an
96 internal constant name with a new unused index appended. */
97 OUString
insertLineDash( const ::com::sun::star::drawing::LineDash
& rDash
);
99 /** Inserts a new named fill gradient, returns the gradient name, based on
100 an internal constant name with a new unused index appended. */
101 OUString
insertFillGradient( const ::com::sun::star::awt::Gradient
& rGradient
);
103 OUString
insertTransGrandient( const ::com::sun::star::awt::Gradient
& rGradient
);
105 /** Inserts a new named fill bitmap URL, returns the bitmap name, based on
106 an internal constant name with a new unused index appended. */
107 OUString
insertFillBitmapUrl( const OUString
& rGraphicUrl
);
109 OUString
getFillBitmapUrl( const OUString
& rGraphicName
);
112 ObjectContainer maMarkerContainer
; ///< Contains all named line markers (line end polygons).
113 ObjectContainer maDashContainer
; ///< Contains all named line dsahes.
114 ObjectContainer maGradientContainer
; ///< Contains all named fill gradients.
115 ObjectContainer maTransGradContainer
; ///< Contains all named transparency Gradients.
116 ObjectContainer maBitmapUrlContainer
; ///< Contains all named fill bitmap URLs.
117 const OUString maDashNameBase
; ///< Base name for all named line dashes.
118 const OUString maGradientNameBase
; ///< Base name for all named fill gradients.
119 const OUString maTransGradNameBase
; ///< Base name for all named fill gradients.
120 const OUString maBitmapUrlNameBase
; ///< Base name for all named fill bitmap URLs.
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */