Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "bundles.hxx"
31 : :
32 : : #include <tools/stream.hxx>
33 : :
34 : 0 : Bundle& Bundle::operator=( Bundle& rSource )
35 : : {
36 : 0 : mnColor = rSource.mnColor;
37 : 0 : mnBundleIndex = rSource.mnBundleIndex;
38 : 0 : return *this;
39 : : };
40 : :
41 : : // ---------------------------------------------------------------
42 : :
43 : 0 : void Bundle::SetColor( sal_uInt32 nColor )
44 : : {
45 : 0 : mnColor = nColor;
46 : 0 : }
47 : :
48 : 0 : sal_uInt32 Bundle::GetColor() const
49 : : {
50 : 0 : return mnColor;
51 : : }
52 : :
53 : : // ---------------------------------------------------------------
54 : :
55 : 0 : LineBundle& LineBundle::operator=( LineBundle& rSource )
56 : : {
57 : 0 : SetIndex( rSource.GetIndex() );
58 : 0 : eLineType = rSource.eLineType;
59 : 0 : nLineWidth = rSource.nLineWidth;
60 : 0 : return *this;
61 : : };
62 : :
63 : 0 : MarkerBundle& MarkerBundle::operator=( MarkerBundle& rSource )
64 : : {
65 : 0 : SetIndex( rSource.GetIndex() );
66 : 0 : eMarkerType = rSource.eMarkerType;
67 : 0 : nMarkerSize = rSource.nMarkerSize;
68 : 0 : return *this;
69 : : };
70 : :
71 : 0 : EdgeBundle& EdgeBundle::operator=( EdgeBundle& rSource )
72 : : {
73 : 0 : SetIndex( rSource.GetIndex() );
74 : 0 : eEdgeType = rSource.eEdgeType;
75 : 0 : nEdgeWidth = rSource.nEdgeWidth;
76 : 0 : return *this;
77 : : };
78 : :
79 : 0 : TextBundle& TextBundle::operator=( TextBundle& rSource )
80 : : {
81 : 0 : SetIndex( rSource.GetIndex() );
82 : 0 : nTextFontIndex = rSource.nTextFontIndex;
83 : 0 : eTextPrecision = rSource.eTextPrecision;
84 : 0 : nCharacterExpansion = rSource.nCharacterExpansion;
85 : 0 : nCharacterSpacing = rSource.nCharacterSpacing;
86 : 0 : return *this;
87 : : };
88 : :
89 : 0 : FillBundle& FillBundle::operator=( FillBundle& rSource )
90 : : {
91 : 0 : SetIndex( rSource.GetIndex() );
92 : 0 : eFillInteriorStyle = rSource.eFillInteriorStyle;
93 : 0 : nFillPatternIndex = rSource.nFillPatternIndex;
94 : 0 : nFillHatchIndex = rSource.nFillHatchIndex;
95 : 0 : return *this;
96 : : };
97 : :
98 : : // ---------------------------------------------------------------
99 : :
100 : 0 : FontEntry::FontEntry() :
101 : : pFontName ( NULL ),
102 : : eCharSetType ( CST_CCOMPLETE ),
103 : : pCharSetValue ( NULL ),
104 : 0 : nFontType ( 0 )
105 : : {
106 : 0 : }
107 : :
108 : 0 : FontEntry::~FontEntry()
109 : : {
110 : 0 : delete pFontName;
111 : 0 : delete pCharSetValue;
112 : 0 : }
113 : :
114 : : // ---------------------------------------------------------------
115 : :
116 : 0 : CGMFList::CGMFList() :
117 : : nFontNameCount ( 0 ),
118 : : nCharSetCount ( 0 ),
119 : 0 : nFontsAvailable ( 0 )
120 : : {
121 : 0 : aFontEntryList.clear();
122 : 0 : }
123 : :
124 : 0 : CGMFList::~CGMFList()
125 : : {
126 : 0 : ImplDeleteList();
127 : 0 : }
128 : :
129 : : // ---------------------------------------------------------------
130 : :
131 : 0 : CGMFList& CGMFList::operator=( CGMFList& rSource )
132 : : {
133 : 0 : ImplDeleteList();
134 : 0 : nFontsAvailable = rSource.nFontsAvailable;
135 : 0 : nFontNameCount = rSource.nFontNameCount;
136 : 0 : nCharSetCount = rSource.nCharSetCount;
137 : 0 : for ( size_t i = 0, n = rSource.aFontEntryList.size(); i < n; ++i )
138 : : {
139 : 0 : FontEntry* pPtr = rSource.aFontEntryList[ i ];
140 : 0 : FontEntry* pCFontEntry = new FontEntry;
141 : 0 : if ( pPtr->pFontName )
142 : : {
143 : 0 : sal_uInt32 nSize = strlen( (const char*)pPtr->pFontName ) + 1;
144 : 0 : pCFontEntry->pFontName = new sal_Int8[ nSize ];
145 : 0 : memcpy( pCFontEntry->pFontName, pPtr->pFontName, nSize );
146 : : }
147 : 0 : if ( pPtr->pCharSetValue )
148 : : {
149 : 0 : sal_uInt32 nSize = strlen( (const char*)pPtr->pCharSetValue ) + 1;
150 : 0 : pCFontEntry->pCharSetValue = new sal_Int8[ nSize ];
151 : 0 : memcpy( pCFontEntry->pCharSetValue, pPtr->pCharSetValue, nSize );
152 : : }
153 : 0 : pCFontEntry->eCharSetType = pPtr->eCharSetType;
154 : 0 : pCFontEntry->nFontType = pPtr->nFontType;
155 : 0 : aFontEntryList.push_back( pCFontEntry );
156 : : }
157 : 0 : return *this;
158 : : }
159 : :
160 : : // ---------------------------------------------------------------
161 : :
162 : 0 : FontEntry* CGMFList::GetFontEntry( sal_uInt32 nIndex )
163 : : {
164 : 0 : sal_uInt32 nInd = nIndex;
165 : 0 : if ( nInd )
166 : 0 : nInd--;
167 : 0 : return ( nInd < aFontEntryList.size() ) ? aFontEntryList[ nInd ] : NULL;
168 : : }
169 : :
170 : : // ---------------------------------------------------------------
171 : :
172 : 0 : static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8* pDest, sal_uInt32 nComp, sal_uInt32 nSize )
173 : : {
174 : 0 : while ( nComp-- >= nSize )
175 : : {
176 : : sal_uInt32 i;
177 : 0 : for ( i = 0; i < nSize; i++ )
178 : : {
179 : 0 : if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
180 : 0 : break;
181 : : }
182 : 0 : if ( i == nSize )
183 : 0 : return pSource;
184 : 0 : pSource++;
185 : : }
186 : 0 : return NULL;
187 : : }
188 : :
189 : 0 : void CGMFList::InsertName( sal_uInt8* pSource, sal_uInt32 nSize )
190 : : {
191 : : FontEntry* pFontEntry;
192 : 0 : if ( nFontsAvailable == nFontNameCount )
193 : : {
194 : 0 : nFontsAvailable++;
195 : 0 : pFontEntry = new FontEntry;
196 : 0 : aFontEntryList.push_back( pFontEntry );
197 : : }
198 : : else
199 : : {
200 : 0 : pFontEntry = aFontEntryList[ nFontNameCount ];
201 : : }
202 : 0 : nFontNameCount++;
203 : 0 : sal_Int8* pBuf = new sal_Int8[ nSize ];
204 : 0 : memcpy( pBuf, pSource, nSize );
205 : 0 : sal_Int8* pFound = ImplSearchEntry( pBuf, (sal_Int8*)"ITALIC", nSize, 6 );
206 : 0 : if ( pFound )
207 : : {
208 : 0 : pFontEntry->nFontType |= 1;
209 : 0 : sal_uInt32 nPrev = ( pFound - pBuf );
210 : 0 : sal_uInt32 nToCopyOfs = 6;
211 : 0 : if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
212 : : {
213 : 0 : nPrev--;
214 : 0 : pFound--;
215 : 0 : nToCopyOfs++;
216 : : }
217 : 0 : sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
218 : 0 : if ( nToCopy )
219 : : {
220 : 0 : memcpy( pFound, pFound + nToCopyOfs, nToCopy );
221 : : }
222 : 0 : nSize -= nToCopyOfs;
223 : : }
224 : 0 : pFound = ImplSearchEntry( pBuf, (sal_Int8*)"BOLD", nSize, 4 );
225 : 0 : if ( pFound )
226 : : {
227 : 0 : pFontEntry->nFontType |= 2;
228 : :
229 : 0 : sal_uInt32 nPrev = ( pFound - pBuf );
230 : 0 : sal_uInt32 nToCopyOfs = 4;
231 : 0 : if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
232 : : {
233 : 0 : nPrev--;
234 : 0 : pFound--;
235 : 0 : nToCopyOfs++;
236 : : }
237 : 0 : sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
238 : 0 : if ( nToCopy )
239 : : {
240 : 0 : memcpy( pFound, pFound + nToCopyOfs, nToCopy );
241 : : }
242 : 0 : nSize -= nToCopyOfs;
243 : : }
244 : 0 : pFontEntry->pFontName = new sal_Int8[ nSize + 1 ];
245 : 0 : pFontEntry->pFontName[ nSize ] = 0;
246 : 0 : memcpy( pFontEntry->pFontName, pBuf, nSize );
247 : 0 : delete[] pBuf;
248 : 0 : }
249 : :
250 : : //--------------------------------------------------------------------------
251 : :
252 : 0 : void CGMFList::InsertCharSet( CharSetType eCharSetType, sal_uInt8* pSource, sal_uInt32 nSize )
253 : : {
254 : : FontEntry* pFontEntry;
255 : 0 : if ( nFontsAvailable == nCharSetCount )
256 : : {
257 : 0 : nFontsAvailable++;
258 : 0 : pFontEntry = new FontEntry;
259 : 0 : aFontEntryList.push_back( pFontEntry );
260 : : }
261 : : else
262 : : {
263 : 0 : pFontEntry = aFontEntryList[ nCharSetCount ];
264 : : }
265 : 0 : nCharSetCount++;
266 : 0 : pFontEntry->eCharSetType = eCharSetType;
267 : 0 : pFontEntry->pCharSetValue = new sal_Int8[ nSize + 1 ];
268 : 0 : pFontEntry->pCharSetValue[ nSize ] = 0;
269 : 0 : memcpy( pFontEntry->pCharSetValue, pSource , nSize );
270 : 0 : }
271 : :
272 : : // ---------------------------------------------------------------
273 : :
274 : 0 : void CGMFList::ImplDeleteList()
275 : : {
276 : 0 : for ( size_t i = 0, n = aFontEntryList.size(); i < n; ++i )
277 : 0 : delete aFontEntryList[ i ];
278 : 0 : aFontEntryList.clear();
279 : 0 : }
280 : :
281 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|