xref: /aoo42x/main/sw/source/core/layout/flypos.cxx (revision 37fb9221)
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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include "doc.hxx"
28 #include "node.hxx"
29 #include <docary.hxx>
30 #include <fmtanchr.hxx>
31 #include "flypos.hxx"
32 #include "frmfmt.hxx"
33 #include "dcontact.hxx"
34 #include "dview.hxx"
35 #include "flyfrm.hxx"
36 #include "dflyobj.hxx"
37 #include "ndindex.hxx"
38 #include "switerator.hxx"
39 
operator ()(const SwPosFlyFrmPtr & rA,const SwPosFlyFrmPtr & rB) const40 bool SwPosFlyFrmCmp::operator()(const SwPosFlyFrmPtr& rA, const SwPosFlyFrmPtr& rB) const
41 {
42     if(rA->GetNdIndex() == rB->GetNdIndex())
43     {
44         return rA->GetOrdNum() < rB->GetOrdNum();
45     }
46 
47     return rA->GetNdIndex() < rB->GetNdIndex();
48 }
49 
SwPosFlyFrm(const SwNodeIndex & rIdx,const SwFrmFmt * pFmt,sal_uInt16 nArrPos)50 SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
51 							sal_uInt16 nArrPos )
52     : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
53 {
54 	bool bFnd = false;
55 	const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
56     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
57     {
58 		pNdIdx = new SwNodeIndex( rIdx );
59     }
60 	else if( pFmt->GetDoc()->GetCurrentViewShell() )	//swmod 071108//swmod 071225
61 	{
62 		if( RES_FLYFRMFMT == pFmt->Which() )
63 		{
64 			// Schauen, ob es ein SdrObject dafuer gibt
65             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
66 			if( pFly )
67             {
68 				nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
69 				bFnd = true;
70 		    }
71 		}
72 		else if( RES_DRAWFRMFMT == pFmt->Which() )
73 		{
74 			// Schauen, ob es ein SdrObject dafuer gibt
75             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
76 			if( pContact )
77             {
78 				nOrdNum = pContact->GetMaster()->GetOrdNum();
79 				bFnd = true;
80 		    }
81 	    }
82 	}
83 
84 	if( !bFnd )
85 	{
86 		nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->Count();
87 		nOrdNum += nArrPos;
88 	}
89 }
90 
~SwPosFlyFrm()91 SwPosFlyFrm::~SwPosFlyFrm()
92 {
93 	const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
94     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
95     {
96 		delete pNdIdx;
97     }
98 }
99 
100 // eof
101