xref: /aoo41x/main/sw/source/core/layout/flypos.cxx (revision efeef26f)
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 
40 SV_IMPL_OP_PTRARR_SORT( SwPosFlyFrms, SwPosFlyFrmPtr )
41 
42 SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
43 							sal_uInt16 nArrPos )
44     : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
45 {
46 	bool bFnd = false;
47 	const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
48     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
49     {
50 		pNdIdx = new SwNodeIndex( rIdx );
51     }
52 	else if( pFmt->GetDoc()->GetCurrentViewShell() )	//swmod 071108//swmod 071225
53 	{
54 		if( RES_FLYFRMFMT == pFmt->Which() )
55 		{
56 			// Schauen, ob es ein SdrObject dafuer gibt
57             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
58 			if( pFly )
59             {
60 				nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
61 				bFnd = true;
62 		    }
63 		}
64 		else if( RES_DRAWFRMFMT == pFmt->Which() )
65 		{
66 			// Schauen, ob es ein SdrObject dafuer gibt
67             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
68 			if( pContact )
69             {
70 				nOrdNum = pContact->GetMaster()->GetOrdNum();
71 				bFnd = true;
72 		    }
73 	    }
74 	}
75 
76 	if( !bFnd )
77 	{
78 		nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->Count();
79 		nOrdNum += nArrPos;
80 	}
81 }
82 
83 SwPosFlyFrm::~SwPosFlyFrm()
84 {
85 	const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
86     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
87     {
88 		delete pNdIdx;
89     }
90 }
91 
92 sal_Bool SwPosFlyFrm::operator==( const SwPosFlyFrm& )
93 {
94 	return sal_False;	// FlyFrames koennen auf der gleichen Position stehen
95 }
96 
97 sal_Bool SwPosFlyFrm::operator<( const SwPosFlyFrm& rPosFly )
98 {
99 	if( pNdIdx->GetIndex() == rPosFly.pNdIdx->GetIndex() )
100 	{
101 		// dann entscheidet die Ordnungsnummer!
102 		return nOrdNum < rPosFly.nOrdNum;
103 	}
104 	return pNdIdx->GetIndex() < rPosFly.pNdIdx->GetIndex();
105 }
106 
107 
108 
109