1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _TOCNTNTANCHOREDOBJECTPOSITION_HXX
24 #define _TOCNTNTANCHOREDOBJECTPOSITION_HXX
25 #include <anchoredobjectposition.hxx>
26 
27 class SwFrm;
28 class SwTxtFrm;
29 class SwLayoutFrm;
30 class SwRect;
31 
32 namespace objectpositioning
33 {
34     class SwToCntntAnchoredObjectPosition : public SwAnchoredObjectPosition
35     {
36         private:
37             // calculated data for object position
38             const SwLayoutFrm* mpVertPosOrientFrm;
39             // --> OD 2004-06-17 #i26791#
40             // determine offset to frame anchor position according to the
41             // positioning alignments
42             Point maOffsetToFrmAnchorPos;
43 
44             // data for calculation of position
45             bool          mbAnchorToChar;
46             const SwFrm*  mpToCharOrientFrm;
47             const SwRect* mpToCharRect;
48             SwTwips       mnToCharTopOfLine;
49 
50             virtual bool IsAnchoredToChar() const;
51             virtual const SwFrm* ToCharOrientFrm() const;
52             virtual const SwRect* ToCharRect() const;
53             // OD 12.11.2003 #i22341#
54             virtual SwTwips ToCharTopOfLine() const;
55 
56             // method to cast <SwAnchoredObjectPosition::GetAnchorFrm()> to
57             // the needed type
58             SwTxtFrm&       GetAnchorTxtFrm() const;
59 
60         // *********************************************************************
61             /** determine frame for horizontal position
62 
63                 OD 04.08.2003
64                 if the given proposed frame is a content frame, the proposed
65                 frame is returned.
66                 otherwise (given proposed frame is a layout frame),
67                 the lower content frames of the proposed frame are checked
68                 for the first, that the anchor or a follow of the anchor.
69                 If none is found, the proposed frame is returned.
70 
71                 @author OD
72 
73                 @param _pProposedFrm
74                 input parameter - proposed frame for horizontal position
75 
76                 @return constant reference to <SwFrm> object, at which the
77                 horizontal position is determined.
78             */
79             const SwFrm& _GetHoriVirtualAnchor( const SwLayoutFrm& _pProposedFrm ) const;
80 
81         public:
82             SwToCntntAnchoredObjectPosition( SdrObject& _rDrawObj );
83             virtual ~SwToCntntAnchoredObjectPosition();
84 
85             /** calculate position of object
86 
87                 @author OD
88             */
89             virtual void CalcPosition();
90 
91             /** frame, at which the vertical position is oriented at
92 
93                 @author OD
94             */
95             const SwLayoutFrm& GetVertPosOrientFrm() const;
96     };
97 } // namespace objectpositioning
98 
99 #endif
100