|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Header PDRRECRD.CPP |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "PDRRECRD.H" |
|
21 |
|
22 EXPORT_C PdrResource* PdrResource::New() |
|
23 /** Creates a new instance of this class. |
|
24 |
|
25 @return Reference to a new object. */ |
|
26 { |
|
27 return new PdrResource(); |
|
28 } |
|
29 |
|
30 EXPORT_C void PdrResource::Delete() |
|
31 /** Deletes the current object. */ |
|
32 { |
|
33 delete this; |
|
34 } |
|
35 |
|
36 void PdrResource::Externalize(ostream& out) |
|
37 { |
|
38 uint8 id = (uint8) iId; |
|
39 out.write((char*) &id, sizeof(id)); |
|
40 iString.Externalize(out); |
|
41 } |
|
42 |
|
43 EXPORT_C PdrResources* PdrResources::New() |
|
44 /** Creates a new instance of this class. |
|
45 |
|
46 @return Reference to a new object. */ |
|
47 { |
|
48 return new PdrResources(); |
|
49 } |
|
50 |
|
51 EXPORT_C void PdrResources::Delete() |
|
52 /** Deletes the current object. */ |
|
53 { |
|
54 delete this; |
|
55 } |
|
56 |
|
57 void PdrResources::Externalize(ostream& out) |
|
58 { |
|
59 iStreamId = out.tellp(); |
|
60 iPdrResourceList.Externalize(out); |
|
61 } |
|
62 |
|
63 EXPORT_C void PdrResources::AddResource(PdrResource* aResource) |
|
64 /** Adds a printer resource to the object. |
|
65 |
|
66 @param aResource Printer resource. */ |
|
67 { |
|
68 iPdrResourceList.Add(aResource); |
|
69 } |
|
70 |
|
71 PdrResources::~PdrResources() |
|
72 /** Default destructor. */ |
|
73 { |
|
74 iPdrResourceList.Destroy(); |
|
75 } |
|
76 |
|
77 EXPORT_C PdrTranslation* PdrTranslation::New() |
|
78 /** Creates a new instance of this class. |
|
79 |
|
80 @return Reference to a new object. */ |
|
81 { |
|
82 return new PdrTranslation(); |
|
83 } |
|
84 |
|
85 EXPORT_C void PdrTranslation::Delete() |
|
86 /** Deletes the current object. */ |
|
87 { |
|
88 delete this; |
|
89 } |
|
90 |
|
91 void PdrTranslation::Externalize(ostream& out) |
|
92 { |
|
93 out.write((char*) &iFrom, sizeof(iFrom)); |
|
94 iTo.Externalize(out); |
|
95 } |
|
96 |
|
97 EXPORT_C PdrTranslates* PdrTranslates::New() |
|
98 /** Creates a new instance of this class. |
|
99 |
|
100 @return Reference to a new object. */ |
|
101 { |
|
102 return new PdrTranslates(); |
|
103 } |
|
104 |
|
105 EXPORT_C void PdrTranslates::Delete() |
|
106 /** Deletes the current object. */ |
|
107 { |
|
108 delete this; |
|
109 } |
|
110 |
|
111 void PdrTranslates::Externalize(ostream& out) |
|
112 { |
|
113 iStreamId = out.tellp(); |
|
114 iPdrTranslationList.Externalize(out); |
|
115 } |
|
116 |
|
117 EXPORT_C void PdrTranslates::AddTranslation(PdrTranslation* aTranslation) |
|
118 /** Adds a printer translation to the list. |
|
119 |
|
120 @param aTranslation Reference to a translation. */ |
|
121 { |
|
122 iPdrTranslationList.Add(aTranslation); |
|
123 } |
|
124 |
|
125 PdrTranslates::~PdrTranslates() |
|
126 /** This function is internal, and is not intended for use. */ |
|
127 { |
|
128 iPdrTranslationList.Destroy(); |
|
129 } |
|
130 |
|
131 EXPORT_C Width* Width::New() |
|
132 /** Creates a new instance of this object. |
|
133 |
|
134 @return Reference to a new object. */ |
|
135 { |
|
136 return new Width(); |
|
137 } |
|
138 |
|
139 EXPORT_C void Width::Delete() |
|
140 /** Deletes the current object. */ |
|
141 { |
|
142 delete this; |
|
143 } |
|
144 |
|
145 void Width::Externalize(ostream& out) |
|
146 { |
|
147 out.write ((char*) &iWidthInPixels, sizeof(iWidthInPixels)); |
|
148 } |
|
149 |
|
150 WidthsCodeSection::WidthsCodeSection() |
|
151 : iWidthList() |
|
152 /** This function is internal only, and is not intended for use. */ |
|
153 { |
|
154 } |
|
155 |
|
156 EXPORT_C WidthsCodeSection* WidthsCodeSection::New() |
|
157 /** Creates a new instance of this class. |
|
158 |
|
159 @return Reference to a new object. */ |
|
160 { |
|
161 return new WidthsCodeSection(); |
|
162 } |
|
163 |
|
164 EXPORT_C void WidthsCodeSection::Delete() |
|
165 /** Deletes the current object. */ |
|
166 { |
|
167 delete this; |
|
168 } |
|
169 |
|
170 void WidthsCodeSection::Externalize(ostream& out) |
|
171 { |
|
172 out.write((char*) &iStart, sizeof(iStart)); |
|
173 out.write((char*) &iEnd, sizeof(iEnd)); |
|
174 iWidthList.Externalize(out); |
|
175 } |
|
176 |
|
177 EXPORT_C void WidthsCodeSection::AddWidth(Width* aWidth) |
|
178 /** Adds a new font width to the list. |
|
179 |
|
180 @param aWidth Font width. */ |
|
181 { |
|
182 iWidthList.Add(aWidth); |
|
183 } |
|
184 |
|
185 EXPORT_C Width* WidthsCodeSection::WidthList(int i) |
|
186 /** Returns a font width from the list at the position specified. |
|
187 |
|
188 @param i Position of font width in list. |
|
189 @return Reference to a font width. */ |
|
190 { |
|
191 return iWidthList[i]; |
|
192 } |
|
193 |
|
194 EXPORT_C int WidthsCodeSection::NumWidths() |
|
195 /** Returns the number of font widths in the list. |
|
196 |
|
197 @return Number of widths. */ |
|
198 { |
|
199 return iWidthList.Size(); |
|
200 } |
|
201 |
|
202 WidthsCodeSection::~WidthsCodeSection() |
|
203 /** Default destructor. */ |
|
204 { |
|
205 iWidthList.Destroy(); |
|
206 } |
|
207 |
|
208 EXPORT_C FontInfo* FontInfo::New() |
|
209 /** Creates a new instance of this class. |
|
210 |
|
211 @return Reference to a new instance of this class. */ |
|
212 { |
|
213 return new FontInfo(); |
|
214 } |
|
215 |
|
216 EXPORT_C void FontInfo::Delete() |
|
217 /** Deletes the current FontInfo object. */ |
|
218 { |
|
219 delete this; |
|
220 } |
|
221 |
|
222 void FontInfo::Externalize(ostream& out) |
|
223 { |
|
224 iStreamId = out.tellp(); |
|
225 out.write((char*) &iAscentInPixels, sizeof(iAscentInPixels)); |
|
226 out.write((char*) &iMaxCharWidthInPixels, sizeof(iMaxCharWidthInPixels)); |
|
227 out.write((char*) &iMaxNormalCharWidthInPixels, sizeof(iMaxNormalCharWidthInPixels)); |
|
228 iCodeSectionList.Externalize(out); |
|
229 } |
|
230 |
|
231 EXPORT_C void FontInfo::AddCodeSection(WidthsCodeSection* aCodeSection) |
|
232 /** Adds a section of information about the font to an internally-stored array. |
|
233 |
|
234 @param aCodeSection Font information. */ |
|
235 { |
|
236 iCodeSectionList.Add(aCodeSection); |
|
237 } |
|
238 |
|
239 EXPORT_C WidthsCodeSection* FontInfo::CodeSectionList(int i) |
|
240 /** Returns a section of font information from a specified position in the internally-stored |
|
241 array. |
|
242 |
|
243 @param i Postion of information in the array. |
|
244 @return Reference to section of font information. */ |
|
245 { |
|
246 return iCodeSectionList[i]; |
|
247 } |
|
248 |
|
249 EXPORT_C int FontInfo::NumCodeSections() |
|
250 /** Returns the number of sections of font information in the internally-stored |
|
251 array. |
|
252 |
|
253 @return Current number of font information sections. */ |
|
254 { |
|
255 return iCodeSectionList.Size(); |
|
256 } |
|
257 |
|
258 FontInfo::~FontInfo() |
|
259 /** This function is internal, and not intended for use. */ |
|
260 { |
|
261 iCodeSectionList.Destroy(); |
|
262 } |
|
263 |
|
264 EXPORT_C PdrStyle* PdrStyle::New() |
|
265 /** Creates a new instance of this class |
|
266 |
|
267 @return Reference to a new object. */ |
|
268 { |
|
269 return new PdrStyle(); |
|
270 } |
|
271 |
|
272 EXPORT_C void PdrStyle::Delete() |
|
273 /** Deletes the current object. */ |
|
274 { |
|
275 delete this; |
|
276 } |
|
277 |
|
278 void PdrStyle::Externalize(ostream& out) |
|
279 { |
|
280 out.write((char*) &iIsAvailable, sizeof(iIsAvailable)); |
|
281 streamoff streamid = 0; |
|
282 if (iIsAvailable) |
|
283 streamid = iFontInfo->iStreamId; |
|
284 ::ExternalizeStreamOff(out, streamid); |
|
285 } |
|
286 |
|
287 PdrStyle::PdrStyle() |
|
288 : iIsAvailable(efalse) |
|
289 /** Default constructor. */ |
|
290 { |
|
291 } |
|
292 |
|
293 EXPORT_C PdrFontHeight* PdrFontHeight::New() |
|
294 /** Returns a new instance of this class. |
|
295 |
|
296 @return Reference to new object. */ |
|
297 { |
|
298 return new PdrFontHeight(); |
|
299 } |
|
300 |
|
301 EXPORT_C void PdrFontHeight::Delete() |
|
302 /** Deletes the current object. */ |
|
303 { |
|
304 delete this; |
|
305 } |
|
306 |
|
307 void PdrFontHeight::Externalize(ostream& out) |
|
308 { |
|
309 iCommandString.Externalize(out); |
|
310 out.write((char*) &iHeightInTwips, sizeof(iHeightInTwips)); |
|
311 out.write((char*) &iWidthScale, sizeof(iWidthScale)); |
|
312 for (int style = Normal;style <= BoldItalic; style++) |
|
313 iStyle[style].Externalize(out); |
|
314 } |
|
315 |
|
316 PdrFontHeight::PdrFontHeight(): |
|
317 iWidthScale(1) |
|
318 /** Default constructor. */ |
|
319 { |
|
320 } |
|
321 |
|
322 PdrScalableFontHeight::PdrScalableFontHeight() |
|
323 /** Default constructor. */ |
|
324 { |
|
325 } |
|
326 |
|
327 void PdrScalableFontHeight::Externalize(ostream& out) |
|
328 { |
|
329 iCommandString.Externalize(out); |
|
330 out.write((char*) &iHeightMinInTwips, sizeof(iHeightMinInTwips)); |
|
331 out.write((char*) &iHeightMaxInTwips, sizeof(iHeightMaxInTwips)); |
|
332 out.write((char*) &iHeightDeltaInTwips, sizeof(iHeightDeltaInTwips)); |
|
333 for (int style = Normal; style <= BoldItalic; style++) |
|
334 iStyle[style].Externalize(out); |
|
335 } |
|
336 |
|
337 EXPORT_C TypefaceFonts* TypefaceFonts::New() |
|
338 /** Creates a new instance of this class. |
|
339 |
|
340 @return Reference to a new object. */ |
|
341 { |
|
342 return new TypefaceFonts(); |
|
343 } |
|
344 |
|
345 EXPORT_C void TypefaceFonts::Delete() |
|
346 /** Deletes the current object. */ |
|
347 { |
|
348 delete this; |
|
349 } |
|
350 |
|
351 void TypefaceFonts::Externalize(ostream& out) |
|
352 { |
|
353 iStreamId = out.tellp(); |
|
354 iTypeface.Externalize(out); |
|
355 out.write((char*) &iIsScalable, sizeof(iIsScalable)); |
|
356 if (iIsScalable) |
|
357 iScalableFontHeight.Externalize(out); |
|
358 else |
|
359 iFontHeightList.Externalize(out); |
|
360 ::ExternalizeStreamOff(out, iTranslates->iStreamId); |
|
361 } |
|
362 |
|
363 EXPORT_C void TypefaceFonts::AddFontHeight(PdrFontHeight* aFontHeight) |
|
364 { |
|
365 iFontHeightList.Add(aFontHeight); |
|
366 } |
|
367 |
|
368 EXPORT_C int TypefaceFonts::NumFontHeights() |
|
369 /** Returns the number of font height descriptions currently held in the list. |
|
370 |
|
371 @return Number of descriptions. */ |
|
372 { |
|
373 return iFontHeightList.Size(); |
|
374 } |
|
375 |
|
376 PdrFontHeight* TypefaceFonts::FontHeightList(int i) |
|
377 /** Returns the font height description from the position specified in the list. |
|
378 |
|
379 @param i Position of description. |
|
380 @return Font height description. */ |
|
381 { |
|
382 return iFontHeightList[i]; |
|
383 } |
|
384 |
|
385 TypefaceFonts::TypefaceFonts(): |
|
386 iIsScalable(efalse) |
|
387 /** This function is internal only, and is not intended for use. */ |
|
388 { |
|
389 } |
|
390 |
|
391 TypefaceFonts::~TypefaceFonts() |
|
392 /** This function is internal only, and is not intended for use. */ |
|
393 { |
|
394 iFontHeightList.Destroy(); |
|
395 } |
|
396 |
|
397 EXPORT_C TypefaceFontsEntry* TypefaceFontsEntry::New(Record* aTypefaceFonts) |
|
398 { |
|
399 return new TypefaceFontsEntry(aTypefaceFonts); |
|
400 } |
|
401 |
|
402 EXPORT_C void TypefaceFontsEntry::Delete() |
|
403 /** Deletes the current object. */ |
|
404 { |
|
405 delete this; |
|
406 } |
|
407 |
|
408 void TypefaceFontsEntry::Externalize(ostream& out) |
|
409 { |
|
410 ::ExternalizeStreamOff(out, iTypefaceFonts->iStreamId); |
|
411 out.write((char*) &iNotInPortrait, sizeof(iNotInPortrait)); |
|
412 out.write((char*) &iNotInLandscape, sizeof(iNotInLandscape)); |
|
413 } |
|
414 |
|
415 TypefaceFontsEntry::TypefaceFontsEntry(Record* aTypefaceFonts) |
|
416 : iTypefaceFonts(aTypefaceFonts), iNotInPortrait(efalse), iNotInLandscape(efalse) |
|
417 { |
|
418 } |
|
419 |
|
420 TypefaceFontsEntry::~TypefaceFontsEntry() |
|
421 /** Default destructor. */ |
|
422 { |
|
423 } |
|
424 |
|
425 void Margins::Externalize(ostream& out) |
|
426 { |
|
427 out.write((char*) &iLeft, sizeof(iLeft)); |
|
428 out.write((char*) &iRight, sizeof(iRight)); |
|
429 out.write((char*) &iTop, sizeof(iTop)); |
|
430 out.write((char*) &iBottom, sizeof(iBottom)); |
|
431 } |
|
432 |
|
433 /* |
|
434 PdrExtraInfo::~PdrExtraInfo() |
|
435 { |
|
436 iInfo.Destroy(); |
|
437 } |
|
438 |
|
439 void PdrExtraInfo::Externalize(ostream& out) |
|
440 { |
|
441 iInfo.Externalize(out); |
|
442 } |
|
443 */ |
|
444 |
|
445 void PdrModelInfo::Externalize(ostream& out) |
|
446 { |
|
447 iStreamId=out.tellp(); |
|
448 out.write((char*) &KPdrtranVersion, sizeof(KPdrtranVersion)); |
|
449 out.write((char*) &iFlags, sizeof(iFlags)); |
|
450 out.write((char*) &iKPixelWidthInTwips, sizeof(iKPixelWidthInTwips)); |
|
451 out.write((char*) &iKPixelHeightInTwips, sizeof(iKPixelHeightInTwips)); |
|
452 iPortraitOffsetInPixels.Externalize(out); |
|
453 iLandscapeOffsetInPixels.Externalize(out); |
|
454 iMinMarginsInPixels.Externalize(out); |
|
455 out.write((char*) &iDisplayMode, sizeof(iDisplayMode)); |
|
456 iTypefaceFontsEntryList.Externalize(out); |
|
457 ::ExternalizeStreamOff(out, iResources->iStreamId); |
|
458 streamoff streamid = 0; |
|
459 if (iSpareRecord) |
|
460 streamid = iSpareRecord->iStreamId; |
|
461 ::ExternalizeStreamOff(out, streamid); |
|
462 } |
|
463 |
|
464 EXPORT_C void PdrModelInfo::AddTypefaceFontsEntry(TypefaceFontsEntry* aTypefaceFontsEntry) |
|
465 /** Adds an entry containing information about typeface fonts to an internally-stored |
|
466 array. |
|
467 |
|
468 @param aTypefaceFontsEntry Typeface font information. */ |
|
469 { |
|
470 iTypefaceFontsEntryList.Add(aTypefaceFontsEntry); |
|
471 } |
|
472 |
|
473 int PdrModelInfo::NumTypefaceFontsEntries() |
|
474 /** Returns the number of entries containing information about typeface fonts in |
|
475 the internally-stored array. |
|
476 |
|
477 @return Number of entries. */ |
|
478 { |
|
479 return iTypefaceFontsEntryList.Size(); |
|
480 } |
|
481 |
|
482 TypefaceFontsEntry* PdrModelInfo::TypefaceFontsEntryList(int i) |
|
483 /** Returns the typeface font entry stored the internal array from the position |
|
484 specified. |
|
485 |
|
486 @param i Position in array. |
|
487 @return Typeface font entry. */ |
|
488 { |
|
489 return iTypefaceFontsEntryList[i]; |
|
490 } |
|
491 |
|
492 PdrModelInfo::PdrModelInfo() |
|
493 : iStreamId(0), |
|
494 iFlags(0), |
|
495 iKPixelWidthInTwips(0), |
|
496 iKPixelHeightInTwips(0), |
|
497 iPortraitOffsetInPixels(), |
|
498 iLandscapeOffsetInPixels(), |
|
499 iMinMarginsInPixels(), |
|
500 iDisplayMode(0), |
|
501 iTypefaceFontsEntryList(), |
|
502 iResources(NULL), |
|
503 iSpareRecord(NULL) // !! Not used yet |
|
504 /** Default constructor. */ |
|
505 { |
|
506 } |
|
507 |
|
508 PdrModelInfo::~PdrModelInfo() |
|
509 /** Default destructor. */ |
|
510 { |
|
511 iTypefaceFontsEntryList.Destroy(); |
|
512 } |
|
513 |
|
514 PrinterModelEntry::PrinterModelEntry() |
|
515 : iName(), iRequiresPrinterPort(efalse), iUid(KNullUid) |
|
516 /** Default constructor. */ |
|
517 { |
|
518 } |
|
519 |
|
520 void PrinterModelEntry::Externalize(ostream& out) |
|
521 { |
|
522 iName.Externalize(out); |
|
523 out.write((char*) &iRequiresPrinterPort, sizeof(iRequiresPrinterPort)); |
|
524 out.write((char*) &iUid, sizeof(iUid)); |
|
525 } |
|
526 |
|
527 EXPORT_C PrinterModelHeader* PrinterModelHeader::New() |
|
528 /** Creates a new instance of this class. |
|
529 |
|
530 @return Reference to a new object. */ |
|
531 { |
|
532 return new PrinterModelHeader(); |
|
533 } |
|
534 |
|
535 EXPORT_C void PrinterModelHeader::Delete() |
|
536 /** Deletes the current object. */ |
|
537 { |
|
538 delete this; |
|
539 } |
|
540 |
|
541 void PrinterModelHeader::Externalize(ostream& out) |
|
542 { |
|
543 iEntry.Externalize(out); |
|
544 ::ExternalizeStreamOff(out, iInfo.iStreamId); |
|
545 } |
|
546 |
|
547 void PrinterModelHeader::ExternalizeData(ostream& out) |
|
548 { |
|
549 iInfo.Externalize(out); |
|
550 } |
|
551 |
|
552 boolean PrinterModelHeader::IsPdrModel() |
|
553 /** Determines whether printer information is available for this printer model. |
|
554 |
|
555 @return ETrue: printer description is available. */ |
|
556 { |
|
557 return iInfo.NumTypefaceFontsEntries() || iInfo.iResources; |
|
558 } |
|
559 |
|
560 EXPORT_C PdrStoreFile* PdrStoreFile::New() |
|
561 /** Creates a new instance of this class. |
|
562 |
|
563 @return Reference to a new object. */ |
|
564 { |
|
565 return new PdrStoreFile(); |
|
566 } |
|
567 |
|
568 EXPORT_C void PdrStoreFile::Delete() |
|
569 /** Deletes the current object. */ |
|
570 { |
|
571 delete this; |
|
572 } |
|
573 |
|
574 EXPORT_C void PdrStoreFile::AddModel(PrinterModelHeader* aModel) |
|
575 /** Adds a printer model. |
|
576 |
|
577 @param aModel Printer model. */ |
|
578 { |
|
579 iModelList.Add(aModel); |
|
580 if (aModel->IsPdrModel()) |
|
581 { |
|
582 for (int i = 0; i < aModel->iInfo.NumTypefaceFontsEntries(); i++) |
|
583 AddTypefaceFonts((TypefaceFonts*) aModel->iInfo.TypefaceFontsEntryList(i)->iTypefaceFonts); |
|
584 iResourcesList.Add(aModel->iInfo.iResources); |
|
585 // if (aModel->iInfo.iSpareRecord) |
|
586 // iExtraInfoList.Add(aModel->iInfo.iSpareRecord); |
|
587 } |
|
588 } |
|
589 |
|
590 void PdrStoreFile::Externalize(ostream& out) |
|
591 { |
|
592 ExternalizeHeader(out); |
|
593 ExternalizeComponents(out); |
|
594 } |
|
595 |
|
596 void PdrStoreFile::ExternalizeHeader(ostream& out) |
|
597 { |
|
598 out.write((char*) &KStoreWriteOnceLayoutUid, sizeof(KStoreWriteOnceLayoutUid)); |
|
599 out.write((char*) &KPdrStoreFileUid, sizeof(KPdrStoreFileUid)); |
|
600 out.write((char*) &KNullUid, sizeof(KNullUid)); |
|
601 out.write((char*) &KPdrStoreFileChecksum, sizeof(KPdrStoreFileChecksum)); |
|
602 ::ExternalizeStreamOff(out, iStreamId); |
|
603 iStreamId = out.tellp(); |
|
604 iPDLName.Externalize(out); |
|
605 out.write((char*) &iPDLUid, sizeof(iPDLUid)); |
|
606 iModelList.Externalize(out); |
|
607 } |
|
608 |
|
609 void PdrStoreFile::AddTypefaceFonts(TypefaceFonts* aTypefaceFonts) |
|
610 { |
|
611 iTypefaceFontsList.Add(aTypefaceFonts); |
|
612 iTranslatesList.Add(aTypefaceFonts->iTranslates); |
|
613 if (aTypefaceFonts->iIsScalable) |
|
614 { |
|
615 for (int style = Normal; style <= BoldItalic; style++) |
|
616 { |
|
617 if (aTypefaceFonts->iScalableFontHeight.iStyle[style].iIsAvailable) |
|
618 iFontInfoList.Add(aTypefaceFonts->iScalableFontHeight.iStyle[style].iFontInfo); |
|
619 } |
|
620 } |
|
621 else |
|
622 { |
|
623 for (int j = 0; j < aTypefaceFonts->NumFontHeights(); j++) |
|
624 { |
|
625 PdrFontHeight* fontheight = aTypefaceFonts->FontHeightList(j); |
|
626 for (int style = Normal; style <= BoldItalic; style++) |
|
627 { |
|
628 if (fontheight->iStyle[style].iIsAvailable) |
|
629 iFontInfoList.Add(fontheight->iStyle[style].iFontInfo); |
|
630 } |
|
631 } |
|
632 } |
|
633 } |
|
634 |
|
635 void PdrStoreFile::ExternalizeComponents(ostream& out) |
|
636 { |
|
637 for (int i = 0; i < iModelList.Size(); i++) |
|
638 { |
|
639 PrinterModelHeader* model = (PrinterModelHeader*) iModelList[i]; |
|
640 if (model->IsPdrModel()) |
|
641 model->ExternalizeData(out); |
|
642 } |
|
643 iTypefaceFontsList.Externalize(out); |
|
644 iFontInfoList.Externalize(out); |
|
645 iResourcesList.Externalize(out); |
|
646 iTranslatesList.Externalize(out); |
|
647 // iExtraInfoList.Externalize(out); |
|
648 } |
|
649 |
|
650 PdrStoreFile::PdrStoreFile() |
|
651 : Record(), |
|
652 iPDLName(), |
|
653 iPDLUid(KNullUid), |
|
654 iModelList(), |
|
655 iTypefaceFontsList(), |
|
656 iFontInfoList(), |
|
657 iResourcesList(), |
|
658 iTranslatesList() |
|
659 /** This function is internal only, and is not intended for use. */ |
|
660 { |
|
661 } |
|
662 |
|
663 EXPORT_C boolean PdrModelStore::Store(const String& aFilename) |
|
664 /** Externalizes printer information from the store to the specfied external file. |
|
665 |
|
666 @param aFilename Filename. |
|
667 @return ETrue: store successful. */ |
|
668 { |
|
669 boolean state = efalse; |
|
670 ofstream fout; |
|
671 String string = aFilename; |
|
672 fout.open(string.Text(), ios::binary); |
|
673 if (!fout.fail()) |
|
674 { |
|
675 iPdrStoreFile->Externalize(fout); |
|
676 fout.close(); |
|
677 fout.open(string.Text(), ios::binary | ios::trunc); |
|
678 iPdrStoreFile->Externalize(fout); |
|
679 fout.close(); |
|
680 state = etrue; |
|
681 } |
|
682 return state; |
|
683 } |
|
684 |
|
685 EXPORT_C void PdrModelStore::AddPdrStoreFile(PdrStoreFile* aPdrStoreFile) |
|
686 { |
|
687 iPdrStoreFile = aPdrStoreFile; |
|
688 } |
|
689 |
|
690 EXPORT_C void PdrModelStore::AddModel(PrinterModelHeader *aModel) |
|
691 /** Adds a printer model to the store. |
|
692 |
|
693 @param aModel Printer model. */ |
|
694 { |
|
695 iModelList.Add(aModel); |
|
696 } |
|
697 |
|
698 EXPORT_C Record *PdrModelStore::FindModel(String& aLabel) |
|
699 { |
|
700 return iModelList.LabelToRecord(aLabel); |
|
701 } |
|
702 |
|
703 EXPORT_C void PdrModelStore::AddTypefaceFonts(TypefaceFonts *aTypefaceFonts) |
|
704 /** Adds typeface information to the store. |
|
705 |
|
706 @param aTypefaceFonts Typeface fonts. */ |
|
707 { |
|
708 iTypefaceFontsList.Add(aTypefaceFonts); |
|
709 } |
|
710 |
|
711 EXPORT_C Record *PdrModelStore::FindTypefaceFonts(String& aLabel) |
|
712 { |
|
713 return iTypefaceFontsList.LabelToRecord(aLabel); |
|
714 } |
|
715 |
|
716 EXPORT_C void PdrModelStore::AddFontInfo(FontInfo *aFontInfo) |
|
717 /** Adds font information to the store. |
|
718 |
|
719 @param aFontInfo Font information. */ |
|
720 { |
|
721 iFontInfoList.Add(aFontInfo); |
|
722 } |
|
723 |
|
724 EXPORT_C Record *PdrModelStore::FindFontInfo(String& aLabel) |
|
725 { |
|
726 return iFontInfoList.LabelToRecord(aLabel); |
|
727 } |
|
728 |
|
729 EXPORT_C void PdrModelStore::AddResources(PdrResources *aResources) |
|
730 { |
|
731 iResourcesList.Add(aResources); |
|
732 } |
|
733 |
|
734 EXPORT_C Record *PdrModelStore::FindResources(String& aLabel) |
|
735 { |
|
736 return iResourcesList.LabelToRecord(aLabel); |
|
737 } |
|
738 |
|
739 EXPORT_C void PdrModelStore::AddTranslates(PdrTranslates *aTranslates) |
|
740 /** Adds printer translations to the store. |
|
741 |
|
742 @param aTranslates Translation list. */ |
|
743 { |
|
744 iTranslatesList.Add(aTranslates); |
|
745 } |
|
746 |
|
747 EXPORT_C Record *PdrModelStore::FindTranslates(String& aLabel) |
|
748 { |
|
749 return iTranslatesList.LabelToRecord(aLabel); |
|
750 } |
|
751 |
|
752 /* |
|
753 void PdrModelStore::AddExtraInfo(PdrExtraInfo *aInfo) |
|
754 { |
|
755 iExtraInfoList.Add(aInfo); |
|
756 } |
|
757 |
|
758 Record* PdrModelStore::FindExtraInfo(String& aLabel) |
|
759 { |
|
760 return iExtraInfoList.LabelToRecord(aLabel); |
|
761 } |
|
762 */ |
|
763 |
|
764 PdrModelStore::PdrModelStore() |
|
765 : iPdrStoreFile(NULL), |
|
766 iModelList(), |
|
767 iTypefaceFontsList(), |
|
768 iFontInfoList(), |
|
769 iResourcesList()//, |
|
770 // iExtraInfoList() |
|
771 /** Default constructor. */ |
|
772 { |
|
773 } |
|
774 |
|
775 PdrModelStore::~PdrModelStore() |
|
776 /** Default destructor. */ |
|
777 { |
|
778 delete iPdrStoreFile; |
|
779 iModelList.Destroy(); |
|
780 iTypefaceFontsList.Destroy(); |
|
781 iFontInfoList.Destroy(); |
|
782 iResourcesList.Destroy(); |
|
783 iTranslatesList.Destroy(); |
|
784 // iExtraInfoList.Destroy(); |
|
785 } |