1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_ATTRIBUTABLESHAPE_HXX
29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_ATTRIBUTABLESHAPE_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "animatableshape.hxx"
34*cdf0e10cSrcweir #include "shapeattributelayer.hxx"
35*cdf0e10cSrcweir #include "doctreenodesupplier.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace slideshow
38*cdf0e10cSrcweir {
39*cdf0e10cSrcweir     namespace internal
40*cdf0e10cSrcweir     {
41*cdf0e10cSrcweir         // forward declaration necessary, because methods use AttributableShapeSharedPtr
42*cdf0e10cSrcweir         class AttributableShape;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir         typedef ::boost::shared_ptr< AttributableShape > AttributableShapeSharedPtr;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir         /** Represents an animatable shape, that can have its
47*cdf0e10cSrcweir             attributes changed.
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir             Over an animatable shape, this interface adds attribute
50*cdf0e10cSrcweir             modification methods. Furthermore, the shape can be
51*cdf0e10cSrcweir             queried for sub items, which in turn can be separated out
52*cdf0e10cSrcweir             into own AttributableShapes.
53*cdf0e10cSrcweir          */
54*cdf0e10cSrcweir         class AttributableShape : public AnimatableShape
55*cdf0e10cSrcweir         {
56*cdf0e10cSrcweir         public:
57*cdf0e10cSrcweir             // Attribute layer methods
58*cdf0e10cSrcweir             //------------------------------------------------------------------
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir             /** Create a new shape attribute layer.
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 				This method creates a new layer for shape attributes,
63*cdf0e10cSrcweir 				which lies atop of all previous attribute layers. That
64*cdf0e10cSrcweir 				is most typically used when a new SMIL animation
65*cdf0e10cSrcweir 				starts (which according to the spec always lies atop
66*cdf0e10cSrcweir 				of all previous animations). Thus, subsequent calls to
67*cdf0e10cSrcweir 				this method generate a sandwich of attribute layers,
68*cdf0e10cSrcweir 				which in total define the shape's attributes.
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir                 Please note that the attribute layers do <em>not</em>
71*cdf0e10cSrcweir                 contain the underlying XShape's attributes as
72*cdf0e10cSrcweir                 default. Instead, attributes not explicitely set by
73*cdf0e10cSrcweir                 animations remain in invalid state, allowing the
74*cdf0e10cSrcweir                 shape's paint method to determine whether they have to
75*cdf0e10cSrcweir                 override the underlying graphical shape
76*cdf0e10cSrcweir                 representation. XShape attributes must be passed
77*cdf0e10cSrcweir                 explicitely to animations which need them (e.g. 'by'
78*cdf0e10cSrcweir                 animations).
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir                 @return the new layer
81*cdf0e10cSrcweir              */
82*cdf0e10cSrcweir             virtual ShapeAttributeLayerSharedPtr createAttributeLayer() = 0;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir             /** Revoke a previously generated attribute layer.
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir             	This method revokes a previously generated attribute
87*cdf0e10cSrcweir             	layer, and removes the effect of that layer from this
88*cdf0e10cSrcweir             	shape. The layer need not be the current toplevel
89*cdf0e10cSrcweir             	layer, it can also be revoked from in between.
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir                 @param rLayer
92*cdf0e10cSrcweir                 Layer to revoke. Must have been generated by
93*cdf0e10cSrcweir                 createAttributeLayer() at the same Shape.
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir                 @return true, if layer was successfully removed, false
96*cdf0e10cSrcweir                 otherwise (e.g. if the given layer was not generated
97*cdf0e10cSrcweir                 for this shape).
98*cdf0e10cSrcweir              */
99*cdf0e10cSrcweir             virtual bool revokeAttributeLayer( const ShapeAttributeLayerSharedPtr& rLayer ) = 0;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir             /** Get the topmost shape attribute layer (if any).
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 				This method returns the topmost layer for shape
104*cdf0e10cSrcweir 				attributes, i.e. the one which ultimately determines
105*cdf0e10cSrcweir 				the shape's look.
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir                 Please note that the attribute layers do <em>not</em>
108*cdf0e10cSrcweir                 contain the underlying XShape's attributes as
109*cdf0e10cSrcweir                 default. Instead, attributes not explicitely set by
110*cdf0e10cSrcweir                 animations remain in invalid state, allowing the
111*cdf0e10cSrcweir                 shape's paint method to determine whether they have to
112*cdf0e10cSrcweir                 override the underlying graphical shape
113*cdf0e10cSrcweir                 representation. XShape attributes must be passed
114*cdf0e10cSrcweir                 explicitely to animations which need them (e.g. 'by'
115*cdf0e10cSrcweir                 animations).
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir                 @return the topmost layer
118*cdf0e10cSrcweir              */
119*cdf0e10cSrcweir             virtual ShapeAttributeLayerSharedPtr getTopmostAttributeLayer() const = 0;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir             /** Change default shape visibility
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir             	This method hides or unhides a shape. Note that every
125*cdf0e10cSrcweir             	attribute layer generated for this shape is able to
126*cdf0e10cSrcweir             	override the setting given here, until it is revoked.
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir                 @param bVisible
129*cdf0e10cSrcweir                 When true, shape will be visible, when false,
130*cdf0e10cSrcweir                 invisible (modulo attribute layer overrides).
131*cdf0e10cSrcweir              */
132*cdf0e10cSrcweir             virtual void setVisibility( bool bVisible ) = 0;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir             // Sub-item handling
135*cdf0e10cSrcweir             //------------------------------------------------------------------
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir             /** Retrieve interface for DocTreeNode creation.
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir             	This method provides the caller with a reference to
140*cdf0e10cSrcweir             	the DocTreeNodeSupplier interface, which can be used
141*cdf0e10cSrcweir             	to request specific tree nodes for this shape.
142*cdf0e10cSrcweir              */
143*cdf0e10cSrcweir             virtual const DocTreeNodeSupplier& getTreeNodeSupplier() const = 0;
144*cdf0e10cSrcweir             virtual DocTreeNodeSupplier& 	   getTreeNodeSupplier() = 0;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir             /** Query the subset this shape displays.
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir             	This method returns a tree node denoting the subset
149*cdf0e10cSrcweir             	displayed by this shape. If this shape is not a subset
150*cdf0e10cSrcweir             	shape, an empty tree node should be returned. If this
151*cdf0e10cSrcweir             	shape is a subset, and itself has subsetted children,
152*cdf0e10cSrcweir             	this method might return more than the shape is
153*cdf0e10cSrcweir             	actually displaying (because a single DocTreeNode is
154*cdf0e10cSrcweir             	not able to model holes in the range).
155*cdf0e10cSrcweir              */
156*cdf0e10cSrcweir             virtual DocTreeNode getSubsetNode() const = 0;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir             /** Query a subset Shape, if already existent at this
159*cdf0e10cSrcweir                 object
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 				This method returns a clone of this Shape, which
162*cdf0e10cSrcweir 				renders only the selected subset of itself, but only
163*cdf0e10cSrcweir 				if such a subset has been explicitely created before.
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir                 @param rTreeNode
166*cdf0e10cSrcweir                 A DocTreeNode instance queried from this Shape, which
167*cdf0e10cSrcweir                 specifies the subset of the Shape to render.
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir                 @return a NULL Shape pointer, if no subset exists for
170*cdf0e10cSrcweir                 the given DocTreeNode.
171*cdf0e10cSrcweir             */
172*cdf0e10cSrcweir             virtual AttributableShapeSharedPtr getSubset( const DocTreeNode& rTreeNode ) const = 0;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir             /** Create a subset Shape
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 				This method creates a clone of this Shape, which
177*cdf0e10cSrcweir 				renders only the selected subset of itself. Multiple
178*cdf0e10cSrcweir 				createSubset() calls for the same DocTreeNode will all
179*cdf0e10cSrcweir 				share the same subset shape.
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir                 The original shape (i.e. the one this method is called
182*cdf0e10cSrcweir                 on) will cease to display the selected subset
183*cdf0e10cSrcweir                 part. That is, together the shapes will display the
184*cdf0e10cSrcweir                 original content, but the content of all subset shapes
185*cdf0e10cSrcweir                 and their original shape will always be mutually
186*cdf0e10cSrcweir                 disjunct.
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir                 After deregistering the subset shape a matching number
189*cdf0e10cSrcweir                 of times via revokeSubset(), the original shape will
190*cdf0e10cSrcweir                 resume displaying the subsetted part.
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir                 @attention To maintain view integrity, this method
193*cdf0e10cSrcweir                 should only be called from the LayerManager
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir                 @param o_rSubset
196*cdf0e10cSrcweir                 The requested Shape
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir                 @param rTreeNode
199*cdf0e10cSrcweir                 A DocTreeNode instance queried from this Shape, which
200*cdf0e10cSrcweir                 specifies the subset of the Shape to render
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir                 @return true, if the shape was newly created, and
203*cdf0e10cSrcweir                 false, if an already existing subset is returned.
204*cdf0e10cSrcweir             */
205*cdf0e10cSrcweir             virtual bool createSubset( AttributableShapeSharedPtr& 	o_rSubset,
206*cdf0e10cSrcweir                                        const DocTreeNode& 			rTreeNode ) = 0;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir             /** Revoke a previously generated shape subset.
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir             	After revoking a subset shape, the corresponding
211*cdf0e10cSrcweir             	subset part will become visible again on the original
212*cdf0e10cSrcweir             	shape.
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir                 @attention To maintain view integrity, this method
215*cdf0e10cSrcweir                 should only be called from the LayerManager
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir                 @param rShape
218*cdf0e10cSrcweir                 The subset to revoke
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir                 @return true, if the last client called
221*cdf0e10cSrcweir                 revokeSubset().
222*cdf0e10cSrcweir              */
223*cdf0e10cSrcweir             virtual bool revokeSubset( const AttributableShapeSharedPtr& rShape ) = 0;
224*cdf0e10cSrcweir         };
225*cdf0e10cSrcweir     }
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_ATTRIBUTABLESHAPE_HXX */
229