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.hxx,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 ************************************************************************/
35 #ifndef _SFXPOOLITEM_HXX //autogen
36 #include <bf_svtools/poolitem.hxx>
40 #include <swtypes.hxx>
58 SV_DECL_PTRARR(SwTOXMarks
, SwTOXMark
*, 0, 10)
60 /*--------------------------------------------------------------------
61 Description: Entry of content index, alphabetical index or user defined index
62 --------------------------------------------------------------------*/
64 #define IVER_TOXMARK_STRPOOL ((USHORT)1)
65 #define IVER_TOXMARK_NEWTOX ((USHORT)2)
67 class SwTOXMark
: public SfxPoolItem
, public SwClient
69 friend void _InitCore();
70 friend class SwTxtTOXMark
;
72 String aAltText
; // Der Text des Eintrages ist unterschiedlich
73 String aPrimaryKey
, aSecondaryKey
;
75 // three more strings for phonetic sorting
77 String aPrimaryKeyReading
;
78 String aSecondaryKeyReading
;
80 SwTxtTOXMark
* pTxtAttr
;
83 BOOL bAutoGenerated
: 1; // generated using a concordance file
84 BOOL bMainEntry
: 1; // main entry emphasized by character style
87 SwTOXMark(); // to create the dflt. atr. in _InitCore
92 SwTOXMark( const SwTOXType
* pTyp
);
93 SwTOXMark( const SwTOXMark
& rCopy
);
96 // "pure virtual methods" of SfxPoolItem
97 virtual int operator==( const SfxPoolItem
& ) const;
98 virtual SfxPoolItem
* Clone( SfxItemPool
* pPool
= 0 ) const;
99 virtual SfxPoolItem
* Create(SvStream
&, USHORT nVer
) const;
100 virtual SvStream
& Store(SvStream
&, USHORT nIVer
) const;
101 virtual USHORT
GetVersion( USHORT nFFVer
) const;
103 SwTOXMark
& operator=( const SwTOXMark
& rCopy
);
105 inline BOOL
IsAlternativeText() const;
106 inline const String
& GetAlternativeText() const;
108 inline void SetAlternativeText( const String
& rAlt
);
110 // content or user defined index
111 inline void SetLevel(USHORT nLevel
);
112 inline USHORT
GetLevel() const;
114 // for alphabetical index only
115 inline void SetPrimaryKey(const String
& rStr
);
116 inline void SetSecondaryKey(const String
& rStr
);
117 inline void SetTextReading(const String
& rStr
);
118 inline void SetPrimaryKeyReading(const String
& rStr
);
119 inline void SetSecondaryKeyReading(const String
& rStr
);
121 inline const String
& GetPrimaryKey() const;
122 inline const String
& GetSecondaryKey() const;
123 inline const String
& GetTextReading() const;
124 inline const String
& GetPrimaryKeyReading() const;
125 inline const String
& GetSecondaryKeyReading() const;
127 BOOL
IsAutoGenerated() const {return bAutoGenerated
;}
128 void SetAutoGenerated(BOOL bSet
) {bAutoGenerated
= bSet
;}
130 BOOL
IsMainEntry() const {return bMainEntry
;}
131 void SetMainEntry(BOOL bSet
) { bMainEntry
= bSet
;}
133 inline const SwTOXType
* GetTOXType() const;
135 const SwTxtTOXMark
* GetTxtTOXMark() const { return pTxtAttr
; }
136 SwTxtTOXMark
* GetTxtTOXMark() { return pTxtAttr
; }
139 /*--------------------------------------------------------------------
140 Description: index types
141 --------------------------------------------------------------------*/
143 class SwTOXType
: public SwModify
146 SwTOXType(TOXTypes eTyp
, const String
& aName
);
147 SwTOXType(const SwTOXType
& rCopy
);
149 inline const String
& GetTypeName() const;
150 void SetTypeName(const String
& rName
);
151 inline TOXTypes
GetType() const;
158 /*--------------------------------------------------------------------
159 Description: Structure of the index lines
160 --------------------------------------------------------------------*/
163 #define FORM_ALPHA_DELIMITTER 1
164 #define FORM_PRIMARY_KEY 2
165 #define FORM_SECONDARY_KEY 3
171 <E#> - entry number <E# CharStyleName,PoolId>
172 <ET> - entry text <ET CharStyleName,PoolId>
173 <E> - entry text and number <E CharStyleName,PoolId>
174 <T> - tab stop <T,,Position,Adjust>
175 <C> - chapter info n = {0, 1, 2, 3, 4 } values of SwChapterFormat <C CharStyleName,PoolId>
176 <TX> - text token <X CharStyleName,PoolId, TOX_STYLE_DELIMITERTextContentTOX_STYLE_DELIMITER>
177 <#> - Page number <# CharStyleName,PoolId>
178 <LS> - Link start <LS>
180 <A00> - Authority entry field <A02 CharStyleName, PoolId>
183 // These enum values are stored and must not be changed!
202 String sCharStyleName
;
203 SwTwips nTabStopPosition
;
204 FormTokenType eTokenType
;
207 USHORT nChapterFormat
; //SwChapterFormat;
208 USHORT nAuthorityField
; //enum ToxAuthorityField
209 sal_Unicode cTabFillChar
;
211 SwFormToken(FormTokenType eType
) :
215 eTabAlign(0 /*SVX_TAB_ADJUST_LEFT*/),
216 nChapterFormat(0 /*CF_NUMBER*/),
217 nAuthorityField(0 /*AUTH_FIELD_IDENTIFIER*/),
220 String
GetString() const;
223 class SwFormTokenEnumerator
226 xub_StrLen nCurPatternPos
;
227 xub_StrLen nCurPatternLen
;
229 FormTokenType
_SearchNextToken( xub_StrLen nStt
, xub_StrLen
& rEnd
,
230 xub_StrLen
* pTokenLen
= 0 ) const;
231 SwFormToken
BuildToken( FormTokenType
, xub_StrLen
) const;
234 SwFormTokenEnumerator( const String
& rPattern
);
235 BOOL
HasNextToken() const
236 { return nCurPatternPos
+ nCurPatternLen
< sPattern
.Len(); }
238 SwFormToken
GetNextToken();
240 const String
& GetPattern() const { return sPattern
; }
245 String aPattern
[ AUTH_TYPE_END
+ 1 ];
246 String aTemplate
[ AUTH_TYPE_END
+ 1 ];
247 USHORT nType
, nFormMaxLevel
;
248 //USHORT nFirstTabPos; -> Value in tab token
249 // BOOL bHasFirstTabPos : 1;
250 BOOL bGenerateTabPos
: 1;
251 BOOL bIsRelTabPos
: 1;
252 BOOL bCommaSeparated
: 1;
255 SwForm( USHORT nType
= TOX_CONTENT
);
256 SwForm( const SwForm
& rForm
);
258 SwForm
& operator=( const SwForm
& rForm
);
260 inline void SetTemplate(USHORT nLevel
, const String
& rName
);
261 inline const String
& GetTemplate(USHORT nLevel
) const;
263 inline void SetPattern(USHORT nLevel
, const String
& rName
);
264 inline const String
& GetPattern(USHORT nLevel
) const;
266 //convert pattern string from old to new format or vice versa
267 static String
ConvertPatternTo51(const String
& rSource
);
268 static String
ConvertPatternFrom51(const String
& rSource
, TOXTypes eType
);
270 // fill tab stop positions from template to pattern
271 void AdjustTabStops(SwDoc
& rDoc
);
273 SwFormTokenEnumerator
CreateTokenEnumerator(USHORT nLevel
) const
274 {return SwFormTokenEnumerator(GetPattern(nLevel
));}
276 inline USHORT
GetTOXType() const;
277 inline USHORT
GetFormMax() const;
279 USHORT
GetFirstTabPos() const ; //{ return nFirstTabPos; }
280 void SetFirstTabPos( USHORT n
); //{ nFirstTabPos = n; }
282 BOOL
IsFirstTabPosFlag() const ; //{ return bHasFirstTabPos; }
284 BOOL
IsGenerateTabPos() const { return bGenerateTabPos
; }
285 void SetGenerateTabPos( BOOL b
) { bGenerateTabPos
= b
; }
287 BOOL
IsRelTabPos() const { return bIsRelTabPos
; }
288 void SetRelTabPos( BOOL b
) { bIsRelTabPos
= b
; }
290 BOOL
IsCommaSeparated() const { return bCommaSeparated
;}
291 void SetCommaSeparated( BOOL b
) { bCommaSeparated
= b
;}
293 static USHORT
GetFormMaxLevel( USHORT nType
);
295 static const sal_Char
* aFormEntry
; // <E>
296 static BYTE nFormEntryLen
; // 3 characters
297 static const sal_Char
* aFormTab
; // <T>
298 static BYTE nFormTabLen
; // 3 characters
299 static const sal_Char
* aFormPageNums
; // <P>
300 static BYTE nFormPageNumsLen
; // 3 characters
301 static const sal_Char
* aFormLinkStt
; // <LS>
302 static BYTE nFormLinkSttLen
; // 4 characters
303 static const sal_Char
* aFormLinkEnd
; // <LE>
304 static BYTE nFormLinkEndLen
; // 4 characters
305 static const sal_Char
* aFormEntryNum
; // <E#>
306 static BYTE nFormEntryNumLen
; // 4 characters
307 static const sal_Char
* aFormEntryTxt
; // <ET>
308 static BYTE nFormEntryTxtLen
; // 4 characters
309 static const sal_Char
* aFormChapterMark
; // <C>
310 static BYTE nFormChapterMarkLen
; // 3 characters
311 static const sal_Char
* aFormText
; // <TX>
312 static BYTE nFormTextLen
; // 4 characters
313 static const sal_Char
* aFormAuth
; // <Axx> xx - decimal enum value
314 static BYTE nFormAuthLen
; // 3 characters
317 /*--------------------------------------------------------------------
318 Description: Content to create indexes of
319 --------------------------------------------------------------------*/
324 TOX_OUTLINELEVEL
= 2,
337 TOI_CASE_SENSITIVE
= 4,
338 TOI_KEY_AS_ENTRY
= 8,
339 TOI_ALPHA_DELIMITTER
= 16,
341 TOI_INITIAL_CAPS
= 64
344 //which part of the caption is to be displayed
345 enum SwCaptionDisplay
357 TOO_DRAW_IMPRESS
= 0x10,
358 // TOO_IMPRESS = 0x20,
363 #define TOX_STYLE_DELIMITER ((sal_Unicode)0x01) //JP 19.07.00: use a control char
365 /*--------------------------------------------------------------------
366 Description: Class for all indexes
367 --------------------------------------------------------------------*/
369 class SwTOXBase
: public SwClient
372 SwTOXBase
& operator=(const SwTOXBase
& rSource
);
374 SwForm aForm
; // description of the lines
375 String aName
; // unique name
376 String aTitle
; // title
378 String sMainEntryCharStyle
; // name of the character style applied to main index entries
380 String aStyleNames
[MAXLEVEL
]; // (additional) style names TOX_CONTENT, TOX_USER
381 String sSequenceName
; // FieldTypeName of a caption sequence
383 LanguageType eLanguage
;
384 String sSortAlgorithm
;
387 USHORT nLevel
; // consider outline levels
388 USHORT nOptions
; // options of alphabetical index
391 USHORT nCreateType
; // sources to create the index from
392 USHORT nOLEOptions
; // OLE sources
393 SwCaptionDisplay eCaptionDisplay
; //
394 BOOL bProtected
: 1; // index protected ?
395 BOOL bFromChapter
: 1; // create from chapter or document
396 BOOL bFromObjectNames
: 1; // create a table or object index
397 // from the names rather than the caption
398 BOOL bLevelFromChapter
: 1; // User index: get the level from the source chapter
400 SwTOXBase( const SwTOXType
* pTyp
, const SwForm
& rForm
,
401 USHORT nCreaType
, const String
& rTitle
);
402 SwTOXBase( const SwTOXBase
& rCopy
, SwDoc
* pDoc
= 0 );
403 virtual ~SwTOXBase();
406 // a kind of CopyCtor - check if the TOXBase is at TOXType of the doc.
407 // If not, so create it an copy all other used things. The return is this
408 SwTOXBase
& CopyTOXBase( SwDoc
*, const SwTOXBase
& );
410 const SwTOXType
* GetTOXType() const; //
412 USHORT
GetCreateType() const; // creation types
414 const String
& GetTOXName() const {return aName
;}
415 void SetTOXName(const String
& rSet
) {aName
= rSet
;}
417 const String
& GetTitle() const; // Title
418 const String
& GetTypeName() const; // Name
419 const SwForm
& GetTOXForm() const; // description of the lines
421 void SetCreate(USHORT
);
422 void SetTitle(const String
& rTitle
);
423 void SetTOXForm(const SwForm
& rForm
);
425 TOXTypes
GetType() const;
427 const String
& GetMainEntryCharStyle() const {return sMainEntryCharStyle
;}
428 void SetMainEntryCharStyle(const String
& rSet
) {sMainEntryCharStyle
= rSet
;}
430 // content index only
431 inline void SetLevel(USHORT
); // consider outline level
432 inline USHORT
GetLevel() const;
434 // alphabetical index only
435 inline USHORT
GetOptions() const; // alphabetical index options
436 inline void SetOptions(USHORT nOpt
);
439 USHORT
GetOLEOptions() const {return nOLEOptions
;}
440 void SetOLEOptions(USHORT nOpt
) {nOLEOptions
= nOpt
;}
444 // user defined index only
445 inline void SetTemplateName(const String
& rName
); // Absatzlayout beachten
446 inline String
GetTemplateName() const;
448 const String
& GetStyleNames(USHORT nLevel
) const
450 DBG_ASSERT( nLevel
< MAXLEVEL
, "Which level?");
451 return aStyleNames
[nLevel
];
453 void SetStyleNames(const String
& rSet
, USHORT nLevel
)
455 DBG_ASSERT( nLevel
< MAXLEVEL
, "Which level?");
456 aStyleNames
[nLevel
] = rSet
;
459 BOOL
IsFromChapter() const { return bFromChapter
;}
460 void SetFromChapter(BOOL bSet
) { bFromChapter
= bSet
;}
462 BOOL
IsFromObjectNames() const {return bFromObjectNames
;}
463 void SetFromObjectNames(BOOL bSet
) {bFromObjectNames
= bSet
;}
465 BOOL
IsLevelFromChapter() const {return bLevelFromChapter
;}
466 void SetLevelFromChapter(BOOL bSet
) {bLevelFromChapter
= bSet
;}
468 BOOL
IsProtected() const { return bProtected
; }
469 void SetProtected(BOOL bSet
) { bProtected
= bSet
; }
471 const String
& GetSequenceName() const {return sSequenceName
;}
472 void SetSequenceName(const String
& rSet
) {sSequenceName
= rSet
;}
474 SwCaptionDisplay
GetCaptionDisplay() const { return eCaptionDisplay
;}
475 void SetCaptionDisplay(SwCaptionDisplay eSet
) {eCaptionDisplay
= eSet
;}
477 static const String
& GetTOXName(TOXTypes eType
); // toxmgr.cxx
479 LanguageType
GetLanguage() const {return eLanguage
;}
480 void SetLanguage(LanguageType nLang
) {eLanguage
= nLang
;}
482 const String
& GetSortAlgorithm()const {return sSortAlgorithm
;}
483 void SetSortAlgorithm(const String
& rSet
) {sSortAlgorithm
= rSet
;}
488 /*--------------------------------------------------------------------
490 --------------------------------------------------------------------*/
495 inline const String
& SwTOXMark::GetAlternativeText() const
498 inline const SwTOXType
* SwTOXMark::GetTOXType() const
499 { return (SwTOXType
*)GetRegisteredIn(); }
501 inline BOOL
SwTOXMark::IsAlternativeText() const
502 { return aAltText
.Len() > 0; }
504 inline void SwTOXMark::SetAlternativeText(const String
& rAlt
)
509 inline void SwTOXMark::SetLevel( USHORT nLvl
)
511 ASSERT( !GetTOXType() || GetTOXType()->GetType() != TOX_INDEX
, "Falscher Feldtyp");
515 inline void SwTOXMark::SetPrimaryKey( const String
& rKey
)
517 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
521 inline void SwTOXMark::SetSecondaryKey( const String
& rKey
)
523 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
524 aSecondaryKey
= rKey
;
527 inline void SwTOXMark::SetTextReading( const String
& rTxt
)
529 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
533 inline void SwTOXMark::SetPrimaryKeyReading( const String
& rKey
)
535 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
536 aPrimaryKeyReading
= rKey
;
539 inline void SwTOXMark::SetSecondaryKeyReading( const String
& rKey
)
541 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
542 aSecondaryKeyReading
= rKey
;
545 inline USHORT
SwTOXMark::GetLevel() const
547 ASSERT( !GetTOXType() || GetTOXType()->GetType() != TOX_INDEX
, "Falscher Feldtyp");
551 inline const String
& SwTOXMark::GetPrimaryKey() const
553 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
557 inline const String
& SwTOXMark::GetSecondaryKey() const
559 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
560 return aSecondaryKey
;
563 inline const String
& SwTOXMark::GetTextReading() const
565 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
569 inline const String
& SwTOXMark::GetPrimaryKeyReading() const
571 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
572 return aPrimaryKeyReading
;
575 inline const String
& SwTOXMark::GetSecondaryKeyReading() const
577 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
578 return aSecondaryKeyReading
;
584 inline void SwForm::SetTemplate(USHORT nLevel
, const String
& rName
)
586 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
587 aTemplate
[nLevel
] = rName
;
590 inline void SwForm::SetPattern(USHORT nLevel
, const String
& rName
)
592 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
593 aPattern
[nLevel
] = rName
;
596 inline const String
& SwForm::GetPattern(USHORT nLevel
) const
598 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
599 return aPattern
[nLevel
];
602 inline const String
& SwForm::GetTemplate(USHORT nLevel
) const
604 ASSERT(nLevel
< GetFormMax(), "Index >= FORM_MAX");
605 return aTemplate
[nLevel
];
608 inline USHORT
SwForm::GetTOXType() const
613 inline USHORT
SwForm::GetFormMax() const
615 return nFormMaxLevel
;
622 inline const String
& SwTOXType::GetTypeName() const
625 inline void SwTOXType::SetTypeName(const String
& rName
)
628 inline TOXTypes
SwTOXType::GetType() const
634 inline const SwTOXType
* SwTOXBase::GetTOXType() const
635 { return (SwTOXType
*)GetRegisteredIn(); }
637 inline USHORT
SwTOXBase::GetCreateType() const
638 { return nCreateType
; }
640 inline const String
& SwTOXBase::GetTitle() const
643 inline const String
& SwTOXBase::GetTypeName() const
644 { return GetTOXType()->GetTypeName(); }
646 inline const SwForm
& SwTOXBase::GetTOXForm() const
649 inline void SwTOXBase::SetCreate(USHORT nCreate
)
650 { nCreateType
= nCreate
; }
652 inline void SwTOXBase::SetTitle(const String
& rTitle
)
655 inline void SwTOXBase::SetTOXForm(const SwForm
& rForm
)
658 inline TOXTypes
SwTOXBase::GetType() const
659 { return GetTOXType()->GetType(); }
661 inline void SwTOXBase::SetLevel(USHORT nLev
)
663 ASSERT(GetTOXType()->GetType() != TOX_INDEX
, "Falscher Feldtyp");
667 inline USHORT
SwTOXBase::GetLevel() const
669 ASSERT(GetTOXType()->GetType() != TOX_INDEX
, "Falscher Feldtyp");
673 inline void SwTOXBase::SetTemplateName(const String
& rName
)
675 // ASSERT(GetTOXType()->GetType() == TOX_USER, "Falscher Feldtyp");
676 // ASSERT(aData.pTemplateName, "pTemplateName == 0");
677 // (*aData.pTemplateName) = rName;
678 DBG_WARNING("SwTOXBase::SetTemplateName obsolete");
679 aStyleNames
[0] = rName
;
683 inline String
SwTOXBase::GetTemplateName() const
685 // ASSERT(GetTOXType()->GetType() == TOX_USER, "Falscher Feldtyp");
686 // return *aData.pTemplateName;
687 DBG_WARNING("SwTOXBase::GetTemplateName obsolete");
688 return aStyleNames
[0].GetToken(0, TOX_STYLE_DELIMITER
);
691 inline USHORT
SwTOXBase::GetOptions() const
693 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
694 return aData
.nOptions
;
697 inline void SwTOXBase::SetOptions(USHORT nOpt
)
699 ASSERT(GetTOXType()->GetType() == TOX_INDEX
, "Falscher Feldtyp");
700 aData
.nOptions
= nOpt
;
704 } //namespace binfilter