Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef OOX_HELPER_MODELOBJECTHELPER_HXX
21 : #define OOX_HELPER_MODELOBJECTHELPER_HXX
22 :
23 : #include <com/sun/star/uno/Reference.hxx>
24 : #include "oox/dllapi.h"
25 :
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; }
32 : } } }
33 :
34 : namespace oox {
35 :
36 : // ============================================================================
37 :
38 : /** This helper manages named objects in a container, which is created on demand.
39 : */
40 : class OOX_DLLPUBLIC ObjectContainer
41 : {
42 : public:
43 : explicit ObjectContainer(
44 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory,
45 : const OUString& rServiceName );
46 : ~ObjectContainer();
47 :
48 : /** Returns true, if the object with the passed name exists in the container. */
49 : bool hasObject( const OUString& rObjName ) const;
50 :
51 : /** Inserts the passed object into the container, returns its final name. */
52 : OUString insertObject(
53 : const OUString& rObjName,
54 : const ::com::sun::star::uno::Any& rObj,
55 : bool bInsertByUnusedName );
56 :
57 : private:
58 : void createContainer() const;
59 :
60 : private:
61 : mutable ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
62 : mxModelFactory; ///< Factory to create the container.
63 : mutable ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
64 : mxContainer; ///< Container for the objects.
65 : OUString maServiceName; ///< Service name to create the container.
66 : sal_Int32 mnIndex; ///< Index to create unique identifiers.
67 : };
68 :
69 : // ============================================================================
70 :
71 : /** Contains tables for named drawing objects for a document model.
72 :
73 : Contains tables for named line markers, line dashes, fill gradients, and
74 : fill bitmap URLs. The class is needed to handle different document models
75 : in the same filter (e.g. embedded charts) which carry their own drawing
76 : object tables.
77 : */
78 84 : class OOX_DLLPUBLIC ModelObjectHelper
79 : {
80 : public:
81 : explicit ModelObjectHelper(
82 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory );
83 :
84 : /** Returns true, if the model contains a line marker with the passed name. */
85 : bool hasLineMarker( const OUString& rMarkerName ) const;
86 :
87 : /** Inserts a new named line marker, overwrites an existing line marker
88 : with the same name. Returns true, if the marker could be inserted. */
89 : bool insertLineMarker(
90 : const OUString& rMarkerName,
91 : const ::com::sun::star::drawing::PolyPolygonBezierCoords& rMarker );
92 :
93 : /** Inserts a new named line dash, returns the line dash name, based on an
94 : internal constant name with a new unused index appended. */
95 : OUString insertLineDash( const ::com::sun::star::drawing::LineDash& rDash );
96 :
97 : /** Inserts a new named fill gradient, returns the gradient name, based on
98 : an internal constant name with a new unused index appended. */
99 : OUString insertFillGradient( const ::com::sun::star::awt::Gradient& rGradient );
100 :
101 : OUString insertTransGrandient( const ::com::sun::star::awt::Gradient& rGradient );
102 :
103 : /** Inserts a new named fill bitmap URL, returns the bitmap name, based on
104 : an internal constant name with a new unused index appended. */
105 : OUString insertFillBitmapUrl( const OUString& rGraphicUrl );
106 :
107 : private:
108 : ObjectContainer maMarkerContainer; ///< Contains all named line markers (line end polygons).
109 : ObjectContainer maDashContainer; ///< Contains all named line dsahes.
110 : ObjectContainer maGradientContainer; ///< Contains all named fill gradients.
111 : ObjectContainer maTransGradContainer; ///< Contains all named transparency Gradients.
112 : ObjectContainer maBitmapUrlContainer; ///< Contains all named fill bitmap URLs.
113 : const OUString maDashNameBase; ///< Base name for all named line dashes.
114 : const OUString maGradientNameBase; ///< Base name for all named fill gradients.
115 : const OUString maTransGradNameBase; ///< Base name for all named fill gradients.
116 : const OUString maBitmapUrlNameBase; ///< Base name for all named fill bitmap URLs.
117 : };
118 :
119 : // ============================================================================
120 :
121 : } // namespace oox
122 :
123 : #endif
124 :
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|