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_SHAPESUBSET_HXX
25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_SHAPESUBSET_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "attributableshape.hxx"
28cdf0e10cSrcweir #include "subsettableshapemanager.hxx"
29cdf0e10cSrcweir #include "doctreenode.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace slideshow
34cdf0e10cSrcweir {
35cdf0e10cSrcweir     namespace internal
36cdf0e10cSrcweir     {
37cdf0e10cSrcweir         class ShapeSubset;
38cdf0e10cSrcweir         typedef ::boost::shared_ptr< ShapeSubset > ShapeSubsetSharedPtr;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 		/* Definition of ShapeSubset class */
41cdf0e10cSrcweir 
42cdf0e10cSrcweir         /** Subset RAII wrapper for shapes.
43cdf0e10cSrcweir 
44cdf0e10cSrcweir         	This class wraps the plain Shape with a wrapper for subset
45cdf0e10cSrcweir         	functionality. Subsetting can be turned on and off. Note
46cdf0e10cSrcweir         	that the reason to have shape subsetting RAII implemented
47cdf0e10cSrcweir         	separately (i.e. not within the DrawShape) was that
48cdf0e10cSrcweir         	subsetting (and de-subsetting) needs the
49cdf0e10cSrcweir         	SubsettableShapeManager. And holding that at the DrawShape
50cdf0e10cSrcweir         	creates one heck of a circular reference.
51cdf0e10cSrcweir          */
52cdf0e10cSrcweir         class ShapeSubset
53cdf0e10cSrcweir         {
54cdf0e10cSrcweir         public:
55cdf0e10cSrcweir             /** Create a subset directly from a Shape.
56cdf0e10cSrcweir 
57cdf0e10cSrcweir             	@param rOriginalShape
58cdf0e10cSrcweir                 Original shape to subset
59cdf0e10cSrcweir 
60cdf0e10cSrcweir                 @param rTreeNode
61cdf0e10cSrcweir                 Subset this object should represent
62cdf0e10cSrcweir 
63cdf0e10cSrcweir                 @param rShapeManager
64cdf0e10cSrcweir                 Manager object, where subsets are
65cdf0e10cSrcweir                 registered/unregistered
66cdf0e10cSrcweir              */
67cdf0e10cSrcweir             ShapeSubset( const AttributableShapeSharedPtr&	     rOriginalShape,
68cdf0e10cSrcweir                          const DocTreeNode&					     rTreeNode,
69cdf0e10cSrcweir                          const SubsettableShapeManagerSharedPtr& rSubsetManager );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir             /** Create a subset from another subset.
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 				Note: if you want this subset to subtract from the
74cdf0e10cSrcweir 				passed subset reference (and not from the original,
75cdf0e10cSrcweir 				unsubsetted shape), the passed subset must be enabled
76cdf0e10cSrcweir 				(enableSubsetShape() must have been called)
77cdf0e10cSrcweir 
78cdf0e10cSrcweir             	@param rOriginalSubset
79cdf0e10cSrcweir                 Original subset, which to subset again.
80cdf0e10cSrcweir 
81cdf0e10cSrcweir                 @param rTreeNode
82cdf0e10cSrcweir                 Subset of the original subset
83cdf0e10cSrcweir              */
84cdf0e10cSrcweir             ShapeSubset( const ShapeSubsetSharedPtr&		rOriginalSubset,
85cdf0e10cSrcweir                          const DocTreeNode&					rTreeNode );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir             /** Create full set for the given shape.
88cdf0e10cSrcweir 
89cdf0e10cSrcweir             	@param rOriginalShape
90cdf0e10cSrcweir                 Original shape, which will be represented as a whole
91cdf0e10cSrcweir                 by this object
92cdf0e10cSrcweir              */
93cdf0e10cSrcweir             ShapeSubset( const AttributableShapeSharedPtr&	     rOriginalShape,
94cdf0e10cSrcweir                          const SubsettableShapeManagerSharedPtr& rShapeManager );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir             ~ShapeSubset();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir             /** Get the actual subset shape.
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             	If the subset is currently revoked, this method
101cdf0e10cSrcweir             	returns the original shape.
102cdf0e10cSrcweir              */
103cdf0e10cSrcweir             AttributableShapeSharedPtr 	getSubsetShape() const;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir             /** Enable the subset shape.
106cdf0e10cSrcweir 
107cdf0e10cSrcweir             	This method enables the subset. That means, on
108cdf0e10cSrcweir             	successful completion of this method, the original
109cdf0e10cSrcweir             	shape will cease to show the subset range, and
110cdf0e10cSrcweir             	getSubsetShape() will return a valid shape.
111cdf0e10cSrcweir 
112cdf0e10cSrcweir                 @return true, if subsetting was successfully enabled.
113cdf0e10cSrcweir              */
114cdf0e10cSrcweir             bool			enableSubsetShape();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir             /** Disable the subset shape.
117cdf0e10cSrcweir 
118cdf0e10cSrcweir             	This method revokes the subset from the original
119cdf0e10cSrcweir             	shape. That means, the original shape will again show
120cdf0e10cSrcweir             	the hidden range.
121cdf0e10cSrcweir              */
122cdf0e10cSrcweir             void			disableSubsetShape();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir             /** Query whether this subset actually is none, but
125cdf0e10cSrcweir                 contains the whole original shape's content
126cdf0e10cSrcweir              */
127cdf0e10cSrcweir             bool isFullSet() const;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir             /** Query subset this object represents
130cdf0e10cSrcweir              */
131cdf0e10cSrcweir             DocTreeNode getSubset() const;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         private:
134cdf0e10cSrcweir             // default copy/assignment are okay
135cdf0e10cSrcweir             //ShapeSubset(const ShapeSubset&);
136cdf0e10cSrcweir             //ShapeSubset& operator=( const ShapeSubset& );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir             AttributableShapeSharedPtr	     mpOriginalShape;
139cdf0e10cSrcweir             AttributableShapeSharedPtr       mpSubsetShape;
140cdf0e10cSrcweir             DocTreeNode                      maTreeNode;
141cdf0e10cSrcweir             SubsettableShapeManagerSharedPtr mpShapeManager;
142cdf0e10cSrcweir         };
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_SHAPESUBSET_HXX */
147