Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "doc.hxx"
22 : #include "node.hxx"
23 : #include <docary.hxx>
24 : #include <fmtanchr.hxx>
25 : #include "flypos.hxx"
26 : #include "frmfmt.hxx"
27 : #include "dcontact.hxx"
28 : #include "dview.hxx"
29 : #include "flyfrm.hxx"
30 : #include "dflyobj.hxx"
31 : #include "ndindex.hxx"
32 : #include "switerator.hxx"
33 :
34 4 : SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt,
35 : sal_uInt16 nArrPos )
36 4 : : pFrmFmt( pFmt ), pNdIdx( (SwNodeIndex*) &rIdx )
37 : {
38 4 : bool bFnd = false;
39 4 : const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
40 4 : if (FLY_AT_PAGE == rAnchor.GetAnchorId())
41 : {
42 0 : pNdIdx = new SwNodeIndex( rIdx );
43 : }
44 4 : else if( pFmt->GetDoc()->GetCurrentViewShell() ) //swmod 071108//swmod 071225
45 : {
46 4 : if( RES_FLYFRMFMT == pFmt->Which() )
47 : {
48 : // Let's see if we have an SdrObject for this
49 3 : SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*pFmt);
50 3 : if( pFly )
51 : {
52 3 : nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
53 3 : bFnd = true;
54 : }
55 : }
56 1 : else if( RES_DRAWFRMFMT == pFmt->Which() )
57 : {
58 : // Let's see if we have an SdrObject for this
59 1 : SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement(*pFmt);
60 1 : if( pContact )
61 : {
62 1 : nOrdNum = pContact->GetMaster()->GetOrdNum();
63 1 : bFnd = true;
64 : }
65 : }
66 : }
67 :
68 4 : if( !bFnd )
69 : {
70 0 : nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->size();
71 0 : nOrdNum += nArrPos;
72 : }
73 4 : }
74 :
75 8 : SwPosFlyFrm::~SwPosFlyFrm()
76 : {
77 4 : const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
78 4 : if (FLY_AT_PAGE == rAnchor.GetAnchorId())
79 : {
80 0 : delete pNdIdx;
81 : }
82 8 : }
83 :
84 0 : sal_Bool SwPosFlyFrm::operator==( const SwPosFlyFrm& )
85 : {
86 0 : return sal_False; // FlyFrames can sit at the same position
87 : }
88 :
89 0 : sal_Bool SwPosFlyFrm::operator<( const SwPosFlyFrm& rPosFly )
90 : {
91 0 : if( pNdIdx->GetIndex() == rPosFly.pNdIdx->GetIndex() )
92 : {
93 : // In this case, the order number decides!
94 0 : return nOrdNum < rPosFly.nOrdNum;
95 : }
96 0 : return pNdIdx->GetIndex() < rPosFly.pNdIdx->GetIndex();
97 : }
98 :
99 :
100 :
101 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|