LibreOffice Module sw (master)  1
htmlfly.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 "htmlfly.hxx"
21 
22 #include <fmtanchr.hxx>
23 #include <fmtornt.hxx>
24 #include <flypos.hxx>
25 
26 #include <frmfmt.hxx>
27 #include <ndindex.hxx>
28 #include <pam.hxx>
29 #include <osl/diagnose.h>
30 
31 using namespace css;
32 
34  const SdrObject *pSdrObj,
35  AllHtmlFlags nFlags ) :
36  pFrameFormat( &rPosFly.GetFormat() ),
37  pSdrObject( pSdrObj ),
38  pNdIdx( new SwNodeIndex( rPosFly.GetNdIndex() ) ),
39  nOrdNum( rPosFly.GetOrdNum() ),
40  nContentIdx( 0 ),
41  nAllFlags( nFlags )
42 {
43  const SwFormatAnchor& rAnchor = rPosFly.GetFormat().GetAnchor();
44  if ((RndStdIds::FLY_AT_CHAR != rAnchor.GetAnchorId()) ||
46  return;
47 
48  // Output of auto-bound frames will be a character farther back,
49  // because then the position aligns with Netscape.
50  OSL_ENSURE( rAnchor.GetContentAnchor(), "No anchor position?" );
51  if( !rAnchor.GetContentAnchor() )
52  return;
53 
55  sal_Int16 eHoriRel = rPosFly.GetFormat().GetHoriOrient().
56  GetRelationOrient();
57  if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel )
58  {
59  const SwContentNode *pCNd = pNdIdx->GetNode().GetContentNode();
60  OSL_ENSURE( pCNd, "No Content-Node at PaM position" );
61  if( pCNd && nContentIdx < pCNd->Len() )
62  nContentIdx++;
63  }
64 }
65 
67 {
68  if( pNdIdx->GetIndex() == rFrame.pNdIdx->GetIndex() )
69  {
70  if( nContentIdx == rFrame.nContentIdx )
71  {
72  if( GetOutPos() == rFrame.GetOutPos() )
73  return nOrdNum < rFrame.nOrdNum;
74  else
75  return GetOutPos() < rFrame.GetOutPos();
76  }
77  else
78  return nContentIdx < rFrame.nContentIdx;
79  }
80  else
81  return pNdIdx->GetIndex() < rFrame.pNdIdx->GetIndex();
82 }
83 
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 nOrdNum
Definition: htmlfly.hxx:100
bool operator<(const SwHTMLPosFlyFrame &) const
Definition: htmlfly.cxx:66
SwNode & GetNode() const
Definition: ndindex.hxx:119
HtmlPosition GetOutPos() const
Definition: htmlfly.hxx:120
SwIndex nContent
Definition: pam.hxx:38
SwHTMLPosFlyFrame(const SwHTMLPosFlyFrame &)=delete
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
SwContentNode * GetContentNode()
Definition: node.hxx:615
FlyAnchors.
Definition: fmtanchr.hxx:34
SwNodeIndex * pNdIdx
Definition: htmlfly.hxx:99
const SwFrameFormat & GetFormat() const
Definition: flypos.hxx:39
Marks a node in the document model.
Definition: ndindex.hxx:31
sal_Int32 GetIndex() const
Definition: index.hxx:91
For querying current flys in document.
Definition: flypos.hxx:30
sal_Int32 nContentIdx
Definition: htmlfly.hxx:101