LibreOffice Module sw (master)  1
flypos.cxx
Go to the documentation of this file.
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>
22 #include <docary.hxx>
23 #include <fmtanchr.hxx>
24 #include <ndindex.hxx>
25 #include <svx/swframetypes.hxx>
26 
28 {
29  if(rA->GetNdIndex() == rB->GetNdIndex())
30  {
31  // In this case, the order number decides!
32  return rA->GetOrdNum() < rB->GetOrdNum();
33  }
34 
35  return rA->GetNdIndex() < rB->GetNdIndex();
36 }
37 
38 SwPosFlyFrame::SwPosFlyFrame(const SwNodeIndex& rIdx, const SwFrameFormat* pFormat, sal_uInt16 nArrPos)
39  : m_pFrameFormat(pFormat), m_pNodeIndex(const_cast<SwNodeIndex*>(&rIdx)), m_nOrdNum(SAL_MAX_UINT32)
40 {
41  const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
42  if(RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId())
43  m_pNodeIndex = new SwNodeIndex(rIdx);
44  else if(pFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell())
47  {
48  m_nOrdNum = pFormat->GetDoc()->GetSpzFrameFormats()->size();
49  m_nOrdNum += nArrPos;
50  }
51 }
52 
54 {
55  const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
56  if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId())
57  {
58  delete m_pNodeIndex;
59  }
60 }
61 
62 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwNodeIndex * m_pNodeIndex
Index for node is sufficient.
Definition: flypos.hxx:33
virtual ~SwPosFlyFrame()
Virtual for Writer (DLL !!)
Definition: flypos.cxx:53
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:740
#define SAL_MAX_UINT32
Style of a layout element.
Definition: frmfmt.hxx:57
SwPosFlyFrame(const SwNodeIndex &, const SwFrameFormat *, sal_uInt16 nArrPos)
Definition: flypos.cxx:38
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
std::shared_ptr< SwPosFlyFrame > SwPosFlyFramePtr
Definition: flypos.hxx:49
FlyAnchors.
Definition: fmtanchr.hxx:34
Marks a node in the document model.
Definition: ndindex.hxx:31
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
sal_uInt32 m_nOrdNum
Definition: flypos.hxx:34
const SwFrameFormat * m_pFrameFormat
FlyFrameFormat.
Definition: flypos.hxx:32
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
bool operator()(const SwPosFlyFramePtr &rA, const SwPosFlyFramePtr &rB) const
Definition: flypos.cxx:27
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:376
size_t size() const
Definition: docary.hxx:225