1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tox.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
37 #include <tools/resid.hxx>
38 #include <hintids.hxx>
39 #include <swtypes.hxx>
43 #include <txttxmrk.hxx>
46 #include <poolfmt.hrc>
51 #include <svx/tstpitem.hxx>
52 #include <SwStyleNameMapper.hxx>
61 const sal_Char
* SwForm::aFormEntry
= "<E>";
62 const sal_Char
* SwForm::aFormTab
= "<T>";
63 const sal_Char
* SwForm::aFormPageNums
= "<#>";
64 const sal_Char
* SwForm::aFormLinkStt
= "<LS>";
65 const sal_Char
* SwForm::aFormLinkEnd
= "<LE>";
66 const sal_Char
* SwForm::aFormEntryNum
= "<E#>";
67 const sal_Char
* SwForm::aFormEntryTxt
= "<ET>";
68 const sal_Char
* SwForm::aFormChapterMark
= "<C>";
69 const sal_Char
* SwForm::aFormText
= "<X>";
70 const sal_Char
* SwForm::aFormAuth
= "<A>";
71 BYTE
SwForm::nFormTabLen
= 3;
72 BYTE
SwForm::nFormEntryLen
= 3;
73 BYTE
SwForm::nFormPageNumsLen
= 3;
74 BYTE
SwForm::nFormLinkSttLen
= 4;
75 BYTE
SwForm::nFormLinkEndLen
= 4;
76 BYTE
SwForm::nFormEntryNumLen
= 4;
77 BYTE
SwForm::nFormEntryTxtLen
= 4;
78 BYTE
SwForm::nFormChapterMarkLen
= 3;
79 BYTE
SwForm::nFormTextLen
= 3;
80 BYTE
SwForm::nFormAuthLen
= 5;
82 SV_IMPL_PTRARR(SwTOXMarks
, SwTOXMark
*)
84 TYPEINIT2( SwTOXMark
, SfxPoolItem
, SwClient
); // fuers rtti
86 /* -----------------23.09.99 13:59-------------------
88 --------------------------------------------------*/
97 const PatternIni aPatternIni
[] =
99 {USHRT_MAX
, USHRT_MAX
, USHRT_MAX
, USHRT_MAX
, USHRT_MAX
}, //Header - no pattern
100 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_ARTICLE,
101 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_BOOK,
102 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_BOOKLET,
103 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_CONFERENCE,
104 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_INBOOK,
105 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_INCOLLECTION,
106 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_INPROCEEDINGS,
107 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_JOURNAL,
108 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_MANUAL,
109 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_MASTERSTHESIS,
110 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_MISC,
111 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_PHDTHESIS,
112 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_PROCEEDINGS,
113 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_TECHREPORT,
114 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_UNPUBLISHED,
115 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_EMAIL,
116 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, AUTH_FIELD_URL
, USHRT_MAX
},//AUTH_TYPE_WWW,
117 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_CUSTOM1,
118 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_CUSTOM2,
119 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_CUSTOM3,
120 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_CUSTOM4,
121 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_TYPE_CUSTOM5,
122 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_YEAR,
123 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_URL,
124 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_CUSTOM1,
125 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_CUSTOM2,
126 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_CUSTOM3,
127 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_CUSTOM4,
128 {AUTH_FIELD_AUTHOR
, AUTH_FIELD_TITLE
, AUTH_FIELD_YEAR
, USHRT_MAX
, USHRT_MAX
}, //AUTH_FIELD_CUSTOM5,
129 {USHRT_MAX
, USHRT_MAX
, USHRT_MAX
, USHRT_MAX
, USHRT_MAX
}
131 /* -----------------23.09.99 13:58-------------------
133 --------------------------------------------------*/
135 SwFormTokens
lcl_GetAuthPattern(USHORT nTypeId
)
137 SwFormTokens aRet
; // #i21237#
140 PatternIni aIni
= aPatternIni
[nTypeId
];
148 SwFormToken
aStartToken( TOKEN_AUTHORITY
);
149 aStartToken
.nAuthorityField
= AUTH_FIELD_IDENTIFIER
;
150 aRet
.push_back( aStartToken
);
151 SwFormToken
aSeparatorToken( TOKEN_TEXT
);
152 aSeparatorToken
.sText
= String::CreateFromAscii( ": " );
153 aRet
.push_back( aSeparatorToken
);
154 SwFormToken
aTextToken( TOKEN_TEXT
);
155 aTextToken
.sText
= String::CreateFromAscii( ", " );
157 for(USHORT i
= 0; i
< 5 ; i
++)
159 if(nVals
[i
] == USHRT_MAX
)
162 aRet
.push_back( aTextToken
);
165 SwFormToken
aToken(TOKEN_AUTHORITY
);
167 aToken
.nAuthorityField
= nVals
[i
];
168 aRet
.push_back(aToken
);
174 /*--------------------------------------------------------------------
175 Beschreibung: Verzeichnis-Markierungen D/Ctor
176 --------------------------------------------------------------------*/
179 // Konstruktor fuers Default vom Attribut-Pool
180 SwTOXMark::SwTOXMark()
181 : SfxPoolItem( RES_TXTATR_TOXMARK
),
184 bAutoGenerated(FALSE
),
190 SwTOXMark::SwTOXMark( const SwTOXType
* pTyp
)
191 : SfxPoolItem( RES_TXTATR_TOXMARK
),
192 SwClient( (SwModify
*)pTyp
),
193 pTxtAttr( 0 ), nLevel( 0 ),
194 bAutoGenerated(FALSE
),
200 SwTOXMark::SwTOXMark( const SwTOXMark
& rCopy
)
201 : SfxPoolItem( RES_TXTATR_TOXMARK
),
202 SwClient((SwModify
*)rCopy
.GetRegisteredIn()),
203 aPrimaryKey( rCopy
.aPrimaryKey
), aSecondaryKey( rCopy
.aSecondaryKey
),
204 aTextReading( rCopy
.aTextReading
),
205 aPrimaryKeyReading( rCopy
.aPrimaryKeyReading
),
206 aSecondaryKeyReading( rCopy
.aSecondaryKeyReading
),
207 pTxtAttr( 0 ), nLevel( rCopy
.nLevel
),
208 bAutoGenerated( rCopy
.bAutoGenerated
),
209 bMainEntry(rCopy
.bMainEntry
)
211 // AlternativString kopieren
212 aAltText
= rCopy
.aAltText
;
216 SwTOXMark::~SwTOXMark()
221 int SwTOXMark::operator==( const SfxPoolItem
& rAttr
) const
223 ASSERT( SfxPoolItem::operator==( rAttr
), "keine gleichen Attribute" );
224 return GetRegisteredIn() == ((SwTOXMark
&)rAttr
).GetRegisteredIn();
228 SfxPoolItem
* SwTOXMark::Clone( SfxItemPool
* ) const
230 return new SwTOXMark( *this );
234 String
SwTOXMark::GetText() const
239 else if( pTxtAttr
&& pTxtAttr
->GetpTxtNd() )
241 xub_StrLen
* pEndIdx
= pTxtAttr
->GetEnd();
242 ASSERT( pEndIdx
, "TOXMark ohne Mark!!");
245 const xub_StrLen nStt
= *pTxtAttr
->GetStart();
246 aStr
= pTxtAttr
->GetpTxtNd()->GetExpandTxt( nStt
, *pEndIdx
-nStt
);
252 /*--------------------------------------------------------------------
253 Beschreibung: Typen von Verzeichnissen verwalten
254 --------------------------------------------------------------------*/
256 SwTOXType::SwTOXType( TOXTypes eTyp
, const String
& rName
)
264 SwTOXType::SwTOXType(const SwTOXType
& rCopy
)
265 : SwModify( (SwModify
*)rCopy
.GetRegisteredIn() ),
271 /*--------------------------------------------------------------------
272 Beschreibung: Formen bearbeiten
273 --------------------------------------------------------------------*/
275 SwForm::SwForm( TOXTypes eTyp
) // #i21237#
276 : eType( eTyp
), nFormMaxLevel( SwForm::GetFormMaxLevel( eTyp
)),
277 // nFirstTabPos( lNumIndent ),
278 bCommaSeparated(FALSE
)
281 bGenerateTabPos
= FALSE
;
284 // Inhaltsverzeichnis hat entsprechend Anzahl Headlines + Ueberschrift
285 // Benutzer hat 10 Ebenen + Ueberschrift
286 // Stichwort hat 3 Ebenen + Ueberschrift + Trenner
287 // indexes of tables, objects illustrations and authorities consist of a heading and one level
292 case TOX_INDEX
: nPoolId
= STR_POOLCOLL_TOX_IDXH
; break;
293 case TOX_USER
: nPoolId
= STR_POOLCOLL_TOX_USERH
; break;
294 case TOX_CONTENT
: nPoolId
= STR_POOLCOLL_TOX_CNTNTH
; break;
295 case TOX_ILLUSTRATIONS
: nPoolId
= STR_POOLCOLL_TOX_ILLUSH
; break;
296 case TOX_OBJECTS
: nPoolId
= STR_POOLCOLL_TOX_OBJECTH
; break;
297 case TOX_TABLES
: nPoolId
= STR_POOLCOLL_TOX_TABLESH
; break;
298 case TOX_AUTHORITIES
: nPoolId
= STR_POOLCOLL_TOX_AUTHORITIESH
; break;
300 ASSERT( !this, "ungueltiger TOXTyp");
304 SwFormTokens aTokens
;
305 if (TOX_CONTENT
== eType
)
307 aTokens
.push_back(SwFormToken(TOKEN_ENTRY_NO
));
308 aTokens
.push_back(SwFormToken(TOKEN_ENTRY_TEXT
));
311 aTokens
.push_back(SwFormToken(TOKEN_ENTRY
));
313 if (TOX_AUTHORITIES
!= eType
)
315 SwFormToken
aToken(TOKEN_TAB_STOP
);
316 aToken
.nTabStopPosition
= 0;
318 // --> FME 2004-12-10 #i36870# right aligned tab for all
319 aToken
.cTabFillChar
= '.';
320 aToken
.eTabAlign
= SVX_TAB_ADJUST_END
;
323 aTokens
.push_back(aToken
);
324 aTokens
.push_back(SwFormToken(TOKEN_PAGE_NUMS
));
327 SetTemplate( 0, SW_RESSTR( nPoolId
++ ));
329 if(TOX_INDEX
== eType
)
331 for( USHORT i
= 1; i
< 5; ++i
)
335 SwFormTokens aTmpTokens
;
336 SwFormToken
aTmpToken(TOKEN_ENTRY
);
337 aTmpTokens
.push_back(aTmpToken
);
339 SetPattern( i
, aTmpTokens
);
340 SetTemplate( i
, SW_RESSTR( STR_POOLCOLL_TOX_IDXBREAK
));
344 SetPattern( i
, aTokens
);
345 SetTemplate( i
, SW_RESSTR( STR_POOLCOLL_TOX_IDX1
+ i
- 2 ));
350 for( USHORT i
= 1; i
< GetFormMax(); ++i
, ++nPoolId
) // Nr 0 ist der Titel
352 if(TOX_AUTHORITIES
== eType
)
353 SetPattern(i
, lcl_GetAuthPattern(i
));
355 SetPattern( i
, aTokens
);
357 if( TOX_CONTENT
== eType
&& 6 == i
)
358 nPoolId
= STR_POOLCOLL_TOX_CNTNT6
;
359 else if( TOX_USER
== eType
&& 6 == i
)
360 nPoolId
= STR_POOLCOLL_TOX_USER6
;
361 else if( TOX_AUTHORITIES
== eType
)
362 nPoolId
= STR_POOLCOLL_TOX_AUTHORITIES1
;
363 SetTemplate( i
, SW_RESSTR( nPoolId
) );
368 SwForm::SwForm(const SwForm
& rForm
)
369 : eType( rForm
.eType
)
375 SwForm
& SwForm::operator=(const SwForm
& rForm
)
378 nFormMaxLevel
= rForm
.nFormMaxLevel
;
379 // nFirstTabPos = rForm.nFirstTabPos;
380 // bHasFirstTabPos = rForm.bHasFirstTabPos;
381 bGenerateTabPos
= rForm
.bGenerateTabPos
;
382 bIsRelTabPos
= rForm
.bIsRelTabPos
;
383 bCommaSeparated
= rForm
.bCommaSeparated
;
384 for(USHORT i
=0; i
< nFormMaxLevel
; ++i
)
386 aPattern
[i
] = rForm
.aPattern
[i
];
387 aTemplate
[i
] = rForm
.aTemplate
[i
];
392 USHORT
SwForm::GetFormMaxLevel( TOXTypes eTOXType
)
397 case TOX_INDEX
: nRet
= 5; break;
398 case TOX_USER
: nRet
= MAXLEVEL
+1; break;
399 case TOX_CONTENT
: nRet
= MAXLEVEL
+1; break;
400 case TOX_ILLUSTRATIONS
:
402 case TOX_TABLES
: nRet
= 2; break;
403 case TOX_AUTHORITIES
: nRet
= AUTH_TYPE_END
+ 1; break;
409 bool operator == (const SwFormToken
& rToken
, FormTokenType eType
)
411 return rToken
.eTokenType
== eType
;
414 //-----------------------------------------------------------------------------
415 void SwForm::AdjustTabStops(SwDoc
& rDoc
, BOOL bInsertNewTapStops
) // #i21237#
417 for(USHORT nLevel
= 1; nLevel
< GetFormMax(); nLevel
++)
419 const String
& sTemplateName
= GetTemplate(nLevel
);
421 SwTxtFmtColl
* pColl
= rDoc
.FindTxtFmtCollByName( sTemplateName
);
424 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName
425 ( sTemplateName
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
); // #i21237#
426 if( USHRT_MAX
!= nId
)
427 pColl
= rDoc
.GetTxtCollFromPool( nId
);
430 const SvxTabStopItem
* pTabStops
= 0;
431 USHORT nTabCount
= 0;
433 0 != ( pTabStops
= &pColl
->GetTabStops(FALSE
) ) &&
434 0 != ( nTabCount
= pTabStops
->Count() ) )
437 SwFormTokens aCurrentPattern
= GetPattern(nLevel
);
438 SwFormTokens::iterator aIt
= aCurrentPattern
.begin();
440 BOOL bChanged
= FALSE
;
442 for(USHORT nTab
= 0; nTab
< nTabCount
; ++nTab
)
444 const SvxTabStop
& rTab
= (*pTabStops
)[nTab
];
446 // --> FME 2004-12-16 #i29178#
447 // For Word import, we do not want to replace exising tokens,
448 // we insert new tabstop tokens without a tabstop character:
449 if ( bInsertNewTapStops
)
451 if ( SVX_TAB_ADJUST_DEFAULT
!= rTab
.GetAdjustment() )
454 SwFormToken
aToken(TOKEN_TAB_STOP
);
455 aToken
.bWithTab
= FALSE
;
456 aToken
.nTabStopPosition
= rTab
.GetTabPos();
457 aToken
.eTabAlign
= rTab
.GetAdjustment();
458 aToken
.cTabFillChar
= rTab
.GetFill();
459 aCurrentPattern
.push_back(aToken
);
465 aIt
= find_if(aIt
, aCurrentPattern
.end(),
466 SwFormTokenEqualToFormTokenType
468 if ( aIt
!= aCurrentPattern
.end() )
471 aIt
->nTabStopPosition
= rTab
.GetTabPos();
472 aIt
->eTabAlign
= nTab
== nTabCount
- 1 &&
473 SVX_TAB_ADJUST_RIGHT
== rTab
.GetAdjustment() ?
475 rTab
.GetAdjustment();
476 aIt
->cTabFillChar
= rTab
.GetFill();
480 break; // no more tokens to replace
486 SetPattern(nLevel
, aCurrentPattern
); // #i21237#
490 /*--------------------------------------------------------------------
491 Beschreibung: Ctor TOXBase
492 --------------------------------------------------------------------*/
495 SwTOXBase::SwTOXBase(const SwTOXType
* pTyp
, const SwForm
& rForm
,
496 USHORT nCreaType
, const String
& rTitle
)
497 : SwClient((SwModify
*)pTyp
),
500 eLanguage((LanguageType
)::GetAppLanguage()),
501 nCreateType(nCreaType
),
503 eCaptionDisplay(CAPTION_COMPLETE
),
506 bFromObjectNames(FALSE
),
507 bLevelFromChapter(FALSE
)
513 SwTOXBase::SwTOXBase( const SwTOXBase
& rSource
, SwDoc
* pDoc
)
514 : SwClient( rSource
.pRegisteredIn
)
516 CopyTOXBase( pDoc
, rSource
);
519 SwTOXBase
& SwTOXBase::CopyTOXBase( SwDoc
* pDoc
, const SwTOXBase
& rSource
)
521 SwTOXType
* pType
= (SwTOXType
*)rSource
.GetTOXType();
522 if( pDoc
&& USHRT_MAX
== pDoc
->GetTOXTypes().GetPos( pType
))
524 // type not in pDoc, so create it now
525 const SwTOXTypes
& rTypes
= pDoc
->GetTOXTypes();
527 for( USHORT n
= rTypes
.Count(); n
; )
529 const SwTOXType
* pCmp
= rTypes
[ --n
];
530 if( pCmp
->GetType() == pType
->GetType() &&
531 pCmp
->GetTypeName() == pType
->GetTypeName() )
533 pType
= (SwTOXType
*)pCmp
;
540 pType
= (SwTOXType
*)pDoc
->InsertTOXType( *pType
);
544 nCreateType
= rSource
.nCreateType
;
545 aTitle
= rSource
.aTitle
;
546 aForm
= rSource
.aForm
;
547 bProtected
= rSource
.bProtected
;
548 bFromChapter
= rSource
.bFromChapter
;
549 bFromObjectNames
= rSource
.bFromObjectNames
;
550 sMainEntryCharStyle
= rSource
.sMainEntryCharStyle
;
551 sSequenceName
= rSource
.sSequenceName
;
552 eCaptionDisplay
= rSource
.eCaptionDisplay
;
553 nOLEOptions
= rSource
.nOLEOptions
;
554 eLanguage
= rSource
.eLanguage
;
555 sSortAlgorithm
= rSource
.sSortAlgorithm
;
557 for( USHORT i
= 0; i
< MAXLEVEL
; ++i
)
558 aStyleNames
[i
] = rSource
.aStyleNames
[i
];
560 // its the same data type!
561 aData
.nOptions
= rSource
.aData
.nOptions
;
563 if( !pDoc
|| pDoc
->IsCopyIsMove() )
564 aName
= rSource
.GetTOXName();
566 aName
= pDoc
->GetUniqueTOXBaseName( *pType
, &rSource
.GetTOXName() );
571 /*--------------------------------------------------------------------
572 Beschreibung: Verzeichnisspezifische Funktionen
573 --------------------------------------------------------------------*/
575 SwTOXBase::~SwTOXBase()
577 // if( GetTOXType()->GetType() == TOX_USER )
578 // delete aData.pTemplateName;
581 void SwTOXBase::SetTitle(const String
& rTitle
)
585 SwTOXBase
& SwTOXBase::operator = (const SwTOXBase
& rSource
)
587 ByteString
aTmpStr(aTitle
, RTL_TEXTENCODING_ASCII_US
);
588 ByteString
aTmpStr1(rSource
.aTitle
, RTL_TEXTENCODING_ASCII_US
);
590 aForm
= rSource
.aForm
;
591 aName
= rSource
.aName
;
592 aTitle
= rSource
.aTitle
;
593 sMainEntryCharStyle
= rSource
.sMainEntryCharStyle
;
594 for(USHORT nLevel
= 0; nLevel
< MAXLEVEL
; nLevel
++)
595 aStyleNames
[nLevel
] = rSource
.aStyleNames
[nLevel
];
596 sSequenceName
= rSource
.sSequenceName
;
597 eLanguage
= rSource
.eLanguage
;
598 sSortAlgorithm
= rSource
.sSortAlgorithm
;
599 aData
= rSource
.aData
;
600 nCreateType
= rSource
.nCreateType
;
601 nOLEOptions
= rSource
.nOLEOptions
;
602 eCaptionDisplay
= rSource
.eCaptionDisplay
;
603 bProtected
= rSource
.bProtected
;
604 bFromChapter
= rSource
.bFromChapter
;
605 bFromObjectNames
= rSource
.bFromObjectNames
;
606 bLevelFromChapter
= rSource
.bLevelFromChapter
;
608 if (rSource
.GetAttrSet())
609 SetAttrSet(*rSource
.GetAttrSet());
614 /* -----------------16.07.99 16:02-------------------
616 SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource)
618 aForm = rSource.aForm;
619 aName = rSource.aName;
620 aTitle = rSource.aTitle;
621 sMainEntryCharStyle = rSource.sMainEntryCharStyle;
622 sSequenceName = rSource.sSequenceName;
623 eLanguage = rSource.eLanguage;
624 sSortAlgorithm = rSource.sSortAlgorithm;
625 aData = rSource.aData;
626 nCreateType = rSource.nCreateType;
627 nOLEOptions = rSource.nOLEOptions;
628 eCaptionDisplay = rSource.eCaptionDisplay;
629 bProtected = rSource.bProtected;
630 bFromChapter = rSource.bFromChapter;
631 bFromObjectNames = rSource.bFromObjectNames;
632 bLevelFromChapter = rSource.bLevelFromChapter;
634 if (rSource.GetAttrSet())
635 SetAttrSet(*rSource.GetAttrSet());
640 --------------------------------------------------*/
642 String
SwFormToken::GetString() const
650 sRet
.AssignAscii( SwForm::aFormEntryNum
);
652 case TOKEN_ENTRY_TEXT
:
653 sRet
.AssignAscii( SwForm::aFormEntryTxt
);
656 sRet
.AssignAscii( SwForm::aFormEntry
);
659 sRet
.AssignAscii( SwForm::aFormTab
);
662 sRet
.AssignAscii( SwForm::aFormText
);
664 case TOKEN_PAGE_NUMS
:
665 sRet
.AssignAscii( SwForm::aFormPageNums
);
667 case TOKEN_CHAPTER_INFO
:
668 sRet
.AssignAscii( SwForm::aFormChapterMark
);
670 case TOKEN_LINK_START
:
671 sRet
.AssignAscii( SwForm::aFormLinkStt
);
674 sRet
.AssignAscii( SwForm::aFormLinkEnd
);
676 case TOKEN_AUTHORITY
:
678 sRet
.AssignAscii( SwForm::aFormAuth
);
679 String
sTmp( String::CreateFromInt32( nAuthorityField
));
682 sRet
.Insert( sTmp
, 2 );
688 sRet
.Erase( sRet
.Len() - 1 );
690 sRet
+= sCharStyleName
;
692 sRet
+= String::CreateFromInt32( nPoolId
);
695 // TabStopPosition and TabAlign or ChapterInfoFormat
696 if(TOKEN_TAB_STOP
== eTokenType
)
698 sRet
+= String::CreateFromInt32( nTabStopPosition
);
700 sRet
+= String::CreateFromInt32( static_cast< sal_Int32
>(eTabAlign
) );
702 sRet
+= cTabFillChar
;
704 sRet
+= String::CreateFromInt32( bWithTab
);
706 else if(TOKEN_CHAPTER_INFO
== eTokenType
)
708 sRet
+= String::CreateFromInt32( nChapterFormat
);
709 //add maximum permetted level
711 sRet
+= String::CreateFromInt32( nOutlineLevel
);
713 else if(TOKEN_TEXT
== eTokenType
)
715 //append Text if Len() > 0 only!
718 sRet
+= TOX_STYLE_DELIMITER
;
719 String
sTmp( sText
);
720 sTmp
.EraseAllChars( TOX_STYLE_DELIMITER
);
722 sRet
+= TOX_STYLE_DELIMITER
;
727 else if(TOKEN_ENTRY_NO
== eTokenType
)
729 sRet
+= String::CreateFromInt32( nChapterFormat
);
730 //add maximum permitted level
732 sRet
+= String::CreateFromInt32( nOutlineLevel
);
741 // don't append empty text tokens
749 SwFormTokensHelper::SwFormTokensHelper(const String
& rPattern
)
751 xub_StrLen nCurPatternPos
= 0;
752 xub_StrLen nCurPatternLen
= 0;
754 while (nCurPatternPos
< rPattern
.Len())
756 nCurPatternPos
= nCurPatternPos
+ nCurPatternLen
;
758 SwFormToken aToken
= BuildToken(rPattern
, nCurPatternPos
);
759 aTokens
.push_back(aToken
);
763 SwFormToken
SwFormTokensHelper::BuildToken( const String
& sPattern
,
764 xub_StrLen
& nCurPatternPos
) const
766 String
sToken( SearchNextToken(sPattern
, nCurPatternPos
) );
767 nCurPatternPos
= nCurPatternPos
+ sToken
.Len();
768 xub_StrLen nTokenLen
;
769 FormTokenType eTokenType
= GetTokenType(sToken
, &nTokenLen
);
771 // at this point sPattern contains the
772 // character style name, the PoolId, tab stop position, tab stop alignment, chapter info format
773 // the form is: CharStyleName, PoolId[, TabStopPosition|ChapterInfoFormat[, TabStopAlignment[, TabFillChar]]]
774 // in text tokens the form differs from the others: CharStyleName, PoolId[,\0xffinserted text\0xff]
775 SwFormToken
eRet( eTokenType
);
776 String sAuthFieldEnum
= sToken
.Copy( 2, 2 );
777 sToken
= sToken
.Copy( nTokenLen
, sToken
.Len() - nTokenLen
- 1);
779 eRet
.sCharStyleName
= sToken
.GetToken( 0, ',');
780 String
sTmp( sToken
.GetToken( 1, ',' ));
782 eRet
.nPoolId
= static_cast<USHORT
>(sTmp
.ToInt32());
788 if( (sTmp
= sToken
.GetToken( 2, ',' ) ).Len() )
789 eRet
.nChapterFormat
= static_cast<USHORT
>(sTmp
.ToInt32());
790 if( (sTmp
= sToken
.GetToken( 3, ',' ) ).Len() )
791 eRet
.nOutlineLevel
= static_cast<USHORT
>(sTmp
.ToInt32()); //the maximum outline level to examine
796 xub_StrLen nStartText
= sToken
.Search( TOX_STYLE_DELIMITER
);
797 if( STRING_NOTFOUND
!= nStartText
)
799 xub_StrLen nEndText
= sToken
.Search( TOX_STYLE_DELIMITER
,
801 if( STRING_NOTFOUND
!= nEndText
)
803 eRet
.sText
= sToken
.Copy( nStartText
+ 1,
804 nEndText
- nStartText
- 1);
811 if( (sTmp
= sToken
.GetToken( 2, ',' ) ).Len() )
812 eRet
.nTabStopPosition
= sTmp
.ToInt32();
814 if( (sTmp
= sToken
.GetToken( 3, ',' ) ).Len() )
815 eRet
.eTabAlign
= static_cast<SvxTabAdjust
>(sTmp
.ToInt32());
817 if( (sTmp
= sToken
.GetToken( 4, ',' ) ).Len() )
818 eRet
.cTabFillChar
= sTmp
.GetChar(0);
820 if( (sTmp
= sToken
.GetToken( 5, ',' ) ).Len() )
821 eRet
.bWithTab
= 0 != sTmp
.ToInt32();
824 case TOKEN_CHAPTER_INFO
:
825 if( (sTmp
= sToken
.GetToken( 2, ',' ) ).Len() )
826 eRet
.nChapterFormat
= static_cast<USHORT
>(sTmp
.ToInt32()); //SwChapterFormat;
828 if( (sTmp
= sToken
.GetToken( 3, ',' ) ).Len() )
829 eRet
.nOutlineLevel
= static_cast<USHORT
>(sTmp
.ToInt32()); //the maximum outline level to examine
833 case TOKEN_AUTHORITY
:
834 eRet
.nAuthorityField
= static_cast<USHORT
>(sAuthFieldEnum
.ToInt32());
841 String
SwFormTokensHelper::SearchNextToken( const String
& sPattern
,
842 xub_StrLen nStt
) const
844 //it's not so easy - it doesn't work if the text part contains a '>'
845 //USHORT nTokenEnd = sPattern.Search('>');
849 xub_StrLen nEnd
= sPattern
.Search( '>', nStt
);
850 if( STRING_NOTFOUND
== nEnd
)
852 nEnd
= sPattern
.Len();
856 xub_StrLen nTextSeparatorFirst
= sPattern
.Search( TOX_STYLE_DELIMITER
, nStt
);
857 if( STRING_NOTFOUND
!= nTextSeparatorFirst
)
859 xub_StrLen nTextSeparatorSecond
= sPattern
.Search( TOX_STYLE_DELIMITER
,
860 nTextSeparatorFirst
+ 1 );
861 if( STRING_NOTFOUND
!= nTextSeparatorSecond
&&
862 nEnd
> nTextSeparatorFirst
)
863 nEnd
= sPattern
.Search( '>', nTextSeparatorSecond
);
868 aResult
= sPattern
.Copy( nStt
, nEnd
- nStt
);
874 FormTokenType
SwFormTokensHelper::GetTokenType(const String
& sToken
,
875 xub_StrLen
* pTokenLen
) const
882 FormTokenType eToken
;
883 } __READONLY_DATA aTokenArr
[] = {
884 { SwForm::aFormTab
, SwForm::nFormEntryLen
, 1, TOKEN_TAB_STOP
},
885 { SwForm::aFormPageNums
, SwForm::nFormPageNumsLen
, 1, TOKEN_PAGE_NUMS
},
886 { SwForm::aFormLinkStt
, SwForm::nFormLinkSttLen
, 1, TOKEN_LINK_START
},
887 { SwForm::aFormLinkEnd
, SwForm::nFormLinkEndLen
, 1, TOKEN_LINK_END
},
888 { SwForm::aFormEntryNum
, SwForm::nFormEntryNumLen
, 1, TOKEN_ENTRY_NO
},
889 { SwForm::aFormEntryTxt
, SwForm::nFormEntryTxtLen
, 1, TOKEN_ENTRY_TEXT
},
890 { SwForm::aFormChapterMark
,SwForm::nFormChapterMarkLen
,1,TOKEN_CHAPTER_INFO
},
891 { SwForm::aFormText
, SwForm::nFormTextLen
, 1, TOKEN_TEXT
},
892 { SwForm::aFormEntry
, SwForm::nFormEntryLen
, 1, TOKEN_ENTRY
},
893 { SwForm::aFormAuth
, SwForm::nFormAuthLen
, 3, TOKEN_AUTHORITY
},
894 { 0, 0, 0, TOKEN_END
}
897 FormTokenType eTokenType
= TOKEN_TEXT
;
898 xub_StrLen nTokenLen
= 0;
900 for( int i
= 0; 0 != ( pNm
= aTokenArr
[ i
].pNm
); ++i
)
901 if( COMPARE_EQUAL
== sToken
.CompareToAscii( pNm
,
902 aTokenArr
[ i
].nLen
- aTokenArr
[ i
].nOffset
))
904 eTokenType
= aTokenArr
[ i
].eToken
;
905 nTokenLen
= aTokenArr
[ i
].nLen
;
909 ASSERT( pNm
, "wrong token" );
911 *pTokenLen
= nTokenLen
;
918 void SwForm::SetPattern(USHORT nLevel
, const SwFormTokens
& rTokens
)
920 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
921 aPattern
[nLevel
] = rTokens
;
924 void SwForm::SetPattern(USHORT nLevel
, const String
& rStr
)
926 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
928 SwFormTokensHelper
aHelper(rStr
);
929 aPattern
[nLevel
] = aHelper
.GetTokens();
932 const SwFormTokens
& SwForm::GetPattern(USHORT nLevel
) const
934 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
935 return aPattern
[nLevel
];