LCOV - code coverage report
Current view: top level - sw/source/filter/ww1 - w1filter.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 1050 0.0 %
Date: 2014-04-11 Functions: 0 41 0.0 %
Legend: Lines: hit not hit

          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             : #include <hintids.hxx>
      21             : #include <tools/solar.h>
      22             : #include <comphelper/string.hxx>
      23             : #include <editeng/paperinf.hxx>
      24             : #include <vcl/graphicfilter.hxx>
      25             : #include <vcl/graph.hxx>
      26             : #include <vcl/wmf.hxx>
      27             : #include <editeng/fontitem.hxx>
      28             : #include <editeng/lrspitem.hxx>
      29             : #include <editeng/ulspitem.hxx>
      30             : #include <editeng/wghtitem.hxx>
      31             : #include <editeng/postitem.hxx>
      32             : #include <editeng/crossedoutitem.hxx>
      33             : #include <editeng/contouritem.hxx>
      34             : #include <editeng/cmapitem.hxx>
      35             : #include <editeng/fhgtitem.hxx>
      36             : #include <editeng/udlnitem.hxx>
      37             : #include <editeng/wrlmitem.hxx>
      38             : #include <editeng/colritem.hxx>
      39             : #include <editeng/kernitem.hxx>
      40             : #include <editeng/escapementitem.hxx>
      41             : #include <editeng/tstpitem.hxx>
      42             : #include <svl/urihelper.hxx>
      43             : #include <fmtfsize.hxx>
      44             : #include <doc.hxx>
      45             : #include <pam.hxx>
      46             : #include <ndtxt.hxx>
      47             : #include <pagedesc.hxx>
      48             : #include <flddat.hxx>
      49             : #include <reffld.hxx>
      50             : #include <expfld.hxx>
      51             : #include <docufld.hxx>
      52             : #include <ftninfo.hxx>
      53             : #include <section.hxx>
      54             : #include <fltini.hxx>
      55             : #include <w1par.hxx>
      56             : #include <docsh.hxx>
      57             : #include <swerror.h>
      58             : #include <mdiexp.hxx>
      59             : #include <statstr.hrc>
      60             : #include <stdio.h>
      61             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      62             : #include <com/sun/star/document/XDocumentProperties.hpp>
      63             : #include <vcl/dibtools.hxx>
      64             : 
      65             : #define MAX_FIELDLEN 64000
      66             : 
      67             : using namespace css;
      68             : using namespace nsSwDocInfoSubType;
      69             : 
      70             : // The methods operator<<, Out, Start and Stop are to be used like
      71             : // this: If possible, information from the document is transferred to
      72             : // the shell with
      73             : //   operator<<()
      74             : // If additional parameters are required, the method
      75             : //   Out()
      76             : // needs to be used. The methods for marking a range (attribute range,
      77             : // for example), are
      78             : //   Start(), Stop()
      79             : // This module contains all of these methods. It is necessary for the
      80             : // filter, but not for the dumper, with one exception though: the
      81             : // module also contains methods, which are useless for the dumper, for
      82             : // example because they operate on sv structures like GetFont() does on
      83             : // SvxFontItem.
      84             : 
      85             : // Manager
      86           0 : Ww1Shell& operator <<(Ww1Shell& rOut, Ww1Manager& This)
      87             : {
      88             :     // prohibit action in case of recursive call
      89           0 :     if (!This.Pushed())
      90             :     {
      91             :         {
      92             :             // is only needed temporarily
      93           0 :             This.SetInStyle( true );
      94           0 :             Ww1StyleSheet(This.aFib).Out(rOut, This);
      95           0 :             This.SetInStyle( false );
      96             :         }
      97             :         {
      98             :             // this one, too
      99           0 :             Ww1Assoc(This.aFib).Out(rOut);
     100             :         }
     101           0 :         This.aDop.Out(rOut);
     102             :         // Decide now how page templates will be created
     103           0 :         if (This.GetSep().Count() <= 1)
     104           0 :             rOut.SetUseStdPageDesc();
     105             :     }
     106             :     // and now the actual dok
     107           0 :     sal_Unicode cUnknown = ' ';
     108           0 :     while (*This.pSeek < This.pDoc->Count())
     109             :     {
     110             :         // output the ProgressState only for main text, because we
     111             :         // cannot determine the correct value otherwise
     112           0 :         if (!This.Pushed())
     113           0 :             ::SetProgressState(This.Where() * 100 / This.pDoc->Count(),
     114           0 :              rOut.GetDoc().GetDocShell());
     115             :         // Here, attributes and characters get pumped into the shell
     116             :         // alternatingly. The positions get incremented by reading
     117             :         // chars from the manager. First, the attributes:
     118           0 :         This.Out(rOut, cUnknown);
     119             :         // The text document pDoc is a Ww1PlainText, whose Out()
     120             :         // method outputs until the next special character or the
     121             :         // requested number of characters has been reached.
     122           0 :         cUnknown = This.pDoc->Out(rOut, *This.pSeek);
     123             :     }
     124           0 :     This.SetStopAll(true);
     125           0 :     This.OutStop(rOut, cUnknown);   // So that attributes get closed at the end
     126           0 :     This.SetStopAll(false);
     127           0 :     return rOut;
     128             : }
     129             : 
     130           0 : void Ww1Manager::OutStop(Ww1Shell& rOut, sal_Unicode cUnknown)
     131             : {
     132             :     // bookmarks don't need to be ended?
     133           0 :     if (pFld)
     134           0 :         pFld->Stop(rOut, *this, cUnknown);
     135           0 :     if (!Pushed())
     136           0 :         aFtn.Stop(rOut, *this, cUnknown);
     137             :     if (true)
     138           0 :         aChp.Stop(rOut, *this, cUnknown);
     139             :     if (true)
     140           0 :         aPap.Stop(rOut, *this, cUnknown);
     141           0 :     if (!Pushed())
     142           0 :         aSep.Stop(rOut, *this, cUnknown);
     143           0 : }
     144             : 
     145           0 : void Ww1Manager::OutStart( Ww1Shell& rOut )
     146             : {
     147             :     // start all attributes which need it
     148           0 :     if (!Pushed())
     149           0 :         aSep.Start(rOut, *this);
     150             :     if (true)
     151           0 :         aPap.Start(rOut, *this);
     152             :     if (true)
     153           0 :         aChp.Start(rOut, *this);
     154           0 :     if (!Pushed())
     155           0 :         aFtn.Start(rOut, *this);
     156           0 :     if (pFld)
     157           0 :         pFld->Start(rOut, *this);
     158           0 :     if (!Pushed())
     159           0 :         aBooks.Start(rOut, *this);
     160             :     // determine next event
     161           0 :     sal_uLong ulEnd = pDoc->Count(); // at the latest at the end of the text
     162           0 :     if (!Pushed())
     163           0 :         if (ulEnd > aSep.Where()) // next Sep prior?
     164           0 :             ulEnd = aSep.Where();
     165             :     if (true)
     166           0 :         if (ulEnd > aPap.Where()) // next Pap prior?
     167           0 :             ulEnd = aPap.Where();
     168             :     if (true)
     169           0 :         if (ulEnd > aChp.Where()) // next Chp prior?
     170           0 :             ulEnd = aChp.Where();
     171           0 :     if (!Pushed())
     172           0 :         if (ulEnd > aFtn.Where()) // next Ftn prior?
     173           0 :             ulEnd = aFtn.Where();
     174           0 :     if (pFld)
     175           0 :         if (ulEnd > pFld->Where()) // next Fld prior?
     176           0 :             ulEnd = pFld->Where();
     177           0 :     if (!Pushed())
     178           0 :         if (ulEnd > aBooks.Where()) // next Bookmark prior?
     179           0 :             ulEnd = aBooks.Where();
     180           0 :     *pSeek = Where(); // current position
     181           0 :     if (*pSeek < ulEnd)
     182           0 :         *pSeek = ulEnd;
     183           0 : }
     184             : 
     185           0 : void Ww1Manager::Out(Ww1Shell& rOut, sal_Unicode cUnknown)
     186             : {
     187             : // Depending on the mode, fields, footnotes, character attributes,
     188             : // paragraph attributes and sections are handled like this: First, the
     189             : // Stop() method is called. If the object determines that there is
     190             : // something to end (obviously not during the first pass), it will be
     191             : // ended, otherwise the call is without effect. Next, unhandled
     192             : // special characters get output. Then, all Start() methods get
     193             : // called, and then Where() is used to find the next interesting
     194             : // position.
     195             : 
     196             : // With the manager in 'push'ed mode, some elements will be
     197             : // skipped. Fields are only skipped under special circumstances, more
     198             : // precisely only during output of ranges which cannot contain
     199             : // fields. Character and paragraph attributes are never skipped. The
     200             : // if (1) instructions were added for uniformity.
     201             : 
     202             : // First, some special-casing for tables:
     203             : // the important attributes are best queried before they end
     204             : // Optimization: they only get set to meaningful values when the 0x07
     205             : // character is pending.
     206             : 
     207           0 :     bool bLIsTtp = false;
     208           0 :     sal_Bool bLHasTtp = sal_False;
     209           0 :     if( cUnknown == 0x07 )
     210             :     {
     211           0 :         bLIsTtp = IsInTtp();
     212           0 :         bLHasTtp = HasTtp();
     213             :     }
     214             : 
     215           0 :     OutStop( rOut, cUnknown );      // End attrs if necessary
     216             : 
     217             :     // interpret meta characters:
     218           0 :     if (!Ww1PlainText::IsChar(cUnknown))
     219           0 :         switch (cUnknown)
     220             :         {
     221             :         case 0x02:
     222             :             // dontknow
     223           0 :         break;
     224             :         case 0x07: // table
     225           0 :             if (rOut.IsInTable() && HasInTable() && !bLIsTtp && !bLHasTtp)
     226           0 :                 rOut.NextTableCell();
     227           0 :         break;
     228             :         case 0x09: // tab
     229           0 :             rOut.NextTab();
     230           0 :         break;
     231             :         case 0x0a: // linefeed
     232           0 :             rOut.NextParagraph();
     233           0 :         break;
     234             :         case 0x0b: // linebreak
     235           0 :             if (rOut.IsInTable())
     236             :                 ;
     237             :             else
     238           0 :                 rOut.NextLine();
     239           0 :         break;
     240             :         case 0x0d: // carriage return
     241             :             // ignore
     242           0 :         break;
     243             :         case 0x0c: // pagebreak
     244           0 :             rOut.NextPage();
     245           0 :         break;
     246             :         case 0x14: // sectionendchar
     247             :             // ignore here
     248           0 :         break;
     249             :         default:
     250           0 :         break;
     251             :         }
     252             : 
     253           0 :     OutStart( rOut );   // End attrs if necessary and calculate next pos
     254           0 : }
     255             : 
     256           0 : SvxFontItem Ww1Manager::GetFont(sal_uInt16 nFCode)
     257             : {
     258           0 :     return aFonts.GetFont(nFCode);
     259             : }
     260             : 
     261           0 : void Ww1Manager::Push0(Ww1PlainText* _pDoc, sal_uLong ulSeek, Ww1Fields* _pFld)
     262             : {
     263             :     OSL_ENSURE(!Pushed(), "Ww1Manager");
     264           0 :     this->pDoc = _pDoc;
     265           0 :     pSeek = new sal_uLong;
     266           0 :     *pSeek = pDoc->Where();
     267           0 :     aPap.Push(ulSeek);
     268           0 :     aChp.Push(ulSeek);
     269           0 :     this->pFld = _pFld;
     270           0 : }
     271             : 
     272             : // ulSeek is the FC distance between start of main text and start of special text
     273             : // ulSeek2 is this special text's offset in the special case range
     274           0 : void Ww1Manager::Push1(Ww1PlainText* _pDoc, sal_uLong ulSeek, sal_uLong ulSeek2,
     275             :                        Ww1Fields* _pFld)
     276             : {
     277             :     OSL_ENSURE(!Pushed(), "Ww1Manager");
     278           0 :     this->pDoc = _pDoc;
     279           0 :     pSeek = new sal_uLong;
     280           0 :     *pSeek = pDoc->Where();
     281           0 :     aPap.Push(ulSeek + ulSeek2);
     282           0 :     aChp.Push(ulSeek + ulSeek2);
     283           0 :     if( _pFld )
     284           0 :         _pFld->Seek( ulSeek2 );
     285           0 :     this->pFld = _pFld;
     286           0 : }
     287             : 
     288           0 : void Ww1Manager::Pop()
     289             : {
     290             :     OSL_ENSURE(Pushed(), "Ww1Manager");
     291           0 :     delete pDoc;
     292           0 :     pDoc = &aDoc;
     293           0 :     delete pSeek;
     294           0 :     pSeek = &ulDocSeek;
     295           0 :     aChp.Pop();
     296           0 :     aPap.Pop();
     297           0 :     delete pFld;
     298           0 :     pFld = &aFld;
     299           0 : }
     300             : 
     301           0 : void Ww1Bookmarks::Out(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16)
     302             : {
     303           0 :     if (GetIsEnd())
     304             :     {
     305           0 :         rOut.SetBookEnd(GetHandle());
     306           0 :         return;
     307             :     }
     308             : 
     309           0 :     const OUString & rName = GetName();
     310           0 :     if( rName.startsWith( "_Toc" ) ) // "_Toc*" is superfluous
     311           0 :         return;
     312             : 
     313           0 :     if( rOut.IsFlagSet( SwFltControlStack::HYPO )
     314           0 :         && rName.equalsIgnoreAsciiCase( "FORMULAR" ) )
     315           0 :         rOut.SetProtect();
     316             : 
     317             :     // Set for transformation bookmark -> variable
     318           0 :     long nLen = Len();
     319           0 :     if( nLen > MAX_FIELDLEN )
     320           0 :         nLen = MAX_FIELDLEN;
     321             : 
     322             :     // read content of the bookmark
     323             :     // Would supposedly also work via Ww1PlainText
     324           0 :     OUString aVal( rMan.GetText().GetText( Where(), nLen ) );
     325             : 
     326             :     // in 2 steps, since OS/2 is too stupid
     327           0 :     SwFltBookmark aBook( rName, aVal, GetHandle() );
     328           0 :     rOut << aBook;
     329             : }
     330             : 
     331           0 : void Ww1Bookmarks::Start(Ww1Shell& rOut, Ww1Manager& rMan)
     332             : {
     333           0 :     if (rMan.Where() >= Where())
     334             :     {
     335           0 :         Out(rOut, rMan);
     336           0 :         ++(*this);
     337             :     }
     338           0 : }
     339             : 
     340           0 : void Ww1Footnotes::Start(Ww1Shell& rOut, Ww1Manager& rMan)
     341             : {
     342           0 :     if (rMan.Where() >= Where())
     343             :     {
     344             :         OSL_ENSURE(nPlcIndex < Count(), "WwFootnotes");
     345             :         sal_Unicode c;
     346           0 :         rMan.Fill(c);
     347             :         OSL_ENSURE(c==0x02, "Ww1Footnotes");
     348           0 :         if (c==0x02)
     349             :         {
     350           0 :             Ww1FtnText* pText = new Ww1FtnText(rMan.GetFib());
     351           0 :             sal_uLong start = aText.Where(nPlcIndex);
     352           0 :             pText->Seek(start);
     353           0 :             sal_uLong count = aText.Where(nPlcIndex+1) - start;
     354           0 :             pText->SetCount(count);
     355             :             // first byte should be foot note marker
     356           0 :             pText->Out(c);
     357             :             OSL_ENSURE(c==0x02, "Ww1Footnotes");
     358           0 :             count--; // for the just read marker byte
     359           0 :             rOut.BeginFootnote();
     360           0 :             bStarted = sal_True;
     361           0 :             rMan.Push0(pText, pText->Offset(rMan.GetFib()),
     362           0 :              new Ww1FootnoteFields(rMan.GetFib()));
     363           0 :             rOut << rMan;
     364           0 :             rMan.Pop();
     365           0 :             rOut.EndFootnote();
     366             :         }
     367             :         else
     368           0 :             ++(*this);
     369             :     }
     370           0 : }
     371             : 
     372           0 : void Ww1Footnotes::Stop(Ww1Shell& /*rOut*/, Ww1Manager& rMan, sal_Unicode& c)
     373             : {
     374           0 :     if (bStarted && rMan.Where() > Where())
     375             :     {
     376             :         OSL_ENSURE(nPlcIndex < Count(), "Ww1Footnotes");
     377           0 :         c = ' ';
     378           0 :         ++(*this);
     379             :     }
     380           0 : }
     381             : 
     382           0 : void Ww1Fields::Start(Ww1Shell& rOut, Ww1Manager& rMan)
     383             : {
     384           0 :     if (rMan.Where() >= Where()){
     385             :         OSL_ENSURE(nPlcIndex < Count(), "Ww1Fields");
     386           0 :         if (GetData()->chGet() == 19)
     387           0 :             Out(rOut, rMan);
     388             :         else
     389           0 :             ++(*this); // ignore
     390             :     }
     391           0 : }
     392             : 
     393           0 : void Ww1Fields::Stop( Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c)
     394             : {
     395           0 :     if (rMan.Where() >= Where())
     396             :     {
     397             :         OSL_ENSURE(nPlcIndex < Count(), "Ww1Fields");
     398           0 :         if (GetData()->chGet() != 19)
     399             :         {
     400           0 :             rMan.Fill( c );
     401             :             OSL_ENSURE(c==21, "Ww1Fields");
     402           0 :             ++(*this);
     403           0 :             c = ' ';
     404           0 :             if (pField)
     405             :             // Do we have a complete field for insertion?
     406             :             {
     407           0 :                 rOut << *pField;
     408           0 :                 delete pField;
     409           0 :                 pField = 0;
     410             :             // The filter does it like this so that attributes
     411             :             // applying to this field actually get read and applied
     412             :             }
     413           0 :             if (!sResult.isEmpty())
     414           0 :                 rOut << sResult;
     415             :         }
     416             :     }
     417           0 : }
     418             : 
     419             : enum WWDateTime{ WW_DONTKNOW = 0x0, WW_DATE = 0x1, WW_TIME = 0x2, WW_BOTH = 0x3 };
     420             : 
     421           0 : static WWDateTime GetTimeDatePara( const OUString& rForm,
     422             :                                     SwTimeFormat* pTime = 0,
     423             :                                      SwDateFormat* pDate = 0 )
     424             : {
     425           0 :     WWDateTime eDT = WW_BOTH;
     426           0 :     if (rForm.indexOf('H') != -1)         // H    -> 24h
     427             :     {
     428           0 :         if( pTime )
     429           0 :             *pTime = TF_SSMM_24;
     430             :     }
     431           0 :     else if (rForm.indexOf('h') != -1)    // h    -> 24h
     432             :     {
     433           0 :         if( pTime )
     434           0 :             *pTime = TF_SSMM_12;
     435             :     }
     436             :     else                                    // no time
     437             :     {
     438           0 :         eDT = (WWDateTime)( eDT & ~(sal_uInt16)WW_TIME );
     439             :     }
     440             : 
     441           0 :     sal_Int32 nDPos = 0;
     442             :     while (true)
     443             :     {
     444           0 :         nDPos = rForm.indexOf('M', nDPos);     // M    -> date
     445           0 :         if (nDPos == 0 || nDPos == -1)
     446             :             break;
     447           0 :         sal_Unicode cPrev = rForm[nDPos - 1];
     448             :         // Ignore "AM", "aM", "PM", "pM" here
     449           0 :         if( 'a' != cPrev && 'A' != cPrev && 'p' != cPrev && 'P' != cPrev )
     450           0 :             break;
     451             :         // else search again
     452           0 :         ++nDPos;
     453             :     }
     454             : 
     455           0 :     if (nDPos != -1)                  // month -> date ?
     456             :     {
     457             :         static SwDateFormat const aDateA[32] =
     458             :         {
     459             :             DFF_DMY, DFF_DMMY, DFF_DMYY, DFF_DMMYY,
     460             :             DFF_DMMMY, DFF_DMMMY, DFF_DMMMYY, DFF_DMMMYY,
     461             :             DFF_DDMMY, DFF_DDMMY, DFF_DDMMMYY, DFF_DDMMMYY,
     462             :             DFF_DDMMMY, DFF_DDMMMY, DFF_DDMMMYY, DFF_DDMMMYY,
     463             :             DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
     464             :             DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
     465             :             DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY,
     466             :             DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY
     467             :         };
     468             : 
     469           0 :         bool bHasDay = rForm.indexOf('t') != -1 ||
     470           0 :                        rForm.indexOf('T') != -1 ||
     471           0 :                        rForm.indexOf('d') != -1 ||
     472           0 :                        rForm.indexOf('D') != -1;
     473             : 
     474           0 :         sal_Bool bLongDayOfWeek = rForm.indexOf("tttt") != -1 ||
     475           0 :                                   rForm.indexOf("TTTT") != -1 ||
     476           0 :                                   rForm.indexOf("dddd") != -1 ||
     477           0 :                                   rForm.indexOf("DDDD") != -1;
     478             : 
     479           0 :         sal_Bool bDayOfWeek = rForm.indexOf("ttt") != -1 ||
     480           0 :                               rForm.indexOf("TTT") != -1 ||
     481           0 :                               rForm.indexOf("ddd") != -1 ||
     482           0 :                               rForm.indexOf("DDD") != -1;
     483             : 
     484             :                     //  M, MM -> numeric month
     485             :                     //  MMM, MMMM -> text. month
     486           0 :         sal_Bool bLitMonth = rForm.indexOf("MMM") != -1;
     487             :                     //  MMMM -> full month
     488           0 :         sal_Bool bFullMonth = rForm.indexOf("MMMM") != -1;
     489             :                     //  jj, JJ -> 2-col-year
     490             :                     //  jjjj, JJJJ -> 4-col-year
     491           0 :         sal_Bool bFullYear = rForm.indexOf("jjj") != -1 ||
     492           0 :                              rForm.indexOf("JJJ") != -1 ||
     493           0 :                              rForm.indexOf("yyy") != -1 ||
     494           0 :                              rForm.indexOf("YYY") != -1;
     495             : 
     496             :         sal_uInt16 i = ( bLitMonth & 1 )
     497           0 :                    | ( ( bFullYear & 1 ) << 1 )
     498           0 :                    | ( ( bFullMonth & 1 ) << 2 )
     499           0 :                    | ( ( bDayOfWeek & 1 ) << 3 )
     500           0 :                    | ( ( bLongDayOfWeek & 1 ) << 4 );
     501           0 :         if( pDate )
     502             :         {
     503           0 :             if( !bHasDay && !bFullMonth )
     504           0 :                 *pDate = DFF_MY;
     505             :             else
     506           0 :                 *pDate = aDateA[i];
     507             :         }
     508             :     }
     509             :     else
     510             :     {
     511           0 :         eDT = (WWDateTime)( eDT & ~(sal_uInt16)WW_DATE );
     512             :     }
     513           0 :     return eDT;
     514             : }
     515             : 
     516             : extern void sw3io_ConvertFromOldField( SwDoc& rDoc, sal_uInt16& rWhich,
     517             :                                 sal_uInt16& rSubType, sal_uLong &rFmt,
     518             :                                 sal_uInt16 nVersion );
     519             : 
     520           0 : void Ww1Fields::Out(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 nDepth)
     521             : {
     522           0 :     OUString sType; // the type as string
     523           0 :     OUString sFormula;
     524           0 :     OUString sFormat;
     525           0 :     OUString sDTFormat;   // date/time format
     526           0 :     W1_FLD* pData = GetData(); // data bound to plc
     527             :     OSL_ENSURE(pData->chGet()==19, "Ww1Fields"); // should be begin
     528             : 
     529             :     sal_Unicode c;
     530           0 :     rMan.Fill( c );
     531             :     OSL_ENSURE(c==19, "Ww1Fields"); // should also be begin
     532           0 :     if (pData->chGet()==19 && c == 19)
     533             :     {
     534           0 :         OUString aStr;
     535           0 :         c = rMan.Fill( aStr, GetLength() );
     536             :         OSL_ENSURE(Ww1PlainText::IsChar(c), "Ww1Fields");
     537           0 :         sal_Int32 pos = aStr.indexOf(' ');
     538             :         // get type out of text
     539           0 :         if ( pos != -1 )
     540             :         {
     541           0 :             sType = aStr.copy(0, pos);
     542           0 :             aStr = aStr.copy(pos+1);
     543             :         }
     544             :         else
     545             :         {
     546           0 :             sType = aStr;
     547           0 :             aStr = "";
     548             :         }
     549           0 :         sFormula += aStr;
     550           0 :         sal_uInt8 rbType = pData->fltGet();
     551           0 :         do {
     552             :             // Read the formula part until the entire field ends or
     553             :             // the result part starts. Of course, other fields can
     554             :             // start during this (Word supports nested fields).
     555           0 :             ++(*this);
     556           0 :             pData = GetData();
     557           0 :             if (pData->chGet()==19) // nested field
     558             :             {
     559           0 :                 Out(rOut, rMan, nDepth+1);
     560           0 :                 rMan.Fill(c);
     561             :                 OSL_ENSURE(c==21, "Ww1PlainText");
     562           0 :                 sFormula += "Ww" + OUString::number(nPlcIndex);
     563           0 :                 c = rMan.Fill(aStr, GetLength());
     564             :                 OSL_ENSURE(Ww1PlainText::IsChar(c), "Ww1PlainText");
     565           0 :                 sFormula += aStr;
     566             :             }
     567             :         }
     568           0 :         while (pData->chGet()==19);
     569             : 
     570             :         // get format out of text
     571           0 :         pos = sFormula.indexOf("\\*");
     572           0 :         if (pos != -1)
     573             :         {
     574           0 :             sFormat = sFormula.copy(pos);
     575           0 :             sFormula = sFormula.copy(0, pos);
     576             :         }
     577             : 
     578           0 :         pos = sFormula.indexOf( "\\@" );
     579           0 :         if (pos != -1)
     580             :         {
     581           0 :             sDTFormat = sFormula.copy(pos);
     582           0 :             sFormula = sFormula.copy(0, pos);
     583             :         }
     584             : 
     585             :         // The formula part is done, does a result part follow?
     586           0 :         if( pData->chGet() == 20 )
     587             :         {
     588           0 :             rMan.Fill( c );
     589             :             OSL_ENSURE(c==20, "Ww1PlainText");
     590           0 :             c = rMan.Fill(sResult, GetLength());
     591           0 :             if (!Ww1PlainText::IsChar(c))
     592           0 :                 sResult += OUString(c); //~ mdt: handle special chars
     593           0 :             ++(*this);
     594           0 :             pData = GetData();
     595             :         }
     596             :         OSL_ENSURE(pData->chGet()==21, "Ww1PlainText");
     597           0 :         bool bKnown = true;
     598             :         OSL_ENSURE(pField==0, "Ww1PlainText");
     599           0 :         if (pField != 0)
     600             :         {
     601           0 :             rOut << *pField;
     602           0 :             delete pField;
     603           0 :             pField = 0;
     604             :         }
     605             : oncemore:
     606           0 :         switch (rbType)
     607             :         {
     608             :         case 3: // bookmark reference
     609           0 :             sFormula = rOut.ConvertUStr(sFormula);
     610             :             pField = new SwGetRefField( (SwGetRefFieldType*)
     611           0 :                 rOut.GetSysFldType( RES_GETREFFLD ),
     612             :                 sFormula,
     613             :                 REF_BOOKMARK,
     614             :                 0,
     615           0 :                 REF_CONTENT );
     616             : 
     617           0 :         break;
     618             :         case 6: // set command
     619             :         {
     620           0 :             pos = aStr.indexOf(' ');
     621           0 :             OUString aName;
     622           0 :             if (pos != -1)
     623             :             {
     624           0 :                 aName = aStr.copy(0, pos);
     625           0 :                 aStr = aStr.copy(pos+1);
     626             :             }
     627             :             else
     628             :             {
     629           0 :                 aName = aStr;
     630           0 :                 aStr = "";
     631             :             }
     632           0 :             if (aName.isEmpty())
     633           0 :                 break;
     634           0 :             aName = rOut.ConvertUStr(aName);
     635           0 :             SwFieldType* pFT = rOut.GetDoc().InsertFldType(
     636           0 :                 SwSetExpFieldType( &rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_STRING ) );
     637           0 :             pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr);
     638           0 :             ((SwSetExpField*)pField)->SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
     639             :             // Invisible causes trouble in 378; should work soon
     640             : 
     641             :             // Ignoring bookmarks is not implemented
     642             :         }
     643           0 :         break;
     644             :         case 14: // info variable
     645             :         {
     646           0 :             OUString aSubType;
     647           0 :             pos = aStr.indexOf(' ');
     648           0 :             if (pos != -1)
     649             :             {
     650           0 :                 aSubType = aStr.copy(0, pos);
     651           0 :                 aStr = aStr.copy(pos+1);
     652             :             }
     653             :             else
     654             :             {
     655           0 :                 aSubType = aStr;
     656           0 :                 aStr = "";
     657             :             }
     658             : 
     659           0 :             aSubType = rOut.ConvertUStr(aSubType);
     660             : 
     661             :             // huge pile of shit: the type 'info' can represent one of
     662             :             // types 15 to 31. it contains as formula the actual field
     663             :             // of the doc info.
     664             :             // Don't use ';' with the following macro
     665             : #define IS(sd, se, t) \
     666             :     if (aSubType == sd || aSubType == se) \
     667             :         rbType = t; \
     668             :     else
     669             : 
     670             :             // german name       english name    type-code
     671           0 :             IS("titel",          "title",          15)
     672           0 :             IS("thema",          "subject",        16)
     673           0 :             IS("autor",          "author",         17)
     674           0 :             IS("stichw?rter",    "keywords",       18) //~ mdt: umlaut
     675           0 :             IS("kommentar",      "comment",        19)
     676           0 :             IS("gespeichertvon", "lastrevisedby",  20)
     677           0 :             IS("ertelldat",      "creationdate",   21)
     678           0 :             IS("speicherdat",    "revisiondate",   22)
     679           0 :             IS("druckdat",       "printdate",      23)
     680           0 :             IS("version",        "revisionnumber", 24)
     681           0 :             IS("zeit",           "edittime",       25)
     682           0 :             IS("anzseit",        "numberofpages",  26)
     683           0 :             IS("anzw?rter",      "numberofwords",  27) //~ mdt: umlaut
     684           0 :             IS("anzzeichen",     "numberofchars",  28)
     685           0 :             IS("dateiname",      "filename",       29)
     686           0 :             IS("vorlage",        "templatename",   30)
     687           0 :                 bKnown = false;
     688             : #undef IS
     689           0 :             if (rbType != 14)
     690           0 :                 goto oncemore;
     691             :         }
     692           0 :         break;
     693             :         case 15: // title
     694             :             pField = new SwDocInfoField((SwDocInfoFieldType*)
     695           0 :              rOut.GetSysFldType(RES_DOCINFOFLD), DI_TITEL, OUString(), 0);
     696           0 :         break;
     697             :         case 16: // subject
     698             :             pField = new SwDocInfoField((SwDocInfoFieldType*)
     699           0 :              rOut.GetSysFldType(RES_DOCINFOFLD), DI_THEMA, OUString(), 0);
     700           0 :         break;
     701             :         case 17: // author
     702             :             pField = new SwAuthorField((SwAuthorFieldType*)
     703           0 :              rOut.GetSysFldType(RES_AUTHORFLD), AF_NAME );
     704           0 :         break;
     705             :         case 18: // keywords
     706             :             pField = new SwDocInfoField((SwDocInfoFieldType*)
     707           0 :              rOut.GetSysFldType(RES_DOCINFOFLD), DI_KEYS, OUString(), 0);
     708           0 :         break;
     709             :         case 19: // comments
     710             :             pField = new SwDocInfoField((SwDocInfoFieldType*)
     711           0 :              rOut.GetSysFldType(RES_DOCINFOFLD), DI_COMMENT, OUString(), 0);
     712           0 :         break;
     713             :         case 20: // last revised by
     714             :             pField = new SwDocInfoField((SwDocInfoFieldType*)
     715           0 :              rOut.GetSysFldType(RES_DOCINFOFLD), DI_CHANGE|DI_SUB_AUTHOR, OUString());
     716           0 :         break;
     717             :         case 21: // creation date
     718             :         case 22: // revision date
     719             :         case 23: // print date
     720             :         case 25:{// edit time
     721             :                     sal_uInt16 nSub;
     722           0 :                     sal_uInt16 nReg = 0;    // RegInfoFormat, DefaultFormat for DocInfo fields
     723             : 
     724           0 :                     switch( rbType )
     725             :                     {
     726             :                         default:
     727           0 :                         case 21: nSub = DI_CREATE;  nReg = DI_SUB_DATE; break;
     728           0 :                         case 23: nSub = DI_PRINT;   nReg = DI_SUB_DATE; break;
     729           0 :                         case 22: nSub = DI_CHANGE;  nReg = DI_SUB_DATE; break;
     730           0 :                         case 25: nSub = DI_CHANGE;  nReg = DI_SUB_TIME; break;
     731             :                     }
     732           0 :                     switch( GetTimeDatePara( sDTFormat ) )
     733             :                     {
     734           0 :                         case WW_DATE: nReg = DI_SUB_DATE; break;
     735           0 :                         case WW_TIME: nReg = DI_SUB_TIME; break;
     736           0 :                         case WW_BOTH: nReg = DI_SUB_DATE; break;
     737             :                         default:
     738           0 :                             break;
     739             :                         // WW_DONTKNOW -> Default already set
     740             :                     }
     741             :                     pField = new SwDocInfoField((SwDocInfoFieldType*)
     742           0 :                         rOut.GetSysFldType(RES_DOCINFOFLD), nSub | nReg, OUString());
     743             :                 }
     744           0 :         break;
     745             :         case 24: // revision number
     746             :             pField = new SwDocInfoField((SwDocInfoFieldType*)
     747           0 :              rOut.GetSysFldType(RES_DOCINFOFLD),  DI_DOCNO, OUString(), 0);
     748           0 :         break;
     749             :         case 26: // number of pages
     750             :             pField = new SwDocStatField((SwDocStatFieldType*)
     751           0 :              rOut.GetSysFldType(RES_DOCSTATFLD), DS_PAGE, SVX_NUM_ARABIC);
     752           0 :         break;
     753             :         case 27: // number of words
     754             :             pField = new SwDocStatField((SwDocStatFieldType*)
     755           0 :              rOut.GetSysFldType(RES_DOCSTATFLD), DS_WORD, SVX_NUM_ARABIC);
     756           0 :         break;
     757             :         case 28: // number of chars
     758             :             pField = new SwDocStatField((SwDocStatFieldType*)
     759           0 :              rOut.GetSysFldType(RES_DOCSTATFLD), DS_CHAR, SVX_NUM_ARABIC);
     760           0 :         break;
     761             :         case 29: // file name
     762             :             pField = new SwFileNameField((SwFileNameFieldType*)
     763           0 :              rOut.GetSysFldType(RES_FILENAMEFLD));
     764           0 :         break;
     765             :         case 30: // doc template name
     766             :             pField = new SwTemplNameField((SwTemplNameFieldType*)
     767           0 :              rOut.GetSysFldType(RES_TEMPLNAMEFLD), FF_NAME);
     768           0 :         break;
     769             :         case 31:
     770             :         case 32:{
     771           0 :                     SwDateFormat aDate = DF_SSYS;
     772           0 :                     SwTimeFormat aTime = TF_SYSTEM;
     773             : 
     774           0 :                     WWDateTime eDT = GetTimeDatePara(sDTFormat, &aTime, &aDate);
     775           0 :                     if( eDT == WW_DONTKNOW )        // no D/T-format string
     776           0 :                         eDT = ( rbType == 32 ) ? WW_TIME : WW_DATE;    // use ID
     777             : 
     778           0 :                     if( eDT & WW_DATE )
     779             :                     {
     780           0 :                         sal_uInt16 nWhich = RES_DATEFLD;
     781           0 :                         sal_uInt16 nSubType = DATEFLD;
     782           0 :                         sal_uLong nFormat = aDate;
     783           0 :                         sw3io_ConvertFromOldField( rOut.GetDoc(),
     784           0 :                             nWhich, nSubType, nFormat, 0x0110 );
     785             :                         pField = new SwDateTimeField((SwDateTimeFieldType*)
     786           0 :                             rOut.GetSysFldType(RES_DATETIMEFLD), DATEFLD, nFormat);
     787             : 
     788           0 :                         if( eDT == WW_BOTH )
     789           0 :                             rOut << * pField << ' ';
     790             :                                 // Cheat: insert directly and a space afterwards
     791             :                     }
     792           0 :                     if( eDT & WW_TIME )
     793             :                     {
     794           0 :                         sal_uInt16 nWhich = RES_TIMEFLD;
     795           0 :                         sal_uInt16 nSubType = TIMEFLD;
     796           0 :                         sal_uLong nFormat = aTime;
     797           0 :                         sw3io_ConvertFromOldField( rOut.GetDoc(),
     798           0 :                             nWhich, nSubType, nFormat, 0x0110 );
     799             :                         pField = new SwDateTimeField((SwDateTimeFieldType*)
     800           0 :                             rOut.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat);
     801             :                     }
     802             : 
     803             :                 }
     804           0 :         break;
     805             :         case 33: // current page
     806             :             pField = new SwPageNumberField((SwPageNumberFieldType*)
     807           0 :              rOut.GetSysFldType(RES_PAGENUMBERFLD), PG_RANDOM, SVX_NUM_ARABIC);
     808           0 :         break;
     809             :         case 34: // evaluation exp
     810             :         {
     811           0 :             if (nDepth == 0)
     812             :             {
     813             :                 SwGetExpFieldType* pFieldType =
     814           0 :                  (SwGetExpFieldType*)rOut.GetSysFldType(RES_GETEXPFLD);
     815             :                 OSL_ENSURE(pFieldType!=0, "Ww1Fields");
     816           0 :                 if (pFieldType != 0)
     817             :                     pField = new SwGetExpField(pFieldType, sFormula,
     818           0 :                      nsSwGetSetExpType::GSE_STRING, VVF_SYS);
     819             :             }
     820             :             else // recursion:
     821             :             {
     822           0 :                 OUString aName("Ww");
     823           0 :                 aName += OUString::number( nPlcIndex );
     824           0 :                 SwFieldType* pFT = rOut.GetDoc().GetFldType( RES_SETEXPFLD, aName, false);
     825           0 :                 if (pFT == 0)
     826             :                 {
     827           0 :                     SwSetExpFieldType aS(&rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_FORMULA);
     828           0 :                     pFT = rOut.GetDoc().InsertFldType(aS);
     829             :                 }
     830           0 :                 SwSetExpField aFld((SwSetExpFieldType*)pFT, sFormula);
     831           0 :                 aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE);
     832           0 :                 rOut << aFld;
     833             :             }
     834             :         }
     835           0 :         break;
     836             :         case 36: // print command, insert file
     837             :         {
     838           0 :             OUString aFName;
     839           0 :             pos = aStr.indexOf(' ');
     840           0 :             if (pos != -1)
     841             :             {
     842           0 :                 aFName = aStr.copy(0, pos);
     843           0 :                 aStr = aStr.copy(pos+1);
     844             :             }
     845             :             else
     846             :             {
     847           0 :                 aFName = aStr;
     848           0 :                 aStr = "";
     849             :             }
     850             : 
     851           0 :             if(aFName.isEmpty())
     852           0 :                 break;
     853           0 :             aFName = aFName.replaceFirst("\\\\", "\\");
     854             : 
     855           0 :             aFName = URIHelper::SmartRel2Abs(
     856           0 :                 INetURLObject(rOut.GetBaseURL()), aFName );
     857             : 
     858           0 :             const OUString sStr(aStr);
     859             :             SwSectionData * pSection = new SwSectionData( FILE_LINK_SECTION,
     860           0 :                 rOut.GetDoc().GetUniqueSectionName( &sStr ) );
     861           0 :             pSection->SetLinkFileName( aFName );
     862           0 :             pSection->SetProtectFlag( true );
     863           0 :             rOut << SwFltSection( pSection );
     864           0 :             rOut.EndItem( RES_FLTR_SECTION );
     865           0 :             rOut.NextParagraph();
     866             :         }
     867             :         case 37: // page ref
     868             :             pField = new SwGetRefField(
     869           0 :              (SwGetRefFieldType*)rOut.GetSysFldType(RES_GETREFFLD),
     870           0 :              sFormula, 0, 0, REF_PAGE);
     871           0 :         break;
     872             :         case 38: // ask command
     873             :         {
     874           0 :             OUString aName;
     875           0 :             pos = aStr.indexOf(' ');
     876           0 :             if (pos != -1)
     877             :             {
     878           0 :                 aName = aStr.copy(0, pos);
     879           0 :                 aStr = aStr.copy(pos+1);
     880             :             }
     881             :             else
     882             :             {
     883           0 :                 aName = aStr;
     884           0 :                 aStr = "";
     885             :             }
     886             : 
     887           0 :             if (aName.isEmpty())
     888           0 :                 break;
     889             : 
     890           0 :             SwFieldType* pFT = rOut.GetDoc().InsertFldType(
     891           0 :                 SwSetExpFieldType( &rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_STRING ) );
     892           0 :             pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr );
     893           0 :             ((SwSetExpField*)pField)->SetInputFlag( sal_True );
     894           0 :             ((SwSetExpField*)pField)->SetSubType(nsSwExtendedSubType::SUB_INVISIBLE);
     895             :         }
     896             :         case 39: // filling command
     897             :             pField = new SwInputField(
     898           0 :                 static_cast<SwInputFieldType*>(rOut.GetSysFldType( RES_INPUTFLD )),
     899             :                 OUString(), sFormula,
     900           0 :                 INP_TXT, 0, false );
     901           0 :         break;
     902             :         case 51: // macro button
     903             :         {
     904           0 :             OUString aName;
     905           0 :             pos = aStr.indexOf(' ');
     906           0 :             if (pos != -1)
     907             :             {
     908           0 :                 aName = aStr.copy(0, pos);
     909           0 :                 aStr = aStr.copy(pos+1);
     910             :             }
     911             :             else
     912             :             {
     913           0 :                 aName = aStr;
     914           0 :                 aStr = "";
     915             :             }
     916             : 
     917           0 :             if (aName.isEmpty() || aStr.isEmpty())
     918           0 :                 break;
     919             : 
     920             :             pField = new SwMacroField( (SwMacroFieldType*)
     921           0 :                             rOut.GetSysFldType( RES_MACROFLD ),
     922           0 :                             "StarOffice.Standard.Modul1." + aName, aStr );
     923             :         }
     924           0 :         break;
     925             :         case 55: // read tiff / or better: import anything
     926             :         {
     927           0 :             const sal_Unicode* pFormula = sFormula.getStr();
     928           0 :             const sal_Unicode* pDot = 0;
     929           0 :             OUString sName;
     930           0 :             while (*pFormula != '\0' && *pFormula != ' ')
     931             :             {
     932             :                 // from here on an extension could appear
     933           0 :                 if (*pFormula == '.')
     934           0 :                     pDot = pFormula;
     935             :                 else
     936             :                     // so far we were in directories
     937           0 :                     if (*pFormula == '\\')
     938             :                     {
     939           0 :                         pDot = 0;
     940           0 :                         if (pFormula[1] == '\\')
     941           0 :                             pFormula++;
     942             :                     }
     943           0 :                 if (*pFormula != '\0')
     944           0 :                     sName += OUString(*pFormula++);
     945             :             }
     946           0 :             if( pDot )
     947             :             {
     948           0 :                 OUStringBuffer sBuf;
     949           0 :                 while( *pDot != '\0' && *pDot != ' ')
     950           0 :                     sBuf.append(*pDot++);
     951           0 :                 OUString sExt = sBuf.makeStringAndClear();
     952             : 
     953           0 :                 if( sExt.equalsIgnoreAsciiCase( ".tiff" )
     954           0 :                  || sExt.equalsIgnoreAsciiCase( ".bmp" )
     955           0 :                  || sExt.equalsIgnoreAsciiCase( ".gif" )
     956           0 :                  || sExt.equalsIgnoreAsciiCase( ".pcx" )
     957           0 :                  || sExt.equalsIgnoreAsciiCase( ".pic" ))
     958           0 :                     rOut.AddGraphic( sName );
     959             :                 else
     960           0 :                     bKnown = false;
     961             :             }
     962             :             else
     963           0 :                 bKnown = false;
     964             :         }
     965           0 :         break;
     966             :         default: // unknown
     967             :             OSL_ENSURE(false, "Ww1PlainText");
     968             :         // unsupported:
     969             :         case 1: // unknown
     970             :         case 2: // possible bookmark
     971             :         case 4: // index entry
     972             :         // wwpar5: 1351/1454
     973             :         case 5: // footnote ref
     974             :         case 7: // if command
     975             :         case 8: // create index
     976             :         // wwpar5: 1351/1454
     977             :         case 9: // table of contents entry
     978             :         // wwpar5: 1351/1454
     979             :         case 10: // style ref
     980             :         case 11: // doc ref
     981             :         case 12: // seq ref
     982             :         case 13: // create table of contents
     983             :         // wwpar5: 1351/1454
     984             :         case 35: // literal text
     985             :         // print merge:
     986             :         case 40: // data command
     987             :         case 41: // next command
     988             :         case 42: // nextif command
     989             :         case 43: // skipif command
     990             :         case 44: // number of record
     991             : 
     992             :         case 45: // dde ref
     993             :         case 46: // dde auto ref
     994             :         case 47: // glossary entry
     995             :         case 48: // print char
     996             :         case 49: // formula def
     997             :         case 50: // goto button
     998             :         case 52: // auto number outline
     999             :         case 53: // auto number legal
    1000             :         case 54: // auto number arabic
    1001           0 :             bKnown = false;
    1002           0 :         break;
    1003             :         }
    1004           0 :         if( bKnown || sResult == "\270" )
    1005           0 :             this->sResult = "";
    1006             :         else
    1007           0 :             this->sResult = sResult;
    1008             :     }
    1009             :     else // oops: we are terribly wrong: skip this
    1010           0 :         ++(*this);
    1011           0 : }
    1012             : 
    1013           0 : sal_uLong Ww1Fields::GetLength()
    1014             : {
    1015             :     // Calculates a field part's length, excluding the terminating
    1016             :     // chars in the text (19, 20, 21) meaning begin, separator and
    1017             :     // end, respectively.
    1018           0 :     sal_uLong ulBeg = Where();
    1019           0 :     sal_uLong ulEnd = Where(nPlcIndex+1);
    1020             :     OSL_ENSURE(ulBeg<ulEnd, "Ww1Fields");
    1021           0 :     return (ulEnd - ulBeg) - 1;
    1022             : }
    1023             : 
    1024           0 : void Ww1Sep::Start(Ww1Shell& rOut, Ww1Manager& rMan)
    1025             : {
    1026           0 :     if (rMan.Where() >= Where())
    1027             :     {
    1028           0 :         rOut.NextSection();
    1029           0 :         SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
    1030           0 :         W1_DOP& rDOP = rMan.GetDop().GetDOP();
    1031           0 :         rOut.GetPageDesc().SetLandscape(rDOP.fWideGet());
    1032           0 :         SwFmtFrmSize aSz(rFmt.GetFrmSize());
    1033           0 :         aSz.SetWidth(rDOP.xaPageGet());
    1034           0 :         aSz.SetHeight(rDOP.yaPageGet());
    1035           0 :         rFmt.SetFmtAttr(aSz);
    1036           0 :         SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(),
    1037           0 :          rDOP.dxaRightGet(), 0, 0, RES_LR_SPACE);
    1038           0 :         rFmt.SetFmtAttr(aLR);
    1039           0 :         SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet(), RES_UL_SPACE);
    1040           0 :         rFmt.SetFmtAttr(aUL);
    1041             : 
    1042             :         // As soon as we've reached reading the start of the current
    1043             :         // sep's attribute, we insert it. This method is the same for
    1044             :         // most member classes of the manager.
    1045           0 :         sal_uInt8* pByte = GetData();
    1046           0 :         Ww1SprmSep aSprm(rFib, SVBT32ToUInt32(pByte + 2));
    1047           0 :         aSprm.Start(rOut, rMan);
    1048           0 :         aSprm.Stop(rOut, rMan);
    1049           0 :         ++(*this);
    1050           0 :         aHdd.Start(rOut, rMan);
    1051             :     }
    1052           0 : }
    1053             : 
    1054           0 : void Ww1Pap::Start(Ww1Shell& rOut, Ww1Manager& rMan)
    1055             : {
    1056           0 :     if (rMan.Where() >= Where())
    1057             :     {
    1058             :         sal_uInt8* pByte;
    1059             :         sal_uInt16 cb;
    1060             :         // Supply the attributes to be started
    1061           0 :         if (FillStart(pByte, cb))
    1062             :         {
    1063           0 :             Ww1SprmPapx aSprm(pByte, cb);
    1064             :             // and give the following output
    1065           0 :             aSprm.Start(rOut, rMan);
    1066             :         }
    1067           0 :         ++(*this);
    1068             :     }
    1069           0 : }
    1070             : 
    1071           0 : void Ww1Pap::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
    1072             : {
    1073           0 :     if (rMan.Where() >= Where() || rMan.IsStopAll())
    1074             :     {
    1075             :         sal_uInt8* pByte;
    1076             :         sal_uInt16 cb;
    1077           0 :         if (FillStop(pByte, cb)){
    1078           0 :             Ww1SprmPapx aSprm(pByte, cb);
    1079           0 :             aSprm.Stop(rOut, rMan);
    1080             :         }else{
    1081             :             OSL_ENSURE( !nPlcIndex || rMan.IsStopAll(), "Pap-Attribut-Stop verloren" );
    1082             :         }
    1083             :     }
    1084           0 : }
    1085             : 
    1086             : // Currently, the output of W1CHPxes cannot be solved only by define...
    1087           0 : void W1_CHP::Out(Ww1Shell& rOut, Ww1Manager& rMan)
    1088             : {
    1089           0 :     if (fBoldGet())
    1090             :         rOut << SvxWeightItem(
    1091           0 :             rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
    1092           0 :     if (fItalicGet())
    1093             :         rOut << SvxPostureItem(
    1094           0 :             rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL, RES_CHRATR_POSTURE);
    1095           0 :     if (fStrikeGet())
    1096             :         rOut << SvxCrossedOutItem(
    1097           0 :             rOut.GetCrossedOut()?STRIKEOUT_NONE:STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT);
    1098           0 :     if (fOutlineGet())
    1099           0 :         rOut << SvxContourItem(!rOut.GetContour(), RES_CHRATR_CONTOUR);
    1100           0 :     if (fSmallCapsGet())
    1101             :         rOut << SvxCaseMapItem(
    1102           0 :             rOut.GetCaseKapitaelchen()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_KAPITAELCHEN, RES_CHRATR_CASEMAP);
    1103           0 :     if (fCapsGet())
    1104             :         rOut << SvxCaseMapItem(
    1105           0 :             rOut.GetCaseVersalien()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_VERSALIEN, RES_CHRATR_CASEMAP);
    1106           0 :     if (fsHpsGet())
    1107           0 :             rOut << SvxFontHeightItem(hpsGet() * 10, 100, RES_CHRATR_FONTSIZE);
    1108           0 :     if (fsKulGet())
    1109           0 :         switch (kulGet()) {
    1110           0 :         case 0: rOut << SvxUnderlineItem(UNDERLINE_NONE, RES_CHRATR_UNDERLINE)
    1111           0 :                      << SvxWordLineModeItem(false, RES_CHRATR_WORDLINEMODE);
    1112           0 :                 break;
    1113           0 :         case 1: rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
    1114           0 :                 break;
    1115           0 :         case 2: rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE)
    1116           0 :                      << SvxWordLineModeItem(true, RES_CHRATR_WORDLINEMODE);
    1117           0 :                 break;
    1118           0 :         case 3: rOut << SvxUnderlineItem(UNDERLINE_DOUBLE, RES_CHRATR_UNDERLINE);
    1119           0 :                 break;
    1120           0 :         case 4: rOut << SvxUnderlineItem(UNDERLINE_DOTTED, RES_CHRATR_UNDERLINE);
    1121           0 :                 break;
    1122             :         default: OSL_ENSURE(false, "Chpx");
    1123             :         }
    1124             : 
    1125           0 :     if (fsIcoGet())
    1126           0 :         switch(icoGet()) {
    1127             :         default: OSL_ENSURE(false, "Chpx");
    1128             :         //fall-through
    1129           0 :         case 0: { rOut.EndItem(RES_CHRATR_COLOR); } break;
    1130           0 :         case 1: { rOut << SvxColorItem(Color(COL_BLACK), RES_CHRATR_COLOR); } break;
    1131           0 :         case 2: { rOut << SvxColorItem(Color(COL_LIGHTBLUE), RES_CHRATR_COLOR); } break;
    1132           0 :         case 3: { rOut << SvxColorItem(Color(COL_LIGHTCYAN), RES_CHRATR_COLOR); } break;
    1133           0 :         case 4: { rOut << SvxColorItem(Color(COL_LIGHTGREEN), RES_CHRATR_COLOR); } break;
    1134           0 :         case 5: { rOut << SvxColorItem(Color(COL_LIGHTMAGENTA), RES_CHRATR_COLOR); } break;
    1135           0 :         case 6: { rOut << SvxColorItem(Color(COL_LIGHTRED), RES_CHRATR_COLOR); } break;
    1136           0 :         case 7: { rOut << SvxColorItem(Color(COL_YELLOW), RES_CHRATR_COLOR); } break;
    1137           0 :         case 8: { rOut << SvxColorItem(Color(COL_WHITE), RES_CHRATR_COLOR); } break;
    1138             :         }
    1139           0 :     if (fsSpaceGet()) {
    1140           0 :         short sQps = qpsSpaceGet();
    1141           0 :         if (sQps > 56)
    1142           0 :             sQps = sQps - 64;
    1143           0 :         rOut << SvxKerningItem(sQps, RES_CHRATR_KERNING);
    1144             :     }
    1145           0 :     if (fsPosGet()) {
    1146           0 :         if (hpsPosGet() == 0)
    1147           0 :             rOut << SvxEscapementItem(SVX_ESCAPEMENT_OFF, 100, RES_CHRATR_ESCAPEMENT);
    1148             :         else {
    1149           0 :             short sHps = hpsPosGet();
    1150           0 :             if (sHps > 128)
    1151           0 :                 sHps =  sHps - 256;
    1152           0 :             sHps *= 100;
    1153           0 :             sHps /= 24;
    1154           0 :             rOut << SvxEscapementItem(sHps, 100, RES_CHRATR_ESCAPEMENT);
    1155             :         }
    1156             :     }
    1157           0 :     if (fsFtcGet()) {
    1158           0 :         SvxFontItem aFont(rMan.GetFont(ftcGet()));
    1159           0 :         rOut << aFont;
    1160             :     }
    1161           0 : }
    1162             : 
    1163           0 : void Ww1Chp::Start(Ww1Shell& rOut, Ww1Manager& rMan)
    1164             : {
    1165           0 :     if (rMan.Where() >= Where())
    1166             :     {
    1167           0 :         W1_CHP aChpx;
    1168           0 :         if (FillStart(aChpx))
    1169             :         {
    1170           0 :             aChpx.Out(rOut, rMan);
    1171           0 :             if (aChpx.fcPicGet())
    1172             :             {
    1173           0 :                 Ww1Picture aPic(rMan.GetFib().GetStream(),
    1174           0 :                  aChpx.fcPicGet());
    1175           0 :                 if (!aPic.GetError())
    1176           0 :                     aPic.Out(rOut, rMan);
    1177             :             }
    1178             :         }
    1179           0 :         ++(*this);
    1180             :     }
    1181           0 : }
    1182             : 
    1183           0 : void Ww1Chp::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
    1184             : {
    1185           0 :     if (rMan.Where() >= Where())
    1186             :     {
    1187           0 :         W1_CHP aChpx;
    1188           0 :         if (FillStop(aChpx))
    1189             :         {
    1190             :             // First all toggle flags
    1191           0 :             if (aChpx.fBoldGet())
    1192           0 :                 rOut.EndItem(RES_CHRATR_WEIGHT);
    1193           0 :             if (aChpx.fItalicGet())
    1194           0 :                 rOut.EndItem(RES_CHRATR_POSTURE);
    1195           0 :             if (aChpx.fStrikeGet())
    1196           0 :                 rOut.EndItem(RES_CHRATR_CROSSEDOUT);
    1197           0 :             if (aChpx.fOutlineGet())
    1198           0 :                 rOut.EndItem(RES_CHRATR_CONTOUR);
    1199           0 :             if (aChpx.fSmallCapsGet() || aChpx.fCapsGet())
    1200           0 :                 rOut.EndItem(RES_CHRATR_CASEMAP);
    1201             :             // then all number values; these have flags when they are set...
    1202           0 :             if (aChpx.fsHpsGet())
    1203           0 :                 rOut.EndItem(RES_CHRATR_FONTSIZE);
    1204           0 :             if (aChpx.fsKulGet())
    1205           0 :                 rOut.EndItem(RES_CHRATR_UNDERLINE)
    1206           0 :                     .EndItem(RES_CHRATR_WORDLINEMODE);
    1207           0 :             if (aChpx.fsIcoGet())
    1208           0 :                 rOut.EndItem(RES_CHRATR_COLOR);
    1209           0 :             if (aChpx.fsSpaceGet())
    1210           0 :                 rOut.EndItem(RES_CHRATR_KERNING);
    1211           0 :             if (aChpx.fsPosGet())
    1212           0 :                 rOut.EndItem(RES_CHRATR_ESCAPEMENT);
    1213           0 :             if (aChpx.fsFtcGet())
    1214           0 :                 rOut.EndItem(RES_CHRATR_FONT);
    1215             :         }else{
    1216             :             OSL_ENSURE( !nPlcIndex, "Lost Chp-Attribut-Stop" );
    1217             :         }
    1218             :     }
    1219           0 : }
    1220             : 
    1221           0 : void Ww1Style::Out(Ww1Shell& rOut, Ww1Manager& rMan)
    1222             : {
    1223             :     // Base first, so that base style attributes can be recognized
    1224             :     // first: Base
    1225           0 :     if(pParent->GetStyle(stcBase).IsUsed() )    // Base valid ?
    1226           0 :         rOut.BaseStyle(stcBase);
    1227             : 
    1228             :     // next of all: CHP
    1229           0 :     aChpx.Out(rOut, rMan);
    1230             :     // Last: PAP
    1231           0 :     if (pPapx)
    1232           0 :         pPapx->Start(rOut, rMan);
    1233           0 : }
    1234             : 
    1235             : // The Out() methods output a number of characters to the shell, a
    1236             : // string or a character. The amount of output is determined by ulEnd,
    1237             : // which specifies the position at which to stop. Control characters
    1238             : // also end the output.
    1239             : // They are defined by MinChar. All characters with a value lower than
    1240             : // that are treated as control characters. This classification is
    1241             : // handled by IsChar. If a control character is encountered, the
    1242             : // output method returns immediately and returns it. Pay attention to
    1243             : // this; ulEnd might not have been reached if !IsChar(Out(...)). In
    1244             : // this case, the control character has been consumed, but not been
    1245             : // output.
    1246           0 : sal_Unicode Ww1PlainText::Out( Ww1Shell& rOut, sal_uLong& ulEnd )
    1247             : {
    1248           0 :     if (ulEnd > Count())
    1249           0 :         ulEnd = Count();
    1250           0 :     while (ulSeek < ulEnd)
    1251             :     {
    1252           0 :         sal_Unicode c = (*this)[ulSeek];
    1253           0 :         ++(*this);
    1254           0 :         if (Ww1PlainText::IsChar(c))
    1255           0 :             rOut << c;
    1256             :         else
    1257           0 :             return c;
    1258             :     }
    1259           0 :     return Ww1PlainText::MinChar;
    1260             : }
    1261             : 
    1262           0 : sal_Unicode Ww1PlainText::Out(OUString& rStr, sal_uLong ulEnd)
    1263             : {
    1264             :     // Like Out(Shell..., but output into a string
    1265           0 :     rStr = "";
    1266           0 :     if (ulEnd > Count())
    1267           0 :         ulEnd = Count();
    1268           0 :     while (ulSeek < ulEnd)
    1269             :     {
    1270           0 :         sal_Unicode c = (*this)[ulSeek];
    1271           0 :         ++(*this);
    1272           0 :         if( Ww1PlainText::IsChar(c) )
    1273           0 :             rStr += OUString(c);
    1274             :         else
    1275           0 :             return c;
    1276             :     }
    1277           0 :     return Ww1PlainText::MinChar;
    1278             : }
    1279             : 
    1280             : // This makes ulEnd unnecessary, right?
    1281           0 : sal_Unicode Ww1PlainText::Out( sal_Unicode& rRead )
    1282             : {
    1283           0 :     rRead = (*this)[ulSeek];
    1284           0 :     ++(*this);
    1285           0 :     return rRead;
    1286             : }
    1287             : 
    1288           0 : void Ww1SprmPapx::Start(Ww1Shell& rOut, Ww1Manager& rMan)
    1289             : {
    1290           0 :     if( !rMan.IsInStyle() ){        // Normal attributes apply within style
    1291           0 :         if (!rOut.IsInFly()
    1292           0 :             && !rOut.IsInTable()
    1293           0 :             && ( rMan.HasPPc() || rMan.HasPDxaAbs())){ // Fly-Start
    1294           0 :             rOut.BeginFly();        // eAnchor );
    1295             :         }
    1296           0 :         if (!rOut.IsInTable() && rMan.HasInTable())
    1297             :         {
    1298           0 :             rOut.BeginTable();
    1299             :         }
    1300           0 :         rOut.SetStyle(aPapx.stcGet());
    1301             :     }
    1302           0 :     Ww1Sprm::Start(rOut, rMan);
    1303           0 : }
    1304             : 
    1305           0 : void Ww1SprmPapx::Stop(Ww1Shell& rOut, Ww1Manager& rMan)
    1306             : {
    1307           0 :     Ww1Sprm::Stop(rOut, rMan);
    1308             : 
    1309           0 :     if( !rMan.IsInStyle() )         // Normal attributes apply within style
    1310             :     {
    1311           0 :         if (rOut.IsInTable() &&( rMan.IsStopAll() || !rMan.HasInTable()))
    1312           0 :             rOut.EndTable();
    1313             : 
    1314           0 :         if( rOut.IsInFly() &&
    1315           0 :             ( rMan.IsStopAll()
    1316           0 :                 || ( !rMan.HasPPc() && !rMan.HasPDxaAbs()   // Fly end
    1317           0 :                     && !rOut.IsInTable())))
    1318           0 :             rOut.EndFly();
    1319             :     }
    1320           0 : }
    1321             : 
    1322           0 : SvxFontItem Ww1Fonts::GetFont(sal_uInt16 nFCode)
    1323             : {
    1324             :     // Create a font in sw fashion from existing word structures
    1325           0 :     FontFamily eFamily = FAMILY_DONTKNOW;
    1326           0 :     OUString aName;
    1327           0 :     FontPitch ePitch = PITCH_DONTKNOW;
    1328           0 :     rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
    1329           0 :     switch (nFCode)
    1330             :     {
    1331             :     // In the Winword 1.x format, the names of the first three fonts were
    1332             :     // omitted from the table and assumed to be "Tms Rmn" (for ftc = 0),
    1333             :     // "Symbol", and "Helv"
    1334             :     case 0:
    1335           0 :          eFamily = FAMILY_ROMAN;
    1336           0 :          aName = "Tms Rmn";
    1337           0 :          ePitch = PITCH_VARIABLE;
    1338           0 :          eCharSet = RTL_TEXTENCODING_MS_1252;
    1339           0 :     break;
    1340             :     case 1:
    1341           0 :          aName = "Symbol";
    1342           0 :          ePitch = PITCH_VARIABLE;
    1343           0 :          eCharSet = RTL_TEXTENCODING_SYMBOL;
    1344           0 :     break;
    1345             :     case 2:
    1346           0 :          eFamily = FAMILY_SWISS;
    1347           0 :          aName = "Helv";
    1348           0 :          ePitch = PITCH_VARIABLE;
    1349           0 :          eCharSet = RTL_TEXTENCODING_MS_1252;
    1350           0 :     break;
    1351             :     default:
    1352             :     {
    1353           0 :         W1_FFN* pF = GetFFN(nFCode - 3);
    1354           0 :         if (pF != 0)
    1355             :         {
    1356             :             // Fontname
    1357           0 :             aName = OUString( (sal_Char*)pF->szFfnGet(), strlen( (sal_Char*)pF->szFfnGet() ),
    1358           0 :                             RTL_TEXTENCODING_MS_1252 );
    1359             :             // Pitch
    1360             :             static const FontPitch ePitchA[] =
    1361             :             {
    1362             :                 PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, PITCH_DONTKNOW
    1363             :             };
    1364           0 :             ePitch = ePitchA[pF->prgGet()];
    1365             :             // CharSet
    1366           0 :             eCharSet = RTL_TEXTENCODING_MS_1252;
    1367           0 :             if (aName.equalsIgnoreAsciiCase("Symbol")
    1368           0 :              || aName.equalsIgnoreAsciiCase("Symbol Set")
    1369           0 :              || aName.equalsIgnoreAsciiCase("Wingdings")
    1370           0 :              || aName.equalsIgnoreAsciiCase("ITC Zapf Dingbats") )
    1371           0 :                 eCharSet = RTL_TEXTENCODING_SYMBOL;
    1372             :             // FontFamily
    1373           0 :             sal_uInt16 b = pF->ffGet();
    1374             :             static const FontFamily eFamilyA[] =
    1375             :             {
    1376             :                 FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
    1377             :                 FAMILY_SCRIPT, FAMILY_DECORATIVE
    1378             :             };
    1379           0 :             if (b < (sizeof(eFamilyA)/sizeof(eFamilyA[0])))
    1380           0 :                 eFamily = eFamilyA[b];
    1381             :         }
    1382             :         else
    1383             :         {
    1384             :             OSL_ENSURE(false, "WW1Fonts::GetFont: Non-existent font !");
    1385           0 :             eFamily = FAMILY_SWISS;
    1386           0 :             aName = "Helv";
    1387           0 :             ePitch = PITCH_VARIABLE;
    1388           0 :             eCharSet = RTL_TEXTENCODING_MS_1252;
    1389             :         }
    1390             :     }
    1391           0 :     break;
    1392             :     }
    1393           0 :     if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO )
    1394           0 :          && ( aName.equalsIgnoreAsciiCase("Helv")
    1395           0 :             || aName.equalsIgnoreAsciiCase("Helvetica") ) )
    1396             :     {
    1397           0 :         aName = "Helvetica Neue";
    1398           0 :         if (eFamily==FAMILY_DONTKNOW)
    1399           0 :             eFamily = FAMILY_SWISS;
    1400             :     }
    1401             :     else
    1402             :     {
    1403             :         // VCL matches fonts on its own
    1404             :         // Unfortunately, this breaks for Helv, Tms Rmn and System
    1405             :         // Monospaced, so they need to be replaced.
    1406             :         // According to TH they should be replaced by fixed values,
    1407             :         // not using System::GetStandardFont, so no name lists appear
    1408             :         // (this could confuse the user)
    1409           0 :         if( aName.equalsIgnoreAsciiCase("Helv"))
    1410             :         {
    1411           0 :             aName  = "Helvetica";
    1412           0 :             if (eFamily==FAMILY_DONTKNOW)
    1413           0 :                 eFamily = FAMILY_SWISS;
    1414             :         }
    1415           0 :         else if (aName.equalsIgnoreAsciiCase("Tms Rmn"))
    1416             :         {
    1417           0 :              aName = "Times New Roman";
    1418           0 :             if (eFamily==FAMILY_DONTKNOW)
    1419           0 :                 eFamily = FAMILY_ROMAN;
    1420             :         }
    1421           0 :         else if (aName.equalsIgnoreAsciiCase("System Monospaced") )
    1422             :         {
    1423           0 :              aName = "Courier";
    1424           0 :             ePitch = PITCH_FIXED;
    1425             :         }
    1426             :     }
    1427           0 :     return SvxFontItem(eFamily, aName, OUString(), ePitch, eCharSet, RES_CHRATR_FONT);
    1428             : }
    1429             : 
    1430           0 : void Ww1Dop::Out(Ww1Shell& rOut)
    1431             : {
    1432             :     //~ mdt: missing
    1433           0 :     long nDefTabSiz = aDop.dxaTabGet();
    1434           0 :     if (nDefTabSiz < 56)
    1435           0 :         nDefTabSiz = 709;
    1436             : 
    1437             :     // we want exactly one DefaultTab
    1438           0 :     SvxTabStopItem aNewTab(1, sal_uInt16(nDefTabSiz), SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP);
    1439           0 :     ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
    1440           0 :     rOut.GetDoc().GetAttrPool().SetPoolDefaultItem( aNewTab); //~ mdt: better (GetDoc)
    1441             : 
    1442           0 :     SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
    1443           0 :     W1_DOP& rDOP = GetDOP();
    1444           0 :     rOut.GetPageDesc().SetLandscape(rDOP.fWideGet());
    1445           0 :     SwFmtFrmSize aSz(rFmt.GetFrmSize());
    1446           0 :     aSz.SetWidth(rDOP.xaPageGet());
    1447           0 :     aSz.SetHeight(rDOP.yaPageGet());
    1448           0 :     rFmt.SetFmtAttr(aSz);
    1449           0 :     SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(),
    1450           0 :      rDOP.dxaRightGet(), 0, 0, RES_LR_SPACE);
    1451           0 :     rFmt.SetFmtAttr(aLR);
    1452           0 :     SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet(), RES_UL_SPACE);
    1453           0 :     rFmt.SetFmtAttr(aUL);
    1454             : 
    1455           0 :     SwFtnInfo aInfo;
    1456           0 :     aInfo = rOut.GetDoc().GetFtnInfo();     // Copy-Ctor private
    1457             :                 // where positioned ? ( 0 == Section, 1 == Page,
    1458             :                 // 2 == next to Text -> Page, 3 == Doc  )
    1459           0 :     switch( rDOP.fpcGet() ){
    1460             :     case 1:
    1461           0 :     case 2: aInfo.ePos = FTNPOS_PAGE; break;
    1462           0 :     default: aInfo.ePos = FTNPOS_CHAPTER; break;
    1463             :     }
    1464             :     // Always doc, because Sw seems to interpret Chapter differently from PMW
    1465           0 :     aInfo.eNum = FTNNUM_DOC;
    1466             :                             // how to renumber ?
    1467             :                             // SW-UI allows number only with FTNNUM_DOC
    1468           0 :     if( rDOP.nFtnGet() > 0 && aInfo.eNum == FTNNUM_DOC )
    1469           0 :         aInfo.nFtnOffset = rDOP.nFtnGet() - 1;
    1470           0 :     rOut.GetDoc().SetFtnInfo( aInfo );
    1471             : 
    1472           0 : }
    1473             : 
    1474           0 : void Ww1Assoc::Out(Ww1Shell& rOut)
    1475             : {
    1476             :     //~ mdt: missing: FileNext, Dot, DataDoc, HeaderDoc, Criteria1,
    1477             :     // Criteria2, Criteria3, Criteria4, Criteria5, Criteria6, Criteria7
    1478           0 :     SwDocShell *pDocShell(rOut.GetDoc().GetDocShell());
    1479             :     OSL_ENSURE(pDocShell, "no SwDocShell");
    1480           0 :     if (pDocShell) {
    1481             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
    1482           0 :             pDocShell->GetModel(), uno::UNO_QUERY_THROW);
    1483             :         uno::Reference<document::XDocumentProperties> xDocProps(
    1484           0 :             xDPS->getDocumentProperties());
    1485             :         OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
    1486           0 :         if (xDocProps.is()) {
    1487           0 :             xDocProps->setTitle( GetStr(Title) );
    1488           0 :             xDocProps->setSubject( GetStr(Subject) );
    1489           0 :             xDocProps->setDescription( GetStr(Comments) );
    1490           0 :             xDocProps->setKeywords(
    1491           0 :               ::comphelper::string::convertCommaSeparated( GetStr(KeyWords) ) );
    1492           0 :             xDocProps->setAuthor( GetStr(Author) );
    1493           0 :             xDocProps->setModifiedBy( GetStr(LastRevBy) );
    1494           0 :         }
    1495             :     }
    1496           0 : }
    1497             : 
    1498           0 : void Ww1StyleSheet::OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc)
    1499             : {
    1500           0 :     switch (stc){
    1501             :     case 222: // Null
    1502           0 :         rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
    1503           0 :         rOut << SvxFontItem(rMan.GetFont(2));
    1504           0 :         break;
    1505             :     case 223: // annotation reference
    1506           0 :         rOut << SvxFontHeightItem(160, 100, RES_CHRATR_FONTSIZE);
    1507           0 :         break;
    1508             :     case 224: // annotation text
    1509           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1510           0 :         break;
    1511             :     case 225: // table of contents 8
    1512             :     case 226: // table of contents 7
    1513             :     case 227: // table of contents 6
    1514             :     case 228: // table of contents 5
    1515             :     case 229: // table of contents 4
    1516             :     case 230: // table of contents 3
    1517             :     case 231: // table of contents 2
    1518             :     case 232: // table of contents 1
    1519           0 :         rOut << SvxLRSpaceItem(( 232 - stc ) * 720, 720, 0, 0, RES_LR_SPACE);
    1520             :             // tabs still missing !
    1521           0 :         break;
    1522             :     case 233: // index 7
    1523             :     case 234: // and index 6
    1524             :     case 235: // and index 5
    1525             :     case 236: // and index 4
    1526             :     case 237: // and index 3
    1527             :     case 238: // and index 2
    1528           0 :         rOut << SvxLRSpaceItem(( 239 - stc ) * 360, 0, 0, 0, RES_LR_SPACE);
    1529           0 :         break;
    1530             :     case 239: // index 1
    1531           0 :         break;
    1532             :     case 240: // line number
    1533           0 :         break;
    1534             :     case 241: // index heading
    1535           0 :         break;
    1536             :     case 242:  // footer
    1537             :     case 243:{ // ... and header
    1538           0 :             SvxTabStopItem aAttr(RES_PARATR_TABSTOP);
    1539           0 :             SvxTabStop aTabStop;
    1540           0 :             aTabStop.GetTabPos() = 4535;  // 8 cm
    1541           0 :             aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
    1542           0 :             aAttr.Insert( aTabStop );
    1543           0 :             aTabStop.GetTabPos() = 9071;  // 16 cm
    1544           0 :             aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
    1545           0 :             aAttr.Insert( aTabStop );
    1546           0 :             rOut << aAttr;
    1547             :         }
    1548           0 :         break;
    1549             :     case 244: // footnote reference
    1550           0 :         rOut << SvxFontHeightItem(160, 100, RES_CHRATR_FONTSIZE);
    1551           0 :         rOut << SvxEscapementItem(6 * 100 / 24, 100, RES_CHRATR_ESCAPEMENT);
    1552           0 :         break;
    1553             :     case 245: // footnote text
    1554           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1555           0 :         break;
    1556             :     case 246: // heading 9
    1557             :     case 247: // und heading 8
    1558             :     case 248: // und heading 7
    1559           0 :         rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
    1560             :         rOut << SvxPostureItem(
    1561           0 :                     rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL, RES_CHRATR_POSTURE);
    1562           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1563           0 :         break;
    1564             :     case 249: // heading 6
    1565           0 :         rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
    1566           0 :         rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
    1567           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1568           0 :         break;
    1569             :     case 250: // heading 5
    1570           0 :         rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
    1571           0 :         rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
    1572           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1573           0 :         break;
    1574             :     case 251: // heading 4
    1575           0 :         rOut << SvxLRSpaceItem(360, 0, 0, 0, RES_LR_SPACE);
    1576           0 :         rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
    1577           0 :         rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
    1578           0 :         break;
    1579             :     case 252: // heading 3
    1580           0 :         rOut << SvxLRSpaceItem(360, 0, 0, 0, RES_LR_SPACE);
    1581           0 :         rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
    1582           0 :         rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
    1583           0 :         break;
    1584             :     case 253: // heading 2
    1585           0 :         rOut << SvxULSpaceItem(120, 0, RES_UL_SPACE);
    1586           0 :         rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
    1587           0 :         rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
    1588           0 :         rOut << SvxFontItem(rMan.GetFont(2));
    1589           0 :         break;
    1590             :     case 254: // heading 1
    1591           0 :         rOut << SvxULSpaceItem(240, 0, RES_UL_SPACE);
    1592           0 :         rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT);
    1593           0 :         rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE);
    1594           0 :         rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE);
    1595           0 :         rOut << SvxFontItem(rMan.GetFont(2));
    1596           0 :         break;
    1597             :     case 255: // Normal indent
    1598           0 :         rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE);
    1599           0 :         break;
    1600             :     case 0: // Normal
    1601           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1602           0 :         break;
    1603             :     default: // custom defined
    1604           0 :         rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE);
    1605           0 :         break;
    1606             :     }
    1607           0 : }
    1608             : 
    1609           0 : void Ww1StyleSheet::OutOne(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc)
    1610             : {
    1611           0 :     const RES_POOL_COLLFMT_TYPE RES_NONE = RES_POOLCOLL_DOC_END;
    1612           0 :     RES_POOL_COLLFMT_TYPE aType = RES_NONE;
    1613             : 
    1614           0 :     switch (stc)
    1615             :     {
    1616             :     case 222: // Null
    1617           0 :         aType = RES_POOLCOLL_TEXT; break;   //???
    1618             :     case 223: // annotation reference
    1619           0 :         break;
    1620             :     case 224: // annotation text
    1621           0 :         break;
    1622             :     case 225: // table of contents 8
    1623           0 :         aType = RES_POOLCOLL_TOX_CNTNT8; break;
    1624             :     case 226: // table of contents 7
    1625           0 :         aType = RES_POOLCOLL_TOX_CNTNT7; break;
    1626             :     case 227: // table of contents 6
    1627           0 :         aType = RES_POOLCOLL_TOX_CNTNT6; break;
    1628             :     case 228: // table of contents 5
    1629           0 :         aType = RES_POOLCOLL_TOX_CNTNT5; break;
    1630             :     case 229: // table of contents 4
    1631           0 :         aType = RES_POOLCOLL_TOX_CNTNT4; break;
    1632             :     case 230: // table of contents 3
    1633           0 :         aType = RES_POOLCOLL_TOX_CNTNT3; break;
    1634             :     case 231: // table of contents 2
    1635           0 :         aType = RES_POOLCOLL_TOX_CNTNT2; break;
    1636             :     case 232: // table of contents 1
    1637           0 :         aType = RES_POOLCOLL_TOX_CNTNT1; break;
    1638             :     case 233: // index 7
    1639           0 :         break;
    1640             :     case 234: // index 6
    1641           0 :         break;
    1642             :     case 235: // index 5
    1643           0 :         break;
    1644             :     case 236: // index 4
    1645           0 :         break;
    1646             :     case 237: // index 3
    1647           0 :         aType = RES_POOLCOLL_TOX_IDX3; break;
    1648             :     case 238: // index 2
    1649           0 :         aType = RES_POOLCOLL_TOX_IDX2; break;
    1650             :     case 239: // index 1
    1651           0 :         aType = RES_POOLCOLL_TOX_IDX1; break;
    1652             :     case 240: // line number
    1653           0 :         break;
    1654             :     case 241: // index heading
    1655           0 :         break;
    1656             :     case 242: // footer
    1657           0 :         aType = RES_POOLCOLL_FOOTER; break;
    1658             :     case 243: // header
    1659           0 :         aType = RES_POOLCOLL_HEADER; break;
    1660             :     case 244: // footnote reference
    1661           0 :         break;
    1662             :     case 245: // footnote text
    1663           0 :         aType = RES_POOLCOLL_FOOTNOTE; break;
    1664             :     case 246: // heading 9
    1665           0 :         break;
    1666             :     case 247: // heading 8
    1667           0 :         break;
    1668             :     case 248: // heading 7
    1669           0 :         break;
    1670             :     case 249: // heading 6
    1671           0 :         break;
    1672             :     case 250: // heading 5
    1673           0 :         aType = RES_POOLCOLL_HEADLINE5; break;
    1674             :     case 251: // heading 4
    1675           0 :         aType = RES_POOLCOLL_HEADLINE4; break;
    1676             :     case 252: // heading 3
    1677           0 :         aType = RES_POOLCOLL_HEADLINE3; break;
    1678             :     case 253: // heading 2
    1679           0 :         aType = RES_POOLCOLL_HEADLINE2; break;
    1680             :     case 254: // heading 1
    1681           0 :         aType = RES_POOLCOLL_HEADLINE1; break;
    1682             :     case 255: // Normal indent
    1683           0 :         aType = RES_POOLCOLL_TEXT_IDENT; break;
    1684             :     case 0: // Normal
    1685           0 :         aType = RES_POOLCOLL_STANDARD; break;
    1686             :     }
    1687           0 :     if (aType == RES_NONE)
    1688           0 :         rOut.BeginStyle(stc, GetStyle(stc).GetName() );
    1689             :     else
    1690           0 :         rOut.BeginStyle(stc, aType);
    1691           0 :     OutDefaults(rOut, rMan, stc);
    1692           0 :     GetStyle(stc).Out(rOut, rMan);
    1693           0 :     rOut.EndStyle();
    1694           0 : }
    1695             : // OutOneWithBase() reads a style using OutOne()
    1696             : // Additionally, it reads the base style, if this has not happened yet
    1697           0 : void Ww1StyleSheet::OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan,
    1698             :                                    sal_uInt16 stc, sal_uInt8* pbStopRecur )
    1699             : {
    1700             : // SH: reading linearly is shit, because BasedOn cannot be set. Also,
    1701             : // toggle and modify attributes (tabs, for example) don't work.
    1702             : 
    1703           0 :     Ww1Style& rSty = GetStyle(stc);
    1704           0 :     sal_uInt16 nBase = rSty.GetnBase();
    1705           0 :     if( nBase != stc
    1706           0 :         && !rOut.IsStyleImported( nBase )
    1707           0 :         && GetStyle(nBase).IsUsed()
    1708           0 :         && !pbStopRecur[nBase] ){
    1709             : 
    1710           0 :         pbStopRecur[nBase] = 1;
    1711           0 :         OutOneWithBase( rOut, rMan, nBase, pbStopRecur ); // Recursive
    1712             :     }
    1713           0 :     OutOne( rOut, rMan, stc );
    1714           0 : }
    1715             : 
    1716           0 : void Ww1StyleSheet::Out(Ww1Shell& rOut, Ww1Manager& rMan)
    1717             : {
    1718             :     sal_uInt16 stc;
    1719             :     sal_uInt8 bStopRecur[256];
    1720           0 :     memset( bStopRecur, sal_False, sizeof(bStopRecur) );
    1721             : 
    1722             : // First pass: Styles with base styles recursively
    1723           0 :     for (stc=0;stc<Count();stc++)
    1724           0 :         if (GetStyle(stc).IsUsed() && !rOut.IsStyleImported( stc ) )
    1725           0 :             OutOneWithBase( rOut, rMan, stc, bStopRecur );
    1726             : 
    1727             : // Second pass: Follow-Styles
    1728           0 :     for (stc=0;stc<Count();stc++){
    1729           0 :         Ww1Style& rSty = GetStyle(stc);
    1730           0 :         if ( rSty.IsUsed() ){
    1731           0 :             sal_uInt16 nNext = rSty.GetnNext();
    1732           0 :             if( nNext != stc && GetStyle(nNext).IsUsed() )
    1733           0 :                 rOut.NextStyle( stc, nNext );
    1734             :         }
    1735             :     }
    1736           0 : }
    1737             : 
    1738             : // Picture
    1739           0 : static sal_uLong GuessPicSize(W1_PIC* pPic)
    1740             : {
    1741           0 :     sal_uInt16 maxx = pPic->mfp.xExtGet();
    1742           0 :     sal_uInt16 padx = ((maxx + 7) / 8) * 8;
    1743           0 :     sal_uInt16 maxy = pPic->mfp.yExtGet();
    1744           0 :     return 120L + (sal_uLong)padx * maxy;
    1745             : }
    1746             : 
    1747             : // Reads 4-bit format, writes 8-bit
    1748           0 : void Ww1Picture::WriteBmp(SvStream& rOut)
    1749             : {
    1750           0 :     long nSize = pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb));
    1751           0 :     sal_uInt8* p = pPic->rgbGet();
    1752           0 :     sal_uInt16 maxx = pPic->mfp.xExtGet();
    1753           0 :     sal_uInt16 padx = ((maxx + 7) / 8) * 8;
    1754           0 :     sal_uInt16 maxy = pPic->mfp.yExtGet();
    1755             : 
    1756           0 :      p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
    1757           0 :      p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
    1758             : #if OSL_DEBUG_LEVEL > 0
    1759             :     sal_uInt16 x = SVBT16ToShort(p);
    1760             :     (void) x;
    1761             : #endif
    1762           0 :     p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
    1763             : #if OSL_DEBUG_LEVEL > 0
    1764             :     sal_uInt16 y = SVBT16ToShort(p);
    1765             :     (void) y;
    1766             : #endif
    1767           0 :     p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
    1768             : #if OSL_DEBUG_LEVEL > 0
    1769             :     sal_uInt16 planes = SVBT16ToShort(p);
    1770             :     (void) planes;
    1771             : #endif
    1772           0 :     p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
    1773             : #if OSL_DEBUG_LEVEL > 0
    1774             :     sal_uInt16 bitcount = SVBT16ToShort(p);
    1775             :     (void) bitcount;
    1776             : #endif
    1777           0 :     p+= sizeof(SVBT16); nSize -= sizeof(SVBT16);
    1778             : 
    1779             : #if OSL_DEBUG_LEVEL > 0
    1780             :     OSL_ENSURE(x==maxx, "Ww1Picture");
    1781             :     OSL_ENSURE(y==maxy, "Ww1Picture");
    1782             :     OSL_ENSURE(planes==1, "Ww1Picture");
    1783             :     OSL_ENSURE(bitcount==4, "Ww1Picture");
    1784             : #endif
    1785             : 
    1786             :     OSL_ENSURE(16*3+padx*maxy/2==nSize, "Ww1Picture");
    1787             : 
    1788             :     SVBT32 tmpLong;
    1789             :     SVBT16 tmpShort;
    1790             :     sal_uInt8 tmpByte;
    1791             : #define wLong(n) \
    1792             :     UInt32ToSVBT32(n, tmpLong); \
    1793             :     if ((rOut.Write(tmpLong, sizeof(SVBT32))) != sizeof(SVBT32)) goto error;
    1794             : #define wShort(n) \
    1795             :     ShortToSVBT16(n, tmpShort); \
    1796             :     if ((rOut.Write(tmpShort, sizeof(SVBT16))) != sizeof(SVBT16)) goto error;
    1797             : #define wByte(n) \
    1798             :     tmpByte = n; \
    1799             :     if ((rOut.Write(&tmpByte, sizeof(sal_uInt8))) != sizeof(sal_uInt8)) goto error;
    1800           0 :     wByte('B'); wByte('M');
    1801           0 :     wLong(54 + 4 * 16 + padx * maxy);
    1802           0 :     wLong(0);
    1803           0 :     wLong(54 + 4 * 16);
    1804           0 :     wLong(40);
    1805           0 :     wLong(maxx);
    1806           0 :     wLong(maxy);
    1807           0 :     wShort(1);
    1808           0 :     wShort(8);
    1809           0 :     wLong(0);
    1810           0 :     wLong(0);
    1811           0 :     wLong(0);
    1812           0 :     wLong(0);
    1813           0 :     wLong(16);
    1814           0 :     wLong(16);
    1815             :     sal_uInt16 i;
    1816           0 :     for (i=0;nSize>0&&i<16;i++)
    1817             :     {
    1818           0 :         wByte(*p);
    1819           0 :         p++;
    1820           0 :         nSize -= sizeof(sal_uInt8);
    1821           0 :         wByte(*p);
    1822           0 :         p++;
    1823           0 :         nSize -= sizeof(sal_uInt8);
    1824           0 :         wByte(*p);
    1825           0 :         p++;
    1826           0 :         nSize -= sizeof(sal_uInt8);
    1827           0 :         wByte(0);
    1828             :     }
    1829             :     OSL_ENSURE(padx*maxy/2==nSize, "Ww1Picture");
    1830             :     sal_uInt16 j;
    1831             :     {
    1832           0 :         sal_uInt8* pBuf = new sal_uInt8[padx];
    1833           0 :         for (j=0;nSize>0&&j<maxy;j++)
    1834             :         {
    1835           0 :             sal_uInt8* q = pBuf;
    1836           0 :             for (i=0;nSize>0&&i<maxx;i+=2)
    1837             :             {
    1838           0 :                 *q++ = *p>>4;
    1839           0 :                 *q++ = *p&0xf;
    1840           0 :                 p++;
    1841           0 :                 nSize -= sizeof(sal_uInt8);
    1842             :             }
    1843           0 :             for (;i<padx;i+=2)
    1844             :             {
    1845           0 :                 *q++ = 0;
    1846           0 :                 p++;
    1847           0 :                 nSize -= sizeof(sal_uInt8);
    1848             :             }
    1849           0 :             if(rOut.Write(pBuf, padx) != padx){
    1850           0 :                 delete [] pBuf;
    1851           0 :                 goto error;
    1852             :             }
    1853             :         }
    1854           0 :         delete [] pBuf;
    1855             :     }
    1856             :     OSL_ENSURE(nSize==0, "Ww1Picture");
    1857             : #undef wLong
    1858             : #undef wShort
    1859             : #undef wByte
    1860           0 :     rOut.Seek(0);
    1861           0 :     return;
    1862             : error:
    1863             :     ;
    1864             : }
    1865             : 
    1866           0 : void Ww1Picture::Out(Ww1Shell& rOut, Ww1Manager& /*rMan*/)
    1867             : {
    1868           0 :     Graphic* pGraphic = 0;
    1869             :     sal_uInt16 mm;
    1870           0 :     switch (mm = pPic->mfp.mmGet())
    1871             :     {
    1872             :     case 8: // embedded metafile
    1873             :     {
    1874           0 :         SvMemoryStream aOut(8192, 8192);
    1875           0 :         aOut.Write(pPic->rgbGet(), pPic->lcbGet() -
    1876           0 :          (sizeof(*pPic)-sizeof(pPic->rgb)));
    1877           0 :         aOut.Seek(0);
    1878           0 :         GDIMetaFile aWMF;
    1879           0 :         if (ReadWindowMetafile( aOut, aWMF, NULL ) && aWMF.GetActionSize() > 0)
    1880             :         {
    1881           0 :             aWMF.SetPrefMapMode(MapMode(MAP_100TH_MM));
    1882           0 :             Size aOldSiz(aWMF.GetPrefSize());
    1883           0 :             Size aNewSiz(pPic->mfp.xExtGet(), pPic->mfp.yExtGet());
    1884           0 :             Fraction aFracX(aNewSiz.Width(), aOldSiz.Width());
    1885           0 :             Fraction aFracY(aNewSiz.Height(), aOldSiz.Height());
    1886           0 :             aWMF.Scale(aFracX, aFracY);
    1887           0 :             aWMF.SetPrefSize(aNewSiz);
    1888           0 :             pGraphic = new Graphic(aWMF);
    1889             :         }
    1890           0 :         break;
    1891             :     }
    1892             :     case 94: // embedded name SH:??? Which one is it? Embedded or Name ?
    1893             :     case 98: // TIFF name
    1894             :     {
    1895           0 :         OUString aDir( (sal_Char*)pPic->rgbGet(),
    1896           0 :                 (sal_uInt16)(pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb))),
    1897           0 :                 RTL_TEXTENCODING_MS_1252 );
    1898             : 
    1899           0 :         rOut.AddGraphic( aDir );
    1900             :     }
    1901           0 :     break;
    1902             :     case 97: // embedded bitmap
    1903             :     {
    1904           0 :         sal_uLong nSiz = GuessPicSize(pPic);
    1905           0 :         SvMemoryStream aOut(nSiz, 8192);
    1906           0 :         WriteBmp(aOut);
    1907           0 :         Bitmap aBmp;
    1908           0 :         ReadDIB(aBmp, aOut, true);
    1909           0 :         pGraphic = new Graphic(aBmp);
    1910             :     }
    1911             :     //fall-through
    1912             :     default:
    1913             :         OSL_ENSURE(pPic->mfp.mmGet() == 97, "Ww1Picture");
    1914             :     }
    1915           0 :     if (pGraphic)
    1916           0 :         rOut << *pGraphic;
    1917           0 : }
    1918             : 
    1919           0 : void Ww1HeaderFooter::Start(Ww1Shell& rOut, Ww1Manager& rMan)
    1920             : {
    1921             :     // Only gets called for SEPs anyway, no further validation necessary:
    1922           0 :     if (!rMan.Pushed())
    1923             :     {
    1924           0 :         while (++(*this))
    1925           0 :             switch (eHeaderFooterMode)
    1926             :             {
    1927             :             case FtnSep:
    1928           0 :             break;
    1929             :             case FtnFollowSep:
    1930           0 :             break;
    1931             :             case FtnNote:
    1932           0 :             break;
    1933             :             case EvenHeadL:
    1934           0 :             break;
    1935             :             case OddHeadL:
    1936             :             {
    1937           0 :                 sal_uLong begin = 0;
    1938           0 :                 sal_uLong end = 0;
    1939           0 :                 if (FillOddHeadL(begin, end))
    1940             :                 {
    1941           0 :                     Ww1HddText* pText = new Ww1HddText(rMan.GetFib());
    1942           0 :                     pText->Seek(begin);
    1943           0 :                     pText->SetCount(end-begin);
    1944           0 :                     rOut.BeginHeader();
    1945           0 :                     rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin,
    1946           0 :                      new Ww1HeaderFooterFields(rMan.GetFib()));
    1947           0 :                     rOut << rMan;
    1948           0 :                     rMan.Pop();
    1949           0 :                     rOut.EndHeaderFooter();
    1950           0 :                     return;
    1951             :                 }
    1952             :             }
    1953           0 :             break;
    1954             :             case EvenFootL:
    1955           0 :             break;
    1956             :             case OddFootL:
    1957             :             {
    1958           0 :                 sal_uLong begin = 0;
    1959           0 :                 sal_uLong end = 0;
    1960           0 :                 if (FillOddFootL(begin, end))
    1961             :                 {
    1962           0 :                     Ww1HddText* pText = new Ww1HddText(rMan.GetFib());
    1963           0 :                     pText->Seek(begin);
    1964           0 :                     pText->SetCount(end-begin);
    1965           0 :                     rOut.BeginFooter();
    1966           0 :                     rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin,
    1967           0 :                      new Ww1HeaderFooterFields(rMan.GetFib()));
    1968           0 :                     rOut << rMan;
    1969           0 :                     rMan.Pop();
    1970           0 :                     rOut.EndHeaderFooter();
    1971           0 :                     return;
    1972             :                 }
    1973             :             }
    1974           0 :             break;
    1975             :             case FirstHeadL:
    1976           0 :             break;
    1977             :             default:
    1978           0 :             break;
    1979             :             }
    1980             :     }
    1981             : }
    1982             : 
    1983           0 : void Ww1HeaderFooter::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&)
    1984             : {
    1985           0 :     if (!rMan.Pushed() && eHeaderFooterMode != None)
    1986             :     {
    1987           0 :         Start(rOut, rMan);
    1988             :     }
    1989           0 : }
    1990             : 
    1991             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10