xref: /trunk/main/sw/source/core/txtnode/atrtox.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <doc.hxx>
29 #include <txttxmrk.hxx>
30 #include <swfont.hxx>
31 #include <tox.hxx>
32 #include <ndtxt.hxx>
33 
SwTxtTOXMark(SwTOXMark & rAttr,xub_StrLen const nStartPos,xub_StrLen const * const pEnd)34 SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr,
35             xub_StrLen const nStartPos, xub_StrLen const*const pEnd)
36     : SwTxtAttrEnd( rAttr, nStartPos, nStartPos )
37     , m_pTxtNode( 0 )
38     , m_pEnd( 0 )
39 {
40     rAttr.pTxtAttr = this;
41     if ( !rAttr.GetAlternativeText().Len() )
42     {
43         m_nEnd = *pEnd;
44         m_pEnd = & m_nEnd;
45     }
46     else
47     {
48         SetHasDummyChar(true);
49     }
50     SetDontMoveAttr( true );
51     SetOverlapAllowedAttr( true );
52 }
53 
~SwTxtTOXMark()54 SwTxtTOXMark::~SwTxtTOXMark()
55 {
56 }
57 
GetEnd()58 xub_StrLen* SwTxtTOXMark::GetEnd()
59 {
60     return m_pEnd;
61 }
62 
CopyTOXMark(SwDoc * pDoc)63 void SwTxtTOXMark::CopyTOXMark( SwDoc* pDoc )
64 {
65 	SwTOXMark& rTOX = (SwTOXMark&)GetTOXMark();
66 	TOXTypes    eType   = rTOX.GetTOXType()->GetType();
67 	sal_uInt16      nCount  = pDoc->GetTOXTypeCount( eType );
68 	const SwTOXType* pType = 0;
69 	const XubString& rNm = rTOX.GetTOXType()->GetTypeName();
70 
71 	// kein entsprechender Verzeichnistyp vorhanden -> anlegen
72 	// sonst verwenden
73 	for(sal_uInt16 i=0; i < nCount; ++i)
74 	{
75 		const SwTOXType* pSrcType = pDoc->GetTOXType(eType, i);
76 		if(pSrcType->GetTypeName() == rNm )
77 		{
78 			pType = pSrcType;
79 			break;
80 		}
81 	}
82 	// kein entsprechender Typ vorhanden -> neu erzeugen
83 	//
84 	if(!pType)
85 	{
86 		pDoc->InsertTOXType( SwTOXType( eType, rNm ) );
87 		pType = pDoc->GetTOXType(eType, 0);
88 	}
89 	// Verzeichnistyp umhaengen
90 	//
91 	((SwTOXType*)pType)->Add( &rTOX );
92 }
93