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