cmcfixes76: #i113073# redundant dereferences
[LibreOffice.git] / sw / source / filter / ww1 / w1filter.cxx
blob45e94726cddc0c3f637e56ce6b22f7e951675256
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 #include <hintids.hxx>
32 #include <tools/solar.h>
33 #include <comphelper/string.hxx>
34 #include <editeng/paperinf.hxx>
35 #include <svtools/filter.hxx>
36 #ifndef _GRAPH_HXX //autogen
37 #include <vcl/graph.hxx>
38 #endif
39 #include <editeng/fontitem.hxx>
40 #include <editeng/lrspitem.hxx>
41 #include <editeng/ulspitem.hxx>
42 #include <editeng/wghtitem.hxx>
43 #include <editeng/postitem.hxx>
44 #include <editeng/crsditem.hxx>
45 #ifndef _SVX_CNTRITEM_HXX //autogen
46 #include <editeng/cntritem.hxx>
47 #endif
48 #include <editeng/cmapitem.hxx>
49 #include <editeng/fhgtitem.hxx>
50 #include <editeng/udlnitem.hxx>
51 #include <editeng/wrlmitem.hxx>
52 #include <editeng/colritem.hxx>
53 #include <editeng/kernitem.hxx>
54 #include <editeng/escpitem.hxx>
55 #ifndef _SVX_TSTPITEM_HXX //autogen
56 #include <editeng/tstpitem.hxx>
57 #endif
58 #include <svl/urihelper.hxx>
59 #include <fmtfsize.hxx>
60 #include <doc.hxx>
61 #include <pam.hxx>
62 #include <ndtxt.hxx>
63 #include <pagedesc.hxx>
64 #include <flddat.hxx>
65 #include <reffld.hxx>
66 #include <expfld.hxx>
67 #include <docufld.hxx>
68 #include <ftninfo.hxx>
69 #include <section.hxx> // class SwSection
70 #include <fltini.hxx>
71 #include <w1par.hxx>
73 #include <docsh.hxx>
74 #include <swerror.h>
75 #include <mdiexp.hxx>
76 #ifndef _STATSTR_HRC
77 #include <statstr.hrc>
78 #endif
79 #if OSL_DEBUG_LEVEL > 1
80 #include <stdio.h>
81 #endif
83 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
84 #include <com/sun/star/document/XDocumentProperties.hpp>
86 #define MAX_FIELDLEN 64000
88 using namespace nsSwDocInfoSubType;
91 ///////////////////////////////////////////////////////////////////////
93 // hier stehen die methoden operator<<, Out, Start und Stop mit
94 // folgender Bedeutung: wenn moeglich wird die information aus dem
95 // dokument per
96 // operator<<()
97 // in die shell uebertragen. sind jedoch weitere parameter noetig
98 // wurde der name
99 // Out()
100 // gewaehlt. ist ein bereich zu kennzeichnen (zB bei attributen
101 // von/bis), heissen die methoden
102 // Start(), Stop()
103 // alle diese methoden stehen in diesem modul, das fuer den filter,
104 // jedoch nicht fuer den dumper noetig ist. und da alle regeln ihre
105 // ausnahme haben: hier stehen auch methoden, die aus anderen gruenden
106 // fuer den dumper sinnlos sind, zB wenn sie auf sv-strukturen beruhen
107 // wie zB GetFont() auf SvxFontItem.
110 /////////////////////////////////////////////////////////////// Manager
111 Ww1Shell& operator <<(Ww1Shell& rOut, Ww1Manager& This)
113 // verhindern, das bei rekusivem aufruf dies mehrfach passiert:
114 if (!This.Pushed())
116 { // der wird nur temporaer gebraucht:
117 This.SetInStyle( TRUE );
118 Ww1StyleSheet(This.aFib).Out(rOut, This);
119 This.SetInStyle( FALSE );
121 { // dieser auch:
122 Ww1Assoc(This.aFib).Out(rOut);
124 // dieser nicht, der ist bereits member:
125 This.aDop.Out(rOut);
126 // Jetzt entscheiden, wie Seitenvorlagen erzeugt werden
127 if (This.GetSep().Count() <= 1)
128 rOut.SetUseStdPageDesc();
130 // und jetzt das eigentliche dok:
131 sal_Unicode cUnknown = ' ';
132 while (*This.pSeek < This.pDoc->Count())
134 // ausgabe des ProgressState nur, wenn im haupttext, da sonst
135 // nicht bestimmt werden kann, wie weit wir sind:
136 if (!This.Pushed())
137 ::SetProgressState(This.Where() * 100 / This.pDoc->Count(),
138 rOut.GetDoc().GetDocShell());
139 // hier werden abwechselnd die attribute und die zeichen in die
140 // shell gepumpt. die positionen werden durch das lesen der
141 // zeichen aus dem manager hoch- gezaehlt. erst alle attribute:
142 This.Out(rOut, cUnknown);
143 // das textdocument pDoc ist ein Ww1PlainText, dessen Out()
144 // methode solange ausgibt, bis entweder ein sonderzeichen
145 // auftaucht oder die anzahl der auszugebenden zeichen erreicht
146 // ist:
147 cUnknown = This.pDoc->Out(rOut, *This.pSeek);
149 This.SetStopAll(TRUE);
150 This.OutStop(rOut, cUnknown); // Damit die Attribute am Ende geschlossen
151 This.SetStopAll(FALSE); // werden
152 return rOut;
155 void Ww1Manager::OutStop(Ww1Shell& rOut, sal_Unicode cUnknown)
157 // Bookmarks brauchen nicht beendet werden ???
158 if (pFld)
159 pFld->Stop(rOut, *this, cUnknown);
160 if (!Pushed())
161 aFtn.Stop(rOut, *this, cUnknown);
162 if (1)
163 aChp.Stop(rOut, *this, cUnknown);
164 if (1)
165 aPap.Stop(rOut, *this, cUnknown);
166 if (!Pushed())
167 aSep.Stop(rOut, *this, cUnknown);
170 void Ww1Manager::OutStart( Ww1Shell& rOut )
172 // alle attribute, die's brauchen beginnen
173 if (!Pushed())
174 aSep.Start(rOut, *this);
175 if (1)
176 aPap.Start(rOut, *this);
177 if (1)
178 aChp.Start(rOut, *this);
179 if (!Pushed())
180 aFtn.Start(rOut, *this);
181 if (pFld)
182 pFld->Start(rOut, *this);
183 if (!Pushed())
184 aBooks.Start(rOut, *this);
185 // bestimmen, wo das naechste Ereigniss ist:
186 ULONG ulEnd = pDoc->Count(); // spaetestens am textende
187 if (!Pushed())
188 if (ulEnd > aSep.Where()) // naechster Sep vorher?
189 ulEnd = aSep.Where();
190 if (1)
191 if (ulEnd > aPap.Where()) // naechster Pap vorher?
192 ulEnd = aPap.Where();
193 if (1)
194 if (ulEnd > aChp.Where()) // naechster Chp vorher?
195 ulEnd = aChp.Where();
196 if (!Pushed())
197 if (ulEnd > aFtn.Where()) // naechster Ftn vorher?
198 ulEnd = aFtn.Where();
199 if (pFld)
200 if (ulEnd > pFld->Where()) // naechster Fld vorher?
201 ulEnd = pFld->Where();
202 if (!Pushed())
203 if (ulEnd > aBooks.Where()) // naechster Bookmark vorher?
204 ulEnd = aBooks.Where();
205 *pSeek = Where(); // momentane position
206 if (*pSeek < ulEnd) // sind wir bereits weiter?
207 *pSeek = ulEnd;
210 void Ww1Manager::Out(Ww1Shell& rOut, sal_Unicode cUnknown)
212 // Je nach modus wird hier mit feldern, fusznoten, zeichenattributen,
213 // absatzatributen und sektionen wie folgt verfahren: von allen wird
214 // zuallererst die stop-methoden gerufen. stellt das objekt fest, dasz
215 // etwas zu beenden ist (natuerlich nicht im ersten durchgang) beendet
216 // es dies, ansonsten ist der aufruf wirkungslos. dann werden
217 // unbehandelte sonderzeichen augegeben. das werden genauso alle
218 // start-methoden gerufen und danach per where festgestellt, an
219 // welcher stelle die naechste aktion zu erwarten ist.
221 // ist der manager in einem ge'push'ten mode, werden bestimmte
222 // elemente ausgeklammert. felder werden wiederum nur in besonderen
223 // faellen augeklammert, wenn naemlich bereiche ausgegeben werden, die
224 // keine felder enthalten koennen. charakterattribute und
225 // paragraphenattribute werden jedoch nie ausgeklammert. die if (1)
226 // wurden zur verdeutlichung der einheitlichkeit eingefuegt.
228 // Erstmal eine Sonderbehandlung fuer Tabellen:
229 // die wichtigen Attribute lassen sich am Besten vor Beendigung derselben
230 // abfragen.
231 // Optimierung: Sie werden nur auf sinnvolle Werte gesetzt, wenn
232 // das 0x07-Zeiche ansteht.
234 BOOL bLIsTtp = FALSE;
235 BOOL bLHasTtp = FALSE;
236 if( cUnknown == 0x07 )
238 bLIsTtp = IsInTtp();
239 bLHasTtp = HasTtp();
242 OutStop( rOut, cUnknown ); // Attrs ggfs. beenden
244 // meta-zeichen interpretieren:
245 if (!Ww1PlainText::IsChar(cUnknown))
246 switch (cUnknown)
248 case 0x02:
249 // dontknow
250 break;
251 case 0x07: // table
252 if (rOut.IsInTable() && HasInTable() && !bLIsTtp && !bLHasTtp)
253 rOut.NextTableCell();
254 break;
255 case 0x09: // tab
256 rOut.NextTab();
257 break;
258 case 0x0a: // linefeed
259 rOut.NextParagraph();
260 break;
261 case 0x0b: // linebreak
262 if (rOut.IsInTable())
263 // rOut.NextBand(); // war Stuss
265 else
266 rOut.NextLine();
267 break;
268 case 0x0d: // carriage return
269 // ignore
270 break;
271 case 0x0c: // pagebreak
272 rOut.NextPage();
273 break;
274 case 0x14: // sectionendchar
275 // ignore here
276 break;
277 default:
278 break;
281 OutStart( rOut ); // Attrs ggfs. starten und Naechste Pos berechnen
284 SvxFontItem Ww1Manager::GetFont(USHORT nFCode)
286 return aFonts.GetFont(nFCode);
289 void Ww1Manager::Push0(Ww1PlainText* _pDoc, ULONG ulSeek, Ww1Fields* _pFld)
291 DBG_ASSERT(!Pushed(), "Ww1Manager");
292 this->pDoc = _pDoc;
293 pSeek = new ULONG;
294 *pSeek = pDoc->Where();
295 aPap.Push(ulSeek);
296 aChp.Push(ulSeek);
297 this->pFld = _pFld;
300 // ulSeek ist der FC-Abstand zwischen Hauptest-Start und Sondertext-Start
301 // ulSeek2 ist der Offset dieses bestimmten Sondertextes im Sondertext-Bereich,
302 // also z.B. der Offset des speziellen K/F-Textes
303 void Ww1Manager::Push1(Ww1PlainText* _pDoc, ULONG ulSeek, ULONG ulSeek2,
304 Ww1Fields* _pFld)
306 DBG_ASSERT(!Pushed(), "Ww1Manager");
307 this->pDoc = _pDoc;
308 pSeek = new ULONG;
309 *pSeek = pDoc->Where();
310 aPap.Push(ulSeek + ulSeek2);
311 aChp.Push(ulSeek + ulSeek2);
312 if( _pFld )
313 _pFld->Seek( ulSeek2 );
314 this->pFld = _pFld;
317 void Ww1Manager::Pop()
319 DBG_ASSERT(Pushed(), "Ww1Manager");
320 delete pDoc;
321 pDoc = &aDoc;
322 delete pSeek;
323 pSeek = &ulDocSeek;
324 aChp.Pop();
325 aPap.Pop();
326 delete pFld;
327 pFld = &aFld;
330 ///////////////////////////////////////////////////////////// Bookmarks
332 void Ww1Bookmarks::Out(Ww1Shell& rOut, Ww1Manager& rMan, USHORT)
334 if (GetIsEnd())
336 rOut.SetBookEnd(GetHandle());
337 return;
340 const String & rName = GetName();
341 if( rName.EqualsAscii( "_Toc", 0, 4 ) ) // "_Toc*" ist ueberfluessig
342 return;
344 if( rOut.IsFlagSet( SwFltControlStack::HYPO )
345 && rName.EqualsIgnoreCaseAscii( "FORMULAR" ) )
346 rOut.SetProtect();
348 // Fuer UEbersetzung Bookmark -> Variable setzen
349 long nLen = Len();
350 if( nLen > MAX_FIELDLEN )
351 nLen = MAX_FIELDLEN;
353 // Lese Inhalt des Bookmark
354 // geht vermulich auch ueber Ww1PlainText
355 String aVal( rMan.GetText().GetText( Where(), nLen ) );
357 // in 2 Schritten, da OS/2 zu doof ist
358 SwFltBookmark aBook( rName, aVal, GetHandle(), FALSE );
359 rOut << aBook;
362 void Ww1Bookmarks::Start(Ww1Shell& rOut, Ww1Manager& rMan)
364 if (rMan.Where() >= Where())
366 Out(rOut, rMan);
367 (*this)++;
371 ///////////////////////////////////////////////////////////// Footnotes
372 void Ww1Footnotes::Start(Ww1Shell& rOut, Ww1Manager& rMan)
374 if (rMan.Where() >= Where())
376 DBG_ASSERT(nPlcIndex < Count(), "WwFootnotes");
377 sal_Unicode c;
378 rMan.Fill(c);
379 DBG_ASSERT(c==0x02, "Ww1Footnotes");
380 if (c==0x02)
382 Ww1FtnText* pText = new Ww1FtnText(rMan.GetFib());
383 // beginn des textes dieser fusznote:
384 ULONG start = aText.Where(nPlcIndex);
385 pText->Seek(start);
386 // laenge des textes
387 ULONG count = aText.Where(nPlcIndex+1) - start;
388 pText->SetCount(count);
389 // fusznotenkennung sollte das erste byte sein
390 pText->Out(c);
391 DBG_ASSERT(c==0x02, "Ww1Footnotes");
392 count--; // fuer das eben gelesene kenn-byte
393 // fusznoten mode beginnen:
394 rOut.BeginFootnote();
395 bStarted = TRUE;
396 rMan.Push0(pText, pText->Offset(rMan.GetFib()),
397 new Ww1FootnoteFields(rMan.GetFib()));
398 rOut << rMan;
399 rMan.Pop();
400 rOut.EndFootnote();
402 else
403 (*this)++;
407 void Ww1Footnotes::Stop(Ww1Shell& /*rOut*/, Ww1Manager& rMan, sal_Unicode& c)
409 if (bStarted && rMan.Where() > Where())
411 DBG_ASSERT(nPlcIndex < Count(), "Ww1Footnotes");
412 // DBG_ASSERT(c==0x02, "Ww1Footnotes"); // scheint Stuss zu sein
413 c = ' ';
414 (*this)++;
418 //////////////////////////////////////////////////////////////// Fields
419 void Ww1Fields::Start(Ww1Shell& rOut, Ww1Manager& rMan)
421 if (rMan.Where() >= Where()){
422 DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
423 if (GetData()->chGet() == 19)
424 Out(rOut, rMan);
425 else
426 (*this)++; // ignore
430 void Ww1Fields::Stop( Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
432 if (rMan.Where() >= Where())
434 DBG_ASSERT(nPlcIndex < Count(), "Ww1Fields");
435 if (GetData()->chGet() != 19)
437 rMan.Fill( c );
438 DBG_ASSERT(c==21, "Ww1Fields");
439 (*this)++;
440 c = ' ';
441 if (pField)
442 // haben wir ein fertiges feld da, das eingefuegt werden soll?
444 rOut << *pField;
445 delete pField;
446 pField = 0;
447 // das macht der filter so, damit attribute die ueber das feld
448 // gelten auch wirklich eingelesen werden und dem feld
449 // zugeordnet werden.
451 if (sErgebnis.Len())
452 rOut << sErgebnis;
457 enum WWDateTime{ WW_DONTKNOW = 0x0, WW_DATE = 0x1, WW_TIME = 0x2, WW_BOTH = 0x3 };
459 static WWDateTime GetTimeDatePara( const String& rForm,
460 SwTimeFormat* pTime = 0,
461 SwDateFormat* pDate = 0 )
463 WWDateTime eDT = WW_BOTH;
464 if( STRING_NOTFOUND == rForm.Search( 'H' )) // H -> 24h
466 if( pTime )
467 *pTime = TF_SSMM_24;
469 else if( STRING_NOTFOUND == rForm.Search( 'H' )) // h -> 24h
471 if( pTime )
472 *pTime = TF_SSMM_12;
474 else // keine Zeit
476 eDT = (WWDateTime)( eDT & ~(USHORT)WW_TIME );
479 xub_StrLen nDPos = 0;
480 while( STRING_NOTFOUND != nDPos )
482 nDPos = rForm.Search( 'M', nDPos ); // M -> Datum
483 if( !nDPos )
484 break;
485 sal_Unicode cPrev = rForm.GetChar( nDPos - 1 );
486 // ignoriere dabei "AM", "aM", "PM", "pM"
487 if( 'a' != cPrev && 'A' != cPrev && 'p' != cPrev && 'P' != cPrev )
488 break;
489 // else search again
490 ++nDPos;
493 if( STRING_NOTFOUND != nDPos ) // Monat -> Datum ?
495 static SwDateFormat __READONLY_DATA aDateA[32] =
497 DFF_DMY, DFF_DMMY, DFF_DMYY, DFF_DMMYY,
498 DFF_DMMMY, DFF_DMMMY, DFF_DMMMYY, DFF_DMMMYY,
499 DFF_DDMMY, DFF_DDMMY, DFF_DDMMMYY, DFF_DDMMMYY,
500 DFF_DDMMMY, DFF_DDMMMY, DFF_DDMMMYY, DFF_DDMMMYY,
501 DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
502 DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
503 DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
504 DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY
507 BOOL bHasDay = STRING_NOTFOUND != rForm.Search( 't' ) ||
508 STRING_NOTFOUND != rForm.Search( 'T' ) ||
509 STRING_NOTFOUND != rForm.Search( 'd' ) ||
510 STRING_NOTFOUND != rForm.Search( 'D' );
512 BOOL bLongDayOfWeek= STRING_NOTFOUND != rForm.SearchAscii( "tttt" ) ||
513 STRING_NOTFOUND != rForm.SearchAscii( "TTTT" ) ||
514 STRING_NOTFOUND != rForm.SearchAscii( "dddd" ) ||
515 STRING_NOTFOUND != rForm.SearchAscii( "DDDD" );
517 BOOL bDayOfWeek = STRING_NOTFOUND != rForm.SearchAscii( "ttt" ) ||
518 STRING_NOTFOUND != rForm.SearchAscii( "TTT" ) ||
519 STRING_NOTFOUND != rForm.SearchAscii( "ddd" ) ||
520 STRING_NOTFOUND != rForm.SearchAscii( "DDD" );
522 // M, MM -> numeric month
523 // MMM, MMMM -> text. month
524 BOOL bLitMonth = STRING_NOTFOUND != rForm.SearchAscii( "MMM" );
525 // MMMM -> full month
526 BOOL bFullMonth = STRING_NOTFOUND != rForm.SearchAscii( "MMMM" );
527 // jj, JJ -> 2-col-year
528 // jjjj, JJJJ -> 4-col-year
529 BOOL bFullYear = STRING_NOTFOUND != rForm.SearchAscii( "jjj" ) ||
530 STRING_NOTFOUND != rForm.SearchAscii( "JJJ" ) ||
531 STRING_NOTFOUND != rForm.SearchAscii( "yyy" ) ||
532 STRING_NOTFOUND != rForm.SearchAscii( "YYY" );
534 USHORT i = ( bLitMonth & 1 )
535 | ( ( bFullYear & 1 ) << 1 )
536 | ( ( bFullMonth & 1 ) << 2 )
537 | ( ( bDayOfWeek & 1 ) << 3 )
538 | ( ( bLongDayOfWeek & 1 ) << 4 );
539 if( pDate )
541 if( !bHasDay && !bFullMonth )
542 *pDate = DFF_MY;
543 else
544 *pDate = aDateA[i];
547 else
549 eDT = (WWDateTime)( eDT & ~(USHORT)WW_DATE );
551 return eDT;
555 extern void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich,
556 USHORT& rSubType, ULONG &rFmt,
557 USHORT nVersion );
559 void Ww1Fields::Out(Ww1Shell& rOut, Ww1Manager& rMan, USHORT nDepth)
561 String sType; // der typ als string
562 String sFormel; // die formel
563 String sFormat;
564 String sDTFormat; // Datum / Zeit-Format
565 W1_FLD* pData = GetData(); // die an den plc gebunden daten
566 DBG_ASSERT(pData->chGet()==19, "Ww1Fields"); // sollte beginn sein
568 sal_Unicode c;
569 rMan.Fill( c );
570 DBG_ASSERT(c==19, "Ww1Fields"); // sollte auch beginn sein
571 if (pData->chGet()==19 && c == 19)
573 String aStr;
574 c = rMan.Fill( aStr, GetLength() );
575 DBG_ASSERT(Ww1PlainText::IsChar(c), "Ww1Fields");
576 xub_StrLen pos = aStr.Search(' ');
577 // get type out of text
578 sType = aStr.Copy( 0, pos );
579 aStr.Erase( 0, pos );
580 if ( pos != STRING_NOTFOUND )
581 aStr.Erase(0, 1);
582 sFormel += aStr;
583 BYTE rbType = pData->fltGet();
584 do {
585 // solange den formelteil einlesen, bis das feld entweder
586 // zuende ist oder der ergebnisteil beginnt. dabei koennen
587 // natuerlich neue felder beginnen (word unterstuetzt felder,
588 // die wiederum felder beinhalten).
589 (*this)++;
590 pData = GetData();
591 if (pData->chGet()==19) // nested field
593 Out(rOut, rMan, nDepth+1);
594 rMan.Fill(c);
595 DBG_ASSERT(c==21, "Ww1PlainText");
596 sFormel.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "Ww" ));
597 sFormel += String::CreateFromInt32( nPlcIndex );
598 c = rMan.Fill(aStr, GetLength());
599 DBG_ASSERT(Ww1PlainText::IsChar(c), "Ww1PlainText");
600 sFormel += aStr;
603 while (pData->chGet()==19);
605 // get format out of text
606 pos = sFormel.SearchAscii( "\\*" );
607 sFormat = sFormel.Copy( pos );
608 sFormel.Erase( pos );
610 pos = sFormel.SearchAscii( "\\@" );
611 sDTFormat = sFormel.Copy( pos );
612 sFormel.Erase( pos );
614 // der formelteil ist zuende, kommt ein ergebnisteil?
615 if( pData->chGet() == 20 )
617 rMan.Fill( c );
618 DBG_ASSERT(c==20, "Ww1PlainText");
619 c = rMan.Fill(sErgebnis, GetLength());
620 if (!Ww1PlainText::IsChar(c))
621 sErgebnis += c; //~ mdt: sonderzeichenbenhandlung
622 (*this)++;
623 pData = GetData();
625 DBG_ASSERT(pData->chGet()==21, "Ww1PlainText");
626 BOOL bKnown = TRUE;
627 DBG_ASSERT(pField==0, "Ww1PlainText");
628 if (pField != 0)
630 rOut << *pField;
631 delete pField;
632 pField = 0;
634 // naja, aber info enthaelt alle moeglichkeiten, die auch direkt da sind
635 oncemore:
636 switch (rbType)
638 case 3: // bookmark reference
639 rOut.ConvertUStr( sFormel );
640 pField = new SwGetRefField( (SwGetRefFieldType*)
641 rOut.GetSysFldType( RES_GETREFFLD ),
642 sFormel,
643 REF_BOOKMARK,
645 REF_CONTENT );
646 // pField = new SwGetExpField((SwGetExpFieldType*)
647 // rOut.GetSysFldType(RES_GETEXPFLD), sFormel, nsSwGetSetExpType::GSE_STRING);
648 // ,
649 // nsSwGetSetExpType::GSE_STRING, VVF_SYS);
650 break;
651 case 6: // set command
653 pos = aStr.Search(' ');
654 String aName( aStr.Copy( 0, pos ));
655 aStr.Erase(0, pos );
656 aStr.Erase(0, 1);
657 if( !aName.Len() )
658 break;
659 rOut.ConvertUStr( aName );
660 SwFieldType* pFT = rOut.GetDoc().InsertFldType(
661 SwSetExpFieldType( &rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_STRING ) );
662 pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr);
663 ((SwSetExpField*)pField)->SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
664 // Invisible macht in 378 AErger, soll aber demnaechst gehen
666 // das Ignorieren des Bookmarks ist nicht implementiert
668 break;
669 case 14: // info var
671 pos = aStr.Search(' ');
672 String aSubType( aStr.Copy( 0, pos ));
673 aStr.Erase(0, pos );
674 aStr.Erase(0, 1);
675 rOut.ConvertUStr( aSubType );
678 // ganz grosze schiete: der typ 'info' kann einem der
679 // typen 15..31 entsprechen. er enthaelt als formel
680 // das eingentliche feld der doc-info.
681 // kein ';' benutzen mit folgendem macro:
682 #define IS(sd, se, t) \
683 if (aSubType.EqualsAscii( sd ) || aSubType.EqualsAscii( se)) \
684 rbType = t; \
685 else
687 // deutsche bez. englische bez. typ-code
688 IS("titel", "title", 15)
689 IS("thema", "subject", 16)
690 IS("autor", "author", 17)
691 IS("stichw?rter", "keywords", 18) //~ mdt: umlaut
692 IS("kommentar", "comment", 19)
693 IS("gespeichertvon", "lastrevisedby", 20)
694 IS("ertelldat", "creationdate", 21)
695 IS("speicherdat", "revisiondate", 22)
696 IS("druckdat", "printdate", 23)
697 IS("version", "revisionnumber", 24)
698 IS("zeit", "edittime", 25)
699 IS("anzseit", "numberofpages", 26)
700 IS("anzw?rter", "numberofwords", 27) //~ mdt: umlaut
701 IS("anzzeichen", "numberofchars", 28)
702 IS("dateiname", "filename", 29)
703 IS("vorlage", "templatename", 30)
704 bKnown = FALSE;
705 #undef IS
706 if (rbType != 14)
707 goto oncemore;
709 break;
710 case 15: // title
711 pField = new SwDocInfoField((SwDocInfoFieldType*)
712 rOut.GetSysFldType(RES_DOCINFOFLD), DI_TITEL, String(), 0);
713 break;
714 case 16: // subject
715 pField = new SwDocInfoField((SwDocInfoFieldType*)
716 rOut.GetSysFldType(RES_DOCINFOFLD), DI_THEMA, String(), 0);
717 break;
718 case 17: // author
719 pField = new SwAuthorField((SwAuthorFieldType*)
720 rOut.GetSysFldType(RES_AUTHORFLD), AF_NAME );
721 break;
722 case 18: // keywords
723 pField = new SwDocInfoField((SwDocInfoFieldType*)
724 rOut.GetSysFldType(RES_DOCINFOFLD), DI_KEYS, String(), 0);
725 break;
726 case 19: // comments
727 pField = new SwDocInfoField((SwDocInfoFieldType*)
728 rOut.GetSysFldType(RES_DOCINFOFLD), DI_COMMENT, String(), 0);
729 break;
730 case 20: // last revised by
731 pField = new SwDocInfoField((SwDocInfoFieldType*)
732 rOut.GetSysFldType(RES_DOCINFOFLD), DI_CHANGE|DI_SUB_AUTHOR, String());
733 break;
734 case 21: // creation date
735 case 22: // revision date
736 case 23: // print date
737 case 25:{// edit time
738 USHORT nSub;
739 USHORT nReg = 0; // RegInfoFormat, DefaultFormat fuer DocInfoFelder
741 switch( rbType )
743 default:
744 case 21: nSub = DI_CREATE; nReg = DI_SUB_DATE; break;
745 case 23: nSub = DI_PRINT; nReg = DI_SUB_DATE; break;
746 case 22: nSub = DI_CHANGE; nReg = DI_SUB_DATE; break;
747 case 25: nSub = DI_CHANGE; nReg = DI_SUB_TIME; break;
749 switch( GetTimeDatePara( sDTFormat ) )
751 case WW_DATE: nReg = DI_SUB_DATE; break;
752 case WW_TIME: nReg = DI_SUB_TIME; break;
753 case WW_BOTH: nReg = DI_SUB_DATE; break;
754 default:
755 break;
756 // WW_DONTKNOW -> Default bereits gesetzt
758 pField = new SwDocInfoField((SwDocInfoFieldType*)
759 rOut.GetSysFldType(RES_DOCINFOFLD), nSub | nReg, String());
761 break;
762 case 24: // revision number
763 pField = new SwDocInfoField((SwDocInfoFieldType*)
764 rOut.GetSysFldType(RES_DOCINFOFLD), DI_DOCNO, String(), 0);
765 break;
766 case 26: // number of pages
767 pField = new SwDocStatField((SwDocStatFieldType*)
768 rOut.GetSysFldType(RES_DOCSTATFLD), DS_PAGE, SVX_NUM_ARABIC);
769 break;
770 case 27: // number of words
771 pField = new SwDocStatField((SwDocStatFieldType*)
772 rOut.GetSysFldType(RES_DOCSTATFLD), DS_WORD, SVX_NUM_ARABIC);
773 break;
774 case 28: // number of chars
775 pField = new SwDocStatField((SwDocStatFieldType*)
776 rOut.GetSysFldType(RES_DOCSTATFLD), DS_CHAR, SVX_NUM_ARABIC);
777 break;
778 case 29: // file name
779 pField = new SwFileNameField((SwFileNameFieldType*)
780 rOut.GetSysFldType(RES_FILENAMEFLD));
781 break;
782 case 30: // doc template name
783 pField = new SwTemplNameField((SwTemplNameFieldType*)
784 rOut.GetSysFldType(RES_TEMPLNAMEFLD), FF_NAME);
785 break;
786 case 31:
787 case 32:{
788 SwDateFormat aDate = DF_SSYS;
789 SwTimeFormat aTime = TF_SYSTEM;
791 WWDateTime eDT = GetTimeDatePara(sDTFormat, &aTime, &aDate);
792 if( eDT == WW_DONTKNOW ) // kein D/T-Formatstring
793 eDT = ( rbType == 32 ) ? WW_TIME : WW_DATE; // benutze ID
795 if( eDT & WW_DATE )
797 USHORT nWhich = RES_DATEFLD;
798 USHORT nSubType = DATEFLD;
799 ULONG nFormat = aDate;
800 sw3io_ConvertFromOldField( rOut.GetDoc(),
801 nWhich, nSubType, nFormat, 0x0110 );
802 pField = new SwDateTimeField((SwDateTimeFieldType*)
803 rOut.GetSysFldType(RES_DATETIMEFLD), DATEFLD, nFormat);
805 if( eDT == WW_BOTH )
806 rOut << * pField << ' ';
807 // Mogel: direkt einfuegen und Space dahinter
809 if( eDT & WW_TIME )
811 USHORT nWhich = RES_TIMEFLD;
812 USHORT nSubType = TIMEFLD;
813 ULONG nFormat = aTime;
814 sw3io_ConvertFromOldField( rOut.GetDoc(),
815 nWhich, nSubType, nFormat, 0x0110 );
816 pField = new SwDateTimeField((SwDateTimeFieldType*)
817 rOut.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat);
821 break;
822 case 33: // current page
823 pField = new SwPageNumberField((SwPageNumberFieldType*)
824 rOut.GetSysFldType(RES_PAGENUMBERFLD), PG_RANDOM, SVX_NUM_ARABIC);
825 break;
826 case 34: // evaluation exp
828 if (nDepth == 0)
830 SwGetExpFieldType* pFieldType =
831 (SwGetExpFieldType*)rOut.GetSysFldType(RES_GETEXPFLD);
832 DBG_ASSERT(pFieldType!=0, "Ww1Fields");
833 if (pFieldType != 0)
834 pField = new SwGetExpField(pFieldType, sFormel,
835 nsSwGetSetExpType::GSE_STRING, VVF_SYS);
837 else // rekursion:
839 String aName( String::CreateFromAscii(
840 RTL_CONSTASCII_STRINGPARAM( "Ww" )));
841 aName += String::CreateFromInt32( nPlcIndex );
842 SwFieldType* pFT = rOut.GetDoc().GetFldType( RES_SETEXPFLD, aName, false);
843 if (pFT == 0)
845 SwSetExpFieldType aS(&rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_FORMULA);
846 pFT = rOut.GetDoc().InsertFldType(aS);
848 SwSetExpField aFld((SwSetExpFieldType*)pFT, sFormel);
849 aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE);
850 rOut << aFld;
853 break;
854 case 36: // print command, Einfuegendatei
856 pos = aStr.Search(' ');
857 String aFName( aStr.Copy( 0, pos ));
858 aStr.Erase(0, pos );
859 aStr.Erase(0, 1);
860 if( !aFName.Len() )
861 break;
862 aFName.SearchAndReplaceAscii( "\\\\", String( '\\' ));
864 // char* pBook = FindNextPara( pNext, 0 ); //!! Bookmark/Feld-Name
865 // //!! erstmal nicht
867 // ConvertFFileName( aPara, pFName ); //!! WW1 ????
868 aFName = URIHelper::SmartRel2Abs(
869 INetURLObject(rOut.GetBaseURL()), aFName );
871 String aName( String::CreateFromAscii(
872 RTL_CONSTASCII_STRINGPARAM( "WW" )));
873 SwSectionData * pSection = new SwSectionData( FILE_LINK_SECTION,
874 rOut.GetDoc().GetUniqueSectionName( &aStr ) );
875 pSection->SetLinkFileName( aFName );
876 pSection->SetProtectFlag( true );
877 rOut << SwFltSection( pSection );
878 rOut.EndItem( RES_FLTR_SECTION );
879 rOut.NextParagraph();
881 case 37: // page ref
882 pField = new SwGetRefField(
883 (SwGetRefFieldType*)rOut.GetSysFldType(RES_GETREFFLD),
884 sFormel, 0, 0, REF_PAGE);
885 break;
886 case 38: // ask command
888 pos = aStr.Search(' ');
889 String aName( aStr.Copy( 0, pos ));
890 aStr.Erase(0, pos );
891 aStr.Erase(0, 1);
892 if( !aName.Len() )
893 break;
895 SwFieldType* pFT = rOut.GetDoc().InsertFldType(
896 SwSetExpFieldType( &rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_STRING ) );
897 pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr );
898 ((SwSetExpField*)pField)->SetInputFlag( TRUE );
899 ((SwSetExpField*)pField)->SetSubType(nsSwExtendedSubType::SUB_INVISIBLE);
900 // pField.SetPromptText( aQ ); //!! fehlt noch
901 // aFld.SetPar2( aDef ); //!! dito
902 // das Ignorieren des Bookmarks ist nicht implementiert
904 case 39: // fillin command
905 pField = new SwInputField(
906 (SwInputFieldType*)rOut.GetSysFldType( RES_INPUTFLD ),
907 aEmptyStr, sFormel,
908 INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders )
909 break;
910 case 51: // macro button
912 pos = aStr.Search(' ');
913 String aName( aStr.Copy( 0, pos ));
914 aStr.Erase(0, pos );
915 aStr.Erase(0, 1);
916 if( !aName.Len() || !aStr.Len() )
917 break;
918 aName.InsertAscii( "StarOffice.Standard.Modul1.", 0 );
920 pField = new SwMacroField( (SwMacroFieldType*)
921 rOut.GetSysFldType( RES_MACROFLD ),
922 aName, aStr );
924 break;
925 case 55: // read tiff / or better: import anything
927 const sal_Unicode* pFormel = sFormel.GetBuffer();
928 const sal_Unicode* pDot = 0;
929 String sName;
930 while (*pFormel != '\0' && *pFormel != ' ')
932 // ab hier koennte eine extension kommen
933 if (*pFormel == '.')
934 pDot = pFormel;
935 else
936 // aha: wir waren bislang noch in dirs
937 if (*pFormel == '\\')
939 pDot = 0;
940 if (pFormel[1] == '\\')
941 pFormel++;
943 if (*pFormel != '\0')
944 sName += *pFormel++;
946 if( pDot )
948 String sExt;
949 while( *pDot != '\0' && *pDot != ' ')
950 sExt += *pDot++;
952 if( sExt.EqualsIgnoreCaseAscii( ".tiff" )
953 || sExt.EqualsIgnoreCaseAscii( ".bmp" )
954 || sExt.EqualsIgnoreCaseAscii( ".gif" )
955 || sExt.EqualsIgnoreCaseAscii( ".pcx" )
956 || sExt.EqualsIgnoreCaseAscii( ".pic" ))
957 rOut.AddGraphic( sName );
958 else
959 bKnown = FALSE;
961 else
962 bKnown = FALSE;
964 break;
965 default: // unknown
966 DBG_ASSERT(FALSE, "Ww1PlainText");
967 // unsupported:
968 case 1: // unknown
969 case 2: // possible bookmark
970 case 4: // index entry
971 // wwpar5: 1351/1454
972 case 5: // footnote ref
973 // pField = new SwGetRefField(
974 // (SwGetRefFieldType*)rDoc.GetSysFldType(RES_GETREFFLD),
975 // sFormel, REF_FOOTNOTE, 0, REF_BEGIN);
976 case 7: // if command
977 case 8: // create index
978 // wwpar5: 1351/1454
979 case 9: // table of contents entry
980 // wwpar5: 1351/1454
981 case 10: // style ref
982 case 11: // doc ref
983 case 12: // seq ref
984 case 13: // create table of contents
985 // wwpar5: 1351/1454
986 case 35: // literal text
987 // print merge:
988 case 40: // data command
989 case 41: // next command
990 case 42: // nextif command
991 case 43: // skipif command
992 case 44: // number of record
994 case 45: // dde ref
995 case 46: // dde auto ref
996 case 47: // glossary entry
997 case 48: // print char
998 case 49: // formula def
999 case 50: // goto button
1000 case 52: // auto number outline
1001 case 53: // auto number legal
1002 case 54: // auto number arabic
1003 bKnown = FALSE;
1004 break;
1006 if( bKnown || sErgebnis.EqualsAscii( "\270" ))
1007 this->sErgebnis.Erase();
1008 else
1009 this->sErgebnis = sErgebnis;
1011 else // oops: we are terribly wrong: skip this
1012 (*this)++;
1015 ULONG Ww1Fields::GetLength()
1017 // berechnet die laenge eines feldteiles. nicht mitgerechnet werden
1018 // die terminierenden zeichen im text (19, 20, 21) die beginn, trenner
1019 // und ende bedeuten.
1020 ULONG ulBeg = Where();
1021 ULONG ulEnd = Where(nPlcIndex+1);
1022 DBG_ASSERT(ulBeg<ulEnd, "Ww1Fields");
1023 return (ulEnd - ulBeg) - 1;
1026 /////////////////////////////////////////////////////////////////// Sep
1027 void Ww1Sep::Start(Ww1Shell& rOut, Ww1Manager& rMan)
1029 if (rMan.Where() >= Where())
1031 rOut.NextSection();
1032 SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
1033 W1_DOP& rDOP = rMan.GetDop().GetDOP();
1034 rOut.GetPageDesc().SetLandscape(rDOP.fWideGet());
1035 SwFmtFrmSize aSz(rFmt.GetFrmSize());
1036 aSz.SetWidth(rDOP.xaPageGet());
1037 aSz.SetHeight(rDOP.yaPageGet());
1038 rFmt.SetFmtAttr(aSz);
1039 SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(),
1040 rDOP.dxaRightGet(), 0, 0, RES_LR_SPACE);
1041 rFmt.SetFmtAttr(aLR);
1042 SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet(), RES_UL_SPACE);
1043 rFmt.SetFmtAttr(aUL);
1044 // sobald wir mit dem lesen der zeichen soweit sind, wo sep's
1045 // momentanes attribut beginnt, wird dieses attribut eingefuegt.
1046 // diese methode ist bei den meisten start/stop methoden der
1047 // memberklassen des managers identisch.
1048 BYTE* pByte = GetData();
1049 Ww1SprmSep aSprm(rFib, SVBT32ToUInt32(pByte + 2));
1050 aSprm.Start(rOut, rMan);
1051 aSprm.Stop(rOut, rMan);
1052 (*this)++;
1053 aHdd.Start(rOut, rMan);
1057 /////////////////////////////////////////////////////////////////// Pap
1058 void Ww1Pap::Start(Ww1Shell& rOut, Ww1Manager& rMan)
1060 if (rMan.Where() >= Where())
1062 BYTE* pByte;
1063 USHORT cb;
1064 // bereitstellen der zu startenden attribute
1065 if (FillStart(pByte, cb))
1067 Ww1SprmPapx aSprm(pByte, cb);
1068 // und ausgeben:
1069 aSprm.Start(rOut, rMan);
1071 (*this)++;
1075 void Ww1Pap::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
1077 if (rMan.Where() >= Where() || rMan.IsStopAll())
1079 BYTE* pByte;
1080 USHORT cb;
1081 if (FillStop(pByte, cb)){
1082 Ww1SprmPapx aSprm(pByte, cb);
1083 aSprm.Stop(rOut, rMan);
1084 }else{
1085 DBG_ASSERT( !nPlcIndex || rMan.IsStopAll(), "Pap-Attribut-Stop verloren" );
1086 // rMan.IsStopAll() ist nicht schoen.
1091 //////////////////////////////////////////////////////////////// W1_CHP
1093 // momentan laesst sich die ausgabe von W1CHPxen nicht nur per define
1094 // loesen....
1096 void W1_CHP::Out(Ww1Shell& rOut, Ww1Manager& rMan)
1098 if (fBoldGet())
1099 rOut << SvxWeightItem(
1100 rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
1101 if (fItalicGet())
1102 rOut << SvxPostureItem(
1103 rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL, RES_CHRATR_POSTURE);
1104 if (fStrikeGet())
1105 rOut << SvxCrossedOutItem(
1106 rOut.GetCrossedOut()?STRIKEOUT_NONE:STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT);
1107 if (fOutlineGet())
1108 rOut << SvxContourItem(!rOut.GetContour(), RES_CHRATR_CONTOUR);
1109 if (fSmallCapsGet())
1110 rOut << SvxCaseMapItem(
1111 rOut.GetCaseKapitaelchen()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_KAPITAELCHEN, RES_CHRATR_CASEMAP);
1112 if (fCapsGet())
1113 rOut << SvxCaseMapItem(
1114 rOut.GetCaseVersalien()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_VERSALIEN, RES_CHRATR_CASEMAP);
1115 if (fsHpsGet())
1116 rOut << SvxFontHeightItem(hpsGet() * 10, 100, RES_CHRATR_FONTSIZE);
1117 if (fsKulGet())
1118 switch (kulGet()) {
1119 case 0: {
1120 rOut << SvxUnderlineItem(UNDERLINE_NONE, RES_CHRATR_UNDERLINE) <<
1121 SvxWordLineModeItem(FALSE, RES_CHRATR_WORDLINEMODE);
1122 } break;
1123 default: DBG_ASSERT(FALSE, "Chpx");
1124 case 1: {
1125 rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
1126 } break;
1127 case 2: {
1128 rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE) <<
1129 SvxWordLineModeItem(TRUE, RES_CHRATR_WORDLINEMODE);
1130 } break;
1131 case 3: {
1132 rOut << SvxUnderlineItem(UNDERLINE_DOUBLE, RES_CHRATR_UNDERLINE);
1133 } break;
1134 case 4: {
1135 rOut << SvxUnderlineItem(UNDERLINE_DOTTED, RES_CHRATR_UNDERLINE);
1136 } break;
1139 if (fsIcoGet())
1140 switch(icoGet()) {
1141 default: DBG_ASSERT(FALSE, "Chpx");
1142 case 0: { rOut.EndItem(RES_CHRATR_COLOR); } break;
1143 case 1: { rOut << SvxColorItem(Color(COL_BLACK), RES_CHRATR_COLOR); } break;
1144 case 2: { rOut << SvxColorItem(Color(COL_LIGHTBLUE), RES_CHRATR_COLOR); } break;
1145 case 3: { rOut << SvxColorItem(Color(COL_LIGHTCYAN), RES_CHRATR_COLOR); } break;
1146 case 4: { rOut << SvxColorItem(Color(COL_LIGHTGREEN), RES_CHRATR_COLOR); } break;
1147 case 5: { rOut << SvxColorItem(Color(COL_LIGHTMAGENTA), RES_CHRATR_COLOR); } break;
1148 case 6: { rOut << SvxColorItem(Color(COL_LIGHTRED), RES_CHRATR_COLOR); } break;
1149 case 7: { rOut << SvxColorItem(Color(COL_YELLOW), RES_CHRATR_COLOR); } break;
1150 case 8: { rOut << SvxColorItem(Color(COL_WHITE), RES_CHRATR_COLOR); } break;
1152 if (fsSpaceGet()) {
1153 short sQps = qpsSpaceGet();
1154 if (sQps > 56)
1155 sQps = sQps - 64;
1156 rOut << SvxKerningItem(sQps, RES_CHRATR_KERNING);
1158 if (fsPosGet()) {
1159 if (hpsPosGet() == 0)
1160 rOut << SvxEscapementItem(SVX_ESCAPEMENT_OFF, 100, RES_CHRATR_ESCAPEMENT);
1161 else {
1162 short sHps = hpsPosGet();
1163 if (sHps > 128)
1164 sHps = sHps - 256;
1165 sHps *= 100;
1166 sHps /= 24;
1167 rOut << SvxEscapementItem(sHps, 100, RES_CHRATR_ESCAPEMENT);
1170 if (fsFtcGet()) {
1171 SvxFontItem aFont(rMan.GetFont(ftcGet()));
1172 rOut << aFont;
1176 /////////////////////////////////////////////////////////////////// Chp
1177 void Ww1Chp::Start(Ww1Shell& rOut, Ww1Manager& rMan)
1179 if (rMan.Where() >= Where())
1181 W1_CHP aChpx;
1182 if (FillStart(aChpx))
1184 aChpx.Out(rOut, rMan);
1185 if (aChpx.fcPicGet())
1187 Ww1Picture aPic(rMan.GetFib().GetStream(),
1188 aChpx.fcPicGet());
1189 if (!aPic.GetError())
1190 aPic.Out(rOut, rMan);
1193 (*this)++;
1197 void Ww1Chp::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
1199 if (rMan.Where() >= Where())
1201 W1_CHP aChpx;
1202 if (FillStop(aChpx))
1204 // zuerst alle toggle-flags
1205 if (aChpx.fBoldGet())
1206 rOut.EndItem(RES_CHRATR_WEIGHT);
1207 if (aChpx.fItalicGet())
1208 rOut.EndItem(RES_CHRATR_POSTURE);
1209 if (aChpx.fStrikeGet())
1210 rOut.EndItem(RES_CHRATR_CROSSEDOUT);
1211 if (aChpx.fOutlineGet())
1212 rOut.EndItem(RES_CHRATR_CONTOUR);
1213 if (aChpx.fSmallCapsGet() || aChpx.fCapsGet())
1214 rOut.EndItem(RES_CHRATR_CASEMAP);
1215 // dann alle zahl-werte, diese haben flags, wenn sie gesetzt
1216 // sind..................
1217 if (aChpx.fsHpsGet())
1218 rOut.EndItem(RES_CHRATR_FONTSIZE);
1219 if (aChpx.fsKulGet())
1220 rOut.EndItem(RES_CHRATR_UNDERLINE)
1221 .EndItem(RES_CHRATR_WORDLINEMODE);
1222 if (aChpx.fsIcoGet())
1223 rOut.EndItem(RES_CHRATR_COLOR);
1224 if (aChpx.fsSpaceGet())
1225 rOut.EndItem(RES_CHRATR_KERNING);
1226 if (aChpx.fsPosGet())
1227 rOut.EndItem(RES_CHRATR_ESCAPEMENT);
1228 if (aChpx.fsFtcGet())
1229 rOut.EndItem(RES_CHRATR_FONT);
1230 }else{
1231 DBG_ASSERT( !nPlcIndex, "Chp-Attribut-Stop verloren" );
1236 ///////////////////////////////////////////////////////////////// Style
1237 void Ww1Style::Out(Ww1Shell& rOut, Ww1Manager& rMan)
1239 // Zuerst Basis, damit Attribute des Basis-Styles erkannt werden
1240 // first: Base................................................
1241 if(pParent->GetStyle(stcBase).IsUsed() ) // Basis gueltig ?
1242 rOut.BaseStyle(stcBase);
1244 // next of all: CHP...............................................
1245 aChpx.Out(rOut, rMan);
1246 // Last: PAP.......................................................
1247 if (pPapx)
1248 pPapx->Start(rOut, rMan);
1251 ////////////////////////////////////////////////////////// Ww1PlainText
1253 // die Out() methoden von plaintext fuer den filter geben eine anzahl
1254 // zeichen aus auf die shell, einen string oder einen char, wieviel
1255 // zeichen ausgegeben werden, bestimmt ulEnd, das das ende bestimmt,
1256 // bis zudem ausgegeben wird. ausserdem beenden die methoden die
1257 // ausgabe bei kontrollzeichen.
1258 // diese sind definiert durch MinChar. alle zeichen mit wert darunter
1259 // gelten als kontroll- zeichen. dafuer gibts die methode IsChar, die
1260 // zurueckgibt, ob es sich um ein standard zeichen handelt. kommt ein
1261 // solches zeichen, wird dieses zeichen zurueckgegeben und die methode
1262 // beendet, auch wenn ulEnd noch nicht erreicht wurde. bei nutzung
1263 // also beachten, dasz wenn !IsChar(Out(...)) gilt, ulEnd unter
1264 // umstaenden nicht erreicht wurde. dann wurde das kontrollzeichen
1265 // zwar (weg-)gelesen, jedoch noch nicht ausgegeben.
1267 sal_Unicode Ww1PlainText::Out( Ww1Shell& rOut, ULONG& ulEnd )
1269 // gibt die zeichen bis ulEnd aus, es sei den es kommen sonderzeichen
1270 // die eine bedeutung haben wie absatzende oder seitenumbruch.
1271 if (ulEnd > Count())
1272 ulEnd = Count();
1273 while (ulSeek < ulEnd)
1275 sal_Unicode c = (*this)[ulSeek];
1276 (*this)++;
1277 if (Ww1PlainText::IsChar(c))
1278 rOut << c;
1279 else
1280 return c;
1282 return Ww1PlainText::MinChar;
1285 sal_Unicode Ww1PlainText::Out( String& rStr, ULONG ulEnd )
1287 // wie Out(Shell..., jedoch ausgabe auf einen string
1288 rStr.Erase();
1289 if (ulEnd > Count())
1290 ulEnd = Count();
1291 while (ulSeek < ulEnd)
1293 sal_Unicode c = (*this)[ulSeek];
1294 (*this)++;
1295 if( Ww1PlainText::IsChar(c) )
1296 rStr += c;
1297 else
1298 return c;
1300 return Ww1PlainText::MinChar;
1304 // hier eruebrigt sich ulEnd...oder?
1306 sal_Unicode Ww1PlainText::Out( sal_Unicode& rRead )
1308 rRead = (*this)[ulSeek];
1309 (*this)++;
1310 return rRead;
1313 /////////////////////////////////////////////////////////// Ww1SprmPapx
1315 void Ww1SprmPapx::Start(Ww1Shell& rOut, Ww1Manager& rMan)
1317 if( !rMan.IsInStyle() ){ // Innerhalb Style gehts ueber die
1318 // normalen Attribute
1319 if (!rOut.IsInFly()
1320 && !rOut.IsInTable() // Nicht innerhalb Tabelle!
1321 && ( rMan.HasPPc() || rMan.HasPDxaAbs())){ // Fly-Start
1322 rOut.BeginFly(); // eAnchor );
1324 if (!rOut.IsInTable() && rMan.HasInTable())
1326 rOut.BeginTable();
1328 rOut.SetStyle(aPapx.stcGet());
1330 Ww1Sprm::Start(rOut, rMan);
1333 void Ww1SprmPapx::Stop(Ww1Shell& rOut, Ww1Manager& rMan)
1335 Ww1Sprm::Stop(rOut, rMan);
1337 if( !rMan.IsInStyle() ) // Innerhalb Style gehts ueber die
1338 { // normalen Attribute
1339 if (rOut.IsInTable() &&( rMan.IsStopAll() || !rMan.HasInTable()))
1340 rOut.EndTable();
1342 if( rOut.IsInFly() &&
1343 ( rMan.IsStopAll()
1344 || ( !rMan.HasPPc() && !rMan.HasPDxaAbs() // Fly-Ende
1345 && !rOut.IsInTable()))) // Nicht innerhalb Tabelle!
1346 rOut.EndFly();
1350 ///////////////////////////////////////////////////////////////// Fonts
1351 SvxFontItem Ww1Fonts::GetFont(USHORT nFCode)
1353 // erzeugen eine fonts im sw-sinne aus den word-strukturen
1354 FontFamily eFamily = FAMILY_DONTKNOW;
1355 String aName;
1356 FontPitch ePitch = PITCH_DONTKNOW;
1357 rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
1358 switch (nFCode)
1360 // In the Winword 1.x format, the names of the first three fonts were
1361 // omitted from the table and assumed to be "Tms Rmn" (for ftc = 0),
1362 // "Symbol", and "Helv"
1363 case 0:
1364 eFamily = FAMILY_ROMAN;
1365 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Tms Rmn" ));
1366 ePitch = PITCH_VARIABLE;
1367 eCharSet = RTL_TEXTENCODING_MS_1252;
1368 break;
1369 case 1:
1370 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Symbol" ));
1371 ePitch = PITCH_VARIABLE;
1372 eCharSet = RTL_TEXTENCODING_SYMBOL;
1373 break;
1374 case 2:
1375 eFamily = FAMILY_SWISS;
1376 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helv" ));
1377 ePitch = PITCH_VARIABLE;
1378 eCharSet = RTL_TEXTENCODING_MS_1252;
1379 break;
1380 default:
1382 W1_FFN* pF = GetFFN(nFCode - 3);
1383 if (pF != 0)
1385 // Fontname .........................................
1386 aName = String( (sal_Char*)pF->szFfnGet(),
1387 RTL_TEXTENCODING_MS_1252 );
1388 // Pitch .............................................
1389 static FontPitch ePitchA[] =
1391 PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, PITCH_DONTKNOW
1393 ePitch = ePitchA[pF->prgGet()];
1394 // CharSet ...........................................
1395 eCharSet = RTL_TEXTENCODING_MS_1252;
1396 if (aName.EqualsIgnoreCaseAscii("Symbol")
1397 || aName.EqualsIgnoreCaseAscii("Symbol Set")
1398 || aName.EqualsIgnoreCaseAscii("Wingdings")
1399 || aName.EqualsIgnoreCaseAscii("ITC Zapf Dingbats") )
1400 eCharSet = RTL_TEXTENCODING_SYMBOL;
1401 // FontFamily ........................................
1402 USHORT b = pF->ffGet();
1403 static FontFamily eFamilyA[] =
1405 FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
1406 FAMILY_SCRIPT, FAMILY_DECORATIVE
1408 if (b < sizeof(eFamilyA))
1409 eFamily = eFamilyA[b];
1411 else
1413 DBG_ASSERT(FALSE, "WW1Fonts::GetFont: Nicht existenter Font !");
1414 eFamily = FAMILY_SWISS;
1415 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helv" ));
1416 ePitch = PITCH_VARIABLE;
1417 eCharSet = RTL_TEXTENCODING_MS_1252;
1420 break;
1422 // Extrawurst Hypo
1423 if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO )
1424 && ( aName.EqualsIgnoreCaseAscii("Helv")
1425 || aName.EqualsIgnoreCaseAscii("Helvetica") ) )
1427 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica Neue" ));
1428 if (eFamily==FAMILY_DONTKNOW)
1429 eFamily = FAMILY_SWISS;
1431 else
1433 // VCL matcht die Fonts selber
1434 // allerdings passiert bei Helv, Tms Rmn und System Monospaced
1435 // Scheisse, so dass diese ersetzt werden muessen.
1436 // Nach TH sollen diese durch feste Werte ersetzt werden,
1437 // also nicht ueber System::GetStandardFont, damit keine
1438 // Namenslisten auftauchen ( Dieses koennte den User verwirren )
1439 if( aName.EqualsIgnoreCaseAscii("Helv"))
1441 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Helvetica" ));
1442 if (eFamily==FAMILY_DONTKNOW)
1443 eFamily = FAMILY_SWISS;
1445 else if (aName.EqualsIgnoreCaseAscii("Tms Rmn"))
1447 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Times New Roman" ));
1448 if (eFamily==FAMILY_DONTKNOW)
1449 eFamily = FAMILY_ROMAN;
1451 else if (aName.EqualsIgnoreCaseAscii("System Monospaced") )
1453 aName.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "Courier" ));
1454 ePitch = PITCH_FIXED;
1457 // nun koennen wir den font basteln: .........................
1458 return SvxFontItem(eFamily, aName, aEmptyStr, ePitch, eCharSet, RES_CHRATR_FONT);
1461 /////////////////////////////////////////////////////////////////// Dop
1462 void Ww1Dop::Out(Ww1Shell& rOut)
1464 //~ mdt: fehlt
1465 // aDop.fWidowControlGet(); // keine Absatztrennung fuer einzelne Zeilen
1466 long nDefTabSiz = aDop.dxaTabGet();
1467 if (nDefTabSiz < 56)
1468 nDefTabSiz = 709;
1470 // wir wollen genau einen DefaultTab
1471 SvxTabStopItem aNewTab(1, USHORT(nDefTabSiz), SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP);
1472 ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
1473 rOut.GetDoc().GetAttrPool().SetPoolDefaultItem( aNewTab); //~ mdt: besser (GetDoc)
1475 SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
1476 W1_DOP& rDOP = GetDOP();
1477 rOut.GetPageDesc().SetLandscape(rDOP.fWideGet());
1478 SwFmtFrmSize aSz(rFmt.GetFrmSize());
1479 aSz.SetWidth(rDOP.xaPageGet());
1480 aSz.SetHeight(rDOP.yaPageGet());
1481 rFmt.SetFmtAttr(aSz);
1482 SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(),
1483 rDOP.dxaRightGet(), 0, 0, RES_LR_SPACE);
1484 rFmt.SetFmtAttr(aLR);
1485 SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet(), RES_UL_SPACE);
1486 rFmt.SetFmtAttr(aUL);
1488 SwFtnInfo aInfo;
1489 aInfo = rOut.GetDoc().GetFtnInfo(); // Copy-Ctor privat
1490 // wo positioniert ? ( 0 == Section, 1 == Page,
1491 // 2 == beim Text -> Page, 3 == Doc )
1492 switch( rDOP.fpcGet() ){
1493 case 1:
1494 case 2: aInfo.ePos = FTNPOS_PAGE; break;
1495 default: aInfo.ePos = FTNPOS_CHAPTER; break;
1497 // aInfo.eNum = ( rDOP.fFtnRestartGet() ) ? FTNNUM_CHAPTER : FTNNUM_DOC;
1498 // Da Sw unter Chapter anscheinend was anderes versteht als PMW
1499 // hier also immer Doc !
1500 aInfo.eNum = FTNNUM_DOC;
1501 // wie neu nummerieren ?
1502 // SW-UI erlaubt Nummer nur bei FTNNUM_DOC
1503 if( rDOP.nFtnGet() > 0 && aInfo.eNum == FTNNUM_DOC )
1504 aInfo.nFtnOffset = rDOP.nFtnGet() - 1;
1505 rOut.GetDoc().SetFtnInfo( aInfo );
1509 ///////////////////////////////////////////////////////////////// Assoc
1510 void Ww1Assoc::Out(Ww1Shell& rOut)
1512 //~ mdt: fehlen: FileNext, Dot, DataDoc, HeaderDoc, Criteria1,
1513 // Criteria2, Criteria3, Criteria4, Criteria5, Criteria6, Criteria7
1514 SwDocShell *pDocShell(rOut.GetDoc().GetDocShell());
1515 DBG_ASSERT(pDocShell, "no SwDocShell");
1516 if (pDocShell) {
1517 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1518 pDocShell->GetModel(), uno::UNO_QUERY_THROW);
1519 uno::Reference<document::XDocumentProperties> xDocProps(
1520 xDPS->getDocumentProperties());
1521 DBG_ASSERT(xDocProps.is(), "DocumentProperties is null");
1522 if (xDocProps.is()) {
1523 xDocProps->setTitle( GetStr(Title) );
1524 xDocProps->setSubject( GetStr(Subject) );
1525 xDocProps->setDescription( GetStr(Comments) );
1526 xDocProps->setKeywords(
1527 ::comphelper::string::convertCommaSeparated( GetStr(KeyWords) ) );
1528 xDocProps->setAuthor( GetStr(Author) );
1529 xDocProps->setModifiedBy( GetStr(LastRevBy) );
1534 //////////////////////////////////////////////////////////// StyleSheet
1535 void Ww1StyleSheet::OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc)
1537 switch (stc){
1538 case 222: // Null
1539 rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
1540 rOut << SvxFontItem(rMan.GetFont(2));
1541 break;
1542 case 223: // annotation reference
1543 rOut << SvxFontHeightItem(160, 100, RES_CHRATR_FONTSIZE);
1544 break;
1545 case 224: // annotation text
1546 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1547 break;
1548 case 225: // table of contents 8
1549 case 226: // table of contents 7
1550 case 227: // table of contents 6
1551 case 228: // table of contents 5
1552 case 229: // table of contents 4
1553 case 230: // table of contents 3
1554 case 231: // table of contents 2
1555 case 232: // table of contents 1
1556 rOut << SvxLRSpaceItem(( 232 - stc ) * 720, 720, 0, 0, RES_LR_SPACE);
1557 // Tabulatoren fehlen noch !
1558 break;
1559 case 233: // index 7
1560 case 234: // und index 6
1561 case 235: // und index 5
1562 case 236: // und index 4
1563 case 237: // und index 3
1564 case 238: // und index 2
1565 rOut << SvxLRSpaceItem(( 239 - stc ) * 360, 0, 0, 0, RES_LR_SPACE);
1566 break;
1567 case 239: // index 1
1568 break;
1569 case 240: // line number
1570 break;
1571 case 241: // index heading
1572 break;
1573 case 242: // footer
1574 case 243:{ // ... und header
1575 SvxTabStopItem aAttr(RES_PARATR_TABSTOP);
1576 SvxTabStop aTabStop;
1577 aTabStop.GetTabPos() = 4535; // 8 cm
1578 aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
1579 aAttr.Insert( aTabStop );
1580 aTabStop.GetTabPos() = 9071; // 16 cm
1581 aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
1582 aAttr.Insert( aTabStop );
1583 rOut << aAttr;
1585 break;
1586 case 244: // footnote reference
1587 rOut << SvxFontHeightItem(160, 100, RES_CHRATR_FONTSIZE);
1588 rOut << SvxEscapementItem(6 * 100 / 24, 100, RES_CHRATR_ESCAPEMENT);
1589 break;
1590 case 245: // footnote text
1591 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1592 break;
1593 case 246: // heading 9
1594 case 247: // und heading 8
1595 case 248: // und heading 7
1596 rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
1597 rOut << SvxPostureItem(
1598 rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL, RES_CHRATR_POSTURE);
1599 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1600 break;
1601 case 249: // heading 6
1602 rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
1603 rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
1604 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1605 break;
1606 case 250: // heading 5
1607 rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
1608 rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
1609 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1610 break;
1611 case 251: // heading 4
1612 rOut << SvxLRSpaceItem(360, 0, 0, 0, RES_LR_SPACE);
1613 rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
1614 rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
1615 break;
1616 case 252: // heading 3
1617 rOut << SvxLRSpaceItem(360, 0, 0, 0, RES_LR_SPACE);
1618 rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
1619 rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
1620 break;
1621 case 253: // heading 2
1622 rOut << SvxULSpaceItem(120, 0, RES_UL_SPACE);
1623 rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
1624 rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
1625 rOut << SvxFontItem(rMan.GetFont(2));
1626 break;
1627 case 254: // heading 1
1628 rOut << SvxULSpaceItem(240, 0, RES_UL_SPACE);
1629 rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
1630 rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
1631 rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
1632 rOut << SvxFontItem(rMan.GetFont(2));
1633 break;
1634 case 255: // Normal indent
1635 rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
1636 break;
1637 case 0: // Normal
1638 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1639 break;
1640 default: // selbstdefiniert
1641 rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
1642 break;
1646 void Ww1StyleSheet::OutOne(Ww1Shell& rOut, Ww1Manager& rMan, USHORT stc)
1648 const RES_POOL_COLLFMT_TYPE RES_NONE = RES_POOLCOLL_DOC_END;
1649 RES_POOL_COLLFMT_TYPE aType = RES_NONE;
1650 // aType = RES_POOLCOLL_JAKETADRESS; break;
1651 // aType = RES_POOLCOLL_LISTS_BEGIN; break;
1652 // aType = RES_POOLCOLL_SENDADRESS; break;
1653 // aType = RES_POOLCOLL_SIGNATURE; break;
1654 // aType = RES_POOLCOLL_TEXT_NEGIDENT; break;
1655 // aType = RES_POOLCOLL_TOX_IDXH; break;
1656 switch (stc)
1658 case 222: // Null
1659 aType = RES_POOLCOLL_TEXT; break; //???
1660 case 223: // annotation reference
1661 break;
1662 case 224: // annotation text
1663 break;
1664 case 225: // table of contents 8
1665 aType = RES_POOLCOLL_TOX_CNTNT8; break;
1666 case 226: // table of contents 7
1667 aType = RES_POOLCOLL_TOX_CNTNT7; break;
1668 case 227: // table of contents 6
1669 aType = RES_POOLCOLL_TOX_CNTNT6; break;
1670 case 228: // table of contents 5
1671 aType = RES_POOLCOLL_TOX_CNTNT5; break;
1672 case 229: // table of contents 4
1673 aType = RES_POOLCOLL_TOX_CNTNT4; break;
1674 case 230: // table of contents 3
1675 aType = RES_POOLCOLL_TOX_CNTNT3; break;
1676 case 231: // table of contents 2
1677 aType = RES_POOLCOLL_TOX_CNTNT2; break;
1678 case 232: // table of contents 1
1679 aType = RES_POOLCOLL_TOX_CNTNT1; break;
1680 case 233: // index 7
1681 break;
1682 case 234: // index 6
1683 break;
1684 case 235: // index 5
1685 break;
1686 case 236: // index 4
1687 break;
1688 case 237: // index 3
1689 aType = RES_POOLCOLL_TOX_IDX3; break;
1690 case 238: // index 2
1691 aType = RES_POOLCOLL_TOX_IDX2; break;
1692 case 239: // index 1
1693 aType = RES_POOLCOLL_TOX_IDX1; break;
1694 case 240: // line number
1695 break;
1696 case 241: // index heading
1697 break;
1698 case 242: // footer
1699 aType = RES_POOLCOLL_FOOTER; break;
1700 case 243: // header
1701 aType = RES_POOLCOLL_HEADER; break;
1702 case 244: // footnote reference
1703 break;
1704 case 245: // footnote text
1705 aType = RES_POOLCOLL_FOOTNOTE; break;
1706 case 246: // heading 9
1707 break;
1708 case 247: // heading 8
1709 break;
1710 case 248: // heading 7
1711 break;
1712 case 249: // heading 6
1713 break;
1714 case 250: // heading 5
1715 aType = RES_POOLCOLL_HEADLINE5; break;
1716 case 251: // heading 4
1717 aType = RES_POOLCOLL_HEADLINE4; break;
1718 case 252: // heading 3
1719 aType = RES_POOLCOLL_HEADLINE3; break;
1720 case 253: // heading 2
1721 aType = RES_POOLCOLL_HEADLINE2; break;
1722 case 254: // heading 1
1723 aType = RES_POOLCOLL_HEADLINE1; break;
1724 case 255: // Normal indent
1725 aType = RES_POOLCOLL_TEXT_IDENT; break;
1726 case 0: // Normal
1727 aType = RES_POOLCOLL_STANDARD; break;
1728 // aType = RES_POOLCOLL_TEXT; break; // Das ist "textkoerper"
1730 if (aType == RES_NONE)
1731 rOut.BeginStyle(stc, GetStyle(stc).GetName() );
1732 else
1733 rOut.BeginStyle(stc, aType);
1734 OutDefaults(rOut, rMan, stc);
1735 GetStyle(stc).Out(rOut, rMan);
1736 rOut.EndStyle();
1737 // rMan.SetInApo(FALSE);
1739 // OutOneWithBase() liest einen Style mit OutOne() einen Style ein
1740 // Jedoch liest er, wenn noch nicht geschehen, den Basisstyle rekursiv ein
1741 void Ww1StyleSheet::OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan,
1742 USHORT stc, BYTE* pbStopRecur )
1744 // SH: lineares Einlesen ist Scheisse, da dann BasedOn nicht gesetzt
1745 // werden kann und ausserdem Toggle- und Modify-Attrs (z.B. Tabs ) nicht gehen.
1747 Ww1Style& rSty = GetStyle(stc);
1748 USHORT nBase = rSty.GetnBase();
1749 if( nBase != stc
1750 && !rOut.IsStyleImported( nBase )
1751 && GetStyle(nBase).IsUsed()
1752 && !pbStopRecur[nBase] ){
1754 pbStopRecur[nBase] = 1;
1755 OutOneWithBase( rOut, rMan, nBase, pbStopRecur ); // Rekursiv
1757 OutOne( rOut, rMan, stc );
1760 void Ww1StyleSheet::Out(Ww1Shell& rOut, Ww1Manager& rMan)
1762 USHORT stc;
1763 BYTE bStopRecur[256];
1764 memset( bStopRecur, FALSE, sizeof(bStopRecur) );
1766 // 1. Durchlauf: Styles mit Basisstyles rekursiv
1767 for (stc=0;stc<Count();stc++)
1768 if (GetStyle(stc).IsUsed() && !rOut.IsStyleImported( stc ) )
1769 OutOneWithBase( rOut, rMan, stc, bStopRecur );
1771 // 2. Durchlauf: Follow-Styles
1772 for (stc=0;stc<Count();stc++){
1773 Ww1Style& rSty = GetStyle(stc);
1774 if ( rSty.IsUsed() ){
1775 USHORT nNext = rSty.GetnNext();
1776 if( nNext != stc && GetStyle(nNext).IsUsed() )
1777 rOut.NextStyle( stc, nNext );
1782 ////////////////////////////////////////////////////////////// Picture
1783 static ULONG GuessPicSize(W1_PIC* pPic)
1785 USHORT maxx = pPic->mfp.xExtGet();
1786 USHORT padx = ((maxx + 7) / 8) * 8;
1787 USHORT maxy = pPic->mfp.yExtGet();
1788 return 120L + (ULONG)padx * maxy;
1792 // folgende methode schreibt eine windows-.BMP-datei aus einem
1793 // embeddeten bild in ww-1 dateien
1794 // gelesen wird 4-bit format, geschrieben jedoch 8-bit.
1796 void Ww1Picture::WriteBmp(SvStream& rOut)
1798 long nSize = pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb));
1799 BYTE* p = pPic->rgbGet();
1800 USHORT maxx = pPic->mfp.xExtGet();
1801 USHORT padx = ((maxx + 7) / 8) * 8;
1802 USHORT maxy = pPic->mfp.yExtGet();
1804 /*USHORT unknown1 = SVBT16ToShort(p);*/ p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
1805 /*USHORT unknown2 = SVBT16ToShort(p);*/ p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
1806 #if OSL_DEBUG_LEVEL > 1
1807 USHORT x = SVBT16ToShort(p);
1808 (void) x;
1809 #endif
1810 p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
1811 #if OSL_DEBUG_LEVEL > 1
1812 USHORT y = SVBT16ToShort(p);
1813 (void) y;
1814 #endif
1815 p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
1816 #if OSL_DEBUG_LEVEL > 1
1817 USHORT planes = SVBT16ToShort(p);
1818 (void) planes;
1819 #endif
1820 p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
1821 #if OSL_DEBUG_LEVEL > 1
1822 USHORT bitcount = SVBT16ToShort(p);
1823 (void) bitcount;
1824 #endif
1825 p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
1827 #if OSL_DEBUG_LEVEL > 1
1828 DBG_ASSERT(x==maxx, "Ww1Picture");
1829 DBG_ASSERT(y==maxy, "Ww1Picture");
1830 DBG_ASSERT(planes==1, "Ww1Picture");
1831 DBG_ASSERT(bitcount==4, "Ww1Picture");
1832 #endif
1834 DBG_ASSERT(16*3+padx*maxy/2==nSize, "Ww1Picture");
1836 SVBT32 tmpLong;
1837 SVBT16 tmpShort;
1838 SVBT8 tmpByte;
1839 #define wLong(n) \
1840 UInt32ToSVBT32(n, tmpLong); \
1841 if ((rOut.Write(tmpLong, sizeof(SVBT32))) != sizeof(SVBT32)) goto error;
1842 #define wShort(n) \
1843 ShortToSVBT16(n, tmpShort); \
1844 if ((rOut.Write(tmpShort, sizeof(SVBT16))) != sizeof(SVBT16)) goto error;
1845 #define wByte(n) \
1846 ByteToSVBT8(n, tmpByte); \
1847 if ((rOut.Write(tmpByte, sizeof(SVBT8))) != sizeof(SVBT8)) goto error;
1848 wByte('B'); wByte('M');
1849 wLong(54 + 4 * 16 + padx * maxy);
1850 wLong(0);
1851 wLong(54 + 4 * 16);
1852 wLong(40);
1853 wLong(maxx);
1854 wLong(maxy);
1855 wShort(1);
1856 wShort(8);
1857 wLong(0);
1858 wLong(0);
1859 wLong(0);
1860 wLong(0);
1861 wLong(16);
1862 wLong(16);
1863 USHORT i;
1864 for (i=0;nSize>0&&i<16;i++)
1866 wByte(*p);
1867 p++;
1868 nSize -= sizeof(BYTE);
1869 wByte(*p);
1870 p++;
1871 nSize -= sizeof(BYTE);
1872 wByte(*p);
1873 p++;
1874 nSize -= sizeof(BYTE);
1875 wByte(0);
1877 DBG_ASSERT(padx*maxy/2==nSize, "Ww1Picture");
1878 USHORT j;
1879 #if 1
1881 BYTE* pBuf = new BYTE[padx];
1882 for (j=0;nSize>0&&j<maxy;j++)
1884 BYTE* q = pBuf;
1885 for (i=0;nSize>0&&i<maxx;i+=2)
1887 *q++ = *p>>4;
1888 *q++ = *p&0xf;
1889 p++;
1890 nSize -= sizeof(BYTE);
1892 for (;i<padx;i+=2)
1894 *q++ = 0;
1895 p++;
1896 nSize -= sizeof(BYTE);
1898 if(rOut.Write(pBuf, padx) != padx){
1899 delete [] pBuf;
1900 goto error;
1903 delete [] pBuf;
1905 #else
1906 for (j=0;nSize>0&&j<maxy;j++)
1908 for (i=0;nSize>0&&i<maxx;i+=2)
1910 wByte(*p>>4);
1911 wByte(*p&0xf);
1912 p++;
1913 nSize -= sizeof(BYTE);
1915 for (;i<padx;i+=2)
1917 wByte(0);
1918 p++;
1919 nSize -= sizeof(BYTE);
1922 #endif
1923 DBG_ASSERT(nSize==0, "Ww1Picture");
1924 #undef wLong
1925 #undef wShort
1926 #undef wByte
1927 rOut.Seek(0);
1928 return;
1929 error:
1933 void Ww1Picture::Out(Ww1Shell& rOut, Ww1Manager& /*rMan*/)
1935 Graphic* pGraphic = 0;
1936 USHORT mm;
1937 switch (mm = pPic->mfp.mmGet())
1939 case 8: // embedded metafile
1941 SvMemoryStream aOut(8192, 8192);
1942 aOut.Write(pPic->rgbGet(), pPic->lcbGet() -
1943 (sizeof(*pPic)-sizeof(pPic->rgb)));
1944 aOut.Seek(0);
1945 GDIMetaFile aWMF;
1946 if (ReadWindowMetafile( aOut, aWMF, NULL ) && aWMF.GetActionCount() > 0)
1948 aWMF.SetPrefMapMode(MapMode(MAP_100TH_MM));
1949 Size aOldSiz(aWMF.GetPrefSize());
1950 Size aNewSiz(pPic->mfp.xExtGet(), pPic->mfp.yExtGet());
1951 Fraction aFracX(aNewSiz.Width(), aOldSiz.Width());
1952 Fraction aFracY(aNewSiz.Height(), aOldSiz.Height());
1953 aWMF.Scale(aFracX, aFracY);
1954 aWMF.SetPrefSize(aNewSiz);
1955 pGraphic = new Graphic(aWMF);
1957 break;
1959 case 94: // embedded name SH:??? Was denn nun ? Embeddet oder Name ?
1960 case 98: // TIFF-Name
1962 String aDir( (sal_Char*)pPic->rgbGet(),
1963 (USHORT)(pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb))),
1964 RTL_TEXTENCODING_MS_1252 );
1965 //SvFileStream aOut(aDir, STREAM_READ|STREAM_WRITE|STREAM_TRUNC);
1966 rOut.AddGraphic( aDir );
1968 break;
1969 case 97: // embedded bitmap
1970 // case 99: // SH: bei meinem BspDoc 41738.doc auch embedded Bitmap,
1971 // aber leider anderes Format
1973 ULONG nSiz = GuessPicSize(pPic);
1974 SvMemoryStream aOut(nSiz, 8192);
1975 WriteBmp(aOut);
1976 Bitmap aBmp;
1977 aOut >> aBmp;
1978 pGraphic = new Graphic(aBmp);
1980 default:
1981 DBG_ASSERT(pPic->mfp.mmGet() == 97, "Ww1Picture");
1983 if (pGraphic)
1984 rOut << *pGraphic;
1987 ////////////////////////////////////////////////////////// HeaderFooter
1988 void Ww1HeaderFooter::Start(Ww1Shell& rOut, Ww1Manager& rMan)
1990 // wird sowieso nur bei SEPs aufgerufen, keine weitere pruefung
1991 // noetig:
1992 if (!rMan.Pushed())
1994 while ((*this)++)
1995 switch (eHeaderFooterMode)
1997 case FtnSep:
1998 break;
1999 case FtnFollowSep:
2000 break;
2001 case FtnNote:
2002 break;
2003 case EvenHeadL:
2004 break;
2005 case OddHeadL:
2007 ULONG begin = 0;
2008 ULONG end = 0;
2009 if (FillOddHeadL(begin, end))
2011 Ww1HddText* pText = new Ww1HddText(rMan.GetFib());
2012 pText->Seek(begin);
2013 pText->SetCount(end-begin);
2014 rOut.BeginHeader();
2015 rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin,
2016 new Ww1HeaderFooterFields(rMan.GetFib()));
2017 rOut << rMan;
2018 rMan.Pop();
2019 rOut.EndHeaderFooter();
2020 return;
2023 break;
2024 case EvenFootL:
2025 break;
2026 case OddFootL:
2028 ULONG begin = 0;
2029 ULONG end = 0;
2030 if (FillOddFootL(begin, end))
2032 Ww1HddText* pText = new Ww1HddText(rMan.GetFib());
2033 pText->Seek(begin);
2034 pText->SetCount(end-begin);
2035 rOut.BeginFooter();
2036 rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin,
2037 new Ww1HeaderFooterFields(rMan.GetFib()));
2038 rOut << rMan;
2039 rMan.Pop();
2040 rOut.EndHeaderFooter();
2041 return;
2044 break;
2045 case FirstHeadL:
2046 break;
2047 default:
2048 break;
2053 void Ww1HeaderFooter::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
2055 if (!rMan.Pushed() && eHeaderFooterMode != None
2056 // && rMan.GetText().Where() >= rMan.GetText().Count()
2059 Start(rOut, rMan);