Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "doc.hxx"
31 : : #include "node.hxx"
32 : : #include <docary.hxx>
33 : : #include <fmtanchr.hxx>
34 : : #include "flypos.hxx"
35 : : #include "frmfmt.hxx"
36 : : #include "dcontact.hxx"
37 : : #include "dview.hxx"
38 : : #include "flyfrm.hxx"
39 : : #include "dflyobj.hxx"
40 : : #include "ndindex.hxx"
41 : : #include "switerator.hxx"
42 : :
43 : 9 : SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
44 : : sal_uInt16 nArrPos )
45 : 9 : : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
46 : : {
47 : 9 : bool bFnd = false;
48 : 9 : const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
49 [ - + ]: 9 : if (FLY_AT_PAGE == rAnchor.GetAnchorId())
50 : : {
51 [ # # ]: 0 : pNdIdx = new SwNodeIndex( rIdx );
52 : : }
53 [ + - ]: 9 : else if( pFmt->GetDoc()->GetCurrentViewShell() ) //swmod 071108//swmod 071225
54 : : {
55 [ + + ]: 9 : if( RES_FLYFRMFMT == pFmt->Which() )
56 : : {
57 : : // Let's see if we have an SdrObject for this
58 : 3 : SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
59 [ + - ]: 3 : if( pFly )
60 : : {
61 : 3 : nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
62 : 3 : bFnd = true;
63 : : }
64 : : }
65 [ + - ]: 6 : else if( RES_DRAWFRMFMT == pFmt->Which() )
66 : : {
67 : : // Let's see if we have an SdrObject for this
68 : 6 : SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
69 [ + - ]: 6 : if( pContact )
70 : : {
71 : 6 : nOrdNum = pContact->GetMaster()->GetOrdNum();
72 : 6 : bFnd = true;
73 : : }
74 : : }
75 : : }
76 : :
77 [ - + ]: 9 : if( !bFnd )
78 : : {
79 : 0 : nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->size();
80 : 0 : nOrdNum += nArrPos;
81 : : }
82 : 9 : }
83 : :
84 : 18 : SwPosFlyFrm::~SwPosFlyFrm()
85 : : {
86 : 9 : const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
87 [ - + ]: 9 : if (FLY_AT_PAGE == rAnchor.GetAnchorId())
88 : : {
89 [ # # ]: 0 : delete pNdIdx;
90 : : }
91 [ - + ]: 18 : }
92 : :
93 : 0 : sal_Bool SwPosFlyFrm::operator==( const SwPosFlyFrm& )
94 : : {
95 : 0 : return sal_False; // FlyFrames can sit at the same position
96 : : }
97 : :
98 : 0 : sal_Bool SwPosFlyFrm::operator<( const SwPosFlyFrm& rPosFly )
99 : : {
100 [ # # ]: 0 : if( pNdIdx->GetIndex() == rPosFly.pNdIdx->GetIndex() )
101 : : {
102 : : // In this case, the order number decides!
103 : 0 : return nOrdNum < rPosFly.nOrdNum;
104 : : }
105 : 0 : return pNdIdx->GetIndex() < rPosFly.pNdIdx->GetIndex();
106 : : }
107 : :
108 : :
109 : :
110 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|