Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / txtnode / atrtox.cxx
blob664ce55968ad0030db5278cbf633065cae75db7d
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( SwTOXMark& rAttr,
25 sal_Int32 const nStartPos, sal_Int32 const*const pEnd)
26 : SwTextAttr( rAttr, nStartPos )
27 , SwTextAttrEnd( rAttr, nStartPos, nStartPos )
28 , m_pTextNode( nullptr )
29 , m_pEnd( nullptr )
31 rAttr.m_pTextAttr = this;
32 if ( rAttr.GetAlternativeText().isEmpty() )
34 m_nEnd = *pEnd;
35 m_pEnd = & m_nEnd;
37 else
39 SetHasDummyChar(true);
41 SetDontMoveAttr( true );
42 SetOverlapAllowedAttr( true );
45 SwTextTOXMark::~SwTextTOXMark()
49 const sal_Int32* SwTextTOXMark::GetEnd() const
51 return m_pEnd;
54 void SwTextTOXMark::SetEnd(sal_Int32 n)
56 *m_pEnd = n;
57 if (m_pHints)
58 m_pHints->EndPosChanged();
61 void SwTextTOXMark::CopyTOXMark( SwDoc& rDoc )
63 SwTOXMark& rTOX = const_cast<SwTOXMark&>(GetTOXMark());
64 TOXTypes eType = rTOX.GetTOXType()->GetType();
65 const sal_uInt16 nCount = rDoc.GetTOXTypeCount( eType );
66 const SwTOXType* pType = nullptr;
67 const OUString rNm = rTOX.GetTOXType()->GetTypeName();
69 for(sal_uInt16 i=0; i < nCount; ++i)
71 const SwTOXType* pSrcType = rDoc.GetTOXType(eType, i);
72 if(pSrcType->GetTypeName() == rNm )
74 pType = pSrcType;
75 break;
79 // if the requested tox type does not exist, create it
80 if(!pType)
82 rDoc.InsertTOXType( SwTOXType( rDoc, eType, rNm ) );
83 pType = rDoc.GetTOXType(eType, 0);
86 // register at target tox type
87 const_cast<SwTOXType*>(pType)->Add( &rTOX );
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */