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