Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / helper / modelobjecthelper.hxx
blob986e0c7c59450f40429b83df3a2b36b6a7151ac8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 { namespace sun { namespace star {
30 namespace awt { struct Gradient; }
31 namespace container { class XNameContainer; }
32 namespace drawing { struct LineDash; }
33 namespace drawing { struct PolyPolygonBezierCoords; }
34 namespace lang { class XMultiServiceFactory; }
35 } } }
37 namespace oox {
40 /** This helper manages named objects in a container, which is created on demand.
42 class OOX_DLLPUBLIC ObjectContainer
44 public:
45 explicit ObjectContainer(
46 const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory,
47 const OUString& rServiceName );
48 ~ObjectContainer();
50 /** Returns true, if the object with the passed name exists in the container. */
51 bool hasObject( const OUString& rObjName ) const;
53 css::uno::Any getObject( const OUString& rObjName ) const;
55 /** Inserts the passed object into the container, returns its final name. */
56 OUString insertObject(
57 const OUString& rObjName,
58 const css::uno::Any& rObj,
59 bool bInsertByUnusedName );
61 private:
62 void createContainer() const;
64 private:
65 mutable css::uno::Reference< css::lang::XMultiServiceFactory >
66 mxModelFactory; ///< Factory to create the container.
67 mutable css::uno::Reference< css::container::XNameContainer >
68 mxContainer; ///< Container for the objects.
69 OUString maServiceName; ///< Service name to create the container.
70 sal_Int32 mnIndex; ///< Index to create unique identifiers.
74 /** Contains tables for named drawing objects for a document model.
76 Contains tables for named line markers, line dashes, fill gradients, and
77 fill bitmap URLs. The class is needed to handle different document models
78 in the same filter (e.g. embedded charts) which carry their own drawing
79 object tables.
81 class OOX_DLLPUBLIC ModelObjectHelper
83 public:
84 explicit ModelObjectHelper(
85 const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory );
87 /** Returns true, if the model contains a line marker with the passed name. */
88 bool hasLineMarker( const OUString& rMarkerName ) const;
90 /** Inserts a new named line marker, overwrites an existing line marker
91 with the same name. Returns true, if the marker could be inserted. */
92 bool insertLineMarker(
93 const OUString& rMarkerName,
94 const css::drawing::PolyPolygonBezierCoords& rMarker );
96 /** Inserts a new named line dash, returns the line dash name, based on an
97 internal constant name with a new unused index appended. */
98 OUString insertLineDash( const css::drawing::LineDash& rDash );
100 /** Inserts a new named fill gradient, returns the gradient name, based on
101 an internal constant name with a new unused index appended. */
102 OUString insertFillGradient( const css::awt::Gradient& rGradient );
104 OUString insertTransGrandient( const css::awt::Gradient& rGradient );
106 /** Inserts a new named fill bitmap URL, returns the bitmap name, based on
107 an internal constant name with a new unused index appended. */
108 OUString insertFillBitmapUrl( const OUString& rGraphicUrl );
110 OUString getFillBitmapUrl( const OUString& rGraphicName );
112 private:
113 ObjectContainer maMarkerContainer; ///< Contains all named line markers (line end polygons).
114 ObjectContainer maDashContainer; ///< Contains all named line dashes.
115 ObjectContainer maGradientContainer; ///< Contains all named fill gradients.
116 ObjectContainer maTransGradContainer; ///< Contains all named transparency Gradients.
117 ObjectContainer maBitmapUrlContainer; ///< Contains all named fill bitmap URLs.
118 const OUString maDashNameBase; ///< Base name for all named line dashes.
119 const OUString maGradientNameBase; ///< Base name for all named fill gradients.
120 const OUString maTransGradNameBase; ///< Base name for all named fill gradients.
121 const OUString maBitmapUrlNameBase; ///< Base name for all named fill bitmap URLs.
125 } // namespace oox
127 #endif
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */