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: bundles.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_goodies.hxx"
34 #include "bundles.hxx"
36 #include <vcl/salbtype.hxx>
37 #include <tools/stream.hxx>
38 #include <tools/list.hxx>
40 Bundle
& Bundle::operator=( Bundle
& rSource
)
42 mnColor
= rSource
.mnColor
;
43 mnBundleIndex
= rSource
.mnBundleIndex
;
47 // ---------------------------------------------------------------
49 void Bundle::SetColor( sal_uInt32 nColor
)
54 sal_uInt32
Bundle::GetColor()
59 // ---------------------------------------------------------------
61 LineBundle
& LineBundle::operator=( LineBundle
& rSource
)
63 SetIndex( rSource
.GetIndex() );
64 eLineType
= rSource
.eLineType
;
65 nLineWidth
= rSource
.nLineWidth
;
69 MarkerBundle
& MarkerBundle::operator=( MarkerBundle
& rSource
)
71 SetIndex( rSource
.GetIndex() );
72 eMarkerType
= rSource
.eMarkerType
;
73 nMarkerSize
= rSource
.nMarkerSize
;
77 EdgeBundle
& EdgeBundle::operator=( EdgeBundle
& rSource
)
79 SetIndex( rSource
.GetIndex() );
80 eEdgeType
= rSource
.eEdgeType
;
81 nEdgeWidth
= rSource
.nEdgeWidth
;
85 TextBundle
& TextBundle::operator=( TextBundle
& rSource
)
87 SetIndex( rSource
.GetIndex() );
88 nTextFontIndex
= rSource
.nTextFontIndex
;
89 eTextPrecision
= rSource
.eTextPrecision
;
90 nCharacterExpansion
= rSource
.nCharacterExpansion
;
91 nCharacterSpacing
= rSource
.nCharacterSpacing
;
95 FillBundle
& FillBundle::operator=( FillBundle
& rSource
)
97 SetIndex( rSource
.GetIndex() );
98 eFillInteriorStyle
= rSource
.eFillInteriorStyle
;
99 nFillPatternIndex
= rSource
.nFillPatternIndex
;
100 nFillHatchIndex
= rSource
.nFillHatchIndex
;
104 // ---------------------------------------------------------------
106 FontEntry::FontEntry() :
108 eCharSetType ( CST_CCOMPLETE
),
109 pCharSetValue ( NULL
),
114 FontEntry::~FontEntry()
117 delete pCharSetValue
;
120 // ---------------------------------------------------------------
122 CGMFList::CGMFList() :
123 nFontNameCount ( 0 ),
125 nFontsAvailable ( 0 )
127 aFontEntryList
.Clear();
130 CGMFList::~CGMFList()
135 // ---------------------------------------------------------------
137 CGMFList
& CGMFList::operator=( CGMFList
& rSource
)
140 nFontsAvailable
= rSource
.nFontsAvailable
;
141 nFontNameCount
= rSource
.nFontNameCount
;
142 nCharSetCount
= rSource
.nCharSetCount
;
143 FontEntry
* pPtr
= (FontEntry
*)rSource
.aFontEntryList
.First();
146 FontEntry
* pCFontEntry
= new FontEntry
;
147 if ( pPtr
->pFontName
)
149 sal_uInt32 nSize
= strlen( (const char*)pPtr
->pFontName
) + 1;
150 pCFontEntry
->pFontName
= new sal_Int8
[ nSize
];
151 memcpy( pCFontEntry
->pFontName
, pPtr
->pFontName
, nSize
);
153 if ( pPtr
->pCharSetValue
)
155 sal_uInt32 nSize
= strlen( (const char*)pPtr
->pCharSetValue
) + 1;
156 pCFontEntry
->pCharSetValue
= new sal_Int8
[ nSize
];
157 memcpy( pCFontEntry
->pCharSetValue
, pPtr
->pCharSetValue
, nSize
);
159 pCFontEntry
->eCharSetType
= pPtr
->eCharSetType
;
160 pCFontEntry
->nFontType
= pPtr
->nFontType
;
161 aFontEntryList
.Insert( pCFontEntry
, LIST_APPEND
);
162 pPtr
= (FontEntry
*)rSource
.aFontEntryList
.Next();
167 // ---------------------------------------------------------------
169 FontEntry
* CGMFList::GetFontEntry( sal_uInt32 nIndex
)
171 sal_uInt32 nInd
= nIndex
;
174 return (FontEntry
*)aFontEntryList
.GetObject( nInd
);
177 // ---------------------------------------------------------------
179 static sal_Int8
* ImplSearchEntry( sal_Int8
* pSource
, sal_Int8
* pDest
, sal_uInt32 nComp
, sal_uInt32 nSize
)
181 while ( nComp
-- >= nSize
)
184 for ( i
= 0; i
< nSize
; i
++ )
186 if ( ( pSource
[i
]&~0x20 ) != ( pDest
[i
]&~0x20 ) )
196 void CGMFList::InsertName( sal_uInt8
* pSource
, sal_uInt32 nSize
)
198 FontEntry
* pFontEntry
;
199 if ( nFontsAvailable
== nFontNameCount
)
202 pFontEntry
= new FontEntry
;
203 aFontEntryList
.Insert( pFontEntry
, LIST_APPEND
);
207 pFontEntry
= (FontEntry
*)aFontEntryList
.GetObject( nFontNameCount
);
210 sal_Int8
* pBuf
= new sal_Int8
[ nSize
];
211 memcpy( pBuf
, pSource
, nSize
);
212 sal_Int8
* pFound
= ImplSearchEntry( pBuf
, (sal_Int8
*)"ITALIC", nSize
, 6 );
215 pFontEntry
->nFontType
|= 1;
216 sal_uInt32 nPrev
= ( pFound
- pBuf
);
217 sal_uInt32 nToCopyOfs
= 6;
218 if ( nPrev
&& ( pFound
[ -1 ] == '-' || pFound
[ -1 ] == ' ' ) )
224 sal_uInt32 nToCopy
= nSize
- nToCopyOfs
- nPrev
;
227 memcpy( pFound
, pFound
+ nToCopyOfs
, nToCopy
);
231 pFound
= ImplSearchEntry( pBuf
, (sal_Int8
*)"BOLD", nSize
, 4 );
234 pFontEntry
->nFontType
|= 2;
236 sal_uInt32 nPrev
= ( pFound
- pBuf
);
237 sal_uInt32 nToCopyOfs
= 4;
238 if ( nPrev
&& ( pFound
[ -1 ] == '-' || pFound
[ -1 ] == ' ' ) )
244 sal_uInt32 nToCopy
= nSize
- nToCopyOfs
- nPrev
;
247 memcpy( pFound
, pFound
+ nToCopyOfs
, nToCopy
);
251 pFontEntry
->pFontName
= new sal_Int8
[ nSize
+ 1 ];
252 pFontEntry
->pFontName
[ nSize
] = 0;
253 memcpy( pFontEntry
->pFontName
, pBuf
, nSize
);
257 //--------------------------------------------------------------------------
259 void CGMFList::InsertCharSet( CharSetType eCharSetType
, sal_uInt8
* pSource
, sal_uInt32 nSize
)
261 FontEntry
* pFontEntry
;
262 if ( nFontsAvailable
== nCharSetCount
)
265 pFontEntry
= new FontEntry
;
266 aFontEntryList
.Insert( pFontEntry
, LIST_APPEND
);
270 pFontEntry
= (FontEntry
*)aFontEntryList
.GetObject( nCharSetCount
);
273 pFontEntry
->eCharSetType
= eCharSetType
;
274 pFontEntry
->pCharSetValue
= new sal_Int8
[ nSize
+ 1 ];
275 pFontEntry
->pCharSetValue
[ nSize
] = 0;
276 memcpy( pFontEntry
->pCharSetValue
, pSource
, nSize
);
279 // ---------------------------------------------------------------
281 void CGMFList::ImplDeleteList()
283 FontEntry
* pFontEntry
= (FontEntry
*)aFontEntryList
.First();
287 pFontEntry
= (FontEntry
*)aFontEntryList
.Next();
289 aFontEntryList
.Clear();