LibreOffice Module sw (master)  1
atrtox.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>
21 #include <txttxmrk.hxx>
22 #include <swfont.hxx>
23 #include <tox.hxx>
24 #include <ndtxt.hxx>
25 
27  sal_Int32 const nStartPos, sal_Int32 const*const pEnd)
28  : SwTextAttr( rAttr, nStartPos )
29  , SwTextAttrEnd( rAttr, nStartPos, nStartPos )
30  , m_pTextNode( nullptr )
31  , m_pEnd( nullptr )
32 {
33  rAttr.m_pTextAttr = this;
34  if ( rAttr.GetAlternativeText().isEmpty() )
35  {
36  m_nEnd = *pEnd;
37  m_pEnd = & m_nEnd;
38  }
39  else
40  {
41  SetHasDummyChar(true);
42  }
43  SetDontMoveAttr( true );
44  SetOverlapAllowedAttr( true );
45 }
46 
48 {
49 }
50 
51 const sal_Int32* SwTextTOXMark::GetEnd() const
52 {
53  return m_pEnd;
54 }
55 
56 void SwTextTOXMark::SetEnd(sal_Int32 n)
57 {
58  *m_pEnd = n;
59  if (m_pHints)
61 }
62 
64 {
65  SwTOXMark& rTOX = const_cast<SwTOXMark&>(GetTOXMark());
66  TOXTypes eType = rTOX.GetTOXType()->GetType();
67  const sal_uInt16 nCount = pDoc->GetTOXTypeCount( eType );
68  const SwTOXType* pType = nullptr;
69  const OUString rNm = rTOX.GetTOXType()->GetTypeName();
70 
71  for(sal_uInt16 i=0; i < nCount; ++i)
72  {
73  const SwTOXType* pSrcType = pDoc->GetTOXType(eType, i);
74  if(pSrcType->GetTypeName() == rNm )
75  {
76  pType = pSrcType;
77  break;
78  }
79  }
80 
81  // if the requested tox type does not exist, create it
82  if(!pType)
83  {
84  pDoc->InsertTOXType( SwTOXType( eType, rNm ) );
85  pType = pDoc->GetTOXType(eType, 0);
86  }
87 
88  // register at target tox type
89  const_cast<SwTOXType*>(pType)->Add( &rTOX );
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nEnd
Definition: txatbase.hxx:130
TOXTypes
Definition: toxe.hxx:39
SwTextTOXMark * m_pTextAttr
Definition: tox.hxx:70
void SetHasDummyChar(const bool bFlag)
Definition: txatbase.hxx:72
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:630
SwpHints * m_pHints
Definition: txatbase.hxx:61
Definition: doc.hxx:185
const SwTOXType * GetTOXType() const
Definition: tox.hxx:542
sal_Int32 * m_pEnd
Definition: txttxmrk.hxx:31
virtual void SetEnd(sal_Int32) override
Definition: atrtox.cxx:56
const SwTOXMark & GetTOXMark() const
Definition: txatbase.hxx:212
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:612
void SetOverlapAllowedAttr(bool bFlag)
Definition: txatbase.hxx:69
virtual const sal_Int32 * GetEnd() const override
end position
Definition: atrtox.cxx:51
void SetDontMoveAttr(bool bFlag)
Definition: txatbase.hxx:67
const OUString & GetAlternativeText() const
Definition: tox.hxx:533
SwTextTOXMark(SwTOXMark &rAttr, sal_Int32 const nStart, sal_Int32 const *const pEnd)
Definition: atrtox.cxx:26
int i
const OUString & GetTypeName() const
Definition: tox.hxx:660
DocumentType const eType
virtual ~SwTextTOXMark() override
Definition: atrtox.cxx:47
void EndPosChanged() const
Definition: ndhints.hxx:213
void CopyTOXMark(SwDoc *pDestDoc)
Definition: atrtox.cxx:63
TOXTypes GetType() const
Definition: tox.hxx:663
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:621