Add a comment to clarify what kind of inputs the class handles
[LibreOffice.git] / sw / source / core / txtnode / atrtox.cxx
blob54cb5cf4f548f6bac5c40f9f18a44007991d0ed2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <doc.hxx>
21 #include <txttxmrk.hxx>
22 #include <tox.hxx>
24 SwTextTOXMark::SwTextTOXMark(
25 const SfxPoolItemHolder& rAttr,
26 sal_Int32 const nStartPos,
27 sal_Int32 const*const pEnd)
28 : SwTextAttr( rAttr, nStartPos )
29 , SwTextAttrEnd( rAttr, nStartPos, nStartPos )
30 , m_pTextNode( nullptr )
31 , m_pEnd( nullptr )
33 SwTOXMark& rSwTOXMark(static_cast<SwTOXMark&>(GetAttr()));
34 rSwTOXMark.m_pTextAttr = this;
35 if ( rSwTOXMark.GetAlternativeText().isEmpty() )
37 m_nEnd = *pEnd;
38 m_pEnd = & m_nEnd;
40 else
42 SetHasDummyChar(true);
44 SetDontMoveAttr( true );
45 SetOverlapAllowedAttr( true );
48 SwTextTOXMark::~SwTextTOXMark()
52 const sal_Int32* SwTextTOXMark::GetEnd() const
54 return m_pEnd;
57 void SwTextTOXMark::SetEnd(sal_Int32 n)
59 if (*m_pEnd != n)
61 sal_Int32 nOldEndPos = *m_pEnd;
62 *m_pEnd = n;
63 if (m_pHints)
64 m_pHints->EndPosChanged(Which(), GetStart(), nOldEndPos, *m_pEnd);
68 void SwTextTOXMark::CopyTOXMark( SwDoc& rDoc )
70 SwTOXMark& rTOX = const_cast<SwTOXMark&>(GetTOXMark());
71 TOXTypes eType = rTOX.GetTOXType()->GetType();
72 const sal_uInt16 nCount = rDoc.GetTOXTypeCount( eType );
73 const SwTOXType* pType = nullptr;
74 const OUString rNm = rTOX.GetTOXType()->GetTypeName();
76 for(sal_uInt16 i=0; i < nCount; ++i)
78 const SwTOXType* pSrcType = rDoc.GetTOXType(eType, i);
79 if(pSrcType->GetTypeName() == rNm )
81 pType = pSrcType;
82 break;
86 // if the requested tox type does not exist, create it
87 if(!pType)
89 rDoc.InsertTOXType( SwTOXType( rDoc, eType, rNm ) );
90 pType = rDoc.GetTOXType(eType, 0);
93 // register at target tox type
94 rTOX.StartListening(const_cast<SwTOXType*>(pType)->GetNotifier());
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */