xref: /trunk/main/sw/source/core/layout/flypos.cxx (revision 37fb9221)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "doc.hxx"
28cdf0e10cSrcweir #include "node.hxx"
29cdf0e10cSrcweir #include <docary.hxx>
30cdf0e10cSrcweir #include <fmtanchr.hxx>
31cdf0e10cSrcweir #include "flypos.hxx"
32cdf0e10cSrcweir #include "frmfmt.hxx"
33cdf0e10cSrcweir #include "dcontact.hxx"
34cdf0e10cSrcweir #include "dview.hxx"
35cdf0e10cSrcweir #include "flyfrm.hxx"
36cdf0e10cSrcweir #include "dflyobj.hxx"
37cdf0e10cSrcweir #include "ndindex.hxx"
38cdf0e10cSrcweir #include "switerator.hxx"
39cdf0e10cSrcweir 
operator ()(const SwPosFlyFrmPtr & rA,const SwPosFlyFrmPtr & rB) const40*37fb9221SArmin Le Grand bool SwPosFlyFrmCmp::operator()(const SwPosFlyFrmPtr& rA, const SwPosFlyFrmPtr& rB) const
41*37fb9221SArmin Le Grand {
42*37fb9221SArmin Le Grand     if(rA->GetNdIndex() == rB->GetNdIndex())
43*37fb9221SArmin Le Grand     {
44*37fb9221SArmin Le Grand         return rA->GetOrdNum() < rB->GetOrdNum();
45*37fb9221SArmin Le Grand     }
46*37fb9221SArmin Le Grand 
47*37fb9221SArmin Le Grand     return rA->GetNdIndex() < rB->GetNdIndex();
48*37fb9221SArmin Le Grand }
49cdf0e10cSrcweir 
SwPosFlyFrm(const SwNodeIndex & rIdx,const SwFrmFmt * pFmt,sal_uInt16 nArrPos)50cdf0e10cSrcweir SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
51cdf0e10cSrcweir 							sal_uInt16 nArrPos )
52cdf0e10cSrcweir     : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	bool bFnd = false;
55cdf0e10cSrcweir 	const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
56cdf0e10cSrcweir     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
57cdf0e10cSrcweir     {
58cdf0e10cSrcweir 		pNdIdx = new SwNodeIndex( rIdx );
59cdf0e10cSrcweir     }
60cdf0e10cSrcweir 	else if( pFmt->GetDoc()->GetCurrentViewShell() )	//swmod 071108//swmod 071225
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir 		if( RES_FLYFRMFMT == pFmt->Which() )
63cdf0e10cSrcweir 		{
64cdf0e10cSrcweir 			// Schauen, ob es ein SdrObject dafuer gibt
65cdf0e10cSrcweir             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
66cdf0e10cSrcweir 			if( pFly )
67cdf0e10cSrcweir             {
68cdf0e10cSrcweir 				nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
69cdf0e10cSrcweir 				bFnd = true;
70cdf0e10cSrcweir 		    }
71cdf0e10cSrcweir 		}
72cdf0e10cSrcweir 		else if( RES_DRAWFRMFMT == pFmt->Which() )
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 			// Schauen, ob es ein SdrObject dafuer gibt
75cdf0e10cSrcweir             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
76cdf0e10cSrcweir 			if( pContact )
77cdf0e10cSrcweir             {
78cdf0e10cSrcweir 				nOrdNum = pContact->GetMaster()->GetOrdNum();
79cdf0e10cSrcweir 				bFnd = true;
80cdf0e10cSrcweir 		    }
81cdf0e10cSrcweir 	    }
82cdf0e10cSrcweir 	}
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	if( !bFnd )
85cdf0e10cSrcweir 	{
86cdf0e10cSrcweir 		nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->Count();
87cdf0e10cSrcweir 		nOrdNum += nArrPos;
88cdf0e10cSrcweir 	}
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
~SwPosFlyFrm()91cdf0e10cSrcweir SwPosFlyFrm::~SwPosFlyFrm()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
94cdf0e10cSrcweir     if (FLY_AT_PAGE == rAnchor.GetAnchorId())
95cdf0e10cSrcweir     {
96cdf0e10cSrcweir 		delete pNdIdx;
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100*37fb9221SArmin Le Grand // eof
101