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: global.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 ************************************************************************/
31 #ifndef SC_PHONETIC_HXX
32 #define SC_PHONETIC_HXX
35 #include "tools/string.hxx"
40 struct PhoneticPortion
42 sal_uInt16 mncpa
; /// position of the first character in the phonetic text
43 sal_uInt16 mncpm
; /// position of the first character in the base text
44 sal_uInt16 mnccm
; /// length of the characters in the base text
45 explicit inline PhoneticPortion() : mncpa( 0 ), mncpm( 0 ), mnccm( 0 ) {}
46 explicit inline PhoneticPortion( sal_uInt16 ncpa
, sal_uInt16 ncpm
, sal_uInt16 nccm
) :
47 mncpa( ncpa
), mncpm( ncpm
), mnccm ( nccm
) {}
50 inline bool operator==( const PhoneticPortion
& rLeft
, const PhoneticPortion
& rRight
)
53 ( rLeft
.mncpa
== rRight
.mncpa
) &&
54 ( rLeft
.mncpm
== rRight
.mncpm
) &&
55 ( rLeft
.mnccm
== rRight
.mnccm
);
58 typedef ::std::vector
< PhoneticPortion
> PhoneticPortionVec
;
61 * A class for store Asian phonetic guide information.
63 class SC_DLLPUBLIC ScPhonetic
66 ScPhonetic() : mnFontIdx( 0 ), mnAdditionalSettings( 0 ), mnRepeatedTotalLength ( 0 ) {}
67 /** A constructor of ScPhonetic.
68 * @param nFontIdx font index.
69 * @param nAdditionalSettings an additional settings.
70 * @param nRepeatedTotalLength the number of repeated total length.
71 * @param rPhoneticString phonetic text.
72 * @param rPhoneticPortions the portion of phonetic text.
74 ScPhonetic( sal_uInt16 nFontIdx
, sal_uInt16 nAdditionalSettings
,
75 sal_uInt16 nRepeatedTotalLength
, const String
& rPhoneticString
,
76 const PhoneticPortionVec
& rPhoneticPortions
) :
77 mnFontIdx( nFontIdx
), mnAdditionalSettings( nAdditionalSettings
),
78 mnRepeatedTotalLength ( nRepeatedTotalLength
),
79 maPhoneticString ( rPhoneticString
), maPhoneticPortions ( rPhoneticPortions
) {}
80 virtual ~ScPhonetic();
82 virtual int operator==( const ScPhonetic
& ) const;
84 /** Returns True if no phonetic information. */
85 inline BOOL
IsEmpty() const { return maPhoneticString
.Len() == 0; }
86 /** Returns the text for phonetic information. */
87 inline const String
& GetString() const { return maPhoneticString
; }
88 /** Returns the portion for phonetic information. */
89 inline const PhoneticPortionVec
& GetPortions() const { return maPhoneticPortions
; }
90 /** Returns font index of phonetic information. */
91 inline sal_uInt16
GetFontIndex() const { return mnFontIdx
; }
92 /** Returns additional settings of phonetic information. */
93 inline sal_uInt16
GetAdditionalSettings() const { return mnAdditionalSettings
; }
94 /** Returns repeated length of phonetic information. */
95 inline sal_uInt16
GetRepeatedTotalLength() const { return mnRepeatedTotalLength
; }
96 /** Returns the size of phonetic information. */
97 inline sal_uInt32
GetSize() const { return 14 + ( maPhoneticString
.Len() ? maPhoneticString
.Len() * 2 : 2 ) + maPhoneticPortions
.size() * 6; }
100 sal_uInt16 mnFontIdx
; /// Index to FONT record
101 sal_uInt16 mnAdditionalSettings
; /// Additional settings for the Asian phonetic text
102 sal_uInt16 mnRepeatedTotalLength
;
103 String maPhoneticString
;
104 PhoneticPortionVec maPhoneticPortions
;