1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/resid.hxx>
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <swtypes.hxx>
30cdf0e10cSrcweir #include <errhdl.hxx>
31cdf0e10cSrcweir #include <txtatr.hxx>
32cdf0e10cSrcweir #include <ndtxt.hxx>
33cdf0e10cSrcweir #include <txttxmrk.hxx>
34cdf0e10cSrcweir #include <tox.hxx>
35cdf0e10cSrcweir #include <poolfmt.hrc>
36cdf0e10cSrcweir #include <doc.hxx>
37cdf0e10cSrcweir #include <docary.hxx>
38cdf0e10cSrcweir #include <paratr.hxx>
39cdf0e10cSrcweir #include <editeng/tstpitem.hxx>
40cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
41cdf0e10cSrcweir #include <hints.hxx> // SwPtrMsgPoolItem
42cdf0e10cSrcweir #include <algorithm>
43cdf0e10cSrcweir #include <functional>
44cdf0e10cSrcweir #include <switerator.hxx>
45cdf0e10cSrcweir
46cdf0e10cSrcweir using namespace std;
47cdf0e10cSrcweir
48cdf0e10cSrcweir const sal_Char* SwForm::aFormEntry = "<E>";
49cdf0e10cSrcweir const sal_Char* SwForm::aFormTab = "<T>";
50cdf0e10cSrcweir const sal_Char* SwForm::aFormPageNums = "<#>";
51cdf0e10cSrcweir const sal_Char* SwForm::aFormLinkStt = "<LS>";
52cdf0e10cSrcweir const sal_Char* SwForm::aFormLinkEnd = "<LE>";
53cdf0e10cSrcweir const sal_Char* SwForm::aFormEntryNum = "<E#>";
54cdf0e10cSrcweir const sal_Char* SwForm::aFormEntryTxt = "<ET>";
55cdf0e10cSrcweir const sal_Char* SwForm::aFormChapterMark= "<C>";
56cdf0e10cSrcweir const sal_Char* SwForm::aFormText = "<X>";
57cdf0e10cSrcweir const sal_Char* SwForm::aFormAuth = "<A>";
58cdf0e10cSrcweir sal_uInt8 SwForm::nFormTabLen = 3;
59cdf0e10cSrcweir sal_uInt8 SwForm::nFormEntryLen = 3;
60cdf0e10cSrcweir sal_uInt8 SwForm::nFormPageNumsLen = 3;
61cdf0e10cSrcweir sal_uInt8 SwForm::nFormLinkSttLen = 4;
62cdf0e10cSrcweir sal_uInt8 SwForm::nFormLinkEndLen = 4;
63cdf0e10cSrcweir sal_uInt8 SwForm::nFormEntryNumLen = 4;
64cdf0e10cSrcweir sal_uInt8 SwForm::nFormEntryTxtLen = 4;
65cdf0e10cSrcweir sal_uInt8 SwForm::nFormChapterMarkLen = 3;
66cdf0e10cSrcweir sal_uInt8 SwForm::nFormTextLen = 3;
67cdf0e10cSrcweir sal_uInt8 SwForm::nFormAuthLen = 5;
68cdf0e10cSrcweir
69cdf0e10cSrcweir SV_IMPL_PTRARR(SwTOXMarks, SwTOXMark*)
70cdf0e10cSrcweir
71cdf0e10cSrcweir TYPEINIT2( SwTOXMark, SfxPoolItem, SwClient ); // fuers rtti
72cdf0e10cSrcweir
73cdf0e10cSrcweir struct PatternIni
74cdf0e10cSrcweir {
75cdf0e10cSrcweir sal_uInt16 n1;
76cdf0e10cSrcweir sal_uInt16 n2;
77cdf0e10cSrcweir sal_uInt16 n3;
78cdf0e10cSrcweir sal_uInt16 n4;
79cdf0e10cSrcweir sal_uInt16 n5;
80cdf0e10cSrcweir };
81cdf0e10cSrcweir const PatternIni aPatternIni[] =
82cdf0e10cSrcweir {
83cdf0e10cSrcweir {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}, //Header - no pattern
84cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_ARTICLE,
85cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_BOOK,
86cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_BOOKLET,
87cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_CONFERENCE,
88cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_INBOOK,
89cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_INCOLLECTION,
90cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_INPROCEEDINGS,
91cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_JOURNAL,
92cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_MANUAL,
93cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_MASTERSTHESIS,
94cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_MISC,
95cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_PHDTHESIS,
96cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_PROCEEDINGS,
97cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_TECHREPORT,
98cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_UNPUBLISHED,
99cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_EMAIL,
100cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, AUTH_FIELD_URL, USHRT_MAX},//AUTH_TYPE_WWW,
101cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_CUSTOM1,
102cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_CUSTOM2,
103cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_CUSTOM3,
104cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_CUSTOM4,
105cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_TYPE_CUSTOM5,
106cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_YEAR,
107cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_URL,
108cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_CUSTOM1,
109cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_CUSTOM2,
110cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_CUSTOM3,
111cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_CUSTOM4,
112cdf0e10cSrcweir {AUTH_FIELD_AUTHOR, AUTH_FIELD_TITLE, AUTH_FIELD_YEAR, USHRT_MAX, USHRT_MAX}, //AUTH_FIELD_CUSTOM5,
113cdf0e10cSrcweir {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}
114cdf0e10cSrcweir };
115cdf0e10cSrcweir
lcl_GetAuthPattern(sal_uInt16 nTypeId)116cdf0e10cSrcweir SwFormTokens lcl_GetAuthPattern(sal_uInt16 nTypeId)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir SwFormTokens aRet;
119cdf0e10cSrcweir
120cdf0e10cSrcweir PatternIni aIni = aPatternIni[nTypeId];
121cdf0e10cSrcweir sal_uInt16 nVals[5];
122cdf0e10cSrcweir nVals[0] = aIni.n1;
123cdf0e10cSrcweir nVals[1] = aIni.n2;
124cdf0e10cSrcweir nVals[2] = aIni.n3;
125cdf0e10cSrcweir nVals[3] = aIni.n4;
126cdf0e10cSrcweir nVals[4] = aIni.n5;
127cdf0e10cSrcweir
128cdf0e10cSrcweir SwFormToken aStartToken( TOKEN_AUTHORITY );
129cdf0e10cSrcweir aStartToken.nAuthorityField = AUTH_FIELD_IDENTIFIER;
130cdf0e10cSrcweir aRet.push_back( aStartToken );
131cdf0e10cSrcweir SwFormToken aSeparatorToken( TOKEN_TEXT );
132cdf0e10cSrcweir aSeparatorToken.sText = String::CreateFromAscii( ": " );
133cdf0e10cSrcweir aRet.push_back( aSeparatorToken );
134cdf0e10cSrcweir SwFormToken aTextToken( TOKEN_TEXT );
135cdf0e10cSrcweir aTextToken.sText = String::CreateFromAscii( ", " );
136cdf0e10cSrcweir
137cdf0e10cSrcweir for(sal_uInt16 i = 0; i < 5 ; i++)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir if(nVals[i] == USHRT_MAX)
140cdf0e10cSrcweir break;
141cdf0e10cSrcweir if( i > 0 )
142cdf0e10cSrcweir aRet.push_back( aTextToken );
143cdf0e10cSrcweir
144cdf0e10cSrcweir // -> #i21237#
145cdf0e10cSrcweir SwFormToken aToken(TOKEN_AUTHORITY);
146cdf0e10cSrcweir
147cdf0e10cSrcweir aToken.nAuthorityField = nVals[i];
148cdf0e10cSrcweir aRet.push_back(aToken);
149cdf0e10cSrcweir // <- #i21237#
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir return aRet;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir /*--------------------------------------------------------------------
155cdf0e10cSrcweir Beschreibung: Verzeichnis-Markierungen D/Ctor
156cdf0e10cSrcweir --------------------------------------------------------------------*/
157cdf0e10cSrcweir
158cdf0e10cSrcweir
159cdf0e10cSrcweir /// pool default constructor
SwTOXMark()160cdf0e10cSrcweir SwTOXMark::SwTOXMark()
161cdf0e10cSrcweir : SfxPoolItem( RES_TXTATR_TOXMARK )
162cdf0e10cSrcweir , SwModify( 0 )
163cdf0e10cSrcweir ,
164cdf0e10cSrcweir pTxtAttr( 0 ),
165cdf0e10cSrcweir bAutoGenerated(sal_False),
166cdf0e10cSrcweir bMainEntry(sal_False)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir
SwTOXMark(const SwTOXType * pTyp)171cdf0e10cSrcweir SwTOXMark::SwTOXMark( const SwTOXType* pTyp )
172cdf0e10cSrcweir : SfxPoolItem( RES_TXTATR_TOXMARK )
173cdf0e10cSrcweir , SwModify( const_cast<SwTOXType*>(pTyp) )
174cdf0e10cSrcweir ,
175cdf0e10cSrcweir pTxtAttr( 0 ), nLevel( 0 ),
176cdf0e10cSrcweir bAutoGenerated(sal_False),
177cdf0e10cSrcweir bMainEntry(sal_False)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir }
180cdf0e10cSrcweir
181cdf0e10cSrcweir
SwTOXMark(const SwTOXMark & rCopy)182cdf0e10cSrcweir SwTOXMark::SwTOXMark( const SwTOXMark& rCopy )
183cdf0e10cSrcweir : SfxPoolItem( RES_TXTATR_TOXMARK )
184cdf0e10cSrcweir , SwModify(rCopy.GetRegisteredInNonConst())
185cdf0e10cSrcweir ,
186cdf0e10cSrcweir aPrimaryKey( rCopy.aPrimaryKey ), aSecondaryKey( rCopy.aSecondaryKey ),
187cdf0e10cSrcweir aTextReading( rCopy.aTextReading ),
188cdf0e10cSrcweir aPrimaryKeyReading( rCopy.aPrimaryKeyReading ),
189cdf0e10cSrcweir aSecondaryKeyReading( rCopy.aSecondaryKeyReading ),
190cdf0e10cSrcweir pTxtAttr( 0 ), nLevel( rCopy.nLevel ),
191cdf0e10cSrcweir bAutoGenerated( rCopy.bAutoGenerated),
192cdf0e10cSrcweir bMainEntry(rCopy.bMainEntry)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir // AlternativString kopieren
195cdf0e10cSrcweir aAltText = rCopy.aAltText;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir
~SwTOXMark()199cdf0e10cSrcweir SwTOXMark::~SwTOXMark()
200cdf0e10cSrcweir {
201cdf0e10cSrcweir }
202cdf0e10cSrcweir
203cdf0e10cSrcweir
RegisterToTOXType(SwTOXType & rMark)204cdf0e10cSrcweir void SwTOXMark::RegisterToTOXType( SwTOXType& rMark )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir rMark.Add(this);
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const209cdf0e10cSrcweir int SwTOXMark::operator==( const SfxPoolItem& rAttr ) const
210cdf0e10cSrcweir {
211cdf0e10cSrcweir ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
212cdf0e10cSrcweir return GetRegisteredIn() == ((SwTOXMark&)rAttr).GetRegisteredIn();
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
215cdf0e10cSrcweir
Clone(SfxItemPool *) const216cdf0e10cSrcweir SfxPoolItem* SwTOXMark::Clone( SfxItemPool* ) const
217cdf0e10cSrcweir {
218cdf0e10cSrcweir return new SwTOXMark( *this );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)221cdf0e10cSrcweir void SwTOXMark::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir NotifyClients(pOld, pNew);
224cdf0e10cSrcweir if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
225cdf0e10cSrcweir { // invalidate cached uno object
226cdf0e10cSrcweir SetXTOXMark(::com::sun::star::uno::Reference<
227cdf0e10cSrcweir ::com::sun::star::text::XDocumentIndexMark>(0));
228cdf0e10cSrcweir }
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
InvalidateTOXMark()231cdf0e10cSrcweir void SwTOXMark::InvalidateTOXMark()
232cdf0e10cSrcweir {
233cdf0e10cSrcweir SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
234cdf0e10cSrcweir &static_cast<SwModify&>(*this) ); // cast to base class!
235cdf0e10cSrcweir NotifyClients(&aMsgHint, &aMsgHint);
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
GetText() const238cdf0e10cSrcweir String SwTOXMark::GetText() const
239cdf0e10cSrcweir {
240cdf0e10cSrcweir String aStr;
241cdf0e10cSrcweir if( aAltText.Len() )
242cdf0e10cSrcweir aStr = aAltText;
243cdf0e10cSrcweir else if( pTxtAttr && pTxtAttr->GetpTxtNd() )
244cdf0e10cSrcweir {
24569a74367SOliver-Rainer Wittmann const xub_StrLen* pEndIdx = pTxtAttr->GetEnd();
246cdf0e10cSrcweir ASSERT( pEndIdx, "TOXMark ohne Mark!!");
247cdf0e10cSrcweir if( pEndIdx )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir const xub_StrLen nStt = *pTxtAttr->GetStart();
250cdf0e10cSrcweir aStr = pTxtAttr->GetpTxtNd()->GetExpandTxt( nStt, *pEndIdx-nStt );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir }
253cdf0e10cSrcweir return aStr;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
InsertTOXMarks(SwTOXMarks & aMarks,const SwTOXType & rType)256cdf0e10cSrcweir void SwTOXMark::InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir SwIterator<SwTOXMark,SwTOXType> aIter(rType);
259cdf0e10cSrcweir SwTOXMark* pMark = aIter.First();
260cdf0e10cSrcweir while( pMark )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir if(pMark->GetTxtTOXMark())
263cdf0e10cSrcweir aMarks.C40_INSERT(SwTOXMark, pMark, aMarks.Count());
264cdf0e10cSrcweir pMark = aIter.Next();
265cdf0e10cSrcweir }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir /*--------------------------------------------------------------------
269cdf0e10cSrcweir Beschreibung: Typen von Verzeichnissen verwalten
270cdf0e10cSrcweir --------------------------------------------------------------------*/
271cdf0e10cSrcweir
SwTOXType(TOXTypes eTyp,const String & rName)272cdf0e10cSrcweir SwTOXType::SwTOXType( TOXTypes eTyp, const String& rName )
273cdf0e10cSrcweir : SwModify(0),
274cdf0e10cSrcweir aName(rName),
275cdf0e10cSrcweir eType(eTyp)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
279cdf0e10cSrcweir
SwTOXType(const SwTOXType & rCopy)280cdf0e10cSrcweir SwTOXType::SwTOXType(const SwTOXType& rCopy)
281cdf0e10cSrcweir : SwModify( (SwModify*)rCopy.GetRegisteredIn() ),
282cdf0e10cSrcweir aName(rCopy.aName),
283cdf0e10cSrcweir eType(rCopy.eType)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir /*--------------------------------------------------------------------
288cdf0e10cSrcweir Beschreibung: Formen bearbeiten
289cdf0e10cSrcweir --------------------------------------------------------------------*/
290cdf0e10cSrcweir
SwForm(TOXTypes eTyp)291cdf0e10cSrcweir SwForm::SwForm( TOXTypes eTyp ) // #i21237#
292cdf0e10cSrcweir : eType( eTyp ), nFormMaxLevel( SwForm::GetFormMaxLevel( eTyp )),
293cdf0e10cSrcweir // nFirstTabPos( lNumIndent ),
294cdf0e10cSrcweir bCommaSeparated(sal_False)
295cdf0e10cSrcweir {
296cdf0e10cSrcweir //bHasFirstTabPos =
297cdf0e10cSrcweir bGenerateTabPos = sal_False;
298cdf0e10cSrcweir bIsRelTabPos = sal_True;
299cdf0e10cSrcweir
300cdf0e10cSrcweir // Inhaltsverzeichnis hat entsprechend Anzahl Headlines + Ueberschrift
301cdf0e10cSrcweir // Benutzer hat 10 Ebenen + Ueberschrift
302cdf0e10cSrcweir // Stichwort hat 3 Ebenen + Ueberschrift + Trenner
303cdf0e10cSrcweir // indexes of tables, objects illustrations and authorities consist of a heading and one level
304cdf0e10cSrcweir
305cdf0e10cSrcweir sal_uInt16 nPoolId;
306cdf0e10cSrcweir switch( eType )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir case TOX_INDEX: nPoolId = STR_POOLCOLL_TOX_IDXH; break;
309cdf0e10cSrcweir case TOX_USER: nPoolId = STR_POOLCOLL_TOX_USERH; break;
310cdf0e10cSrcweir case TOX_CONTENT: nPoolId = STR_POOLCOLL_TOX_CNTNTH; break;
311cdf0e10cSrcweir case TOX_ILLUSTRATIONS: nPoolId = STR_POOLCOLL_TOX_ILLUSH; break;
312cdf0e10cSrcweir case TOX_OBJECTS : nPoolId = STR_POOLCOLL_TOX_OBJECTH; break;
313cdf0e10cSrcweir case TOX_TABLES : nPoolId = STR_POOLCOLL_TOX_TABLESH; break;
314cdf0e10cSrcweir case TOX_AUTHORITIES : nPoolId = STR_POOLCOLL_TOX_AUTHORITIESH; break;
315cdf0e10cSrcweir default:
316*870262e3SDon Lewis ASSERT( sal_False, "invalid TOXType");
317cdf0e10cSrcweir return ;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir SwFormTokens aTokens;
321cdf0e10cSrcweir if (TOX_CONTENT == eType)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir aTokens.push_back(SwFormToken(TOKEN_ENTRY_NO));
324cdf0e10cSrcweir aTokens.push_back(SwFormToken(TOKEN_ENTRY_TEXT));
325cdf0e10cSrcweir }
326cdf0e10cSrcweir else
327cdf0e10cSrcweir aTokens.push_back(SwFormToken(TOKEN_ENTRY));
328cdf0e10cSrcweir
329cdf0e10cSrcweir if (TOX_AUTHORITIES != eType)
330cdf0e10cSrcweir {
331cdf0e10cSrcweir SwFormToken aToken(TOKEN_TAB_STOP);
332cdf0e10cSrcweir aToken.nTabStopPosition = 0;
333cdf0e10cSrcweir
334cdf0e10cSrcweir // --> FME 2004-12-10 #i36870# right aligned tab for all
335cdf0e10cSrcweir aToken.cTabFillChar = '.';
336cdf0e10cSrcweir aToken.eTabAlign = SVX_TAB_ADJUST_END;
337cdf0e10cSrcweir // <--
338cdf0e10cSrcweir
339cdf0e10cSrcweir aTokens.push_back(aToken);
340cdf0e10cSrcweir aTokens.push_back(SwFormToken(TOKEN_PAGE_NUMS));
341cdf0e10cSrcweir }
342cdf0e10cSrcweir
343cdf0e10cSrcweir SetTemplate( 0, SW_RESSTR( nPoolId++ ));
344cdf0e10cSrcweir
345cdf0e10cSrcweir if(TOX_INDEX == eType)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir for( sal_uInt16 i = 1; i < 5; ++i )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir if(1 == i)
350cdf0e10cSrcweir {
351cdf0e10cSrcweir SwFormTokens aTmpTokens;
352cdf0e10cSrcweir SwFormToken aTmpToken(TOKEN_ENTRY);
353cdf0e10cSrcweir aTmpTokens.push_back(aTmpToken);
354cdf0e10cSrcweir
355cdf0e10cSrcweir SetPattern( i, aTmpTokens );
356cdf0e10cSrcweir SetTemplate( i, SW_RESSTR( STR_POOLCOLL_TOX_IDXBREAK ));
357cdf0e10cSrcweir }
358cdf0e10cSrcweir else
359cdf0e10cSrcweir {
360cdf0e10cSrcweir SetPattern( i, aTokens );
361cdf0e10cSrcweir SetTemplate( i, SW_RESSTR( STR_POOLCOLL_TOX_IDX1 + i - 2 ));
362cdf0e10cSrcweir }
363cdf0e10cSrcweir }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir else
366cdf0e10cSrcweir for( sal_uInt16 i = 1; i < GetFormMax(); ++i, ++nPoolId ) // Nr 0 ist der Titel
367cdf0e10cSrcweir {
368cdf0e10cSrcweir if(TOX_AUTHORITIES == eType)
369cdf0e10cSrcweir SetPattern(i, lcl_GetAuthPattern(i));
370cdf0e10cSrcweir else
371cdf0e10cSrcweir SetPattern( i, aTokens );
372cdf0e10cSrcweir
373cdf0e10cSrcweir if( TOX_CONTENT == eType && 6 == i )
374cdf0e10cSrcweir nPoolId = STR_POOLCOLL_TOX_CNTNT6;
375cdf0e10cSrcweir else if( TOX_USER == eType && 6 == i )
376cdf0e10cSrcweir nPoolId = STR_POOLCOLL_TOX_USER6;
377cdf0e10cSrcweir else if( TOX_AUTHORITIES == eType )
378cdf0e10cSrcweir nPoolId = STR_POOLCOLL_TOX_AUTHORITIES1;
379cdf0e10cSrcweir SetTemplate( i, SW_RESSTR( nPoolId ) );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir
SwForm(const SwForm & rForm)384cdf0e10cSrcweir SwForm::SwForm(const SwForm& rForm)
385cdf0e10cSrcweir : eType( rForm.eType )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir *this = rForm;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir
operator =(const SwForm & rForm)391cdf0e10cSrcweir SwForm& SwForm::operator=(const SwForm& rForm)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir eType = rForm.eType;
394cdf0e10cSrcweir nFormMaxLevel = rForm.nFormMaxLevel;
395cdf0e10cSrcweir // nFirstTabPos = rForm.nFirstTabPos;
396cdf0e10cSrcweir // bHasFirstTabPos = rForm.bHasFirstTabPos;
397cdf0e10cSrcweir bGenerateTabPos = rForm.bGenerateTabPos;
398cdf0e10cSrcweir bIsRelTabPos = rForm.bIsRelTabPos;
399cdf0e10cSrcweir bCommaSeparated = rForm.bCommaSeparated;
400cdf0e10cSrcweir for(sal_uInt16 i=0; i < nFormMaxLevel; ++i)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir aPattern[i] = rForm.aPattern[i];
403cdf0e10cSrcweir aTemplate[i] = rForm.aTemplate[i];
404cdf0e10cSrcweir }
405cdf0e10cSrcweir return *this;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
GetFormMaxLevel(TOXTypes eTOXType)408cdf0e10cSrcweir sal_uInt16 SwForm::GetFormMaxLevel( TOXTypes eTOXType )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir sal_uInt16 nRet = 0;
411cdf0e10cSrcweir switch( eTOXType )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir case TOX_INDEX: nRet = 5; break;
414cdf0e10cSrcweir case TOX_USER: nRet = MAXLEVEL+1; break;
415cdf0e10cSrcweir case TOX_CONTENT: nRet = MAXLEVEL+1; break;
416cdf0e10cSrcweir case TOX_ILLUSTRATIONS:
417cdf0e10cSrcweir case TOX_OBJECTS :
418cdf0e10cSrcweir case TOX_TABLES : nRet = 2; break;
419cdf0e10cSrcweir case TOX_AUTHORITIES : nRet = AUTH_TYPE_END + 1; break;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir return nRet;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
424cdf0e10cSrcweir // #i21237#
operator ==(const SwFormToken & rToken,FormTokenType eType)425cdf0e10cSrcweir bool operator == (const SwFormToken & rToken, FormTokenType eType)
426cdf0e10cSrcweir {
427cdf0e10cSrcweir return rToken.eTokenType == eType;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir
430cdf0e10cSrcweir //-----------------------------------------------------------------------------
AdjustTabStops(SwDoc & rDoc)431e8b037c9SOliver-Rainer Wittmann void SwForm::AdjustTabStops( SwDoc& rDoc ) // #i21237#
432cdf0e10cSrcweir {
433378ccc1aSOliver-Rainer Wittmann const sal_uInt16 nFormMaxLevel = GetFormMax();
434378ccc1aSOliver-Rainer Wittmann for ( sal_uInt16 nLevel = 1; nLevel < nFormMaxLevel; ++nLevel )
435cdf0e10cSrcweir {
436378ccc1aSOliver-Rainer Wittmann SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( GetTemplate(nLevel) );
437e8b037c9SOliver-Rainer Wittmann if( pColl == NULL )
438cdf0e10cSrcweir {
439378ccc1aSOliver-Rainer Wittmann // Paragraph Style for this level has not been created.
440378ccc1aSOliver-Rainer Wittmann // --> No need to propagate default values
441378ccc1aSOliver-Rainer Wittmann continue;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444e8b037c9SOliver-Rainer Wittmann const SvxTabStopItem* pTabStops = pColl != NULL ? &pColl->GetTabStops(sal_False) : 0;
445e8b037c9SOliver-Rainer Wittmann const sal_uInt16 nTabCount = pTabStops != NULL ? pTabStops->Count() : 0;
446e8b037c9SOliver-Rainer Wittmann if( pTabStops != NULL
447e8b037c9SOliver-Rainer Wittmann && nTabCount != 0 )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir SwFormTokens aCurrentPattern = GetPattern(nLevel);
450cdf0e10cSrcweir SwFormTokens::iterator aIt = aCurrentPattern.begin();
451cdf0e10cSrcweir
452e8b037c9SOliver-Rainer Wittmann bool bChanged = false;
453cdf0e10cSrcweir for(sal_uInt16 nTab = 0; nTab < nTabCount; ++nTab)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir const SvxTabStop& rTab = (*pTabStops)[nTab];
456cdf0e10cSrcweir
457378ccc1aSOliver-Rainer Wittmann if ( rTab.GetAdjustment() == SVX_TAB_ADJUST_DEFAULT )
458378ccc1aSOliver-Rainer Wittmann continue; // ignore the default tab stop
459378ccc1aSOliver-Rainer Wittmann
460e8b037c9SOliver-Rainer Wittmann aIt = find_if( aIt, aCurrentPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_TAB_STOP) );
461e8b037c9SOliver-Rainer Wittmann if ( aIt != aCurrentPattern.end() )
462cdf0e10cSrcweir {
463e8b037c9SOliver-Rainer Wittmann bChanged = true;
464e8b037c9SOliver-Rainer Wittmann aIt->nTabStopPosition = rTab.GetTabPos();
465e8b037c9SOliver-Rainer Wittmann aIt->eTabAlign =
466e8b037c9SOliver-Rainer Wittmann ( nTab == nTabCount - 1
467e8b037c9SOliver-Rainer Wittmann && rTab.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
468e8b037c9SOliver-Rainer Wittmann ? SVX_TAB_ADJUST_END
469e8b037c9SOliver-Rainer Wittmann : rTab.GetAdjustment();
470e8b037c9SOliver-Rainer Wittmann aIt->cTabFillChar = rTab.GetFill();
471e8b037c9SOliver-Rainer Wittmann ++aIt;
472cdf0e10cSrcweir }
473cdf0e10cSrcweir else
474e8b037c9SOliver-Rainer Wittmann break; // no more tokens to replace
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477e8b037c9SOliver-Rainer Wittmann if ( bChanged )
478e8b037c9SOliver-Rainer Wittmann SetPattern( nLevel, aCurrentPattern );
479cdf0e10cSrcweir }
480cdf0e10cSrcweir }
481cdf0e10cSrcweir }
482cdf0e10cSrcweir /*--------------------------------------------------------------------
483cdf0e10cSrcweir Beschreibung: Ctor TOXBase
484cdf0e10cSrcweir --------------------------------------------------------------------*/
485cdf0e10cSrcweir
486cdf0e10cSrcweir
SwTOXBase(const SwTOXType * pTyp,const SwForm & rForm,sal_uInt16 nCreaType,const String & rTitle)487cdf0e10cSrcweir SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm,
488cdf0e10cSrcweir sal_uInt16 nCreaType, const String& rTitle )
489f66c5aafSOliver-Rainer Wittmann : SwClient((SwModify*)pTyp)
490f66c5aafSOliver-Rainer Wittmann , aForm(rForm)
491f66c5aafSOliver-Rainer Wittmann , aTitle(rTitle)
492f66c5aafSOliver-Rainer Wittmann , eLanguage((LanguageType)::GetAppLanguage())
493f66c5aafSOliver-Rainer Wittmann , nCreateType(nCreaType)
494f66c5aafSOliver-Rainer Wittmann , nOLEOptions(0)
495f66c5aafSOliver-Rainer Wittmann , eCaptionDisplay(CAPTION_COMPLETE)
496f66c5aafSOliver-Rainer Wittmann , bProtected( sal_True )
497f66c5aafSOliver-Rainer Wittmann , bFromChapter(sal_False)
498f66c5aafSOliver-Rainer Wittmann , bFromObjectNames(sal_False)
499f66c5aafSOliver-Rainer Wittmann , bLevelFromChapter(sal_False)
500f66c5aafSOliver-Rainer Wittmann , maMSTOCExpression()
501f66c5aafSOliver-Rainer Wittmann , mbKeepExpression(sal_True)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir aData.nOptions = 0;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir
SwTOXBase(const SwTOXBase & rSource,SwDoc * pDoc)507cdf0e10cSrcweir SwTOXBase::SwTOXBase( const SwTOXBase& rSource, SwDoc* pDoc )
508cdf0e10cSrcweir : SwClient( rSource.GetRegisteredInNonConst() )
509f66c5aafSOliver-Rainer Wittmann , mbKeepExpression(sal_True)
510cdf0e10cSrcweir {
511cdf0e10cSrcweir CopyTOXBase( pDoc, rSource );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
RegisterToTOXType(SwTOXType & rType)514cdf0e10cSrcweir void SwTOXBase::RegisterToTOXType( SwTOXType& rType )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir rType.Add( this );
517cdf0e10cSrcweir }
518cdf0e10cSrcweir
CopyTOXBase(SwDoc * pDoc,const SwTOXBase & rSource)519cdf0e10cSrcweir SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource )
520cdf0e10cSrcweir {
521f66c5aafSOliver-Rainer Wittmann maMSTOCExpression = rSource.maMSTOCExpression;
522cdf0e10cSrcweir SwTOXType* pType = (SwTOXType*)rSource.GetTOXType();
523cdf0e10cSrcweir if( pDoc && USHRT_MAX == pDoc->GetTOXTypes().GetPos( pType ))
524cdf0e10cSrcweir {
525cdf0e10cSrcweir // type not in pDoc, so create it now
526cdf0e10cSrcweir const SwTOXTypes& rTypes = pDoc->GetTOXTypes();
527cdf0e10cSrcweir sal_Bool bFound = sal_False;
528cdf0e10cSrcweir for( sal_uInt16 n = rTypes.Count(); n; )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir const SwTOXType* pCmp = rTypes[ --n ];
531cdf0e10cSrcweir if( pCmp->GetType() == pType->GetType() &&
532cdf0e10cSrcweir pCmp->GetTypeName() == pType->GetTypeName() )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir pType = (SwTOXType*)pCmp;
535cdf0e10cSrcweir bFound = sal_True;
536cdf0e10cSrcweir break;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir }
539cdf0e10cSrcweir
540cdf0e10cSrcweir if( !bFound )
541cdf0e10cSrcweir pType = (SwTOXType*)pDoc->InsertTOXType( *pType );
542cdf0e10cSrcweir }
543cdf0e10cSrcweir pType->Add( this );
544cdf0e10cSrcweir
545cdf0e10cSrcweir nCreateType = rSource.nCreateType;
546cdf0e10cSrcweir aTitle = rSource.aTitle;
547cdf0e10cSrcweir aForm = rSource.aForm;
548cdf0e10cSrcweir bProtected = rSource.bProtected;
549cdf0e10cSrcweir bFromChapter = rSource.bFromChapter;
550cdf0e10cSrcweir bFromObjectNames = rSource.bFromObjectNames;
551cdf0e10cSrcweir sMainEntryCharStyle = rSource.sMainEntryCharStyle;
552cdf0e10cSrcweir sSequenceName = rSource.sSequenceName;
553cdf0e10cSrcweir eCaptionDisplay = rSource.eCaptionDisplay;
554cdf0e10cSrcweir nOLEOptions = rSource.nOLEOptions;
555cdf0e10cSrcweir eLanguage = rSource.eLanguage;
556cdf0e10cSrcweir sSortAlgorithm = rSource.sSortAlgorithm;
557cdf0e10cSrcweir
558cdf0e10cSrcweir for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
559cdf0e10cSrcweir aStyleNames[i] = rSource.aStyleNames[i];
560cdf0e10cSrcweir
561cdf0e10cSrcweir // its the same data type!
562cdf0e10cSrcweir aData.nOptions = rSource.aData.nOptions;
563cdf0e10cSrcweir
564cdf0e10cSrcweir if( !pDoc || pDoc->IsCopyIsMove() )
565cdf0e10cSrcweir aName = rSource.GetTOXName();
566cdf0e10cSrcweir else
567cdf0e10cSrcweir aName = pDoc->GetUniqueTOXBaseName( *pType, &rSource.GetTOXName() );
568cdf0e10cSrcweir
569cdf0e10cSrcweir return *this;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
572cdf0e10cSrcweir /*--------------------------------------------------------------------
573cdf0e10cSrcweir Beschreibung: Verzeichnisspezifische Funktionen
574cdf0e10cSrcweir --------------------------------------------------------------------*/
575cdf0e10cSrcweir
~SwTOXBase()576cdf0e10cSrcweir SwTOXBase::~SwTOXBase()
577cdf0e10cSrcweir {
578cdf0e10cSrcweir // if( GetTOXType()->GetType() == TOX_USER )
579cdf0e10cSrcweir // delete aData.pTemplateName;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir
SetTitle(const String & rTitle)582cdf0e10cSrcweir void SwTOXBase::SetTitle(const String& rTitle)
583cdf0e10cSrcweir { aTitle = rTitle; }
584cdf0e10cSrcweir
585cdf0e10cSrcweir
operator =(const SwTOXBase & rSource)586cdf0e10cSrcweir SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource)
587cdf0e10cSrcweir {
588cdf0e10cSrcweir ByteString aTmpStr(aTitle, RTL_TEXTENCODING_ASCII_US);
589cdf0e10cSrcweir ByteString aTmpStr1(rSource.aTitle, RTL_TEXTENCODING_ASCII_US);
590cdf0e10cSrcweir
591cdf0e10cSrcweir aForm = rSource.aForm;
592cdf0e10cSrcweir aName = rSource.aName;
593cdf0e10cSrcweir aTitle = rSource.aTitle;
594cdf0e10cSrcweir sMainEntryCharStyle = rSource.sMainEntryCharStyle;
595cdf0e10cSrcweir for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++)
596cdf0e10cSrcweir aStyleNames[nLevel] = rSource.aStyleNames[nLevel];
597cdf0e10cSrcweir sSequenceName = rSource.sSequenceName;
598cdf0e10cSrcweir eLanguage = rSource.eLanguage;
599cdf0e10cSrcweir sSortAlgorithm = rSource.sSortAlgorithm;
600cdf0e10cSrcweir aData = rSource.aData;
601cdf0e10cSrcweir nCreateType = rSource.nCreateType;
602cdf0e10cSrcweir nOLEOptions = rSource.nOLEOptions;
603cdf0e10cSrcweir eCaptionDisplay = rSource.eCaptionDisplay;
604cdf0e10cSrcweir bProtected = rSource.bProtected;
605cdf0e10cSrcweir bFromChapter = rSource.bFromChapter;
606cdf0e10cSrcweir bFromObjectNames = rSource.bFromObjectNames;
607cdf0e10cSrcweir bLevelFromChapter = rSource.bLevelFromChapter;
608cdf0e10cSrcweir
609cdf0e10cSrcweir if (rSource.GetAttrSet())
610cdf0e10cSrcweir SetAttrSet(*rSource.GetAttrSet());
611cdf0e10cSrcweir
612cdf0e10cSrcweir return *this;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir
615cdf0e10cSrcweir /* -----------------16.07.99 16:02-------------------
616cdf0e10cSrcweir
617cdf0e10cSrcweir SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource)
618cdf0e10cSrcweir {
619cdf0e10cSrcweir aForm = rSource.aForm;
620cdf0e10cSrcweir aName = rSource.aName;
621cdf0e10cSrcweir aTitle = rSource.aTitle;
622cdf0e10cSrcweir sMainEntryCharStyle = rSource.sMainEntryCharStyle;
623cdf0e10cSrcweir sSequenceName = rSource.sSequenceName;
624cdf0e10cSrcweir eLanguage = rSource.eLanguage;
625cdf0e10cSrcweir sSortAlgorithm = rSource.sSortAlgorithm;
626cdf0e10cSrcweir aData = rSource.aData;
627cdf0e10cSrcweir nCreateType = rSource.nCreateType;
628cdf0e10cSrcweir nOLEOptions = rSource.nOLEOptions;
629cdf0e10cSrcweir eCaptionDisplay = rSource.eCaptionDisplay;
630cdf0e10cSrcweir bProtected = rSource.bProtected;
631cdf0e10cSrcweir bFromChapter = rSource.bFromChapter;
632cdf0e10cSrcweir bFromObjectNames = rSource.bFromObjectNames;
633cdf0e10cSrcweir bLevelFromChapter = rSource.bLevelFromChapter;
634cdf0e10cSrcweir
635cdf0e10cSrcweir if (rSource.GetAttrSet())
636cdf0e10cSrcweir SetAttrSet(*rSource.GetAttrSet());
637cdf0e10cSrcweir
638cdf0e10cSrcweir return *this;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir --------------------------------------------------*/
642cdf0e10cSrcweir
GetString() const643cdf0e10cSrcweir String SwFormToken::GetString() const
644cdf0e10cSrcweir {
645cdf0e10cSrcweir String sRet;
646cdf0e10cSrcweir
647cdf0e10cSrcweir sal_Bool bAppend = sal_True;
648cdf0e10cSrcweir switch( eTokenType )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir case TOKEN_ENTRY_NO:
651cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormEntryNum );
652cdf0e10cSrcweir break;
653cdf0e10cSrcweir case TOKEN_ENTRY_TEXT:
654cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormEntryTxt );
655cdf0e10cSrcweir break;
656cdf0e10cSrcweir case TOKEN_ENTRY:
657cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormEntry );
658cdf0e10cSrcweir break;
659cdf0e10cSrcweir case TOKEN_TAB_STOP:
660cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormTab );
661cdf0e10cSrcweir break;
662cdf0e10cSrcweir case TOKEN_TEXT:
663cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormText );
664cdf0e10cSrcweir break;
665cdf0e10cSrcweir case TOKEN_PAGE_NUMS:
666cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormPageNums );
667cdf0e10cSrcweir break;
668cdf0e10cSrcweir case TOKEN_CHAPTER_INFO:
669cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormChapterMark );
670cdf0e10cSrcweir break;
671cdf0e10cSrcweir case TOKEN_LINK_START:
672cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormLinkStt );
673cdf0e10cSrcweir break;
674cdf0e10cSrcweir case TOKEN_LINK_END:
675cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormLinkEnd );
676cdf0e10cSrcweir break;
677cdf0e10cSrcweir case TOKEN_AUTHORITY:
678cdf0e10cSrcweir {
679cdf0e10cSrcweir sRet.AssignAscii( SwForm::aFormAuth );
680cdf0e10cSrcweir String sTmp( String::CreateFromInt32( nAuthorityField ));
681cdf0e10cSrcweir if( sTmp.Len() < 2 )
682cdf0e10cSrcweir sTmp.Insert('0', 0);
683cdf0e10cSrcweir sRet.Insert( sTmp, 2 );
684cdf0e10cSrcweir }
685cdf0e10cSrcweir break;
686cdf0e10cSrcweir case TOKEN_END:
687cdf0e10cSrcweir break;
688cdf0e10cSrcweir }
689cdf0e10cSrcweir sRet.Erase( sRet.Len() - 1 );
690cdf0e10cSrcweir sRet += ' ';
691cdf0e10cSrcweir sRet += sCharStyleName;
692cdf0e10cSrcweir sRet += ',';
693cdf0e10cSrcweir sRet += String::CreateFromInt32( nPoolId );
694cdf0e10cSrcweir sRet += ',';
695cdf0e10cSrcweir
696cdf0e10cSrcweir // TabStopPosition and TabAlign or ChapterInfoFormat
697cdf0e10cSrcweir if(TOKEN_TAB_STOP == eTokenType)
698cdf0e10cSrcweir {
699cdf0e10cSrcweir sRet += String::CreateFromInt32( nTabStopPosition );
700cdf0e10cSrcweir sRet += ',';
701cdf0e10cSrcweir sRet += String::CreateFromInt32( static_cast< sal_Int32 >(eTabAlign) );
702cdf0e10cSrcweir sRet += ',';
703cdf0e10cSrcweir sRet += cTabFillChar;
704cdf0e10cSrcweir sRet += ',';
705cdf0e10cSrcweir sRet += String::CreateFromInt32( bWithTab );
706cdf0e10cSrcweir }
707cdf0e10cSrcweir else if(TOKEN_CHAPTER_INFO == eTokenType)
708cdf0e10cSrcweir {
709cdf0e10cSrcweir sRet += String::CreateFromInt32( nChapterFormat );
710cdf0e10cSrcweir //add maximum permetted level
711cdf0e10cSrcweir sRet += ',';
712cdf0e10cSrcweir sRet += String::CreateFromInt32( nOutlineLevel );
713cdf0e10cSrcweir }
714cdf0e10cSrcweir else if(TOKEN_TEXT == eTokenType)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir //append Text if Len() > 0 only!
717cdf0e10cSrcweir if( sText.Len() )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir sRet += TOX_STYLE_DELIMITER;
720cdf0e10cSrcweir String sTmp( sText );
721cdf0e10cSrcweir sTmp.EraseAllChars( TOX_STYLE_DELIMITER );
722cdf0e10cSrcweir sRet += sTmp;
723cdf0e10cSrcweir sRet += TOX_STYLE_DELIMITER;
724cdf0e10cSrcweir }
725cdf0e10cSrcweir else
726cdf0e10cSrcweir bAppend = sal_False;
727cdf0e10cSrcweir }
728cdf0e10cSrcweir else if(TOKEN_ENTRY_NO == eTokenType)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir sRet += String::CreateFromInt32( nChapterFormat );
731cdf0e10cSrcweir //add maximum permitted level
732cdf0e10cSrcweir sRet += ',';
733cdf0e10cSrcweir sRet += String::CreateFromInt32( nOutlineLevel );
734cdf0e10cSrcweir }
735cdf0e10cSrcweir
736cdf0e10cSrcweir if(bAppend)
737cdf0e10cSrcweir {
738cdf0e10cSrcweir sRet += '>';
739cdf0e10cSrcweir }
740cdf0e10cSrcweir else
741cdf0e10cSrcweir {
742cdf0e10cSrcweir // don't append empty text tokens
743cdf0e10cSrcweir sRet.Erase();
744cdf0e10cSrcweir }
745cdf0e10cSrcweir
746cdf0e10cSrcweir return sRet;
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
749cdf0e10cSrcweir // -> #i21237#
SwFormTokensHelper(const String & rPattern)750cdf0e10cSrcweir SwFormTokensHelper::SwFormTokensHelper(const String & rPattern)
751cdf0e10cSrcweir {
752cdf0e10cSrcweir xub_StrLen nCurPatternPos = 0;
753cdf0e10cSrcweir xub_StrLen nCurPatternLen = 0;
754cdf0e10cSrcweir
755cdf0e10cSrcweir while (nCurPatternPos < rPattern.Len())
756cdf0e10cSrcweir {
757cdf0e10cSrcweir nCurPatternPos = nCurPatternPos + nCurPatternLen;
758cdf0e10cSrcweir
759cdf0e10cSrcweir SwFormToken aToken = BuildToken(rPattern, nCurPatternPos);
760cdf0e10cSrcweir aTokens.push_back(aToken);
761cdf0e10cSrcweir }
762cdf0e10cSrcweir }
763cdf0e10cSrcweir
BuildToken(const String & sPattern,xub_StrLen & nCurPatternPos) const764cdf0e10cSrcweir SwFormToken SwFormTokensHelper::BuildToken( const String & sPattern,
765cdf0e10cSrcweir xub_StrLen & nCurPatternPos ) const
766cdf0e10cSrcweir {
767cdf0e10cSrcweir String sToken( SearchNextToken(sPattern, nCurPatternPos) );
768cdf0e10cSrcweir nCurPatternPos = nCurPatternPos + sToken.Len();
769cdf0e10cSrcweir xub_StrLen nTokenLen;
770cdf0e10cSrcweir FormTokenType eTokenType = GetTokenType(sToken, &nTokenLen);
771cdf0e10cSrcweir
772cdf0e10cSrcweir // at this point sPattern contains the
773cdf0e10cSrcweir // character style name, the PoolId, tab stop position, tab stop alignment, chapter info format
774cdf0e10cSrcweir // the form is: CharStyleName, PoolId[, TabStopPosition|ChapterInfoFormat[, TabStopAlignment[, TabFillChar]]]
775cdf0e10cSrcweir // in text tokens the form differs from the others: CharStyleName, PoolId[,\0xffinserted text\0xff]
776cdf0e10cSrcweir SwFormToken eRet( eTokenType );
777cdf0e10cSrcweir String sAuthFieldEnum = sToken.Copy( 2, 2 );
778cdf0e10cSrcweir sToken = sToken.Copy( nTokenLen, sToken.Len() - nTokenLen - 1);
779cdf0e10cSrcweir
780cdf0e10cSrcweir eRet.sCharStyleName = sToken.GetToken( 0, ',');
781cdf0e10cSrcweir String sTmp( sToken.GetToken( 1, ',' ));
782cdf0e10cSrcweir if( sTmp.Len() )
783cdf0e10cSrcweir eRet.nPoolId = static_cast<sal_uInt16>(sTmp.ToInt32());
784cdf0e10cSrcweir
785cdf0e10cSrcweir switch( eTokenType )
786cdf0e10cSrcweir {
787cdf0e10cSrcweir //i53420
788cdf0e10cSrcweir case TOKEN_ENTRY_NO:
789cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() )
790cdf0e10cSrcweir eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.ToInt32());
791cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() )
792cdf0e10cSrcweir eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.ToInt32()); //the maximum outline level to examine
793cdf0e10cSrcweir break;
794cdf0e10cSrcweir
795cdf0e10cSrcweir case TOKEN_TEXT:
796cdf0e10cSrcweir {
797cdf0e10cSrcweir xub_StrLen nStartText = sToken.Search( TOX_STYLE_DELIMITER );
798cdf0e10cSrcweir if( STRING_NOTFOUND != nStartText )
799cdf0e10cSrcweir {
800cdf0e10cSrcweir xub_StrLen nEndText = sToken.Search( TOX_STYLE_DELIMITER,
801cdf0e10cSrcweir nStartText + 1);
802cdf0e10cSrcweir if( STRING_NOTFOUND != nEndText )
803cdf0e10cSrcweir {
804cdf0e10cSrcweir eRet.sText = sToken.Copy( nStartText + 1,
805cdf0e10cSrcweir nEndText - nStartText - 1);
806cdf0e10cSrcweir }
807cdf0e10cSrcweir }
808cdf0e10cSrcweir }
809cdf0e10cSrcweir break;
810cdf0e10cSrcweir
811cdf0e10cSrcweir case TOKEN_TAB_STOP:
812cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() )
813cdf0e10cSrcweir eRet.nTabStopPosition = sTmp.ToInt32();
814cdf0e10cSrcweir
815cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() )
816cdf0e10cSrcweir eRet.eTabAlign = static_cast<SvxTabAdjust>(sTmp.ToInt32());
817cdf0e10cSrcweir
818cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 4, ',' ) ).Len() )
819cdf0e10cSrcweir eRet.cTabFillChar = sTmp.GetChar(0);
820cdf0e10cSrcweir
821cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 5, ',' ) ).Len() )
822cdf0e10cSrcweir eRet.bWithTab = 0 != sTmp.ToInt32();
823cdf0e10cSrcweir break;
824cdf0e10cSrcweir
825cdf0e10cSrcweir case TOKEN_CHAPTER_INFO:
826cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 2, ',' ) ).Len() )
827cdf0e10cSrcweir eRet.nChapterFormat = static_cast<sal_uInt16>(sTmp.ToInt32()); //SwChapterFormat;
828cdf0e10cSrcweir //i53420
829cdf0e10cSrcweir if( (sTmp = sToken.GetToken( 3, ',' ) ).Len() )
830cdf0e10cSrcweir eRet.nOutlineLevel = static_cast<sal_uInt16>(sTmp.ToInt32()); //the maximum outline level to examine
831cdf0e10cSrcweir
832cdf0e10cSrcweir break;
833cdf0e10cSrcweir
834cdf0e10cSrcweir case TOKEN_AUTHORITY:
835cdf0e10cSrcweir eRet.nAuthorityField = static_cast<sal_uInt16>(sAuthFieldEnum.ToInt32());
836cdf0e10cSrcweir break;
837cdf0e10cSrcweir default: break;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir return eRet;
840cdf0e10cSrcweir }
841cdf0e10cSrcweir
SearchNextToken(const String & sPattern,xub_StrLen nStt) const842cdf0e10cSrcweir String SwFormTokensHelper::SearchNextToken( const String & sPattern,
843cdf0e10cSrcweir xub_StrLen nStt ) const
844cdf0e10cSrcweir {
845cdf0e10cSrcweir //it's not so easy - it doesn't work if the text part contains a '>'
846cdf0e10cSrcweir //sal_uInt16 nTokenEnd = sPattern.Search('>');
847cdf0e10cSrcweir
848cdf0e10cSrcweir String aResult;
849cdf0e10cSrcweir
850cdf0e10cSrcweir xub_StrLen nEnd = sPattern.Search( '>', nStt );
851cdf0e10cSrcweir if( STRING_NOTFOUND == nEnd )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir nEnd = sPattern.Len();
854cdf0e10cSrcweir }
855cdf0e10cSrcweir else
856cdf0e10cSrcweir {
857cdf0e10cSrcweir xub_StrLen nTextSeparatorFirst = sPattern.Search( TOX_STYLE_DELIMITER, nStt );
858cdf0e10cSrcweir if( STRING_NOTFOUND != nTextSeparatorFirst )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir xub_StrLen nTextSeparatorSecond = sPattern.Search( TOX_STYLE_DELIMITER,
861cdf0e10cSrcweir nTextSeparatorFirst + 1 );
862cdf0e10cSrcweir if( STRING_NOTFOUND != nTextSeparatorSecond &&
863cdf0e10cSrcweir nEnd > nTextSeparatorFirst )
864cdf0e10cSrcweir nEnd = sPattern.Search( '>', nTextSeparatorSecond );
865cdf0e10cSrcweir }
866cdf0e10cSrcweir
867cdf0e10cSrcweir ++nEnd;
868cdf0e10cSrcweir
869cdf0e10cSrcweir aResult = sPattern.Copy( nStt, nEnd - nStt );
870cdf0e10cSrcweir }
871cdf0e10cSrcweir
872cdf0e10cSrcweir return aResult;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir
GetTokenType(const String & sToken,xub_StrLen * pTokenLen) const875cdf0e10cSrcweir FormTokenType SwFormTokensHelper::GetTokenType(const String & sToken,
876cdf0e10cSrcweir xub_StrLen * pTokenLen) const
877cdf0e10cSrcweir {
878cdf0e10cSrcweir static struct
879cdf0e10cSrcweir {
880cdf0e10cSrcweir const sal_Char* pNm;
881cdf0e10cSrcweir sal_uInt16 nLen;
882cdf0e10cSrcweir sal_uInt16 nOffset;
883cdf0e10cSrcweir FormTokenType eToken;
884cdf0e10cSrcweir } __READONLY_DATA aTokenArr[] = {
885cdf0e10cSrcweir { SwForm::aFormTab, SwForm::nFormEntryLen, 1, TOKEN_TAB_STOP },
886cdf0e10cSrcweir { SwForm::aFormPageNums, SwForm::nFormPageNumsLen, 1, TOKEN_PAGE_NUMS },
887cdf0e10cSrcweir { SwForm::aFormLinkStt, SwForm::nFormLinkSttLen, 1, TOKEN_LINK_START },
888cdf0e10cSrcweir { SwForm::aFormLinkEnd, SwForm::nFormLinkEndLen, 1, TOKEN_LINK_END },
889cdf0e10cSrcweir { SwForm::aFormEntryNum, SwForm::nFormEntryNumLen, 1, TOKEN_ENTRY_NO },
890cdf0e10cSrcweir { SwForm::aFormEntryTxt, SwForm::nFormEntryTxtLen, 1, TOKEN_ENTRY_TEXT },
891cdf0e10cSrcweir { SwForm::aFormChapterMark,SwForm::nFormChapterMarkLen,1,TOKEN_CHAPTER_INFO },
892cdf0e10cSrcweir { SwForm::aFormText, SwForm::nFormTextLen, 1, TOKEN_TEXT },
893cdf0e10cSrcweir { SwForm::aFormEntry, SwForm::nFormEntryLen, 1, TOKEN_ENTRY },
894cdf0e10cSrcweir { SwForm::aFormAuth, SwForm::nFormAuthLen, 3, TOKEN_AUTHORITY },
895cdf0e10cSrcweir { 0, 0, 0, TOKEN_END }
896cdf0e10cSrcweir };
897cdf0e10cSrcweir
898cdf0e10cSrcweir FormTokenType eTokenType = TOKEN_TEXT;
899cdf0e10cSrcweir xub_StrLen nTokenLen = 0;
900cdf0e10cSrcweir const sal_Char* pNm;
901cdf0e10cSrcweir for( int i = 0; 0 != ( pNm = aTokenArr[ i ].pNm ); ++i )
902cdf0e10cSrcweir if( COMPARE_EQUAL == sToken.CompareToAscii( pNm,
903cdf0e10cSrcweir aTokenArr[ i ].nLen - aTokenArr[ i ].nOffset ))
904cdf0e10cSrcweir {
905cdf0e10cSrcweir eTokenType = aTokenArr[ i ].eToken;
906cdf0e10cSrcweir nTokenLen = aTokenArr[ i ].nLen;
907cdf0e10cSrcweir break;
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir ASSERT( pNm, "wrong token" );
911cdf0e10cSrcweir if (pTokenLen)
912cdf0e10cSrcweir *pTokenLen = nTokenLen;
913cdf0e10cSrcweir
914cdf0e10cSrcweir return eTokenType;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
917cdf0e10cSrcweir // <- #i21237#
918cdf0e10cSrcweir
SetPattern(sal_uInt16 nLevel,const SwFormTokens & rTokens)919cdf0e10cSrcweir void SwForm::SetPattern(sal_uInt16 nLevel, const SwFormTokens& rTokens)
920cdf0e10cSrcweir {
921cdf0e10cSrcweir ASSERT(nLevel < GetFormMax(), "Index >= FORM_MAX");
922cdf0e10cSrcweir aPattern[nLevel] = rTokens;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir
SetPattern(sal_uInt16 nLevel,const String & rStr)925cdf0e10cSrcweir void SwForm::SetPattern(sal_uInt16 nLevel, const String & rStr)
926cdf0e10cSrcweir {
927cdf0e10cSrcweir ASSERT(nLevel < GetFormMax(), "Index >= FORM_MAX");
928cdf0e10cSrcweir
929cdf0e10cSrcweir SwFormTokensHelper aHelper(rStr);
930cdf0e10cSrcweir aPattern[nLevel] = aHelper.GetTokens();
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
GetPattern(sal_uInt16 nLevel) const933cdf0e10cSrcweir const SwFormTokens& SwForm::GetPattern(sal_uInt16 nLevel) const
934cdf0e10cSrcweir {
935cdf0e10cSrcweir ASSERT(nLevel < GetFormMax(), "Index >= FORM_MAX");
936cdf0e10cSrcweir return aPattern[nLevel];
937cdf0e10cSrcweir }
938cdf0e10cSrcweir
939