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/Any.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <oox/dllapi.h>
26 #include <rtl/ustring.hxx>
27 #include <sal/types.h>
29 namespace com::sun::star
{
30 namespace awt
{ struct Gradient
;
33 namespace graphic
{ class XGraphic
; }
34 namespace container
{ class XNameContainer
; }
35 namespace drawing
{ struct LineDash
; }
36 namespace drawing
{ struct Hatch
; }
37 namespace drawing
{ struct PolyPolygonBezierCoords
; }
38 namespace lang
{ class XMultiServiceFactory
; }
44 /** This helper manages named objects in a container, which is created on demand.
46 class OOX_DLLPUBLIC ObjectContainer
49 explicit ObjectContainer(
50 const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rxModelFactory
,
51 OUString aServiceName
);
54 /** Returns true, if the object with the passed name exists in the container. */
55 bool hasObject( const OUString
& rObjName
) const;
57 css::uno::Any
getObject( const OUString
& rObjName
) const;
59 /** Inserts the passed object into the container, returns its final name. */
60 OUString
insertObject(
61 const OUString
& rObjName
,
62 const css::uno::Any
& rObj
,
63 bool bInsertByUnusedName
);
66 void createContainer() const;
69 mutable css::uno::Reference
< css::lang::XMultiServiceFactory
>
70 mxModelFactory
; ///< Factory to create the container.
71 mutable css::uno::Reference
< css::container::XNameContainer
>
72 mxContainer
; ///< Container for the objects.
73 OUString maServiceName
; ///< Service name to create the container.
74 sal_Int32 mnIndex
; ///< Index to create unique identifiers.
78 /** Contains tables for named drawing objects for a document model.
80 Contains tables for named line markers, line dashes, fill gradients, and
81 fill bitmap URLs. The class is needed to handle different document models
82 in the same filter (e.g. embedded charts) which carry their own drawing
85 class OOX_DLLPUBLIC ModelObjectHelper
88 explicit ModelObjectHelper(
89 const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rxModelFactory
);
91 /** Returns true, if the model contains a line marker with the passed name. */
92 bool hasLineMarker( const OUString
& rMarkerName
) const;
94 /** Inserts a new named line marker, overwrites an existing line marker
95 with the same name. Returns true, if the marker could be inserted. */
96 bool insertLineMarker(
97 const OUString
& rMarkerName
,
98 const css::drawing::PolyPolygonBezierCoords
& rMarker
);
100 /** Inserts a new named line dash, returns the line dash name, based on an
101 internal constant name with a new unused index appended. */
102 OUString
insertLineDash( const css::drawing::LineDash
& rDash
);
104 /** Inserts a new named fill gradient, returns the gradient name, based on
105 an internal constant name with a new unused index appended. */
106 OUString
insertFillGradient( const css::awt::Gradient2
& rGradient
);
107 OUString
insertFillGradient( const css::awt::Gradient
& rGradient
);
109 OUString
insertTransGrandient( const css::awt::Gradient2
& rGradient
);
110 OUString
insertTransGrandient( const css::awt::Gradient
& rGradient
);
112 OUString
insertFillHatch( const css::drawing::Hatch
& rHatch
);
114 /** Inserts a new named fill graphic, returns the bitmap name, based on
115 an internal constant name with a new unused index appended. */
116 OUString
insertFillBitmapXGraphic(css::uno::Reference
<css::graphic::XGraphic
> const & rxGraphic
);
118 css::uno::Reference
<css::awt::XBitmap
> getFillBitmap(OUString
const & rGraphicName
);
121 ObjectContainer maMarkerContainer
; ///< Contains all named line markers (line end polygons).
122 ObjectContainer maDashContainer
; ///< Contains all named line dashes.
123 ObjectContainer maGradientContainer
; ///< Contains all named fill gradients.
124 ObjectContainer maTransGradContainer
; ///< Contains all named transparency Gradients.
125 ObjectContainer maBitmapUrlContainer
; ///< Contains all named fill bitmap URLs.
126 ObjectContainer maHatchContainer
; ///< Contains all named fill hatches.
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */