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 : #include "doc.hxx"
21 : #include <IDocumentLayoutAccess.hxx>
22 : #include <docary.hxx>
23 : #include "dcontact.hxx"
24 : #include "flyfrm.hxx"
25 : #include "dflyobj.hxx"
26 : #include <calbck.hxx>
27 :
28 2172 : bool SwPosFlyFrmCmp::operator()(const SwPosFlyFrmPtr& rA, const SwPosFlyFrmPtr& rB) const
29 : {
30 2172 : if(rA->GetNdIndex() == rB->GetNdIndex())
31 : {
32 : // In this case, the order number decides!
33 1809 : return rA->GetOrdNum() < rB->GetOrdNum();
34 : }
35 :
36 363 : return rA->GetNdIndex() < rB->GetNdIndex();
37 : }
38 :
39 552 : SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrameFormat* pFormat,
40 : sal_uInt16 nArrPos )
41 552 : : pFrameFormat( pFormat ), pNdIdx( const_cast<SwNodeIndex*>(&rIdx) )
42 : {
43 552 : bool bFnd = false;
44 552 : const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
45 552 : if (FLY_AT_PAGE == rAnchor.GetAnchorId())
46 : {
47 4 : pNdIdx = new SwNodeIndex( rIdx );
48 : }
49 548 : else if( pFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
50 : {
51 534 : if( RES_FLYFRMFMT == pFormat->Which() )
52 : {
53 : // Let's see if we have an SdrObject for this
54 234 : SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFormat>(*pFormat).First();
55 234 : if( pFly )
56 : {
57 222 : nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
58 222 : bFnd = true;
59 : }
60 : }
61 300 : else if( RES_DRAWFRMFMT == pFormat->Which() )
62 : {
63 : // Let's see if we have an SdrObject for this
64 300 : SwDrawContact* pContact = SwIterator<SwDrawContact,SwFormat>(*pFormat).First();
65 300 : if( pContact )
66 : {
67 300 : nOrdNum = pContact->GetMaster()->GetOrdNum();
68 300 : bFnd = true;
69 : }
70 : }
71 : }
72 :
73 552 : if( !bFnd )
74 : {
75 30 : nOrdNum = pFormat->GetDoc()->GetSpzFrameFormats()->size();
76 30 : nOrdNum += nArrPos;
77 : }
78 552 : }
79 :
80 1104 : SwPosFlyFrm::~SwPosFlyFrm()
81 : {
82 552 : const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
83 552 : if (FLY_AT_PAGE == rAnchor.GetAnchorId())
84 : {
85 4 : delete pNdIdx;
86 : }
87 1281 : }
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|