Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "bundles.hxx"
22 :
23 : #include <tools/stream.hxx>
24 :
25 0 : Bundle& Bundle::operator=( Bundle& rSource )
26 : {
27 0 : mnColor = rSource.mnColor;
28 0 : mnBundleIndex = rSource.mnBundleIndex;
29 0 : return *this;
30 : };
31 :
32 : // ---------------------------------------------------------------
33 :
34 0 : void Bundle::SetColor( sal_uInt32 nColor )
35 : {
36 0 : mnColor = nColor;
37 0 : }
38 :
39 0 : sal_uInt32 Bundle::GetColor() const
40 : {
41 0 : return mnColor;
42 : }
43 :
44 : // ---------------------------------------------------------------
45 :
46 0 : LineBundle& LineBundle::operator=( LineBundle& rSource )
47 : {
48 0 : SetIndex( rSource.GetIndex() );
49 0 : eLineType = rSource.eLineType;
50 0 : nLineWidth = rSource.nLineWidth;
51 0 : return *this;
52 : };
53 :
54 0 : MarkerBundle& MarkerBundle::operator=( MarkerBundle& rSource )
55 : {
56 0 : SetIndex( rSource.GetIndex() );
57 0 : eMarkerType = rSource.eMarkerType;
58 0 : nMarkerSize = rSource.nMarkerSize;
59 0 : return *this;
60 : };
61 :
62 0 : EdgeBundle& EdgeBundle::operator=( EdgeBundle& rSource )
63 : {
64 0 : SetIndex( rSource.GetIndex() );
65 0 : eEdgeType = rSource.eEdgeType;
66 0 : nEdgeWidth = rSource.nEdgeWidth;
67 0 : return *this;
68 : };
69 :
70 0 : TextBundle& TextBundle::operator=( TextBundle& rSource )
71 : {
72 0 : SetIndex( rSource.GetIndex() );
73 0 : nTextFontIndex = rSource.nTextFontIndex;
74 0 : eTextPrecision = rSource.eTextPrecision;
75 0 : nCharacterExpansion = rSource.nCharacterExpansion;
76 0 : nCharacterSpacing = rSource.nCharacterSpacing;
77 0 : return *this;
78 : };
79 :
80 0 : FillBundle& FillBundle::operator=( FillBundle& rSource )
81 : {
82 0 : SetIndex( rSource.GetIndex() );
83 0 : eFillInteriorStyle = rSource.eFillInteriorStyle;
84 0 : nFillPatternIndex = rSource.nFillPatternIndex;
85 0 : nFillHatchIndex = rSource.nFillHatchIndex;
86 0 : return *this;
87 : };
88 :
89 : // ---------------------------------------------------------------
90 :
91 0 : FontEntry::FontEntry() :
92 : pFontName ( NULL ),
93 : eCharSetType ( CST_CCOMPLETE ),
94 : pCharSetValue ( NULL ),
95 0 : nFontType ( 0 )
96 : {
97 0 : }
98 :
99 0 : FontEntry::~FontEntry()
100 : {
101 0 : delete pFontName;
102 0 : delete pCharSetValue;
103 0 : }
104 :
105 : // ---------------------------------------------------------------
106 :
107 0 : CGMFList::CGMFList() :
108 : nFontNameCount ( 0 ),
109 : nCharSetCount ( 0 ),
110 0 : nFontsAvailable ( 0 )
111 : {
112 0 : aFontEntryList.clear();
113 0 : }
114 :
115 0 : CGMFList::~CGMFList()
116 : {
117 0 : ImplDeleteList();
118 0 : }
119 :
120 : // ---------------------------------------------------------------
121 :
122 0 : CGMFList& CGMFList::operator=( CGMFList& rSource )
123 : {
124 0 : ImplDeleteList();
125 0 : nFontsAvailable = rSource.nFontsAvailable;
126 0 : nFontNameCount = rSource.nFontNameCount;
127 0 : nCharSetCount = rSource.nCharSetCount;
128 0 : for ( size_t i = 0, n = rSource.aFontEntryList.size(); i < n; ++i )
129 : {
130 0 : FontEntry* pPtr = rSource.aFontEntryList[ i ];
131 0 : FontEntry* pCFontEntry = new FontEntry;
132 0 : if ( pPtr->pFontName )
133 : {
134 0 : sal_uInt32 nSize = strlen( (const char*)pPtr->pFontName ) + 1;
135 0 : pCFontEntry->pFontName = new sal_Int8[ nSize ];
136 0 : memcpy( pCFontEntry->pFontName, pPtr->pFontName, nSize );
137 : }
138 0 : if ( pPtr->pCharSetValue )
139 : {
140 0 : sal_uInt32 nSize = strlen( (const char*)pPtr->pCharSetValue ) + 1;
141 0 : pCFontEntry->pCharSetValue = new sal_Int8[ nSize ];
142 0 : memcpy( pCFontEntry->pCharSetValue, pPtr->pCharSetValue, nSize );
143 : }
144 0 : pCFontEntry->eCharSetType = pPtr->eCharSetType;
145 0 : pCFontEntry->nFontType = pPtr->nFontType;
146 0 : aFontEntryList.push_back( pCFontEntry );
147 : }
148 0 : return *this;
149 : }
150 :
151 : // ---------------------------------------------------------------
152 :
153 0 : FontEntry* CGMFList::GetFontEntry( sal_uInt32 nIndex )
154 : {
155 0 : sal_uInt32 nInd = nIndex;
156 0 : if ( nInd )
157 0 : nInd--;
158 0 : return ( nInd < aFontEntryList.size() ) ? aFontEntryList[ nInd ] : NULL;
159 : }
160 :
161 : // ---------------------------------------------------------------
162 :
163 0 : static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8* pDest, sal_uInt32 nComp, sal_uInt32 nSize )
164 : {
165 0 : while ( nComp-- >= nSize )
166 : {
167 : sal_uInt32 i;
168 0 : for ( i = 0; i < nSize; i++ )
169 : {
170 0 : if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
171 0 : break;
172 : }
173 0 : if ( i == nSize )
174 0 : return pSource;
175 0 : pSource++;
176 : }
177 0 : return NULL;
178 : }
179 :
180 0 : void CGMFList::InsertName( sal_uInt8* pSource, sal_uInt32 nSize )
181 : {
182 : FontEntry* pFontEntry;
183 0 : if ( nFontsAvailable == nFontNameCount )
184 : {
185 0 : nFontsAvailable++;
186 0 : pFontEntry = new FontEntry;
187 0 : aFontEntryList.push_back( pFontEntry );
188 : }
189 : else
190 : {
191 0 : pFontEntry = aFontEntryList[ nFontNameCount ];
192 : }
193 0 : nFontNameCount++;
194 0 : sal_Int8* pBuf = new sal_Int8[ nSize ];
195 0 : memcpy( pBuf, pSource, nSize );
196 0 : sal_Int8* pFound = ImplSearchEntry( pBuf, (sal_Int8*)"ITALIC", nSize, 6 );
197 0 : if ( pFound )
198 : {
199 0 : pFontEntry->nFontType |= 1;
200 0 : sal_uInt32 nPrev = ( pFound - pBuf );
201 0 : sal_uInt32 nToCopyOfs = 6;
202 0 : if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
203 : {
204 0 : nPrev--;
205 0 : pFound--;
206 0 : nToCopyOfs++;
207 : }
208 0 : sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
209 0 : if ( nToCopy )
210 : {
211 0 : memcpy( pFound, pFound + nToCopyOfs, nToCopy );
212 : }
213 0 : nSize -= nToCopyOfs;
214 : }
215 0 : pFound = ImplSearchEntry( pBuf, (sal_Int8*)"BOLD", nSize, 4 );
216 0 : if ( pFound )
217 : {
218 0 : pFontEntry->nFontType |= 2;
219 :
220 0 : sal_uInt32 nPrev = ( pFound - pBuf );
221 0 : sal_uInt32 nToCopyOfs = 4;
222 0 : if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
223 : {
224 0 : nPrev--;
225 0 : pFound--;
226 0 : nToCopyOfs++;
227 : }
228 0 : sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
229 0 : if ( nToCopy )
230 : {
231 0 : memcpy( pFound, pFound + nToCopyOfs, nToCopy );
232 : }
233 0 : nSize -= nToCopyOfs;
234 : }
235 0 : pFontEntry->pFontName = new sal_Int8[ nSize + 1 ];
236 0 : pFontEntry->pFontName[ nSize ] = 0;
237 0 : memcpy( pFontEntry->pFontName, pBuf, nSize );
238 0 : delete[] pBuf;
239 0 : }
240 :
241 : //--------------------------------------------------------------------------
242 :
243 0 : void CGMFList::InsertCharSet( CharSetType eCharSetType, sal_uInt8* pSource, sal_uInt32 nSize )
244 : {
245 : FontEntry* pFontEntry;
246 0 : if ( nFontsAvailable == nCharSetCount )
247 : {
248 0 : nFontsAvailable++;
249 0 : pFontEntry = new FontEntry;
250 0 : aFontEntryList.push_back( pFontEntry );
251 : }
252 : else
253 : {
254 0 : pFontEntry = aFontEntryList[ nCharSetCount ];
255 : }
256 0 : nCharSetCount++;
257 0 : pFontEntry->eCharSetType = eCharSetType;
258 0 : pFontEntry->pCharSetValue = new sal_Int8[ nSize + 1 ];
259 0 : pFontEntry->pCharSetValue[ nSize ] = 0;
260 0 : memcpy( pFontEntry->pCharSetValue, pSource , nSize );
261 0 : }
262 :
263 : // ---------------------------------------------------------------
264 :
265 0 : void CGMFList::ImplDeleteList()
266 : {
267 0 : for ( size_t i = 0, n = aFontEntryList.size(); i < n; ++i )
268 0 : delete aFontEntryList[ i ];
269 0 : aFontEntryList.clear();
270 0 : }
271 :
272 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|