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